[PATCH] dm: usb: add hook for low level usb init

Simon-Pierre Allaire sp.allaire93 at gmail.com
Fri Jul 16 18:35:18 CEST 2021


Signed-off-by: Simon-Pierre Allaire <spallaire at distech-controls.com>
---

 drivers/usb/host/usb-uclass.c     |  7 ++++++-
 drivers/usb/musb-new/musb_uboot.c | 13 +++++++++++++
 2 files changed, 19 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/host/usb-uclass.c b/drivers/usb/host/usb-uclass.c
index 611ea97a72..e1ea21970c 100644
--- a/drivers/usb/host/usb-uclass.c
+++ b/drivers/usb/host/usb-uclass.c
@@ -243,6 +243,7 @@ int usb_init(void)
 	struct udevice *bus;
 	struct uclass *uc;
 	int count = 0;
+	void *ctrl;
 	int ret;
 
 	asynch_allowed = 1;
@@ -256,7 +257,11 @@ int usb_init(void)
 	uclass_foreach_dev(bus, uc) {
 		/* init low_level USB */
 		printf("USB%d:   ", count);
-		count++;
+		ret = usb_lowlevel_init(count, USB_INIT_HOST, &ctrl);
+		if (ret == -ENODEV)	/* No such device. */
+			puts("Port not available.\n");
+		else
+			count++;
 
 #ifdef CONFIG_SANDBOX
 		/*
diff --git a/drivers/usb/musb-new/musb_uboot.c b/drivers/usb/musb-new/musb_uboot.c
index 9c8cc6e584..5540640d6d 100644
--- a/drivers/usb/musb-new/musb_uboot.c
+++ b/drivers/usb/musb-new/musb_uboot.c
@@ -303,6 +303,19 @@ int usb_lowlevel_init(int index, enum usb_init_type init, void **controller)
 #endif /* !CONFIG_IS_ENABLED(DM_USB) */
 
 #if CONFIG_IS_ENABLED(DM_USB)
+
+int usb_lowlevel_init(int index, enum usb_init_type init, void **controller)
+{
+	int ret;
+
+	ret = board_usb_init(index, init);
+	if (ret != 0) {
+		puts("Failed to initialize board for USB\n");
+		return ret;
+	}
+	return 0;
+}
+
 static int musb_submit_control_msg(struct udevice *dev, struct usb_device *udev,
 				   unsigned long pipe, void *buffer, int length,
 				   struct devrequest *setup)
-- 
2.30.2



More information about the U-Boot mailing list