mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-25 22:23:14 -04:00
charging: add charge counter prop
As VTS require, must to add charge counter prop in sys/class/power_supply/battery Change-Id: Iad117f5bd7261ed435c5b6704a6242181245da75 Signed-off-by: mahj8 <mahj8@motorola.com> Reviewed-on: https://gerrit.mot.com/2130897 SME-Granted: SME Approvals Granted SLTApproved: Slta Waiver Tested-by: Jira Key Reviewed-by: Huosheng Liao <liaohs@motorola.com> Submit-Approved: Jira Key
This commit is contained in:
parent
1f977a8a0b
commit
50231385d2
3 changed files with 32 additions and 0 deletions
|
|
@ -823,6 +823,17 @@ static int cw_battery_set_property(struct power_supply *psy,
|
|||
return ret;
|
||||
}
|
||||
|
||||
static unsigned int cw_get_charge_counter(struct cw_battery *cw_bat)
|
||||
{
|
||||
int charge_counter;
|
||||
int full_capacity;
|
||||
|
||||
full_capacity = (cw_bat->fcc_design * cw_bat->soh * 1000) / 100;
|
||||
charge_counter = div_s64(full_capacity * cw_bat->ui_soc, 100);
|
||||
|
||||
return charge_counter;
|
||||
}
|
||||
|
||||
static int cw_battery_get_property(struct power_supply *psy,
|
||||
enum power_supply_property psp,
|
||||
union power_supply_propval *val)
|
||||
|
|
@ -867,6 +878,9 @@ static int cw_battery_get_property(struct power_supply *psy,
|
|||
case POWER_SUPPLY_PROP_TEMP:
|
||||
val->intval = cw_bat->temp;
|
||||
break;
|
||||
case POWER_SUPPLY_PROP_CHARGE_COUNTER:
|
||||
val->intval = cw_get_charge_counter(cw_bat);
|
||||
break;
|
||||
default:
|
||||
ret = -EINVAL;
|
||||
break;
|
||||
|
|
@ -886,6 +900,7 @@ static enum power_supply_property cw_battery_properties[] = {
|
|||
POWER_SUPPLY_PROP_CHARGE_FULL_DESIGN,
|
||||
POWER_SUPPLY_PROP_CHARGE_FULL,
|
||||
POWER_SUPPLY_PROP_TEMP,
|
||||
POWER_SUPPLY_PROP_CHARGE_COUNTER,
|
||||
};
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -1146,6 +1146,7 @@ static enum power_supply_property batt_props[] = {
|
|||
POWER_SUPPLY_PROP_TECHNOLOGY,
|
||||
POWER_SUPPLY_PROP_CHARGE_CONTROL_LIMIT_MAX,
|
||||
POWER_SUPPLY_PROP_CHARGE_CONTROL_LIMIT,
|
||||
POWER_SUPPLY_PROP_CHARGE_COUNTER,
|
||||
POWER_SUPPLY_PROP_CYCLE_COUNT,
|
||||
POWER_SUPPLY_PROP_CHARGE_FULL,
|
||||
POWER_SUPPLY_PROP_CHARGE_FULL_DESIGN,
|
||||
|
|
@ -1201,6 +1202,7 @@ static int batt_get_prop(struct power_supply *psy,
|
|||
case POWER_SUPPLY_PROP_CHARGE_CONTROL_LIMIT:
|
||||
rc = get_prop_system_temp_level(chip, val);
|
||||
break;
|
||||
case POWER_SUPPLY_PROP_CHARGE_COUNTER:
|
||||
case POWER_SUPPLY_PROP_VOLTAGE_NOW:
|
||||
rc = power_supply_get_property(chip->bms_psy, psp, val);
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -511,6 +511,16 @@ static unsigned int rt9426a_get_full_capacity(struct rt9426a_chip *chip)
|
|||
return chip->full_capacity;
|
||||
}
|
||||
|
||||
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;
|
||||
charge_counter = div_s64(full_capacity * chip->capacity, 100);
|
||||
|
||||
return charge_counter;
|
||||
}
|
||||
|
||||
/* checking cycle_cnt & bccomp */
|
||||
static int rt9426a_set_cyccnt(struct rt9426a_chip *chip, unsigned int cyc_new)
|
||||
|
|
@ -1178,6 +1188,10 @@ static int rt_fg_get_property(struct power_supply *psy,
|
|||
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;
|
||||
break;
|
||||
|
|
@ -1260,6 +1274,7 @@ static enum power_supply_property rt_fg_props[] = {
|
|||
POWER_SUPPLY_PROP_CAPACITY,
|
||||
POWER_SUPPLY_PROP_VOLTAGE_OCV,
|
||||
POWER_SUPPLY_PROP_CHARGE_FULL,
|
||||
POWER_SUPPLY_PROP_CHARGE_COUNTER,
|
||||
};
|
||||
|
||||
static struct power_supply_desc fg_psy_desc = {
|
||||
|
|
|
|||
Loading…
Reference in a new issue