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

Commit 9358212a authored by Azhar Shaikh's avatar Azhar Shaikh Committed by Gerrit - the friendly Code Review server
Browse files

usb: dwc3: Change the current drawn for HVDCP to 1800mA



Currently HVDCP charger is detected as a DCP charger and it draws 1500mA
current. Change the current drawn for HVDCP as 1800mA and keep it as it
is for DCP i.e. 1500mA

Change-Id: I2a04e124764c6290b3c16d447a56ac7de89125b4
Signed-off-by: default avatarAzhar Shaikh <azhars@codeaurora.org>
parent 59ce3ca1
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -2238,6 +2238,9 @@ static int dwc3_msm_power_set_property_usb(struct power_supply *psy,
{
	struct dwc3_msm *mdwc = container_of(psy, struct dwc3_msm,
								usb_psy);
	struct dwc3 *dwc = platform_get_drvdata(mdwc->dwc3);
	struct dwc3_otg *dotg = dwc->dotg;
	struct usb_phy *phy = dotg->otg.phy;

	switch (psp) {
	case POWER_SUPPLY_PROP_USB_OTG:
@@ -2292,8 +2295,11 @@ static int dwc3_msm_power_set_property_usb(struct power_supply *psy,
			mdwc->charger.chg_type = DWC3_SDP_CHARGER;
			break;
		case POWER_SUPPLY_TYPE_USB_DCP:
			mdwc->charger.chg_type = DWC3_DCP_CHARGER;
			break;
		case POWER_SUPPLY_TYPE_USB_HVDCP:
			mdwc->charger.chg_type = DWC3_DCP_CHARGER;
			usb_phy_set_power(phy, DWC3_HVDCP_CHG_MAX);
			break;
		case POWER_SUPPLY_TYPE_USB_CDP:
			mdwc->charger.chg_type = DWC3_CDP_CHARGER;
+18 −10
Original line number Diff line number Diff line
@@ -395,7 +395,7 @@ static void dwc3_otg_notify_host_mode(struct usb_otg *otg, int host_mode)

static int dwc3_otg_set_power(struct usb_phy *phy, unsigned mA)
{
	static int power_supply_type;
	enum power_supply_property power_supply_type;
	struct dwc3_otg *dotg = container_of(phy->otg, struct dwc3_otg, otg);


@@ -407,6 +407,13 @@ static int dwc3_otg_set_power(struct usb_phy *phy, unsigned mA)
	if (dotg->charger->charging_disabled)
		return 0;

	if (dotg->charger->chg_type != DWC3_INVALID_CHARGER) {
		dev_dbg(phy->dev,
			"SKIP setting power supply type again,chg_type = %d\n",
			dotg->charger->chg_type);
		goto skip_psy_type;
	}

	if (dotg->charger->chg_type == DWC3_SDP_CHARGER)
		power_supply_type = POWER_SUPPLY_TYPE_USB;
	else if (dotg->charger->chg_type == DWC3_CDP_CHARGER)
@@ -419,6 +426,8 @@ static int dwc3_otg_set_power(struct usb_phy *phy, unsigned mA)

	power_supply_set_supply_type(dotg->psy, power_supply_type);

skip_psy_type:

	if (dotg->charger->chg_type == DWC3_CDP_CHARGER)
		mA = DWC3_IDEV_CHG_MAX;

@@ -427,20 +436,19 @@ static int dwc3_otg_set_power(struct usb_phy *phy, unsigned mA)

	dev_info(phy->dev, "Avail curr from USB = %u\n", mA);

	if (dotg->charger->max_power <= 2 && mA > 2) {
		/* Enable charging */
		if (power_supply_set_online(dotg->psy, true))
			goto psy_error;
		if (power_supply_set_current_limit(dotg->psy, 1000*mA))
			goto psy_error;
	} else if (dotg->charger->max_power > 0 && (mA == 0 || mA == 2)) {
	if (dotg->charger->max_power > 0 && (mA == 0 || mA == 2)) {
		/* Disable charging */
		if (power_supply_set_online(dotg->psy, false))
			goto psy_error;
	} else {
		/* Enable charging */
		if (power_supply_set_online(dotg->psy, true))
			goto psy_error;
	}

	/* Set max current limit in uA */
	if (power_supply_set_current_limit(dotg->psy, 1000*mA))
		goto psy_error;
	}

	power_supply_changed(dotg->psy);
	dotg->charger->max_power = mA;
+1 −1
Original line number Diff line number Diff line
@@ -23,6 +23,7 @@
#include "power.h"

#define DWC3_IDEV_CHG_MAX 1500
#define DWC3_HVDCP_CHG_MAX 1800

struct dwc3_charger;

@@ -119,5 +120,4 @@ struct dwc3_ext_xceiv {
/* for external transceiver driver */
extern int dwc3_set_ext_xceiv(struct usb_otg *otg,
				struct dwc3_ext_xceiv *ext_xceiv);

#endif /* __LINUX_USB_DWC3_OTG_H */