MLK-11340-31 usb: chipidea: udc: add OTG status request handling
authorLi Jun <b47624@freescale.com>
Mon, 23 Jun 2014 07:50:50 +0000 (15:50 +0800)
committerNitin Garg <nitin.garg@nxp.com>
Mon, 19 Mar 2018 19:46:56 +0000 (14:46 -0500)
Peripheral answers OTG status selector request from host according to
host request flag of gadget, length is 1. this flag may be set by application
via sysfs.

Signed-off-by: Li Jun <b47624@freescale.com>
(cherry picked from commit c08edfce9dded6a49d3127179d5f0a036ddb99aa)

drivers/usb/chipidea/udc.c

index 6a15b72..2baa017 100644 (file)
@@ -873,7 +873,10 @@ __acquires(hwep->lock)
                return -ENOMEM;
 
        req->complete = isr_get_status_complete;
-       req->length   = 2;
+       if (setup->wIndex == OTG_STS_SELECTOR)
+               req->length = 1;
+       else
+               req->length = 2;
        req->buf      = kzalloc(req->length, gfp_flags);
        if (req->buf == NULL) {
                retval = -ENOMEM;
@@ -881,8 +884,16 @@ __acquires(hwep->lock)
        }
 
        if ((setup->bRequestType & USB_RECIP_MASK) == USB_RECIP_DEVICE) {
-               *(u16 *)req->buf = (ci->remote_wakeup << 1) |
-                       ci->gadget.is_selfpowered;
+               if ((setup->wIndex == OTG_STS_SELECTOR) &&
+                                       ci_otg_is_fsm_mode(ci)) {
+                       if (ci->gadget.host_request_flag)
+                               *(u8 *)req->buf = HOST_REQUEST_FLAG;
+                       else
+                               *(u8 *)req->buf = 0;
+               } else {
+                       *(u16 *)req->buf = (ci->remote_wakeup << 1) |
+                               ci->gadget.is_selfpowered;
+               }
        } else if ((setup->bRequestType & USB_RECIP_MASK) \
                   == USB_RECIP_ENDPOINT) {
                dir = (le16_to_cpu(setup->wIndex) & USB_ENDPOINT_DIR_MASK) ?
@@ -1077,8 +1088,9 @@ __acquires(ci->lock)
                    type != (USB_DIR_IN|USB_RECIP_ENDPOINT) &&
                    type != (USB_DIR_IN|USB_RECIP_INTERFACE))
                        goto delegate;
-               if (le16_to_cpu(req.wLength) != 2 ||
-                   le16_to_cpu(req.wValue)  != 0)
+               if ((le16_to_cpu(req.wLength) != 2 &&
+                       le16_to_cpu(req.wLength) != 1) ||
+                               le16_to_cpu(req.wValue) != 0)
                        break;
                err = isr_get_status_response(ci, &req);
                break;