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

Commit f2454873 authored by Harry Yang's avatar Harry Yang
Browse files

power: smb5-lib: use USB options in low ICL range



When USB ICL drops below 500mA, USB options show better input current
limit accuracy over USB high current mode. Make the change to always
try USB 2.0/3.0 options first for low ICL range, even for non-SDP
source type.

Change-Id: Iad5b369616b80e492de3daab10532e8cb2a67c82
Signed-off-by: default avatarHarry Yang <harryy@codeaurora.org>
parent 01697ba5
Loading
Loading
Loading
Loading
+11 −2
Original line number Original line Diff line number Diff line
@@ -1078,7 +1078,6 @@ static int set_sdp_current(struct smb_charger *chg, int icl_ua)
		icl_options = CFG_USB3P0_SEL_BIT | USB51_MODE_BIT;
		icl_options = CFG_USB3P0_SEL_BIT | USB51_MODE_BIT;
		break;
		break;
	default:
	default:
		smblib_err(chg, "ICL %duA isn't supported for SDP\n", icl_ua);
		return -EINVAL;
		return -EINVAL;
	}
	}


@@ -1164,7 +1163,17 @@ int smblib_set_icl_current(struct smb_charger *chg, int icl_ua)
			goto out;
			goto out;
		}
		}
	} else {
	} else {
		set_sdp_current(chg, 100000);
		/*
		 * Try USB 2.0/3,0 option first on USB path when maximum input
		 * current limit is 500mA or below for better accuracy; in case
		 * of error, proceed to use USB high-current mode.
		 */
		if (icl_ua <= USBIN_500MA) {
			rc = set_sdp_current(chg, icl_ua);
			if (rc >= 0)
				goto out;
		}

		rc = smblib_set_charge_param(chg, &chg->param.usb_icl, icl_ua);
		rc = smblib_set_charge_param(chg, &chg->param.usb_icl, icl_ua);
		if (rc < 0) {
		if (rc < 0) {
			smblib_err(chg, "Couldn't set HC ICL rc=%d\n", rc);
			smblib_err(chg, "Couldn't set HC ICL rc=%d\n", rc);