usb_therm: SDP/CDP should't toggle mosfet

optzimize the usb protection code. SDP and CDP shouldn't toggle
the mosfet.For SDP/CDP type, only suspend and disable the charger.

Change-Id: I1e1acd68cb059ac4086e60ce80c4b3b9ad9f8acf
Signed-off-by: Lei Chen <chenlei18@lenovo.com>
Reviewed-on: https://gerrit.mot.com/2487019
SME-Granted: SME Approvals Granted
SLTApproved: Slta Waiver
Tested-by: Jira Key
Reviewed-by: Wei Xu <xuwei9@lenovo.com>
Reviewed-by: Xiangpo Zhao <zhaoxp3@motorola.com>
Submit-Approved: Jira Key
This commit is contained in:
Lei Chen authored and Lei Chen committed 2023-01-13 01:44:57 -06:00
1 parent 4791c8f304
commit e5f26584b6
1 file changed
+9 -4
@@ -1835,8 +1835,11 @@ static int usb_therm_set_mosfet(struct mmi_discrete_charger *chip,bool enable)
ret = charger_dev_enable_charging(chip->master_chg_dev,false);
ret = charger_dev_enable_hz(chip->master_chg_dev,true);
udelay(300);
gpio_direction_output(chip->mos_en_gpio, enable);
mmi_err(chip, "%s,open mos en: %d %d",__func__,enable,ret);
if ((chip->bc1p2_charger_type != POWER_SUPPLY_TYPE_USB)&&
(chip->bc1p2_charger_type !=POWER_SUPPLY_TYPE_USB_CDP)) {
gpio_direction_output(chip->mos_en_gpio, enable);
mmi_err(chip, "%s,open mos en: %d %d",__func__,enable,ret);
}
}
else{
gpio_direction_output(chip->mos_en_gpio, enable);
@@ -1892,8 +1895,10 @@ static int usb_therm_set_cur_state(struct thermal_cooling_device *cdev,
chip->real_charger_type == POWER_SUPPLY_TYPE_USB_PD |
chip->real_charger_type == POWER_SUPPLY_TYPE_USB_HVDCP |
chip->real_charger_type == POWER_SUPPLY_TYPE_USB_HVDCP_3 |
chip->real_charger_type== POWER_SUPPLY_TYPE_USB_HVDCP_3P5) {
mmi_info(chip, "Enable typec mosfet for DCP/PD/HVDCP.");
chip->real_charger_type == POWER_SUPPLY_TYPE_USB_HVDCP_3P5 |
chip->real_charger_type == POWER_SUPPLY_TYPE_USB |
chip->real_charger_type == POWER_SUPPLY_TYPE_USB_CDP) {
mmi_info(chip, "Enable typec mosfet for DCP/PD/HVDCP/USB/CDP.");
usb_therm_set_mosfet(chip, true);
}
} else {