1 #ifndef __LINUX_UHCI_HCD_H
2 #define __LINUX_UHCI_HCD_H
4 #include <linux/list.h>
7 #define usb_packetid(pipe) (usb_pipein(pipe) ? USB_PID_IN : USB_PID_OUT)
8 #define PIPE_DEVEP_MASK 0x0007ff00
17 #define USBCMD_RS 0x0001
18 #define USBCMD_HCRESET 0x0002
19 #define USBCMD_GRESET 0x0004
20 #define USBCMD_EGSM 0x0008
21 #define USBCMD_FGR 0x0010
22 #define USBCMD_SWDBG 0x0020
23 #define USBCMD_CF 0x0040
24 #define USBCMD_MAXP 0x0080
28 #define USBSTS_USBINT 0x0001
29 #define USBSTS_ERROR 0x0002
30 #define USBSTS_RD 0x0004
31 #define USBSTS_HSE 0x0008
32 #define USBSTS_HCPE 0x0010
34 #define USBSTS_HCH 0x0020
38 #define USBINTR_TIMEOUT 0x0001
39 #define USBINTR_RESUME 0x0002
40 #define USBINTR_IOC 0x0004
41 #define USBINTR_SP 0x0008
44 #define USBFLBASEADD 8
46 #define USBSOF_DEFAULT 64
51 #define USBPORTSC_CCS 0x0001
53 #define USBPORTSC_CSC 0x0002
54 #define USBPORTSC_PE 0x0004
55 #define USBPORTSC_PEC 0x0008
56 #define USBPORTSC_DPLUS 0x0010
57 #define USBPORTSC_DMINUS 0x0020
58 #define USBPORTSC_RD 0x0040
59 #define USBPORTSC_RES1 0x0080
60 #define USBPORTSC_LSDA 0x0100
61 #define USBPORTSC_PR 0x0200
63 #define USBPORTSC_OC 0x0400
64 #define USBPORTSC_OCC 0x0800
65 #define USBPORTSC_SUSP 0x1000
66 #define USBPORTSC_RES2 0x2000
67 #define USBPORTSC_RES3 0x4000
68 #define USBPORTSC_RES4 0x8000
71 #define USBLEGSUP 0xc0
72 #define USBLEGSUP_DEFAULT 0x2000
73 #define USBLEGSUP_RWC 0x8f00
74 #define USBLEGSUP_RO 0x5040
77 #define USBRES_INTEL 0xc4
78 #define USBPORT1EN 0x01
79 #define USBPORT2EN 0x02
81 #define UHCI_PTR_BITS(uhci) cpu_to_hc32((uhci), 0x000F)
82 #define UHCI_PTR_TERM(uhci) cpu_to_hc32((uhci), 0x0001)
83 #define UHCI_PTR_QH(uhci) cpu_to_hc32((uhci), 0x0002)
84 #define UHCI_PTR_DEPTH(uhci) cpu_to_hc32((uhci), 0x0004)
85 #define UHCI_PTR_BREADTH(uhci) cpu_to_hc32((uhci), 0x0000)
87 #define UHCI_NUMFRAMES 1024
88 #define UHCI_MAX_SOF_NUMBER 2047
89 #define CAN_SCHEDULE_FRAMES 1000
95 #define FSBR_OFF_DELAY msecs_to_jiffies(10)
98 #define QH_WAIT_TIMEOUT msecs_to_jiffies(200)
109 #ifdef CONFIG_USB_UHCI_BIG_ENDIAN_DESC
113 #define __hc32 __le32
114 #define __hc16 __le16
141 #define QH_STATE_IDLE 1
142 #define QH_STATE_UNLINKING 2
145 #define QH_STATE_ACTIVE 3
156 struct usb_host_endpoint *
hep;
187 #define qh_element(qh) ACCESS_ONCE((qh)->element)
189 #define LINK_TO_QH(uhci, qh) (UHCI_PTR_QH((uhci)) | \
190 cpu_to_hc32((uhci), (qh)->dma_handle))
200 #define TD_CTRL_SPD (1 << 29)
201 #define TD_CTRL_C_ERR_MASK (3 << 27)
202 #define TD_CTRL_C_ERR_SHIFT 27
203 #define TD_CTRL_LS (1 << 26)
204 #define TD_CTRL_IOS (1 << 25)
205 #define TD_CTRL_IOC (1 << 24)
206 #define TD_CTRL_ACTIVE (1 << 23)
207 #define TD_CTRL_STALLED (1 << 22)
208 #define TD_CTRL_DBUFERR (1 << 21)
209 #define TD_CTRL_BABBLE (1 << 20)
210 #define TD_CTRL_NAK (1 << 19)
211 #define TD_CTRL_CRCTIMEO (1 << 18)
212 #define TD_CTRL_BITSTUFF (1 << 17)
213 #define TD_CTRL_ACTLEN_MASK 0x7FF
215 #define TD_CTRL_ANY_ERROR (TD_CTRL_STALLED | TD_CTRL_DBUFERR | \
216 TD_CTRL_BABBLE | TD_CTRL_CRCTIME | \
219 #define uhci_maxerr(err) ((err) << TD_CTRL_C_ERR_SHIFT)
220 #define uhci_status_bits(ctrl_sts) ((ctrl_sts) & 0xF60000)
221 #define uhci_actual_length(ctrl_sts) (((ctrl_sts) + 1) & \
227 #define td_token(uhci, td) hc32_to_cpu((uhci), (td)->token)
228 #define TD_TOKEN_DEVADDR_SHIFT 8
229 #define TD_TOKEN_TOGGLE_SHIFT 19
230 #define TD_TOKEN_TOGGLE (1 << 19)
231 #define TD_TOKEN_EXPLEN_SHIFT 21
232 #define TD_TOKEN_EXPLEN_MASK 0x7FF
233 #define TD_TOKEN_PID_MASK 0xFF
235 #define uhci_explen(len) ((((len) - 1) & TD_TOKEN_EXPLEN_MASK) << \
236 TD_TOKEN_EXPLEN_SHIFT)
238 #define uhci_expected_length(token) ((((token) >> TD_TOKEN_EXPLEN_SHIFT) + \
239 1) & TD_TOKEN_EXPLEN_MASK)
240 #define uhci_toggle(token) (((token) >> TD_TOKEN_TOGGLE_SHIFT) & 1)
241 #define uhci_endpoint(token) (((token) >> 15) & 0xf)
242 #define uhci_devaddr(token) (((token) >> TD_TOKEN_DEVADDR_SHIFT) & 0x7f)
243 #define uhci_devep(token) (((token) >> TD_TOKEN_DEVADDR_SHIFT) & 0x7ff)
244 #define uhci_packetid(token) ((token) & TD_TOKEN_PID_MASK)
245 #define uhci_packetout(token) (uhci_packetid(token) != USB_PID_IN)
246 #define uhci_packetin(token) (uhci_packetid(token) == USB_PID_IN)
278 #define td_status(uhci, td) hc32_to_cpu((uhci), \
279 ACCESS_ONCE((td)->status))
281 #define LINK_TO_TD(uhci, td) (cpu_to_hc32((uhci), (td)->dma_handle))
329 #define UHCI_NUM_SKELQH 11
330 #define SKEL_UNLINK 0
331 #define skel_unlink_qh skelqh[SKEL_UNLINK]
333 #define skel_iso_qh skelqh[SKEL_ISO]
335 #define SKEL_INDEX(exponent) (9 - exponent)
337 #define skel_async_qh skelqh[SKEL_ASYNC]
339 #define skel_term_qh skelqh[SKEL_TERM]
342 #define SKEL_LS_CONTROL 20
343 #define SKEL_FS_CONTROL 21
344 #define SKEL_FSBR SKEL_FS_CONTROL
412 #define UHCI_IS_STOPPED 9999
462 static inline struct uhci_hcd *hcd_to_uhci(
struct usb_hcd *hcd)
464 return (
struct uhci_hcd *) (hcd->hcd_priv);
466 static inline struct usb_hcd *uhci_to_hcd(
struct uhci_hcd *uhci)
468 return container_of((
void *) uhci,
struct usb_hcd, hcd_priv);
471 #define uhci_dev(u) (uhci_to_hcd(u)->self.controller)
474 #define uhci_frame_before_eq(f1, f2) (0 <= (int) ((f2) - (f1)))
494 #define PCI_VENDOR_ID_GENESYS 0x17a0
495 #define PCI_DEVICE_ID_GL880S_UHCI 0x8083
503 #ifndef CONFIG_USB_UHCI_SUPPORT_NON_PCI_HC
505 static inline u32 uhci_readl(
const struct uhci_hcd *uhci,
int reg)
515 static inline u16 uhci_readw(
const struct uhci_hcd *uhci,
int reg)
525 static inline u8 uhci_readb(
const struct uhci_hcd *uhci,
int reg)
530 static inline void uhci_writeb(
const struct uhci_hcd *uhci,
u8 val,
int reg)
539 #define uhci_has_pci_registers(u) ((u)->io_addr != 0)
542 #define uhci_has_pci_registers(u) 0
545 #ifdef CONFIG_USB_UHCI_BIG_ENDIAN_MMIO
547 #define uhci_big_endian_mmio(u) ((u)->big_endian_mmio)
549 #define uhci_big_endian_mmio(u) 0
552 static inline u32 uhci_readl(
const struct uhci_hcd *uhci,
int reg)
554 if (uhci_has_pci_registers(uhci))
556 #ifdef CONFIG_USB_UHCI_BIG_ENDIAN_MMIO
557 else if (uhci_big_endian_mmio(uhci))
564 static inline void uhci_writel(
const struct uhci_hcd *uhci,
u32 val,
int reg)
566 if (uhci_has_pci_registers(uhci))
568 #ifdef CONFIG_USB_UHCI_BIG_ENDIAN_MMIO
569 else if (uhci_big_endian_mmio(uhci))
576 static inline u16 uhci_readw(
const struct uhci_hcd *uhci,
int reg)
578 if (uhci_has_pci_registers(uhci))
580 #ifdef CONFIG_USB_UHCI_BIG_ENDIAN_MMIO
581 else if (uhci_big_endian_mmio(uhci))
588 static inline void uhci_writew(
const struct uhci_hcd *uhci,
u16 val,
int reg)
590 if (uhci_has_pci_registers(uhci))
592 #ifdef CONFIG_USB_UHCI_BIG_ENDIAN_MMIO
593 else if (uhci_big_endian_mmio(uhci))
600 static inline u8 uhci_readb(
const struct uhci_hcd *uhci,
int reg)
602 if (uhci_has_pci_registers(uhci))
604 #ifdef CONFIG_USB_UHCI_BIG_ENDIAN_MMIO
605 else if (uhci_big_endian_mmio(uhci))
612 static inline void uhci_writeb(
const struct uhci_hcd *uhci,
u8 val,
int reg)
614 if (uhci_has_pci_registers(uhci))
616 #ifdef CONFIG_USB_UHCI_BIG_ENDIAN_MMIO
617 else if (uhci_big_endian_mmio(uhci))
631 #ifdef CONFIG_USB_UHCI_BIG_ENDIAN_DESC
632 #define uhci_big_endian_desc(u) ((u)->big_endian_desc)
637 return uhci_big_endian_desc(uhci)
645 return uhci_big_endian_desc(uhci)