Revert "smb138x: use chg src bit to disable parallel charger"
This reverts commit 0f0e36134d
("smb138x:
use chg src bit to disable parallel charger)
This is not required, since smb1355 support is moved to its own driver.
Change-Id: I1bd454030d29195f03be132d167ec8294169b9d5
Signed-off-by: Abhijeet Dharmapurikar <adharmap@codeaurora.org>
This commit is contained in:
parent
9d0fdc3738
commit
df7b29506b
1 changed files with 32 additions and 54 deletions
|
@ -598,26 +598,6 @@ static enum power_supply_property smb1355_parallel_props[] = {
|
||||||
POWER_SUPPLY_PROP_CHARGER_TEMP_MAX,
|
POWER_SUPPLY_PROP_CHARGER_TEMP_MAX,
|
||||||
};
|
};
|
||||||
|
|
||||||
static int smb138x_get_parallel_charging(struct smb138x *chip, int *disabled)
|
|
||||||
{
|
|
||||||
struct smb_charger *chg = &chip->chg;
|
|
||||||
int rc = 0;
|
|
||||||
u8 cfg2;
|
|
||||||
|
|
||||||
rc = smblib_read(chg, CHGR_CFG2_REG, &cfg2);
|
|
||||||
if (rc < 0) {
|
|
||||||
pr_err("Couldn't read en_cmg_reg rc=%d\n", rc);
|
|
||||||
return rc;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (cfg2 & CHG_EN_SRC_BIT)
|
|
||||||
*disabled = 0;
|
|
||||||
else
|
|
||||||
*disabled = 1;
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int smb138x_parallel_get_prop(struct power_supply *psy,
|
static int smb138x_parallel_get_prop(struct power_supply *psy,
|
||||||
enum power_supply_property prop,
|
enum power_supply_property prop,
|
||||||
union power_supply_propval *val)
|
union power_supply_propval *val)
|
||||||
|
@ -644,7 +624,7 @@ static int smb138x_parallel_get_prop(struct power_supply *psy,
|
||||||
val->intval = !(temp & DISABLE_CHARGING_BIT);
|
val->intval = !(temp & DISABLE_CHARGING_BIT);
|
||||||
break;
|
break;
|
||||||
case POWER_SUPPLY_PROP_INPUT_SUSPEND:
|
case POWER_SUPPLY_PROP_INPUT_SUSPEND:
|
||||||
rc = smb138x_get_parallel_charging(chip, &val->intval);
|
rc = smblib_get_usb_suspend(chg, &val->intval);
|
||||||
break;
|
break;
|
||||||
case POWER_SUPPLY_PROP_INPUT_CURRENT_LIMITED:
|
case POWER_SUPPLY_PROP_INPUT_CURRENT_LIMITED:
|
||||||
if ((chip->dt.pl_mode == POWER_SUPPLY_PL_USBIN_USBIN)
|
if ((chip->dt.pl_mode == POWER_SUPPLY_PL_USBIN_USBIN)
|
||||||
|
@ -714,33 +694,28 @@ static int smb138x_parallel_get_prop(struct power_supply *psy,
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int smb138x_set_parallel_charging(struct smb138x *chip, bool disable)
|
static int smb138x_set_parallel_suspend(struct smb138x *chip, bool suspend)
|
||||||
{
|
{
|
||||||
struct smb_charger *chg = &chip->chg;
|
struct smb_charger *chg = &chip->chg;
|
||||||
int rc = 0;
|
int rc = 0;
|
||||||
|
|
||||||
rc = smblib_masked_write(chg, WD_CFG_REG, WDOG_TIMER_EN_BIT,
|
rc = smblib_masked_write(chg, WD_CFG_REG, WDOG_TIMER_EN_BIT,
|
||||||
disable ? 0 : WDOG_TIMER_EN_BIT);
|
suspend ? 0 : WDOG_TIMER_EN_BIT);
|
||||||
if (rc < 0) {
|
if (rc < 0) {
|
||||||
pr_err("Couldn't %s watchdog rc=%d\n",
|
pr_err("Couldn't %s watchdog rc=%d\n",
|
||||||
disable ? "disable" : "enable", rc);
|
suspend ? "disable" : "enable", rc);
|
||||||
disable = true;
|
suspend = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
rc = smblib_masked_write(chg, USBIN_CMD_IL_REG, USBIN_SUSPEND_BIT,
|
||||||
* Configure charge enable for high polarity and
|
suspend ? USBIN_SUSPEND_BIT : 0);
|
||||||
* When disabling charging set it to cmd register control(cmd bit=0)
|
|
||||||
* When enabling charging set it to pin control
|
|
||||||
*/
|
|
||||||
rc = smblib_masked_write(chg, CHGR_CFG2_REG,
|
|
||||||
CHG_EN_POLARITY_BIT | CHG_EN_SRC_BIT,
|
|
||||||
disable ? 0 : CHG_EN_SRC_BIT);
|
|
||||||
if (rc < 0) {
|
if (rc < 0) {
|
||||||
pr_err("Couldn't configure charge enable source rc=%d\n", rc);
|
pr_err("Couldn't %s parallel charger rc=%d\n",
|
||||||
|
suspend ? "suspend" : "resume", rc);
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int smb138x_parallel_set_prop(struct power_supply *psy,
|
static int smb138x_parallel_set_prop(struct power_supply *psy,
|
||||||
|
@ -753,7 +728,7 @@ static int smb138x_parallel_set_prop(struct power_supply *psy,
|
||||||
|
|
||||||
switch (prop) {
|
switch (prop) {
|
||||||
case POWER_SUPPLY_PROP_INPUT_SUSPEND:
|
case POWER_SUPPLY_PROP_INPUT_SUSPEND:
|
||||||
rc = smb138x_set_parallel_charging(chip, (bool)val->intval);
|
rc = smb138x_set_parallel_suspend(chip, (bool)val->intval);
|
||||||
break;
|
break;
|
||||||
case POWER_SUPPLY_PROP_CURRENT_MAX:
|
case POWER_SUPPLY_PROP_CURRENT_MAX:
|
||||||
if ((chip->dt.pl_mode == POWER_SUPPLY_PL_USBIN_USBIN)
|
if ((chip->dt.pl_mode == POWER_SUPPLY_PL_USBIN_USBIN)
|
||||||
|
@ -971,25 +946,10 @@ static int smb138x_init_slave_hw(struct smb138x *chip)
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* disable the charging path when under s/w control */
|
/* suspend parallel charging */
|
||||||
rc = smblib_masked_write(chg, CHARGING_ENABLE_CMD_REG,
|
rc = smb138x_set_parallel_suspend(chip, true);
|
||||||
CHARGING_ENABLE_CMD_BIT, 0);
|
|
||||||
if (rc < 0) {
|
if (rc < 0) {
|
||||||
pr_err("Couldn't disable charging rc=%d\n", rc);
|
pr_err("Couldn't suspend parallel charging rc=%d\n", rc);
|
||||||
return rc;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* disable parallel charging path */
|
|
||||||
rc = smb138x_set_parallel_charging(chip, true);
|
|
||||||
if (rc < 0) {
|
|
||||||
pr_err("Couldn't disable parallel path rc=%d\n", rc);
|
|
||||||
return rc;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* unsuspend parallel charging */
|
|
||||||
rc = smblib_masked_write(chg, USBIN_CMD_IL_REG, USBIN_SUSPEND_BIT, 0);
|
|
||||||
if (rc < 0) {
|
|
||||||
pr_err("Couldn't unsuspend parallel charging rc=%d\n", rc);
|
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1000,6 +960,24 @@ static int smb138x_init_slave_hw(struct smb138x *chip)
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* enable the charging path */
|
||||||
|
rc = smblib_masked_write(chg, CHARGING_ENABLE_CMD_REG,
|
||||||
|
CHARGING_ENABLE_CMD_BIT,
|
||||||
|
CHARGING_ENABLE_CMD_BIT);
|
||||||
|
if (rc < 0) {
|
||||||
|
pr_err("Couldn't enable charging rc=%d\n", rc);
|
||||||
|
return rc;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* configure charge enable for software control; active high */
|
||||||
|
rc = smblib_masked_write(chg, CHGR_CFG2_REG,
|
||||||
|
CHG_EN_POLARITY_BIT | CHG_EN_SRC_BIT, 0);
|
||||||
|
if (rc < 0) {
|
||||||
|
pr_err("Couldn't configure charge enable source rc=%d\n",
|
||||||
|
rc);
|
||||||
|
return rc;
|
||||||
|
}
|
||||||
|
|
||||||
/* enable parallel current sensing */
|
/* enable parallel current sensing */
|
||||||
rc = smblib_masked_write(chg, CFG_REG,
|
rc = smblib_masked_write(chg, CFG_REG,
|
||||||
VCHG_EN_CFG_BIT, VCHG_EN_CFG_BIT);
|
VCHG_EN_CFG_BIT, VCHG_EN_CFG_BIT);
|
||||||
|
|
Loading…
Add table
Reference in a new issue