[PATCH v2 2/2] usb: gadget: composite: Draw 100mA current if not configured
From: Prashanth K
Date: Thu Feb 23 2023 - 03:58:11 EST
Currently we don't change the current value if device isn't in
configured state. But the battery charging specification says,
device can draw up to 100mA of current if its in unconfigured
state. Hence add a Vbus_draw work in composite_resume to draw
100mA if the device isn't configured.
Signed-off-by: Prashanth K <quic_prashk@xxxxxxxxxxx>
---
drivers/usb/gadget/composite.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/usb/gadget/composite.c b/drivers/usb/gadget/composite.c
index 403563c..23b7347a8 100644
--- a/drivers/usb/gadget/composite.c
+++ b/drivers/usb/gadget/composite.c
@@ -2449,6 +2449,9 @@ void composite_resume(struct usb_gadget *gadget)
usb_gadget_clear_selfpowered(gadget);
usb_gadget_vbus_draw(gadget, maxpower);
+ } else {
+ maxpower = min(CONFIG_USB_GADGET_VBUS_DRAW, 100U)
+ usb_gadget_vbus_draw(gadget, maxpower);
}
cdev->suspended = 0;
--
2.7.4