aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/host/ehci.h
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/usb/host/ehci.h')
-rw-r--r--drivers/usb/host/ehci.h234
1 files changed, 181 insertions, 53 deletions
diff --git a/drivers/usb/host/ehci.h b/drivers/usb/host/ehci.h
index 46fa57a520d0..2c68a04230c1 100644
--- a/drivers/usb/host/ehci.h
+++ b/drivers/usb/host/ehci.h
@@ -21,6 +21,22 @@
21 21
22/* definitions used for the EHCI driver */ 22/* definitions used for the EHCI driver */
23 23
24/*
25 * __hc32 and __hc16 are "Host Controller" types, they may be equivalent to
26 * __leXX (normally) or __beXX (given EHCI_BIG_ENDIAN_DESC), depending on
27 * the host controller implementation.
28 *
29 * To facilitate the strongest possible byte-order checking from "sparse"
30 * and so on, we use __leXX unless that's not practical.
31 */
32#ifdef CONFIG_USB_EHCI_BIG_ENDIAN_DESC
33typedef __u32 __bitwise __hc32;
34typedef __u16 __bitwise __hc16;
35#else
36#define __hc32 __le32
37#define __hc16 __le16
38#endif
39
24/* statistics can be kept for for tuning/monitoring */ 40/* statistics can be kept for for tuning/monitoring */
25struct ehci_stats { 41struct ehci_stats {
26 /* irq usage */ 42 /* irq usage */
@@ -55,6 +71,12 @@ struct ehci_hcd { /* one per controller */
55 __u32 hcs_params; /* cached register copy */ 71 __u32 hcs_params; /* cached register copy */
56 spinlock_t lock; 72 spinlock_t lock;
57 73
74#ifdef CONFIG_CPU_FREQ
75 struct notifier_block cpufreq_transition;
76 int cpufreq_changing;
77 struct list_head split_intr_qhs;
78#endif
79
58 /* async schedule support */ 80 /* async schedule support */
59 struct ehci_qh *async; 81 struct ehci_qh *async;
60 struct ehci_qh *reclaim; 82 struct ehci_qh *reclaim;
@@ -64,7 +86,7 @@ struct ehci_hcd { /* one per controller */
64 /* periodic schedule support */ 86 /* periodic schedule support */
65#define DEFAULT_I_TDPS 1024 /* some HCs can do less */ 87#define DEFAULT_I_TDPS 1024 /* some HCs can do less */
66 unsigned periodic_size; 88 unsigned periodic_size;
67 __le32 *periodic; /* hw periodic table */ 89 __hc32 *periodic; /* hw periodic table */
68 dma_addr_t periodic_dma; 90 dma_addr_t periodic_dma;
69 unsigned i_thresh; /* uframes HC might cache */ 91 unsigned i_thresh; /* uframes HC might cache */
70 92
@@ -74,11 +96,14 @@ struct ehci_hcd { /* one per controller */
74 96
75 /* per root hub port */ 97 /* per root hub port */
76 unsigned long reset_done [EHCI_MAX_ROOT_PORTS]; 98 unsigned long reset_done [EHCI_MAX_ROOT_PORTS];
99
77 /* bit vectors (one bit per port) */ 100 /* bit vectors (one bit per port) */
78 unsigned long bus_suspended; /* which ports were 101 unsigned long bus_suspended; /* which ports were
79 already suspended at the start of a bus suspend */ 102 already suspended at the start of a bus suspend */
80 unsigned long companion_ports; /* which ports are 103 unsigned long companion_ports; /* which ports are
81 dedicated to the companion controller */ 104 dedicated to the companion controller */
105 unsigned long owned_ports; /* which ports are
106 owned by the companion during a bus suspend */
82 107
83 /* per-HC memory pools (could be per-bus, but ...) */ 108 /* per-HC memory pools (could be per-bus, but ...) */
84 struct dma_pool *qh_pool; /* qh per active urb */ 109 struct dma_pool *qh_pool; /* qh per active urb */
@@ -97,6 +122,7 @@ struct ehci_hcd { /* one per controller */
97 unsigned no_selective_suspend:1; 122 unsigned no_selective_suspend:1;
98 unsigned has_fsl_port_bug:1; /* FreeScale */ 123 unsigned has_fsl_port_bug:1; /* FreeScale */
99 unsigned big_endian_mmio:1; 124 unsigned big_endian_mmio:1;
125 unsigned big_endian_desc:1;
100 126
101 u8 sbrn; /* packed release number */ 127 u8 sbrn; /* packed release number */
102 128
@@ -276,6 +302,12 @@ struct ehci_regs {
276#define PORT_RWC_BITS (PORT_CSC | PORT_PEC | PORT_OCC) 302#define PORT_RWC_BITS (PORT_CSC | PORT_PEC | PORT_OCC)
277} __attribute__ ((packed)); 303} __attribute__ ((packed));
278 304
305#define USBMODE 0x68 /* USB Device mode */
306#define USBMODE_SDIS (1<<3) /* Stream disable */
307#define USBMODE_BE (1<<2) /* BE/LE endianness select */
308#define USBMODE_CM_HC (3<<0) /* host controller mode */
309#define USBMODE_CM_IDLE (0<<0) /* idle state */
310
279/* Appendix C, Debug port ... intended for use with special "debug devices" 311/* Appendix C, Debug port ... intended for use with special "debug devices"
280 * that can help if there's no serial console. (nonstandard enumeration.) 312 * that can help if there's no serial console. (nonstandard enumeration.)
281 */ 313 */
@@ -303,7 +335,7 @@ struct ehci_dbg_port {
303 335
304/*-------------------------------------------------------------------------*/ 336/*-------------------------------------------------------------------------*/
305 337
306#define QTD_NEXT(dma) cpu_to_le32((u32)dma) 338#define QTD_NEXT(ehci, dma) cpu_to_hc32(ehci, (u32)dma)
307 339
308/* 340/*
309 * EHCI Specification 0.95 Section 3.5 341 * EHCI Specification 0.95 Section 3.5
@@ -315,9 +347,9 @@ struct ehci_dbg_port {
315 */ 347 */
316struct ehci_qtd { 348struct ehci_qtd {
317 /* first part defined by EHCI spec */ 349 /* first part defined by EHCI spec */
318 __le32 hw_next; /* see EHCI 3.5.1 */ 350 __hc32 hw_next; /* see EHCI 3.5.1 */
319 __le32 hw_alt_next; /* see EHCI 3.5.2 */ 351 __hc32 hw_alt_next; /* see EHCI 3.5.2 */
320 __le32 hw_token; /* see EHCI 3.5.3 */ 352 __hc32 hw_token; /* see EHCI 3.5.3 */
321#define QTD_TOGGLE (1 << 31) /* data toggle */ 353#define QTD_TOGGLE (1 << 31) /* data toggle */
322#define QTD_LENGTH(tok) (((tok)>>16) & 0x7fff) 354#define QTD_LENGTH(tok) (((tok)>>16) & 0x7fff)
323#define QTD_IOC (1 << 15) /* interrupt on complete */ 355#define QTD_IOC (1 << 15) /* interrupt on complete */
@@ -331,8 +363,13 @@ struct ehci_qtd {
331#define QTD_STS_MMF (1 << 2) /* incomplete split transaction */ 363#define QTD_STS_MMF (1 << 2) /* incomplete split transaction */
332#define QTD_STS_STS (1 << 1) /* split transaction state */ 364#define QTD_STS_STS (1 << 1) /* split transaction state */
333#define QTD_STS_PING (1 << 0) /* issue PING? */ 365#define QTD_STS_PING (1 << 0) /* issue PING? */
334 __le32 hw_buf [5]; /* see EHCI 3.5.4 */ 366
335 __le32 hw_buf_hi [5]; /* Appendix B */ 367#define ACTIVE_BIT(ehci) cpu_to_hc32(ehci, QTD_STS_ACTIVE)
368#define HALT_BIT(ehci) cpu_to_hc32(ehci, QTD_STS_HALT)
369#define STATUS_BIT(ehci) cpu_to_hc32(ehci, QTD_STS_STS)
370
371 __hc32 hw_buf [5]; /* see EHCI 3.5.4 */
372 __hc32 hw_buf_hi [5]; /* Appendix B */
336 373
337 /* the rest is HCD-private */ 374 /* the rest is HCD-private */
338 dma_addr_t qtd_dma; /* qtd address */ 375 dma_addr_t qtd_dma; /* qtd address */
@@ -342,26 +379,33 @@ struct ehci_qtd {
342} __attribute__ ((aligned (32))); 379} __attribute__ ((aligned (32)));
343 380
344/* mask NakCnt+T in qh->hw_alt_next */ 381/* mask NakCnt+T in qh->hw_alt_next */
345#define QTD_MASK __constant_cpu_to_le32 (~0x1f) 382#define QTD_MASK(ehci) cpu_to_hc32 (ehci, ~0x1f)
346 383
347#define IS_SHORT_READ(token) (QTD_LENGTH (token) != 0 && QTD_PID (token) == 1) 384#define IS_SHORT_READ(token) (QTD_LENGTH (token) != 0 && QTD_PID (token) == 1)
348 385
349/*-------------------------------------------------------------------------*/ 386/*-------------------------------------------------------------------------*/
350 387
351/* type tag from {qh,itd,sitd,fstn}->hw_next */ 388/* type tag from {qh,itd,sitd,fstn}->hw_next */
352#define Q_NEXT_TYPE(dma) ((dma) & __constant_cpu_to_le32 (3 << 1)) 389#define Q_NEXT_TYPE(ehci,dma) ((dma) & cpu_to_hc32(ehci, 3 << 1))
353 390
391/*
392 * Now the following defines are not converted using the
393 * __constant_cpu_to_le32() macro anymore, since we have to support
394 * "dynamic" switching between be and le support, so that the driver
395 * can be used on one system with SoC EHCI controller using big-endian
396 * descriptors as well as a normal little-endian PCI EHCI controller.
397 */
354/* values for that type tag */ 398/* values for that type tag */
355#define Q_TYPE_ITD __constant_cpu_to_le32 (0 << 1) 399#define Q_TYPE_ITD (0 << 1)
356#define Q_TYPE_QH __constant_cpu_to_le32 (1 << 1) 400#define Q_TYPE_QH (1 << 1)
357#define Q_TYPE_SITD __constant_cpu_to_le32 (2 << 1) 401#define Q_TYPE_SITD (2 << 1)
358#define Q_TYPE_FSTN __constant_cpu_to_le32 (3 << 1) 402#define Q_TYPE_FSTN (3 << 1)
359 403
360/* next async queue entry, or pointer to interrupt/periodic QH */ 404/* next async queue entry, or pointer to interrupt/periodic QH */
361#define QH_NEXT(dma) (cpu_to_le32(((u32)dma)&~0x01f)|Q_TYPE_QH) 405#define QH_NEXT(ehci,dma) (cpu_to_hc32(ehci, (((u32)dma)&~0x01f)|Q_TYPE_QH))
362 406
363/* for periodic/async schedules and qtd lists, mark end of list */ 407/* for periodic/async schedules and qtd lists, mark end of list */
364#define EHCI_LIST_END __constant_cpu_to_le32(1) /* "null pointer" to hw */ 408#define EHCI_LIST_END(ehci) cpu_to_hc32(ehci, 1) /* "null pointer" to hw */
365 409
366/* 410/*
367 * Entries in periodic shadow table are pointers to one of four kinds 411 * Entries in periodic shadow table are pointers to one of four kinds
@@ -376,7 +420,7 @@ union ehci_shadow {
376 struct ehci_itd *itd; /* Q_TYPE_ITD */ 420 struct ehci_itd *itd; /* Q_TYPE_ITD */
377 struct ehci_sitd *sitd; /* Q_TYPE_SITD */ 421 struct ehci_sitd *sitd; /* Q_TYPE_SITD */
378 struct ehci_fstn *fstn; /* Q_TYPE_FSTN */ 422 struct ehci_fstn *fstn; /* Q_TYPE_FSTN */
379 __le32 *hw_next; /* (all types) */ 423 __hc32 *hw_next; /* (all types) */
380 void *ptr; 424 void *ptr;
381}; 425};
382 426
@@ -392,23 +436,27 @@ union ehci_shadow {
392 436
393struct ehci_qh { 437struct ehci_qh {
394 /* first part defined by EHCI spec */ 438 /* first part defined by EHCI spec */
395 __le32 hw_next; /* see EHCI 3.6.1 */ 439 __hc32 hw_next; /* see EHCI 3.6.1 */
396 __le32 hw_info1; /* see EHCI 3.6.2 */ 440 __hc32 hw_info1; /* see EHCI 3.6.2 */
397#define QH_HEAD 0x00008000 441#define QH_HEAD 0x00008000
398 __le32 hw_info2; /* see EHCI 3.6.2 */ 442#define QH_INACTIVATE 0x00000080
443
444#define INACTIVATE_BIT(ehci) cpu_to_hc32(ehci, QH_INACTIVATE)
445
446 __hc32 hw_info2; /* see EHCI 3.6.2 */
399#define QH_SMASK 0x000000ff 447#define QH_SMASK 0x000000ff
400#define QH_CMASK 0x0000ff00 448#define QH_CMASK 0x0000ff00
401#define QH_HUBADDR 0x007f0000 449#define QH_HUBADDR 0x007f0000
402#define QH_HUBPORT 0x3f800000 450#define QH_HUBPORT 0x3f800000
403#define QH_MULT 0xc0000000 451#define QH_MULT 0xc0000000
404 __le32 hw_current; /* qtd list - see EHCI 3.6.4 */ 452 __hc32 hw_current; /* qtd list - see EHCI 3.6.4 */
405 453
406 /* qtd overlay (hardware parts of a struct ehci_qtd) */ 454 /* qtd overlay (hardware parts of a struct ehci_qtd) */
407 __le32 hw_qtd_next; 455 __hc32 hw_qtd_next;
408 __le32 hw_alt_next; 456 __hc32 hw_alt_next;
409 __le32 hw_token; 457 __hc32 hw_token;
410 __le32 hw_buf [5]; 458 __hc32 hw_buf [5];
411 __le32 hw_buf_hi [5]; 459 __hc32 hw_buf_hi [5];
412 460
413 /* the rest is HCD-private */ 461 /* the rest is HCD-private */
414 dma_addr_t qh_dma; /* address of qh */ 462 dma_addr_t qh_dma; /* address of qh */
@@ -418,7 +466,14 @@ struct ehci_qh {
418 struct ehci_qh *reclaim; /* next to reclaim */ 466 struct ehci_qh *reclaim; /* next to reclaim */
419 467
420 struct ehci_hcd *ehci; 468 struct ehci_hcd *ehci;
421 struct kref kref; 469
470 /*
471 * Do NOT use atomic operations for QH refcounting. On some CPUs
472 * (PPC7448 for example), atomic operations cannot be performed on
473 * memory that is cache-inhibited (i.e. being used for DMA).
474 * Spinlocks are used to protect all QH fields.
475 */
476 u32 refcount;
422 unsigned stamp; 477 unsigned stamp;
423 478
424 u8 qh_state; 479 u8 qh_state;
@@ -437,6 +492,10 @@ struct ehci_qh {
437 unsigned short start; /* where polling starts */ 492 unsigned short start; /* where polling starts */
438#define NO_FRAME ((unsigned short)~0) /* pick new start */ 493#define NO_FRAME ((unsigned short)~0) /* pick new start */
439 struct usb_device *dev; /* access to TT */ 494 struct usb_device *dev; /* access to TT */
495#ifdef CONFIG_CPU_FREQ
496 struct list_head split_intr_qhs; /* list of split qhs */
497 __le32 was_active; /* active bit before "i" set */
498#endif
440} __attribute__ ((aligned (32))); 499} __attribute__ ((aligned (32)));
441 500
442/*-------------------------------------------------------------------------*/ 501/*-------------------------------------------------------------------------*/
@@ -445,7 +504,7 @@ struct ehci_qh {
445struct ehci_iso_packet { 504struct ehci_iso_packet {
446 /* These will be copied to iTD when scheduling */ 505 /* These will be copied to iTD when scheduling */
447 u64 bufp; /* itd->hw_bufp{,_hi}[pg] |= */ 506 u64 bufp; /* itd->hw_bufp{,_hi}[pg] |= */
448 __le32 transaction; /* itd->hw_transaction[i] |= */ 507 __hc32 transaction; /* itd->hw_transaction[i] |= */
449 u8 cross; /* buf crosses pages */ 508 u8 cross; /* buf crosses pages */
450 /* for full speed OUT splits */ 509 /* for full speed OUT splits */
451 u32 buf1; 510 u32 buf1;
@@ -467,8 +526,8 @@ struct ehci_iso_sched {
467 */ 526 */
468struct ehci_iso_stream { 527struct ehci_iso_stream {
469 /* first two fields match QH, but info1 == 0 */ 528 /* first two fields match QH, but info1 == 0 */
470 __le32 hw_next; 529 __hc32 hw_next;
471 __le32 hw_info1; 530 __hc32 hw_info1;
472 531
473 u32 refcount; 532 u32 refcount;
474 u8 bEndpointAddress; 533 u8 bEndpointAddress;
@@ -483,7 +542,7 @@ struct ehci_iso_stream {
483 unsigned long start; /* jiffies */ 542 unsigned long start; /* jiffies */
484 unsigned long rescheduled; 543 unsigned long rescheduled;
485 int next_uframe; 544 int next_uframe;
486 __le32 splits; 545 __hc32 splits;
487 546
488 /* the rest is derived from the endpoint descriptor, 547 /* the rest is derived from the endpoint descriptor,
489 * trusting urb->interval == f(epdesc->bInterval) and 548 * trusting urb->interval == f(epdesc->bInterval) and
@@ -497,12 +556,12 @@ struct ehci_iso_stream {
497 unsigned bandwidth; 556 unsigned bandwidth;
498 557
499 /* This is used to initialize iTD's hw_bufp fields */ 558 /* This is used to initialize iTD's hw_bufp fields */
500 __le32 buf0; 559 __hc32 buf0;
501 __le32 buf1; 560 __hc32 buf1;
502 __le32 buf2; 561 __hc32 buf2;
503 562
504 /* this is used to initialize sITD's tt info */ 563 /* this is used to initialize sITD's tt info */
505 __le32 address; 564 __hc32 address;
506}; 565};
507 566
508/*-------------------------------------------------------------------------*/ 567/*-------------------------------------------------------------------------*/
@@ -515,8 +574,8 @@ struct ehci_iso_stream {
515 */ 574 */
516struct ehci_itd { 575struct ehci_itd {
517 /* first part defined by EHCI spec */ 576 /* first part defined by EHCI spec */
518 __le32 hw_next; /* see EHCI 3.3.1 */ 577 __hc32 hw_next; /* see EHCI 3.3.1 */
519 __le32 hw_transaction [8]; /* see EHCI 3.3.2 */ 578 __hc32 hw_transaction [8]; /* see EHCI 3.3.2 */
520#define EHCI_ISOC_ACTIVE (1<<31) /* activate transfer this slot */ 579#define EHCI_ISOC_ACTIVE (1<<31) /* activate transfer this slot */
521#define EHCI_ISOC_BUF_ERR (1<<30) /* Data buffer error */ 580#define EHCI_ISOC_BUF_ERR (1<<30) /* Data buffer error */
522#define EHCI_ISOC_BABBLE (1<<29) /* babble detected */ 581#define EHCI_ISOC_BABBLE (1<<29) /* babble detected */
@@ -524,10 +583,10 @@ struct ehci_itd {
524#define EHCI_ITD_LENGTH(tok) (((tok)>>16) & 0x0fff) 583#define EHCI_ITD_LENGTH(tok) (((tok)>>16) & 0x0fff)
525#define EHCI_ITD_IOC (1 << 15) /* interrupt on complete */ 584#define EHCI_ITD_IOC (1 << 15) /* interrupt on complete */
526 585
527#define ITD_ACTIVE __constant_cpu_to_le32(EHCI_ISOC_ACTIVE) 586#define ITD_ACTIVE(ehci) cpu_to_hc32(ehci, EHCI_ISOC_ACTIVE)
528 587
529 __le32 hw_bufp [7]; /* see EHCI 3.3.3 */ 588 __hc32 hw_bufp [7]; /* see EHCI 3.3.3 */
530 __le32 hw_bufp_hi [7]; /* Appendix B */ 589 __hc32 hw_bufp_hi [7]; /* Appendix B */
531 590
532 /* the rest is HCD-private */ 591 /* the rest is HCD-private */
533 dma_addr_t itd_dma; /* for this itd */ 592 dma_addr_t itd_dma; /* for this itd */
@@ -554,11 +613,11 @@ struct ehci_itd {
554 */ 613 */
555struct ehci_sitd { 614struct ehci_sitd {
556 /* first part defined by EHCI spec */ 615 /* first part defined by EHCI spec */
557 __le32 hw_next; 616 __hc32 hw_next;
558/* uses bit field macros above - see EHCI 0.95 Table 3-8 */ 617/* uses bit field macros above - see EHCI 0.95 Table 3-8 */
559 __le32 hw_fullspeed_ep; /* EHCI table 3-9 */ 618 __hc32 hw_fullspeed_ep; /* EHCI table 3-9 */
560 __le32 hw_uframe; /* EHCI table 3-10 */ 619 __hc32 hw_uframe; /* EHCI table 3-10 */
561 __le32 hw_results; /* EHCI table 3-11 */ 620 __hc32 hw_results; /* EHCI table 3-11 */
562#define SITD_IOC (1 << 31) /* interrupt on completion */ 621#define SITD_IOC (1 << 31) /* interrupt on completion */
563#define SITD_PAGE (1 << 30) /* buffer 0/1 */ 622#define SITD_PAGE (1 << 30) /* buffer 0/1 */
564#define SITD_LENGTH(x) (0x3ff & ((x)>>16)) 623#define SITD_LENGTH(x) (0x3ff & ((x)>>16))
@@ -570,11 +629,11 @@ struct ehci_sitd {
570#define SITD_STS_MMF (1 << 2) /* incomplete split transaction */ 629#define SITD_STS_MMF (1 << 2) /* incomplete split transaction */
571#define SITD_STS_STS (1 << 1) /* split transaction state */ 630#define SITD_STS_STS (1 << 1) /* split transaction state */
572 631
573#define SITD_ACTIVE __constant_cpu_to_le32(SITD_STS_ACTIVE) 632#define SITD_ACTIVE(ehci) cpu_to_hc32(ehci, SITD_STS_ACTIVE)
574 633
575 __le32 hw_buf [2]; /* EHCI table 3-12 */ 634 __hc32 hw_buf [2]; /* EHCI table 3-12 */
576 __le32 hw_backpointer; /* EHCI table 3-13 */ 635 __hc32 hw_backpointer; /* EHCI table 3-13 */
577 __le32 hw_buf_hi [2]; /* Appendix B */ 636 __hc32 hw_buf_hi [2]; /* Appendix B */
578 637
579 /* the rest is HCD-private */ 638 /* the rest is HCD-private */
580 dma_addr_t sitd_dma; 639 dma_addr_t sitd_dma;
@@ -599,8 +658,8 @@ struct ehci_sitd {
599 * it hits a "restore" FSTN; then it returns to finish other uframe 0/1 work. 658 * it hits a "restore" FSTN; then it returns to finish other uframe 0/1 work.
600 */ 659 */
601struct ehci_fstn { 660struct ehci_fstn {
602 __le32 hw_next; /* any periodic q entry */ 661 __hc32 hw_next; /* any periodic q entry */
603 __le32 hw_prev; /* qh or EHCI_LIST_END */ 662 __hc32 hw_prev; /* qh or EHCI_LIST_END */
604 663
605 /* the rest is HCD-private */ 664 /* the rest is HCD-private */
606 dma_addr_t fstn_dma; 665 dma_addr_t fstn_dma;
@@ -672,8 +731,21 @@ ehci_port_speed(struct ehci_hcd *ehci, unsigned int portsc)
672#define ehci_big_endian_mmio(e) 0 731#define ehci_big_endian_mmio(e) 0
673#endif 732#endif
674 733
675static inline unsigned int ehci_readl (const struct ehci_hcd *ehci, 734/*
676 __u32 __iomem * regs) 735 * Big-endian read/write functions are arch-specific.
736 * Other arches can be added if/when they're needed.
737 *
738 * REVISIT: arch/powerpc now has readl/writel_be, so the
739 * definition below can die once the 4xx support is
740 * finally ported over.
741 */
742#if defined(CONFIG_PPC)
743#define readl_be(addr) in_be32((__force unsigned *)addr)
744#define writel_be(val, addr) out_be32((__force unsigned *)addr, val)
745#endif
746
747static inline unsigned int ehci_readl(const struct ehci_hcd *ehci,
748 __u32 __iomem * regs)
677{ 749{
678#ifdef CONFIG_USB_EHCI_BIG_ENDIAN_MMIO 750#ifdef CONFIG_USB_EHCI_BIG_ENDIAN_MMIO
679 return ehci_big_endian_mmio(ehci) ? 751 return ehci_big_endian_mmio(ehci) ?
@@ -684,8 +756,8 @@ static inline unsigned int ehci_readl (const struct ehci_hcd *ehci,
684#endif 756#endif
685} 757}
686 758
687static inline void ehci_writel (const struct ehci_hcd *ehci, 759static inline void ehci_writel(const struct ehci_hcd *ehci,
688 const unsigned int val, __u32 __iomem *regs) 760 const unsigned int val, __u32 __iomem *regs)
689{ 761{
690#ifdef CONFIG_USB_EHCI_BIG_ENDIAN_MMIO 762#ifdef CONFIG_USB_EHCI_BIG_ENDIAN_MMIO
691 ehci_big_endian_mmio(ehci) ? 763 ehci_big_endian_mmio(ehci) ?
@@ -698,6 +770,62 @@ static inline void ehci_writel (const struct ehci_hcd *ehci,
698 770
699/*-------------------------------------------------------------------------*/ 771/*-------------------------------------------------------------------------*/
700 772
773/*
774 * The AMCC 440EPx not only implements its EHCI registers in big-endian
775 * format, but also its DMA data structures (descriptors).
776 *
777 * EHCI controllers accessed through PCI work normally (little-endian
778 * everywhere), so we won't bother supporting a BE-only mode for now.
779 */
780#ifdef CONFIG_USB_EHCI_BIG_ENDIAN_DESC
781#define ehci_big_endian_desc(e) ((e)->big_endian_desc)
782
783/* cpu to ehci */
784static inline __hc32 cpu_to_hc32 (const struct ehci_hcd *ehci, const u32 x)
785{
786 return ehci_big_endian_desc(ehci)
787 ? (__force __hc32)cpu_to_be32(x)
788 : (__force __hc32)cpu_to_le32(x);
789}
790
791/* ehci to cpu */
792static inline u32 hc32_to_cpu (const struct ehci_hcd *ehci, const __hc32 x)
793{
794 return ehci_big_endian_desc(ehci)
795 ? be32_to_cpu((__force __be32)x)
796 : le32_to_cpu((__force __le32)x);
797}
798
799static inline u32 hc32_to_cpup (const struct ehci_hcd *ehci, const __hc32 *x)
800{
801 return ehci_big_endian_desc(ehci)
802 ? be32_to_cpup((__force __be32 *)x)
803 : le32_to_cpup((__force __le32 *)x);
804}
805
806#else
807
808/* cpu to ehci */
809static inline __hc32 cpu_to_hc32 (const struct ehci_hcd *ehci, const u32 x)
810{
811 return cpu_to_le32(x);
812}
813
814/* ehci to cpu */
815static inline u32 hc32_to_cpu (const struct ehci_hcd *ehci, const __hc32 x)
816{
817 return le32_to_cpu(x);
818}
819
820static inline u32 hc32_to_cpup (const struct ehci_hcd *ehci, const __hc32 *x)
821{
822 return le32_to_cpup(x);
823}
824
825#endif
826
827/*-------------------------------------------------------------------------*/
828
701#ifndef DEBUG 829#ifndef DEBUG
702#define STUB_DEBUG_FILES 830#define STUB_DEBUG_FILES
703#endif /* DEBUG */ 831#endif /* DEBUG */