mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-11 15:11:48 -04:00
charging: update charging status when power supply get
update charging status when policy get power supply prop for sgm41542 Change-Id: Idbf9addb9312dc2705d0c722b4f1bf07b03712fb Signed-off-by: mahj8 <mahj8@motorola.com> Reviewed-on: https://gerrit.mot.com/2118981 Reviewed-by: Huosheng Liao <liaohs@motorola.com> SLTApproved: Slta Waiver SME-Granted: SME Approvals Granted Tested-by: Jira Key Submit-Approved: Jira Key
This commit is contained in:
parent
ce40bdb1a9
commit
7221ea47ce
2 changed files with 23 additions and 4 deletions
|
|
@ -1007,7 +1007,7 @@ static int bq2589x_power_supply_get_property(struct power_supply *psy,
|
|||
{
|
||||
struct bq2589x *bq = power_supply_get_drvdata(psy);
|
||||
struct bq2589x_state state = bq->state;
|
||||
u8 chrg_status = bq2589x_get_charging_status(bq);
|
||||
u8 chrg_status = 0;
|
||||
|
||||
switch (psp) {
|
||||
case POWER_SUPPLY_PROP_MANUFACTURER:
|
||||
|
|
@ -1024,6 +1024,7 @@ static int bq2589x_power_supply_get_property(struct power_supply *psy,
|
|||
val->strval = "UNKNOWN";
|
||||
break;
|
||||
case POWER_SUPPLY_PROP_STATUS:
|
||||
chrg_status = bq2589x_get_charging_status(bq);
|
||||
if (!state.online)
|
||||
val->intval = POWER_SUPPLY_STATUS_DISCHARGING;
|
||||
else if (chrg_status == STATUS_NOT_CHARGING)
|
||||
|
|
@ -1072,6 +1073,7 @@ static int bq2589x_power_supply_get_property(struct power_supply *psy,
|
|||
val->intval = bq2589x_get_vindpm_volt(bq);
|
||||
break;
|
||||
case POWER_SUPPLY_PROP_CHARGE_TYPE:
|
||||
chrg_status = bq2589x_get_charging_status(bq);
|
||||
switch (chrg_status) {
|
||||
case STATUS_PRE_CHARGING:
|
||||
val->intval = POWER_SUPPLY_CHARGE_TYPE_TRICKLE;
|
||||
|
|
|
|||
|
|
@ -1025,7 +1025,21 @@ static int sgm4154x_charger_set_property(struct power_supply *psy,
|
|||
return ret;
|
||||
}
|
||||
|
||||
int sgm4154x_get_charging_status(struct sgm4154x_device *sgm)
|
||||
{
|
||||
int ret = 0;
|
||||
int chrg_stat;
|
||||
|
||||
ret = regmap_read(sgm->regmap, SGM4154x_CHRG_STAT, &chrg_stat);
|
||||
if (ret) {
|
||||
pr_err("%s read SGM4154x_CHRG_STAT fail\n",__func__);
|
||||
return ret;
|
||||
}
|
||||
|
||||
chrg_stat &= SGM4154x_CHG_STAT_MASK;
|
||||
|
||||
return chrg_stat;
|
||||
}
|
||||
|
||||
static int sgm4154x_charger_get_property(struct power_supply *psy,
|
||||
enum power_supply_property psp,
|
||||
|
|
@ -1033,6 +1047,7 @@ static int sgm4154x_charger_get_property(struct power_supply *psy,
|
|||
{
|
||||
struct sgm4154x_device *sgm = power_supply_get_drvdata(psy);
|
||||
struct sgm4154x_state state;
|
||||
int chrg_status = 0;
|
||||
int ret = 0;
|
||||
|
||||
mutex_lock(&sgm->lock);
|
||||
|
|
@ -1044,17 +1059,19 @@ static int sgm4154x_charger_get_property(struct power_supply *psy,
|
|||
|
||||
switch (psp) {
|
||||
case POWER_SUPPLY_PROP_STATUS:
|
||||
chrg_status = sgm4154x_get_charging_status(sgm);
|
||||
if (!state.chrg_type || (state.chrg_type == SGM4154x_OTG_MODE))
|
||||
val->intval = POWER_SUPPLY_STATUS_DISCHARGING;
|
||||
else if (!state.chrg_stat)
|
||||
else if (!chrg_status)
|
||||
val->intval = POWER_SUPPLY_STATUS_NOT_CHARGING;
|
||||
else if (state.chrg_stat == SGM4154x_TERM_CHRG)
|
||||
else if (chrg_status == SGM4154x_TERM_CHRG)
|
||||
val->intval = POWER_SUPPLY_STATUS_FULL;
|
||||
else
|
||||
val->intval = POWER_SUPPLY_STATUS_CHARGING;
|
||||
break;
|
||||
case POWER_SUPPLY_PROP_CHARGE_TYPE:
|
||||
switch (state.chrg_stat) {
|
||||
chrg_status = sgm4154x_get_charging_status(sgm);
|
||||
switch (chrg_status) {
|
||||
case SGM4154x_PRECHRG:
|
||||
val->intval = POWER_SUPPLY_CHARGE_TYPE_TRICKLE;
|
||||
break;
|
||||
|
|
|
|||
Loading…
Reference in a new issue