aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/host/uhci-hcd.h
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/usb/host/uhci-hcd.h')
-rw-r--r--drivers/usb/host/uhci-hcd.h90
1 files changed, 74 insertions, 16 deletions
diff --git a/drivers/usb/host/uhci-hcd.h b/drivers/usb/host/uhci-hcd.h
index 0deeab6c9e56..7af2b7052047 100644
--- a/drivers/usb/host/uhci-hcd.h
+++ b/drivers/usb/host/uhci-hcd.h
@@ -78,11 +78,11 @@
78#define USBPORT1EN 0x01 78#define USBPORT1EN 0x01
79#define USBPORT2EN 0x02 79#define USBPORT2EN 0x02
80 80
81#define UHCI_PTR_BITS cpu_to_le32(0x000F) 81#define UHCI_PTR_BITS(uhci) cpu_to_hc32((uhci), 0x000F)
82#define UHCI_PTR_TERM cpu_to_le32(0x0001) 82#define UHCI_PTR_TERM(uhci) cpu_to_hc32((uhci), 0x0001)
83#define UHCI_PTR_QH cpu_to_le32(0x0002) 83#define UHCI_PTR_QH(uhci) cpu_to_hc32((uhci), 0x0002)
84#define UHCI_PTR_DEPTH cpu_to_le32(0x0004) 84#define UHCI_PTR_DEPTH(uhci) cpu_to_hc32((uhci), 0x0004)
85#define UHCI_PTR_BREADTH cpu_to_le32(0x0000) 85#define UHCI_PTR_BREADTH(uhci) cpu_to_hc32((uhci), 0x0000)
86 86
87#define UHCI_NUMFRAMES 1024 /* in the frame list [array] */ 87#define UHCI_NUMFRAMES 1024 /* in the frame list [array] */
88#define UHCI_MAX_SOF_NUMBER 2047 /* in an SOF packet */ 88#define UHCI_MAX_SOF_NUMBER 2047 /* in an SOF packet */
@@ -99,6 +99,22 @@
99 99
100 100
101/* 101/*
102 * __hc32 and __hc16 are "Host Controller" types, they may be equivalent to
103 * __leXX (normally) or __beXX (given UHCI_BIG_ENDIAN_DESC), depending on
104 * the host controller implementation.
105 *
106 * To facilitate the strongest possible byte-order checking from "sparse"
107 * and so on, we use __leXX unless that's not practical.
108 */
109#ifdef CONFIG_USB_UHCI_BIG_ENDIAN_DESC
110typedef __u32 __bitwise __hc32;
111typedef __u16 __bitwise __hc16;
112#else
113#define __hc32 __le32
114#define __hc16 __le16
115#endif
116
117/*
102 * Queue Headers 118 * Queue Headers
103 */ 119 */
104 120
@@ -130,8 +146,8 @@
130 146
131struct uhci_qh { 147struct uhci_qh {
132 /* Hardware fields */ 148 /* Hardware fields */
133 __le32 link; /* Next QH in the schedule */ 149 __hc32 link; /* Next QH in the schedule */
134 __le32 element; /* Queue element (TD) pointer */ 150 __hc32 element; /* Queue element (TD) pointer */
135 151
136 /* Software fields */ 152 /* Software fields */
137 dma_addr_t dma_handle; 153 dma_addr_t dma_handle;
@@ -170,7 +186,8 @@ struct uhci_qh {
170 */ 186 */
171#define qh_element(qh) ACCESS_ONCE((qh)->element) 187#define qh_element(qh) ACCESS_ONCE((qh)->element)
172 188
173#define LINK_TO_QH(qh) (UHCI_PTR_QH | cpu_to_le32((qh)->dma_handle)) 189#define LINK_TO_QH(uhci, qh) (UHCI_PTR_QH((uhci)) | \
190 cpu_to_hc32((uhci), (qh)->dma_handle))
174 191
175 192
176/* 193/*
@@ -207,7 +224,7 @@ struct uhci_qh {
207/* 224/*
208 * for TD <info>: (a.k.a. Token) 225 * for TD <info>: (a.k.a. Token)
209 */ 226 */
210#define td_token(td) le32_to_cpu((td)->token) 227#define td_token(uhci, td) hc32_to_cpu((uhci), (td)->token)
211#define TD_TOKEN_DEVADDR_SHIFT 8 228#define TD_TOKEN_DEVADDR_SHIFT 8
212#define TD_TOKEN_TOGGLE_SHIFT 19 229#define TD_TOKEN_TOGGLE_SHIFT 19
213#define TD_TOKEN_TOGGLE (1 << 19) 230#define TD_TOKEN_TOGGLE (1 << 19)
@@ -240,10 +257,10 @@ struct uhci_qh {
240 */ 257 */
241struct uhci_td { 258struct uhci_td {
242 /* Hardware fields */ 259 /* Hardware fields */
243 __le32 link; 260 __hc32 link;
244 __le32 status; 261 __hc32 status;
245 __le32 token; 262 __hc32 token;
246 __le32 buffer; 263 __hc32 buffer;
247 264
248 /* Software fields */ 265 /* Software fields */
249 dma_addr_t dma_handle; 266 dma_addr_t dma_handle;
@@ -258,9 +275,10 @@ struct uhci_td {
258 * We need a special accessor for the control/status word because it is 275 * We need a special accessor for the control/status word because it is
259 * subject to asynchronous updates by the controller. 276 * subject to asynchronous updates by the controller.
260 */ 277 */
261#define td_status(td) le32_to_cpu(ACCESS_ONCE((td)->status)) 278#define td_status(uhci, td) hc32_to_cpu((uhci), \
279 ACCESS_ONCE((td)->status))
262 280
263#define LINK_TO_TD(td) (cpu_to_le32((td)->dma_handle)) 281#define LINK_TO_TD(uhci, td) (cpu_to_hc32((uhci), (td)->dma_handle))
264 282
265 283
266/* 284/*
@@ -383,7 +401,7 @@ struct uhci_hcd {
383 spinlock_t lock; 401 spinlock_t lock;
384 402
385 dma_addr_t frame_dma_handle; /* Hardware frame list */ 403 dma_addr_t frame_dma_handle; /* Hardware frame list */
386 __le32 *frame; 404 __hc32 *frame;
387 void **frame_cpu; /* CPU's frame list */ 405 void **frame_cpu; /* CPU's frame list */
388 406
389 enum uhci_rh_state rh_state; 407 enum uhci_rh_state rh_state;
@@ -412,6 +430,7 @@ struct uhci_hcd {
412 unsigned int oc_low:1; /* OverCurrent bit active low */ 430 unsigned int oc_low:1; /* OverCurrent bit active low */
413 unsigned int wait_for_hp:1; /* Wait for HP port reset */ 431 unsigned int wait_for_hp:1; /* Wait for HP port reset */
414 unsigned int big_endian_mmio:1; /* Big endian registers */ 432 unsigned int big_endian_mmio:1; /* Big endian registers */
433 unsigned int big_endian_desc:1; /* Big endian descriptors */
415 434
416 /* Support for port suspend/resume/reset */ 435 /* Support for port suspend/resume/reset */
417 unsigned long port_c_suspend; /* Bit-arrays of ports */ 436 unsigned long port_c_suspend; /* Bit-arrays of ports */
@@ -603,4 +622,43 @@ static inline void uhci_writeb(const struct uhci_hcd *uhci, u8 val, int reg)
603} 622}
604#endif /* CONFIG_USB_UHCI_SUPPORT_NON_PCI_HC */ 623#endif /* CONFIG_USB_UHCI_SUPPORT_NON_PCI_HC */
605 624
625/*
626 * The GRLIB GRUSBHC controller can use big endian format for its descriptors.
627 *
628 * UHCI controllers accessed through PCI work normally (little-endian
629 * everywhere), so we don't bother supporting a BE-only mode.
630 */
631#ifdef CONFIG_USB_UHCI_BIG_ENDIAN_DESC
632#define uhci_big_endian_desc(u) ((u)->big_endian_desc)
633
634/* cpu to uhci */
635static inline __hc32 cpu_to_hc32(const struct uhci_hcd *uhci, const u32 x)
636{
637 return uhci_big_endian_desc(uhci)
638 ? (__force __hc32)cpu_to_be32(x)
639 : (__force __hc32)cpu_to_le32(x);
640}
641
642/* uhci to cpu */
643static inline u32 hc32_to_cpu(const struct uhci_hcd *uhci, const __hc32 x)
644{
645 return uhci_big_endian_desc(uhci)
646 ? be32_to_cpu((__force __be32)x)
647 : le32_to_cpu((__force __le32)x);
648}
649
650#else
651/* cpu to uhci */
652static inline __hc32 cpu_to_hc32(const struct uhci_hcd *uhci, const u32 x)
653{
654 return cpu_to_le32(x);
655}
656
657/* uhci to cpu */
658static inline u32 hc32_to_cpu(const struct uhci_hcd *uhci, const __hc32 x)
659{
660 return le32_to_cpu(x);
661}
662#endif
663
606#endif 664#endif