Merge "qpnp-smb2: support POWER_SUPPLY_PROP_CTM_CURRENT_MAX"

This commit is contained in:
Linux Build Service Account 2017-02-10 06:46:02 -08:00 committed by Gerrit - the friendly Code Review server
commit 564ead6a58
7 changed files with 38 additions and 14 deletions

View file

@ -286,9 +286,9 @@ static struct device_attribute power_supply_attrs[] = {
POWER_SUPPLY_ATTR(fcc_delta),
POWER_SUPPLY_ATTR(icl_reduction),
POWER_SUPPLY_ATTR(parallel_mode),
POWER_SUPPLY_ATTR(connector_therm_zone),
POWER_SUPPLY_ATTR(die_health),
POWER_SUPPLY_ATTR(connector_health),
POWER_SUPPLY_ATTR(ctm_current_max),
/* Local extensions of type int64_t */
POWER_SUPPLY_ATTR(charge_counter_ext),
/* Properties of type `const char *' */

View file

@ -412,6 +412,7 @@ static enum power_supply_property smb2_usb_props[] = {
POWER_SUPPLY_PROP_INPUT_CURRENT_NOW,
POWER_SUPPLY_PROP_BOOST_CURRENT,
POWER_SUPPLY_PROP_PE_START,
POWER_SUPPLY_PROP_CTM_CURRENT_MAX,
};
static int smb2_usb_get_prop(struct power_supply *psy,
@ -497,6 +498,9 @@ static int smb2_usb_get_prop(struct power_supply *psy,
case POWER_SUPPLY_PROP_PE_START:
rc = smblib_get_pe_start(chg, val);
break;
case POWER_SUPPLY_PROP_CTM_CURRENT_MAX:
val->intval = get_client_vote(chg->usb_icl_votable, CTM_VOTER);
break;
default:
pr_err("get prop %d is not supported in usb\n", psp);
rc = -EINVAL;
@ -545,6 +549,10 @@ static int smb2_usb_set_prop(struct power_supply *psy,
case POWER_SUPPLY_PROP_BOOST_CURRENT:
rc = smblib_set_prop_boost_current(chg, val);
break;
case POWER_SUPPLY_PROP_CTM_CURRENT_MAX:
rc = vote(chg->usb_icl_votable, CTM_VOTER,
val->intval >= 0, val->intval);
break;
default:
pr_err("set prop %d is not supported\n", psp);
rc = -EINVAL;
@ -560,6 +568,7 @@ static int smb2_usb_prop_is_writeable(struct power_supply *psy,
switch (psp) {
case POWER_SUPPLY_PROP_CURRENT_MAX:
case POWER_SUPPLY_PROP_TYPEC_POWER_ROLE:
case POWER_SUPPLY_PROP_CTM_CURRENT_MAX:
return 1;
default:
break;
@ -833,6 +842,7 @@ static enum power_supply_property smb2_batt_props[] = {
POWER_SUPPLY_PROP_CHARGE_DONE,
POWER_SUPPLY_PROP_PARALLEL_DISABLE,
POWER_SUPPLY_PROP_SET_SHIP_MODE,
POWER_SUPPLY_PROP_DIE_HEALTH,
};
static int smb2_batt_get_prop(struct power_supply *psy,
@ -909,6 +919,9 @@ static int smb2_batt_get_prop(struct power_supply *psy,
/* Not in ship mode as long as device is active */
val->intval = 0;
break;
case POWER_SUPPLY_PROP_DIE_HEALTH:
rc = smblib_get_prop_die_health(chg, val);
break;
default:
pr_err("batt power supply prop %d not supported\n", psp);
return -EINVAL;

View file

@ -2027,10 +2027,10 @@ int smblib_get_pe_start(struct smb_charger *chg,
return 0;
}
int smblib_get_prop_connector_therm_zone(struct smb_charger *chg,
int smblib_get_prop_die_health(struct smb_charger *chg,
union power_supply_propval *val)
{
int rc, i;
int rc;
u8 stat;
rc = smblib_read(chg, TEMP_RANGE_STATUS_REG, &stat);
@ -2040,13 +2040,24 @@ int smblib_get_prop_connector_therm_zone(struct smb_charger *chg,
return rc;
}
i = fls((stat & TEMP_RANGE_MASK) >> TEMP_RANGE_SHIFT) - 1;
if (i < 0) {
smblib_err(chg, "TEMP_RANGE is invalid\n");
return -EINVAL;
/* TEMP_RANGE bits are mutually exclusive */
switch (stat & TEMP_RANGE_MASK) {
case TEMP_BELOW_RANGE_BIT:
val->intval = POWER_SUPPLY_HEALTH_COOL;
break;
case TEMP_WITHIN_RANGE_BIT:
val->intval = POWER_SUPPLY_HEALTH_WARM;
break;
case TEMP_ABOVE_RANGE_BIT:
val->intval = POWER_SUPPLY_HEALTH_HOT;
break;
case ALERT_LEVEL_BIT:
val->intval = POWER_SUPPLY_HEALTH_OVERHEAT;
break;
default:
val->intval = POWER_SUPPLY_HEALTH_UNKNOWN;
}
val->intval = i;
return 0;
}

View file

@ -55,6 +55,7 @@ enum print_reason {
#define DEBUG_BOARD_VOTER "DEBUG_BOARD_VOTER"
#define PD_SUSPEND_SUPPORTED_VOTER "PD_SUSPEND_SUPPORTED_VOTER"
#define PL_DISABLE_HVDCP_VOTER "PL_DISABLE_HVDCP_VOTER"
#define CTM_VOTER "CTM_VOTER"
#define VCONN_MAX_ATTEMPTS 3
#define OTG_MAX_ATTEMPTS 3
@ -384,7 +385,7 @@ int smblib_get_prop_charger_temp(struct smb_charger *chg,
union power_supply_propval *val);
int smblib_get_prop_charger_temp_max(struct smb_charger *chg,
union power_supply_propval *val);
int smblib_get_prop_connector_therm_zone(struct smb_charger *chg,
int smblib_get_prop_die_health(struct smb_charger *chg,
union power_supply_propval *val);
int smblib_set_prop_pd_current_max(struct smb_charger *chg,
const union power_supply_propval *val);

View file

@ -825,7 +825,6 @@ enum {
#define THERM_REG_ACTIVE_BIT BIT(6)
#define TLIM_BIT BIT(5)
#define TEMP_RANGE_MASK GENMASK(4, 1)
#define TEMP_RANGE_SHIFT 1
#define ALERT_LEVEL_BIT BIT(4)
#define TEMP_ABOVE_RANGE_BIT BIT(3)
#define TEMP_WITHIN_RANGE_BIT BIT(2)

View file

@ -432,7 +432,7 @@ static enum power_supply_property smb138x_parallel_props[] = {
POWER_SUPPLY_PROP_CHARGER_TEMP_MAX,
POWER_SUPPLY_PROP_MODEL_NAME,
POWER_SUPPLY_PROP_PARALLEL_MODE,
POWER_SUPPLY_PROP_CONNECTOR_THERM_ZONE,
POWER_SUPPLY_PROP_CONNECTOR_HEALTH,
};
static int smb138x_parallel_get_prop(struct power_supply *psy,
@ -485,8 +485,8 @@ static int smb138x_parallel_get_prop(struct power_supply *psy,
case POWER_SUPPLY_PROP_PARALLEL_MODE:
val->intval = POWER_SUPPLY_PARALLEL_MID_MID;
break;
case POWER_SUPPLY_PROP_CONNECTOR_THERM_ZONE:
rc = smblib_get_prop_connector_therm_zone(chg, val);
case POWER_SUPPLY_PROP_CONNECTOR_HEALTH:
rc = smblib_get_prop_die_health(chg, val);
break;
default:
pr_err("parallel power supply get prop %d not supported\n",

View file

@ -238,9 +238,9 @@ enum power_supply_property {
POWER_SUPPLY_PROP_FCC_DELTA,
POWER_SUPPLY_PROP_ICL_REDUCTION,
POWER_SUPPLY_PROP_PARALLEL_MODE,
POWER_SUPPLY_PROP_CONNECTOR_THERM_ZONE,
POWER_SUPPLY_PROP_DIE_HEALTH,
POWER_SUPPLY_PROP_CONNECTOR_HEALTH,
POWER_SUPPLY_PROP_CTM_CURRENT_MAX,
/* Local extensions of type int64_t */
POWER_SUPPLY_PROP_CHARGE_COUNTER_EXT,
/* Properties of type `const char *' */