Go to the documentation of this file.
12 #ifndef __FSL_USB2_UDC_H
13 #define __FSL_USB2_UDC_H
17 #define USB_MAX_CTRL_PAYLOAD 64
18 #define USB_DR_SYS_OFFSET 0x400
106 #define WAIT_FOR_SETUP 0
107 #define DATA_STATE_XMIT 1
108 #define DATA_STATE_NEED_ZLP 2
109 #define WAIT_FOR_OUT_STATUS 3
110 #define DATA_STATE_RECV 4
113 #define DCCPARAMS_DC 0x00000080
114 #define DCCPARAMS_DEN_MASK 0x0000001f
117 #define USB_FRINDEX_MASKS 0x3fff
119 #define USB_CMD_RUN_STOP 0x00000001
120 #define USB_CMD_CTRL_RESET 0x00000002
121 #define USB_CMD_PERIODIC_SCHEDULE_EN 0x00000010
122 #define USB_CMD_ASYNC_SCHEDULE_EN 0x00000020
123 #define USB_CMD_INT_AA_DOORBELL 0x00000040
124 #define USB_CMD_ASP 0x00000300
125 #define USB_CMD_ASYNC_SCH_PARK_EN 0x00000800
126 #define USB_CMD_SUTW 0x00002000
127 #define USB_CMD_ATDTW 0x00004000
128 #define USB_CMD_ITC 0x00FF0000
131 #define USB_CMD_FRAME_SIZE_1024 0x00000000
132 #define USB_CMD_FRAME_SIZE_512 0x00000004
133 #define USB_CMD_FRAME_SIZE_256 0x00000008
134 #define USB_CMD_FRAME_SIZE_128 0x0000000C
135 #define USB_CMD_FRAME_SIZE_64 0x00008000
136 #define USB_CMD_FRAME_SIZE_32 0x00008004
137 #define USB_CMD_FRAME_SIZE_16 0x00008008
138 #define USB_CMD_FRAME_SIZE_8 0x0000800C
141 #define USB_CMD_ASP_00 0x00000000
142 #define USB_CMD_ASP_01 0x00000100
143 #define USB_CMD_ASP_10 0x00000200
144 #define USB_CMD_ASP_11 0x00000300
145 #define USB_CMD_ASP_BIT_POS 8
148 #define USB_CMD_ITC_NO_THRESHOLD 0x00000000
149 #define USB_CMD_ITC_1_MICRO_FRM 0x00010000
150 #define USB_CMD_ITC_2_MICRO_FRM 0x00020000
151 #define USB_CMD_ITC_4_MICRO_FRM 0x00040000
152 #define USB_CMD_ITC_8_MICRO_FRM 0x00080000
153 #define USB_CMD_ITC_16_MICRO_FRM 0x00100000
154 #define USB_CMD_ITC_32_MICRO_FRM 0x00200000
155 #define USB_CMD_ITC_64_MICRO_FRM 0x00400000
156 #define USB_CMD_ITC_BIT_POS 16
159 #define USB_STS_INT 0x00000001
160 #define USB_STS_ERR 0x00000002
161 #define USB_STS_PORT_CHANGE 0x00000004
162 #define USB_STS_FRM_LST_ROLL 0x00000008
163 #define USB_STS_SYS_ERR 0x00000010
164 #define USB_STS_IAA 0x00000020
165 #define USB_STS_RESET 0x00000040
166 #define USB_STS_SOF 0x00000080
167 #define USB_STS_SUSPEND 0x00000100
168 #define USB_STS_HC_HALTED 0x00001000
169 #define USB_STS_RCL 0x00002000
170 #define USB_STS_PERIODIC_SCHEDULE 0x00004000
171 #define USB_STS_ASYNC_SCHEDULE 0x00008000
174 #define USB_INTR_INT_EN 0x00000001
175 #define USB_INTR_ERR_INT_EN 0x00000002
176 #define USB_INTR_PTC_DETECT_EN 0x00000004
177 #define USB_INTR_FRM_LST_ROLL_EN 0x00000008
178 #define USB_INTR_SYS_ERR_EN 0x00000010
179 #define USB_INTR_ASYN_ADV_EN 0x00000020
180 #define USB_INTR_RESET_EN 0x00000040
181 #define USB_INTR_SOF_EN 0x00000080
182 #define USB_INTR_DEVICE_SUSPEND 0x00000100
185 #define USB_DEVICE_ADDRESS_MASK 0xFE000000
186 #define USB_DEVICE_ADDRESS_BIT_POS 25
189 #define USB_EP_LIST_ADDRESS_MASK 0xfffff800
192 #define PORTSCX_CURRENT_CONNECT_STATUS 0x00000001
193 #define PORTSCX_CONNECT_STATUS_CHANGE 0x00000002
194 #define PORTSCX_PORT_ENABLE 0x00000004
195 #define PORTSCX_PORT_EN_DIS_CHANGE 0x00000008
196 #define PORTSCX_OVER_CURRENT_ACT 0x00000010
197 #define PORTSCX_OVER_CURRENT_CHG 0x00000020
198 #define PORTSCX_PORT_FORCE_RESUME 0x00000040
199 #define PORTSCX_PORT_SUSPEND 0x00000080
200 #define PORTSCX_PORT_RESET 0x00000100
201 #define PORTSCX_LINE_STATUS_BITS 0x00000C00
202 #define PORTSCX_PORT_POWER 0x00001000
203 #define PORTSCX_PORT_INDICTOR_CTRL 0x0000C000
204 #define PORTSCX_PORT_TEST_CTRL 0x000F0000
205 #define PORTSCX_WAKE_ON_CONNECT_EN 0x00100000
206 #define PORTSCX_WAKE_ON_CONNECT_DIS 0x00200000
207 #define PORTSCX_WAKE_ON_OVER_CURRENT 0x00400000
208 #define PORTSCX_PHY_LOW_POWER_SPD 0x00800000
209 #define PORTSCX_PORT_FORCE_FULL_SPEED 0x01000000
210 #define PORTSCX_PORT_SPEED_MASK 0x0C000000
211 #define PORTSCX_PORT_WIDTH 0x10000000
212 #define PORTSCX_PHY_TYPE_SEL 0xC0000000
215 #define PORTSCX_LINE_STATUS_SE0 0x00000000
216 #define PORTSCX_LINE_STATUS_JSTATE 0x00000400
217 #define PORTSCX_LINE_STATUS_KSTATE 0x00000800
218 #define PORTSCX_LINE_STATUS_UNDEF 0x00000C00
219 #define PORTSCX_LINE_STATUS_BIT_POS 10
222 #define PORTSCX_PIC_OFF 0x00000000
223 #define PORTSCX_PIC_AMBER 0x00004000
224 #define PORTSCX_PIC_GREEN 0x00008000
225 #define PORTSCX_PIC_UNDEF 0x0000C000
226 #define PORTSCX_PIC_BIT_POS 14
229 #define PORTSCX_PTC_DISABLE 0x00000000
230 #define PORTSCX_PTC_JSTATE 0x00010000
231 #define PORTSCX_PTC_KSTATE 0x00020000
232 #define PORTSCX_PTC_SEQNAK 0x00030000
233 #define PORTSCX_PTC_PACKET 0x00040000
234 #define PORTSCX_PTC_FORCE_EN 0x00050000
235 #define PORTSCX_PTC_BIT_POS 16
238 #define PORTSCX_PORT_SPEED_FULL 0x00000000
239 #define PORTSCX_PORT_SPEED_LOW 0x04000000
240 #define PORTSCX_PORT_SPEED_HIGH 0x08000000
241 #define PORTSCX_PORT_SPEED_UNDEF 0x0C000000
242 #define PORTSCX_SPEED_BIT_POS 26
245 #define PORTSCX_PTW 0x10000000
246 #define PORTSCX_PTW_8BIT 0x00000000
247 #define PORTSCX_PTW_16BIT 0x10000000
250 #define PORTSCX_PTS_UTMI 0x00000000
251 #define PORTSCX_PTS_ULPI 0x80000000
252 #define PORTSCX_PTS_FSLS 0xC0000000
253 #define PORTSCX_PTS_BIT_POS 30
256 #define OTGSC_CTRL_VUSB_DISCHARGE 0x00000001
257 #define OTGSC_CTRL_VUSB_CHARGE 0x00000002
258 #define OTGSC_CTRL_OTG_TERM 0x00000008
259 #define OTGSC_CTRL_DATA_PULSING 0x00000010
260 #define OTGSC_STS_USB_ID 0x00000100
261 #define OTGSC_STS_A_VBUS_VALID 0x00000200
262 #define OTGSC_STS_A_SESSION_VALID 0x00000400
263 #define OTGSC_STS_B_SESSION_VALID 0x00000800
264 #define OTGSC_STS_B_SESSION_END 0x00001000
265 #define OTGSC_STS_1MS_TOGGLE 0x00002000
266 #define OTGSC_STS_DATA_PULSING 0x00004000
267 #define OTGSC_INTSTS_USB_ID 0x00010000
268 #define OTGSC_INTSTS_A_VBUS_VALID 0x00020000
269 #define OTGSC_INTSTS_A_SESSION_VALID 0x00040000
270 #define OTGSC_INTSTS_B_SESSION_VALID 0x00080000
271 #define OTGSC_INTSTS_B_SESSION_END 0x00100000
272 #define OTGSC_INTSTS_1MS 0x00200000
273 #define OTGSC_INTSTS_DATA_PULSING 0x00400000
274 #define OTGSC_INTR_USB_ID 0x01000000
275 #define OTGSC_INTR_A_VBUS_VALID 0x02000000
276 #define OTGSC_INTR_A_SESSION_VALID 0x04000000
277 #define OTGSC_INTR_B_SESSION_VALID 0x08000000
278 #define OTGSC_INTR_B_SESSION_END 0x10000000
279 #define OTGSC_INTR_1MS_TIMER 0x20000000
280 #define OTGSC_INTR_DATA_PULSING 0x40000000
283 #define USB_MODE_CTRL_MODE_IDLE 0x00000000
284 #define USB_MODE_CTRL_MODE_DEVICE 0x00000002
285 #define USB_MODE_CTRL_MODE_HOST 0x00000003
286 #define USB_MODE_CTRL_MODE_MASK 0x00000003
287 #define USB_MODE_CTRL_MODE_RSV 0x00000001
288 #define USB_MODE_ES 0x00000004
289 #define USB_MODE_SETUP_LOCK_OFF 0x00000008
290 #define USB_MODE_STREAM_DISABLE 0x00000010
292 #define EPFLUSH_TX_OFFSET 0x00010000
293 #define EPFLUSH_RX_OFFSET 0x00000000
296 #define EP_SETUP_STATUS_MASK 0x0000003F
297 #define EP_SETUP_STATUS_EP0 0x00000001
300 #define EPCTRL_TX_ENABLE 0x00800000
301 #define EPCTRL_TX_DATA_TOGGLE_RST 0x00400000
302 #define EPCTRL_TX_DATA_TOGGLE_INH 0x00200000
303 #define EPCTRL_TX_TYPE 0x000C0000
304 #define EPCTRL_TX_DATA_SOURCE 0x00020000
305 #define EPCTRL_TX_EP_STALL 0x00010000
306 #define EPCTRL_RX_ENABLE 0x00000080
307 #define EPCTRL_RX_DATA_TOGGLE_RST 0x00000040
308 #define EPCTRL_RX_DATA_TOGGLE_INH 0x00000020
309 #define EPCTRL_RX_TYPE 0x0000000C
310 #define EPCTRL_RX_DATA_SINK 0x00000002
311 #define EPCTRL_RX_EP_STALL 0x00000001
314 #define EPCTRL_EP_TYPE_CONTROL 0
315 #define EPCTRL_EP_TYPE_ISO 1
316 #define EPCTRL_EP_TYPE_BULK 2
317 #define EPCTRL_EP_TYPE_INTERRUPT 3
318 #define EPCTRL_TX_EP_TYPE_SHIFT 18
319 #define EPCTRL_RX_EP_TYPE_SHIFT 2
322 #define SNOOP_ADDRESS_MASK 0xFFFFF000
323 #define SNOOP_SIZE_ZERO 0x00
324 #define SNOOP_SIZE_4KB 0x0B
325 #define SNOOP_SIZE_8KB 0x0C
326 #define SNOOP_SIZE_16KB 0x0D
327 #define SNOOP_SIZE_32KB 0x0E
328 #define SNOOP_SIZE_64KB 0x0F
329 #define SNOOP_SIZE_128KB 0x10
330 #define SNOOP_SIZE_256KB 0x11
331 #define SNOOP_SIZE_512KB 0x12
332 #define SNOOP_SIZE_1MB 0x13
333 #define SNOOP_SIZE_2MB 0x14
334 #define SNOOP_SIZE_4MB 0x15
335 #define SNOOP_SIZE_8MB 0x16
336 #define SNOOP_SIZE_16MB 0x17
337 #define SNOOP_SIZE_32MB 0x18
338 #define SNOOP_SIZE_64MB 0x19
339 #define SNOOP_SIZE_128MB 0x1A
340 #define SNOOP_SIZE_256MB 0x1B
341 #define SNOOP_SIZE_512MB 0x1C
342 #define SNOOP_SIZE_1GB 0x1D
343 #define SNOOP_SIZE_2GB 0x1E
346 #define PRI_CTRL_PRI_LVL1 0x0000000C
347 #define PRI_CTRL_PRI_LVL0 0x00000003
350 #define SI_CTRL_ERR_DISABLE 0x00000010
351 #define SI_CTRL_IDRC_DISABLE 0x00000008
352 #define SI_CTRL_RD_SAFE_EN 0x00000004
353 #define SI_CTRL_RD_PREFETCH_DISABLE 0x00000002
354 #define SI_CTRL_RD_PREFEFETCH_VAL 0x00000001
357 #define USB_CTRL_IOENB 0x00000004
358 #define USB_CTRL_ULPI_INT0EN 0x00000001
359 #define USB_CTRL_UTMI_PHY_EN 0x00000200
360 #define USB_CTRL_USB_EN 0x00000004
361 #define USB_CTRL_ULPI_PHY_CLK_SEL 0x00000400
385 #define EP_QUEUE_HEAD_MULT_POS 30
386 #define EP_QUEUE_HEAD_ZLT_SEL 0x20000000
387 #define EP_QUEUE_HEAD_MAX_PKT_LEN_POS 16
388 #define EP_QUEUE_HEAD_MAX_PKT_LEN(ep_info) (((ep_info)>>16)&0x07ff)
389 #define EP_QUEUE_HEAD_IOS 0x00008000
390 #define EP_QUEUE_HEAD_NEXT_TERMINATE 0x00000001
391 #define EP_QUEUE_HEAD_IOC 0x00008000
392 #define EP_QUEUE_HEAD_MULTO 0x00000C00
393 #define EP_QUEUE_HEAD_STATUS_HALT 0x00000040
394 #define EP_QUEUE_HEAD_STATUS_ACTIVE 0x00000080
395 #define EP_QUEUE_CURRENT_OFFSET_MASK 0x00000FFF
396 #define EP_QUEUE_HEAD_NEXT_POINTER_MASK 0xFFFFFFE0
397 #define EP_QUEUE_FRINDEX_MASK 0x000007FF
398 #define EP_MAX_LENGTH_TRANSFER 0x4000
420 #define DTD_NEXT_TERMINATE 0x00000001
421 #define DTD_IOC 0x00008000
422 #define DTD_STATUS_ACTIVE 0x00000080
423 #define DTD_STATUS_HALTED 0x00000040
424 #define DTD_STATUS_DATA_BUFF_ERR 0x00000020
425 #define DTD_STATUS_TRANSACTION_ERR 0x00000008
426 #define DTD_RESERVED_FIELDS 0x80007300
427 #define DTD_ADDR_MASK 0xFFFFFFE0
428 #define DTD_PACKET_SIZE 0x7FFF0000
429 #define DTD_LENGTH_BIT_POS 16
430 #define DTD_ERROR_MASK (DTD_STATUS_HALTED | \
431 DTD_STATUS_DATA_BUFF_ERR | \
432 DTD_STATUS_TRANSACTION_ERR)
434 #define DTD_ALIGNMENT 0x20
435 #define QH_ALIGNMENT 2048
438 #define UDC_DMA_BOUNDARY 0x1000
457 #define REQ_UNCOMPLETE 1
513 #define DBG(fmt, args...) printk(KERN_DEBUG "[%s] " fmt "\n", \
516 #define DBG(fmt, args...) do{}while(0)
527 DBG(
"%s, length %u:\n", label, length);
530 num =
min(length, 16
u);
532 for (i = 0; i < num; ++
i) {
550 #define VDBG(stuff...) do{}while(0)
553 #define ERR(stuff...) pr_err("udc: " stuff)
554 #define WARNING(stuff...) pr_warning("udc: " stuff)
555 #define INFO(stuff...) pr_info("udc: " stuff)
571 #define ep_index(EP) ((EP)->ep.desc->bEndpointAddress&0xF)
572 #define ep_maxpacket(EP) ((EP)->ep.maxpacket)
573 #define ep_is_in(EP) ( (ep_index(EP) == 0) ? (EP->udc->ep0_dir == \
574 USB_DIR_IN) : ((EP)->ep.desc->bEndpointAddress \
575 & USB_DIR_IN)==USB_DIR_IN)
576 #define get_ep_by_pipe(udc, pipe) ((pipe == 1)? &udc->eps[0]: \
578 #define get_pipe_by_windex(windex) ((windex & USB_ENDPOINT_NUMBER_MASK) \
579 * 2 + ((windex & USB_DIR_IN) ? 1 : 0))
580 #define get_pipe_by_ep(EP) (ep_index(EP) * 2 + ep_is_in(EP))
588 return &ep->
udc->ep_qh[(ep->
udc->ep0_dir ==
593 #ifdef CONFIG_ARCH_MXC