RE: [PATCH v5 0/2] dm: core: drivers: add function uclass_probe_all()

2020-12-16 Thread Vabhav Sharma (OSS)
Dear Sean Anderson,
I have incorporated all your review comments and request your review/ack to 
merge the changes

Regards,
Vabhav

> -Original Message-
> From: Vabhav Sharma 
> Sent: Wednesday, December 9, 2020 10:42 AM
> To: s...@chromium.org; s...@denx.de; sean...@gmail.com
> Cc: u-boot@lists.denx.de; Varun Sethi ;
> andre.przyw...@arm.com; Vabhav Sharma 
> Subject: [PATCH v5 0/2] dm: core: drivers: add function uclass_probe_all()
> 
> From: Vabhav Sharma 
> 
> - Add common method to probe devices belonging to same uclass
> - Add config in serial uclass to support optional inclusion of 
> uclass_probe_all
> - Enable support for available serial devices probe
> 
> Changes for v5:
> Incorporated review comments from Sean Anderson
>   - Added error check
>   - Replaced for() loop with while() loop
>   - Updated macro description
>   - Modified function description
> 
> Changes for v4:
> Incorporated review comments from Simon
>   - Removed if (dev)..  conditional check in function uclass_probe_all()
> 
> Changes for v3:
>   Incorporated Simon and Stephan review comment
>   - Define generic function uclass_probe_all(enum uclass_id)
> in drivers/core/uclass.c
>   - Added the function in caller of serial_find_console_or_panic()
>   - Removed repeated sequence with generic function call uclass_probe_all()
> 
> Changes for v2:
>   Incorporated Stefan review comment,Update #ifdef with macro if
> (IS_ENABLED).
> 
> Vabhav Sharma (2):
>   dm: core: add function uclass_probe_all() to probe all devices
>   drivers: serial: probe all uart devices
> 
>  drivers/core/uclass.c  | 19 +++
>  drivers/serial/Kconfig | 16 
>  drivers/serial/serial-uclass.c |  9 +
>  include/dm/uclass.h| 11 +++
>  4 files changed, 55 insertions(+)
> 
> --
> 2.7.4



[PATCH v5 2/2] drivers: serial: probe all uart devices

2020-12-08 Thread Vabhav Sharma
From: Vabhav Sharma 

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 
Reviewed-by: Stefan Roese 
Reviewed-by: Simon Glass 
--
v5:
  Incorporated review comments from Sean Anderson
  - Modified the macro description
  - Added error check

v3:
  Incorporated Simon and Stephan review comment
  - Define generic function uclass_probe_all(enum uclass_id)
in drivers/core/uclass.c
  - Added the function in caller of serial_find_console_or_panic()
  - Removed repeated sequence with generic function call uclass_probe_all()
  - Dependent on other patch [PATCH] dm: core: add function uclass_probe_all()
to probe all devices

v2:
  Incorporated Stefan review comment, Update #ifdef with macro
  if (IS_ENABLED)..
---
 drivers/serial/Kconfig | 16 
 drivers/serial/serial-uclass.c |  9 +
 2 files changed, 25 insertions(+)

diff --git a/drivers/serial/Kconfig b/drivers/serial/Kconfig
index b4805a2..1294943 100644
--- a/drivers/serial/Kconfig
+++ b/drivers/serial/Kconfig
@@ -134,6 +134,22 @@ config SERIAL_SEARCH_ALL
 
  If unsure, say N.
 
+config SERIAL_PROBE_ALL
+   bool "Probe all available serial devices"
+   depends on DM_SERIAL
+   default n
+   help
+ The serial subsystem only probes for a 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 talks to one serial port at a time, but SBSA
+ compliant UART devices like PL011 require initialization
+ by firmware and to let the kernel use serial port for sending
+ and receiving the characters.
+
+ If unsure, 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 f3c25d4..48e0080 100644
--- a/drivers/serial/serial-uclass.c
+++ b/drivers/serial/serial-uclass.c
@@ -172,6 +172,15 @@ int serial_init(void)
 /* Called after relocation */
 int serial_initialize(void)
 {
+   /* Scanning uclass to probe devices */
+   if (IS_ENABLED(CONFIG_SERIAL_PROBE_ALL)) {
+   int ret;
+
+   ret  = uclass_probe_all(UCLASS_SERIAL);
+   if (ret)
+   return ret;
+   }
+
return serial_init();
 }
 
-- 
2.7.4



[PATCH v5 1/2] dm: core: add function uclass_probe_all() to probe all devices

2020-12-08 Thread Vabhav Sharma
From: Vabhav Sharma 

Support a common method to probe all devices associated with uclass.

This includes data structures and code for finding the first device and
looping for remaining devices associated with uclasses (groups of devices
with the same purpose, e.g. all SERIAL ports will be in the same uclass).

An example is SBSA compliant PL011 UART IP, where firmware does the serial
port initialization and prepare uart device to let the kernel use it for
sending and reveiving the characters.SERIAL uclass will use this function
to initialize PL011 UART ports.

The feature is enabled with CONFIG_DM.

Signed-off-by: Vabhav Sharma 
Reviewed-by: Stefan Roese 
Reviewed-by: Simon Glass 
--
  v5:
  Incorporated review comments of Sean Anderson
  Replace for loop with while loop
  Error check added
  Function description updated

  v4:
  Incorporated review comments of Simon
  Removed if (dev)..  conditional check

  v3:
  Incorporated review comments of Stephan,Simon
  Related discussion https://patchwork.ozlabs.org/project/uboot/patch/1601400
385-11854-1-git-send-email-vabhav.sha...@oss.nxp.com/
---
 drivers/core/uclass.c | 19 +++
 include/dm/uclass.h   | 11 +++
 2 files changed, 30 insertions(+)

diff --git a/drivers/core/uclass.c b/drivers/core/uclass.c
index c3f1b73..27972ef 100644
--- a/drivers/core/uclass.c
+++ b/drivers/core/uclass.c
@@ -792,6 +792,25 @@ int uclass_pre_remove_device(struct udevice *dev)
 }
 #endif
 
+int uclass_probe_all(enum uclass_id id)
+{
+   struct udevice *dev;
+   int ret;
+
+   ret = uclass_first_device(id, );
+   if (ret || !dev)
+   return ret;
+
+   /* Scanning uclass to probe all devices */
+   while (dev) {
+   ret = uclass_next_device();
+   if (ret)
+   return ret;
+   }
+
+   return 0;
+}
+
 UCLASS_DRIVER(nop) = {
.id = UCLASS_NOP,
.name   = "nop",
diff --git a/include/dm/uclass.h b/include/dm/uclass.h
index 7188304..6bd33d4 100644
--- a/include/dm/uclass.h
+++ b/include/dm/uclass.h
@@ -381,6 +381,17 @@ int uclass_first_device_drvdata(enum uclass_id id, ulong 
driver_data,
 int uclass_resolve_seq(struct udevice *dev);
 
 /**
+ * uclass_probe_all() - Probe all devices based on an uclass ID
+ *
+ * This function probes all devices associated with a uclass by
+ * looking for its ID.
+ *
+ * @id: uclass ID to look up
+ * @return 0 if OK, other -ve on error
+ */
+int uclass_probe_all(enum uclass_id id);
+
+/**
  * uclass_id_foreach_dev() - Helper function to iteration through devices
  *
  * This creates a for() loop which works through the available devices in
-- 
2.7.4



[PATCH v5 0/2] dm: core: drivers: add function uclass_probe_all()

2020-12-08 Thread Vabhav Sharma
From: Vabhav Sharma 

- Add common method to probe devices belonging to same uclass 
- Add config in serial uclass to support optional inclusion of uclass_probe_all
- Enable support for available serial devices probe

Changes for v5:
Incorporated review comments from Sean Anderson
  - Added error check
  - Replaced for() loop with while() loop 
  - Updated macro description
  - Modified function description
  
Changes for v4:
Incorporated review comments from Simon  
  - Removed if (dev)..  conditional check in function uclass_probe_all()

Changes for v3:
  Incorporated Simon and Stephan review comment
  - Define generic function uclass_probe_all(enum uclass_id)
in drivers/core/uclass.c
  - Added the function in caller of serial_find_console_or_panic()
  - Removed repeated sequence with generic function call uclass_probe_all()

Changes for v2:
  Incorporated Stefan review comment,Update #ifdef with macro if (IS_ENABLED).

Vabhav Sharma (2):
  dm: core: add function uclass_probe_all() to probe all devices
  drivers: serial: probe all uart devices

 drivers/core/uclass.c  | 19 +++
 drivers/serial/Kconfig | 16 
 drivers/serial/serial-uclass.c |  9 +
 include/dm/uclass.h| 11 +++
 4 files changed, 55 insertions(+)

-- 
2.7.4



RE: [PATCH v4 1/2] dm: core: add function uclass_probe_all() to probe all devices

2020-12-01 Thread Vabhav Sharma (OSS)


> -Original Message-
> From: Sean Anderson 
> Sent: Monday, November 23, 2020 6:54 PM
> To: Vabhav Sharma (OSS) ;
> s...@chromium.org; s...@denx.de
> Cc: u-boot@lists.denx.de; Varun Sethi ;
> andre.przyw...@arm.com
> Subject: Re: [PATCH v4 1/2] dm: core: add function uclass_probe_all() to
> probe all devices
> 
> On 11/23/20 3:06 AM, Vabhav Sharma (OSS) wrote:
> >
> >
> >> -Original Message-
> >> From: Sean Anderson 
> >> Sent: Thursday, November 19, 2020 9:05 AM
> >> To: Vabhav Sharma (OSS) ;
> >> s...@chromium.org; s...@denx.de
> >> Cc: u-boot@lists.denx.de; Varun Sethi ;
> >> andre.przyw...@arm.com; Vabhav Sharma 
> >> Subject: Re: [PATCH v4 1/2] dm: core: add function uclass_probe_all()
> >> to probe all devices
> >>
> >> On 11/17/20 10:00 AM, Vabhav Sharma wrote:
> >>> From: Vabhav Sharma 
> >>>
> >>> Support a common method to probe all devices associated with uclass.
> >>>
> >>> This includes data structures and code for finding the first device
> >>> and looping for remaining devices associated with uclasses (groups
> >>> of devices with the same purpose, e.g. all SERIAL ports will be in
> >>> the same
> >> uclass).
> >>>
> >>> An example is SBSA compliant PL011 UART IP, where firmware does the
> >>> serial port initialization and prepare uart device to let the kernel
> >>> use it for sending and reveiving the characters.SERIAL uclass will
> >>> use this function to initialize PL011 UART ports.
> >>>
> >>> The feature is enabled with CONFIG_DM.
> >>>
> >>> Signed-off-by: Vabhav Sharma 
> >>> Reviewed-by: Stefan Roese 
> >>> Reviewed-by: Simon Glass 
> >>> --
> >>>v4:
> >>>Incorporated review comments of Simon
> >>>Removed if (dev)..  conditional check
> >>>
> >>>v3:
> >>>Incorporated review comments of Stephan,Simon
> >>>Related discussion
> >>> https://patchwork.ozlabs.org/project/uboot/patch/1601400
> >>> 385-11854-1-git-send-email-vabhav.sha...@oss.nxp.com/
> >>> ---
> >>>   drivers/core/uclass.c | 16 
> >>>   include/dm/uclass.h   | 12 
> >>>   2 files changed, 28 insertions(+)
> >>>
> >>> diff --git a/drivers/core/uclass.c b/drivers/core/uclass.c index
> >>> c3f1b73..a1dc8bb 100644
> >>> --- a/drivers/core/uclass.c
> >>> +++ b/drivers/core/uclass.c
> >>> @@ -792,6 +792,22 @@ int uclass_pre_remove_device(struct udevice
> >> *dev)
> >>> }  #endif
> >>>
> >>> +int uclass_probe_all(enum uclass_id id) {
> >>> + struct udevice *dev;
> >>> + int ret;
> >>> +
> >>> + ret = uclass_first_device(id, );
> >>> + if (ret || !dev)
> >>> + return ret;
> >>> +
> >>> + /* Scanning uclass to probe all devices */
> >>> + for (; dev; uclass_next_device())
> >>
> >> You must check the return value of this function.
> > Error check is done for first device before passing the device to
> > uclass_next_device(), I think of other implementation is to combine
> > the first device check and iterating through device list of u-class as for 
> > (ret =
> uclass_first_device(id, ); dev && !ret;  ret = uclass_next_device())
> > ;
> > But iteration is not required if first device is not found and current
> > changes seems to be ok Please share valuable feedback
> 
> 
> If the second (or any device after the first) fails to init, then the error 
> will be
> silently ignored.
I see
> 
> >>
> >> Also, I would suggest using a while loop instead of an empty for loop.
> > Please elaborate, Found for loop best suitable to use here
> 
> In terms of original functionality,
> 
> while (dev)
>   uclass_next_device()
> 
> However, I suggest
> 
> while (dev) {
>   ret = uclass_next_device()
>   if (ret)
>   return ret;
> }
> 
> So that errors are handled properly.
> 
Sure, I will verify the changes to push next version 
> >>
> >>> + ;
> >>> +
> >>> + return 0;
> >>> +}
> >>> +
> >>>   UCLASS_DRIVER(nop) = {
> >>>   .id = UCLASS_NOP,
> >>>   .name   = "nop",

RE: [PATCH v4 1/2] dm: core: add function uclass_probe_all() to probe all devices

2020-11-23 Thread Vabhav Sharma (OSS)


> -Original Message-
> From: Sean Anderson 
> Sent: Thursday, November 19, 2020 9:05 AM
> To: Vabhav Sharma (OSS) ;
> s...@chromium.org; s...@denx.de
> Cc: u-boot@lists.denx.de; Varun Sethi ;
> andre.przyw...@arm.com; Vabhav Sharma 
> Subject: Re: [PATCH v4 1/2] dm: core: add function uclass_probe_all() to
> probe all devices
> 
> On 11/17/20 10:00 AM, Vabhav Sharma wrote:
> > From: Vabhav Sharma 
> >
> > Support a common method to probe all devices associated with uclass.
> >
> > This includes data structures and code for finding the first device
> > and looping for remaining devices associated with uclasses (groups of
> > devices with the same purpose, e.g. all SERIAL ports will be in the same
> uclass).
> >
> > An example is SBSA compliant PL011 UART IP, where firmware does the
> > serial port initialization and prepare uart device to let the kernel
> > use it for sending and reveiving the characters.SERIAL uclass will use
> > this function to initialize PL011 UART ports.
> >
> > The feature is enabled with CONFIG_DM.
> >
> > Signed-off-by: Vabhav Sharma 
> > Reviewed-by: Stefan Roese 
> > Reviewed-by: Simon Glass 
> > --
> >   v4:
> >   Incorporated review comments of Simon
> >   Removed if (dev)..  conditional check
> >
> >   v3:
> >   Incorporated review comments of Stephan,Simon
> >   Related discussion
> > https://patchwork.ozlabs.org/project/uboot/patch/1601400
> > 385-11854-1-git-send-email-vabhav.sha...@oss.nxp.com/
> > ---
> >  drivers/core/uclass.c | 16 
> >  include/dm/uclass.h   | 12 
> >  2 files changed, 28 insertions(+)
> >
> > diff --git a/drivers/core/uclass.c b/drivers/core/uclass.c index
> > c3f1b73..a1dc8bb 100644
> > --- a/drivers/core/uclass.c
> > +++ b/drivers/core/uclass.c
> > @@ -792,6 +792,22 @@ int uclass_pre_remove_device(struct udevice
> *dev)
> > }  #endif
> >
> > +int uclass_probe_all(enum uclass_id id) {
> > +   struct udevice *dev;
> > +   int ret;
> > +
> > +   ret = uclass_first_device(id, );
> > +   if (ret || !dev)
> > +   return ret;
> > +
> > +   /* Scanning uclass to probe all devices */
> > +   for (; dev; uclass_next_device())
> 
> You must check the return value of this function.
Error check is done for first device before passing the device to 
uclass_next_device(),
I think of other implementation is to combine the first device check and 
iterating through device list of u-class as 
for (ret = uclass_first_device(id, ); dev && !ret;  ret = 
uclass_next_device())
;
But iteration is not required if first device is not found and current changes 
seems to be ok
Please share valuable feedback
> 
> Also, I would suggest using a while loop instead of an empty for loop.
Please elaborate, Found for loop best suitable to use here
> 
> > +   ;
> > +
> > +   return 0;
> > +}
> > +
> >  UCLASS_DRIVER(nop) = {
> > .id = UCLASS_NOP,
> > .name   = "nop",
> > diff --git a/include/dm/uclass.h b/include/dm/uclass.h index
> > 7188304..7ac0aaa 100644
> > --- a/include/dm/uclass.h
> > +++ b/include/dm/uclass.h
> > @@ -381,6 +381,18 @@ int uclass_first_device_drvdata(enum uclass_id
> > id, ulong driver_data,  int uclass_resolve_seq(struct udevice *dev);
> >
> >  /**
> > + * uclass_probe_all() - Probe all devices based on an uclass ID
> > + *
> > + * Every uclass is identified by an ID, a number from 0 to n-1 where
> > + n is
> > + * the number of uclasses. This function probe all devices asocciated
> > + with
> 
> nit: probes associated
Ok
> 
> > + * a uclass by looking its ID.
> 
> nit: for its
Sure
> 
> AFAICT uclass_find_next_device walks the linked-list of devices in a uclass,
> and does not care about the ID. So this documentation is incorrect.
This documentation is for new function uclass_probe_all() and understand each 
Uclass is identified by enum ID e.g. UCLASS_SERIAL for serial devices.
According used the statement  "Every uclass is identified by an ID"

Please suggest.
> 
> > + *
> > + * @id: uclass ID to look up
> > + * @return 0 if OK, other -ve on error  */ int uclass_probe_all(enum
> > +uclass_id id);
> > +
> > +/**
> >   * uclass_id_foreach_dev() - Helper function to iteration through devices
> >   *
> >   * This creates a for() loop which works through the available
> > devices in
> >



RE: [PATCH v4 2/2] drivers: serial: probe all uart devices

2020-11-22 Thread Vabhav Sharma (OSS)


> -Original Message-
> From: Sean Anderson 
> Sent: Thursday, November 19, 2020 9:01 AM
> To: Vabhav Sharma (OSS) ;
> s...@chromium.org; s...@denx.de
> Cc: u-boot@lists.denx.de; Varun Sethi ;
> andre.przyw...@arm.com; Vabhav Sharma 
> Subject: Re: [PATCH v4 2/2] drivers: serial: probe all uart devices
> 
> On 11/17/20 10:00 AM, Vabhav Sharma wrote:
> > From: Vabhav Sharma 
> >
> > 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 
> > Reviewed-by: Stefan Roese 
> > Reviewed-by: Simon Glass 
> > --
> > v3:
> >   Incorporated Simon and Stephan review comment
> >   - Define generic function uclass_probe_all(enum uclass_id)
> > in drivers/core/uclass.c
> >   - Added the function in caller of serial_find_console_or_panic()
> >   - Removed repeated sequence with generic function call uclass_probe_all()
> >   - Dependent on other patch [PATCH] dm: core: add function
> uclass_probe_all()
> > to probe all devices
> >
> > v2:
> >   Incorporated Stefan review comment, Update #ifdef with macro
> >   if (IS_ENABLED)..
> > ---
> >  drivers/serial/Kconfig | 17 +
> >  drivers/serial/serial-uclass.c |  4 
> >  2 files changed, 21 insertions(+)
> >
> > diff --git a/drivers/serial/Kconfig b/drivers/serial/Kconfig index
> > b4805a2..af8779b 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
> > +   help
> > + The serial subsystem only probe for single serial device,
> 
> nit: probes for a
Ok
> 
> > + but does not probe for other remaining serial devices.
> > + With this option set,we make probing and searching for
> 
> nit: set, we
Sure
>
> > + all available devices optional.
> > + Normally, U-Boot talk to one serial port at a time but SBSA
> 
> nit: talks
> nit: time, but
Agree
> 
> > + compliant UART devices like PL011 require initialization
> > + by firmware and let the kernel use serial port for sending
> 
> nit: to let the kernel use the
I understand
> 
> > + and receiving the characters.
> > +
> > + If probing is not required for all remaining available
> > + devices other than default current console device, say N.
> 
> Perhaps use the "If unsure, say N." wording like other Kconfigs.
Got it
> 
> > +
> >  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 f3c25d4..417d3af 100644
> > --- a/drivers/serial/serial-uclass.c
> > +++ b/drivers/serial/serial-uclass.c
> > @@ -172,6 +172,10 @@ int serial_init(void)
> >  /* Called after relocation */
> >  int serial_initialize(void)
> >  {
> > +   /* Scanning uclass to probe devices */
> > +   if (IS_ENABLED(CONFIG_SERIAL_PROBE_ALL))
> > +   uclass_probe_all(UCLASS_SERIAL);
> > +
> > return serial_init();
> >  }
> >
> >



[PATCH v4 2/2] drivers: serial: probe all uart devices

2020-11-17 Thread Vabhav Sharma
From: Vabhav Sharma 

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 
Reviewed-by: Stefan Roese 
Reviewed-by: Simon Glass 
--
v3:
  Incorporated Simon and Stephan review comment
  - Define generic function uclass_probe_all(enum uclass_id)
in drivers/core/uclass.c
  - Added the function in caller of serial_find_console_or_panic()
  - Removed repeated sequence with generic function call uclass_probe_all()
  - Dependent on other patch [PATCH] dm: core: add function uclass_probe_all()
to probe all devices

v2:
  Incorporated Stefan review comment, Update #ifdef with macro
  if (IS_ENABLED)..
---
 drivers/serial/Kconfig | 17 +
 drivers/serial/serial-uclass.c |  4 
 2 files changed, 21 insertions(+)

diff --git a/drivers/serial/Kconfig b/drivers/serial/Kconfig
index b4805a2..af8779b 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
+   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 f3c25d4..417d3af 100644
--- a/drivers/serial/serial-uclass.c
+++ b/drivers/serial/serial-uclass.c
@@ -172,6 +172,10 @@ int serial_init(void)
 /* Called after relocation */
 int serial_initialize(void)
 {
+   /* Scanning uclass to probe devices */
+   if (IS_ENABLED(CONFIG_SERIAL_PROBE_ALL))
+   uclass_probe_all(UCLASS_SERIAL);
+
return serial_init();
 }
 
-- 
2.7.4



RE: [PATCH v3 1/2] dm: core: add function uclass_probe_all() to probe all devices

2020-11-17 Thread Vabhav Sharma (OSS)


> -Original Message-
> From: Simon Glass 
> Sent: Tuesday, October 27, 2020 10:22 AM
> To: Vabhav Sharma (OSS) 
> Cc: Stefan Roese ; U-Boot Mailing List ;
> Varun Sethi ; Andre Przywara
> ; Vabhav Sharma 
> Subject: Re: [PATCH v3 1/2] dm: core: add function uclass_probe_all() to
> probe all devices
> 
> On Mon, 19 Oct 2020 at 12:10, Vabhav Sharma
>  wrote:
> >
> > From: Vabhav Sharma 
> >
> > Support a common method to probe all devices associated with uclass.
> >
> > This includes data structures and code for finding the first device
> > and looping for remaining devices associated with uclasses (groups of
> > devices with the same purpose, e.g. all SERIAL ports will be in the same
> uclass).
> >
> > An example is SBSA compliant PL011 UART IP, where firmware does the
> > serial port initialization and prepare uart device to let the kernel
> > use it for sending and reveiving the characters.SERIAL uclass will use
> > this function to initialize PL011 UART ports.
> >
> > The feature is enabled with CONFIG_DM.
> >
> > Signed-off-by: Vabhav Sharma 
> > Reviewed-by: Stefan Roese 
> > --
> >   v3:
> >   Incorporated review comments of Stephan,Simon
> >   Related discussion
> > https://patchwork.ozlabs.org/project/uboot/patch/1601400
> > 385-11854-1-git-send-email-vabhav.sha...@oss.nxp.com/
> > ---
> >  drivers/core/uclass.c | 17 +
> >  include/dm/uclass.h   | 12 
> >  2 files changed, 29 insertions(+)
> 
> Reviewed-by: Simon Glass 
> 
> >
> > diff --git a/drivers/core/uclass.c b/drivers/core/uclass.c index
> > c3f1b73..0725e8e 100644
> > --- a/drivers/core/uclass.c
> > +++ b/drivers/core/uclass.c
> > @@ -792,6 +792,23 @@ int uclass_pre_remove_device(struct udevice *dev)
> > }  #endif
> >
> > +int uclass_probe_all(enum uclass_id id) {
> > +   struct udevice *dev;
> > +   int ret;
> > +
> > +   ret = uclass_first_device(id, );
> > +   if (ret || !dev)
> > +   return ret;
> > +   if (dev) {
> 
> nit: I think that if() is not needed.
Sure
> 
> 
> > +   /* Scanning uclass to probe all devices */
> > +   for (; dev; uclass_next_device())
> > +   ;
> > +   }
> > +
> > +   return 0;
> > +}
> > +
> >  UCLASS_DRIVER(nop) = {
> > .id = UCLASS_NOP,
> > .name   = "nop",
> > diff --git a/include/dm/uclass.h b/include/dm/uclass.h index
> > 67ff746..0fce83f 100644
> > --- a/include/dm/uclass.h
> > +++ b/include/dm/uclass.h
> > @@ -380,6 +380,18 @@ int uclass_first_device_drvdata(enum uclass_id
> > id, ulong driver_data,  int uclass_resolve_seq(struct udevice *dev);
> >
> >  /**
> > + * uclass_probe_all() - Probe all devices based on an uclass ID
> > + *
> > + * Every uclass is identified by an ID, a number from 0 to n-1 where
> > +n is
> > + * the number of uclasses. This function probe all devices asocciated
> > +with
> > + * a uclass by looking its ID.
> > + *
> > + * @id: uclass ID to look up
> > + * @return 0 if OK, other -ve on error  */ int uclass_probe_all(enum
> > +uclass_id id);
> > +
> > +/**
> >   * uclass_id_foreach_dev() - Helper function to iteration through devices
> >   *
> >   * This creates a for() loop which works through the available
> > devices in
> > --
> > 2.7.4
> >


[PATCH v4 1/2] dm: core: add function uclass_probe_all() to probe all devices

2020-11-17 Thread Vabhav Sharma
From: Vabhav Sharma 

Support a common method to probe all devices associated with uclass.

This includes data structures and code for finding the first device and
looping for remaining devices associated with uclasses (groups of devices
with the same purpose, e.g. all SERIAL ports will be in the same uclass).

An example is SBSA compliant PL011 UART IP, where firmware does the serial
port initialization and prepare uart device to let the kernel use it for
sending and reveiving the characters.SERIAL uclass will use this function
to initialize PL011 UART ports.

The feature is enabled with CONFIG_DM.

Signed-off-by: Vabhav Sharma 
Reviewed-by: Stefan Roese 
Reviewed-by: Simon Glass 
--
  v4:
  Incorporated review comments of Simon
  Removed if (dev)..  conditional check

  v3:
  Incorporated review comments of Stephan,Simon
  Related discussion https://patchwork.ozlabs.org/project/uboot/patch/1601400
385-11854-1-git-send-email-vabhav.sha...@oss.nxp.com/
---
 drivers/core/uclass.c | 16 
 include/dm/uclass.h   | 12 
 2 files changed, 28 insertions(+)

diff --git a/drivers/core/uclass.c b/drivers/core/uclass.c
index c3f1b73..a1dc8bb 100644
--- a/drivers/core/uclass.c
+++ b/drivers/core/uclass.c
@@ -792,6 +792,22 @@ int uclass_pre_remove_device(struct udevice *dev)
 }
 #endif
 
+int uclass_probe_all(enum uclass_id id)
+{
+   struct udevice *dev;
+   int ret;
+
+   ret = uclass_first_device(id, );
+   if (ret || !dev)
+   return ret;
+
+   /* Scanning uclass to probe all devices */
+   for (; dev; uclass_next_device())
+   ;
+
+   return 0;
+}
+
 UCLASS_DRIVER(nop) = {
.id = UCLASS_NOP,
.name   = "nop",
diff --git a/include/dm/uclass.h b/include/dm/uclass.h
index 7188304..7ac0aaa 100644
--- a/include/dm/uclass.h
+++ b/include/dm/uclass.h
@@ -381,6 +381,18 @@ int uclass_first_device_drvdata(enum uclass_id id, ulong 
driver_data,
 int uclass_resolve_seq(struct udevice *dev);
 
 /**
+ * uclass_probe_all() - Probe all devices based on an uclass ID
+ *
+ * Every uclass is identified by an ID, a number from 0 to n-1 where n is
+ * the number of uclasses. This function probe all devices asocciated with
+ * a uclass by looking its ID.
+ *
+ * @id: uclass ID to look up
+ * @return 0 if OK, other -ve on error
+ */
+int uclass_probe_all(enum uclass_id id);
+
+/**
  * uclass_id_foreach_dev() - Helper function to iteration through devices
  *
  * This creates a for() loop which works through the available devices in
-- 
2.7.4



[PATCH v4 0/2] dm: core: drivers: add function uclass_probe_all()

2020-11-17 Thread Vabhav Sharma
From: Vabhav Sharma 

- Add common method to probe devices belonging to same uclass 
- Add config in serial uclass to support optional inclusion of uclass_probe_all
- Enable support for available serial devices probe

Changes for v4:
Incorporated review comments from Simon  
  - Removed if (dev)..  conditional check in function uclass_probe_all()

Changes for v3:
  Incorporated Simon and Stephan review comment
  - Define generic function uclass_probe_all(enum uclass_id)
in drivers/core/uclass.c
  - Added the function in caller of serial_find_console_or_panic()
  - Removed repeated sequence with generic function call uclass_probe_all()

Changes for v2:
  Incorporated Stefan review comment,Update #ifdef with macro if (IS_ENABLED).

Vabhav Sharma (2):
  dm: core: add function uclass_probe_all() to probe all devices
  drivers: serial: probe all uart devices

 drivers/core/uclass.c  | 16 
 drivers/serial/Kconfig | 17 +
 drivers/serial/serial-uclass.c |  4 
 include/dm/uclass.h| 12 
 4 files changed, 49 insertions(+)

-- 
2.7.4



RE: [PATCH] dm: core: add function uclass_probe_all() to probe all devices

2020-10-19 Thread Vabhav Sharma (OSS)


> -Original Message-
> From: Stefan Roese 
> Sent: Monday, October 19, 2020 3:40 PM
> To: Vabhav Sharma (OSS) ; u-
> b...@lists.denx.de; s...@chromium.org
> Cc: Varun Sethi ; andre.przyw...@arm.com; Vabhav
> Sharma 
> Subject: Re: [PATCH] dm: core: add function uclass_probe_all() to probe all
> devices
> 
> On 19.10.20 11:37, Vabhav Sharma wrote:
> > From: Vabhav Sharma 
> >
> > Support a common method to probe all devices associated with uclass.
> >
> > This includes data structures and code for finding the first device
> > and looping for remaining devices associated with uclasses (groups of
> > devices with the same purpose, e.g. all SERIAL ports will be in the same
> uclass).
> >
> > An example is SBSA compliant PL011 UART IP, where firmware does the
> > serial port initialization and prepare uart device to let the kernel
> > use it for sending and reveiving the characters.SERIAL uclass will use
> > this function to initialize PL011 UART ports.
> >
> > The feature is enabled with CONFIG_DM.
> >
> > Signed-off-by: Vabhav Sharma 
> > --
> >Related discussion
> > https://patchwork.ozlabs.org/project/uboot/patch/1601400
> > 385-11854-1-git-send-email-vabhav.sha...@oss.nxp.com/
> > ---
> >   drivers/core/uclass.c | 17 +
> >   include/dm/uclass.h   | 12 
> >   2 files changed, 29 insertions(+)
> >
> > diff --git a/drivers/core/uclass.c b/drivers/core/uclass.c index
> > c3f1b73..0725e8e 100644
> > --- a/drivers/core/uclass.c
> > +++ b/drivers/core/uclass.c
> > @@ -792,6 +792,23 @@ int uclass_pre_remove_device(struct udevice *dev)
> >   }
> >   #endif
> >
> > +int uclass_probe_all(enum uclass_id id) {
> > +   struct udevice *dev;
> > +   int ret;
> > +
> > +   ret = uclass_first_device(id, );
> > +   if (ret || !dev)
> > +   return ret;
> > +   if (dev) {
> > +   /* Scanning uclass to probe all devices */
> > +   for (; dev; uclass_next_device())
> > +   ;
> > +   }
> > +
> > +   return 0;
> > +}
> > +
> >   UCLASS_DRIVER(nop) = {
> > .id = UCLASS_NOP,
> > .name   = "nop",
> > diff --git a/include/dm/uclass.h b/include/dm/uclass.h index
> > 67ff746..0fce83f 100644
> > --- a/include/dm/uclass.h
> > +++ b/include/dm/uclass.h
> > @@ -380,6 +380,18 @@ int uclass_first_device_drvdata(enum uclass_id id,
> ulong driver_data,
> >   int uclass_resolve_seq(struct udevice *dev);
> >
> >   /**
> > + * uclass_probe_all() - Probe all devices based on an uclass ID
> > + *
> > + * Every uclass is identified by an ID, a number from 0 to n-1 where
> > +n is
> > + * the number of uclasses. This function probe all devices asocciated
> > +with
> > + * a uclass by looking its ID.
> > + *
> > + * @id: uclass ID to look up
> > + * @return 0 if OK, other -ve on error  */ int uclass_probe_all(enum
> > +uclass_id id);
> > +
> > +/**
> >* uclass_id_foreach_dev() - Helper function to iteration through devices
> >*
> >* This creates a for() loop which works through the available
> > devices in
> >
> 
> Ahh, here is the function. You should better move both patches into one
> patchset, so that the dependency can be seen. Especially while applying.
Sure.
> 
> Other that that:
> 
> Reviewed-by: Stefan Roese 
> 
> Thanks,
> Stefan


[PATCH v3 2/2] drivers: serial: probe all uart devices

2020-10-19 Thread Vabhav Sharma
From: Vabhav Sharma 

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 
Reviewed-by: Stefan Roese 
--
v3:
  Incorporated Simon and Stephan review comment
  - Define generic function uclass_probe_all(enum uclass_id)
in drivers/core/uclass.c
  - Added the function in caller of serial_find_console_or_panic()
  - Removed repeated sequence with generic function call uclass_probe_all()
  - Dependent on other patch [PATCH] dm: core: add function uclass_probe_all()
to probe all devices

v2:
  Incorporated Stefan review comment, Update #ifdef with macro
  if (IS_ENABLED)..
---
 drivers/serial/Kconfig | 17 +
 drivers/serial/serial-uclass.c |  4 
 2 files changed, 21 insertions(+)

diff --git a/drivers/serial/Kconfig b/drivers/serial/Kconfig
index b4805a2..af8779b 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
+   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..09bc6f4 100644
--- a/drivers/serial/serial-uclass.c
+++ b/drivers/serial/serial-uclass.c
@@ -172,6 +172,10 @@ int serial_init(void)
 /* Called after relocation */
 int serial_initialize(void)
 {
+   /* Scanning uclass to probe devices */
+   if (IS_ENABLED(CONFIG_SERIAL_PROBE_ALL))
+   uclass_probe_all(UCLASS_SERIAL);
+
return serial_init();
 }
 
-- 
2.7.4



[PATCH v3 0/2] dm: core: drivers: add function uclass_probe_all()

2020-10-19 Thread Vabhav Sharma
From: Vabhav Sharma 

- Add common method to probe devices belonging to same uclass 
- Add config in serial uclass to support optional inclusion of uclass_probe_all
- Enable support for available serial devices probe

Changes for v3:
  Incorporated Simon and Stephan review comment
  - Define generic function uclass_probe_all(enum uclass_id)
in drivers/core/uclass.c
  - Added the function in caller of serial_find_console_or_panic()
  - Removed repeated sequence with generic function call uclass_probe_all()
 
Changes for v2:
  Incorporated Stefan review comment,Update #ifdef with macro if (IS_ENABLED).

Vabhav Sharma (2):
  dm: core: add function uclass_probe_all() to probe all devices
  drivers: serial: probe all uart devices

 drivers/core/uclass.c  | 17 +
 drivers/serial/Kconfig | 17 +
 drivers/serial/serial-uclass.c |  4 
 include/dm/uclass.h| 12 
 4 files changed, 50 insertions(+)

-- 
2.7.4



[PATCH v3 1/2] dm: core: add function uclass_probe_all() to probe all devices

2020-10-19 Thread Vabhav Sharma
From: Vabhav Sharma 

Support a common method to probe all devices associated with uclass.

This includes data structures and code for finding the first device and
looping for remaining devices associated with uclasses (groups of devices
with the same purpose, e.g. all SERIAL ports will be in the same uclass).

An example is SBSA compliant PL011 UART IP, where firmware does the serial
port initialization and prepare uart device to let the kernel use it for
sending and reveiving the characters.SERIAL uclass will use this function
to initialize PL011 UART ports.

The feature is enabled with CONFIG_DM.

Signed-off-by: Vabhav Sharma 
Reviewed-by: Stefan Roese 
--
  v3:
  Incorporated review comments of Stephan,Simon
  Related discussion https://patchwork.ozlabs.org/project/uboot/patch/1601400
385-11854-1-git-send-email-vabhav.sha...@oss.nxp.com/
---
 drivers/core/uclass.c | 17 +
 include/dm/uclass.h   | 12 
 2 files changed, 29 insertions(+)

diff --git a/drivers/core/uclass.c b/drivers/core/uclass.c
index c3f1b73..0725e8e 100644
--- a/drivers/core/uclass.c
+++ b/drivers/core/uclass.c
@@ -792,6 +792,23 @@ int uclass_pre_remove_device(struct udevice *dev)
 }
 #endif
 
+int uclass_probe_all(enum uclass_id id)
+{
+   struct udevice *dev;
+   int ret;
+
+   ret = uclass_first_device(id, );
+   if (ret || !dev)
+   return ret;
+   if (dev) {
+   /* Scanning uclass to probe all devices */
+   for (; dev; uclass_next_device())
+   ;
+   }
+
+   return 0;
+}
+
 UCLASS_DRIVER(nop) = {
.id = UCLASS_NOP,
.name   = "nop",
diff --git a/include/dm/uclass.h b/include/dm/uclass.h
index 67ff746..0fce83f 100644
--- a/include/dm/uclass.h
+++ b/include/dm/uclass.h
@@ -380,6 +380,18 @@ int uclass_first_device_drvdata(enum uclass_id id, ulong 
driver_data,
 int uclass_resolve_seq(struct udevice *dev);
 
 /**
+ * uclass_probe_all() - Probe all devices based on an uclass ID
+ *
+ * Every uclass is identified by an ID, a number from 0 to n-1 where n is
+ * the number of uclasses. This function probe all devices asocciated with
+ * a uclass by looking its ID.
+ *
+ * @id: uclass ID to look up
+ * @return 0 if OK, other -ve on error
+ */
+int uclass_probe_all(enum uclass_id id);
+
+/**
  * uclass_id_foreach_dev() - Helper function to iteration through devices
  *
  * This creates a for() loop which works through the available devices in
-- 
2.7.4



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

2020-10-19 Thread Vabhav Sharma (OSS)
Hi Simon, Stefan,
Thank you for feedback and time

> -Original Message-
> From: Simon Glass 
> Sent: Thursday, October 15, 2020 8:35 PM
> To: Stefan Roese 
> Cc: Vabhav Sharma (OSS) ;
> andre.przyw...@arm.com; u-boot@lists.denx.de
> Subject: Re: [PATCH v2] drivers: serial: probe all uart devices
> 
> Hi,
> 
> On Wed, 14 Oct 2020 at 06:47, Stefan Roese  wrote:
> >
> > Hi Vabhav,
> >
> > On 14.10.20 13:15, Vabhav Sharma (OSS) wrote:
> > > Hi Stefan,
> > > Sorry for delayed reply, Occupied with high priority task
> > >
> > >> -Original Message-
> > >> From: Stefan Roese 
> > >> Sent: Wednesday, September 30, 2020 10:46 AM
> > >> To: Vabhav Sharma (OSS) ;
> > >> andre.przyw...@arm.com; u-boot@lists.denx.de; s...@chromium.org
> > >> Cc: Vabhav Sharma 
> > >> Subject: Re: [PATCH v2] drivers: serial: probe all uart devices
> > >>
> > >> On 29.09.20 19:26, Vabhav Sharma wrote:
> > >>> From: Vabhav Sharma 
> > >>>
> > >>> 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 
> > >>> ---
> > >>> v2:
> > >>>  Incorporated Stefan review comment, Update #ifdef with macro
> > >>>  if (IS_ENABLED)..
> > >>
> > >> Better, thanks. But...
> > >>
> > >>> ---
> > >>> ---
> > >>>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
> > >>> +   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, );
> > >>> if (dev) {
> > >>> gd->cur_serial_dev = dev;
> > >>> +   if

[PATCH] dm: core: add function uclass_probe_all() to probe all devices

2020-10-19 Thread Vabhav Sharma
From: Vabhav Sharma 

Support a common method to probe all devices associated with uclass.

This includes data structures and code for finding the first device and
looping for remaining devices associated with uclasses (groups of devices
with the same purpose, e.g. all SERIAL ports will be in the same uclass).

An example is SBSA compliant PL011 UART IP, where firmware does the serial
port initialization and prepare uart device to let the kernel use it for
sending and reveiving the characters.SERIAL uclass will use this function
to initialize PL011 UART ports.

The feature is enabled with CONFIG_DM.

Signed-off-by: Vabhav Sharma 
--
  Related discussion https://patchwork.ozlabs.org/project/uboot/patch/1601400
385-11854-1-git-send-email-vabhav.sha...@oss.nxp.com/
---
 drivers/core/uclass.c | 17 +
 include/dm/uclass.h   | 12 
 2 files changed, 29 insertions(+)

diff --git a/drivers/core/uclass.c b/drivers/core/uclass.c
index c3f1b73..0725e8e 100644
--- a/drivers/core/uclass.c
+++ b/drivers/core/uclass.c
@@ -792,6 +792,23 @@ int uclass_pre_remove_device(struct udevice *dev)
 }
 #endif
 
+int uclass_probe_all(enum uclass_id id)
+{
+   struct udevice *dev;
+   int ret;
+
+   ret = uclass_first_device(id, );
+   if (ret || !dev)
+   return ret;
+   if (dev) {
+   /* Scanning uclass to probe all devices */
+   for (; dev; uclass_next_device())
+   ;
+   }
+
+   return 0;
+}
+
 UCLASS_DRIVER(nop) = {
.id = UCLASS_NOP,
.name   = "nop",
diff --git a/include/dm/uclass.h b/include/dm/uclass.h
index 67ff746..0fce83f 100644
--- a/include/dm/uclass.h
+++ b/include/dm/uclass.h
@@ -380,6 +380,18 @@ int uclass_first_device_drvdata(enum uclass_id id, ulong 
driver_data,
 int uclass_resolve_seq(struct udevice *dev);
 
 /**
+ * uclass_probe_all() - Probe all devices based on an uclass ID
+ *
+ * Every uclass is identified by an ID, a number from 0 to n-1 where n is
+ * the number of uclasses. This function probe all devices asocciated with
+ * a uclass by looking its ID.
+ *
+ * @id: uclass ID to look up
+ * @return 0 if OK, other -ve on error
+ */
+int uclass_probe_all(enum uclass_id id);
+
+/**
  * uclass_id_foreach_dev() - Helper function to iteration through devices
  *
  * This creates a for() loop which works through the available devices in
-- 
2.7.4



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

2020-10-19 Thread Vabhav Sharma
From: Vabhav Sharma 

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 
--
v3:
  Incorporated Simon and Stephan review comment
  - Define generic function uclass_probe_all(enum uclass_id)
in drivers/core/uclass.c
  - Added the function in caller of serial_find_console_or_panic()
  - Removed repeated sequence with generic function call uclass_probe_all()
  - Dependent on other patch [PATCH] dm: core: add function uclass_probe_all()
to probe all devices

v2:
  Incorporated Stefan review comment, Update #ifdef with macro
  if (IS_ENABLED)..
---
 drivers/serial/Kconfig | 17 +
 drivers/serial/serial-uclass.c |  4 
 2 files changed, 21 insertions(+)

diff --git a/drivers/serial/Kconfig b/drivers/serial/Kconfig
index b4805a2..af8779b 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
+   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..09bc6f4 100644
--- a/drivers/serial/serial-uclass.c
+++ b/drivers/serial/serial-uclass.c
@@ -172,6 +172,10 @@ int serial_init(void)
 /* Called after relocation */
 int serial_initialize(void)
 {
+   /* Scanning uclass to probe devices */
+   if (IS_ENABLED(CONFIG_SERIAL_PROBE_ALL))
+   uclass_probe_all(UCLASS_SERIAL);
+
return serial_init();
 }
 
-- 
2.7.4



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

2020-10-14 Thread Vabhav Sharma (OSS)
Hi Simon,
Apology for delayed reply, Got occupied due to other business deliverables

> -Original Message-
> From: Simon Glass 
> Sent: Wednesday, September 30, 2020 10:15 PM
> To: Vabhav Sharma (OSS) 
> Cc: Andre Przywara ; U-Boot Mailing List  b...@lists.denx.de>; Stefan Roese ; Vabhav Sharma
> 
> Subject: Re: [PATCH v2] drivers: serial: probe all uart devices
> 
> Hi Vabhav,
> 
> On Tue, 29 Sep 2020 at 11:33, Vabhav Sharma 
> wrote:
> >
> > From: Vabhav Sharma 
> >
> > 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 
> > ---
> > 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, );
> > 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())
> > +   ;
> 
> 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?
>
Ok, Let me check the above the above functions feasibility to probe serial ports
> 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().
I see, Situation is rare but possible as SBSA compliance required 
initialization by firmware.
> 
> 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,
Ok, Both are possible as per the requirement.

Current changes target PL011 UART IP which is SBSA compliant and accordingly 
used Serial uclass functions to do the needful.


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

2020-10-14 Thread Vabhav Sharma (OSS)
Hi Stefan,
Sorry for delayed reply, Occupied with high priority task

> -Original Message-
> From: Stefan Roese 
> Sent: Wednesday, September 30, 2020 10:46 AM
> To: Vabhav Sharma (OSS) ;
> andre.przyw...@arm.com; u-boot@lists.denx.de; s...@chromium.org
> Cc: Vabhav Sharma 
> Subject: Re: [PATCH v2] drivers: serial: probe all uart devices
> 
> On 29.09.20 19:26, Vabhav Sharma wrote:
> > From: Vabhav Sharma 
> >
> > 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 
> > ---
> > v2:
> > Incorporated Stefan review comment, Update #ifdef with macro
> > if (IS_ENABLED)..
> 
> Better, thanks. But...
> 
> > ---
> > ---
> >   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
> > +   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, );
> > 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())
> > +   ;
> > +   }
> > return;
> > }
> > } else if (CONFIG_IS_ENABLED(OF_CONTROL) && blob) { @@ -96,11
> > +101,21 @@ static void serial_find_console_or_panic(void)
> > if (np
> && !uclass_get_device_by_ofnode(UCLASS_SERIAL,
> > np_to_ofnode(np), )) {
> > gd->cur_serial_dev = dev;
> > +   if (IS_ENABLED(CONFIG_SERIAL_PROBE_ALL))
> {
> > +   /* Scanning uclass to probe devices
> */
> > +   for (; dev; uclass_next_device())
> > +   ;
> > +   }
> 
> This code sequence (incl. gd->cur_serial_dev = dev;) is repeated multiple
> times (below as well). Could you instead move this into a function and call
> this function to reduce code and binary size?
I understand.
Checked and found that 56 bytes of code is added (including enabling the macro 
on LS platform)

Intended to define it earlier but defining one line of code in a function cause 
more overhead (function call, Stack operations, Po

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

2020-09-29 Thread Vabhav Sharma
From: Vabhav Sharma 

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 
---
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
+   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, );
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())
+   ;
+   }
return;
}
} else if (CONFIG_IS_ENABLED(OF_CONTROL) && blob) {
@@ -96,11 +101,21 @@ static void serial_find_console_or_panic(void)
if (np && !uclass_get_device_by_ofnode(UCLASS_SERIAL,
np_to_ofnode(np), )) {
gd->cur_serial_dev = dev;
+   if (IS_ENABLED(CONFIG_SERIAL_PROBE_ALL)) {
+   /* Scanning uclass to probe devices */
+   for (; dev; uclass_next_device())
+   ;
+   }
return;
}
} else {
if (!serial_check_stdout(blob, )) {
gd->cur_serial_dev = dev;
+   if (IS_ENABLED(CONFIG_SERIAL_PROBE_ALL)) {
+   /* Scanning uclass to probe devices */
+   for (; dev; uclass_next_device())
+   ;
+   }
return;
}
}
@@ -125,6 +140,11 @@ static void serial_find_console_or_panic(void)
!uclass_get_device(UCLASS_SERIAL, INDEX, )) {
if (dev->flags & DM_FLAG_ACTIVATED) {
gd->cur_serial_dev = dev;
+   if (IS_ENABLED(CONFIG_SERIAL_PROBE_ALL)) {
+   /* Scanning uclass to probe devices */
+   for (; dev; uclass_next_device())
+   ;
+   }
return;
}
}
@@ -136,6 +156,11 @@ static void serial_find_console_or_panic(void)
if (!ret) {
/* Device did succeed probing */
gd->cur_serial_dev = dev;
+   if (IS_ENABLED(CONFIG_SERIAL_PROBE_ALL)) {
+

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

2020-09-29 Thread Vabhav Sharma (OSS)


> -Original Message-
> From: Stefan Roese 
> Sent: Tuesday, September 29, 2020 10:52 AM
> To: Vabhav Sharma (OSS) ;
> andre.przyw...@arm.com; u-boot@lists.denx.de; s...@chromium.org
> Cc: Vabhav Sharma 
> Subject: Re: [PATCH] drivers: serial: probe all uart devices
> 
> On 28.09.20 19:43, Vabhav Sharma wrote:
> > From: Vabhav Sharma 
> >
> > 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 
> > ---
> >   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
> > +   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..9b2fcb0 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, );
> > if (dev) {
> > gd->cur_serial_dev = dev;
> > +#ifdef CONFIG_SERIAL_PROBE_ALL
> > +   /* Scanning uclass to probe all devices */
> > +   for (; dev; uclass_next_device())
> > +   ;
> > +#endif
> 
> Please don't use #ifdef's here but instead something like this:
> 
>   if (IS_ENABLED(CONFIG_SERIAL_PROBE_ALL)) {
>   /* Scanning uclass to probe all devices */
>   for (; dev; uclass_next_device())
>   ;
>   }
> 
Ok
> > return;
> > }
> > } else if (CONFIG_IS_ENABLED(OF_CONTROL) && blob) { @@ -96,11
> > +101,21 @@ static void serial_find_console_or_panic(void)
> > if (np
> && !uclass_get_device_by_ofnode(UCLASS_SERIAL,
> > np_to_ofnode(np), )) {
> > gd->cur_serial_dev = dev;
> > +#ifdef CONFIG_SERIAL_PROBE_ALL
> > +   /* Scanning uclass to probe all devices */
> > +   for (; dev; uclass_next_device())
> > +   ;
> > +#endif
> 
> And please everywhere else as well.
Sure
> 
> Thanks,
> Stefan
> 
> > return;
> > }
> > } else {
> > if (!serial_check_stdout(blob, )) {
> > gd->cur_serial_dev = dev;
> > +#ifdef CONFIG_SERIAL_PROBE_ALL
> > +   /* Scanning uclass to probe all devices */
> > +   for (; dev; uclass_next_device())
> > +   ;
> > +#endif
> >  

[PATCH] drivers: serial: probe all uart devices

2020-09-28 Thread Vabhav Sharma
From: Vabhav Sharma 

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 
---
 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
+   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..9b2fcb0 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, );
if (dev) {
gd->cur_serial_dev = dev;
+#ifdef CONFIG_SERIAL_PROBE_ALL
+   /* Scanning uclass to probe all devices */
+   for (; dev; uclass_next_device())
+   ;
+#endif
return;
}
} else if (CONFIG_IS_ENABLED(OF_CONTROL) && blob) {
@@ -96,11 +101,21 @@ static void serial_find_console_or_panic(void)
if (np && !uclass_get_device_by_ofnode(UCLASS_SERIAL,
np_to_ofnode(np), )) {
gd->cur_serial_dev = dev;
+#ifdef CONFIG_SERIAL_PROBE_ALL
+   /* Scanning uclass to probe all devices */
+   for (; dev; uclass_next_device())
+   ;
+#endif
return;
}
} else {
if (!serial_check_stdout(blob, )) {
gd->cur_serial_dev = dev;
+#ifdef CONFIG_SERIAL_PROBE_ALL
+   /* Scanning uclass to probe all devices */
+   for (; dev; uclass_next_device())
+   ;
+#endif
return;
}
}
@@ -125,6 +140,11 @@ static void serial_find_console_or_panic(void)
!uclass_get_device(UCLASS_SERIAL, INDEX, )) {
if (dev->flags & DM_FLAG_ACTIVATED) {
gd->cur_serial_dev = dev;
+#ifdef CONFIG_SERIAL_PROBE_ALL
+   /* Scanning uclass to probe all devices */
+   for (; dev; uclass_next_device())
+   ;
+#endif
return;
}
}
@@ -136,6 +156,11 @@ static void serial_find_console_or_panic(void)
if (!ret) {
/* Device did succeed probing */
gd->cur_serial_dev = dev;
+#ifdef CONFIG_SERIAL_PROBE_ALL
+   /* Scanning uclass to probe all devices */
+   for (; dev; uclass_next_device())
+   ;
+#endif
return;
}
}
@@ -144,6 +169,11 @@ static void serial_find_console_or_panic(void)
!uclass_get_device(UCLASS_SERIAL, INDEX, ) ||
(!uclass_first_device(UCLASS_SERIAL, ) && dev)) {
gd->cur_serial_dev = dev;
+#ifdef CONFIG_SERIAL_PROBE_ALL
+   /* Scanning uclass t

[U-Boot] [PATCH] arm64: lx2160a: dts: Fix UART node status

2019-11-26 Thread Vabhav Sharma
LX2160A PL011 UART driver fetch IP block values using
platform data from board file instead of device tree.

Modified UART nodes in device tree to disable state.

Signed-off-by: Vabhav Sharma 
---
 arch/arm/dts/fsl-lx2160a.dtsi | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/arch/arm/dts/fsl-lx2160a.dtsi b/arch/arm/dts/fsl-lx2160a.dtsi
index a189333..9d018ca 100644
--- a/arch/arm/dts/fsl-lx2160a.dtsi
+++ b/arch/arm/dts/fsl-lx2160a.dtsi
@@ -127,12 +127,14 @@
compatible = "arm,pl011";
reg = <0x0 0x21c 0x0 0x1000>;
clocks = < 4 0>;
+   status = "disabled";
};
 
uart1: serial@21d {
compatible = "arm,pl011";
reg = <0x0 0x21d 0x0 0x1000>;
clocks = < 4 0>;
+   status = "disabled";
};
 
uart2: serial@21e {
-- 
2.7.4

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH v2] armv8: ls1046afrwy: Add support for LS1046AFRWY platform

2019-06-06 Thread Vabhav Sharma
LS1046AFRWY board supports LS1046A family SoCs. This patch
add base support for this board.
Board support's 4GB ddr memory, i2c, micro-click module,microSD card,
serial console,qspi nor flash,ifc nand flash,qsgmii network interface,
usb 3.0 and serdes interface to support two x1gen3 pcie interface.

Signed-off-by: Camelia Groza 
Signed-off-by: Madalin Bucur 
Signed-off-by: Pankit Garg 
Signed-off-by: Pramod Kumar 
Signed-off-by: Rajesh Bhagat 
Signed-off-by: Vabhav Sharma 
---
Changes in v2:
- Incorporated review comments from Prabhakar Kushwaha
- Removed non tfa boot support changes
- Removed PMIC and DEEP sleep config
- Unset CONFIG_SPI_FLASH_BAR in defconfig
- Updated mtd-id for QSPI nor in mtdparts variable 

 arch/arm/Kconfig   |  15 ++
 arch/arm/cpu/armv8/Kconfig |   1 +
 arch/arm/cpu/armv8/fsl-layerscape/ls1046a_serdes.c |   2 +
 arch/arm/dts/Makefile  |   1 +
 arch/arm/dts/fsl-ls1046a-frwy.dts  |  34 
 board/freescale/ls1046afrwy/Kconfig|  17 ++
 board/freescale/ls1046afrwy/MAINTAINERS|   7 +
 board/freescale/ls1046afrwy/Makefile   |   7 +
 board/freescale/ls1046afrwy/README |  76 +++
 board/freescale/ls1046afrwy/ddr.c  |  19 ++
 board/freescale/ls1046afrwy/eth.c  | 114 +++
 board/freescale/ls1046afrwy/ls1046afrwy.c  | 223 +
 configs/ls1046afrwy_tfa_defconfig  |  59 ++
 include/configs/ls1046a_common.h   |  13 +-
 include/configs/ls1046afrwy.h  | 136 +
 include/fm_eth.h   |  12 ++
 16 files changed, 734 insertions(+), 2 deletions(-)
 create mode 100644 arch/arm/dts/fsl-ls1046a-frwy.dts
 create mode 100644 board/freescale/ls1046afrwy/Kconfig
 create mode 100644 board/freescale/ls1046afrwy/MAINTAINERS
 create mode 100644 board/freescale/ls1046afrwy/Makefile
 create mode 100644 board/freescale/ls1046afrwy/README
 create mode 100644 board/freescale/ls1046afrwy/ddr.c
 create mode 100644 board/freescale/ls1046afrwy/eth.c
 create mode 100644 board/freescale/ls1046afrwy/ls1046afrwy.c
 create mode 100644 configs/ls1046afrwy_tfa_defconfig
 create mode 100644 include/configs/ls1046afrwy.h

diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index 01ff57c..d9ad32c 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -1406,6 +1406,20 @@ config TARGET_LS1046ARDB
  development platform that supports the QorIQ LS1046A
  Layerscape Architecture processor.
 
+config TARGET_LS1046AFRWY
+   bool "Support ls1046afrwy"
+   select ARCH_LS1046A
+   select ARM64
+   select ARMV8_MULTIENTRY
+   select BOARD_EARLY_INIT_F
+   select BOARD_LATE_INIT
+   select DM_SPI_FLASH if DM_SPI
+   imply SCSI
+   help
+ Support for Freescale LS1046AFRWY platform.
+ The LS1046A Freeway Board (FRWY) is a high-performance
+ development platform that supports the QorIQ LS1046A
+ Layerscape Architecture processor.
 config TARGET_H2200
bool "Support h2200"
select CPU_PXA
@@ -1697,6 +1711,7 @@ source "board/freescale/ls1021aiot/Kconfig"
 source "board/freescale/ls1046aqds/Kconfig"
 source "board/freescale/ls1043ardb/Kconfig"
 source "board/freescale/ls1046ardb/Kconfig"
+source "board/freescale/ls1046afrwy/Kconfig"
 source "board/freescale/ls1012aqds/Kconfig"
 source "board/freescale/ls1012ardb/Kconfig"
 source "board/freescale/ls1012afrdm/Kconfig"
diff --git a/arch/arm/cpu/armv8/Kconfig b/arch/arm/cpu/armv8/Kconfig
index 8a97d5b..92a2b58 100644
--- a/arch/arm/cpu/armv8/Kconfig
+++ b/arch/arm/cpu/armv8/Kconfig
@@ -107,6 +107,7 @@ config PSCI_RESET
   !TARGET_LS1028ARDB && !TARGET_LS1028AQDS && \
   !TARGET_LS1043ARDB && !TARGET_LS1043AQDS && \
   !TARGET_LS1046ARDB && !TARGET_LS1046AQDS && \
+  !TARGET_LS1046AFRWY && \
   !TARGET_LS2081ARDB && !TARGET_LX2160ARDB && \
   !TARGET_LX2160AQDS && \
   !ARCH_UNIPHIER && !TARGET_S32V234EVB
diff --git a/arch/arm/cpu/armv8/fsl-layerscape/ls1046a_serdes.c 
b/arch/arm/cpu/armv8/fsl-layerscape/ls1046a_serdes.c
index f8310f2..caa4862 100644
--- a/arch/arm/cpu/armv8/fsl-layerscape/ls1046a_serdes.c
+++ b/arch/arm/cpu/armv8/fsl-layerscape/ls1046a_serdes.c
@@ -1,6 +1,7 @@
 // SPDX-License-Identifier: GPL-2.0+
 /*
  * Copyright 2016 Freescale Semiconductor, Inc.
+ * Copyright 2019 NXP
  */
 
 #include 
@@ -33,6 +34,7 @@ static struct serdes_config serdes1_cfg_tbl[] = {
  SGMII_FM1_DTSEC6} },
{0x2223, {SGMII_2500_FM1_DTSEC9, SGMII_2500_FM1_DTSEC10,

Re: [U-Boot] [PATCH] armv8: ls1046afrwy: Add support for LS1046AFRWY platform

2019-06-04 Thread Vabhav Sharma
Dear Prabhakar,

> -Original Message-
> From: Prabhakar Kushwaha
> Sent: Tuesday, May 21, 2019 7:45 PM
> To: Vabhav Sharma ; u-boot@lists.denx.de
> Cc: Pramod Kumar ; Pankit Garg
> ; Varun Sethi ; Camelia
> Alexandra Groza 
> Subject: RE: [U-Boot] [PATCH] armv8: ls1046afrwy: Add support for
> LS1046AFRWY platform
> 
> Dear Vabhav,
> 
> > -Original Message-----
> > From: U-Boot  On Behalf Of Vabhav
> Sharma
> > Sent: Thursday, May 9, 2019 7:34 PM
> > To: u-boot@lists.denx.de
> > Cc: Pramod Kumar ; Pankit Garg
> > ; Varun Sethi ; Camelia
> > Alexandra Groza 
> > Subject: [U-Boot] [PATCH] armv8: ls1046afrwy: Add support for
> > LS1046AFRWY platform
> >
> > LS1046AFRWY board supports LS1046A family SoCs. This patch add base
> > support for this board.
> > Board support's 4GB ddr memory, i2c, micro-click module,microSD card,
> > serial console,qspi nor flash,ifc nand flash,qsgmii network interface,
> > usb 3.0 and serdes interface to support two x1gen3 pcie interface.
> >
> > Signed-off-by: Camelia Groza 
> > Signed-off-by: Madalin Bucur 
> > Signed-off-by: Pankit Garg 
> > Signed-off-by: Pramod Kumar 
> > Signed-off-by: Rajesh Bhagat 
> > Signed-off-by: Vabhav Sharma 
> > ---
> >  arch/arm/Kconfig   |  17 ++
> >  arch/arm/cpu/armv8/Kconfig |   1 +
> >  arch/arm/cpu/armv8/fsl-layerscape/ls1046a_serdes.c |   2 +
> >  arch/arm/dts/Makefile  |   1 +
> >  arch/arm/dts/fsl-ls1046a-frwy.dts  |  34 +++
> >  board/freescale/ls1046afrwy/Kconfig|  17 ++
> >  board/freescale/ls1046afrwy/MAINTAINERS|  17 ++
> >  board/freescale/ls1046afrwy/Makefile   |   9 +
> >  board/freescale/ls1046afrwy/README |  76 +++
> >  board/freescale/ls1046afrwy/ddr.c  |  24 ++
> >  board/freescale/ls1046afrwy/eth.c  | 114 ++
> >  board/freescale/ls1046afrwy/ls1046afrwy.c  | 249
> > +
> >  board/freescale/ls1046afrwy/ls1046afrwy_pbi.cfg|  22 ++
> >  .../freescale/ls1046afrwy/ls1046afrwy_qspi_pbi.cfg |  26 +++
> >  .../freescale/ls1046afrwy/ls1046afrwy_rcw_qspi.cfg |   7 +
> >  board/freescale/ls1046afrwy/ls1046afrwy_rcw_sd.cfg |   7 +
> >  configs/ls1046afrwy_tfa_defconfig  |  58 +
> >  include/configs/ls1046a_common.h   |  13 +-
> >  include/configs/ls1046afrwy.h  | 204 +
> >  include/fm_eth.h   |  12 +
> >  20 files changed, 908 insertions(+), 2 deletions(-)  create mode
> > 100644 arch/arm/dts/fsl-ls1046a-frwy.dts  create mode 100644
> > board/freescale/ls1046afrwy/Kconfig
> >  create mode 100644 board/freescale/ls1046afrwy/MAINTAINERS
> >  create mode 100644 board/freescale/ls1046afrwy/Makefile
> >  create mode 100644 board/freescale/ls1046afrwy/README
> >  create mode 100644 board/freescale/ls1046afrwy/ddr.c  create mode
> > 100644 board/freescale/ls1046afrwy/eth.c  create mode 100644
> > board/freescale/ls1046afrwy/ls1046afrwy.c
> >  create mode 100644 board/freescale/ls1046afrwy/ls1046afrwy_pbi.cfg
> >  create mode 100644
> > board/freescale/ls1046afrwy/ls1046afrwy_qspi_pbi.cfg
> >  create mode 100644
> > board/freescale/ls1046afrwy/ls1046afrwy_rcw_qspi.cfg
> >  create mode 100644 board/freescale/ls1046afrwy/ls1046afrwy_rcw_sd.cfg
> >  create mode 100644 configs/ls1046afrwy_tfa_defconfig  create mode
> > 100644 include/configs/ls1046afrwy.h
> >
> > diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig index
> > f91c590..15699a2
> > 100644
> > --- a/arch/arm/Kconfig
> > +++ b/arch/arm/Kconfig
> > @@ -1329,6 +1329,22 @@ config TARGET_LS1046ARDB
> >   development platform that supports the QorIQ LS1046A
> >   Layerscape Architecture processor.
> >
> > +config TARGET_LS1046AFRWY
> > +   bool "Support ls1046afrwy"
> > +   select ARCH_LS1046A
> > +   select ARM64
> > +   select ARMV8_MULTIENTRY
> > +   select BOARD_EARLY_INIT_F
> > +   select BOARD_LATE_INIT
> > +   select DM_SPI_FLASH if DM_SPI
> > +   select POWER_MC34VR500
> > +   select SUPPORT_SPL
> > +   imply SCSI
> > +   help
> > + Support for Freescale LS1046AFRWY platform.
> > + The LS1046A Freeway Board (FRWY) is a high-performance
> > + development platform that supports the QorIQ LS1046A
> > + Layerscape Architecture processor.
> >  config TARGET_H2

[U-Boot] [PATCH v2] mtd: spi: add spi flash id mt25qu512a

2019-05-14 Thread Vabhav Sharma
Add micron mt25qu512a flash description.

Signed-off-by: Ashish Kumar 
Signed-off-by: Pramod Kumar 
Signed-off-by: Vabhav Sharma 
---
Changes for v2:
- Use INFO6
- Removed SPI_NOR_4B_OPCODES
 
 drivers/mtd/spi/spi-nor-ids.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/mtd/spi/spi-nor-ids.c b/drivers/mtd/spi/spi-nor-ids.c
index ec92976..69bc989 100644
--- a/drivers/mtd/spi/spi-nor-ids.c
+++ b/drivers/mtd/spi/spi-nor-ids.c
@@ -163,6 +163,8 @@ const struct flash_info spi_nor_ids[] = {
{ INFO("n25q128a13",  0x20ba18, 0, 64 * 1024,  256, SECT_4K | 
SPI_NOR_QUAD_READ) },
{ INFO("n25q256a",0x20ba19, 0, 64 * 1024,  512, SECT_4K | 
SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ | SPI_NOR_4B_OPCODES) },
{ INFO("n25q256ax1",  0x20bb19, 0, 64 * 1024,  512, SECT_4K | 
SPI_NOR_QUAD_READ | SPI_NOR_4B_OPCODES) },
+   { INFO6("mt25qu512a",  0x20bb20, 0x104400, 64 * 1024, 1024,
+SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ) },
{ INFO("n25q512a",0x20bb20, 0, 64 * 1024, 1024, SECT_4K | USE_FSR | 
SPI_NOR_QUAD_READ | SPI_NOR_4B_OPCODES) },
{ INFO("n25q512ax3",  0x20ba20, 0, 64 * 1024, 1024, SECT_4K | USE_FSR | 
SPI_NOR_QUAD_READ | SPI_NOR_4B_OPCODES) },
{ INFO("n25q00",  0x20ba21, 0, 64 * 1024, 2048, SECT_4K | USE_FSR | 
SPI_NOR_QUAD_READ | NO_CHIP_ERASE) },
-- 
2.7.4

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH] mtd: spi: add spi flash id mt25qu512a

2019-05-10 Thread Vabhav Sharma
Add micron mt25qu512a flash description.

Signed-off-by: Ashish Kumar 
Signed-off-by: Pramod Kumar 
Signed-off-by: Vabhav Sharma 
---
 drivers/mtd/spi/spi-nor-ids.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/mtd/spi/spi-nor-ids.c b/drivers/mtd/spi/spi-nor-ids.c
index ec92976..eb5d49f 100644
--- a/drivers/mtd/spi/spi-nor-ids.c
+++ b/drivers/mtd/spi/spi-nor-ids.c
@@ -163,6 +163,8 @@ const struct flash_info spi_nor_ids[] = {
{ INFO("n25q128a13",  0x20ba18, 0, 64 * 1024,  256, SECT_4K | 
SPI_NOR_QUAD_READ) },
{ INFO("n25q256a",0x20ba19, 0, 64 * 1024,  512, SECT_4K | 
SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ | SPI_NOR_4B_OPCODES) },
{ INFO("n25q256ax1",  0x20bb19, 0, 64 * 1024,  512, SECT_4K | 
SPI_NOR_QUAD_READ | SPI_NOR_4B_OPCODES) },
+   { INFO("mt25qu512a",  0x20bb20, 0x104400, 64 * 1024, 1024,
+   SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ | SPI_NOR_4B_OPCODES) },
{ INFO("n25q512a",0x20bb20, 0, 64 * 1024, 1024, SECT_4K | USE_FSR | 
SPI_NOR_QUAD_READ | SPI_NOR_4B_OPCODES) },
{ INFO("n25q512ax3",  0x20ba20, 0, 64 * 1024, 1024, SECT_4K | USE_FSR | 
SPI_NOR_QUAD_READ | SPI_NOR_4B_OPCODES) },
{ INFO("n25q00",  0x20ba21, 0, 64 * 1024, 2048, SECT_4K | USE_FSR | 
SPI_NOR_QUAD_READ | NO_CHIP_ERASE) },
-- 
2.7.4

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH] armv8: ls1046afrwy: Add support for LS1046AFRWY platform

2019-05-09 Thread Vabhav Sharma
LS1046AFRWY board supports LS1046A family SoCs. This patch
add base support for this board.
Board support's 4GB ddr memory, i2c, micro-click module,microSD card,
serial console,qspi nor flash,ifc nand flash,qsgmii network interface,
usb 3.0 and serdes interface to support two x1gen3 pcie interface.

Signed-off-by: Camelia Groza 
Signed-off-by: Madalin Bucur 
Signed-off-by: Pankit Garg 
Signed-off-by: Pramod Kumar 
Signed-off-by: Rajesh Bhagat 
Signed-off-by: Vabhav Sharma 
---
 arch/arm/Kconfig   |  17 ++
 arch/arm/cpu/armv8/Kconfig |   1 +
 arch/arm/cpu/armv8/fsl-layerscape/ls1046a_serdes.c |   2 +
 arch/arm/dts/Makefile  |   1 +
 arch/arm/dts/fsl-ls1046a-frwy.dts  |  34 +++
 board/freescale/ls1046afrwy/Kconfig|  17 ++
 board/freescale/ls1046afrwy/MAINTAINERS|  17 ++
 board/freescale/ls1046afrwy/Makefile   |   9 +
 board/freescale/ls1046afrwy/README |  76 +++
 board/freescale/ls1046afrwy/ddr.c  |  24 ++
 board/freescale/ls1046afrwy/eth.c  | 114 ++
 board/freescale/ls1046afrwy/ls1046afrwy.c  | 249 +
 board/freescale/ls1046afrwy/ls1046afrwy_pbi.cfg|  22 ++
 .../freescale/ls1046afrwy/ls1046afrwy_qspi_pbi.cfg |  26 +++
 .../freescale/ls1046afrwy/ls1046afrwy_rcw_qspi.cfg |   7 +
 board/freescale/ls1046afrwy/ls1046afrwy_rcw_sd.cfg |   7 +
 configs/ls1046afrwy_tfa_defconfig  |  58 +
 include/configs/ls1046a_common.h   |  13 +-
 include/configs/ls1046afrwy.h  | 204 +
 include/fm_eth.h   |  12 +
 20 files changed, 908 insertions(+), 2 deletions(-)
 create mode 100644 arch/arm/dts/fsl-ls1046a-frwy.dts
 create mode 100644 board/freescale/ls1046afrwy/Kconfig
 create mode 100644 board/freescale/ls1046afrwy/MAINTAINERS
 create mode 100644 board/freescale/ls1046afrwy/Makefile
 create mode 100644 board/freescale/ls1046afrwy/README
 create mode 100644 board/freescale/ls1046afrwy/ddr.c
 create mode 100644 board/freescale/ls1046afrwy/eth.c
 create mode 100644 board/freescale/ls1046afrwy/ls1046afrwy.c
 create mode 100644 board/freescale/ls1046afrwy/ls1046afrwy_pbi.cfg
 create mode 100644 board/freescale/ls1046afrwy/ls1046afrwy_qspi_pbi.cfg
 create mode 100644 board/freescale/ls1046afrwy/ls1046afrwy_rcw_qspi.cfg
 create mode 100644 board/freescale/ls1046afrwy/ls1046afrwy_rcw_sd.cfg
 create mode 100644 configs/ls1046afrwy_tfa_defconfig
 create mode 100644 include/configs/ls1046afrwy.h

diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index f91c590..15699a2 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -1329,6 +1329,22 @@ config TARGET_LS1046ARDB
  development platform that supports the QorIQ LS1046A
  Layerscape Architecture processor.
 
+config TARGET_LS1046AFRWY
+   bool "Support ls1046afrwy"
+   select ARCH_LS1046A
+   select ARM64
+   select ARMV8_MULTIENTRY
+   select BOARD_EARLY_INIT_F
+   select BOARD_LATE_INIT
+   select DM_SPI_FLASH if DM_SPI
+   select POWER_MC34VR500
+   select SUPPORT_SPL
+   imply SCSI
+   help
+ Support for Freescale LS1046AFRWY platform.
+ The LS1046A Freeway Board (FRWY) is a high-performance
+ development platform that supports the QorIQ LS1046A
+ Layerscape Architecture processor.
 config TARGET_H2200
bool "Support h2200"
select CPU_PXA
@@ -1617,6 +1633,7 @@ source "board/freescale/ls1021aiot/Kconfig"
 source "board/freescale/ls1046aqds/Kconfig"
 source "board/freescale/ls1043ardb/Kconfig"
 source "board/freescale/ls1046ardb/Kconfig"
+source "board/freescale/ls1046afrwy/Kconfig"
 source "board/freescale/ls1012aqds/Kconfig"
 source "board/freescale/ls1012ardb/Kconfig"
 source "board/freescale/ls1012afrdm/Kconfig"
diff --git a/arch/arm/cpu/armv8/Kconfig b/arch/arm/cpu/armv8/Kconfig
index 7405c3a..ed31df1 100644
--- a/arch/arm/cpu/armv8/Kconfig
+++ b/arch/arm/cpu/armv8/Kconfig
@@ -106,6 +106,7 @@ config PSCI_RESET
   !TARGET_LS1012AFRWY && \
   !TARGET_LS1043ARDB && !TARGET_LS1043AQDS && \
   !TARGET_LS1046ARDB && !TARGET_LS1046AQDS && \
+  !TARGET_LS1046AFRWY && \
   !TARGET_LS2081ARDB && !TARGET_LX2160ARDB && \
   !TARGET_LX2160AQDS && \
   !ARCH_UNIPHIER && !TARGET_S32V234EVB
diff --git a/arch/arm/cpu/armv8/fsl-layerscape/ls1046a_serdes.c 
b/arch/arm/cpu/armv8/fsl-layerscape/ls1046a_serdes.c
index f8310f2..caa4862 100644
--- a/arch/arm/cpu/armv8/fsl-layerscape/ls1046a_serdes.c
+++ b/arch/arm/cpu/armv8/fsl-layerscape/ls1046a_serdes.c
@@ -1,6 +1,7 

Re: [U-Boot] [PATCH] drivers: serial: lpuart: Enable Little Endian Support

2019-04-18 Thread Vabhav Sharma
Hello Maintainers,
A gentle reminder to merge the changes.

Regards,
Vabhav

> -Original Message-
> From: Vabhav Sharma
> Sent: Thursday, January 31, 2019 5:38 PM
> To: u-boot@lists.denx.de; u-boot...@lists.denx.de
> Cc: Vabhav Sharma 
> Subject: [PATCH] drivers: serial: lpuart: Enable Little Endian Support
> 
> By default LPUART driver with compatible string "fsl,ls1021a-lpuart"
> support big-endian mode.On NXP SoC like LS1028A LPUART IP is little-
> endian,Added support to Fetch LPUART IP Endianness from lpuart device-
> tree node.
> 
> Signed-off-by: Vabhav Sharma 
> ---
>  drivers/serial/serial_lpuart.c | 4 
>  1 file changed, 4 insertions(+)
> 
> diff --git a/drivers/serial/serial_lpuart.c b/drivers/serial/serial_lpuart.c 
> index
> a357b00..57dd4a7 100644
> --- a/drivers/serial/serial_lpuart.c
> +++ b/drivers/serial/serial_lpuart.c
> @@ -1,5 +1,6 @@
>  // SPDX-License-Identifier: GPL-2.0+
>  /*
> + * Copyright 2019 NXP
>   * Copyright 2013 Freescale Semiconductor, Inc.
>   */
> 
> @@ -502,6 +503,9 @@ static int lpuart_serial_ofdata_to_platdata(struct
> udevice *dev)
>   plat->reg = (void *)addr;
>   plat->flags = dev_get_driver_data(dev);
> 
> + if (fdtdec_get_bool(blob, node, "little-endian"))
> + plat->flags &= ~LPUART_FLAG_REGMAP_ENDIAN_BIG;
> +
>   if (!fdt_node_check_compatible(blob, node, "fsl,ls1021a-lpuart"))
>   plat->devtype = DEV_LS1021A;
>   else if (!fdt_node_check_compatible(blob, node, "fsl,imx7ulp-
> lpuart"))
> --
> 2.7.4

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH] drivers: serial: lpuart: Enable Little Endian Support

2019-01-31 Thread Vabhav Sharma
By default LPUART driver with compatible string "fsl,ls1021a-lpuart"
support big-endian mode.On NXP SoC like LS1028A LPUART IP is
little-endian,Added support to Fetch LPUART IP Endianness from lpuart
device-tree node.

Signed-off-by: Vabhav Sharma 
---
 drivers/serial/serial_lpuart.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/drivers/serial/serial_lpuart.c b/drivers/serial/serial_lpuart.c
index a357b00..57dd4a7 100644
--- a/drivers/serial/serial_lpuart.c
+++ b/drivers/serial/serial_lpuart.c
@@ -1,5 +1,6 @@
 // SPDX-License-Identifier: GPL-2.0+
 /*
+ * Copyright 2019 NXP
  * Copyright 2013 Freescale Semiconductor, Inc.
  */
 
@@ -502,6 +503,9 @@ static int lpuart_serial_ofdata_to_platdata(struct udevice 
*dev)
plat->reg = (void *)addr;
plat->flags = dev_get_driver_data(dev);
 
+   if (fdtdec_get_bool(blob, node, "little-endian"))
+   plat->flags &= ~LPUART_FLAG_REGMAP_ENDIAN_BIG;
+
if (!fdt_node_check_compatible(blob, node, "fsl,ls1021a-lpuart"))
plat->devtype = DEV_LS1021A;
else if (!fdt_node_check_compatible(blob, node, "fsl,imx7ulp-lpuart"))
-- 
2.7.4

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH] drivers: serial: dm: Enable DM_FLAG_PRE_RELOC in SBSA pl011 uart driver

2019-01-30 Thread Vabhav Sharma
The DM_FLAG_PRE_RELOC shall be enabled in SBSA PL011 uart driver
as this driver is used in NXP based SoCs

It is necessary to have Serial console running before relocation

The !CONFIG_IS_ENABLED(OF_CONTROL) [*] check is set as "workaround"
for DM problem : 4687919684e

This flag is set if board does not support device-tree and using
platform data, In DM Model either of device tree or platform data
can be used to fetch device configuration

It is possible to use SBSA UART with CONFIG_DM_SERIAL but witout
corresponding device tree description (OF_CONTROL)

Other board/SoCs have this flag set unconditionally

Signed-off-by: Vabhav Sharma 
---
 drivers/serial/serial_pl01x.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/drivers/serial/serial_pl01x.c b/drivers/serial/serial_pl01x.c
index 12512f6..2a5f256 100644
--- a/drivers/serial/serial_pl01x.c
+++ b/drivers/serial/serial_pl01x.c
@@ -363,9 +363,7 @@ U_BOOT_DRIVER(serial_pl01x) = {
.platdata_auto_alloc_size = sizeof(struct pl01x_serial_platdata),
.probe = pl01x_serial_probe,
.ops= _serial_ops,
-#if !CONFIG_IS_ENABLED(OF_CONTROL)
.flags = DM_FLAG_PRE_RELOC,
-#endif
.priv_auto_alloc_size = sizeof(struct pl01x_priv),
 };
 
-- 
2.7.4

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [U-Boot-DM] [PATCH] drivers: serial: probe all serial devices

2018-11-02 Thread Vabhav Sharma


> -Original Message-
> From: Wolfgang Denk 
> Sent: Friday, October 26, 2018 4:57 PM
> To: Vabhav Sharma 
> Cc: Marek Vasut ; u-boot@lists.denx.de; u-boot-
> d...@lists.denx.de; s...@chromium.org; yamada.masah...@socionext.com;
> bmeng...@gmail.com
> Subject: Re: [U-Boot-DM] [PATCH] drivers: serial: probe all serial devices
> 
> Dear Vabhav,
> 
> In message
>  prod.outlook.com> you wrote:
> >
> > > U-Boot does lazy initialization intentionally.  It is wrong to
> > > initialize devices which are not actually used.
> 
> > There is configuration option to enable the device using platform data
> > or device tree using DM model.
> 
> "enable" means we have all required information needed to initialize them,
> if we need them.  The need arises only when someone wants to transfer
> data over that UART.  If nobody uses the UArt, there is no need to ever
> initialize it.
On u-boot, only one console is used
There is need to use multiple console for network firmware logging, linux boot
> 
> Lazy initialization is a good thing - it saves resources, especially memory 
> and
> time.  Think for example of boot time optimizations...
I understand
> 
> > For e.g: 2 UART controllers are enabled in device tree but DM model
> > initialized only one, This is limitation
> 
> In which way is this a limitation?  We use only one UART (for the serial
> console), so it works as supposed: only the used devices are fully 
> initialized.
Limitation for aforesaid example
> 
> 
> > My suggestion is to initialize all devices which are enabled, E.g.
> > use case is using UART1 for uboot consoled and UART2 for linux boot
> 
> What do you mean "for Linux boot"?  If Linux needs the UART, it will
> initialize it itself in the Linux dvice driver.
Example is PL011 UART linux driver which expect initialization(integer and 
fractional baud date) done by bootloader
> 
> > On NXP SoC, We also use UART3 for ethernet firmware logging but using
> > DM model all enabled devices are not probed  posing limitation.
> 
> Again, this is intentional, and not a limitation.
> 
> And what exactly do you mean by "UART3 for ethernet firmware logging"?
Different console than linux boot console.
> 
> Maybe you should rethink your software concept.  We don't want to have a
> zillion of ports in used if not really necessary.  Either you use standard
> channels (STDOUT, STDERR) for logging.  Also, there used to be a syslog
> compatible logging driver.
Agree
> 
> > > I have a feeling that you attempt to do the Wong Thing.
> 
> > I quoted the reason above and also discussed on in email(23 may) "
> > [U-Boot-DM] QUERY:U-boot DM:SERIAL:Multiple On-chip UART Controller
> > Support" with suggested solution from Simon which is sent as patch for
> > review.
> 
> But Simon also explained "U-Boot only probes things in a 'lazy'
> manner so far", and there should be really good reasons for deviating from
> this principle.  In no way should a "probe all devices" be made the default.
I see.
Not default and config will be selected as required 
Sent patch has config option
> 
> And Andreas also wrote how to solve this issue in a board-specific way if it 
> is
> really, really needed on some board.
> 
> However, you still fail to explain why you ned multiple serial ports in U-Boot
> running in parallel.
I am trying to convince you for the discussed problem faced recently in DM model
> 
> Best regards,
> 
> Wolfgang Denk
> 
> --
> DENX Software Engineering GmbH,  Managing Director: Wolfgang Denk
> HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
> Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: w...@denx.de
> Well, the way I see it, logic is only a way of being ignorant by num-
> bers. - Terry Pratchett, _Small Gods_
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] Feedback: Device probe during boot

2018-11-02 Thread Vabhav Sharma
Hello Maintainer/Owners,

Please provide your valuable input



Referring '[PATCH] drivers: serial: probe all serial devices' email regarding 
unified way to probe device during boot using DM model

I would like to take this thread forward and request your time to help identify 
the design framework

  1.  In dm_init(),
 *   Identify the class of devices to be probed
 *   Call dm_set_uclass_autoprobe(enum uclass_id, bool)
  2.  In core file on every device class
 *   uclass_next_device() to iterate through next device


There would be config option to choose probe all devices or not

Let me know your time if I can schedule skype session for further discussion



NOTE: Attaching previous threads discussed on this issue

Regards,

Vabhav

--- Begin Message ---
Vabhav, Simon,

On Wed, May 23, 2018 at 12:55:41PM -0600, Simon Glass wrote:
> Hi,
>
> On 23 May 2018 at 12:04, Simon Glass  wrote:
> > On 23 May 2018 at 11:56, Vabhav Sharma  wrote:
> >> Hello Everyone,
> >>
> >> I am working on integrating  generic PL011 driver in u-boot and linux for
>
> Note, it is 'U-Boot'
>
> >> ARMv8 NXP SoC and facing issue with multiple UART console enablement in
> >> u-boot using DM model
> >>
> >> Kindly provide your valuable feedback and experts comments.
> >>
> >>
> >>
> >> DTS require stdout-path(e.g-UART0) to the /chosen device tree node
> >> ,Accordingly controller(UART0) is probed/initialized as boot console
> >>
> >> On u-boot prompt, Bootargs is modified to use UART1(ttyAMA1) console for
> >> linux boot but kernel hangs after “Starting kernel ... print”
> >>
> >>
> >>
> >> After debugging it’s found that UART1 is not initialized and single(first)
> >> controller is  probed/initialized in u-boot (Irrespective of 4 UART nodes
> >> are enabled in dts)
> >>
> >> In drivers/serial/serial-uclass.c ,gd->cur_serial_dev is updated to the DT
> >> stdout-path or CONFIG_CONS_INDEX or platform data(first index)
> >>
> >>
> >>
> >> Does the u-boot DM model support only one or multiple UART driver
> >> probing/initialization? Is there any configuration parameter required to
> >> define number of UART controllers to be probed/initialized.
> >>
> >> This looks limitation as same boot console is used for u-boot and linux and
> >> unable to use all available UART controllers.
> >>
> >>
> >>
> >> I am new to u-boot and please correct any misunderstanding
> >>
> >> Let me know If I can submit a patch for multiple UART probe in 
> >> serial-uclass
> >> or open a bug for multiple UART support in u-boot DM model
>
> You can probe additional serial drivers if you like. U-Boot only
> probes things in a 'lazy' manner so far. Perhaps you could submit a
> patch which probes all serial devices? That is just a case of using
> uclass_first_device()...uclass_next_device() to iterate through them.
> I suppose we could have a CONFIG option to enable this.

That would indeed be useful. I was facing a similar issue of having to
initialize multiple UARTs, and ended up probing additional instances
manually from the board file using the respective DM functions
(unreleased code). Not pretty but it worked. I'll be happy to test such
a patch if created.


--
Andreas Dannenberg
Texas Instruments Inc



> >>
> >>
> >>
> >> PS:I am unable to find owner of serial uclass driver from MAINTAINERS file
>
> Not guilty but I did port a lot of things to driver model.
>
> >>
> >>
> >>
> >> Regards,
> >>
> >> Vabhav
> >>
> >>
>
> Regards,
> Simon
> ___
> U-Boot-DM mailing list
> u-boot...@lists.denx.de
> https://emea01.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.denx.de%2Flistinfo%2Fu-boot-dm=02%7C01%7Cvabhav.sharma%40nxp.com%7Ca10d407bc0024e9b962908d5c0df874c%7C686ea1d3bc2b4c6fa92cd99c5c301635%7C0%7C0%7C636626988663924872=smL6H9FguBogHLVE9DOAmn%2FxShMLydghC1029C9XBZY%3D=0
--- End Message ---
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [U-Boot-DM] [PATCH] drivers: serial: probe all serial devices

2018-10-25 Thread Vabhav Sharma


> -Original Message-
> From: Wolfgang Denk 
> Sent: Thursday, October 25, 2018 7:35 PM
> To: Vabhav Sharma 
> Cc: Marek Vasut ; u-boot@lists.denx.de; u-boot-
> d...@lists.denx.de; s...@chromium.org; yamada.masah...@socionext.com;
> bmeng...@gmail.com
> Subject: Re: [U-Boot-DM] [PATCH] drivers: serial: probe all serial devices
> 
> Dear Vabhav,
> 
> In message
>  prod.outlook.com> you wrote:
> >
> > > You can also use setenv stdin/stdout/stderr to alternate between
> > > stdio devices. So what is the problem ?
> > Problem is seen with PL011 driver using DM model, Only boot console
> baud rate is set.
> 
> U-Boot can talk to only one serial device at a time anyway, so why should it
> intiaalize othe rports than the one used for the (then
> current) console?
> 
> U-Boot does lazy initializationintentionally.  It is wrong to initialize 
> devices
> which are not actually used.
There is configuration option to enable the device using platform data or 
device tree using DM model.
For e.g: 2 UART controllers are enabled in device tree but DM model initialized 
only one, This is limitation
My suggestion is to initialize all devices which are enabled, E.g. use case is 
using UART1 for uboot consoled and UART2 for linux boot 
On NXP SoC, We also use UART3 for ethernet firmware logging but using DM model 
all enabled devices are not probed  posing limitation
> 
> > Tried modifying the environment variable but seems readonly  (## Error
> > inserting "stdout" variable, errno=22)
> 
> How exactly did you try to do that?
#editenv stdout
> 
> > Multiple UART enablement is required to use all console.
> 
> I have a feeling that you attempt to do the Wong Thing.
I quoted the reason above and also discussed on in email(23 may) " [U-Boot-DM] 
QUERY:U-boot DM:SERIAL:Multiple On-chip UART Controller Support" with suggested 
solution from Simon which is sent as patch for review.
Similar issue was faced by Andreas
> 
> Best regards,
> 
> Wolfgang Denk
> 
> --
> DENX Software Engineering GmbH,  Managing Director: Wolfgang Denk
> HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
> Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: w...@denx.de I
> am an atheist, thank God!
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH] drivers: serial: probe all serial devices

2018-10-25 Thread Vabhav Sharma


> -Original Message-
> From: s...@google.com  On Behalf Of Simon Glass
> Sent: Friday, October 19, 2018 8:56 AM
> To: Bin Meng 
> Cc: Vabhav Sharma ; U-Boot Mailing List  b...@lists.denx.de>; u-boot...@lists.denx.de; Andreas Dannenberg
> ; Masahiro Yamada
> ; Stefan Roese 
> Subject: Re: [PATCH] drivers: serial: probe all serial devices
> 
> Hi Bin,
> 
> On 15 October 2018 at 06:28, Bin Meng  wrote:
> > On Mon, Oct 15, 2018 at 8:15 PM Vabhav Sharma
>  wrote:
> >>
> >> Serial subsystem search and probe only one first serial device and
> >> unable to use remaining available UART devices
> >>
> >> This patch changes the logic to probe all available serial devices
> >> using platform data or device tree in DM model in order to use all
> >> UART devices
> >>
> >> Signed-off-by: Vabhav Sharma 
> >> ---
> >>  drivers/serial/Kconfig | 12 
> >>  drivers/serial/serial-uclass.c | 42
> >> ++
> >>  2 files changed, 54 insertions(+)
> >>
> >
> > Looks more and more devices have requirement to be probed during boot.
> > Guess we should handle such in a unified way?
> 
> How about:
> 
> - in dm_init(), after binding, we move on to an auto-probe step
> - a uclass flag indicates that all devices in that uclass must be probed  
> (that
> will be useful for PCI)
For devices class respective UCLASS to be provided with auto-probe, How many 
class to be included?
> 
> - a way to tell DM to probe all devices in a particular uclass (e.g. a call to
> dm_set_uclass_autoprobe(enum uclass_id, bool)
>   (that will be useful for this serial case)
Do you mean to verify and send patch for serial uclass with this approach after 
device_probe in dm_init
> 
> Regards,
> Simon
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [U-Boot-DM] [PATCH] drivers: serial: probe all serial devices

2018-10-25 Thread Vabhav Sharma
Hi Marek Vasut,
Apology for delayed reply, Occupied with other work

> -Original Message-
> From: Marek Vasut 
> Sent: Tuesday, October 16, 2018 2:39 PM
> To: Vabhav Sharma ; u-boot@lists.denx.de; u-
> boot...@lists.denx.de; s...@chromium.org
> Cc: yamada.masah...@socionext.com; bmeng...@gmail.com; Andreas
> Dannenberg 
> Subject: Re: [U-Boot-DM] [PATCH] drivers: serial: probe all serial devices
> 
> On 10/16/2018 09:20 AM, Vabhav Sharma wrote:
> >
> >
> >> -Original Message-
> >> From: Marek Vasut 
> >> Sent: Tuesday, October 16, 2018 12:29 PM
> >> To: Vabhav Sharma ; u-boot@lists.denx.de;
> >> u-boot- d...@lists.denx.de; s...@chromium.org
> >> Cc: yamada.masah...@socionext.com; bmeng...@gmail.com
> >> Subject: Re: [U-Boot-DM] [PATCH] drivers: serial: probe all serial
> >> devices
> >>
> >> On 10/15/2018 02:09 AM, Vabhav Sharma wrote:
> >>> Serial subsystem search and probe only one first serial device and
> >>> unable to use remaining available UART devices
> >>
> >> The serial devices are bound and you can switch to them. What is the
> >> real problem ?
> > Yes, I understand switch is possible with change in DTS or platform data for
> choosing UART device to be used as boot console(e.g. UART0) with gd-
> >cur_serial_dev is updated to chosen UART device.
> > The problem was stated in email(attached 23 may) " [U-Boot-DM]
> QUERY:U-boot DM:SERIAL:Multiple On-chip UART Controller Support" with
> suggested solution from Simon which is sent as patch for review.
> > Similar issue was faced by Andreas
> 
> You can also use setenv stdin/stdout/stderr to alternate between stdio
> devices. So what is the problem ?
Problem is seen with PL011 driver using DM model, Only boot console baud rate 
is set.
Tried modifying the environment variable but seems readonly  (## Error 
inserting "stdout" variable, errno=22)
Multiple UART enablement is required to use all console.
> 
> >>> This patch changes the logic to probe all available serial devices
> >>> using platform data or device tree in DM model in order to use all
> >>> UART devices
> >>
> >> Get rid of the ifdeffery and copied code please.
> > This is case for using uclass_next_device() to iterate through them, Having
> CONFIG option doesn't make it mandatory for every platform to probe all
> serial devices.
> 
> Is this also the case for having 6 copies of exactly the same code ? You can
> turn it into a function if needed.
Ok, I understand
> 
> >>> Signed-off-by: Vabhav Sharma 
> >>> ---
> >>>  drivers/serial/Kconfig | 12 
> >>>  drivers/serial/serial-uclass.c | 42
> >>> ++
> >>>  2 files changed, 54 insertions(+)
> >>>
> >>> diff --git a/drivers/serial/Kconfig b/drivers/serial/Kconfig index
> >>> 597db4b..d6451b1 100644
> >>> --- a/drivers/serial/Kconfig
> >>> +++ b/drivers/serial/Kconfig
> >>> @@ -133,6 +133,18 @@ config SERIAL_SEARCH_ALL
> >>>
> >>> If unsure, say N.
> >>>
> >>> +config SERIAL_PROBE_ALL
> >>> + bool "Probe all available serial devices"
> >>> + depends on DM_SERIAL
> >>> + help
> >>> +  The serial subsystem only probe for single serial device, but does
> >>> +  not probe for remaining available devices.
> >>> +  With this option set,we make probing for all available devices
> >>> +  mandatory.
> >>> +
> >>> +  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 e50f0aa..405e60e 100644
> >>> --- a/drivers/serial/serial-uclass.c
> >>> +++ b/drivers/serial/serial-uclass.c
> >>> @@ -82,6 +82,13 @@ static void serial_find_console_or_panic(void)
> >>>   uclass_first_device(UCLASS_SERIAL, );
> >>>   if (dev) {
> >>>   gd->cur_serial_dev = dev;
> >>> +#ifdef CONFIG_SERIAL_PROBE_ALL
> >>> + /* Scanning uclass to probe all devices */
> >>> + for (;
> >>> +

Re: [U-Boot] [PATCH] drivers: serial: probe all serial devices

2018-10-16 Thread Vabhav Sharma


> -Original Message-
> From: Bin Meng 
> Sent: Monday, October 15, 2018 5:58 PM
> To: Vabhav Sharma 
> Cc: U-Boot Mailing List ; u-boot...@lists.denx.de;
> Simon Glass ; dannenb...@ti.com; Masahiro Yamada
> ; Stefan Roese 
> Subject: Re: [PATCH] drivers: serial: probe all serial devices
> 
> On Mon, Oct 15, 2018 at 8:15 PM Vabhav Sharma 
> wrote:
> >
> > Serial subsystem search and probe only one first serial device and
> > unable to use remaining available UART devices
> >
> > This patch changes the logic to probe all available serial devices
> > using platform data or device tree in DM model in order to use all
> > UART devices
> >
> > Signed-off-by: Vabhav Sharma 
> > ---
> >  drivers/serial/Kconfig | 12 
> >  drivers/serial/serial-uclass.c | 42
> > ++
> >  2 files changed, 54 insertions(+)
> >
> 
> Looks more and more devices have requirement to be probed during boot.
> Guess we should handle such in a unified way?
I understand, For serial devices config is included to make it optional
Generic way might make it mandatory which also increase boot time.
> 
> Regards,
> Bin
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [U-Boot-DM] [PATCH] drivers: serial: probe all serial devices

2018-10-16 Thread Vabhav Sharma


> -Original Message-
> From: Marek Vasut 
> Sent: Tuesday, October 16, 2018 12:29 PM
> To: Vabhav Sharma ; u-boot@lists.denx.de; u-boot-
> d...@lists.denx.de; s...@chromium.org
> Cc: yamada.masah...@socionext.com; bmeng...@gmail.com
> Subject: Re: [U-Boot-DM] [PATCH] drivers: serial: probe all serial devices
> 
> On 10/15/2018 02:09 AM, Vabhav Sharma wrote:
> > Serial subsystem search and probe only one first serial device and
> > unable to use remaining available UART devices
> 
> The serial devices are bound and you can switch to them. What is the real
> problem ?
Yes, I understand switch is possible with change in DTS or platform data for 
choosing UART device to be used as boot console(e.g. UART0) with 
gd->cur_serial_dev is updated to chosen UART device.
The problem was stated in email(attached 23 may) " [U-Boot-DM] QUERY:U-boot 
DM:SERIAL:Multiple On-chip UART Controller Support" with suggested solution 
from Simon which is sent as patch for review.
Similar issue was faced by Andreas
> 
> > This patch changes the logic to probe all available serial devices
> > using platform data or device tree in DM model in order to use all
> > UART devices
> 
> Get rid of the ifdeffery and copied code please.
This is case for using uclass_next_device() to iterate through them, Having 
CONFIG option doesn't make it mandatory for every platform to probe all serial 
devices.
> 
> > Signed-off-by: Vabhav Sharma 
> > ---
> >  drivers/serial/Kconfig | 12 
> >  drivers/serial/serial-uclass.c | 42
> > ++
> >  2 files changed, 54 insertions(+)
> >
> > diff --git a/drivers/serial/Kconfig b/drivers/serial/Kconfig index
> > 597db4b..d6451b1 100644
> > --- a/drivers/serial/Kconfig
> > +++ b/drivers/serial/Kconfig
> > @@ -133,6 +133,18 @@ config SERIAL_SEARCH_ALL
> >
> >   If unsure, say N.
> >
> > +config SERIAL_PROBE_ALL
> > +   bool "Probe all available serial devices"
> > +   depends on DM_SERIAL
> > +   help
> > +The serial subsystem only probe for single serial device, but does
> > +not probe for remaining available devices.
> > +With this option set,we make probing for all available devices
> > +mandatory.
> > +
> > +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 e50f0aa..405e60e 100644
> > --- a/drivers/serial/serial-uclass.c
> > +++ b/drivers/serial/serial-uclass.c
> > @@ -82,6 +82,13 @@ static void serial_find_console_or_panic(void)
> > uclass_first_device(UCLASS_SERIAL, );
> > if (dev) {
> > gd->cur_serial_dev = dev;
> > +#ifdef CONFIG_SERIAL_PROBE_ALL
> > +   /* Scanning uclass to probe all devices */
> > +   for (;
> > +dev;
> > +uclass_next_device())
> > +   ;
> > +#endif
> > return;
> > }
> > } else if (CONFIG_IS_ENABLED(OF_CONTROL) && blob) { @@ -92,11
> +99,25
> > @@ static void serial_find_console_or_panic(void)
> > if (np
> && !uclass_get_device_by_ofnode(UCLASS_SERIAL,
> > np_to_ofnode(np), )) {
> > gd->cur_serial_dev = dev;
> > +#ifdef CONFIG_SERIAL_PROBE_ALL
> > +   /* Scanning uclass to probe all devices */
> > +   for (;
> > +dev;
> > +uclass_next_device())
> > +   ;
> > +#endif
> > return;
> > }
> > } else {
> > if (!serial_check_stdout(blob, )) {
> > gd->cur_serial_dev = dev;
> > +#ifdef CONFIG_SERIAL_PROBE_ALL
> > +   /* Scanning uclass to probe all devices */
> > +   for (;
> > +dev;
> > +uclass_next_device())
> > +   ;
> > +#endif
> >

[U-Boot] [PATCH] drivers: serial: probe all serial devices

2018-10-15 Thread Vabhav Sharma
Serial subsystem search and probe only one first serial
device and unable to use remaining available UART devices

This patch changes the logic to probe all available serial devices
using platform data or device tree in DM model in order to use all
UART devices

Signed-off-by: Vabhav Sharma 
---
 drivers/serial/Kconfig | 12 
 drivers/serial/serial-uclass.c | 42 ++
 2 files changed, 54 insertions(+)

diff --git a/drivers/serial/Kconfig b/drivers/serial/Kconfig
index 597db4b..d6451b1 100644
--- a/drivers/serial/Kconfig
+++ b/drivers/serial/Kconfig
@@ -133,6 +133,18 @@ config SERIAL_SEARCH_ALL
 
  If unsure, say N.
 
+config SERIAL_PROBE_ALL
+   bool "Probe all available serial devices"
+   depends on DM_SERIAL
+   help
+The serial subsystem only probe for single serial device, but does
+not probe for remaining available devices.
+With this option set,we make probing for all available devices
+mandatory.
+
+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 e50f0aa..405e60e 100644
--- a/drivers/serial/serial-uclass.c
+++ b/drivers/serial/serial-uclass.c
@@ -82,6 +82,13 @@ static void serial_find_console_or_panic(void)
uclass_first_device(UCLASS_SERIAL, );
if (dev) {
gd->cur_serial_dev = dev;
+#ifdef CONFIG_SERIAL_PROBE_ALL
+   /* Scanning uclass to probe all devices */
+   for (;
+dev;
+uclass_next_device())
+   ;
+#endif
return;
}
} else if (CONFIG_IS_ENABLED(OF_CONTROL) && blob) {
@@ -92,11 +99,25 @@ static void serial_find_console_or_panic(void)
if (np && !uclass_get_device_by_ofnode(UCLASS_SERIAL,
np_to_ofnode(np), )) {
gd->cur_serial_dev = dev;
+#ifdef CONFIG_SERIAL_PROBE_ALL
+   /* Scanning uclass to probe all devices */
+   for (;
+dev;
+uclass_next_device())
+   ;
+#endif
return;
}
} else {
if (!serial_check_stdout(blob, )) {
gd->cur_serial_dev = dev;
+#ifdef CONFIG_SERIAL_PROBE_ALL
+   /* Scanning uclass to probe all devices */
+   for (;
+dev;
+uclass_next_device())
+   ;
+#endif
return;
}
}
@@ -121,6 +142,13 @@ static void serial_find_console_or_panic(void)
!uclass_get_device(UCLASS_SERIAL, INDEX, )) {
if (dev->flags & DM_FLAG_ACTIVATED) {
gd->cur_serial_dev = dev;
+#ifdef CONFIG_SERIAL_PROBE_ALL
+   /* Scanning uclass to probe all devices */
+   for (;
+dev;
+uclass_next_device())
+   ;
+#endif
return;
}
}
@@ -132,6 +160,13 @@ static void serial_find_console_or_panic(void)
if (!ret) {
/* Device did succeed probing */
gd->cur_serial_dev = dev;
+#ifdef CONFIG_SERIAL_PROBE_ALL
+   /* Scanning uclass to probe all devices */
+   for (;
+dev;
+uclass_next_device())
+   ;
+#endif
return;
}
}
@@ -140,6 +175,13 @@ static void serial_find_console_or_panic(void)
!uclass_get_device(UCLASS_SERIAL, INDEX, ) ||
(!uclass_first_device(UCLASS_SERIAL, ) && dev)) {
gd->cur_serial_dev = dev;
+#ifdef CONFIG_SERIAL_PROBE_ALL
+   /* Scanning uclass to probe all devices */
+   for (;
+dev;
+uclass_next_device())
+