All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 00/21] dm: Preparation for enhanced of-platdata (part B)
@ 2020-12-23 15:11 Simon Glass
  2020-12-23 15:11 ` [PATCH v2 01/21] pinctrl: Drop post_bind() method when not needed Simon Glass
                   ` (38 more replies)
  0 siblings, 39 replies; 40+ messages in thread
From: Simon Glass @ 2020-12-23 15:11 UTC (permalink / raw)
  To: u-boot

This series includes some refactoring of the dtoc tool and some changes
to a few drivers (particularly on x86) to reduce TPL size.

It is available at u-boot-dm/prep-working

Changes in v2:
- Rename DriverInfo to Driver
- Add a test for the new code and a comment for Driver

Simon Glass (21):
  pinctrl: Drop post_bind() method when not needed
  sysreset: Use a shorter error with SPL
  arc: m68k: nds32: nios2: sh: xtensa: Add empty spl.h header
  timer: Use a shorter error in TPL
  test: Use a simple variable to record removed device
  test: Move some test drivers into their own file
  dtoc: Fix a few pylint warnings in dtb_platdata
  dtoc: Make _output_list a top-level function
  dtoc: Output the device in a separate function
  dtoc: Output the struct values in a separate function
  dtoc: Convert _drivers to a dict
  dtoc: Scan drivers for available information
  dtoc: Allow use of the of_match_ptr() macro
  x86: apl: Use const for driver operations
  x86: Move call64 into its own section
  x86: coral: Move fsp-m settings to a subnode
  x86: apl: Update hostbridge to remove unwanted TPL code
  x86: apl: Reduce size for TPL
  x86: pinctrl: Drop unlikely error messages from TPL
  x86: tpl: Remove unwanted devicetree string
  x86: Fix header guard in asm/pmu.h

 arch/arc/include/asm/spl.h               |   0
 arch/m68k/include/asm/spl.h              |   0
 arch/nds32/include/asm/spl.h             |   0
 arch/nios2/include/asm/spl.h             |   0
 arch/sh/include/asm/spl.h                |   0
 arch/x86/cpu/apollolake/fsp_m.c          |   5 +-
 arch/x86/cpu/apollolake/hostbridge.c     |  14 +-
 arch/x86/cpu/apollolake/lpc.c            |  13 +-
 arch/x86/cpu/apollolake/pch.c            |   4 +-
 arch/x86/cpu/apollolake/pmc.c            |   6 +-
 arch/x86/cpu/apollolake/uart.c           |   4 +-
 arch/x86/cpu/i386/call64.S               |   1 +
 arch/x86/cpu/intel_common/Makefile       |   2 +-
 arch/x86/cpu/intel_common/itss.c         |   4 +-
 arch/x86/cpu/intel_common/p2sb.c         |   6 +-
 arch/x86/cpu/turbo.c                     |   5 +
 arch/x86/dts/chromebook_coral.dts        |   5 +
 arch/x86/include/asm/pmu.h               |   6 +-
 arch/x86/lib/tpl.c                       |   4 +-
 arch/xtensa/include/asm/spl.h            |   0
 board/google/chromebook_coral/coral.c    |   4 +-
 drivers/gpio/intel_gpio.c                |   4 +-
 drivers/misc/Kconfig                     |   9 +
 drivers/misc/Makefile                    |   1 +
 drivers/misc/test_drv.c                  | 230 ++++++++++++++
 drivers/pinctrl/intel/pinctrl.c          |  11 +-
 drivers/pinctrl/intel/pinctrl_apl.c      |   4 +-
 drivers/pinctrl/pinctrl-uclass.c         |   4 +-
 drivers/power/acpi_pmc/acpi-pmc-uclass.c |   4 +-
 drivers/sysreset/sysreset-uclass.c       |  12 +-
 drivers/timer/tsc_timer.c                |   4 +-
 include/dm/test.h                        |  20 +-
 include/test/test.h                      |   9 +
 lib/time.c                               |  10 +-
 test/dm/bus.c                            | 107 +------
 test/dm/test-fdt.c                       | 120 --------
 tools/dtoc/dtb_platdata.py               | 370 +++++++++++++++++------
 tools/dtoc/test_dtoc.py                  | 123 ++++++++
 38 files changed, 777 insertions(+), 348 deletions(-)
 create mode 100644 arch/arc/include/asm/spl.h
 create mode 100644 arch/m68k/include/asm/spl.h
 create mode 100644 arch/nds32/include/asm/spl.h
 create mode 100644 arch/nios2/include/asm/spl.h
 create mode 100644 arch/sh/include/asm/spl.h
 create mode 100644 arch/xtensa/include/asm/spl.h
 create mode 100644 drivers/misc/test_drv.c

-- 
2.29.2.729.g45daf8777d-goog

^ permalink raw reply	[flat|nested] 40+ messages in thread

* [PATCH v2 01/21] pinctrl: Drop post_bind() method when not needed
  2020-12-23 15:11 [PATCH v2 00/21] dm: Preparation for enhanced of-platdata (part B) Simon Glass
@ 2020-12-23 15:11 ` Simon Glass
  2020-12-23 15:11 ` [PATCH v2 02/21] sysreset: Use a shorter error with SPL Simon Glass
                   ` (37 subsequent siblings)
  38 siblings, 0 replies; 40+ messages in thread
From: Simon Glass @ 2020-12-23 15:11 UTC (permalink / raw)
  To: u-boot

This is not used with of-platdata, so remove it in that case.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

(no changes since v1)

 drivers/pinctrl/pinctrl-uclass.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/pinctrl/pinctrl-uclass.c b/drivers/pinctrl/pinctrl-uclass.c
index aba88104747..4e474cbff73 100644
--- a/drivers/pinctrl/pinctrl-uclass.c
+++ b/drivers/pinctrl/pinctrl-uclass.c
@@ -305,7 +305,7 @@ int pinctrl_select_state(struct udevice *dev, const char *statename)
 	 * Some device which is logical like mmc.blk, do not have
 	 * a valid ofnode.
 	 */
-	if (!ofnode_valid(dev->node))
+	if (!dev_has_of_node(dev))
 		return 0;
 	/*
 	 * Try full-implemented pinctrl first.
@@ -416,7 +416,9 @@ static int __maybe_unused pinctrl_post_bind(struct udevice *dev)
 
 UCLASS_DRIVER(pinctrl) = {
 	.id = UCLASS_PINCTRL,
+#if !CONFIG_IS_ENABLED(OF_PLATDATA)
 	.post_bind = pinctrl_post_bind,
+#endif
 	.flags = DM_UC_FLAG_SEQ_ALIAS,
 	.name = "pinctrl",
 };
-- 
2.29.2.729.g45daf8777d-goog

^ permalink raw reply related	[flat|nested] 40+ messages in thread

* [PATCH v2 02/21] sysreset: Use a shorter error with SPL
  2020-12-23 15:11 [PATCH v2 00/21] dm: Preparation for enhanced of-platdata (part B) Simon Glass
  2020-12-23 15:11 ` [PATCH v2 01/21] pinctrl: Drop post_bind() method when not needed Simon Glass
@ 2020-12-23 15:11 ` Simon Glass
  2020-12-23 15:11 ` [PATCH v2 03/21] arc: m68k: nds32: nios2: sh: xtensa: Add empty spl.h header Simon Glass
                   ` (36 subsequent siblings)
  38 siblings, 0 replies; 40+ messages in thread
From: Simon Glass @ 2020-12-23 15:11 UTC (permalink / raw)
  To: u-boot

Use a minimal error message to save space. Sort the header files while we
are here.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

(no changes since v1)

 drivers/sysreset/sysreset-uclass.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/drivers/sysreset/sysreset-uclass.c b/drivers/sysreset/sysreset-uclass.c
index 3f5414ed1f8..e69fb2255b6 100644
--- a/drivers/sysreset/sysreset-uclass.c
+++ b/drivers/sysreset/sysreset-uclass.c
@@ -9,12 +9,13 @@
 #include <common.h>
 #include <command.h>
 #include <cpu_func.h>
-#include <hang.h>
-#include <log.h>
-#include <sysreset.h>
 #include <dm.h>
 #include <errno.h>
+#include <hang.h>
+#include <log.h>
 #include <regmap.h>
+#include <spl.h>
+#include <sysreset.h>
 #include <dm/device-internal.h>
 #include <dm/lists.h>
 #include <dm/root.h>
@@ -101,7 +102,10 @@ void sysreset_walk_halt(enum sysreset_t type)
 		mdelay(100);
 
 	/* Still no reset? Give up */
-	log_err("System reset not supported on this platform\n");
+	if (spl_phase() <= PHASE_SPL)
+		log_err("no sysreset\n");
+	else
+		log_err("System reset not supported on this platform\n");
 	hang();
 }
 
-- 
2.29.2.729.g45daf8777d-goog

^ permalink raw reply related	[flat|nested] 40+ messages in thread

* [PATCH v2 03/21] arc: m68k: nds32: nios2: sh: xtensa: Add empty spl.h header
  2020-12-23 15:11 [PATCH v2 00/21] dm: Preparation for enhanced of-platdata (part B) Simon Glass
  2020-12-23 15:11 ` [PATCH v2 01/21] pinctrl: Drop post_bind() method when not needed Simon Glass
  2020-12-23 15:11 ` [PATCH v2 02/21] sysreset: Use a shorter error with SPL Simon Glass
@ 2020-12-23 15:11 ` Simon Glass
  2020-12-23 15:11 ` [PATCH v2 04/21] timer: Use a shorter error in TPL Simon Glass
                   ` (35 subsequent siblings)
  38 siblings, 0 replies; 40+ messages in thread
From: Simon Glass @ 2020-12-23 15:11 UTC (permalink / raw)
  To: u-boot

At present it is not possible to include spl.h in on these architectures
since the asm/spl.h file is not present. We want to be able to use the
spl_phase() function, so add empty headers to make things build.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

(no changes since v1)

 arch/arc/include/asm/spl.h    | 0
 arch/m68k/include/asm/spl.h   | 0
 arch/nds32/include/asm/spl.h  | 0
 arch/nios2/include/asm/spl.h  | 0
 arch/sh/include/asm/spl.h     | 0
 arch/xtensa/include/asm/spl.h | 0
 6 files changed, 0 insertions(+), 0 deletions(-)
 create mode 100644 arch/arc/include/asm/spl.h
 create mode 100644 arch/m68k/include/asm/spl.h
 create mode 100644 arch/nds32/include/asm/spl.h
 create mode 100644 arch/nios2/include/asm/spl.h
 create mode 100644 arch/sh/include/asm/spl.h
 create mode 100644 arch/xtensa/include/asm/spl.h

diff --git a/arch/arc/include/asm/spl.h b/arch/arc/include/asm/spl.h
new file mode 100644
index 00000000000..e69de29bb2d
diff --git a/arch/m68k/include/asm/spl.h b/arch/m68k/include/asm/spl.h
new file mode 100644
index 00000000000..e69de29bb2d
diff --git a/arch/nds32/include/asm/spl.h b/arch/nds32/include/asm/spl.h
new file mode 100644
index 00000000000..e69de29bb2d
diff --git a/arch/nios2/include/asm/spl.h b/arch/nios2/include/asm/spl.h
new file mode 100644
index 00000000000..e69de29bb2d
diff --git a/arch/sh/include/asm/spl.h b/arch/sh/include/asm/spl.h
new file mode 100644
index 00000000000..e69de29bb2d
diff --git a/arch/xtensa/include/asm/spl.h b/arch/xtensa/include/asm/spl.h
new file mode 100644
index 00000000000..e69de29bb2d
-- 
2.29.2.729.g45daf8777d-goog

^ permalink raw reply	[flat|nested] 40+ messages in thread

* [PATCH v2 04/21] timer: Use a shorter error in TPL
  2020-12-23 15:11 [PATCH v2 00/21] dm: Preparation for enhanced of-platdata (part B) Simon Glass
                   ` (2 preceding siblings ...)
  2020-12-23 15:11 ` [PATCH v2 03/21] arc: m68k: nds32: nios2: sh: xtensa: Add empty spl.h header Simon Glass
@ 2020-12-23 15:11 ` Simon Glass
  2020-12-23 15:11 ` [PATCH v2 05/21] test: Use a simple variable to record removed device Simon Glass
                   ` (34 subsequent siblings)
  38 siblings, 0 replies; 40+ messages in thread
From: Simon Glass @ 2020-12-23 15:11 UTC (permalink / raw)
  To: u-boot

This error should not happen in normal use. Reduce the length of it to
save space in the image.

Add an empty spl.h file to sh since it appears to lack this.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

(no changes since v1)

 lib/time.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/lib/time.c b/lib/time.c
index 88bc50405ff..cc6944ec345 100644
--- a/lib/time.c
+++ b/lib/time.c
@@ -9,6 +9,7 @@
 #include <dm.h>
 #include <errno.h>
 #include <init.h>
+#include <spl.h>
 #include <time.h>
 #include <timer.h>
 #include <watchdog.h>
@@ -96,8 +97,13 @@ uint64_t notrace get_ticks(void)
 	}
 
 	ret = timer_get_count(gd->timer, &count);
-	if (ret)
-		panic("Could not read count from timer (err %d)\n", ret);
+	if (ret) {
+		if (spl_phase() > PHASE_TPL)
+			panic("Could not read count from timer (err %d)\n",
+			      ret);
+		else
+			panic("no timer (err %d)\n", ret);
+	}
 
 	return count;
 }
-- 
2.29.2.729.g45daf8777d-goog

^ permalink raw reply related	[flat|nested] 40+ messages in thread

* [PATCH v2 05/21] test: Use a simple variable to record removed device
  2020-12-23 15:11 [PATCH v2 00/21] dm: Preparation for enhanced of-platdata (part B) Simon Glass
                   ` (3 preceding siblings ...)
  2020-12-23 15:11 ` [PATCH v2 04/21] timer: Use a shorter error in TPL Simon Glass
@ 2020-12-23 15:11 ` Simon Glass
  2020-12-23 15:11 ` [PATCH v2 06/21] test: Move some test drivers into their own file Simon Glass
                   ` (33 subsequent siblings)
  38 siblings, 0 replies; 40+ messages in thread
From: Simon Glass @ 2020-12-23 15:11 UTC (permalink / raw)
  To: u-boot

At present the entire test state is effective passed into a test driver
just to record which device was removed. This is unnecessary and makes it
harder to track what is going on.

Use a simple boolean instead.

Also drop the unused 'removed' member while we are here.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

(no changes since v1)

 include/dm/test.h |  2 --
 test/dm/bus.c     | 14 ++++++--------
 2 files changed, 6 insertions(+), 10 deletions(-)

diff --git a/include/dm/test.h b/include/dm/test.h
index b2adce730ad..cbe1b57d95f 100644
--- a/include/dm/test.h
+++ b/include/dm/test.h
@@ -134,14 +134,12 @@ extern struct unit_test_state global_dm_test_state;
  * @testdev: Test device
  * @force_fail_alloc: Force all memory allocs to fail
  * @skip_post_probe: Skip uclass post-probe processing
- * @removed: Used to keep track of a device that was removed
  */
 struct dm_test_state {
 	struct udevice *root;
 	struct udevice *testdev;
 	int force_fail_alloc;
 	int skip_post_probe;
-	struct udevice *removed;
 };
 
 /* Declare a new driver model test */
diff --git a/test/dm/bus.c b/test/dm/bus.c
index 60ddb1d6b14..b95c106f5f0 100644
--- a/test/dm/bus.c
+++ b/test/dm/bus.c
@@ -30,7 +30,8 @@ enum {
 	FLAG_CHILD_REMOVED	= -7,
 };
 
-static struct dm_test_state *test_state;
+/* Records the last testbus device that was removed */
+static struct udevice *testbus_removed;
 
 static int testbus_drv_probe(struct udevice *dev)
 {
@@ -78,11 +79,9 @@ static int testbus_child_post_probe_uclass(struct udevice *dev)
 static int testbus_child_post_remove(struct udevice *dev)
 {
 	struct dm_test_parent_data *parent_data = dev_get_parent_priv(dev);
-	struct dm_test_state *dms = test_state;
 
 	parent_data->flag += FLAG_CHILD_REMOVED;
-	if (dms)
-		dms->removed = dev;
+	testbus_removed = dev;
 
 	return 0;
 }
@@ -335,11 +334,10 @@ DM_TEST(dm_test_bus_parent_data_uclass,
 static int dm_test_bus_parent_ops(struct unit_test_state *uts)
 {
 	struct dm_test_parent_data *parent_data;
-	struct dm_test_state *dms = uts->priv;
 	struct udevice *bus, *dev;
 	struct uclass *uc;
 
-	test_state = dms;
+	testbus_removed = NULL;
 	ut_assertok(uclass_get_device(UCLASS_TEST_BUS, 0, &bus));
 	ut_assertok(uclass_get(UCLASS_TEST_FDT, &uc));
 
@@ -362,9 +360,9 @@ static int dm_test_bus_parent_ops(struct unit_test_state *uts)
 		ut_asserteq(FLAG_CHILD_PROBED, parent_data->flag);
 		ut_assertok(device_remove(dev, DM_REMOVE_NORMAL));
 		ut_asserteq_ptr(NULL, dev_get_parent_priv(dev));
-		ut_asserteq_ptr(dms->removed, dev);
+		ut_asserteq_ptr(testbus_removed, dev);
 	}
-	test_state = NULL;
+	testbus_removed = NULL;
 
 	return 0;
 }
-- 
2.29.2.729.g45daf8777d-goog

^ permalink raw reply related	[flat|nested] 40+ messages in thread

* [PATCH v2 06/21] test: Move some test drivers into their own file
  2020-12-23 15:11 [PATCH v2 00/21] dm: Preparation for enhanced of-platdata (part B) Simon Glass
                   ` (4 preceding siblings ...)
  2020-12-23 15:11 ` [PATCH v2 05/21] test: Use a simple variable to record removed device Simon Glass
@ 2020-12-23 15:11 ` Simon Glass
  2020-12-23 15:11 ` [PATCH v2 07/21] dtoc: Fix a few pylint warnings in dtb_platdata Simon Glass
                   ` (32 subsequent siblings)
  38 siblings, 0 replies; 40+ messages in thread
From: Simon Glass @ 2020-12-23 15:11 UTC (permalink / raw)
  To: u-boot

At present several test drivers are part of the test file itself. Some of
these are useful for of-platdata tests. Separate them out so we can use
them for other things also.

A few adjustments are needed so this driver can build for sandbox_spl as
well.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

(no changes since v1)

 drivers/misc/Kconfig    |   9 ++
 drivers/misc/Makefile   |   1 +
 drivers/misc/test_drv.c | 230 ++++++++++++++++++++++++++++++++++++++++
 include/dm/test.h       |  18 ++++
 include/test/test.h     |   9 ++
 test/dm/bus.c           | 105 +-----------------
 test/dm/test-fdt.c      | 120 ---------------------
 7 files changed, 271 insertions(+), 221 deletions(-)
 create mode 100644 drivers/misc/test_drv.c

diff --git a/drivers/misc/Kconfig b/drivers/misc/Kconfig
index 29432ae7eb4..7d2a2997797 100644
--- a/drivers/misc/Kconfig
+++ b/drivers/misc/Kconfig
@@ -343,6 +343,15 @@ config TEGRA186_BPMP
 	  can make requests to the BPMP. This driver is similar to an MFD
 	  driver in the Linux kernel.
 
+config TEST_DRV
+	bool "Enable support for test drivers"
+	default y if SANDBOX
+	help
+	  This enables drivers and uclasses that provides a way of testing the
+	  operations of memory allocation and driver/uclass methods in driver
+	  model. This should only be enabled for testing as it is not useful for
+	  anything else.
+
 config TWL4030_LED
 	bool "Enable TWL4030 LED controller"
 	help
diff --git a/drivers/misc/Makefile b/drivers/misc/Makefile
index 947bd3a647f..d7372037045 100644
--- a/drivers/misc/Makefile
+++ b/drivers/misc/Makefile
@@ -67,6 +67,7 @@ obj-$(CONFIG_STM32_RCC) += stm32_rcc.o
 obj-$(CONFIG_SYS_DPAA_QBMAN) += fsl_portals.o
 obj-$(CONFIG_TEGRA186_BPMP) += tegra186_bpmp.o
 obj-$(CONFIG_TEGRA_CAR) += tegra_car.o
+obj-$(CONFIG_TEST_DRV) += test_drv.o
 obj-$(CONFIG_TWL4030_LED) += twl4030_led.o
 obj-$(CONFIG_VEXPRESS_CONFIG) += vexpress_config.o
 obj-$(CONFIG_WINBOND_W83627) += winbond_w83627.o
diff --git a/drivers/misc/test_drv.c b/drivers/misc/test_drv.c
new file mode 100644
index 00000000000..a163312b108
--- /dev/null
+++ b/drivers/misc/test_drv.c
@@ -0,0 +1,230 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright (c) 2014 Google, Inc
+ */
+
+#include <common.h>
+#include <dm.h>
+#include <dm/test.h>
+
+/* Records the last testbus device that was removed */
+static struct udevice *testbus_removed;
+
+struct udevice *testbus_get_clear_removed(void)
+{
+	struct udevice *removed = testbus_removed;
+
+	testbus_removed = NULL;
+
+	return removed;
+}
+
+static int testbus_drv_probe(struct udevice *dev)
+{
+	if (!CONFIG_IS_ENABLED(OF_PLATDATA)) {
+		int ret;
+
+		ret = dm_scan_fdt_dev(dev);
+		if (ret)
+			return ret;
+	}
+
+	return 0;
+}
+
+static int testbus_child_post_bind(struct udevice *dev)
+{
+	struct dm_test_parent_plat *plat;
+
+	plat = dev_get_parent_plat(dev);
+	plat->bind_flag = 1;
+	plat->uclass_bind_flag = 2;
+
+	return 0;
+}
+
+static int testbus_child_pre_probe(struct udevice *dev)
+{
+	struct dm_test_parent_data *parent_data = dev_get_parent_priv(dev);
+
+	parent_data->flag += TEST_FLAG_CHILD_PROBED;
+
+	return 0;
+}
+
+static int testbus_child_pre_probe_uclass(struct udevice *dev)
+{
+	struct dm_test_priv *priv = dev_get_priv(dev);
+
+	priv->uclass_flag++;
+
+	return 0;
+}
+
+static int testbus_child_post_probe_uclass(struct udevice *dev)
+{
+	struct dm_test_priv *priv = dev_get_priv(dev);
+
+	priv->uclass_postp++;
+
+	return 0;
+}
+
+static int testbus_child_post_remove(struct udevice *dev)
+{
+	struct dm_test_parent_data *parent_data = dev_get_parent_priv(dev);
+
+	parent_data->flag += TEST_FLAG_CHILD_REMOVED;
+	testbus_removed = dev;
+
+	return 0;
+}
+
+static const struct udevice_id testbus_ids[] = {
+	{
+		.compatible = "denx,u-boot-test-bus",
+		.data = DM_TEST_TYPE_FIRST },
+	{ }
+};
+
+U_BOOT_DRIVER(testbus_drv) = {
+	.name	= "testbus_drv",
+	.of_match	= testbus_ids,
+	.id	= UCLASS_TEST_BUS,
+	.probe	= testbus_drv_probe,
+	.child_post_bind = testbus_child_post_bind,
+	.priv_auto	= sizeof(struct dm_test_priv),
+	.plat_auto	= sizeof(struct dm_test_pdata),
+	.per_child_auto	= sizeof(struct dm_test_parent_data),
+	.per_child_plat_auto	= sizeof(struct dm_test_parent_plat),
+	.child_pre_probe = testbus_child_pre_probe,
+	.child_post_remove = testbus_child_post_remove,
+};
+
+UCLASS_DRIVER(testbus) = {
+	.name		= "testbus",
+	.id		= UCLASS_TEST_BUS,
+	.flags		= DM_UC_FLAG_SEQ_ALIAS,
+	.child_pre_probe = testbus_child_pre_probe_uclass,
+	.child_post_probe = testbus_child_post_probe_uclass,
+};
+
+static int testfdt_drv_ping(struct udevice *dev, int pingval, int *pingret)
+{
+	const struct dm_test_pdata *pdata = dev_get_plat(dev);
+	struct dm_test_priv *priv = dev_get_priv(dev);
+
+	*pingret = pingval + pdata->ping_add;
+	priv->ping_total += *pingret;
+
+	return 0;
+}
+
+static const struct test_ops test_ops = {
+	.ping = testfdt_drv_ping,
+};
+
+static int testfdt_of_to_plat(struct udevice *dev)
+{
+	struct dm_test_pdata *pdata = dev_get_plat(dev);
+
+	pdata->ping_add = fdtdec_get_int(gd->fdt_blob, dev_of_offset(dev),
+					 "ping-add", -1);
+	pdata->base = fdtdec_get_addr(gd->fdt_blob, dev_of_offset(dev),
+				      "ping-expect");
+
+	return 0;
+}
+
+static int testfdt_drv_probe(struct udevice *dev)
+{
+	struct dm_test_priv *priv = dev_get_priv(dev);
+
+	priv->ping_total += DM_TEST_START_TOTAL;
+
+	/*
+	 * If this device is on a bus, the uclass_flag will be set before
+	 * calling this function. In the meantime the uclass_postp is
+	 * initlized to a value -1. These are used respectively by
+	 * dm_test_bus_child_pre_probe_uclass() and
+	 * dm_test_bus_child_post_probe_uclass().
+	 */
+	priv->uclass_total += priv->uclass_flag;
+	priv->uclass_postp = -1;
+
+	return 0;
+}
+
+static const struct udevice_id testfdt_ids[] = {
+	{
+		.compatible = "denx,u-boot-fdt-test",
+		.data = DM_TEST_TYPE_FIRST },
+	{
+		.compatible = "google,another-fdt-test",
+		.data = DM_TEST_TYPE_SECOND },
+	{ }
+};
+
+U_BOOT_DRIVER(testfdt_drv) = {
+	.name	= "testfdt_drv",
+	.of_match	= testfdt_ids,
+	.id	= UCLASS_TEST_FDT,
+	.of_to_plat = testfdt_of_to_plat,
+	.probe	= testfdt_drv_probe,
+	.ops	= &test_ops,
+	.priv_auto	= sizeof(struct dm_test_priv),
+	.plat_auto	= sizeof(struct dm_test_pdata),
+};
+
+static const struct udevice_id testfdt1_ids[] = {
+	{
+		.compatible = "denx,u-boot-fdt-test1",
+		.data = DM_TEST_TYPE_FIRST },
+	{ }
+};
+
+U_BOOT_DRIVER(testfdt1_drv) = {
+	.name	= "testfdt1_drv",
+	.of_match	= testfdt1_ids,
+	.id	= UCLASS_TEST_FDT,
+	.of_to_plat = testfdt_of_to_plat,
+	.probe	= testfdt_drv_probe,
+	.ops	= &test_ops,
+	.priv_auto	= sizeof(struct dm_test_priv),
+	.plat_auto	= sizeof(struct dm_test_pdata),
+	.flags = DM_FLAG_PRE_RELOC,
+};
+
+/* From here is the testfdt uclass code */
+int testfdt_ping(struct udevice *dev, int pingval, int *pingret)
+{
+	const struct test_ops *ops = device_get_ops(dev);
+
+	if (!ops->ping)
+		return -ENOSYS;
+
+	return ops->ping(dev, pingval, pingret);
+}
+
+UCLASS_DRIVER(testfdt) = {
+	.name		= "testfdt",
+	.id		= UCLASS_TEST_FDT,
+	.flags		= DM_UC_FLAG_SEQ_ALIAS,
+};
+
+static const struct udevice_id testfdtm_ids[] = {
+	{ .compatible = "denx,u-boot-fdtm-test" },
+	{ }
+};
+
+U_BOOT_DRIVER(testfdtm_drv) = {
+	.name	= "testfdtm_drv",
+	.of_match	= testfdtm_ids,
+	.id	= UCLASS_TEST_FDT_MANUAL,
+};
+
+UCLASS_DRIVER(testfdtm) = {
+	.name		= "testfdtm",
+	.id		= UCLASS_TEST_FDT_MANUAL,
+	.flags		= DM_UC_FLAG_SEQ_ALIAS | DM_UC_FLAG_NO_AUTO_SEQ,
+};
diff --git a/include/dm/test.h b/include/dm/test.h
index cbe1b57d95f..6ac6672cd6f 100644
--- a/include/dm/test.h
+++ b/include/dm/test.h
@@ -167,6 +167,24 @@ struct sandbox_sdl_plat {
 	int font_size;
 };
 
+/**
+ * struct dm_test_parent_plat - Used to track state in bus tests
+ *
+ * @count:
+ * @bind_flag: Indicates that the child post-bind method was called
+ * @uclass_bind_flag: Also indicates that the child post-bind method was called
+ */
+struct dm_test_parent_plat {
+	int count;
+	int bind_flag;
+	int uclass_bind_flag;
+};
+
+enum {
+	TEST_FLAG_CHILD_PROBED	= 10,
+	TEST_FLAG_CHILD_REMOVED	= -7,
+};
+
 /* Declare ping methods for the drivers */
 int test_ping(struct udevice *dev, int pingval, int *pingret);
 int testfdt_ping(struct udevice *dev, int pingval, int *pingret);
diff --git a/include/test/test.h b/include/test/test.h
index 03e29290bf4..3fdaa2b5e51 100644
--- a/include/test/test.h
+++ b/include/test/test.h
@@ -94,6 +94,15 @@ enum {
 	TEST_DEVRES_SIZE3	= 37,
 };
 
+/**
+ * testbus_get_clear_removed() - Test function to obtain removed device
+ *
+ * This is used in testbus to find out which device was removed. Calling this
+ * function returns a pointer to the device and then clears it back to NULL, so
+ * that a future test can check it.
+ */
+struct udevice *testbus_get_clear_removed(void);
+
 /**
  * dm_test_main() - Run driver model tests
  *
diff --git a/test/dm/bus.c b/test/dm/bus.c
index b95c106f5f0..785ccfc25d1 100644
--- a/test/dm/bus.c
+++ b/test/dm/bus.c
@@ -19,102 +19,6 @@
 
 DECLARE_GLOBAL_DATA_PTR;
 
-struct dm_test_parent_plat {
-	int count;
-	int bind_flag;
-	int uclass_bind_flag;
-};
-
-enum {
-	FLAG_CHILD_PROBED	= 10,
-	FLAG_CHILD_REMOVED	= -7,
-};
-
-/* Records the last testbus device that was removed */
-static struct udevice *testbus_removed;
-
-static int testbus_drv_probe(struct udevice *dev)
-{
-	return dm_scan_fdt_dev(dev);
-}
-
-static int testbus_child_post_bind(struct udevice *dev)
-{
-	struct dm_test_parent_plat *plat;
-
-	plat = dev_get_parent_plat(dev);
-	plat->bind_flag = 1;
-	plat->uclass_bind_flag = 2;
-
-	return 0;
-}
-
-static int testbus_child_pre_probe(struct udevice *dev)
-{
-	struct dm_test_parent_data *parent_data = dev_get_parent_priv(dev);
-
-	parent_data->flag += FLAG_CHILD_PROBED;
-
-	return 0;
-}
-
-static int testbus_child_pre_probe_uclass(struct udevice *dev)
-{
-	struct dm_test_priv *priv = dev_get_priv(dev);
-
-	priv->uclass_flag++;
-
-	return 0;
-}
-
-static int testbus_child_post_probe_uclass(struct udevice *dev)
-{
-	struct dm_test_priv *priv = dev_get_priv(dev);
-
-	priv->uclass_postp++;
-
-	return 0;
-}
-
-static int testbus_child_post_remove(struct udevice *dev)
-{
-	struct dm_test_parent_data *parent_data = dev_get_parent_priv(dev);
-
-	parent_data->flag += FLAG_CHILD_REMOVED;
-	testbus_removed = dev;
-
-	return 0;
-}
-
-static const struct udevice_id testbus_ids[] = {
-	{
-		.compatible = "denx,u-boot-test-bus",
-		.data = DM_TEST_TYPE_FIRST },
-	{ }
-};
-
-U_BOOT_DRIVER(testbus_drv) = {
-	.name	= "testbus_drv",
-	.of_match	= testbus_ids,
-	.id	= UCLASS_TEST_BUS,
-	.probe	= testbus_drv_probe,
-	.child_post_bind = testbus_child_post_bind,
-	.priv_auto	= sizeof(struct dm_test_priv),
-	.plat_auto	= sizeof(struct dm_test_pdata),
-	.per_child_auto	= sizeof(struct dm_test_parent_data),
-	.per_child_plat_auto	= sizeof(struct dm_test_parent_plat),
-	.child_pre_probe = testbus_child_pre_probe,
-	.child_post_remove = testbus_child_post_remove,
-};
-
-UCLASS_DRIVER(testbus) = {
-	.name		= "testbus",
-	.id		= UCLASS_TEST_BUS,
-	.flags		= DM_UC_FLAG_SEQ_ALIAS,
-	.child_pre_probe = testbus_child_pre_probe_uclass,
-	.child_post_probe = testbus_child_post_probe_uclass,
-};
-
 /* Test that we can probe for children */
 static int dm_test_bus_children(struct unit_test_state *uts)
 {
@@ -337,7 +241,7 @@ static int dm_test_bus_parent_ops(struct unit_test_state *uts)
 	struct udevice *bus, *dev;
 	struct uclass *uc;
 
-	testbus_removed = NULL;
+	testbus_get_clear_removed();
 	ut_assertok(uclass_get_device(UCLASS_TEST_BUS, 0, &bus));
 	ut_assertok(uclass_get(UCLASS_TEST_FDT, &uc));
 
@@ -349,7 +253,7 @@ static int dm_test_bus_parent_ops(struct unit_test_state *uts)
 
 		ut_assertok(device_probe(dev));
 		parent_data = dev_get_parent_priv(dev);
-		ut_asserteq(FLAG_CHILD_PROBED, parent_data->flag);
+		ut_asserteq(TEST_FLAG_CHILD_PROBED, parent_data->flag);
 	}
 
 	uclass_foreach_dev(dev, uc) {
@@ -357,12 +261,11 @@ static int dm_test_bus_parent_ops(struct unit_test_state *uts)
 		if (dev->parent != bus)
 			continue;
 		parent_data = dev_get_parent_priv(dev);
-		ut_asserteq(FLAG_CHILD_PROBED, parent_data->flag);
+		ut_asserteq(TEST_FLAG_CHILD_PROBED, parent_data->flag);
 		ut_assertok(device_remove(dev, DM_REMOVE_NORMAL));
 		ut_asserteq_ptr(NULL, dev_get_parent_priv(dev));
-		ut_asserteq_ptr(testbus_removed, dev);
+		ut_asserteq_ptr(testbus_get_clear_removed(), dev);
 	}
-	testbus_removed = NULL;
 
 	return 0;
 }
diff --git a/test/dm/test-fdt.c b/test/dm/test-fdt.c
index 9e8c2906e84..633256821c2 100644
--- a/test/dm/test-fdt.c
+++ b/test/dm/test-fdt.c
@@ -23,126 +23,6 @@
 
 DECLARE_GLOBAL_DATA_PTR;
 
-static int testfdt_drv_ping(struct udevice *dev, int pingval, int *pingret)
-{
-	const struct dm_test_pdata *pdata = dev_get_plat(dev);
-	struct dm_test_priv *priv = dev_get_priv(dev);
-
-	*pingret = pingval + pdata->ping_add;
-	priv->ping_total += *pingret;
-
-	return 0;
-}
-
-static const struct test_ops test_ops = {
-	.ping = testfdt_drv_ping,
-};
-
-static int testfdt_of_to_plat(struct udevice *dev)
-{
-	struct dm_test_pdata *pdata = dev_get_plat(dev);
-
-	pdata->ping_add = fdtdec_get_int(gd->fdt_blob, dev_of_offset(dev),
-					"ping-add", -1);
-	pdata->base = fdtdec_get_addr(gd->fdt_blob, dev_of_offset(dev),
-				      "ping-expect");
-
-	return 0;
-}
-
-static int testfdt_drv_probe(struct udevice *dev)
-{
-	struct dm_test_priv *priv = dev_get_priv(dev);
-
-	priv->ping_total += DM_TEST_START_TOTAL;
-
-	/*
-	 * If this device is on a bus, the uclass_flag will be set before
-	 * calling this function. In the meantime the uclass_postp is
-	 * initlized to a value -1. These are used respectively by
-	 * dm_test_bus_child_pre_probe_uclass() and
-	 * dm_test_bus_child_post_probe_uclass().
-	 */
-	priv->uclass_total += priv->uclass_flag;
-	priv->uclass_postp = -1;
-
-	return 0;
-}
-
-static const struct udevice_id testfdt_ids[] = {
-	{
-		.compatible = "denx,u-boot-fdt-test",
-		.data = DM_TEST_TYPE_FIRST },
-	{
-		.compatible = "google,another-fdt-test",
-		.data = DM_TEST_TYPE_SECOND },
-	{ }
-};
-
-U_BOOT_DRIVER(testfdt_drv) = {
-	.name	= "testfdt_drv",
-	.of_match	= testfdt_ids,
-	.id	= UCLASS_TEST_FDT,
-	.of_to_plat = testfdt_of_to_plat,
-	.probe	= testfdt_drv_probe,
-	.ops	= &test_ops,
-	.priv_auto	= sizeof(struct dm_test_priv),
-	.plat_auto	= sizeof(struct dm_test_pdata),
-};
-
-static const struct udevice_id testfdt1_ids[] = {
-	{
-		.compatible = "denx,u-boot-fdt-test1",
-		.data = DM_TEST_TYPE_FIRST },
-	{ }
-};
-
-U_BOOT_DRIVER(testfdt1_drv) = {
-	.name	= "testfdt1_drv",
-	.of_match	= testfdt1_ids,
-	.id	= UCLASS_TEST_FDT,
-	.of_to_plat = testfdt_of_to_plat,
-	.probe	= testfdt_drv_probe,
-	.ops	= &test_ops,
-	.priv_auto	= sizeof(struct dm_test_priv),
-	.plat_auto	= sizeof(struct dm_test_pdata),
-	.flags = DM_FLAG_PRE_RELOC,
-};
-
-/* From here is the testfdt uclass code */
-int testfdt_ping(struct udevice *dev, int pingval, int *pingret)
-{
-	const struct test_ops *ops = device_get_ops(dev);
-
-	if (!ops->ping)
-		return -ENOSYS;
-
-	return ops->ping(dev, pingval, pingret);
-}
-
-UCLASS_DRIVER(testfdt) = {
-	.name		= "testfdt",
-	.id		= UCLASS_TEST_FDT,
-	.flags		= DM_UC_FLAG_SEQ_ALIAS,
-};
-
-static const struct udevice_id testfdtm_ids[] = {
-	{ .compatible = "denx,u-boot-fdtm-test" },
-	{ }
-};
-
-U_BOOT_DRIVER(testfdtm_drv) = {
-	.name	= "testfdtm_drv",
-	.of_match	= testfdtm_ids,
-	.id	= UCLASS_TEST_FDT_MANUAL,
-};
-
-UCLASS_DRIVER(testfdtm) = {
-	.name		= "testfdtm",
-	.id		= UCLASS_TEST_FDT_MANUAL,
-	.flags		= DM_UC_FLAG_SEQ_ALIAS | DM_UC_FLAG_NO_AUTO_SEQ,
-};
-
 struct dm_testprobe_pdata {
 	int probe_err;
 };
-- 
2.29.2.729.g45daf8777d-goog

^ permalink raw reply related	[flat|nested] 40+ messages in thread

* [PATCH v2 07/21] dtoc: Fix a few pylint warnings in dtb_platdata
  2020-12-23 15:11 [PATCH v2 00/21] dm: Preparation for enhanced of-platdata (part B) Simon Glass
                   ` (5 preceding siblings ...)
  2020-12-23 15:11 ` [PATCH v2 06/21] test: Move some test drivers into their own file Simon Glass
@ 2020-12-23 15:11 ` Simon Glass
  2020-12-23 15:11 ` [PATCH v2 08/21] dtoc: Make _output_list a top-level function Simon Glass
                   ` (31 subsequent siblings)
  38 siblings, 0 replies; 40+ messages in thread
From: Simon Glass @ 2020-12-23 15:11 UTC (permalink / raw)
  To: u-boot

These have crept in again. Update the file to fix all but these ones:

   dtb_platdata.py:143:0: R0902: Too many instance attributes (10/7)
      (too-many-instance-attributes)
   dtb_platdata.py:713:0: R0913: Too many arguments (6/5)
      (too-many-arguments)

Signed-off-by: Simon Glass <sjg@chromium.org>
---

(no changes since v1)

 tools/dtoc/dtb_platdata.py | 31 ++++++++++++++++---------------
 1 file changed, 16 insertions(+), 15 deletions(-)

diff --git a/tools/dtoc/dtb_platdata.py b/tools/dtoc/dtb_platdata.py
index 82671138a9a..cc3e58a1cd6 100644
--- a/tools/dtoc/dtb_platdata.py
+++ b/tools/dtoc/dtb_platdata.py
@@ -112,18 +112,19 @@ def get_value(ftype, value):
         str: String representation of the value
     """
     if ftype == fdt.Type.INT:
-        return '%#x' % fdt_util.fdt32_to_cpu(value)
+        val = '%#x' % fdt_util.fdt32_to_cpu(value)
     elif ftype == fdt.Type.BYTE:
         char = value[0]
-        return '%#x' % (ord(char) if isinstance(char, str) else char)
+        val = '%#x' % (ord(char) if isinstance(char, str) else char)
     elif ftype == fdt.Type.STRING:
         # Handle evil ACPI backslashes by adding another backslash before them.
         # So "\\_SB.GPO0" in the device tree effectively stays like that in C
-        return '"%s"' % value.replace('\\', '\\\\')
+        val = '"%s"' % value.replace('\\', '\\\\')
     elif ftype == fdt.Type.BOOL:
-        return 'true'
+        val = 'true'
     else:  # ftype == fdt.Type.INT64:
-        return '%#x' % value
+        val = '%#x' % value
+    return val
 
 def get_compat_name(node):
     """Get the node's list of compatible string as a C identifiers
@@ -131,7 +132,7 @@ def get_compat_name(node):
     Args:
         node (fdt.Node): Node object to check
     Return:
-        List of C identifiers for all the compatible strings
+        list of str: List of C identifiers for all the compatible strings
     """
     compat = node.props['compatible'].value
     if not isinstance(compat, list):
@@ -139,7 +140,7 @@ def get_compat_name(node):
     return [conv_name_to_c(c) for c in compat]
 
 
-class DtbPlatdata(object):
+class DtbPlatdata():
     """Provide a means to convert device tree binary data to platform data
 
     The output of this process is C structures which can be used in space-
@@ -183,7 +184,7 @@ class DtbPlatdata(object):
         and a lookup in driver_aliases printing a warning in case of failure.
 
         Args:
-            node: Node object to check
+            node (Node): Node object to check
         Return:
             Tuple:
                 Driver name associated with the first compatible string
@@ -330,7 +331,7 @@ class DtbPlatdata(object):
 
             # The following re will search for driver names declared as
             # U_BOOT_DRIVER(driver_name)
-            drivers = re.findall('U_BOOT_DRIVER\((.*)\)', buff)
+            drivers = re.findall(r'U_BOOT_DRIVER\((.*)\)', buff)
 
             for driver in drivers:
                 self._drivers.append(driver)
@@ -338,7 +339,7 @@ class DtbPlatdata(object):
             # The following re will search for driver aliases declared as
             # U_BOOT_DRIVER_ALIAS(alias, driver_name)
             driver_aliases = re.findall(
-                'U_BOOT_DRIVER_ALIAS\(\s*(\w+)\s*,\s*(\w+)\s*\)',
+                r'U_BOOT_DRIVER_ALIAS\(\s*(\w+)\s*,\s*(\w+)\s*\)',
                 buff)
 
             for alias in driver_aliases: # pragma: no cover
@@ -383,8 +384,8 @@ class DtbPlatdata(object):
         This adds each node to self._valid_nodes.
 
         Args:
-            root: Root node for scan
-            valid_nodes: List of Node objects to add to
+            root (Node): Root node for scan
+            valid_nodes (list of Node): List of Node objects to add to
         """
         for node in root.subnodes:
             if 'compatible' in node.props:
@@ -484,7 +485,7 @@ class DtbPlatdata(object):
         updated to match that width.
 
         Returns:
-            dict containing structures:
+            dict of dict: dict containing structures:
                 key (str): Node name, as a C identifier
                 value: dict containing structure fields:
                     key (str): Field name
@@ -559,7 +560,7 @@ class DtbPlatdata(object):
         doc/driver-model/of-plat.rst for more information.
 
         Args:
-            structs: dict containing structures:
+            structs (dict): dict containing structures:
                 key (str): Node name, as a C identifier
                 value: dict containing structure fields:
                     key (str): Field name
@@ -720,7 +721,7 @@ def run_steps(args, dtb_file, include_disabled, output, warning_disabled=False,
         output (str): Name of output file
         warning_disabled (bool): True to avoid showing warnings about missing
             drivers
-       _drivers_additional (list): List of additional drivers to use during
+        drivers_additional (list): List of additional drivers to use during
             scanning
     Raises:
         ValueError: if args has no command, or an unknown command
-- 
2.29.2.729.g45daf8777d-goog

^ permalink raw reply related	[flat|nested] 40+ messages in thread

* [PATCH v2 08/21] dtoc: Make _output_list a top-level function
  2020-12-23 15:11 [PATCH v2 00/21] dm: Preparation for enhanced of-platdata (part B) Simon Glass
                   ` (6 preceding siblings ...)
  2020-12-23 15:11 ` [PATCH v2 07/21] dtoc: Fix a few pylint warnings in dtb_platdata Simon Glass
@ 2020-12-23 15:11 ` Simon Glass
  2020-12-23 15:11 ` [PATCH v2 09/21] dtoc: Output the device in a separate function Simon Glass
                   ` (30 subsequent siblings)
  38 siblings, 0 replies; 40+ messages in thread
From: Simon Glass @ 2020-12-23 15:11 UTC (permalink / raw)
  To: u-boot

It is annoying to have this function inside its parent since it makes the
parent longer and hard to read. Move it to the top level.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

(no changes since v1)

 tools/dtoc/dtb_platdata.py | 80 +++++++++++++++++++-------------------
 1 file changed, 40 insertions(+), 40 deletions(-)

diff --git a/tools/dtoc/dtb_platdata.py b/tools/dtoc/dtb_platdata.py
index cc3e58a1cd6..372f756037e 100644
--- a/tools/dtoc/dtb_platdata.py
+++ b/tools/dtoc/dtb_platdata.py
@@ -592,51 +592,51 @@ class DtbPlatdata():
                 self.out(';\n')
             self.out('};\n')
 
+    def _output_list(self, node, prop):
+        """Output the C code for a devicetree property that holds a list
+
+        Args:
+            node (fdt.Node): Node to output
+            prop (fdt.Prop): Prop to output
+        """
+        self.buf('{')
+        vals = []
+        # For phandles, output a reference to the platform data
+        # of the target node.
+        info = self.get_phandle_argc(prop, node.name)
+        if info:
+            # Process the list as pairs of (phandle, id)
+            pos = 0
+            for args in info.args:
+                phandle_cell = prop.value[pos]
+                phandle = fdt_util.fdt32_to_cpu(phandle_cell)
+                target_node = self._fdt.phandle_to_node[phandle]
+                arg_values = []
+                for i in range(args):
+                    arg_values.append(
+                        str(fdt_util.fdt32_to_cpu(prop.value[pos + 1 + i])))
+                pos += 1 + args
+                vals.append('\t{%d, {%s}}' % (target_node.idx,
+                                              ', '.join(arg_values)))
+            for val in vals:
+                self.buf('\n\t\t%s,' % val)
+        else:
+            for val in prop.value:
+                vals.append(get_value(prop.type, val))
+
+            # Put 8 values per line to avoid very long lines.
+            for i in range(0, len(vals), 8):
+                if i:
+                    self.buf(',\n\t\t')
+                self.buf(', '.join(vals[i:i + 8]))
+        self.buf('}')
+
     def output_node(self, node):
         """Output the C code for a node
 
         Args:
             node (fdt.Node): node to output
         """
-        def _output_list(node, prop):
-            """Output the C code for a devicetree property that holds a list
-
-            Args:
-                node (fdt.Node): Node to output
-                prop (fdt.Prop): Prop to output
-            """
-            self.buf('{')
-            vals = []
-            # For phandles, output a reference to the platform data
-            # of the target node.
-            info = self.get_phandle_argc(prop, node.name)
-            if info:
-                # Process the list as pairs of (phandle, id)
-                pos = 0
-                for args in info.args:
-                    phandle_cell = prop.value[pos]
-                    phandle = fdt_util.fdt32_to_cpu(phandle_cell)
-                    target_node = self._fdt.phandle_to_node[phandle]
-                    arg_values = []
-                    for i in range(args):
-                        arg_values.append(
-                            str(fdt_util.fdt32_to_cpu(prop.value[pos + 1 + i])))
-                    pos += 1 + args
-                    vals.append('\t{%d, {%s}}' % (target_node.idx,
-                                                  ', '.join(arg_values)))
-                for val in vals:
-                    self.buf('\n\t\t%s,' % val)
-            else:
-                for val in prop.value:
-                    vals.append(get_value(prop.type, val))
-
-                # Put 8 values per line to avoid very long lines.
-                for i in range(0, len(vals), 8):
-                    if i:
-                        self.buf(',\n\t\t')
-                    self.buf(', '.join(vals[i:i + 8]))
-            self.buf('}')
-
         struct_name, _ = self.get_normalized_compat_name(node)
         var_name = conv_name_to_c(node.name)
         self.buf('/* Node %s index %d */\n' % (node.path, node.idx))
@@ -651,7 +651,7 @@ class DtbPlatdata():
 
             # Special handling for lists
             if isinstance(prop.value, list):
-                _output_list(node, prop)
+                self._output_list(node, prop)
             else:
                 self.buf(get_value(prop.type, prop.value))
             self.buf(',\n')
-- 
2.29.2.729.g45daf8777d-goog

^ permalink raw reply related	[flat|nested] 40+ messages in thread

* [PATCH v2 09/21] dtoc: Output the device in a separate function
  2020-12-23 15:11 [PATCH v2 00/21] dm: Preparation for enhanced of-platdata (part B) Simon Glass
                   ` (7 preceding siblings ...)
  2020-12-23 15:11 ` [PATCH v2 08/21] dtoc: Make _output_list a top-level function Simon Glass
@ 2020-12-23 15:11 ` Simon Glass
  2020-12-23 15:11 ` [PATCH v2 10/21] dtoc: Output the struct values " Simon Glass
                   ` (29 subsequent siblings)
  38 siblings, 0 replies; 40+ messages in thread
From: Simon Glass @ 2020-12-23 15:11 UTC (permalink / raw)
  To: u-boot

Reduce the length of output_node() by moving the device-output
functionality into a separate function.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

(no changes since v1)

 tools/dtoc/dtb_platdata.py | 33 ++++++++++++++++++++++-----------
 1 file changed, 22 insertions(+), 11 deletions(-)

diff --git a/tools/dtoc/dtb_platdata.py b/tools/dtoc/dtb_platdata.py
index 372f756037e..2d701ac24da 100644
--- a/tools/dtoc/dtb_platdata.py
+++ b/tools/dtoc/dtb_platdata.py
@@ -631,6 +631,27 @@ class DtbPlatdata():
                 self.buf(', '.join(vals[i:i + 8]))
         self.buf('}')
 
+    def _declare_device(self, var_name, struct_name, node_parent):
+        """Add a device declaration to the output
+
+        This declares a U_BOOT_DEVICE() for the device being processed
+
+        Args:
+            var_name (str): C name for the node
+            struct_name (str): Name for the dt struct associated with the node
+            node_parent (Node): Parent of the node (or None if none)
+        """
+        self.buf('U_BOOT_DEVICE(%s) = {\n' % var_name)
+        self.buf('\t.name\t\t= "%s",\n' % struct_name)
+        self.buf('\t.plat\t= &%s%s,\n' % (VAL_PREFIX, var_name))
+        self.buf('\t.plat_size\t= sizeof(%s%s),\n' % (VAL_PREFIX, var_name))
+        idx = -1
+        if node_parent and node_parent in self._valid_nodes:
+            idx = node_parent.idx
+        self.buf('\t.parent_idx\t= %d,\n' % idx)
+        self.buf('};\n')
+        self.buf('\n')
+
     def output_node(self, node):
         """Output the C code for a node
 
@@ -657,17 +678,7 @@ class DtbPlatdata():
             self.buf(',\n')
         self.buf('};\n')
 
-        # Add a device declaration
-        self.buf('U_BOOT_DEVICE(%s) = {\n' % var_name)
-        self.buf('\t.name\t\t= "%s",\n' % struct_name)
-        self.buf('\t.plat\t= &%s%s,\n' % (VAL_PREFIX, var_name))
-        self.buf('\t.plat_size\t= sizeof(%s%s),\n' % (VAL_PREFIX, var_name))
-        idx = -1
-        if node.parent and node.parent in self._valid_nodes:
-            idx = node.parent.idx
-        self.buf('\t.parent_idx\t= %d,\n' % idx)
-        self.buf('};\n')
-        self.buf('\n')
+        self._declare_device(var_name, struct_name, node.parent)
 
         self.out(''.join(self.get_buf()))
 
-- 
2.29.2.729.g45daf8777d-goog

^ permalink raw reply related	[flat|nested] 40+ messages in thread

* [PATCH v2 10/21] dtoc: Output the struct values in a separate function
  2020-12-23 15:11 [PATCH v2 00/21] dm: Preparation for enhanced of-platdata (part B) Simon Glass
                   ` (8 preceding siblings ...)
  2020-12-23 15:11 ` [PATCH v2 09/21] dtoc: Output the device in a separate function Simon Glass
@ 2020-12-23 15:11 ` Simon Glass
  2020-12-23 15:11 ` [PATCH v2 11/21] dtoc: Convert _drivers to a dict Simon Glass
                   ` (28 subsequent siblings)
  38 siblings, 0 replies; 40+ messages in thread
From: Simon Glass @ 2020-12-23 15:11 UTC (permalink / raw)
  To: u-boot

Reduce the length of output_node() futher by moving the struct-output
functionality into a two separate functions.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

(no changes since v1)

 tools/dtoc/dtb_platdata.py | 50 ++++++++++++++++++++++++++------------
 1 file changed, 34 insertions(+), 16 deletions(-)

diff --git a/tools/dtoc/dtb_platdata.py b/tools/dtoc/dtb_platdata.py
index 2d701ac24da..1d89f77a00b 100644
--- a/tools/dtoc/dtb_platdata.py
+++ b/tools/dtoc/dtb_platdata.py
@@ -652,6 +652,39 @@ class DtbPlatdata():
         self.buf('};\n')
         self.buf('\n')
 
+    def _output_prop(self, node, prop):
+        """Output a line containing the value of a struct member
+
+        Args:
+            node (Node): Node being output
+            prop (Prop): Prop object to output
+        """
+        if prop.name in PROP_IGNORE_LIST or prop.name[0] == '#':
+            return
+        member_name = conv_name_to_c(prop.name)
+        self.buf('\t%s= ' % tab_to(3, '.' + member_name))
+
+        # Special handling for lists
+        if isinstance(prop.value, list):
+            self._output_list(node, prop)
+        else:
+            self.buf(get_value(prop.type, prop.value))
+        self.buf(',\n')
+
+    def _output_values(self, var_name, struct_name, node):
+        """Output the definition of a device's struct values
+
+        Args:
+            var_name (str): C name for the node
+            struct_name (str): Name for the dt struct associated with the node
+            node (Node): Node being output
+        """
+        self.buf('static struct %s%s %s%s = {\n' %
+                 (STRUCT_PREFIX, struct_name, VAL_PREFIX, var_name))
+        for pname in sorted(node.props):
+            self._output_prop(node, node.props[pname])
+        self.buf('};\n')
+
     def output_node(self, node):
         """Output the C code for a node
 
@@ -661,23 +694,8 @@ class DtbPlatdata():
         struct_name, _ = self.get_normalized_compat_name(node)
         var_name = conv_name_to_c(node.name)
         self.buf('/* Node %s index %d */\n' % (node.path, node.idx))
-        self.buf('static struct %s%s %s%s = {\n' %
-                 (STRUCT_PREFIX, struct_name, VAL_PREFIX, var_name))
-        for pname in sorted(node.props):
-            prop = node.props[pname]
-            if pname in PROP_IGNORE_LIST or pname[0] == '#':
-                continue
-            member_name = conv_name_to_c(prop.name)
-            self.buf('\t%s= ' % tab_to(3, '.' + member_name))
-
-            # Special handling for lists
-            if isinstance(prop.value, list):
-                self._output_list(node, prop)
-            else:
-                self.buf(get_value(prop.type, prop.value))
-            self.buf(',\n')
-        self.buf('};\n')
 
+        self._output_values(var_name, struct_name, node)
         self._declare_device(var_name, struct_name, node.parent)
 
         self.out(''.join(self.get_buf()))
-- 
2.29.2.729.g45daf8777d-goog

^ permalink raw reply related	[flat|nested] 40+ messages in thread

* [PATCH v2 11/21] dtoc: Convert _drivers to a dict
  2020-12-23 15:11 [PATCH v2 00/21] dm: Preparation for enhanced of-platdata (part B) Simon Glass
                   ` (9 preceding siblings ...)
  2020-12-23 15:11 ` [PATCH v2 10/21] dtoc: Output the struct values " Simon Glass
@ 2020-12-23 15:11 ` Simon Glass
  2020-12-23 15:11 ` [PATCH v2 12/21] dtoc: Scan drivers for available information Simon Glass
                   ` (27 subsequent siblings)
  38 siblings, 0 replies; 40+ messages in thread
From: Simon Glass @ 2020-12-23 15:11 UTC (permalink / raw)
  To: u-boot

At present this member holds a simple list of driver names. Update it to
be a dict of DriverInfo, with the name being the key. This will allow more
information to be added about each driver, in future patches.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

Changes in v2:
- Rename DriverInfo to Driver
- Add a test for the new code and a comment for Driver

 tools/dtoc/dtb_platdata.py | 26 ++++++++++++++++++++++----
 tools/dtoc/test_dtoc.py    | 10 ++++++++++
 2 files changed, 32 insertions(+), 4 deletions(-)

diff --git a/tools/dtoc/dtb_platdata.py b/tools/dtoc/dtb_platdata.py
index 1d89f77a00b..5b1bb7e5fd9 100644
--- a/tools/dtoc/dtb_platdata.py
+++ b/tools/dtoc/dtb_platdata.py
@@ -64,6 +64,22 @@ PhandleInfo = collections.namedtuple('PhandleInfo', ['max_args', 'args'])
 PhandleLink = collections.namedtuple('PhandleLink', ['var_node', 'dev_name'])
 
 
+class Driver:
+    """Information about a driver in U-Boot
+
+    Attributes:
+        name: Name of driver. For U_BOOT_DRIVER(x) this is 'x'
+    """
+    def __init__(self, name):
+        self.name = name
+
+    def __eq__(self, other):
+        return self.name == other.name
+
+    def __repr__(self):
+        return "Driver(name='%s')" % self.name
+
+
 def conv_name_to_c(name):
     """Convert a device-tree name to a C identifier
 
@@ -156,7 +172,9 @@ class DtbPlatdata():
         _outfile: The current output file (sys.stdout or a real file)
         _warning_disabled: true to disable warnings about driver names not found
         _lines: Stashed list of output lines for outputting in the future
-        _drivers: List of valid driver names found in drivers/
+        _drivers: Dict of valid driver names found in drivers/
+            key: Driver name
+            value: Driver for that driver
         _driver_aliases: Dict that holds aliases for driver names
             key: Driver alias declared with
                 U_BOOT_DRIVER_ALIAS(driver_alias, driver_name)
@@ -172,7 +190,7 @@ class DtbPlatdata():
         self._outfile = None
         self._warning_disabled = warning_disabled
         self._lines = []
-        self._drivers = []
+        self._drivers = {}
         self._driver_aliases = {}
         self._drivers_additional = drivers_additional or []
 
@@ -196,7 +214,7 @@ class DtbPlatdata():
         compat_list_c = get_compat_name(node)
 
         for compat_c in compat_list_c:
-            if not compat_c in self._drivers:
+            if not compat_c in self._drivers.keys():
                 compat_c = self._driver_aliases.get(compat_c)
                 if not compat_c:
                     continue
@@ -334,7 +352,7 @@ class DtbPlatdata():
             drivers = re.findall(r'U_BOOT_DRIVER\((.*)\)', buff)
 
             for driver in drivers:
-                self._drivers.append(driver)
+                self._drivers[driver] = Driver(driver)
 
             # The following re will search for driver aliases declared as
             # U_BOOT_DRIVER_ALIAS(alias, driver_name)
diff --git a/tools/dtoc/test_dtoc.py b/tools/dtoc/test_dtoc.py
index 49ab75b85da..c76942c9e2d 100755
--- a/tools/dtoc/test_dtoc.py
+++ b/tools/dtoc/test_dtoc.py
@@ -906,3 +906,13 @@ U_BOOT_DEVICE(spl_test2) = {
         with test_util.capture_sys_output() as (stdout, stderr):
             dtb_platdata.run_steps(['struct'], dtb_file, False, output, True,
                                [driver_fn])
+
+    def testDriver(self):
+        """Test the Driver class"""
+        drv1 = dtb_platdata.Driver('fred')
+        drv2 = dtb_platdata.Driver('mary')
+        drv3 = dtb_platdata.Driver('fred')
+        self.assertEqual("Driver(name='fred')", str(drv1))
+        self.assertEqual(drv1, drv3)
+        self.assertNotEqual(drv1, drv2)
+        self.assertNotEqual(drv2, drv3)
-- 
2.29.2.729.g45daf8777d-goog

^ permalink raw reply related	[flat|nested] 40+ messages in thread

* [PATCH v2 12/21] dtoc: Scan drivers for available information
  2020-12-23 15:11 [PATCH v2 00/21] dm: Preparation for enhanced of-platdata (part B) Simon Glass
                   ` (10 preceding siblings ...)
  2020-12-23 15:11 ` [PATCH v2 11/21] dtoc: Convert _drivers to a dict Simon Glass
@ 2020-12-23 15:11 ` Simon Glass
  2020-12-23 15:11 ` [PATCH v2 13/21] dtoc: Allow use of the of_match_ptr() macro Simon Glass
                   ` (26 subsequent siblings)
  38 siblings, 0 replies; 40+ messages in thread
From: Simon Glass @ 2020-12-23 15:11 UTC (permalink / raw)
  To: u-boot

At present we simply record the name of a driver parsed from its
implementation file. We also need to get the uclass and a few other
things so we can instantiate devices at build time. Add support for
collecting this information. This requires parsing each driver file.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

(no changes since v1)

 tools/dtoc/dtb_platdata.py | 171 ++++++++++++++++++++++++++++++++++---
 tools/dtoc/test_dtoc.py    | 101 +++++++++++++++++++++-
 2 files changed, 258 insertions(+), 14 deletions(-)

diff --git a/tools/dtoc/dtb_platdata.py b/tools/dtoc/dtb_platdata.py
index 5b1bb7e5fd9..51c4d1cae00 100644
--- a/tools/dtoc/dtb_platdata.py
+++ b/tools/dtoc/dtb_platdata.py
@@ -69,15 +69,26 @@ class Driver:
 
     Attributes:
         name: Name of driver. For U_BOOT_DRIVER(x) this is 'x'
+        uclass_id: Name of uclass (e.g. 'UCLASS_I2C')
+        compat: Driver data for each compatible string:
+            key: Compatible string, e.g. 'rockchip,rk3288-grf'
+            value: Driver data, e,g, 'ROCKCHIP_SYSCON_GRF', or None
     """
-    def __init__(self, name):
+    def __init__(self, name, uclass_id, compat):
         self.name = name
+        self.uclass_id = uclass_id
+        self.compat = compat
+        self.priv_size = 0
 
     def __eq__(self, other):
-        return self.name == other.name
+        return (self.name == other.name and
+                self.uclass_id == other.uclass_id and
+                self.compat == other.compat and
+                self.priv_size == other.priv_size)
 
     def __repr__(self):
-        return "Driver(name='%s')" % self.name
+        return ("Driver(name='%s', uclass_id='%s', compat=%s, priv_size=%s)" %
+                (self.name, self.uclass_id, self.compat, self.priv_size))
 
 
 def conv_name_to_c(name):
@@ -180,6 +191,12 @@ class DtbPlatdata():
                 U_BOOT_DRIVER_ALIAS(driver_alias, driver_name)
             value: Driver name declared with U_BOOT_DRIVER(driver_name)
         _drivers_additional: List of additional drivers to use during scanning
+        _of_match: Dict holding information about compatible strings
+            key: Name of struct udevice_id variable
+            value: Dict of compatible info in that variable:
+               key: Compatible string, e.g. 'rockchip,rk3288-grf'
+               value: Driver data, e,g, 'ROCKCHIP_SYSCON_GRF', or None
+        _compat_to_driver: Maps compatible strings to Driver
     """
     def __init__(self, dtb_fname, include_disabled, warning_disabled,
                  drivers_additional=None):
@@ -193,6 +210,8 @@ class DtbPlatdata():
         self._drivers = {}
         self._driver_aliases = {}
         self._drivers_additional = drivers_additional or []
+        self._of_match = {}
+        self._compat_to_driver = {}
 
     def get_normalized_compat_name(self, node):
         """Get a node's normalized compat name
@@ -331,10 +350,144 @@ class DtbPlatdata():
             return PhandleInfo(max_args, args)
         return None
 
+    def _parse_driver(self, fname, buff):
+        """Parse a C file to extract driver information contained within
+
+        This parses U_BOOT_DRIVER() structs to obtain various pieces of useful
+        information.
+
+        It updates the following members:
+            _drivers - updated with new Driver records for each driver found
+                in the file
+            _of_match - updated with each compatible string found in the file
+            _compat_to_driver - Maps compatible string to Driver
+
+        Args:
+            fname (str): Filename being parsed (used for warnings)
+            buff (str): Contents of file
+
+        Raises:
+            ValueError: Compatible variable is mentioned in .of_match in
+                U_BOOT_DRIVER() but not found in the file
+        """
+        # Dict holding information about compatible strings collected in this
+        # function so far
+        #    key: Name of struct udevice_id variable
+        #    value: Dict of compatible info in that variable:
+        #       key: Compatible string, e.g. 'rockchip,rk3288-grf'
+        #       value: Driver data, e,g, 'ROCKCHIP_SYSCON_GRF', or None
+        of_match = {}
+
+        # Dict holding driver information collected in this function so far
+        #    key: Driver name (C name as in U_BOOT_DRIVER(xxx))
+        #    value: Driver
+        drivers = {}
+
+        # Collect the driver name (None means not found yet)
+        driver_name = None
+        re_driver = re.compile(r'U_BOOT_DRIVER\((.*)\)')
+
+        # Collect the uclass ID, e.g. 'UCLASS_SPI'
+        uclass_id = None
+        re_id = re.compile(r'\s*\.id\s*=\s*(UCLASS_[A-Z0-9_]+)')
+
+        # Collect the compatible string, e.g. 'rockchip,rk3288-grf'
+        compat = None
+        re_compat = re.compile(r'{\s*.compatible\s*=\s*"(.*)"\s*'
+                               r'(,\s*.data\s*=\s*(.*))?\s*},')
+
+        # This is a dict of compatible strings that were found:
+        #    key: Compatible string, e.g. 'rockchip,rk3288-grf'
+        #    value: Driver data, e,g, 'ROCKCHIP_SYSCON_GRF', or None
+        compat_dict = {}
+
+        # Holds the var nane of the udevice_id list, e.g.
+        # 'rk3288_syscon_ids_noc' in
+        # static const struct udevice_id rk3288_syscon_ids_noc[] = {
+        ids_name = None
+        re_ids = re.compile(r'struct udevice_id (.*)\[\]\s*=')
+
+        # Matches the references to the udevice_id list
+        re_of_match = re.compile(r'\.of_match\s*=\s*([a-z0-9_]+),')
+
+        # Matches the header/size information for priv
+        re_priv = re.compile(r'^\s*DM_PRIV\((.*)\)$')
+        prefix = ''
+        for line in buff.splitlines():
+            # Handle line continuation
+            if prefix:
+                line = prefix + line
+                prefix = ''
+            if line.endswith('\\'):
+                prefix = line[:-1]
+                continue
+
+            driver_match = re_driver.search(line)
+
+            # If we have seen U_BOOT_DRIVER()...
+            if driver_name:
+                id_m = re_id.search(line)
+                id_of_match = re_of_match.search(line)
+                if id_m:
+                    uclass_id = id_m.group(1)
+                elif id_of_match:
+                    compat = id_of_match.group(1)
+                elif '};' in line:
+                    if uclass_id and compat:
+                        if compat not in of_match:
+                            raise ValueError(
+                                "%s: Unknown compatible var '%s' (found: %s)" %
+                                (fname, compat, ','.join(of_match.keys())))
+                        driver = Driver(driver_name, uclass_id,
+                                        of_match[compat])
+                        drivers[driver_name] = driver
+
+                        # This needs to be deterministic, since a driver may
+                        # have multiple compatible strings pointing to it.
+                        # We record the one earliest in the alphabet so it
+                        # will produce the same result on all machines.
+                        for compat_id in of_match[compat]:
+                            old = self._compat_to_driver.get(compat_id)
+                            if not old or driver.name < old.name:
+                                self._compat_to_driver[compat_id] = driver
+                    else:
+                        # The driver does not have a uclass or compat string.
+                        # The first is required but the second is not, so just
+                        # ignore this.
+                        pass
+                    driver_name = None
+                    uclass_id = None
+                    ids_name = None
+                    compat = None
+                    compat_dict = {}
+
+            elif ids_name:
+                compat_m = re_compat.search(line)
+                if compat_m:
+                    compat_dict[compat_m.group(1)] = compat_m.group(3)
+                elif '};' in line:
+                    of_match[ids_name] = compat_dict
+                    ids_name = None
+            elif driver_match:
+                driver_name = driver_match.group(1)
+            else:
+                ids_m = re_ids.search(line)
+                if ids_m:
+                    ids_name = ids_m.group(1)
+
+        # Make the updates based on what we found
+        self._drivers.update(drivers)
+        self._of_match.update(of_match)
+
     def scan_driver(self, fname):
         """Scan a driver file to build a list of driver names and aliases
 
-        This procedure will populate self._drivers and self._driver_aliases
+        It updates the following members:
+            _drivers - updated with new Driver records for each driver found
+                in the file
+            _of_match - updated with each compatible string found in the file
+            _compat_to_driver - Maps compatible string to Driver
+            _driver_aliases - Maps alias names to driver name
 
         Args
             fname: Driver filename to scan
@@ -347,12 +500,10 @@ class DtbPlatdata():
                 print("Skipping file '%s' due to unicode error" % fname)
                 return
 
-            # The following re will search for driver names declared as
-            # U_BOOT_DRIVER(driver_name)
-            drivers = re.findall(r'U_BOOT_DRIVER\((.*)\)', buff)
-
-            for driver in drivers:
-                self._drivers[driver] = Driver(driver)
+            # If this file has any U_BOOT_DRIVER() declarations, process it to
+            # obtain driver information
+            if 'U_BOOT_DRIVER' in buff:
+                self._parse_driver(fname, buff)
 
             # The following re will search for driver aliases declared as
             # U_BOOT_DRIVER_ALIAS(alias, driver_name)
diff --git a/tools/dtoc/test_dtoc.py b/tools/dtoc/test_dtoc.py
index c76942c9e2d..89192797781 100755
--- a/tools/dtoc/test_dtoc.py
+++ b/tools/dtoc/test_dtoc.py
@@ -18,6 +18,7 @@ import unittest
 
 from dtoc import dtb_platdata
 from dtb_platdata import conv_name_to_c
+from dtb_platdata import Driver
 from dtb_platdata import get_compat_name
 from dtb_platdata import get_value
 from dtb_platdata import tab_to
@@ -71,6 +72,17 @@ def get_dtb_file(dts_fname, capture_stderr=False):
                                    capture_stderr=capture_stderr)
 
 
+class FakeNode:
+    """Fake Node object for testing"""
+    def __init__(self):
+        pass
+
+class FakeProp:
+    """Fake Prop object for testing"""
+    def __init__(self):
+        pass
+
+
 class TestDtoc(unittest.TestCase):
     """Tests for dtoc"""
     @classmethod
@@ -909,10 +921,91 @@ U_BOOT_DEVICE(spl_test2) = {
 
     def testDriver(self):
         """Test the Driver class"""
-        drv1 = dtb_platdata.Driver('fred')
-        drv2 = dtb_platdata.Driver('mary')
-        drv3 = dtb_platdata.Driver('fred')
-        self.assertEqual("Driver(name='fred')", str(drv1))
+        i2c = 'I2C_UCLASS'
+        compat = {'rockchip,rk3288-grf': 'ROCKCHIP_SYSCON_GRF',
+                  'rockchip,rk3288-srf': None}
+        drv1 = dtb_platdata.Driver('fred', i2c, compat)
+        drv2 = dtb_platdata.Driver('mary', i2c, {})
+        drv3 = dtb_platdata.Driver('fred', i2c, compat)
+        self.assertEqual(
+            "Driver(name='fred', uclass_id='I2C_UCLASS', "
+            "compat={'rockchip,rk3288-grf': 'ROCKCHIP_SYSCON_GRF', "
+            "'rockchip,rk3288-srf': None}, priv_size=0)", str(drv1))
         self.assertEqual(drv1, drv3)
         self.assertNotEqual(drv1, drv2)
         self.assertNotEqual(drv2, drv3)
+
+    def testScan(self):
+        """Test scanning of a driver"""
+        fname = os.path.join(our_path, '..', '..', 'drivers/i2c/tegra_i2c.c')
+        buff = tools.ReadFile(fname, False)
+        dpd = dtb_platdata.DtbPlatdata(None, False, False)
+        dpd._parse_driver(fname, buff)
+        self.assertIn('i2c_tegra', dpd._drivers)
+        drv = dpd._drivers['i2c_tegra']
+        self.assertEqual('i2c_tegra', drv.name)
+        self.assertEqual('UCLASS_I2C', drv.uclass_id)
+        self.assertEqual(
+            {'nvidia,tegra114-i2c': 'TYPE_114 ',
+             'nvidia,tegra20-i2c': 'TYPE_STD ',
+             'nvidia,tegra20-i2c-dvc': 'TYPE_DVC '}, drv.compat)
+        self.assertEqual(0, drv.priv_size)
+        self.assertEqual(1, len(dpd._drivers))
+
+    def testNormalizedName(self):
+        """Test operation of get_normalized_compat_name()"""
+        prop = FakeNode()
+        prop.name = 'compatible'
+        prop.value = 'rockchip,rk3288-grf'
+        node = FakeProp()
+        node.props = {'compatible': prop}
+        dpd = dtb_platdata.DtbPlatdata(None, False, False)
+        with test_util.capture_sys_output() as (stdout, stderr):
+            name, aliases = dpd.get_normalized_compat_name(node)
+        self.assertEqual('rockchip_rk3288_grf', name)
+        self.assertEqual([], aliases)
+        self.assertEqual(
+            'WARNING: the driver rockchip_rk3288_grf was not found in the driver list',
+            stdout.getvalue().strip())
+
+        i2c = 'I2C_UCLASS'
+        compat = {'rockchip,rk3288-grf': 'ROCKCHIP_SYSCON_GRF',
+                  'rockchip,rk3288-srf': None}
+        drv = dtb_platdata.Driver('fred', i2c, compat)
+        dpd._drivers['rockchip_rk3288_grf'] = drv
+
+        dpd._driver_aliases['rockchip_rk3288_srf'] = 'rockchip_rk3288_grf'
+
+        with test_util.capture_sys_output() as (stdout, stderr):
+            name, aliases = dpd.get_normalized_compat_name(node)
+        self.assertEqual('', stdout.getvalue().strip())
+        self.assertEqual('rockchip_rk3288_grf', name)
+        self.assertEqual([], aliases)
+
+        prop.value = 'rockchip,rk3288-srf'
+        with test_util.capture_sys_output() as (stdout, stderr):
+            name, aliases = dpd.get_normalized_compat_name(node)
+        self.assertEqual('', stdout.getvalue().strip())
+        self.assertEqual('rockchip_rk3288_grf', name)
+        self.assertEqual(['rockchip_rk3288_srf'], aliases)
+
+    def testScanErrors(self):
+        """Test detection of scanning errors"""
+        buff = '''
+static const struct udevice_id tegra_i2c_ids2[] = {
+	{ .compatible = "nvidia,tegra114-i2c", .data = TYPE_114 },
+	{ }
+};
+
+U_BOOT_DRIVER(i2c_tegra) = {
+	.name	= "i2c_tegra",
+	.id	= UCLASS_I2C,
+	.of_match = tegra_i2c_ids,
+};
+'''
+        dpd = dtb_platdata.DtbPlatdata(None, False, False)
+        with self.assertRaises(ValueError) as e:
+            dpd._parse_driver('file.c', buff)
+        self.assertIn(
+            "file.c: Unknown compatible var 'tegra_i2c_ids' (found: tegra_i2c_ids2)",
+            str(e.exception))
-- 
2.29.2.729.g45daf8777d-goog

^ permalink raw reply related	[flat|nested] 40+ messages in thread

* [PATCH v2 13/21] dtoc: Allow use of the of_match_ptr() macro
  2020-12-23 15:11 [PATCH v2 00/21] dm: Preparation for enhanced of-platdata (part B) Simon Glass
                   ` (11 preceding siblings ...)
  2020-12-23 15:11 ` [PATCH v2 12/21] dtoc: Scan drivers for available information Simon Glass
@ 2020-12-23 15:11 ` Simon Glass
  2020-12-23 15:11 ` [PATCH v2 14/21] x86: apl: Use const for driver operations Simon Glass
                   ` (25 subsequent siblings)
  38 siblings, 0 replies; 40+ messages in thread
From: Simon Glass @ 2020-12-23 15:11 UTC (permalink / raw)
  To: u-boot

Update the regex for the of_match member to allow of_match_ptr() so it
matches both:

	.of_match	= apl_hostbridge_ids,
and
	.of_match	= of_match_ptr(apl_hostbridge_ids),

Without this, dtoc emits warnings and cannot find the drivers.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

(no changes since v1)

 tools/dtoc/dtb_platdata.py |  5 +++--
 tools/dtoc/test_dtoc.py    | 20 ++++++++++++++++++++
 2 files changed, 23 insertions(+), 2 deletions(-)

diff --git a/tools/dtoc/dtb_platdata.py b/tools/dtoc/dtb_platdata.py
index 51c4d1cae00..9c2bd18f5a4 100644
--- a/tools/dtoc/dtb_platdata.py
+++ b/tools/dtoc/dtb_platdata.py
@@ -408,7 +408,8 @@ class DtbPlatdata():
         re_ids = re.compile(r'struct udevice_id (.*)\[\]\s*=')
 
         # Matches the references to the udevice_id list
-        re_of_match = re.compile(r'\.of_match\s*=\s*([a-z0-9_]+),')
+        re_of_match = re.compile(
+            r'\.of_match\s*=\s*(of_match_ptr\()?([a-z0-9_]+)(\))?,')
 
         # Matches the header/size information for priv
         re_priv = re.compile(r'^\s*DM_PRIV\((.*)\)$')
@@ -431,7 +432,7 @@ class DtbPlatdata():
                 if id_m:
                     uclass_id = id_m.group(1)
                 elif id_of_match:
-                    compat = id_of_match.group(1)
+                    compat = id_of_match.group(2)
                 elif '};' in line:
                     if uclass_id and compat:
                         if compat not in of_match:
diff --git a/tools/dtoc/test_dtoc.py b/tools/dtoc/test_dtoc.py
index 89192797781..1fd981f51e1 100755
--- a/tools/dtoc/test_dtoc.py
+++ b/tools/dtoc/test_dtoc.py
@@ -1009,3 +1009,23 @@ U_BOOT_DRIVER(i2c_tegra) = {
         self.assertIn(
             "file.c: Unknown compatible var 'tegra_i2c_ids' (found: tegra_i2c_ids2)",
             str(e.exception))
+
+    def testOfmatch(self):
+        """Test detection of of_match_ptr() member"""
+        buff = '''
+static const struct udevice_id tegra_i2c_ids[] = {
+	{ .compatible = "nvidia,tegra114-i2c", .data = TYPE_114 },
+	{ }
+};
+
+U_BOOT_DRIVER(i2c_tegra) = {
+	.name	= "i2c_tegra",
+	.id	= UCLASS_I2C,
+	.of_match = of_match_ptr(tegra_i2c_ids),
+};
+'''
+        dpd = dtb_platdata.DtbPlatdata(None, False, False)
+        dpd._parse_driver('file.c', buff)
+        self.assertIn('i2c_tegra', dpd._drivers)
+        drv = dpd._drivers['i2c_tegra']
+        self.assertEqual('i2c_tegra', drv.name)
-- 
2.29.2.729.g45daf8777d-goog

^ permalink raw reply related	[flat|nested] 40+ messages in thread

* [PATCH v2 14/21] x86: apl: Use const for driver operations
  2020-12-23 15:11 [PATCH v2 00/21] dm: Preparation for enhanced of-platdata (part B) Simon Glass
                   ` (12 preceding siblings ...)
  2020-12-23 15:11 ` [PATCH v2 13/21] dtoc: Allow use of the of_match_ptr() macro Simon Glass
@ 2020-12-23 15:11 ` Simon Glass
  2020-12-23 15:11 ` [PATCH v2 15/21] x86: Move call64 into its own section Simon Glass
                   ` (24 subsequent siblings)
  38 siblings, 0 replies; 40+ messages in thread
From: Simon Glass @ 2020-12-23 15:11 UTC (permalink / raw)
  To: u-boot

Update these declarations to const to ensure that the data ends up in the
rodata section.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

(no changes since v1)

 arch/x86/cpu/apollolake/pmc.c    | 2 +-
 arch/x86/cpu/intel_common/p2sb.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/x86/cpu/apollolake/pmc.c b/arch/x86/cpu/apollolake/pmc.c
index 290b2cb3e71..c40065ab8cf 100644
--- a/arch/x86/cpu/apollolake/pmc.c
+++ b/arch/x86/cpu/apollolake/pmc.c
@@ -205,7 +205,7 @@ static int apl_pmc_probe(struct udevice *dev)
 	return 0;
 }
 
-static struct acpi_pmc_ops apl_pmc_ops = {
+static const struct acpi_pmc_ops apl_pmc_ops = {
 	.init			= apl_pmc_fill_power_state,
 	.prev_sleep_state	= apl_prev_sleep_state,
 	.disable_tco		= apl_disable_tco,
diff --git a/arch/x86/cpu/intel_common/p2sb.c b/arch/x86/cpu/intel_common/p2sb.c
index e6edab0b056..3765eeeab0d 100644
--- a/arch/x86/cpu/intel_common/p2sb.c
+++ b/arch/x86/cpu/intel_common/p2sb.c
@@ -180,7 +180,7 @@ static int p2sb_child_post_bind(struct udevice *dev)
 	return 0;
 }
 
-struct p2sb_ops p2sb_ops = {
+static const struct p2sb_ops p2sb_ops = {
 	.set_hide	= intel_p2sb_set_hide,
 };
 
-- 
2.29.2.729.g45daf8777d-goog

^ permalink raw reply related	[flat|nested] 40+ messages in thread

* [PATCH v2 15/21] x86: Move call64 into its own section
  2020-12-23 15:11 [PATCH v2 00/21] dm: Preparation for enhanced of-platdata (part B) Simon Glass
                   ` (13 preceding siblings ...)
  2020-12-23 15:11 ` [PATCH v2 14/21] x86: apl: Use const for driver operations Simon Glass
@ 2020-12-23 15:11 ` Simon Glass
  2020-12-23 15:11 ` [PATCH v2 16/21] x86: coral: Move fsp-m settings to a subnode Simon Glass
                   ` (23 subsequent siblings)
  38 siblings, 0 replies; 40+ messages in thread
From: Simon Glass @ 2020-12-23 15:11 UTC (permalink / raw)
  To: u-boot

When this code is not used (e.g. by TPL) we want it to be excluded from
the image. Put it in its own section so that this happens.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

(no changes since v1)

 arch/x86/cpu/i386/call64.S | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/x86/cpu/i386/call64.S b/arch/x86/cpu/i386/call64.S
index 275063c4af8..0ffc1006bbf 100644
--- a/arch/x86/cpu/i386/call64.S
+++ b/arch/x86/cpu/i386/call64.S
@@ -11,6 +11,7 @@
 #include <asm/processor-flags.h>
 
 .code32
+.section .text_call64
 .globl cpu_call64
 cpu_call64:
 	/*
-- 
2.29.2.729.g45daf8777d-goog

^ permalink raw reply related	[flat|nested] 40+ messages in thread

* [PATCH v2 16/21] x86: coral: Move fsp-m settings to a subnode
  2020-12-23 15:11 [PATCH v2 00/21] dm: Preparation for enhanced of-platdata (part B) Simon Glass
                   ` (14 preceding siblings ...)
  2020-12-23 15:11 ` [PATCH v2 15/21] x86: Move call64 into its own section Simon Glass
@ 2020-12-23 15:11 ` Simon Glass
  2020-12-23 15:11 ` [PATCH v2 17/21] x86: apl: Update hostbridge to remove unwanted TPL code Simon Glass
                   ` (22 subsequent siblings)
  38 siblings, 0 replies; 40+ messages in thread
From: Simon Glass @ 2020-12-23 15:11 UTC (permalink / raw)
  To: u-boot

At present these settings are in the node for host-bridge and so are
visible in TPL as well as SPL. But they are only used for SPL.

Move them to a subnode so that TPL does not included them.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

(no changes since v1)

 arch/x86/cpu/apollolake/fsp_m.c   | 5 ++++-
 arch/x86/dts/chromebook_coral.dts | 5 +++++
 2 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/arch/x86/cpu/apollolake/fsp_m.c b/arch/x86/cpu/apollolake/fsp_m.c
index cef937573b0..c6be707e4ea 100644
--- a/arch/x86/cpu/apollolake/fsp_m.c
+++ b/arch/x86/cpu/apollolake/fsp_m.c
@@ -32,7 +32,10 @@ int fspm_update_config(struct udevice *dev, struct fspm_upd *upd)
 
 	node = dev_ofnode(dev);
 	if (!ofnode_valid(node))
-		return log_msg_ret("fsp-m settings", -ENOENT);
+		return log_msg_ret("node", -ENOENT);
+	node = ofnode_find_subnode(node, "fsp-m");
+	if (!ofnode_valid(node))
+		return log_msg_ret("fspm", -ENOENT);
 
 	ret = fsp_m_update_config_from_dtb(node, cfg);
 	if (ret)
diff --git a/arch/x86/dts/chromebook_coral.dts b/arch/x86/dts/chromebook_coral.dts
index d66e128ae62..3c8fdf23809 100644
--- a/arch/x86/dts/chromebook_coral.dts
+++ b/arch/x86/dts/chromebook_coral.dts
@@ -174,6 +174,9 @@
 			 */
 			fsp_s: fsp-s {
 			};
+			fsp_m: fsp-m {
+				u-boot,dm-spl;
+			};
 
 			nhlt {
 				intel,dmic-channels = <4>;
@@ -650,7 +653,9 @@
 		PAD_CFG_NF(LPC_CLKRUNB, UP_20K, DEEP, NF1) /* LPC_CLKRUN_N */
 		PAD_CFG_NF(LPC_FRAMEB, NATIVE, DEEP, NF1) /* LPC_FRAME_N */
 		>;
+};
 
+&fsp_m {
 	fspm,package = <PACKAGE_BGA>;
 	fspm,profile = <PROFILE_LPDDR4_2400_24_22_22>;
 	fspm,memory-down = <MEMORY_DOWN_YES>;
-- 
2.29.2.729.g45daf8777d-goog

^ permalink raw reply related	[flat|nested] 40+ messages in thread

* [PATCH v2 17/21] x86: apl: Update hostbridge to remove unwanted TPL code
  2020-12-23 15:11 [PATCH v2 00/21] dm: Preparation for enhanced of-platdata (part B) Simon Glass
                   ` (15 preceding siblings ...)
  2020-12-23 15:11 ` [PATCH v2 16/21] x86: coral: Move fsp-m settings to a subnode Simon Glass
@ 2020-12-23 15:11 ` Simon Glass
  2020-12-23 15:11 ` [PATCH v2 18/21] x86: apl: Reduce size for TPL Simon Glass
                   ` (21 subsequent siblings)
  38 siblings, 0 replies; 40+ messages in thread
From: Simon Glass @ 2020-12-23 15:11 UTC (permalink / raw)
  To: u-boot

At present several strings from this file appear in the TPL binary. Add
preprocessor checks to drop them.

This reduces the TPL binary size by about 128 bytes.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

(no changes since v1)

 arch/x86/cpu/apollolake/hostbridge.c | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/arch/x86/cpu/apollolake/hostbridge.c b/arch/x86/cpu/apollolake/hostbridge.c
index e4674f3788a..9ec2309d086 100644
--- a/arch/x86/cpu/apollolake/hostbridge.c
+++ b/arch/x86/cpu/apollolake/hostbridge.c
@@ -60,6 +60,7 @@ struct apl_hostbridge_plat {
 	pci_dev_t bdf;
 };
 
+#if CONFIG_IS_ENABLED(GENERATE_ACPI_TABLE)
 static const struct nhlt_format_config dmic_1ch_formats[] = {
 	/* 48 KHz 16-bits per sample. */
 	{
@@ -155,6 +156,7 @@ static const struct nhlt_endp_descriptor dmic_4ch_descriptors[] = {
 		.num_formats = ARRAY_SIZE(dmic_4ch_formats),
 	},
 };
+#endif
 
 static int apl_hostbridge_early_init_pinctrl(struct udevice *dev)
 {
@@ -283,7 +285,7 @@ static int apl_acpi_hb_get_name(const struct udevice *dev, char *out_name)
 	return acpi_copy_name(out_name, "RHUB");
 }
 
-#ifdef CONFIG_GENERATE_ACPI_TABLE
+#if CONFIG_IS_ENABLED(GENERATE_ACPI_TABLE)
 static int apl_acpi_hb_write_tables(const struct udevice *dev,
 				    struct acpi_ctx *ctx)
 {
@@ -322,7 +324,6 @@ static int apl_acpi_hb_write_tables(const struct udevice *dev,
 
 	return 0;
 }
-#endif
 
 static int apl_acpi_setup_nhlt(const struct udevice *dev, struct acpi_ctx *ctx)
 {
@@ -347,6 +348,7 @@ static int apl_acpi_setup_nhlt(const struct udevice *dev, struct acpi_ctx *ctx)
 
 	return log_msg_ret("channels", -EINVAL);
 }
+#endif
 
 static int apl_hostbridge_remove(struct udevice *dev)
 {
@@ -385,21 +387,23 @@ ulong sa_get_tseg_base(struct udevice *dev)
 
 struct acpi_ops apl_hostbridge_acpi_ops = {
 	.get_name	= apl_acpi_hb_get_name,
-#ifdef CONFIG_GENERATE_ACPI_TABLE
+#if CONFIG_IS_ENABLED(GENERATE_ACPI_TABLE)
 	.write_tables	= apl_acpi_hb_write_tables,
-#endif
 	.setup_nhlt	= apl_acpi_setup_nhlt,
+#endif
 };
 
+#if !CONFIG_IS_ENABLED(OF_PLATDATA)
 static const struct udevice_id apl_hostbridge_ids[] = {
 	{ .compatible = "intel,apl-hostbridge" },
 	{ }
 };
+#endif
 
 U_BOOT_DRIVER(intel_apl_hostbridge) = {
 	.name		= "intel_apl_hostbridge",
 	.id		= UCLASS_NORTHBRIDGE,
-	.of_match	= apl_hostbridge_ids,
+	.of_match	= of_match_ptr(apl_hostbridge_ids),
 	.of_to_plat = apl_hostbridge_of_to_plat,
 	.probe		= apl_hostbridge_probe,
 	.remove		= apl_hostbridge_remove,
-- 
2.29.2.729.g45daf8777d-goog

^ permalink raw reply related	[flat|nested] 40+ messages in thread

* [PATCH v2 18/21] x86: apl: Reduce size for TPL
  2020-12-23 15:11 [PATCH v2 00/21] dm: Preparation for enhanced of-platdata (part B) Simon Glass
                   ` (16 preceding siblings ...)
  2020-12-23 15:11 ` [PATCH v2 17/21] x86: apl: Update hostbridge to remove unwanted TPL code Simon Glass
@ 2020-12-23 15:11 ` Simon Glass
  2020-12-23 15:11 ` [PATCH v2 19/21] x86: pinctrl: Drop unlikely error messages from TPL Simon Glass
                   ` (20 subsequent siblings)
  38 siblings, 0 replies; 40+ messages in thread
From: Simon Glass @ 2020-12-23 15:11 UTC (permalink / raw)
  To: u-boot

Update various drivers to use of_match_ptr() and to avoid including debug
strings in TPL. Omit the WiFi driver entirely, since it is not used in
TPL.

This reduces the TPL binary size by about 608 bytes.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

(no changes since v1)

 arch/x86/cpu/apollolake/lpc.c            | 13 ++++++++-----
 arch/x86/cpu/apollolake/pch.c            |  4 +++-
 arch/x86/cpu/apollolake/pmc.c            |  4 +++-
 arch/x86/cpu/apollolake/uart.c           |  4 +++-
 arch/x86/cpu/intel_common/Makefile       |  2 +-
 arch/x86/cpu/intel_common/itss.c         |  4 +++-
 arch/x86/cpu/intel_common/p2sb.c         |  4 +++-
 arch/x86/cpu/turbo.c                     |  5 +++++
 board/google/chromebook_coral/coral.c    |  4 +++-
 drivers/gpio/intel_gpio.c                |  4 +++-
 drivers/pinctrl/intel/pinctrl_apl.c      |  4 +++-
 drivers/power/acpi_pmc/acpi-pmc-uclass.c |  4 +++-
 drivers/timer/tsc_timer.c                |  4 +++-
 13 files changed, 44 insertions(+), 16 deletions(-)

diff --git a/arch/x86/cpu/apollolake/lpc.c b/arch/x86/cpu/apollolake/lpc.c
index d8e05f6a8f4..e085890d638 100644
--- a/arch/x86/cpu/apollolake/lpc.c
+++ b/arch/x86/cpu/apollolake/lpc.c
@@ -81,10 +81,11 @@ int lpc_open_pmio_window(uint base, uint size)
 
 		lgir_reg_num = find_unused_pmio_window();
 		if (lgir_reg_num < 0) {
-			log_err("LPC: Cannot open IO window: %lx size %lx\n",
-				bridge_base, size - bridged_size);
-			log_err("No more IO windows\n");
-
+			if (spl_phase() > PHASE_TPL) {
+				log_err("LPC: Cannot open IO window: %lx size %lx\n",
+					bridge_base, size - bridged_size);
+				log_err("No more IO windows\n");
+			}
 			return -ENOSPC;
 		}
 		lgir_reg_offset = LPC_GENERIC_IO_RANGE(lgir_reg_num);
@@ -127,15 +128,17 @@ struct acpi_ops apl_lpc_acpi_ops = {
 	.inject_dsdt	= southbridge_inject_dsdt,
 };
 
+#if !CONFIG_IS_ENABLED(OF_PLATDATA)
 static const struct udevice_id apl_lpc_ids[] = {
 	{ .compatible = "intel,apl-lpc" },
 	{ }
 };
+#endif
 
 /* All pads are LPC already configured by the hostbridge, so no probing here */
 U_BOOT_DRIVER(intel_apl_lpc) = {
 	.name		= "intel_apl_lpc",
 	.id		= UCLASS_LPC,
-	.of_match	= apl_lpc_ids,
+	.of_match	= of_match_ptr(apl_lpc_ids),
 	ACPI_OPS_PTR(&apl_lpc_acpi_ops)
 };
diff --git a/arch/x86/cpu/apollolake/pch.c b/arch/x86/cpu/apollolake/pch.c
index d9832ff2496..39d6ad5ed49 100644
--- a/arch/x86/cpu/apollolake/pch.c
+++ b/arch/x86/cpu/apollolake/pch.c
@@ -23,14 +23,16 @@ static const struct pch_ops apl_pch_ops = {
 	.set_spi_protect = apl_set_spi_protect,
 };
 
+#if !CONFIG_IS_ENABLED(OF_PLATDATA)
 static const struct udevice_id apl_pch_ids[] = {
 	{ .compatible = "intel,apl-pch" },
 	{ }
 };
+#endif
 
 U_BOOT_DRIVER(intel_apl_pch) = {
 	.name		= "intel_apl_pch",
 	.id		= UCLASS_PCH,
-	.of_match	= apl_pch_ids,
+	.of_match	= of_match_ptr(apl_pch_ids),
 	.ops		= &apl_pch_ops,
 };
diff --git a/arch/x86/cpu/apollolake/pmc.c b/arch/x86/cpu/apollolake/pmc.c
index c40065ab8cf..e033baf1205 100644
--- a/arch/x86/cpu/apollolake/pmc.c
+++ b/arch/x86/cpu/apollolake/pmc.c
@@ -212,15 +212,17 @@ static const struct acpi_pmc_ops apl_pmc_ops = {
 	.global_reset_set_enable = apl_global_reset_set_enable,
 };
 
+#if !CONFIG_IS_ENABLED(OF_PLATDATA)
 static const struct udevice_id apl_pmc_ids[] = {
 	{ .compatible = "intel,apl-pmc" },
 	{ }
 };
+#endif
 
 U_BOOT_DRIVER(intel_apl_pmc) = {
 	.name		= "intel_apl_pmc",
 	.id		= UCLASS_ACPI_PMC,
-	.of_match	= apl_pmc_ids,
+	.of_match	= of_match_ptr(apl_pmc_ids),
 	.of_to_plat = apl_pmc_ofdata_to_uc_plat,
 	.probe		= apl_pmc_probe,
 	.ops		= &apl_pmc_ops,
diff --git a/arch/x86/cpu/apollolake/uart.c b/arch/x86/cpu/apollolake/uart.c
index e523d85b1b4..69e5899235b 100644
--- a/arch/x86/cpu/apollolake/uart.c
+++ b/arch/x86/cpu/apollolake/uart.c
@@ -118,15 +118,17 @@ static int apl_ns16550_of_to_plat(struct udevice *dev)
 	return 0;
 }
 
+#if !CONFIG_IS_ENABLED(OF_PLATDATA)
 static const struct udevice_id apl_ns16550_serial_ids[] = {
 	{ .compatible = "intel,apl-ns16550" },
 	{ },
 };
+#endif
 
 U_BOOT_DRIVER(intel_apl_ns16550) = {
 	.name	= "intel_apl_ns16550",
 	.id	= UCLASS_SERIAL,
-	.of_match = apl_ns16550_serial_ids,
+	.of_match = of_match_ptr(apl_ns16550_serial_ids),
 	.plat_auto	= sizeof(struct ns16550_plat),
 	.priv_auto	= sizeof(struct ns16550),
 	.ops	= &ns16550_serial_ops,
diff --git a/arch/x86/cpu/intel_common/Makefile b/arch/x86/cpu/intel_common/Makefile
index 4a5cf17e41d..8b9a810f66d 100644
--- a/arch/x86/cpu/intel_common/Makefile
+++ b/arch/x86/cpu/intel_common/Makefile
@@ -26,7 +26,7 @@ obj-y += cpu.o
 obj-y += fast_spi.o
 obj-y += lpc.o
 obj-y += lpss.o
-obj-$(CONFIG_INTEL_GENERIC_WIFI) += generic_wifi.o
+obj-$(CONFIG_$(SPL_)INTEL_GENERIC_WIFI) += generic_wifi.o
 ifndef CONFIG_TARGET_EFI_APP
 obj-$(CONFIG_$(SPL_TPL_)X86_32BIT_INIT) += microcode.o
 ifndef CONFIG_$(SPL_)X86_64
diff --git a/arch/x86/cpu/intel_common/itss.c b/arch/x86/cpu/intel_common/itss.c
index e71ea029e51..6515d1f471f 100644
--- a/arch/x86/cpu/intel_common/itss.c
+++ b/arch/x86/cpu/intel_common/itss.c
@@ -230,15 +230,17 @@ static const struct irq_ops itss_ops = {
 #endif
 };
 
+#if !CONFIG_IS_ENABLED(OF_PLATDATA)
 static const struct udevice_id itss_ids[] = {
 	{ .compatible = "intel,itss", .data = X86_IRQT_ITSS },
 	{ }
 };
+#endif
 
 U_BOOT_DRIVER(intel_itss) = {
 	.name		= "intel_itss",
 	.id		= UCLASS_IRQ,
-	.of_match	= itss_ids,
+	.of_match	= of_match_ptr(itss_ids),
 	.ops		= &itss_ops,
 	.bind		= itss_bind,
 	.of_to_plat = itss_of_to_plat,
diff --git a/arch/x86/cpu/intel_common/p2sb.c b/arch/x86/cpu/intel_common/p2sb.c
index 3765eeeab0d..cb901f265e2 100644
--- a/arch/x86/cpu/intel_common/p2sb.c
+++ b/arch/x86/cpu/intel_common/p2sb.c
@@ -184,15 +184,17 @@ static const struct p2sb_ops p2sb_ops = {
 	.set_hide	= intel_p2sb_set_hide,
 };
 
+#if !CONFIG_IS_ENABLED(OF_PLATDATA)
 static const struct udevice_id p2sb_ids[] = {
 	{ .compatible = "intel,p2sb" },
 	{ }
 };
+#endif
 
 U_BOOT_DRIVER(intel_p2sb) = {
 	.name		= "intel_p2sb",
 	.id		= UCLASS_P2SB,
-	.of_match	= p2sb_ids,
+	.of_match	= of_match_ptr(p2sb_ids),
 	.probe		= p2sb_probe,
 	.remove		= p2sb_remove,
 	.ops		= &p2sb_ops,
diff --git a/arch/x86/cpu/turbo.c b/arch/x86/cpu/turbo.c
index f8d85d5a339..4a73cb240da 100644
--- a/arch/x86/cpu/turbo.c
+++ b/arch/x86/cpu/turbo.c
@@ -35,12 +35,15 @@ static inline void set_global_turbo_state(int state)
 }
 #endif
 
+/* gcc 7.3 does not wwant to drop strings, so use #ifdef */
+#ifndef CONFIG_TPL_BUILD
 static const char *const turbo_state_desc[] = {
 	[TURBO_UNKNOWN]		= "unknown",
 	[TURBO_UNAVAILABLE]	= "unavailable",
 	[TURBO_DISABLED]	= "available but hidden",
 	[TURBO_ENABLED]		= "available and visible"
 };
+#endif
 
 /*
  * Determine the current state of Turbo and cache it for later.
@@ -76,7 +79,9 @@ int turbo_get_state(void)
 	}
 
 	set_global_turbo_state(turbo_state);
+#ifndef CONFIG_TPL_BUILD
 	debug("Turbo is %s\n", turbo_state_desc[turbo_state]);
+#endif
 	return turbo_state;
 }
 
diff --git a/board/google/chromebook_coral/coral.c b/board/google/chromebook_coral/coral.c
index b8b923c139e..34b2c2ac5d5 100644
--- a/board/google/chromebook_coral/coral.c
+++ b/board/google/chromebook_coral/coral.c
@@ -143,14 +143,16 @@ struct acpi_ops coral_acpi_ops = {
 	.inject_dsdt	= chromeos_acpi_gpio_generate,
 };
 
+#if !CONFIG_IS_ENABLED(OF_PLATDATA)
 static const struct udevice_id coral_ids[] = {
 	{ .compatible = "google,coral" },
 	{ }
 };
+#endif
 
 U_BOOT_DRIVER(coral_drv) = {
 	.name		= "coral",
 	.id		= UCLASS_SYSINFO,
-	.of_match	= coral_ids,
+	.of_match	= of_match_ptr(coral_ids),
 	ACPI_OPS_PTR(&coral_acpi_ops)
 };
diff --git a/drivers/gpio/intel_gpio.c b/drivers/gpio/intel_gpio.c
index 41540d8ebc6..eda95485c93 100644
--- a/drivers/gpio/intel_gpio.c
+++ b/drivers/gpio/intel_gpio.c
@@ -188,15 +188,17 @@ static const struct dm_gpio_ops gpio_intel_ops = {
 #endif
 };
 
+#if !CONFIG_IS_ENABLED(OF_PLATDATA)
 static const struct udevice_id intel_intel_gpio_ids[] = {
 	{ .compatible = "intel,gpio" },
 	{ }
 };
+#endif
 
 U_BOOT_DRIVER(intel_gpio) = {
 	.name	= "intel_gpio",
 	.id	= UCLASS_GPIO,
-	.of_match = intel_intel_gpio_ids,
+	.of_match = of_match_ptr(intel_intel_gpio_ids),
 	.ops	= &gpio_intel_ops,
 	.of_to_plat	= intel_gpio_of_to_plat,
 	.probe	= intel_gpio_probe,
diff --git a/drivers/pinctrl/intel/pinctrl_apl.c b/drivers/pinctrl/intel/pinctrl_apl.c
index 2bb654c8a18..b512a85f3e6 100644
--- a/drivers/pinctrl/intel/pinctrl_apl.c
+++ b/drivers/pinctrl/intel/pinctrl_apl.c
@@ -167,15 +167,17 @@ static int apl_pinctrl_of_to_plat(struct udevice *dev)
 	return intel_pinctrl_of_to_plat(dev, comm, 2);
 }
 
+#if !CONFIG_IS_ENABLED(OF_PLATDATA)
 static const struct udevice_id apl_gpio_ids[] = {
 	{ .compatible = "intel,apl-pinctrl"},
 	{ }
 };
+#endif
 
 U_BOOT_DRIVER(intel_apl_pinctrl) = {
 	.name		= "intel_apl_pinctrl",
 	.id		= UCLASS_PINCTRL,
-	.of_match	= apl_gpio_ids,
+	.of_match	= of_match_ptr(apl_gpio_ids),
 	.probe		= intel_pinctrl_probe,
 	.ops		= &intel_pinctrl_ops,
 #if !CONFIG_IS_ENABLED(OF_PLATDATA)
diff --git a/drivers/power/acpi_pmc/acpi-pmc-uclass.c b/drivers/power/acpi_pmc/acpi-pmc-uclass.c
index 32a2836f0bf..34446a34e60 100644
--- a/drivers/power/acpi_pmc/acpi-pmc-uclass.c
+++ b/drivers/power/acpi_pmc/acpi-pmc-uclass.c
@@ -8,6 +8,7 @@
 #include <common.h>
 #include <dm.h>
 #include <log.h>
+#include <spl.h>
 #include <acpi/acpi_s3.h>
 #ifdef CONFIG_X86
 #include <asm/intel_pinctrl.h>
@@ -60,7 +61,8 @@ int pmc_gpe_init(struct udevice *dev)
 	 * are different and if they aren't, use the reset values.
 	 */
 	if (dw[0] == dw[1] || dw[1] == dw[2]) {
-		log_info("PMC: Using default GPE route");
+		if (spl_phase() > PHASE_TPL)
+			log_info("PMC: Using default GPE route");
 		gpio_cfg = readl(upriv->gpe_cfg);
 		for (i = 0; i < upriv->gpe0_count; i++)
 			dw[i] = gpio_cfg >> gpe0_shift(upriv, i);
diff --git a/drivers/timer/tsc_timer.c b/drivers/timer/tsc_timer.c
index e3677704b33..706d52b830a 100644
--- a/drivers/timer/tsc_timer.c
+++ b/drivers/timer/tsc_timer.c
@@ -477,15 +477,17 @@ static const struct timer_ops tsc_timer_ops = {
 	.get_count = tsc_timer_get_count,
 };
 
+#if !CONFIG_IS_ENABLED(OF_PLATDATA)
 static const struct udevice_id tsc_timer_ids[] = {
 	{ .compatible = "x86,tsc-timer", },
 	{ }
 };
+#endif
 
 U_BOOT_DRIVER(x86_tsc_timer) = {
 	.name	= "x86_tsc_timer",
 	.id	= UCLASS_TIMER,
-	.of_match = tsc_timer_ids,
+	.of_match = of_match_ptr(tsc_timer_ids),
 	.probe = tsc_timer_probe,
 	.ops	= &tsc_timer_ops,
 };
-- 
2.29.2.729.g45daf8777d-goog

^ permalink raw reply related	[flat|nested] 40+ messages in thread

* [PATCH v2 19/21] x86: pinctrl: Drop unlikely error messages from TPL
  2020-12-23 15:11 [PATCH v2 00/21] dm: Preparation for enhanced of-platdata (part B) Simon Glass
                   ` (17 preceding siblings ...)
  2020-12-23 15:11 ` [PATCH v2 18/21] x86: apl: Reduce size for TPL Simon Glass
@ 2020-12-23 15:11 ` Simon Glass
  2020-12-23 15:11 ` [PATCH v2 20/21] x86: tpl: Remove unwanted devicetree string Simon Glass
                   ` (19 subsequent siblings)
  38 siblings, 0 replies; 40+ messages in thread
From: Simon Glass @ 2020-12-23 15:11 UTC (permalink / raw)
  To: u-boot

These errors are only really for development purposes. Drop them to reduce
the size of TPL. The error numbers are still reported.

This reduces the TPL binary size on coral by about 160 bytes.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

(no changes since v1)

 drivers/pinctrl/intel/pinctrl.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/drivers/pinctrl/intel/pinctrl.c b/drivers/pinctrl/intel/pinctrl.c
index 9f96505dd5a..987a56b715e 100644
--- a/drivers/pinctrl/intel/pinctrl.c
+++ b/drivers/pinctrl/intel/pinctrl.c
@@ -274,7 +274,9 @@ static int pinctrl_configure_itss(struct udevice *dev,
 	irq = pcr_read32(dev, PAD_CFG1_OFFSET(pad_cfg_offset));
 	irq &= PAD_CFG1_IRQ_MASK;
 	if (!irq) {
-		log_err("GPIO %u doesn't support APIC routing\n", cfg->pad);
+		if (spl_phase() > PHASE_TPL)
+			log_err("GPIO %u doesn't support APIC routing\n",
+				cfg->pad);
 
 		return -EPROTONOSUPPORT;
 	}
@@ -314,7 +316,8 @@ static int pinctrl_pad_reset_config_override(const struct pad_community *comm,
 			return config_value;
 		}
 	}
-	log_err("Logical-to-Chipset mapping not found\n");
+	if (spl_phase() > PHASE_TPL)
+		log_err("Logical-to-Chipset mapping not found\n");
 
 	return -ENOENT;
 }
@@ -620,7 +623,9 @@ int intel_pinctrl_of_to_plat(struct udevice *dev,
 	struct intel_pinctrl_priv *priv = dev_get_priv(dev);
 
 	if (!comm) {
-		log_err("Cannot find community for pid %d\n", pplat->pid);
+		if (spl_phase() > PHASE_TPL)
+			log_err("Cannot find community for pid %d\n",
+				pplat->pid);
 		return -EDOM;
 	}
 	priv->comm = comm;
-- 
2.29.2.729.g45daf8777d-goog

^ permalink raw reply related	[flat|nested] 40+ messages in thread

* [PATCH v2 20/21] x86: tpl: Remove unwanted devicetree string
  2020-12-23 15:11 [PATCH v2 00/21] dm: Preparation for enhanced of-platdata (part B) Simon Glass
                   ` (18 preceding siblings ...)
  2020-12-23 15:11 ` [PATCH v2 19/21] x86: pinctrl: Drop unlikely error messages from TPL Simon Glass
@ 2020-12-23 15:11 ` Simon Glass
  2020-12-23 15:11 ` [PATCH v2 21/21] x86: Fix header guard in asm/pmu.h Simon Glass
                   ` (18 subsequent siblings)
  38 siblings, 0 replies; 40+ messages in thread
From: Simon Glass @ 2020-12-23 15:11 UTC (permalink / raw)
  To: u-boot

Update this driver to use of_match_ptr().

This reduces the TPL binary size by about 32 bytes.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

(no changes since v1)

 arch/x86/lib/tpl.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/arch/x86/lib/tpl.c b/arch/x86/lib/tpl.c
index 15b0212d190..04ff32277fd 100644
--- a/arch/x86/lib/tpl.c
+++ b/arch/x86/lib/tpl.c
@@ -133,14 +133,16 @@ void spl_board_init(void)
  * for devices, so the TPL BARs continue to be used. Once U-Boot starts it does
  * the auto allocation (after relocation).
  */
+#if !CONFIG_IS_ENABLED(OF_PLATDATA)
 static const struct udevice_id tpl_fake_pci_ids[] = {
 	{ .compatible = "pci-x86" },
 	{ }
 };
+#endif
 
 U_BOOT_DRIVER(pci_x86) = {
 	.name	= "pci_x86",
 	.id	= UCLASS_SIMPLE_BUS,
-	.of_match = tpl_fake_pci_ids,
+	.of_match = of_match_ptr(tpl_fake_pci_ids),
 };
 #endif
-- 
2.29.2.729.g45daf8777d-goog

^ permalink raw reply related	[flat|nested] 40+ messages in thread

* [PATCH v2 21/21] x86: Fix header guard in asm/pmu.h
  2020-12-23 15:11 [PATCH v2 00/21] dm: Preparation for enhanced of-platdata (part B) Simon Glass
                   ` (19 preceding siblings ...)
  2020-12-23 15:11 ` [PATCH v2 20/21] x86: tpl: Remove unwanted devicetree string Simon Glass
@ 2020-12-23 15:11 ` Simon Glass
  2020-12-28 16:25 ` Simon Glass
                   ` (17 subsequent siblings)
  38 siblings, 0 replies; 40+ messages in thread
From: Simon Glass @ 2020-12-23 15:11 UTC (permalink / raw)
  To: u-boot

This has the wrong name. Fix it.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

(no changes since v1)

 arch/x86/include/asm/pmu.h | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/arch/x86/include/asm/pmu.h b/arch/x86/include/asm/pmu.h
index b76bdf64a30..818e80881ec 100644
--- a/arch/x86/include/asm/pmu.h
+++ b/arch/x86/include/asm/pmu.h
@@ -2,9 +2,9 @@
 /*
  * Copyright (c) 2017 Intel Corporation
  */
-#ifndef _X86_ASM_PMU_IPC_H_
-#define _X86_ASM_PMU_IPC_H_
+#ifndef _X86_ASM_PMU_H_
+#define _X86_ASM_PMU_H_
 
 int pmu_turn_power(unsigned int lss, bool on);
 
-#endif	/* _X86_ASM_PMU_IPC_H_ */
+#endif	/* _X86_ASM_PMU_H_ */
-- 
2.29.2.729.g45daf8777d-goog

^ permalink raw reply related	[flat|nested] 40+ messages in thread

* [PATCH v2 20/21] x86: tpl: Remove unwanted devicetree string
  2020-12-23 15:11 [PATCH v2 00/21] dm: Preparation for enhanced of-platdata (part B) Simon Glass
                   ` (21 preceding siblings ...)
  2020-12-28 16:25 ` Simon Glass
@ 2020-12-28 16:25 ` Simon Glass
  2020-12-28 16:25 ` [PATCH v2 19/21] x86: pinctrl: Drop unlikely error messages from TPL Simon Glass
                   ` (15 subsequent siblings)
  38 siblings, 0 replies; 40+ messages in thread
From: Simon Glass @ 2020-12-28 16:25 UTC (permalink / raw)
  To: u-boot

Update this driver to use of_match_ptr().

This reduces the TPL binary size by about 32 bytes.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

(no changes since v1)

 arch/x86/lib/tpl.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

Applied to u-boot-dm/next, thanks!

^ permalink raw reply	[flat|nested] 40+ messages in thread

* [PATCH v2 21/21] x86: Fix header guard in asm/pmu.h
  2020-12-23 15:11 [PATCH v2 00/21] dm: Preparation for enhanced of-platdata (part B) Simon Glass
                   ` (20 preceding siblings ...)
  2020-12-23 15:11 ` [PATCH v2 21/21] x86: Fix header guard in asm/pmu.h Simon Glass
@ 2020-12-28 16:25 ` Simon Glass
  2020-12-28 16:25 ` [PATCH v2 20/21] x86: tpl: Remove unwanted devicetree string Simon Glass
                   ` (16 subsequent siblings)
  38 siblings, 0 replies; 40+ messages in thread
From: Simon Glass @ 2020-12-28 16:25 UTC (permalink / raw)
  To: u-boot

This has the wrong name. Fix it.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

(no changes since v1)

 arch/x86/include/asm/pmu.h | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

Applied to u-boot-dm/next, thanks!

^ permalink raw reply	[flat|nested] 40+ messages in thread

* [PATCH v2 19/21] x86: pinctrl: Drop unlikely error messages from TPL
  2020-12-23 15:11 [PATCH v2 00/21] dm: Preparation for enhanced of-platdata (part B) Simon Glass
                   ` (22 preceding siblings ...)
  2020-12-28 16:25 ` [PATCH v2 20/21] x86: tpl: Remove unwanted devicetree string Simon Glass
@ 2020-12-28 16:25 ` Simon Glass
  2020-12-28 16:25 ` [PATCH v2 18/21] x86: apl: Reduce size for TPL Simon Glass
                   ` (14 subsequent siblings)
  38 siblings, 0 replies; 40+ messages in thread
From: Simon Glass @ 2020-12-28 16:25 UTC (permalink / raw)
  To: u-boot

These errors are only really for development purposes. Drop them to reduce
the size of TPL. The error numbers are still reported.

This reduces the TPL binary size on coral by about 160 bytes.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

(no changes since v1)

 drivers/pinctrl/intel/pinctrl.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

Applied to u-boot-dm/next, thanks!

^ permalink raw reply	[flat|nested] 40+ messages in thread

* [PATCH v2 18/21] x86: apl: Reduce size for TPL
  2020-12-23 15:11 [PATCH v2 00/21] dm: Preparation for enhanced of-platdata (part B) Simon Glass
                   ` (23 preceding siblings ...)
  2020-12-28 16:25 ` [PATCH v2 19/21] x86: pinctrl: Drop unlikely error messages from TPL Simon Glass
@ 2020-12-28 16:25 ` Simon Glass
  2020-12-28 16:25 ` [PATCH v2 17/21] x86: apl: Update hostbridge to remove unwanted TPL code Simon Glass
                   ` (13 subsequent siblings)
  38 siblings, 0 replies; 40+ messages in thread
From: Simon Glass @ 2020-12-28 16:25 UTC (permalink / raw)
  To: u-boot

Update various drivers to use of_match_ptr() and to avoid including debug
strings in TPL. Omit the WiFi driver entirely, since it is not used in
TPL.

This reduces the TPL binary size by about 608 bytes.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

(no changes since v1)

 arch/x86/cpu/apollolake/lpc.c            | 13 ++++++++-----
 arch/x86/cpu/apollolake/pch.c            |  4 +++-
 arch/x86/cpu/apollolake/pmc.c            |  4 +++-
 arch/x86/cpu/apollolake/uart.c           |  4 +++-
 arch/x86/cpu/intel_common/Makefile       |  2 +-
 arch/x86/cpu/intel_common/itss.c         |  4 +++-
 arch/x86/cpu/intel_common/p2sb.c         |  4 +++-
 arch/x86/cpu/turbo.c                     |  5 +++++
 board/google/chromebook_coral/coral.c    |  4 +++-
 drivers/gpio/intel_gpio.c                |  4 +++-
 drivers/pinctrl/intel/pinctrl_apl.c      |  4 +++-
 drivers/power/acpi_pmc/acpi-pmc-uclass.c |  4 +++-
 drivers/timer/tsc_timer.c                |  4 +++-
 13 files changed, 44 insertions(+), 16 deletions(-)

Applied to u-boot-dm/next, thanks!

^ permalink raw reply	[flat|nested] 40+ messages in thread

* [PATCH v2 17/21] x86: apl: Update hostbridge to remove unwanted TPL code
  2020-12-23 15:11 [PATCH v2 00/21] dm: Preparation for enhanced of-platdata (part B) Simon Glass
                   ` (24 preceding siblings ...)
  2020-12-28 16:25 ` [PATCH v2 18/21] x86: apl: Reduce size for TPL Simon Glass
@ 2020-12-28 16:25 ` Simon Glass
  2020-12-28 16:25 ` [PATCH v2 16/21] x86: coral: Move fsp-m settings to a subnode Simon Glass
                   ` (12 subsequent siblings)
  38 siblings, 0 replies; 40+ messages in thread
From: Simon Glass @ 2020-12-28 16:25 UTC (permalink / raw)
  To: u-boot

At present several strings from this file appear in the TPL binary. Add
preprocessor checks to drop them.

This reduces the TPL binary size by about 128 bytes.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

(no changes since v1)

 arch/x86/cpu/apollolake/hostbridge.c | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)

Applied to u-boot-dm/next, thanks!

^ permalink raw reply	[flat|nested] 40+ messages in thread

* [PATCH v2 16/21] x86: coral: Move fsp-m settings to a subnode
  2020-12-23 15:11 [PATCH v2 00/21] dm: Preparation for enhanced of-platdata (part B) Simon Glass
                   ` (25 preceding siblings ...)
  2020-12-28 16:25 ` [PATCH v2 17/21] x86: apl: Update hostbridge to remove unwanted TPL code Simon Glass
@ 2020-12-28 16:25 ` Simon Glass
  2020-12-28 16:25 ` [PATCH v2 15/21] x86: Move call64 into its own section Simon Glass
                   ` (11 subsequent siblings)
  38 siblings, 0 replies; 40+ messages in thread
From: Simon Glass @ 2020-12-28 16:25 UTC (permalink / raw)
  To: u-boot

At present these settings are in the node for host-bridge and so are
visible in TPL as well as SPL. But they are only used for SPL.

Move them to a subnode so that TPL does not included them.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

(no changes since v1)

 arch/x86/cpu/apollolake/fsp_m.c   | 5 ++++-
 arch/x86/dts/chromebook_coral.dts | 5 +++++
 2 files changed, 9 insertions(+), 1 deletion(-)

Applied to u-boot-dm/next, thanks!

^ permalink raw reply	[flat|nested] 40+ messages in thread

* [PATCH v2 15/21] x86: Move call64 into its own section
  2020-12-23 15:11 [PATCH v2 00/21] dm: Preparation for enhanced of-platdata (part B) Simon Glass
                   ` (26 preceding siblings ...)
  2020-12-28 16:25 ` [PATCH v2 16/21] x86: coral: Move fsp-m settings to a subnode Simon Glass
@ 2020-12-28 16:25 ` Simon Glass
  2020-12-28 16:25 ` [PATCH v2 14/21] x86: apl: Use const for driver operations Simon Glass
                   ` (10 subsequent siblings)
  38 siblings, 0 replies; 40+ messages in thread
From: Simon Glass @ 2020-12-28 16:25 UTC (permalink / raw)
  To: u-boot

When this code is not used (e.g. by TPL) we want it to be excluded from
the image. Put it in its own section so that this happens.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

(no changes since v1)

 arch/x86/cpu/i386/call64.S | 1 +
 1 file changed, 1 insertion(+)

Applied to u-boot-dm/next, thanks!

^ permalink raw reply	[flat|nested] 40+ messages in thread

* [PATCH v2 14/21] x86: apl: Use const for driver operations
  2020-12-23 15:11 [PATCH v2 00/21] dm: Preparation for enhanced of-platdata (part B) Simon Glass
                   ` (27 preceding siblings ...)
  2020-12-28 16:25 ` [PATCH v2 15/21] x86: Move call64 into its own section Simon Glass
@ 2020-12-28 16:25 ` Simon Glass
  2020-12-28 16:25 ` [PATCH v2 11/21] dtoc: Convert _drivers to a dict Simon Glass
                   ` (9 subsequent siblings)
  38 siblings, 0 replies; 40+ messages in thread
From: Simon Glass @ 2020-12-28 16:25 UTC (permalink / raw)
  To: u-boot

Update these declarations to const to ensure that the data ends up in the
rodata section.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

(no changes since v1)

 arch/x86/cpu/apollolake/pmc.c    | 2 +-
 arch/x86/cpu/intel_common/p2sb.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

Applied to u-boot-dm/next, thanks!

^ permalink raw reply	[flat|nested] 40+ messages in thread

* [PATCH v2 11/21] dtoc: Convert _drivers to a dict
  2020-12-23 15:11 [PATCH v2 00/21] dm: Preparation for enhanced of-platdata (part B) Simon Glass
                   ` (28 preceding siblings ...)
  2020-12-28 16:25 ` [PATCH v2 14/21] x86: apl: Use const for driver operations Simon Glass
@ 2020-12-28 16:25 ` Simon Glass
  2020-12-28 16:25 ` [PATCH v2 10/21] dtoc: Output the struct values in a separate function Simon Glass
                   ` (8 subsequent siblings)
  38 siblings, 0 replies; 40+ messages in thread
From: Simon Glass @ 2020-12-28 16:25 UTC (permalink / raw)
  To: u-boot

At present this member holds a simple list of driver names. Update it to
be a dict of DriverInfo, with the name being the key. This will allow more
information to be added about each driver, in future patches.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

Changes in v2:
- Rename DriverInfo to Driver
- Add a test for the new code and a comment for Driver

 tools/dtoc/dtb_platdata.py | 26 ++++++++++++++++++++++----
 tools/dtoc/test_dtoc.py    | 10 ++++++++++
 2 files changed, 32 insertions(+), 4 deletions(-)

Applied to u-boot-dm/next, thanks!

^ permalink raw reply	[flat|nested] 40+ messages in thread

* [PATCH v2 10/21] dtoc: Output the struct values in a separate function
  2020-12-23 15:11 [PATCH v2 00/21] dm: Preparation for enhanced of-platdata (part B) Simon Glass
                   ` (29 preceding siblings ...)
  2020-12-28 16:25 ` [PATCH v2 11/21] dtoc: Convert _drivers to a dict Simon Glass
@ 2020-12-28 16:25 ` Simon Glass
  2020-12-28 16:25 ` [PATCH v2 09/21] dtoc: Output the device " Simon Glass
                   ` (7 subsequent siblings)
  38 siblings, 0 replies; 40+ messages in thread
From: Simon Glass @ 2020-12-28 16:25 UTC (permalink / raw)
  To: u-boot

Reduce the length of output_node() futher by moving the struct-output
functionality into a two separate functions.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

(no changes since v1)

 tools/dtoc/dtb_platdata.py | 50 ++++++++++++++++++++++++++------------
 1 file changed, 34 insertions(+), 16 deletions(-)

Applied to u-boot-dm/next, thanks!

^ permalink raw reply	[flat|nested] 40+ messages in thread

* [PATCH v2 09/21] dtoc: Output the device in a separate function
  2020-12-23 15:11 [PATCH v2 00/21] dm: Preparation for enhanced of-platdata (part B) Simon Glass
                   ` (30 preceding siblings ...)
  2020-12-28 16:25 ` [PATCH v2 10/21] dtoc: Output the struct values in a separate function Simon Glass
@ 2020-12-28 16:25 ` Simon Glass
  2020-12-28 16:25 ` [PATCH v2 08/21] dtoc: Make _output_list a top-level function Simon Glass
                   ` (6 subsequent siblings)
  38 siblings, 0 replies; 40+ messages in thread
From: Simon Glass @ 2020-12-28 16:25 UTC (permalink / raw)
  To: u-boot

Reduce the length of output_node() by moving the device-output
functionality into a separate function.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

(no changes since v1)

 tools/dtoc/dtb_platdata.py | 33 ++++++++++++++++++++++-----------
 1 file changed, 22 insertions(+), 11 deletions(-)

Applied to u-boot-dm/next, thanks!

^ permalink raw reply	[flat|nested] 40+ messages in thread

* [PATCH v2 08/21] dtoc: Make _output_list a top-level function
  2020-12-23 15:11 [PATCH v2 00/21] dm: Preparation for enhanced of-platdata (part B) Simon Glass
                   ` (31 preceding siblings ...)
  2020-12-28 16:25 ` [PATCH v2 09/21] dtoc: Output the device " Simon Glass
@ 2020-12-28 16:25 ` Simon Glass
  2020-12-28 16:25 ` [PATCH v2 07/21] dtoc: Fix a few pylint warnings in dtb_platdata Simon Glass
                   ` (5 subsequent siblings)
  38 siblings, 0 replies; 40+ messages in thread
From: Simon Glass @ 2020-12-28 16:25 UTC (permalink / raw)
  To: u-boot

It is annoying to have this function inside its parent since it makes the
parent longer and hard to read. Move it to the top level.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

(no changes since v1)

 tools/dtoc/dtb_platdata.py | 80 +++++++++++++++++++-------------------
 1 file changed, 40 insertions(+), 40 deletions(-)

Applied to u-boot-dm/next, thanks!

^ permalink raw reply	[flat|nested] 40+ messages in thread

* [PATCH v2 07/21] dtoc: Fix a few pylint warnings in dtb_platdata
  2020-12-23 15:11 [PATCH v2 00/21] dm: Preparation for enhanced of-platdata (part B) Simon Glass
                   ` (32 preceding siblings ...)
  2020-12-28 16:25 ` [PATCH v2 08/21] dtoc: Make _output_list a top-level function Simon Glass
@ 2020-12-28 16:25 ` Simon Glass
  2020-12-28 16:25 ` [PATCH v2 06/21] test: Move some test drivers into their own file Simon Glass
                   ` (4 subsequent siblings)
  38 siblings, 0 replies; 40+ messages in thread
From: Simon Glass @ 2020-12-28 16:25 UTC (permalink / raw)
  To: u-boot

These have crept in again. Update the file to fix all but these ones:

   dtb_platdata.py:143:0: R0902: Too many instance attributes (10/7)
      (too-many-instance-attributes)
   dtb_platdata.py:713:0: R0913: Too many arguments (6/5)
      (too-many-arguments)

Signed-off-by: Simon Glass <sjg@chromium.org>
---

(no changes since v1)

 tools/dtoc/dtb_platdata.py | 31 ++++++++++++++++---------------
 1 file changed, 16 insertions(+), 15 deletions(-)

Applied to u-boot-dm/next, thanks!

^ permalink raw reply	[flat|nested] 40+ messages in thread

* [PATCH v2 06/21] test: Move some test drivers into their own file
  2020-12-23 15:11 [PATCH v2 00/21] dm: Preparation for enhanced of-platdata (part B) Simon Glass
                   ` (33 preceding siblings ...)
  2020-12-28 16:25 ` [PATCH v2 07/21] dtoc: Fix a few pylint warnings in dtb_platdata Simon Glass
@ 2020-12-28 16:25 ` Simon Glass
  2020-12-28 16:25 ` [PATCH v2 05/21] test: Use a simple variable to record removed device Simon Glass
                   ` (3 subsequent siblings)
  38 siblings, 0 replies; 40+ messages in thread
From: Simon Glass @ 2020-12-28 16:25 UTC (permalink / raw)
  To: u-boot

At present several test drivers are part of the test file itself. Some of
these are useful for of-platdata tests. Separate them out so we can use
them for other things also.

A few adjustments are needed so this driver can build for sandbox_spl as
well.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

(no changes since v1)

 drivers/misc/Kconfig    |   9 ++
 drivers/misc/Makefile   |   1 +
 drivers/misc/test_drv.c | 230 ++++++++++++++++++++++++++++++++++++++++
 include/dm/test.h       |  18 ++++
 include/test/test.h     |   9 ++
 test/dm/bus.c           | 105 +-----------------
 test/dm/test-fdt.c      | 120 ---------------------
 7 files changed, 271 insertions(+), 221 deletions(-)
 create mode 100644 drivers/misc/test_drv.c

Applied to u-boot-dm/next, thanks!

^ permalink raw reply	[flat|nested] 40+ messages in thread

* [PATCH v2 05/21] test: Use a simple variable to record removed device
  2020-12-23 15:11 [PATCH v2 00/21] dm: Preparation for enhanced of-platdata (part B) Simon Glass
                   ` (34 preceding siblings ...)
  2020-12-28 16:25 ` [PATCH v2 06/21] test: Move some test drivers into their own file Simon Glass
@ 2020-12-28 16:25 ` Simon Glass
  2020-12-28 16:25 ` [PATCH v2 04/21] timer: Use a shorter error in TPL Simon Glass
                   ` (2 subsequent siblings)
  38 siblings, 0 replies; 40+ messages in thread
From: Simon Glass @ 2020-12-28 16:25 UTC (permalink / raw)
  To: u-boot

At present the entire test state is effective passed into a test driver
just to record which device was removed. This is unnecessary and makes it
harder to track what is going on.

Use a simple boolean instead.

Also drop the unused 'removed' member while we are here.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

(no changes since v1)

 include/dm/test.h |  2 --
 test/dm/bus.c     | 14 ++++++--------
 2 files changed, 6 insertions(+), 10 deletions(-)

Applied to u-boot-dm/next, thanks!

^ permalink raw reply	[flat|nested] 40+ messages in thread

* [PATCH v2 04/21] timer: Use a shorter error in TPL
  2020-12-23 15:11 [PATCH v2 00/21] dm: Preparation for enhanced of-platdata (part B) Simon Glass
                   ` (35 preceding siblings ...)
  2020-12-28 16:25 ` [PATCH v2 05/21] test: Use a simple variable to record removed device Simon Glass
@ 2020-12-28 16:25 ` Simon Glass
  2020-12-28 16:25 ` [PATCH v2 02/21] sysreset: Use a shorter error with SPL Simon Glass
  2020-12-28 16:25 ` [PATCH v2 01/21] pinctrl: Drop post_bind() method when not needed Simon Glass
  38 siblings, 0 replies; 40+ messages in thread
From: Simon Glass @ 2020-12-28 16:25 UTC (permalink / raw)
  To: u-boot

This error should not happen in normal use. Reduce the length of it to
save space in the image.

Add an empty spl.h file to sh since it appears to lack this.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

(no changes since v1)

 lib/time.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

Applied to u-boot-dm/next, thanks!

^ permalink raw reply	[flat|nested] 40+ messages in thread

* [PATCH v2 02/21] sysreset: Use a shorter error with SPL
  2020-12-23 15:11 [PATCH v2 00/21] dm: Preparation for enhanced of-platdata (part B) Simon Glass
                   ` (36 preceding siblings ...)
  2020-12-28 16:25 ` [PATCH v2 04/21] timer: Use a shorter error in TPL Simon Glass
@ 2020-12-28 16:25 ` Simon Glass
  2020-12-28 16:25 ` [PATCH v2 01/21] pinctrl: Drop post_bind() method when not needed Simon Glass
  38 siblings, 0 replies; 40+ messages in thread
From: Simon Glass @ 2020-12-28 16:25 UTC (permalink / raw)
  To: u-boot

Use a minimal error message to save space. Sort the header files while we
are here.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

(no changes since v1)

 drivers/sysreset/sysreset-uclass.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

Applied to u-boot-dm/next, thanks!

^ permalink raw reply	[flat|nested] 40+ messages in thread

* [PATCH v2 01/21] pinctrl: Drop post_bind() method when not needed
  2020-12-23 15:11 [PATCH v2 00/21] dm: Preparation for enhanced of-platdata (part B) Simon Glass
                   ` (37 preceding siblings ...)
  2020-12-28 16:25 ` [PATCH v2 02/21] sysreset: Use a shorter error with SPL Simon Glass
@ 2020-12-28 16:25 ` Simon Glass
  38 siblings, 0 replies; 40+ messages in thread
From: Simon Glass @ 2020-12-28 16:25 UTC (permalink / raw)
  To: u-boot

This is not used with of-platdata, so remove it in that case.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

(no changes since v1)

 drivers/pinctrl/pinctrl-uclass.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

Applied to u-boot-dm/next, thanks!

^ permalink raw reply	[flat|nested] 40+ messages in thread

end of thread, other threads:[~2020-12-28 16:25 UTC | newest]

Thread overview: 40+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-23 15:11 [PATCH v2 00/21] dm: Preparation for enhanced of-platdata (part B) Simon Glass
2020-12-23 15:11 ` [PATCH v2 01/21] pinctrl: Drop post_bind() method when not needed Simon Glass
2020-12-23 15:11 ` [PATCH v2 02/21] sysreset: Use a shorter error with SPL Simon Glass
2020-12-23 15:11 ` [PATCH v2 03/21] arc: m68k: nds32: nios2: sh: xtensa: Add empty spl.h header Simon Glass
2020-12-23 15:11 ` [PATCH v2 04/21] timer: Use a shorter error in TPL Simon Glass
2020-12-23 15:11 ` [PATCH v2 05/21] test: Use a simple variable to record removed device Simon Glass
2020-12-23 15:11 ` [PATCH v2 06/21] test: Move some test drivers into their own file Simon Glass
2020-12-23 15:11 ` [PATCH v2 07/21] dtoc: Fix a few pylint warnings in dtb_platdata Simon Glass
2020-12-23 15:11 ` [PATCH v2 08/21] dtoc: Make _output_list a top-level function Simon Glass
2020-12-23 15:11 ` [PATCH v2 09/21] dtoc: Output the device in a separate function Simon Glass
2020-12-23 15:11 ` [PATCH v2 10/21] dtoc: Output the struct values " Simon Glass
2020-12-23 15:11 ` [PATCH v2 11/21] dtoc: Convert _drivers to a dict Simon Glass
2020-12-23 15:11 ` [PATCH v2 12/21] dtoc: Scan drivers for available information Simon Glass
2020-12-23 15:11 ` [PATCH v2 13/21] dtoc: Allow use of the of_match_ptr() macro Simon Glass
2020-12-23 15:11 ` [PATCH v2 14/21] x86: apl: Use const for driver operations Simon Glass
2020-12-23 15:11 ` [PATCH v2 15/21] x86: Move call64 into its own section Simon Glass
2020-12-23 15:11 ` [PATCH v2 16/21] x86: coral: Move fsp-m settings to a subnode Simon Glass
2020-12-23 15:11 ` [PATCH v2 17/21] x86: apl: Update hostbridge to remove unwanted TPL code Simon Glass
2020-12-23 15:11 ` [PATCH v2 18/21] x86: apl: Reduce size for TPL Simon Glass
2020-12-23 15:11 ` [PATCH v2 19/21] x86: pinctrl: Drop unlikely error messages from TPL Simon Glass
2020-12-23 15:11 ` [PATCH v2 20/21] x86: tpl: Remove unwanted devicetree string Simon Glass
2020-12-23 15:11 ` [PATCH v2 21/21] x86: Fix header guard in asm/pmu.h Simon Glass
2020-12-28 16:25 ` Simon Glass
2020-12-28 16:25 ` [PATCH v2 20/21] x86: tpl: Remove unwanted devicetree string Simon Glass
2020-12-28 16:25 ` [PATCH v2 19/21] x86: pinctrl: Drop unlikely error messages from TPL Simon Glass
2020-12-28 16:25 ` [PATCH v2 18/21] x86: apl: Reduce size for TPL Simon Glass
2020-12-28 16:25 ` [PATCH v2 17/21] x86: apl: Update hostbridge to remove unwanted TPL code Simon Glass
2020-12-28 16:25 ` [PATCH v2 16/21] x86: coral: Move fsp-m settings to a subnode Simon Glass
2020-12-28 16:25 ` [PATCH v2 15/21] x86: Move call64 into its own section Simon Glass
2020-12-28 16:25 ` [PATCH v2 14/21] x86: apl: Use const for driver operations Simon Glass
2020-12-28 16:25 ` [PATCH v2 11/21] dtoc: Convert _drivers to a dict Simon Glass
2020-12-28 16:25 ` [PATCH v2 10/21] dtoc: Output the struct values in a separate function Simon Glass
2020-12-28 16:25 ` [PATCH v2 09/21] dtoc: Output the device " Simon Glass
2020-12-28 16:25 ` [PATCH v2 08/21] dtoc: Make _output_list a top-level function Simon Glass
2020-12-28 16:25 ` [PATCH v2 07/21] dtoc: Fix a few pylint warnings in dtb_platdata Simon Glass
2020-12-28 16:25 ` [PATCH v2 06/21] test: Move some test drivers into their own file Simon Glass
2020-12-28 16:25 ` [PATCH v2 05/21] test: Use a simple variable to record removed device Simon Glass
2020-12-28 16:25 ` [PATCH v2 04/21] timer: Use a shorter error in TPL Simon Glass
2020-12-28 16:25 ` [PATCH v2 02/21] sysreset: Use a shorter error with SPL Simon Glass
2020-12-28 16:25 ` [PATCH v2 01/21] pinctrl: Drop post_bind() method when not needed Simon Glass

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.