diff options
author | Stefan Roese <ml@stefan-roese.de> | 2007-05-01 12:29:37 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2007-07-12 19:29:45 -0400 |
commit | 6dbd682b7c6d58916096616cdf94852641bc09d9 (patch) | |
tree | 74bc2fa9038a426ac5f81969ad85cae5e4262501 /drivers/usb/host/ehci.h | |
parent | 196705c9bbc03540429b0f7cf9ee35c2f928a534 (diff) |
USB: EHCI support for big-endian descriptors
This patch implements supports for EHCI controllers whose in-memory
data structures are represented in big-endian format. This is needed
(unfortunately) for the AMCC PPC440EPx SoC EHCI controller; the EHCI
spec doesn't specify little-endian format, although that's what most
other implementations use.
The guts of the patch are to introduce the hc32 type and change all
references from le32 to hc32. All access routines are converted from
cpu_to_le32(...) to cpu_to_hc32(ehci, ...) and similar for the other
"direction". (This is the same approach used with OHCI.)
David fixed:
Whitespace fixes; refresh against ehci cpufreq patch; move glue
for that PPC driver to the patch adding it; fix free symbol
capture bugs in modified "constant" macros; and make "hc32" etc
be "le32" unless we really need the BE options, so "sparse" can
do some real good.
Signed-off-by: Stefan Roese <sr@denx.de>
Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/usb/host/ehci.h')
-rw-r--r-- | drivers/usb/host/ehci.h | 205 |
1 files changed, 153 insertions, 52 deletions
diff --git a/drivers/usb/host/ehci.h b/drivers/usb/host/ehci.h index a9ba5d28cdc2..79ad2af5ef6a 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 | ||
33 | typedef __u32 __bitwise __hc32; | ||
34 | typedef __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 */ |
25 | struct ehci_stats { | 41 | struct ehci_stats { |
26 | /* irq usage */ | 42 | /* irq usage */ |
@@ -70,7 +86,7 @@ struct ehci_hcd { /* one per controller */ | |||
70 | /* periodic schedule support */ | 86 | /* periodic schedule support */ |
71 | #define DEFAULT_I_TDPS 1024 /* some HCs can do less */ | 87 | #define DEFAULT_I_TDPS 1024 /* some HCs can do less */ |
72 | unsigned periodic_size; | 88 | unsigned periodic_size; |
73 | __le32 *periodic; /* hw periodic table */ | 89 | __hc32 *periodic; /* hw periodic table */ |
74 | dma_addr_t periodic_dma; | 90 | dma_addr_t periodic_dma; |
75 | unsigned i_thresh; /* uframes HC might cache */ | 91 | unsigned i_thresh; /* uframes HC might cache */ |
76 | 92 | ||
@@ -103,6 +119,7 @@ struct ehci_hcd { /* one per controller */ | |||
103 | unsigned no_selective_suspend:1; | 119 | unsigned no_selective_suspend:1; |
104 | unsigned has_fsl_port_bug:1; /* FreeScale */ | 120 | unsigned has_fsl_port_bug:1; /* FreeScale */ |
105 | unsigned big_endian_mmio:1; | 121 | unsigned big_endian_mmio:1; |
122 | unsigned big_endian_desc:1; | ||
106 | 123 | ||
107 | u8 sbrn; /* packed release number */ | 124 | u8 sbrn; /* packed release number */ |
108 | 125 | ||
@@ -309,7 +326,7 @@ struct ehci_dbg_port { | |||
309 | 326 | ||
310 | /*-------------------------------------------------------------------------*/ | 327 | /*-------------------------------------------------------------------------*/ |
311 | 328 | ||
312 | #define QTD_NEXT(dma) cpu_to_le32((u32)dma) | 329 | #define QTD_NEXT(ehci, dma) cpu_to_hc32(ehci, (u32)dma) |
313 | 330 | ||
314 | /* | 331 | /* |
315 | * EHCI Specification 0.95 Section 3.5 | 332 | * EHCI Specification 0.95 Section 3.5 |
@@ -321,9 +338,9 @@ struct ehci_dbg_port { | |||
321 | */ | 338 | */ |
322 | struct ehci_qtd { | 339 | struct ehci_qtd { |
323 | /* first part defined by EHCI spec */ | 340 | /* first part defined by EHCI spec */ |
324 | __le32 hw_next; /* see EHCI 3.5.1 */ | 341 | __hc32 hw_next; /* see EHCI 3.5.1 */ |
325 | __le32 hw_alt_next; /* see EHCI 3.5.2 */ | 342 | __hc32 hw_alt_next; /* see EHCI 3.5.2 */ |
326 | __le32 hw_token; /* see EHCI 3.5.3 */ | 343 | __hc32 hw_token; /* see EHCI 3.5.3 */ |
327 | #define QTD_TOGGLE (1 << 31) /* data toggle */ | 344 | #define QTD_TOGGLE (1 << 31) /* data toggle */ |
328 | #define QTD_LENGTH(tok) (((tok)>>16) & 0x7fff) | 345 | #define QTD_LENGTH(tok) (((tok)>>16) & 0x7fff) |
329 | #define QTD_IOC (1 << 15) /* interrupt on complete */ | 346 | #define QTD_IOC (1 << 15) /* interrupt on complete */ |
@@ -337,8 +354,13 @@ struct ehci_qtd { | |||
337 | #define QTD_STS_MMF (1 << 2) /* incomplete split transaction */ | 354 | #define QTD_STS_MMF (1 << 2) /* incomplete split transaction */ |
338 | #define QTD_STS_STS (1 << 1) /* split transaction state */ | 355 | #define QTD_STS_STS (1 << 1) /* split transaction state */ |
339 | #define QTD_STS_PING (1 << 0) /* issue PING? */ | 356 | #define QTD_STS_PING (1 << 0) /* issue PING? */ |
340 | __le32 hw_buf [5]; /* see EHCI 3.5.4 */ | 357 | |
341 | __le32 hw_buf_hi [5]; /* Appendix B */ | 358 | #define ACTIVE_BIT(ehci) cpu_to_hc32(ehci, QTD_STS_ACTIVE) |
359 | #define HALT_BIT(ehci) cpu_to_hc32(ehci, QTD_STS_HALT) | ||
360 | #define STATUS_BIT(ehci) cpu_to_hc32(ehci, QTD_STS_STS) | ||
361 | |||
362 | __hc32 hw_buf [5]; /* see EHCI 3.5.4 */ | ||
363 | __hc32 hw_buf_hi [5]; /* Appendix B */ | ||
342 | 364 | ||
343 | /* the rest is HCD-private */ | 365 | /* the rest is HCD-private */ |
344 | dma_addr_t qtd_dma; /* qtd address */ | 366 | dma_addr_t qtd_dma; /* qtd address */ |
@@ -348,26 +370,33 @@ struct ehci_qtd { | |||
348 | } __attribute__ ((aligned (32))); | 370 | } __attribute__ ((aligned (32))); |
349 | 371 | ||
350 | /* mask NakCnt+T in qh->hw_alt_next */ | 372 | /* mask NakCnt+T in qh->hw_alt_next */ |
351 | #define QTD_MASK __constant_cpu_to_le32 (~0x1f) | 373 | #define QTD_MASK(ehci) cpu_to_hc32 (ehci, ~0x1f) |
352 | 374 | ||
353 | #define IS_SHORT_READ(token) (QTD_LENGTH (token) != 0 && QTD_PID (token) == 1) | 375 | #define IS_SHORT_READ(token) (QTD_LENGTH (token) != 0 && QTD_PID (token) == 1) |
354 | 376 | ||
355 | /*-------------------------------------------------------------------------*/ | 377 | /*-------------------------------------------------------------------------*/ |
356 | 378 | ||
357 | /* type tag from {qh,itd,sitd,fstn}->hw_next */ | 379 | /* type tag from {qh,itd,sitd,fstn}->hw_next */ |
358 | #define Q_NEXT_TYPE(dma) ((dma) & __constant_cpu_to_le32 (3 << 1)) | 380 | #define Q_NEXT_TYPE(ehci,dma) ((dma) & cpu_to_hc32(ehci, 3 << 1)) |
359 | 381 | ||
382 | /* | ||
383 | * Now the following defines are not converted using the | ||
384 | * __constant_cpu_to_le32() macro anymore, since we have to support | ||
385 | * "dynamic" switching between be and le support, so that the driver | ||
386 | * can be used on one system with SoC EHCI controller using big-endian | ||
387 | * descriptors as well as a normal little-endian PCI EHCI controller. | ||
388 | */ | ||
360 | /* values for that type tag */ | 389 | /* values for that type tag */ |
361 | #define Q_TYPE_ITD __constant_cpu_to_le32 (0 << 1) | 390 | #define Q_TYPE_ITD (0 << 1) |
362 | #define Q_TYPE_QH __constant_cpu_to_le32 (1 << 1) | 391 | #define Q_TYPE_QH (1 << 1) |
363 | #define Q_TYPE_SITD __constant_cpu_to_le32 (2 << 1) | 392 | #define Q_TYPE_SITD (2 << 1) |
364 | #define Q_TYPE_FSTN __constant_cpu_to_le32 (3 << 1) | 393 | #define Q_TYPE_FSTN (3 << 1) |
365 | 394 | ||
366 | /* next async queue entry, or pointer to interrupt/periodic QH */ | 395 | /* next async queue entry, or pointer to interrupt/periodic QH */ |
367 | #define QH_NEXT(dma) (cpu_to_le32(((u32)dma)&~0x01f)|Q_TYPE_QH) | 396 | #define QH_NEXT(ehci,dma) (cpu_to_hc32(ehci, (((u32)dma)&~0x01f)|Q_TYPE_QH)) |
368 | 397 | ||
369 | /* for periodic/async schedules and qtd lists, mark end of list */ | 398 | /* for periodic/async schedules and qtd lists, mark end of list */ |
370 | #define EHCI_LIST_END __constant_cpu_to_le32(1) /* "null pointer" to hw */ | 399 | #define EHCI_LIST_END(ehci) cpu_to_hc32(ehci, 1) /* "null pointer" to hw */ |
371 | 400 | ||
372 | /* | 401 | /* |
373 | * Entries in periodic shadow table are pointers to one of four kinds | 402 | * Entries in periodic shadow table are pointers to one of four kinds |
@@ -382,7 +411,7 @@ union ehci_shadow { | |||
382 | struct ehci_itd *itd; /* Q_TYPE_ITD */ | 411 | struct ehci_itd *itd; /* Q_TYPE_ITD */ |
383 | struct ehci_sitd *sitd; /* Q_TYPE_SITD */ | 412 | struct ehci_sitd *sitd; /* Q_TYPE_SITD */ |
384 | struct ehci_fstn *fstn; /* Q_TYPE_FSTN */ | 413 | struct ehci_fstn *fstn; /* Q_TYPE_FSTN */ |
385 | __le32 *hw_next; /* (all types) */ | 414 | __hc32 *hw_next; /* (all types) */ |
386 | void *ptr; | 415 | void *ptr; |
387 | }; | 416 | }; |
388 | 417 | ||
@@ -398,24 +427,27 @@ union ehci_shadow { | |||
398 | 427 | ||
399 | struct ehci_qh { | 428 | struct ehci_qh { |
400 | /* first part defined by EHCI spec */ | 429 | /* first part defined by EHCI spec */ |
401 | __le32 hw_next; /* see EHCI 3.6.1 */ | 430 | __hc32 hw_next; /* see EHCI 3.6.1 */ |
402 | __le32 hw_info1; /* see EHCI 3.6.2 */ | 431 | __hc32 hw_info1; /* see EHCI 3.6.2 */ |
403 | #define QH_HEAD 0x00008000 | 432 | #define QH_HEAD 0x00008000 |
404 | #define QH_INACTIVATE 0x00000080 | 433 | #define QH_INACTIVATE 0x00000080 |
405 | __le32 hw_info2; /* see EHCI 3.6.2 */ | 434 | |
435 | #define INACTIVATE_BIT(ehci) cpu_to_hc32(ehci, QH_INACTIVATE) | ||
436 | |||
437 | __hc32 hw_info2; /* see EHCI 3.6.2 */ | ||
406 | #define QH_SMASK 0x000000ff | 438 | #define QH_SMASK 0x000000ff |
407 | #define QH_CMASK 0x0000ff00 | 439 | #define QH_CMASK 0x0000ff00 |
408 | #define QH_HUBADDR 0x007f0000 | 440 | #define QH_HUBADDR 0x007f0000 |
409 | #define QH_HUBPORT 0x3f800000 | 441 | #define QH_HUBPORT 0x3f800000 |
410 | #define QH_MULT 0xc0000000 | 442 | #define QH_MULT 0xc0000000 |
411 | __le32 hw_current; /* qtd list - see EHCI 3.6.4 */ | 443 | __hc32 hw_current; /* qtd list - see EHCI 3.6.4 */ |
412 | 444 | ||
413 | /* qtd overlay (hardware parts of a struct ehci_qtd) */ | 445 | /* qtd overlay (hardware parts of a struct ehci_qtd) */ |
414 | __le32 hw_qtd_next; | 446 | __hc32 hw_qtd_next; |
415 | __le32 hw_alt_next; | 447 | __hc32 hw_alt_next; |
416 | __le32 hw_token; | 448 | __hc32 hw_token; |
417 | __le32 hw_buf [5]; | 449 | __hc32 hw_buf [5]; |
418 | __le32 hw_buf_hi [5]; | 450 | __hc32 hw_buf_hi [5]; |
419 | 451 | ||
420 | /* the rest is HCD-private */ | 452 | /* the rest is HCD-private */ |
421 | dma_addr_t qh_dma; /* address of qh */ | 453 | dma_addr_t qh_dma; /* address of qh */ |
@@ -456,7 +488,7 @@ struct ehci_qh { | |||
456 | struct ehci_iso_packet { | 488 | struct ehci_iso_packet { |
457 | /* These will be copied to iTD when scheduling */ | 489 | /* These will be copied to iTD when scheduling */ |
458 | u64 bufp; /* itd->hw_bufp{,_hi}[pg] |= */ | 490 | u64 bufp; /* itd->hw_bufp{,_hi}[pg] |= */ |
459 | __le32 transaction; /* itd->hw_transaction[i] |= */ | 491 | __hc32 transaction; /* itd->hw_transaction[i] |= */ |
460 | u8 cross; /* buf crosses pages */ | 492 | u8 cross; /* buf crosses pages */ |
461 | /* for full speed OUT splits */ | 493 | /* for full speed OUT splits */ |
462 | u32 buf1; | 494 | u32 buf1; |
@@ -478,8 +510,8 @@ struct ehci_iso_sched { | |||
478 | */ | 510 | */ |
479 | struct ehci_iso_stream { | 511 | struct ehci_iso_stream { |
480 | /* first two fields match QH, but info1 == 0 */ | 512 | /* first two fields match QH, but info1 == 0 */ |
481 | __le32 hw_next; | 513 | __hc32 hw_next; |
482 | __le32 hw_info1; | 514 | __hc32 hw_info1; |
483 | 515 | ||
484 | u32 refcount; | 516 | u32 refcount; |
485 | u8 bEndpointAddress; | 517 | u8 bEndpointAddress; |
@@ -494,7 +526,7 @@ struct ehci_iso_stream { | |||
494 | unsigned long start; /* jiffies */ | 526 | unsigned long start; /* jiffies */ |
495 | unsigned long rescheduled; | 527 | unsigned long rescheduled; |
496 | int next_uframe; | 528 | int next_uframe; |
497 | __le32 splits; | 529 | __hc32 splits; |
498 | 530 | ||
499 | /* the rest is derived from the endpoint descriptor, | 531 | /* the rest is derived from the endpoint descriptor, |
500 | * trusting urb->interval == f(epdesc->bInterval) and | 532 | * trusting urb->interval == f(epdesc->bInterval) and |
@@ -508,12 +540,12 @@ struct ehci_iso_stream { | |||
508 | unsigned bandwidth; | 540 | unsigned bandwidth; |
509 | 541 | ||
510 | /* This is used to initialize iTD's hw_bufp fields */ | 542 | /* This is used to initialize iTD's hw_bufp fields */ |
511 | __le32 buf0; | 543 | __hc32 buf0; |
512 | __le32 buf1; | 544 | __hc32 buf1; |
513 | __le32 buf2; | 545 | __hc32 buf2; |
514 | 546 | ||
515 | /* this is used to initialize sITD's tt info */ | 547 | /* this is used to initialize sITD's tt info */ |
516 | __le32 address; | 548 | __hc32 address; |
517 | }; | 549 | }; |
518 | 550 | ||
519 | /*-------------------------------------------------------------------------*/ | 551 | /*-------------------------------------------------------------------------*/ |
@@ -526,8 +558,8 @@ struct ehci_iso_stream { | |||
526 | */ | 558 | */ |
527 | struct ehci_itd { | 559 | struct ehci_itd { |
528 | /* first part defined by EHCI spec */ | 560 | /* first part defined by EHCI spec */ |
529 | __le32 hw_next; /* see EHCI 3.3.1 */ | 561 | __hc32 hw_next; /* see EHCI 3.3.1 */ |
530 | __le32 hw_transaction [8]; /* see EHCI 3.3.2 */ | 562 | __hc32 hw_transaction [8]; /* see EHCI 3.3.2 */ |
531 | #define EHCI_ISOC_ACTIVE (1<<31) /* activate transfer this slot */ | 563 | #define EHCI_ISOC_ACTIVE (1<<31) /* activate transfer this slot */ |
532 | #define EHCI_ISOC_BUF_ERR (1<<30) /* Data buffer error */ | 564 | #define EHCI_ISOC_BUF_ERR (1<<30) /* Data buffer error */ |
533 | #define EHCI_ISOC_BABBLE (1<<29) /* babble detected */ | 565 | #define EHCI_ISOC_BABBLE (1<<29) /* babble detected */ |
@@ -535,10 +567,10 @@ struct ehci_itd { | |||
535 | #define EHCI_ITD_LENGTH(tok) (((tok)>>16) & 0x0fff) | 567 | #define EHCI_ITD_LENGTH(tok) (((tok)>>16) & 0x0fff) |
536 | #define EHCI_ITD_IOC (1 << 15) /* interrupt on complete */ | 568 | #define EHCI_ITD_IOC (1 << 15) /* interrupt on complete */ |
537 | 569 | ||
538 | #define ITD_ACTIVE __constant_cpu_to_le32(EHCI_ISOC_ACTIVE) | 570 | #define ITD_ACTIVE(ehci) cpu_to_hc32(ehci, EHCI_ISOC_ACTIVE) |
539 | 571 | ||
540 | __le32 hw_bufp [7]; /* see EHCI 3.3.3 */ | 572 | __hc32 hw_bufp [7]; /* see EHCI 3.3.3 */ |
541 | __le32 hw_bufp_hi [7]; /* Appendix B */ | 573 | __hc32 hw_bufp_hi [7]; /* Appendix B */ |
542 | 574 | ||
543 | /* the rest is HCD-private */ | 575 | /* the rest is HCD-private */ |
544 | dma_addr_t itd_dma; /* for this itd */ | 576 | dma_addr_t itd_dma; /* for this itd */ |
@@ -565,11 +597,11 @@ struct ehci_itd { | |||
565 | */ | 597 | */ |
566 | struct ehci_sitd { | 598 | struct ehci_sitd { |
567 | /* first part defined by EHCI spec */ | 599 | /* first part defined by EHCI spec */ |
568 | __le32 hw_next; | 600 | __hc32 hw_next; |
569 | /* uses bit field macros above - see EHCI 0.95 Table 3-8 */ | 601 | /* uses bit field macros above - see EHCI 0.95 Table 3-8 */ |
570 | __le32 hw_fullspeed_ep; /* EHCI table 3-9 */ | 602 | __hc32 hw_fullspeed_ep; /* EHCI table 3-9 */ |
571 | __le32 hw_uframe; /* EHCI table 3-10 */ | 603 | __hc32 hw_uframe; /* EHCI table 3-10 */ |
572 | __le32 hw_results; /* EHCI table 3-11 */ | 604 | __hc32 hw_results; /* EHCI table 3-11 */ |
573 | #define SITD_IOC (1 << 31) /* interrupt on completion */ | 605 | #define SITD_IOC (1 << 31) /* interrupt on completion */ |
574 | #define SITD_PAGE (1 << 30) /* buffer 0/1 */ | 606 | #define SITD_PAGE (1 << 30) /* buffer 0/1 */ |
575 | #define SITD_LENGTH(x) (0x3ff & ((x)>>16)) | 607 | #define SITD_LENGTH(x) (0x3ff & ((x)>>16)) |
@@ -581,11 +613,11 @@ struct ehci_sitd { | |||
581 | #define SITD_STS_MMF (1 << 2) /* incomplete split transaction */ | 613 | #define SITD_STS_MMF (1 << 2) /* incomplete split transaction */ |
582 | #define SITD_STS_STS (1 << 1) /* split transaction state */ | 614 | #define SITD_STS_STS (1 << 1) /* split transaction state */ |
583 | 615 | ||
584 | #define SITD_ACTIVE __constant_cpu_to_le32(SITD_STS_ACTIVE) | 616 | #define SITD_ACTIVE(ehci) cpu_to_hc32(ehci, SITD_STS_ACTIVE) |
585 | 617 | ||
586 | __le32 hw_buf [2]; /* EHCI table 3-12 */ | 618 | __hc32 hw_buf [2]; /* EHCI table 3-12 */ |
587 | __le32 hw_backpointer; /* EHCI table 3-13 */ | 619 | __hc32 hw_backpointer; /* EHCI table 3-13 */ |
588 | __le32 hw_buf_hi [2]; /* Appendix B */ | 620 | __hc32 hw_buf_hi [2]; /* Appendix B */ |
589 | 621 | ||
590 | /* the rest is HCD-private */ | 622 | /* the rest is HCD-private */ |
591 | dma_addr_t sitd_dma; | 623 | dma_addr_t sitd_dma; |
@@ -610,8 +642,8 @@ struct ehci_sitd { | |||
610 | * it hits a "restore" FSTN; then it returns to finish other uframe 0/1 work. | 642 | * it hits a "restore" FSTN; then it returns to finish other uframe 0/1 work. |
611 | */ | 643 | */ |
612 | struct ehci_fstn { | 644 | struct ehci_fstn { |
613 | __le32 hw_next; /* any periodic q entry */ | 645 | __hc32 hw_next; /* any periodic q entry */ |
614 | __le32 hw_prev; /* qh or EHCI_LIST_END */ | 646 | __hc32 hw_prev; /* qh or EHCI_LIST_END */ |
615 | 647 | ||
616 | /* the rest is HCD-private */ | 648 | /* the rest is HCD-private */ |
617 | dma_addr_t fstn_dma; | 649 | dma_addr_t fstn_dma; |
@@ -683,8 +715,21 @@ ehci_port_speed(struct ehci_hcd *ehci, unsigned int portsc) | |||
683 | #define ehci_big_endian_mmio(e) 0 | 715 | #define ehci_big_endian_mmio(e) 0 |
684 | #endif | 716 | #endif |
685 | 717 | ||
686 | static inline unsigned int ehci_readl (const struct ehci_hcd *ehci, | 718 | /* |
687 | __u32 __iomem * regs) | 719 | * Big-endian read/write functions are arch-specific. |
720 | * Other arches can be added if/when they're needed. | ||
721 | * | ||
722 | * REVISIT: arch/powerpc now has readl/writel_be, so the | ||
723 | * definition below can die once the 4xx support is | ||
724 | * finally ported over. | ||
725 | */ | ||
726 | #if defined(CONFIG_PPC) | ||
727 | #define readl_be(addr) in_be32((__force unsigned *)addr) | ||
728 | #define writel_be(val, addr) out_be32((__force unsigned *)addr, val) | ||
729 | #endif | ||
730 | |||
731 | static inline unsigned int ehci_readl(const struct ehci_hcd *ehci, | ||
732 | __u32 __iomem * regs) | ||
688 | { | 733 | { |
689 | #ifdef CONFIG_USB_EHCI_BIG_ENDIAN_MMIO | 734 | #ifdef CONFIG_USB_EHCI_BIG_ENDIAN_MMIO |
690 | return ehci_big_endian_mmio(ehci) ? | 735 | return ehci_big_endian_mmio(ehci) ? |
@@ -695,8 +740,8 @@ static inline unsigned int ehci_readl (const struct ehci_hcd *ehci, | |||
695 | #endif | 740 | #endif |
696 | } | 741 | } |
697 | 742 | ||
698 | static inline void ehci_writel (const struct ehci_hcd *ehci, | 743 | static inline void ehci_writel(const struct ehci_hcd *ehci, |
699 | const unsigned int val, __u32 __iomem *regs) | 744 | const unsigned int val, __u32 __iomem *regs) |
700 | { | 745 | { |
701 | #ifdef CONFIG_USB_EHCI_BIG_ENDIAN_MMIO | 746 | #ifdef CONFIG_USB_EHCI_BIG_ENDIAN_MMIO |
702 | ehci_big_endian_mmio(ehci) ? | 747 | ehci_big_endian_mmio(ehci) ? |
@@ -709,6 +754,62 @@ static inline void ehci_writel (const struct ehci_hcd *ehci, | |||
709 | 754 | ||
710 | /*-------------------------------------------------------------------------*/ | 755 | /*-------------------------------------------------------------------------*/ |
711 | 756 | ||
757 | /* | ||
758 | * The AMCC 440EPx not only implements its EHCI registers in big-endian | ||
759 | * format, but also its DMA data structures (descriptors). | ||
760 | * | ||
761 | * EHCI controllers accessed through PCI work normally (little-endian | ||
762 | * everywhere), so we won't bother supporting a BE-only mode for now. | ||
763 | */ | ||
764 | #ifdef CONFIG_USB_EHCI_BIG_ENDIAN_DESC | ||
765 | #define ehci_big_endian_desc(e) ((e)->big_endian_desc) | ||
766 | |||
767 | /* cpu to ehci */ | ||
768 | static inline __hc32 cpu_to_hc32 (const struct ehci_hcd *ehci, const u32 x) | ||
769 | { | ||
770 | return ehci_big_endian_desc(ehci) | ||
771 | ? (__force __hc32)cpu_to_be32(x) | ||
772 | : (__force __hc32)cpu_to_le32(x); | ||
773 | } | ||
774 | |||
775 | /* ehci to cpu */ | ||
776 | static inline u32 hc32_to_cpu (const struct ehci_hcd *ehci, const __hc32 x) | ||
777 | { | ||
778 | return ehci_big_endian_desc(ehci) | ||
779 | ? be32_to_cpu((__force __be32)x) | ||
780 | : le32_to_cpu((__force __le32)x); | ||
781 | } | ||
782 | |||
783 | static inline u32 hc32_to_cpup (const struct ehci_hcd *ehci, const __hc32 *x) | ||
784 | { | ||
785 | return ehci_big_endian_desc(ehci) | ||
786 | ? be32_to_cpup((__force __be32 *)x) | ||
787 | : le32_to_cpup((__force __le32 *)x); | ||
788 | } | ||
789 | |||
790 | #else | ||
791 | |||
792 | /* cpu to ehci */ | ||
793 | static inline __hc32 cpu_to_hc32 (const struct ehci_hcd *ehci, const u32 x) | ||
794 | { | ||
795 | return cpu_to_le32(x); | ||
796 | } | ||
797 | |||
798 | /* ehci to cpu */ | ||
799 | static inline u32 hc32_to_cpu (const struct ehci_hcd *ehci, const __hc32 x) | ||
800 | { | ||
801 | return le32_to_cpu(x); | ||
802 | } | ||
803 | |||
804 | static inline u32 hc32_to_cpup (const struct ehci_hcd *ehci, const __hc32 *x) | ||
805 | { | ||
806 | return le32_to_cpup(x); | ||
807 | } | ||
808 | |||
809 | #endif | ||
810 | |||
811 | /*-------------------------------------------------------------------------*/ | ||
812 | |||
712 | #ifndef DEBUG | 813 | #ifndef DEBUG |
713 | #define STUB_DEBUG_FILES | 814 | #define STUB_DEBUG_FILES |
714 | #endif /* DEBUG */ | 815 | #endif /* DEBUG */ |