Thread (2 messages) 2 messages, 2 authors, 2021-07-20

Re: [PATCH] usb: gadget: composite: Allow bMaxPower=0 if self-powered

From: Felipe Balbi <balbi@kernel.org>
Date: 2021-07-20 09:32:25

Jack Pham [off-list ref] writes:
Currently the composite driver encodes the MaxPower field of
the configuration descriptor by reading the c->MaxPower of the
usb_configuration only if it is non-zero, otherwise it falls back
to using the value hard-coded in CONFIG_USB_GADGET_VBUS_DRAW.
However, there are cases when a configuration must explicitly set
bMaxPower to 0, particularly if its bmAttributes also has the
Self-Powered bit set, which is a valid combination.

This is specifically called out in the USB PD specification section
9.1, in which a PDUSB device "shall report zero in the bMaxPower
field after negotiating a mutually agreeable Contract", and also
verified by the USB Type-C Functional Test TD.4.10.2 Sink Power
Precedence Test.

The fix allows the c->MaxPower to be used for encoding the bMaxPower
even if it is 0, if the self-powered bit is also set.  An example
usage of this would be for a ConfigFS gadget to be dynamically
updated by userspace when the Type-C connection is determined to be
operating in Power Delivery mode.

Co-developed-by: Ronak Vijay Raheja <redacted>
Signed-off-by: Ronak Vijay Raheja <redacted>
Signed-off-by: Jack Pham <redacted>
Nice catch!

Acked-by: Felipe Balbi <balbi@kernel.org>

-- 
balbi

Attachments

Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help