[U-Boot] [PATCH v4 02/10] usb: ehci-marvell: add support for second USB controller

Sascha Silbe t-uboot at infra-silbe.de
Sun May 26 20:36:55 CEST 2013


From: Sascha Silbe <sascha-pgp at silbe.org>

Marvell 88AP510 (Armada 510, dove) has two separate USB
controllers. Use the index parameter that already gets passed in to
calculate the base address of the controller.

Signed-off-by: Sascha Silbe <t-uboot at infra-silbe.de>
---
 v3->v4: new patch

 drivers/usb/host/ehci-marvell.c | 35 ++++++++++++++++++++++++-----------
 1 file changed, 24 insertions(+), 11 deletions(-)

diff --git a/drivers/usb/host/ehci-marvell.c b/drivers/usb/host/ehci-marvell.c
index 2b73e4a..d2cf026 100644
--- a/drivers/usb/host/ehci-marvell.c
+++ b/drivers/usb/host/ehci-marvell.c
@@ -28,7 +28,9 @@
 #include "ehci.h"
 #include <asm/arch/cpu.h>
 
-#if defined(CONFIG_KIRKWOOD)
+#if defined(CONFIG_DOVE)
+#include <asm/arch/dove.h>
+#elif defined(CONFIG_KIRKWOOD)
 #include <asm/arch/kirkwood.h>
 #elif defined(CONFIG_ORION5X)
 #include <asm/arch/orion5x.h>
@@ -36,8 +38,8 @@
 
 DECLARE_GLOBAL_DATA_PTR;
 
-#define rdl(off)	readl(MVUSB0_BASE + (off))
-#define wrl(off, val)	writel((val), MVUSB0_BASE + (off))
+#define rdl(base, off)		readl((base) + (off))
+#define wrl(base, off, val)	writel((val), (base) + (off))
 
 #define USB_WINDOW_CTRL(i)	(0x320 + ((i) << 4))
 #define USB_WINDOW_BASE(i)	(0x324 + ((i) << 4))
@@ -46,10 +48,15 @@ DECLARE_GLOBAL_DATA_PTR;
 /*
  * USB 2.0 Bridge Address Decoding registers setup
  */
-static void usb_brg_adrdec_setup(void)
+static void usb_brg_adrdec_setup(int index)
 {
 	int i;
 	u32 size, base, attrib;
+#ifdef MVUSB1_BASE
+	u32 usb_base = (index == 0) ? MVUSB0_BASE : MVUSB1_BASE;
+#else
+	u32 usb_base = MVUSB0_BASE;
+#endif
 
 	for (i = 0; i < CONFIG_NR_DRAM_BANKS; i++) {
 
@@ -76,13 +83,13 @@ static void usb_brg_adrdec_setup(void)
 		size = gd->bd->bi_dram[i].size;
 		base = gd->bd->bi_dram[i].start;
 		if ((size) && (attrib))
-			wrl(USB_WINDOW_CTRL(i),
-				MVCPU_WIN_CTRL_DATA(size, USB_TARGET_DRAM,
-					attrib, MVCPU_WIN_ENABLE));
+			wrl(usb_base, USB_WINDOW_CTRL(i),
+			    MVCPU_WIN_CTRL_DATA(size, USB_TARGET_DRAM,
+						attrib, MVCPU_WIN_ENABLE));
 		else
-			wrl(USB_WINDOW_CTRL(i), MVCPU_WIN_DISABLE);
+			wrl(usb_base, USB_WINDOW_CTRL(i), MVCPU_WIN_DISABLE);
 
-		wrl(USB_WINDOW_BASE(i), base);
+		wrl(usb_base, USB_WINDOW_BASE(i), base);
 	}
 }
 
@@ -92,9 +99,15 @@ static void usb_brg_adrdec_setup(void)
  */
 int ehci_hcd_init(int index, struct ehci_hccr **hccr, struct ehci_hcor **hcor)
 {
-	usb_brg_adrdec_setup();
+#ifdef MVUSB1_BASE
+	u32 usb_base = (index == 0) ? MVUSB0_BASE : MVUSB1_BASE;
+#else
+	u32 usb_base = MVUSB0_BASE;
+#endif
 
-	*hccr = (struct ehci_hccr *)(MVUSB0_BASE + 0x100);
+	usb_brg_adrdec_setup(index);
+
+	*hccr = (struct ehci_hccr *)(usb_base + 0x100);
 	*hcor = (struct ehci_hcor *)((uint32_t) *hccr
 			+ HC_LENGTH(ehci_readl(&(*hccr)->cr_capbase)));
 
-- 
1.8.2.1



More information about the U-Boot mailing list