Merge "qcom_charger: smb-lib: support faking battery capacity"

This commit is contained in:
Linux Build Service Account 2016-08-26 14:48:52 -07:00 committed by Gerrit - the friendly Code Review server
commit d319bf625a
4 changed files with 29 additions and 2 deletions

View file

@ -528,6 +528,9 @@ static int smb2_batt_set_prop(struct power_supply *psy,
case POWER_SUPPLY_PROP_SYSTEM_TEMP_LEVEL:
rc = smblib_set_prop_system_temp_level(chg, val);
break;
case POWER_SUPPLY_PROP_CAPACITY:
rc = smblib_set_prop_batt_capacity(chg, val);
break;
default:
rc = -EINVAL;
}
@ -541,6 +544,7 @@ static int smb2_batt_prop_is_writeable(struct power_supply *psy,
switch (psp) {
case POWER_SUPPLY_PROP_INPUT_SUSPEND:
case POWER_SUPPLY_PROP_SYSTEM_TEMP_LEVEL:
case POWER_SUPPLY_PROP_CAPACITY:
return 1;
default:
break;

View file

@ -759,6 +759,11 @@ int smblib_get_prop_batt_capacity(struct smb_charger *chg,
{
int rc = -EINVAL;
if (chg->fake_capacity >= 0) {
val->intval = chg->fake_capacity;
return 0;
}
if (chg->bms_psy)
rc = power_supply_get_property(chg->bms_psy,
POWER_SUPPLY_PROP_CAPACITY, val);
@ -913,6 +918,16 @@ int smblib_set_prop_input_suspend(struct smb_charger *chg,
return rc;
}
int smblib_set_prop_batt_capacity(struct smb_charger *chg,
const union power_supply_propval *val)
{
chg->fake_capacity = val->intval;
power_supply_changed(chg->batt_psy);
return 0;
}
int smblib_set_prop_system_temp_level(struct smb_charger *chg,
const union power_supply_propval *val)
{
@ -1917,6 +1932,7 @@ int smblib_init(struct smb_charger *chg)
INIT_WORK(&chg->pl_detect_work, smblib_pl_detect_work);
INIT_DELAYED_WORK(&chg->hvdcp_detect_work, smblib_hvdcp_detect_work);
INIT_DELAYED_WORK(&chg->pl_taper_work, smblib_pl_taper_work);
chg->fake_capacity = -EINVAL;
switch (chg->mode) {
case PARALLEL_MASTER:

View file

@ -143,6 +143,8 @@ struct smb_charger {
int system_temp_level;
int thermal_levels;
int *thermal_mitigation;
int fake_capacity;
};
int smblib_read(struct smb_charger *chg, u16 addr, u8 *val);
@ -194,6 +196,8 @@ int smblib_get_prop_system_temp_level(struct smb_charger *chg,
int smblib_set_prop_input_suspend(struct smb_charger *chg,
const union power_supply_propval *val);
int smblib_set_prop_batt_capacity(struct smb_charger *chg,
const union power_supply_propval *val);
int smblib_set_prop_system_temp_level(struct smb_charger *chg,
const union power_supply_propval *val);

View file

@ -311,9 +311,11 @@ static int smb138x_batt_set_prop(struct power_supply *psy,
case POWER_SUPPLY_PROP_INPUT_SUSPEND:
rc = smblib_set_prop_input_suspend(chg, val);
break;
case POWER_SUPPLY_PROP_CAPACITY:
rc = smblib_set_prop_batt_capacity(chg, val);
break;
default:
pr_err("batt power supply set prop %d not supported\n",
prop);
pr_err("batt power supply set prop %d not supported\n", prop);
return -EINVAL;
}
@ -325,6 +327,7 @@ static int smb138x_batt_prop_is_writeable(struct power_supply *psy,
{
switch (prop) {
case POWER_SUPPLY_PROP_INPUT_SUSPEND:
case POWER_SUPPLY_PROP_CAPACITY:
return 1;
default:
break;