[PATCH] EHCI: Safe endianness for transfer buffers after reset in case of HUB with TT

Vladimir Barinov <[email protected]>
Newsgroups gmane.linux.usb.devel
Message-ID <[email protected]>
This patch fixes the endianness select for transfer buffers in EHCI controllers that have Transaction Translator built in the hub.
Also I cleaned it up to make rid of magic numbers.

Signed-off-by: Vladimir Barinov <[email protected]>

------

--- usb-2.6.orig/drivers/usb/host/ehci.h        2007-05-02 17:31:10.000000000 +0400
+++ usb-2.6.new/drivers/usb/host/ehci.h 2007-05-02 18:15:11.000000000 +0400
@@ -299,6 +299,12 @@ struct ehci_regs {
 #define PORT_RWC_BITS   (PORT_CSC | PORT_PEC | PORT_OCC)
 } __attribute__ ((packed));
 
+#define USBMODE                0x68            /* USB Device mode */
+#define USBMODE_SDIS   (1<<3)          /* Stream disable */
+#define USBMODE_BE     (1<<2)          /* BE/LE endianness select */
+#define USBMODE_CM_HC  (3<<0)          /* host controller mode */
+#define USBMODE_CM_IDLE        (0<<0)          /* idle state */
+
 /* Appendix C, Debug port ... intended for use with special "debug devices"
  * that can help if there's no serial console.  (nonstandard enumeration.)
  */
--- usb-2.6.orig/drivers/usb/host/ehci-hcd.c    2007-05-02 17:31:18.000000000 +0400
+++ usb-2.6.new/drivers/usb/host/ehci-hcd.c     2007-05-02 18:14:49.000000000 +0400
@@ -202,9 +202,15 @@ static void tdi_reset (struct ehci_hcd *
        u32 __iomem     *reg_ptr;
        u32             tmp;
 
-       reg_ptr = (u32 __iomem *)(((u8 __iomem *)ehci->regs) + 0x68);
+       reg_ptr = (u32 __iomem *)(((u8 __iomem *)ehci->regs) + USBMODE);
        tmp = ehci_readl(ehci, reg_ptr);
-       tmp |= 0x3;
+       tmp |= USBMODE_CM_HC;
+       /* The default byte access to MMR space is LE after
+        * controller reset. Set the required endian mode
+        * for transfer buffers to match the host microprocessor
+        */
+       if (ehci_big_endian_mmio(ehci))
+               tmp |= USBMODE_BE;
        ehci_writel(ehci, tmp, reg_ptr);
 }
 

-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
[email protected]
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.