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

Commit 8f7c5d5c authored by Subbaraman Narayanamurthy's avatar Subbaraman Narayanamurthy
Browse files

power: supply: qti_battery_charger: Allow ICL to be set only for SDP



Input Current Limit (ICL) needs to be set only for SDP and not
for other charger types. Add that logic.

Change-Id: Ib48acf5666ea4190b7a11c27ab9cefbb534632fb
Signed-off-by: default avatarSubbaraman Narayanamurthy <subbaram@codeaurora.org>
parent 3a82802e
Loading
Loading
Loading
Loading
+10 −2
Original line number Diff line number Diff line
@@ -504,9 +504,18 @@ static const struct power_supply_desc wls_psy_desc = {

static int usb_psy_set_icl(struct battery_chg_dev *bcdev, u32 prop_id, int val)
{
	struct psy_state *pst = &bcdev->psy_list[PSY_TYPE_USB];
	u32 temp;
	int rc;

	rc = read_property_id(bcdev, pst, USB_ADAP_TYPE);
	if (rc < 0)
		return rc;

	/* Allow this only for SDP and not for other charger types */
	if (pst->prop[USB_ADAP_TYPE] != POWER_SUPPLY_USB_TYPE_SDP)
		return -EINVAL;

	/*
	 * Input current limit (ICL) can be set by different clients. E.g. USB
	 * driver can request for a current of 500/900 mA depending on the
@@ -518,8 +527,7 @@ static int usb_psy_set_icl(struct battery_chg_dev *bcdev, u32 prop_id, int val)
	if (val < 0)
		temp = UINT_MAX;

	rc = write_property_id(bcdev, &bcdev->psy_list[PSY_TYPE_USB], prop_id,
				temp);
	rc = write_property_id(bcdev, pst, prop_id, temp);
	if (!rc)
		pr_debug("Set ICL to %u\n", temp);