From d3647e52a2d965bf9e4b909c8c7b3d5833c9be34 Mon Sep 17 00:00:00 2001 From: xuwei9 Date: Mon, 14 Jan 2019 13:10:47 +0800 Subject: [PATCH] kernel:avoid FG reset algorithm Avoid FG reset algorithm Change-Id: I0a58b08d35a9db5335412a2137a71b4958760008 Signed-off-by: xuwei9 Reviewed-on: https://gerrit.mot.com/1293527 SLTApproved: Slta Waiver SME-Granted: SME Approvals Granted Tested-by: Jira Key Reviewed-by: Xiangpo Zhao Submit-Approved: Jira Key --- drivers/power/supply/s2mu00x_battery.c | 30 ++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/drivers/power/supply/s2mu00x_battery.c b/drivers/power/supply/s2mu00x_battery.c index e3e12bd2bcd3..75721d2a6f15 100644 --- a/drivers/power/supply/s2mu00x_battery.c +++ b/drivers/power/supply/s2mu00x_battery.c @@ -478,7 +478,7 @@ struct s2mu00x_battery_info { }; static int is_charging_mode = S2MU00X_NOR_MODE; - +bool is_cable_present(struct s2mu00x_battery_info *chip); static void smbchg_stay_awake(struct s2mu00x_battery_info *chip); static void smbchg_relax(struct s2mu00x_battery_info *chip); bool is_dc_present(struct s2mu00x_battery_info *chip); @@ -2731,6 +2731,28 @@ bool is_usb_present(struct s2mu00x_battery_info *chip) return present; } +bool is_cable_present(struct s2mu00x_battery_info *chip) +{ + int type = chip->cable_type; + bool present = false; + + switch (type) { + case POWER_SUPPLY_TYPE_UNKNOWN: + case POWER_SUPPLY_TYPE_BATTERY: + case POWER_SUPPLY_TYPE_OTG: + case POWER_SUPPLY_TYPE_END: + present = false; + break; + default: + present = true; + break; + } + + printk(KERN_ERR "%s,cable_present:%d",__func__,present); + + return present; +} + bool is_sdp_cdp(struct s2mu00x_battery_info *chip) { int type = chip->cable_type; @@ -3840,8 +3862,12 @@ static void smbchg_heartbeat_work(struct work_struct *work) int index; int state; - pr_info("%s: start heatbeat\n", __func__); + if(!is_cable_present(chip)){ + pr_info("%s:cable not inserted\n",__func__); + return; + } + pr_info("%s: start heatbeat\n", __func__); //smbchg_stay_awake(chip); //dump register of charger get_property_from_charger(chip, POWER_SUPPLY_PROP_PRESENT, &state); -- 2.20.1