2 * Copyright 2011, Marvell Semiconductor Inc.
3 * Lei Wen <leiwen@marvell.com>
5 * SPDX-License-Identifier: GPL-2.0+
12 #include <asm/byteorder.h>
13 #include <asm/errno.h>
14 #include <linux/usb/ch9.h>
15 #include <linux/usb/gadget.h>
17 /* Endpoint 0 states */
20 #define EP0_OUT_DATA 2
21 #define EP0_XFER_COMPLETE 3
24 /* Endpoint parameters */
25 #define MAX_ENDPOINTS 4
26 #define EP_MAX_PACKET_SIZE 0x200
28 #define EP0_MAX_PACKET_SIZE 64
29 #define UDC_OUT_ENDPOINT 0x02
30 #define UDC_OUT_PACKET_SIZE EP_MAX_PACKET_SIZE
31 #define UDC_IN_ENDPOINT 0x01
32 #define UDC_IN_PACKET_SIZE EP_MAX_PACKET_SIZE
33 #define UDC_INT_ENDPOINT 0x05
34 #define UDC_INT_PACKET_SIZE EP_MAX_PACKET_SIZE
35 #define UDC_BULK_PACKET_SIZE EP_MAX_PACKET_SIZE
37 #define NUM_ENDPOINTS 6
41 struct usb_request req;
42 struct list_head queue;
43 const struct usb_endpoint_descriptor *desc;
48 #define MICRO_8FRAME 0x8
49 #define USBCMD_ITC(x) (((x > 0xff) ? 0xff : x) << 16)
50 #define USBCMD_FS2 (1 << 15)
51 #define USBCMD_RST (1 << 1)
52 #define USBCMD_RUN (1)
53 u32 usbcmd; /* 0x140 */
54 #define STS_SLI (1 << 8)
55 #define STS_URI (1 << 6)
56 #define STS_PCI (1 << 2)
57 #define STS_UEI (1 << 1)
58 #define STS_UI (1 << 0)
59 u32 usbsts; /* 0x144 */
61 u32 devaddr; /* 0x154 */
62 u32 epinitaddr; /* 0x158 */
65 #define PTS(x) ((x & 0x3) << 30)
66 #define PFSC (1 << 24)
67 u32 portsc; /* 0x184 */
69 #define USBMODE_DEVICE 2
70 u32 usbmode; /* 0x1a8 */
71 u32 epstat; /* 0x1ac */
72 #define EPT_TX(x) (1 << ((x & 0xffff) + 16))
73 #define EPT_RX(x) (1 << (x & 0xffff))
74 u32 epprime; /* 0x1b0 */
75 u32 epflush; /* 0x1b4 */
77 u32 epcomp; /* 0x1bc */
78 #define CTRL_TXE (1 << 23)
79 #define CTRL_TXR (1 << 22)
80 #define CTRL_RXE (1 << 7)
81 #define CTRL_RXR (1 << 6)
82 #define CTRL_TXT_BULK (2 << 18)
83 #define CTRL_RXT_BULK (2 << 2)
84 u32 epctrl[16]; /* 0x1c0 */
88 struct usb_gadget gadget;
89 struct usb_gadget_driver *driver;
93 struct ept_queue_head {
95 unsigned current; /* read-only */
106 unsigned char setup_data[8];
114 #define CONFIG_MAX_PKT(n) ((n) << 16)
115 #define CONFIG_ZLT (1 << 29) /* stop on zero-len xfer */
116 #define CONFIG_IOS (1 << 15) /* IRQ on setup */
118 struct ept_queue_item {
130 #define INFO_BYTES(n) ((n) << 16)
131 #define INFO_IOC (1 << 15)
132 #define INFO_ACTIVE (1 << 7)
133 #define INFO_HALTED (1 << 6)
134 #define INFO_BUFFER_ERROR (1 << 5)
135 #define INFO_TX_ERROR (1 << 3)
137 extern int usb_lowlevel_init(int index, void **controller);
138 #endif /* __MV_UDC_H__ */