1
2
3
4
5
6
7
8
9#ifndef _FOTG210_H
10#define _FOTG210_H
11
12struct fotg210_regs {
13
14 struct {
15 uint32_t data[4];
16 } hccr;
17 struct {
18 uint32_t data[9];
19 } hcor;
20 uint32_t rsvd1[3];
21 uint32_t miscr;
22 uint32_t rsvd2[15];
23
24 uint32_t otgcsr;
25 uint32_t otgisr;
26 uint32_t otgier;
27 uint32_t rsvd3[13];
28 uint32_t isr;
29 uint32_t imr;
30 uint32_t rsvd4[14];
31
32 uint32_t dev_ctrl;
33 uint32_t dev_addr;
34 uint32_t dev_test;
35 uint32_t sof_fnr;
36 uint32_t sof_mtr;
37 uint32_t phy_tmsr;
38 uint32_t rsvd5[2];
39 uint32_t cxfifo;
40 uint32_t idle;
41 uint32_t rsvd6[2];
42 uint32_t gimr;
43 uint32_t gimr0;
44 uint32_t gimr1;
45 uint32_t gimr2;
46 uint32_t gisr;
47 uint32_t gisr0;
48 uint32_t gisr1;
49 uint32_t gisr2;
50 uint32_t rxzlp;
51 uint32_t txzlp;
52 uint32_t isoeasr;
53 uint32_t rsvd7[1];
54 uint32_t iep[8];
55 uint32_t oep[8];
56 uint32_t epmap14;
57 uint32_t epmap58;
58 uint32_t fifomap;
59 uint32_t fifocfg;
60 uint32_t fifocsr[4];
61 uint32_t dma_fifo;
62 uint32_t rsvd8[1];
63 uint32_t dma_ctrl;
64 uint32_t dma_addr;
65 uint32_t ep0_data;
66};
67
68
69#define MISCR_SUSPEND (1 << 6)
70#define MISCR_EOF2(x) (((x) & 0x3) << 4)
71#define MISCR_EOF1(x) (((x) & 0x3) << 2)
72#define MISCR_ASST(x) (((x) & 0x3) << 0)
73
74
75#define OTGCSR_SPD_HIGH (2 << 22)
76#define OTGCSR_SPD_LOW (1 << 22)
77#define OTGCSR_SPD_FULL (0 << 22)
78#define OTGCSR_SPD_MASK (3 << 22)
79#define OTGCSR_SPD_SHIFT 22
80#define OTGCSR_SPD(x) (((x) >> 22) & 0x03)
81#define OTGCSR_DEV_A (0 << 21)
82#define OTGCSR_DEV_B (1 << 21)
83#define OTGCSR_ROLE_H (0 << 20)
84#define OTGCSR_ROLE_D (1 << 20)
85#define OTGCSR_A_VBUS_VLD (1 << 19)
86#define OTGCSR_A_SESS_VLD (1 << 18)
87#define OTGCSR_B_SESS_VLD (1 << 17)
88#define OTGCSR_B_SESS_END (1 << 16)
89#define OTGCSR_HFT_LONG (1 << 11)
90#define OTGCSR_HFT (0 << 11)
91#define OTGCSR_VFT_LONG (1 << 10)
92#define OTGCSR_VFT (0 << 10)
93#define OTGCSR_IDFT_LONG (1 << 9)
94#define OTGCSR_IDFT (0 << 9)
95#define OTGCSR_A_SRPR_VBUS (0 << 8)
96#define OTGCSR_A_SRPR_DATA (1 << 8)
97#define OTGCSR_A_SRP_EN (1 << 7)
98#define OTGCSR_A_HNP (1 << 6)
99#define OTGCSR_A_BUSDROP (1 << 5)
100#define OTGCSR_A_BUSREQ (1 << 4)
101#define OTGCSR_B_VBUS_DISC (1 << 2)
102#define OTGCSR_B_HNP (1 << 1)
103#define OTGCSR_B_BUSREQ (1 << 0)
104
105
106#define OTGISR_APRM (1 << 12)
107#define OTGISR_BPRM (1 << 11)
108#define OTGISR_OVD (1 << 10)
109#define OTGISR_IDCHG (1 << 9)
110#define OTGISR_RLCHG (1 << 8)
111#define OTGISR_BSESSEND (1 << 6)
112#define OTGISR_AVBUSERR (1 << 5)
113#define OTGISR_ASRP (1 << 4)
114#define OTGISR_BSRP (1 << 0)
115
116
117#define OTGIER_APRM (1 << 12)
118#define OTGIER_BPRM (1 << 11)
119#define OTGIER_OVD (1 << 10)
120#define OTGIER_IDCHG (1 << 9)
121#define OTGIER_RLCHG (1 << 8)
122#define OTGIER_BSESSEND (1 << 6)
123#define OTGIER_AVBUSERR (1 << 5)
124#define OTGIER_ASRP (1 << 4)
125#define OTGIER_BSRP (1 << 0)
126
127
128#define ISR_HOST (1 << 2)
129#define ISR_OTG (1 << 1)
130#define ISR_DEV (1 << 0)
131#define ISR_MASK 0x07
132
133
134#define IMR_IRQLH (1 << 3)
135#define IMR_IRQLL (0 << 3)
136#define IMR_HOST (1 << 2)
137#define IMR_OTG (1 << 1)
138#define IMR_DEV (1 << 0)
139#define IMR_MASK 0x0f
140
141
142#define DEVCTRL_FS_FORCED (1 << 9)
143#define DEVCTRL_HS (1 << 6)
144#define DEVCTRL_FS (0 << 6)
145#define DEVCTRL_EN (1 << 5)
146#define DEVCTRL_RESET (1 << 4)
147#define DEVCTRL_SUSPEND (1 << 3)
148#define DEVCTRL_GIRQ_EN (1 << 2)
149#define DEVCTRL_HALFSPD (1 << 1)
150#define DEVCTRL_RWAKEUP (1 << 0)
151
152
153#define DEVADDR_CONF (1 << 7)
154#define DEVADDR_ADDR(x) ((x) & 0x7f)
155#define DEVADDR_ADDR_MASK 0x7f
156
157
158#define DEVTEST_NOSOF (1 << 6)
159#define DEVTEST_TST_MODE (1 << 5)
160#define DEVTEST_TST_NOTS (1 << 4)
161#define DEVTEST_TST_NOCRC (1 << 3)
162#define DEVTEST_TST_CLREA (1 << 2)
163#define DEVTEST_TST_CXLP (1 << 1)
164#define DEVTEST_TST_CLRFF (1 << 0)
165
166
167#define SOFFNR_UFN(x) (((x) >> 11) & 0x7)
168#define SOFFNR_FNR(x) ((x) & 0x7ff)
169
170
171#define SOFMTR_TMR(x) ((x) & 0xffff)
172
173
174#define PHYTMSR_TST_PKT (1 << 4)
175#define PHYTMSR_TST_SE0NAK (1 << 3)
176#define PHYTMSR_TST_KSTA (1 << 2)
177#define PHYTMSR_TST_JSTA (1 << 1)
178#define PHYTMSR_UNPLUG (1 << 0)
179
180
181#define CXFIFO_BYTES(x) (((x) >> 24) & 0x7f)
182#define CXFIFO_FIFOE(x) (1 << (((x) & 0x03) + 8))
183#define CXFIFO_FIFOE_FIFO0 (1 << 8)
184#define CXFIFO_FIFOE_FIFO1 (1 << 9)
185#define CXFIFO_FIFOE_FIFO2 (1 << 10)
186#define CXFIFO_FIFOE_FIFO3 (1 << 11)
187#define CXFIFO_FIFOE_MASK (0x0f << 8)
188#define CXFIFO_CXFIFOE (1 << 5)
189#define CXFIFO_CXFIFOF (1 << 4)
190#define CXFIFO_CXFIFOCLR (1 << 3)
191#define CXFIFO_CXSTALL (1 << 2)
192#define CXFIFO_TSTPKTFIN (1 << 1)
193#define CXFIFO_CXFIN (1 << 0)
194
195
196#define IDLE_MS(x) ((x) & 0x07)
197
198
199#define GIMR_GRP2 (1 << 2)
200#define GIMR_GRP1 (1 << 1)
201#define GIMR_GRP0 (1 << 0)
202#define GIMR_MASK 0x07
203
204
205#define GIMR0_CXABORT (1 << 5)
206#define GIMR0_CXERR (1 << 4)
207#define GIMR0_CXEND (1 << 3)
208#define GIMR0_CXOUT (1 << 2)
209#define GIMR0_CXIN (1 << 1)
210#define GIMR0_CXSETUP (1 << 0)
211#define GIMR0_MASK 0x3f
212
213
214#define GIMR1_FIFO_IN(x) (1 << (((x) & 3) + 16))
215#define GIMR1_FIFO_TX(x) GIMR1_FIFO_IN(x)
216#define GIMR1_FIFO_OUT(x) (1 << (((x) & 3) * 2))
217#define GIMR1_FIFO_SPK(x) (1 << (((x) & 3) * 2 + 1))
218#define GIMR1_FIFO_RX(x) (GIMR1_FIFO_OUT(x) | GIMR1_FIFO_SPK(x))
219#define GIMR1_MASK 0xf00ff
220
221
222#define GIMR2_WAKEUP (1 << 10)
223#define GIMR2_IDLE (1 << 9)
224#define GIMR2_DMAERR (1 << 8)
225#define GIMR2_DMAFIN (1 << 7)
226#define GIMR2_ZLPRX (1 << 6)
227#define GIMR2_ZLPTX (1 << 5)
228#define GIMR2_ISOCABT (1 << 4)
229#define GIMR2_ISOCERR (1 << 3)
230#define GIMR2_RESUME (1 << 2)
231#define GIMR2_SUSPEND (1 << 1)
232#define GIMR2_RESET (1 << 0)
233#define GIMR2_MASK 0x7ff
234
235
236#define GISR_GRP2 (1 << 2)
237#define GISR_GRP1 (1 << 1)
238#define GISR_GRP0 (1 << 0)
239
240
241#define GISR0_CXABORT (1 << 5)
242#define GISR0_CXERR (1 << 4)
243#define GISR0_CXEND (1 << 3)
244#define GISR0_CXOUT (1 << 2)
245#define GISR0_CXIN (1 << 1)
246#define GISR0_CXSETUP (1 << 0)
247
248
249#define GISR1_IN_FIFO(x) (1 << (((x) & 0x03) + 16))
250#define GISR1_OUT_FIFO(x) (1 << (((x) & 0x03) * 2))
251#define GISR1_SPK_FIFO(x) (1 << (((x) & 0x03) * 2 + 1))
252#define GISR1_RX_FIFO(x) (3 << (((x) & 0x03) * 2))
253
254
255#define GISR2_WAKEUP (1 << 10)
256#define GISR2_IDLE (1 << 9)
257#define GISR2_DMAERR (1 << 8)
258#define GISR2_DMAFIN (1 << 7)
259#define GISR2_ZLPRX (1 << 6)
260#define GISR2_ZLPTX (1 << 5)
261#define GISR2_ISOCABT (1 << 4)
262#define GISR2_ISOCERR (1 << 3)
263#define GISR2_RESUME (1 << 2)
264#define GISR2_SUSPEND (1 << 1)
265#define GISR2_RESET (1 << 0)
266
267
268#define RXZLP_EP(x) (1 << ((x) - 1))
269
270
271#define TXZLP_EP(x) (1 << ((x) - 1))
272
273
274#define ISOEASR_EP(x) (0x10001 << ((x) - 1))
275
276
277#define IEP_SENDZLP (1 << 15)
278#define IEP_TNRHB(x) (((x) & 0x03) << 13) \
279
280#define IEP_RESET (1 << 12)
281#define IEP_STALL (1 << 11)
282#define IEP_MAXPS(x) ((x) & 0x7ff)
283
284
285#define OEP_RESET (1 << 12)
286#define OEP_STALL (1 << 11)
287#define OEP_MAXPS(x) ((x) & 0x7ff)
288
289
290#define EPMAP14_SET_IN(ep, fifo) \
291 ((fifo) & 3) << (((ep) - 1) << 3 + 0)
292#define EPMAP14_SET_OUT(ep, fifo) \
293 ((fifo) & 3) << (((ep) - 1) << 3 + 4)
294#define EPMAP14_SET(ep, in, out) \
295 do { \
296 EPMAP14_SET_IN(ep, in); \
297 EPMAP14_SET_OUT(ep, out); \
298 } while (0)
299
300#define EPMAP14_DEFAULT 0x33221100
301
302
303#define EPMAP58_SET_IN(ep, fifo) \
304 ((fifo) & 3) << (((ep) - 5) << 3 + 0)
305#define EPMAP58_SET_OUT(ep, fifo) \
306 ((fifo) & 3) << (((ep) - 5) << 3 + 4)
307#define EPMAP58_SET(ep, in, out) \
308 do { \
309 EPMAP58_SET_IN(ep, in); \
310 EPMAP58_SET_OUT(ep, out); \
311 } while (0)
312
313#define EPMAP58_DEFAULT 0x00000000
314
315
316#define FIFOMAP_BIDIR (2 << 4)
317#define FIFOMAP_IN (1 << 4)
318#define FIFOMAP_OUT (0 << 4)
319#define FIFOMAP_DIR_MASK 0x30
320#define FIFOMAP_EP(x) ((x) & 0x0f)
321#define FIFOMAP_EP_MASK 0x0f
322#define FIFOMAP_CFG_MASK 0x3f
323#define FIFOMAP_DEFAULT 0x04030201
324#define FIFOMAP(fifo, cfg) (((cfg) & 0x3f) << (((fifo) & 3) << 3))
325
326
327#define FIFOCFG_EN (1 << 5)
328#define FIFOCFG_BLKSZ_1024 (1 << 4)
329#define FIFOCFG_BLKSZ_512 (0 << 4)
330#define FIFOCFG_3BLK (2 << 2)
331#define FIFOCFG_2BLK (1 << 2)
332#define FIFOCFG_1BLK (0 << 2)
333#define FIFOCFG_NBLK_MASK 3
334#define FIFOCFG_NBLK_SHIFT 2
335#define FIFOCFG_INTR (3 << 0)
336#define FIFOCFG_BULK (2 << 0)
337#define FIFOCFG_ISOC (1 << 0)
338#define FIFOCFG_RSVD (0 << 0)
339#define FIFOCFG_TYPE_MASK 3
340#define FIFOCFG_TYPE_SHIFT 0
341#define FIFOCFG_CFG_MASK 0x3f
342#define FIFOCFG(fifo, cfg) (((cfg) & 0x3f) << (((fifo) & 3) << 3))
343
344
345#define FIFOCSR_RESET (1 << 12)
346#define FIFOCSR_BYTES(x) ((x) & 0x7ff)
347
348
349#define DMAFIFO_CX (1 << 4)
350#define DMAFIFO_FIFO(x) (1 << ((x) & 0x3))
351
352
353#define DMACTRL_LEN(x) (((x) & 0x1ffff) << 8)
354#define DMACTRL_LEN_SHIFT 8
355#define DMACTRL_CLRFF (1 << 4)
356#define DMACTRL_ABORT (1 << 3)
357#define DMACTRL_IO2IO (1 << 2)
358#define DMACTRL_FIFO2MEM (0 << 1)
359#define DMACTRL_MEM2FIFO (1 << 1)
360#define DMACTRL_START (1 << 0)
361
362#endif
363