Commit a9548c55 authored by John Youn's avatar John Youn Committed by Felipe Balbi

usb: gadget: Allow a non-SuperSpeed gadget to support LPM

This commit allows a gadget that does not support SuperSpeed to indicate
that it supports LPM. It does this by setting the 'lpm_capable' flag in
the gadget structure.

If a gadget sets this, the composite gadget framework will set the
bcdUSB to 0x0201 to indicate that this supports BOS descriptors, and
also return a USB 2.0 Extension descriptor as part of the BOS descriptor
set.

See USB 2.0 LPM ECN Section 3.
Signed-off-by: default avatarJohn Youn <johnyoun@synopsys.com>
Signed-off-by: default avatarSevak Arakelyan <sevaka@synopsys.com>
Signed-off-by: default avatarFelipe Balbi <felipe.balbi@linux.intel.com>
parent 0b67a6be
...@@ -1608,6 +1608,9 @@ composite_setup(struct usb_gadget *gadget, const struct usb_ctrlrequest *ctrl) ...@@ -1608,6 +1608,9 @@ composite_setup(struct usb_gadget *gadget, const struct usb_ctrlrequest *ctrl)
cdev->desc.bcdUSB = cpu_to_le16(0x0210); cdev->desc.bcdUSB = cpu_to_le16(0x0210);
} }
} else { } else {
if (gadget->lpm_capable)
cdev->desc.bcdUSB = cpu_to_le16(0x0201);
else
cdev->desc.bcdUSB = cpu_to_le16(0x0200); cdev->desc.bcdUSB = cpu_to_le16(0x0200);
} }
...@@ -1639,7 +1642,8 @@ composite_setup(struct usb_gadget *gadget, const struct usb_ctrlrequest *ctrl) ...@@ -1639,7 +1642,8 @@ composite_setup(struct usb_gadget *gadget, const struct usb_ctrlrequest *ctrl)
value = min(w_length, (u16) value); value = min(w_length, (u16) value);
break; break;
case USB_DT_BOS: case USB_DT_BOS:
if (gadget_is_superspeed(gadget)) { if (gadget_is_superspeed(gadget) ||
gadget->lpm_capable) {
value = bos_desc(cdev); value = bos_desc(cdev);
value = min(w_length, (u16) value); value = min(w_length, (u16) value);
} }
......
...@@ -352,6 +352,8 @@ struct usb_gadget_ops { ...@@ -352,6 +352,8 @@ struct usb_gadget_ops {
* @deactivated: True if gadget is deactivated - in deactivated state it cannot * @deactivated: True if gadget is deactivated - in deactivated state it cannot
* be connected. * be connected.
* @connected: True if gadget is connected. * @connected: True if gadget is connected.
* @lpm_capable: If the gadget max_speed is FULL or HIGH, this flag
* indicates that it supports LPM as per the LPM ECN & errata.
* *
* Gadgets have a mostly-portable "gadget driver" implementing device * Gadgets have a mostly-portable "gadget driver" implementing device
* functions, handling all usb configurations and interfaces. Gadget * functions, handling all usb configurations and interfaces. Gadget
...@@ -404,6 +406,7 @@ struct usb_gadget { ...@@ -404,6 +406,7 @@ struct usb_gadget {
unsigned is_selfpowered:1; unsigned is_selfpowered:1;
unsigned deactivated:1; unsigned deactivated:1;
unsigned connected:1; unsigned connected:1;
unsigned lpm_capable:1;
}; };
#define work_to_gadget(w) (container_of((w), struct usb_gadget, work)) #define work_to_gadget(w) (container_of((w), struct usb_gadget, work))
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment