From 7f6626a7caa06e9dc72d6fdfb5764012d1cecb20 Mon Sep 17 00:00:00 2001 From: litong20 Date: Tue, 9 May 2023 18:10:18 +0800 Subject: [PATCH] Set the thermal_ratio_nums. sc760x: The step of thermal radio is 0.5, so the thermal_ratio is (thermal_ratio_nums * 0.5). Change-Id: I87238d652c90be53c7bd2901c63fcf2c84Montana467 Reviewed-on: https://gerrit.mot.com/2601346 SME-Granted: SME Approvals Granted SLTApproved: Slta Waiver Tested-by: Jira Key Reviewed-by: Wentao Xu Reviewed-by: Guobin Zhang Submit-Approved: Jira Key --- drivers/power/sc760x_charger_mmi/sc760x_charger_mmi.c | 11 ++++++----- drivers/power/sc760x_charger_mmi/sc760x_charger_mmi.h | 2 +- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/drivers/power/sc760x_charger_mmi/sc760x_charger_mmi.c b/drivers/power/sc760x_charger_mmi/sc760x_charger_mmi.c index 06e91aeb68cd..3ca689524744 100644 --- a/drivers/power/sc760x_charger_mmi/sc760x_charger_mmi.c +++ b/drivers/power/sc760x_charger_mmi/sc760x_charger_mmi.c @@ -1127,10 +1127,10 @@ static int sc760x_parse_dt(struct sc760x_chip *sc, struct device *dev) sc->thermal_fcc_ua = sc->init_data.max_ichg; ret = device_property_read_u32(sc->dev, - "mmi,thermal-ratio", - &sc->thermal_ratio); + "mmi,thermal-ratio-nums", + &sc->thermal_ratio_nums); if (ret) - sc->thermal_ratio = 1; + sc->thermal_ratio_nums = 1; return 0; } @@ -1590,8 +1590,9 @@ static int sc760x_charger_config_charge(void *data, struct mmi_charger_cfg *conf ibat_limit_vote = MIN_VAL(chg->chg_cfg.target_fcc, chg->sc->thermal_fcc_ua / 1000); #ifdef THERMAL_RATIO_CONTROL - ibat_limit_vote = MIN_VAL(chg->chg_cfg.target_fcc, chg->paired_batt_info.batt_fcc_ma / chg->sc->thermal_ratio); - chg->sc->thermal_fcc_ua = (chg->paired_batt_info.batt_fcc_ma / chg->sc->thermal_ratio) * 1000; + /* The thermal_radio step is 0.5, this is equivalent to (batt_fcc_ma / (0.5 * thermal_ratio_nums)) */ + chg->sc->thermal_fcc_ua = (chg->paired_batt_info.batt_fcc_ma * 2 / chg->sc->thermal_ratio_nums) * 1000; + ibat_limit_vote = MIN_VAL(chg->chg_cfg.target_fcc, chg->sc->thermal_fcc_ua / 1000); #endif if (sc760x_ibat_limit_set > (ibat_limit_vote + IBAT_CHG_LIM_BASE)) { diff --git a/drivers/power/sc760x_charger_mmi/sc760x_charger_mmi.h b/drivers/power/sc760x_charger_mmi/sc760x_charger_mmi.h index 51f40a9e99ea..d2e096acdc7f 100644 --- a/drivers/power/sc760x_charger_mmi/sc760x_charger_mmi.h +++ b/drivers/power/sc760x_charger_mmi/sc760x_charger_mmi.h @@ -206,7 +206,7 @@ struct sc760x_chip { u32 thermal_fcc_ua; int curr_thermal_level; int num_thermal_levels; - int thermal_ratio; + int thermal_ratio_nums; bool use_ext_usb_psy; bool use_ext_wls_psy;