kernel:report cable attch event three thime
authorxuwei9 <xuwei9@lenovo.com>
Wed, 10 Apr 2019 10:29:33 +0000 (18:29 +0800)
committerlingsen1 <lingsen1@lenovo.com>
Mon, 10 Jun 2019 03:24:57 +0000 (11:24 +0800)
samsung report cable attach event three times
which result in battery status override

Change-Id: I6ae9dd37d369254d15b1d5678dcb1a0d79dcb8a7
Signed-off-by: xuwei9 <xuwei9@mt.com>
Reviewed-on: https://gerrit.mot.com/1334878
SLTApproved: Slta Waiver
SME-Granted: SME Approvals Granted
Tested-by: Jira Key
Reviewed-by: Zonghua Liu <a17671@motorola.com>
Reviewed-by: Hua Tan <tanhua1@motorola.com>
Submit-Approved: Jira Key

drivers/power/supply/s2mu00x_battery.c

index 126f55f7792426d9b4e7757f3d9474f9315b3f12..9b707cc0cd530e488bb460c89e3417d294c338e4 100644 (file)
@@ -473,6 +473,7 @@ struct s2mu00x_battery_info {
        bool                            enable_factory_wa;
        int                         max_chrg_temp;
        bool                    charging_disabled;
+       int                     cable_attach_flag;
 };
 
 static int is_charging_mode = S2MU00X_NOR_MODE;
@@ -1651,12 +1652,14 @@ end_ifconn_handle:
                smbchg_relax(battery);
                cancel_delayed_work_sync(&battery->heartbeat_work);
                battery->stepchg_state = STEP_NONE;
+               battery->cable_attach_flag = 0;
                battery->charging_limit_modes = CHARGING_LIMIT_OFF;
                set_max_allowed_current_ma(battery,battery->stepchg_current_ma);
                battery->charger_rate = POWER_SUPPLY_CHARGE_RATE_NONE;
        } else {
                battery->charger_rate = POWER_SUPPLY_CHARGE_RATE_NORMAL;
                smbchg_stay_awake(battery);
+               battery->cable_attach_flag = 1;
                cancel_delayed_work(&battery->heartbeat_work);
                schedule_delayed_work(&battery->heartbeat_work, msecs_to_jiffies(0));
        }
@@ -4010,9 +4013,11 @@ static void smbchg_heartbeat_work(struct work_struct *work)
        if ((prev_batt_health != chip->temp_state) ||
            (prev_ext_lvl != chip->ext_high_temp) ||
            (prev_step != chip->stepchg_state) ||
-           (chip->update_allowed_fastchg_current_ma)) {
+           (chip->update_allowed_fastchg_current_ma) ||
+               (chip->cable_attach_flag == 1)) {
                pr_info("%s, temp state: %d\n",
                        __func__, chip->temp_state);
+               chip->cable_attach_flag = 0;
                smbchg_set_temp_chgpath(chip, prev_batt_health);
                if (chip->stepchg_state == STEP_MAX)
                        set_max_allowed_current_ma(chip,
@@ -4427,6 +4432,7 @@ static int s2mu00x_battery_probe(struct platform_device *pdev)
        battery->test_mode_temp = DEFAULT_TEST_MODE_TEMP;
        battery->test_mode = qpnp_smbcharger_test_mode();
        battery->max_chrg_temp = 0;
+       battery->cable_attach_flag = 0;
        if (battery->test_mode)
                pr_err("Test Mode Enabled\n");
        battery->is_weak_charger = false;