1 // SPDX-License-Identifier: GPL-2.0+
3 * Intel PXA25x on-chip full speed USB device controller
5 * Copyright (C) 2003 Robert Schwebel <r.schwebel@pengutronix.de>, Pengutronix
6 * Copyright (C) 2003 David Brownell
9 #ifndef __LINUX_USB_GADGET_PXA25X_H
10 #define __LINUX_USB_GADGET_PXA25X_H
12 #include <linux/types.h>
14 /*-------------------------------------------------------------------------*/
16 /* pxa25x has this (move to include/asm-arm/arch-pxa/pxa-regs.h) */
17 #define UFNRH_SIR (1 << 7) /* SOF interrupt request */
18 #define UFNRH_SIM (1 << 6) /* SOF interrupt mask */
19 #define UFNRH_IPE14 (1 << 5) /* ISO packet error, ep14 */
20 #define UFNRH_IPE9 (1 << 4) /* ISO packet error, ep9 */
21 #define UFNRH_IPE4 (1 << 3) /* ISO packet error, ep4 */
23 /* pxa255 has this (move to include/asm-arm/arch-pxa/pxa-regs.h) */
24 #define UDCCFR UDC_RES2 /* UDC Control Function Register */
25 #define UDCCFR_AREN (1 << 7) /* ACK response enable (now) */
26 #define UDCCFR_ACM (1 << 2) /* ACK control mode (wait for AREN) */
28 /* latest pxa255 errata define new "must be one" bits in UDCCFR */
29 #define UDCCFR_MB1 (0xff & ~(UDCCFR_AREN|UDCCFR_ACM))
31 /*-------------------------------------------------------------------------*/
37 struct pxa25x_udc
*dev
;
39 struct list_head queue
;
40 unsigned long pio_irqs
;
42 unsigned short fifo_size
;
47 unsigned dma_fixup
: 1;
49 /* UDCCS = UDC Control/Status for this EP
50 * UBCR = UDC Byte Count Remaining (contents of OUT fifo)
51 * UDDR = UDC Endpoint Data Register (the fifo)
52 * DRCM = DMA Request Channel Map
59 struct pxa25x_request
{
60 struct usb_request req
;
61 struct list_head queue
;
72 #define EP0_FIFO_SIZE ((unsigned)16)
73 #define BULK_FIFO_SIZE ((unsigned)64)
74 #define ISO_FIFO_SIZE ((unsigned)256)
75 #define INT_FIFO_SIZE ((unsigned)8)
85 #ifdef CONFIG_USB_PXA25X_SMALL
86 /* when memory's tight, SMALL config saves code+data. */
87 #define PXA_UDC_NUM_ENDPOINTS 3
90 #ifndef PXA_UDC_NUM_ENDPOINTS
91 #define PXA_UDC_NUM_ENDPOINTS 16
95 struct usb_gadget gadget
;
96 struct usb_gadget_driver
*driver
;
98 enum ep0_state ep0state
;
99 struct udc_stats stats
;
100 unsigned got_irq
: 1,
110 #define start_watchdog(dev) mod_timer(&dev->timer, jiffies + (HZ/200))
111 struct timer_list timer
;
115 struct pxa2xx_udc_mach_info
*mach
;
116 struct usb_phy
*transceiver
;
118 struct pxa25x_ep ep
[PXA_UDC_NUM_ENDPOINTS
];
120 #ifdef CONFIG_USB_GADGET_DEBUG_FS
121 struct dentry
*debugfs_udc
;
125 #define to_pxa25x(g) (container_of((g), struct pxa25x_udc, gadget))
127 /*-------------------------------------------------------------------------*/
129 #ifdef CONFIG_ARCH_LUBBOCK
130 #include <mach/lubbock.h>
131 /* lubbock can also report usb connect/disconnect irqs */
134 static struct pxa25x_udc
*the_controller
;
136 /*-------------------------------------------------------------------------*/
139 * Debugging support vanishes in non-debug builds. DBG_NORMAL should be
140 * mostly silent during normal use/testing, with no timing side-effects.
142 #define DBG_NORMAL 1 /* error paths, device state transitions */
143 #define DBG_VERBOSE 2 /* add some success path trace info */
144 #define DBG_NOISY 3 /* ... even more: request level */
145 #define DBG_VERY_NOISY 4 /* ... even more: packet level */
147 #define DMSG(stuff...) pr_debug("udc: " stuff)
151 static const char *state_name
[] = {
153 "EP0_IN_DATA_PHASE", "EP0_OUT_DATA_PHASE",
154 "EP0_END_XFER", "EP0_STALL"
158 # define UDC_DEBUG DBG_VERBOSE
160 # define UDC_DEBUG DBG_NORMAL
163 static void __maybe_unused
164 dump_udccr(const char *label
)
167 DMSG("%s %02X =%s%s%s%s%s%s%s%s\n",
169 (udccr
& UDCCR_REM
) ? " rem" : "",
170 (udccr
& UDCCR_RSTIR
) ? " rstir" : "",
171 (udccr
& UDCCR_SRM
) ? " srm" : "",
172 (udccr
& UDCCR_SUSIR
) ? " susir" : "",
173 (udccr
& UDCCR_RESIR
) ? " resir" : "",
174 (udccr
& UDCCR_RSM
) ? " rsm" : "",
175 (udccr
& UDCCR_UDA
) ? " uda" : "",
176 (udccr
& UDCCR_UDE
) ? " ude" : "");
179 static void __maybe_unused
180 dump_udccs0(const char *label
)
184 DMSG("%s %s %02X =%s%s%s%s%s%s%s%s\n",
185 label
, state_name
[the_controller
->ep0state
], udccs0
,
186 (udccs0
& UDCCS0_SA
) ? " sa" : "",
187 (udccs0
& UDCCS0_RNE
) ? " rne" : "",
188 (udccs0
& UDCCS0_FST
) ? " fst" : "",
189 (udccs0
& UDCCS0_SST
) ? " sst" : "",
190 (udccs0
& UDCCS0_DRWF
) ? " dwrf" : "",
191 (udccs0
& UDCCS0_FTF
) ? " ftf" : "",
192 (udccs0
& UDCCS0_IPR
) ? " ipr" : "",
193 (udccs0
& UDCCS0_OPR
) ? " opr" : "");
196 static inline u32
udc_ep_get_UDCCS(struct pxa25x_ep
*);
198 static void __maybe_unused
199 dump_state(struct pxa25x_udc
*dev
)
204 DMSG("%s, uicr %02X.%02X, usir %02X.%02x, ufnr %02X.%02X\n",
205 state_name
[dev
->ep0state
],
206 UICR1
, UICR0
, USIR1
, USIR0
, UFNRH
, UFNRL
);
210 DMSG("udccfr %02X =%s%s\n", tmp
,
211 (tmp
& UDCCFR_AREN
) ? " aren" : "",
212 (tmp
& UDCCFR_ACM
) ? " acm" : "");
216 DMSG("no gadget driver bound\n");
219 DMSG("ep0 driver '%s'\n", dev
->driver
->driver
.name
);
221 dump_udccs0 ("udccs0");
222 DMSG("ep0 IN %lu/%lu, OUT %lu/%lu\n",
223 dev
->stats
.write
.bytes
, dev
->stats
.write
.ops
,
224 dev
->stats
.read
.bytes
, dev
->stats
.read
.ops
);
226 for (i
= 1; i
< PXA_UDC_NUM_ENDPOINTS
; i
++) {
227 if (dev
->ep
[i
].ep
.desc
== NULL
)
229 DMSG ("udccs%d = %02x\n", i
, udc_ep_get_UDCCS(&dev
->ep
[i
]));
235 #define dump_udccr(x) do{}while(0)
236 #define dump_udccs0(x) do{}while(0)
237 #define dump_state(x) do{}while(0)
239 #define UDC_DEBUG ((unsigned)0)
243 #define DBG(lvl, stuff...) do{if ((lvl) <= UDC_DEBUG) DMSG(stuff);}while(0)
245 #define ERR(stuff...) pr_err("udc: " stuff)
246 #define WARNING(stuff...) pr_warn("udc: " stuff)
247 #define INFO(stuff...) pr_info("udc: " stuff)
250 #endif /* __LINUX_USB_GADGET_PXA25X_H */