]> git.kernelconcepts.de Git - karo-tx-uboot.git/blob - include/usb/mv_udc.h
karo: tx48: move FDT to low RAM
[karo-tx-uboot.git] / include / usb / mv_udc.h
1 /*
2  * Copyright 2011, Marvell Semiconductor Inc.
3  * Lei Wen <leiwen@marvell.com>
4  *
5  * SPDX-License-Identifier:     GPL-2.0+
6  */
7
8
9 #ifndef __MV_UDC_H__
10 #define __MV_UDC_H__
11
12 #include <asm/byteorder.h>
13 #include <asm/errno.h>
14 #include <linux/usb/ch9.h>
15 #include <linux/usb/gadget.h>
16
17 #include "../../drivers/usb/host/ehci.h"
18
19 #define NUM_ENDPOINTS           6
20
21 /* Endpoint parameters */
22 #define MAX_ENDPOINTS           4
23
24 #define EP_MAX_PACKET_SIZE      0x200
25 #define EP0_MAX_PACKET_SIZE     64
26
27 struct mv_udc {
28 #define MICRO_8FRAME    0x8
29 #define USBCMD_ITC(x)   ((((x) > 0xff) ? 0xff : x) << 16)
30 #define USBCMD_FS2      (1 << 15)
31 #define USBCMD_RST      (1 << 1)
32 #define USBCMD_RUN      (1)
33         u32 usbcmd;             /* 0x140 */
34 #define STS_SLI         (1 << 8)
35 #define STS_URI         (1 << 6)
36 #define STS_PCI         (1 << 2)
37 #define STS_UEI         (1 << 1)
38 #define STS_UI          (1 << 0)
39         u32 usbsts;             /* 0x144 */
40         u32 pad1[3];
41         u32 devaddr;            /* 0x154 */
42         u32 epinitaddr;         /* 0x158 */
43         u32 pad2[10];
44 #define PTS_ENABLE      2
45 #define PTS(x)          (((x) & 0x3) << 30)
46 #define PFSC            (1 << 24)
47         u32 portsc;             /* 0x184 */
48         u32 pad3[8];
49 #define USBMODE_DEVICE  2
50         u32 usbmode;            /* 0x1a8 */
51         u32 epstat;             /* 0x1ac */
52 #define EPT_TX(x)       (1 << (((x) & 0xffff) + 16))
53 #define EPT_RX(x)       (1 << ((x) & 0xffff))
54         u32 epprime;            /* 0x1b0 */
55         u32 epflush;            /* 0x1b4 */
56         u32 pad4;
57         u32 epcomp;             /* 0x1bc */
58 #define CTRL_TXE        (1 << 23)
59 #define CTRL_TXR        (1 << 22)
60 #define CTRL_RXE        (1 << 7)
61 #define CTRL_RXR        (1 << 6)
62 #define CTRL_TXT_BULK   (2 << 18)
63 #define CTRL_RXT_BULK   (2 << 2)
64         u32 epctrl[16];         /* 0x1c0 */
65 };
66
67 struct mv_ep {
68         struct usb_ep ep;
69         struct list_head queue;
70         const struct usb_endpoint_descriptor *desc;
71
72         struct usb_request req;
73         uint8_t *b_buf;
74         uint32_t b_len;
75         uint8_t b_fast[64] __aligned(ARCH_DMA_MINALIGN);
76 };
77
78 struct mv_drv {
79         struct usb_gadget               gadget;
80         struct usb_gadget_driver        *driver;
81         struct ehci_ctrl                *ctrl;
82         struct ept_queue_head           *epts;
83         struct ept_queue_item           *items[2 * NUM_ENDPOINTS];
84         uint8_t                         *items_mem;
85         struct mv_ep                    ep[NUM_ENDPOINTS];
86 };
87
88 struct ept_queue_head {
89         unsigned config;
90         unsigned current;       /* read-only */
91
92         unsigned next;
93         unsigned info;
94         unsigned page0;
95         unsigned page1;
96         unsigned page2;
97         unsigned page3;
98         unsigned page4;
99         unsigned reserved_0;
100
101         unsigned char setup_data[8];
102
103         unsigned reserved_1;
104         unsigned reserved_2;
105         unsigned reserved_3;
106         unsigned reserved_4;
107 };
108
109 #define CONFIG_MAX_PKT(n)       ((n) << 16)
110 #define CONFIG_ZLT              (1 << 29)       /* stop on zero-len xfer */
111 #define CONFIG_IOS              (1 << 15)       /* IRQ on setup */
112
113 struct ept_queue_item {
114         unsigned next;
115         unsigned info;
116         unsigned page0;
117         unsigned page1;
118         unsigned page2;
119         unsigned page3;
120         unsigned page4;
121         unsigned reserved;
122 };
123
124 #define TERMINATE 1
125 #define INFO_BYTES(n)           ((n) << 16)
126 #define INFO_IOC                (1 << 15)
127 #define INFO_ACTIVE             (1 << 7)
128 #define INFO_HALTED             (1 << 6)
129 #define INFO_BUFFER_ERROR       (1 << 5)
130 #define INFO_TX_ERROR           (1 << 3)
131
132 #endif /* __MV_UDC_H__ */