Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 710f5052 authored by Subbaraman Narayanamurthy's avatar Subbaraman Narayanamurthy Committed by Abhijeet Dharmapurikar
Browse files

power: qpnp-smbcharger: fix suspend current misconfiguration



Commit 387cacdfdcfe0a ("power: qpnp-smbcharger: always set high
current when setting ICL")
tried fixing a problem where the APSD results couldn't be
overridden when setting lower currents like 500/900 mA.

However, it broke a special case handling the suspend current
configuration. Fix it.

CRs-Fixed: 844200
Change-Id: I02ff84d1e17ca6d714aed99c41c0399afefb71cc
Signed-off-by: default avatarSubbaraman Narayanamurthy <subbaram@codeaurora.org>
Signed-off-by: default avatarAbhijeet Dharmapurikar <adharmap@codeaurora.org>
parent 8b54a5a1
Loading
Loading
Loading
Loading
+4 −8
Original line number Diff line number Diff line
@@ -1401,7 +1401,7 @@ static int smbchg_set_high_usb_chg_current(struct smbchg_chip *chip,
static int smbchg_set_usb_current_max(struct smbchg_chip *chip,
							int current_ma)
{
	int rc;
	int rc = 0;
	bool changed;

	if (!chip->batt_present) {
@@ -1429,7 +1429,6 @@ static int smbchg_set_usb_current_max(struct smbchg_chip *chip,
					USBIN_MODE_CHG_BIT | USB51_MODE_BIT,
					USBIN_LIMITED_MODE | USB51_100MA);
		chip->usb_max_current_ma = 100;
		goto out;
	}
	/* specific current values */
	if (current_ma == CURRENT_150_MA) {
@@ -1440,7 +1439,6 @@ static int smbchg_set_usb_current_max(struct smbchg_chip *chip,
					USBIN_MODE_CHG_BIT | USB51_MODE_BIT,
					USBIN_LIMITED_MODE | USB51_100MA);
		chip->usb_max_current_ma = 150;
		goto out;
	}
	if (current_ma == CURRENT_500_MA) {
		rc = smbchg_sec_masked_write(chip,
@@ -1450,7 +1448,6 @@ static int smbchg_set_usb_current_max(struct smbchg_chip *chip,
					USBIN_MODE_CHG_BIT | USB51_MODE_BIT,
					USBIN_LIMITED_MODE | USB51_500MA);
		chip->usb_max_current_ma = 500;
		goto out;
	}
	if (current_ma == CURRENT_900_MA) {
		rc = smbchg_sec_masked_write(chip,
@@ -1460,16 +1457,15 @@ static int smbchg_set_usb_current_max(struct smbchg_chip *chip,
					USBIN_MODE_CHG_BIT | USB51_MODE_BIT,
					USBIN_LIMITED_MODE | USB51_500MA);
		chip->usb_max_current_ma = 900;
		goto out;
	}

out:
	rc = smbchg_set_high_usb_chg_current(chip, current_ma);
	pr_smb(PR_STATUS, "usb current set to %d mA\n",
			chip->usb_max_current_ma);
	if (rc < 0)
		dev_err(chip->dev,
			"Couldn't set %dmA rc = %d\n", current_ma, rc);
out:
	pr_smb(PR_STATUS, "usb current set to %d mA\n",
			chip->usb_max_current_ma);
	return rc;
}