dm: usb: add hook for low level usb init
PATCH v2 1/1 dm: usb: add hook for low level usb init
This patch adds a hook to enable us to call a custom function when booting from USB
Signed-off-by Simon-Pierre Allaire <[email protected]>
---
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(-)
drivers/usb/host/usb-uclass.c +6 -1
@@ -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 /*
drivers/usb/musb-new/musb_uboot.c +13 -0
@@ -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)
Signature · 1 line
2.30.2