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

Simon Glass sjg at chromium.org
Sat Jul 17 00:12:09 CEST 2021


Hi Simon-Pierre,

On Fri, 16 Jul 2021 at 10:35, Simon-Pierre Allaire
<sp.allaire93 at gmail.com> wrote:
>
> Signed-off-by: Simon-Pierre Allaire <spallaire at distech-controls.com>
> ---
>

commit message? Needs motivation and what it does.

But I think we're going to have to figure out a driver model way of doing this.

>  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
>

Regards,
Simon


More information about the U-Boot mailing list