Skip to contentSkip to conversation

dm: core: Scan "/firmware" node by default

PATCH Superseded Rajan Vaja 3 participants 21 messages Aug 10, 2018 – Oct 2, 2018

lore
Share & tools
lore

Rajan Vaja

author
#0 lore raw

cover 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(-)
Signature · 6 lines
BRANCH: zynq3/master-next-test

Changes since RFC:
  * Rebase on top on zynq3 branch.
-- 
2.7.4
author
#1 lore raw

PATCH 1/2 dm: core: Move "/clock" node scan into function

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.

---
 drivers/core/root.c | 33 ++++++++++++++++++---------------
 1 file changed, 18 insertions(+), 15 deletions(-)
drivers/core/root.c +18 -15
index 72bcc7d..1ab4c38 100644
@@ -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;
 }
Signature · 1 line
2.7.4
#2 lore raw

PATCH 1/2 dm: core: Move "/clock" node scan into function

Quoted 10 lines · Rajan Vaja

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.

---
 drivers/core/root.c | 33 ++++++++++++++++++---------------
 1 file changed, 18 insertions(+), 15 deletions(-)
author
#3 lore raw

PATCH 2/2 dm: core: Scan "/firmware" node by default

In reply to Rajan Vaja

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".

---
 drivers/core/root.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
drivers/core/root.c +7 -1
index 1ab4c38..47d10b8 100644
@@ -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;
 }
Signature · 1 line
2.7.4
#4 lore raw

PATCH 2/2 dm: core: Scan "/firmware" node by default

Quoted 7 lines · Rajan Vaja

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.

Quoted 6 lines

This patch scans "/firmware" node by default like "/clocks".

---
 drivers/core/root.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

We should add a firmware device for sandbox.

#5 lore raw

PATCH 2/2 dm: core: Scan "/firmware" node by default

Quoted 10 lines · Simon Glass
Quoted 9 lines · Rajan Vaja

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".

Quoted 9 lines
Quoted 4 lines
---
 drivers/core/root.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

We should add a firmware device for sandbox.

what to add there?

M

#6 lore raw

PATCH 2/2 dm: core: Scan "/firmware" node by default

Hi Michael,

Quoted 16 lines · Michal Simek
Quoted 15 lines · Simon Glass
Quoted 13 lines · Rajan Vaja

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".

---
 drivers/core/root.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
Quoted 6 lines
Quoted 4 lines

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

#7 lore raw

PATCH 2/2 dm: core: Scan "/firmware" node by default

Quoted 21 lines · Simon Glass

Hi Michael,

Quoted 18 lines · Michal Simek
Quoted 17 lines · Simon Glass
Quoted 7 lines · Rajan Vaja

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.

Quoted 6 lines

This patch scans "/firmware" node by default like "/clocks".

---
 drivers/core/root.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
Quoted 8 lines
Quoted 4 lines
Quoted 2 lines

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

#8 lore raw

cover dm: core: Scan "/firmware" node by default

In reply to Rajan Vaja

Hi Simon,

Quoted 11 lines · Rajan Vaja

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.

Quoted 7 lines

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

author
#9 lore raw

v2 cover dm: core: Scan "/firmware" node by default

In reply to Rajan Vaja

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
Signature · 5 lines
Changes in v2:
 * Add firmware device for sanbox and its test
 * Fix Kconfig to enable FIRMWARE config
-- 
2.7.4
author
#10 lore raw

PATCH v2 1/4 firmware: Add FIRMWARE config prompt string

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.

---
Changes in v2:
* New patch

---
 drivers/firmware/Kconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/firmware/Kconfig +1 -1
index cb73b70..feaea81 100644
@@ -1,5 +1,5 @@
 config FIRMWARE
-	bool
+	bool "Enable Firmware driver support"
 
 config ARM_PSCI_FW
 	bool
Signature · 1 line
2.7.4
#11 lore raw

PATCH v2 1/4 firmware: Add FIRMWARE config prompt string

Quoted 11 lines · Rajan Vaja

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.

---
Changes in v2:
* New patch

---
 drivers/firmware/Kconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
#12 lore raw

PATCH v2 1/4 firmware: Add FIRMWARE config prompt string

Quoted 13 lines · Simon Glass
Quoted 11 lines · Rajan Vaja

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.

---
Changes in v2:
* New patch

---
 drivers/firmware/Kconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 1 line

Applied to u-boot-dm, and now in mainline, thanks!

author
#13 lore raw

PATCH v2 2/4 dm: core: Move "/clock" node scan into function

In reply to Rajan Vaja

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.

---
Changes in v2:
* None

---
 drivers/core/root.c | 33 ++++++++++++++++++---------------
 1 file changed, 18 insertions(+), 15 deletions(-)
drivers/core/root.c +18 -15
index 72bcc7d..1ab4c38 100644
@@ -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;
 }
Signature · 1 line
2.7.4
#14 lore raw

PATCH v2 2/4 dm: core: Move "/clock" node scan into function

Quoted 5 lines · Rajan Vaja

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.

Quoted 8 lines

---
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!

author
#15 lore raw

PATCH v2 3/4 dm: core: Scan "/firmware" node by default

In reply to Rajan Vaja

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".

---
Changes in v2:
* None

---
 drivers/core/root.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
drivers/core/root.c +7 -1
index 1ab4c38..47d10b8 100644
@@ -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;
 }
Signature · 1 line
2.7.4
author
#16 lore raw

PATCH v2 4/4 dm: test: Add "/firmware" node scan test

In reply to Rajan Vaja

Add a test which verifies that all subnodes under "/firmware" nodes are scanned.

---
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
arch/sandbox/dts/test.dts +7 -0
index 3668263..94c603a 100644
@@ -630,6 +630,13 @@
 			};
 		};
 	};
+
+	firmware {
+		sandbox_firmware: sandbox-firmware {
+			compatible = "sandbox,firmware";
+		};
+	};
+
 };
 
 #include "sandbox_pmic.dtsi"
drivers/firmware/Makefile +1 -0
index 1cdda14..6cb8358 100644
@@ -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
drivers/firmware/firmware-sandbox.c new file +20 -0
new file mode 100644
index 0000000..d970d75
@@ -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,
+};
test/dm/Makefile +1 -0
index 3f5a634..3f54710 100644
@@ -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
test/dm/firmware.c new file +22 -0
new file mode 100644
index 0000000..60fdcbb
@@ -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);
Signature · 1 line
2.7.4
#17 lore raw

PATCH v2 4/4 dm: test: Add "/firmware" node scan test

Quoted 7 lines · Rajan Vaja

Add a test which verifies that all subnodes under "/firmware" nodes are scanned.

---
Changes in v2:
* New patch

Quoted 9 lines
---
 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
#18 lore raw

PATCH v2 4/4 dm: test: Add "/firmware" node scan test

Quoted 18 lines · Simon Glass
Quoted 7 lines · Rajan Vaja

Add a test which verifies that all subnodes under "/firmware" nodes are scanned.

---
Changes in v2:
* New patch

Quoted 9 lines
---
 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
Quoted 1 line

Applied to u-boot-dm, and now in mainline, thanks!

#19 lore raw

v2 cover dm: core: Scan "/firmware" node by default

In reply to Rajan Vaja

Hi Simon,

Quoted 20 lines · Rajan Vaja

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

Quoted 11 lines
 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

#20 lore raw

v2 cover dm: core: Scan "/firmware" node by default

Quoted 35 lines · Michal Simek

Hi Simon,

Quoted 20 lines · Rajan Vaja

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

Quoted 11 lines
 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
Quoted 4 lines

Can you please take it via your tree?

Thanks,
Michal

Applied to u-boot-dm, and now in mainline, thanks!