diff options
author | Vabhav Sharma <vabhav.sharma@nxp.com> | 2020-12-09 08:12:03 +0300 |
---|---|---|
committer | Tom Rini <trini@konsulko.com> | 2021-01-16 22:49:09 +0300 |
commit | a59153dfebb065663fef64827e73aa771c683960 (patch) | |
tree | 9f4334fb344de2b086001ecdbebdd054d4008a8d /drivers/core/uclass.c | |
parent | 449efce69a7b7aa5d399d750a5ed12273d0ca851 (diff) | |
download | u-boot-a59153dfebb065663fef64827e73aa771c683960.tar.xz |
dm: core: add function uclass_probe_all() to probe all devices
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 <vabhav.sharma@nxp.com>
Reviewed-by: Stefan Roese <sr@denx.de>
Reviewed-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Sean Anderson <seanga2@gmail.com>
Diffstat (limited to 'drivers/core/uclass.c')
-rw-r--r-- | drivers/core/uclass.c | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/drivers/core/uclass.c b/drivers/core/uclass.c index cdb975d5b3..f38122d54b 100644 --- a/drivers/core/uclass.c +++ b/drivers/core/uclass.c @@ -757,6 +757,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", |