Disable charGing via sysfs
authorhuangzq2 <huangzq2@motorola.com>
Wed, 23 Jan 2019 00:42:13 +0000 (08:42 +0800)
committerxiest1 <xiest1@lenovo.com>
Tue, 5 Nov 2019 09:30:34 +0000 (17:30 +0800)
Change-Id: I343895372db2576fb71534309c7d875538d1e24e
Signed-off-by: huangzq2 <huangzq2@motorola.com>
Reviewed-on: https://gerrit.mot.com/1298890
SLTApproved: Slta Waiver
SME-Granted: SME Approvals Granted
Tested-by: Jira Key
Reviewed-by: Wei Xu <xuwei9@mt.com>
Reviewed-by: Xiangpo Zhao <zhaoxp3@motorola.com>
Submit-Approved: Jira Key

drivers/power/supply/s2mu00x_battery.c

index 75721d2a6f15abd4efa39e8b67a636c407713dca..73a3c2d5bb215c5440cbe71f6522c02b2bdfcc56 100644 (file)
@@ -475,6 +475,7 @@ struct s2mu00x_battery_info {
        int                             temp_allowed_fastchg_current_ma;
        bool                            enable_factory_wa;
        int                         max_chrg_temp;
+       bool                    charging_disabled;
 };
 
 static int is_charging_mode = S2MU00X_NOR_MODE;
@@ -828,6 +829,11 @@ static void set_bat_status_by_cable(struct s2mu00x_battery_info *battery)
                return;
        }
 
+       if (battery->charging_disabled) {
+               pr_info("%s: charging disabled. Skip!\n", __func__);
+               return;
+       }
+
 #if defined(CONFIG_CHARGER_S2MU106)
        if (battery->cable_type == POWER_SUPPLY_TYPE_BATTERY ||
                battery->cable_type == POWER_SUPPLY_TYPE_UNKNOWN ||
@@ -1028,6 +1034,8 @@ static int s2mu00x_battery_set_property(struct power_supply *psy,
                        smbchg_chg_system_temp_level_set(battery, val->intval);
                break;
        case POWER_SUPPLY_PROP_CHARGING_ENABLED:
+               pr_info("%s: POWER_SUPPLY_PROP_CHARGING_ENABLED, val->intval = %d.\n", __func__, val->intval);
+               battery->charging_disabled = !val->intval;
                smbchg_usb_en(battery, val->intval);
                break;
        case POWER_SUPPLY_PROP_CAPACITY:
@@ -4251,6 +4259,7 @@ static int s2mu00x_battery_probe(struct platform_device *pdev)
 
        battery->max_rawsoc = battery->pdata->max_rawsoc;
 
+       battery->charging_disabled = false;
        battery->is_recharging = false;
        battery->cable_type = POWER_SUPPLY_TYPE_BATTERY;
 #if defined(CHARGER_S2MU106)