sm5602:set battery temp to 25 in moto-factory mode

battery ntc is on the board,so battery temp is error in factorymode testing
it doesnot test quick charger in moto-factory mode when battery is error
set battery temp to 25 in moto-factory mode

Change-Id: I230edcfa1118b303561d21ce2b16e1fab92e298f
Signed-off-by: wutao <huaqin89@motorola.com>
Reviewed-on: https://gerrit.mot.com/2166164
SME-Granted: SME Approvals Granted
SLTApproved: Slta Waiver
Tested-by: Jira Key
Reviewed-by: Haijian Ma <mahj8@motorola.com>
Reviewed-by: Yuecai Liu <liuyc20@motorola.com>
Reviewed-by: Huosheng Liao <liaohs@motorola.com>
Submit-Approved: Jira Key
This commit is contained in:
wutao 2022-01-11 15:39:44 +08:00 • committed by huaqin85
commit b856b01a42

View file

@ -175,6 +175,8 @@ struct sm_fg_chip {
bool iocv_man_mode;
int aging_ctrl;
int batt_rsns; /* Sensing resistor value */
int ntc_exist;
bool factory_mode;
int cycle_cfg;
int fg_irq_set;
int low_soc1;
@ -445,6 +447,35 @@ static unsigned int fg_read_ocv(struct sm_fg_chip *sm)
return ocv; //mV
}
bool is_factory_mode(void)
{
struct device_node *np = of_find_node_by_path("/chosen");
bool factory_mode = false;
const char *bootargs = NULL;
char *bootmode = NULL;
char *end = NULL;
if (!np)
return factory_mode;
if (!of_property_read_string(np, "bootargs", &bootargs)) {
bootmode = strstr(bootargs, "androidboot.mode=");
if (bootmode) {
end = strpbrk(bootmode, " ");
bootmode = strpbrk(bootmode, "=");
}
if (bootmode &&
end > bootmode &&
strnstr(bootmode, "mot-factory", end - bootmode)) {
factory_mode = true;
}
}
of_node_put(np);
return factory_mode;
}
static int _calculate_battery_temp_ex(struct sm_fg_chip *sm, u16 uval)
{
int i = 0, temp = 0;
@ -474,6 +505,8 @@ static int _calculate_battery_temp_ex(struct sm_fg_chip *sm, u16 uval)
pr_info("uval = 0x%x, val = 0x%x, temp = %d\n",uval, val, temp);
if(sm->factory_mode && !sm->ntc_exist && (-20 == temp))
temp = 25;
return temp;
}
@ -2263,6 +2296,11 @@ static int fg_common_parse_dt(struct sm_fg_chip *sm)
if (rc < 0)
sm->batt_rsns = -EINVAL;
rc = of_property_read_u32(np, "factory_mode_ntc_exist",
&sm->ntc_exist);
if (rc < 0)
sm->ntc_exist = true;
/* IRQ Mask */
rc = of_property_read_u32(np, "sm,fg_irq_set",
&sm->fg_irq_set);
@ -2753,6 +2791,9 @@ static int sm_fg_probe(struct i2c_client *client,
fg_dump_debug(sm);
if(is_factory_mode())
sm->factory_mode = true;
//schedule_delayed_work(&sm->monitor_work, 10 * HZ);
pr_info("sm fuel gauge probe successfully, %s\n",device2str[sm->chip]);