Merge "qcom-charger: Add ship mode support"
This commit is contained in:
commit
e76c8c8e73
3 changed files with 32 additions and 1 deletions
|
@ -688,6 +688,7 @@ static enum power_supply_property smb2_batt_props[] = {
|
||||||
POWER_SUPPLY_PROP_CHARGE_DONE,
|
POWER_SUPPLY_PROP_CHARGE_DONE,
|
||||||
POWER_SUPPLY_PROP_PARALLEL_DISABLE,
|
POWER_SUPPLY_PROP_PARALLEL_DISABLE,
|
||||||
POWER_SUPPLY_PROP_PARALLEL_PERCENT,
|
POWER_SUPPLY_PROP_PARALLEL_PERCENT,
|
||||||
|
POWER_SUPPLY_PROP_SET_SHIP_MODE,
|
||||||
};
|
};
|
||||||
|
|
||||||
static int smb2_batt_get_prop(struct power_supply *psy,
|
static int smb2_batt_get_prop(struct power_supply *psy,
|
||||||
|
@ -763,6 +764,10 @@ static int smb2_batt_get_prop(struct power_supply *psy,
|
||||||
case POWER_SUPPLY_PROP_PARALLEL_PERCENT:
|
case POWER_SUPPLY_PROP_PARALLEL_PERCENT:
|
||||||
val->intval = chg->pl.slave_pct;
|
val->intval = chg->pl.slave_pct;
|
||||||
break;
|
break;
|
||||||
|
case POWER_SUPPLY_PROP_SET_SHIP_MODE:
|
||||||
|
/* Not in ship mode as long as device is active */
|
||||||
|
val->intval = 0;
|
||||||
|
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;
|
||||||
|
@ -808,6 +813,12 @@ static int smb2_batt_set_prop(struct power_supply *psy,
|
||||||
case POWER_SUPPLY_PROP_CONSTANT_CHARGE_CURRENT_MAX:
|
case POWER_SUPPLY_PROP_CONSTANT_CHARGE_CURRENT_MAX:
|
||||||
vote(chg->fcc_max_votable, DEFAULT_VOTER, true, val->intval);
|
vote(chg->fcc_max_votable, DEFAULT_VOTER, true, val->intval);
|
||||||
break;
|
break;
|
||||||
|
case POWER_SUPPLY_PROP_SET_SHIP_MODE:
|
||||||
|
/* Not in ship mode as long as the device is active */
|
||||||
|
if (!val->intval)
|
||||||
|
break;
|
||||||
|
rc = smblib_set_prop_ship_mode(chg, val);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
rc = -EINVAL;
|
rc = -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,6 +39,9 @@
|
||||||
|
|
||||||
static bool is_secure(struct smb_charger *chg, int addr)
|
static bool is_secure(struct smb_charger *chg, int addr)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
if (addr == SHIP_MODE_REG)
|
||||||
|
return true;
|
||||||
/* assume everything above 0xA0 is secure */
|
/* assume everything above 0xA0 is secure */
|
||||||
return (bool)((addr & 0xFF) >= 0xA0);
|
return (bool)((addr & 0xFF) >= 0xA0);
|
||||||
}
|
}
|
||||||
|
@ -2070,6 +2073,22 @@ int smblib_set_prop_pd_active(struct smb_charger *chg,
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int smblib_set_prop_ship_mode(struct smb_charger *chg,
|
||||||
|
const union power_supply_propval *val)
|
||||||
|
{
|
||||||
|
int rc;
|
||||||
|
|
||||||
|
smblib_dbg(chg, PR_MISC, "Set ship mode: %d!!\n", !!val->intval);
|
||||||
|
|
||||||
|
rc = smblib_masked_write(chg, SHIP_MODE_REG, SHIP_MODE_EN_BIT,
|
||||||
|
!!val->intval ? SHIP_MODE_EN_BIT : 0);
|
||||||
|
if (rc < 0)
|
||||||
|
dev_err(chg->dev, "Couldn't %s ship mode, rc=%d\n",
|
||||||
|
!!val->intval ? "enable" : "disable", rc);
|
||||||
|
|
||||||
|
return rc;
|
||||||
|
}
|
||||||
|
|
||||||
int smblib_reg_block_update(struct smb_charger *chg,
|
int smblib_reg_block_update(struct smb_charger *chg,
|
||||||
struct reg_info *entry)
|
struct reg_info *entry)
|
||||||
{
|
{
|
||||||
|
|
|
@ -358,9 +358,10 @@ int smblib_set_prop_pd_active(struct smb_charger *chg,
|
||||||
const union power_supply_propval *val);
|
const union power_supply_propval *val);
|
||||||
int smblib_set_prop_pd_in_hard_reset(struct smb_charger *chg,
|
int smblib_set_prop_pd_in_hard_reset(struct smb_charger *chg,
|
||||||
const union power_supply_propval *val);
|
const union power_supply_propval *val);
|
||||||
|
|
||||||
int smblib_get_prop_slave_current_now(struct smb_charger *chg,
|
int smblib_get_prop_slave_current_now(struct smb_charger *chg,
|
||||||
union power_supply_propval *val);
|
union power_supply_propval *val);
|
||||||
|
int smblib_set_prop_ship_mode(struct smb_charger *chg,
|
||||||
|
const union power_supply_propval *val);
|
||||||
|
|
||||||
int smblib_validate_initial_typec_legacy_status(struct smb_charger *chg);
|
int smblib_validate_initial_typec_legacy_status(struct smb_charger *chg);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue