[U-Boot] [PATCH 2/2] tegra20: Initialize multiple USB controllers at once

Jim Lin jilin at nvidia.com
Thu Aug 9 04:52:39 CEST 2012


Add support for command line "usb reset" or "usb start" to initialize
, "usb stop" to stop multiple USB controllers at once.
Other commands like "usb tree" also support multiple controllers.

Example to add definitions in header file like include/configs/seaboard.h are:
define CONFIG_USB_MULTI
define CONFIG_USB_MAX_CONTROLLER_COUNT 3

Signed-off-by: Jim Lin <jilin at nvidia.com>
---
 arch/arm/cpu/armv7/tegra20/usb.c        |   15 +++++++++++++++
 arch/arm/include/asm/arch-tegra20/usb.h |    4 ++++
 drivers/usb/host/ehci-tegra.c           |   15 +++++++++++++++
 3 files changed, 34 insertions(+), 0 deletions(-)

diff --git a/arch/arm/cpu/armv7/tegra20/usb.c b/arch/arm/cpu/armv7/tegra20/usb.c
index 178bb13..141d608 100644
--- a/arch/arm/cpu/armv7/tegra20/usb.c
+++ b/arch/arm/cpu/armv7/tegra20/usb.c
@@ -352,7 +352,11 @@ int tegrausb_start_port(unsigned portnum, u32 *hccr, u32 *hcor)
 
 	if (portnum >= port_count)
 		return -1;
+#ifdef CONFIG_USB_MULTI
+	tegrausb_stop_port(portnum);
+#else
 	tegrausb_stop_port();
+#endif
 	set_host_mode(&port[portnum]);
 
 	usbctlr = port[portnum].reg;
@@ -362,6 +366,16 @@ int tegrausb_start_port(unsigned portnum, u32 *hccr, u32 *hcor)
 	return 0;
 }
 
+#ifdef CONFIG_USB_MULTI
+int tegrausb_stop_port(unsigned portnum)
+{
+	struct usb_ctlr *usbctlr;
+
+	if (portnum >= port_count)
+		return -1;
+
+	usbctlr = port[portnum].reg;
+#else
 int tegrausb_stop_port(void)
 {
 	struct usb_ctlr *usbctlr;
@@ -370,6 +384,7 @@ int tegrausb_stop_port(void)
 		return -1;
 
 	usbctlr = port[port_current].reg;
+#endif
 
 	/* Stop controller */
 	writel(0, &usbctlr->usb_cmd);
diff --git a/arch/arm/include/asm/arch-tegra20/usb.h b/arch/arm/include/asm/arch-tegra20/usb.h
index 638033b..e7bc167 100644
--- a/arch/arm/include/asm/arch-tegra20/usb.h
+++ b/arch/arm/include/asm/arch-tegra20/usb.h
@@ -247,6 +247,10 @@ int tegrausb_start_port(unsigned portnum, u32 *hccr, u32 *hcor);
  *
  * @return 0 if ok, -1 if no port was active
  */
+#ifdef CONFIG_USB_MULTI
+int tegrausb_stop_port(unsigned portnum);
+#else
 int tegrausb_stop_port(void);
+#endif
 
 #endif	/* _TEGRA_USB_H_ */
diff --git a/drivers/usb/host/ehci-tegra.c b/drivers/usb/host/ehci-tegra.c
index 4646b29..fa2e1b1 100644
--- a/drivers/usb/host/ehci-tegra.c
+++ b/drivers/usb/host/ehci-tegra.c
@@ -50,6 +50,12 @@ void ehci_powerup_fixup(uint32_t *status_reg, uint32_t *reg)
  * Create the appropriate control structures to manage
  * a new EHCI host controller.
  */
+#ifdef CONFIG_USB_MULTI
+int ehci_hcd_init(int index, struct ehci_hccr **hccr, struct ehci_hcor **hcor)
+{
+	return tegrausb_start_port(index, hccr, hcor);
+}
+#else
 int ehci_hcd_init(void)
 {
 	u32 our_hccr, our_hcor;
@@ -66,13 +72,22 @@ int ehci_hcd_init(void)
 
 	return 0;
 }
+#endif
 
 /*
  * Destroy the appropriate control structures corresponding
  * the the EHCI host controller.
  */
+#ifdef CONFIG_USB_MULTI
+int ehci_hcd_stop(int index)
+{
+	tegrausb_stop_port(index);
+	return 0;
+}
+#else
 int ehci_hcd_stop(void)
 {
 	tegrausb_stop_port();
 	return 0;
 }
+#endif
-- 
1.7.3

--
nvpublic


More information about the U-Boot mailing list