FROMGIT: usb: dwc3: add an alternate path in vbus_draw callback

This patch adds an alternate path in vbus_draw callback through
power supply property POWER_SUPPLY_PROP_INPUT_CURRENT_LIMIT.

Signed-off-by: Ray Chi <raychi@google.com>
Link: https://lore.kernel.org/r/20210222115149.3606776-3-raychi@google.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
(cherry picked from commit effcaf3f59b5557b0423f4b0d64df49658a9ec64
 https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git usb-next)
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Change-Id: Id0b67ec0c4f811fdde441250a5d15f4aa1978d7b
This commit is contained in:
Ray Chi
2021-02-22 19:51:49 +08:00
committed by Greg Kroah-Hartman
parent 790c8081d9
commit e82f5e70b0

View File

@@ -2532,11 +2532,19 @@ static void dwc3_gadget_set_ssp_rate(struct usb_gadget *g,
static int dwc3_gadget_vbus_draw(struct usb_gadget *g, unsigned int mA)
{
struct dwc3 *dwc = gadget_to_dwc(g);
union power_supply_propval val = {0};
int ret;
if (dwc->usb2_phy)
return usb_phy_set_power(dwc->usb2_phy, mA);
return 0;
if (!dwc->usb_psy)
return -EOPNOTSUPP;
val.intval = mA;
ret = power_supply_set_property(dwc->usb_psy, POWER_SUPPLY_PROP_INPUT_CURRENT_LIMIT, &val);
return ret;
}
static const struct usb_gadget_ops dwc3_gadget_ops = {