* [PATCH v2] dm: usb: add hook for low level usb init
@ 2021-08-18 13:13 Simon-Pierre Allaire
0 siblings, 0 replies; only message in thread
From: Simon-Pierre Allaire @ 2021-08-18 13:13 UTC (permalink / raw)
To: u-boot; +Cc: Simon-Pierre Allaire, Marek Vasut, Simon Glass
This patch adds a hook to enable us to call a custom function when
booting from USB
Signed-off-by: Simon-Pierre Allaire <spallaire@distech-controls.com>
---
Changes for v2:
- Added description of the patch
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
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2021-08-18 15:25 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-18 13:13 [PATCH v2] dm: usb: add hook for low level usb init Simon-Pierre Allaire
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.