[U-Boot] [UBOOT PATCH 0/2] dm: core: Scan "/firmware" node by default

All Linux firmware drivers are put under "/firmware" node and it has support to populate "/firmware" node by default.
u-boot and Linux can share same DTB. In this case, driver probe for devices under "/firmware" will not be invoked as "/firmware" does not have its own "compatible" property.
This patch series scans "/firmware" node by default like "/clocks". To avoid duplication of code, first patch moves, node scan code into separate function.
Rajan Vaja (2): dm: core: Move "/clock" node scan into function dm: core: Scan "/firmware" node by default
drivers/core/root.c | 35 ++++++++++++++++++++++------------- 1 file changed, 22 insertions(+), 13 deletions(-)

Create separate function for scanning node by path and move "/clock" node scan code into that function.
This will be usable if scanning of more node is required.
Signed-off-by: Rajan Vaja rajan.vaja@xilinx.com --- drivers/core/root.c | 33 ++++++++++++++++++--------------- 1 file changed, 18 insertions(+), 15 deletions(-)
diff --git a/drivers/core/root.c b/drivers/core/root.c index 72bcc7d..1ab4c38 100644 --- a/drivers/core/root.c +++ b/drivers/core/root.c @@ -330,10 +330,25 @@ static int dm_scan_fdt_node(struct udevice *parent, const void *blob, } #endif
+static int dm_scan_fdt_ofnode_path(const char *path, bool pre_reloc_only) +{ + ofnode node; + + node = ofnode_path(path); + if (!ofnode_valid(node)) + return 0; + +#if CONFIG_IS_ENABLED(OF_LIVE) + if (of_live_active()) + return dm_scan_fdt_live(gd->dm_root, node.np, pre_reloc_only); +#endif + return dm_scan_fdt_node(gd->dm_root, gd->fdt_blob, node.of_offset, + pre_reloc_only); +} + int dm_extended_scan_fdt(const void *blob, bool pre_reloc_only) { int ret; - ofnode node;
ret = dm_scan_fdt(gd->fdt_blob, pre_reloc_only); if (ret) { @@ -341,21 +356,9 @@ int dm_extended_scan_fdt(const void *blob, bool pre_reloc_only) return ret; }
- /* bind fixed-clock */ - node = ofnode_path("/clocks"); - /* if no DT "clocks" node, no need to go further */ - if (!ofnode_valid(node)) - return ret; - -#if CONFIG_IS_ENABLED(OF_LIVE) - if (of_live_active()) - ret = dm_scan_fdt_live(gd->dm_root, node.np, pre_reloc_only); - else -#endif - ret = dm_scan_fdt_node(gd->dm_root, gd->fdt_blob, node.of_offset, - pre_reloc_only); + ret = dm_scan_fdt_ofnode_path("/clocks", pre_reloc_only); if (ret) - debug("dm_scan_fdt_node() failed: %d\n", ret); + debug("scan for /clocks failed: %d\n", ret);
return ret; }

On 10 August 2018 at 02:45, Rajan Vaja rajan.vaja@xilinx.com wrote:
Create separate function for scanning node by path and move "/clock" node scan code into that function.
This will be usable if scanning of more node is required.
Signed-off-by: Rajan Vaja rajan.vaja@xilinx.com
drivers/core/root.c | 33 ++++++++++++++++++--------------- 1 file changed, 18 insertions(+), 15 deletions(-)
Reviewed-by: Simon Glass sjg@chromium.org

All Linux firmware drivers are put under "/firmware" node and it has support to populate "/firmware" node by default.
u-boot and Linux can share same DTB. In this case, driver probe for devices under "/firmware" will not be invoked as "/firmware" does not have its own "compatible" property.
This patch scans "/firmware" node by default like "/clocks".
Signed-off-by: Rajan Vaja rajan.vaja@xilinx.com --- drivers/core/root.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/drivers/core/root.c b/drivers/core/root.c index 1ab4c38..47d10b8 100644 --- a/drivers/core/root.c +++ b/drivers/core/root.c @@ -357,8 +357,14 @@ int dm_extended_scan_fdt(const void *blob, bool pre_reloc_only) }
ret = dm_scan_fdt_ofnode_path("/clocks", pre_reloc_only); - if (ret) + if (ret) { debug("scan for /clocks failed: %d\n", ret); + return ret; + } + + ret = dm_scan_fdt_ofnode_path("/firmware", pre_reloc_only); + if (ret) + debug("scan for /firmware failed: %d\n", ret);
return ret; }

On 10 August 2018 at 02:45, Rajan Vaja rajan.vaja@xilinx.com wrote:
All Linux firmware drivers are put under "/firmware" node and it has support to populate "/firmware" node by default.
u-boot and Linux can share same DTB. In this case, driver probe for devices under "/firmware" will not be invoked as "/firmware" does not have its own "compatible" property.
This patch scans "/firmware" node by default like "/clocks".
Signed-off-by: Rajan Vaja rajan.vaja@xilinx.com
drivers/core/root.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
Reviewed-by: Simon Glass sjg@chromium.org
We should add a firmware device for sandbox.

On 17.8.2018 14:49, Simon Glass wrote:
On 10 August 2018 at 02:45, Rajan Vaja rajan.vaja@xilinx.com wrote:
All Linux firmware drivers are put under "/firmware" node and it has support to populate "/firmware" node by default.
u-boot and Linux can share same DTB. In this case, driver probe for devices under "/firmware" will not be invoked as "/firmware" does not have its own "compatible" property.
This patch scans "/firmware" node by default like "/clocks".
Signed-off-by: Rajan Vaja rajan.vaja@xilinx.com
drivers/core/root.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
Reviewed-by: Simon Glass sjg@chromium.org
We should add a firmware device for sandbox.
what to add there?
M

Hi Michael,
On 17 August 2018 at 07:22, Michal Simek michal.simek@xilinx.com wrote:
On 17.8.2018 14:49, Simon Glass wrote:
On 10 August 2018 at 02:45, Rajan Vaja rajan.vaja@xilinx.com wrote:
All Linux firmware drivers are put under "/firmware" node and it has support to populate "/firmware" node by default.
u-boot and Linux can share same DTB. In this case, driver probe for devices under "/firmware" will not be invoked as "/firmware" does not have its own "compatible" property.
This patch scans "/firmware" node by default like "/clocks".
Signed-off-by: Rajan Vaja rajan.vaja@xilinx.com
drivers/core/root.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
Reviewed-by: Simon Glass sjg@chromium.org
We should add a firmware device for sandbox.
what to add there?
It can be any device, but I suggest something simple like a demo-shape? Then you can check that it is accessible in a test in test/dm/core.c, perhaps.
Regards, Simon

On 17.8.2018 20:03, Simon Glass wrote:
Hi Michael,
On 17 August 2018 at 07:22, Michal Simek michal.simek@xilinx.com wrote:
On 17.8.2018 14:49, Simon Glass wrote:
On 10 August 2018 at 02:45, Rajan Vaja rajan.vaja@xilinx.com wrote:
All Linux firmware drivers are put under "/firmware" node and it has support to populate "/firmware" node by default.
u-boot and Linux can share same DTB. In this case, driver probe for devices under "/firmware" will not be invoked as "/firmware" does not have its own "compatible" property.
This patch scans "/firmware" node by default like "/clocks".
Signed-off-by: Rajan Vaja rajan.vaja@xilinx.com
drivers/core/root.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
Reviewed-by: Simon Glass sjg@chromium.org
We should add a firmware device for sandbox.
what to add there?
It can be any device, but I suggest something simple like a demo-shape? Then you can check that it is accessible in a test in test/dm/core.c, perhaps.
Rajan: please take a look at it.
Thanks, Michal

Hi Simon,
On 10.8.2018 10:45, Rajan Vaja wrote:
All Linux firmware drivers are put under "/firmware" node and it has support to populate "/firmware" node by default.
u-boot and Linux can share same DTB. In this case, driver probe for devices under "/firmware" will not be invoked as "/firmware" does not have its own "compatible" property.
This patch series scans "/firmware" node by default like "/clocks". To avoid duplication of code, first patch moves, node scan code into separate function.
Rajan Vaja (2): dm: core: Move "/clock" node scan into function dm: core: Scan "/firmware" node by default
drivers/core/root.c | 35 ++++++++++++++++++++++------------- 1 file changed, 22 insertions(+), 13 deletions(-)
This patch is done based on acked binding https://lkml.org/lkml/2018/8/3/683 and https://lkml.org/lkml/2018/8/3/684
where clock driver is child of firmware node.
Can you please look at these 2 patches?
Thanks, Michal

All Linux firmware drivers are put under "/firmware" node and it has support to populate "/firmware" node by default.
u-boot and Linux can share same DTB. In this case, driver probe for devices under "/firmware" will not be invoked as "/firmware" does not have its own "compatible" property.
This patch series scans "/firmware" node by default like "/clocks". To avoid duplication of code, first patch moves, node scan code into separate function.
This series also test to make sure "/firmware" nodes are scanned properly.
Rajan Vaja (4): firmware: Add FIRMWARE config prompt string dm: core: Move "/clock" node scan into function dm: core: Scan "/firmware" node by default dm: test: Add "/firmware" node scan test
arch/sandbox/dts/test.dts | 7 +++++++ drivers/core/root.c | 35 ++++++++++++++++++++++------------- drivers/firmware/Kconfig | 2 +- drivers/firmware/Makefile | 1 + drivers/firmware/firmware-sandbox.c | 20 ++++++++++++++++++++ test/dm/Makefile | 1 + test/dm/firmware.c | 22 ++++++++++++++++++++++ 7 files changed, 74 insertions(+), 14 deletions(-) create mode 100644 drivers/firmware/firmware-sandbox.c create mode 100644 test/dm/firmware.c

There is no prompt string for FIRMWARE config. Without this, FIRMWARE config cannot be enabled through menuconfing or config file. Fix this by adding prompt summary.
Signed-off-by: Rajan Vaja rajan.vaja@xilinx.com --- Changes in v2: * New patch --- drivers/firmware/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/firmware/Kconfig b/drivers/firmware/Kconfig index cb73b70..feaea81 100644 --- a/drivers/firmware/Kconfig +++ b/drivers/firmware/Kconfig @@ -1,5 +1,5 @@ config FIRMWARE - bool + bool "Enable Firmware driver support"
config ARM_PSCI_FW bool

On 19 September 2018 at 04:43, Rajan Vaja rajan.vaja@xilinx.com wrote:
There is no prompt string for FIRMWARE config. Without this, FIRMWARE config cannot be enabled through menuconfing or config file. Fix this by adding prompt summary.
Signed-off-by: Rajan Vaja rajan.vaja@xilinx.com
Changes in v2:
- New patch
drivers/firmware/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Reviewed-by: Simon Glass sjg@chromium.org

On 25 September 2018 at 22:41, Simon Glass sjg@chromium.org wrote:
On 19 September 2018 at 04:43, Rajan Vaja rajan.vaja@xilinx.com wrote:
There is no prompt string for FIRMWARE config. Without this, FIRMWARE config cannot be enabled through menuconfing or config file. Fix this by adding prompt summary.
Signed-off-by: Rajan Vaja rajan.vaja@xilinx.com
Changes in v2:
- New patch
drivers/firmware/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Reviewed-by: Simon Glass sjg@chromium.org
Applied to u-boot-dm, and now in mainline, thanks!

Create separate function for scanning node by path and move "/clock" node scan code into that function.
This will be usable if scanning of more node is required.
Signed-off-by: Rajan Vaja rajan.vaja@xilinx.com Reviewed-by: Simon Glass sjg@chromium.org --- Changes in v2: * None --- drivers/core/root.c | 33 ++++++++++++++++++--------------- 1 file changed, 18 insertions(+), 15 deletions(-)
diff --git a/drivers/core/root.c b/drivers/core/root.c index 72bcc7d..1ab4c38 100644 --- a/drivers/core/root.c +++ b/drivers/core/root.c @@ -330,10 +330,25 @@ static int dm_scan_fdt_node(struct udevice *parent, const void *blob, } #endif
+static int dm_scan_fdt_ofnode_path(const char *path, bool pre_reloc_only) +{ + ofnode node; + + node = ofnode_path(path); + if (!ofnode_valid(node)) + return 0; + +#if CONFIG_IS_ENABLED(OF_LIVE) + if (of_live_active()) + return dm_scan_fdt_live(gd->dm_root, node.np, pre_reloc_only); +#endif + return dm_scan_fdt_node(gd->dm_root, gd->fdt_blob, node.of_offset, + pre_reloc_only); +} + int dm_extended_scan_fdt(const void *blob, bool pre_reloc_only) { int ret; - ofnode node;
ret = dm_scan_fdt(gd->fdt_blob, pre_reloc_only); if (ret) { @@ -341,21 +356,9 @@ int dm_extended_scan_fdt(const void *blob, bool pre_reloc_only) return ret; }
- /* bind fixed-clock */ - node = ofnode_path("/clocks"); - /* if no DT "clocks" node, no need to go further */ - if (!ofnode_valid(node)) - return ret; - -#if CONFIG_IS_ENABLED(OF_LIVE) - if (of_live_active()) - ret = dm_scan_fdt_live(gd->dm_root, node.np, pre_reloc_only); - else -#endif - ret = dm_scan_fdt_node(gd->dm_root, gd->fdt_blob, node.of_offset, - pre_reloc_only); + ret = dm_scan_fdt_ofnode_path("/clocks", pre_reloc_only); if (ret) - debug("dm_scan_fdt_node() failed: %d\n", ret); + debug("scan for /clocks failed: %d\n", ret);
return ret; }

On 19 September 2018 at 03:43, Rajan Vaja rajan.vaja@xilinx.com wrote:
Create separate function for scanning node by path and move "/clock" node scan code into that function.
This will be usable if scanning of more node is required.
Signed-off-by: Rajan Vaja rajan.vaja@xilinx.com Reviewed-by: Simon Glass sjg@chromium.org
Changes in v2:
- None
drivers/core/root.c | 33 ++++++++++++++++++--------------- 1 file changed, 18 insertions(+), 15 deletions(-)
Applied to u-boot-dm, and now in mainline, thanks!

All Linux firmware drivers are put under "/firmware" node and it has support to populate "/firmware" node by default.
u-boot and Linux can share same DTB. In this case, driver probe for devices under "/firmware" will not be invoked as "/firmware" does not have its own "compatible" property.
This patch scans "/firmware" node by default like "/clocks".
Signed-off-by: Rajan Vaja rajan.vaja@xilinx.com Reviewed-by: Simon Glass sjg@chromium.org --- Changes in v2: * None --- drivers/core/root.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/drivers/core/root.c b/drivers/core/root.c index 1ab4c38..47d10b8 100644 --- a/drivers/core/root.c +++ b/drivers/core/root.c @@ -357,8 +357,14 @@ int dm_extended_scan_fdt(const void *blob, bool pre_reloc_only) }
ret = dm_scan_fdt_ofnode_path("/clocks", pre_reloc_only); - if (ret) + if (ret) { debug("scan for /clocks failed: %d\n", ret); + return ret; + } + + ret = dm_scan_fdt_ofnode_path("/firmware", pre_reloc_only); + if (ret) + debug("scan for /firmware failed: %d\n", ret);
return ret; }

Add a test which verifies that all subnodes under "/firmware" nodes are scanned.
Signed-off-by: Rajan Vaja rajan.vaja@xilinx.com --- Changes in v2: * New patch --- arch/sandbox/dts/test.dts | 7 +++++++ drivers/firmware/Makefile | 1 + drivers/firmware/firmware-sandbox.c | 20 ++++++++++++++++++++ test/dm/Makefile | 1 + test/dm/firmware.c | 22 ++++++++++++++++++++++ 5 files changed, 51 insertions(+) create mode 100644 drivers/firmware/firmware-sandbox.c create mode 100644 test/dm/firmware.c
diff --git a/arch/sandbox/dts/test.dts b/arch/sandbox/dts/test.dts index 3668263..94c603a 100644 --- a/arch/sandbox/dts/test.dts +++ b/arch/sandbox/dts/test.dts @@ -630,6 +630,13 @@ }; }; }; + + firmware { + sandbox_firmware: sandbox-firmware { + compatible = "sandbox,firmware"; + }; + }; + };
#include "sandbox_pmic.dtsi" diff --git a/drivers/firmware/Makefile b/drivers/firmware/Makefile index 1cdda14..6cb8358 100644 --- a/drivers/firmware/Makefile +++ b/drivers/firmware/Makefile @@ -1,3 +1,4 @@ obj-$(CONFIG_FIRMWARE) += firmware-uclass.o obj-$(CONFIG_ARM_PSCI_FW) += psci.o obj-$(CONFIG_TI_SCI_PROTOCOL) += ti_sci.o +obj-$(CONFIG_SANDBOX) += firmware-sandbox.o diff --git a/drivers/firmware/firmware-sandbox.c b/drivers/firmware/firmware-sandbox.c new file mode 100644 index 0000000..d970d75 --- /dev/null +++ b/drivers/firmware/firmware-sandbox.c @@ -0,0 +1,20 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * sandbox firmware driver + * + * Copyright (C) 2018 Xilinx, Inc. + */ + +#include <common.h> +#include <dm.h> + +static const struct udevice_id generic_sandbox_firmware_ids[] = { + { .compatible = "sandbox,firmware" }, + { } +}; + +U_BOOT_DRIVER(sandbox_firmware) = { + .name = "sandbox_firmware", + .id = UCLASS_FIRMWARE, + .of_match = generic_sandbox_firmware_ids, +}; diff --git a/test/dm/Makefile b/test/dm/Makefile index 3f5a634..3f54710 100644 --- a/test/dm/Makefile +++ b/test/dm/Makefile @@ -47,4 +47,5 @@ obj-$(CONFIG_WDT) += wdt.o obj-$(CONFIG_AXI) += axi.o obj-$(CONFIG_MISC) += misc.o obj-$(CONFIG_DM_SERIAL) += serial.o +obj-$(CONFIG_FIRMWARE) += firmware.o endif diff --git a/test/dm/firmware.c b/test/dm/firmware.c new file mode 100644 index 0000000..60fdcbb --- /dev/null +++ b/test/dm/firmware.c @@ -0,0 +1,22 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Copyright (C) 2018 Xilinx, Inc. + */ + +#include <common.h> +#include <dm.h> +#include <syscon.h> +#include <asm/test.h> +#include <dm/test.h> +#include <test/ut.h> + +/* Base test of firmware probe */ +static int dm_test_firmware_probe(struct unit_test_state *uts) +{ + struct udevice *dev; + + ut_assertok(uclass_get_device_by_name(UCLASS_FIRMWARE, + "sandbox-firmware", &dev)); + return 0; +} +DM_TEST(dm_test_firmware_probe, DM_TESTF_SCAN_FDT);

On 19 September 2018 at 04:43, Rajan Vaja rajan.vaja@xilinx.com wrote:
Add a test which verifies that all subnodes under "/firmware" nodes are scanned.
Signed-off-by: Rajan Vaja rajan.vaja@xilinx.com
Changes in v2:
- New patch
arch/sandbox/dts/test.dts | 7 +++++++ drivers/firmware/Makefile | 1 + drivers/firmware/firmware-sandbox.c | 20 ++++++++++++++++++++ test/dm/Makefile | 1 + test/dm/firmware.c | 22 ++++++++++++++++++++++ 5 files changed, 51 insertions(+) create mode 100644 drivers/firmware/firmware-sandbox.c create mode 100644 test/dm/firmware.c
Reviewed-by: Simon Glass sjg@chromium.org

On 25 September 2018 at 22:41, Simon Glass sjg@chromium.org wrote:
On 19 September 2018 at 04:43, Rajan Vaja rajan.vaja@xilinx.com wrote:
Add a test which verifies that all subnodes under "/firmware" nodes are scanned.
Signed-off-by: Rajan Vaja rajan.vaja@xilinx.com
Changes in v2:
- New patch
arch/sandbox/dts/test.dts | 7 +++++++ drivers/firmware/Makefile | 1 + drivers/firmware/firmware-sandbox.c | 20 ++++++++++++++++++++ test/dm/Makefile | 1 + test/dm/firmware.c | 22 ++++++++++++++++++++++ 5 files changed, 51 insertions(+) create mode 100644 drivers/firmware/firmware-sandbox.c create mode 100644 test/dm/firmware.c
Reviewed-by: Simon Glass sjg@chromium.org
Applied to u-boot-dm, and now in mainline, thanks!

Hi Simon,
On 19.9.2018 12:43, Rajan Vaja wrote:
All Linux firmware drivers are put under "/firmware" node and it has support to populate "/firmware" node by default.
u-boot and Linux can share same DTB. In this case, driver probe for devices under "/firmware" will not be invoked as "/firmware" does not have its own "compatible" property.
This patch series scans "/firmware" node by default like "/clocks". To avoid duplication of code, first patch moves, node scan code into separate function.
This series also test to make sure "/firmware" nodes are scanned properly.
Rajan Vaja (4): firmware: Add FIRMWARE config prompt string dm: core: Move "/clock" node scan into function dm: core: Scan "/firmware" node by default dm: test: Add "/firmware" node scan test
arch/sandbox/dts/test.dts | 7 +++++++ drivers/core/root.c | 35 ++++++++++++++++++++++------------- drivers/firmware/Kconfig | 2 +- drivers/firmware/Makefile | 1 + drivers/firmware/firmware-sandbox.c | 20 ++++++++++++++++++++ test/dm/Makefile | 1 + test/dm/firmware.c | 22 ++++++++++++++++++++++ 7 files changed, 74 insertions(+), 14 deletions(-) create mode 100644 drivers/firmware/firmware-sandbox.c create mode 100644 test/dm/firmware.c
Can you please take it via your tree?
Thanks, Michal

On 25 September 2018 at 23:33, Michal Simek michal.simek@xilinx.com wrote:
Hi Simon,
On 19.9.2018 12:43, Rajan Vaja wrote:
All Linux firmware drivers are put under "/firmware" node and it has support to populate "/firmware" node by default.
u-boot and Linux can share same DTB. In this case, driver probe for devices under "/firmware" will not be invoked as "/firmware" does not have its own "compatible" property.
This patch series scans "/firmware" node by default like "/clocks". To avoid duplication of code, first patch moves, node scan code into separate function.
This series also test to make sure "/firmware" nodes are scanned properly.
Rajan Vaja (4): firmware: Add FIRMWARE config prompt string dm: core: Move "/clock" node scan into function dm: core: Scan "/firmware" node by default dm: test: Add "/firmware" node scan test
arch/sandbox/dts/test.dts | 7 +++++++ drivers/core/root.c | 35 ++++++++++++++++++++++------------- drivers/firmware/Kconfig | 2 +- drivers/firmware/Makefile | 1 + drivers/firmware/firmware-sandbox.c | 20 ++++++++++++++++++++ test/dm/Makefile | 1 + test/dm/firmware.c | 22 ++++++++++++++++++++++ 7 files changed, 74 insertions(+), 14 deletions(-) create mode 100644 drivers/firmware/firmware-sandbox.c create mode 100644 test/dm/firmware.c
Can you please take it via your tree?
Thanks, Michal
Applied to u-boot-dm, and now in mainline, thanks!
participants (3)
-
Michal Simek
-
Rajan Vaja
-
Simon Glass