mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-10 14:19:09 -04:00
FG: power_supply_property get rt9426a battery info from local value
1.when plug the USB cable, charger policy will trigle to get POWER_SUPPORY_PROPERTY For rt9426a fg getting power_supply_property vaule by read i2c data, that will make i2c busy and affect the PD sink. 2.remove useless debug info Change-Id: I2ebee58e1deb9e0d4eeb4d3fa01b731fc0385ffc Signed-off-by: liuyc20 <liuyc20@lenovo.com> Reviewed-on: https://gerrit.mot.com/2139569 SME-Granted: SME Approvals Granted SLTApproved: Slta Waiver Tested-by: Jira Key Reviewed-by: Lu Chai <chailu1@motorola.com> Reviewed-by: Huosheng Liao <liaohs@motorola.com> Submit-Approved: Jira Key
This commit is contained in:
parent
099f74a3fd
commit
2828296591
1 changed files with 14 additions and 23 deletions
|
|
@ -36,6 +36,8 @@ struct rt9426a_chip {
|
|||
int btemp;
|
||||
int bvolt;
|
||||
int bcurr;
|
||||
unsigned cyccnt;
|
||||
int soh;
|
||||
u16 ic_ver;
|
||||
int design_capacity;
|
||||
int full_capacity;
|
||||
|
|
@ -397,28 +399,26 @@ static int rt9426a_get_temp(struct rt9426a_chip *chip)
|
|||
static unsigned int rt9426a_get_cyccnt(struct rt9426a_chip *chip)
|
||||
{
|
||||
int ret;
|
||||
unsigned int cyccnt = 0;
|
||||
|
||||
ret = rt9426a_reg_read_word(chip->i2c, RT9426A_REG_CYC);
|
||||
if (ret < 0)
|
||||
dev_notice(chip->dev, "%s: read cycle count fail\n", __func__);
|
||||
else
|
||||
cyccnt = ret;
|
||||
chip->cyccnt = ret;
|
||||
|
||||
return cyccnt;
|
||||
return chip->cyccnt;
|
||||
}
|
||||
static int rt9426a_get_soh(struct rt9426a_chip *chip)
|
||||
{
|
||||
int ret;
|
||||
int soh = 100;
|
||||
|
||||
ret = rt9426a_reg_read_word(chip->i2c, RT9426A_REG_SOH);
|
||||
if (ret < 0)
|
||||
dev_notice(chip->dev, "%s: read soh fail\n", __func__);
|
||||
else
|
||||
soh = ret;
|
||||
chip->soh = ret;
|
||||
|
||||
return soh;
|
||||
return chip->soh;
|
||||
}
|
||||
|
||||
static int rt9426a_get_current(struct rt9426a_chip *chip)
|
||||
|
|
@ -501,7 +501,7 @@ static unsigned int rt9426a_get_design_capacity(struct rt9426a_chip *chip)
|
|||
|
||||
static unsigned int rt9426a_get_full_capacity(struct rt9426a_chip *chip)
|
||||
{
|
||||
int curr_soh = rt9426a_get_soh(chip);
|
||||
int curr_soh = chip->soh;
|
||||
|
||||
chip->full_capacity = chip->design_capacity * curr_soh / 100;
|
||||
if (chip->full_capacity < 0) {
|
||||
|
|
@ -516,7 +516,7 @@ static unsigned int rt9426a_get_charge_counter(struct rt9426a_chip *chip)
|
|||
int charge_counter;
|
||||
int full_capacity;
|
||||
|
||||
full_capacity = rt9426a_get_full_capacity(chip) * 1000;
|
||||
full_capacity = chip->full_capacity * 1000;
|
||||
charge_counter = div_s64(full_capacity * chip->capacity, 100);
|
||||
|
||||
return charge_counter;
|
||||
|
|
@ -1147,50 +1147,39 @@ static int rt_fg_get_property(struct power_supply *psy,
|
|||
switch (psp) {
|
||||
case POWER_SUPPLY_PROP_PRESENT:
|
||||
val->intval = chip->online;
|
||||
dev_info(chip->dev, "psp_online = %d\n", val->intval);
|
||||
break;
|
||||
case POWER_SUPPLY_PROP_VOLTAGE_NOW:
|
||||
val->intval = rt9426a_get_volt(chip) * 1000;
|
||||
dev_info(chip->dev, "psp_volt_now = %d\n", val->intval);
|
||||
val->intval = chip->bvolt * 1000;
|
||||
break;
|
||||
case POWER_SUPPLY_PROP_VOLTAGE_MAX_DESIGN:
|
||||
val->intval = chip->pdata->battery_type;
|
||||
dev_info(chip->dev, "psp_volt_max_design = %d\n", val->intval);
|
||||
break;
|
||||
case POWER_SUPPLY_PROP_CAPACITY:
|
||||
/* add for smooth_soc */
|
||||
/*chip->capacity = rt9426a_fg_get_soc(chip); */
|
||||
val->intval = chip->capacity;
|
||||
dev_info(chip->dev, "psp_capacity = %d\n", val->intval);
|
||||
break;
|
||||
case POWER_SUPPLY_PROP_CHARGE_FULL_DESIGN:
|
||||
val->intval = rt9426a_get_design_capacity(chip) * 1000;
|
||||
dev_info(chip->dev, "psp_charge_full_design = %d\n", val->intval);
|
||||
break;
|
||||
case POWER_SUPPLY_PROP_CURRENT_NOW:
|
||||
val->intval = rt9426a_get_current(chip) * 1000 * (-1);
|
||||
dev_info(chip->dev, "psp_curr_now = %d\n", val->intval);
|
||||
val->intval = chip->bcurr * 1000 * (-1);
|
||||
break;
|
||||
case POWER_SUPPLY_PROP_TEMP:
|
||||
val->intval = rt9426a_get_temp(chip);
|
||||
dev_info(chip->dev, "psp_temp = %d\n", val->intval);
|
||||
val->intval = chip->btemp;
|
||||
break;
|
||||
case POWER_SUPPLY_PROP_CYCLE_COUNT:
|
||||
val->intval = rt9426a_get_cyccnt(chip);
|
||||
dev_info(chip->dev, "psp_cyccnt = %d\n", val->intval);
|
||||
val->intval = chip->cyccnt;
|
||||
break;
|
||||
/* add for aging cv */
|
||||
case POWER_SUPPLY_PROP_VOLTAGE_OCV:
|
||||
val->intval = chip->ocv_index;
|
||||
dev_info(chip->dev, "ocv index = %d\n", chip->ocv_index);
|
||||
break;
|
||||
case POWER_SUPPLY_PROP_CHARGE_FULL:
|
||||
val->intval = rt9426a_get_full_capacity(chip) * 1000;
|
||||
dev_info(chip->dev, "psp_charge_full = %d\n", val->intval);
|
||||
break;
|
||||
case POWER_SUPPLY_PROP_CHARGE_COUNTER:
|
||||
val->intval = rt9426a_get_charge_counter(chip);
|
||||
dev_info(chip->dev, "psp_charge_counter = %d\n", val->intval);
|
||||
break;
|
||||
default:
|
||||
rc = -EINVAL;
|
||||
|
|
@ -2879,6 +2868,8 @@ static int rt9426a_i2c_probe(struct i2c_client *i2c)
|
|||
chip->bcurr = 1000;
|
||||
chip->design_capacity = 2000;
|
||||
chip->full_capacity = 2000;
|
||||
chip->soh = 100;
|
||||
chip->cyccnt = 0;
|
||||
chip->ocv_checksum_ic = 0;
|
||||
chip->ocv_index = 0; /* init as 0 */
|
||||
/* add for aging cv */
|
||||
|
|
|
|||
Loading…
Reference in a new issue