Skip to content

Commit

Permalink
power: qpnp-smbcharger: Fix charging rates
Browse files Browse the repository at this point in the history
Change-Id: d922bb865fe8743a86e467e38252e68213d951c4
Signed-off-by: TogoFire <togofire@mailfence.com>
  • Loading branch information
Umang96 authored and TogoFire committed Mar 13, 2023
1 parent af8c390 commit 7db6c98
Showing 1 changed file with 15 additions and 15 deletions.
30 changes: 15 additions & 15 deletions drivers/power/supply/qcom/qpnp-smbcharger.c
Original file line number Diff line number Diff line change
Expand Up @@ -1642,15 +1642,15 @@ static int smbchg_set_high_usb_chg_current(struct smbchg_chip *chip,

rc = smbchg_masked_write(chip, chip->usb_chgpth_base + CMD_IL,
USBIN_MODE_CHG_BIT | USB51_MODE_BIT | ICL_OVERRIDE_BIT,
USBIN_LIMITED_MODE | USB51_100MA | ICL_OVERRIDE_BIT);
USBIN_LIMITED_MODE | USB51_500MA | ICL_OVERRIDE_BIT);
if (rc < 0) {
pr_err("Couldn't set ICL_OVERRIDE rc=%d\n", rc);
return rc;
}

pr_smb(PR_STATUS,
"Forcing 100mA current limit\n");
chip->usb_max_current_ma = CURRENT_100_MA;
"Forcing 500mA current limit\n");
chip->usb_max_current_ma = CURRENT_500_MA;
return rc;
}

Expand All @@ -1659,19 +1659,19 @@ static int smbchg_set_high_usb_chg_current(struct smbchg_chip *chip,
if (i < 0) {
dev_err(chip->dev,
"Cannot find %dma current_table using %d\n",
current_ma, CURRENT_150_MA);
current_ma, CURRENT_500_MA);

rc = smbchg_sec_masked_write(chip,
chip->usb_chgpth_base + CHGPTH_CFG,
CFG_USB_2_3_SEL_BIT, CFG_USB_3);
CFG_USB_2_3_SEL_BIT, CFG_USB_2);
rc |= smbchg_masked_write(chip, chip->usb_chgpth_base + CMD_IL,
USBIN_MODE_CHG_BIT | USB51_MODE_BIT,
USBIN_LIMITED_MODE | USB51_100MA);
USBIN_LIMITED_MODE | USB51_500MA);
if (rc < 0)
dev_err(chip->dev, "Couldn't set %dmA rc=%d\n",
CURRENT_150_MA, rc);
else
chip->usb_max_current_ma = 150;
chip->usb_max_current_ma = 500;
return rc;
}

Expand Down Expand Up @@ -1714,7 +1714,7 @@ static int smbchg_set_usb_current_max(struct smbchg_chip *chip,
}
pr_smb(PR_STATUS, "USB current_ma = %d\n", current_ma);

if (current_ma <= SUSPEND_CURRENT_MA) {
if (current_ma == SUSPEND_CURRENT_MA) {
/* suspend the usb if current <= 2mA */
rc = vote(chip->usb_suspend_votable, USB_EN_VOTER, true, 0);
chip->usb_max_current_ma = 0;
Expand All @@ -1727,7 +1727,7 @@ static int smbchg_set_usb_current_max(struct smbchg_chip *chip,
case POWER_SUPPLY_TYPE_USB:
if ((current_ma < CURRENT_150_MA) &&
(chip->wa_flags & SMBCHG_USB100_WA))
current_ma = CURRENT_150_MA;
current_ma = CURRENT_500_MA;

if (current_ma < CURRENT_150_MA) {
/* force 100mA */
Expand All @@ -1741,7 +1741,7 @@ static int smbchg_set_usb_current_max(struct smbchg_chip *chip,
rc = smbchg_masked_write(chip,
chip->usb_chgpth_base + CMD_IL,
USBIN_MODE_CHG_BIT | USB51_MODE_BIT,
USBIN_LIMITED_MODE | USB51_100MA);
USBIN_LIMITED_MODE | USB51_500MA);
if (rc < 0) {
pr_err("Couldn't set CMD_IL rc = %d\n", rc);
goto out;
Expand All @@ -1752,15 +1752,15 @@ static int smbchg_set_usb_current_max(struct smbchg_chip *chip,
if (current_ma == CURRENT_150_MA) {
rc = smbchg_sec_masked_write(chip,
chip->usb_chgpth_base + CHGPTH_CFG,
CFG_USB_2_3_SEL_BIT, CFG_USB_3);
CFG_USB_2_3_SEL_BIT, CFG_USB_2);
if (rc < 0) {
pr_err("Couldn't set CHGPTH_CFG rc = %d\n", rc);
goto out;
}
rc = smbchg_masked_write(chip,
chip->usb_chgpth_base + CMD_IL,
USBIN_MODE_CHG_BIT | USB51_MODE_BIT,
USBIN_LIMITED_MODE | USB51_100MA);
USBIN_LIMITED_MODE | USB51_500MA);
if (rc < 0) {
pr_err("Couldn't set CMD_IL rc = %d\n", rc);
goto out;
Expand Down Expand Up @@ -4512,7 +4512,7 @@ static int smbchg_set_optimal_charging_mode(struct smbchg_chip *chip, int type)
return 0;
}

#define DEFAULT_SDP_MA 100
#define DEFAULT_SDP_MA 500
#define DEFAULT_CDP_MA 1500
enum power_supply_type hvdcp_flag = 0;
static int smbchg_change_usb_supply_type(struct smbchg_chip *chip,
Expand Down Expand Up @@ -5044,10 +5044,10 @@ static void increment_aicl_count(struct smbchg_chip *chip)

/* Vote 100mA current limit */
rc = vote(chip->usb_icl_votable, WEAK_CHARGER_ICL_VOTER,
true, CURRENT_100_MA);
true, CURRENT_500_MA);
if (rc < 0) {
pr_err("Can't vote %d current limit rc=%d\n",
CURRENT_100_MA, rc);
CURRENT_500_MA, rc);
}

chip->aicl_irq_count = 0;
Expand Down

0 comments on commit 7db6c98

Please sign in to comment.