Skip to contentSkip to conversation

USB: EHCI: Initialize multiple USB controllers at once

PATCH New Jim Lin 2 participants 2 messages Aug 10, 2012

Subsystems (2)
lore
Share & tools
lore

Jim Lin

author
#0 lore raw

PATCH v2 1/1 USB: EHCI: Initialize multiple USB controllers at once

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

New added definitions in header file are:
CONFIG_USB_MULTI
CONFIG_USB_MAX_CONTROLLER_COUNT

---
Changes in v2:
- Renaming from CONFIG_USB_INIT_MULTI to CONFIG_USB_MULTI
- Define CONFIG_USB_MAX_CONTROLLER_COUNT as 1 if not defined
- Remove volatile from structure ehci_ctrl of ehci-hcd.c for a checkpatch.pl warning

 common/cmd_usb.c            |   10 +++
 common/usb.c                |   98 +++++++++++++++++++++++++-
 common/usb_hub.c            |    4 +
 drivers/usb/host/ehci-hcd.c |  167 +++++++++++++++++++++++++++++++-----------
 drivers/usb/host/ehci.h     |    5 ++
 include/usb.h               |   12 +++
 6 files changed, 251 insertions(+), 45 deletions(-)
common/cmd_usb.c +10 -0
index a8e3ae5..8d3093b 100644
@@ -554,7 +554,17 @@ int do_usb(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 	}
 	if (strncmp(argv[1], "tree", 4) == 0) {
 		printf("\nDevice Tree:\n");
+#ifdef CONFIG_USB_MULTI
+		for (i = 0; i < USB_MAX_DEVICE; i++) {
+			dev = usb_get_dev_index(i);
+			if (dev == NULL)
+				break;
+			if (dev->parent == NULL)
+				usb_show_tree(dev);
+		}
+#else
 		usb_show_tree(usb_get_dev_index(0));
+#endif
 		return 0;
 	}
 	if (strncmp(argv[1], "inf", 3) == 0) {
common/usb.c +97 -1

137 lines not on this page · raw message

common/usb_hub.c +4 -0
index f35ad95..8f2e3e3 100644
@@ -243,7 +243,11 @@ void usb_hub_port_connect_change(struct usb_device *dev, int port)
 	mdelay(200);
 
 	/* Allocate a new device struct for it */
+#ifdef CONFIG_USB_MULTI
+	usb = usb_alloc_new_device(dev->controller);
+#else
 	usb = usb_alloc_new_device();
+#endif
 
 	if (portstatus & USB_PORT_STAT_HIGH_SPEED)
 		usb->speed = USB_SPEED_HIGH;
drivers/usb/host/ehci-hcd.c +123 -44

333 lines not on this page · raw message

drivers/usb/host/ehci.h +5 -0
index cc00ce4..1cc5c6e 100644
@@ -201,7 +201,12 @@ struct QH {
 };
 
 /* Low level init functions */
+#ifdef CONFIG_USB_MULTI
+int ehci_hcd_init(int index, struct ehci_hccr **hccr, struct ehci_hcor **hcor);
+int ehci_hcd_stop(int index);
+#else
 int ehci_hcd_init(void);
 int ehci_hcd_stop(void);
+#endif
 
 #endif /* USB_EHCI_H */
include/usb.h +12 -0
index ba3d169..628cfd5 100644
@@ -140,6 +140,9 @@ struct usb_device {
 	int portnr;
 	struct usb_device *parent;
 	struct usb_device *children[USB_MAXCHILDREN];
+#ifdef CONFIG_USB_MULTI
+	void *controller;               /* hardware controller private data */
+#endif
 };
 
 /**********************************************************************
@@ -153,8 +156,13 @@ struct usb_device {
 	defined(CONFIG_USB_OMAP3) || defined(CONFIG_USB_DA8XX) || \
 	defined(CONFIG_USB_BLACKFIN) || defined(CONFIG_USB_AM35X)
 
+#ifdef CONFIG_USB_MULTI
+void *usb_lowlevel_init(int index);
+int usb_lowlevel_stop(int index);
+#else
 int usb_lowlevel_init(void);
 int usb_lowlevel_stop(void);
+#endif
 int submit_bulk_msg(struct usb_device *dev, unsigned long pipe,
 			void *buffer, int transfer_len);
 int submit_control_msg(struct usb_device *dev, unsigned long pipe, void *buffer,
@@ -382,7 +390,11 @@ void usb_hub_reset(void);
 int hub_port_reset(struct usb_device *dev, int port,
 			  unsigned short *portstat);
 
+#ifdef CONFIG_USB_MULTI
+struct usb_device *usb_alloc_new_device(void *controller);
+#else
 struct usb_device *usb_alloc_new_device(void);
+#endif
 int usb_new_device(struct usb_device *dev);
 
 #endif /*_USB_H_ */
Signature · 9 lines
1.7.3


-----------------------------------------------------------------------------------
This email message is for the sole use of the intended recipient(s) and may contain
confidential information.  Any unauthorized review, use, disclosure or distribution
is prohibited.  If you are not the intended recipient, please contact the sender by
reply email and destroy all copies of the original message.
-----------------------------------------------------------------------------------
#1 lore raw

PATCH v2 1/1 USB: EHCI: Initialize multiple USB controllers at once

Quoted 3 lines · Jim Lin

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

I assume these were reposted because you rebased on the latest u-boot-tegra/master branch. It's usual to includes details of why you're reposting.

I applied these two patches, without changing the Seaboard config file, and built. I got the following warnings:

ehci-hcd.c: In function 'ehci_submit_async':
ehci-hcd.c:250:6: warning: assignment from incompatible pointer type ehci-hcd.c: In function 'usb_lowlevel_multi_init':
ehci-hcd.c:800:20: warning: assignment discards qualifiers from pointer target type

I tested the patches in this case and found no regressions on a regular Seaboard.

I get slightly different warnings if I do enable the feature in the Seaboard config file:

ehci-hcd.c: In function 'ehci_submit_async':
ehci-hcd.c:250:6: warning: assignment from incompatible pointer type ehci-hcd.c: In function 'usb_lowlevel_multi_init':
ehci-hcd.c:800:20: warning: assignment discards qualifiers from pointer target type
ehci-tegra.c: In function 'ehci_hcd_init':
ehci-tegra.c:56:2: warning: passing argument 2 of 'tegrausb_start_port' from incompatible pointer type /home/swarren/shared/git_wa/u-boot/include/asm/arch/usb.h:243:5: note:
expected 'u32 *' but argument is of type 'struct ehci_hccr **' ehci-tegra.c:56:2: warning: passing argument 3 of 'tegrausb_start_port' from incompatible pointer type /home/swarren/shared/git_wa/u-boot/include/asm/arch/usb.h:243:5: note:
expected 'u32 *' but argument is of type 'struct ehci_hcor **'

I tested the patches on a regular Seaboard, and found that both USB ports now work (great!).

However, this patch breaks the "enterrcm" command if "usb start" has been run, I assume since the VBUS GPIO is asserted to USB port 1. Can we add some hook into that command to shut down the USB1 VBUS GPIO? I can live with this patch being applied before that's fixed though.

I also tested Springbank, and found that this also enables the USB port there, but strangely "enterrcm" following "usb start" does still seem to work on that board!

So overall, once the warnings are fixed, I'm OK with these patches, assuming some followup work on "enterrcm" will happen.