[PATCH v2 2/4] dm: board: complete the initialization of the muxes in initr_dm()

Simon Glass sjg at chromium.org
Tue Dec 24 16:58:47 CET 2019


Hi Jean-Jacques,

On Tue, 5 Nov 2019 at 04:50, Jean-Jacques Hiblot <jjhiblot at ti.com> wrote:
>
> This will probe the multiplexer devices that have a "u-boot,mux-autoprobe"
> property. As a consequence they will be put in their idle state.
>
> Signed-off-by: Jean-Jacques Hiblot <jjhiblot at ti.com>
>
> ---
>
> Changes in v2:
> - insert the mux initialization in init_sequence_r[], just before the
> console is initialized as its serial port may be muxed
> - moved the definition of dm_mux_init() in this commit
>
>  common/board_r.c         | 16 ++++++++++++++++
>  drivers/mux/mux-uclass.c | 22 ++++++++++++++++++++++
>  include/mux.h            |  2 ++
>  3 files changed, 40 insertions(+)
>
> diff --git a/common/board_r.c b/common/board_r.c
> index c1ecb06b74..3d410f3504 100644
> --- a/common/board_r.c
> +++ b/common/board_r.c
> @@ -32,6 +32,7 @@
>  #include <miiphy.h>
>  #endif
>  #include <mmc.h>
> +#include <mux.h>
>  #include <nand.h>
>  #include <of_live.h>
>  #include <onenand_uboot.h>
> @@ -178,6 +179,18 @@ static int initr_serial(void)
>         return 0;
>  }
>
> +#if CONFIG_MULTIPLEXER
> +static int initr_mux(void)
> +{
> +       /*
> +        * Initialize the multiplexer controls to their default state.
> +        * This must be done early as other drivers may unknowingly rely on it.
> +        */
> +       dm_mux_init();

Needs to get an error code and at least log_debug() it here, even if
it continues.

> +       return 0;
> +}

Can you rebase on x86/next? It has a initr_dm_devices() function which
you can add this to.

> +#endif
> +
>  #if defined(CONFIG_PPC) || defined(CONFIG_M68K) || defined(CONFIG_MIPS)
>  static int initr_trap(void)
>  {
> @@ -691,6 +704,9 @@ static init_fnc_t init_sequence_r[] = {
>  #endif
>  #ifdef CONFIG_EFI_LOADER
>         efi_memory_init,
> +#endif
> +#if CONFIG_MULTIPLEXER
> +       initr_mux,
>  #endif
>         stdio_init_tables,
>         initr_serial,
> diff --git a/drivers/mux/mux-uclass.c b/drivers/mux/mux-uclass.c
> index 6aaf4dc964..71392e9e50 100644
> --- a/drivers/mux/mux-uclass.c
> +++ b/drivers/mux/mux-uclass.c
> @@ -262,6 +262,28 @@ int mux_uclass_post_probe(struct udevice *dev)
>         return 0;
>  }
>
> +void dm_mux_init(void)
> +{
> +       struct uclass *uc;
> +       struct udevice *dev;
> +       int ret;
> +
> +       ret = uclass_get(UCLASS_MUX, &uc);
> +       if (ret < 0) {
> +               debug("unable to get MUX uclass\n");
> +               return;

return ret

This should be a fatal error.

> +       }
> +       uclass_foreach_dev(dev, uc) {
> +               if (dev_read_bool(dev, "u-boot,mux-autoprobe")) {
> +                       ret = device_probe(dev);
> +                       if (ret)
> +                               debug("unable to probe device %s\n", dev->name);

Doesn't this need to be reported to the caller?

> +               } else {
> +                       printf("not found for dev %s\n", dev->name);

What does this mean? If autoprobe is off we can't find the device? I
suggest changing the message, and debug() as Vignesh suggests.

> +               }
> +       }
> +}
> +
>  UCLASS_DRIVER(mux) = {
>         .id             = UCLASS_MUX,
>         .name           = "mux",
> diff --git a/include/mux.h b/include/mux.h
> index 060f71a47c..2467723951 100644
> --- a/include/mux.h
> +++ b/include/mux.h
> @@ -75,6 +75,8 @@ void mux_control_put(struct mux_control *mux);
>
>  struct mux_control *devm_mux_control_get(struct udevice *dev,
>                                          const char *mux_name);
> +void dm_mux_init(void);

Function comments again.

> +
>  #else
>  unsigned int mux_control_states(struct mux_control *mux)
>  {
> --
> 2.17.1
>

Regards,
Simon


More information about the U-Boot mailing list