This 3-part patch adds support for the big-endian OHCI implementations
found on IBM's stb04xxx and Freescale's MPC52xx processors.

Patch 1 Removes byteswapped OHCI constants in preparation for
        dynamically handling endianness.

Patch 2 Adds support for big-endian OHCI controllers.
        This is done primarily by applying the following transforms
        when dealing with controller data:
                ohci_readl(p)   --> ohci_read(ohci, p)
                writel(v, p)    --> ohci_writel(ohci, v, p)
                cpu_to_le16(v)  --> cpu_to_ohci16(ohci, v)
                cpu_to_le16p(v) --> cpu_to_ohci16p(ohci, v)
                cpu_to_le32(v)  --> cpu_to_ohci32(ohci, v)
                cpu_to_le32p(v) --> cpu_to_ohci32p(ohci, v)
                le16_to_cpu(v)  --> ohci16_to_cpu(ohci, v)
                le16_to_cpup(v) --> ohci16_to_cpup(ohci, v)
                le32_to_cpu(v)  --> ohci32_to_cpu(ohci, v)
                le32_to_cpup(v) --> ohci32_to_cpup(ohci, v)

        A bit in the flags field of struct ohci_hcd, OHCI_BIG_ENDIAN,
        enables the the transformed functions to support both
        big-endian and little-endian controllers at runtime, if needed.

Patch 3 Adds support for ohci controllers (big-endian) on STB04xxx and MPC52xx

Signed-off-by: Dale Farnsworth <[EMAIL PROTECTED]>

diff -Nru a/drivers/usb/host/ohci.h b/drivers/usb/host/ohci.h
--- a/drivers/usb/host/ohci.h   2004-08-02 13:31:00 -07:00
+++ b/drivers/usb/host/ohci.h   2004-08-02 13:31:00 -07:00
@@ -176,10 +176,9 @@
        /* 
         * OHCI defines u16 frame_no, followed by u16 zero pad.
         * Since some processors can't do 16 bit bus accesses,
-        * portable access must be a 32 bit byteswapped access.
+        * portable access must be a 32 bit access.
         */
        u32     frame_no;               /* current frame number */
-#define OHCI_FRAME_NO(hccap) ((u16)le32_to_cpup(&(hccap)->frame_no))
        __u32   done_head;              /* info returned for an interrupt */
        u8      reserved_for_hc [116];
        u8      what [4];               /* spec only identifies 252 bytes :) */
@@ -377,9 +376,10 @@
 
        struct work_struct      rh_resume;
 
-       unsigned long           flags;          /* for HC bugs */
+       unsigned long           flags;          /* for HC bugs (features?) */
 #define        OHCI_QUIRK_AMD756       0x01                    /* erratum #4 */
 #define        OHCI_QUIRK_SUPERIO      0x02                    /* natsemi */
+#define        OHCI_BIG_ENDIAN         0x04                    /* big endian HC */
        // there are also chip quirks/bugs in init logic
 
        /*
@@ -392,24 +392,6 @@
 
 /*-------------------------------------------------------------------------*/
 
-static inline void disable (struct ohci_hcd *ohci)
-{
-       ohci->hcd.state = USB_STATE_HALT;
-}
-
-#define        FI                      0x2edf          /* 12000 bits per frame (-1) */
-#define        DEFAULT_FMINTERVAL      ((((6 * (FI - 210)) / 7) << 16) | FI)
-#define LSTHRESH               0x628           /* lowspeed bit threshold */
-
-static inline void periodic_reinit (struct ohci_hcd *ohci)
-{
-       writel (ohci->fminterval, &ohci->regs->fminterval);
-       writel (((9 * FI) / 10) & 0x3fff, &ohci->regs->periodicstart);
-       writel (LSTHRESH, &ohci->regs->lsthresh);
-}
-
-/*-------------------------------------------------------------------------*/
-
 #ifndef DEBUG
 #define STUB_DEBUG_FILES
 #endif /* DEBUG */
@@ -429,13 +411,27 @@
 #      define ohci_vdbg(ohci, fmt, args...) do { } while (0)
 #endif
 
+/*
+ * While most USB host controllers implement their registers and
+ * in-memory communication descriptors in little-endian format,
+ * a minority (notably the IBM STB04XXX and the Motorola MPC5200
+ * processors) implement them in little endian format.  This file
+ * attempts to support either format at compile time without a
+ * runtime penalty, or both formats with the additional overhead
+ * of checking an endian flag bit.
+ */
+
+#if !defined(CONFIG_USB_OHCI_BIG_ENDIAN)
+/* only support little endian */
+
 #ifdef CONFIG_ARCH_LH7A404
        /* Marc Singer: at the time this code was written, the LH7A404
         * had a problem reading the USB host registers.  This
         * implementation of the ohci_readl function performs the read
         * twice as a work-around.
         */
-static inline unsigned int ohci_readl (void* regs)
+static inline unsigned int ohci_readl (const struct ohci_hcd *ohci,
+                                      const void* regs)
 {
        *(volatile unsigned int*) regs;
        return *(volatile unsigned int*) regs;
@@ -443,8 +439,235 @@
 #else
        /* Standard version of ohci_readl uses standard, platform
         * specific implementation. */
-static inline unsigned int ohci_readl (void* regs)
+static inline unsigned int ohci_readl (const struct ohci_hcd *ohci,
+                                      const void* regs)
 {
        return readl (regs);
 }
 #endif
+
+static inline void ohci_writel (const struct ohci_hcd *ohci,
+                               const unsigned int val, void *regs)
+{
+       writel(val, regs);
+}
+
+/* cpu to ohci */
+static inline __u16 cpu_to_ohci16 (const struct ohci_hcd *ohci,
+                                  const __u16 x)
+{
+       return cpu_to_le16(x);
+}
+
+static inline __u16 cpu_to_ohci16p (const struct ohci_hcd *ohci,
+                                   const __u16 *x)
+{
+       return cpu_to_le16p(x);
+}
+
+static inline __u32 cpu_to_ohci32 (const struct ohci_hcd *ohci,
+                                  const __u32 x)
+{
+       return cpu_to_le32(x);
+}
+
+static inline __u32 cpu_to_ohci32p (const struct ohci_hcd *ohci,
+                                   const __u32 *x)
+{
+       return cpu_to_le32p(x);
+}
+
+/* ohci to cpu */
+static inline __u16 ohci16_to_cpu (const struct ohci_hcd *ohci,
+                                  const __u16 x)
+{
+       return le16_to_cpu(x);
+}
+
+static inline __u16 ohci16_to_cpup (const struct ohci_hcd *ohci,
+                                   const __u16 *x)
+{
+       return le16_to_cpup(x);
+}
+
+static inline __u32 ohci32_to_cpu (const struct ohci_hcd *ohci,
+                                  const __u32 x)
+{
+       return le32_to_cpu(x);
+}
+
+static inline __u32 ohci32_to_cpup (const struct ohci_hcd *ohci,
+                                   const __u32 *x)
+{
+       return le32_to_cpup(x);
+}
+
+static inline __u16 ohci_frame_no(const struct ohci_hcd *ohci)
+{
+       return (__u16)le32_to_cpup(&ohci->hcca->frame_no);
+}
+
+#elif defined(CONFIG_USB_OHCI_BIG_ENDIAN) && !defined(CONFIG_USB_OHCI_LITTLE_ENDIAN)
+/* only support big endian */
+
+static inline unsigned int ohci_readl (const struct ohci_hcd *ohci,
+                                      const void* regs)
+{
+       return __raw_readl (regs);
+}
+
+static inline void ohci_writel (const struct ohci_hcd *ohci,
+                               const unsigned int val, void *regs)
+{
+       __raw_writel(val, regs);
+}
+
+/* cpu to ohci */
+static inline __u16 cpu_to_ohci16 (const struct ohci_hcd *ohci,
+                                  const __u16 x)
+{
+       return cpu_to_be16(x);
+}
+
+static inline __u16 cpu_to_ohci16p (const struct ohci_hcd *ohci,
+                                   const __u16 *x)
+{
+       return cpu_to_be16p(x);
+}
+
+static inline __u32 cpu_to_ohci32 (const struct ohci_hcd *ohci,
+                                  const __u32 x)
+{
+       return cpu_to_be32(x);
+}
+
+static inline __u32 cpu_to_ohci32p (const struct ohci_hcd *ohci,
+                                   const __u32 *x)
+{
+       return cpu_to_be32p(x);
+}
+
+/* ohci to cpu */
+static inline __u16 ohci16_to_cpu (const struct ohci_hcd *ohci,
+                                  const __u16 x)
+{
+       return be16_to_cpu(x);
+}
+
+static inline __u16 ohci16_to_cpup (const struct ohci_hcd *ohci,
+                                   const __u16 *x)
+{
+       return be16_to_cpup(x);
+}
+
+static inline __u32 ohci32_to_cpu (const struct ohci_hcd *ohci,
+                                  const __u32 x)
+{
+       return be32_to_cpu(x);
+}
+
+static inline __u32 ohci32_to_cpup (const struct ohci_hcd *ohci,
+                                   const __u32 *x)
+{
+       return be32_to_cpup(x);
+}
+
+static inline __u16 ohci_frame_no(const struct ohci_hcd *ohci)
+{
+       return (__u16)(be32_to_cpup(&ohci->hcca->frame_no) >> 16);
+}
+
+#elif defined(CONFIG_USB_OHCI_BIG_ENDIAN) && defined(CONFIG_USB_OHCI_LITTLE_ENDIAN)
+/* simultaneously support both little endian and big endian controllers */
+
+static inline unsigned int ohci_readl (const struct ohci_hcd *ohci, 
+                                      const void* regs)
+{
+       return (ohci->flags & OHCI_BIG_ENDIAN) ? __raw_readl(regs) : readl(regs);
+}
+
+static inline void ohci_writel (const struct ohci_hcd *ohci,
+                               const unsigned int val, void *regs)
+{
+       (ohci->flags & OHCI_BIG_ENDIAN) ?
+                               __raw_writel(val, regs) : writel(val, regs);
+}
+
+/* cpu to ohci */
+static inline __u16 cpu_to_ohci16 (const struct ohci_hcd *ohci,
+                                  const __u16 x)
+{
+       return (ohci->flags & OHCI_BIG_ENDIAN) ? cpu_to_be16(x) : cpu_to_le16(x);
+}
+
+static inline __u16 cpu_to_ohci16p (const struct ohci_hcd *ohci, 
+                                   const __u16 *x)
+{
+       return (ohci->flags & OHCI_BIG_ENDIAN) ? cpu_to_be16p(x) : cpu_to_le16p(x);
+}
+
+static inline __u32 cpu_to_ohci32 (const struct ohci_hcd *ohci,
+                                  const __u32 x)
+{
+       return (ohci->flags & OHCI_BIG_ENDIAN) ? cpu_to_be32(x) : cpu_to_le32(x);
+}
+
+static inline __u32 cpu_to_ohci32p (const struct ohci_hcd *ohci,
+                                   const __u32 *x)
+{
+       return (ohci->flags & OHCI_BIG_ENDIAN) ? cpu_to_be32p(x) : cpu_to_le32p(x);
+}
+
+/* ohci to cpu */
+static inline __u16 ohci16_to_cpu (const struct ohci_hcd *ohci,
+                                  const __u16 x)
+{
+       return (ohci->flags & OHCI_BIG_ENDIAN) ? be16_to_cpu(x) : le16_to_cpu(x);
+}
+
+static inline __u16 ohci16_to_cpup (const struct ohci_hcd *ohci,
+                                   const __u16 *x)
+{
+       return (ohci->flags & OHCI_BIG_ENDIAN) ? be16_to_cpup(x) : le16_to_cpup(x);
+}
+
+static inline __u32 ohci32_to_cpu (const struct ohci_hcd *ohci,
+                                  const __u32 x)
+{
+       return (ohci->flags & OHCI_BIG_ENDIAN) ? be32_to_cpu(x) : le32_to_cpu(x);
+}
+
+static inline __u32 ohci32_to_cpup (const struct ohci_hcd *ohci,
+                                   const __u32 *x)
+{
+       return (ohci->flags & OHCI_BIG_ENDIAN) ? be32_to_cpup(x) : le32_to_cpup(x);
+}
+
+static inline __u16 ohci_frame_no(const struct ohci_hcd *ohci)
+{
+       return (__u16)((ohci->flags & OHCI_BIG_ENDIAN) ?
+                       be32_to_cpup(&ohci->hcca->frame_no) >> 16 :
+                       le32_to_cpup(&ohci->hcca->frame_no));
+}
+
+#endif
+
+/*-------------------------------------------------------------------------*/
+
+static inline void disable (struct ohci_hcd *ohci)
+{
+       ohci->hcd.state = USB_STATE_HALT;
+}
+
+#define        FI                      0x2edf          /* 12000 bits per frame (-1) */
+#define        DEFAULT_FMINTERVAL      ((((6 * (FI - 210)) / 7) << 16) | FI)
+#define LSTHRESH               0x628           /* lowspeed bit threshold */
+
+
+static inline void periodic_reinit (struct ohci_hcd *ohci)
+{
+       ohci_writel (ohci, ohci->fminterval, &ohci->regs->fminterval);
+       ohci_writel (ohci, ((9 * FI) / 10) & 0x3fff,
+                       &ohci->regs->periodicstart);
+       ohci_writel (ohci, LSTHRESH, &ohci->regs->lsthresh);
+}
diff -Nru a/drivers/usb/host/ohci-dbg.c b/drivers/usb/host/ohci-dbg.c
--- a/drivers/usb/host/ohci-dbg.c       2004-08-02 13:31:00 -07:00
+++ b/drivers/usb/host/ohci-dbg.c       2004-08-02 13:31:00 -07:00
@@ -134,13 +134,13 @@
        struct ohci_regs        *regs = controller->regs;
        u32                     temp;
 
-       temp = ohci_readl (&regs->revision) & 0xff;
+       temp = ohci_readl (controller, &regs->revision) & 0xff;
        ohci_dbg_sw (controller, next, size,
                "OHCI %d.%d, %s legacy support registers\n",
                0x03 & (temp >> 4), (temp & 0x0f),
                (temp & 0x10) ? "with" : "NO");
 
-       temp = ohci_readl (&regs->control);
+       temp = ohci_readl (controller, &regs->control);
        ohci_dbg_sw (controller, next, size,
                "control 0x%03x%s%s%s HCFS=%s%s%s%s%s CBSR=%d\n",
                temp,
@@ -155,7 +155,7 @@
                temp & OHCI_CTRL_CBSR
                );
 
-       temp = ohci_readl (&regs->cmdstatus);
+       temp = ohci_readl (controller, &regs->cmdstatus);
        ohci_dbg_sw (controller, next, size,
                "cmdstatus 0x%05x SOC=%d%s%s%s%s\n", temp,
                (temp & OHCI_SOC) >> 16,
@@ -166,26 +166,33 @@
                );
 
        ohci_dump_intr_mask (controller, "intrstatus",
-                       ohci_readl (&regs->intrstatus), next, size);
+                       ohci_readl (controller, &regs->intrstatus),
+                       next, size);
        ohci_dump_intr_mask (controller, "intrenable",
-                       ohci_readl (&regs->intrenable), next, size);
+                       ohci_readl (controller, &regs->intrenable),
+                       next, size);
        // intrdisable always same as intrenable
 
        maybe_print_eds (controller, "ed_periodcurrent",
-                       ohci_readl (&regs->ed_periodcurrent), next, size);
+                       ohci_readl (controller, &regs->ed_periodcurrent),
+                       next, size);
 
        maybe_print_eds (controller, "ed_controlhead",
-                       ohci_readl (&regs->ed_controlhead), next, size);
+                       ohci_readl (controller, &regs->ed_controlhead),
+                       next, size);
        maybe_print_eds (controller, "ed_controlcurrent",
-                       ohci_readl (&regs->ed_controlcurrent), next, size);
+                       ohci_readl (controller, &regs->ed_controlcurrent),
+                       next, size);
 
        maybe_print_eds (controller, "ed_bulkhead",
-                       ohci_readl (&regs->ed_bulkhead), next, size);
+                       ohci_readl (controller, &regs->ed_bulkhead),
+                       next, size);
        maybe_print_eds (controller, "ed_bulkcurrent",
-                       ohci_readl (&regs->ed_bulkcurrent), next, size);
+                       ohci_readl (controller, &regs->ed_bulkcurrent),
+                       next, size);
 
        maybe_print_eds (controller, "donehead",
-                       ohci_readl (&regs->donehead), next, size);
+                       ohci_readl (controller, &regs->donehead), next, size);
 }
 
 #define dbg_port_sw(hc,num,value,next,size) \
@@ -269,7 +276,7 @@
        ohci_dump_status (controller, NULL, NULL);
        if (controller->hcca)
                ohci_dbg (controller,
-                       "hcca frame #%04x\n", OHCI_FRAME_NO(controller->hcca));
+                       "hcca frame #%04x\n", ohci_frame_no(controller));
        ohci_dump_roothub (controller, 1, NULL, NULL);
 }
 
@@ -279,13 +286,13 @@
 static void ohci_dump_td (const struct ohci_hcd *ohci, const char *label,
                const struct td *td)
 {
-       u32     tmp = le32_to_cpup (&td->hwINFO);
+       u32     tmp = ohci32_to_cpup (ohci, &td->hwINFO);
 
        ohci_dbg (ohci, "%s td %p%s; urb %p index %d; hw next td %08x\n",
                label, td,
                (tmp & TD_DONE) ? " (DONE)" : "",
                td->urb, td->index,
-               le32_to_cpup (&td->hwNextTD));
+               ohci32_to_cpup (ohci, &td->hwNextTD));
        if ((tmp & TD_ISO) == 0) {
                const char      *toggle, *pid;
                u32     cbp, be;
@@ -306,8 +313,8 @@
                        TD_CC_GET(tmp), /* EC, */ toggle,
                        (tmp & TD_DI) >> 21, pid,
                        (tmp & TD_R) ? "R" : "");
-               cbp = le32_to_cpup (&td->hwCBP);
-               be = le32_to_cpup (&td->hwBE);
+               cbp = ohci32_to_cpup (ohci, &td->hwCBP);
+               be = ohci32_to_cpup (ohci, &td->hwBE);
                ohci_dbg (ohci, "     cbp %08x be %08x (len %d)\n", cbp, be,
                        cbp ? (be + 1 - cbp) : 0);
        } else {
@@ -318,10 +325,10 @@
                        (tmp & TD_DI) >> 21,
                        tmp & 0x0000ffff);
                ohci_dbg (ohci, "  bp0 %08x be %08x\n",
-                       le32_to_cpup (&td->hwCBP) & ~0x0fff,
-                       le32_to_cpup (&td->hwBE));
+                       ohci32_to_cpup (ohci, &td->hwCBP) & ~0x0fff,
+                       ohci32_to_cpup (ohci, &td->hwBE));
                for (i = 0; i < MAXPSW; i++) {
-                       u16     psw = le16_to_cpup (&td->hwPSW [i]);
+                       u16     psw = ohci16_to_cpup (ohci, &td->hwPSW [i]);
                        int     cc = (psw >> 12) & 0x0f;
                        ohci_dbg (ohci, "    psw [%d] = %2x, CC=%x %s=%d\n", i,
                                psw, cc,
@@ -336,13 +343,13 @@
 ohci_dump_ed (const struct ohci_hcd *ohci, const char *label,
                const struct ed *ed, int verbose)
 {
-       u32     tmp = le32_to_cpu (ed->hwINFO);
+       u32     tmp = ohci32_to_cpu (ohci, ed->hwINFO);
        char    *type = "";
 
        ohci_dbg (ohci, "%s, ed %p state 0x%x type %s; next ed %08x\n",
                label,
                ed, ed->state, edstring (ed->type),
-               le32_to_cpup (&ed->hwNextED));
+               ohci32_to_cpup (ohci, &ed->hwNextED));
        switch (tmp & (ED_IN|ED_OUT)) {
        case ED_OUT: type = "-OUT"; break;
        case ED_IN: type = "-IN"; break;
@@ -358,12 +365,12 @@
                0x000f & (tmp >> 7),
                type,
                0x007f & tmp);
-       tmp = le32_to_cpup (&ed->hwHeadP);
+       tmp = ohci32_to_cpup (ohci, &ed->hwHeadP);
        ohci_dbg (ohci, "  tds: head %08x %s%s tail %08x%s\n",
                tmp,
                (tmp & ED_C) ? data1 : data0,
                (tmp & ED_H) ? " HALT" : "",
-               le32_to_cpup (&ed->hwTailP),
+               ohci32_to_cpup (ohci, &ed->hwTailP),
                verbose ? "" : " (not listing)");
        if (verbose) {
                struct list_head        *tmp;
@@ -416,11 +423,11 @@
 
        /* dump a snapshot of the bulk or control schedule */
        while (ed) {
-               u32                     info = le32_to_cpu (ed->hwINFO);
-               u32                     scratch = cpu_to_le32p (&ed->hwINFO);
-               u32                     scratch2 = cpu_to_le32 (ed->hwHeadP);
-               struct list_head        *entry;
-               struct td               *td;
+               u32             info = ohci32_to_cpu (ohci, ed->hwINFO);
+               u32             scratch = cpu_to_ohci32p (ohci, &ed->hwINFO);
+               u32             scratch2 = cpu_to_ohci32 (ohci, ed->hwHeadP);
+               struct list_head *entry;
+               struct td       *td;
 
                temp = scnprintf (buf, size,
                        "ed/%p %cs dev%d ep%d%s max %d %08x%s%s %s",
@@ -441,9 +448,9 @@
                        u32             cbp, be;
 
                        td = list_entry (entry, struct td, td_list);
-                       scratch = cpu_to_le32p (&td->hwINFO);
-                       cbp = le32_to_cpup (&td->hwCBP);
-                       be = le32_to_cpup (&td->hwBE);
+                       scratch = cpu_to_ohci32p (ohci, &td->hwINFO);
+                       cbp = ohci32_to_cpup (ohci, &td->hwCBP);
+                       be = ohci32_to_cpup (ohci, &td->hwBE);
                        temp = scnprintf (buf, size,
                                        "\n\ttd %p %s %d cc=%x urb %p (%08x)",
                                        td,
@@ -544,7 +551,8 @@
                        /* show more info the first time around */
                        if (temp == seen_count) {
                                u32     info = ohci32_to_cpu(ohci, ed->hwINFO);
-                               u32     scratch = cpu_to_le32p (&ed->hwINFO);
+                               u32     scratch = cpu_to_ohci32p (ohci,
+                                                                 &ed->hwINFO);
                                struct list_head        *entry;
                                unsigned                qlen = 0;
 
@@ -564,7 +572,7 @@
                                        0x03ff & (scratch >> 16),
                                        scratch,
                                        (info & ED_SKIP) ? " K" : "",
-                                       (le32_to_cpu(ed->hwHeadP) &
+                                       (ohci32_to_cpu(ohci, ed->hwHeadP) &
                                         ED_H) ? " H" : "");
                                size -= temp;
                                next += temp;
@@ -637,10 +645,10 @@
        /* hcca */
        if (ohci->hcca)
                ohci_dbg_sw (ohci, &next, &size,
-                       "hcca frame 0x%04x\n", OHCI_FRAME_NO(ohci->hcca));
+                       "hcca frame 0x%04x\n", ohci_frame_no(ohci));
 
        /* other registers mostly affect frame timings */
-       rdata = ohci_readl (&regs->fminterval);
+       rdata = ohci_readl (ohci, &regs->fminterval);
        temp = scnprintf (next, size,
                        "fmintvl 0x%08x %sFSMPS=0x%04x FI=0x%04x\n",
                        rdata, (rdata >> 31) ? " FIT" : "",
@@ -648,20 +656,20 @@
        size -= temp;
        next += temp;
 
-       rdata = ohci_readl (&regs->fmremaining);
+       rdata = ohci_readl (ohci, &regs->fmremaining);
        temp = scnprintf (next, size, "fmremaining 0x%08x %sFR=0x%04x\n",
                        rdata, (rdata >> 31) ? " FRT" : "",
                        rdata & 0x3fff);
        size -= temp;
        next += temp;
 
-       rdata = ohci_readl (&regs->periodicstart);
+       rdata = ohci_readl (ohci, &regs->periodicstart);
        temp = scnprintf (next, size, "periodicstart 0x%04x\n",
                        rdata & 0x3fff);
        size -= temp;
        next += temp;
 
-       rdata = ohci_readl (&regs->lsthresh);
+       rdata = ohci_readl (ohci, &regs->lsthresh);
        temp = scnprintf (next, size, "lsthresh 0x%04x\n",
                        rdata & 0x3fff);
        size -= temp;
diff -Nru a/drivers/usb/host/ohci-hcd.c b/drivers/usb/host/ohci-hcd.c
--- a/drivers/usb/host/ohci-hcd.c       2004-08-02 13:31:00 -07:00
+++ b/drivers/usb/host/ohci-hcd.c       2004-08-02 13:31:00 -07:00
@@ -240,7 +240,7 @@
                if (retval < 0)
                        goto fail0;
                if (ed->type == PIPE_ISOCHRONOUS) {
-                       u16     frame = OHCI_FRAME_NO(ohci->hcca);
+                       u16     frame = ohci_frame_no(ohci);
 
                        /* delay a few frames before the first TD */
                        frame += max_t (u16, 8, ed->interval);
@@ -383,7 +383,7 @@
 {
        struct ohci_hcd         *ohci = hcd_to_ohci (hcd);
 
-       return OHCI_FRAME_NO(ohci->hcca);
+       return ohci_frame_no(ohci);
 }
 
 /*-------------------------------------------------------------------------*
@@ -398,7 +398,7 @@
 
        /* boot firmware should have set this up (5.1.1.3.1) */
        if (!ohci->fminterval) {
-               temp = ohci_readl (&ohci->regs->fminterval);
+               temp = ohci_readl (ohci, &ohci->regs->fminterval);
                if (temp & 0x3fff0000)
                        ohci->fminterval = temp;
                else
@@ -410,7 +410,7 @@
         * On PA-RISC, PDC can leave IR set incorrectly; ignore it there.
         */
 #ifndef __hppa__
-       if (ohci_readl (&ohci->regs->control) & OHCI_CTRL_IR) {
+       if (ohci_readl (ohci, &ohci->regs->control) & OHCI_CTRL_IR) {
                ohci_dbg (ohci, "USB HC TakeOver from BIOS/SMM\n");
 
                /* this timeout is arbitrary.  we make it long, so systems
@@ -419,9 +419,9 @@
                 */
                temp = 500;     /* arbitrary: five seconds */
 
-               writel (OHCI_INTR_OC, &ohci->regs->intrenable);
-               writel (OHCI_OCR, &ohci->regs->cmdstatus);
-               while (ohci_readl (&ohci->regs->control) & OHCI_CTRL_IR) {
+               ohci_writel (ohci, OHCI_INTR_OC, &ohci->regs->intrenable);
+               ohci_writel (ohci, OHCI_OCR, &ohci->regs->cmdstatus);
+               while (ohci_readl (ohci, &ohci->regs->control) & OHCI_CTRL_IR) {
                        msleep (10);
                        if (--temp == 0) {
                                ohci_err (ohci, "USB HC TakeOver failed!\n");
@@ -432,36 +432,36 @@
 #endif
 
        /* Disable HC interrupts */
-       writel (OHCI_INTR_MIE, &ohci->regs->intrdisable);
+       ohci_writel (ohci, OHCI_INTR_MIE, &ohci->regs->intrdisable);
 
        ohci_dbg (ohci, "reset, control = 0x%x\n",
-                 ohci_readl (&ohci->regs->control));
+                 ohci_readl (ohci, &ohci->regs->control));
 
        /* Reset USB (needed by some controllers); RemoteWakeupConnected
         * saved if boot firmware (BIOS/SMM/...) told us it's connected
         * (for OHCI integrated on mainboard, it normally is)
         */
-       ohci->hc_control = ohci_readl (&ohci->regs->control);
+       ohci->hc_control = ohci_readl (ohci, &ohci->regs->control);
        ohci->hc_control &= OHCI_CTRL_RWC;      /* hcfs 0 = RESET */
        if (ohci->hc_control)
                ohci->hcd.can_wakeup = 1;
-       writel (ohci->hc_control, &ohci->regs->control);
+       ohci_writel (ohci, ohci->hc_control, &ohci->regs->control);
        if (power_switching) {
                unsigned ports = roothub_a (ohci) & RH_A_NDP; 
 
                /* power down each port */
                for (temp = 0; temp < ports; temp++)
-                       writel (RH_PS_LSDA,
+                       ohci_writel (ohci, RH_PS_LSDA,
                                &ohci->regs->roothub.portstatus [temp]);
        }
        // flush those pci writes
-       (void) ohci_readl (&ohci->regs->control);
+       (void) ohci_readl (ohci, &ohci->regs->control);
        msleep (50);
 
        /* HC Reset requires max 10 us delay */
-       writel (OHCI_HCR,  &ohci->regs->cmdstatus);
+       ohci_writel (ohci, OHCI_HCR,  &ohci->regs->cmdstatus);
        temp = 30;      /* ... allow extra time */
-       while ((ohci_readl (&ohci->regs->cmdstatus) & OHCI_HCR) != 0) {
+       while ((ohci_readl (ohci, &ohci->regs->cmdstatus) & OHCI_HCR) != 0) {
                if (--temp == 0) {
                        ohci_err (ohci, "USB HC reset timed out!\n");
                        return -1;
@@ -476,9 +476,9 @@
         * (SiS, OPTi ...), so reset again instead.  SiS doesn't need
         * this if we write fmInterval after we're OPERATIONAL.
         */
-       writel (ohci->hc_control, &ohci->regs->control);
+       ohci_writel (ohci, ohci->hc_control, &ohci->regs->control);
        // flush those pci writes
-       (void) ohci_readl (&ohci->regs->control);
+       (void) ohci_readl (ohci, &ohci->regs->control);
 
        return 0;
 }
@@ -499,19 +499,19 @@
 
        /* Tell the controller where the control and bulk lists are
         * The lists are empty now. */
-       writel (0, &ohci->regs->ed_controlhead);
-       writel (0, &ohci->regs->ed_bulkhead);
+       ohci_writel (ohci, 0, &ohci->regs->ed_controlhead);
+       ohci_writel (ohci, 0, &ohci->regs->ed_bulkhead);
 
        /* a reset clears this */
-       writel ((u32) ohci->hcca_dma, &ohci->regs->hcca);
+       ohci_writel (ohci, (u32) ohci->hcca_dma, &ohci->regs->hcca);
 
        periodic_reinit (ohci);
 
        /* some OHCI implementations are finicky about how they init.
         * bogus values here mean not even enumeration could work.
         */
-       if ((ohci_readl (&ohci->regs->fminterval) & 0x3fff0000) == 0
-                       || !ohci_readl (&ohci->regs->periodicstart)) {
+       if ((ohci_readl (ohci, &ohci->regs->fminterval) & 0x3fff0000) == 0
+                       || !ohci_readl (ohci, &ohci->regs->periodicstart)) {
                ohci_err (ohci, "init err\n");
                return -EOVERFLOW;
        }
@@ -519,7 +519,7 @@
        /* start controller operations */
        ohci->hc_control &= OHCI_CTRL_RWC;
        ohci->hc_control |= OHCI_CONTROL_INIT | OHCI_USB_OPER;
-       writel (ohci->hc_control, &ohci->regs->control);
+       ohci_writel (ohci, ohci->hc_control, &ohci->regs->control);
        ohci->hcd.state = USB_STATE_RUNNING;
 
        /* wake on ConnectStatusChange, matching external hubs */
@@ -527,8 +527,8 @@
 
        /* Choose the interrupts we care about now, others later on demand */
        mask = OHCI_INTR_INIT;
-       writel (mask, &ohci->regs->intrstatus);
-       writel (mask, &ohci->regs->intrenable);
+       ohci_writel (ohci, mask, &ohci->regs->intrstatus);
+       ohci_writel (ohci, mask, &ohci->regs->intrenable);
 
        /* handle root hub init quirks ... */
        tmp = roothub_a (ohci);
@@ -549,11 +549,12 @@
                 */
                tmp |= RH_A_NPS;
        }
-       writel (tmp, &ohci->regs->roothub.a);
-       writel (RH_HS_LPSC, &ohci->regs->roothub.status);
-       writel (power_switching ? RH_B_PPCM : 0, &ohci->regs->roothub.b);
+       ohci_writel (ohci, tmp, &ohci->regs->roothub.a);
+       ohci_writel (ohci, RH_HS_LPSC, &ohci->regs->roothub.status);
+       ohci_writel (ohci, power_switching ? RH_B_PPCM : 0,
+                       &ohci->regs->roothub.b);
        // flush those pci writes
-       (void) ohci_readl (&ohci->regs->control);
+       (void) ohci_readl (ohci, &ohci->regs->control);
 
        // POTPGT delay is bits 24-31, in 2 ms units.
        mdelay ((roothub_a (ohci) >> 23) & 0x1fe);
@@ -570,7 +571,7 @@
        if (!udev) {
                disable (ohci);
                ohci->hc_control &= ~OHCI_CTRL_HCFS;
-               writel (ohci->hc_control, &ohci->regs->control);
+               ohci_writel (ohci, ohci->hc_control, &ohci->regs->control);
                return -ENOMEM;
        }
 
@@ -579,7 +580,7 @@
                usb_put_dev (udev);
                disable (ohci);
                ohci->hc_control &= ~OHCI_CTRL_HCFS;
-               writel (ohci->hc_control, &ohci->regs->control);
+               ohci_writel (ohci, ohci->hc_control, &ohci->regs->control);
                return -ENODEV;
        }
 
@@ -599,17 +600,18 @@
        /* we can eliminate a (slow) ohci_readl()
           if _only_ WDH caused this irq */
        if ((ohci->hcca->done_head != 0)
-                       && ! (le32_to_cpup (&ohci->hcca->done_head) & 0x01)) {
+                       && ! (ohci32_to_cpup (ohci, &ohci->hcca->done_head)
+                               & 0x01)) {
                ints =  OHCI_INTR_WDH;
 
        /* cardbus/... hardware gone before remove() */
-       } else if ((ints = ohci_readl (&regs->intrstatus)) == ~(u32)0) {
+       } else if ((ints = ohci_readl (ohci, &regs->intrstatus)) == ~(u32)0) {
                disable (ohci);
                ohci_dbg (ohci, "device removed!\n");
                return IRQ_HANDLED;
 
        /* interrupt for some other device? */
-       } else if ((ints &= ohci_readl (&regs->intrenable)) == 0) {
+       } else if ((ints &= ohci_readl (ohci, &regs->intrenable)) == 0) {
                return IRQ_NONE;
        } 
 
@@ -629,12 +631,12 @@
 
        if (ints & OHCI_INTR_WDH) {
                if (HCD_IS_RUNNING(hcd->state))
-                       writel (OHCI_INTR_WDH, &regs->intrdisable);     
+                       ohci_writel (ohci, OHCI_INTR_WDH, &regs->intrdisable);  
                spin_lock (&ohci->lock);
                dl_done_list (ohci, ptregs);
                spin_unlock (&ohci->lock);
                if (HCD_IS_RUNNING(hcd->state))
-                       writel (OHCI_INTR_WDH, &regs->intrenable); 
+                       ohci_writel (ohci, OHCI_INTR_WDH, &regs->intrenable); 
        }
   
        /* could track INTR_SO to reduce available PCI/... bandwidth */
@@ -644,18 +646,18 @@
         */
        spin_lock (&ohci->lock);
        if (ohci->ed_rm_list)
-               finish_unlinks (ohci, OHCI_FRAME_NO(ohci->hcca),
+               finish_unlinks (ohci, ohci_frame_no(ohci),
                                ptregs);
        if ((ints & OHCI_INTR_SF) != 0 && !ohci->ed_rm_list
                        && HCD_IS_RUNNING(ohci->hcd.state))
-               writel (OHCI_INTR_SF, &regs->intrdisable);      
+               ohci_writel (ohci, OHCI_INTR_SF, &regs->intrdisable);   
        spin_unlock (&ohci->lock);
 
        if (HCD_IS_RUNNING(ohci->hcd.state)) {
-               writel (ints, &regs->intrstatus);
-               writel (OHCI_INTR_MIE, &regs->intrenable);      
+               ohci_writel (ohci, ints, &regs->intrstatus);
+               ohci_writel (ohci, OHCI_INTR_MIE, &regs->intrenable);   
                // flush those pci writes
-               (void) ohci_readl (&ohci->regs->control);
+               (void) ohci_readl (ohci, &ohci->regs->control);
        }
 
        return IRQ_HANDLED;
@@ -730,7 +732,7 @@
                switch (ed->state) {
                case ED_OPER:
                        ed->state = ED_UNLINK;
-                       ed->hwINFO |= cpu_to_le32(ED_DEQUEUE);
+                       ed->hwINFO |= cpu_to_ohci32(ED_DEQUEUE);
                        ed_deschedule (ohci, ed);
 
                        ed->ed_next = ohci->ed_rm_list;
diff -Nru a/drivers/usb/host/ohci-hub.c b/drivers/usb/host/ohci-hub.c
--- a/drivers/usb/host/ohci-hub.c       2004-08-02 13:31:00 -07:00
+++ b/drivers/usb/host/ohci-hub.c       2004-08-02 13:31:00 -07:00
@@ -12,7 +12,7 @@
 /*
  * OHCI Root Hub ... the nonsharable stuff
  *
- * Registers don't need cpu_to_le32, that happens transparently
+ * Registers don't need cpu_to_ohci32, that happens transparently
  */
 
 /* AMD-756 (D2 rev) reports corrupt register contents in some cases.
@@ -20,20 +20,20 @@
  * till some bits (mostly reserved) are clear; ok for all revs.
  */
 #define read_roothub(hc, register, mask) ({ \
-       u32 temp = ohci_readl (&hc->regs->roothub.register); \
+       u32 temp = ohci_readl (hc, &hc->regs->roothub.register); \
        if (temp == -1) \
                disable (hc); \
        else if (hc->flags & OHCI_QUIRK_AMD756) \
                while (temp & mask) \
-                       temp = ohci_readl (&hc->regs->roothub.register); \
+                       temp = ohci_readl (hc, &hc->regs->roothub.register); \
        temp; })
 
 static u32 roothub_a (struct ohci_hcd *hc)
        { return read_roothub (hc, a, 0xfc0fe000); }
 static inline u32 roothub_b (struct ohci_hcd *hc)
-       { return ohci_readl (&hc->regs->roothub.b); }
+       { return ohci_readl (hc, &hc->regs->roothub.b); }
 static inline u32 roothub_status (struct ohci_hcd *hc)
-       { return ohci_readl (&hc->regs->roothub.status); }
+       { return ohci_readl (hc, &hc->regs->roothub.status); }
 static u32 roothub_portstatus (struct ohci_hcd *hc, int i)
        { return read_roothub (hc, portstatus [i], 0xffe0fce0); }
 
@@ -83,14 +83,14 @@
 
        spin_lock_irq (&ohci->lock);
 
-       ohci->hc_control = ohci_readl (&ohci->regs->control);
+       ohci->hc_control = ohci_readl (ohci, &ohci->regs->control);
        switch (ohci->hc_control & OHCI_CTRL_HCFS) {
        case OHCI_USB_RESUME:
                ohci_dbg (ohci, "resume/suspend?\n");
                ohci->hc_control &= ~OHCI_CTRL_HCFS;
                ohci->hc_control |= OHCI_USB_RESET;
-               writel (ohci->hc_control, &ohci->regs->control);
-               (void) ohci_readl (&ohci->regs->control);
+               ohci_writel (ohci, ohci->hc_control, &ohci->regs->control);
+               (void) ohci_readl (ohci, &ohci->regs->control);
                /* FALL THROUGH */
        case OHCI_USB_RESET:
                status = -EBUSY;
@@ -108,9 +108,9 @@
                int             limit;
 
                ohci->hc_control &= ~OHCI_SCHED_ENABLES;
-               writel (ohci->hc_control, &ohci->regs->control);
-               ohci->hc_control = ohci_readl (&ohci->regs->control);
-               writel (OHCI_INTR_SF, &ohci->regs->intrstatus);
+               ohci_writel (ohci, ohci->hc_control, &ohci->regs->control);
+               ohci->hc_control = ohci_readl (ohci, &ohci->regs->control);
+               ohci_writel (ohci, OHCI_INTR_SF, &ohci->regs->intrstatus);
 
                /* sched disables take effect on the next frame,
                 * then the last WDH could take 6+ msec
@@ -120,15 +120,17 @@
                while (limit > 0) {
                        udelay (250);
                        limit =- 250;
-                       if (ohci_readl (&ohci->regs->intrstatus) & OHCI_INTR_SF)
+                       if (ohci_readl (ohci, &ohci->regs->intrstatus)
+                                       & OHCI_INTR_SF)
                                break;
                }
                dl_done_list (ohci, NULL);
                mdelay (7);
        }
        dl_done_list (ohci, NULL);
-       finish_unlinks (ohci, OHCI_FRAME_NO(ohci->hcca), NULL);
-       writel (ohci_readl (&ohci->regs->intrstatus), &ohci->regs->intrstatus);
+       finish_unlinks (ohci, ohci_frame_no(ohci), NULL);
+       ohci_writel (ohci, ohci_readl (ohci, &ohci->regs->intrstatus),
+                       &ohci->regs->intrstatus);
 
        /* maybe resume can wake root hub */
        if (ohci->hcd.remote_wakeup)
@@ -139,8 +141,8 @@
        /* Suspend hub */
        ohci->hc_control &= ~OHCI_CTRL_HCFS;
        ohci->hc_control |= OHCI_USB_SUSPEND;
-       writel (ohci->hc_control, &ohci->regs->control);
-       (void) ohci_readl (&ohci->regs->control);
+       ohci_writel (ohci, ohci->hc_control, &ohci->regs->control);
+       (void) ohci_readl (ohci, &ohci->regs->control);
 
        /* no resumes until devices finish suspending */
        ohci->next_statechange = jiffies + msecs_to_jiffies (5);
@@ -179,13 +181,13 @@
                return -EAGAIN;
 
        spin_lock_irq (&ohci->lock);
-       ohci->hc_control = ohci_readl (&ohci->regs->control);
+       ohci->hc_control = ohci_readl (ohci, &ohci->regs->control);
        switch (ohci->hc_control & OHCI_CTRL_HCFS) {
        case OHCI_USB_SUSPEND:
                ohci->hc_control &= ~(OHCI_CTRL_HCFS|OHCI_SCHED_ENABLES);
                ohci->hc_control |= OHCI_USB_RESUME;
-               writel (ohci->hc_control, &ohci->regs->control);
-               (void) ohci_readl (&ohci->regs->control);
+               ohci_writel (ohci, ohci->hc_control, &ohci->regs->control);
+               (void) ohci_readl (ohci, &ohci->regs->control);
                ohci_dbg (ohci, "resume root hub\n");
                break;
        case OHCI_USB_RESUME:
@@ -210,19 +212,21 @@
        temp = roothub_a (ohci) & RH_A_NDP;
        enables = 0;
        while (temp--) {
-               u32 stat = ohci_readl (&ohci->regs->roothub.portstatus [temp]);
+               u32 stat = ohci_readl (ohci,
+                                      &ohci->regs->roothub.portstatus [temp]);
 
                /* force global, not selective, resume */
                if (!(stat & RH_PS_PSS))
                        continue;
-               writel (RH_PS_POCI, &ohci->regs->roothub.portstatus [temp]);
+               ohci_writel (ohci, RH_PS_POCI,
+                               &ohci->regs->roothub.portstatus [temp]);
        }
 
        /* Some controllers (lucent) need extra-long delays */
        ohci->hcd.state = USB_STATE_RESUMING;
        mdelay (20 /* usb 11.5.1.10 */ + 15);
 
-       temp = ohci_readl (&ohci->regs->control);
+       temp = ohci_readl (ohci, &ohci->regs->control);
        temp &= OHCI_CTRL_HCFS;
        if (temp != OHCI_USB_RESUME) {
                ohci_err (ohci, "controller won't resume\n");
@@ -230,32 +234,33 @@
        }
 
        /* disable old schedule state, reinit from scratch */
-       writel (0, &ohci->regs->ed_controlhead);
-       writel (0, &ohci->regs->ed_controlcurrent);
-       writel (0, &ohci->regs->ed_bulkhead);
-       writel (0, &ohci->regs->ed_bulkcurrent);
-       writel (0, &ohci->regs->ed_periodcurrent);
-       writel ((u32) ohci->hcca_dma, &ohci->regs->hcca);
+       ohci_writel (ohci, 0, &ohci->regs->ed_controlhead);
+       ohci_writel (ohci, 0, &ohci->regs->ed_controlcurrent);
+       ohci_writel (ohci, 0, &ohci->regs->ed_bulkhead);
+       ohci_writel (ohci, 0, &ohci->regs->ed_bulkcurrent);
+       ohci_writel (ohci, 0, &ohci->regs->ed_periodcurrent);
+       ohci_writel (ohci, (u32) ohci->hcca_dma, &ohci->regs->hcca);
 
        periodic_reinit (ohci);
 
        /* interrupts might have been disabled */
-       writel (OHCI_INTR_INIT, &ohci->regs->intrenable);
+       ohci_writel (ohci, OHCI_INTR_INIT, &ohci->regs->intrenable);
        if (ohci->ed_rm_list)
-               writel (OHCI_INTR_SF, &ohci->regs->intrenable);
-       writel (ohci_readl (&ohci->regs->intrstatus), &ohci->regs->intrstatus);
+               ohci_writel (ohci, OHCI_INTR_SF, &ohci->regs->intrenable);
+       ohci_writel (ohci, ohci_readl (ohci, &ohci->regs->intrstatus),
+                       &ohci->regs->intrstatus);
 
        /* Then re-enable operations */
-       writel (OHCI_USB_OPER, &ohci->regs->control);
-       (void) ohci_readl (&ohci->regs->control);
+       ohci_writel (ohci, OHCI_USB_OPER, &ohci->regs->control);
+       (void) ohci_readl (ohci, &ohci->regs->control);
        msleep (3);
 
        temp = OHCI_CONTROL_INIT | OHCI_USB_OPER;
        if (ohci->hcd.can_wakeup)
                temp |= OHCI_CTRL_RWC;
        ohci->hc_control = temp;
-       writel (temp, &ohci->regs->control);
-       (void) ohci_readl (&ohci->regs->control);
+       ohci_writel (ohci, temp, &ohci->regs->control);
+       (void) ohci_readl (ohci, &ohci->regs->control);
 
        /* TRSMRCY */
        msleep (10);
@@ -269,13 +274,13 @@
        temp = 0;
        if (!ohci->ed_rm_list) {
                if (ohci->ed_controltail) {
-                       writel (find_head (ohci->ed_controltail)->dma,
+                       writel (ohci, find_head (ohci->ed_controltail)->dma,
                                &ohci->regs->ed_controlhead);
                        enables |= OHCI_CTRL_CLE;
                        temp |= OHCI_CLF;
                }
                if (ohci->ed_bulktail) {
-                       writel (find_head (ohci->ed_bulktail)->dma,
+                       writel (ohci, find_head (ohci->ed_bulktail)->dma,
                                &ohci->regs->ed_bulkhead);
                        enables |= OHCI_CTRL_BLE;
                        temp |= OHCI_BLF;
@@ -287,10 +292,10 @@
        if (enables) {
                ohci_dbg (ohci, "restarting schedules ... %08x\n", enables);
                ohci->hc_control |= enables;
-               writel (ohci->hc_control, &ohci->regs->control);
+               ohci_writel (ohci, ohci->hc_control, &ohci->regs->control);
                if (temp)
-                       writel (status, &ohci->regs->cmdstatus);
-               (void) ohci_readl (&ohci->regs->control);
+                       ohci_writel (ohci, status, &ohci->regs->cmdstatus);
+               (void) ohci_readl (ohci, &ohci->regs->control);
        }
 
        ohci->hcd.state = USB_STATE_RUNNING;
@@ -331,8 +336,8 @@
        if (ports > MAX_ROOT_PORTS) {
                if (!HCD_IS_RUNNING(ohci->hcd.state))
                        return -ESHUTDOWN;
-               ohci_err (ohci, "bogus NDP=%d, rereads as NDP=%d\n",
-                       ports, ohci_readl (&ohci->regs->roothub.a) & RH_A_NDP);
+               ohci_err (ohci, "bogus NDP=%d, rereads as NDP=%d\n", ports,
+                         ohci_readl (ohci, &ohci->regs->roothub.a) & RH_A_NDP);
                /* retry later; "should not happen" */
                return 0;
        }
@@ -421,7 +426,7 @@
            temp |= 0x0010;
        else if (rh & RH_A_OCPM)        /* per-port overcurrent reporting? */
            temp |= 0x0008;
-       desc->wHubCharacteristics = cpu_to_le16 (temp);
+       desc->wHubCharacteristics = cpu_to_ohci16 (ohci, temp);
 
        /* two bitmaps:  ports removable, and usb 1.0 legacy PortPwrCtrlMask */
        rh = roothub_b (ohci);
@@ -452,7 +457,8 @@
        case ClearHubFeature:
                switch (wValue) {
                case C_HUB_OVER_CURRENT:
-                       writel (RH_HS_OCIC, &ohci->regs->roothub.status);
+                       ohci_writel (ohci, RH_HS_OCIC,
+                                       &ohci->regs->roothub.status);
                case C_HUB_LOCAL_POWER:
                        break;
                default:
@@ -495,8 +501,9 @@
                default:
                        goto error;
                }
-               writel (temp, &ohci->regs->roothub.portstatus [wIndex]);
-               // ohci_readl (&ohci->regs->roothub.portstatus [wIndex]);
+               ohci_writel (ohci, temp,
+                               &ohci->regs->roothub.portstatus [wIndex]);
+               // ohci_readl (ohci, &ohci->regs->roothub.portstatus [wIndex]);
                break;
        case GetHubDescriptor:
                ohci_hub_descriptor (ohci, (struct usb_hub_descriptor *) buf);
@@ -533,17 +540,18 @@
                wIndex--;
                switch (wValue) {
                case USB_PORT_FEAT_SUSPEND:
-                       writel (RH_PS_PSS,
+                       ohci_writel (ohci, RH_PS_PSS,
                                &ohci->regs->roothub.portstatus [wIndex]);
                        break;
                case USB_PORT_FEAT_POWER:
-                       writel (RH_PS_PPS,
+                       ohci_writel (ohci, RH_PS_PPS,
                                &ohci->regs->roothub.portstatus [wIndex]);
                        break;
                case USB_PORT_FEAT_RESET:
-                       temp = ohci_readl (&ohci->regs->roothub.portstatus [wIndex]);
+                       temp = ohci_readl (ohci,
+                                   &ohci->regs->roothub.portstatus [wIndex]);
                        if (temp & RH_PS_CCS)
-                               writel (RH_PS_PRS,
+                               ohci_writel (ohci, RH_PS_PRS,
                                    &ohci->regs->roothub.portstatus [wIndex]);
                        break;
                default:
diff -Nru a/drivers/usb/host/ohci-mem.c b/drivers/usb/host/ohci-mem.c
--- a/drivers/usb/host/ohci-mem.c       2004-08-02 13:31:00 -07:00
+++ b/drivers/usb/host/ohci-mem.c       2004-08-02 13:31:00 -07:00
@@ -104,7 +104,7 @@
        if (td) {
                /* in case hc fetches it, make it look dead */
                memset (td, 0, sizeof *td);
-               td->hwNextTD = cpu_to_le32 (dma);
+               td->hwNextTD = cpu_to_ohci32 (hc, dma);
                td->td_dma = dma;
                /* hashed in td_fill */
        }
@@ -120,7 +120,7 @@
                prev = &(*prev)->td_hash;
        if (*prev)
                *prev = td->td_hash;
-       else if ((le32_to_cpu(td->hwINFO) & TD_DONE) != 0)
+       else if ((ohci32_to_cpu(hc, td->hwINFO) & TD_DONE) != 0)
                ohci_dbg (hc, "no hash for td %p\n", td);
        dma_pool_free (hc->td_cache, td, td->td_dma);
 }
diff -Nru a/drivers/usb/host/ohci-q.c b/drivers/usb/host/ohci-q.c
--- a/drivers/usb/host/ohci-q.c 2004-08-02 13:31:00 -07:00
+++ b/drivers/usb/host/ohci-q.c 2004-08-02 13:31:00 -07:00
@@ -78,7 +78,7 @@
        if (hcd_to_bus (&ohci->hcd)->bandwidth_isoc_reqs == 0
                        && hcd_to_bus (&ohci->hcd)->bandwidth_int_reqs == 0) {
                ohci->hc_control &= ~(OHCI_CTRL_PLE|OHCI_CTRL_IE);
-               writel (ohci->hc_control, &ohci->regs->control);
+               ohci_writel (ohci, ohci->hc_control, &ohci->regs->control);
        }
 }
 
@@ -131,7 +131,7 @@
        unsigned        i;
 
        ohci_vdbg (ohci, "link %sed %p branch %d [%dus.], interval %d\n",
-               (ed->hwINFO & cpu_to_le32 (ED_ISO)) ? "iso " : "",
+               (ed->hwINFO & cpu_to_ohci32 (ohci, ED_ISO)) ? "iso " : "",
                ed, ed->branch, ed->load, ed->interval);
 
        for (i = ed->branch; i < NUM_INTS; i += ed->interval) {
@@ -156,7 +156,7 @@
                                ed->hwNextED = *prev_p;
                        wmb ();
                        *prev = ed;
-                       *prev_p = cpu_to_le32p (&ed->dma);
+                       *prev_p = cpu_to_ohci32p (ohci, &ed->dma);
                        wmb();
                }
                ohci->load [i] += ed->load;
@@ -193,17 +193,20 @@
        case PIPE_CONTROL:
                if (ohci->ed_controltail == NULL) {
                        WARN_ON (ohci->hc_control & OHCI_CTRL_CLE);
-                       writel (ed->dma, &ohci->regs->ed_controlhead);
+                       ohci_writel (ohci, ed->dma,
+                                       &ohci->regs->ed_controlhead);
                } else {
                        ohci->ed_controltail->ed_next = ed;
-                       ohci->ed_controltail->hwNextED = cpu_to_le32 (ed->dma);
+                       ohci->ed_controltail->hwNextED = cpu_to_ohci32 (ohci,
+                                                               ed->dma);
                }
                ed->ed_prev = ohci->ed_controltail;
                if (!ohci->ed_controltail && !ohci->ed_rm_list) {
                        wmb();
                        ohci->hc_control |= OHCI_CTRL_CLE;
-                       writel (0, &ohci->regs->ed_controlcurrent);
-                       writel (ohci->hc_control, &ohci->regs->control);
+                       ohci_writel (ohci, 0, &ohci->regs->ed_controlcurrent);
+                       ohci_writel (ohci, ohci->hc_control,
+                                       &ohci->regs->control);
                }
                ohci->ed_controltail = ed;
                break;
@@ -211,17 +214,19 @@
        case PIPE_BULK:
                if (ohci->ed_bulktail == NULL) {
                        WARN_ON (ohci->hc_control & OHCI_CTRL_BLE);
-                       writel (ed->dma, &ohci->regs->ed_bulkhead);
+                       ohci_writel (ohci, ed->dma, &ohci->regs->ed_bulkhead);
                } else {
                        ohci->ed_bulktail->ed_next = ed;
-                       ohci->ed_bulktail->hwNextED = cpu_to_le32 (ed->dma);
+                       ohci->ed_bulktail->hwNextED = cpu_to_ohci32 (ohci,
+                                                               ed->dma);
                }
                ed->ed_prev = ohci->ed_bulktail;
                if (!ohci->ed_bulktail && !ohci->ed_rm_list) {
                        wmb();
                        ohci->hc_control |= OHCI_CTRL_BLE;
-                       writel (0, &ohci->regs->ed_bulkcurrent);
-                       writel (ohci->hc_control, &ohci->regs->control);
+                       ohci_writel (ohci, 0, &ohci->regs->ed_bulkcurrent);
+                       ohci_writel (ohci, ohci->hc_control,
+                                       &ohci->regs->control);
                }
                ohci->ed_bulktail = ed;
                break;
@@ -272,7 +277,7 @@
        hcd_to_bus (&ohci->hcd)->bandwidth_allocated -= ed->load / ed->interval;
 
        ohci_vdbg (ohci, "unlink %sed %p branch %d [%dus.], interval %d\n",
-               (ed->hwINFO & cpu_to_le32 (ED_ISO)) ? "iso " : "",
+               (ed->hwINFO & cpu_to_ohci32 (ohci, ED_ISO)) ? "iso " : "",
                ed, ed->branch, ed->load, ed->interval);
 }
 
@@ -300,7 +305,7 @@
  */
 static void ed_deschedule (struct ohci_hcd *ohci, struct ed *ed) 
 {
-       ed->hwINFO |= cpu_to_le32 (ED_SKIP);
+       ed->hwINFO |= cpu_to_ohci32 (ohci, ED_SKIP);
        wmb ();
        ed->state = ED_UNLINK;
 
@@ -320,10 +325,12 @@
                if (ed->ed_prev == NULL) {
                        if (!ed->hwNextED) {
                                ohci->hc_control &= ~OHCI_CTRL_CLE;
-                               writel (ohci->hc_control, &ohci->regs->control);
+                               ohci_writel (ohci, ohci->hc_control,
+                                               &ohci->regs->control);
                                // a ohci_readl() later syncs CLE with the HC
                        } else
-                               writel (le32_to_cpup (&ed->hwNextED),
+                               ohci_writel (ohci,
+                                       ohci32_to_cpup (ohci, &ed->hwNextED),
                                        &ohci->regs->ed_controlhead);
                } else {
                        ed->ed_prev->ed_next = ed->ed_next;
@@ -344,10 +351,12 @@
                if (ed->ed_prev == NULL) {
                        if (!ed->hwNextED) {
                                ohci->hc_control &= ~OHCI_CTRL_BLE;
-                               writel (ohci->hc_control, &ohci->regs->control);
+                               ohci_writel (ohci, ohci->hc_control,
+                                               &ohci->regs->control);
                                // a ohci_readl() later syncs BLE with the HC
                        } else
-                               writel (le32_to_cpup (&ed->hwNextED),
+                               ohci_writel (ohci,
+                                       ohci32_to_cpup (ohci, &ed->hwNextED),
                                        &ohci->regs->ed_bulkhead);
                } else {
                        ed->ed_prev->ed_next = ed->ed_next;
@@ -416,7 +425,7 @@
                        goto done;
                }
                ed->dummy = td;
-               ed->hwTailP = cpu_to_le32 (td->td_dma);
+               ed->hwTailP = cpu_to_ohci32 (ohci, td->td_dma);
                ed->hwHeadP = ed->hwTailP;      /* ED_C, ED_H zeroed */
                ed->state = ED_IDLE;
                ed->type = type;
@@ -431,16 +440,16 @@
                info = usb_pipedevice (pipe);
                info |= (ep >> 1) << 7;
                info |= usb_maxpacket (udev, pipe, is_out) << 16;
-               info = cpu_to_le32 (info);
+               info = cpu_to_ohci32 (ohci, info);
                if (udev->speed == USB_SPEED_LOW)
-                       info |= cpu_to_le32 (ED_LOWSPEED);
+                       info |= cpu_to_ohci32 (ohci, ED_LOWSPEED);
                /* only control transfers store pids in tds */
                if (type != PIPE_CONTROL) {
-                       info |= cpu_to_le32(is_out ? ED_OUT : ED_IN);
+                       info |= cpu_to_ohci32(ohci, is_out ? ED_OUT : ED_IN);
                        if (type != PIPE_BULK) {
                                /* periodic transfers... */
                                if (type == PIPE_ISOCHRONOUS)
-                                       info |= cpu_to_le32 (ED_ISO);
+                                       info |= cpu_to_ohci32 (ohci, ED_ISO);
                                else if (interval > 32) /* iso can be bigger */
                                        interval = 32;
                                ed->interval = interval;
@@ -469,7 +478,7 @@
  */
 static void start_ed_unlink (struct ohci_hcd *ohci, struct ed *ed)
 {    
-       ed->hwINFO |= cpu_to_le32 (ED_DEQUEUE);
+       ed->hwINFO |= cpu_to_ohci32 (ohci, ED_DEQUEUE);
        ed_deschedule (ohci, ed);
 
        /* rm_list is just singly linked, for simplicity */
@@ -478,17 +487,17 @@
        ohci->ed_rm_list = ed;
 
        /* enable SOF interrupt */
-       writel (OHCI_INTR_SF, &ohci->regs->intrstatus);
-       writel (OHCI_INTR_SF, &ohci->regs->intrenable);
+       ohci_writel (ohci, OHCI_INTR_SF, &ohci->regs->intrstatus);
+       ohci_writel (ohci, OHCI_INTR_SF, &ohci->regs->intrenable);
        // flush those writes, and get latest HCCA contents
-       (void) ohci_readl (&ohci->regs->control);
+       (void) ohci_readl (ohci, &ohci->regs->control);
 
        /* SF interrupt might get delayed; record the frame counter value that
         * indicates when the HC isn't looking at it, so concurrent unlinks
         * behave.  frame_no wraps every 2^16 msec, and changes right before
         * SF is triggered.
         */
-       ed->tick = OHCI_FRAME_NO(ohci->hcca) + 1;
+       ed->tick = ohci_frame_no(ohci) + 1;
 
 }
 
@@ -540,19 +549,19 @@
        if (!len)
                data = 0;
 
-       td->hwINFO = cpu_to_le32 (info);
+       td->hwINFO = cpu_to_ohci32 (ohci, info);
        if (is_iso) {
-               td->hwCBP = cpu_to_le32 (data & 0xFFFFF000);
-               td->hwPSW [0] = cpu_to_le16 ((data & 0x0FFF) | 0xE000);
+               td->hwCBP = cpu_to_ohci32 (ohci, data & 0xFFFFF000);
+               td->hwPSW [0] = cpu_to_ohci16 (ohci, (data & 0x0FFF) | 0xE000);
                td->ed->last_iso = info & 0xffff;
        } else {
-               td->hwCBP = cpu_to_le32 (data); 
+               td->hwCBP = cpu_to_ohci32 (ohci, data); 
        }                       
        if (data)
-               td->hwBE = cpu_to_le32 (data + len - 1);
+               td->hwBE = cpu_to_ohci32 (ohci, data + len - 1);
        else
                td->hwBE = 0;
-       td->hwNextTD = cpu_to_le32 (td_pt->td_dma);
+       td->hwNextTD = cpu_to_ohci32 (ohci, td_pt->td_dma);
 
        /* append to queue */
        list_add_tail (&td->td_list, &td->ed->td_list);
@@ -593,7 +602,7 @@
        if (!usb_gettoggle (urb->dev, usb_pipeendpoint (urb->pipe), is_out)) {
                usb_settoggle (urb->dev, usb_pipeendpoint (urb->pipe),
                        is_out, 1);
-               urb_priv->ed->hwHeadP &= ~cpu_to_le32 (ED_C);
+               urb_priv->ed->hwHeadP &= ~cpu_to_ohci32 (ohci, ED_C);
        }
 
        urb_priv->td_cnt = 0;
@@ -642,7 +651,7 @@
                /* maybe kickstart bulk list */
                if (urb_priv->ed->type == PIPE_BULK) {
                        wmb ();
-                       writel (OHCI_BLF, &ohci->regs->cmdstatus);
+                       ohci_writel (ohci, OHCI_BLF, &ohci->regs->cmdstatus);
                }
                break;
 
@@ -664,7 +673,7 @@
                td_fill (ohci, info, data, 0, urb, cnt++);
                /* maybe kickstart control list */
                wmb ();
-               writel (OHCI_CLF, &ohci->regs->cmdstatus);
+               ohci_writel (ohci, OHCI_CLF, &ohci->regs->cmdstatus);
                break;
 
        /* ISO has no retransmit, so no toggle; and it uses special TDs.
@@ -693,7 +702,7 @@
        if (periodic) {
                wmb ();
                ohci->hc_control |= OHCI_CTRL_PLE|OHCI_CTRL_IE;
-               writel (ohci->hc_control, &ohci->regs->control);
+               ohci_writel (ohci, ohci->hc_control, &ohci->regs->control);
        }
 
        // ASSERT (urb_priv->length == cnt);
@@ -708,14 +717,14 @@
  */
 static void td_done (struct ohci_hcd *ohci, struct urb *urb, struct td *td)
 {
-       u32     tdINFO = le32_to_cpup (&td->hwINFO);
+       u32     tdINFO = ohci32_to_cpup (ohci, &td->hwINFO);
        int     cc = 0;
 
        list_del (&td->td_list);
 
        /* ISO ... drivers see per-TD length/status */
        if (tdINFO & TD_ISO) {
-               u16     tdPSW = le16_to_cpu (td->hwPSW [0]);
+               u16     tdPSW = ohci16_to_cpu (ohci, td->hwPSW [0]);
                int     dlen = 0;
 
                /* NOTE:  assumes FC in tdINFO == 0 (and MAXPSW == 1) */
@@ -747,7 +756,7 @@
         */
        } else {
                int     type = usb_pipetype (urb->pipe);
-               u32     tdBE = le32_to_cpup (&td->hwBE);
+               u32     tdBE = ohci32_to_cpup (ohci, &td->hwBE);
 
                cc = TD_CC_GET (tdINFO);
 
@@ -774,7 +783,7 @@
                                urb->actual_length += tdBE - td->data_dma + 1;
                        else
                                urb->actual_length +=
-                                         le32_to_cpup (&td->hwCBP)
+                                         ohci32_to_cpup (ohci, &td->hwCBP)
                                        - td->data_dma;
                }
 
@@ -792,17 +801,17 @@
 static inline struct td *
 ed_halted (struct ohci_hcd *ohci, struct td *td, int cc, struct td *rev)
 {
-       struct urb              *urb = td->urb;
-       struct ed               *ed = td->ed;
-       struct list_head        *tmp = td->td_list.next;
-       u32                     toggle = ed->hwHeadP & cpu_to_ohci32 (ED_C);
+       struct urb      *urb = td->urb;
+       struct ed       *ed = td->ed;
+       struct list_head *tmp = td->td_list.next;
+       u32             toggle = ed->hwHeadP & cpu_to_ohci32 (ohci, ED_C);
 
        /* clear ed halt; this is the td that caused it, but keep it inactive
         * until its urb->complete() has a chance to clean up.
         */
-       ed->hwINFO |= cpu_to_le32 (ED_SKIP);
+       ed->hwINFO |= cpu_to_ohci32 (ohci, ED_SKIP);
        wmb ();
-       ed->hwHeadP &= ~cpu_to_le32 (ED_H); 
+       ed->hwHeadP &= ~cpu_to_ohci32 (ohci, ED_H); 
 
        /* put any later tds from this urb onto the donelist, after 'td',
         * order won't matter here: no errors, and nothing was transferred.
@@ -826,8 +835,8 @@
                 * and clear ED_SKIP.
                 */
                info = next->hwINFO;
-               info |= cpu_to_le32 (TD_DONE);
-               info &= ~cpu_to_le32 (TD_CC);
+               info |= cpu_to_ohci32 (ohci, TD_DONE);
+               info &= ~cpu_to_ohci32 (ohci, TD_CC);
                next->hwINFO = info;
 
                next->next_dl_td = rev; 
@@ -855,7 +864,7 @@
                        urb, urb->dev->devpath,
                        usb_pipeendpoint (urb->pipe),
                        usb_pipein (urb->pipe) ? "in" : "out",
-                       le32_to_cpu (td->hwINFO),
+                       ohci32_to_cpu (ohci, td->hwINFO),
                        cc, cc_to_error [cc]);
        }
 
@@ -871,7 +880,7 @@
        struct td       *td_rev = NULL;
        struct td       *td = NULL;
 
-       td_dma = le32_to_cpup (&ohci->hcca->done_head);
+       td_dma = ohci32_to_cpup (ohci, &ohci->hcca->done_head);
        ohci->hcca->done_head = 0;
        wmb();
 
@@ -887,20 +896,20 @@
                        break;
                }
 
-               td->hwINFO |= cpu_to_le32 (TD_DONE);
-               cc = TD_CC_GET (le32_to_cpup (&td->hwINFO));
+               td->hwINFO |= cpu_to_ohci32 (ohci, TD_DONE);
+               cc = TD_CC_GET (ohci32_to_cpup (ohci, &td->hwINFO));
 
                /* Non-iso endpoints can halt on error; un-halt,
                 * and dequeue any other TDs from this urb.
                 * No other TD could have caused the halt.
                 */
                if (cc != TD_CC_NOERROR &&
-                               (td->ed->hwHeadP & cpu_to_le32 (ED_H)))
+                               (td->ed->hwHeadP & cpu_to_ohci32 (ohci, ED_H)))
                        td_rev = ed_halted (ohci, td, cc, td_rev);
 
                td->next_dl_td = td_rev;        
                td_rev = td;
-               td_dma = le32_to_cpup (&td->hwNextTD);
+               td_dma = ohci32_to_cpup (ohci, &td->hwNextTD);
        }       
        return td_rev;
 }
@@ -938,7 +947,8 @@
 
                                td = list_entry (ed->td_list.next, struct td,
                                                        td_list);
-                               head = cpu_to_le32 (ed->hwHeadP) & TD_MASK;
+                               head = ohci32_to_cpu (ohci, ed->hwHeadP) &
+                                                               TD_MASK;
 
                                /* INTR_WDH may need to clean up first */
                                if (td->td_dma != head)
@@ -981,7 +991,7 @@
                        }
 
                        /* patch pointer hc uses */
-                       savebits = *prev & ~cpu_to_le32 (TD_MASK);
+                       savebits = *prev & ~cpu_to_ohci32 (ohci, TD_MASK);
                        *prev = td->hwNextTD | savebits;
 
                        /* HC may have partly processed this TD */
@@ -999,10 +1009,10 @@
 
                /* ED's now officially unlinked, hc doesn't see */
                ed->state = ED_IDLE;
-               ed->hwHeadP &= ~cpu_to_le32(ED_H);
+               ed->hwHeadP &= ~cpu_to_ohci32(ohci, ED_H);
                ed->hwNextED = 0;
                wmb ();
-               ed->hwINFO &= ~cpu_to_le32 (ED_SKIP | ED_DEQUEUE);
+               ed->hwINFO &= ~cpu_to_ohci32 (ohci, ED_SKIP | ED_DEQUEUE);
 
                /* but if there's work queued, reschedule */
                if (!list_empty (&ed->td_list)) {
@@ -1024,24 +1034,27 @@
                        command |= OHCI_CLF;
                        if (!(ohci->hc_control & OHCI_CTRL_CLE)) {
                                control |= OHCI_CTRL_CLE;
-                               writel (0, &ohci->regs->ed_controlcurrent);
+                               ohci_writel (ohci, 0,
+                                       &ohci->regs->ed_controlcurrent);
                        }
                }
                if (ohci->ed_bulktail) {
                        command |= OHCI_BLF;
                        if (!(ohci->hc_control & OHCI_CTRL_BLE)) {
                                control |= OHCI_CTRL_BLE;
-                               writel (0, &ohci->regs->ed_bulkcurrent);
+                               ohci_writel (ohci, 0,
+                                       &ohci->regs->ed_bulkcurrent);
                        }
                }
                
                /* CLE/BLE to enable, CLF/BLF to (maybe) kickstart */
                if (control) {
                        ohci->hc_control |= control;
-                       writel (ohci->hc_control, &ohci->regs->control);   
+                       ohci_writel (ohci, ohci->hc_control,
+                                       &ohci->regs->control);   
                }
                if (command)
-                       writel (command, &ohci->regs->cmdstatus);   
+                       ohci_writel (ohci, command, &ohci->regs->cmdstatus);   
        }
 }
 
@@ -1081,18 +1094,18 @@
                                start_ed_unlink (ohci, ed);
 
                /* ... reenabling halted EDs only after fault cleanup */
-               } else if ((ed->hwINFO & cpu_to_le32 (ED_SKIP | ED_DEQUEUE)) == 
cpu_to_le32 (ED_SKIP)) {
+               } else if ((ed->hwINFO & cpu_to_ohci32 (ohci, ED_SKIP | ED_DEQUEUE)) 
== cpu_to_ohci32 (ohci, ED_SKIP)) {
                        td = list_entry (ed->td_list.next, struct td, td_list);
                        if (!(td->hwINFO & TD_DONE)) {
-                               ed->hwINFO &= ~cpu_to_le32 (ED_SKIP);
+                               ed->hwINFO &= ~cpu_to_ohci32 (ohci, ED_SKIP);
                                /* ... hc may need waking-up */
                                switch (ed->type) {
                                case PIPE_CONTROL:
-                                       writel (OHCI_CLF,
+                                       ohci_writel (ohci, OHCI_CLF,
                                                &ohci->regs->cmdstatus);   
                                        break;
                                case PIPE_BULK:
-                                       writel (OHCI_BLF,
+                                       ohci_writel (ohci, OHCI_BLF,
                                                &ohci->regs->cmdstatus);   
                                        break;
                                }


-------------------------------------------------------
This SF.Net email is sponsored by OSTG. Have you noticed the changes on
Linux.com, ITManagersJournal and NewsForge in the past few weeks? Now,
one more big change to announce. We are now OSTG- Open Source Technology
Group. Come see the changes on the new OSTG site. www.ostg.com
_______________________________________________
[EMAIL PROTECTED]
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel

Reply via email to