13 #ifndef __LINUX_USB_GADGET_IMX_H
14 #define __LINUX_USB_GADGET_IMX_H
16 #include <linux/types.h>
19 #define EP_NO(ep) ((ep->bEndpointAddress) & ~USB_DIR_IN)
20 #define EP_DIR(ep) ((ep->bEndpointAddress) & USB_DIR_IN ? 1 : 0)
21 #define IMX_USB_NB_EP 6
66 #define USB_FRAME (0x00)
67 #define USB_SPEC (0x04)
68 #define USB_STAT (0x08)
69 #define USB_CTRL (0x0C)
70 #define USB_DADR (0x10)
71 #define USB_DDAT (0x14)
72 #define USB_INTR (0x18)
73 #define USB_MASK (0x1C)
74 #define USB_ENAB (0x24)
75 #define USB_EP_STAT(x) (0x30 + (x*0x30))
76 #define USB_EP_INTR(x) (0x34 + (x*0x30))
77 #define USB_EP_MASK(x) (0x38 + (x*0x30))
78 #define USB_EP_FDAT(x) (0x3C + (x*0x30))
79 #define USB_EP_FDAT0(x) (0x3C + (x*0x30))
80 #define USB_EP_FDAT1(x) (0x3D + (x*0x30))
81 #define USB_EP_FDAT2(x) (0x3E + (x*0x30))
82 #define USB_EP_FDAT3(x) (0x3F + (x*0x30))
83 #define USB_EP_FSTAT(x) (0x40 + (x*0x30))
84 #define USB_EP_FCTRL(x) (0x44 + (x*0x30))
85 #define USB_EP_LRFP(x) (0x48 + (x*0x30))
86 #define USB_EP_LWFP(x) (0x4C + (x*0x30))
87 #define USB_EP_FALRM(x) (0x50 + (x*0x30))
88 #define USB_EP_FRDP(x) (0x54 + (x*0x30))
89 #define USB_EP_FWRP(x) (0x58 + (x*0x30))
91 #define CTRL_CMDOVER (1<<6)
92 #define CTRL_CMDERROR (1<<5)
93 #define CTRL_FE_ENA (1<<3)
94 #define CTRL_UDC_RST (1<<2)
95 #define CTRL_AFE_ENA (1<<1)
96 #define CTRL_RESUME (1<<0)
98 #define STAT_RST (1<<8)
99 #define STAT_SUSP (1<<7)
100 #define STAT_CFG (3<<5)
101 #define STAT_INTF (3<<3)
102 #define STAT_ALTSET (7<<0)
104 #define INTR_WAKEUP (1<<31)
105 #define INTR_MSOF (1<<7)
106 #define INTR_SOF (1<<6)
107 #define INTR_RESET_STOP (1<<5)
108 #define INTR_RESET_START (1<<4)
109 #define INTR_RESUME (1<<3)
110 #define INTR_SUSPEND (1<<2)
111 #define INTR_FRAME_MATCH (1<<1)
112 #define INTR_CFG_CHG (1<<0)
114 #define ENAB_RST (1<<31)
115 #define ENAB_ENAB (1<<30)
116 #define ENAB_SUSPEND (1<<29)
117 #define ENAB_ENDIAN (1<<28)
118 #define ENAB_PWRMD (1<<0)
120 #define DADR_CFG (1<<31)
121 #define DADR_BSY (1<<30)
122 #define DADR_DADR (0x1FF)
124 #define DDAT_DDAT (0xFF)
126 #define EPSTAT_BCOUNT (0x7F<<16)
127 #define EPSTAT_SIP (1<<8)
128 #define EPSTAT_DIR (1<<7)
129 #define EPSTAT_MAX (3<<5)
130 #define EPSTAT_TYP (3<<3)
131 #define EPSTAT_ZLPS (1<<2)
132 #define EPSTAT_FLUSH (1<<1)
133 #define EPSTAT_STALL (1<<0)
135 #define FSTAT_FRAME_STAT (0xF<<24)
136 #define FSTAT_ERR (1<<22)
137 #define FSTAT_UF (1<<21)
138 #define FSTAT_OF (1<<20)
139 #define FSTAT_FR (1<<19)
140 #define FSTAT_FULL (1<<18)
141 #define FSTAT_ALRM (1<<17)
142 #define FSTAT_EMPTY (1<<16)
144 #define FCTRL_WFR (1<<29)
146 #define EPINTR_FIFO_FULL (1<<8)
147 #define EPINTR_FIFO_EMPTY (1<<7)
148 #define EPINTR_FIFO_ERROR (1<<6)
149 #define EPINTR_FIFO_HIGH (1<<5)
150 #define EPINTR_FIFO_LOW (1<<4)
151 #define EPINTR_MDEVREQ (1<<3)
152 #define EPINTR_EOT (1<<2)
153 #define EPINTR_DEVREQ (1<<1)
154 #define EPINTR_EOF (1<<0)
170 #define D_REQ(dev, args...) dev_dbg(dev, ## args)
172 #define D_REQ(dev, args...) do {} while (0)
176 #define D_TRX(dev, args...) dev_dbg(dev, ## args)
178 #define D_TRX(dev, args...) do {} while (0)
182 #define D_INI(dev, args...) dev_dbg(dev, ## args)
184 #define D_INI(dev, args...) do {} while (0)
188 static const char *state_name[] = {
191 "EP0_OUT_DATA_PHASE",
195 #define D_EP0(dev, args...) dev_dbg(dev, ## args)
197 #define D_EP0(dev, args...) do {} while (0)
201 #define D_EPX(dev, args...) dev_dbg(dev, ## args)
203 #define D_EPX(dev, args...) do {} while (0)
209 dev_dbg(dev,
"<%s> USB_INTR=[%s%s%s%s%s%s%s%s%s]\n", label,
221 #define dump_intr(x, y, z) do {} while (0)
228 dev_dbg(dev,
"<%s> EP%d_INTR=[%s%s%s%s%s%s%s%s%s]\n", label, nr,
240 #define dump_ep_intr(x, y, z, i) do {} while (0)
250 "<%s> USB_STAT=[%s%s CFG=%d, INTF=%d, ALTR=%d]\n", label,
265 "<%s> EP%d_INTR=[%s%s%s%s%s%s%s%s%s]\n",
266 label,
EP_NO(imx_ep),
267 (temp & EPINTR_FIFO_FULL) ?
" full" :
"",
268 (temp & EPINTR_FIFO_EMPTY) ?
" fempty" :
"",
269 (temp & EPINTR_FIFO_ERROR) ?
" ferr" :
"",
270 (temp & EPINTR_FIFO_HIGH) ?
" fhigh" :
"",
271 (temp & EPINTR_FIFO_LOW) ?
" flow" :
"",
272 (temp & EPINTR_MDEVREQ) ?
" mreq" :
"",
273 (temp & EPINTR_EOF) ?
" eof" :
"",
281 "<%s> EP%d_STAT=[%s%s bcount=%d]\n",
282 label,
EP_NO(imx_ep),
291 "<%s> EP%d_FSTAT=[%s%s%s%s%s%s%s]\n",
292 label,
EP_NO(imx_ep),
307 if (!req || !req->
buf) {
309 "<%s> req or req buf is free\n", label);
318 "<%s> request dump <", label);
319 for (i = 0; i < req->
length; i++)
326 #define dump_ep_stat(x, y) do {} while (0)
327 #define dump_usb_stat(x, y) do {} while (0)
328 #define dump_req(x, y, z) do {} while (0)
332 #define D_ERR(dev, args...) dev_dbg(dev, ## args)
334 #define D_ERR(dev, args...) do {} while (0)
338 #define D_REQ(dev, args...) do {} while (0)
339 #define D_TRX(dev, args...) do {} while (0)
340 #define D_INI(dev, args...) do {} while (0)
341 #define D_EP0(dev, args...) do {} while (0)
342 #define D_EPX(dev, args...) do {} while (0)
343 #define dump_ep_intr(x, y, z, i) do {} while (0)
344 #define dump_intr(x, y, z) do {} while (0)
345 #define dump_ep_stat(x, y) do {} while (0)
346 #define dump_usb_stat(x, y) do {} while (0)
347 #define dump_req(x, y, z) do {} while (0)
348 #define D_ERR(dev, args...) do {} while (0)