Merge "smb-lib: introduce votable to disable charging"
This commit is contained in:
commit
14051dfb5d
4 changed files with 31 additions and 19 deletions
|
@ -627,7 +627,7 @@ static int smb2_init_hw(struct smb2 *chip)
|
|||
}
|
||||
|
||||
/* enable the charging path */
|
||||
rc = smblib_enable_charging(chg, true);
|
||||
rc = vote(chg->chg_disable_votable, DEFAULT_VOTER, false, 0);
|
||||
if (rc < 0) {
|
||||
dev_err(chg->dev, "Couldn't enable charging rc=%d\n", rc);
|
||||
return rc;
|
||||
|
|
|
@ -210,22 +210,6 @@ static const struct apsd_result *smblib_get_apsd_result(struct smb_charger *chg)
|
|||
* REGISTER SETTERS *
|
||||
********************/
|
||||
|
||||
int smblib_enable_charging(struct smb_charger *chg, bool enable)
|
||||
{
|
||||
int rc = 0;
|
||||
|
||||
rc = smblib_masked_write(chg, CHARGING_ENABLE_CMD_REG,
|
||||
CHARGING_ENABLE_CMD_BIT,
|
||||
enable ? CHARGING_ENABLE_CMD_BIT : 0);
|
||||
if (rc < 0) {
|
||||
dev_err(chg->dev, "Couldn't %s charging rc=%d\n",
|
||||
enable ? "enable" : "disable", rc);
|
||||
return rc;
|
||||
}
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
int smblib_set_charge_param(struct smb_charger *chg,
|
||||
struct smb_chg_param *param, int val_u)
|
||||
{
|
||||
|
@ -606,6 +590,23 @@ static int smblib_pl_disable_vote_callback(struct votable *votable, void *data,
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int smblib_chg_disable_vote_callback(struct votable *votable, void *data,
|
||||
int chg_disable, const char *client)
|
||||
{
|
||||
struct smb_charger *chg = data;
|
||||
int rc;
|
||||
|
||||
rc = smblib_masked_write(chg, CHARGING_ENABLE_CMD_REG,
|
||||
CHARGING_ENABLE_CMD_BIT,
|
||||
chg_disable ? 0 : CHARGING_ENABLE_CMD_BIT);
|
||||
if (rc < 0) {
|
||||
dev_err(chg->dev, "Couldn't %s charging rc=%d\n",
|
||||
chg_disable ? "disable" : "enable", rc);
|
||||
return rc;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
/*****************
|
||||
* OTG REGULATOR *
|
||||
*****************/
|
||||
|
@ -1749,6 +1750,14 @@ int smblib_create_votables(struct smb_charger *chg)
|
|||
return rc;
|
||||
}
|
||||
|
||||
chg->chg_disable_votable = create_votable("CHG_DISABLE", VOTE_SET_ANY,
|
||||
smblib_chg_disable_vote_callback,
|
||||
chg);
|
||||
if (IS_ERR(chg->chg_disable_votable)) {
|
||||
rc = PTR_ERR(chg->chg_disable_votable);
|
||||
return rc;
|
||||
}
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
|
|
@ -113,6 +113,7 @@ struct smb_charger {
|
|||
struct votable *pd_allowed_votable;
|
||||
struct votable *awake_votable;
|
||||
struct votable *pl_disable_votable;
|
||||
struct votable *chg_disable_votable;
|
||||
|
||||
/* work */
|
||||
struct work_struct pl_detect_work;
|
||||
|
|
|
@ -564,7 +564,7 @@ static int smb138x_init_hw(struct smb138x *chip)
|
|||
}
|
||||
|
||||
/* enable the charging path */
|
||||
rc = smblib_enable_charging(chg, true);
|
||||
rc = vote(chg->chg_disable_votable, DEFAULT_VOTER, false, 0);
|
||||
if (rc < 0) {
|
||||
dev_err(chg->dev, "Couldn't enable charging rc=%d\n", rc);
|
||||
return rc;
|
||||
|
@ -857,7 +857,9 @@ static int smb138x_slave_probe(struct smb138x *chip)
|
|||
}
|
||||
|
||||
/* enable the charging path */
|
||||
rc = smblib_enable_charging(chg, true);
|
||||
rc = smblib_masked_write(chg, CHARGING_ENABLE_CMD_REG,
|
||||
CHARGING_ENABLE_CMD_BIT,
|
||||
CHARGING_ENABLE_CMD_BIT);
|
||||
if (rc < 0) {
|
||||
dev_err(chg->dev, "Couldn't enable charging rc=%d\n", rc);
|
||||
return rc;
|
||||
|
|
Loading…
Add table
Reference in a new issue