Message ID | 20250120111702.3738161-1-prashanth.k@oss.qualcomm.com (mailing list archive) |
---|---|
State | New |
Headers | show |
Series | usb: gadget: Increase the limit of USB_GADGET_VBUS_DRAW to 900mA | expand |
On Mon, Jan 20, 2025 at 04:47:02PM +0530, Prashanth K wrote: > Currently CONFIG_USB_GADGET_VBUS_DRAW limits the maximum current > drawn from Vbus to be up to 500mA. However USB gadget operating > in SuperSpeed or higher can draw up to 900mA. Also, MaxPower in > ConfigFS takes its default value from this config. Hence increase > the allowed range of CONFIG_USB_GADGET_VBUS_DRAW to 900mA. Is this the sort of thing that really needs to be a Kconfig option? Why not make the decision at runtime, based on the needs of the gadget or function drivers and the connection speed? Alan Stern > Signed-off-by: Prashanth K <prashanth.k@oss.qualcomm.com> > --- > drivers/usb/gadget/Kconfig | 11 +++++++---- > 1 file changed, 7 insertions(+), 4 deletions(-) > > diff --git a/drivers/usb/gadget/Kconfig b/drivers/usb/gadget/Kconfig > index 76521555e3c1..904652c37385 100644 > --- a/drivers/usb/gadget/Kconfig > +++ b/drivers/usb/gadget/Kconfig > @@ -97,8 +97,8 @@ config USB_GADGET_DEBUG_FS > to conserve kernel memory, say "N". > > config USB_GADGET_VBUS_DRAW > - int "Maximum VBUS Power usage (2-500 mA)" > - range 2 500 > + int "Maximum VBUS Power usage (2-900 mA)" > + range 2 900 > default 2 > help > Some devices need to draw power from USB when they are > @@ -107,8 +107,11 @@ config USB_GADGET_VBUS_DRAW > such as an AC adapter or batteries. > > Enter the maximum power your device draws through USB, in > - milliAmperes. The permitted range of values is 2 - 500 mA; > - 0 mA would be legal, but can make some hosts misbehave. > + milliAmperes. The permitted range of values depends on the > + connection speed, for SuperSpeed and higher it's 2 - 900 mA, > + but connections with High-Speed or slower can draw power > + ranging from 2 - 500 mA; 0 mA would be legal, but can make > + some hosts misbehave. > > This value will be used except for system-specific gadget > drivers that have more specific information. > -- > 2.25.1 > >
On 20-01-25 08:17 pm, Alan Stern wrote: > On Mon, Jan 20, 2025 at 04:47:02PM +0530, Prashanth K wrote: >> Currently CONFIG_USB_GADGET_VBUS_DRAW limits the maximum current >> drawn from Vbus to be up to 500mA. However USB gadget operating >> in SuperSpeed or higher can draw up to 900mA. Also, MaxPower in >> ConfigFS takes its default value from this config. Hence increase >> the allowed range of CONFIG_USB_GADGET_VBUS_DRAW to 900mA. > > Is this the sort of thing that really needs to be a Kconfig option? Why > not make the decision at runtime, based on the needs of the gadget or > function drivers and the connection speed? > > Alan Stern > Right, set_config() in composite.c does this in runtime based on the values of MaxPower (from configFS), VBUS_DRAW defconfig and speed. If we don't set MaxPower from configFS, this config helps to set it during compile time. In fact MaxPower in configFS takes its default value from CONFIG_USB_GADGET_VBUS_DRAW . Sent this patch because Kconfig has this limitation where it's only allowing values upto 500mA. Regards, Prashanth K
diff --git a/drivers/usb/gadget/Kconfig b/drivers/usb/gadget/Kconfig index 76521555e3c1..904652c37385 100644 --- a/drivers/usb/gadget/Kconfig +++ b/drivers/usb/gadget/Kconfig @@ -97,8 +97,8 @@ config USB_GADGET_DEBUG_FS to conserve kernel memory, say "N". config USB_GADGET_VBUS_DRAW - int "Maximum VBUS Power usage (2-500 mA)" - range 2 500 + int "Maximum VBUS Power usage (2-900 mA)" + range 2 900 default 2 help Some devices need to draw power from USB when they are @@ -107,8 +107,11 @@ config USB_GADGET_VBUS_DRAW such as an AC adapter or batteries. Enter the maximum power your device draws through USB, in - milliAmperes. The permitted range of values is 2 - 500 mA; - 0 mA would be legal, but can make some hosts misbehave. + milliAmperes. The permitted range of values depends on the + connection speed, for SuperSpeed and higher it's 2 - 900 mA, + but connections with High-Speed or slower can draw power + ranging from 2 - 500 mA; 0 mA would be legal, but can make + some hosts misbehave. This value will be used except for system-specific gadget drivers that have more specific information.
Currently CONFIG_USB_GADGET_VBUS_DRAW limits the maximum current drawn from Vbus to be up to 500mA. However USB gadget operating in SuperSpeed or higher can draw up to 900mA. Also, MaxPower in ConfigFS takes its default value from this config. Hence increase the allowed range of CONFIG_USB_GADGET_VBUS_DRAW to 900mA. Signed-off-by: Prashanth K <prashanth.k@oss.qualcomm.com> --- drivers/usb/gadget/Kconfig | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-)