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

Commit 196df007 authored by David Keitel's avatar David Keitel
Browse files

power/usb: fix USB suspend requests from USB



The USB suspend specification dictates that
only 2 mA may be drawn from a host.

All power supply framework properties are in
units of 10^-6. Thus the correct current
limit to request would be 2000 uA rather than 0.

Fix this in the relevant USB drivers. Also fix
qpnp-charger which currently looks for this 2 uA limit
rather than 2000 uA.

CRs-Fixed: 583273
Change-Id: I491e6180c0f1f2e38b745fe33970fdae70db2e24
Signed-off-by: default avatarDavid Keitel <dkeitel@codeaurora.org>
parent 7bbebd78
Loading
Loading
Loading
Loading
+5 −3
Original line number Diff line number Diff line
@@ -2511,6 +2511,7 @@ static int get_prop_online(struct qpnp_chg_chip *chip)
	return qpnp_chg_is_batfet_closed(chip);
}

#define USB_SUSPEND_UA	2000
static void
qpnp_batt_external_power_changed(struct power_supply *psy)
{
@@ -2534,9 +2535,10 @@ qpnp_batt_external_power_changed(struct power_supply *psy)

		chip->prev_usb_max_ma = ret.intval;

		if (ret.intval <= 2 && !chip->use_default_batt_values &&
		if (ret.intval <= USB_SUSPEND_UA &&
					!chip->use_default_batt_values &&
					get_prop_batt_present(chip)) {
			if (ret.intval ==  2)
			if (ret.intval == USB_SUSPEND_UA)
				qpnp_chg_usb_suspend_enable(chip, 1);
			qpnp_chg_iusbmax_set(chip, QPNP_CHG_I_MAX_MIN_100);
		} else {
+2 −2
Original line number Diff line number Diff line
@@ -555,8 +555,8 @@ static int dwc3_otg_set_power(struct usb_phy *phy, unsigned mA)
		/* Disable charging */
		if (power_supply_set_online(dotg->psy, false))
			goto psy_error;
		/* Set max current limit */
		if (power_supply_set_current_limit(dotg->psy, 0))
		/* Set max current limit in uA */
		if (power_supply_set_current_limit(dotg->psy, 1000*mA))
			goto psy_error;
	}

+2 −2
Original line number Diff line number Diff line
@@ -1406,8 +1406,8 @@ static int msm_otg_notify_power_supply(struct msm_otg *motg, unsigned mA)
		/* Disable charging */
		if (power_supply_set_online(psy, false))
			goto psy_error;
		/* Set max current limit */
		if (power_supply_set_current_limit(psy, 0))
		/* Set max current limit in uA */
		if (power_supply_set_current_limit(psy, 1000*mA))
			goto psy_error;
	} else {
		if (power_supply_set_online(psy, true))