qpnp-smb2: add missing battery psy properties for healthd

healthd expects battery voltage, current, temperature, and technology from
the battery power supply. Add them.

Change-Id: I85f589030903ead938af2712875eb5daa81710d9
Signed-off-by: Nicholas Troast <ntroast@codeaurora.org>
This commit is contained in:
Nicholas Troast 2016-09-20 15:33:20 -07:00 committed by Subbaraman Narayanamurthy
parent a3946ad93e
commit 3603cc87ba
3 changed files with 64 additions and 2 deletions

View file

@ -596,14 +596,17 @@ static enum power_supply_property smb2_batt_props[] = {
POWER_SUPPLY_PROP_CHARGER_TEMP, POWER_SUPPLY_PROP_CHARGER_TEMP,
POWER_SUPPLY_PROP_CHARGER_TEMP_MAX, POWER_SUPPLY_PROP_CHARGER_TEMP_MAX,
POWER_SUPPLY_PROP_INPUT_CURRENT_LIMITED, POWER_SUPPLY_PROP_INPUT_CURRENT_LIMITED,
POWER_SUPPLY_PROP_VOLTAGE_NOW,
POWER_SUPPLY_PROP_CURRENT_NOW,
POWER_SUPPLY_PROP_TEMP,
POWER_SUPPLY_PROP_TECHNOLOGY,
}; };
static int smb2_batt_get_prop(struct power_supply *psy, static int smb2_batt_get_prop(struct power_supply *psy,
enum power_supply_property psp, enum power_supply_property psp,
union power_supply_propval *val) union power_supply_propval *val)
{ {
struct smb2 *chip = power_supply_get_drvdata(psy); struct smb_charger *chg = power_supply_get_drvdata(psy);
struct smb_charger *chg = &chip->chg;
int rc = 0; int rc = 0;
switch (psp) { switch (psp) {
@ -637,14 +640,28 @@ static int smb2_batt_get_prop(struct power_supply *psy,
case POWER_SUPPLY_PROP_INPUT_CURRENT_LIMITED: case POWER_SUPPLY_PROP_INPUT_CURRENT_LIMITED:
rc = smblib_get_prop_input_current_limited(chg, val); rc = smblib_get_prop_input_current_limited(chg, val);
break; break;
case POWER_SUPPLY_PROP_VOLTAGE_NOW:
rc = smblib_get_prop_batt_voltage_now(chg, val);
break;
case POWER_SUPPLY_PROP_CURRENT_NOW:
rc = smblib_get_prop_batt_current_now(chg, val);
break;
case POWER_SUPPLY_PROP_TEMP:
rc = smblib_get_prop_batt_temp(chg, val);
break;
case POWER_SUPPLY_PROP_TECHNOLOGY:
val->intval = POWER_SUPPLY_TECHNOLOGY_LION;
break;
default: default:
pr_err("batt power supply prop %d not supported\n", psp); pr_err("batt power supply prop %d not supported\n", psp);
return -EINVAL; return -EINVAL;
} }
if (rc < 0) { if (rc < 0) {
pr_debug("Couldn't get prop %d rc = %d\n", psp, rc); pr_debug("Couldn't get prop %d rc = %d\n", psp, rc);
return -ENODATA; return -ENODATA;
} }
return 0; return 0;
} }

View file

@ -1003,6 +1003,45 @@ int smblib_get_prop_input_current_limited(struct smb_charger *chg,
return 0; return 0;
} }
int smblib_get_prop_batt_voltage_now(struct smb_charger *chg,
union power_supply_propval *val)
{
int rc;
if (!chg->bms_psy)
return -EINVAL;
rc = power_supply_get_property(chg->bms_psy,
POWER_SUPPLY_PROP_VOLTAGE_NOW, val);
return rc;
}
int smblib_get_prop_batt_current_now(struct smb_charger *chg,
union power_supply_propval *val)
{
int rc;
if (!chg->bms_psy)
return -EINVAL;
rc = power_supply_get_property(chg->bms_psy,
POWER_SUPPLY_PROP_CURRENT_NOW, val);
return rc;
}
int smblib_get_prop_batt_temp(struct smb_charger *chg,
union power_supply_propval *val)
{
int rc;
if (!chg->bms_psy)
return -EINVAL;
rc = power_supply_get_property(chg->bms_psy,
POWER_SUPPLY_PROP_TEMP, val);
return rc;
}
/*********************** /***********************
* BATTERY PSY SETTERS * * BATTERY PSY SETTERS *
***********************/ ***********************/

View file

@ -222,6 +222,12 @@ int smblib_get_prop_system_temp_level(struct smb_charger *chg,
union power_supply_propval *val); union power_supply_propval *val);
int smblib_get_prop_input_current_limited(struct smb_charger *chg, int smblib_get_prop_input_current_limited(struct smb_charger *chg,
union power_supply_propval *val); union power_supply_propval *val);
int smblib_get_prop_batt_voltage_now(struct smb_charger *chg,
union power_supply_propval *val);
int smblib_get_prop_batt_current_now(struct smb_charger *chg,
union power_supply_propval *val);
int smblib_get_prop_batt_temp(struct smb_charger *chg,
union power_supply_propval *val);
int smblib_set_prop_input_suspend(struct smb_charger *chg, int smblib_set_prop_input_suspend(struct smb_charger *chg,
const union power_supply_propval *val); const union power_supply_propval *val);