[U-Boot] [PATCH v5 12/14] usb: extend generic OHCI with clock, reset and phy

Simon Glass sjg at chromium.org
Sun May 14 09:13:28 UTC 2017


On 10 May 2017 at 10:09,  <patrice.chotard at st.com> wrote:
> From: Patrice Chotard <patrice.chotard at st.com>
>
> Make this driver more generic as echi-generic
>
> Signed-off-by: Patrice Chotard <patrice.chotard at st.com>
> ---
>
> v5:   _ add clock, reset and generic phy support
>
>  drivers/usb/host/ohci-generic.c | 48 +++++++++++++++++++++++++++++++++++------
>  1 file changed, 42 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/usb/host/ohci-generic.c b/drivers/usb/host/ohci-generic.c
> index f3307f4..33e8095 100644
> --- a/drivers/usb/host/ohci-generic.c
> +++ b/drivers/usb/host/ohci-generic.c
> @@ -5,7 +5,12 @@
>   */
>
>  #include <common.h>
> +#include <clk.h>
>  #include <dm.h>
> +#include <fdtdec.h>
> +#include <generic-phy.h>
> +#include <reset.h>
> +
>  #include "ohci.h"
>
>  #if !defined(CONFIG_USB_OHCI_NEW)
> @@ -19,13 +24,44 @@ struct generic_ohci {
>  static int ohci_usb_probe(struct udevice *dev)
>  {
>         struct ohci_regs *regs = (struct ohci_regs *)dev_get_addr(dev);
> +       int i;
>
> -       return ohci_register(dev, regs);
> -}
> +       for (i = 0; ; i++) {
> +               struct clk clk;
> +               int ret;
>
> -static int ohci_usb_remove(struct udevice *dev)
> -{
> -       return ohci_deregister(dev);
> +               ret = clk_get_by_index(dev, i, &clk);
> +               if (ret < 0)
> +                       break;
> +               if (clk_enable(&clk))
> +                       printf("failed to enable clock %d\n", i);
> +               clk_free(&clk);
> +       }

Don't you want to store these clocks in your private data so you can
disable them at the end?

> +
> +       for (i = 0; ; i++) {
> +               struct reset_ctl reset;
> +               int ret;
> +
> +               ret = reset_get_by_index(dev, i, &reset);
> +               if (ret < 0)
> +                       break;
> +               if (reset_deassert(&reset))
> +                       printf("failed to deassert reset %d\n", i);
> +               reset_free(&reset);
> +       }
> +
> +       for (i = 0; ; i++) {
> +               struct phy usb_phy;
> +               int ret;
> +
> +               ret = generic_phy_get_by_index(dev, i, &usb_phy);
> +               if (ret < 0)
> +                       break;
> +               if (generic_phy_init(&usb_phy))
> +                       printf("failed to init usb phy %d\n", i);
> +       }
> +
> +       return ohci_register(dev, regs);
>  }
>
>  static const struct udevice_id ohci_usb_ids[] = {
> @@ -38,7 +74,7 @@ U_BOOT_DRIVER(ohci_generic) = {
>         .id     = UCLASS_USB,
>         .of_match = ohci_usb_ids,
>         .probe = ohci_usb_probe,
> -       .remove = ohci_usb_remove,
> +       .remove = ohci_deregister,
>         .ops    = &ohci_usb_ops,
>         .priv_auto_alloc_size = sizeof(struct generic_ohci),
>         .flags  = DM_FLAG_ALLOC_PRIV_DMA,
> --
> 1.9.1
>

Regards,
Simon


More information about the U-Boot mailing list