diff options
author | Felipe Balbi <balbi@ti.com> | 2012-04-24 09:19:11 -0400 |
---|---|---|
committer | Felipe Balbi <balbi@ti.com> | 2012-05-02 02:42:56 -0400 |
commit | b09bb64239c83113b8b35fa6a1ecae43d8297eaa (patch) | |
tree | f7f765e01d4aea0422cd1cf4c586a0cd86ec995a /drivers/usb/dwc3 | |
parent | 93c309ded1f6d4d0ff210263e62693825d441819 (diff) |
usb: dwc3: gadget: implement Global Command support
This will be used by the ep0 layer for implementing
Set SEL Standard Request.
Signed-off-by: Felipe Balbi <balbi@ti.com>
Diffstat (limited to 'drivers/usb/dwc3')
-rw-r--r-- | drivers/usb/dwc3/core.h | 6 | ||||
-rw-r--r-- | drivers/usb/dwc3/gadget.c | 27 | ||||
-rw-r--r-- | drivers/usb/dwc3/gadget.h | 1 |
3 files changed, 32 insertions, 2 deletions
diff --git a/drivers/usb/dwc3/core.h b/drivers/usb/dwc3/core.h index 93f9973ad53e..42641ada9e2d 100644 --- a/drivers/usb/dwc3/core.h +++ b/drivers/usb/dwc3/core.h | |||
@@ -284,12 +284,14 @@ | |||
284 | #define DWC3_DGCMD_SET_ENDPOINT_NRDY 0x0c | 284 | #define DWC3_DGCMD_SET_ENDPOINT_NRDY 0x0c |
285 | #define DWC3_DGCMD_RUN_SOC_BUS_LOOPBACK 0x10 | 285 | #define DWC3_DGCMD_RUN_SOC_BUS_LOOPBACK 0x10 |
286 | 286 | ||
287 | #define DWC3_DGCMD_STATUS(n) (((n) >> 15) & 1) | ||
288 | #define DWC3_DGCMD_CMDACT (1 << 10) | ||
289 | |||
287 | /* Device Endpoint Command Register */ | 290 | /* Device Endpoint Command Register */ |
288 | #define DWC3_DEPCMD_PARAM_SHIFT 16 | 291 | #define DWC3_DEPCMD_PARAM_SHIFT 16 |
289 | #define DWC3_DEPCMD_PARAM(x) ((x) << DWC3_DEPCMD_PARAM_SHIFT) | 292 | #define DWC3_DEPCMD_PARAM(x) ((x) << DWC3_DEPCMD_PARAM_SHIFT) |
290 | #define DWC3_DEPCMD_GET_RSC_IDX(x) (((x) >> DWC3_DEPCMD_PARAM_SHIFT) & 0x7f) | 293 | #define DWC3_DEPCMD_GET_RSC_IDX(x) (((x) >> DWC3_DEPCMD_PARAM_SHIFT) & 0x7f) |
291 | #define DWC3_DEPCMD_STATUS_MASK (0x0f << 12) | 294 | #define DWC3_DEPCMD_STATUS(x) (((x) >> 15) & 1) |
292 | #define DWC3_DEPCMD_STATUS(x) (((x) & DWC3_DEPCMD_STATUS_MASK) >> 12) | ||
293 | #define DWC3_DEPCMD_HIPRI_FORCERM (1 << 11) | 295 | #define DWC3_DEPCMD_HIPRI_FORCERM (1 << 11) |
294 | #define DWC3_DEPCMD_CMDACT (1 << 10) | 296 | #define DWC3_DEPCMD_CMDACT (1 << 10) |
295 | #define DWC3_DEPCMD_CMDIOC (1 << 8) | 297 | #define DWC3_DEPCMD_CMDIOC (1 << 8) |
diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c index 906db570ef4f..158d396d0d0c 100644 --- a/drivers/usb/dwc3/gadget.c +++ b/drivers/usb/dwc3/gadget.c | |||
@@ -276,6 +276,33 @@ static const char *dwc3_gadget_ep_cmd_string(u8 cmd) | |||
276 | } | 276 | } |
277 | } | 277 | } |
278 | 278 | ||
279 | int dwc3_send_gadget_generic_command(struct dwc3 *dwc, int cmd, u32 param) | ||
280 | { | ||
281 | u32 timeout = 500; | ||
282 | u32 reg; | ||
283 | |||
284 | dwc3_writel(dwc->regs, DWC3_DGCMDPAR, param); | ||
285 | dwc3_writel(dwc->regs, DWC3_DGCMD, cmd | DWC3_DGCMD_CMDACT); | ||
286 | |||
287 | do { | ||
288 | reg = dwc3_readl(dwc->regs, DWC3_DGCMD); | ||
289 | if (!(reg & DWC3_DGCMD_CMDACT)) { | ||
290 | dev_vdbg(dwc->dev, "Command Complete --> %d\n", | ||
291 | DWC3_DGCMD_STATUS(reg)); | ||
292 | return 0; | ||
293 | } | ||
294 | |||
295 | /* | ||
296 | * We can't sleep here, because it's also called from | ||
297 | * interrupt context. | ||
298 | */ | ||
299 | timeout--; | ||
300 | if (!timeout) | ||
301 | return -ETIMEDOUT; | ||
302 | udelay(1); | ||
303 | } while (1); | ||
304 | } | ||
305 | |||
279 | int dwc3_send_gadget_ep_cmd(struct dwc3 *dwc, unsigned ep, | 306 | int dwc3_send_gadget_ep_cmd(struct dwc3 *dwc, unsigned ep, |
280 | unsigned cmd, struct dwc3_gadget_ep_cmd_params *params) | 307 | unsigned cmd, struct dwc3_gadget_ep_cmd_params *params) |
281 | { | 308 | { |
diff --git a/drivers/usb/dwc3/gadget.h b/drivers/usb/dwc3/gadget.h index a8600084348c..95ef6a2f7764 100644 --- a/drivers/usb/dwc3/gadget.h +++ b/drivers/usb/dwc3/gadget.h | |||
@@ -111,6 +111,7 @@ int dwc3_gadget_ep0_queue(struct usb_ep *ep, struct usb_request *request, | |||
111 | int __dwc3_gadget_ep_set_halt(struct dwc3_ep *dep, int value); | 111 | int __dwc3_gadget_ep_set_halt(struct dwc3_ep *dep, int value); |
112 | int dwc3_send_gadget_ep_cmd(struct dwc3 *dwc, unsigned ep, | 112 | int dwc3_send_gadget_ep_cmd(struct dwc3 *dwc, unsigned ep, |
113 | unsigned cmd, struct dwc3_gadget_ep_cmd_params *params); | 113 | unsigned cmd, struct dwc3_gadget_ep_cmd_params *params); |
114 | int dwc3_send_gadget_generic_command(struct dwc3 *dwc, int cmd, u32 param); | ||
114 | 115 | ||
115 | /** | 116 | /** |
116 | * dwc3_gadget_ep_get_transfer_index - Gets transfer index from HW | 117 | * dwc3_gadget_ep_get_transfer_index - Gets transfer index from HW |