[PATCH v2] drivers: serial: probe all uart devices

Simon Glass sjg at chromium.org
Wed Sep 30 18:44:34 CEST 2020


Hi Vabhav,

On Tue, 29 Sep 2020 at 11:33, Vabhav Sharma <vabhav.sharma at oss.nxp.com> wrote:
>
> From: Vabhav Sharma <vabhav.sharma at nxp.com>
>
> U-Boot DM model probe only single device at a time
> which is enabled and configured using device tree
> or platform data method.
>
> PL011 UART IP is SBSA compliant and firmware does the
> serial port set-up, initialization and let the kernel use
> UART port for sending and receiving characters.
>
> Normally software talk to one serial port time but some
> LayerScape platform require all the UART devices enabled
> in Linux for various use case.
>
> Adding support to probe all enabled serial devices like SBSA
> compliant PL011 UART ports probe and initialization by firmware.
>
> Signed-off-by: Vabhav Sharma <vabhav.sharma at nxp.com>
> ---
> v2:
>    Incorporated Stefan review comment, Update #ifdef with macro
>    if (IS_ENABLED)..
> ---
> ---
>  drivers/serial/Kconfig         | 17 +++++++++++++++++
>  drivers/serial/serial-uclass.c | 30 ++++++++++++++++++++++++++++++
>  2 files changed, 47 insertions(+)
>
> diff --git a/drivers/serial/Kconfig b/drivers/serial/Kconfig
> index e344677..b2e30f1 100644
> --- a/drivers/serial/Kconfig
> +++ b/drivers/serial/Kconfig
> @@ -134,6 +134,23 @@ config SERIAL_SEARCH_ALL
>
>           If unsure, say N.
>
> +config SERIAL_PROBE_ALL
> +       bool "Probe all available serial devices"
> +       depends on DM_SERIAL
> +       default n

not needed

> +       help
> +         The serial subsystem only probe for single serial device,
> +         but does not probe for other remaining serial devices.
> +         With this option set,we make probing and searching for
> +         all available devices optional.
> +         Normally, U-Boot talk to one serial port at a time but SBSA
> +         compliant UART devices like PL011 require initialization
> +         by firmware and let the kernel use serial port for sending
> +         and receiving the characters.
> +
> +         If probing is not required for all remaining available
> +         devices other than default current console device, say N.
> +
>  config SPL_DM_SERIAL
>         bool "Enable Driver Model for serial drivers in SPL"
>         depends on DM_SERIAL && SPL_DM
> diff --git a/drivers/serial/serial-uclass.c b/drivers/serial/serial-uclass.c
> index 0027625..d303a66 100644
> --- a/drivers/serial/serial-uclass.c
> +++ b/drivers/serial/serial-uclass.c
> @@ -86,6 +86,11 @@ static void serial_find_console_or_panic(void)
>                 uclass_first_device(UCLASS_SERIAL, &dev);
>                 if (dev) {
>                         gd->cur_serial_dev = dev;
> +                       if (IS_ENABLED(CONFIG_SERIAL_PROBE_ALL)) {
> +                               /* Scanning uclass to probe all devices */
> +                               for (; dev; uclass_next_device(&dev))
> +                                       ;

Please put this into a function in drivers/core/uclass.c since this is
a useful function. E.g. uclass_probe_all(enum uclass_id)

Also you could use device_foreach_child_probe().

Can you put this in the only caller of serial_find_console_or_panic() instead?

Do you ever have a situation where there is no serial console in
U-Boot but you still want to probe everything? If so, a better place
might be at the end of dm_init_and_scan().

Finally, do you want to do this in SPL as well, or is it enough to
just do it in U-Boot proper? If the latter you could use

if (CONFIG_IS_ENABLED(SERIAL_PROBE_ALL)) {
// do it
}
Regards,
Simon,


More information about the U-Boot mailing list