All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v4 00/42] dm: Implement OF_PLATDATA_INST in driver model (part E)
@ 2021-03-15  4:25 Simon Glass
  2021-03-15  4:25 ` [PATCH v4 01/42] dtoc: Drop use of DECL() macros Simon Glass
                   ` (83 more replies)
  0 siblings, 84 replies; 85+ messages in thread
From: Simon Glass @ 2021-03-15  4:25 UTC (permalink / raw)
  To: u-boot

This series builds on the recent dtoc implementation of build-time device
instantiation.

It adds the required driver model support, which is basically a few more
data structures.

With this, sandbox_spl and chromebook_coral both use the new feature.

For coral TPL there is a 1.5KB code-size reduction and a 1.75KB data-size
increase:

   text   data     bss     dec     hex
  18836   3080      12   21928    55a8    original
  17229   4896      12   22137    5679    with OF_PLATDATA_INST
  17277   4896      12   22185    56a9    with OF_PLATDATA_RT

The extra data size is due to the build-time devices which are now
included in the image instead of being built at runtime. Also the private
data for each device is allocated in the data region at present, even
through much of it is just zeroes.

The reduction in code size is due to not needing to bind devices at
runtime, as a well as a simplified probe() function. Coral requires that
data be copied out to RAM before being updated, so that adds a small
amount to size (shown in the third line).

Quite a lot of future work is possible, including reducing the size of
data structures. See [1] for more ideas. But this series implements the
basic feature.

To try this out on your board, define CONFIG_SPL_OF_PLATDATA_INST and see
what you get.

This series is available at u-boot-dm/tin-working

[1]  https://lists.denx.de/pipermail/u-boot/2020-July/418433.html

Changes in v4:
- Rebase to -next

Changes in v3:
- Add new patch to drop DECL() macros from dtoc (to squash in)
- Drop the decl() variant since it is just as easy to use extern
- Drop the decl() versions of the macros
- Add full documentation for the macros
- Update the commit message to explain OF_PLATDATA_NO_BIND better
- Update OF_PLATDATA_NO_BIND help as well
- Drop DM_DRVINFO_GET() also
- Aew patch with warnings for private / platform setters
- Add documentation updates
- Add documentation for of-platdata-inst
- Don't drop 'ranges' since we use the full PCI driver in SPL
- Add new patch to drop coral's TPM and ACPI interrupts from TPL
- Use 'u-boot,dm-pre-proper' so these are not present in TPL/SPL

Changes in v2:
- Update to deal with test refactoring series
- Use separate OF_PLATDATA_DRIVER_RT Kconfigs for driver run-time data
- Update the condition for dm_test_of_plat_dev()
- Leave the flags_ memeber in the same struct position

Simon Glass (42):
  dtoc: Drop use of DECL() macros
  sandbox: Drop debug message in os_spl_to_uboot()
  linker_lists: Allow use in data structures
  dm: core: Add macros to access the new linker lists
  dm: core: Allow dropping run-time binding of devices
  dm: core: Adjust uclass setup with of-platdata
  dm: core: Set up driver model for OF_PLATDATA_INST
  dm: core: Skip adding uclasses with OF_PLATDATA_INST
  dm: Add the new dtoc-generated files to the build
  dm: core: Include dt-decl.h automatically
  dm: test: Avoid destroying uclasses with of-platdata-inst
  clk: sandbox: Move priv/plat data to a header file
  clk: fixed-rate: Export driver parts for OF_PLATDATA_INST
  clk: sandbox: Create a special fixed-rate driver
  dm: core: Drop device_get_by_driver_info()
  dm: core: Drop uclass_find_device_by_phandle() with of-platdata
  sandbox: i2c: Move platdata structs to header files
  dm: Rename device_get_by_driver_info_idx()
  sandbox_spl: Increase SPL malloc() size
  sandbox: i2c: Support i2c emulation with of-platdata
  Revert "sandbox: Disable I2C emulators in SPL"
  sandbox: Create a new sandbox_noinst build
  test: Run sandbox_spl tests on sandbox_noinst
  azure/gitlab: Add tests for sandbox_noinst
  dm: core: Add an option to support SPL in read-only memory
  dm: core: Create a struct for device runtime info
  dm: core: Move flags to device-runtime info
  dm: core: Allow storing priv/plat data separately
  sandbox: Define a region for device priv/plat data
  dm: core: Use separate priv/plat data region
  dm: core: Add warnings to private / platform setters
  dm: doc: Tidy up of-platdata docs
  dm: doc: Add documentation for of-platdata-inst
  x86: Define a region for device priv/plat data
  x86: apl: Fix the header order in pmc
  x86: apl: Tell of-platdata about a required header file
  x86: itss: Tidy up bind() for of-platdata-inst
  x86: Support a fake PCI device with of-platdata-inst
  x86: Don't include reset driver in SPL
  x86: coral: Drop ACPI properties from of-platdata
  x86: coral: Drop TPM and ACPI interrupts from TPL
  x86: apl: Use read-only SPL and new of-platdata

 .azure-pipelines.yml               |   3 +
 .gitlab-ci.yml                     |  10 +-
 arch/sandbox/cpu/os.c              |   1 -
 arch/sandbox/cpu/u-boot-spl.lds    |   8 +
 arch/sandbox/dts/sandbox.dtsi      |  12 +-
 arch/sandbox/include/asm/clk.h     |  24 +
 arch/sandbox/include/asm/i2c.h     |  15 +
 arch/sandbox/include/asm/rtc.h     |  24 +
 arch/x86/cpu/apollolake/Kconfig    |   2 +
 arch/x86/cpu/apollolake/pmc.c      |   2 +-
 arch/x86/cpu/apollolake/punit.c    |   1 +
 arch/x86/cpu/intel_common/itss.c   |   5 +-
 arch/x86/cpu/u-boot-spl.lds        |   8 +
 arch/x86/dts/chromebook_coral.dts  |  10 +-
 arch/x86/dts/reset.dtsi            |   2 +-
 arch/x86/lib/tpl.c                 |   1 +
 board/sandbox/MAINTAINERS          |   7 +
 common/spl/Kconfig                 |  24 +
 configs/chromebook_coral_defconfig |   1 +
 configs/sandbox_noinst_defconfig   | 231 +++++++++
 configs/sandbox_spl_defconfig      |   3 +
 doc/driver-model/of-plat.rst       | 725 +++++++++++++++++++++++++----
 drivers/clk/clk-uclass.c           |   2 +-
 drivers/clk/clk_fixed_rate.c       |  14 +-
 drivers/clk/clk_sandbox.c          |  40 +-
 drivers/clk/clk_sandbox_test.c     |   6 -
 drivers/core/device.c              | 111 +++--
 drivers/core/root.c                |  85 +++-
 drivers/core/uclass.c              |   7 +-
 drivers/i2c/Makefile               |   2 -
 drivers/i2c/i2c-emul-uclass.c      |  30 +-
 drivers/misc/irq-uclass.c          |   2 +-
 drivers/mmc/fsl_esdhc_imx.c        |   3 +-
 drivers/rtc/i2c_rtc_emul.c         |  19 -
 drivers/rtc/sandbox_rtc.c          |  13 +
 dts/Kconfig                        |  60 +++
 include/asm-generic/global_data.h  |  26 +-
 include/asm-generic/sections.h     |   3 +
 include/dm/device-internal.h       |  93 ++++
 include/dm/device.h                |  74 ++-
 include/dm/platdata.h              |  15 -
 include/dm/root.h                  |   3 +
 include/dm/uclass-internal.h       |  52 +++
 include/dm/uclass.h                |  31 ++
 include/dm/util.h                  |   9 +
 include/dt-structs.h               |   2 +
 include/i2c.h                      |  15 +
 include/linker_lists.h             |  12 +
 include/linux/clk-provider.h       |   5 +
 scripts/Makefile.spl               |   3 +-
 test/dm/of_platdata.c              |  32 +-
 test/run                           |   4 +
 test/test-main.c                   |  30 +-
 tools/dtoc/dtb_platdata.py         |   8 +-
 tools/dtoc/test_dtoc.py            |  64 +--
 55 files changed, 1677 insertions(+), 317 deletions(-)
 create mode 100644 configs/sandbox_noinst_defconfig

-- 
2.31.0.rc2.261.g7f71774620-goog

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

* [PATCH v4 01/42] dtoc: Drop use of DECL() macros
  2021-03-15  4:25 [PATCH v4 00/42] dm: Implement OF_PLATDATA_INST in driver model (part E) Simon Glass
@ 2021-03-15  4:25 ` Simon Glass
  2021-03-15  4:25 ` [PATCH v4 02/42] sandbox: Drop debug message in os_spl_to_uboot() Simon Glass
                   ` (82 subsequent siblings)
  83 siblings, 0 replies; 85+ messages in thread
From: Simon Glass @ 2021-03-15  4:25 UTC (permalink / raw)
  To: u-boot

We can use extern instead, so let's drop these macros. It adds one more
thing to learn about and doesn't make the code any clearer.

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

(no changes since v3)

Changes in v3:
- Add new patch to drop DECL() macros from dtoc (to squash in)

 tools/dtoc/dtb_platdata.py |  8 ++---
 tools/dtoc/test_dtoc.py    | 64 +++++++++++++++++++-------------------
 2 files changed, 36 insertions(+), 36 deletions(-)

diff --git a/tools/dtoc/dtb_platdata.py b/tools/dtoc/dtb_platdata.py
index f5b5ad5f71a..b5c449ebb47 100644
--- a/tools/dtoc/dtb_platdata.py
+++ b/tools/dtoc/dtb_platdata.py
@@ -902,14 +902,14 @@ class DtbPlatdata():
         self.buf(
             '/* driver declarations - these allow DM_DRIVER_GET() to be used */\n')
         for node in nodes_to_output:
-            self.buf('DM_DRIVER_DECL(%s);\n' % node.struct_name);
+            self.buf('extern U_BOOT_DRIVER(%s);\n' % node.struct_name);
         self.buf('\n')
 
         if self._instantiate:
             self.buf(
                 '/* device declarations - these allow DM_DEVICE_REF() to be used */\n')
             for node in nodes_to_output:
-                self.buf('DM_DEVICE_DECL(%s);\n' % node.var_name)
+                self.buf('extern DM_DEVICE_INST(%s);\n' % node.var_name)
             self.buf('\n')
 
         uclass_list = self._valid_uclasses
@@ -917,13 +917,13 @@ class DtbPlatdata():
         self.buf(
             '/* uclass driver declarations - needed for DM_UCLASS_DRIVER_REF() */\n')
         for uclass in uclass_list:
-            self.buf('DM_UCLASS_DRIVER_DECL(%s);\n' % uclass.name)
+            self.buf('extern UCLASS_DRIVER(%s);\n' % uclass.name)
 
         if self._instantiate:
             self.buf('\n')
             self.buf('/* uclass declarations - needed for DM_UCLASS_REF() */\n')
             for uclass in uclass_list:
-                self.buf('DM_UCLASS_DECL(%s);\n' % uclass.name)
+                self.buf('extern DM_UCLASS_INST(%s);\n' % uclass.name)
         self.out(''.join(self.get_buf()))
 
     def assign_seqs(self):
diff --git a/tools/dtoc/test_dtoc.py b/tools/dtoc/test_dtoc.py
index bb689f3b6e9..1912a8723f2 100755
--- a/tools/dtoc/test_dtoc.py
+++ b/tools/dtoc/test_dtoc.py
@@ -241,52 +241,52 @@ class TestDtoc(unittest.TestCase):
 #include <dm/uclass-internal.h>
 
 /* driver declarations - these allow DM_DRIVER_GET() to be used */
-DM_DRIVER_DECL(sandbox_i2c);
-DM_DRIVER_DECL(sandbox_pmic);
-DM_DRIVER_DECL(sandbox_spl_test);
-DM_DRIVER_DECL(sandbox_spl_test);
-DM_DRIVER_DECL(sandbox_spl_test);
+extern U_BOOT_DRIVER(sandbox_i2c);
+extern U_BOOT_DRIVER(sandbox_pmic);
+extern U_BOOT_DRIVER(sandbox_spl_test);
+extern U_BOOT_DRIVER(sandbox_spl_test);
+extern U_BOOT_DRIVER(sandbox_spl_test);
 
 /* uclass driver declarations - needed for DM_UCLASS_DRIVER_REF() */
-DM_UCLASS_DRIVER_DECL(i2c);
-DM_UCLASS_DRIVER_DECL(misc);
-DM_UCLASS_DRIVER_DECL(pmic);
+extern UCLASS_DRIVER(i2c);
+extern UCLASS_DRIVER(misc);
+extern UCLASS_DRIVER(pmic);
 '''
     decl_text_inst = DECL_HEADER + '''
 #include <dm/device-internal.h>
 #include <dm/uclass-internal.h>
 
 /* driver declarations - these allow DM_DRIVER_GET() to be used */
-DM_DRIVER_DECL(sandbox_i2c);
-DM_DRIVER_DECL(root_driver);
-DM_DRIVER_DECL(denx_u_boot_test_bus);
-DM_DRIVER_DECL(sandbox_spl_test);
-DM_DRIVER_DECL(sandbox_spl_test);
-DM_DRIVER_DECL(denx_u_boot_fdt_test);
-DM_DRIVER_DECL(denx_u_boot_fdt_test);
+extern U_BOOT_DRIVER(sandbox_i2c);
+extern U_BOOT_DRIVER(root_driver);
+extern U_BOOT_DRIVER(denx_u_boot_test_bus);
+extern U_BOOT_DRIVER(sandbox_spl_test);
+extern U_BOOT_DRIVER(sandbox_spl_test);
+extern U_BOOT_DRIVER(denx_u_boot_fdt_test);
+extern U_BOOT_DRIVER(denx_u_boot_fdt_test);
 
 /* device declarations - these allow DM_DEVICE_REF() to be used */
-DM_DEVICE_DECL(i2c);
-DM_DEVICE_DECL(root);
-DM_DEVICE_DECL(some_bus);
-DM_DEVICE_DECL(spl_test);
-DM_DEVICE_DECL(spl_test3);
-DM_DEVICE_DECL(test);
-DM_DEVICE_DECL(test0);
+extern DM_DEVICE_INST(i2c);
+extern DM_DEVICE_INST(root);
+extern DM_DEVICE_INST(some_bus);
+extern DM_DEVICE_INST(spl_test);
+extern DM_DEVICE_INST(spl_test3);
+extern DM_DEVICE_INST(test);
+extern DM_DEVICE_INST(test0);
 
 /* uclass driver declarations - needed for DM_UCLASS_DRIVER_REF() */
-DM_UCLASS_DRIVER_DECL(i2c);
-DM_UCLASS_DRIVER_DECL(misc);
-DM_UCLASS_DRIVER_DECL(root);
-DM_UCLASS_DRIVER_DECL(testbus);
-DM_UCLASS_DRIVER_DECL(testfdt);
+extern UCLASS_DRIVER(i2c);
+extern UCLASS_DRIVER(misc);
+extern UCLASS_DRIVER(root);
+extern UCLASS_DRIVER(testbus);
+extern UCLASS_DRIVER(testfdt);
 
 /* uclass declarations - needed for DM_UCLASS_REF() */
-DM_UCLASS_DECL(i2c);
-DM_UCLASS_DECL(misc);
-DM_UCLASS_DECL(root);
-DM_UCLASS_DECL(testbus);
-DM_UCLASS_DECL(testfdt);
+extern DM_UCLASS_INST(i2c);
+extern DM_UCLASS_INST(misc);
+extern DM_UCLASS_INST(root);
+extern DM_UCLASS_INST(testbus);
+extern DM_UCLASS_INST(testfdt);
 '''
     struct_text = HEADER + '''
 struct dtd_sandbox_i2c {
-- 
2.31.0.rc2.261.g7f71774620-goog

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

* [PATCH v4 02/42] sandbox: Drop debug message in os_spl_to_uboot()
  2021-03-15  4:25 [PATCH v4 00/42] dm: Implement OF_PLATDATA_INST in driver model (part E) Simon Glass
  2021-03-15  4:25 ` [PATCH v4 01/42] dtoc: Drop use of DECL() macros Simon Glass
@ 2021-03-15  4:25 ` Simon Glass
  2021-03-15  4:25 ` [PATCH v4 03/42] linker_lists: Allow use in data structures Simon Glass
                   ` (81 subsequent siblings)
  83 siblings, 0 replies; 85+ messages in thread
From: Simon Glass @ 2021-03-15  4:25 UTC (permalink / raw)
  To: u-boot

This is not needed in normal operation. Drop it.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
---

(no changes since v1)

 arch/sandbox/cpu/os.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/arch/sandbox/cpu/os.c b/arch/sandbox/cpu/os.c
index 2d9583c17ca..68825d28d6a 100644
--- a/arch/sandbox/cpu/os.c
+++ b/arch/sandbox/cpu/os.c
@@ -845,7 +845,6 @@ int os_spl_to_uboot(const char *fname)
 {
 	struct sandbox_state *state = state_get_current();
 
-	printf("%s\n", __func__);
 	/* U-Boot will delete ram buffer after read: "--rm_memory"*/
 	state->ram_buf_rm = true;
 	return os_jump_to_file(fname);
-- 
2.31.0.rc2.261.g7f71774620-goog

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

* [PATCH v4 03/42] linker_lists: Allow use in data structures
  2021-03-15  4:25 [PATCH v4 00/42] dm: Implement OF_PLATDATA_INST in driver model (part E) Simon Glass
  2021-03-15  4:25 ` [PATCH v4 01/42] dtoc: Drop use of DECL() macros Simon Glass
  2021-03-15  4:25 ` [PATCH v4 02/42] sandbox: Drop debug message in os_spl_to_uboot() Simon Glass
@ 2021-03-15  4:25 ` Simon Glass
  2021-03-15  4:25 ` [PATCH v4 04/42] dm: core: Add macros to access the new linker lists Simon Glass
                   ` (80 subsequent siblings)
  83 siblings, 0 replies; 85+ messages in thread
From: Simon Glass @ 2021-03-15  4:25 UTC (permalink / raw)
  To: u-boot

At present linker lists are designed for use in code. They make use of
statements within expressions ({...}), for example.

It is possible to generate a reference to a linker_list entry that can
be used in data structures, where such features are not permitted. It
requires that the reference first be declared as extern. In other
words the existing macro needs to be split into two parts.

Add new macros to support this.

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

(no changes since v3)

Changes in v3:
- Drop the decl() variant since it is just as easy to use extern

 include/linker_lists.h | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/include/linker_lists.h b/include/linker_lists.h
index fd98ecd297c..0ca30da4172 100644
--- a/include/linker_lists.h
+++ b/include/linker_lists.h
@@ -211,6 +211,18 @@
 		_ll_result;						\
 	})
 
+/**
+ * ll_entry_ref() - Get a reference to a linker-generated array entry
+ *
+ * Once ll_entry_decl() has been used to declare the reference, this macro
+ * allows the entry to be accessed.
+ *
+ * This is like ll_entry_get(), but without the extra code, so it is suitable
+ * for putting into data structures.
+ */
+#define ll_entry_ref(_type, _name, _list)				\
+	((_type *)&_u_boot_list_2_##_list##_2_##_name)
+
 /**
  * ll_start() - Point to first entry of first linker-generated array
  * @_type:	Data type of the entry
-- 
2.31.0.rc2.261.g7f71774620-goog

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

* [PATCH v4 04/42] dm: core: Add macros to access the new linker lists
  2021-03-15  4:25 [PATCH v4 00/42] dm: Implement OF_PLATDATA_INST in driver model (part E) Simon Glass
                   ` (2 preceding siblings ...)
  2021-03-15  4:25 ` [PATCH v4 03/42] linker_lists: Allow use in data structures Simon Glass
@ 2021-03-15  4:25 ` Simon Glass
  2021-03-15  4:25 ` [PATCH v4 05/42] dm: core: Allow dropping run-time binding of devices Simon Glass
                   ` (79 subsequent siblings)
  83 siblings, 0 replies; 85+ messages in thread
From: Simon Glass @ 2021-03-15  4:25 UTC (permalink / raw)
  To: u-boot

Add macros which work with instantiated devices and uclasses, as created
at build time by dtoc. Include variants that can be used in data
structures.

These are mostly used by dtoc but it is worth documenting them fully for
the occasional case where they might come up in user code.

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

(no changes since v3)

Changes in v3:
- Drop the decl() versions of the macros
- Add full documentation for the macros

 include/dm/device-internal.h | 75 ++++++++++++++++++++++++++++++++++++
 include/dm/device.h          | 22 +++++++++++
 include/dm/uclass-internal.h | 49 +++++++++++++++++++++++
 include/dm/uclass.h          | 31 +++++++++++++++
 include/linker_lists.h       |  4 +-
 5 files changed, 179 insertions(+), 2 deletions(-)

diff --git a/include/dm/device-internal.h b/include/dm/device-internal.h
index 39406c3f352..71e5c75028d 100644
--- a/include/dm/device-internal.h
+++ b/include/dm/device-internal.h
@@ -10,11 +10,86 @@
 #ifndef _DM_DEVICE_INTERNAL_H
 #define _DM_DEVICE_INTERNAL_H
 
+#include <linker_lists.h>
 #include <dm/ofnode.h>
 
 struct device_node;
 struct udevice;
 
+/*
+ * These two macros DM_DEVICE_INST and DM_DEVICE_REF are only allowed in code
+ * generated by dtoc, because the ordering is important and if other instances
+ * creep in then they may mess up the ordering expected by dtoc.
+ *
+ * It is OK to use them with 'extern' though, since that does not actually
+ * add a new record to the linker_list.
+ */
+
+/**
+ * DM_DEVICE_INST() - Declare a bound device ready for run-time use
+ *
+ * This adds an actual struct udevice to a list which is found by driver model
+ * on start-up.
+ *
+ * For example:
+ *
+ * extern U_BOOT_DRIVER(sandbox_fixed_clock);
+ * extern DM_UCLASS_INST(clk);
+ *
+ * DM_DEVICE_INST(clk_fixed) = {
+ *	.driver		= DM_DRIVER_REF(sandbox_fixed_clock),
+ *	.name		= "sandbox_fixed_clock",
+ *	.plat_		= &_sandbox_fixed_clock_plat_clk_fixed,
+ *	.uclass		= DM_UCLASS_REF(clk),
+ *	...
+ *	.seq_		= 0,
+ * };
+ *
+ * @_name: Name of the udevice. This must be a valid C identifier, used by the
+ *	linker_list.
+ */
+#define DM_DEVICE_INST(_name)						\
+	ll_entry_declare(struct udevice, _name, udevice)
+
+/**
+ * DM_DEVICE_REF() - Get a reference to a device
+ *
+ * This is useful in data structures and code for referencing a udevice at
+ * build time. Before this is used, an extern DM_DEVICE_INST() must have been
+ * declared.
+ *
+ * For example:
+ *
+ * extern DM_DEVICE_INST(clk_fixed);
+ *
+ * struct udevice *devs[] = {
+ *	DM_DEVICE_REF(clk_fixed),
+ * };
+ *
+ * @_name: Name of the udevice. This must be a valid C identifier, used by the
+ *	linker_list
+ * @returns struct udevice * for the device
+ */
+#define DM_DEVICE_REF(_name)						\
+	ll_entry_ref(struct udevice, _name, udevice)
+
+/**
+ * DM_DEVICE_GET() - Get a pointer to a given device
+ *
+ * This is similar to DM_DEVICE_REF() except that it does not need the extern
+ * declaration before it. However it cannot be used in a data structures, only
+ * in code within a function.
+ *
+ * For example:
+ *
+ * void some_function() {
+ *	struct udevice *dev = DM_DEVICE_GET(clk_fixed);
+ * ...
+ * }
+ */
+#define DM_DEVICE_GET(__name)						\
+	ll_entry_get(struct udevice, __name, udevice)
+
 /**
  * device_bind() - Create a device and bind it to a driver
  *
diff --git a/include/dm/device.h b/include/dm/device.h
index 45010b4df92..5b8f27d455b 100644
--- a/include/dm/device.h
+++ b/include/dm/device.h
@@ -362,6 +362,28 @@ struct driver {
 #define DM_DRIVER_GET(__name)						\
 	ll_entry_get(struct driver, __name, driver)
 
+/**
+ * DM_DRIVER_REF() - Get a reference to a driver
+ *
+ * This is useful in data structures and code for referencing a driver at
+ * build time. Before this is used, an extern U_BOOT_DRIVER() must have been
+ * declared.
+ *
+ * For example:
+ *
+ * extern U_BOOT_DRIVER(sandbox_fixed_clock);
+ *
+ * struct driver *drvs[] = {
+ *	DM_DRIVER_REF(sandbox_fixed_clock),
+ * };
+ *
+ * @_name: Name of the driver. This must be a valid C identifier, used by the
+ *	linker_list
+ * @returns struct driver * for the driver
+ */
+#define DM_DRIVER_REF(_name)					\
+	ll_entry_ref(struct driver, _name, driver)
+
 /**
  * Declare a macro to state a alias for a driver name. This macro will
  * produce no code but its information will be parsed by tools like
diff --git a/include/dm/uclass-internal.h b/include/dm/uclass-internal.h
index c5a464be7c4..f2a780682b4 100644
--- a/include/dm/uclass-internal.h
+++ b/include/dm/uclass-internal.h
@@ -11,6 +11,55 @@
 
 #include <dm/ofnode.h>
 
+/*
+ * These next two macros DM_UCLASS_INST() and DM_UCLASS_REF() are only allowed
+ * in code generated by dtoc, because the ordering is important and if other
+ * instances creep in then they may mess up the ordering expected by dtoc.
+ *
+ * It is OK to use them with 'extern' though, since that does not actually
+ * add a new record to the linker_list.
+ */
+
+/**
+ * DM_UCLASS_INST() - Declare a uclass ready for run-time use
+ *
+ * This adds an actual struct uclass to a list which is found by driver model
+ * on start-up.
+ *
+ * For example:
+ *
+ * DM_UCLASS_INST(clk) = {
+ *	.uc_drv		= DM_UCLASS_DRIVER_REF(clk),
+ * ...
+ * };
+ *
+ * @_name: Name of the uclass. This must be a valid C identifier, used by the
+ *	linker_list.
+ */
+#define DM_UCLASS_INST(_name)						\
+	ll_entry_declare(struct uclass, _name, uclass)
+
+/**
+ * DM_UCLASS_REF() - Get a reference to a uclass
+ *
+ * This is useful for referencing a uclass at build time. Before this is used,
+ * an extern DM_UCLASS_INST() must have been declared.
+ *
+ * For example:
+ *
+ * extern DM_UCLASS_INST(clk);
+ *
+ * struct uclass *ucs[] = {
+ *	DM_UCLASS_REF(clk),
+ * }
+ *
+ * @_name: Name of the uclass. This must be a valid C identifier, used by the
+ *	linker_list
+ * @returns struct uclass * for the device
+ */
+#define DM_UCLASS_REF(_name)						\
+	ll_entry_ref(struct uclass, _name, uclass)
+
 /**
  * uclass_set_priv() - Set the private data for a uclass
  *
diff --git a/include/dm/uclass.h b/include/dm/uclass.h
index d95683740cb..6752d8ee0be 100644
--- a/include/dm/uclass.h
+++ b/include/dm/uclass.h
@@ -114,6 +114,37 @@ struct uclass_driver {
 #define UCLASS_DRIVER(__name)						\
 	ll_entry_declare(struct uclass_driver, __name, uclass_driver)
 
+/*
+ * These two macros DM_UCLASS_DRIVER_REF and DM_UCLASS_DRIVER_REF are only
+ * allowed in code generated by dtoc, because the ordering is important and if
+ * other instances creep in then they may mess up the ordering expected by dtoc.
+ *
+ * It is OK to use them with 'extern' though, since that does not actually
+ * add a new record to the linker_list.
+ */
+
+/**
+ * DM_UCLASS_DRIVER_REF() - Get a reference to a uclass driver
+ *
+ * This is useful in data structures and code for referencing a uclass_driver at
+ * build time. Before this is used, an extern UCLASS_DRIVER() must have been
+ * declared.
+ *
+ * For example:
+ *
+ * extern UCLASS_DRIVER(clk);
+ *
+ * struct uclass_driver *drvs[] = {
+ *	DM_UCLASS_DRIVER_REF(clk),
+ * };
+ *
+ * @_name: Name of the uclass_driver. This must be a valid C identifier, used by
+ *	the linker_list.
+ * @returns struct uclass_driver * for the uclass driver
+ */
+#define DM_UCLASS_DRIVER_REF(_name)					\
+	ll_entry_ref(struct uclass_driver, _name, uclass_driver)
+
 /**
  * uclass_get_priv() - Get the private data for a uclass
  *
diff --git a/include/linker_lists.h b/include/linker_lists.h
index 0ca30da4172..81a280a8841 100644
--- a/include/linker_lists.h
+++ b/include/linker_lists.h
@@ -214,8 +214,8 @@
 /**
  * ll_entry_ref() - Get a reference to a linker-generated array entry
  *
- * Once ll_entry_decl() has been used to declare the reference, this macro
- * allows the entry to be accessed.
+ * Once an extern ll_entry_declare() has been used to declare the reference,
+ * this macro allows the entry to be accessed.
  *
  * This is like ll_entry_get(), but without the extra code, so it is suitable
  * for putting into data structures.
-- 
2.31.0.rc2.261.g7f71774620-goog

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

* [PATCH v4 05/42] dm: core: Allow dropping run-time binding of devices
  2021-03-15  4:25 [PATCH v4 00/42] dm: Implement OF_PLATDATA_INST in driver model (part E) Simon Glass
                   ` (3 preceding siblings ...)
  2021-03-15  4:25 ` [PATCH v4 04/42] dm: core: Add macros to access the new linker lists Simon Glass
@ 2021-03-15  4:25 ` Simon Glass
  2021-03-15  4:25 ` [PATCH v4 06/42] dm: core: Adjust uclass setup with of-platdata Simon Glass
                   ` (78 subsequent siblings)
  83 siblings, 0 replies; 85+ messages in thread
From: Simon Glass @ 2021-03-15  4:25 UTC (permalink / raw)
  To: u-boot

With OF_PLATDATA_INST devices are bound at build time. We should not need
binding of devices at runtime in most cases. However it is inflexible to
absolutely prohibit it, so add an option to control this.

Update the driver model core so that it does not bind devices. Update
device_bind() to return an error if called.

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

(no changes since v3)

Changes in v3:
- Update the commit message to explain OF_PLATDATA_NO_BIND better
- Update OF_PLATDATA_NO_BIND help as well

 drivers/core/device.c | 42 +++++++++++++++++++++++++-----------------
 dts/Kconfig           | 18 ++++++++++++++++++
 2 files changed, 43 insertions(+), 17 deletions(-)

diff --git a/drivers/core/device.c b/drivers/core/device.c
index 81f6880eac4..e915b3089de 100644
--- a/drivers/core/device.c
+++ b/drivers/core/device.c
@@ -45,6 +45,9 @@ static int device_bind_common(struct udevice *parent, const struct driver *drv,
 	bool auto_seq = true;
 	void *ptr;
 
+	if (CONFIG_IS_ENABLED(OF_PLATDATA_NO_BIND))
+		return -ENOSYS;
+
 	if (devp)
 		*devp = NULL;
 	if (!name)
@@ -395,26 +398,31 @@ int device_of_to_plat(struct udevice *dev)
 	if (dev_get_flags(dev) & DM_FLAG_PLATDATA_VALID)
 		return 0;
 
-	/* Ensure all parents have ofdata */
-	if (dev->parent) {
-		ret = device_of_to_plat(dev->parent);
+	/*
+	 * This is not needed if binding is disabled, since data is allocated
+	 * at build time.
+	 */
+	if (!CONFIG_IS_ENABLED(OF_PLATDATA_NO_BIND)) {
+		/* Ensure all parents have ofdata */
+		if (dev->parent) {
+			ret = device_of_to_plat(dev->parent);
+			if (ret)
+				goto fail;
+
+			/*
+			 * The device might have already been probed during
+			 * the call to device_probe() on its parent device
+			 * (e.g. PCI bridge devices). Test the flags again
+			 * so that we don't mess up the device.
+			 */
+			if (dev_get_flags(dev) & DM_FLAG_PLATDATA_VALID)
+				return 0;
+		}
+
+		ret = device_alloc_priv(dev);
 		if (ret)
 			goto fail;
-
-		/*
-		 * The device might have already been probed during
-		 * the call to device_probe() on its parent device
-		 * (e.g. PCI bridge devices). Test the flags again
-		 * so that we don't mess up the device.
-		 */
-		if (dev_get_flags(dev) & DM_FLAG_PLATDATA_VALID)
-			return 0;
 	}
-
-	ret = device_alloc_priv(dev);
-	if (ret)
-		goto fail;
-
 	drv = dev->driver;
 	assert(drv);
 
diff --git a/dts/Kconfig b/dts/Kconfig
index c39cc368881..d289752a139 100644
--- a/dts/Kconfig
+++ b/dts/Kconfig
@@ -371,6 +371,15 @@ config SPL_OF_PLATDATA_INST
 	  Declare devices as udevice instances so that they do not need to be
 	  bound when U-Boot starts. This can save time and code space.
 
+config SPL_OF_PLATDATA_NO_BIND
+	bool "Don't allow run-time binding of devices"
+	depends on SPL_OF_PLATDATA_INST
+	default y
+	help
+	  This removes the ability to bind devices at run time, thus saving
+	  some code space in U-Boot. This can be disabled if binding is needed,
+	  at the code of some code size increase.
+
 endif
 
 config TPL_OF_PLATDATA
@@ -411,6 +420,15 @@ config TPL_OF_PLATDATA_INST
 	  Declare devices as udevice instances so that they do not need to be
 	  bound when U-Boot starts. This can save time and code space.
 
+config TPL_OF_PLATDATA_NO_BIND
+	bool "Don't allow run-time binding of devices"
+	depends on TPL_OF_PLATDATA_INST
+	default y
+	help
+	  This removes the ability to bind devices at run time, thus saving
+	  some code space in U-Boot. This can be disabled if binding is needed,
+	  at the code of some code size increase.
+
 endif
 
 endmenu
-- 
2.31.0.rc2.261.g7f71774620-goog

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

* [PATCH v4 06/42] dm: core: Adjust uclass setup with of-platdata
  2021-03-15  4:25 [PATCH v4 00/42] dm: Implement OF_PLATDATA_INST in driver model (part E) Simon Glass
                   ` (4 preceding siblings ...)
  2021-03-15  4:25 ` [PATCH v4 05/42] dm: core: Allow dropping run-time binding of devices Simon Glass
@ 2021-03-15  4:25 ` Simon Glass
  2021-03-15  4:25 ` [PATCH v4 07/42] dm: core: Set up driver model for OF_PLATDATA_INST Simon Glass
                   ` (77 subsequent siblings)
  83 siblings, 0 replies; 85+ messages in thread
From: Simon Glass @ 2021-03-15  4:25 UTC (permalink / raw)
  To: u-boot

When OF_PLATDATA_INST is enabled we don't need to create the uclass list.
Instead we just need to point to the existing list. Update the code
accordingly.

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

(no changes since v1)

 drivers/core/root.c | 8 ++++++--
 include/dm/root.h   | 3 +++
 2 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/drivers/core/root.c b/drivers/core/root.c
index 9bc682cffea..3feadb77b56 100644
--- a/drivers/core/root.c
+++ b/drivers/core/root.c
@@ -140,8 +140,12 @@ int dm_init(bool of_live)
 		dm_warn("Virtual root driver already exists!\n");
 		return -EINVAL;
 	}
-	gd->uclass_root = &DM_UCLASS_ROOT_S_NON_CONST;
-	INIT_LIST_HEAD(DM_UCLASS_ROOT_NON_CONST);
+	if (CONFIG_IS_ENABLED(OF_PLATDATA_INST)) {
+		gd->uclass_root = &uclass_head;
+	} else {
+		gd->uclass_root = &DM_UCLASS_ROOT_S_NON_CONST;
+		INIT_LIST_HEAD(DM_UCLASS_ROOT_NON_CONST);
+	}
 
 	if (IS_ENABLED(CONFIG_NEEDS_MANUAL_RELOC)) {
 		fix_drivers();
diff --git a/include/dm/root.h b/include/dm/root.h
index 89afbee6196..42510b106ab 100644
--- a/include/dm/root.h
+++ b/include/dm/root.h
@@ -11,6 +11,9 @@
 
 struct udevice;
 
+/* Head of the uclass list if CONFIG_OF_PLATDATA_INST is enabled */
+extern struct list_head uclass_head;
+
 /**
  * dm_root() - Return pointer to the top of the driver tree
  *
-- 
2.31.0.rc2.261.g7f71774620-goog

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

* [PATCH v4 07/42] dm: core: Set up driver model for OF_PLATDATA_INST
  2021-03-15  4:25 [PATCH v4 00/42] dm: Implement OF_PLATDATA_INST in driver model (part E) Simon Glass
                   ` (5 preceding siblings ...)
  2021-03-15  4:25 ` [PATCH v4 06/42] dm: core: Adjust uclass setup with of-platdata Simon Glass
@ 2021-03-15  4:25 ` Simon Glass
  2021-03-15  4:25 ` [PATCH v4 08/42] dm: core: Skip adding uclasses with OF_PLATDATA_INST Simon Glass
                   ` (76 subsequent siblings)
  83 siblings, 0 replies; 85+ messages in thread
From: Simon Glass @ 2021-03-15  4:25 UTC (permalink / raw)
  To: u-boot

With this we don't need to scan and bind drivers, not even the root
device. We just need to locate the root device that was set up at build
time, then set our root in global_data to point to it.

Update the code to handle this case.

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

(no changes since v1)

 drivers/core/root.c | 42 ++++++++++++++++++++++++++++++------------
 1 file changed, 30 insertions(+), 12 deletions(-)

diff --git a/drivers/core/root.c b/drivers/core/root.c
index 3feadb77b56..3e52452cd85 100644
--- a/drivers/core/root.c
+++ b/drivers/core/root.c
@@ -129,6 +129,13 @@ void fix_devices(void)
 	}
 }
 
+static int dm_setup_inst(void)
+{
+	DM_ROOT_NON_CONST = DM_DEVICE_GET(root);
+
+	return 0;
+}
+
 int dm_init(bool of_live)
 {
 	int ret;
@@ -153,14 +160,23 @@ int dm_init(bool of_live)
 		fix_devices();
 	}
 
-	ret = device_bind_by_name(NULL, false, &root_info, &DM_ROOT_NON_CONST);
-	if (ret)
-		return ret;
-	if (CONFIG_IS_ENABLED(OF_CONTROL))
-		dev_set_ofnode(DM_ROOT_NON_CONST, ofnode_root());
-	ret = device_probe(DM_ROOT_NON_CONST);
-	if (ret)
-		return ret;
+	if (CONFIG_IS_ENABLED(OF_PLATDATA_INST)) {
+		ret = dm_setup_inst();
+		if (ret) {
+			log_debug("dm_setup_inst() failed: %d\n", ret);
+			return ret;
+		}
+	} else {
+		ret = device_bind_by_name(NULL, false, &root_info,
+					  &DM_ROOT_NON_CONST);
+		if (ret)
+			return ret;
+		if (CONFIG_IS_ENABLED(OF_CONTROL))
+			dev_set_ofnode(DM_ROOT_NON_CONST, ofnode_root());
+		ret = device_probe(DM_ROOT_NON_CONST);
+		if (ret)
+			return ret;
+	}
 
 	return 0;
 }
@@ -351,10 +367,12 @@ int dm_init_and_scan(bool pre_reloc_only)
 		debug("dm_init() failed: %d\n", ret);
 		return ret;
 	}
-	ret = dm_scan(pre_reloc_only);
-	if (ret) {
-		log_debug("dm_scan() failed: %d\n", ret);
-		return ret;
+	if (!CONFIG_IS_ENABLED(OF_PLATDATA_INST)) {
+		ret = dm_scan(pre_reloc_only);
+		if (ret) {
+			log_debug("dm_scan() failed: %d\n", ret);
+			return ret;
+		}
 	}
 
 	return 0;
-- 
2.31.0.rc2.261.g7f71774620-goog

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

* [PATCH v4 08/42] dm: core: Skip adding uclasses with OF_PLATDATA_INST
  2021-03-15  4:25 [PATCH v4 00/42] dm: Implement OF_PLATDATA_INST in driver model (part E) Simon Glass
                   ` (6 preceding siblings ...)
  2021-03-15  4:25 ` [PATCH v4 07/42] dm: core: Set up driver model for OF_PLATDATA_INST Simon Glass
@ 2021-03-15  4:25 ` Simon Glass
  2021-03-15  4:25 ` [PATCH v4 09/42] dm: Add the new dtoc-generated files to the build Simon Glass
                   ` (75 subsequent siblings)
  83 siblings, 0 replies; 85+ messages in thread
From: Simon Glass @ 2021-03-15  4:25 UTC (permalink / raw)
  To: u-boot

There is no need to ever add new uclasses since these are set up at build
time. Update the code to return an error if this is attempted.

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

(no changes since v1)

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

diff --git a/drivers/core/uclass.c b/drivers/core/uclass.c
index 1a4ea7a57a6..f753a1f91e7 100644
--- a/drivers/core/uclass.c
+++ b/drivers/core/uclass.c
@@ -148,8 +148,11 @@ int uclass_get(enum uclass_id id, struct uclass **ucp)
 
 	*ucp = NULL;
 	uc = uclass_find(id);
-	if (!uc)
+	if (!uc) {
+		if (CONFIG_IS_ENABLED(OF_PLATDATA_INST))
+			return -ENOENT;
 		return uclass_add(id, ucp);
+	}
 	*ucp = uc;
 
 	return 0;
-- 
2.31.0.rc2.261.g7f71774620-goog

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

* [PATCH v4 09/42] dm: Add the new dtoc-generated files to the build
  2021-03-15  4:25 [PATCH v4 00/42] dm: Implement OF_PLATDATA_INST in driver model (part E) Simon Glass
                   ` (7 preceding siblings ...)
  2021-03-15  4:25 ` [PATCH v4 08/42] dm: core: Skip adding uclasses with OF_PLATDATA_INST Simon Glass
@ 2021-03-15  4:25 ` Simon Glass
  2021-03-15  4:25 ` [PATCH v4 10/42] dm: core: Include dt-decl.h automatically Simon Glass
                   ` (74 subsequent siblings)
  83 siblings, 0 replies; 85+ messages in thread
From: Simon Glass @ 2021-03-15  4:25 UTC (permalink / raw)
  To: u-boot

Now that dtoc generates some new C files, add these to the build so that
the instantiated devices and uclasses can be used.

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

(no changes since v1)

 scripts/Makefile.spl | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/scripts/Makefile.spl b/scripts/Makefile.spl
index 52609112ecd..fe9b616dcc4 100644
--- a/scripts/Makefile.spl
+++ b/scripts/Makefile.spl
@@ -120,7 +120,8 @@ endif
 u-boot-spl-init := $(head-y)
 u-boot-spl-main := $(libs-y)
 ifdef CONFIG_$(SPL_TPL_)OF_PLATDATA
-u-boot-spl-platdata := $(obj)/dts/dt-plat.o
+u-boot-spl-platdata := $(obj)/dts/dt-plat.o $(obj)/dts/dt-uclass.o \
+	$(obj)/dts/dt-device.o
 u-boot-spl-platdata_c := $(patsubst %.o,%.c,$(u-boot-spl-platdata))
 endif
 
-- 
2.31.0.rc2.261.g7f71774620-goog

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

* [PATCH v4 10/42] dm: core: Include dt-decl.h automatically
  2021-03-15  4:25 [PATCH v4 00/42] dm: Implement OF_PLATDATA_INST in driver model (part E) Simon Glass
                   ` (8 preceding siblings ...)
  2021-03-15  4:25 ` [PATCH v4 09/42] dm: Add the new dtoc-generated files to the build Simon Glass
@ 2021-03-15  4:25 ` Simon Glass
  2021-03-15  4:25 ` [PATCH v4 11/42] dm: test: Avoid destroying uclasses with of-platdata-inst Simon Glass
                   ` (73 subsequent siblings)
  83 siblings, 0 replies; 85+ messages in thread
From: Simon Glass @ 2021-03-15  4:25 UTC (permalink / raw)
  To: u-boot

When dt-structs.h is used, include the dt-decl.h header as well, so that
these declarations are available.

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

(no changes since v1)

 include/dt-structs.h | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/include/dt-structs.h b/include/dt-structs.h
index f0e1c9cb901..f9ccaf56a46 100644
--- a/include/dt-structs.h
+++ b/include/dt-structs.h
@@ -24,7 +24,9 @@ struct phandle_2_arg {
 	uint idx;
 	int arg[2];
 };
+
 #include <generated/dt-structs-gen.h>
+#include <generated/dt-decl.h>
 #endif
 
 #endif
-- 
2.31.0.rc2.261.g7f71774620-goog

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

* [PATCH v4 11/42] dm: test: Avoid destroying uclasses with of-platdata-inst
  2021-03-15  4:25 [PATCH v4 00/42] dm: Implement OF_PLATDATA_INST in driver model (part E) Simon Glass
                   ` (9 preceding siblings ...)
  2021-03-15  4:25 ` [PATCH v4 10/42] dm: core: Include dt-decl.h automatically Simon Glass
@ 2021-03-15  4:25 ` Simon Glass
  2021-03-15  4:25 ` [PATCH v4 12/42] clk: sandbox: Move priv/plat data to a header file Simon Glass
                   ` (72 subsequent siblings)
  83 siblings, 0 replies; 85+ messages in thread
From: Simon Glass @ 2021-03-15  4:25 UTC (permalink / raw)
  To: u-boot

It is not possible to destroy the uclasses when they are created at
build time. Skip this step so that SPL test can complete successfully.

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

(no changes since v2)

Changes in v2:
- Update to deal with test refactoring series

 test/test-main.c | 30 +++++++++++++++++++-----------
 1 file changed, 19 insertions(+), 11 deletions(-)

diff --git a/test/test-main.c b/test/test-main.c
index e1b49e091ab..46a0c2ee2f6 100644
--- a/test/test-main.c
+++ b/test/test-main.c
@@ -62,17 +62,25 @@ static int dm_test_post_run(struct unit_test_state *uts)
 {
 	int id;
 
-	for (id = 0; id < UCLASS_COUNT; id++) {
-		struct uclass *uc;
-
-		/*
-		 * If the uclass doesn't exist we don't want to create it. So
-		 * check that here before we call uclass_find_device().
-		 */
-		uc = uclass_find(id);
-		if (!uc)
-			continue;
-		ut_assertok(uclass_destroy(uc));
+	/*
+	 * With of-platdata-inst the uclasses are created@build time. If we
+	 * destroy them we cannot get them back since uclass_add() is not
+	 * supported. So skip this.
+	 */
+	if (!CONFIG_IS_ENABLED(OF_PLATDATA_INST)) {
+		for (id = 0; id < UCLASS_COUNT; id++) {
+			struct uclass *uc;
+
+			/*
+			 * If the uclass doesn't exist we don't want to create
+			 * it. So check that here before we call
+			 * uclass_find_device().
+			 */
+			uc = uclass_find(id);
+			if (!uc)
+				continue;
+			ut_assertok(uclass_destroy(uc));
+		}
 	}
 
 	return 0;
-- 
2.31.0.rc2.261.g7f71774620-goog

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

* [PATCH v4 12/42] clk: sandbox: Move priv/plat data to a header file
  2021-03-15  4:25 [PATCH v4 00/42] dm: Implement OF_PLATDATA_INST in driver model (part E) Simon Glass
                   ` (10 preceding siblings ...)
  2021-03-15  4:25 ` [PATCH v4 11/42] dm: test: Avoid destroying uclasses with of-platdata-inst Simon Glass
@ 2021-03-15  4:25 ` Simon Glass
  2021-03-15  4:25 ` [PATCH v4 13/42] clk: fixed-rate: Export driver parts for OF_PLATDATA_INST Simon Glass
                   ` (71 subsequent siblings)
  83 siblings, 0 replies; 85+ messages in thread
From: Simon Glass @ 2021-03-15  4:25 UTC (permalink / raw)
  To: u-boot

At present the structs used by this driver are not accessible outside it,
so cannot be used with OF_PLATDATA_INST. Move them to a header file to
fix this.

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

(no changes since v1)

 arch/sandbox/include/asm/clk.h | 16 ++++++++++++++++
 drivers/clk/clk_sandbox.c      |  7 -------
 drivers/clk/clk_sandbox_test.c |  6 ------
 3 files changed, 16 insertions(+), 13 deletions(-)

diff --git a/arch/sandbox/include/asm/clk.h b/arch/sandbox/include/asm/clk.h
index 68a8687f578..6972b9e743a 100644
--- a/arch/sandbox/include/asm/clk.h
+++ b/arch/sandbox/include/asm/clk.h
@@ -7,6 +7,9 @@
 #define __SANDBOX_CLK_H
 
 #include <common.h>
+#include <clk.h>
+#include <dt-structs.h>
+#include <linux/clk-provider.h>
 
 struct udevice;
 
@@ -45,6 +48,19 @@ enum sandbox_clk_test_id {
 
 #define SANDBOX_CLK_TEST_NON_DEVM_COUNT SANDBOX_CLK_TEST_ID_DEVM1
 
+struct sandbox_clk_priv {
+	bool probed;
+	ulong rate[SANDBOX_CLK_ID_COUNT];
+	bool enabled[SANDBOX_CLK_ID_COUNT];
+	bool requested[SANDBOX_CLK_ID_COUNT];
+};
+
+struct sandbox_clk_test {
+	struct clk clks[SANDBOX_CLK_TEST_NON_DEVM_COUNT];
+	struct clk *clkps[SANDBOX_CLK_TEST_ID_COUNT];
+	struct clk_bulk bulk;
+};
+
 /**
  * sandbox_clk_query_rate - Query the current rate of a sandbox clock.
  *
diff --git a/drivers/clk/clk_sandbox.c b/drivers/clk/clk_sandbox.c
index b28b67b4486..e1313f6d880 100644
--- a/drivers/clk/clk_sandbox.c
+++ b/drivers/clk/clk_sandbox.c
@@ -10,13 +10,6 @@
 #include <malloc.h>
 #include <asm/clk.h>
 
-struct sandbox_clk_priv {
-	bool probed;
-	ulong rate[SANDBOX_CLK_ID_COUNT];
-	bool enabled[SANDBOX_CLK_ID_COUNT];
-	bool requested[SANDBOX_CLK_ID_COUNT];
-};
-
 static ulong sandbox_clk_get_rate(struct clk *clk)
 {
 	struct sandbox_clk_priv *priv = dev_get_priv(clk->dev);
diff --git a/drivers/clk/clk_sandbox_test.c b/drivers/clk/clk_sandbox_test.c
index c4e44815084..f665fd3cc45 100644
--- a/drivers/clk/clk_sandbox_test.c
+++ b/drivers/clk/clk_sandbox_test.c
@@ -11,12 +11,6 @@
 #include <dm/device_compat.h>
 #include <linux/err.h>
 
-struct sandbox_clk_test {
-	struct clk clks[SANDBOX_CLK_TEST_NON_DEVM_COUNT];
-	struct clk *clkps[SANDBOX_CLK_TEST_ID_COUNT];
-	struct clk_bulk bulk;
-};
-
 static const char * const sandbox_clk_test_names[] = {
 	[SANDBOX_CLK_TEST_ID_FIXED] = "fixed",
 	[SANDBOX_CLK_TEST_ID_SPI] = "spi",
-- 
2.31.0.rc2.261.g7f71774620-goog

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

* [PATCH v4 13/42] clk: fixed-rate: Export driver parts for OF_PLATDATA_INST
  2021-03-15  4:25 [PATCH v4 00/42] dm: Implement OF_PLATDATA_INST in driver model (part E) Simon Glass
                   ` (11 preceding siblings ...)
  2021-03-15  4:25 ` [PATCH v4 12/42] clk: sandbox: Move priv/plat data to a header file Simon Glass
@ 2021-03-15  4:25 ` Simon Glass
  2021-03-15  4:25 ` [PATCH v4 14/42] clk: sandbox: Create a special fixed-rate driver Simon Glass
                   ` (70 subsequent siblings)
  83 siblings, 0 replies; 85+ messages in thread
From: Simon Glass @ 2021-03-15  4:25 UTC (permalink / raw)
  To: u-boot

We need to allow SoCs to create their own drivers for this so that they
can use their own of-platdata structs. To minimise code duplication,
export the driver operations and the ofdata_to_plat() setup function.

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

(no changes since v1)

 drivers/clk/clk_fixed_rate.c | 14 ++++++++++----
 include/linux/clk-provider.h |  5 +++++
 2 files changed, 15 insertions(+), 4 deletions(-)

diff --git a/drivers/clk/clk_fixed_rate.c b/drivers/clk/clk_fixed_rate.c
index 3c5a83c523c..09f9ef26a42 100644
--- a/drivers/clk/clk_fixed_rate.c
+++ b/drivers/clk/clk_fixed_rate.c
@@ -25,18 +25,24 @@ const struct clk_ops clk_fixed_rate_ops = {
 	.enable = dummy_enable,
 };
 
-static int clk_fixed_rate_of_to_plat(struct udevice *dev)
+void clk_fixed_rate_ofdata_to_plat_(struct udevice *dev,
+				    struct clk_fixed_rate *plat)
 {
-	struct clk *clk = &to_clk_fixed_rate(dev)->clk;
+	struct clk *clk = &plat->clk;
 #if !CONFIG_IS_ENABLED(OF_PLATDATA)
-	to_clk_fixed_rate(dev)->fixed_rate =
-		dev_read_u32_default(dev, "clock-frequency", 0);
+	plat->fixed_rate = dev_read_u32_default(dev, "clock-frequency", 0);
 #endif
 	/* Make fixed rate clock accessible from higher level struct clk */
 	/* FIXME: This is not allowed */
 	dev_set_uclass_priv(dev, clk);
+
 	clk->dev = dev;
 	clk->enable_count = 0;
+}
+
+static int clk_fixed_rate_of_to_plat(struct udevice *dev)
+{
+	clk_fixed_rate_ofdata_to_plat_(dev, to_clk_fixed_rate(dev));
 
 	return 0;
 }
diff --git a/include/linux/clk-provider.h b/include/linux/clk-provider.h
index cc9c430512d..6fda14f5fe6 100644
--- a/include/linux/clk-provider.h
+++ b/include/linux/clk-provider.h
@@ -192,6 +192,8 @@ struct clk_fixed_factor {
 	unsigned int	div;
 };
 
+extern const struct clk_ops clk_fixed_rate_ops;
+
 #define to_clk_fixed_factor(_clk) container_of(_clk, struct clk_fixed_factor,\
 					       clk)
 
@@ -202,6 +204,9 @@ struct clk_fixed_rate {
 
 #define to_clk_fixed_rate(dev)	((struct clk_fixed_rate *)dev_get_plat(dev))
 
+void clk_fixed_rate_ofdata_to_plat_(struct udevice *dev,
+				    struct clk_fixed_rate *plat);
+
 struct clk_composite {
 	struct clk	clk;
 	struct clk_ops	ops;
-- 
2.31.0.rc2.261.g7f71774620-goog

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

* [PATCH v4 14/42] clk: sandbox: Create a special fixed-rate driver
  2021-03-15  4:25 [PATCH v4 00/42] dm: Implement OF_PLATDATA_INST in driver model (part E) Simon Glass
                   ` (12 preceding siblings ...)
  2021-03-15  4:25 ` [PATCH v4 13/42] clk: fixed-rate: Export driver parts for OF_PLATDATA_INST Simon Glass
@ 2021-03-15  4:25 ` Simon Glass
  2021-03-15  4:25 ` [PATCH v4 15/42] dm: core: Drop device_get_by_driver_info() Simon Glass
                   ` (69 subsequent siblings)
  83 siblings, 0 replies; 85+ messages in thread
From: Simon Glass @ 2021-03-15  4:25 UTC (permalink / raw)
  To: u-boot

Create a version of this driver for sandbox so that it can use the
of-platdata struct.

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

(no changes since v1)

 arch/sandbox/dts/sandbox.dtsi  |  2 +-
 arch/sandbox/include/asm/clk.h |  8 ++++++++
 drivers/clk/clk_sandbox.c      | 33 +++++++++++++++++++++++++++++++++
 test/dm/of_platdata.c          |  2 +-
 4 files changed, 43 insertions(+), 2 deletions(-)

diff --git a/arch/sandbox/dts/sandbox.dtsi b/arch/sandbox/dts/sandbox.dtsi
index 7455c99a739..5bf84451c99 100644
--- a/arch/sandbox/dts/sandbox.dtsi
+++ b/arch/sandbox/dts/sandbox.dtsi
@@ -31,7 +31,7 @@
 
 	clk_fixed: clk-fixed {
 		u-boot,dm-pre-reloc;
-		compatible = "fixed-clock";
+		compatible = "sandbox,fixed-clock";
 		#clock-cells = <0>;
 		clock-frequency = <1234>;
 	};
diff --git a/arch/sandbox/include/asm/clk.h b/arch/sandbox/include/asm/clk.h
index 6972b9e743a..df7156fe317 100644
--- a/arch/sandbox/include/asm/clk.h
+++ b/arch/sandbox/include/asm/clk.h
@@ -61,6 +61,14 @@ struct sandbox_clk_test {
 	struct clk_bulk bulk;
 };
 
+/* Platform data for the sandbox fixed-rate clock driver */
+struct sandbox_clk_fixed_rate_plat {
+#if CONFIG_IS_ENABLED(OF_PLATDATA)
+	struct dtd_sandbox_fixed_clock dtplat;
+#endif
+	struct clk_fixed_rate fixed;
+};
+
 /**
  * sandbox_clk_query_rate - Query the current rate of a sandbox clock.
  *
diff --git a/drivers/clk/clk_sandbox.c b/drivers/clk/clk_sandbox.c
index e1313f6d880..57acf7d8553 100644
--- a/drivers/clk/clk_sandbox.c
+++ b/drivers/clk/clk_sandbox.c
@@ -9,6 +9,7 @@
 #include <errno.h>
 #include <malloc.h>
 #include <asm/clk.h>
+#include <linux/clk-provider.h>
 
 static ulong sandbox_clk_get_rate(struct clk *clk)
 {
@@ -171,3 +172,35 @@ int sandbox_clk_query_requested(struct udevice *dev, int id)
 		return -EINVAL;
 	return priv->requested[id];
 }
+
+int clk_fixed_rate_of_to_plat(struct udevice *dev)
+{
+	struct clk_fixed_rate *cplat;
+
+#if CONFIG_IS_ENABLED(OF_PLATDATA)
+	struct sandbox_clk_fixed_rate_plat *plat = dev_get_plat(dev);
+
+	cplat = &plat->fixed;
+	cplat->fixed_rate = plat->dtplat.clock_frequency;
+#else
+	cplat = to_clk_fixed_rate(dev);
+#endif
+	clk_fixed_rate_ofdata_to_plat_(dev, cplat);
+
+	return 0;
+}
+
+static const struct udevice_id sandbox_clk_fixed_rate_match[] = {
+	{ .compatible = "sandbox,fixed-clock" },
+	{ /* sentinel */ }
+};
+
+U_BOOT_DRIVER(sandbox_fixed_clock) = {
+	.name = "sandbox_fixed_clock",
+	.id = UCLASS_CLK,
+	.of_match = sandbox_clk_fixed_rate_match,
+	.of_to_plat = clk_fixed_rate_of_to_plat,
+	.plat_auto = sizeof(struct sandbox_clk_fixed_rate_plat),
+	.ops = &clk_fixed_rate_ops,
+	.flags = DM_FLAG_PRE_RELOC,
+};
diff --git a/test/dm/of_platdata.c b/test/dm/of_platdata.c
index e9804cc27fa..93ad5727255 100644
--- a/test/dm/of_platdata.c
+++ b/test/dm/of_platdata.c
@@ -185,7 +185,7 @@ static int dm_test_of_plat_phandle(struct unit_test_state *uts)
 	plat = dev_get_plat(dev);
 
 	ut_assertok(device_get_by_driver_info_idx(plat->clocks[0].idx, &clk));
-	ut_asserteq_str("fixed_clock", clk->name);
+	ut_asserteq_str("sandbox_fixed_clock", clk->name);
 
 	ut_assertok(device_get_by_driver_info_idx(plat->clocks[1].idx, &clk));
 	ut_asserteq_str("sandbox_clk", clk->name);
-- 
2.31.0.rc2.261.g7f71774620-goog

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

* [PATCH v4 15/42] dm: core: Drop device_get_by_driver_info()
  2021-03-15  4:25 [PATCH v4 00/42] dm: Implement OF_PLATDATA_INST in driver model (part E) Simon Glass
                   ` (13 preceding siblings ...)
  2021-03-15  4:25 ` [PATCH v4 14/42] clk: sandbox: Create a special fixed-rate driver Simon Glass
@ 2021-03-15  4:25 ` Simon Glass
  2021-03-15  4:25 ` [PATCH v4 16/42] dm: core: Drop uclass_find_device_by_phandle() with of-platdata Simon Glass
                   ` (68 subsequent siblings)
  83 siblings, 0 replies; 85+ messages in thread
From: Simon Glass @ 2021-03-15  4:25 UTC (permalink / raw)
  To: u-boot

This function is now only used in a test. Drop it. Also drop
DM_DRVINFO_GET() which was the only purpose for having the function.

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

(no changes since v3)

Changes in v3:
- Drop DM_DRVINFO_GET() also

 drivers/core/device.c | 15 ---------------
 include/dm/device.h   | 15 ---------------
 include/dm/platdata.h | 15 ---------------
 test/dm/of_platdata.c |  7 ++-----
 4 files changed, 2 insertions(+), 50 deletions(-)

diff --git a/drivers/core/device.c b/drivers/core/device.c
index e915b3089de..2399f6f70ce 100644
--- a/drivers/core/device.c
+++ b/drivers/core/device.c
@@ -811,21 +811,6 @@ int device_get_global_by_ofnode(ofnode ofnode, struct udevice **devp)
 }
 
 #if CONFIG_IS_ENABLED(OF_PLATDATA)
-int device_get_by_driver_info(const struct driver_info *info,
-			      struct udevice **devp)
-{
-	struct driver_info *info_base =
-		ll_entry_start(struct driver_info, driver_info);
-	int idx = info - info_base;
-	struct driver_rt *drt = gd_dm_driver_rt() + idx;
-	struct udevice *dev;
-
-	dev = drt->dev;
-	*devp = NULL;
-
-	return device_get_device_tail(dev, dev ? 0 : -ENOENT, devp);
-}
-
 int device_get_by_driver_info_idx(uint idx, struct udevice **devp)
 {
 	struct driver_rt *drt = gd_dm_driver_rt() + idx;
diff --git a/include/dm/device.h b/include/dm/device.h
index 5b8f27d455b..ca796059e0c 100644
--- a/include/dm/device.h
+++ b/include/dm/device.h
@@ -666,21 +666,6 @@ int device_find_global_by_ofnode(ofnode node, struct udevice **devp);
  */
 int device_get_global_by_ofnode(ofnode node, struct udevice **devp);
 
-/**
- * device_get_by_driver_info() - Get a device based on driver_info
- *
- * Locates a device by its struct driver_info, by using its reference which
- * is updated during the bind process.
- *
- * The device is probed to activate it ready for use.
- *
- * @info: Struct driver_info
- * @devp: Returns pointer to device if found, otherwise this is set to NULL
- * @return 0 if OK, -ve on error
- */
-int device_get_by_driver_info(const struct driver_info *info,
-			      struct udevice **devp);
-
 /**
  * device_get_by_driver_info_idx() - Get a device based on driver_info index
  *
diff --git a/include/dm/platdata.h b/include/dm/platdata.h
index 3821a56f2ca..4efb1dfe12d 100644
--- a/include/dm/platdata.h
+++ b/include/dm/platdata.h
@@ -71,19 +71,4 @@ struct driver_rt {
 #define U_BOOT_DRVINFOS(__name)						\
 	ll_entry_declare_list(struct driver_info, __name, driver_info)
 
-/**
- * Get a pointer to a given device info given its name
- *
- * With the declaration U_BOOT_DRVINFO(name), DM_DRVINFO_GET(name) will return a
- * pointer to the struct driver_info created by that declaration.
- *
- * if OF_PLATDATA is enabled, from this it is possible to use the @dev member of
- * struct driver_info to find the device pointer itself.
- *
- * @__name: Driver name (C identifier, not a string. E.g. gpio7_at_ff7e0000)
- * @return struct driver_info * to the driver that created the device
- */
-#define DM_DRVINFO_GET(__name)						\
-	ll_entry_get(struct driver_info, __name, driver_info)
-
 #endif
diff --git a/test/dm/of_platdata.c b/test/dm/of_platdata.c
index 93ad5727255..d68c5912828 100644
--- a/test/dm/of_platdata.c
+++ b/test/dm/of_platdata.c
@@ -142,8 +142,6 @@ static int find_driver_info(struct unit_test_state *uts, struct udevice *parent,
 /* Check that every device is recorded in its driver_info struct */
 static int dm_test_of_plat_dev(struct unit_test_state *uts)
 {
-	const struct driver_info *info =
-		ll_entry_start(struct driver_info, driver_info);
 	const int n_ents = ll_entry_count(struct driver_info, driver_info);
 	bool found[n_ents];
 	uint i;
@@ -155,18 +153,17 @@ static int dm_test_of_plat_dev(struct unit_test_state *uts)
 	/* Make sure that the driver entries without devices have no ->dev */
 	for (i = 0; i < n_ents; i++) {
 		const struct driver_rt *drt = gd_dm_driver_rt() + i;
-		const struct driver_info *entry = info + i;
 		struct udevice *dev;
 
 		if (found[i]) {
 			/* Make sure we can find it */
 			ut_assertnonnull(drt->dev);
-			ut_assertok(device_get_by_driver_info(entry, &dev));
+			ut_assertok(device_get_by_driver_info_idx(i, &dev));
 			ut_asserteq_ptr(dev, drt->dev);
 		} else {
 			ut_assertnull(drt->dev);
 			ut_asserteq(-ENOENT,
-				    device_get_by_driver_info(entry, &dev));
+				    device_get_by_driver_info_idx(i, &dev));
 		}
 	}
 
-- 
2.31.0.rc2.261.g7f71774620-goog

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

* [PATCH v4 16/42] dm: core: Drop uclass_find_device_by_phandle() with of-platdata
  2021-03-15  4:25 [PATCH v4 00/42] dm: Implement OF_PLATDATA_INST in driver model (part E) Simon Glass
                   ` (14 preceding siblings ...)
  2021-03-15  4:25 ` [PATCH v4 15/42] dm: core: Drop device_get_by_driver_info() Simon Glass
@ 2021-03-15  4:25 ` Simon Glass
  2021-03-15  4:25 ` [PATCH v4 17/42] sandbox: i2c: Move platdata structs to header files Simon Glass
                   ` (67 subsequent siblings)
  83 siblings, 0 replies; 85+ messages in thread
From: Simon Glass @ 2021-03-15  4:25 UTC (permalink / raw)
  To: u-boot

At present this function is included in the build but with of-platdata it
only services to produce a confusing link error complaining about a call
to dev_read_u32_default().

Drop it so that any call to uclass_find_device_by_phandle() is flagged as
an error, making it easier to see what is going on.

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

(no changes since v1)

 drivers/core/uclass.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/core/uclass.c b/drivers/core/uclass.c
index f753a1f91e7..117d35ac49c 100644
--- a/drivers/core/uclass.c
+++ b/drivers/core/uclass.c
@@ -394,7 +394,7 @@ done:
 	return ret;
 }
 
-#if CONFIG_IS_ENABLED(OF_CONTROL)
+#if CONFIG_IS_ENABLED(OF_CONTROL) && !CONFIG_IS_ENABLED(OF_PLATDATA)
 int uclass_find_device_by_phandle(enum uclass_id id, struct udevice *parent,
 				  const char *name, struct udevice **devp)
 {
-- 
2.31.0.rc2.261.g7f71774620-goog

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

* [PATCH v4 17/42] sandbox: i2c: Move platdata structs to header files
  2021-03-15  4:25 [PATCH v4 00/42] dm: Implement OF_PLATDATA_INST in driver model (part E) Simon Glass
                   ` (15 preceding siblings ...)
  2021-03-15  4:25 ` [PATCH v4 16/42] dm: core: Drop uclass_find_device_by_phandle() with of-platdata Simon Glass
@ 2021-03-15  4:25 ` Simon Glass
  2021-03-15  4:25 ` [PATCH v4 18/42] dm: Rename device_get_by_driver_info_idx() Simon Glass
                   ` (66 subsequent siblings)
  83 siblings, 0 replies; 85+ messages in thread
From: Simon Glass @ 2021-03-15  4:25 UTC (permalink / raw)
  To: u-boot

At present the structs used by these drivers are declared in the C files
and so are not accessible to dtoc. Move them to header files, as required.

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

(no changes since v1)

 arch/sandbox/include/asm/i2c.h | 15 +++++++++++++++
 arch/sandbox/include/asm/rtc.h | 24 ++++++++++++++++++++++++
 drivers/i2c/i2c-emul-uclass.c  | 13 +------------
 drivers/rtc/i2c_rtc_emul.c     | 19 -------------------
 4 files changed, 40 insertions(+), 31 deletions(-)

diff --git a/arch/sandbox/include/asm/i2c.h b/arch/sandbox/include/asm/i2c.h
index b482be485ca..4fc190be4bd 100644
--- a/arch/sandbox/include/asm/i2c.h
+++ b/arch/sandbox/include/asm/i2c.h
@@ -11,4 +11,19 @@ struct sandbox_i2c_priv {
 	bool test_mode;
 };
 
+/**
+ * struct i2c_emul_uc_plat - information about the emulator for this device
+ *
+ * This is used by devices in UCLASS_I2C_EMUL to record information about the
+ * device being emulated. It is accessible with dev_get_uclass_plat()
+ *
+ * @dev: Device being emulated
+ * @idx: of-platdata index, set up by the device's bind() method if of-platdata
+ *	is in use
+ */
+struct i2c_emul_uc_plat {
+	struct udevice *dev;
+	int idx;
+};
+
 #endif /* __asn_i2c_h */
diff --git a/arch/sandbox/include/asm/rtc.h b/arch/sandbox/include/asm/rtc.h
index 5bb032f59f2..025cd6c67cf 100644
--- a/arch/sandbox/include/asm/rtc.h
+++ b/arch/sandbox/include/asm/rtc.h
@@ -9,6 +9,8 @@
 #ifndef __asm_rtc_h
 #define __asm_rtc_h
 
+#include <dt-structs.h>
+
 /* Register numbers in the sandbox RTC */
 enum {
 	REG_SEC		= 5,
@@ -29,4 +31,26 @@ enum {
 	REG_COUNT	= 0x80,
 };
 
+/**
+ * struct sandbox_i2c_rtc_plat_data - platform data for the RTC
+ *
+ * @base_time:		Base system time when RTC device was bound
+ * @offset:		RTC offset from current system time
+ * @use_system_time:	true to use system time, false to use @base_time
+ * @reg:		Register values
+ */
+struct sandbox_i2c_rtc_plat_data {
+#if CONFIG_IS_ENABLED(OF_PLATDATA)
+	struct dtd_sandbox_i2c_rtc_emul dtplat;
+#endif
+	long base_time;
+	long offset;
+	bool use_system_time;
+	u8 reg[REG_COUNT];
+};
+
+struct sandbox_i2c_rtc {
+	unsigned int offset_secs;
+};
+
 #endif
diff --git a/drivers/i2c/i2c-emul-uclass.c b/drivers/i2c/i2c-emul-uclass.c
index 75d79883380..9ef4651fa43 100644
--- a/drivers/i2c/i2c-emul-uclass.c
+++ b/drivers/i2c/i2c-emul-uclass.c
@@ -7,6 +7,7 @@
 #include <dm.h>
 #include <i2c.h>
 #include <log.h>
+#include <asm/i2c.h>
 #include <dm/device-internal.h>
 #include <dm/uclass-internal.h>
 
@@ -23,18 +24,6 @@
  * uclass so avoid having strange devices on the I2C bus.
  */
 
-/**
- * struct i2c_emul_uc_plat - information about the emulator for this device
- *
- * This is used by devices in UCLASS_I2C_EMUL to record information about the
- * device being emulated. It is accessible with dev_get_uclass_plat()
- *
- * @dev: Device being emulated
- */
-struct i2c_emul_uc_plat {
-	struct udevice *dev;
-};
-
 struct udevice *i2c_emul_get_device(struct udevice *emul)
 {
 	struct i2c_emul_uc_plat *uc_plat = dev_get_uclass_plat(emul);
diff --git a/drivers/rtc/i2c_rtc_emul.c b/drivers/rtc/i2c_rtc_emul.c
index fdc885c518b..ba418c25daf 100644
--- a/drivers/rtc/i2c_rtc_emul.c
+++ b/drivers/rtc/i2c_rtc_emul.c
@@ -28,25 +28,6 @@
 #define debug_buffer(x, ...)
 #endif
 
-/**
- * struct sandbox_i2c_rtc_plat_data - platform data for the RTC
- *
- * @base_time:		Base system time when RTC device was bound
- * @offset:		RTC offset from current system time
- * @use_system_time:	true to use system time, false to use @base_time
- * @reg:		Register values
- */
-struct sandbox_i2c_rtc_plat_data {
-	long base_time;
-	long offset;
-	bool use_system_time;
-	u8 reg[REG_COUNT];
-};
-
-struct sandbox_i2c_rtc {
-	unsigned int offset_secs;
-};
-
 long sandbox_i2c_rtc_set_offset(struct udevice *dev, bool use_system_time,
 				int offset)
 {
-- 
2.31.0.rc2.261.g7f71774620-goog

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

* [PATCH v4 18/42] dm: Rename device_get_by_driver_info_idx()
  2021-03-15  4:25 [PATCH v4 00/42] dm: Implement OF_PLATDATA_INST in driver model (part E) Simon Glass
                   ` (16 preceding siblings ...)
  2021-03-15  4:25 ` [PATCH v4 17/42] sandbox: i2c: Move platdata structs to header files Simon Glass
@ 2021-03-15  4:25 ` Simon Glass
  2021-03-15  4:25 ` [PATCH v4 19/42] sandbox_spl: Increase SPL malloc() size Simon Glass
                   ` (65 subsequent siblings)
  83 siblings, 0 replies; 85+ messages in thread
From: Simon Glass @ 2021-03-15  4:25 UTC (permalink / raw)
  To: u-boot

This function finds a device by its driver_info index. With
of-platdata-inst we do not use driver_info, but instead instantiate
udevice records at build-time.

However the semantics of using the function are the same in each case:
the caller provides an index and gets back a device.

So rename the function to device_get_by_ofplat_idx(), so that it can be
used for both situations. The caller does not really need to worry about
the details.

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

(no changes since v1)

 drivers/clk/clk-uclass.c    |  2 +-
 drivers/core/device.c       | 13 ++++++++++---
 drivers/misc/irq-uclass.c   |  2 +-
 drivers/mmc/fsl_esdhc_imx.c |  3 +--
 include/dm/device.h         | 16 +++++++++++-----
 test/dm/of_platdata.c       | 15 +++++++--------
 6 files changed, 31 insertions(+), 20 deletions(-)

diff --git a/drivers/clk/clk-uclass.c b/drivers/clk/clk-uclass.c
index b87288da7a2..4ab3c402ed8 100644
--- a/drivers/clk/clk-uclass.c
+++ b/drivers/clk/clk-uclass.c
@@ -39,7 +39,7 @@ int clk_get_by_driver_info(struct udevice *dev, struct phandle_1_arg *cells,
 {
 	int ret;
 
-	ret = device_get_by_driver_info_idx(cells->idx, &clk->dev);
+	ret = device_get_by_ofplat_idx(cells->idx, &clk->dev);
 	if (ret)
 		return ret;
 	clk->id = cells->arg[0];
diff --git a/drivers/core/device.c b/drivers/core/device.c
index 2399f6f70ce..1990b6f69f8 100644
--- a/drivers/core/device.c
+++ b/drivers/core/device.c
@@ -811,12 +811,19 @@ int device_get_global_by_ofnode(ofnode ofnode, struct udevice **devp)
 }
 
 #if CONFIG_IS_ENABLED(OF_PLATDATA)
-int device_get_by_driver_info_idx(uint idx, struct udevice **devp)
+int device_get_by_ofplat_idx(uint idx, struct udevice **devp)
 {
-	struct driver_rt *drt = gd_dm_driver_rt() + idx;
 	struct udevice *dev;
 
-	dev = drt->dev;
+	if (CONFIG_IS_ENABLED(OF_PLATDATA_INST)) {
+		struct udevice *base = ll_entry_start(struct udevice, udevice);
+
+		dev = base + idx;
+	} else {
+		struct driver_rt *drt = gd_dm_driver_rt() + idx;
+
+		dev = drt->dev;
+	}
 	*devp = NULL;
 
 	return device_get_device_tail(dev, dev ? 0 : -ENOENT, devp);
diff --git a/drivers/misc/irq-uclass.c b/drivers/misc/irq-uclass.c
index 24b27962a7d..3aa26f61d9e 100644
--- a/drivers/misc/irq-uclass.c
+++ b/drivers/misc/irq-uclass.c
@@ -69,7 +69,7 @@ int irq_get_by_driver_info(struct udevice *dev,
 {
 	int ret;
 
-	ret = device_get_by_driver_info_idx(cells->idx, &irq->dev);
+	ret = device_get_by_ofplat_idx(cells->idx, &irq->dev);
 	if (ret)
 		return ret;
 	irq->id = cells->arg[0];
diff --git a/drivers/mmc/fsl_esdhc_imx.c b/drivers/mmc/fsl_esdhc_imx.c
index e0e132698e3..2e8fef93cde 100644
--- a/drivers/mmc/fsl_esdhc_imx.c
+++ b/drivers/mmc/fsl_esdhc_imx.c
@@ -1524,8 +1524,7 @@ static int fsl_esdhc_probe(struct udevice *dev)
 	if (CONFIG_IS_ENABLED(DM_GPIO) && !priv->non_removable) {
 		struct udevice *gpiodev;
 
-		ret = device_get_by_driver_info_idx(dtplat->cd_gpios->idx,
-						    &gpiodev);
+		ret = device_get_by_ofplat_idx(dtplat->cd_gpios->idx, &gpiodev);
 		if (ret)
 			return ret;
 
diff --git a/include/dm/device.h b/include/dm/device.h
index ca796059e0c..9183356468f 100644
--- a/include/dm/device.h
+++ b/include/dm/device.h
@@ -667,18 +667,24 @@ int device_find_global_by_ofnode(ofnode node, struct udevice **devp);
 int device_get_global_by_ofnode(ofnode node, struct udevice **devp);
 
 /**
- * device_get_by_driver_info_idx() - Get a device based on driver_info index
+ * device_get_by_ofplat_idx() - Get a device based on of-platdata index
  *
- * Locates a device by its struct driver_info, by using its index number which
- * is written into the idx field of struct phandle_1_arg, etc.
+ * Locates a device by either its struct driver_info index, or its
+ * struct udevice index. The latter is used with OF_PLATDATA_INST, since we have
+ * a list of build-time instantiated struct udevice records, The former is used
+ * with !OF_PLATDATA_INST since in that case we have a list of
+ * struct driver_info records.
+ *
+ * The index number is written into the idx field of struct phandle_1_arg, etc.
+ * It is the position of this driver_info/udevice in its linker list.
  *
  * The device is probed to activate it ready for use.
  *
- * @idx: Index number of the driver_info structure (0=first)
+ * @idx: Index number of the driver_info/udevice structure (0=first)
  * @devp: Returns pointer to device if found, otherwise this is set to NULL
  * @return 0 if OK, -ve on error
  */
-int device_get_by_driver_info_idx(uint idx, struct udevice **devp);
+int device_get_by_ofplat_idx(uint idx, struct udevice **devp);
 
 /**
  * device_find_first_child() - Find the first child of a device
diff --git a/test/dm/of_platdata.c b/test/dm/of_platdata.c
index d68c5912828..e5f32a0f1c4 100644
--- a/test/dm/of_platdata.c
+++ b/test/dm/of_platdata.c
@@ -158,12 +158,11 @@ static int dm_test_of_plat_dev(struct unit_test_state *uts)
 		if (found[i]) {
 			/* Make sure we can find it */
 			ut_assertnonnull(drt->dev);
-			ut_assertok(device_get_by_driver_info_idx(i, &dev));
+			ut_assertok(device_get_by_ofplat_idx(i, &dev));
 			ut_asserteq_ptr(dev, drt->dev);
 		} else {
 			ut_assertnull(drt->dev);
-			ut_asserteq(-ENOENT,
-				    device_get_by_driver_info_idx(i, &dev));
+			ut_asserteq(-ENOENT, device_get_by_ofplat_idx(i, &dev));
 		}
 	}
 
@@ -181,22 +180,22 @@ static int dm_test_of_plat_phandle(struct unit_test_state *uts)
 	ut_asserteq_str("sandbox_clk_test", dev->name);
 	plat = dev_get_plat(dev);
 
-	ut_assertok(device_get_by_driver_info_idx(plat->clocks[0].idx, &clk));
+	ut_assertok(device_get_by_ofplat_idx(plat->clocks[0].idx, &clk));
 	ut_asserteq_str("sandbox_fixed_clock", clk->name);
 
-	ut_assertok(device_get_by_driver_info_idx(plat->clocks[1].idx, &clk));
+	ut_assertok(device_get_by_ofplat_idx(plat->clocks[1].idx, &clk));
 	ut_asserteq_str("sandbox_clk", clk->name);
 	ut_asserteq(1, plat->clocks[1].arg[0]);
 
-	ut_assertok(device_get_by_driver_info_idx(plat->clocks[2].idx, &clk));
+	ut_assertok(device_get_by_ofplat_idx(plat->clocks[2].idx, &clk));
 	ut_asserteq_str("sandbox_clk", clk->name);
 	ut_asserteq(0, plat->clocks[2].arg[0]);
 
-	ut_assertok(device_get_by_driver_info_idx(plat->clocks[3].idx, &clk));
+	ut_assertok(device_get_by_ofplat_idx(plat->clocks[3].idx, &clk));
 	ut_asserteq_str("sandbox_clk", clk->name);
 	ut_asserteq(3, plat->clocks[3].arg[0]);
 
-	ut_assertok(device_get_by_driver_info_idx(plat->clocks[4].idx, &clk));
+	ut_assertok(device_get_by_ofplat_idx(plat->clocks[4].idx, &clk));
 	ut_asserteq_str("sandbox_clk", clk->name);
 	ut_asserteq(2, plat->clocks[4].arg[0]);
 
-- 
2.31.0.rc2.261.g7f71774620-goog

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

* [PATCH v4 19/42] sandbox_spl: Increase SPL malloc() size
  2021-03-15  4:25 [PATCH v4 00/42] dm: Implement OF_PLATDATA_INST in driver model (part E) Simon Glass
                   ` (17 preceding siblings ...)
  2021-03-15  4:25 ` [PATCH v4 18/42] dm: Rename device_get_by_driver_info_idx() Simon Glass
@ 2021-03-15  4:25 ` Simon Glass
  2021-03-15  4:25 ` [PATCH v4 20/42] sandbox: i2c: Support i2c emulation with of-platdata Simon Glass
                   ` (64 subsequent siblings)
  83 siblings, 0 replies; 85+ messages in thread
From: Simon Glass @ 2021-03-15  4:25 UTC (permalink / raw)
  To: u-boot

The test framework reinits driver model tests before running each test.
Since malloc_simple does not support free(), this eventually runs out of
memory.

Fix it for now by increasing the space to 32KB.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
---

(no changes since v1)

 configs/sandbox_spl_defconfig | 1 +
 1 file changed, 1 insertion(+)

diff --git a/configs/sandbox_spl_defconfig b/configs/sandbox_spl_defconfig
index 2696d0b6cdd..4c020528fda 100644
--- a/configs/sandbox_spl_defconfig
+++ b/configs/sandbox_spl_defconfig
@@ -7,6 +7,7 @@ CONFIG_SYS_MEMTEST_END=0x00101000
 CONFIG_ENV_SIZE=0x2000
 CONFIG_SPL_SERIAL_SUPPORT=y
 CONFIG_SPL_DRIVERS_MISC_SUPPORT=y
+CONFIG_SPL_SYS_MALLOC_F_LEN=0x8000
 CONFIG_SPL=y
 CONFIG_BOOTSTAGE_STASH_ADDR=0x0
 CONFIG_DEFAULT_DEVICE_TREE="sandbox"
-- 
2.31.0.rc2.261.g7f71774620-goog

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

* [PATCH v4 20/42] sandbox: i2c: Support i2c emulation with of-platdata
  2021-03-15  4:25 [PATCH v4 00/42] dm: Implement OF_PLATDATA_INST in driver model (part E) Simon Glass
                   ` (18 preceding siblings ...)
  2021-03-15  4:25 ` [PATCH v4 19/42] sandbox_spl: Increase SPL malloc() size Simon Glass
@ 2021-03-15  4:25 ` Simon Glass
  2021-03-15  4:25 ` [PATCH v4 21/42] Revert "sandbox: Disable I2C emulators in SPL" Simon Glass
                   ` (63 subsequent siblings)
  83 siblings, 0 replies; 85+ messages in thread
From: Simon Glass @ 2021-03-15  4:25 UTC (permalink / raw)
  To: u-boot

At present the i2c emulators require access to the devicetree, which is
not possible (by design) with of-platdata.

Add a way for drivers to record the of-platdata index of their emulator,
so that we can still find the emulator.

This allows i2c emulation to work with of-platdata.

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

(no changes since v1)

 drivers/i2c/i2c-emul-uclass.c | 17 +++++++++++++++--
 drivers/rtc/sandbox_rtc.c     | 13 +++++++++++++
 include/i2c.h                 | 15 +++++++++++++++
 3 files changed, 43 insertions(+), 2 deletions(-)

diff --git a/drivers/i2c/i2c-emul-uclass.c b/drivers/i2c/i2c-emul-uclass.c
index 9ef4651fa43..7917b63c55b 100644
--- a/drivers/i2c/i2c-emul-uclass.c
+++ b/drivers/i2c/i2c-emul-uclass.c
@@ -31,14 +31,27 @@ struct udevice *i2c_emul_get_device(struct udevice *emul)
 	return uc_plat->dev;
 }
 
+void i2c_emul_set_idx(struct udevice *dev, int emul_idx)
+{
+	struct dm_i2c_chip *plat = dev_get_parent_plat(dev);
+
+	plat->emul_idx = emul_idx;
+}
+
 int i2c_emul_find(struct udevice *dev, struct udevice **emulp)
 {
 	struct i2c_emul_uc_plat *uc_plat;
 	struct udevice *emul;
 	int ret;
 
-	ret = uclass_find_device_by_phandle(UCLASS_I2C_EMUL, dev,
-					    "sandbox,emul", &emul);
+	if (!CONFIG_IS_ENABLED(OF_PLATDATA)) {
+		ret = uclass_find_device_by_phandle(UCLASS_I2C_EMUL, dev,
+						    "sandbox,emul", &emul);
+	} else {
+		struct dm_i2c_chip *plat = dev_get_parent_plat(dev);
+
+		ret = device_get_by_ofplat_idx(plat->emul_idx, &emul);
+	}
 	if (ret) {
 		log_err("No emulators for device '%s'\n", dev->name);
 		return ret;
diff --git a/drivers/rtc/sandbox_rtc.c b/drivers/rtc/sandbox_rtc.c
index d0864b1df97..657e5c7be2c 100644
--- a/drivers/rtc/sandbox_rtc.c
+++ b/drivers/rtc/sandbox_rtc.c
@@ -79,6 +79,18 @@ struct acpi_ops sandbox_rtc_acpi_ops = {
 };
 #endif
 
+static int sandbox_rtc_bind(struct udevice *dev)
+{
+#if CONFIG_IS_ENABLED(PLATDATA)
+	struct sandbox_i2c_rtc_plat_data *plat = dev_get_plat(dev);
+
+	/* Set up the emul_idx for i2c_emul_find() */
+	i2c_emul_set_idx(dev, plat->dtplat.sandbox_emul->idx);
+#endif
+
+	return 0;
+}
+
 static const struct rtc_ops sandbox_rtc_ops = {
 	.get = sandbox_rtc_get,
 	.set = sandbox_rtc_set,
@@ -97,5 +109,6 @@ U_BOOT_DRIVER(sandbox_rtc) = {
 	.id	= UCLASS_RTC,
 	.of_match = sandbox_rtc_ids,
 	.ops	= &sandbox_rtc_ops,
+	.bind	= sandbox_rtc_bind,
 	ACPI_OPS_PTR(&sandbox_rtc_acpi_ops)
 };
diff --git a/include/i2c.h b/include/i2c.h
index 7ae0c42706e..c0fe94c1f33 100644
--- a/include/i2c.h
+++ b/include/i2c.h
@@ -93,6 +93,8 @@ struct udevice;
  *			   datasheet explains it's usage of this addressing
  *			   mode.
  * @emul: Emulator for this chip address (only used for emulation)
+ * @emul_idx: Emulator index, used for of-platdata and set by each i2c chip's
+ *	bind() method. This allows i2c_emul_find() to work with of-platdata.
  */
 struct dm_i2c_chip {
 	uint chip_addr;
@@ -102,6 +104,7 @@ struct dm_i2c_chip {
 #ifdef CONFIG_SANDBOX
 	struct udevice *emul;
 	bool test_mode;
+	int emul_idx;
 #endif
 };
 
@@ -554,6 +557,18 @@ void i2c_dump_msgs(struct i2c_msg *msg, int nmsgs);
  */
 int i2c_emul_find(struct udevice *dev, struct udevice **emulp);
 
+/**
+ * i2c_emul_set_idx() - Set the emulator index for an i2c sandbox device
+ *
+ * With of-platdata we cannot find the emulator using the device tree, so rely
+ * on the bind() method of each i2c driver calling this function to tell us
+ * the of-platdata idx of the emulator
+ *
+ * @dev: i2c device to set the emulator for
+ * @emul_idx: of-platdata index for that emulator
+ */
+void i2c_emul_set_idx(struct udevice *dev, int emul_idx);
+
 /**
  * i2c_emul_get_device() - Find the device being emulated
  *
-- 
2.31.0.rc2.261.g7f71774620-goog

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

* [PATCH v4 21/42] Revert "sandbox: Disable I2C emulators in SPL"
  2021-03-15  4:25 [PATCH v4 00/42] dm: Implement OF_PLATDATA_INST in driver model (part E) Simon Glass
                   ` (19 preceding siblings ...)
  2021-03-15  4:25 ` [PATCH v4 20/42] sandbox: i2c: Support i2c emulation with of-platdata Simon Glass
@ 2021-03-15  4:25 ` Simon Glass
  2021-03-15  4:25 ` [PATCH v4 22/42] sandbox: Create a new sandbox_noinst build Simon Glass
                   ` (62 subsequent siblings)
  83 siblings, 0 replies; 85+ messages in thread
From: Simon Glass @ 2021-03-15  4:25 UTC (permalink / raw)
  To: u-boot

With recent changes this can be supported again. Add it back.

This reverts commit d85f2c4f2970d0ec2f5f075de734afd11200d153.

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

(no changes since v1)

 arch/sandbox/dts/sandbox.dtsi | 10 +++-------
 configs/sandbox_spl_defconfig |  1 +
 drivers/i2c/Makefile          |  2 --
 test/dm/of_platdata.c         |  8 ++++----
 4 files changed, 8 insertions(+), 13 deletions(-)

diff --git a/arch/sandbox/dts/sandbox.dtsi b/arch/sandbox/dts/sandbox.dtsi
index 5bf84451c99..69d7d3019ee 100644
--- a/arch/sandbox/dts/sandbox.dtsi
+++ b/arch/sandbox/dts/sandbox.dtsi
@@ -264,14 +264,10 @@
 		stringarray = "pre-proper";
 	};
 
-	test-bus {
-		compatible = "simple-bus";
+	spl-test7 {
 		u-boot,dm-spl;
-		spl-test7 {
-			u-boot,dm-spl;
-			compatible = "sandbox,spl-test";
-			stringarray = "spl";
-		};
+		compatible = "sandbox,spl-test";
+		stringarray = "spl";
 	};
 
 	square {
diff --git a/configs/sandbox_spl_defconfig b/configs/sandbox_spl_defconfig
index 4c020528fda..1ac7e025b60 100644
--- a/configs/sandbox_spl_defconfig
+++ b/configs/sandbox_spl_defconfig
@@ -103,6 +103,7 @@ CONFIG_SYSCON=y
 CONFIG_SPL_SYSCON=y
 CONFIG_DEVRES=y
 CONFIG_DEBUG_DEVRES=y
+# CONFIG_SPL_SIMPLE_BUS is not set
 CONFIG_ADC=y
 CONFIG_ADC_SANDBOX=y
 CONFIG_AXI=y
diff --git a/drivers/i2c/Makefile b/drivers/i2c/Makefile
index acd27ac29d2..8c9f1fcd8b9 100644
--- a/drivers/i2c/Makefile
+++ b/drivers/i2c/Makefile
@@ -39,9 +39,7 @@ obj-$(CONFIG_SYS_I2C_RCAR_I2C) += rcar_i2c.o
 obj-$(CONFIG_SYS_I2C_RCAR_IIC) += rcar_iic.o
 obj-$(CONFIG_SYS_I2C_ROCKCHIP) += rk_i2c.o
 obj-$(CONFIG_SYS_I2C_S3C24X0) += s3c24x0_i2c.o exynos_hs_i2c.o
-ifndef CONFIG_SPL_BUILD
 obj-$(CONFIG_SYS_I2C_SANDBOX) += sandbox_i2c.o i2c-emul-uclass.o
-endif
 obj-$(CONFIG_SYS_I2C_SH) += sh_i2c.o
 obj-$(CONFIG_SYS_I2C_SOFT) += soft_i2c.o
 obj-$(CONFIG_SYS_I2C_STM32F7) += stm32f7_i2c.o
diff --git a/test/dm/of_platdata.c b/test/dm/of_platdata.c
index e5f32a0f1c4..7cbb1161ed2 100644
--- a/test/dm/of_platdata.c
+++ b/test/dm/of_platdata.c
@@ -207,11 +207,11 @@ DM_TEST(dm_test_of_plat_phandle, UT_TESTF_SCAN_PDATA);
 /* Test that device parents are correctly set up */
 static int dm_test_of_plat_parent(struct unit_test_state *uts)
 {
-	struct udevice *dev, *bus;
+	struct udevice *rtc, *i2c;
 
-	ut_assertok(uclass_first_device_err(UCLASS_SIMPLE_BUS, &bus));
-	ut_assertok(device_first_child_err(bus, &dev));
-	ut_asserteq_ptr(bus, dev_get_parent(dev));
+	ut_assertok(uclass_first_device_err(UCLASS_RTC, &rtc));
+	ut_assertok(uclass_first_device_err(UCLASS_I2C, &i2c));
+	ut_asserteq_ptr(i2c, dev_get_parent(rtc));
 
 	return 0;
 }
-- 
2.31.0.rc2.261.g7f71774620-goog

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

* [PATCH v4 22/42] sandbox: Create a new sandbox_noinst build
  2021-03-15  4:25 [PATCH v4 00/42] dm: Implement OF_PLATDATA_INST in driver model (part E) Simon Glass
                   ` (20 preceding siblings ...)
  2021-03-15  4:25 ` [PATCH v4 21/42] Revert "sandbox: Disable I2C emulators in SPL" Simon Glass
@ 2021-03-15  4:25 ` Simon Glass
  2021-03-15  4:25 ` [PATCH v4 23/42] test: Run sandbox_spl tests on sandbox_noinst Simon Glass
                   ` (61 subsequent siblings)
  83 siblings, 0 replies; 85+ messages in thread
From: Simon Glass @ 2021-03-15  4:25 UTC (permalink / raw)
  To: u-boot

Move sandbox_spl over to use OF_PLATDATA_INST. Create a new board to
test the case when this is not enabled, since we will be keeping that
code around for several months and want to avoid regressions.

Skip the dm_test_of_plat_dev() test since driver info is not available
for OF_PLATDATA_INST.

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

(no changes since v1)

 board/sandbox/MAINTAINERS        |   7 +
 configs/sandbox_noinst_defconfig | 231 +++++++++++++++++++++++++++++++
 configs/sandbox_spl_defconfig    |   1 +
 test/dm/of_platdata.c            |   4 +
 4 files changed, 243 insertions(+)
 create mode 100644 configs/sandbox_noinst_defconfig

diff --git a/board/sandbox/MAINTAINERS b/board/sandbox/MAINTAINERS
index 433be48a6f1..d32561cd1d0 100644
--- a/board/sandbox/MAINTAINERS
+++ b/board/sandbox/MAINTAINERS
@@ -20,6 +20,13 @@ F:	board/sandbox/
 F:	include/configs/sandbox_spl.h
 F:	configs/sandbox_spl_defconfig
 
+SANDBOX NOINST BOARD
+M:	Simon Glass <sjg@chromium.org>
+S:	Maintained
+F:	board/sandbox/
+F:	include/configs/sandbox_spl.h
+F:	configs/sandbox_noinst_defconfig
+
 SANDBOX FLAT TREE BOARD
 M:	Simon Glass <sjg@chromium.org>
 S:	Maintained
diff --git a/configs/sandbox_noinst_defconfig b/configs/sandbox_noinst_defconfig
new file mode 100644
index 00000000000..1ac7e025b60
--- /dev/null
+++ b/configs/sandbox_noinst_defconfig
@@ -0,0 +1,231 @@
+CONFIG_SYS_TEXT_BASE=0x200000
+CONFIG_SPL_LIBCOMMON_SUPPORT=y
+CONFIG_SPL_LIBGENERIC_SUPPORT=y
+CONFIG_NR_DRAM_BANKS=1
+CONFIG_SYS_MEMTEST_START=0x00100000
+CONFIG_SYS_MEMTEST_END=0x00101000
+CONFIG_ENV_SIZE=0x2000
+CONFIG_SPL_SERIAL_SUPPORT=y
+CONFIG_SPL_DRIVERS_MISC_SUPPORT=y
+CONFIG_SPL_SYS_MALLOC_F_LEN=0x8000
+CONFIG_SPL=y
+CONFIG_BOOTSTAGE_STASH_ADDR=0x0
+CONFIG_DEFAULT_DEVICE_TREE="sandbox"
+CONFIG_SANDBOX_SPL=y
+CONFIG_DEBUG_UART=y
+CONFIG_DISTRO_DEFAULTS=y
+CONFIG_FIT=y
+CONFIG_FIT_SIGNATURE=y
+CONFIG_FIT_VERBOSE=y
+CONFIG_SPL_LOAD_FIT=y
+# CONFIG_USE_SPL_FIT_GENERATOR is not set
+CONFIG_BOOTSTAGE=y
+CONFIG_BOOTSTAGE_REPORT=y
+CONFIG_BOOTSTAGE_FDT=y
+CONFIG_BOOTSTAGE_STASH=y
+CONFIG_BOOTSTAGE_STASH_SIZE=0x4096
+CONFIG_CONSOLE_RECORD=y
+CONFIG_CONSOLE_RECORD_OUT_SIZE=0x1000
+CONFIG_DISPLAY_BOARDINFO_LATE=y
+CONFIG_HANDOFF=y
+CONFIG_SPL_BOARD_INIT=y
+CONFIG_SPL_ENV_SUPPORT=y
+CONFIG_SPL_I2C_SUPPORT=y
+CONFIG_SPL_RTC_SUPPORT=y
+CONFIG_CMD_CPU=y
+CONFIG_CMD_LICENSE=y
+CONFIG_CMD_BOOTZ=y
+CONFIG_CMD_BOOTEFI_HELLO=y
+# CONFIG_CMD_ELF is not set
+CONFIG_CMD_ASKENV=y
+CONFIG_CMD_GREPENV=y
+CONFIG_CMD_ERASEENV=y
+CONFIG_CMD_ENV_CALLBACK=y
+CONFIG_CMD_ENV_FLAGS=y
+CONFIG_CMD_NVEDIT_INFO=y
+CONFIG_CMD_NVEDIT_LOAD=y
+CONFIG_CMD_NVEDIT_SELECT=y
+CONFIG_LOOPW=y
+CONFIG_CMD_MD5SUM=y
+CONFIG_CMD_MEMINFO=y
+CONFIG_CMD_MX_CYCLIC=y
+CONFIG_CMD_MEMTEST=y
+CONFIG_CMD_DEMO=y
+CONFIG_CMD_GPIO=y
+CONFIG_CMD_GPT=y
+CONFIG_CMD_IDE=y
+CONFIG_CMD_I2C=y
+CONFIG_CMD_OSD=y
+CONFIG_CMD_PCI=y
+CONFIG_CMD_REMOTEPROC=y
+CONFIG_CMD_SPI=y
+CONFIG_CMD_USB=y
+CONFIG_BOOTP_DNS2=y
+CONFIG_CMD_TFTPPUT=y
+CONFIG_CMD_TFTPSRV=y
+CONFIG_CMD_RARP=y
+CONFIG_CMD_CDP=y
+CONFIG_CMD_SNTP=y
+CONFIG_CMD_DNS=y
+CONFIG_CMD_LINK_LOCAL=y
+CONFIG_CMD_BMP=y
+CONFIG_CMD_EFIDEBUG=y
+CONFIG_CMD_TIME=y
+CONFIG_CMD_TIMER=y
+CONFIG_CMD_SOUND=y
+CONFIG_CMD_QFW=y
+CONFIG_CMD_BOOTSTAGE=y
+CONFIG_CMD_PMIC=y
+CONFIG_CMD_REGULATOR=y
+CONFIG_CMD_TPM=y
+CONFIG_CMD_TPM_TEST=y
+CONFIG_CMD_CBFS=y
+CONFIG_CMD_CRAMFS=y
+CONFIG_CMD_EXT4_WRITE=y
+CONFIG_MAC_PARTITION=y
+CONFIG_AMIGA_PARTITION=y
+CONFIG_OF_CONTROL=y
+CONFIG_SPL_OF_CONTROL=y
+CONFIG_OF_HOSTFILE=y
+CONFIG_SPL_OF_PLATDATA=y
+CONFIG_ENV_IS_NOWHERE=y
+CONFIG_ENV_IS_IN_EXT4=y
+CONFIG_ENV_EXT4_INTERFACE="host"
+CONFIG_ENV_EXT4_DEVICE_AND_PART="0:0"
+CONFIG_BOOTP_SEND_HOSTNAME=y
+CONFIG_NETCONSOLE=y
+CONFIG_IP_DEFRAG=y
+CONFIG_SPL_DM=y
+CONFIG_DM_DMA=y
+CONFIG_REGMAP=y
+CONFIG_SPL_REGMAP=y
+CONFIG_SYSCON=y
+CONFIG_SPL_SYSCON=y
+CONFIG_DEVRES=y
+CONFIG_DEBUG_DEVRES=y
+# CONFIG_SPL_SIMPLE_BUS is not set
+CONFIG_ADC=y
+CONFIG_ADC_SANDBOX=y
+CONFIG_AXI=y
+CONFIG_AXI_SANDBOX=y
+CONFIG_CLK=y
+CONFIG_SPL_CLK=y
+CONFIG_CPU=y
+CONFIG_DM_DEMO=y
+CONFIG_DM_DEMO_SIMPLE=y
+CONFIG_DM_DEMO_SHAPE=y
+CONFIG_SPL_FIRMWARE=y
+CONFIG_GPIO_HOG=y
+CONFIG_PM8916_GPIO=y
+CONFIG_SANDBOX_GPIO=y
+CONFIG_I2C_CROS_EC_TUNNEL=y
+CONFIG_I2C_CROS_EC_LDO=y
+CONFIG_DM_I2C_GPIO=y
+CONFIG_SYS_I2C_SANDBOX=y
+CONFIG_I2C_MUX=y
+CONFIG_I2C_ARB_GPIO_CHALLENGE=y
+CONFIG_CROS_EC_KEYB=y
+CONFIG_I8042_KEYB=y
+CONFIG_LED=y
+CONFIG_LED_BLINK=y
+CONFIG_LED_GPIO=y
+CONFIG_DM_MAILBOX=y
+CONFIG_SANDBOX_MBOX=y
+CONFIG_MISC=y
+CONFIG_CROS_EC=y
+CONFIG_CROS_EC_I2C=y
+CONFIG_CROS_EC_LPC=y
+CONFIG_CROS_EC_SANDBOX=y
+CONFIG_CROS_EC_SPI=y
+CONFIG_IRQ=y
+CONFIG_P2SB=y
+CONFIG_PWRSEQ=y
+CONFIG_SPL_PWRSEQ=y
+CONFIG_MMC_SANDBOX=y
+CONFIG_SPI_FLASH_SANDBOX=y
+CONFIG_SPI_FLASH_ATMEL=y
+CONFIG_SPI_FLASH_EON=y
+CONFIG_SPI_FLASH_GIGADEVICE=y
+CONFIG_SPI_FLASH_MACRONIX=y
+CONFIG_SPI_FLASH_SPANSION=y
+CONFIG_SPI_FLASH_STMICRO=y
+CONFIG_SPI_FLASH_SST=y
+CONFIG_SPI_FLASH_WINBOND=y
+CONFIG_DM_ETH=y
+CONFIG_NVME=y
+CONFIG_PCI=y
+CONFIG_DM_PCI=y
+CONFIG_DM_PCI_COMPAT=y
+CONFIG_PCI_SANDBOX=y
+CONFIG_PHY=y
+CONFIG_PHY_SANDBOX=y
+CONFIG_PINCTRL=y
+CONFIG_PINCONF=y
+CONFIG_PINCTRL_SANDBOX=y
+CONFIG_DM_PMIC=y
+CONFIG_PMIC_ACT8846=y
+CONFIG_DM_PMIC_PFUZE100=y
+CONFIG_DM_PMIC_MAX77686=y
+CONFIG_DM_PMIC_MC34708=y
+CONFIG_PMIC_PM8916=y
+CONFIG_PMIC_RK8XX=y
+CONFIG_PMIC_S2MPS11=y
+CONFIG_DM_PMIC_SANDBOX=y
+CONFIG_PMIC_S5M8767=y
+CONFIG_PMIC_TPS65090=y
+CONFIG_DM_REGULATOR=y
+CONFIG_REGULATOR_ACT8846=y
+CONFIG_DM_REGULATOR_PFUZE100=y
+CONFIG_DM_REGULATOR_MAX77686=y
+CONFIG_DM_REGULATOR_FIXED=y
+CONFIG_REGULATOR_RK8XX=y
+CONFIG_REGULATOR_S5M8767=y
+CONFIG_DM_REGULATOR_SANDBOX=y
+CONFIG_REGULATOR_TPS65090=y
+CONFIG_DM_PWM=y
+CONFIG_PWM_SANDBOX=y
+CONFIG_RAM=y
+CONFIG_REMOTEPROC_SANDBOX=y
+CONFIG_DM_RESET=y
+CONFIG_SANDBOX_RESET=y
+CONFIG_DM_RTC=y
+CONFIG_SPL_DM_RTC=y
+CONFIG_SANDBOX_SERIAL=y
+CONFIG_SOUND=y
+CONFIG_SOUND_SANDBOX=y
+CONFIG_SOC_DEVICE=y
+CONFIG_SANDBOX_SPI=y
+CONFIG_SPMI=y
+CONFIG_SPMI_SANDBOX=y
+CONFIG_SYSINFO=y
+CONFIG_SYSINFO_SANDBOX=y
+CONFIG_SYSRESET=y
+CONFIG_SPL_SYSRESET=y
+CONFIG_TIMER=y
+CONFIG_TIMER_EARLY=y
+CONFIG_SANDBOX_TIMER=y
+CONFIG_USB=y
+CONFIG_DM_USB=y
+CONFIG_USB_EMUL=y
+CONFIG_USB_KEYBOARD=y
+CONFIG_DM_VIDEO=y
+CONFIG_CONSOLE_ROTATION=y
+CONFIG_CONSOLE_TRUETYPE=y
+CONFIG_CONSOLE_TRUETYPE_CANTORAONE=y
+CONFIG_VIDEO_SANDBOX_SDL=y
+CONFIG_OSD=y
+CONFIG_SANDBOX_OSD=y
+CONFIG_SPLASH_SCREEN_ALIGN=y
+CONFIG_VIDEO_BMP_RLE8=y
+CONFIG_FS_CBFS=y
+CONFIG_FS_CRAMFS=y
+# CONFIG_SPL_USE_TINY_PRINTF is not set
+CONFIG_CMD_DHRYSTONE=y
+CONFIG_RSA_VERIFY_WITH_PKEY=y
+CONFIG_TPM=y
+CONFIG_LZ4=y
+CONFIG_ERRNO_STR=y
+CONFIG_UNIT_TEST=y
+CONFIG_SPL_UNIT_TEST=y
+CONFIG_UT_TIME=y
+CONFIG_UT_DM=y
diff --git a/configs/sandbox_spl_defconfig b/configs/sandbox_spl_defconfig
index 1ac7e025b60..ac71cab5f1e 100644
--- a/configs/sandbox_spl_defconfig
+++ b/configs/sandbox_spl_defconfig
@@ -88,6 +88,7 @@ CONFIG_OF_CONTROL=y
 CONFIG_SPL_OF_CONTROL=y
 CONFIG_OF_HOSTFILE=y
 CONFIG_SPL_OF_PLATDATA=y
+CONFIG_SPL_OF_PLATDATA_INST=y
 CONFIG_ENV_IS_NOWHERE=y
 CONFIG_ENV_IS_IN_EXT4=y
 CONFIG_ENV_EXT4_INTERFACE="host"
diff --git a/test/dm/of_platdata.c b/test/dm/of_platdata.c
index 7cbb1161ed2..f2b45b9a868 100644
--- a/test/dm/of_platdata.c
+++ b/test/dm/of_platdata.c
@@ -146,6 +146,10 @@ static int dm_test_of_plat_dev(struct unit_test_state *uts)
 	bool found[n_ents];
 	uint i;
 
+	/* Skip this test if there is no platform data */
+	if (CONFIG_IS_ENABLED(OF_PLATDATA_INST))
+		return 0;
+
 	/* Record the indexes that are found */
 	memset(found, '\0', sizeof(found));
 	ut_assertok(find_driver_info(uts, gd->dm_root, found));
-- 
2.31.0.rc2.261.g7f71774620-goog

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

* [PATCH v4 23/42] test: Run sandbox_spl tests on sandbox_noinst
  2021-03-15  4:25 [PATCH v4 00/42] dm: Implement OF_PLATDATA_INST in driver model (part E) Simon Glass
                   ` (21 preceding siblings ...)
  2021-03-15  4:25 ` [PATCH v4 22/42] sandbox: Create a new sandbox_noinst build Simon Glass
@ 2021-03-15  4:25 ` Simon Glass
  2021-03-15  4:25 ` [PATCH v4 24/42] azure/gitlab: Add tests for sandbox_noinst Simon Glass
                   ` (60 subsequent siblings)
  83 siblings, 0 replies; 85+ messages in thread
From: Simon Glass @ 2021-03-15  4:25 UTC (permalink / raw)
  To: u-boot

Run the tests on this build too, to prevent regressions.

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

(no changes since v1)

 test/run | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/test/run b/test/run
index 735628e7e37..869406cd8d2 100755
--- a/test/run
+++ b/test/run
@@ -30,6 +30,10 @@ fi
 run_test "sandbox_spl" ./test/py/test.py --bd sandbox_spl --build \
 		-k 'test_ofplatdata or test_handoff or test_spl'
 
+# Run the sane tests with sandbox_noinst (i.e. without OF_PLATDATA_INST)
+run_test "sandbox_spl" ./test/py/test.py --bd sandbox_noinst --build \
+		-k 'test_ofplatdata or test_handoff or test_spl'
+
 if [ -z "$tools_only" ]; then
 	# Run tests for the flat-device-tree version of sandbox. This is a special
 	# build which does not enable CONFIG_OF_LIVE for the live device tree, so we can
-- 
2.31.0.rc2.261.g7f71774620-goog

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

* [PATCH v4 24/42] azure/gitlab: Add tests for sandbox_noinst
  2021-03-15  4:25 [PATCH v4 00/42] dm: Implement OF_PLATDATA_INST in driver model (part E) Simon Glass
                   ` (22 preceding siblings ...)
  2021-03-15  4:25 ` [PATCH v4 23/42] test: Run sandbox_spl tests on sandbox_noinst Simon Glass
@ 2021-03-15  4:25 ` Simon Glass
  2021-03-15  4:25 ` [PATCH v4 25/42] dm: core: Add an option to support SPL in read-only memory Simon Glass
                   ` (59 subsequent siblings)
  83 siblings, 0 replies; 85+ messages in thread
From: Simon Glass @ 2021-03-15  4:25 UTC (permalink / raw)
  To: u-boot

Add this new board to the test plans. Travis-CI is left out, since it is
being removed soon due to lack of capacity.

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

(no changes since v1)

 .azure-pipelines.yml |  3 +++
 .gitlab-ci.yml       | 10 +++++++++-
 2 files changed, 12 insertions(+), 1 deletion(-)

diff --git a/.azure-pipelines.yml b/.azure-pipelines.yml
index 013b170bf25..e6434b3f4e3 100644
--- a/.azure-pipelines.yml
+++ b/.azure-pipelines.yml
@@ -187,6 +187,9 @@ jobs:
         sandbox_spl:
           TEST_PY_BD: "sandbox_spl"
           TEST_PY_TEST_SPEC: "test_ofplatdata or test_handoff or test_spl"
+        sandbox_noinst:
+          TEST_PY_BD: "sandbox_noinst"
+          TEST_PY_TEST_SPEC: "test_ofplatdata or test_handoff or test_spl"
         sandbox_flattree:
           TEST_PY_BD: "sandbox_flattree"
         evb_ast2500:
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index cd38e65a59f..22cec5fce68 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -168,7 +168,8 @@ Run binman, buildman, dtoc, Kconfig and patman testsuites:
       export UBOOT_TRAVIS_BUILD_DIR=/tmp/sandbox_spl;
       export PYTHONPATH="${UBOOT_TRAVIS_BUILD_DIR}/scripts/dtc/pylibfdt";
       export PATH="${UBOOT_TRAVIS_BUILD_DIR}/scripts/dtc:${PATH}";
-      ./tools/buildman/buildman -o ${UBOOT_TRAVIS_BUILD_DIR} -w sandbox_spl;
+      ./tools/buildman/buildman -o ${UBOOT_TRAVIS_BUILD_DIR} -w
+        --board sandbox_spl;
       ./tools/binman/binman --toolpath ${UBOOT_TRAVIS_BUILD_DIR}/tools test;
       ./tools/buildman/buildman -t;
       ./tools/dtoc/dtoc -t;
@@ -204,6 +205,13 @@ sandbox_spl test.py:
     TEST_PY_TEST_SPEC: "test_ofplatdata or test_handoff or test_spl"
   <<: *buildman_and_testpy_dfn
 
+sandbox_noinst_test.py:
+  tags: [ 'all' ]
+  variables:
+    TEST_PY_BD: "sandbox_noinst"
+    TEST_PY_TEST_SPEC: "test_ofplatdata or test_handoff or test_spl"
+  <<: *buildman_and_testpy_dfn
+
 evb-ast2500 test.py:
   tags: [ 'all' ]
   variables:
-- 
2.31.0.rc2.261.g7f71774620-goog

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

* [PATCH v4 25/42] dm: core: Add an option to support SPL in read-only memory
  2021-03-15  4:25 [PATCH v4 00/42] dm: Implement OF_PLATDATA_INST in driver model (part E) Simon Glass
                   ` (23 preceding siblings ...)
  2021-03-15  4:25 ` [PATCH v4 24/42] azure/gitlab: Add tests for sandbox_noinst Simon Glass
@ 2021-03-15  4:25 ` Simon Glass
  2021-03-15  4:25 ` [PATCH v4 26/42] dm: core: Create a struct for device runtime info Simon Glass
                   ` (58 subsequent siblings)
  83 siblings, 0 replies; 85+ messages in thread
From: Simon Glass @ 2021-03-15  4:25 UTC (permalink / raw)
  To: u-boot

Some systems (e.g. x86 APL) run SPL from read-only memory. The device
instances created by dtoc are therefore not writeable. To make things work
we would need to copy the devices to read/write memory.

To avoid this, add an option to use a separate runtime struct for devices,
just as is done for drivers. This can be used to hold information that
changes at runtime, avoiding the need for a copy.

Also add a Kconfig option for read-only SPL, which selects this feature.

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

(no changes since v1)

 common/spl/Kconfig | 24 ++++++++++++++++++++++++
 dts/Kconfig        | 22 ++++++++++++++++++++++
 2 files changed, 46 insertions(+)

diff --git a/common/spl/Kconfig b/common/spl/Kconfig
index 774541c02bc..584f8483e2e 100644
--- a/common/spl/Kconfig
+++ b/common/spl/Kconfig
@@ -276,6 +276,19 @@ config SPL_SEPARATE_BSS
 	  location is used. Normally we put the device tree at the end of BSS
 	  but with this option enabled, it goes at _image_binary_end.
 
+config SPL_READ_ONLY
+	bool
+	depends on SPL_OF_PLATDATA
+	# Bind cannot be supported because the udevice structs are in read-only
+	# memory so we cannot update the linked lists.
+	select SPL_OF_PLATDATA_NO_BIND
+	select SPL_OF_PLATDATA_RT
+	help
+	  Some platforms (e.g. x86 Apollo Lake) load SPL into a read-only
+	  section of memory. This means that of-platdata must make a copy (in
+	  writeable memory) of anything it wants to modify, such as
+	  device-private data.
+
 config SPL_BANNER_PRINT
 	bool "Enable output of the SPL banner 'U-Boot SPL ...'"
 	default y
@@ -1440,6 +1453,17 @@ config TPL_STACK
 	  The address of the initial stack-pointer for the TPL stage.
 	  Usually this will be the (aligned) top-of-stack.
 
+config TPL_READ_ONLY
+	bool
+	depends on TPL_OF_PLATDATA
+	select TPL_OF_PLATDATA_NO_BIND
+	select TPL_OF_PLATDATA_RT
+	help
+	  Some platforms (e.g. x86 Apollo Lake) load SPL into a read-only
+	  section of memory. This means that of-platdata must make a copy (in
+	  writeable memory) of anything it wants to modify, such as
+	  device-private data.
+
 config TPL_BOOTROM_SUPPORT
         bool "Support returning to the BOOTROM (from TPL)"
 	help
diff --git a/dts/Kconfig b/dts/Kconfig
index d289752a139..e6bbdc596bd 100644
--- a/dts/Kconfig
+++ b/dts/Kconfig
@@ -380,6 +380,17 @@ config SPL_OF_PLATDATA_NO_BIND
 	  some code space in U-Boot. This can be disabled if binding is needed,
 	  at the code of some code size increase.
 
+config SPL_OF_PLATDATA_RT
+	bool "Use a separate struct for device runtime data"
+	depends on SPL_OF_PLATDATA_INST
+	default y
+	help
+	  For systems running SPL from read-only memory it is convenient to
+	  separate out the runtime information, so that the devices don't need
+	  to be copied before being used. This moves the read-write parts of
+	  struct udevice (at present just the flags) into a separate struct,
+	  which is allocated at runtime.
+
 endif
 
 config TPL_OF_PLATDATA
@@ -429,6 +440,17 @@ config TPL_OF_PLATDATA_NO_BIND
 	  some code space in U-Boot. This can be disabled if binding is needed,
 	  at the code of some code size increase.
 
+config TPL_OF_PLATDATA_RT
+	bool "Use a separate struct for device runtime data"
+	depends on TPL_OF_PLATDATA_INST
+	default y
+	help
+	  For systems running TPL from read-only memory it is convenient to
+	  separate out the runtime information, so that the devices don't need
+	  to be copied before being used. This moves the read-write parts of
+	  struct udevice (at present just the flags) into a separate struct,
+	  which is allocated at runtime.
+
 endif
 
 endmenu
-- 
2.31.0.rc2.261.g7f71774620-goog

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

* [PATCH v4 26/42] dm: core: Create a struct for device runtime info
  2021-03-15  4:25 [PATCH v4 00/42] dm: Implement OF_PLATDATA_INST in driver model (part E) Simon Glass
                   ` (24 preceding siblings ...)
  2021-03-15  4:25 ` [PATCH v4 25/42] dm: core: Add an option to support SPL in read-only memory Simon Glass
@ 2021-03-15  4:25 ` Simon Glass
  2021-03-15  4:25 ` [PATCH v4 27/42] dm: core: Move flags to device-runtime info Simon Glass
                   ` (57 subsequent siblings)
  83 siblings, 0 replies; 85+ messages in thread
From: Simon Glass @ 2021-03-15  4:25 UTC (permalink / raw)
  To: u-boot

At present when driver model needs to change a device it simply updates
the struct udevice structure. But with of-platdata-inst most of the fields
are not modified at runtime. In fact, typically only the flags need to
change.

For systems running SPL from read-only memory it is convenient to separate
out the runtime information, so that the devices don't need to be copied
before being used.

Create a new udevice_rt table, similar to the existing driver_rt. For now
it just holds the flags, although they are not used in this patch.

Add a new Kconfig for the driver_rt data, since this is not needed when
of-platdata-inst is used.

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

(no changes since v2)

Changes in v2:
- Use separate OF_PLATDATA_DRIVER_RT Kconfigs for driver run-time data
- Update the condition for dm_test_of_plat_dev()

 drivers/core/root.c               | 14 +++++++++++++-
 dts/Kconfig                       | 20 ++++++++++++++++++++
 include/asm-generic/global_data.h | 16 ++++++++++++++--
 include/dm/device.h               | 15 +++++++++++++++
 test/dm/of_platdata.c             |  2 +-
 5 files changed, 63 insertions(+), 4 deletions(-)

diff --git a/drivers/core/root.c b/drivers/core/root.c
index 3e52452cd85..446ac2ff774 100644
--- a/drivers/core/root.c
+++ b/drivers/core/root.c
@@ -133,6 +133,18 @@ static int dm_setup_inst(void)
 {
 	DM_ROOT_NON_CONST = DM_DEVICE_GET(root);
 
+	if (CONFIG_IS_ENABLED(OF_PLATDATA_RT)) {
+		struct udevice_rt *urt;
+		int n_ents;
+
+		/* Allocate the udevice_rt table */
+		n_ents = ll_entry_count(struct udevice, udevice);
+		urt = calloc(n_ents, sizeof(struct udevice_rt));
+		if (!urt)
+			return log_msg_ret("urt", -ENOMEM);
+		gd_set_dm_udevice_rt(urt);
+	}
+
 	return 0;
 }
 
@@ -205,7 +217,7 @@ int dm_scan_plat(bool pre_reloc_only)
 {
 	int ret;
 
-	if (CONFIG_IS_ENABLED(OF_PLATDATA)) {
+	if (CONFIG_IS_ENABLED(OF_PLATDATA_DRIVER_RT)) {
 		struct driver_rt *dyn;
 		int n_ents;
 
diff --git a/dts/Kconfig b/dts/Kconfig
index e6bbdc596bd..99ce75e1a2a 100644
--- a/dts/Kconfig
+++ b/dts/Kconfig
@@ -338,6 +338,7 @@ config SPL_OF_PLATDATA
 	bool "Generate platform data for use in SPL"
 	depends on SPL_OF_CONTROL
 	select DTOC
+	select SPL_OF_PLATDATA_DRIVER_RT if !SPL_OF_PLATDATA_INST
 	help
 	  For very constrained SPL environments the overhead of decoding
 	  device tree nodes and converting their contents into platform data
@@ -391,12 +392,22 @@ config SPL_OF_PLATDATA_RT
 	  struct udevice (at present just the flags) into a separate struct,
 	  which is allocated at runtime.
 
+config SPL_OF_PLATDATA_DRIVER_RT
+	bool
+	help
+	  Use a separate struct for driver runtime data.
+
+	  This enables the driver_rt information, used with of-platdata when
+	  of-platdata-inst is not used. It allows finding devices by their
+	  driver data.
+
 endif
 
 config TPL_OF_PLATDATA
 	bool "Generate platform data for use in TPL"
 	depends on TPL_OF_CONTROL
 	select DTOC
+	select TPL_OF_PLATDATA_DRIVER_RT if !TPL_OF_PLATDATA_INST
 	help
 	  For very constrained SPL environments the overhead of decoding
 	  device tree nodes and converting their contents into platform data
@@ -451,6 +462,15 @@ config TPL_OF_PLATDATA_RT
 	  struct udevice (at present just the flags) into a separate struct,
 	  which is allocated at runtime.
 
+config TPL_OF_PLATDATA_DRIVER_RT
+	bool
+	help
+	  Use a separate struct for driver runtime data.
+
+	  This enables the driver_rt information, used with of-platdata when
+	  of-platdata-inst is not used. It allows finding devices by their
+	  driver data.
+
 endif
 
 endmenu
diff --git a/include/asm-generic/global_data.h b/include/asm-generic/global_data.h
index b6a9991fc9a..b88361cd087 100644
--- a/include/asm-generic/global_data.h
+++ b/include/asm-generic/global_data.h
@@ -215,10 +215,14 @@ struct global_data {
 	 * @uclass_root_s.
 	 */
 	struct list_head *uclass_root;
-# if CONFIG_IS_ENABLED(OF_PLATDATA)
+# if CONFIG_IS_ENABLED(OF_PLATDATA_DRIVER_RT)
 	/** @dm_driver_rt: Dynamic info about the driver */
 	struct driver_rt *dm_driver_rt;
 # endif
+#if CONFIG_IS_ENABLED(OF_PLATDATA_RT)
+	/** @dm_udevice_rt: Dynamic info about the udevice */
+	struct udevice_rt *dm_udevice_rt;
+# endif
 #endif
 #ifdef CONFIG_TIMER
 	/**
@@ -477,7 +481,7 @@ struct global_data {
 #define gd_set_of_root(_root)
 #endif
 
-#if CONFIG_IS_ENABLED(OF_PLATDATA)
+#if CONFIG_IS_ENABLED(OF_PLATDATA_DRIVER_RT)
 #define gd_set_dm_driver_rt(dyn)	gd->dm_driver_rt = dyn
 #define gd_dm_driver_rt()		gd->dm_driver_rt
 #else
@@ -485,6 +489,14 @@ struct global_data {
 #define gd_dm_driver_rt()		NULL
 #endif
 
+#if CONFIG_IS_ENABLED(OF_PLATDATA_RT)
+#define gd_set_dm_udevice_rt(dyn)	gd->dm_udevice_rt = dyn
+#define gd_dm_udevice_rt()		gd->dm_udevice_rt
+#else
+#define gd_set_dm_udevice_rt(dyn)
+#define gd_dm_udevice_rt()		NULL
+#endif
+
 #ifdef CONFIG_GENERATE_ACPI_TABLE
 #define gd_acpi_ctx()		gd->acpi_ctx
 #else
diff --git a/include/dm/device.h b/include/dm/device.h
index 9183356468f..8e16f2ea497 100644
--- a/include/dm/device.h
+++ b/include/dm/device.h
@@ -190,6 +190,21 @@ struct udevice {
 #endif
 };
 
+/**
+ * udevice_rt - runtime information set up by U-Boot
+ *
+ * This is only used with OF_PLATDATA_RT
+ *
+ * There is one of these for every udevice in the linker list, indexed by
+ * the udevice_info idx value.
+ *
+ * @flags_: Flags for this device DM_FLAG_... (do not access outside driver
+ *	model)
+ */
+struct udevice_rt {
+	u32 flags_;
+};
+
 /* Maximum sequence number supported */
 #define DM_MAX_SEQ	999
 
diff --git a/test/dm/of_platdata.c b/test/dm/of_platdata.c
index f2b45b9a868..0f89c7a7da8 100644
--- a/test/dm/of_platdata.c
+++ b/test/dm/of_platdata.c
@@ -147,7 +147,7 @@ static int dm_test_of_plat_dev(struct unit_test_state *uts)
 	uint i;
 
 	/* Skip this test if there is no platform data */
-	if (CONFIG_IS_ENABLED(OF_PLATDATA_INST))
+	if (!CONFIG_IS_ENABLED(OF_PLATDATA_DRIVER_RT))
 		return 0;
 
 	/* Record the indexes that are found */
-- 
2.31.0.rc2.261.g7f71774620-goog

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

* [PATCH v4 27/42] dm: core: Move flags to device-runtime info
  2021-03-15  4:25 [PATCH v4 00/42] dm: Implement OF_PLATDATA_INST in driver model (part E) Simon Glass
                   ` (25 preceding siblings ...)
  2021-03-15  4:25 ` [PATCH v4 26/42] dm: core: Create a struct for device runtime info Simon Glass
@ 2021-03-15  4:25 ` Simon Glass
  2021-03-15  4:25 ` [PATCH v4 28/42] dm: core: Allow storing priv/plat data separately Simon Glass
                   ` (56 subsequent siblings)
  83 siblings, 0 replies; 85+ messages in thread
From: Simon Glass @ 2021-03-15  4:25 UTC (permalink / raw)
  To: u-boot

When of-platdata-inst is active, use the flags in the new udevice_rt
table, dropping them from the main struct udevice. This ensures that the
latter is not updated at runtime.

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

(no changes since v2)

Changes in v2:
- Leave the flags_ memeber in the same struct position

 drivers/core/device.c | 33 +++++++++++++++++++++++++++++++++
 include/dm/device.h   |  8 ++++++++
 2 files changed, 41 insertions(+)

diff --git a/drivers/core/device.c b/drivers/core/device.c
index 1990b6f69f8..06d2467825f 100644
--- a/drivers/core/device.c
+++ b/drivers/core/device.c
@@ -1136,3 +1136,36 @@ int dev_enable_by_path(const char *path)
 	return lists_bind_fdt(parent, node, NULL, false);
 }
 #endif
+
+#if CONFIG_IS_ENABLED(OF_PLATDATA_RT)
+static struct udevice_rt *dev_get_rt(const struct udevice *dev)
+{
+	struct udevice *base = ll_entry_start(struct udevice, udevice);
+	int idx = dev - base;
+
+	struct udevice_rt *urt = gd_dm_udevice_rt() + idx;
+
+	return urt;
+}
+
+u32 dev_get_flags(const struct udevice *dev)
+{
+	const struct udevice_rt *urt = dev_get_rt(dev);
+
+	return urt->flags_;
+}
+
+void dev_or_flags(const struct udevice *dev, u32 or)
+{
+	struct udevice_rt *urt = dev_get_rt(dev);
+
+	urt->flags_ |= or;
+}
+
+void dev_bic_flags(const struct udevice *dev, u32 bic)
+{
+	struct udevice_rt *urt = dev_get_rt(dev);
+
+	urt->flags_ &= ~bic;
+}
+#endif /* OF_PLATDATA_RT */
diff --git a/include/dm/device.h b/include/dm/device.h
index 8e16f2ea497..0a9718a5b81 100644
--- a/include/dm/device.h
+++ b/include/dm/device.h
@@ -177,7 +177,9 @@ struct udevice {
 	struct list_head uclass_node;
 	struct list_head child_head;
 	struct list_head sibling_node;
+#if !CONFIG_IS_ENABLED(OF_PLATDATA_RT)
 	u32 flags_;
+#endif
 	int seq_;
 #if !CONFIG_IS_ENABLED(OF_PLATDATA)
 	ofnode node_;
@@ -211,6 +213,11 @@ struct udevice_rt {
 /* Returns the operations for a device */
 #define device_get_ops(dev)	(dev->driver->ops)
 
+#if CONFIG_IS_ENABLED(OF_PLATDATA_RT)
+u32 dev_get_flags(const struct udevice *dev);
+void dev_or_flags(const struct udevice *dev, u32 or);
+void dev_bic_flags(const struct udevice *dev, u32 bic);
+#else
 static inline u32 dev_get_flags(const struct udevice *dev)
 {
 	return dev->flags_;
@@ -225,6 +232,7 @@ static inline void dev_bic_flags(struct udevice *dev, u32 bic)
 {
 	dev->flags_ &= ~bic;
 }
+#endif /* OF_PLATDATA_RT */
 
 /**
  * dev_ofnode() - get the DT node reference associated with a udevice
-- 
2.31.0.rc2.261.g7f71774620-goog

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

* [PATCH v4 28/42] dm: core: Allow storing priv/plat data separately
  2021-03-15  4:25 [PATCH v4 00/42] dm: Implement OF_PLATDATA_INST in driver model (part E) Simon Glass
                   ` (26 preceding siblings ...)
  2021-03-15  4:25 ` [PATCH v4 27/42] dm: core: Move flags to device-runtime info Simon Glass
@ 2021-03-15  4:25 ` Simon Glass
  2021-03-15  4:25 ` [PATCH v4 29/42] sandbox: Define a region for device priv/plat data Simon Glass
                   ` (55 subsequent siblings)
  83 siblings, 0 replies; 85+ messages in thread
From: Simon Glass @ 2021-03-15  4:25 UTC (permalink / raw)
  To: u-boot

At present the device priv/data data allocated by dtoc is stored in the
data section along with other variables. On some platforms it is better
to allocate space for it separately, e.g. if SPL is running from read-only
memory.

Create a new space with the same size as that allocated by dtoc, ready for
use.

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

(no changes since v1)

 drivers/core/root.c               | 12 ++++++++++++
 include/asm-generic/global_data.h | 10 ++++++++++
 include/asm-generic/sections.h    |  3 +++
 3 files changed, 25 insertions(+)

diff --git a/drivers/core/root.c b/drivers/core/root.c
index 446ac2ff774..82b3c7de715 100644
--- a/drivers/core/root.c
+++ b/drivers/core/root.c
@@ -11,6 +11,7 @@
 #include <fdtdec.h>
 #include <log.h>
 #include <malloc.h>
+#include <asm-generic/sections.h>
 #include <asm/global_data.h>
 #include <linux/libfdt.h>
 #include <dm/acpi.h>
@@ -135,7 +136,9 @@ static int dm_setup_inst(void)
 
 	if (CONFIG_IS_ENABLED(OF_PLATDATA_RT)) {
 		struct udevice_rt *urt;
+		void *base;
 		int n_ents;
+		uint size;
 
 		/* Allocate the udevice_rt table */
 		n_ents = ll_entry_count(struct udevice, udevice);
@@ -143,6 +146,15 @@ static int dm_setup_inst(void)
 		if (!urt)
 			return log_msg_ret("urt", -ENOMEM);
 		gd_set_dm_udevice_rt(urt);
+
+		/* Now allocate space for the priv/plat data, and copy it in */
+		size = __priv_data_end - __priv_data_start;
+
+		base = calloc(1, size);
+		if (!base)
+			return log_msg_ret("priv", -ENOMEM);
+		memcpy(base, __priv_data_start, size);
+		gd_set_dm_priv_base(base);
 	}
 
 	return 0;
diff --git a/include/asm-generic/global_data.h b/include/asm-generic/global_data.h
index b88361cd087..29f4a98342d 100644
--- a/include/asm-generic/global_data.h
+++ b/include/asm-generic/global_data.h
@@ -222,6 +222,12 @@ struct global_data {
 #if CONFIG_IS_ENABLED(OF_PLATDATA_RT)
 	/** @dm_udevice_rt: Dynamic info about the udevice */
 	struct udevice_rt *dm_udevice_rt;
+	/**
+	 * @dm_priv_base: Base address of the priv/plat region used when
+	 * udevices and uclasses are in read-only memory. This is NULL if not
+	 * used
+	 */
+	void *dm_priv_base;
 # endif
 #endif
 #ifdef CONFIG_TIMER
@@ -492,9 +498,13 @@ struct global_data {
 #if CONFIG_IS_ENABLED(OF_PLATDATA_RT)
 #define gd_set_dm_udevice_rt(dyn)	gd->dm_udevice_rt = dyn
 #define gd_dm_udevice_rt()		gd->dm_udevice_rt
+#define gd_set_dm_priv_base(dyn)	gd->dm_priv_base = dyn
+#define gd_dm_priv_base()		gd->dm_priv_base
 #else
 #define gd_set_dm_udevice_rt(dyn)
 #define gd_dm_udevice_rt()		NULL
+#define gd_set_dm_priv_base(dyn)
+#define gd_dm_priv_base()		NULL
 #endif
 
 #ifdef CONFIG_GENERATE_ACPI_TABLE
diff --git a/include/asm-generic/sections.h b/include/asm-generic/sections.h
index 0577238d60b..267f1db73f2 100644
--- a/include/asm-generic/sections.h
+++ b/include/asm-generic/sections.h
@@ -28,6 +28,9 @@ extern char __efi_helloworld_end[];
 extern char __efi_var_file_begin[];
 extern char __efi_var_file_end[];
 
+/* Private data used by of-platdata devices/uclasses */
+extern char __priv_data_start[], __priv_data_end[];
+
 /* Start and end of .ctors section - used for constructor calls. */
 extern char __ctors_start[], __ctors_end[];
 
-- 
2.31.0.rc2.261.g7f71774620-goog

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

* [PATCH v4 29/42] sandbox: Define a region for device priv/plat data
  2021-03-15  4:25 [PATCH v4 00/42] dm: Implement OF_PLATDATA_INST in driver model (part E) Simon Glass
                   ` (27 preceding siblings ...)
  2021-03-15  4:25 ` [PATCH v4 28/42] dm: core: Allow storing priv/plat data separately Simon Glass
@ 2021-03-15  4:25 ` Simon Glass
  2021-03-15  4:25 ` [PATCH v4 30/42] dm: core: Use separate priv/plat data region Simon Glass
                   ` (54 subsequent siblings)
  83 siblings, 0 replies; 85+ messages in thread
From: Simon Glass @ 2021-03-15  4:25 UTC (permalink / raw)
  To: u-boot

Collect this together in one place, so driver model can access set it up
in a new place if needed.

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

(no changes since v1)

 arch/sandbox/cpu/u-boot-spl.lds | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/arch/sandbox/cpu/u-boot-spl.lds b/arch/sandbox/cpu/u-boot-spl.lds
index 649abeb5ee7..18160436a36 100644
--- a/arch/sandbox/cpu/u-boot-spl.lds
+++ b/arch/sandbox/cpu/u-boot-spl.lds
@@ -13,6 +13,14 @@ SECTIONS
 		KEEP(*(SORT(.u_boot_list*)));
 	}
 
+	/* Private data for devices with OF_PLATDATA_RT */
+	. = ALIGN(4);
+	.priv_data : {
+		__priv_data_start = .;
+		*(SORT_BY_ALIGNMENT(SORT_BY_NAME(.priv_data*)))
+		__priv_data_end = .;
+	}
+
 	__u_boot_sandbox_option_start = .;
 	_u_boot_sandbox_getopt : { KEEP(*(.u_boot_sandbox_getopt)) }
 	__u_boot_sandbox_option_end = .;
-- 
2.31.0.rc2.261.g7f71774620-goog

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

* [PATCH v4 30/42] dm: core: Use separate priv/plat data region
  2021-03-15  4:25 [PATCH v4 00/42] dm: Implement OF_PLATDATA_INST in driver model (part E) Simon Glass
                   ` (28 preceding siblings ...)
  2021-03-15  4:25 ` [PATCH v4 29/42] sandbox: Define a region for device priv/plat data Simon Glass
@ 2021-03-15  4:25 ` Simon Glass
  2021-03-15  4:25 ` [PATCH v4 31/42] dm: core: Add warnings to private / platform setters Simon Glass
                   ` (53 subsequent siblings)
  83 siblings, 0 replies; 85+ messages in thread
From: Simon Glass @ 2021-03-15  4:25 UTC (permalink / raw)
  To: u-boot

Make use of the new priv/plat data region if enabled. This is implemented
as a simple offset from the position set up by dtoc to the new position.

So long as all access goes through dm_priv_to_rw() this is safe.

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

(no changes since v1)

 drivers/core/device.c | 12 ++++++------
 drivers/core/root.c   |  9 +++++++++
 include/dm/util.h     |  9 +++++++++
 3 files changed, 24 insertions(+), 6 deletions(-)

diff --git a/drivers/core/device.c b/drivers/core/device.c
index 06d2467825f..cb960f8ec44 100644
--- a/drivers/core/device.c
+++ b/drivers/core/device.c
@@ -600,7 +600,7 @@ void *dev_get_plat(const struct udevice *dev)
 		return NULL;
 	}
 
-	return dev->plat_;
+	return dm_priv_to_rw(dev->plat_);
 }
 
 void *dev_get_parent_plat(const struct udevice *dev)
@@ -610,7 +610,7 @@ void *dev_get_parent_plat(const struct udevice *dev)
 		return NULL;
 	}
 
-	return dev->parent_plat_;
+	return dm_priv_to_rw(dev->parent_plat_);
 }
 
 void *dev_get_uclass_plat(const struct udevice *dev)
@@ -620,7 +620,7 @@ void *dev_get_uclass_plat(const struct udevice *dev)
 		return NULL;
 	}
 
-	return dev->uclass_plat_;
+	return dm_priv_to_rw(dev->uclass_plat_);
 }
 
 void *dev_get_priv(const struct udevice *dev)
@@ -630,7 +630,7 @@ void *dev_get_priv(const struct udevice *dev)
 		return NULL;
 	}
 
-	return dev->priv_;
+	return dm_priv_to_rw(dev->priv_);
 }
 
 void *dev_get_uclass_priv(const struct udevice *dev)
@@ -640,7 +640,7 @@ void *dev_get_uclass_priv(const struct udevice *dev)
 		return NULL;
 	}
 
-	return dev->uclass_priv_;
+	return dm_priv_to_rw(dev->uclass_priv_);
 }
 
 void *dev_get_parent_priv(const struct udevice *dev)
@@ -650,7 +650,7 @@ void *dev_get_parent_priv(const struct udevice *dev)
 		return NULL;
 	}
 
-	return dev->parent_priv_;
+	return dm_priv_to_rw(dev->parent_priv_);
 }
 
 static int device_get_device_tail(struct udevice *dev, int ret,
diff --git a/drivers/core/root.c b/drivers/core/root.c
index 82b3c7de715..d9a19c5e6b6 100644
--- a/drivers/core/root.c
+++ b/drivers/core/root.c
@@ -347,6 +347,15 @@ __weak int dm_scan_other(bool pre_reloc_only)
 	return 0;
 }
 
+#if CONFIG_IS_ENABLED(OF_PLATDATA_INST) && CONFIG_IS_ENABLED(READ_ONLY)
+void *dm_priv_to_rw(void *priv)
+{
+	long offset = priv - (void *)__priv_data_start;
+
+	return gd_dm_priv_base() + offset;
+}
+#endif
+
 /**
  * dm_scan() - Scan tables to bind devices
  *
diff --git a/include/dm/util.h b/include/dm/util.h
index 01a044992f2..138893c9354 100644
--- a/include/dm/util.h
+++ b/include/dm/util.h
@@ -49,3 +49,12 @@ void dm_dump_driver_compat(void);
 void dm_dump_static_driver_info(void);
 
 #endif
+
+#if CONFIG_IS_ENABLED(OF_PLATDATA_INST) && CONFIG_IS_ENABLED(READ_ONLY)
+void *dm_priv_to_rw(void *priv);
+#else
+static inline void *dm_priv_to_rw(void *priv)
+{
+	return priv;
+}
+#endif
-- 
2.31.0.rc2.261.g7f71774620-goog

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

* [PATCH v4 31/42] dm: core: Add warnings to private / platform setters
  2021-03-15  4:25 [PATCH v4 00/42] dm: Implement OF_PLATDATA_INST in driver model (part E) Simon Glass
                   ` (29 preceding siblings ...)
  2021-03-15  4:25 ` [PATCH v4 30/42] dm: core: Use separate priv/plat data region Simon Glass
@ 2021-03-15  4:25 ` Simon Glass
  2021-03-15  4:25 ` [PATCH v4 32/42] dm: doc: Tidy up of-platdata docs Simon Glass
                   ` (52 subsequent siblings)
  83 siblings, 0 replies; 85+ messages in thread
From: Simon Glass @ 2021-03-15  4:25 UTC (permalink / raw)
  To: u-boot

Add a warning to each of these functions so that people do not attempt to
use them outside driver model.

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

(no changes since v3)

Changes in v3:
- Aew patch with warnings for private / platform setters

 include/dm/device-internal.h | 18 ++++++++++++++++++
 include/dm/uclass-internal.h |  3 +++
 2 files changed, 21 insertions(+)

diff --git a/include/dm/device-internal.h b/include/dm/device-internal.h
index 71e5c75028d..e6b71cbfd2b 100644
--- a/include/dm/device-internal.h
+++ b/include/dm/device-internal.h
@@ -284,6 +284,9 @@ static inline int device_chld_remove(struct udevice *dev, struct driver *drv,
  * Use this function to override normal operation for special situations, such
  * as needing to allocate a variable amount of data.
  *
+ * If OF_PLATDATA_RT is enabled, this function cannot be used out of core driver
+ * model code, since the pointer must be within the gd->dm_priv_base region.
+ *
  * @dev		Device to check
  * @priv	New private-data pointer
  */
@@ -298,6 +301,9 @@ void dev_set_priv(struct udevice *dev, void *priv);
  * Use this function to override normal operation for special situations, such
  * as needing to allocate a variable amount of data.
  *
+ * If OF_PLATDATA_RT is enabled, this function cannot be used out of core driver
+ * model code, since the pointer must be within the gd->dm_priv_base region.
+ *
  * @dev:	Device to update
  * @parent_priv: New parent-private data
  */
@@ -312,6 +318,9 @@ void dev_set_parent_priv(struct udevice *dev, void *parent_priv);
  * Use this function to override normal operation for special situations, such
  * as needing to allocate a variable amount of data.
  *
+ * If OF_PLATDATA_RT is enabled, this function cannot be used out of core driver
+ * model code, since the pointer must be within the gd->dm_priv_base region.
+ *
  * @dev:	Device to update
  * @uclass_priv: New uclass private data
  */
@@ -326,6 +335,9 @@ void dev_set_uclass_priv(struct udevice *dev, void *uclass_priv);
  * Use this function to override normal operation for special situations, such
  * as needing to allocate a variable amount of data.
  *
+ * If OF_PLATDATA_RT is enabled, this function cannot be used out of core driver
+ * model code, since the pointer must be within the gd->dm_priv_base region.
+ *
  * @dev		Device to check
  * @plat	New platform-data pointer
  */
@@ -340,6 +352,9 @@ void dev_set_plat(struct udevice *dev, void *priv);
  * Use this function to override normal operation for special situations, such
  * as needing to allocate a variable amount of data.
  *
+ * If OF_PLATDATA_RT is enabled, this function cannot be used out of core driver
+ * model code, since the pointer must be within the gd->dm_priv_base region.
+ *
  * @dev:	Device to update
  * @parent_plat: New parent platform data
  */
@@ -354,6 +369,9 @@ void dev_set_parent_plat(struct udevice *dev, void *parent_plat);
  * Use this function to override normal operation for special situations, such
  * as needing to allocate a variable amount of data.
  *
+ * If OF_PLATDATA_RT is enabled, this function cannot be used out of core driver
+ * model code, since the pointer must be within the gd->dm_priv_base region.
+ *
  * @dev:	Device to update
  * @uclass_plat: New uclass platform data
  */
diff --git a/include/dm/uclass-internal.h b/include/dm/uclass-internal.h
index f2a780682b4..57c664c6daa 100644
--- a/include/dm/uclass-internal.h
+++ b/include/dm/uclass-internal.h
@@ -69,6 +69,9 @@
  * Use this function to override normal operation for special situations, such
  * as needing to allocate a variable amount of data.
  *
+ * If OF_PLATDATA_RT is enabled, this function cannot be used out of core driver
+ * model code, since the pointer must be within the gd->dm_priv_base region.
+ *
  * @uc		Uclass to update
  * @priv	New private-data pointer
  */
-- 
2.31.0.rc2.261.g7f71774620-goog

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

* [PATCH v4 32/42] dm: doc: Tidy up of-platdata docs
  2021-03-15  4:25 [PATCH v4 00/42] dm: Implement OF_PLATDATA_INST in driver model (part E) Simon Glass
                   ` (30 preceding siblings ...)
  2021-03-15  4:25 ` [PATCH v4 31/42] dm: core: Add warnings to private / platform setters Simon Glass
@ 2021-03-15  4:25 ` Simon Glass
  2021-03-15  4:25 ` [PATCH v4 33/42] dm: doc: Add documentation for of-platdata-inst Simon Glass
                   ` (51 subsequent siblings)
  83 siblings, 0 replies; 85+ messages in thread
From: Simon Glass @ 2021-03-15  4:25 UTC (permalink / raw)
  To: u-boot

This doc has a few pieces that are out-of-date. Fix these. Also we have
started to use 'devicetree' instead of 'device tree' or 'device-tree'
since it is easier to see as a single term, so replace all ocurrences
accordingly.

Also move the caveats to the end, since this is a fairly solid part of
U-Boot now.

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

(no changes since v3)

Changes in v3:
- Add documentation updates

 doc/driver-model/of-plat.rst | 138 +++++++++++++----------------------
 1 file changed, 52 insertions(+), 86 deletions(-)

diff --git a/doc/driver-model/of-plat.rst b/doc/driver-model/of-plat.rst
index a5a6e46e3ec..3c9ba01b302 100644
--- a/doc/driver-model/of-plat.rst
+++ b/doc/driver-model/of-plat.rst
@@ -11,61 +11,25 @@ Device tree is the standard configuration method in U-Boot. It is used to
 define what devices are in the system and provide configuration information
 to these devices.
 
-The overhead of adding device tree access to U-Boot is fairly modest,
+The overhead of adding devicetree access to U-Boot is fairly modest,
 approximately 3KB on Thumb 2 (plus the size of the DT itself). This means
-that in most cases it is best to use device tree for configuration.
+that in most cases it is best to use devicetree for configuration.
 
 However there are some very constrained environments where U-Boot needs to
 work. These include SPL with severe memory limitations. For example, some
 SoCs require a 16KB SPL image which must include a full MMC stack. In this
-case the overhead of device tree access may be too great.
+case the overhead of devicetree access may be too great.
 
 It is possible to create platform data manually by defining C structures
-for it, and reference that data in a U_BOOT_DRVINFO() declaration. This
-bypasses the use of device tree completely, effectively creating a parallel
+for it, and reference that data in a `U_BOOT_DRVINFO()` declaration. This
+bypasses the use of devicetree completely, effectively creating a parallel
 configuration mechanism. But it is an available option for SPL.
 
-As an alternative, a new 'of-platdata' feature is provided. This converts the
-device tree contents into C code which can be compiled into the SPL binary.
+As an alternative, the 'of-platdata' feature is provided. This converts the
+devicetree contents into C code which can be compiled into the SPL binary.
 This saves the 3KB of code overhead and perhaps a few hundred more bytes due
 to more efficient storage of the data.
 
-Note: Quite a bit of thought has gone into the design of this feature.
-However it still has many rough edges and comments and suggestions are
-strongly encouraged! Quite possibly there is a much better approach.
-
-
-Caveats
--------
-
-There are many problems with this features. It should only be used when
-strictly necessary. Notable problems include:
-
-   - Device tree does not describe data types. But the C code must define a
-     type for each property. These are guessed using heuristics which
-     are wrong in several fairly common cases. For example an 8-byte value
-     is considered to be a 2-item integer array, and is byte-swapped. A
-     boolean value that is not present means 'false', but cannot be
-     included in the structures since there is generally no mention of it
-     in the device tree file.
-
-   - Naming of nodes and properties is automatic. This means that they follow
-     the naming in the device tree, which may result in C identifiers that
-     look a bit strange.
-
-   - It is not possible to find a value given a property name. Code must use
-     the associated C member variable directly in the code. This makes
-     the code less robust in the face of device-tree changes. It also
-     makes it very unlikely that your driver code will be useful for more
-     than one SoC. Even if the code is common, each SoC will end up with
-     a different C struct name, and a likely a different format for the
-     platform data.
-
-   - The platform data is provided to drivers as a C structure. The driver
-     must use the same structure to access the data. Since a driver
-     normally also supports device tree it must use #ifdef to separate
-     out this code, since the structures are only available in SPL.
-
 
 How it works
 ------------
@@ -77,9 +41,9 @@ SPL/TPL and should be tested with:
 
     #if CONFIG_IS_ENABLED(OF_PLATDATA)
 
-A new tool called 'dtoc' converts a device tree file either into a set of
+A tool called 'dtoc' converts a devicetree file either into a set of
 struct declarations, one for each compatible node, and a set of
-U_BOOT_DRVINFO() declarations along with the actual platform data for each
+`U_BOOT_DRVINFO()` declarations along with the actual platform data for each
 device. As an example, consider this MMC node:
 
 .. code-block:: none
@@ -170,35 +134,35 @@ accessed using:
     struct udevice *dev;
     struct dtd_rockchip_rk3288_dw_mshc *plat = dev_get_plat(dev);
 
-This avoids the code overhead of converting the device tree data to
-platform data in the driver. The of_to_plat() method should
+This avoids the code overhead of converting the devicetree data to
+platform data in the driver. The `of_to_plat()` method should
 therefore do nothing in such a driver.
 
 Note that for the platform data to be matched with a driver, the 'name'
-property of the U_BOOT_DRVINFO() declaration has to match a driver declared
-via U_BOOT_DRIVER(). This effectively means that a U_BOOT_DRIVER() with a
+property of the `U_BOOT_DRVINFO()` declaration has to match a driver declared
+via `U_BOOT_DRIVER()`. This effectively means that a `U_BOOT_DRIVER()` with a
 'name' corresponding to the devicetree 'compatible' string (after converting
 it to a valid name for C) is needed, so a dedicated driver is required for
 each 'compatible' string.
 
-In order to make this a bit more flexible DM_DRIVER_ALIAS macro can be
+In order to make this a bit more flexible, the `DM_DRIVER_ALIAS()` macro can be
 used to declare an alias for a driver name, typically a 'compatible' string.
-This macro produces no code, but it is by dtoc tool. It must be located in the
+This macro produces no code, but is used by dtoc tool. It must be located in the
 same file as its associated driver, ideally just after it.
 
-The parent_idx is the index of the parent driver_info structure within its
-linker list (instantiated by the U_BOOT_DRVINFO() macro). This is used to support
-dev_get_parent().
+The parent_idx is the index of the parent `driver_info` structure within its
+linker list (instantiated by the `U_BOOT_DRVINFO()` macro). This is used to
+support `dev_get_parent()`.
 
-During the build process dtoc parses both U_BOOT_DRIVER and DM_DRIVER_ALIAS
-to build a list of valid driver names and driver aliases. If the 'compatible'
-string used for a device does not not match a valid driver name, it will be
-checked against the list of driver aliases in order to get the right driver
-name to use. If in this step there is no match found a warning is issued to
-avoid run-time failures.
+During the build process dtoc parses both `U_BOOT_DRIVER()` and
+`DM_DRIVER_ALIAS()` to build a list of valid driver names and driver aliases.
+If the 'compatible' string used for a device does not not match a valid driver
+name, it will be checked against the list of driver aliases in order to get the
+right driver name to use. If in this step there is no match found a warning is
+issued to avoid run-time failures.
 
-Where a node has multiple compatible strings, a #define is used to make them
-equivalent, e.g.:
+Where a node has multiple compatible strings, dtoc generates a `#define` to
+make them equivalent, e.g.:
 
 .. code-block:: c
 
@@ -210,26 +174,26 @@ Converting of-platdata to a useful form
 
 Of course it would be possible to use the of-platdata directly in your driver
 whenever configuration information is required. However this means that the
-driver will not be able to support device tree, since the of-platdata
-structure is not available when device tree is used. It would make no sense
-to use this structure if device tree were available, since the structure has
-all the limitations metioned in caveats above.
+driver will not be able to support devicetree, since the of-platdata
+structure is not available when devicetree is used. It would make no sense
+to use this structure if devicetree were available, since the structure has
+all the limitations metioned in caveats below.
 
 Therefore it is recommended that the of-platdata structure should be used
-only in the probe() method of your driver. It cannot be used in the
-of_to_plat() method since this is not called when platform data is
+only in the `probe()` method of your driver. It cannot be used in the
+`of_to_plat()` method since this is not called when platform data is
 already present.
 
 
 How to structure your driver
 ----------------------------
 
-Drivers should always support device tree as an option. The of-platdata
+Drivers should always support devicetree as an option. The of-platdata
 feature is intended as a add-on to existing drivers.
 
-Your driver should convert the plat struct in its probe() method. The
-existing device tree decoding logic should be kept in the
-of_to_plat() method and wrapped with #if.
+Your driver should convert the plat struct in its `probe()` method. The
+existing devicetree decoding logic should be kept in the
+`of_to_plat()` method and wrapped with `#if`.
 
 For example:
 
@@ -244,7 +208,7 @@ For example:
     #endif
             /*
              * Other fields can go here, to be filled in by decoding from
-             * the device tree (or the C structures when of-platdata is used).
+             * the devicetree (or the C structures when of-platdata is used).
              */
             int fifo_depth;
     };
@@ -252,7 +216,7 @@ For example:
     static int mmc_of_to_plat(struct udevice *dev)
     {
     #if !CONFIG_IS_ENABLED(OF_PLATDATA)
-            /* Decode the device tree data */
+            /* Decode the devicetree data */
             struct mmc_plat *plat = dev_get_plat(dev);
             const void *blob = gd->fdt_blob;
             int node = dev_of_offset(dev);
@@ -294,29 +258,29 @@ For example:
 
     DM_DRIVER_ALIAS(mmc_drv, vendor_mmc) /* matches compatible string */
 
-Note that struct mmc_plat is defined in the C file, not in a header. This
+Note that `struct mmc_plat` is defined in the C file, not in a header. This
 is to avoid needing to include dt-structs.h in a header file. The idea is to
 keep the use of each of-platdata struct to the smallest possible code area.
 There is just one driver C file for each struct, that can convert from the
 of-platdata struct to the standard one used by the driver.
 
-In the case where SPL_OF_PLATDATA is enabled, plat_auto is
+In the case where SPL_OF_PLATDATA is enabled, `plat_auto` is
 still used to allocate space for the platform data. This is different from
 the normal behaviour and is triggered by the use of of-platdata (strictly
-speaking it is a non-zero plat_size which triggers this).
+speaking it is a non-zero `plat_size` which triggers this).
 
 The of-platdata struct contents is copied from the C structure data to the
-start of the newly allocated area. In the case where device tree is used,
+start of the newly allocated area. In the case where devicetree is used,
 the platform data is allocated, and starts zeroed. In this case the
-of_to_plat() method should still set up the platform data (and the
+`of_to_plat()` method should still set up the platform data (and the
 of-platdata struct will not be present).
 
-SPL must use either of-platdata or device tree. Drivers cannot use both at
-the same time, but they must support device tree. Supporting of-platdata is
+SPL must use either of-platdata or devicetree. Drivers cannot use both at
+the same time, but they must support devicetree. Supporting of-platdata is
 optional.
 
-The device tree becomes in accessible when CONFIG_SPL_OF_PLATDATA is enabled,
-since the device-tree access code is not compiled in. A corollary is that
+The devicetree becomes inaccessible when CONFIG_SPL_OF_PLATDATA is enabled,
+since the devicetree access code is not compiled in. A corollary is that
 a board can only move to using of-platdata if all the drivers it uses support
 it. There would be little point in having some drivers require the device
 tree data, since then libfdt would still be needed for those drivers and
@@ -326,10 +290,10 @@ Internals
 ---------
 
 The dt-structs.h file includes the generated file
-(include/generated//dt-structs.h) if CONFIG_SPL_OF_PLATDATA is enabled.
+`(include/generated/dt-structs.h`) if CONFIG_SPL_OF_PLATDATA is enabled.
 Otherwise (such as in U-Boot proper) these structs are not available. This
 prevents them being used inadvertently. All usage must be bracketed with
-#if CONFIG_IS_ENABLED(OF_PLATDATA).
+`#if CONFIG_IS_ENABLED(OF_PLATDATA)`.
 
 The dt-plat.c file contains the device declarations and is is built in
 spl/dt-plat.c.
@@ -349,8 +313,9 @@ This is an implementation of an idea by Tom Rini <trini@konsulko.com>.
 
 Future work
 -----------
-- Consider programmatically reading binding files instead of device tree
+- Consider programmatically reading binding files instead of devicetree
   contents
+- Allow IS_ENABLED() to be used in the C code instead of #if
 
 
 .. Simon Glass <sjg@chromium.org>
@@ -358,3 +323,4 @@ Future work
 .. 6/6/16
 .. Updated Independence Day 2016
 .. Updated 1st October 2020
+.. Updated 5th February 2021
-- 
2.31.0.rc2.261.g7f71774620-goog

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

* [PATCH v4 33/42] dm: doc: Add documentation for of-platdata-inst
  2021-03-15  4:25 [PATCH v4 00/42] dm: Implement OF_PLATDATA_INST in driver model (part E) Simon Glass
                   ` (31 preceding siblings ...)
  2021-03-15  4:25 ` [PATCH v4 32/42] dm: doc: Tidy up of-platdata docs Simon Glass
@ 2021-03-15  4:25 ` Simon Glass
  2021-03-15  4:25 ` [PATCH v4 34/42] x86: Define a region for device priv/plat data Simon Glass
                   ` (50 subsequent siblings)
  83 siblings, 0 replies; 85+ messages in thread
From: Simon Glass @ 2021-03-15  4:25 UTC (permalink / raw)
  To: u-boot

Add a description of the new features, along with internal technical
documentation.

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

(no changes since v3)

Changes in v3:
- Add documentation for of-platdata-inst

 doc/driver-model/of-plat.rst | 587 +++++++++++++++++++++++++++++++++++
 1 file changed, 587 insertions(+)

diff --git a/doc/driver-model/of-plat.rst b/doc/driver-model/of-plat.rst
index 3c9ba01b302..74f1932473b 100644
--- a/doc/driver-model/of-plat.rst
+++ b/doc/driver-model/of-plat.rst
@@ -286,9 +286,394 @@ it. There would be little point in having some drivers require the device
 tree data, since then libfdt would still be needed for those drivers and
 there would be no code-size benefit.
 
+
+Build-time instantiation
+------------------------
+
+Even with of-platdata there is a fair amount of code required in driver model.
+It is possible to have U-Boot handle the instantiation of devices at build-time,
+so avoiding the need for the `device_bind()` code and some parts of
+`device_probe()`.
+
+The feature is enabled by CONFIG_OF_PLATDATA_INST.
+
+Here is an example device, as generated by dtoc::
+
+   /*
+    * Node /serial index 6
+    * driver sandbox_serial parent root_driver
+   */
+
+   #include <asm/serial.h>
+   struct sandbox_serial_plat __attribute__ ((section (".priv_data")))
+      _sandbox_serial_plat_serial = {
+      .dtplat = {
+         .sandbox_text_colour   = "cyan",
+      },
+   };
+   #include <asm/serial.h>
+   u8 _sandbox_serial_priv_serial[sizeof(struct sandbox_serial_priv)]
+      __attribute__ ((section (".priv_data")));
+   #include <serial.h>
+   u8 _sandbox_serial_uc_priv_serial[sizeof(struct serial_dev_priv)]
+      __attribute__ ((section (".priv_data")));
+
+   DM_DEVICE_INST(serial) = {
+      .driver     = DM_DRIVER_REF(sandbox_serial),
+      .name       = "sandbox_serial",
+      .plat_      = &_sandbox_serial_plat_serial,
+      .priv_      = _sandbox_serial_priv_serial,
+      .uclass     = DM_UCLASS_REF(serial),
+      .uclass_priv_ = _sandbox_serial_uc_priv_serial,
+      .uclass_node   = {
+         .prev = &DM_UCLASS_REF(serial)->dev_head,
+         .next = &DM_UCLASS_REF(serial)->dev_head,
+      },
+      .child_head   = {
+         .prev = &DM_DEVICE_REF(serial)->child_head,
+         .next = &DM_DEVICE_REF(serial)->child_head,
+      },
+      .sibling_node   = {
+         .prev = &DM_DEVICE_REF(i2c_at_0)->sibling_node,
+         .next = &DM_DEVICE_REF(spl_test)->sibling_node,
+      },
+      .seq_ = 0,
+   };
+
+Here is part of the driver, for reference::
+
+   static const struct udevice_id sandbox_serial_ids[] = {
+      { .compatible = "sandbox,serial" },
+      { }
+   };
+
+   U_BOOT_DRIVER(sandbox_serial) = {
+      .name   = "sandbox_serial",
+      .id   = UCLASS_SERIAL,
+      .of_match    = sandbox_serial_ids,
+      .of_to_plat  = sandbox_serial_of_to_plat,
+      .plat_auto   = sizeof(struct sandbox_serial_plat),
+      .priv_auto   = sizeof(struct sandbox_serial_priv),
+      .probe = sandbox_serial_probe,
+      .remove = sandbox_serial_remove,
+      .ops   = &sandbox_serial_ops,
+      .flags = DM_FLAG_PRE_RELOC,
+   };
+
+
+The `DM_DEVICE_INST()` macro declares a struct udevice so you can see that the
+members are from that struct. The private data is declared immediately above,
+as `_sandbox_serial_priv_serial`, so there is no need for run-time memory
+allocation. The #include lines are generated as well, since dtoc searches the
+U-Boot source code for the definition of `struct sandbox_serial_priv` and adds
+the relevant header so that the code will compile without errors.
+
+The `plat_` member is set to the dtv data which is declared immediately above
+the device. This is similar to how it would look without of-platdata-inst, but
+node that the `dtplat` member inside is part of the wider
+`_sandbox_serial_plat_serial` struct. This is because the driver declares its
+own platform data, and the part generated by dtoc can only be a portion of it.
+The `dtplat` part is always first in the struct. If the device has no
+`.plat_auto` field, then a simple dtv struct can be used as with this example::
+
+   static struct dtd_sandbox_clk dtv_clk_sbox = {
+      .assigned_clock_rates   = 0x141,
+      .assigned_clocks   = {0x7, 0x3},
+   };
+
+   #include <asm/clk.h>
+   u8 _sandbox_clk_priv_clk_sbox[sizeof(struct sandbox_clk_priv)]
+      __attribute__ ((section (".priv_data")));
+
+   DM_DEVICE_INST(clk_sbox) = {
+      .driver    = DM_DRIVER_REF(sandbox_clk),
+      .name      = "sandbox_clk",
+      .plat_     = &dtv_clk_sbox,
+
+Here is part of the driver, for reference::
+
+   static const struct udevice_id sandbox_clk_ids[] = {
+      { .compatible = "sandbox,clk" },
+      { }
+   };
+
+   U_BOOT_DRIVER(sandbox_clk) = {
+      .name       = "sandbox_clk",
+      .id         = UCLASS_CLK,
+      .of_match   = sandbox_clk_ids,
+      .ops        = &sandbox_clk_ops,
+      .probe      = sandbox_clk_probe,
+      .priv_auto  = sizeof(struct sandbox_clk_priv),
+   };
+
+
+You can see that `dtv_clk_sbox` just has the devicetree contents and there is
+no need for the `dtplat` separation, since the driver has no platform data of
+its own, besides that provided by the devicetree (i.e. no `.plat_auto` field).
+
+The doubly linked lists are handled by explicitly declaring the value of each
+node, as you can see with the `.prev` and `.next` values in the example above.
+Since dtoc knows the order of devices it can link them into the appropriate
+lists correctly.
+
+One of the features of driver model is the ability for a uclass to have a
+small amount of private data for each device in that uclass. This is used to
+provide a generic data structure that the uclass can use for all devices, thus
+allowing generic features to be implemented in common code. An example is I2C,
+which stores the bus speed there.
+
+Similarly, parent devices can have data associated with each of their children.
+This is used to provide information common to all children of a particular bus.
+For an I2C bus, this is used to store the I2C address of each child on the bus.
+
+This is all handled automatically by dtoc::
+
+   #include <asm/i2c.h>
+   u8 _sandbox_i2c_priv_i2c_at_0[sizeof(struct sandbox_i2c_priv)]
+      __attribute__ ((section (".priv_data")));
+   #include <i2c.h>
+   u8 _sandbox_i2c_uc_priv_i2c_at_0[sizeof(struct dm_i2c_bus)]
+      __attribute__ ((section (".priv_data")));
+
+   DM_DEVICE_INST(i2c_at_0) = {
+      .driver      = DM_DRIVER_REF(sandbox_i2c),
+      .name      = "sandbox_i2c",
+      .plat_   = &dtv_i2c_at_0,
+      .priv_      = _sandbox_i2c_priv_i2c_at_0,
+      .uclass   = DM_UCLASS_REF(i2c),
+      .uclass_priv_ = _sandbox_i2c_uc_priv_i2c_at_0,
+     ...
+
+Part of driver, for reference::
+
+   static const struct udevice_id sandbox_i2c_ids[] = {
+      { .compatible = "sandbox,i2c" },
+      { }
+   };
+
+   U_BOOT_DRIVER(sandbox_i2c) = {
+      .name   = "sandbox_i2c",
+      .id   = UCLASS_I2C,
+      .of_match = sandbox_i2c_ids,
+      .ops   = &sandbox_i2c_ops,
+      .priv_auto   = sizeof(struct sandbox_i2c_priv),
+   };
+
+Part of I2C uclass, for reference::
+
+   UCLASS_DRIVER(i2c) = {
+      .id         = UCLASS_I2C,
+      .name       = "i2c",
+      .flags      = DM_UC_FLAG_SEQ_ALIAS,
+      .post_bind  = i2c_post_bind,
+      .pre_probe  = i2c_pre_probe,
+      .post_probe = i2c_post_probe,
+      .per_device_auto   = sizeof(struct dm_i2c_bus),
+      .per_child_plat_auto   = sizeof(struct dm_i2c_chip),
+      .child_post_bind = i2c_child_post_bind,
+   };
+
+Here, `_sandbox_i2c_uc_priv_i2c_at_0` is required by the uclass but is declared
+in the device, as required by driver model. The required header file is included
+so that the code will compile without errors. A similar mechanism is used for
+child devices, but is not shown by this example.
+
+It would not be that useful to avoid binding devices but still need to allocate
+uclasses at runtime. So dtoc generates uclass instances as well::
+
+   struct list_head uclass_head = {
+      .prev = &DM_UCLASS_REF(serial)->sibling_node,
+      .next = &DM_UCLASS_REF(clk)->sibling_node,
+   };
+
+   DM_UCLASS_INST(clk) = {
+      .uc_drv      = DM_UCLASS_DRIVER_REF(clk),
+      .sibling_node   = {
+         .prev = &uclass_head,
+         .next = &DM_UCLASS_REF(i2c)->sibling_node,
+      },
+      .dev_head   = {
+         .prev = &DM_DEVICE_REF(clk_sbox)->uclass_node,
+         .next = &DM_DEVICE_REF(clk_fixed)->uclass_node,
+      },
+   };
+
+At the top is the list head. Driver model uses this on start-up, instead of
+creating its own.
+
+Below that are a set of `DM_UCLASS_INST()` macros, each declaring a
+`struct uclass`. The doubly linked lists work as for devices.
+
+All private data is placed into a `.priv_data` section so that it is contiguous
+in the resulting output binary.
+
+
+Indexes
+-------
+
+U-Boot stores drivers, devices and many other things in linker_list structures.
+These are sorted by name, so dtoc knows the order that they will appear when
+the linker runs. Each driver_info / udevice is referenced by its index in the
+linker_list array, called 'idx' in the code.
+
+When CONFIG_OF_PLATDATA_INST is enabled, idx is the udevice index, otherwise it
+is the driver_info index. In either case, indexes are used to reference devices
+using device_get_by_ofplat_idx(). This allows phandles to work as expected.
+
+
+Phases
+------
+
+U-Boot operates in several phases, typically TPL, SPL and U-Boot proper.
+The latter does not use dtoc.
+
+In some rare cases different drivers are used for two phases. For example,
+in TPL it may not be necessary to use the full PCI subsystem, so a simple
+driver can be used instead.
+
+This works in the build system simply by compiling in one driver or the
+other (e.g. PCI driver + uclass for SPL; simple_bus for TPL). But dtoc has
+no way of knowing which code is compiled in for which phase, since it does
+not inspect Makefiles or dependency graphs.
+
+So to make this work for dtoc, we need to be able to explicitly mark
+drivers with their phase. This is done by adding a macro to the driver::
+
+   /* code in tpl.c only compiled into TPL */
+   U_BOOT_DRIVER(pci_x86) = {
+      .name   = "pci_x86",
+      .id   = UCLASS_SIMPLE_BUS,
+      .of_match = of_match_ptr(tpl_fake_pci_ids),
+      DM_PHASE(tpl)
+   };
+
+
+   /* code in pci_x86.c compiled into SPL and U-Boot proper */
+   U_BOOT_DRIVER(pci_x86) = {
+      .name   = "pci_x86",
+      .id   = UCLASS_PCI,
+      .of_match = pci_x86_ids,
+      .ops   = &pci_x86_ops,
+   };
+
+
+Notice that the second driver has the same name but no DM_PHASE(), so it will be
+used for SPL and U-Boot.
+
+Note also that this only affects the code generated by dtoc. You still need to
+make sure that only the required driver is build into each phase.
+
+
+Header files
+------------
+
+With OF_PLATDATA_INST, dtoc must include the correct header file in the
+generated code for any structs that are used, so that the code will compile.
+For example, if `struct ns16550_plat` is used, the code must include the
+`ns16550.h` header file.
+
+Typically dtoc can detect the header file needed for a driver by looking
+for the structs that it uses. For example, if a driver as a `.priv_auto`
+that uses `struct ns16550_plat`, then dtoc can search header files for the
+definition of that struct and use the file.
+
+In some cases, enums are used in drivers, typically with the `.data` field
+of `struct udevice_id`. Since dtoc does not support searching for these,
+you must use the `DM_HDR()` macro to tell dtoc which header to use. This works
+as a macro included in the driver definition::
+
+   static const struct udevice_id apl_syscon_ids[] = {
+      { .compatible = "intel,apl-punit", .data = X86_SYSCON_PUNIT },
+      { }
+   };
+
+   U_BOOT_DRIVER(intel_apl_punit) = {
+      .name       = "intel_apl_punit",
+      .id         = UCLASS_SYSCON,
+      .of_match   = apl_syscon_ids,
+      .probe      = apl_punit_probe,
+      DM_HEADER(<asm/cpu.h>)    /* for X86_SYSCON_PUNIT */
+   };
+
+
+
+Caveats
+-------
+
+There are various complications with this feature which mean it should only
+be used when strictly necessary, i.e. in SPL with limited memory. Notable
+caveats include:
+
+   - Device tree does not describe data types. But the C code must define a
+     type for each property. These are guessed using heuristics which
+     are wrong in several fairly common cases. For example an 8-byte value
+     is considered to be a 2-item integer array, and is byte-swapped. A
+     boolean value that is not present means 'false', but cannot be
+     included in the structures since there is generally no mention of it
+     in the devicetree file.
+
+   - Naming of nodes and properties is automatic. This means that they follow
+     the naming in the devicetree, which may result in C identifiers that
+     look a bit strange.
+
+   - It is not possible to find a value given a property name. Code must use
+     the associated C member variable directly in the code. This makes
+     the code less robust in the face of devicetree changes. To avoid having
+     a second struct with similar members and names you need to explicitly
+     declare it as an alias with `DM_DRIVER_ALIAS()`.
+
+   - The platform data is provided to drivers as a C structure. The driver
+     must use the same structure to access the data. Since a driver
+     normally also supports devicetree it must use `#ifdef` to separate
+     out this code, since the structures are only available in SPL. This could
+     be fixed fairly easily by making the structs available outside SPL, so
+     that `IS_ENABLED()` could be used.
+
+   - With CONFIG_OF_PLATDATA_INST all binding happens at build-time, meaning
+     that (by default) it is not possible to call `device_bind()` from C code.
+     This means that all devices must have an associated devicetree node and
+     compatible string. For example if a GPIO device currently creates child
+     devices in its `bind()` method, it will not work with
+     CONFIG_OF_PLATDATA_INST. Arguably this is bad practice anyway and the
+     devicetree binding should be updated to declare compatible strings for
+     the child devices. It is possible to disable OF_PLATDATA_NO_BIND but this
+     is not recommended since it increases code size.
+
+
 Internals
 ---------
 
+Generated files
+```````````````
+
+When enabled, dtoc generates the following five files:
+
+include/generated/dt-decl.h (OF_PLATDATA_INST only)
+   Contains declarations for all drivers, devices and uclasses. This allows
+   any `struct udevice`, `struct driver` or `struct uclass` to be located by its
+   name
+
+include/generated/dt-structs-gen.h
+   Contains the struct definitions for the devicetree nodes that are used. This
+   is the same as without OF_PLATDATA_INST
+
+spl/dts/dt-plat.c (only with !OF_PLATDATA_INST)
+   Contains the `U_BOOT_DRVINFO()` declarations that U-Boot uses to bind devices
+   at start-up. See above for an example
+
+spl/dts/dt-device.c (only with OF_PLATDATA_INST)
+   Contains `DM_DEVICE_INST()` declarations for each device that can be used at
+   run-time. These are declared in the file along with any private/platform data
+   that they use. Every device has an idx, as above. Since each device must be
+   part of a double-linked list, the nodes are declared in the code as well.
+
+spl/dts/dt-uclass.c (only with OF_PLATDATA_INST)
+   Contains `DM_UCLASS_INST()` declarations for each uclass that can be used at
+   run-time. These are declared in the file along with any private data
+   associated with the uclass itself (the `.priv_auto` member). Since each
+   uclass must be part of a double-linked list, the nodes are declared in the
+   code as well.
+
 The dt-structs.h file includes the generated file
 `(include/generated/dt-structs.h`) if CONFIG_SPL_OF_PLATDATA is enabled.
 Otherwise (such as in U-Boot proper) these structs are not available. This
@@ -298,6 +683,208 @@ prevents them being used inadvertently. All usage must be bracketed with
 The dt-plat.c file contains the device declarations and is is built in
 spl/dt-plat.c.
 
+
+CONFIG options
+``````````````
+
+Several CONFIG options are used to control the behaviour of of-platdata, all
+available for both SPL and TPL:
+
+OF_PLATDATA
+   This is the main option which enables the of-platdata feature
+
+OF_PLATDATA_PARENT
+   This allows `device_get_parent()` to work. Without this, all devices exist as
+   direct children of the root node. This option is highly desirable (if not
+   always absolutely essential) for buses such as I2C.
+
+OF_PLATDATA_INST
+   This controls the instantiation of devices at build time. With it disabled,
+   only `U_BOOT_DRVINFO()` records are created, with U-Boot handling the binding
+   in `device_bind()` on start-up. With it enabled, only `DM_DEVICE_INST()` and
+   `DM_UCLASS_INST()` records are created, and `device_bind()` is not needed at
+   runtime.
+
+OF_PLATDATA_NO_BIND
+   This controls whether `device_bind()` is supported. It is enabled by default
+   with OF_PLATDATA_INST since code-size reduction is really the main point of
+   the feature. It can be disabled if needed but is not likely to be supported
+   in the long term.
+
+OF_PLATDATA_DRIVER_RT
+   This controls whether the `struct driver_rt` records are used by U-Boot.
+   Normally when a device is bound, U-Boot stores the device pointer in one of
+   these records. There is one for every `struct driver_info` in the system,
+   i.e. one for every device that is bound from those records. It provides a
+   way to locate a device in the code and is used by
+   `device_get_by_ofplat_idx()`. This option is always enabled with of-platdata,
+   provided OF_PLATDATA_INST is not. In that case the records are useless since
+   we don't have any `struct driver_info` records.
+
+OF_PLATDATA_RT
+   This controls whether the `struct udevice_rt` records are used by U-Boot.
+   It moves the updatable fields from `struct udevice` (currently only `flags`)
+   into a separate structure, allowing the records to be kept in read-only
+   memory. It is generally enabled if OF_PLATDATA_INST is enabled. This option
+   also controls whether the private data is used in situ, or first copied into
+   an allocated region. Again this is to allow the private data declared by
+   dtoc-generated code to be in read-only memory. Note that access to private
+   data must be done via accessor functions, such as `dev_get_priv()`, so that
+   the relocation is handled.
+
+READ_ONLY
+   This indicates that the data generated by dtoc should not be modified. Only
+   a few fields actually do get changed in U-Boot, such as device flags. This
+   option causes those to move into an allocated space (see OF_PLATDATA_RT).
+   Also, since updating doubly linked lists is generally impossible when some of
+   the nodes cannot be updated, OF_PLATDATA_NO_BIND is enabled.
+
+Data structures
+```````````````
+
+A few extra data structures are used with of-platdata:
+
+`struct udevice_rt`
+   Run-time information for devices. When OF_PLATDATA_RT is enabled, this holds
+   the flags for each device, so that `struct udevice` can remain unchanged by
+   U-Boot, and potentially reside in read-only memory. Access to flags is then
+   via functions like `dev_get_flags()` and `dev_or_flags()`. This data
+   structure is allocated on start-up, where the private data is also copied.
+   All flags values start at 0 and any changes are handled by `dev_or_flags()`
+   and `dev_bic_flags()`. It would be more correct for the flags to be set to
+   `DM_FLAG_BOUND`, or perhaps `DM_FLAG_BOUND | DM_FLAG_ALLOC_PDATA`, but since
+   there is no code to bind/unbind devices and no code to allocate/free
+   private data / platform data, it doesn't matter.
+
+`struct driver_rt`
+   Run-time information for `struct driver_info` records. When
+   OF_PLATDATA_DRIVER_RT is enabled, this holds a pointer to the device
+   created by each record. This is needed so that is it possible to locate a
+   device from C code. Specifically, the code can use `DM_DRVINFO_GET(name)` to
+   get a reference to a particular `struct driver_info`, with `name` being the
+   name of the devicetree node. This is very convenient. It is also fast, since
+   no    searching or string comparison is needed. This data structure is
+   allocated    on start-up, filled out by `device_bind()` and used by
+   `device_get_by_ofplat_idx()`.
+
+Other changes
+`````````````
+
+Some other changes are made with of-platdata:
+
+Accessor functions
+   Accessing private / platform data via functions such as `dev_get_priv()` has
+   always been encouraged. With OF_PLATDATA_RT this is essential, since the
+   `priv_` and `plat_`  (etc.) values point to the data generated by dtoc, not
+   the read-write copy that is sometimes made on start-up. Changing the
+   private / platform data  pointers has always been discouraged (the API is
+   marked internal) but with OF_PLATDATA_RT this is not currently supported in
+   general, since it assumes that all such pointers point to the relocated data.
+   Note also that the renaming of struct members to have a trailing underscore
+   was partly done to make people aware that they should not be accessed
+   directly.
+
+`gd->uclass_root_s`
+   Normally U-Boot sets up the head of the uclass list here and makes
+   `gd->uclass_root` point to it. With OF_PLATDATA_INST, dtoc generates a
+   declaration of `uclass_head` in `dt-uclass.c` since it needs to link the
+   head node into the list. In that case, `gd->uclass_root_s` is not used and
+   U-Boot just makes `gd->uclass_root` point to `uclass_head`.
+
+`gd->dm_driver_rt`
+   This holds a pointer to a list of `struct driver_rt` records, one for each
+   `struct driver_info`. The list is in alphabetical order by the name used
+   in `U_BOOT_DRVINFO(name)` and indexed by idx, with the first record having
+   an index of 0. It is only used if OF_PLATDATA_INST is not enabled. This is
+   accessed via macros so that it can be used inside IS_ENABLED(), rather than
+   requiring #ifdefs in the C code when it is not present.
+
+`gd->dm_udevice_rt`
+   This holds a pointer to a list of `struct udevice_rt` records, one for each
+   `struct udevice`. The list is in alphabetical order by the name used
+   in `DM_DEVICE_INST(name)` (a C version of the devicetree node) and indexed by
+   idx, with the first record having an index of 0. It is only used if
+   OF_PLATDATA_INST is enabled. This is accessed via macros so that it can be
+   used inside `IS_ENABLED()`, rather than requiring #ifdefs in the C code when
+   it is not present.
+
+`gd->dm_priv_base`
+   When OF_PLATDATA_RT is enabled, the private/platform data for each device is
+   copied into an allocated region by U-Boot on start-up. This points to that
+   region. All calls to accessor functions (e.g. `dev_get_priv()`) then
+   translate from the pointer provided by the caller (assumed to lie between
+   `__priv_data_start` and `__priv_data_end`) to the new allocated region. This
+   member is accessed via macros so that it can be used inside IS_ENABLED(),
+   rather than required #ifdefs in the C code when it is not present.
+
+`struct udevice->flags_`
+   When OF_PLATDATA_RT is enabled, device flags are no-longer part of
+   `struct udevice`, but are instead kept in `struct udevice_rt`, as described
+   above. Flags are accessed via functions, such as `dev_get_flags()` and
+   `dev_or_flags()`.
+
+`struct udevice->node_`
+   When OF_PLATDATA is enabled, there is no devicetree at runtime, so no need
+   for this field. It is removed, just to save space.
+
+`DM_PHASE`
+   This macro is used to indicate which phase of U-Boot a driver is intended
+   for. See above for details.
+
+`DM_HDR`
+   This macro is used to indicate which header file dtoc should use to allow
+   a driver declaration to compile correctly. See above for details.
+
+`device_get_by_ofplat_idx()`
+   There used to be a function called `device_get_by_driver_info()` which
+   looked up a `struct driver_info` pointer and returned the `struct udevice`
+   that was created from it. It was only available for use with of-platdata.
+   This has been removed in favour of `device_get_by_ofplat_idx()` which uses
+   `idx`, the index of the `struct driver_info` or `struct udevice` in the
+   linker_list. Similarly, the `struct phandle_0_arg` (etc.) structs have been
+   updated to use this index instead of a pointer to `struct driver_info`.
+
+`DM_DRVINFO_GET`
+   This has been removed since we now use indexes to obtain a driver from
+   `struct phandle_0_arg` and the like.
+
+Two-pass binding
+   The original of-platdata tried to order `U_BOOT_DRVINFO()` in the generated
+   files so as to have parents declared ahead of children. This was convenient
+   as it avoided any special code in U-Boot. With OF_PLATDATA_INST this does
+   not work as the idx value relies on using alphabetical order for everything,
+   so that dtoc and U-Boot's linker_lists agree on the idx value. Devices are
+   then bound in order of idx, having no regard to parent/child relationships.
+   For this reason, device binding now hapens in multiple passes, with parents
+   being bound before their children. This is important so that children can
+   find their parents in the bind() method if needed.
+
+Root device
+   The root device is generally bound by U-Boot but with OF_PLATDATA_INST it
+   cannot be, since binding needs to be done at build time. So in this case
+   dtoc sets up a root device using `DM_DEVICE_INST()` in `dt-device.c` and
+   U-Boot makes use of that. When OF_PLATDATA_INST is not enabled, U-Boot
+   generally ignores the root node and does not create a `U_BOOT_DRVINFO()`
+   record for it. This means that the idx numbers used by `struct driver_info`
+   (when OF_PLATDATA_INST is disabled) and the idx numbers used by
+   `struct udevice` (when OF_PLATDATA_INST is enabled) differ, since one has a
+   root node and the other does not. This does not actually matter, since only
+   one of them is actually used for any particular build, but it is worth
+   keeping in mind if comparing index values and switching OF_PLATDATA_INST on
+   and off.
+
+`__priv_data_start` and `__priv_data_end`
+   The private/platform data declared by dtoc is all collected together in
+   a linker section and these symbols mark the start and end of it. This allows
+   U-Boot to relocate the area to a new location if needed (with
+   OF_PLATDATA_RT)
+
+`dm_priv_to_rw()`
+   This function converts a private- or platform-data pointer value generated by
+   dtoc into one that can be used by U-Boot. It is a NOP unless OF_PLATDATA_RT
+   is enabled, in which case it translates the address to the relocated
+   region. See above for more information.
+
 The dm_populate_phandle_data() function that was previous needed has now been
 removed, since dtoc can address the drivers directly from dt-plat.c and does
 not need to fix up things at runtime.
-- 
2.31.0.rc2.261.g7f71774620-goog

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

* [PATCH v4 34/42] x86: Define a region for device priv/plat data
  2021-03-15  4:25 [PATCH v4 00/42] dm: Implement OF_PLATDATA_INST in driver model (part E) Simon Glass
                   ` (32 preceding siblings ...)
  2021-03-15  4:25 ` [PATCH v4 33/42] dm: doc: Add documentation for of-platdata-inst Simon Glass
@ 2021-03-15  4:25 ` Simon Glass
  2021-03-15  4:25 ` [PATCH v4 35/42] x86: apl: Fix the header order in pmc Simon Glass
                   ` (49 subsequent siblings)
  83 siblings, 0 replies; 85+ messages in thread
From: Simon Glass @ 2021-03-15  4:25 UTC (permalink / raw)
  To: u-boot

Collect this together in one place, so driver model can access set it up
in a new place if needed.

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

(no changes since v1)

 arch/x86/cpu/u-boot-spl.lds | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/arch/x86/cpu/u-boot-spl.lds b/arch/x86/cpu/u-boot-spl.lds
index b82e53ab124..4a655bf9b59 100644
--- a/arch/x86/cpu/u-boot-spl.lds
+++ b/arch/x86/cpu/u-boot-spl.lds
@@ -32,6 +32,14 @@ SECTIONS
 	. = ALIGN(4);
 	.rodata : { *(SORT_BY_ALIGNMENT(SORT_BY_NAME(.rodata*))) }
 
+	. = ALIGN(4);
+
+	.priv_data : {
+		__priv_data_start = .;
+		*(SORT_BY_ALIGNMENT(SORT_BY_NAME(.priv_data*)))
+		__priv_data_end = .;
+	}
+
 	. = ALIGN(4);
 	.data : { *(.data*) }
 
-- 
2.31.0.rc2.261.g7f71774620-goog

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

* [PATCH v4 35/42] x86: apl: Fix the header order in pmc
  2021-03-15  4:25 [PATCH v4 00/42] dm: Implement OF_PLATDATA_INST in driver model (part E) Simon Glass
                   ` (33 preceding siblings ...)
  2021-03-15  4:25 ` [PATCH v4 34/42] x86: Define a region for device priv/plat data Simon Glass
@ 2021-03-15  4:25 ` Simon Glass
  2021-03-15  4:25 ` [PATCH v4 36/42] x86: apl: Tell of-platdata about a required header file Simon Glass
                   ` (48 subsequent siblings)
  83 siblings, 0 replies; 85+ messages in thread
From: Simon Glass @ 2021-03-15  4:25 UTC (permalink / raw)
  To: u-boot

The dm.h header should come first. In fact it needs to, since otherwise
the driver model definitions are not available to dt-structs.h

Fix this, since it causes problems with OF_PLATDATA_INST.

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

(no changes since v1)

 arch/x86/cpu/apollolake/pmc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/x86/cpu/apollolake/pmc.c b/arch/x86/cpu/apollolake/pmc.c
index e23d38ea072..1d21187c96d 100644
--- a/arch/x86/cpu/apollolake/pmc.c
+++ b/arch/x86/cpu/apollolake/pmc.c
@@ -9,8 +9,8 @@
 #define LOG_CATEGORY UCLASS_ACPI_PMC
 
 #include <common.h>
-#include <dt-structs.h>
 #include <dm.h>
+#include <dt-structs.h>
 #include <log.h>
 #include <spl.h>
 #include <acpi/acpi_s3.h>
-- 
2.31.0.rc2.261.g7f71774620-goog

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

* [PATCH v4 36/42] x86: apl: Tell of-platdata about a required header file
  2021-03-15  4:25 [PATCH v4 00/42] dm: Implement OF_PLATDATA_INST in driver model (part E) Simon Glass
                   ` (34 preceding siblings ...)
  2021-03-15  4:25 ` [PATCH v4 35/42] x86: apl: Fix the header order in pmc Simon Glass
@ 2021-03-15  4:25 ` Simon Glass
  2021-03-15  4:25 ` [PATCH v4 37/42] x86: itss: Tidy up bind() for of-platdata-inst Simon Glass
                   ` (47 subsequent siblings)
  83 siblings, 0 replies; 85+ messages in thread
From: Simon Glass @ 2021-03-15  4:25 UTC (permalink / raw)
  To: u-boot

This enum is needed to generate build-time devices. Tell dtoc where to
find the header, to avoid compile errors in the generated code.

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

(no changes since v1)

 arch/x86/cpu/apollolake/punit.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/x86/cpu/apollolake/punit.c b/arch/x86/cpu/apollolake/punit.c
index e67c011e22c..5ed7963579e 100644
--- a/arch/x86/cpu/apollolake/punit.c
+++ b/arch/x86/cpu/apollolake/punit.c
@@ -93,4 +93,5 @@ U_BOOT_DRIVER(intel_apl_punit) = {
 	.id		= UCLASS_SYSCON,
 	.of_match	= apl_syscon_ids,
 	.probe		= apl_punit_probe,
+	DM_HEADER(<asm/cpu.h>)    /* for X86_SYSCON_PUNIT */
 };
-- 
2.31.0.rc2.261.g7f71774620-goog

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

* [PATCH v4 37/42] x86: itss: Tidy up bind() for of-platdata-inst
  2021-03-15  4:25 [PATCH v4 00/42] dm: Implement OF_PLATDATA_INST in driver model (part E) Simon Glass
                   ` (35 preceding siblings ...)
  2021-03-15  4:25 ` [PATCH v4 36/42] x86: apl: Tell of-platdata about a required header file Simon Glass
@ 2021-03-15  4:25 ` Simon Glass
  2021-03-15  4:25 ` [PATCH v4 38/42] x86: Support a fake PCI device with of-platdata-inst Simon Glass
                   ` (46 subsequent siblings)
  83 siblings, 0 replies; 85+ messages in thread
From: Simon Glass @ 2021-03-15  4:25 UTC (permalink / raw)
  To: u-boot

With the standard of-platdata we must fix up driver_data manually. With
of-platadata-inst this is not necessary, since it is added to the device
by dtoc.

Update the code to handle this.

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

(no changes since v1)

 arch/x86/cpu/intel_common/itss.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/arch/x86/cpu/intel_common/itss.c b/arch/x86/cpu/intel_common/itss.c
index 588a512ecd4..1eff0309831 100644
--- a/arch/x86/cpu/intel_common/itss.c
+++ b/arch/x86/cpu/intel_common/itss.c
@@ -153,8 +153,9 @@ static int route_pmc_gpio_gpe(struct udevice *dev, uint pmc_gpe_num)
 
 static int itss_bind(struct udevice *dev)
 {
-	/* This is not set with of-platdata, so set it manually */
-	if (CONFIG_IS_ENABLED(OF_PLATDATA))
+	/* This is not set with basic of-platdata, so set it manually */
+	if (CONFIG_IS_ENABLED(OF_PLATDATA) &&
+	    !CONFIG_IS_ENABLED(OF_PLATDATA_INST))
 		dev->driver_data = X86_IRQT_ITSS;
 
 	return 0;
-- 
2.31.0.rc2.261.g7f71774620-goog

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

* [PATCH v4 38/42] x86: Support a fake PCI device with of-platdata-inst
  2021-03-15  4:25 [PATCH v4 00/42] dm: Implement OF_PLATDATA_INST in driver model (part E) Simon Glass
                   ` (36 preceding siblings ...)
  2021-03-15  4:25 ` [PATCH v4 37/42] x86: itss: Tidy up bind() for of-platdata-inst Simon Glass
@ 2021-03-15  4:25 ` Simon Glass
  2021-03-15  4:25 ` [PATCH v4 39/42] x86: Don't include reset driver in SPL Simon Glass
                   ` (45 subsequent siblings)
  83 siblings, 0 replies; 85+ messages in thread
From: Simon Glass @ 2021-03-15  4:25 UTC (permalink / raw)
  To: u-boot

With TPL we don't need full PCI support and it adds to code size. Instead,
a simple_bus driver is good enough to be able to read and write the PCI
config and do a little basic setup.

So at present there are two drivers in U-Boot called pci_x86. One is in
UCLASS_PCI, used in SPL and U-Boot proper. The other is in
UCLASS_SIMPLE_BUS and used only in TPL.

Add a tag to tell dtoc about this, so it knows which one to use when
generating the devices and uclasses.

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

(no changes since v1)

 arch/x86/lib/tpl.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/x86/lib/tpl.c b/arch/x86/lib/tpl.c
index ac6b6efbccd..b3e5f9c9138 100644
--- a/arch/x86/lib/tpl.c
+++ b/arch/x86/lib/tpl.c
@@ -150,5 +150,6 @@ U_BOOT_DRIVER(pci_x86) = {
 	.name	= "pci_x86",
 	.id	= UCLASS_SIMPLE_BUS,
 	.of_match = of_match_ptr(tpl_fake_pci_ids),
+	DM_PHASE(tpl)
 };
 #endif
-- 
2.31.0.rc2.261.g7f71774620-goog

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

* [PATCH v4 39/42] x86: Don't include reset driver in SPL
  2021-03-15  4:25 [PATCH v4 00/42] dm: Implement OF_PLATDATA_INST in driver model (part E) Simon Glass
                   ` (37 preceding siblings ...)
  2021-03-15  4:25 ` [PATCH v4 38/42] x86: Support a fake PCI device with of-platdata-inst Simon Glass
@ 2021-03-15  4:25 ` Simon Glass
  2021-03-15  4:25 ` [PATCH v4 40/42] x86: coral: Drop ACPI properties from of-platdata Simon Glass
                   ` (44 subsequent siblings)
  83 siblings, 0 replies; 85+ messages in thread
From: Simon Glass @ 2021-03-15  4:25 UTC (permalink / raw)
  To: u-boot

We don't normally need this driver in TPL/SPL, so drop it for now. It can
be enabled by individual boards if needed.

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

(no changes since v1)

 arch/x86/dts/reset.dtsi | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/x86/dts/reset.dtsi b/arch/x86/dts/reset.dtsi
index 555d0dd9608..f2ba2fb5e84 100644
--- a/arch/x86/dts/reset.dtsi
+++ b/arch/x86/dts/reset.dtsi
@@ -1,6 +1,6 @@
 / {
 	reset: reset {
 		compatible = "x86,reset";
-		u-boot,dm-pre-reloc;
+		u-boot,dm-pre-proper;
 	};
 };
-- 
2.31.0.rc2.261.g7f71774620-goog

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

* [PATCH v4 40/42] x86: coral: Drop ACPI properties from of-platdata
  2021-03-15  4:25 [PATCH v4 00/42] dm: Implement OF_PLATDATA_INST in driver model (part E) Simon Glass
                   ` (38 preceding siblings ...)
  2021-03-15  4:25 ` [PATCH v4 39/42] x86: Don't include reset driver in SPL Simon Glass
@ 2021-03-15  4:25 ` Simon Glass
  2021-03-15  4:25 ` [PATCH v4 41/42] x86: coral: Drop TPM and ACPI interrupts from TPL Simon Glass
                   ` (43 subsequent siblings)
  83 siblings, 0 replies; 85+ messages in thread
From: Simon Glass @ 2021-03-15  4:25 UTC (permalink / raw)
  To: u-boot

We don't use these in TPL or SPL, so drop them.

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

(no changes since v3)

Changes in v3:
- Don't drop 'ranges' since we use the full PCI driver in SPL

 configs/chromebook_coral_defconfig | 1 +
 1 file changed, 1 insertion(+)

diff --git a/configs/chromebook_coral_defconfig b/configs/chromebook_coral_defconfig
index ab73a0a88ce..31c035fedb4 100644
--- a/configs/chromebook_coral_defconfig
+++ b/configs/chromebook_coral_defconfig
@@ -72,6 +72,7 @@ CONFIG_MAC_PARTITION=y
 CONFIG_ISO_PARTITION=y
 CONFIG_EFI_PARTITION=y
 # CONFIG_SPL_EFI_PARTITION is not set
+CONFIG_OF_SPL_REMOVE_PROPS="clocks clock-names interrupt-parent interrupts linux-name acpi,name acpi,path u-boot,acpi-dsdt-order u-boot,acpi-ssdt-order"
 CONFIG_ENV_OVERWRITE=y
 CONFIG_REGMAP=y
 CONFIG_SYSCON=y
-- 
2.31.0.rc2.261.g7f71774620-goog

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

* [PATCH v4 41/42] x86: coral: Drop TPM and ACPI interrupts from TPL
  2021-03-15  4:25 [PATCH v4 00/42] dm: Implement OF_PLATDATA_INST in driver model (part E) Simon Glass
                   ` (39 preceding siblings ...)
  2021-03-15  4:25 ` [PATCH v4 40/42] x86: coral: Drop ACPI properties from of-platdata Simon Glass
@ 2021-03-15  4:25 ` Simon Glass
  2021-03-15  4:25 ` [PATCH v4 42/42] x86: apl: Use read-only SPL and new of-platdata Simon Glass
                   ` (42 subsequent siblings)
  83 siblings, 0 replies; 85+ messages in thread
From: Simon Glass @ 2021-03-15  4:25 UTC (permalink / raw)
  To: u-boot

These devices are not actually built in TPL but are currently active in
the TPL devicetree. For of-platdata-inst this means that we will try to
generate devices for them, which fails.

Update them to be active only in U-Boot proper.

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

(no changes since v3)

Changes in v3:
- Add new patch to drop coral's TPM and ACPI interrupts from TPL
- Use 'u-boot,dm-pre-proper' so these are not present in TPL/SPL

 arch/x86/dts/chromebook_coral.dts | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/arch/x86/dts/chromebook_coral.dts b/arch/x86/dts/chromebook_coral.dts
index 2ffe3b423c3..d109a387597 100644
--- a/arch/x86/dts/chromebook_coral.dts
+++ b/arch/x86/dts/chromebook_coral.dts
@@ -100,7 +100,7 @@
 	clk: clock {
 		compatible = "intel,apl-clk";
 		#clock-cells = <1>;
-		u-boot,dm-pre-reloc;
+		u-boot,dm-pre-proper;
 	};
 
 	cpus {
@@ -141,7 +141,7 @@
 	};
 
 	acpi_gpe: general-purpose-events {
-		u-boot,dm-pre-reloc;
+		u-boot,dm-pre-proper;
 		reg = <IOMAP_ACPI_BASE IOMAP_ACPI_SIZE>;
 		compatible = "intel,acpi-gpe";
 		interrupt-controller;
@@ -423,7 +423,7 @@
 			compatible = "intel,apl-i2c", "snps,designware-i2c-pci";
 			reg = <0x0200b210 0 0 0 0>;
 			early-regs = <IOMAP_I2C2_BASE 0x1000>;
-			u-boot,dm-pre-reloc;
+			u-boot,dm-pre-proper;
 			#address-cells = <1>;
 			#size-cells = <0>;
 			clock-frequency = <400000>;
@@ -434,7 +434,7 @@
 			tpm: tpm at 50 {
 				reg = <0x50>;
 				compatible = "google,cr50";
-				u-boot,dm-pre-reloc;
+				u-boot,dm-pre-proper;
 				u-boot,i2c-offset-len = <0>;
 				ready-gpios = <&gpio_n 28 GPIO_ACTIVE_LOW>;
 				interrupts-extended = <&acpi_gpe GPIO_28_IRQ
@@ -1233,5 +1233,5 @@
 &rtc {
 	#address-cells = <1>;
 	#size-cells = <0>;
-	u-boot,dm-pre-reloc;
+	u-boot,dm-pre-proper;
 };
-- 
2.31.0.rc2.261.g7f71774620-goog

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

* [PATCH v4 42/42] x86: apl: Use read-only SPL and new of-platdata
  2021-03-15  4:25 [PATCH v4 00/42] dm: Implement OF_PLATDATA_INST in driver model (part E) Simon Glass
                   ` (40 preceding siblings ...)
  2021-03-15  4:25 ` [PATCH v4 41/42] x86: coral: Drop TPM and ACPI interrupts from TPL Simon Glass
@ 2021-03-15  4:25 ` Simon Glass
  2021-03-17  1:28 ` Simon Glass
                   ` (41 subsequent siblings)
  83 siblings, 0 replies; 85+ messages in thread
From: Simon Glass @ 2021-03-15  4:25 UTC (permalink / raw)
  To: u-boot

With Apollo Lake, SPL is placed in read-only memory. Set this new option
so that OF_PLATDATA_INST can be used.

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

Changes in v4:
- Rebase to -next

 arch/x86/cpu/apollolake/Kconfig | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/arch/x86/cpu/apollolake/Kconfig b/arch/x86/cpu/apollolake/Kconfig
index f5dbd6cbd34..63a05149df8 100644
--- a/arch/x86/cpu/apollolake/Kconfig
+++ b/arch/x86/cpu/apollolake/Kconfig
@@ -20,6 +20,8 @@ config INTEL_APOLLOLAKE
 	select INTEL_GMA_SWSMISCI
 	select ACPI_GNVS_EXTERNAL
 	select TPL_OF_PLATDATA_PARENT
+	select TPL_OF_PLATDATA_INST
+	select TPL_READ_ONLY
 	imply ENABLE_MRC_CACHE
 	imply AHCI_PCI
 	imply SCSI
-- 
2.31.0.rc2.261.g7f71774620-goog

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

* [PATCH v4 42/42] x86: apl: Use read-only SPL and new of-platdata
  2021-03-15  4:25 [PATCH v4 00/42] dm: Implement OF_PLATDATA_INST in driver model (part E) Simon Glass
                   ` (41 preceding siblings ...)
  2021-03-15  4:25 ` [PATCH v4 42/42] x86: apl: Use read-only SPL and new of-platdata Simon Glass
@ 2021-03-17  1:28 ` Simon Glass
  2021-03-17  1:28 ` [PATCH v4 41/42] x86: coral: Drop TPM and ACPI interrupts from TPL Simon Glass
                   ` (40 subsequent siblings)
  83 siblings, 0 replies; 85+ messages in thread
From: Simon Glass @ 2021-03-17  1:28 UTC (permalink / raw)
  To: u-boot

With Apollo Lake, SPL is placed in read-only memory. Set this new option
so that OF_PLATDATA_INST can be used.

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

Changes in v4:
- Rebase to -next

 arch/x86/cpu/apollolake/Kconfig | 2 ++
 1 file changed, 2 insertions(+)

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

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

* [PATCH v4 41/42] x86: coral: Drop TPM and ACPI interrupts from TPL
  2021-03-15  4:25 [PATCH v4 00/42] dm: Implement OF_PLATDATA_INST in driver model (part E) Simon Glass
                   ` (42 preceding siblings ...)
  2021-03-17  1:28 ` Simon Glass
@ 2021-03-17  1:28 ` Simon Glass
  2021-03-17  1:28 ` [PATCH v4 39/42] x86: Don't include reset driver in SPL Simon Glass
                   ` (39 subsequent siblings)
  83 siblings, 0 replies; 85+ messages in thread
From: Simon Glass @ 2021-03-17  1:28 UTC (permalink / raw)
  To: u-boot

These devices are not actually built in TPL but are currently active in
the TPL devicetree. For of-platdata-inst this means that we will try to
generate devices for them, which fails.

Update them to be active only in U-Boot proper.

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

(no changes since v3)

Changes in v3:
- Add new patch to drop coral's TPM and ACPI interrupts from TPL
- Use 'u-boot,dm-pre-proper' so these are not present in TPL/SPL

 arch/x86/dts/chromebook_coral.dts | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

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

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

* [PATCH v4 40/42] x86: coral: Drop ACPI properties from of-platdata
  2021-03-15  4:25 [PATCH v4 00/42] dm: Implement OF_PLATDATA_INST in driver model (part E) Simon Glass
                   ` (44 preceding siblings ...)
  2021-03-17  1:28 ` [PATCH v4 39/42] x86: Don't include reset driver in SPL Simon Glass
@ 2021-03-17  1:28 ` Simon Glass
  2021-03-17  1:28 ` [PATCH v4 38/42] x86: Support a fake PCI device with of-platdata-inst Simon Glass
                   ` (37 subsequent siblings)
  83 siblings, 0 replies; 85+ messages in thread
From: Simon Glass @ 2021-03-17  1:28 UTC (permalink / raw)
  To: u-boot

We don't use these in TPL or SPL, so drop them.

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

(no changes since v3)

Changes in v3:
- Don't drop 'ranges' since we use the full PCI driver in SPL

 configs/chromebook_coral_defconfig | 1 +
 1 file changed, 1 insertion(+)

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

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

* [PATCH v4 39/42] x86: Don't include reset driver in SPL
  2021-03-15  4:25 [PATCH v4 00/42] dm: Implement OF_PLATDATA_INST in driver model (part E) Simon Glass
                   ` (43 preceding siblings ...)
  2021-03-17  1:28 ` [PATCH v4 41/42] x86: coral: Drop TPM and ACPI interrupts from TPL Simon Glass
@ 2021-03-17  1:28 ` Simon Glass
  2021-03-17  1:28 ` [PATCH v4 40/42] x86: coral: Drop ACPI properties from of-platdata Simon Glass
                   ` (38 subsequent siblings)
  83 siblings, 0 replies; 85+ messages in thread
From: Simon Glass @ 2021-03-17  1:28 UTC (permalink / raw)
  To: u-boot

We don't normally need this driver in TPL/SPL, so drop it for now. It can
be enabled by individual boards if needed.

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

(no changes since v1)

 arch/x86/dts/reset.dtsi | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

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

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

* [PATCH v4 38/42] x86: Support a fake PCI device with of-platdata-inst
  2021-03-15  4:25 [PATCH v4 00/42] dm: Implement OF_PLATDATA_INST in driver model (part E) Simon Glass
                   ` (45 preceding siblings ...)
  2021-03-17  1:28 ` [PATCH v4 40/42] x86: coral: Drop ACPI properties from of-platdata Simon Glass
@ 2021-03-17  1:28 ` Simon Glass
  2021-03-17  1:28 ` [PATCH v4 37/42] x86: itss: Tidy up bind() for of-platdata-inst Simon Glass
                   ` (36 subsequent siblings)
  83 siblings, 0 replies; 85+ messages in thread
From: Simon Glass @ 2021-03-17  1:28 UTC (permalink / raw)
  To: u-boot

With TPL we don't need full PCI support and it adds to code size. Instead,
a simple_bus driver is good enough to be able to read and write the PCI
config and do a little basic setup.

So at present there are two drivers in U-Boot called pci_x86. One is in
UCLASS_PCI, used in SPL and U-Boot proper. The other is in
UCLASS_SIMPLE_BUS and used only in TPL.

Add a tag to tell dtoc about this, so it knows which one to use when
generating the devices and uclasses.

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

(no changes since v1)

 arch/x86/lib/tpl.c | 1 +
 1 file changed, 1 insertion(+)

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

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

* [PATCH v4 37/42] x86: itss: Tidy up bind() for of-platdata-inst
  2021-03-15  4:25 [PATCH v4 00/42] dm: Implement OF_PLATDATA_INST in driver model (part E) Simon Glass
                   ` (46 preceding siblings ...)
  2021-03-17  1:28 ` [PATCH v4 38/42] x86: Support a fake PCI device with of-platdata-inst Simon Glass
@ 2021-03-17  1:28 ` Simon Glass
  2021-03-17  1:28 ` [PATCH v4 36/42] x86: apl: Tell of-platdata about a required header file Simon Glass
                   ` (35 subsequent siblings)
  83 siblings, 0 replies; 85+ messages in thread
From: Simon Glass @ 2021-03-17  1:28 UTC (permalink / raw)
  To: u-boot

With the standard of-platdata we must fix up driver_data manually. With
of-platadata-inst this is not necessary, since it is added to the device
by dtoc.

Update the code to handle this.

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

(no changes since v1)

 arch/x86/cpu/intel_common/itss.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

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

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

* [PATCH v4 36/42] x86: apl: Tell of-platdata about a required header file
  2021-03-15  4:25 [PATCH v4 00/42] dm: Implement OF_PLATDATA_INST in driver model (part E) Simon Glass
                   ` (47 preceding siblings ...)
  2021-03-17  1:28 ` [PATCH v4 37/42] x86: itss: Tidy up bind() for of-platdata-inst Simon Glass
@ 2021-03-17  1:28 ` Simon Glass
  2021-03-17  1:28 ` [PATCH v4 35/42] x86: apl: Fix the header order in pmc Simon Glass
                   ` (34 subsequent siblings)
  83 siblings, 0 replies; 85+ messages in thread
From: Simon Glass @ 2021-03-17  1:28 UTC (permalink / raw)
  To: u-boot

This enum is needed to generate build-time devices. Tell dtoc where to
find the header, to avoid compile errors in the generated code.

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

(no changes since v1)

 arch/x86/cpu/apollolake/punit.c | 1 +
 1 file changed, 1 insertion(+)

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

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

* [PATCH v4 35/42] x86: apl: Fix the header order in pmc
  2021-03-15  4:25 [PATCH v4 00/42] dm: Implement OF_PLATDATA_INST in driver model (part E) Simon Glass
                   ` (48 preceding siblings ...)
  2021-03-17  1:28 ` [PATCH v4 36/42] x86: apl: Tell of-platdata about a required header file Simon Glass
@ 2021-03-17  1:28 ` Simon Glass
  2021-03-17  1:28 ` [PATCH v4 34/42] x86: Define a region for device priv/plat data Simon Glass
                   ` (33 subsequent siblings)
  83 siblings, 0 replies; 85+ messages in thread
From: Simon Glass @ 2021-03-17  1:28 UTC (permalink / raw)
  To: u-boot

The dm.h header should come first. In fact it needs to, since otherwise
the driver model definitions are not available to dt-structs.h

Fix this, since it causes problems with OF_PLATDATA_INST.

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

(no changes since v1)

 arch/x86/cpu/apollolake/pmc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

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

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

* [PATCH v4 34/42] x86: Define a region for device priv/plat data
  2021-03-15  4:25 [PATCH v4 00/42] dm: Implement OF_PLATDATA_INST in driver model (part E) Simon Glass
                   ` (49 preceding siblings ...)
  2021-03-17  1:28 ` [PATCH v4 35/42] x86: apl: Fix the header order in pmc Simon Glass
@ 2021-03-17  1:28 ` Simon Glass
  2021-03-17  1:28 ` [PATCH v4 32/42] dm: doc: Tidy up of-platdata docs Simon Glass
                   ` (32 subsequent siblings)
  83 siblings, 0 replies; 85+ messages in thread
From: Simon Glass @ 2021-03-17  1:28 UTC (permalink / raw)
  To: u-boot

Collect this together in one place, so driver model can access set it up
in a new place if needed.

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

(no changes since v1)

 arch/x86/cpu/u-boot-spl.lds | 8 ++++++++
 1 file changed, 8 insertions(+)

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

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

* [PATCH v4 32/42] dm: doc: Tidy up of-platdata docs
  2021-03-15  4:25 [PATCH v4 00/42] dm: Implement OF_PLATDATA_INST in driver model (part E) Simon Glass
                   ` (50 preceding siblings ...)
  2021-03-17  1:28 ` [PATCH v4 34/42] x86: Define a region for device priv/plat data Simon Glass
@ 2021-03-17  1:28 ` Simon Glass
  2021-03-17  1:28 ` [PATCH v4 33/42] dm: doc: Add documentation for of-platdata-inst Simon Glass
                   ` (31 subsequent siblings)
  83 siblings, 0 replies; 85+ messages in thread
From: Simon Glass @ 2021-03-17  1:28 UTC (permalink / raw)
  To: u-boot

This doc has a few pieces that are out-of-date. Fix these. Also we have
started to use 'devicetree' instead of 'device tree' or 'device-tree'
since it is easier to see as a single term, so replace all ocurrences
accordingly.

Also move the caveats to the end, since this is a fairly solid part of
U-Boot now.

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

(no changes since v3)

Changes in v3:
- Add documentation updates

 doc/driver-model/of-plat.rst | 138 +++++++++++++----------------------
 1 file changed, 52 insertions(+), 86 deletions(-)

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

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

* [PATCH v4 33/42] dm: doc: Add documentation for of-platdata-inst
  2021-03-15  4:25 [PATCH v4 00/42] dm: Implement OF_PLATDATA_INST in driver model (part E) Simon Glass
                   ` (51 preceding siblings ...)
  2021-03-17  1:28 ` [PATCH v4 32/42] dm: doc: Tidy up of-platdata docs Simon Glass
@ 2021-03-17  1:28 ` Simon Glass
  2021-03-17  1:28 ` [PATCH v4 31/42] dm: core: Add warnings to private / platform setters Simon Glass
                   ` (30 subsequent siblings)
  83 siblings, 0 replies; 85+ messages in thread
From: Simon Glass @ 2021-03-17  1:28 UTC (permalink / raw)
  To: u-boot

Add a description of the new features, along with internal technical
documentation.

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

(no changes since v3)

Changes in v3:
- Add documentation for of-platdata-inst

 doc/driver-model/of-plat.rst | 587 +++++++++++++++++++++++++++++++++++
 1 file changed, 587 insertions(+)

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

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

* [PATCH v4 31/42] dm: core: Add warnings to private / platform setters
  2021-03-15  4:25 [PATCH v4 00/42] dm: Implement OF_PLATDATA_INST in driver model (part E) Simon Glass
                   ` (52 preceding siblings ...)
  2021-03-17  1:28 ` [PATCH v4 33/42] dm: doc: Add documentation for of-platdata-inst Simon Glass
@ 2021-03-17  1:28 ` Simon Glass
  2021-03-17  1:28 ` [PATCH v4 30/42] dm: core: Use separate priv/plat data region Simon Glass
                   ` (29 subsequent siblings)
  83 siblings, 0 replies; 85+ messages in thread
From: Simon Glass @ 2021-03-17  1:28 UTC (permalink / raw)
  To: u-boot

Add a warning to each of these functions so that people do not attempt to
use them outside driver model.

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

(no changes since v3)

Changes in v3:
- Aew patch with warnings for private / platform setters

 include/dm/device-internal.h | 18 ++++++++++++++++++
 include/dm/uclass-internal.h |  3 +++
 2 files changed, 21 insertions(+)

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

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

* [PATCH v4 30/42] dm: core: Use separate priv/plat data region
  2021-03-15  4:25 [PATCH v4 00/42] dm: Implement OF_PLATDATA_INST in driver model (part E) Simon Glass
                   ` (53 preceding siblings ...)
  2021-03-17  1:28 ` [PATCH v4 31/42] dm: core: Add warnings to private / platform setters Simon Glass
@ 2021-03-17  1:28 ` Simon Glass
  2021-03-17  1:28 ` [PATCH v4 29/42] sandbox: Define a region for device priv/plat data Simon Glass
                   ` (28 subsequent siblings)
  83 siblings, 0 replies; 85+ messages in thread
From: Simon Glass @ 2021-03-17  1:28 UTC (permalink / raw)
  To: u-boot

Make use of the new priv/plat data region if enabled. This is implemented
as a simple offset from the position set up by dtoc to the new position.

So long as all access goes through dm_priv_to_rw() this is safe.

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

(no changes since v1)

 drivers/core/device.c | 12 ++++++------
 drivers/core/root.c   |  9 +++++++++
 include/dm/util.h     |  9 +++++++++
 3 files changed, 24 insertions(+), 6 deletions(-)

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

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

* [PATCH v4 29/42] sandbox: Define a region for device priv/plat data
  2021-03-15  4:25 [PATCH v4 00/42] dm: Implement OF_PLATDATA_INST in driver model (part E) Simon Glass
                   ` (54 preceding siblings ...)
  2021-03-17  1:28 ` [PATCH v4 30/42] dm: core: Use separate priv/plat data region Simon Glass
@ 2021-03-17  1:28 ` Simon Glass
  2021-03-17  1:28 ` [PATCH v4 28/42] dm: core: Allow storing priv/plat data separately Simon Glass
                   ` (27 subsequent siblings)
  83 siblings, 0 replies; 85+ messages in thread
From: Simon Glass @ 2021-03-17  1:28 UTC (permalink / raw)
  To: u-boot

Collect this together in one place, so driver model can access set it up
in a new place if needed.

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

(no changes since v1)

 arch/sandbox/cpu/u-boot-spl.lds | 8 ++++++++
 1 file changed, 8 insertions(+)

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

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

* [PATCH v4 28/42] dm: core: Allow storing priv/plat data separately
  2021-03-15  4:25 [PATCH v4 00/42] dm: Implement OF_PLATDATA_INST in driver model (part E) Simon Glass
                   ` (55 preceding siblings ...)
  2021-03-17  1:28 ` [PATCH v4 29/42] sandbox: Define a region for device priv/plat data Simon Glass
@ 2021-03-17  1:28 ` Simon Glass
  2021-03-17  1:28 ` [PATCH v4 27/42] dm: core: Move flags to device-runtime info Simon Glass
                   ` (26 subsequent siblings)
  83 siblings, 0 replies; 85+ messages in thread
From: Simon Glass @ 2021-03-17  1:28 UTC (permalink / raw)
  To: u-boot

At present the device priv/data data allocated by dtoc is stored in the
data section along with other variables. On some platforms it is better
to allocate space for it separately, e.g. if SPL is running from read-only
memory.

Create a new space with the same size as that allocated by dtoc, ready for
use.

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

(no changes since v1)

 drivers/core/root.c               | 12 ++++++++++++
 include/asm-generic/global_data.h | 10 ++++++++++
 include/asm-generic/sections.h    |  3 +++
 3 files changed, 25 insertions(+)

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

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

* [PATCH v4 27/42] dm: core: Move flags to device-runtime info
  2021-03-15  4:25 [PATCH v4 00/42] dm: Implement OF_PLATDATA_INST in driver model (part E) Simon Glass
                   ` (56 preceding siblings ...)
  2021-03-17  1:28 ` [PATCH v4 28/42] dm: core: Allow storing priv/plat data separately Simon Glass
@ 2021-03-17  1:28 ` Simon Glass
  2021-03-17  1:28 ` [PATCH v4 26/42] dm: core: Create a struct for device runtime info Simon Glass
                   ` (25 subsequent siblings)
  83 siblings, 0 replies; 85+ messages in thread
From: Simon Glass @ 2021-03-17  1:28 UTC (permalink / raw)
  To: u-boot

When of-platdata-inst is active, use the flags in the new udevice_rt
table, dropping them from the main struct udevice. This ensures that the
latter is not updated at runtime.

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

(no changes since v2)

Changes in v2:
- Leave the flags_ memeber in the same struct position

 drivers/core/device.c | 33 +++++++++++++++++++++++++++++++++
 include/dm/device.h   |  8 ++++++++
 2 files changed, 41 insertions(+)

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

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

* [PATCH v4 26/42] dm: core: Create a struct for device runtime info
  2021-03-15  4:25 [PATCH v4 00/42] dm: Implement OF_PLATDATA_INST in driver model (part E) Simon Glass
                   ` (57 preceding siblings ...)
  2021-03-17  1:28 ` [PATCH v4 27/42] dm: core: Move flags to device-runtime info Simon Glass
@ 2021-03-17  1:28 ` Simon Glass
  2021-03-17  1:28 ` [PATCH v4 25/42] dm: core: Add an option to support SPL in read-only memory Simon Glass
                   ` (24 subsequent siblings)
  83 siblings, 0 replies; 85+ messages in thread
From: Simon Glass @ 2021-03-17  1:28 UTC (permalink / raw)
  To: u-boot

At present when driver model needs to change a device it simply updates
the struct udevice structure. But with of-platdata-inst most of the fields
are not modified at runtime. In fact, typically only the flags need to
change.

For systems running SPL from read-only memory it is convenient to separate
out the runtime information, so that the devices don't need to be copied
before being used.

Create a new udevice_rt table, similar to the existing driver_rt. For now
it just holds the flags, although they are not used in this patch.

Add a new Kconfig for the driver_rt data, since this is not needed when
of-platdata-inst is used.

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

(no changes since v2)

Changes in v2:
- Use separate OF_PLATDATA_DRIVER_RT Kconfigs for driver run-time data
- Update the condition for dm_test_of_plat_dev()

 drivers/core/root.c               | 14 +++++++++++++-
 dts/Kconfig                       | 20 ++++++++++++++++++++
 include/asm-generic/global_data.h | 16 ++++++++++++++--
 include/dm/device.h               | 15 +++++++++++++++
 test/dm/of_platdata.c             |  2 +-
 5 files changed, 63 insertions(+), 4 deletions(-)

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

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

* [PATCH v4 25/42] dm: core: Add an option to support SPL in read-only memory
  2021-03-15  4:25 [PATCH v4 00/42] dm: Implement OF_PLATDATA_INST in driver model (part E) Simon Glass
                   ` (58 preceding siblings ...)
  2021-03-17  1:28 ` [PATCH v4 26/42] dm: core: Create a struct for device runtime info Simon Glass
@ 2021-03-17  1:28 ` Simon Glass
  2021-03-17  1:28 ` [PATCH v4 24/42] azure/gitlab: Add tests for sandbox_noinst Simon Glass
                   ` (23 subsequent siblings)
  83 siblings, 0 replies; 85+ messages in thread
From: Simon Glass @ 2021-03-17  1:28 UTC (permalink / raw)
  To: u-boot

Some systems (e.g. x86 APL) run SPL from read-only memory. The device
instances created by dtoc are therefore not writeable. To make things work
we would need to copy the devices to read/write memory.

To avoid this, add an option to use a separate runtime struct for devices,
just as is done for drivers. This can be used to hold information that
changes at runtime, avoiding the need for a copy.

Also add a Kconfig option for read-only SPL, which selects this feature.

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

(no changes since v1)

 common/spl/Kconfig | 24 ++++++++++++++++++++++++
 dts/Kconfig        | 22 ++++++++++++++++++++++
 2 files changed, 46 insertions(+)

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

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

* [PATCH v4 24/42] azure/gitlab: Add tests for sandbox_noinst
  2021-03-15  4:25 [PATCH v4 00/42] dm: Implement OF_PLATDATA_INST in driver model (part E) Simon Glass
                   ` (59 preceding siblings ...)
  2021-03-17  1:28 ` [PATCH v4 25/42] dm: core: Add an option to support SPL in read-only memory Simon Glass
@ 2021-03-17  1:28 ` Simon Glass
  2021-03-17  1:28 ` [PATCH v4 23/42] test: Run sandbox_spl tests on sandbox_noinst Simon Glass
                   ` (22 subsequent siblings)
  83 siblings, 0 replies; 85+ messages in thread
From: Simon Glass @ 2021-03-17  1:28 UTC (permalink / raw)
  To: u-boot

Add this new board to the test plans. Travis-CI is left out, since it is
being removed soon due to lack of capacity.

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

(no changes since v1)

 .azure-pipelines.yml |  3 +++
 .gitlab-ci.yml       | 10 +++++++++-
 2 files changed, 12 insertions(+), 1 deletion(-)

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

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

* [PATCH v4 23/42] test: Run sandbox_spl tests on sandbox_noinst
  2021-03-15  4:25 [PATCH v4 00/42] dm: Implement OF_PLATDATA_INST in driver model (part E) Simon Glass
                   ` (60 preceding siblings ...)
  2021-03-17  1:28 ` [PATCH v4 24/42] azure/gitlab: Add tests for sandbox_noinst Simon Glass
@ 2021-03-17  1:28 ` Simon Glass
  2021-03-17  1:28 ` [PATCH v4 22/42] sandbox: Create a new sandbox_noinst build Simon Glass
                   ` (21 subsequent siblings)
  83 siblings, 0 replies; 85+ messages in thread
From: Simon Glass @ 2021-03-17  1:28 UTC (permalink / raw)
  To: u-boot

Run the tests on this build too, to prevent regressions.

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

(no changes since v1)

 test/run | 4 ++++
 1 file changed, 4 insertions(+)

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

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

* [PATCH v4 22/42] sandbox: Create a new sandbox_noinst build
  2021-03-15  4:25 [PATCH v4 00/42] dm: Implement OF_PLATDATA_INST in driver model (part E) Simon Glass
                   ` (61 preceding siblings ...)
  2021-03-17  1:28 ` [PATCH v4 23/42] test: Run sandbox_spl tests on sandbox_noinst Simon Glass
@ 2021-03-17  1:28 ` Simon Glass
  2021-03-17  1:28 ` [PATCH v4 21/42] Revert "sandbox: Disable I2C emulators in SPL" Simon Glass
                   ` (20 subsequent siblings)
  83 siblings, 0 replies; 85+ messages in thread
From: Simon Glass @ 2021-03-17  1:28 UTC (permalink / raw)
  To: u-boot

Move sandbox_spl over to use OF_PLATDATA_INST. Create a new board to
test the case when this is not enabled, since we will be keeping that
code around for several months and want to avoid regressions.

Skip the dm_test_of_plat_dev() test since driver info is not available
for OF_PLATDATA_INST.

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

(no changes since v1)

 board/sandbox/MAINTAINERS        |   7 +
 configs/sandbox_noinst_defconfig | 231 +++++++++++++++++++++++++++++++
 configs/sandbox_spl_defconfig    |   1 +
 test/dm/of_platdata.c            |   4 +
 4 files changed, 243 insertions(+)
 create mode 100644 configs/sandbox_noinst_defconfig

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

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

* [PATCH v4 21/42] Revert "sandbox: Disable I2C emulators in SPL"
  2021-03-15  4:25 [PATCH v4 00/42] dm: Implement OF_PLATDATA_INST in driver model (part E) Simon Glass
                   ` (62 preceding siblings ...)
  2021-03-17  1:28 ` [PATCH v4 22/42] sandbox: Create a new sandbox_noinst build Simon Glass
@ 2021-03-17  1:28 ` Simon Glass
  2021-03-17  1:28 ` [PATCH v4 20/42] sandbox: i2c: Support i2c emulation with of-platdata Simon Glass
                   ` (19 subsequent siblings)
  83 siblings, 0 replies; 85+ messages in thread
From: Simon Glass @ 2021-03-17  1:28 UTC (permalink / raw)
  To: u-boot

With recent changes this can be supported again. Add it back.

This reverts commit d85f2c4f2970d0ec2f5f075de734afd11200d153.

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

(no changes since v1)

 arch/sandbox/dts/sandbox.dtsi | 10 +++-------
 configs/sandbox_spl_defconfig |  1 +
 drivers/i2c/Makefile          |  2 --
 test/dm/of_platdata.c         |  8 ++++----
 4 files changed, 8 insertions(+), 13 deletions(-)

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

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

* [PATCH v4 20/42] sandbox: i2c: Support i2c emulation with of-platdata
  2021-03-15  4:25 [PATCH v4 00/42] dm: Implement OF_PLATDATA_INST in driver model (part E) Simon Glass
                   ` (63 preceding siblings ...)
  2021-03-17  1:28 ` [PATCH v4 21/42] Revert "sandbox: Disable I2C emulators in SPL" Simon Glass
@ 2021-03-17  1:28 ` Simon Glass
  2021-03-17  1:28 ` [PATCH v4 19/42] sandbox_spl: Increase SPL malloc() size Simon Glass
                   ` (18 subsequent siblings)
  83 siblings, 0 replies; 85+ messages in thread
From: Simon Glass @ 2021-03-17  1:28 UTC (permalink / raw)
  To: u-boot

At present the i2c emulators require access to the devicetree, which is
not possible (by design) with of-platdata.

Add a way for drivers to record the of-platdata index of their emulator,
so that we can still find the emulator.

This allows i2c emulation to work with of-platdata.

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

(no changes since v1)

 drivers/i2c/i2c-emul-uclass.c | 17 +++++++++++++++--
 drivers/rtc/sandbox_rtc.c     | 13 +++++++++++++
 include/i2c.h                 | 15 +++++++++++++++
 3 files changed, 43 insertions(+), 2 deletions(-)

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

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

* [PATCH v4 19/42] sandbox_spl: Increase SPL malloc() size
  2021-03-15  4:25 [PATCH v4 00/42] dm: Implement OF_PLATDATA_INST in driver model (part E) Simon Glass
                   ` (64 preceding siblings ...)
  2021-03-17  1:28 ` [PATCH v4 20/42] sandbox: i2c: Support i2c emulation with of-platdata Simon Glass
@ 2021-03-17  1:28 ` Simon Glass
  2021-03-17  1:28 ` [PATCH v4 18/42] dm: Rename device_get_by_driver_info_idx() Simon Glass
                   ` (17 subsequent siblings)
  83 siblings, 0 replies; 85+ messages in thread
From: Simon Glass @ 2021-03-17  1:28 UTC (permalink / raw)
  To: u-boot

The test framework reinits driver model tests before running each test.
Since malloc_simple does not support free(), this eventually runs out of
memory.

Fix it for now by increasing the space to 32KB.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
---

(no changes since v1)

 configs/sandbox_spl_defconfig | 1 +
 1 file changed, 1 insertion(+)

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

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

* [PATCH v4 18/42] dm: Rename device_get_by_driver_info_idx()
  2021-03-15  4:25 [PATCH v4 00/42] dm: Implement OF_PLATDATA_INST in driver model (part E) Simon Glass
                   ` (65 preceding siblings ...)
  2021-03-17  1:28 ` [PATCH v4 19/42] sandbox_spl: Increase SPL malloc() size Simon Glass
@ 2021-03-17  1:28 ` Simon Glass
  2021-03-17  1:28 ` [PATCH v4 17/42] sandbox: i2c: Move platdata structs to header files Simon Glass
                   ` (16 subsequent siblings)
  83 siblings, 0 replies; 85+ messages in thread
From: Simon Glass @ 2021-03-17  1:28 UTC (permalink / raw)
  To: u-boot

This function finds a device by its driver_info index. With
of-platdata-inst we do not use driver_info, but instead instantiate
udevice records at build-time.

However the semantics of using the function are the same in each case:
the caller provides an index and gets back a device.

So rename the function to device_get_by_ofplat_idx(), so that it can be
used for both situations. The caller does not really need to worry about
the details.

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

(no changes since v1)

 drivers/clk/clk-uclass.c    |  2 +-
 drivers/core/device.c       | 13 ++++++++++---
 drivers/misc/irq-uclass.c   |  2 +-
 drivers/mmc/fsl_esdhc_imx.c |  3 +--
 include/dm/device.h         | 16 +++++++++++-----
 test/dm/of_platdata.c       | 15 +++++++--------
 6 files changed, 31 insertions(+), 20 deletions(-)

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

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

* [PATCH v4 17/42] sandbox: i2c: Move platdata structs to header files
  2021-03-15  4:25 [PATCH v4 00/42] dm: Implement OF_PLATDATA_INST in driver model (part E) Simon Glass
                   ` (66 preceding siblings ...)
  2021-03-17  1:28 ` [PATCH v4 18/42] dm: Rename device_get_by_driver_info_idx() Simon Glass
@ 2021-03-17  1:28 ` Simon Glass
  2021-03-17  1:28 ` [PATCH v4 16/42] dm: core: Drop uclass_find_device_by_phandle() with of-platdata Simon Glass
                   ` (15 subsequent siblings)
  83 siblings, 0 replies; 85+ messages in thread
From: Simon Glass @ 2021-03-17  1:28 UTC (permalink / raw)
  To: u-boot

At present the structs used by these drivers are declared in the C files
and so are not accessible to dtoc. Move them to header files, as required.

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

(no changes since v1)

 arch/sandbox/include/asm/i2c.h | 15 +++++++++++++++
 arch/sandbox/include/asm/rtc.h | 24 ++++++++++++++++++++++++
 drivers/i2c/i2c-emul-uclass.c  | 13 +------------
 drivers/rtc/i2c_rtc_emul.c     | 19 -------------------
 4 files changed, 40 insertions(+), 31 deletions(-)

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

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

* [PATCH v4 16/42] dm: core: Drop uclass_find_device_by_phandle() with of-platdata
  2021-03-15  4:25 [PATCH v4 00/42] dm: Implement OF_PLATDATA_INST in driver model (part E) Simon Glass
                   ` (67 preceding siblings ...)
  2021-03-17  1:28 ` [PATCH v4 17/42] sandbox: i2c: Move platdata structs to header files Simon Glass
@ 2021-03-17  1:28 ` Simon Glass
  2021-03-17  1:28 ` [PATCH v4 15/42] dm: core: Drop device_get_by_driver_info() Simon Glass
                   ` (14 subsequent siblings)
  83 siblings, 0 replies; 85+ messages in thread
From: Simon Glass @ 2021-03-17  1:28 UTC (permalink / raw)
  To: u-boot

At present this function is included in the build but with of-platdata it
only services to produce a confusing link error complaining about a call
to dev_read_u32_default().

Drop it so that any call to uclass_find_device_by_phandle() is flagged as
an error, making it easier to see what is going on.

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

(no changes since v1)

 drivers/core/uclass.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

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

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

* [PATCH v4 15/42] dm: core: Drop device_get_by_driver_info()
  2021-03-15  4:25 [PATCH v4 00/42] dm: Implement OF_PLATDATA_INST in driver model (part E) Simon Glass
                   ` (68 preceding siblings ...)
  2021-03-17  1:28 ` [PATCH v4 16/42] dm: core: Drop uclass_find_device_by_phandle() with of-platdata Simon Glass
@ 2021-03-17  1:28 ` Simon Glass
  2021-03-17  1:28 ` [PATCH v4 14/42] clk: sandbox: Create a special fixed-rate driver Simon Glass
                   ` (13 subsequent siblings)
  83 siblings, 0 replies; 85+ messages in thread
From: Simon Glass @ 2021-03-17  1:28 UTC (permalink / raw)
  To: u-boot

This function is now only used in a test. Drop it. Also drop
DM_DRVINFO_GET() which was the only purpose for having the function.

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

(no changes since v3)

Changes in v3:
- Drop DM_DRVINFO_GET() also

 drivers/core/device.c | 15 ---------------
 include/dm/device.h   | 15 ---------------
 include/dm/platdata.h | 15 ---------------
 test/dm/of_platdata.c |  7 ++-----
 4 files changed, 2 insertions(+), 50 deletions(-)

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

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

* [PATCH v4 14/42] clk: sandbox: Create a special fixed-rate driver
  2021-03-15  4:25 [PATCH v4 00/42] dm: Implement OF_PLATDATA_INST in driver model (part E) Simon Glass
                   ` (69 preceding siblings ...)
  2021-03-17  1:28 ` [PATCH v4 15/42] dm: core: Drop device_get_by_driver_info() Simon Glass
@ 2021-03-17  1:28 ` Simon Glass
  2021-03-17  1:28 ` [PATCH v4 13/42] clk: fixed-rate: Export driver parts for OF_PLATDATA_INST Simon Glass
                   ` (12 subsequent siblings)
  83 siblings, 0 replies; 85+ messages in thread
From: Simon Glass @ 2021-03-17  1:28 UTC (permalink / raw)
  To: u-boot

Create a version of this driver for sandbox so that it can use the
of-platdata struct.

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

(no changes since v1)

 arch/sandbox/dts/sandbox.dtsi  |  2 +-
 arch/sandbox/include/asm/clk.h |  8 ++++++++
 drivers/clk/clk_sandbox.c      | 33 +++++++++++++++++++++++++++++++++
 test/dm/of_platdata.c          |  2 +-
 4 files changed, 43 insertions(+), 2 deletions(-)

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

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

* [PATCH v4 13/42] clk: fixed-rate: Export driver parts for OF_PLATDATA_INST
  2021-03-15  4:25 [PATCH v4 00/42] dm: Implement OF_PLATDATA_INST in driver model (part E) Simon Glass
                   ` (70 preceding siblings ...)
  2021-03-17  1:28 ` [PATCH v4 14/42] clk: sandbox: Create a special fixed-rate driver Simon Glass
@ 2021-03-17  1:28 ` Simon Glass
  2021-03-17  1:28 ` [PATCH v4 12/42] clk: sandbox: Move priv/plat data to a header file Simon Glass
                   ` (11 subsequent siblings)
  83 siblings, 0 replies; 85+ messages in thread
From: Simon Glass @ 2021-03-17  1:28 UTC (permalink / raw)
  To: u-boot

We need to allow SoCs to create their own drivers for this so that they
can use their own of-platdata structs. To minimise code duplication,
export the driver operations and the ofdata_to_plat() setup function.

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

(no changes since v1)

 drivers/clk/clk_fixed_rate.c | 14 ++++++++++----
 include/linux/clk-provider.h |  5 +++++
 2 files changed, 15 insertions(+), 4 deletions(-)

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

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

* [PATCH v4 12/42] clk: sandbox: Move priv/plat data to a header file
  2021-03-15  4:25 [PATCH v4 00/42] dm: Implement OF_PLATDATA_INST in driver model (part E) Simon Glass
                   ` (71 preceding siblings ...)
  2021-03-17  1:28 ` [PATCH v4 13/42] clk: fixed-rate: Export driver parts for OF_PLATDATA_INST Simon Glass
@ 2021-03-17  1:28 ` Simon Glass
  2021-03-17  1:28 ` [PATCH v4 11/42] dm: test: Avoid destroying uclasses with of-platdata-inst Simon Glass
                   ` (10 subsequent siblings)
  83 siblings, 0 replies; 85+ messages in thread
From: Simon Glass @ 2021-03-17  1:28 UTC (permalink / raw)
  To: u-boot

At present the structs used by this driver are not accessible outside it,
so cannot be used with OF_PLATDATA_INST. Move them to a header file to
fix this.

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

(no changes since v1)

 arch/sandbox/include/asm/clk.h | 16 ++++++++++++++++
 drivers/clk/clk_sandbox.c      |  7 -------
 drivers/clk/clk_sandbox_test.c |  6 ------
 3 files changed, 16 insertions(+), 13 deletions(-)

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

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

* [PATCH v4 11/42] dm: test: Avoid destroying uclasses with of-platdata-inst
  2021-03-15  4:25 [PATCH v4 00/42] dm: Implement OF_PLATDATA_INST in driver model (part E) Simon Glass
                   ` (72 preceding siblings ...)
  2021-03-17  1:28 ` [PATCH v4 12/42] clk: sandbox: Move priv/plat data to a header file Simon Glass
@ 2021-03-17  1:28 ` Simon Glass
  2021-03-17  1:28 ` [PATCH v4 10/42] dm: core: Include dt-decl.h automatically Simon Glass
                   ` (9 subsequent siblings)
  83 siblings, 0 replies; 85+ messages in thread
From: Simon Glass @ 2021-03-17  1:28 UTC (permalink / raw)
  To: u-boot

It is not possible to destroy the uclasses when they are created at
build time. Skip this step so that SPL test can complete successfully.

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

(no changes since v2)

Changes in v2:
- Update to deal with test refactoring series

 test/test-main.c | 30 +++++++++++++++++++-----------
 1 file changed, 19 insertions(+), 11 deletions(-)

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

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

* [PATCH v4 10/42] dm: core: Include dt-decl.h automatically
  2021-03-15  4:25 [PATCH v4 00/42] dm: Implement OF_PLATDATA_INST in driver model (part E) Simon Glass
                   ` (73 preceding siblings ...)
  2021-03-17  1:28 ` [PATCH v4 11/42] dm: test: Avoid destroying uclasses with of-platdata-inst Simon Glass
@ 2021-03-17  1:28 ` Simon Glass
  2021-03-17  1:28 ` [PATCH v4 09/42] dm: Add the new dtoc-generated files to the build Simon Glass
                   ` (8 subsequent siblings)
  83 siblings, 0 replies; 85+ messages in thread
From: Simon Glass @ 2021-03-17  1:28 UTC (permalink / raw)
  To: u-boot

When dt-structs.h is used, include the dt-decl.h header as well, so that
these declarations are available.

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

(no changes since v1)

 include/dt-structs.h | 2 ++
 1 file changed, 2 insertions(+)

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

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

* [PATCH v4 09/42] dm: Add the new dtoc-generated files to the build
  2021-03-15  4:25 [PATCH v4 00/42] dm: Implement OF_PLATDATA_INST in driver model (part E) Simon Glass
                   ` (74 preceding siblings ...)
  2021-03-17  1:28 ` [PATCH v4 10/42] dm: core: Include dt-decl.h automatically Simon Glass
@ 2021-03-17  1:28 ` Simon Glass
  2021-03-17  1:28 ` [PATCH v4 08/42] dm: core: Skip adding uclasses with OF_PLATDATA_INST Simon Glass
                   ` (7 subsequent siblings)
  83 siblings, 0 replies; 85+ messages in thread
From: Simon Glass @ 2021-03-17  1:28 UTC (permalink / raw)
  To: u-boot

Now that dtoc generates some new C files, add these to the build so that
the instantiated devices and uclasses can be used.

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

(no changes since v1)

 scripts/Makefile.spl | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

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

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

* [PATCH v4 08/42] dm: core: Skip adding uclasses with OF_PLATDATA_INST
  2021-03-15  4:25 [PATCH v4 00/42] dm: Implement OF_PLATDATA_INST in driver model (part E) Simon Glass
                   ` (75 preceding siblings ...)
  2021-03-17  1:28 ` [PATCH v4 09/42] dm: Add the new dtoc-generated files to the build Simon Glass
@ 2021-03-17  1:28 ` Simon Glass
  2021-03-17  1:28 ` [PATCH v4 07/42] dm: core: Set up driver model for OF_PLATDATA_INST Simon Glass
                   ` (6 subsequent siblings)
  83 siblings, 0 replies; 85+ messages in thread
From: Simon Glass @ 2021-03-17  1:28 UTC (permalink / raw)
  To: u-boot

There is no need to ever add new uclasses since these are set up at build
time. Update the code to return an error if this is attempted.

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

(no changes since v1)

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

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

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

* [PATCH v4 07/42] dm: core: Set up driver model for OF_PLATDATA_INST
  2021-03-15  4:25 [PATCH v4 00/42] dm: Implement OF_PLATDATA_INST in driver model (part E) Simon Glass
                   ` (76 preceding siblings ...)
  2021-03-17  1:28 ` [PATCH v4 08/42] dm: core: Skip adding uclasses with OF_PLATDATA_INST Simon Glass
@ 2021-03-17  1:28 ` Simon Glass
  2021-03-17  1:28 ` [PATCH v4 06/42] dm: core: Adjust uclass setup with of-platdata Simon Glass
                   ` (5 subsequent siblings)
  83 siblings, 0 replies; 85+ messages in thread
From: Simon Glass @ 2021-03-17  1:28 UTC (permalink / raw)
  To: u-boot

With this we don't need to scan and bind drivers, not even the root
device. We just need to locate the root device that was set up at build
time, then set our root in global_data to point to it.

Update the code to handle this case.

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

(no changes since v1)

 drivers/core/root.c | 42 ++++++++++++++++++++++++++++++------------
 1 file changed, 30 insertions(+), 12 deletions(-)

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

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

* [PATCH v4 06/42] dm: core: Adjust uclass setup with of-platdata
  2021-03-15  4:25 [PATCH v4 00/42] dm: Implement OF_PLATDATA_INST in driver model (part E) Simon Glass
                   ` (77 preceding siblings ...)
  2021-03-17  1:28 ` [PATCH v4 07/42] dm: core: Set up driver model for OF_PLATDATA_INST Simon Glass
@ 2021-03-17  1:28 ` Simon Glass
  2021-03-17  1:28 ` [PATCH v4 05/42] dm: core: Allow dropping run-time binding of devices Simon Glass
                   ` (4 subsequent siblings)
  83 siblings, 0 replies; 85+ messages in thread
From: Simon Glass @ 2021-03-17  1:28 UTC (permalink / raw)
  To: u-boot

When OF_PLATDATA_INST is enabled we don't need to create the uclass list.
Instead we just need to point to the existing list. Update the code
accordingly.

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

(no changes since v1)

 drivers/core/root.c | 8 ++++++--
 include/dm/root.h   | 3 +++
 2 files changed, 9 insertions(+), 2 deletions(-)

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

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

* [PATCH v4 05/42] dm: core: Allow dropping run-time binding of devices
  2021-03-15  4:25 [PATCH v4 00/42] dm: Implement OF_PLATDATA_INST in driver model (part E) Simon Glass
                   ` (78 preceding siblings ...)
  2021-03-17  1:28 ` [PATCH v4 06/42] dm: core: Adjust uclass setup with of-platdata Simon Glass
@ 2021-03-17  1:28 ` Simon Glass
  2021-03-17  1:28 ` [PATCH v4 04/42] dm: core: Add macros to access the new linker lists Simon Glass
                   ` (3 subsequent siblings)
  83 siblings, 0 replies; 85+ messages in thread
From: Simon Glass @ 2021-03-17  1:28 UTC (permalink / raw)
  To: u-boot

With OF_PLATDATA_INST devices are bound at build time. We should not need
binding of devices at runtime in most cases. However it is inflexible to
absolutely prohibit it, so add an option to control this.

Update the driver model core so that it does not bind devices. Update
device_bind() to return an error if called.

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

(no changes since v3)

Changes in v3:
- Update the commit message to explain OF_PLATDATA_NO_BIND better
- Update OF_PLATDATA_NO_BIND help as well

 drivers/core/device.c | 42 +++++++++++++++++++++++++-----------------
 dts/Kconfig           | 18 ++++++++++++++++++
 2 files changed, 43 insertions(+), 17 deletions(-)

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

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

* [PATCH v4 04/42] dm: core: Add macros to access the new linker lists
  2021-03-15  4:25 [PATCH v4 00/42] dm: Implement OF_PLATDATA_INST in driver model (part E) Simon Glass
                   ` (79 preceding siblings ...)
  2021-03-17  1:28 ` [PATCH v4 05/42] dm: core: Allow dropping run-time binding of devices Simon Glass
@ 2021-03-17  1:28 ` Simon Glass
  2021-03-17  1:29 ` [PATCH v4 03/42] linker_lists: Allow use in data structures Simon Glass
                   ` (2 subsequent siblings)
  83 siblings, 0 replies; 85+ messages in thread
From: Simon Glass @ 2021-03-17  1:28 UTC (permalink / raw)
  To: u-boot

Add macros which work with instantiated devices and uclasses, as created
at build time by dtoc. Include variants that can be used in data
structures.

These are mostly used by dtoc but it is worth documenting them fully for
the occasional case where they might come up in user code.

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

(no changes since v3)

Changes in v3:
- Drop the decl() versions of the macros
- Add full documentation for the macros

 include/dm/device-internal.h | 75 ++++++++++++++++++++++++++++++++++++
 include/dm/device.h          | 22 +++++++++++
 include/dm/uclass-internal.h | 49 +++++++++++++++++++++++
 include/dm/uclass.h          | 31 +++++++++++++++
 include/linker_lists.h       |  4 +-
 5 files changed, 179 insertions(+), 2 deletions(-)

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

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

* [PATCH v4 03/42] linker_lists: Allow use in data structures
  2021-03-15  4:25 [PATCH v4 00/42] dm: Implement OF_PLATDATA_INST in driver model (part E) Simon Glass
                   ` (80 preceding siblings ...)
  2021-03-17  1:28 ` [PATCH v4 04/42] dm: core: Add macros to access the new linker lists Simon Glass
@ 2021-03-17  1:29 ` Simon Glass
  2021-03-17  1:29 ` [PATCH v4 02/42] sandbox: Drop debug message in os_spl_to_uboot() Simon Glass
  2021-03-17  1:29 ` [PATCH v4 01/42] dtoc: Drop use of DECL() macros Simon Glass
  83 siblings, 0 replies; 85+ messages in thread
From: Simon Glass @ 2021-03-17  1:29 UTC (permalink / raw)
  To: u-boot

At present linker lists are designed for use in code. They make use of
statements within expressions ({...}), for example.

It is possible to generate a reference to a linker_list entry that can
be used in data structures, where such features are not permitted. It
requires that the reference first be declared as extern. In other
words the existing macro needs to be split into two parts.

Add new macros to support this.

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

(no changes since v3)

Changes in v3:
- Drop the decl() variant since it is just as easy to use extern

 include/linker_lists.h | 12 ++++++++++++
 1 file changed, 12 insertions(+)

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

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

* [PATCH v4 02/42] sandbox: Drop debug message in os_spl_to_uboot()
  2021-03-15  4:25 [PATCH v4 00/42] dm: Implement OF_PLATDATA_INST in driver model (part E) Simon Glass
                   ` (81 preceding siblings ...)
  2021-03-17  1:29 ` [PATCH v4 03/42] linker_lists: Allow use in data structures Simon Glass
@ 2021-03-17  1:29 ` Simon Glass
  2021-03-17  1:29 ` [PATCH v4 01/42] dtoc: Drop use of DECL() macros Simon Glass
  83 siblings, 0 replies; 85+ messages in thread
From: Simon Glass @ 2021-03-17  1:29 UTC (permalink / raw)
  To: u-boot

This is not needed in normal operation. Drop it.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
---

(no changes since v1)

 arch/sandbox/cpu/os.c | 1 -
 1 file changed, 1 deletion(-)

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

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

* [PATCH v4 01/42] dtoc: Drop use of DECL() macros
  2021-03-15  4:25 [PATCH v4 00/42] dm: Implement OF_PLATDATA_INST in driver model (part E) Simon Glass
                   ` (82 preceding siblings ...)
  2021-03-17  1:29 ` [PATCH v4 02/42] sandbox: Drop debug message in os_spl_to_uboot() Simon Glass
@ 2021-03-17  1:29 ` Simon Glass
  83 siblings, 0 replies; 85+ messages in thread
From: Simon Glass @ 2021-03-17  1:29 UTC (permalink / raw)
  To: u-boot

We can use extern instead, so let's drop these macros. It adds one more
thing to learn about and doesn't make the code any clearer.

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

(no changes since v3)

Changes in v3:
- Add new patch to drop DECL() macros from dtoc (to squash in)

 tools/dtoc/dtb_platdata.py |  8 ++---
 tools/dtoc/test_dtoc.py    | 64 +++++++++++++++++++-------------------
 2 files changed, 36 insertions(+), 36 deletions(-)

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

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

end of thread, other threads:[~2021-03-17  1:29 UTC | newest]

Thread overview: 85+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-15  4:25 [PATCH v4 00/42] dm: Implement OF_PLATDATA_INST in driver model (part E) Simon Glass
2021-03-15  4:25 ` [PATCH v4 01/42] dtoc: Drop use of DECL() macros Simon Glass
2021-03-15  4:25 ` [PATCH v4 02/42] sandbox: Drop debug message in os_spl_to_uboot() Simon Glass
2021-03-15  4:25 ` [PATCH v4 03/42] linker_lists: Allow use in data structures Simon Glass
2021-03-15  4:25 ` [PATCH v4 04/42] dm: core: Add macros to access the new linker lists Simon Glass
2021-03-15  4:25 ` [PATCH v4 05/42] dm: core: Allow dropping run-time binding of devices Simon Glass
2021-03-15  4:25 ` [PATCH v4 06/42] dm: core: Adjust uclass setup with of-platdata Simon Glass
2021-03-15  4:25 ` [PATCH v4 07/42] dm: core: Set up driver model for OF_PLATDATA_INST Simon Glass
2021-03-15  4:25 ` [PATCH v4 08/42] dm: core: Skip adding uclasses with OF_PLATDATA_INST Simon Glass
2021-03-15  4:25 ` [PATCH v4 09/42] dm: Add the new dtoc-generated files to the build Simon Glass
2021-03-15  4:25 ` [PATCH v4 10/42] dm: core: Include dt-decl.h automatically Simon Glass
2021-03-15  4:25 ` [PATCH v4 11/42] dm: test: Avoid destroying uclasses with of-platdata-inst Simon Glass
2021-03-15  4:25 ` [PATCH v4 12/42] clk: sandbox: Move priv/plat data to a header file Simon Glass
2021-03-15  4:25 ` [PATCH v4 13/42] clk: fixed-rate: Export driver parts for OF_PLATDATA_INST Simon Glass
2021-03-15  4:25 ` [PATCH v4 14/42] clk: sandbox: Create a special fixed-rate driver Simon Glass
2021-03-15  4:25 ` [PATCH v4 15/42] dm: core: Drop device_get_by_driver_info() Simon Glass
2021-03-15  4:25 ` [PATCH v4 16/42] dm: core: Drop uclass_find_device_by_phandle() with of-platdata Simon Glass
2021-03-15  4:25 ` [PATCH v4 17/42] sandbox: i2c: Move platdata structs to header files Simon Glass
2021-03-15  4:25 ` [PATCH v4 18/42] dm: Rename device_get_by_driver_info_idx() Simon Glass
2021-03-15  4:25 ` [PATCH v4 19/42] sandbox_spl: Increase SPL malloc() size Simon Glass
2021-03-15  4:25 ` [PATCH v4 20/42] sandbox: i2c: Support i2c emulation with of-platdata Simon Glass
2021-03-15  4:25 ` [PATCH v4 21/42] Revert "sandbox: Disable I2C emulators in SPL" Simon Glass
2021-03-15  4:25 ` [PATCH v4 22/42] sandbox: Create a new sandbox_noinst build Simon Glass
2021-03-15  4:25 ` [PATCH v4 23/42] test: Run sandbox_spl tests on sandbox_noinst Simon Glass
2021-03-15  4:25 ` [PATCH v4 24/42] azure/gitlab: Add tests for sandbox_noinst Simon Glass
2021-03-15  4:25 ` [PATCH v4 25/42] dm: core: Add an option to support SPL in read-only memory Simon Glass
2021-03-15  4:25 ` [PATCH v4 26/42] dm: core: Create a struct for device runtime info Simon Glass
2021-03-15  4:25 ` [PATCH v4 27/42] dm: core: Move flags to device-runtime info Simon Glass
2021-03-15  4:25 ` [PATCH v4 28/42] dm: core: Allow storing priv/plat data separately Simon Glass
2021-03-15  4:25 ` [PATCH v4 29/42] sandbox: Define a region for device priv/plat data Simon Glass
2021-03-15  4:25 ` [PATCH v4 30/42] dm: core: Use separate priv/plat data region Simon Glass
2021-03-15  4:25 ` [PATCH v4 31/42] dm: core: Add warnings to private / platform setters Simon Glass
2021-03-15  4:25 ` [PATCH v4 32/42] dm: doc: Tidy up of-platdata docs Simon Glass
2021-03-15  4:25 ` [PATCH v4 33/42] dm: doc: Add documentation for of-platdata-inst Simon Glass
2021-03-15  4:25 ` [PATCH v4 34/42] x86: Define a region for device priv/plat data Simon Glass
2021-03-15  4:25 ` [PATCH v4 35/42] x86: apl: Fix the header order in pmc Simon Glass
2021-03-15  4:25 ` [PATCH v4 36/42] x86: apl: Tell of-platdata about a required header file Simon Glass
2021-03-15  4:25 ` [PATCH v4 37/42] x86: itss: Tidy up bind() for of-platdata-inst Simon Glass
2021-03-15  4:25 ` [PATCH v4 38/42] x86: Support a fake PCI device with of-platdata-inst Simon Glass
2021-03-15  4:25 ` [PATCH v4 39/42] x86: Don't include reset driver in SPL Simon Glass
2021-03-15  4:25 ` [PATCH v4 40/42] x86: coral: Drop ACPI properties from of-platdata Simon Glass
2021-03-15  4:25 ` [PATCH v4 41/42] x86: coral: Drop TPM and ACPI interrupts from TPL Simon Glass
2021-03-15  4:25 ` [PATCH v4 42/42] x86: apl: Use read-only SPL and new of-platdata Simon Glass
2021-03-17  1:28 ` Simon Glass
2021-03-17  1:28 ` [PATCH v4 41/42] x86: coral: Drop TPM and ACPI interrupts from TPL Simon Glass
2021-03-17  1:28 ` [PATCH v4 39/42] x86: Don't include reset driver in SPL Simon Glass
2021-03-17  1:28 ` [PATCH v4 40/42] x86: coral: Drop ACPI properties from of-platdata Simon Glass
2021-03-17  1:28 ` [PATCH v4 38/42] x86: Support a fake PCI device with of-platdata-inst Simon Glass
2021-03-17  1:28 ` [PATCH v4 37/42] x86: itss: Tidy up bind() for of-platdata-inst Simon Glass
2021-03-17  1:28 ` [PATCH v4 36/42] x86: apl: Tell of-platdata about a required header file Simon Glass
2021-03-17  1:28 ` [PATCH v4 35/42] x86: apl: Fix the header order in pmc Simon Glass
2021-03-17  1:28 ` [PATCH v4 34/42] x86: Define a region for device priv/plat data Simon Glass
2021-03-17  1:28 ` [PATCH v4 32/42] dm: doc: Tidy up of-platdata docs Simon Glass
2021-03-17  1:28 ` [PATCH v4 33/42] dm: doc: Add documentation for of-platdata-inst Simon Glass
2021-03-17  1:28 ` [PATCH v4 31/42] dm: core: Add warnings to private / platform setters Simon Glass
2021-03-17  1:28 ` [PATCH v4 30/42] dm: core: Use separate priv/plat data region Simon Glass
2021-03-17  1:28 ` [PATCH v4 29/42] sandbox: Define a region for device priv/plat data Simon Glass
2021-03-17  1:28 ` [PATCH v4 28/42] dm: core: Allow storing priv/plat data separately Simon Glass
2021-03-17  1:28 ` [PATCH v4 27/42] dm: core: Move flags to device-runtime info Simon Glass
2021-03-17  1:28 ` [PATCH v4 26/42] dm: core: Create a struct for device runtime info Simon Glass
2021-03-17  1:28 ` [PATCH v4 25/42] dm: core: Add an option to support SPL in read-only memory Simon Glass
2021-03-17  1:28 ` [PATCH v4 24/42] azure/gitlab: Add tests for sandbox_noinst Simon Glass
2021-03-17  1:28 ` [PATCH v4 23/42] test: Run sandbox_spl tests on sandbox_noinst Simon Glass
2021-03-17  1:28 ` [PATCH v4 22/42] sandbox: Create a new sandbox_noinst build Simon Glass
2021-03-17  1:28 ` [PATCH v4 21/42] Revert "sandbox: Disable I2C emulators in SPL" Simon Glass
2021-03-17  1:28 ` [PATCH v4 20/42] sandbox: i2c: Support i2c emulation with of-platdata Simon Glass
2021-03-17  1:28 ` [PATCH v4 19/42] sandbox_spl: Increase SPL malloc() size Simon Glass
2021-03-17  1:28 ` [PATCH v4 18/42] dm: Rename device_get_by_driver_info_idx() Simon Glass
2021-03-17  1:28 ` [PATCH v4 17/42] sandbox: i2c: Move platdata structs to header files Simon Glass
2021-03-17  1:28 ` [PATCH v4 16/42] dm: core: Drop uclass_find_device_by_phandle() with of-platdata Simon Glass
2021-03-17  1:28 ` [PATCH v4 15/42] dm: core: Drop device_get_by_driver_info() Simon Glass
2021-03-17  1:28 ` [PATCH v4 14/42] clk: sandbox: Create a special fixed-rate driver Simon Glass
2021-03-17  1:28 ` [PATCH v4 13/42] clk: fixed-rate: Export driver parts for OF_PLATDATA_INST Simon Glass
2021-03-17  1:28 ` [PATCH v4 12/42] clk: sandbox: Move priv/plat data to a header file Simon Glass
2021-03-17  1:28 ` [PATCH v4 11/42] dm: test: Avoid destroying uclasses with of-platdata-inst Simon Glass
2021-03-17  1:28 ` [PATCH v4 10/42] dm: core: Include dt-decl.h automatically Simon Glass
2021-03-17  1:28 ` [PATCH v4 09/42] dm: Add the new dtoc-generated files to the build Simon Glass
2021-03-17  1:28 ` [PATCH v4 08/42] dm: core: Skip adding uclasses with OF_PLATDATA_INST Simon Glass
2021-03-17  1:28 ` [PATCH v4 07/42] dm: core: Set up driver model for OF_PLATDATA_INST Simon Glass
2021-03-17  1:28 ` [PATCH v4 06/42] dm: core: Adjust uclass setup with of-platdata Simon Glass
2021-03-17  1:28 ` [PATCH v4 05/42] dm: core: Allow dropping run-time binding of devices Simon Glass
2021-03-17  1:28 ` [PATCH v4 04/42] dm: core: Add macros to access the new linker lists Simon Glass
2021-03-17  1:29 ` [PATCH v4 03/42] linker_lists: Allow use in data structures Simon Glass
2021-03-17  1:29 ` [PATCH v4 02/42] sandbox: Drop debug message in os_spl_to_uboot() Simon Glass
2021-03-17  1:29 ` [PATCH v4 01/42] dtoc: Drop use of DECL() macros 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.