From 4203affa6806bd214666f3c4f65c1527c3cf9b3c Mon Sep 17 00:00:00 2001 From: Hao Wu Date: Fri, 26 Aug 2011 11:55:05 +0100 Subject: [PATCH] usb: langwell_udc: Add hnp polling support This patch adds get_status support for HNP polling in langwell_udc. Change-Id: Ia700cb6a64d3c428de2fdd047960be6c98c1736b Signed-off-by: Hao Wu [Reapplied by hand due to other changes] Signed-off-by: Heikki Krogerus Signed-off-by: Alan Cox --- drivers/usb/gadget/langwell_udc.c | 15 ++++++++++++--- include/linux/usb/ch9.h | 6 ++++++ 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/drivers/usb/gadget/langwell_udc.c b/drivers/usb/gadget/langwell_udc.c index 5e2e575..b2fa281 100644 --- a/drivers/usb/gadget/langwell_udc.c +++ b/drivers/usb/gadget/langwell_udc.c @@ -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; diff --git a/include/linux/usb/ch9.h b/include/linux/usb/ch9.h index 0fd3fbd..6ec27fb 100644 --- a/include/linux/usb/ch9.h +++ b/include/linux/usb/ch9.h @@ -134,6 +134,12 @@ #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 */ -- 2.7.4