Open FFBoard
Open source force feedback firmware
musb_def.h
Go to the documentation of this file.
1
/*
2
* The MIT License (MIT)
3
*
4
* Copyright (c) 2021 Koji KITAYAMA
5
* Copyright (c) 2021 Tian Yunhao (t123yh)
6
* Copyright (c) 2021 Ha Thach (tinyusb.org)
7
*
8
* Permission is hereby granted, free of charge, to any person obtaining a copy
9
* of this software and associated documentation files (the "Software"), to deal
10
* in the Software without restriction, including without limitation the rights
11
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12
* copies of the Software, and to permit persons to whom the Software is
13
* furnished to do so, subject to the following conditions:
14
*
15
* The above copyright notice and this permission notice shall be included in
16
* all copies or substantial portions of the Software.
17
*
18
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24
* THE SOFTWARE.
25
*
26
* This file is part of the TinyUSB stack.
27
*/
28
29
#ifndef _TUSB_MUSB_DEF
30
#define _TUSB_MUSB_DEF
31
32
33
#define USBC_Readb(reg) (*(volatile unsigned char *)(reg))
34
#define USBC_Readw(reg) (*(volatile unsigned short *)(reg))
35
#define USBC_Readl(reg) (*(volatile unsigned long *)(reg))
36
37
#define USBC_Writeb(value, reg) (*(volatile unsigned char *)(reg) = (value))
38
#define USBC_Writew(value, reg) (*(volatile unsigned short *)(reg) = (value))
39
#define USBC_Writel(value, reg) (*(volatile unsigned long *)(reg) = (value))
40
41
42
#define USBC_SetBit_Mask_b(reg,mask) do { \
43
unsigned char _r = USBC_Readb(reg); \
44
_r |= (unsigned char)(mask); \
45
USBC_Writeb(_r,reg); \
46
}while(0)
47
#define USBC_SetBit_Mask_w(reg,mask) do { \
48
unsigned short _r = USBC_Readw(reg); \
49
_r |= (unsigned short)(mask); \
50
USBC_Writew(_r,reg); \
51
}while(0)
52
#define USBC_SetBit_Mask_l(reg,mask) do { \
53
unsigned int _r = USBC_Readl(reg); \
54
_r |= (unsigned int)(mask); \
55
USBC_Writel(_r,reg); \
56
}while(0)
57
58
59
#define USBC_ClrBit_Mask_b(reg,mask) do { \
60
unsigned char _r = USBC_Readb(reg); \
61
_r &= (~(unsigned char)(mask)); \
62
USBC_Writeb(_r,reg); \
63
}while(0);
64
#define USBC_ClrBit_Mask_w(reg,mask) do { \
65
unsigned short _r = USBC_Readw(reg); \
66
_r &= (~(unsigned short)(mask)); \
67
USBC_Writew(_r,reg); \
68
}while(0)
69
#define USBC_ClrBit_Mask_l(reg,mask) do { \
70
unsigned int _r = USBC_Readl(reg); \
71
_r &= (~(unsigned int)(mask)); \
72
USBC_Writel(_r,reg); \
73
}while(0)
74
#define USBC_REG_test_bit_b(bp, reg) (USBC_Readb(reg) & (1 << (bp)))
75
#define USBC_REG_test_bit_w(bp, reg) (USBC_Readw(reg) & (1 << (bp)))
76
#define USBC_REG_test_bit_l(bp, reg) (USBC_Readl(reg) & (1 << (bp)))
77
78
#define USBC_REG_set_bit_b(bp, reg) (USBC_Writeb((USBC_Readb(reg) | (1 << (bp))) , (reg)))
79
#define USBC_REG_set_bit_w(bp, reg) (USBC_Writew((USBC_Readw(reg) | (1 << (bp))) , (reg)))
80
#define USBC_REG_set_bit_l(bp, reg) (USBC_Writel((USBC_Readl(reg) | (1 << (bp))) , (reg)))
81
82
#define USBC_REG_clear_bit_b(bp, reg) (USBC_Writeb((USBC_Readb(reg) & (~ (1 << (bp)))) , (reg)))
83
#define USBC_REG_clear_bit_w(bp, reg) (USBC_Writew((USBC_Readw(reg) & (~ (1 << (bp)))) , (reg)))
84
#define USBC_REG_clear_bit_l(bp, reg) (USBC_Writel((USBC_Readl(reg) & (~ (1 << (bp)))) , (reg)))
85
86
#define SW_UDC_EPNUMS 3
87
88
#define SUNXI_SRAMC_BASE 0x01c00000
89
//---------------------------------------------------------------
90
// reg base
91
//---------------------------------------------------------------
92
#define USBC0_BASE 0x01c13000
93
#define USBC1_BASE 0x01c14000
94
#define USBC2_BASE 0x01c1E000
95
96
//Some reg within musb
97
#define USBPHY_CLK_REG 0x01c200CC
98
#define USBPHY_CLK_RST_BIT 0
99
#define USBPHY_CLK_GAT_BIT 1
100
101
#define BUS_CLK_RST_REG 0x01c202c0
//Bus Clock Reset Register Bit24 : USB CLK RST
102
#define BUS_RST_USB_BIT 24
103
104
#define BUS_CLK_GATE0_REG 0x01c20060
//Bus Clock Gating Register Bit24 : USB CLK GATE 0: Mask 1 : Pass
105
#define BUS_CLK_USB_BIT 24
106
107
//#define USB_INTR
108
109
#define NDMA_CFG_REG
110
//-----------------------------------------------------------------------
111
// musb reg offset
112
//-----------------------------------------------------------------------
113
114
#define USBC_REG_o_FADDR 0x0098
115
#define USBC_REG_o_PCTL 0x0040
116
#define USBC_REG_o_INTTx 0x0044
117
#define USBC_REG_o_INTRx 0x0046
118
#define USBC_REG_o_INTTxE 0x0048
119
#define USBC_REG_o_INTRxE 0x004A
120
#define USBC_REG_o_INTUSB 0x004C
121
#define USBC_REG_o_INTUSBE 0x0050
122
#define USBC_REG_o_FRNUM 0x0054
123
#define USBC_REG_o_EPIND 0x0042
124
#define USBC_REG_o_TMCTL 0x007C
125
126
#define USBC_REG_o_TXMAXP 0x0080
127
#define USBC_REG_o_CSR0 0x0082
128
#define USBC_REG_o_TXCSR 0x0082
129
#define USBC_REG_o_RXMAXP 0x0084
130
#define USBC_REG_o_RXCSR 0x0086
131
#define USBC_REG_o_COUNT0 0x0088
132
#define USBC_REG_o_RXCOUNT 0x0088
133
#define USBC_REG_o_EP0TYPE 0x008C
134
#define USBC_REG_o_TXTYPE 0x008C
135
#define USBC_REG_o_NAKLIMIT0 0x008D
136
#define USBC_REG_o_TXINTERVAL 0x008D
137
#define USBC_REG_o_RXTYPE 0x008E
138
#define USBC_REG_o_RXINTERVAL 0x008F
139
140
//#define USBC_REG_o_CONFIGDATA 0x001F //
141
142
#define USBC_REG_o_EPFIFO0 0x0000
143
#define USBC_REG_o_EPFIFO1 0x0004
144
#define USBC_REG_o_EPFIFO2 0x0008
145
#define USBC_REG_o_EPFIFO3 0x000C
146
#define USBC_REG_o_EPFIFO4 0x0010
147
#define USBC_REG_o_EPFIFO5 0x0014
148
#define USBC_REG_o_EPFIFOx(n) (0x0000 + (n<<2))
149
150
#define USBC_REG_o_DEVCTL 0x0041
151
152
#define USBC_REG_o_TXFIFOSZ 0x0090
153
#define USBC_REG_o_RXFIFOSZ 0x0094
154
#define USBC_REG_o_TXFIFOAD 0x0092
155
#define USBC_REG_o_RXFIFOAD 0x0096
156
157
#define USBC_REG_o_VEND0 0x0043
158
#define USBC_REG_o_VEND1 0x007D
159
#define USBC_REG_o_VEND3 0x007E
160
161
//#define USBC_REG_o_PHYCTL 0x006C
162
#define USBC_REG_o_EPINFO 0x0078
163
#define USBC_REG_o_RAMINFO 0x0079
164
#define USBC_REG_o_LINKINFO 0x007A
165
#define USBC_REG_o_VPLEN 0x007B
166
#define USBC_REG_o_HSEOF 0x007C
167
#define USBC_REG_o_FSEOF 0x007D
168
#define USBC_REG_o_LSEOF 0x007E
169
170
//new
171
#define USBC_REG_o_FADDR0 0x0098
172
#define USBC_REG_o_HADDR0 0x009A
173
#define USBC_REG_o_HPORT0 0x009B
174
#define USBC_REG_o_TXFADDRx 0x0098
175
#define USBC_REG_o_TXHADDRx 0x009A
176
#define USBC_REG_o_TXHPORTx 0x009B
177
#define USBC_REG_o_RXFADDRx 0x009C
178
#define USBC_REG_o_RXHADDRx 0x009E
179
#define USBC_REG_o_RXHPORTx 0x009F
180
181
182
#define USBC_REG_o_RPCOUNT 0x008A
183
184
//new
185
#define USBC_REG_o_ISCR 0x0400
186
#define USBC_REG_o_PHYCTL 0x0404
187
#define USBC_REG_o_PHYBIST 0x0408
188
#define USBC_REG_o_PHYTUNE 0x040c
189
190
#define USBC_REG_o_CSR 0x0410
191
192
#define USBC_REG_o_PMU_IRQ 0x0800
193
194
//-----------------------------------------------------------------------
195
// registers
196
//-----------------------------------------------------------------------
197
198
#define USBC_REG_FADDR(usbc_base_addr) ((usbc_base_addr) + USBC_REG_o_FADDR )
199
#define USBC_REG_PCTL(usbc_base_addr) ((usbc_base_addr) + USBC_REG_o_PCTL )
200
#define USBC_REG_INTTx(usbc_base_addr) ((usbc_base_addr) + USBC_REG_o_INTTx )
201
#define USBC_REG_INTRx(usbc_base_addr) ((usbc_base_addr) + USBC_REG_o_INTRx )
202
#define USBC_REG_INTTxE(usbc_base_addr) ((usbc_base_addr) + USBC_REG_o_INTTxE )
203
#define USBC_REG_INTRxE(usbc_base_addr) ((usbc_base_addr) + USBC_REG_o_INTRxE )
204
#define USBC_REG_INTUSB(usbc_base_addr) ((usbc_base_addr) + USBC_REG_o_INTUSB )
205
#define USBC_REG_INTUSBE(usbc_base_addr) ((usbc_base_addr) + USBC_REG_o_INTUSBE )
206
#define USBC_REG_FRNUM(usbc_base_addr) ((usbc_base_addr) + USBC_REG_o_FRNUM )
207
#define USBC_REG_EPIND(usbc_base_addr) ((usbc_base_addr) + USBC_REG_o_EPIND )
208
#define USBC_REG_TMCTL(usbc_base_addr) ((usbc_base_addr) + USBC_REG_o_TMCTL )
209
#define USBC_REG_TXMAXP(usbc_base_addr) ((usbc_base_addr) + USBC_REG_o_TXMAXP )
210
211
#define USBC_REG_CSR0(usbc_base_addr) ((usbc_base_addr) + USBC_REG_o_CSR0 )
212
#define USBC_REG_TXCSR(usbc_base_addr) ((usbc_base_addr) + USBC_REG_o_TXCSR )
213
214
#define USBC_REG_RXMAXP(usbc_base_addr) ((usbc_base_addr) + USBC_REG_o_RXMAXP )
215
#define USBC_REG_RXCSR(usbc_base_addr) ((usbc_base_addr) + USBC_REG_o_RXCSR )
216
217
#define USBC_REG_COUNT0(usbc_base_addr) ((usbc_base_addr) + USBC_REG_o_COUNT0 )
218
#define USBC_REG_RXCOUNT(usbc_base_addr) ((usbc_base_addr) + USBC_REG_o_RXCOUNT )
219
220
#define USBC_REG_EP0TYPE(usbc_base_addr) ((usbc_base_addr) + USBC_REG_o_EP0TYPE )
221
#define USBC_REG_TXTYPE(usbc_base_addr) ((usbc_base_addr) + USBC_REG_o_TXTYPE )
222
223
#define USBC_REG_NAKLIMIT0(usbc_base_addr) ((usbc_base_addr) + USBC_REG_o_NAKLIMIT0 )
224
#define USBC_REG_TXINTERVAL(usbc_base_addr) ((usbc_base_addr) + USBC_REG_o_TXINTERVAL )
225
226
#define USBC_REG_RXTYPE(usbc_base_addr) ((usbc_base_addr) + USBC_REG_o_RXTYPE )
227
#define USBC_REG_RXINTERVAL(usbc_base_addr) ((usbc_base_addr) + USBC_REG_o_RXINTERVAL )
228
//#define USBC_REG_CONFIGDATA(usbc_base_addr) ((usbc_base_addr) + USBC_REG_o_CONFIGDATA )
229
#define USBC_REG_EPFIFO0(usbc_base_addr) ((usbc_base_addr) + USBC_REG_o_EPFIFO0 )
230
#define USBC_REG_EPFIFO1(usbc_base_addr) ((usbc_base_addr) + USBC_REG_o_EPFIFO1 )
231
#define USBC_REG_EPFIFO2(usbc_base_addr) ((usbc_base_addr) + USBC_REG_o_EPFIFO2 )
232
#define USBC_REG_EPFIFO3(usbc_base_addr) ((usbc_base_addr) + USBC_REG_o_EPFIFO3 )
233
#define USBC_REG_EPFIFO4(usbc_base_addr) ((usbc_base_addr) + USBC_REG_o_EPFIFO4 )
234
#define USBC_REG_EPFIFO5(usbc_base_addr) ((usbc_base_addr) + USBC_REG_o_EPFIFO5 )
235
#define USBC_REG_EPFIFOx(usbc_base_addr, n) ((usbc_base_addr) + USBC_REG_o_EPFIFOx(n) )
236
#define USBC_REG_DEVCTL(usbc_base_addr) ((usbc_base_addr) + USBC_REG_o_DEVCTL )
237
#define USBC_REG_TXFIFOSZ(usbc_base_addr) ((usbc_base_addr) + USBC_REG_o_TXFIFOSZ )
238
#define USBC_REG_RXFIFOSZ(usbc_base_addr) ((usbc_base_addr) + USBC_REG_o_RXFIFOSZ )
239
#define USBC_REG_TXFIFOAD(usbc_base_addr) ((usbc_base_addr) + USBC_REG_o_TXFIFOAD )
240
#define USBC_REG_RXFIFOAD(usbc_base_addr) ((usbc_base_addr) + USBC_REG_o_RXFIFOAD )
241
#define USBC_REG_VEND0(usbc_base_addr) ((usbc_base_addr) + USBC_REG_o_VEND0 )
242
#define USBC_REG_VEND1(usbc_base_addr) ((usbc_base_addr) + USBC_REG_o_VEND1 )
243
#define USBC_REG_EPINFO(usbc_base_addr) ((usbc_base_addr) + USBC_REG_o_EPINFO )
244
#define USBC_REG_RAMINFO(usbc_base_addr) ((usbc_base_addr) + USBC_REG_o_RAMINFO )
245
#define USBC_REG_LINKINFO(usbc_base_addr) ((usbc_base_addr) + USBC_REG_o_LINKINFO )
246
#define USBC_REG_VPLEN(usbc_base_addr) ((usbc_base_addr) + USBC_REG_o_VPLEN )
247
#define USBC_REG_HSEOF(usbc_base_addr) ((usbc_base_addr) + USBC_REG_o_HSEOF )
248
#define USBC_REG_FSEOF(usbc_base_addr) ((usbc_base_addr) + USBC_REG_o_FSEOF )
249
#define USBC_REG_LSEOF(usbc_base_addr) ((usbc_base_addr) + USBC_REG_o_LSEOF )
250
251
#define USBC_REG_FADDR0(usbc_base_addr) ((usbc_base_addr) + USBC_REG_o_FADDR0 )
252
#define USBC_REG_HADDR0(usbc_base_addr) ((usbc_base_addr) + USBC_REG_o_HADDR0 )
253
#define USBC_REG_HPORT0(usbc_base_addr) ((usbc_base_addr) + USBC_REG_o_HPORT0 )
254
255
#define USBC_REG_TXFADDRx(usbc_base_addr, n) ((usbc_base_addr) + USBC_REG_o_TXFADDRx )
256
#define USBC_REG_TXHADDRx(usbc_base_addr, n) ((usbc_base_addr) + USBC_REG_o_TXHADDRx )
257
#define USBC_REG_TXHPORTx(usbc_base_addr, n) ((usbc_base_addr) + USBC_REG_o_TXHPORTx )
258
#define USBC_REG_RXFADDRx(usbc_base_addr, n) ((usbc_base_addr) + USBC_REG_o_RXFADDRx )
259
#define USBC_REG_RXHADDRx(usbc_base_addr, n) ((usbc_base_addr) + USBC_REG_o_RXHADDRx )
260
#define USBC_REG_RXHPORTx(usbc_base_addr, n) ((usbc_base_addr) + USBC_REG_o_RXHPORTx )
261
262
#define USBC_REG_RPCOUNTx(usbc_base_addr, n) ((usbc_base_addr) + USBC_REG_o_RPCOUNT )
263
264
#define USBC_REG_ISCR(usbc_base_addr) ((usbc_base_addr) + USBC_REG_o_ISCR )
265
#define USBC_REG_PHYCTL(usbc_base_addr) ((usbc_base_addr) + USBC_REG_o_PHYCTL )
266
#define USBC_REG_PHYBIST(usbc_base_addr) ((usbc_base_addr) + USBC_REG_o_PHYBIST )
267
#define USBC_REG_PHYTUNE(usbc_base_addr) ((usbc_base_addr) + USBC_REG_o_PHYTUNE )
268
#define USBC_REG_PMU_IRQ(usbc_base_addr) ((usbc_base_addr) + USBC_REG_o_PMU_IRQ )
269
#define USBC_REG_CSR(usbc_base_addr) ((usbc_base_addr) + USBC_REG_o_CSR)
270
//-----------------------------------------------------------------------
271
// bit position
272
//-----------------------------------------------------------------------
273
274
/* USB Power Control for Host only */
275
#define USBC_BP_POWER_H_HIGH_SPEED_EN 5
276
#define USBC_BP_POWER_H_HIGH_SPEED_FLAG 4
277
#define USBC_BP_POWER_H_RESET 3
278
#define USBC_BP_POWER_H_RESUME 2
279
#define USBC_BP_POWER_H_SUSPEND 1
280
#define USBC_BP_POWER_H_SUEPEND_EN 0
281
282
/* USB Power Control for device only */
283
#define USBC_BP_POWER_D_ISO_UPDATE_EN 7
284
#define USBC_BP_POWER_D_SOFT_CONNECT 6
285
#define USBC_BP_POWER_D_HIGH_SPEED_EN 5
286
#define USBC_BP_POWER_D_HIGH_SPEED_FLAG 4
287
#define USBC_BP_POWER_D_RESET_FLAG 3
288
#define USBC_BP_POWER_D_RESUME 2
289
#define USBC_BP_POWER_D_SUSPEND 1
290
#define USBC_BP_POWER_D_ENABLE_SUSPENDM 0
291
292
/* interrupt flags for ep0 and the Tx ep1~4 */
293
#define USBC_BP_INTTx_FLAG_EP5 5
294
#define USBC_BP_INTTx_FLAG_EP4 4
295
#define USBC_BP_INTTx_FLAG_EP3 3
296
#define USBC_BP_INTTx_FLAG_EP2 2
297
#define USBC_BP_INTTx_FLAG_EP1 1
298
#define USBC_BP_INTTx_FLAG_EP0 0
299
300
/* interrupt flags for Rx ep1~4 */
301
#define USBC_BP_INTRx_FLAG_EP5 5
302
#define USBC_BP_INTRx_FLAG_EP4 4
303
#define USBC_BP_INTRx_FLAG_EP3 3
304
#define USBC_BP_INTRx_FLAG_EP2 2
305
#define USBC_BP_INTRx_FLAG_EP1 1
306
307
/* interrupt enable for Tx ep0~4 */
308
#define USBC_BP_INTTxE_EN_EP5 5
309
#define USBC_BP_INTTxE_EN_EP4 4
310
#define USBC_BP_INTTxE_EN_EP3 3
311
#define USBC_BP_INTTxE_EN_EP2 2
312
#define USBC_BP_INTTxE_EN_EP1 1
313
#define USBC_BP_INTTxE_EN_EP0 0
314
315
/* interrupt enable for Rx ep1~4 */
316
#define USBC_BP_INTRxE_EN_EP5 5
317
#define USBC_BP_INTRxE_EN_EP4 4
318
#define USBC_BP_INTRxE_EN_EP3 3
319
#define USBC_BP_INTRxE_EN_EP2 2
320
#define USBC_BP_INTRxE_EN_EP1 1
321
322
/* USB interrupt */
323
#define USBC_BP_INTUSB_VBUS_ERROR 7
324
#define USBC_BP_INTUSB_SESSION_REQ 6
325
#define USBC_BP_INTUSB_DISCONNECT 5
326
#define USBC_BP_INTUSB_CONNECT 4
327
#define USBC_BP_INTUSB_SOF 3
328
#define USBC_BP_INTUSB_RESET 2
329
#define USBC_BP_INTUSB_RESUME 1
330
#define USBC_BP_INTUSB_SUSPEND 0
331
332
/* USB interrupt enable */
333
#define USBC_BP_INTUSBE_EN_VBUS_ERROR 7
334
#define USBC_BP_INTUSBE_EN_SESSION_REQ 6
335
#define USBC_BP_INTUSBE_EN_DISCONNECT 5
336
#define USBC_BP_INTUSBE_EN_CONNECT 4
337
#define USBC_BP_INTUSBE_EN_SOF 3
338
#define USBC_BP_INTUSBE_EN_RESET 2
339
#define USBC_BP_INTUSBE_EN_RESUME 1
340
#define USBC_BP_INTUSBE_EN_SUSPEND 0
341
342
/* Test Mode Control */
343
#define USBC_BP_TMCTL_FORCE_HOST 7
344
#define USBC_BP_TMCTL_FIFO_ACCESS 6
345
#define USBC_BP_TMCTL_FORCE_FS 5
346
#define USBC_BP_TMCTL_FORCE_HS 4
347
#define USBC_BP_TMCTL_TEST_PACKET 3
348
#define USBC_BP_TMCTL_TEST_K 2
349
#define USBC_BP_TMCTL_TEST_J 1
350
#define USBC_BP_TMCTL_TEST_SE0_NAK 0
351
352
/* Tx Max packet */
353
#define USBC_BP_TXMAXP_PACKET_COUNT 11
354
#define USBC_BP_TXMAXP_MAXIMUM_PAYLOAD 0
355
356
/* Control and Status Register for ep0 for Host only */
357
#define USBC_BP_CSR0_H_DisPing 11
358
#define USBC_BP_CSR0_H_FlushFIFO 8
359
#define USBC_BP_CSR0_H_NAK_Timeout 7
360
#define USBC_BP_CSR0_H_StatusPkt 6
361
#define USBC_BP_CSR0_H_ReqPkt 5
362
#define USBC_BP_CSR0_H_Error 4
363
#define USBC_BP_CSR0_H_SetupPkt 3
364
#define USBC_BP_CSR0_H_RxStall 2
365
#define USBC_BP_CSR0_H_TxPkRdy 1
366
#define USBC_BP_CSR0_H_RxPkRdy 0
367
368
/* Control and Status Register for ep0 for device only */
369
#define USBC_BP_CSR0_D_FLUSH_FIFO 8
370
#define USBC_BP_CSR0_D_SERVICED_SETUP_END 7
371
#define USBC_BP_CSR0_D_SERVICED_RX_PKT_READY 6
372
#define USBC_BP_CSR0_D_SEND_STALL 5
373
#define USBC_BP_CSR0_D_SETUP_END 4
374
#define USBC_BP_CSR0_D_DATA_END 3
375
#define USBC_BP_CSR0_D_SENT_STALL 2
376
#define USBC_BP_CSR0_D_TX_PKT_READY 1
377
#define USBC_BP_CSR0_D_RX_PKT_READY 0
378
379
/* Tx ep Control and Status Register for Host only */
380
#define USBC_BP_TXCSR_H_AUTOSET 15
381
#define USBC_BP_TXCSR_H_RESERVED 14
382
#define USBC_BP_TXCSR_H_MODE 13
383
#define USBC_BP_TXCSR_H_DMA_REQ_EN 12
384
#define USBC_BP_TXCSR_H_FORCE_DATA_TOGGLE 11
385
#define USBC_BP_TXCSR_H_DMA_REQ_MODE 10
386
#define USBC_BP_TXCSR_H_NAK_TIMEOUT 7
387
#define USBC_BP_TXCSR_H_CLEAR_DATA_TOGGLE 6
388
#define USBC_BP_TXCSR_H_TX_STALL 5
389
#define USBC_BP_TXCSR_H_FLUSH_FIFO 3
390
#define USBC_BP_TXCSR_H_ERROR 2
391
#define USBC_BP_TXCSR_H_FIFO_NOT_EMPTY 1
392
#define USBC_BP_TXCSR_H_TX_READY 0
393
394
/* Tx ep Control and Status Register for Device only */
395
#define USBC_BP_TXCSR_D_AUTOSET 15
396
#define USBC_BP_TXCSR_D_ISO 14
397
#define USBC_BP_TXCSR_D_MODE 13
398
#define USBC_BP_TXCSR_D_DMA_REQ_EN 12
399
#define USBC_BP_TXCSR_D_FORCE_DATA_TOGGLE 11
400
#define USBC_BP_TXCSR_D_DMA_REQ_MODE 10
401
#define USBC_BP_TXCSR_D_INCOMPLETE 7
402
#define USBC_BP_TXCSR_D_CLEAR_DATA_TOGGLE 6
403
#define USBC_BP_TXCSR_D_SENT_STALL 5
404
#define USBC_BP_TXCSR_D_SEND_STALL 4
405
#define USBC_BP_TXCSR_D_FLUSH_FIFO 3
406
#define USBC_BP_TXCSR_D_UNDER_RUN 2
407
#define USBC_BP_TXCSR_D_FIFO_NOT_EMPTY 1
408
#define USBC_BP_TXCSR_D_TX_READY 0
409
410
/* Rx Max Packet */
411
#define USBC_BP_RXMAXP_PACKET_COUNT 11
412
#define USBC_BP_RXMAXP_MAXIMUM_PAYLOAD 0
413
414
/* Rx ep Control and Status Register for Host only */
415
#define USBC_BP_RXCSR_H_AUTO_CLEAR 15
416
#define USBC_BP_RXCSR_H_AUTO_REQ 14
417
#define USBC_BP_RXCSR_H_DMA_REQ_EN 13
418
#define USBC_BP_RXCSR_H_PID_ERROR 12
419
#define USBC_BP_RXCSR_H_DMA_REQ_MODE 11
420
421
#define USBC_BP_RXCSR_H_INCOMPLETE 8
422
#define USBC_BP_RXCSR_H_CLEAR_DATA_TOGGLE 7
423
#define USBC_BP_RXCSR_H_RX_STALL 6
424
#define USBC_BP_RXCSR_H_REQ_PACKET 5
425
#define USBC_BP_RXCSR_H_FLUSH_FIFO 4
426
#define USBC_BP_RXCSR_H_NAK_TIMEOUT 3
427
#define USBC_BP_RXCSR_H_ERROR 2
428
#define USBC_BP_RXCSR_H_FIFO_FULL 1
429
#define USBC_BP_RXCSR_H_RX_PKT_READY 0
430
431
/* Rx ep Control and Status Register for Device only */
432
#define USBC_BP_RXCSR_D_AUTO_CLEAR 15
433
#define USBC_BP_RXCSR_D_ISO 14
434
#define USBC_BP_RXCSR_D_DMA_REQ_EN 13
435
#define USBC_BP_RXCSR_D_DISABLE_NYET 12
436
#define USBC_BP_RXCSR_D_DMA_REQ_MODE 11
437
438
#define USBC_BP_RXCSR_D_INCOMPLETE 8
439
#define USBC_BP_RXCSR_D_CLEAR_DATA_TOGGLE 7
440
#define USBC_BP_RXCSR_D_SENT_STALL 6
441
#define USBC_BP_RXCSR_D_SEND_STALL 5
442
#define USBC_BP_RXCSR_D_FLUSH_FIFO 4
443
#define USBC_BP_RXCSR_D_DATA_ERROR 3
444
#define USBC_BP_RXCSR_D_OVERRUN 2
445
#define USBC_BP_RXCSR_D_FIFO_FULL 1
446
#define USBC_BP_RXCSR_D_RX_PKT_READY 0
447
448
/* Tx Type Register for host only */
449
#define USBC_BP_TXTYPE_SPEED 6
//new
450
#define USBC_BP_TXTYPE_PROROCOL 4
451
#define USBC_BP_TXTYPE_TARGET_EP_NUM 0
452
453
/* Rx Type Register for host only */
454
#define USBC_BP_RXTYPE_SPEED 6
//new
455
#define USBC_BP_RXTYPE_PROROCOL 4
456
#define USBC_BP_RXTYPE_TARGET_EP_NUM 0
457
458
/* Core Configueation */
459
#define USBC_BP_CONFIGDATA_MPRXE 7
460
#define USBC_BP_CONFIGDATA_MPTXE 6
461
#define USBC_BP_CONFIGDATA_BIGENDIAN 5
462
#define USBC_BP_CONFIGDATA_HBRXE 4
463
#define USBC_BP_CONFIGDATA_HBTXE 3
464
#define USBC_BP_CONFIGDATA_DYNFIFO_SIZING 2
465
#define USBC_BP_CONFIGDATA_SOFTCONE 1
466
#define USBC_BP_CONFIGDATA_UTMI_DATAWIDTH 0
467
468
/* OTG Device Control */
469
#define USBC_BP_DEVCTL_B_DEVICE 7
470
#define USBC_BP_DEVCTL_FS_DEV 6
471
#define USBC_BP_DEVCTL_LS_DEV 5
472
473
#define USBC_BP_DEVCTL_VBUS 3
474
#define USBC_BP_DEVCTL_HOST_MODE 2
475
#define USBC_BP_DEVCTL_HOST_REQ 1
476
#define USBC_BP_DEVCTL_SESSION 0
477
478
/* Tx EP FIFO size control */
479
#define USBC_BP_TXFIFOSZ_DPB 4
480
#define USBC_BP_TXFIFOSZ_SZ 0
481
482
/* Rx EP FIFO size control */
483
#define USBC_BP_RXFIFOSZ_DPB 4
484
#define USBC_BP_RXFIFOSZ_SZ 0
485
486
/* vendor0 */
487
#define USBC_BP_VEND0_DRQ_SEL 1
488
#define USBC_BP_VEND0_BUS_SEL 0
489
490
/* hub address */
491
#define USBC_BP_HADDR_MULTI_TT 7
492
493
/* Interface Status and Control */
494
#define USBC_BP_ISCR_VBUS_VALID_FROM_DATA 30
495
#define USBC_BP_ISCR_VBUS_VALID_FROM_VBUS 29
496
#define USBC_BP_ISCR_EXT_ID_STATUS 28
497
#define USBC_BP_ISCR_EXT_DM_STATUS 27
498
#define USBC_BP_ISCR_EXT_DP_STATUS 26
499
#define USBC_BP_ISCR_MERGED_VBUS_STATUS 25
500
#define USBC_BP_ISCR_MERGED_ID_STATUS 24
501
502
#define USBC_BP_ISCR_ID_PULLUP_EN 17
503
#define USBC_BP_ISCR_DPDM_PULLUP_EN 16
504
#define USBC_BP_ISCR_FORCE_ID 14
505
#define USBC_BP_ISCR_FORCE_VBUS_VALID 12
506
#define USBC_BP_ISCR_VBUS_VALID_SRC 10
507
508
#define USBC_BP_ISCR_HOSC_EN 7
509
#define USBC_BP_ISCR_VBUS_CHANGE_DETECT 6
510
#define USBC_BP_ISCR_ID_CHANGE_DETECT 5
511
#define USBC_BP_ISCR_DPDM_CHANGE_DETECT 4
512
#define USBC_BP_ISCR_IRQ_ENABLE 3
513
#define USBC_BP_ISCR_VBUS_CHANGE_DETECT_EN 2
514
#define USBC_BP_ISCR_ID_CHANGE_DETECT_EN 1
515
#define USBC_BP_ISCR_DPDM_CHANGE_DETECT_EN 0
516
517
518
#define SUNXI_EHCI_AHB_ICHR8_EN (1 << 10)
519
#define SUNXI_EHCI_AHB_INCR4_BURST_EN (1 << 9)
520
#define SUNXI_EHCI_AHB_INCRX_ALIGN_EN (1 << 8)
521
#define SUNXI_EHCI_ULPI_BYPASS_EN (1 << 0)
522
//-----------------------------------------------------------------------
523
// �Զ���
524
//-----------------------------------------------------------------------
525
526
/* usb��Դ���� */
527
#define USBC_MAX_CTL_NUM 1
528
#define USBC_MAX_EP_NUM 3
//ep0~2, ep�ĸ���
529
#define USBC_MAX_FIFO_SIZE (2 * 1024)
530
531
/* usb OTG mode */
532
#define USBC_OTG_HOST 0
533
#define USBC_OTG_DEVICE 1
534
535
/* usb device type */
536
#define USBC_DEVICE_HSDEV 0
537
#define USBC_DEVICE_FSDEV 1
538
#define USBC_DEVICE_LSDEV 2
539
540
/* usb transfer type */
541
#define USBC_TS_TYPE_IDLE 0
542
#define USBC_TS_TYPE_CTRL 1
543
#define USBC_TS_TYPE_ISO 2
544
#define USBC_TS_TYPE_INT 3
545
#define USBC_TS_TYPE_BULK 4
546
547
/* usb transfer mode */
548
#define USBC_TS_MODE_UNKOWN 0
549
#define USBC_TS_MODE_LS 1
550
#define USBC_TS_MODE_FS 2
551
#define USBC_TS_MODE_HS 3
552
553
/* usb Vbus status */
554
#define USBC_VBUS_STATUS_BELOW_SESSIONEND 0
555
#define USBC_VBUS_STATUS_ABOVE_SESSIONEND_BELOW_AVALID 1
556
#define USBC_VBUS_STATUS_ABOVE_AVALID_BELOW_VBUSVALID 2
557
#define USBC_VBUS_STATUS_ABOVE_VBUSVALID 3
558
559
/* usb io type */
560
#define USBC_IO_TYPE_PIO 0
561
#define USBC_IO_TYPE_DMA 1
562
563
/* usb ep type */
564
#define USBC_EP_TYPE_IDLE 0
565
#define USBC_EP_TYPE_EP0 1
566
#define USBC_EP_TYPE_TX 2
567
#define USBC_EP_TYPE_RX 3
568
569
/* usb id type */
570
#define USBC_ID_TYPE_DISABLE 0
571
#define USBC_ID_TYPE_HOST 1
572
#define USBC_ID_TYPE_DEVICE 2
573
574
/* usb vbus valid type */
575
#define USBC_VBUS_TYPE_DISABLE 0
576
#define USBC_VBUS_TYPE_LOW 1
577
#define USBC_VBUS_TYPE_HIGH 2
578
579
/* usb a valid source */
580
#define USBC_A_VALID_SOURCE_UTMI_AVALID 0
581
#define USBC_A_VALID_SOURCE_UTMI_VBUS 1
582
583
/* usb device switch */
584
#define USBC_DEVICE_SWITCH_OFF 0
585
#define USBC_DEVICE_SWITCH_ON 1
586
587
/* usb fifo config mode */
588
#define USBC_FIFO_MODE_4K 0
589
#define USBC_FIFO_MODE_8K 1
590
591
/*
592
**************************************************
593
* usb interrupt mask
594
*
595
**************************************************
596
*/
597
598
/* interrupt flags for ep0 and the Tx ep1~4 */
599
#define USBC_INTTx_FLAG_EP5 (1 << USBC_BP_INTTx_FLAG_EP5)
600
#define USBC_INTTx_FLAG_EP4 (1 << USBC_BP_INTTx_FLAG_EP4)
601
#define USBC_INTTx_FLAG_EP3 (1 << USBC_BP_INTTx_FLAG_EP3)
602
#define USBC_INTTx_FLAG_EP2 (1 << USBC_BP_INTTx_FLAG_EP2)
603
#define USBC_INTTx_FLAG_EP1 (1 << USBC_BP_INTTx_FLAG_EP1)
604
#define USBC_INTTx_FLAG_EP0 (1 << USBC_BP_INTTx_FLAG_EP0)
605
606
/* interrupt flags for Rx ep1~4 */
607
#define USBC_INTRx_FLAG_EP5 (1 << USBC_BP_INTRx_FLAG_EP5)
608
#define USBC_INTRx_FLAG_EP4 (1 << USBC_BP_INTRx_FLAG_EP4)
609
#define USBC_INTRx_FLAG_EP3 (1 << USBC_BP_INTRx_FLAG_EP3)
610
#define USBC_INTRx_FLAG_EP2 (1 << USBC_BP_INTRx_FLAG_EP2)
611
#define USBC_INTRx_FLAG_EP1 (1 << USBC_BP_INTRx_FLAG_EP1)
612
613
/* USB interrupt */
614
#define USBC_INTUSB_VBUS_ERROR (1 << USBC_BP_INTUSB_VBUS_ERROR)
615
#define USBC_INTUSB_SESSION_REQ (1 << USBC_BP_INTUSB_SESSION_REQ)
616
#define USBC_INTUSB_DISCONNECT (1 << USBC_BP_INTUSB_DISCONNECT)
617
#define USBC_INTUSB_CONNECT (1 << USBC_BP_INTUSB_CONNECT)
618
#define USBC_INTUSB_SOF (1 << USBC_BP_INTUSB_SOF)
619
#define USBC_INTUSB_RESET (1 << USBC_BP_INTUSB_RESET)
620
#define USBC_INTUSB_RESUME (1 << USBC_BP_INTUSB_RESUME)
621
#define USBC_INTUSB_SUSPEND (1 << USBC_BP_INTUSB_SUSPEND)
622
623
#define USB_CSRL0_NAKTO 0x00000080
// NAK Timeout
624
#define USB_CSRL0_SETENDC 0x00000080
// Setup End Clear
625
#define USB_CSRL0_STATUS 0x00000040
// STATUS Packet
626
#define USB_CSRL0_RXRDYC 0x00000040
// RXRDY Clear
627
#define USB_CSRL0_REQPKT 0x00000020
// Request Packet
628
#define USB_CSRL0_STALL 0x00000020
// Send Stall
629
#define USB_CSRL0_SETEND 0x00000010
// Setup End
630
#define USB_CSRL0_ERROR 0x00000010
// Error
631
#define USB_CSRL0_DATAEND 0x00000008
// Data End
632
#define USB_CSRL0_SETUP 0x00000008
// Setup Packet
633
#define USB_CSRL0_STALLED 0x00000004
// Endpoint Stalled
634
#define USB_CSRL0_TXRDY 0x00000002
// Transmit Packet Ready
635
#define USB_CSRL0_RXRDY 0x00000001
// Receive Packet Ready
636
637
#define USB_RXFIFOSZ_DPB 0x00000010
// Double Packet Buffer Support
638
#define USB_RXFIFOSZ_SIZE_M 0x0000000F
// Max Packet Size
639
640
#define USB_TXFIFOSZ_DPB 0x00000010
// Double Packet Buffer Support
641
#define USB_TXFIFOSZ_SIZE_M 0x0000000F
// Max Packet Size
642
643
#endif
Firmware
FFBoard
USB
portable
sunxi
musb_def.h
Generated by
1.9.2