[U-Boot] [PATCH] arm: mvebu: add multiple usb-hostcontroller support for AXP

Anton Schubert anton.schubert at gmx.de
Thu Jul 23 14:25:13 CEST 2015


This patch adds support for multiple hostcontrollers to the ehci-marvell driver
and enables all 3 usb-hcs on the db-mv784mp-gp board.

It depends on the initial Armada XP usb support patch from Stefan.

Signed-off-by: Anton Schubert <anton.schubert at gmx.de>
Cc: Stefan Roese <sr at denx.de>
Cc: Luka Perkov <luka.perkov at sartura.hr>
---
 drivers/usb/host/ehci-marvell.c | 23 ++++++++++++-----------
 include/configs/db-mv784mp-gp.h |  1 +
 2 files changed, 13 insertions(+), 11 deletions(-)

diff --git a/drivers/usb/host/ehci-marvell.c b/drivers/usb/host/ehci-marvell.c
index 826e7f7..6548cb2 100644
--- a/drivers/usb/host/ehci-marvell.c
+++ b/drivers/usb/host/ehci-marvell.c
@@ -22,7 +22,8 @@
 DECLARE_GLOBAL_DATA_PTR;

 #define rdl(off)	readl(MVUSB0_BASE + (off))
-#define wrl(off, val)	writel((val), MVUSB0_BASE + (off))
+#define wrl(port, off, val)	writel((val), MVUSB0_BASE + (off) + \
+	((port) << 12))

 #define USB_WINDOW_CTRL(i)	(0x320 + ((i) << 4))
 #define USB_WINDOW_BASE(i)	(0x324 + ((i) << 4))
@@ -47,7 +48,7 @@ DECLARE_GLOBAL_DATA_PTR;
  * to the common mvebu archticture including the mbus setup, this
  * will be the only function needed to configure the access windows
  */
-static void usb_brg_adrdec_setup(void)
+static void usb_brg_adrdec_setup(int index)
 {
 	const struct mbus_dram_target_info *dram;
 	int i;
@@ -55,24 +56,24 @@ static void usb_brg_adrdec_setup(void)
 	dram = mvebu_mbus_dram_info();

 	for (i = 0; i < 4; i++) {
-		wrl(USB_WINDOW_CTRL(i), 0);
-		wrl(USB_WINDOW_BASE(i), 0);
+		wrl(index, USB_WINDOW_CTRL(i), 0);
+		wrl(index, USB_WINDOW_BASE(i), 0);
 	}

 	for (i = 0; i < dram->num_cs; i++) {
 		const struct mbus_dram_window *cs = dram->cs + i;

 		/* Write size, attributes and target id to control register */
-		wrl(USB_WINDOW_CTRL(i),
+		wrl(index, USB_WINDOW_CTRL(i),
 		    ((cs->size - 1) & 0xffff0000) | (cs->mbus_attr << 8) |
 		    (dram->mbus_dram_target_id << 4) | 1);

 		/* Write base address to base register */
-		wrl(USB_WINDOW_BASE(i), cs->base);
+		wrl(index, USB_WINDOW_BASE(i), cs->base);
 	}
 }
 #else
-static void usb_brg_adrdec_setup(void)
+static void usb_brg_adrdec_setup(int index)
 {
 	int i;
 	u32 size, base, attrib;
@@ -102,13 +103,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),
+			wrl(index, 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(index, USB_WINDOW_CTRL(i), MVCPU_WIN_DISABLE);

-		wrl(USB_WINDOW_BASE(i), base);
+		wrl(index, USB_WINDOW_BASE(i), base);
 	}
 }
 #endif
@@ -120,7 +121,7 @@ static void usb_brg_adrdec_setup(void)
 int ehci_hcd_init(int index, enum usb_init_type init,
 		struct ehci_hccr **hccr, struct ehci_hcor **hcor)
 {
-	usb_brg_adrdec_setup();
+	usb_brg_adrdec_setup(index);

 	*hccr = (struct ehci_hccr *)(MVUSB0_BASE + 0x100);
 	*hcor = (struct ehci_hcor *)((uint32_t) *hccr
diff --git a/include/configs/db-mv784mp-gp.h b/include/configs/db-mv784mp-gp.h
index 1314fd3..21581e2 100644
--- a/include/configs/db-mv784mp-gp.h
+++ b/include/configs/db-mv784mp-gp.h
@@ -47,6 +47,7 @@
 #define CONFIG_USB_STORAGE
 #define CONFIG_USB_EHCI_MARVELL
 #define CONFIG_EHCI_IS_TDI
+#define CONFIG_USB_MAX_CONTROLLER_COUNT 3

 /* SPI NOR flash default params, used by sf commands */
 #define CONFIG_SF_DEFAULT_SPEED		1000000
--
2.3.6


More information about the U-Boot mailing list