]> git.karo-electronics.de Git - karo-tx-uboot.git/blobdiff - drivers/usb/usb_ohci.c
Fix endianess conversion in usb_ohci.c
[karo-tx-uboot.git] / drivers / usb / usb_ohci.c
index cfa384eff6f4ac67e41beae6772a7b3a62c9b55f..fd60edbb3d446f32cf6bbc3d18d23b15fcca701e 100644 (file)
@@ -53,6 +53,9 @@
 
 #if defined(CONFIG_PCI_OHCI)
 # include <pci.h>
+#if !defined(CONFIG_PCI_OHCI_DEVNO)
+#define CONFIG_PCI_OHCI_DEVNO  0
+#endif
 #endif
 
 #include <malloc.h>
@@ -68,7 +71,8 @@
     defined(CONFIG_S3C2410) || \
     defined(CONFIG_440EP) || \
     defined(CONFIG_PCI_OHCI) || \
-    defined(CONFIG_MPC5200)
+    defined(CONFIG_MPC5200) || \
+    defined(CFG_OHCI_USE_NPS)
 # define OHCI_USE_NPS          /* force NoPowerSwitching mode */
 #endif
 
  * e.g. PCI controllers need this
  */
 #ifdef CFG_OHCI_SWAP_REG_ACCESS
-# define readl(a) __swap_32(*((vu_long *)(a)))
-# define writel(a, b) (*((vu_long *)(b)) = __swap_32((vu_long)a))
+# define readl(a) __swap_32(*((volatile u32 *)(a)))
+# define writel(a, b) (*((volatile u32 *)(b)) = __swap_32((volatile u32)a))
 #else
-# define readl(a) (*((vu_long *)(a)))
-# define writel(a, b) (*((vu_long *)(b)) = ((vu_long)a))
+# define readl(a) (*((volatile u32 *)(a)))
+# define writel(a, b) (*((volatile u32 *)(b)) = ((volatile u32)a))
 #endif /* CFG_OHCI_SWAP_REG_ACCESS */
 
 #define min_t(type,x,y) ({ type __x = (x); type __y = (y); __x < __y ? __x: __y; })
 static struct pci_device_id ohci_pci_ids[] = {
        {0x10b9, 0x5237},       /* ULI1575 PCI OHCI module ids */
        {0x1033, 0x0035},       /* NEC PCI OHCI module ids */
+       {0x1131, 0x1561},       /* Philips 1561 PCI OHCI module ids */
        /* Please add supported PCI OHCI controller ids here */
        {0, 0}
 };
@@ -109,7 +114,6 @@ static struct pci_device_id ohci_pci_ids[] = {
 #define dbg(format, arg...) do {} while(0)
 #endif /* DEBUG */
 #define err(format, arg...) printf("ERROR: " format "\n", ## arg)
-#undef SHOW_INFO
 #ifdef SHOW_INFO
 #define info(format, arg...) printf("INFO: " format "\n", ## arg)
 #else
@@ -137,28 +141,14 @@ int got_rhsc;
 /* device which was disconnected */
 struct usb_device *devgone;
 
-/*-------------------------------------------------------------------------*/
-
-/* AMD-756 (D2 rev) reports corrupt register contents in some cases.
- * The erratum (#4) description is incorrect.  AMD's workaround waits
- * till some bits (mostly reserved) are clear; ok for all revs.
- */
-#define OHCI_QUIRK_AMD756 0xabcd
-#define read_roothub(hc, register, mask) ({ \
-       u32 temp = readl (&hc->regs->roothub.register); \
-       if (hc->flags & OHCI_QUIRK_AMD756) \
-               while (temp & mask) \
-                       temp = readl (&hc->regs->roothub.register); \
-       temp; })
-
-static u32 roothub_a (struct ohci *hc)
-       { return read_roothub (hc, a, 0xfc0fe000); }
+static inline u32 roothub_a (struct ohci *hc)
+       { return readl (&hc->regs->roothub.a); }
 static inline u32 roothub_b (struct ohci *hc)
        { return readl (&hc->regs->roothub.b); }
 static inline u32 roothub_status (struct ohci *hc)
        { return readl (&hc->regs->roothub.status); }
-static u32 roothub_portstatus (struct ohci *hc, int i)
-       { return read_roothub (hc, portstatus [i], 0xffe0fce0); }
+static inline u32 roothub_portstatus (struct ohci *hc, int i)
+       { return readl (&hc->regs->roothub.portstatus[i]); }
 
 /* forward declaration */
 static int hc_interrupt (void);
@@ -414,7 +404,7 @@ static void ohci_dump (ohci_t *controller, int verbose)
                ep_print_int_eds (controller, "hcca");
        dbg ("hcca frame #%04x", controller->hcca->frame_no);
        ohci_dump_roothub (controller, 1);
-
+}
 #endif /* DEBUG */
 
 /*-------------------------------------------------------------------------*
@@ -1231,9 +1221,9 @@ pkt_print(NULL, dev, pipe, buffer, transfer_len, cmd, "SUB(rh)", usb_pipein(pipe
        }
 
        bmRType_bReq  = cmd->requesttype | (cmd->request << 8);
-       wValue        = cpu_to_le16 (cmd->value);
-       wIndex        = cpu_to_le16 (cmd->index);
-       wLength       = cpu_to_le16 (cmd->length);
+       wValue        = le16_to_cpu (cmd->value);
+       wIndex        = le16_to_cpu (cmd->index);
+       wLength       = le16_to_cpu (cmd->length);
 
        info("Root-Hub: adr: %2x cmd(%1x): %08x %04x %04x %04x",
                dev->devnum, 8, bmRType_bReq, wValue, wIndex, wLength);
@@ -1831,7 +1821,7 @@ int usb_lowlevel_init(void)
        gohci.sleeping = 0;
        gohci.irq = -1;
 #ifdef CONFIG_PCI_OHCI
-       pdev = pci_find_devices(ohci_pci_ids, 0);
+       pdev = pci_find_devices(ohci_pci_ids, CONFIG_PCI_OHCI_DEVNO);
 
        if (pdev != -1) {
                u16 vid, did;