2 * Copyright 2011, Marvell Semiconductor Inc.
3 * Lei Wen <leiwen@marvell.com>
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License as
7 * published by the Free Software Foundation; either version 2 of
8 * the License, or (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
25 #include <asm/byteorder.h>
26 #include <asm/errno.h>
27 #include <linux/usb/ch9.h>
28 #include <linux/usb/gadget.h>
30 /* Endpoint 0 states */
33 #define EP0_OUT_DATA 2
34 #define EP0_XFER_COMPLETE 3
37 /* Endpoint parameters */
38 #define MAX_ENDPOINTS 4
39 #define EP_MAX_PACKET_SIZE 0x200
41 #define EP0_MAX_PACKET_SIZE 64
42 #define UDC_OUT_ENDPOINT 0x02
43 #define UDC_OUT_PACKET_SIZE EP_MAX_PACKET_SIZE
44 #define UDC_IN_ENDPOINT 0x01
45 #define UDC_IN_PACKET_SIZE EP_MAX_PACKET_SIZE
46 #define UDC_INT_ENDPOINT 0x05
47 #define UDC_INT_PACKET_SIZE EP_MAX_PACKET_SIZE
48 #define UDC_BULK_PACKET_SIZE EP_MAX_PACKET_SIZE
50 #define NUM_ENDPOINTS 6
54 struct usb_request req;
55 struct list_head queue;
56 const struct usb_endpoint_descriptor *desc;
61 #define MICRO_8FRAME 0x8
62 #define USBCMD_ITC(x) (((x > 0xff) ? 0xff : x) << 16)
63 #define USBCMD_FS2 (1 << 15)
64 #define USBCMD_RST (1 << 1)
65 #define USBCMD_RUN (1)
66 u32 usbcmd; /* 0x140 */
67 #define STS_SLI (1 << 8)
68 #define STS_URI (1 << 6)
69 #define STS_PCI (1 << 2)
70 #define STS_UEI (1 << 1)
71 #define STS_UI (1 << 0)
72 u32 usbsts; /* 0x144 */
74 u32 devaddr; /* 0x154 */
75 u32 epinitaddr; /* 0x158 */
78 #define PTS(x) ((x & 0x3) << 30)
79 #define PFSC (1 << 24)
80 u32 portsc; /* 0x184 */
82 #define USBMODE_DEVICE 2
83 u32 usbmode; /* 0x1a8 */
84 u32 epstat; /* 0x1ac */
85 #define EPT_TX(x) (1 << ((x & 0xffff) + 16))
86 #define EPT_RX(x) (1 << (x & 0xffff))
87 u32 epprime; /* 0x1b0 */
88 u32 epflush; /* 0x1b4 */
90 u32 epcomp; /* 0x1bc */
91 #define CTRL_TXE (1 << 23)
92 #define CTRL_TXR (1 << 22)
93 #define CTRL_RXE (1 << 7)
94 #define CTRL_RXR (1 << 6)
95 #define CTRL_TXT_BULK (2 << 18)
96 #define CTRL_RXT_BULK (2 << 2)
97 u32 epctrl[16]; /* 0x1c0 */
101 struct usb_gadget gadget;
102 struct usb_gadget_driver *driver;
106 struct ept_queue_head {
108 unsigned current; /* read-only */
119 unsigned char setup_data[8];
127 #define CONFIG_MAX_PKT(n) ((n) << 16)
128 #define CONFIG_ZLT (1 << 29) /* stop on zero-len xfer */
129 #define CONFIG_IOS (1 << 15) /* IRQ on setup */
131 struct ept_queue_item {
143 #define INFO_BYTES(n) ((n) << 16)
144 #define INFO_IOC (1 << 15)
145 #define INFO_ACTIVE (1 << 7)
146 #define INFO_HALTED (1 << 6)
147 #define INFO_BUFFER_ERROR (1 << 5)
148 #define INFO_TX_ERROR (1 << 3)
150 extern int usb_lowlevel_init(int index, void **controller);
151 #endif /* __MV_UDC_H__ */