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