mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-07 04:12:04 -04:00
charge rt9426a add ffc mode
rt9426a set FC_VTH and FC_ITH add ffc mode set FC_VTH and FC_ITH in kernel Change-Id: I0822f8b8ba459cb1b61148024205116bd2755fa6 Reviewed-on: https://gerrit.mot.com/2748210 SME-Granted: SME Approvals Granted SLTApproved: Slta Waiver Tested-by: Jira Key Reviewed-by: Lei Chen <chenl18@motorola.com> Reviewed-by: Wei Xu <xuwei9@lenovo.com> Reviewed-by: Xiangpo Zhao <zhaoxp3@motorola.com> Submit-Approved: Jira Key
This commit is contained in:
parent
42c96a8ee5
commit
496cb2c408
3 changed files with 75 additions and 7 deletions
|
|
@ -1324,11 +1324,10 @@ static void mmi_discrete_config_chgmod_to_fg(struct mmi_discrete_charger *chip)
|
|||
{
|
||||
union power_supply_propval val;
|
||||
int rc = 0;
|
||||
|
||||
if (!chip->bms_psy || !chip->chgmod_to_fg)
|
||||
if (!chip->bms_psy)
|
||||
return;
|
||||
|
||||
if (chip->chg_info.chrg_pmax_mw > TURBO_CHRG_FFC_THRSH_MW) {
|
||||
if (chip->chg_info.chrg_pmax_mw > TURBO_CHRG_FFC_THRSH_MW||
|
||||
(chip->is_ffc_enable && chip->enable_10w_ffc)) {
|
||||
val.intval = MMI_CHARGER_MODE_FFC;
|
||||
} else if (chip->chg_info.chrg_type == POWER_SUPPLY_TYPE_USB) {
|
||||
val.intval = MMI_CHARGER_MODE_USB;
|
||||
|
|
@ -1337,7 +1336,7 @@ static void mmi_discrete_config_chgmod_to_fg(struct mmi_discrete_charger *chip)
|
|||
}
|
||||
|
||||
rc = power_supply_set_property(chip->bms_psy, POWER_SUPPLY_PROP_TYPE, &val);
|
||||
mmi_dbg(chip, "%s config charger mode to fg\n", rc? "Can't" : "success");
|
||||
mmi_dbg(chip,"%s config charger mode to fg\n", rc? "Can't" : "success");
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -910,6 +910,9 @@ static void rt9426a_update_info(struct rt9426a_chip *chip)
|
|||
regval = rt9426a_get_soh(chip);
|
||||
dev_info(chip->dev, "SOH(%d)\n", regval);
|
||||
|
||||
rt9426a_write_page_cmd(chip, RT9426A_PAGE_5);
|
||||
regval = rt9426a_reg_read_word(chip->i2c, RT9426A_REG_SWINDOW3);
|
||||
dev_info(chip->dev, "FC_ITH,FC_VTH =(0x%04x)\n", regval);
|
||||
/* rt9426a_update_ieoc_setting(chip); */
|
||||
|
||||
if (batt_psy) {
|
||||
|
|
@ -1171,6 +1174,52 @@ out:
|
|||
return offset;
|
||||
}
|
||||
|
||||
static int rt9426a_set_ffc_mode(struct rt9426a_chip *chip,u8 mode)
|
||||
{
|
||||
int i = 0;
|
||||
int ret = 0;
|
||||
if (mode == 0) {
|
||||
if (chip->btemp < 250 && chip->btemp >= 0)
|
||||
i = RT9426A_CV4500_IEOC243;
|
||||
else if(chip->btemp < 250)
|
||||
i = RT9426A_CV4530_IEOC506;
|
||||
else if (chip->btemp < 350)
|
||||
i = RT9426A_CV4530_IEOC560;
|
||||
else if (chip->btemp < 450)
|
||||
i = RT9426A_CV4530_IEOC965;
|
||||
else
|
||||
i = RT9426A_CV4200_IEOC243;
|
||||
} else {
|
||||
if (chip->btemp < 350 && chip->btemp >= 0)
|
||||
i = RT9426A_CV4500_IEOC243;
|
||||
else if (chip->btemp < 450)
|
||||
i = RT9426A_CV4500_IEOC670;
|
||||
else
|
||||
i = RT9426A_CV4200_IEOC243;
|
||||
}
|
||||
mutex_lock(&chip->update_lock);
|
||||
if (rt9426a_unseal_wi_retry(chip) == RT9426A_UNSEAL_FAIL) {
|
||||
ret = -EINVAL;
|
||||
goto ccv_out;
|
||||
}
|
||||
rt9426a_write_page_cmd(chip, RT9426A_PAGE_5);
|
||||
ret = rt9426a_reg_read_word(chip->i2c, RT9426A_REG_SWINDOW3);
|
||||
if (ret < 0)
|
||||
goto ccv_out;
|
||||
if (ret != chip->pdata->fc_vth_ith[i])
|
||||
ret = rt9426a_reg_write_word(chip->i2c,
|
||||
RT9426A_REG_SWINDOW3,
|
||||
chip->pdata->fc_vth_ith[i]);
|
||||
else
|
||||
ret = 0;
|
||||
ccv_out:
|
||||
mutex_unlock(&chip->update_lock);
|
||||
dev_notice(chip->dev, "RT9426A ffc_mode:%d chip->btemp:%d fc_vth_ith %x\n",
|
||||
mode,chip->btemp,chip->pdata->fc_vth_ith[i]);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int rt_fg_get_property(struct power_supply *psy,
|
||||
enum power_supply_property psp,
|
||||
union power_supply_propval *val)
|
||||
|
|
@ -1266,11 +1315,14 @@ static int rt_fg_set_property(struct power_supply *psy,
|
|||
chip->ocv_checksum_dtsi = *((u32 *)chip->pdata->ocv_table +
|
||||
(chip->ocv_index * 80) + RT9426A_IDX_OF_OCV_CKSUM);
|
||||
break;
|
||||
case POWER_SUPPLY_PROP_TYPE:
|
||||
if (chip->pdata->fc_vth_ith[0] != 0x0)
|
||||
rc = rt9426a_set_ffc_mode(chip,val->intval);
|
||||
break;
|
||||
default:
|
||||
rc = -EINVAL;
|
||||
break;
|
||||
}
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
|
@ -1281,6 +1333,7 @@ static int rt_fg_property_is_writeable(struct power_supply *psy, enum power_supp
|
|||
case POWER_SUPPLY_PROP_CYCLE_COUNT:
|
||||
/* add for aging cv */
|
||||
case POWER_SUPPLY_PROP_VOLTAGE_OCV:
|
||||
case POWER_SUPPLY_PROP_TYPE:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
|
|
@ -1297,6 +1350,7 @@ static enum power_supply_property rt_fg_props[] = {
|
|||
POWER_SUPPLY_PROP_CHARGE_FULL_DESIGN,
|
||||
POWER_SUPPLY_PROP_CAPACITY,
|
||||
POWER_SUPPLY_PROP_VOLTAGE_OCV,
|
||||
POWER_SUPPLY_PROP_TYPE,
|
||||
POWER_SUPPLY_PROP_CHARGE_FULL,
|
||||
POWER_SUPPLY_PROP_CHARGE_COUNTER,
|
||||
};
|
||||
|
|
@ -2680,7 +2734,12 @@ static int rt_parse_dt(struct device *dev, struct rt9426a_platform_data *pdata)
|
|||
ret = of_property_read_u32(np, "rt,para_version", &pdata->para_version);
|
||||
if (ret < 0)
|
||||
pdata->para_version = 0;
|
||||
|
||||
ret = of_property_read_u32_array(np, "rt,fc_vth-fc_ith", pdata->fc_vth_ith, 6);
|
||||
if (ret < 0) {
|
||||
dev_notice(dev, "no fc_vth-fc_ith, use defaut 0x4CAC\n");
|
||||
for (i = 0; i < 6; i++)
|
||||
pdata->fc_vth_ith[i] = 0x0;
|
||||
}
|
||||
ret = of_property_read_string(np, "rt,bat_name",
|
||||
(const char **)&pdata->bat_name);
|
||||
if (ret < 0)
|
||||
|
|
|
|||
|
|
@ -159,6 +159,15 @@ enum {
|
|||
RT9426A_TEMP_FROM_IC,
|
||||
};
|
||||
|
||||
enum {
|
||||
RT9426A_CV4500_IEOC243 = 0,
|
||||
RT9426A_CV4500_IEOC670,
|
||||
RT9426A_CV4200_IEOC243,
|
||||
RT9426A_CV4530_IEOC506,
|
||||
RT9426A_CV4530_IEOC560,
|
||||
RT9426A_CV4530_IEOC965,
|
||||
};
|
||||
|
||||
struct fg_ocv_table {
|
||||
int data[8];
|
||||
};
|
||||
|
|
@ -170,6 +179,7 @@ struct fg_extreg_table {
|
|||
struct rt9426a_platform_data {
|
||||
u32 dtsi_version[2];
|
||||
u32 para_version;
|
||||
u32 fc_vth_ith[6];
|
||||
int soc_offset_size[2];
|
||||
struct soc_offset_table soc_offset;
|
||||
int offset_interpolation_order[2];
|
||||
|
|
|
|||
Loading…
Reference in a new issue