From 80c729b5132d8d6a94de0e6e8969281af6abf27f Mon Sep 17 00:00:00 2001 From: Anirudh Ghayal Date: Fri, 22 Feb 2013 11:17:19 +0530 Subject: [PATCH] power: pm8921-charger: Make charger removal detection workaround optional On some platforms such as MPQ8064 the charger removal detection workarounds - reverse boost fix and OVP FET stuck do not work as expected as the SMBC module is disconnected from USBout. On these targets the USB interface is not used for charging but merely to indicate the USB driver of the insertion/removal. Add a platform data variable to make this optional and enable the same for MPQ8064 Change-Id: I3fca1b357f8fc280483302f72ffbc61fb50109a7 Signed-off-by: Anirudh Ghayal --- arch/arm/mach-msm/board-8064-pmic.c | 3 +++ drivers/power/pm8921-charger.c | 7 +++++-- include/linux/mfd/pm8xxx/pm8921-charger.h | 3 ++- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/arch/arm/mach-msm/board-8064-pmic.c b/arch/arm/mach-msm/board-8064-pmic.c index a1ff607a29b..0b3366cf7cd 100644 --- a/arch/arm/mach-msm/board-8064-pmic.c +++ b/arch/arm/mach-msm/board-8064-pmic.c @@ -557,4 +557,7 @@ void __init apq8064_init_pmic(void) if (!machine_is_apq8064_mtp() && !machine_is_apq8064_liquid()) apq8064_pm8921_chg_pdata.battery_less_hardware = 1; + + if (machine_is_mpq8064_hrd()) + apq8064_pm8921_chg_pdata.disable_chg_rmvl_wrkarnd = 1; } diff --git a/drivers/power/pm8921-charger.c b/drivers/power/pm8921-charger.c index f87a443ae6e..85f868c43e9 100644 --- a/drivers/power/pm8921-charger.c +++ b/drivers/power/pm8921-charger.c @@ -296,6 +296,7 @@ struct pm8921_chg_chip { int stop_chg_upon_expiry; bool disable_aicl; int usb_type; + bool disable_chg_rmvl_wrkarnd; }; /* user space parameter to limit usb current */ @@ -3057,7 +3058,7 @@ static void unplug_check_worker(struct work_struct *work) pr_debug("reg_loop=0x%x usb_ma = %d\n", reg_loop, usb_ma); ibat = get_prop_batt_current(chip); - if (reg_loop & VIN_ACTIVE_BIT) { + if ((reg_loop & VIN_ACTIVE_BIT) && !chip->disable_chg_rmvl_wrkarnd) { if (ibat > 0) { pr_debug("revboost ibat = %d fsm = %d loop = 0x%x\n", ibat, pm_chg_get_fsm_state(chip), reg_loop); @@ -3077,7 +3078,8 @@ static void unplug_check_worker(struct work_struct *work) active_path, active_chg_plugged_in); chg_gone = pm_chg_get_rt_status(chip, CHG_GONE_IRQ); - if (chg_gone == 1 && active_chg_plugged_in == 1) { + if (chg_gone == 1 && active_chg_plugged_in == 1 && + !chip->disable_chg_rmvl_wrkarnd) { pr_debug("chg_gone=%d, active_chg_plugged_in = %d\n", chg_gone, active_chg_plugged_in); unplug_ovp_fet_open(chip); @@ -4869,6 +4871,7 @@ static int __devinit pm8921_charger_probe(struct platform_device *pdev) chip->vin_min = pdata->vin_min; chip->thermal_mitigation = pdata->thermal_mitigation; chip->thermal_levels = pdata->thermal_levels; + chip->disable_chg_rmvl_wrkarnd = pdata->disable_chg_rmvl_wrkarnd; chip->cold_thr = pdata->cold_thr; chip->hot_thr = pdata->hot_thr; diff --git a/include/linux/mfd/pm8xxx/pm8921-charger.h b/include/linux/mfd/pm8xxx/pm8921-charger.h index 785a33aa26c..1c67b1eeb3b 100644 --- a/include/linux/mfd/pm8xxx/pm8921-charger.h +++ b/include/linux/mfd/pm8xxx/pm8921-charger.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2011-2012, The Linux Foundation. All rights reserved. +/* Copyright (c) 2011-2013, The Linux Foundation. All rights reserved. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 and @@ -188,6 +188,7 @@ struct pm8921_charger_platform_data { int btc_delay_ms; int btc_panic_if_cant_stop_chg; int stop_chg_upon_expiry; + bool disable_chg_rmvl_wrkarnd; }; enum pm8921_charger_source {