dm: core: drivers: add function uclass_probe_all()
v5 cover dm: core: drivers: add function uclass_probe_all()
From: Vabhav Sharma <[email protected]>
- 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(+)
Signature · 1 line
2.7.4
PATCH v5 1/2 dm: core: add function uclass_probe_all() to probe all devices
From: Vabhav Sharma <[email protected]>
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.
--
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.sharma at oss.nxp.com/
--- drivers/core/uclass.c | 19 +++++++++++++++++++ include/dm/uclass.h | 11 +++++++++++ 2 files changed, 30 insertions(+)
drivers/core/uclass.c +19 -0
@@ -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, &dev); +if (ret || !dev) +return ret; + +/* Scanning uclass to probe all devices */ +while (dev) { + ret =uclass_next_device (&dev); +if (ret) +return ret; + } + +return 0 ; +} +UCLASS_DRIVER (nop) = { .id =UCLASS_NOP , .name ="nop" ,
include/dm/uclass.h +11 -0
@@ -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
Signature · 1 line
2.7.4
PATCH v5 1/2 dm: core: add function uclass_probe_all() to probe all devices
Quoted 81 lines · Vabhav Sharma
From: Vabhav Sharma <[email protected]>
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 <[email protected]>Reviewed-by Stefan Roese <[email protected]>Reviewed-by Simon Glass <[email protected]>--
v5:
Incorporated review comments of Sean Anderson
Replace for loop with while loop
Error check added
Function description updatedv4:
Incorporated review comments of Simon
Removed if (dev).. conditional checkv3:
Incorporated review comments of Stephan,Simon
Related discussion https://patchwork.ozlabs.org/project/uboot/patch/1601400
385-11854-1-git-send-email-vabhav.sharma at oss.nxp.com/--- drivers/core/uclass.c | 19 +++++++++++++++++++ include/dm/uclass.h | 11 +++++++++++ 2 files changed, 30 insertions(+)drivers/core/uclass.c +19
-0@@ -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, &dev); +if (ret || !dev) +return ret; + +/* Scanning uclass to probe all devices */ +while (dev) { + ret =uclass_next_device (&dev); +if (ret) +return ret; + } + +return 0 ; +} +UCLASS_DRIVER (nop) = { .id =UCLASS_NOP , .name ="nop" ,include/dm/uclass.h +4
-0@@ -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.
include/dm/uclass.h int uclass_first_device_drvdata(enum uclass_id id, ulong driver_data, · line 397
Quoted 10 lines
include/dm/uclass.h +7
-0+* +* @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
PATCH v5 1/2 dm: core: add function uclass_probe_all() to probe all devices
In reply to Vabhav SharmaQuoted 13 lines · Vabhav Sharma
From: Vabhav Sharma <[email protected]>
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.
Quoted 6 lines
The feature is enabled with
CONFIG_DM.Signed-off-by Vabhav Sharma <[email protected]>Reviewed-by Stefan Roese <[email protected]>Reviewed-by Simon Glass <[email protected]>Reviewed-by Sean Anderson <[email protected]>
Applied to u-boot/master, thanks!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 659 bytes Desc: not available URL: <https://lists.denx.de/pipermail/u-boot/attachments/20210118/ee113752/attachment.sig>
PATCH v5 2/2 drivers: serial: probe all uart devices
In reply to Vabhav SharmaFrom: Vabhav Sharma <[email protected]>
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.
--
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(+)
drivers/serial/Kconfig +16 -0
@@ -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
drivers/serial/serial-uclass.c +9 -0
@@ -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 (); }
Signature · 1 line
2.7.4
PATCH v5 2/2 drivers: serial: probe all uart devices
Quoted 53 lines · Vabhav Sharma
From: Vabhav Sharma <[email protected]>
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 <[email protected]>Reviewed-by Stefan Roese <[email protected]>Reviewed-by Simon Glass <[email protected]>--
v5:
Incorporated review comments from Sean Anderson
- Modified the macro description
- Added error checkv3:
Incorporated Simon and Stephan review comment
- Define generic functionuclass_probe_all(enum uclass_id)
indrivers/core/uclass.c
- Added the function in caller ofserial_find_console_or_panic()
- Removed repeated sequence with generic function calluclass_probe_all()
- Dependent on other patch [PATCH] dm: core: add functionuclass_probe_all()to probe all devicesv2:
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(+)drivers/serial/Kconfig +2
-0@@ -134,6 +134,22 @@ config SERIAL_SEARCH_ALL If unsure, say N. +config SERIAL_PROBE_ALL + bool "Probe all available serial devices"
drivers/serial/Kconfig config SERIAL_SEARCH_ALL · line 148
Quoted 10 lines
drivers/serial/Kconfig +10
-0+ 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
Nit: "and" or "to" but not both
Quoted 17 lines
drivers/serial/Kconfig +4
-0+ 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_DMdrivers/serial/serial-uclass.c +2
-0@@ -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 )) {
drivers/serial/serial-uclass.c int serial_init(void) · line 186
Quoted 10 lines
drivers/serial/serial-uclass.c +7
-0+int ret; + + ret =uclass_probe_all (UCLASS_SERIAL ); +if (ret) +return ret; + } +return serial_init (); }
PATCH v5 2/2 drivers: serial: probe all uart devices
In reply to Vabhav SharmaQuoted 14 lines · Vabhav Sharma
From: Vabhav Sharma <[email protected]>
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.
Quoted 7 lines
Adding support to probe all enabled serial devices like SBSA compliant PL011 UART ports probe and initialization by firmware.
Signed-off-by Vabhav Sharma <[email protected]>Reviewed-by Stefan Roese <[email protected]>Reviewed-by Simon Glass <[email protected]>Reviewed-by Sean Anderson <[email protected]>
Applied to u-boot/master, thanks!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 659 bytes Desc: not available URL: <https://lists.denx.de/pipermail/u-boot/attachments/20210118/116eb41b/attachment.sig>
v5 cover dm: core: drivers: add function uclass_probe_all()
In reply to Vabhav SharmaDear Sean Anderson,
I have incorporated all your review comments and request your review/ack to merge the changes
Regards,
Vabhav
Quoted 48 lines
-----Original Message-----
From: Vabhav Sharma <[email protected]>
Sent: Wednesday, December 9, 2020 10:42 AM
To: sjg at chromium.org; sr at denx.de; seanga2 at gmail.com
Cc: u-boot at lists.denx.de; Varun Sethi <[email protected]>; andre.przywara at arm.com; Vabhav Sharma <[email protected]>
Subject: [PATCH v5 0/2] dm: core: drivers: add functionuclass_probe_all()From: Vabhav Sharma <[email protected]>
- Add common method to probe devices belonging to same uclass
- Add config in serial uclass to support optional inclusion ofuclass_probe_all
- Enable support for available serial devices probeChanges for v5:
Incorporated review comments from Sean Anderson
- Added error check
- Replacedfor()loop withwhile()loop
- Updated macro description
- Modified function descriptionChanges for v4:
Incorporated review comments from Simon
- Removed if (dev).. conditional check in functionuclass_probe_all()Changes for v3:
Incorporated Simon and Stephan review comment
- Define generic functionuclass_probe_all(enum uclass_id)
indrivers/core/uclass.c
- Added the function in caller ofserial_find_console_or_panic()
- Removed repeated sequence with generic function calluclass_probe_all()Changes for v2:
Incorporated Stefan review comment,Update #ifdef with macro if
(IS_ENABLED).Vabhav Sharma (2):
dm: core: add functionuclass_probe_all()to probe all devices
drivers: serial: probe all uart devicesdrivers/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