Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

+32 -2
+4 -2
drivers/usb/dwc3/core.h
··· 284 284 #define DWC3_DGCMD_SET_ENDPOINT_NRDY 0x0c 285 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 290 /* Device Endpoint Command Register */ 288 291 #define DWC3_DEPCMD_PARAM_SHIFT 16 289 292 #define DWC3_DEPCMD_PARAM(x) ((x) << DWC3_DEPCMD_PARAM_SHIFT) 290 293 #define DWC3_DEPCMD_GET_RSC_IDX(x) (((x) >> DWC3_DEPCMD_PARAM_SHIFT) & 0x7f) 291 - #define DWC3_DEPCMD_STATUS_MASK (0x0f << 12) 292 - #define DWC3_DEPCMD_STATUS(x) (((x) & DWC3_DEPCMD_STATUS_MASK) >> 12) 294 + #define DWC3_DEPCMD_STATUS(x) (((x) >> 15) & 1) 293 295 #define DWC3_DEPCMD_HIPRI_FORCERM (1 << 11) 294 296 #define DWC3_DEPCMD_CMDACT (1 << 10) 295 297 #define DWC3_DEPCMD_CMDIOC (1 << 8)
+27
drivers/usb/dwc3/gadget.c
··· 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 306 int dwc3_send_gadget_ep_cmd(struct dwc3 *dwc, unsigned ep, 280 307 unsigned cmd, struct dwc3_gadget_ep_cmd_params *params) 281 308 {
+1
drivers/usb/dwc3/gadget.h
··· 111 111 int __dwc3_gadget_ep_set_halt(struct dwc3_ep *dep, int value); 112 112 int dwc3_send_gadget_ep_cmd(struct dwc3 *dwc, unsigned ep, 113 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 117 * dwc3_gadget_ep_get_transfer_index - Gets transfer index from HW