sc760x_charger_mmi: Support THERMAL_RATIO_CONTROL

Dual battery thermal mitigation, Add equal ratio thermal level control
Define THERMAL_RATIO_CONTRO to enable this feature.
It will ignore thermal-mitigation-level and force to rewite new thermal
level through calculating the (batt_fcc_ma/thermal-ratio) of parnter
battery

Change-Id: Ib44eccfe540b6d8d705bb53fb5001207288a7b85
Signed-off-by: xuwt2 <xuwt2@lenovo.com>
Reviewed-on: https://gerrit.mot.com/2567981
SME-Granted: SME Approvals Granted
SLTApproved: Slta Waiver
Tested-by: Jira Key
Reviewed-by: litong <litong20@motorola.com>
Reviewed-by: Guobin Zhang <zhanggb@motorola.com>
Submit-Approved: Jira Key
This commit is contained in:
xuwt2 2023-04-06 21:14:12 +08:00 • committed by Wentao Xu
commit 8cc8dc29b0
4 changed files with 21 additions and 0 deletions

View file

@ -7,5 +7,10 @@ LOCAL_MODULE := sc760x_charger_mmi.ko
LOCAL_MODULE_PATH := $(KERNEL_MODULES_OUT)
LOCAL_ADDITIONAL_DEPENDENCIES := $(KERNEL_MODULES_OUT)/mmi_charger.ko
ifeq ($(THERMAL_RATIO_CONTROL),true)
KERNEL_CFLAGS += CONFIG_THERMAL_RATIO_CONTROL=y
KBUILD_OPTIONS += CONFIG_THERMAL_RATIO_CONTROL=y
endif
KBUILD_OPTIONS_GKI += GKI_OBJ_MODULE_DIR=gki
include $(DLKM_DIR)/AndroidKernelModule.mk

View file

@ -4,6 +4,9 @@ EXTRA_CFLAGS += -I$(ANDROID_BUILD_TOP)/motorola/kernel/modules/include \
-I$(ANDROID_BUILD_TOP)/motorola/kernel/modules/drivers/power/sc760x_charger_mmi \
-I$(ANDROID_BUILD_TOP)/motorola/kernel/modules/drivers/power/mmi_charger
ifneq ($(filter m y,$(CONFIG_THERMAL_RATIO_CONTROL)),)
EXTRA_CFLAGS += -DTHERMAL_RATIO_CONTROL
endif
obj-m += sc760x_charger_mmi.o

View file

@ -1110,6 +1110,12 @@ static int sc760x_parse_dt(struct sc760x_chip *sc, struct device *dev)
sc->num_thermal_levels = len;
sc->thermal_fcc_ua = sc->init_data.max_ichg;
ret = device_property_read_u32(sc->dev,
"mmi,thermal-ratio",
&sc->thermal_ratio);
if (ret)
sc->thermal_ratio = 1;
return ret;
}
@ -1569,6 +1575,11 @@ 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;
#endif
if (sc760x_ibat_limit_set > (ibat_limit_vote + IBAT_CHG_LIM_BASE)) {
sc760x_ibat_limit_set -= IBAT_CHG_LIM_BASE;
sc760x_set_ibat_limit(chg->sc, sc760x_ibat_limit_set);
@ -1778,6 +1789,7 @@ static void sc760x_paired_battery_notify(void *data,
return;
}
memcpy(&chg->paired_batt_info, batt_info, sizeof(struct mmi_battery_info));
if (chg->sc->sc760x_enable) {
pr_info("sc760x has been power on\n");
return;

View file

@ -206,6 +206,7 @@ struct sc760x_chip {
u32 thermal_fcc_ua;
int curr_thermal_level;
int num_thermal_levels;
int thermal_ratio;
bool use_ext_usb_psy;
bool use_ext_wls_psy;