usb: langwell_udc: Add hnp polling support
authorHao Wu <hao.wu@intel.com>
Fri, 26 Aug 2011 10:55:05 +0000 (11:55 +0100)
committermgross <mark.gross@intel.com>
Wed, 9 Nov 2011 20:38:22 +0000 (12:38 -0800)
This patch adds get_status support for HNP polling in langwell_udc.

Change-Id: Ia700cb6a64d3c428de2fdd047960be6c98c1736b
Signed-off-by: Hao Wu <hao.wu@intel.com>
[Reapplied by hand due to other changes]
Signed-off-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
Signed-off-by: Alan Cox <alan@linux.intel.com>
drivers/usb/gadget/langwell_udc.c
include/linux/usb/ch9.h

index 5e2e575..b2fa281 100644 (file)
@@ -2131,14 +2131,23 @@ static void get_status(struct langwell_udc *dev, u8 request_type, u16 value,
        struct langwell_ep      *ep;
        u16     status_data = 0;        /* 16 bits cpu view status data */
        int     status = 0;
+       int     flag = 0;
 
        dev_vdbg(&dev->pdev->dev, "---> %s()\n", __func__);
 
        ep = &dev->ep[0];
 
        if ((request_type & USB_RECIP_MASK) == USB_RECIP_DEVICE) {
-               /* get device status */
-               status_data = dev->dev_status;
+               /* HNP polling for host_request_flag */
+               if (index == OTG_STATUS_SELECTOR) {
+                       status_data = dev->gadget.host_request_flag;
+                       flag = 1;
+
+                       dev_vdbg(&dev->pdev->dev,
+                               "request_flag 0x%x\n", status_data);
+
+               } else
+                       status_data = dev->dev_status;
        } else if ((request_type & USB_RECIP_MASK) == USB_RECIP_INTERFACE) {
                /* get interface status */
                status_data = 0;
@@ -2163,7 +2172,7 @@ static void get_status(struct langwell_udc *dev, u8 request_type, u16 value,
        /* fill in the reqest structure */
        *((u16 *) req->req.buf) = cpu_to_le16(status_data);
        req->ep = ep;
-       req->req.length = 2;
+       req->req.length = flag ? 1 : 2;
        req->req.status = -EINPROGRESS;
        req->req.actual = 0;
        req->req.complete = NULL;
index 0fd3fbd..6ec27fb 100644 (file)
 #define        TEST_FORCE_EN   5
 
 /*
+ * OTG 2.0
+ * Section 6.2 & 6.3
+ */
+#define         OTG_STATUS_SELECTOR    0xF000
+
+/*
  * New Feature Selectors as added by USB 3.0
  * See USB 3.0 spec Table 9-6
  */