All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 00/21] dm: core: Support multiple device trees in ofnode
@ 2022-08-31  3:07 Simon Glass
  2022-08-31  3:07 ` [PATCH 01/21] image: Fix BOOTM_STATE values Simon Glass
                   ` (20 more replies)
  0 siblings, 21 replies; 23+ messages in thread
From: Simon Glass @ 2022-08-31  3:07 UTC (permalink / raw)
  To: U-Boot Mailing List
  Cc: Michal Simek, Marek Behún, Kishon Vijay Abraham I, Tom Rini,
	Simon Glass, AKASHI Takahiro, Adrian Fiergolski,
	Alexandru Gagniuc, Alexey Brodkin, Alper Nebi Yasak,
	Andre Przywara, Andrew Davis, Angelo Dureghello, Artem Lapkin,
	Ashok Reddy Soma, Aspeed BMC SW team, Balamanikandan Gunasundar,
	Bin Meng, Chia-Wei Wang, Chunfeng Yun, Daniel Golle,
	Daniel Schwierzeck, Dzmitry Sankouski, Eugeniy Paltsev,
	Ezequiel Garcia, Fabio Estevam, GSS_MTK_Uboot_upstream,
	Harald Seiler, Heiko Schocher, Heiko Thiery, Heinrich Schuchardt,
	Huan Wang, Ilias Apalodimas, Jagan Teki, Jan Kiszka, Jason Liu,
	Jens Wiklander, Joe Hershberger, Joel Stanley,
	Jérôme Carretero, Leo, Ley Foon Tan, Lokesh Vutla,
	Lukasz Majewski, Mamta Shukla, Marek Vasut, Max Filippov,
	Michael Trimarchi, NXP i.MX U-Boot Team, Nobuhiro Iwamatsu,
	Oleksandr Suvorov, Ovidiu Panait, Ovidiu Panait, Pali Rohár,
	Patrick Delaunay, Pavel Herrmann, Peng Fan, Peter Hoyes,
	Philippe Reynes, Rasmus Villemoes, Ricardo Salveti, Rick Chen,
	Ryan Chen, Ryder Lee, Samuel Holland, Sean Anderson,
	Simon Goldschmidt, Stefan Eichenberger, Stefan Roese,
	Stefano Babic, Thomas Chou, Thomas Haemmerle, Thomas Huth,
	Tien Fong Chee, Vaishnav Achath, Vignesh Raghavendra,
	Vitaly Andrianov, Weijie Gao, Wolfgang Denk, uboot-snps-arc

At present the ofnode interface is somewhat limited, in that it cannot
access the device tree provided by the OS, only the one used by U-Boot
itself (assuming these are separate). This prevents using ofnode functions
to handle device tree fixups, i.e. ft_board_setup() and the like.

The ofnode interface was introduced to allow a consistent API to access
the device tree, whether a flat tree or a live tree (OF_LIVE) is in use.

With the flat tree, adding nodes and properties at the start of the tree
(as often happens when writing to the /chosen node) requires copying a
lot of data for each operation. With live tree, such operations are
quite a bit faster, since there is no memory copying required. This has to
be weighed against the required memory allocation with OF_LIVE, as well
as the cost of unflattening and flattening the device tree which U-Boot
is running.

This series enables support for access to multiple device trees with the
ofnode interface. This is already available to some extent with OF_LIVE,
but some of the ofnode functions need changes to allow the tree to be
specified.

The mechanism works by using the top 1-4 bits of the device tree offset.
The sign bit is not affected, since negative values must be supported.

With this implemented, it becomes possible to use the ofnode interface
to do device tree fixups. The only current user is the EVT_FT_FIXUP
event.

This has two main benefits:

- ofnode can now be used everywhere, in preference to the libfdt calls
- live tree can eventually be used everywhere, with potential speed
  improvements when larger number of fixups are used

This series is only a step along the way. Firstly, while it is possible
to access the 'fix-up' tree using OF_LIVE, most of the fixup functions use
flat tree directly, rather than the ofnode interface. These need to be
updated. Also the tree must be flattened again before it is passed to the
OS. This is not currently implemented.

With OFNODE_MULTI_TREE disabled this has almost no effect on code size:
around 4 bytes if EVENT is enabled, 0 if not. With the feature enabled,
the increase is around 500 bytes, e.g. on venice2:

buildman -b ofn venice2   -sS --step 0
Summary of 2 commits for 1 boards (1 thread, 64 jobs per thread)
01: image: Drop some other #ifdefs in image-board.c
       arm:  w+   venice2
23: dm: core: Add the ofnode multi-tree implementation
24: wip
       arm: (for 1/1 boards) all +580.0 text +580.0

This size increase is not too bad, considering the extra functionality,
but is too large to enable everywhere. So for now this features needs to
be opt-in only, based on EVENT.


Simon Glass (21):
  image: Fix BOOTM_STATE values
  treewide: Drop bootm_headers_t typedef
  treewide: Drop image_info_t typedef
  treewide: Drop image_header_t typedef
  event: Fix a typo in the EVENT help
  dm: core: Pass a root node to of_find_node_by_phandle()
  event: Pass the images to EVT_FT_FIXUP
  dm: core: Allow adding ofnode subnodes
  dm: core: Support writing a property to an empty node
  dm: core: Drop the const from ofnode
  test: Make a copy of the device tree before running a test
  test: Detect a change in the device tree
  test: Drop the UT_TESTF_LIVE_OR_FLAT flag
  dm: core: Provide a way to reset the device tree
  dm: core: Add an ofnode function to obtain the flat tree
  dm: core: Add ofnode functions to obtain an oftree
  dm: core: Add a way to look up a phandle in an oftree
  dm: core: Allow obtaining a node offset in the same tree
  dm: core: Add definitions for multiple ofnode trees
  dm: core: Reduce code size with dev_of_offset()
  dm: core: Add the ofnode multi-tree implementation

 arch/arc/lib/bootm.c                   |   8 +-
 arch/arm/lib/bootm.c                   |  13 +-
 arch/arm/mach-aspeed/ast2600/spl.c     |   4 +-
 arch/arm/mach-imx/hab.c                |   2 +-
 arch/arm/mach-imx/spl_imx_romapi.c     |   6 +-
 arch/arm/mach-k3/common.c              |   2 +-
 arch/arm/mach-k3/sysfw-loader.c        |   6 +-
 arch/arm/mach-keystone/cmd_mon.c       |   6 +-
 arch/arm/mach-socfpga/board.c          |   2 +-
 arch/arm/mach-sunxi/spl_spi_sunxi.c    |   4 +-
 arch/m68k/lib/bootm.c                  |   2 +-
 arch/microblaze/lib/bootm.c            |   6 +-
 arch/mips/lib/bootm.c                  |  16 +-
 arch/mips/mach-jz47xx/jz4780/jz4780.c  |   6 +-
 arch/mips/mach-mtmips/mt7621/spl/spl.c |   4 +-
 arch/mips/mach-mtmips/mt7621/tpl/tpl.c |   4 +-
 arch/nios2/lib/bootm.c                 |   2 +-
 arch/powerpc/lib/bootm.c               |  16 +-
 arch/riscv/lib/bootm.c                 |   8 +-
 arch/sandbox/lib/bootm.c               |   2 +-
 arch/sh/lib/bootm.c                    |   2 +-
 arch/x86/lib/bootm.c                   |   8 +-
 arch/xtensa/lib/bootm.c                |   2 +-
 board/synopsys/hsdk/hsdk.c             |   2 +-
 board/ti/ks2_evm/board.c               |   4 +-
 boot/boot_fit.c                        |   4 +-
 boot/bootm.c                           |  26 +--
 boot/bootm_os.c                        |  35 ++--
 boot/image-android.c                   |   6 +-
 boot/image-board.c                     |  26 +--
 boot/image-fdt.c                       |  13 +-
 boot/image-fit.c                       |  16 +-
 boot/image.c                           |  14 +-
 cmd/bootefi.c                          |   2 +-
 cmd/booti.c                            |   2 +-
 cmd/bootm.c                            |   4 +-
 cmd/bootz.c                            |   2 +-
 cmd/disk.c                             |   4 +-
 cmd/fpga.c                             |   2 +-
 cmd/nand.c                             |   4 +-
 cmd/source.c                           |   2 +-
 cmd/ximg.c                             |   4 +-
 common/Kconfig                         |   2 +-
 common/board_r.c                       |   2 +
 common/spl/spl.c                       |  10 +-
 common/spl/spl_ext.c                   |   4 +-
 common/spl/spl_fat.c                   |   6 +-
 common/spl/spl_legacy.c                |   8 +-
 common/spl/spl_mmc.c                   |   4 +-
 common/spl/spl_nand.c                  |   4 +-
 common/spl/spl_net.c                   |   2 +-
 common/spl/spl_nor.c                   |   8 +-
 common/spl/spl_onenand.c               |   2 +-
 common/spl/spl_ram.c                   |   8 +-
 common/spl/spl_sata.c                  |   2 +-
 common/spl/spl_semihosting.c           |   4 +-
 common/spl/spl_spi.c                   |   6 +-
 common/spl/spl_ubi.c                   |   4 +-
 common/spl/spl_xip.c                   |   2 +-
 common/spl/spl_ymodem.c                |  14 +-
 common/splash_source.c                 |   6 +-
 doc/develop/driver-model/livetree.rst  |  30 ++-
 doc/uImage.FIT/source_file_format.txt  |   2 +-
 drivers/core/Kconfig                   |  24 +++
 drivers/core/fdtaddr.c                 |  18 +-
 drivers/core/of_access.c               |  65 +++++-
 drivers/core/ofnode.c                  | 263 ++++++++++++++++++++-----
 drivers/fpga/socfpga_arria10.c         |   4 +-
 drivers/usb/gadget/f_sdp.c             |   2 +-
 include/asm-generic/global_data.h      |   4 +
 include/bootm.h                        |   6 +-
 include/configs/uniphier.h             |   2 +-
 include/dm/device.h                    |   6 +-
 include/dm/of_access.h                 |  16 +-
 include/dm/ofnode.h                    | 159 +++++++++++++--
 include/dm/ofnode_decl.h               |  31 ++-
 include/event.h                        |   2 +
 include/image.h                        | 118 +++++------
 include/spl.h                          |   8 +-
 include/tee/optee.h                    |   4 +-
 include/test/test.h                    |   8 +-
 lib/efi_loader/efi_dt_fixup.c          |   2 +-
 lib/fdtdec.c                           |   5 +-
 test/dm/ofnode.c                       |  30 ++-
 test/image/spl_load.c                  |   4 +-
 test/test-main.c                       |  89 ++++++++-
 tools/binman/ftest.py                  |   4 +-
 tools/default_image.c                  |  31 ++-
 tools/fit_image.c                      |   4 +-
 tools/imx8mimage.c                     |   8 +-
 tools/mkimage.c                        |   2 +-
 tools/mtk_image.c                      |  10 +-
 92 files changed, 951 insertions(+), 411 deletions(-)

-- 
2.37.2.672.g94769d06f0-goog


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

* [PATCH 01/21] image: Fix BOOTM_STATE values
  2022-08-31  3:07 [PATCH 00/21] dm: core: Support multiple device trees in ofnode Simon Glass
@ 2022-08-31  3:07 ` Simon Glass
  2022-08-31  3:07 ` [PATCH 02/21] treewide: Drop bootm_headers_t typedef Simon Glass
                   ` (19 subsequent siblings)
  20 siblings, 0 replies; 23+ messages in thread
From: Simon Glass @ 2022-08-31  3:07 UTC (permalink / raw)
  To: U-Boot Mailing List
  Cc: Michal Simek, Marek Behún, Kishon Vijay Abraham I, Tom Rini,
	Simon Glass, Alexandru Gagniuc, Andre Przywara,
	Heinrich Schuchardt, Jan Kiszka, Joe Hershberger, Marek Vasut,
	Philippe Reynes

Tidy up the code style for these.

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

 include/image.h | 24 ++++++++++++------------
 1 file changed, 12 insertions(+), 12 deletions(-)

diff --git a/include/image.h b/include/image.h
index a148073113a..5e81fad8774 100644
--- a/include/image.h
+++ b/include/image.h
@@ -341,18 +341,18 @@ typedef struct bootm_headers {
 
 	int		verify;		/* env_get("verify")[0] != 'n' */
 
-#define	BOOTM_STATE_START	(0x00000001)
-#define	BOOTM_STATE_FINDOS	(0x00000002)
-#define	BOOTM_STATE_FINDOTHER	(0x00000004)
-#define	BOOTM_STATE_LOADOS	(0x00000008)
-#define	BOOTM_STATE_RAMDISK	(0x00000010)
-#define	BOOTM_STATE_FDT		(0x00000020)
-#define	BOOTM_STATE_OS_CMDLINE	(0x00000040)
-#define	BOOTM_STATE_OS_BD_T	(0x00000080)
-#define	BOOTM_STATE_OS_PREP	(0x00000100)
-#define	BOOTM_STATE_OS_FAKE_GO	(0x00000200)	/* 'Almost' run the OS */
-#define	BOOTM_STATE_OS_GO	(0x00000400)
-#define	BOOTM_STATE_PRE_LOAD	0x00000800
+#define BOOTM_STATE_START	0x00000001
+#define BOOTM_STATE_FINDOS	0x00000002
+#define BOOTM_STATE_FINDOTHER	0x00000004
+#define BOOTM_STATE_LOADOS	0x00000008
+#define BOOTM_STATE_RAMDISK	0x00000010
+#define BOOTM_STATE_FDT		0x00000020
+#define BOOTM_STATE_OS_CMDLINE	0x00000040
+#define BOOTM_STATE_OS_BD_T	0x00000080
+#define BOOTM_STATE_OS_PREP	0x00000100
+#define BOOTM_STATE_OS_FAKE_GO	0x00000200	/* 'Almost' run the OS */
+#define BOOTM_STATE_OS_GO	0x00000400
+#define BOOTM_STATE_PRE_LOAD	0x00000800
 	int		state;
 
 #if defined(CONFIG_LMB) && !defined(USE_HOSTCC)
-- 
2.37.2.672.g94769d06f0-goog


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

* [PATCH 02/21] treewide: Drop bootm_headers_t typedef
  2022-08-31  3:07 [PATCH 00/21] dm: core: Support multiple device trees in ofnode Simon Glass
  2022-08-31  3:07 ` [PATCH 01/21] image: Fix BOOTM_STATE values Simon Glass
@ 2022-08-31  3:07 ` Simon Glass
  2022-08-31  3:07 ` [PATCH 03/21] treewide: Drop image_info_t typedef Simon Glass
                   ` (18 subsequent siblings)
  20 siblings, 0 replies; 23+ messages in thread
From: Simon Glass @ 2022-08-31  3:07 UTC (permalink / raw)
  To: U-Boot Mailing List
  Cc: Michal Simek, Marek Behún, Kishon Vijay Abraham I, Tom Rini,
	Simon Glass, Alexandru Gagniuc, Alexey Brodkin, Alper Nebi Yasak,
	Andre Przywara, Angelo Dureghello, Artem Lapkin,
	Ashok Reddy Soma, Bin Meng, Chia-Wei Wang, Daniel Golle,
	Daniel Schwierzeck, Eugeniy Paltsev, Heinrich Schuchardt,
	Huan Wang, Ilias Apalodimas, Jan Kiszka, Joel Stanley, Leo,
	Marek Vasut, Max Filippov, Nobuhiro Iwamatsu, Ovidiu Panait,
	Pali Rohár, Peter Hoyes, Philippe Reynes, Ricardo Salveti,
	Rick Chen, Sean Anderson, Simon Goldschmidt, Stefan Roese,
	Thomas Chou, Thomas Huth, Tien Fong Chee, Wolfgang Denk,
	uboot-snps-arc

This is not needed and we should avoid typedefs. Use the struct instead.

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

 arch/arc/lib/bootm.c          |  8 ++++----
 arch/arm/lib/bootm.c          | 13 +++++++------
 arch/arm/mach-k3/common.c     |  2 +-
 arch/arm/mach-socfpga/board.c |  2 +-
 arch/m68k/lib/bootm.c         |  2 +-
 arch/microblaze/lib/bootm.c   |  6 +++---
 arch/mips/lib/bootm.c         | 16 ++++++++--------
 arch/nios2/lib/bootm.c        |  2 +-
 arch/powerpc/lib/bootm.c      | 16 ++++++++--------
 arch/riscv/lib/bootm.c        |  8 ++++----
 arch/sandbox/lib/bootm.c      |  2 +-
 arch/sh/lib/bootm.c           |  2 +-
 arch/x86/lib/bootm.c          |  6 +++---
 arch/xtensa/lib/bootm.c       |  2 +-
 board/synopsys/hsdk/hsdk.c    |  2 +-
 boot/bootm.c                  | 16 ++++++++--------
 boot/bootm_os.c               | 28 +++++++++++++--------------
 boot/image-board.c            | 14 +++++++-------
 boot/image-fdt.c              |  6 +++---
 boot/image-fit.c              | 16 ++++++++--------
 cmd/bootefi.c                 |  2 +-
 cmd/booti.c                   |  2 +-
 cmd/bootz.c                   |  2 +-
 common/spl/spl.c              |  2 +-
 include/bootm.h               |  6 +++---
 include/image.h               | 36 +++++++++++++++++------------------
 lib/efi_loader/efi_dt_fixup.c |  2 +-
 27 files changed, 111 insertions(+), 110 deletions(-)

diff --git a/arch/arc/lib/bootm.c b/arch/arc/lib/bootm.c
index 628addd87ed..07b2c1540d0 100644
--- a/arch/arc/lib/bootm.c
+++ b/arch/arc/lib/bootm.c
@@ -22,10 +22,10 @@ static int cleanup_before_linux(void)
 	return 0;
 }
 
-__weak int board_prep_linux(bootm_headers_t *images) { return 0; }
+__weak int board_prep_linux(struct bootm_headers *images) { return 0; }
 
 /* Subcommand: PREP */
-static int boot_prep_linux(bootm_headers_t *images)
+static int boot_prep_linux(struct bootm_headers *images)
 {
 	int ret;
 
@@ -49,7 +49,7 @@ __weak void board_jump_and_run(ulong entry, int zero, int arch, uint params)
 }
 
 /* Subcommand: GO */
-static void boot_jump_linux(bootm_headers_t *images, int flag)
+static void boot_jump_linux(struct bootm_headers *images, int flag)
 {
 	ulong kernel_entry;
 	unsigned int r0, r2;
@@ -79,7 +79,7 @@ static void boot_jump_linux(bootm_headers_t *images, int flag)
 		board_jump_and_run(kernel_entry, r0, 0, r2);
 }
 
-int do_bootm_linux(int flag, int argc, char *argv[], bootm_headers_t *images)
+int do_bootm_linux(int flag, int argc, char *argv[], struct bootm_headers *images)
 {
 	/* No need for those on ARC */
 	if ((flag & BOOTM_STATE_OS_BD_T) || (flag & BOOTM_STATE_OS_CMDLINE))
diff --git a/arch/arm/lib/bootm.c b/arch/arm/lib/bootm.c
index 9f086f3b904..e414ef82673 100644
--- a/arch/arm/lib/bootm.c
+++ b/arch/arm/lib/bootm.c
@@ -192,10 +192,10 @@ static void do_nonsec_virt_switch(void)
 }
 #endif
 
-__weak void board_prep_linux(bootm_headers_t *images) { }
+__weak void board_prep_linux(struct bootm_headers *images) { }
 
 /* Subcommand: PREP */
-static void boot_prep_linux(bootm_headers_t *images)
+static void boot_prep_linux(struct bootm_headers *images)
 {
 	char *commandline = env_get("bootargs");
 
@@ -288,7 +288,7 @@ static void switch_to_el1(void)
 #endif
 
 /* Subcommand: GO */
-static void boot_jump_linux(bootm_headers_t *images, int flag)
+static void boot_jump_linux(struct bootm_headers *images, int flag)
 {
 #ifdef CONFIG_ARM64
 	void (*kernel_entry)(void *fdt_addr, void *res0, void *res1,
@@ -379,7 +379,7 @@ static void boot_jump_linux(bootm_headers_t *images, int flag)
  * they are called if subcommand is equal 0.
  */
 int do_bootm_linux(int flag, int argc, char *const argv[],
-		   bootm_headers_t *images)
+		   struct bootm_headers *images)
 {
 	/* No need for those on ARM */
 	if (flag & BOOTM_STATE_OS_BD_T || flag & BOOTM_STATE_OS_CMDLINE)
@@ -401,7 +401,7 @@ int do_bootm_linux(int flag, int argc, char *const argv[],
 }
 
 #if defined(CONFIG_BOOTM_VXWORKS)
-void boot_prep_vxworks(bootm_headers_t *images)
+void boot_prep_vxworks(struct bootm_headers *images)
 {
 #if defined(CONFIG_OF_LIBFDT)
 	int off;
@@ -416,7 +416,8 @@ void boot_prep_vxworks(bootm_headers_t *images)
 #endif
 	cleanup_before_linux();
 }
-void boot_jump_vxworks(bootm_headers_t *images)
+
+void boot_jump_vxworks(struct bootm_headers *images)
 {
 #if defined(CONFIG_ARM64) && defined(CONFIG_ARMV8_PSCI)
 	armv8_setup_psci();
diff --git a/arch/arm/mach-k3/common.c b/arch/arm/mach-k3/common.c
index 3962f2800f9..14c37acbce7 100644
--- a/arch/arm/mach-k3/common.c
+++ b/arch/arm/mach-k3/common.c
@@ -493,7 +493,7 @@ bool soc_is_j7200(void)
 }
 
 #ifdef CONFIG_ARM64
-void board_prep_linux(bootm_headers_t *images)
+void board_prep_linux(struct bootm_headers *images)
 {
 	debug("Linux kernel Image start = 0x%lx end = 0x%lx\n",
 	      images->os.start, images->os.end);
diff --git a/arch/arm/mach-socfpga/board.c b/arch/arm/mach-socfpga/board.c
index 72671632220..b49006c6c8a 100644
--- a/arch/arm/mach-socfpga/board.c
+++ b/arch/arm/mach-socfpga/board.c
@@ -114,7 +114,7 @@ void board_fit_image_post_process(const void *fit, int node, void **p_image,
 #endif
 
 #if !IS_ENABLED(CONFIG_SPL_BUILD) && IS_ENABLED(CONFIG_FIT)
-void board_prep_linux(bootm_headers_t *images)
+void board_prep_linux(struct bootm_headers *images)
 {
 	if (!images->fit_uname_cfg) {
 		if (IS_ENABLED(CONFIG_SOCFPGA_SECURE_VAB_AUTH) &&
diff --git a/arch/m68k/lib/bootm.c b/arch/m68k/lib/bootm.c
index 9cade929541..c1c9bdceb50 100644
--- a/arch/m68k/lib/bootm.c
+++ b/arch/m68k/lib/bootm.c
@@ -36,7 +36,7 @@ void arch_lmb_reserve(struct lmb *lmb)
 }
 
 int do_bootm_linux(int flag, int argc, char *const argv[],
-		   bootm_headers_t *images)
+		   struct bootm_headers *images)
 {
 	int ret;
 	struct bd_info  *kbd;
diff --git a/arch/microblaze/lib/bootm.c b/arch/microblaze/lib/bootm.c
index 31b6659cdf7..4a5421497e5 100644
--- a/arch/microblaze/lib/bootm.c
+++ b/arch/microblaze/lib/bootm.c
@@ -37,7 +37,7 @@ void arch_lmb_reserve(struct lmb *lmb)
 	arch_lmb_reserve_generic(lmb, get_sp(), gd->ram_top, 4096);
 }
 
-static void boot_jump_linux(bootm_headers_t *images, int flag)
+static void boot_jump_linux(struct bootm_headers *images, int flag)
 {
 	void (*thekernel)(char *cmdline, ulong rd, ulong dt);
 	ulong dt = (ulong)images->ft_addr;
@@ -71,7 +71,7 @@ static void boot_jump_linux(bootm_headers_t *images, int flag)
 	}
 }
 
-static void boot_prep_linux(bootm_headers_t *images)
+static void boot_prep_linux(struct bootm_headers *images)
 {
 	if (CONFIG_IS_ENABLED(OF_LIBFDT) && CONFIG_IS_ENABLED(LMB) && images->ft_len) {
 		debug("using: FDT\n");
@@ -83,7 +83,7 @@ static void boot_prep_linux(bootm_headers_t *images)
 }
 
 int do_bootm_linux(int flag, int argc, char *const argv[],
-		   bootm_headers_t *images)
+		   struct bootm_headers *images)
 {
 	images->cmdline_start = (ulong)env_get("bootargs");
 
diff --git a/arch/mips/lib/bootm.c b/arch/mips/lib/bootm.c
index cab8da4860c..5fda914e6ba 100644
--- a/arch/mips/lib/bootm.c
+++ b/arch/mips/lib/bootm.c
@@ -71,7 +71,7 @@ static void linux_cmdline_dump(void)
 		debug("   arg %03d: %s\n", i, linux_argv[i]);
 }
 
-static void linux_cmdline_legacy(bootm_headers_t *images)
+static void linux_cmdline_legacy(struct bootm_headers *images)
 {
 	const char *bootargs, *next, *quote;
 
@@ -111,7 +111,7 @@ static void linux_cmdline_legacy(bootm_headers_t *images)
 	}
 }
 
-static void linux_cmdline_append(bootm_headers_t *images)
+static void linux_cmdline_append(struct bootm_headers *images)
 {
 	char buf[24];
 	ulong mem, rd_start, rd_size;
@@ -164,7 +164,7 @@ static void linux_env_set(const char *env_name, const char *env_val)
 	}
 }
 
-static void linux_env_legacy(bootm_headers_t *images)
+static void linux_env_legacy(struct bootm_headers *images)
 {
 	char env_buf[12];
 	const char *cp;
@@ -213,7 +213,7 @@ static void linux_env_legacy(bootm_headers_t *images)
 	}
 }
 
-static int boot_reloc_fdt(bootm_headers_t *images)
+static int boot_reloc_fdt(struct bootm_headers *images)
 {
 	/*
 	 * In case of legacy uImage's, relocation of FDT is already done
@@ -243,7 +243,7 @@ int arch_fixup_fdt(void *blob)
 }
 #endif
 
-static int boot_setup_fdt(bootm_headers_t *images)
+static int boot_setup_fdt(struct bootm_headers *images)
 {
 	images->initrd_start = virt_to_phys((void *)images->initrd_start);
 	images->initrd_end = virt_to_phys((void *)images->initrd_end);
@@ -251,7 +251,7 @@ static int boot_setup_fdt(bootm_headers_t *images)
 		&images->lmb);
 }
 
-static void boot_prep_linux(bootm_headers_t *images)
+static void boot_prep_linux(struct bootm_headers *images)
 {
 	if (CONFIG_IS_ENABLED(MIPS_BOOT_FDT) && images->ft_len) {
 		boot_reloc_fdt(images);
@@ -271,7 +271,7 @@ static void boot_prep_linux(bootm_headers_t *images)
 	}
 }
 
-static void boot_jump_linux(bootm_headers_t *images)
+static void boot_jump_linux(struct bootm_headers *images)
 {
 	typedef void __noreturn (*kernel_entry_t)(int, ulong, ulong, ulong);
 	kernel_entry_t kernel = (kernel_entry_t) images->ep;
@@ -302,7 +302,7 @@ static void boot_jump_linux(bootm_headers_t *images)
 }
 
 int do_bootm_linux(int flag, int argc, char *const argv[],
-		   bootm_headers_t *images)
+		   struct bootm_headers *images)
 {
 	/* No need for those on MIPS */
 	if (flag & BOOTM_STATE_OS_BD_T)
diff --git a/arch/nios2/lib/bootm.c b/arch/nios2/lib/bootm.c
index 3cb59bd9777..06c094d0f1c 100644
--- a/arch/nios2/lib/bootm.c
+++ b/arch/nios2/lib/bootm.c
@@ -17,7 +17,7 @@ DECLARE_GLOBAL_DATA_PTR;
 #define NIOS_MAGIC 0x534f494e /* enable command line and initrd passing */
 
 int do_bootm_linux(int flag, int argc, char *const argv[],
-		   bootm_headers_t *images)
+		   struct bootm_headers *images)
 {
 	void (*kernel)(int, int, int, char *) = (void *)images->ep;
 	char *commandline = env_get("bootargs");
diff --git a/arch/powerpc/lib/bootm.c b/arch/powerpc/lib/bootm.c
index e52aa75703f..8ce4ab3fe39 100644
--- a/arch/powerpc/lib/bootm.c
+++ b/arch/powerpc/lib/bootm.c
@@ -45,7 +45,7 @@ static void set_clocks_in_mhz (struct bd_info *kbd);
 #define CONFIG_SYS_LINUX_LOWMEM_MAX_SIZE	(768*1024*1024)
 #endif
 
-static void boot_jump_linux(bootm_headers_t *images)
+static void boot_jump_linux(struct bootm_headers *images)
 {
 	void	(*kernel)(struct bd_info *, ulong r4, ulong r5, ulong r6,
 			      ulong r7, ulong r8, ulong r9);
@@ -151,7 +151,7 @@ void arch_lmb_reserve(struct lmb *lmb)
 	return ;
 }
 
-static void boot_prep_linux(bootm_headers_t *images)
+static void boot_prep_linux(struct bootm_headers *images)
 {
 #ifdef CONFIG_MP
 	/*
@@ -163,7 +163,7 @@ static void boot_prep_linux(bootm_headers_t *images)
 #endif
 }
 
-static int boot_cmdline_linux(bootm_headers_t *images)
+static int boot_cmdline_linux(struct bootm_headers *images)
 {
 	ulong of_size = images->ft_len;
 	struct lmb *lmb = &images->lmb;
@@ -184,7 +184,7 @@ static int boot_cmdline_linux(bootm_headers_t *images)
 	return ret;
 }
 
-static int boot_bd_t_linux(bootm_headers_t *images)
+static int boot_bd_t_linux(struct bootm_headers *images)
 {
 	ulong of_size = images->ft_len;
 	struct lmb *lmb = &images->lmb;
@@ -205,7 +205,7 @@ static int boot_bd_t_linux(bootm_headers_t *images)
 	return ret;
 }
 
-static int boot_body_linux(bootm_headers_t *images)
+static int boot_body_linux(struct bootm_headers *images)
 {
 	int ret;
 
@@ -224,7 +224,7 @@ static int boot_body_linux(bootm_headers_t *images)
 }
 
 noinline int do_bootm_linux(int flag, int argc, char *const argv[],
-			    bootm_headers_t *images)
+			    struct bootm_headers *images)
 {
 	int	ret;
 
@@ -273,7 +273,7 @@ static void set_clocks_in_mhz (struct bd_info *kbd)
 }
 
 #if defined(CONFIG_BOOTM_VXWORKS)
-void boot_prep_vxworks(bootm_headers_t *images)
+void boot_prep_vxworks(struct bootm_headers *images)
 {
 #if defined(CONFIG_OF_LIBFDT)
 	int off;
@@ -305,7 +305,7 @@ void boot_prep_vxworks(bootm_headers_t *images)
 #endif
 }
 
-void boot_jump_vxworks(bootm_headers_t *images)
+void boot_jump_vxworks(struct bootm_headers *images)
 {
 	/* PowerPC VxWorks boot interface conforms to the ePAPR standard
 	 * general purpuse registers:
diff --git a/arch/riscv/lib/bootm.c b/arch/riscv/lib/bootm.c
index 670d9c9ebcf..f5f8b4c7333 100644
--- a/arch/riscv/lib/bootm.c
+++ b/arch/riscv/lib/bootm.c
@@ -62,7 +62,7 @@ static void announce_and_cleanup(int fake)
 	cleanup_before_linux();
 }
 
-static void boot_prep_linux(bootm_headers_t *images)
+static void boot_prep_linux(struct bootm_headers *images)
 {
 	if (CONFIG_IS_ENABLED(OF_LIBFDT) && CONFIG_IS_ENABLED(LMB) && images->ft_len) {
 		debug("using: FDT\n");
@@ -76,7 +76,7 @@ static void boot_prep_linux(bootm_headers_t *images)
 	}
 }
 
-static void boot_jump_linux(bootm_headers_t *images, int flag)
+static void boot_jump_linux(struct bootm_headers *images, int flag)
 {
 	void (*kernel)(ulong hart, void *dtb);
 	int fake = (flag & BOOTM_STATE_OS_FAKE_GO);
@@ -107,7 +107,7 @@ static void boot_jump_linux(bootm_headers_t *images, int flag)
 }
 
 int do_bootm_linux(int flag, int argc, char *const argv[],
-		   bootm_headers_t *images)
+		   struct bootm_headers *images)
 {
 	/* No need for those on RISC-V */
 	if (flag & BOOTM_STATE_OS_BD_T || flag & BOOTM_STATE_OS_CMDLINE)
@@ -129,7 +129,7 @@ int do_bootm_linux(int flag, int argc, char *const argv[],
 }
 
 int do_bootm_vxworks(int flag, int argc, char *const argv[],
-		     bootm_headers_t *images)
+		     struct bootm_headers *images)
 {
 	return do_bootm_linux(flag, argc, argv, images);
 }
diff --git a/arch/sandbox/lib/bootm.c b/arch/sandbox/lib/bootm.c
index d1d460b84a4..c1742f94de7 100644
--- a/arch/sandbox/lib/bootm.c
+++ b/arch/sandbox/lib/bootm.c
@@ -50,7 +50,7 @@ int bootz_setup(ulong image, ulong *start, ulong *end)
 	return ret;
 }
 
-int do_bootm_linux(int flag, int argc, char *argv[], bootm_headers_t *images)
+int do_bootm_linux(int flag, int argc, char *argv[], struct bootm_headers *images)
 {
 	if (flag & (BOOTM_STATE_OS_GO | BOOTM_STATE_OS_FAKE_GO)) {
 		bootstage_mark(BOOTSTAGE_ID_RUN_OS);
diff --git a/arch/sh/lib/bootm.c b/arch/sh/lib/bootm.c
index 7ea04442b87..a5fad6c46c7 100644
--- a/arch/sh/lib/bootm.c
+++ b/arch/sh/lib/bootm.c
@@ -40,7 +40,7 @@ static unsigned long sh_check_cmd_arg(char *cmdline, char *key, int base)
 }
 
 int do_bootm_linux(int flag, int argc, char *const argv[],
-		   bootm_headers_t *images)
+		   struct bootm_headers *images)
 {
 	/* Linux kernel load address */
 	void (*kernel) (void) = (void (*)(void))images->ep;
diff --git a/arch/x86/lib/bootm.c b/arch/x86/lib/bootm.c
index 1bcdb3e30d2..4fdf1b2365a 100644
--- a/arch/x86/lib/bootm.c
+++ b/arch/x86/lib/bootm.c
@@ -69,7 +69,7 @@ int arch_fixup_memory_node(void *blob)
 #endif
 
 /* Subcommand: PREP */
-static int boot_prep_linux(bootm_headers_t *images)
+static int boot_prep_linux(struct bootm_headers *images)
 {
 	char *cmd_line_dest = NULL;
 	image_header_t *hdr;
@@ -201,7 +201,7 @@ int boot_linux_kernel(ulong setup_base, ulong load_address, bool image_64bit)
 }
 
 /* Subcommand: GO */
-static int boot_jump_linux(bootm_headers_t *images)
+static int boot_jump_linux(struct bootm_headers *images)
 {
 	debug("## Transferring control to Linux (at address %08lx, kernel %08lx) ...\n",
 	      images->ep, images->os.load);
@@ -211,7 +211,7 @@ static int boot_jump_linux(bootm_headers_t *images)
 }
 
 int do_bootm_linux(int flag, int argc, char *const argv[],
-		   bootm_headers_t *images)
+		   struct bootm_headers *images)
 {
 	/* No need for those on x86 */
 	if (flag & BOOTM_STATE_OS_BD_T || flag & BOOTM_STATE_OS_CMDLINE)
diff --git a/arch/xtensa/lib/bootm.c b/arch/xtensa/lib/bootm.c
index 277af181683..fee33928150 100644
--- a/arch/xtensa/lib/bootm.c
+++ b/arch/xtensa/lib/bootm.c
@@ -134,7 +134,7 @@ static struct bp_tag *setup_fdt_tag(struct bp_tag *params, void *fdt_start)
  * Boot Linux.
  */
 
-int do_bootm_linux(int flag, int argc, char *argv[], bootm_headers_t *images)
+int do_bootm_linux(int flag, int argc, char *argv[], struct bootm_headers *images)
 {
 	struct bp_tag *params, *params_start;
 	ulong initrd_start, initrd_end;
diff --git a/board/synopsys/hsdk/hsdk.c b/board/synopsys/hsdk/hsdk.c
index 226fbba6296..4308c7e440a 100644
--- a/board/synopsys/hsdk/hsdk.c
+++ b/board/synopsys/hsdk/hsdk.c
@@ -844,7 +844,7 @@ static int hsdk_go_run(u32 cpu_start_reg)
 	return 0;
 }
 
-int board_prep_linux(bootm_headers_t *images)
+int board_prep_linux(struct bootm_headers *images)
 {
 	int ret, ofst;
 	char mask[15];
diff --git a/boot/bootm.c b/boot/bootm.c
index 86dbfbcfed5..73f7552fe4c 100644
--- a/boot/bootm.c
+++ b/boot/bootm.c
@@ -41,10 +41,10 @@
 
 DECLARE_GLOBAL_DATA_PTR;
 
-bootm_headers_t images;		/* pointers to os/initrd/fdt images */
+struct bootm_headers images;		/* pointers to os/initrd/fdt images */
 
 static const void *boot_get_kernel(struct cmd_tbl *cmdtp, int flag, int argc,
-				   char *const argv[], bootm_headers_t *images,
+				   char *const argv[], struct bootm_headers *images,
 				   ulong *os_data, ulong *os_len);
 
 __weak void board_quiesce_devices(void)
@@ -52,7 +52,7 @@ __weak void board_quiesce_devices(void)
 }
 
 #ifdef CONFIG_LMB
-static void boot_start_lmb(bootm_headers_t *images)
+static void boot_start_lmb(struct bootm_headers *images)
 {
 	ulong		mem_start;
 	phys_size_t	mem_size;
@@ -65,7 +65,7 @@ static void boot_start_lmb(bootm_headers_t *images)
 }
 #else
 #define lmb_reserve(lmb, base, size)
-static inline void boot_start_lmb(bootm_headers_t *images) { }
+static inline void boot_start_lmb(struct bootm_headers *images) { }
 #endif
 
 static int bootm_start(struct cmd_tbl *cmdtp, int flag, int argc,
@@ -397,7 +397,7 @@ static int handle_decomp_error(int comp_type, size_t uncomp_size,
 #endif
 
 #ifndef USE_HOSTCC
-static int bootm_load_os(bootm_headers_t *images, int boot_progress)
+static int bootm_load_os(struct bootm_headers *images, int boot_progress)
 {
 	image_info_t os = images->os;
 	ulong load = os.load;
@@ -688,7 +688,7 @@ int bootm_process_cmdline_env(int flags)
  *	unless the image type is standalone.
  */
 int do_bootm_states(struct cmd_tbl *cmdtp, int flag, int argc,
-		    char *const argv[], int states, bootm_headers_t *images,
+		    char *const argv[], int states, struct bootm_headers *images,
 		    int boot_progress)
 {
 	boot_os_fn *boot_fn;
@@ -878,7 +878,7 @@ static image_header_t *image_get_kernel(ulong img_addr, int verify)
  *     address and length, otherwise NULL
  */
 static const void *boot_get_kernel(struct cmd_tbl *cmdtp, int flag, int argc,
-				   char *const argv[], bootm_headers_t *images,
+				   char *const argv[], struct bootm_headers *images,
 				   ulong *os_data, ulong *os_len)
 {
 #if CONFIG_IS_ENABLED(LEGACY_IMAGE_FORMAT)
@@ -1002,7 +1002,7 @@ static int bootm_host_load_image(const void *fit, int req_image_type,
 {
 	const char *fit_uname_config = NULL;
 	ulong data, len;
-	bootm_headers_t images;
+	struct bootm_headers images;
 	int noffset;
 	ulong load_end, buf_size;
 	uint8_t image_type;
diff --git a/boot/bootm_os.c b/boot/bootm_os.c
index f31820cd07e..bd266e790cd 100644
--- a/boot/bootm_os.c
+++ b/boot/bootm_os.c
@@ -24,7 +24,7 @@
 DECLARE_GLOBAL_DATA_PTR;
 
 static int do_bootm_standalone(int flag, int argc, char *const argv[],
-			       bootm_headers_t *images)
+			       struct bootm_headers *images)
 {
 	int (*appl)(int, char *const[]);
 
@@ -65,7 +65,7 @@ static void __maybe_unused fit_unsupported_reset(const char *msg)
 
 #ifdef CONFIG_BOOTM_NETBSD
 static int do_bootm_netbsd(int flag, int argc, char *const argv[],
-			   bootm_headers_t *images)
+			   struct bootm_headers *images)
 {
 	void (*loader)(struct bd_info *, image_header_t *, char *, char *);
 	image_header_t *os_hdr, *hdr;
@@ -137,7 +137,7 @@ static int do_bootm_netbsd(int flag, int argc, char *const argv[],
 
 #ifdef CONFIG_BOOTM_RTEMS
 static int do_bootm_rtems(int flag, int argc, char *const argv[],
-			  bootm_headers_t *images)
+			  struct bootm_headers *images)
 {
 	void (*entry_point)(struct bd_info *);
 
@@ -170,7 +170,7 @@ static int do_bootm_rtems(int flag, int argc, char *const argv[],
 
 #if defined(CONFIG_BOOTM_OSE)
 static int do_bootm_ose(int flag, int argc, char *const argv[],
-			bootm_headers_t *images)
+			struct bootm_headers *images)
 {
 	void (*entry_point)(void);
 
@@ -203,7 +203,7 @@ static int do_bootm_ose(int flag, int argc, char *const argv[],
 
 #if defined(CONFIG_BOOTM_PLAN9)
 static int do_bootm_plan9(int flag, int argc, char *const argv[],
-			  bootm_headers_t *images)
+			  struct bootm_headers *images)
 {
 	void (*entry_point)(void);
 	char *s;
@@ -252,7 +252,7 @@ static int do_bootm_plan9(int flag, int argc, char *const argv[],
 #if defined(CONFIG_BOOTM_VXWORKS) && \
 	(defined(CONFIG_PPC) || defined(CONFIG_ARM))
 
-static void do_bootvx_fdt(bootm_headers_t *images)
+static void do_bootvx_fdt(struct bootm_headers *images)
 {
 #if defined(CONFIG_OF_LIBFDT)
 	int ret;
@@ -310,7 +310,7 @@ static void do_bootvx_fdt(bootm_headers_t *images)
 }
 
 static int do_bootm_vxworks_legacy(int flag, int argc, char *const argv[],
-				   bootm_headers_t *images)
+				   struct bootm_headers *images)
 {
 	if (flag != BOOTM_STATE_OS_GO)
 		return 0;
@@ -328,7 +328,7 @@ static int do_bootm_vxworks_legacy(int flag, int argc, char *const argv[],
 }
 
 int do_bootm_vxworks(int flag, int argc, char *const argv[],
-		     bootm_headers_t *images)
+		     struct bootm_headers *images)
 {
 	char *bootargs;
 	int pos;
@@ -364,7 +364,7 @@ int do_bootm_vxworks(int flag, int argc, char *const argv[],
 
 #if defined(CONFIG_CMD_ELF)
 static int do_bootm_qnxelf(int flag, int argc, char *const argv[],
-			   bootm_headers_t *images)
+			   struct bootm_headers *images)
 {
 	char *local_args[2];
 	char str[16];
@@ -402,7 +402,7 @@ static int do_bootm_qnxelf(int flag, int argc, char *const argv[],
 
 #ifdef CONFIG_INTEGRITY
 static int do_bootm_integrity(int flag, int argc, char *const argv[],
-			      bootm_headers_t *images)
+			      struct bootm_headers *images)
 {
 	void (*entry_point)(void);
 
@@ -435,7 +435,7 @@ static int do_bootm_integrity(int flag, int argc, char *const argv[],
 
 #ifdef CONFIG_BOOTM_OPENRTOS
 static int do_bootm_openrtos(int flag, int argc, char *const argv[],
-			     bootm_headers_t *images)
+			     struct bootm_headers *images)
 {
 	void (*entry_point)(void);
 
@@ -461,7 +461,7 @@ static int do_bootm_openrtos(int flag, int argc, char *const argv[],
 
 #ifdef CONFIG_BOOTM_OPTEE
 static int do_bootm_tee(int flag, int argc, char *const argv[],
-			bootm_headers_t *images)
+			struct bootm_headers *images)
 {
 	int ret;
 
@@ -489,7 +489,7 @@ static int do_bootm_tee(int flag, int argc, char *const argv[],
 
 #ifdef CONFIG_BOOTM_EFI
 static int do_bootm_efi(int flag, int argc, char *const argv[],
-			bootm_headers_t *images)
+			struct bootm_headers *images)
 {
 	int ret;
 	efi_status_t efi_ret;
@@ -588,7 +588,7 @@ __weak void board_preboot_os(void)
 }
 
 int boot_selected_os(int argc, char *const argv[], int state,
-		     bootm_headers_t *images, boot_os_fn *boot_fn)
+		     struct bootm_headers *images, boot_os_fn *boot_fn)
 {
 	arch_preboot_os();
 	board_preboot_os();
diff --git a/boot/image-board.c b/boot/image-board.c
index 1be0a359aba..b61d64c65f8 100644
--- a/boot/image-board.c
+++ b/boot/image-board.c
@@ -301,7 +301,7 @@ int genimg_get_format(const void *img_addr)
  *     0, no FIT support or no configuration found
  *     1, configuration found
  */
-int genimg_has_config(bootm_headers_t *images)
+int genimg_has_config(struct bootm_headers *images)
 {
 	if (CONFIG_IS_ENABLED(FIT) && images->fit_uname_cfg)
 		return 1;
@@ -320,7 +320,7 @@ int genimg_has_config(bootm_headers_t *images)
  * Return: 0 if OK, -ENOPKG if no ramdisk (but an error should not be reported),
  *	other -ve value on other error
  */
-static int select_ramdisk(bootm_headers_t *images, const char *select, u8 arch,
+static int select_ramdisk(struct bootm_headers *images, const char *select, u8 arch,
 			  ulong *rd_datap, ulong *rd_lenp)
 {
 	const char *fit_uname_config;
@@ -482,7 +482,7 @@ static int select_ramdisk(bootm_headers_t *images, const char *select, u8 arch,
  *     1, if ramdisk image is found but corrupted, or invalid
  *     rd_start and rd_end are set to 0 if no ramdisk exists
  */
-int boot_get_ramdisk(int argc, char *const argv[], bootm_headers_t *images,
+int boot_get_ramdisk(int argc, char *const argv[], struct bootm_headers *images,
 		     u8 arch, ulong *rd_start, ulong *rd_end)
 {
 	ulong rd_data, rd_len;
@@ -646,7 +646,7 @@ error:
 	return -1;
 }
 
-int boot_get_setup(bootm_headers_t *images, u8 arch,
+int boot_get_setup(struct bootm_headers *images, u8 arch,
 		   ulong *setup_start, ulong *setup_len)
 {
 	if (!CONFIG_IS_ENABLED(FIT))
@@ -655,7 +655,7 @@ int boot_get_setup(bootm_headers_t *images, u8 arch,
 	return boot_get_setup_fit(images, arch, setup_start, setup_len);
 }
 
-int boot_get_fpga(int argc, char *const argv[], bootm_headers_t *images,
+int boot_get_fpga(int argc, char *const argv[], struct bootm_headers *images,
 		  u8 arch, const ulong *ld_start, ulong * const ld_len)
 {
 	ulong tmp_img_addr, img_data, img_len;
@@ -758,7 +758,7 @@ static void fit_loadable_process(u8 img_type,
 			fit_loadable_handler->handler(img_data, img_len);
 }
 
-int boot_get_loadable(int argc, char *const argv[], bootm_headers_t *images,
+int boot_get_loadable(int argc, char *const argv[], struct bootm_headers *images,
 		      u8 arch, const ulong *ld_start, ulong * const ld_len)
 {
 	/*
@@ -919,7 +919,7 @@ int boot_get_kbd(struct lmb *lmb, struct bd_info **kbd)
 	return 0;
 }
 
-int image_setup_linux(bootm_headers_t *images)
+int image_setup_linux(struct bootm_headers *images)
 {
 	ulong of_size = images->ft_len;
 	char **of_flat_tree = &images->ft_addr;
diff --git a/boot/image-fdt.c b/boot/image-fdt.c
index e75d051c872..78417bd8898 100644
--- a/boot/image-fdt.c
+++ b/boot/image-fdt.c
@@ -291,7 +291,7 @@ error:
  *	other -ve value on other error
  */
 
-static int select_fdt(bootm_headers_t *images, const char *select, u8 arch,
+static int select_fdt(struct bootm_headers *images, const char *select, u8 arch,
 		      ulong *fdt_addrp)
 {
 	const char *buf;
@@ -470,7 +470,7 @@ static int select_fdt(bootm_headers_t *images, const char *select, u8 arch,
  *     of_flat_tree and of_size are set to 0 if no fdt exists
  */
 int boot_get_fdt(int flag, int argc, char *const argv[], uint8_t arch,
-		 bootm_headers_t *images, char **of_flat_tree, ulong *of_size)
+		 struct bootm_headers *images, char **of_flat_tree, ulong *of_size)
 {
 	ulong		img_addr;
 	ulong		fdt_addr;
@@ -602,7 +602,7 @@ __weak int arch_fixup_fdt(void *blob)
 	return 0;
 }
 
-int image_setup_libfdt(bootm_headers_t *images, void *blob,
+int image_setup_libfdt(struct bootm_headers *images, void *blob,
 		       int of_size, struct lmb *lmb)
 {
 	ulong *initrd_start = &images->initrd_start;
diff --git a/boot/image-fit.c b/boot/image-fit.c
index df3e5df8836..a7acd762272 100644
--- a/boot/image-fit.c
+++ b/boot/image-fit.c
@@ -1933,8 +1933,8 @@ static int fit_image_select(const void *fit, int rd_noffset, int verify)
 	return 0;
 }
 
-int fit_get_node_from_config(bootm_headers_t *images, const char *prop_name,
-			ulong addr)
+int fit_get_node_from_config(struct bootm_headers *images,
+			     const char *prop_name, ulong addr)
 {
 	int cfg_noffset;
 	void *fit_hdr;
@@ -1995,7 +1995,7 @@ static const char *fit_get_image_type_property(int type)
 	return "unknown";
 }
 
-int fit_image_load(bootm_headers_t *images, ulong addr,
+int fit_image_load(struct bootm_headers *images, ulong addr,
 		   const char **fit_unamep, const char **fit_uname_configp,
 		   int arch, int image_type, int bootstage_id,
 		   enum fit_load_op load_op, ulong *datap, ulong *lenp)
@@ -2253,8 +2253,8 @@ int fit_image_load(bootm_headers_t *images, ulong addr,
 	return noffset;
 }
 
-int boot_get_setup_fit(bootm_headers_t *images, uint8_t arch,
-			ulong *setup_start, ulong *setup_len)
+int boot_get_setup_fit(struct bootm_headers *images, uint8_t arch,
+		       ulong *setup_start, ulong *setup_len)
 {
 	int noffset;
 	ulong addr;
@@ -2274,9 +2274,9 @@ int boot_get_setup_fit(bootm_headers_t *images, uint8_t arch,
 }
 
 #ifndef USE_HOSTCC
-int boot_get_fdt_fit(bootm_headers_t *images, ulong addr,
-		   const char **fit_unamep, const char **fit_uname_configp,
-		   int arch, ulong *datap, ulong *lenp)
+int boot_get_fdt_fit(struct bootm_headers *images, ulong addr,
+		     const char **fit_unamep, const char **fit_uname_configp,
+		     int arch, ulong *datap, ulong *lenp)
 {
 	int fdt_noffset, cfg_noffset, count;
 	const void *fit;
diff --git a/cmd/bootefi.c b/cmd/bootefi.c
index 8ab0ff5a642..3041873afbb 100644
--- a/cmd/bootefi.c
+++ b/cmd/bootefi.c
@@ -281,7 +281,7 @@ efi_status_t efi_install_fdt(void *fdt)
 		return EFI_SUCCESS;
 	}
 #else
-	bootm_headers_t img = { 0 };
+	struct bootm_headers img = { 0 };
 	efi_status_t ret;
 
 	if (fdt == EFI_FDT_USE_INTERNAL) {
diff --git a/cmd/booti.c b/cmd/booti.c
index 397d4b83236..6ac39193db8 100644
--- a/cmd/booti.c
+++ b/cmd/booti.c
@@ -21,7 +21,7 @@ DECLARE_GLOBAL_DATA_PTR;
  * Image booting support
  */
 static int booti_start(struct cmd_tbl *cmdtp, int flag, int argc,
-		       char *const argv[], bootm_headers_t *images)
+		       char *const argv[], struct bootm_headers *images)
 {
 	int ret;
 	ulong ld;
diff --git a/cmd/bootz.c b/cmd/bootz.c
index 4f024bde5fe..f1423573d23 100644
--- a/cmd/bootz.c
+++ b/cmd/bootz.c
@@ -25,7 +25,7 @@ int __weak bootz_setup(ulong image, ulong *start, ulong *end)
  * zImage booting support
  */
 static int bootz_start(struct cmd_tbl *cmdtp, int flag, int argc,
-		       char *const argv[], bootm_headers_t *images)
+		       char *const argv[], struct bootm_headers *images)
 {
 	int ret;
 	ulong zi_start, zi_end;
diff --git a/common/spl/spl.c b/common/spl/spl.c
index 29e0898f03d..13a343b9170 100644
--- a/common/spl/spl.c
+++ b/common/spl/spl.c
@@ -255,7 +255,7 @@ void spl_set_header_raw_uboot(struct spl_image_info *spl_image)
 static int spl_load_fit_image(struct spl_image_info *spl_image,
 			      const struct image_header *header)
 {
-	bootm_headers_t images;
+	struct bootm_headers images;
 	const char *fit_uname_config = NULL;
 	uintptr_t fdt_hack;
 	const char *uname;
diff --git a/include/bootm.h b/include/bootm.h
index 7ed5650fcaa..044a4797ed3 100644
--- a/include/bootm.h
+++ b/include/bootm.h
@@ -33,7 +33,7 @@ struct cmd_tbl;
  * not return.
  */
 typedef int boot_os_fn(int flag, int argc, char *const argv[],
-			bootm_headers_t *images);
+			struct bootm_headers *images);
 
 extern boot_os_fn do_bootm_linux;
 extern boot_os_fn do_bootm_vxworks;
@@ -47,7 +47,7 @@ int bootm_host_load_images(const void *fit, int cfg_noffset);
 #endif
 
 int boot_selected_os(int argc, char *const argv[], int state,
-		     bootm_headers_t *images, boot_os_fn *boot_fn);
+		     struct bootm_headers *images, boot_os_fn *boot_fn);
 
 ulong bootm_disable_interrupts(void);
 
@@ -56,7 +56,7 @@ int bootm_find_images(int flag, int argc, char *const argv[], ulong start,
 		      ulong size);
 
 int do_bootm_states(struct cmd_tbl *cmdtp, int flag, int argc,
-		    char *const argv[], int states, bootm_headers_t *images,
+		    char *const argv[], int states, struct bootm_headers *images,
 		    int boot_progress);
 
 void arch_preboot_os(void);
diff --git a/include/image.h b/include/image.h
index 5e81fad8774..a725892cbed 100644
--- a/include/image.h
+++ b/include/image.h
@@ -290,7 +290,7 @@ typedef struct image_info {
  * Legacy and FIT format headers used by do_bootm() and do_bootm_<os>()
  * routines.
  */
-typedef struct bootm_headers {
+struct bootm_headers {
 	/*
 	 * Legacy os image header, if it is a multi component image
 	 * then boot_get_ramdisk() and get_fdt() will attempt to get
@@ -358,7 +358,7 @@ typedef struct bootm_headers {
 #if defined(CONFIG_LMB) && !defined(USE_HOSTCC)
 	struct lmb	lmb;		/* for memory mgmt */
 #endif
-} bootm_headers_t;
+};
 
 #ifdef CONFIG_LMB
 #define images_lmb(_images)	(&(_images)->lmb)
@@ -366,7 +366,7 @@ typedef struct bootm_headers {
 #define images_lmb(_images)	NULL
 #endif
 
-extern bootm_headers_t images;
+extern struct bootm_headers images;
 
 /*
  * Some systems (for example LWMON) have very short watchdog periods;
@@ -530,7 +530,7 @@ enum fit_load_op {
 	FIT_LOAD_REQUIRED,	/* Must be provided */
 };
 
-int boot_get_setup(bootm_headers_t *images, uint8_t arch, ulong *setup_start,
+int boot_get_setup(struct bootm_headers *images, uint8_t arch, ulong *setup_start,
 		   ulong *setup_len);
 
 /* Image format types, returned by _get_format() routine */
@@ -544,11 +544,11 @@ ulong genimg_get_kernel_addr_fit(char * const img_addr,
 			         const char **fit_uname_kernel);
 ulong genimg_get_kernel_addr(char * const img_addr);
 int genimg_get_format(const void *img_addr);
-int genimg_has_config(bootm_headers_t *images);
+int genimg_has_config(struct bootm_headers *images);
 
-int boot_get_fpga(int argc, char *const argv[], bootm_headers_t *images,
+int boot_get_fpga(int argc, char *const argv[], struct bootm_headers *images,
 		  uint8_t arch, const ulong *ld_start, ulong * const ld_len);
-int boot_get_ramdisk(int argc, char *const argv[], bootm_headers_t *images,
+int boot_get_ramdisk(int argc, char *const argv[], struct bootm_headers *images,
 		     uint8_t arch, ulong *rd_start, ulong *rd_end);
 
 /**
@@ -572,10 +572,10 @@ int boot_get_ramdisk(int argc, char *const argv[], bootm_headers_t *images,
  *     0, if only valid images or no images are found
  *     error code, if an error occurs during fit_image_load
  */
-int boot_get_loadable(int argc, char *const argv[], bootm_headers_t *images,
+int boot_get_loadable(int argc, char *const argv[], struct bootm_headers *images,
 		      uint8_t arch, const ulong *ld_start, ulong *const ld_len);
 
-int boot_get_setup_fit(bootm_headers_t *images, uint8_t arch,
+int boot_get_setup_fit(struct bootm_headers *images, uint8_t arch,
 		       ulong *setup_start, ulong *setup_len);
 
 /**
@@ -599,9 +599,9 @@ int boot_get_setup_fit(bootm_headers_t *images, uint8_t arch,
  *
  * Return: node offset of base image, or -ve error code on error
  */
-int boot_get_fdt_fit(bootm_headers_t *images, ulong addr,
-		   const char **fit_unamep, const char **fit_uname_configp,
-		   int arch, ulong *datap, ulong *lenp);
+int boot_get_fdt_fit(struct bootm_headers *images, ulong addr,
+		     const char **fit_unamep, const char **fit_uname_configp,
+		     int arch, ulong *datap, ulong *lenp);
 
 /**
  * fit_image_load() - load an image from a FIT
@@ -633,7 +633,7 @@ int boot_get_fdt_fit(bootm_headers_t *images, ulong addr,
  * @param lenp		Returns length of loaded image
  * Return: node offset of image, or -ve error code on error
  */
-int fit_image_load(bootm_headers_t *images, ulong addr,
+int fit_image_load(struct bootm_headers *images, ulong addr,
 		   const char **fit_unamep, const char **fit_uname_configp,
 		   int arch, int image_type, int bootstage_id,
 		   enum fit_load_op load_op, ulong *datap, ulong *lenp);
@@ -677,11 +677,11 @@ int image_source_script(ulong addr, const char *fit_uname);
  * @param prop_name	Property name to look up (FIT_..._PROP)
  * @param addr		Address of FIT in memory
  */
-int fit_get_node_from_config(bootm_headers_t *images, const char *prop_name,
-			ulong addr);
+int fit_get_node_from_config(struct bootm_headers *images,
+			     const char *prop_name, ulong addr);
 
 int boot_get_fdt(int flag, int argc, char *const argv[], uint8_t arch,
-		 bootm_headers_t *images,
+		 struct bootm_headers *images,
 		 char **of_flat_tree, ulong *of_size);
 void boot_fdt_add_mem_rsv_regions(struct lmb *lmb, void *fdt_blob);
 int boot_relocate_fdt(struct lmb *lmb, char **of_flat_tree, ulong *of_size);
@@ -871,7 +871,7 @@ int image_decomp(int comp, ulong load, ulong image_start, int type,
  * @lmb:	Points to logical memory block structure
  * Return: 0 if ok, <0 on failure
  */
-int image_setup_libfdt(bootm_headers_t *images, void *blob,
+int image_setup_libfdt(struct bootm_headers *images, void *blob,
 		       int of_size, struct lmb *lmb);
 
 /**
@@ -883,7 +883,7 @@ int image_setup_libfdt(bootm_headers_t *images, void *blob,
  * @param images	Images information
  * Return: 0 if ok, <0 on failure
  */
-int image_setup_linux(bootm_headers_t *images);
+int image_setup_linux(struct bootm_headers *images);
 
 /**
  * bootz_setup() - Extract stat and size of a Linux xImage
diff --git a/lib/efi_loader/efi_dt_fixup.c b/lib/efi_loader/efi_dt_fixup.c
index d3923e5dba1..838023c78ff 100644
--- a/lib/efi_loader/efi_dt_fixup.c
+++ b/lib/efi_loader/efi_dt_fixup.c
@@ -145,7 +145,7 @@ efi_dt_fixup(struct efi_dt_fixup_protocol *this, void *dtb,
 	efi_status_t ret;
 	size_t required_size;
 	size_t total_size;
-	bootm_headers_t img = { 0 };
+	struct bootm_headers img = { 0 };
 
 	EFI_ENTRY("%p, %p, %p, %d", this, dtb, buffer_size, flags);
 
-- 
2.37.2.672.g94769d06f0-goog


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

* [PATCH 03/21] treewide: Drop image_info_t typedef
  2022-08-31  3:07 [PATCH 00/21] dm: core: Support multiple device trees in ofnode Simon Glass
  2022-08-31  3:07 ` [PATCH 01/21] image: Fix BOOTM_STATE values Simon Glass
  2022-08-31  3:07 ` [PATCH 02/21] treewide: Drop bootm_headers_t typedef Simon Glass
@ 2022-08-31  3:07 ` Simon Glass
  2022-08-31  3:08 ` [PATCH 04/21] treewide: Drop image_header_t typedef Simon Glass
                   ` (17 subsequent siblings)
  20 siblings, 0 replies; 23+ messages in thread
From: Simon Glass @ 2022-08-31  3:07 UTC (permalink / raw)
  To: U-Boot Mailing List
  Cc: Michal Simek, Marek Behún, Kishon Vijay Abraham I, Tom Rini,
	Simon Glass, Alexandru Gagniuc, Andre Przywara, Artem Lapkin,
	Heinrich Schuchardt, Jan Kiszka, Philippe Reynes, Sean Anderson

This is not needed and we should avoid typedefs. Use the struct instead.

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

 boot/bootm.c    | 2 +-
 include/image.h | 6 +++---
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/boot/bootm.c b/boot/bootm.c
index 73f7552fe4c..93bdbb0455c 100644
--- a/boot/bootm.c
+++ b/boot/bootm.c
@@ -399,7 +399,7 @@ static int handle_decomp_error(int comp_type, size_t uncomp_size,
 #ifndef USE_HOSTCC
 static int bootm_load_os(struct bootm_headers *images, int boot_progress)
 {
-	image_info_t os = images->os;
+	struct image_info os = images->os;
 	ulong load = os.load;
 	ulong load_end;
 	ulong blob_start = os.start;
diff --git a/include/image.h b/include/image.h
index a725892cbed..e1a65cce7ba 100644
--- a/include/image.h
+++ b/include/image.h
@@ -278,13 +278,13 @@ typedef struct image_header {
 	uint8_t		ih_name[IH_NMLEN];	/* Image Name		*/
 } image_header_t;
 
-typedef struct image_info {
+struct image_info {
 	ulong		start, end;		/* start/end of blob */
 	ulong		image_start, image_len; /* start of image within blob, len of image */
 	ulong		load;			/* load addr for the image */
 	uint8_t		comp, type, os;		/* compression, type of image, os type */
 	uint8_t		arch;			/* CPU architecture */
-} image_info_t;
+};
 
 /*
  * Legacy and FIT format headers used by do_bootm() and do_bootm_<os>()
@@ -324,7 +324,7 @@ struct bootm_headers {
 	int		fit_noffset_setup;/* x86 setup subimage node offset */
 
 #ifndef USE_HOSTCC
-	image_info_t	os;		/* os image info */
+	struct image_info	os;		/* os image info */
 	ulong		ep;		/* entry point of OS */
 
 	ulong		rd_start, rd_end;/* ramdisk start/end */
-- 
2.37.2.672.g94769d06f0-goog


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

* [PATCH 04/21] treewide: Drop image_header_t typedef
  2022-08-31  3:07 [PATCH 00/21] dm: core: Support multiple device trees in ofnode Simon Glass
                   ` (2 preceding siblings ...)
  2022-08-31  3:07 ` [PATCH 03/21] treewide: Drop image_info_t typedef Simon Glass
@ 2022-08-31  3:08 ` Simon Glass
  2022-08-31  3:08 ` [PATCH 05/21] event: Fix a typo in the EVENT help Simon Glass
                   ` (16 subsequent siblings)
  20 siblings, 0 replies; 23+ messages in thread
From: Simon Glass @ 2022-08-31  3:08 UTC (permalink / raw)
  To: U-Boot Mailing List
  Cc: Michal Simek, Marek Behún, Kishon Vijay Abraham I, Tom Rini,
	Simon Glass, Adrian Fiergolski, Alexandru Gagniuc,
	Alper Nebi Yasak, Andre Przywara, Andrew Davis, Artem Lapkin,
	Ashok Reddy Soma, Aspeed BMC SW team, Balamanikandan Gunasundar,
	Bin Meng, Chia-Wei Wang, Chunfeng Yun, Daniel Golle,
	Daniel Schwierzeck, Ezequiel Garcia, Fabio Estevam,
	GSS_MTK_Uboot_upstream, Harald Seiler, Heiko Schocher,
	Heiko Thiery, Heinrich Schuchardt, Jagan Teki, Jan Kiszka,
	Jens Wiklander, Joel Stanley, Jérôme Carretero,
	Leo Yu-Chi Liang, Ley Foon Tan, Lokesh Vutla, Lukasz Majewski,
	Mamta Shukla, Marek Vasut, Michael Trimarchi,
	NXP i.MX U-Boot Team, Oleksandr Suvorov, Ovidiu Panait,
	Pali Rohár, Patrick Delaunay, Peng Fan, Philippe Reynes,
	Ricardo Salveti, Rick Chen, Ryan Chen, Ryder Lee, Samuel Holland,
	Sean Anderson, Stefan Eichenberger, Stefan Roese, Stefano Babic,
	Thomas Haemmerle, Thomas Huth, Vaishnav Achath,
	Vignesh Raghavendra, Vitaly Andrianov, Weijie Gao, Wolfgang Denk

This is not needed and we should avoid typedefs. Use the struct instead
and rename it to indicate that it really is a legacy struct.

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

 arch/arm/mach-aspeed/ast2600/spl.c     |  4 +-
 arch/arm/mach-imx/hab.c                |  2 +-
 arch/arm/mach-imx/spl_imx_romapi.c     |  6 +--
 arch/arm/mach-k3/sysfw-loader.c        |  6 +--
 arch/arm/mach-keystone/cmd_mon.c       |  6 +--
 arch/arm/mach-sunxi/spl_spi_sunxi.c    |  4 +-
 arch/mips/mach-jz47xx/jz4780/jz4780.c  |  6 +--
 arch/mips/mach-mtmips/mt7621/spl/spl.c |  4 +-
 arch/mips/mach-mtmips/mt7621/tpl/tpl.c |  4 +-
 arch/x86/lib/bootm.c                   |  2 +-
 board/ti/ks2_evm/board.c               |  4 +-
 boot/boot_fit.c                        |  4 +-
 boot/bootm.c                           |  8 ++--
 boot/bootm_os.c                        |  7 ++--
 boot/image-android.c                   |  6 +--
 boot/image-board.c                     | 12 +++---
 boot/image-fdt.c                       |  6 +--
 boot/image.c                           | 14 +++----
 cmd/bootm.c                            |  4 +-
 cmd/disk.c                             |  4 +-
 cmd/fpga.c                             |  2 +-
 cmd/nand.c                             |  4 +-
 cmd/source.c                           |  2 +-
 cmd/ximg.c                             |  4 +-
 common/spl/spl.c                       |  8 ++--
 common/spl/spl_ext.c                   |  4 +-
 common/spl/spl_fat.c                   |  6 +--
 common/spl/spl_legacy.c                |  8 ++--
 common/spl/spl_mmc.c                   |  4 +-
 common/spl/spl_nand.c                  |  4 +-
 common/spl/spl_net.c                   |  2 +-
 common/spl/spl_nor.c                   |  8 ++--
 common/spl/spl_onenand.c               |  2 +-
 common/spl/spl_ram.c                   |  8 ++--
 common/spl/spl_sata.c                  |  2 +-
 common/spl/spl_semihosting.c           |  4 +-
 common/spl/spl_spi.c                   |  6 +--
 common/spl/spl_ubi.c                   |  4 +-
 common/spl/spl_xip.c                   |  2 +-
 common/spl/spl_ymodem.c                | 14 +++----
 common/splash_source.c                 |  6 +--
 doc/uImage.FIT/source_file_format.txt  |  2 +-
 drivers/fpga/socfpga_arria10.c         |  4 +-
 drivers/usb/gadget/f_sdp.c             |  2 +-
 include/configs/uniphier.h             |  2 +-
 include/image.h                        | 52 ++++++++++++++------------
 include/spl.h                          |  8 ++--
 include/tee/optee.h                    |  4 +-
 test/image/spl_load.c                  |  4 +-
 tools/binman/ftest.py                  |  4 +-
 tools/default_image.c                  | 31 ++++++++-------
 tools/fit_image.c                      |  4 +-
 tools/imx8mimage.c                     |  8 ++--
 tools/mkimage.c                        |  2 +-
 tools/mtk_image.c                      | 10 ++---
 55 files changed, 179 insertions(+), 175 deletions(-)

diff --git a/arch/arm/mach-aspeed/ast2600/spl.c b/arch/arm/mach-aspeed/ast2600/spl.c
index 53c8a15bf9c..0952e73a457 100644
--- a/arch/arm/mach-aspeed/ast2600/spl.c
+++ b/arch/arm/mach-aspeed/ast2600/spl.c
@@ -56,9 +56,9 @@ out:
 	return BOOT_DEVICE_RAM;
 }
 
-struct image_header *spl_get_load_buffer(ssize_t offset, size_t size)
+struct legacy_img_hdr *spl_get_load_buffer(ssize_t offset, size_t size)
 {
-	return (struct image_header *)(CONFIG_SYS_LOAD_ADDR);
+	return (struct legacy_img_hdr *)(CONFIG_SYS_LOAD_ADDR);
 }
 
 #ifdef CONFIG_SPL_OS_BOOT
diff --git a/arch/arm/mach-imx/hab.c b/arch/arm/mach-imx/hab.c
index 0d1a7766be8..c6747b257c4 100644
--- a/arch/arm/mach-imx/hab.c
+++ b/arch/arm/mach-imx/hab.c
@@ -589,7 +589,7 @@ static ulong get_image_ivt_offset(ulong img_addr)
 	switch (genimg_get_format(buf)) {
 #if CONFIG_IS_ENABLED(LEGACY_IMAGE_FORMAT)
 	case IMAGE_FORMAT_LEGACY:
-		return (image_get_image_size((image_header_t *)img_addr)
+		return (image_get_image_size((struct legacy_img_hdr *)img_addr)
 			+ 0x1000 - 1)  & ~(0x1000 - 1);
 #endif
 #if CONFIG_IS_ENABLED(FIT)
diff --git a/arch/arm/mach-imx/spl_imx_romapi.c b/arch/arm/mach-imx/spl_imx_romapi.c
index cc3c1251dc9..8ab9f2f052a 100644
--- a/arch/arm/mach-imx/spl_imx_romapi.c
+++ b/arch/arm/mach-imx/spl_imx_romapi.c
@@ -72,7 +72,7 @@ static int spl_romapi_load_image_seekable(struct spl_image_info *spl_image,
 	int ret;
 	u32 offset;
 	u32 pagesize, size;
-	struct image_header *header;
+	struct legacy_img_hdr *header;
 	u32 image_offset;
 
 	ret = rom_api_query_boot_infor(QUERY_IVT_OFF, &offset);
@@ -84,14 +84,14 @@ static int spl_romapi_load_image_seekable(struct spl_image_info *spl_image,
 		return -1;
 	}
 
-	header = (struct image_header *)(CONFIG_SPL_IMX_ROMAPI_LOADADDR);
+	header = (struct legacy_img_hdr *)(CONFIG_SPL_IMX_ROMAPI_LOADADDR);
 
 	printf("image offset 0x%x, pagesize 0x%x, ivt offset 0x%x\n",
 	       image_offset, pagesize, offset);
 
 	offset = spl_romapi_get_uboot_base(image_offset, rom_bt_dev);
 
-	size = ALIGN(sizeof(struct image_header), pagesize);
+	size = ALIGN(sizeof(struct legacy_img_hdr), pagesize);
 	ret = rom_api_download_image((u8 *)header, offset, size);
 
 	if (ret != ROM_API_OKAY) {
diff --git a/arch/arm/mach-k3/sysfw-loader.c b/arch/arm/mach-k3/sysfw-loader.c
index b3beeca9472..aea640b5700 100644
--- a/arch/arm/mach-k3/sysfw-loader.c
+++ b/arch/arm/mach-k3/sysfw-loader.c
@@ -88,10 +88,10 @@ static void *sysfw_load_address;
  * Populate SPL hook to override the default load address used by the SPL
  * loader function with a custom address for SYSFW loading.
  */
-struct image_header *spl_get_load_buffer(ssize_t offset, size_t size)
+struct legacy_img_hdr *spl_get_load_buffer(ssize_t offset, size_t size)
 {
 	if (sysfw_loaded)
-		return (struct image_header *)(CONFIG_SYS_TEXT_BASE + offset);
+		return (struct legacy_img_hdr *)(CONFIG_SYS_TEXT_BASE + offset);
 	else if (sysfw_load_address)
 		return sysfw_load_address;
 	else
@@ -490,7 +490,7 @@ void k3_sysfw_loader(bool rom_loaded_sysfw,
 	sysfw_loaded = true;
 
 	/* Ensure the SYSFW image is in FIT format */
-	if (image_get_magic((const image_header_t *)sysfw_load_address) !=
+	if (image_get_magic((const struct legacy_img_hdr *)sysfw_load_address) !=
 	    FDT_MAGIC)
 		panic("SYSFW image not in FIT format!\n");
 
diff --git a/arch/arm/mach-keystone/cmd_mon.c b/arch/arm/mach-keystone/cmd_mon.c
index e26296b6da6..4734e4c7143 100644
--- a/arch/arm/mach-keystone/cmd_mon.c
+++ b/arch/arm/mach-keystone/cmd_mon.c
@@ -17,7 +17,7 @@ static int do_mon_install(struct cmd_tbl *cmdtp, int flag, int argc,
 {
 	u32 addr, dpsc_base = 0x1E80000, freq, load_addr, size;
 	int     rcode = 0;
-	struct image_header *header;
+	struct legacy_img_hdr *header;
 	u32 ecrypt_bm_addr = 0;
 
 	if (argc < 2)
@@ -27,7 +27,7 @@ static int do_mon_install(struct cmd_tbl *cmdtp, int flag, int argc,
 
 	addr = hextoul(argv[1], NULL);
 
-	header = (struct image_header *)addr;
+	header = (struct legacy_img_hdr *)addr;
 
 	if (image_get_magic(header) != IH_MAGIC) {
 		printf("## Please update monitor image\n");
@@ -36,7 +36,7 @@ static int do_mon_install(struct cmd_tbl *cmdtp, int flag, int argc,
 
 	load_addr = image_get_load(header);
 	size = image_get_data_size(header);
-	memcpy((void *)load_addr, (void *)(addr + sizeof(struct image_header)),
+	memcpy((void *)load_addr, (void *)(addr + sizeof(struct legacy_img_hdr)),
 	       size);
 
 	if (argc >=  3)
diff --git a/arch/arm/mach-sunxi/spl_spi_sunxi.c b/arch/arm/mach-sunxi/spl_spi_sunxi.c
index de9aa68c4ac..925bf85f2d2 100644
--- a/arch/arm/mach-sunxi/spl_spi_sunxi.c
+++ b/arch/arm/mach-sunxi/spl_spi_sunxi.c
@@ -335,10 +335,10 @@ static int spl_spi_load_image(struct spl_image_info *spl_image,
 			      struct spl_boot_device *bootdev)
 {
 	int ret = 0;
-	struct image_header *header;
-	header = (struct image_header *)(CONFIG_SYS_TEXT_BASE);
+	struct legacy_img_hdr *header;
 	uint32_t load_offset = sunxi_get_spl_size();
 
+	header = (struct legacy_img_hdr *)CONFIG_SYS_TEXT_BASE;
 	load_offset = max_t(uint32_t, load_offset, CONFIG_SYS_SPI_U_BOOT_OFFS);
 
 	spi0_init();
diff --git a/arch/mips/mach-jz47xx/jz4780/jz4780.c b/arch/mips/mach-jz47xx/jz4780/jz4780.c
index fefba12873b..310c0934a44 100644
--- a/arch/mips/mach-jz47xx/jz4780/jz4780.c
+++ b/arch/mips/mach-jz47xx/jz4780/jz4780.c
@@ -30,7 +30,7 @@ void board_init_f(ulong dummy)
 	typedef void __noreturn (*image_entry_noargs_t)(void);
 	struct mmc *mmc;
 	unsigned long count;
-	struct image_header *header;
+	struct legacy_img_hdr *header;
 	int ret;
 
 	/* Set global data pointer */
@@ -58,8 +58,8 @@ void board_init_f(ulong dummy)
 	if (ret)
 		hang();
 
-	header = (struct image_header *)(CONFIG_SYS_TEXT_BASE -
-					 sizeof(struct image_header));
+	header = (struct legacy_img_hdr *)(CONFIG_SYS_TEXT_BASE -
+					 sizeof(struct legacy_img_hdr));
 
 	count = blk_dread(mmc_get_blk_desc(mmc),
 			  CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR,
diff --git a/arch/mips/mach-mtmips/mt7621/spl/spl.c b/arch/mips/mach-mtmips/mt7621/spl/spl.c
index 91eebc6c1fb..aa5b267bb96 100644
--- a/arch/mips/mach-mtmips/mt7621/spl/spl.c
+++ b/arch/mips/mach-mtmips/mt7621/spl/spl.c
@@ -64,7 +64,7 @@ void board_boot_order(u32 *spl_boot_list)
 unsigned long spl_nor_get_uboot_base(void)
 {
 	const struct tpl_info *tpli;
-	const image_header_t *hdr;
+	const struct legacy_img_hdr *hdr;
 	u32 addr;
 
 	addr = FLASH_MMAP_BASE + TPL_INFO_OFFSET;
@@ -72,7 +72,7 @@ unsigned long spl_nor_get_uboot_base(void)
 
 	if (tpli->magic == TPL_INFO_MAGIC) {
 		addr = FLASH_MMAP_BASE + tpli->size;
-		hdr = (const image_header_t *)KSEG1ADDR(addr);
+		hdr = (const struct legacy_img_hdr *)KSEG1ADDR(addr);
 
 		if (image_get_magic(hdr) == IH_MAGIC) {
 			addr += sizeof(*hdr) + image_get_size(hdr);
diff --git a/arch/mips/mach-mtmips/mt7621/tpl/tpl.c b/arch/mips/mach-mtmips/mt7621/tpl/tpl.c
index 2a828907a34..d77592da5fe 100644
--- a/arch/mips/mach-mtmips/mt7621/tpl/tpl.c
+++ b/arch/mips/mach-mtmips/mt7621/tpl/tpl.c
@@ -116,7 +116,7 @@ static void mt7621_cache_init(void)
 
 void __noreturn tpl_main(void)
 {
-	const image_header_t *hdr = (const image_header_t *)__image_copy_end;
+	const struct legacy_img_hdr *hdr = (const struct legacy_img_hdr *)__image_copy_end;
 	image_entry_noargs_t image_entry;
 	u32 loadaddr, size;
 	uintptr_t data;
@@ -132,7 +132,7 @@ void __noreturn tpl_main(void)
 	image_entry = (image_entry_noargs_t)image_get_ep(hdr);
 
 	/* Load TPL image to L2 cache */
-	data = (uintptr_t)__image_copy_end + sizeof(struct image_header);
+	data = (uintptr_t)__image_copy_end + sizeof(struct legacy_img_hdr);
 	fill_lock_l2cache(data, loadaddr, size);
 
 	/* Jump to SPL */
diff --git a/arch/x86/lib/bootm.c b/arch/x86/lib/bootm.c
index 4fdf1b2365a..eafcddfa24b 100644
--- a/arch/x86/lib/bootm.c
+++ b/arch/x86/lib/bootm.c
@@ -72,7 +72,7 @@ int arch_fixup_memory_node(void *blob)
 static int boot_prep_linux(struct bootm_headers *images)
 {
 	char *cmd_line_dest = NULL;
-	image_header_t *hdr;
+	struct legacy_img_hdr *hdr;
 	int is_zimage = 0;
 	void *data = NULL;
 	size_t len;
diff --git a/board/ti/ks2_evm/board.c b/board/ti/ks2_evm/board.c
index 0c5c2c9146f..5ba3aa35a9f 100644
--- a/board/ti/ks2_evm/board.c
+++ b/board/ti/ks2_evm/board.c
@@ -64,9 +64,9 @@ int dram_init(void)
 	return 0;
 }
 
-struct image_header *spl_get_load_buffer(ssize_t offset, size_t size)
+struct legacy_img_hdr *spl_get_load_buffer(ssize_t offset, size_t size)
 {
-	return (struct image_header *)(CONFIG_SYS_TEXT_BASE);
+	return (struct legacy_img_hdr *)(CONFIG_SYS_TEXT_BASE);
 }
 
 int board_init(void)
diff --git a/boot/boot_fit.c b/boot/boot_fit.c
index dfc2a3117d1..4a493b36847 100644
--- a/boot/boot_fit.c
+++ b/boot/boot_fit.c
@@ -57,14 +57,14 @@ static int fdt_offset(const void *fit)
 
 void *locate_dtb_in_fit(const void *fit)
 {
-	struct image_header *header;
+	struct legacy_img_hdr *header;
 	int size;
 	int ret;
 
 	size = fdt_totalsize(fit);
 	size = (size + 3) & ~3;
 
-	header = (struct image_header *)fit;
+	header = (struct legacy_img_hdr *)fit;
 
 	if (image_get_magic(header) != FDT_MAGIC) {
 		debug("No FIT image appended to U-boot\n");
diff --git a/boot/bootm.c b/boot/bootm.c
index 93bdbb0455c..f6713807fda 100644
--- a/boot/bootm.c
+++ b/boot/bootm.c
@@ -825,9 +825,9 @@ err:
  *     pointer to a legacy image header if valid image was found
  *     otherwise return NULL
  */
-static image_header_t *image_get_kernel(ulong img_addr, int verify)
+static struct legacy_img_hdr *image_get_kernel(ulong img_addr, int verify)
 {
-	image_header_t *hdr = (image_header_t *)img_addr;
+	struct legacy_img_hdr *hdr = (struct legacy_img_hdr *)img_addr;
 
 	if (!image_check_magic(hdr)) {
 		puts("Bad Magic Number\n");
@@ -882,7 +882,7 @@ static const void *boot_get_kernel(struct cmd_tbl *cmdtp, int flag, int argc,
 				   ulong *os_data, ulong *os_len)
 {
 #if CONFIG_IS_ENABLED(LEGACY_IMAGE_FORMAT)
-	image_header_t	*hdr;
+	struct legacy_img_hdr	*hdr;
 #endif
 	ulong		img_addr;
 	const void *buf;
@@ -940,7 +940,7 @@ static const void *boot_get_kernel(struct cmd_tbl *cmdtp, int flag, int argc,
 		 * kernel decompression.
 		 */
 		memmove(&images->legacy_hdr_os_copy, hdr,
-			sizeof(image_header_t));
+			sizeof(struct legacy_img_hdr));
 
 		/* save pointer to image header */
 		images->legacy_hdr_os = hdr;
diff --git a/boot/bootm_os.c b/boot/bootm_os.c
index bd266e790cd..3e651b38ddb 100644
--- a/boot/bootm_os.c
+++ b/boot/bootm_os.c
@@ -67,8 +67,9 @@ static void __maybe_unused fit_unsupported_reset(const char *msg)
 static int do_bootm_netbsd(int flag, int argc, char *const argv[],
 			   struct bootm_headers *images)
 {
-	void (*loader)(struct bd_info *, image_header_t *, char *, char *);
-	image_header_t *os_hdr, *hdr;
+	void (*loader)(struct bd_info *bd, struct legacy_img_hdr *hdr,
+		       char *console, char *cmdline);
+	struct legacy_img_hdr *os_hdr, *hdr;
 	ulong kernel_data, kernel_len;
 	char *cmdline;
 
@@ -115,7 +116,7 @@ static int do_bootm_netbsd(int flag, int argc, char *const argv[],
 			cmdline = "";
 	}
 
-	loader = (void (*)(struct bd_info *, image_header_t *, char *, char *))images->ep;
+	loader = (void (*)(struct bd_info *, struct legacy_img_hdr *, char *, char *))images->ep;
 
 	printf("## Transferring control to NetBSD stage-2 loader (at address %08lx) ...\n",
 	       (ulong)loader);
diff --git a/boot/image-android.c b/boot/image-android.c
index 1fbbbba1eb0..2628db37412 100644
--- a/boot/image-android.c
+++ b/boot/image-android.c
@@ -63,7 +63,7 @@ int android_image_get_kernel(const struct andr_img_hdr *hdr, int verify,
 			     ulong *os_data, ulong *os_len)
 {
 	u32 kernel_addr = android_image_get_kernel_addr(hdr);
-	const struct image_header *ihdr = (const struct image_header *)
+	const struct legacy_img_hdr *ihdr = (const struct legacy_img_hdr *)
 		((uintptr_t)hdr + hdr->page_size);
 
 	/*
@@ -159,8 +159,8 @@ ulong android_image_get_kcomp(const struct andr_img_hdr *hdr)
 {
 	const void *p = (void *)((uintptr_t)hdr + hdr->page_size);
 
-	if (image_get_magic((image_header_t *)p) == IH_MAGIC)
-		return image_get_comp((image_header_t *)p);
+	if (image_get_magic((struct legacy_img_hdr *)p) == IH_MAGIC)
+		return image_get_comp((struct legacy_img_hdr *)p);
 	else if (get_unaligned_le32(p) == LZ4F_MAGIC)
 		return IH_COMP_LZ4;
 	else
diff --git a/boot/image-board.c b/boot/image-board.c
index b61d64c65f8..44b57768f00 100644
--- a/boot/image-board.c
+++ b/boot/image-board.c
@@ -40,10 +40,10 @@ DECLARE_GLOBAL_DATA_PTR;
  *     pointer to a ramdisk image header, if image was found and valid
  *     otherwise, return NULL
  */
-static const image_header_t *image_get_ramdisk(ulong rd_addr, u8 arch,
-					       int verify)
+static const struct legacy_img_hdr *image_get_ramdisk(ulong rd_addr, u8 arch,
+						      int verify)
 {
-	const image_header_t *rd_hdr = (const image_header_t *)rd_addr;
+	const struct legacy_img_hdr *rd_hdr = (const struct legacy_img_hdr *)rd_addr;
 
 	if (!image_check_magic(rd_hdr)) {
 		puts("Bad Magic Number\n");
@@ -273,9 +273,9 @@ ulong genimg_get_kernel_addr(char * const img_addr)
 int genimg_get_format(const void *img_addr)
 {
 	if (CONFIG_IS_ENABLED(LEGACY_IMAGE_FORMAT)) {
-		const image_header_t *hdr;
+		const struct legacy_img_hdr *hdr;
 
-		hdr = (const image_header_t *)img_addr;
+		hdr = (const struct legacy_img_hdr *)img_addr;
 		if (image_check_magic(hdr))
 			return IMAGE_FORMAT_LEGACY;
 	}
@@ -389,7 +389,7 @@ static int select_ramdisk(struct bootm_headers *images, const char *select, u8 a
 	switch (genimg_get_format(buf)) {
 	case IMAGE_FORMAT_LEGACY:
 		if (CONFIG_IS_ENABLED(LEGACY_IMAGE_FORMAT)) {
-			const image_header_t *rd_hdr;
+			const struct legacy_img_hdr *rd_hdr;
 
 			printf("## Loading init Ramdisk from Legacy Image at %08lx ...\n",
 			       rd_addr);
diff --git a/boot/image-fdt.c b/boot/image-fdt.c
index 78417bd8898..ca51796322d 100644
--- a/boot/image-fdt.c
+++ b/boot/image-fdt.c
@@ -37,9 +37,9 @@ static void fdt_error(const char *msg)
 }
 
 #if CONFIG_IS_ENABLED(LEGACY_IMAGE_FORMAT)
-static const image_header_t *image_get_fdt(ulong fdt_addr)
+static const struct legacy_img_hdr *image_get_fdt(ulong fdt_addr)
 {
-	const image_header_t *fdt_hdr = map_sysmem(fdt_addr, 0);
+	const struct legacy_img_hdr *fdt_hdr = map_sysmem(fdt_addr, 0);
 
 	image_print_contents(fdt_hdr);
 
@@ -358,7 +358,7 @@ static int select_fdt(struct bootm_headers *images, const char *select, u8 arch,
 	switch (genimg_get_format(buf)) {
 #if CONFIG_IS_ENABLED(LEGACY_IMAGE_FORMAT)
 	case IMAGE_FORMAT_LEGACY: {
-			const image_header_t *fdt_hdr;
+			const struct legacy_img_hdr *fdt_hdr;
 			ulong load, load_end;
 			ulong image_start, image_data, image_end;
 
diff --git a/boot/image.c b/boot/image.c
index a0d0cc2403d..9f95b3260a8 100644
--- a/boot/image.c
+++ b/boot/image.c
@@ -220,11 +220,11 @@ static const struct table_info table_info[IH_COUNT] = {
 /*****************************************************************************/
 /* Legacy format routines */
 /*****************************************************************************/
-int image_check_hcrc(const image_header_t *hdr)
+int image_check_hcrc(const struct legacy_img_hdr *hdr)
 {
 	ulong hcrc;
 	ulong len = image_get_header_size();
-	image_header_t header;
+	struct legacy_img_hdr header;
 
 	/* Copy header so we can blank CRC field for re-calculation */
 	memmove(&header, (char *)hdr, image_get_header_size());
@@ -235,7 +235,7 @@ int image_check_hcrc(const image_header_t *hdr)
 	return (hcrc == image_get_hcrc(hdr));
 }
 
-int image_check_dcrc(const image_header_t *hdr)
+int image_check_dcrc(const struct legacy_img_hdr *hdr)
 {
 	ulong data = image_get_data(hdr);
 	ulong len = image_get_data_size(hdr);
@@ -257,7 +257,7 @@ int image_check_dcrc(const image_header_t *hdr)
  * returns:
  *     number of components
  */
-ulong image_multi_count(const image_header_t *hdr)
+ulong image_multi_count(const struct legacy_img_hdr *hdr)
 {
 	ulong i, count = 0;
 	uint32_t *size;
@@ -290,7 +290,7 @@ ulong image_multi_count(const image_header_t *hdr)
  *     data address and size of the component, if idx is valid
  *     0 in data and len, if idx is out of range
  */
-void image_multi_getimg(const image_header_t *hdr, ulong idx,
+void image_multi_getimg(const struct legacy_img_hdr *hdr, ulong idx,
 			ulong *data, ulong *len)
 {
 	int i;
@@ -326,7 +326,7 @@ void image_multi_getimg(const image_header_t *hdr, ulong idx,
 	}
 }
 
-static void image_print_type(const image_header_t *hdr)
+static void image_print_type(const struct legacy_img_hdr *hdr)
 {
 	const char __maybe_unused *os, *arch, *type, *comp;
 
@@ -352,7 +352,7 @@ static void image_print_type(const image_header_t *hdr)
  */
 void image_print_contents(const void *ptr)
 {
-	const image_header_t *hdr = (const image_header_t *)ptr;
+	const struct legacy_img_hdr *hdr = (const struct legacy_img_hdr *)ptr;
 	const char __maybe_unused *p;
 
 	p = IMAGE_INDENT_STRING;
diff --git a/cmd/bootm.c b/cmd/bootm.c
index 9fe8ce4a27c..d764a27002d 100644
--- a/cmd/bootm.c
+++ b/cmd/bootm.c
@@ -511,7 +511,7 @@ static int do_imls_nand(void)
 			continue;
 
 		for (off = 0; off < mtd->size; off += mtd->erasesize) {
-			const image_header_t *header;
+			const struct legacy_img_hdr *header;
 			int ret;
 
 			if (nand_block_isbad(mtd, off))
@@ -529,7 +529,7 @@ static int do_imls_nand(void)
 			switch (genimg_get_format(buffer)) {
 #if defined(CONFIG_LEGACY_IMAGE_FORMAT)
 			case IMAGE_FORMAT_LEGACY:
-				header = (const image_header_t *)buffer;
+				header = (const struct legacy_img_hdr *)buffer;
 
 				len = image_get_image_size(header);
 				nand_imls_legacyimage(mtd, nand_dev, off, len);
diff --git a/cmd/disk.c b/cmd/disk.c
index cb3b990ba3a..3d7bc2f6018 100644
--- a/cmd/disk.c
+++ b/cmd/disk.c
@@ -20,7 +20,7 @@ int common_diskboot(struct cmd_tbl *cmdtp, const char *intf, int argc,
 	ulong cnt;
 	struct disk_partition info;
 #if defined(CONFIG_LEGACY_IMAGE_FORMAT)
-	image_header_t *hdr;
+	struct legacy_img_hdr *hdr;
 #endif
 	struct blk_desc *dev_desc;
 
@@ -68,7 +68,7 @@ int common_diskboot(struct cmd_tbl *cmdtp, const char *intf, int argc,
 	switch (genimg_get_format((void *) addr)) {
 #if defined(CONFIG_LEGACY_IMAGE_FORMAT)
 	case IMAGE_FORMAT_LEGACY:
-		hdr = (image_header_t *) addr;
+		hdr = (struct legacy_img_hdr *)addr;
 
 		bootstage_mark(BOOTSTAGE_ID_IDE_FORMAT);
 
diff --git a/cmd/fpga.c b/cmd/fpga.c
index c4651dd403e..2d972d992bb 100644
--- a/cmd/fpga.c
+++ b/cmd/fpga.c
@@ -288,7 +288,7 @@ static int do_fpga_loadmk(struct cmd_tbl *cmdtp, int flag, int argc,
 #if defined(CONFIG_LEGACY_IMAGE_FORMAT)
 	case IMAGE_FORMAT_LEGACY:
 	{
-		image_header_t *hdr = (image_header_t *)fpga_data;
+		struct legacy_img_hdr *hdr = (struct legacy_img_hdr *)fpga_data;
 		ulong data;
 		u8 comp;
 
diff --git a/cmd/nand.c b/cmd/nand.c
index e730484d0b7..5bb43794e90 100644
--- a/cmd/nand.c
+++ b/cmd/nand.c
@@ -975,7 +975,7 @@ static int nand_load_image(struct cmd_tbl *cmdtp, struct mtd_info *mtd,
 	char *s;
 	size_t cnt;
 #if defined(CONFIG_LEGACY_IMAGE_FORMAT)
-	image_header_t *hdr;
+	struct legacy_img_hdr *hdr;
 #endif
 #if defined(CONFIG_FIT)
 	const void *fit_hdr = NULL;
@@ -1004,7 +1004,7 @@ static int nand_load_image(struct cmd_tbl *cmdtp, struct mtd_info *mtd,
 	switch (genimg_get_format ((void *)addr)) {
 #if defined(CONFIG_LEGACY_IMAGE_FORMAT)
 	case IMAGE_FORMAT_LEGACY:
-		hdr = (image_header_t *)addr;
+		hdr = (struct legacy_img_hdr *)addr;
 
 		bootstage_mark(BOOTSTAGE_ID_NAND_TYPE);
 		image_print_contents (hdr);
diff --git a/cmd/source.c b/cmd/source.c
index 81e015b64ef..698d9f86d96 100644
--- a/cmd/source.c
+++ b/cmd/source.c
@@ -46,7 +46,7 @@ int image_source_script(ulong addr, const char *fit_uname)
 {
 	ulong		len;
 #if defined(CONFIG_LEGACY_IMAGE_FORMAT)
-	const image_header_t *hdr;
+	const struct legacy_img_hdr *hdr;
 #endif
 	u32		*data;
 	int		verify;
diff --git a/cmd/ximg.c b/cmd/ximg.c
index 65ba41320a0..bdf691ffcba 100644
--- a/cmd/ximg.c
+++ b/cmd/ximg.c
@@ -42,7 +42,7 @@ do_imgextract(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
 	int		part = 0;
 #if defined(CONFIG_LEGACY_IMAGE_FORMAT)
 	ulong		count;
-	image_header_t	*hdr = NULL;
+	struct legacy_img_hdr	*hdr = NULL;
 #endif
 #if defined(CONFIG_FIT)
 	const char	*uname = NULL;
@@ -78,7 +78,7 @@ do_imgextract(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
 		printf("## Copying part %d from legacy image "
 			"at %08lx ...\n", part, addr);
 
-		hdr = (image_header_t *)addr;
+		hdr = (struct legacy_img_hdr *)addr;
 		if (!image_check_magic(hdr)) {
 			printf("Bad Magic Number\n");
 			return 1;
diff --git a/common/spl/spl.c b/common/spl/spl.c
index 13a343b9170..d97d5eccb9d 100644
--- a/common/spl/spl.c
+++ b/common/spl/spl.c
@@ -222,7 +222,7 @@ __weak void spl_board_prepare_for_boot(void)
 	/* Nothing to do! */
 }
 
-__weak struct image_header *spl_get_load_buffer(ssize_t offset, size_t size)
+__weak struct legacy_img_hdr *spl_get_load_buffer(ssize_t offset, size_t size)
 {
 	return map_sysmem(CONFIG_SYS_TEXT_BASE + offset, 0);
 }
@@ -253,7 +253,7 @@ void spl_set_header_raw_uboot(struct spl_image_info *spl_image)
 #if CONFIG_IS_ENABLED(LOAD_FIT_FULL)
 /* Parse and load full fitImage in SPL */
 static int spl_load_fit_image(struct spl_image_info *spl_image,
-			      const struct image_header *header)
+			      const struct legacy_img_hdr *header)
 {
 	struct bootm_headers images;
 	const char *fit_uname_config = NULL;
@@ -354,7 +354,7 @@ __weak int spl_parse_board_header(struct spl_image_info *spl_image,
 }
 
 __weak int spl_parse_legacy_header(struct spl_image_info *spl_image,
-				   const struct image_header *header)
+				   const struct legacy_img_hdr *header)
 {
 	/* LEGACY image not supported */
 	debug("Legacy boot image support not enabled, proceeding to other boot methods\n");
@@ -363,7 +363,7 @@ __weak int spl_parse_legacy_header(struct spl_image_info *spl_image,
 
 int spl_parse_image_header(struct spl_image_info *spl_image,
 			   const struct spl_boot_device *bootdev,
-			   const struct image_header *header)
+			   const struct legacy_img_hdr *header)
 {
 #if CONFIG_IS_ENABLED(LOAD_FIT_FULL)
 	int ret = spl_load_fit_image(spl_image, header);
diff --git a/common/spl/spl_ext.c b/common/spl/spl_ext.c
index ebd914c4926..f117c630bfe 100644
--- a/common/spl/spl_ext.c
+++ b/common/spl/spl_ext.c
@@ -15,7 +15,7 @@ int spl_load_image_ext(struct spl_image_info *spl_image,
 		       const char *filename)
 {
 	s32 err;
-	struct image_header *header;
+	struct legacy_img_hdr *header;
 	loff_t filelen, actlen;
 	struct disk_partition part_info = {};
 
@@ -41,7 +41,7 @@ int spl_load_image_ext(struct spl_image_info *spl_image,
 		puts("spl: ext4fs_open failed\n");
 		goto end;
 	}
-	err = ext4fs_read((char *)header, 0, sizeof(struct image_header), &actlen);
+	err = ext4fs_read((char *)header, 0, sizeof(struct legacy_img_hdr), &actlen);
 	if (err < 0) {
 		puts("spl: ext4fs_read failed\n");
 		goto end;
diff --git a/common/spl/spl_fat.c b/common/spl/spl_fat.c
index 5b270541fcc..f8a5b80a3bd 100644
--- a/common/spl/spl_fat.c
+++ b/common/spl/spl_fat.c
@@ -60,7 +60,7 @@ int spl_load_image_fat(struct spl_image_info *spl_image,
 		       const char *filename)
 {
 	int err;
-	struct image_header *header;
+	struct legacy_img_hdr *header;
 
 	err = spl_register_fat_device(block_dev, partition);
 	if (err)
@@ -68,7 +68,7 @@ int spl_load_image_fat(struct spl_image_info *spl_image,
 
 	header = spl_get_load_buffer(-sizeof(*header), sizeof(*header));
 
-	err = file_fat_read(filename, header, sizeof(struct image_header));
+	err = file_fat_read(filename, header, sizeof(struct legacy_img_hdr));
 	if (err <= 0)
 		goto end;
 
@@ -78,7 +78,7 @@ int spl_load_image_fat(struct spl_image_info *spl_image,
 		if (err <= 0)
 			goto end;
 		err = spl_parse_image_header(spl_image, bootdev,
-				(struct image_header *)CONFIG_SYS_LOAD_ADDR);
+				(struct legacy_img_hdr *)CONFIG_SYS_LOAD_ADDR);
 		if (err == -EAGAIN)
 			return err;
 		if (err == 0)
diff --git a/common/spl/spl_legacy.c b/common/spl/spl_legacy.c
index ae8731c782a..b3624dfbb77 100644
--- a/common/spl/spl_legacy.c
+++ b/common/spl/spl_legacy.c
@@ -16,9 +16,9 @@
 #define LZMA_LEN	(1 << 20)
 
 int spl_parse_legacy_header(struct spl_image_info *spl_image,
-			    const struct image_header *header)
+			    const struct legacy_img_hdr *header)
 {
-	u32 header_size = sizeof(struct image_header);
+	u32 header_size = sizeof(struct legacy_img_hdr);
 
 	/* check uImage header CRC */
 	if (IS_ENABLED(CONFIG_SPL_LEGACY_IMAGE_CRC_CHECK) &&
@@ -67,7 +67,7 @@ int spl_parse_legacy_header(struct spl_image_info *spl_image,
  * following switch/case statement in spl_load_legacy_img() away due to
  * Dead Code Elimination.
  */
-static inline int spl_image_get_comp(const struct image_header *hdr)
+static inline int spl_image_get_comp(const struct legacy_img_hdr *hdr)
 {
 	if (IS_ENABLED(CONFIG_SPL_LZMA))
 		return image_get_comp(hdr);
@@ -81,7 +81,7 @@ int spl_load_legacy_img(struct spl_image_info *spl_image,
 {
 	__maybe_unused SizeT lzma_len;
 	__maybe_unused void *src;
-	struct image_header hdr;
+	struct legacy_img_hdr hdr;
 	ulong dataptr;
 	int ret;
 
diff --git a/common/spl/spl_mmc.c b/common/spl/spl_mmc.c
index 23a395e63d4..e4135b20487 100644
--- a/common/spl/spl_mmc.c
+++ b/common/spl/spl_mmc.c
@@ -20,7 +20,7 @@
 static int mmc_load_legacy(struct spl_image_info *spl_image,
 			   struct spl_boot_device *bootdev,
 			   struct mmc *mmc,
-			   ulong sector, struct image_header *header)
+			   ulong sector, struct legacy_img_hdr *header)
 {
 	u32 image_offset_sectors;
 	u32 image_size_sectors;
@@ -83,7 +83,7 @@ int mmc_load_image_raw_sector(struct spl_image_info *spl_image,
 			      struct mmc *mmc, unsigned long sector)
 {
 	unsigned long count;
-	struct image_header *header;
+	struct legacy_img_hdr *header;
 	struct blk_desc *bd = mmc_get_blk_desc(mmc);
 	int ret = 0;
 
diff --git a/common/spl/spl_nand.c b/common/spl/spl_nand.c
index 7b7579a2df1..a16738818c1 100644
--- a/common/spl/spl_nand.c
+++ b/common/spl/spl_nand.c
@@ -78,7 +78,7 @@ struct mtd_info * __weak nand_get_mtd(void)
 
 static int spl_nand_load_element(struct spl_image_info *spl_image,
 				 struct spl_boot_device *bootdev,
-				 int offset, struct image_header *header)
+				 int offset, struct legacy_img_hdr *header)
 {
 	struct mtd_info *mtd = nand_get_mtd();
 	int bl_len = mtd ? mtd->writesize : 1;
@@ -133,7 +133,7 @@ static int spl_nand_load_image(struct spl_image_info *spl_image,
 			       struct spl_boot_device *bootdev)
 {
 	int err;
-	struct image_header *header;
+	struct legacy_img_hdr *header;
 	int *src __attribute__((unused));
 	int *dst __attribute__((unused));
 
diff --git a/common/spl/spl_net.c b/common/spl/spl_net.c
index a853e6aead4..b2c901b554b 100644
--- a/common/spl/spl_net.c
+++ b/common/spl/spl_net.c
@@ -28,7 +28,7 @@ static ulong spl_net_load_read(struct spl_load_info *load, ulong sector,
 static int spl_net_load_image(struct spl_image_info *spl_image,
 			      struct spl_boot_device *bootdev)
 {
-	struct image_header *header = (struct image_header *)image_load_addr;
+	struct legacy_img_hdr *header = (struct legacy_img_hdr *)image_load_addr;
 	int rv;
 
 	env_init();
diff --git a/common/spl/spl_nor.c b/common/spl/spl_nor.c
index 7986e930d28..281c6136f54 100644
--- a/common/spl/spl_nor.c
+++ b/common/spl/spl_nor.c
@@ -26,7 +26,7 @@ unsigned long __weak spl_nor_get_uboot_base(void)
 static int spl_nor_load_image(struct spl_image_info *spl_image,
 			      struct spl_boot_device *bootdev)
 {
-	__maybe_unused const struct image_header *header;
+	__maybe_unused const struct legacy_img_hdr *header;
 	__maybe_unused struct spl_load_info load;
 
 	/*
@@ -41,7 +41,7 @@ static int spl_nor_load_image(struct spl_image_info *spl_image,
 		 * Load Linux from its location in NOR flash to its defined
 		 * location in SDRAM
 		 */
-		header = (const struct image_header *)CONFIG_SYS_OS_BASE;
+		header = (const struct legacy_img_hdr *)CONFIG_SYS_OS_BASE;
 #ifdef CONFIG_SPL_LOAD_FIT
 		if (image_get_magic(header) == FDT_MAGIC) {
 			int ret;
@@ -72,7 +72,7 @@ static int spl_nor_load_image(struct spl_image_info *spl_image,
 
 			memcpy((void *)spl_image->load_addr,
 			       (void *)(CONFIG_SYS_OS_BASE +
-					sizeof(struct image_header)),
+					sizeof(struct legacy_img_hdr)),
 			       spl_image->size);
 #ifdef CONFIG_SYS_SPL_ARGS_ADDR
 			spl_image->arg = (void *)CONFIG_SYS_SPL_ARGS_ADDR;
@@ -92,7 +92,7 @@ static int spl_nor_load_image(struct spl_image_info *spl_image,
 	 * defined location in SDRAM
 	 */
 #ifdef CONFIG_SPL_LOAD_FIT
-	header = (const struct image_header *)spl_nor_get_uboot_base();
+	header = (const struct legacy_img_hdr *)spl_nor_get_uboot_base();
 	if (image_get_magic(header) == FDT_MAGIC) {
 		debug("Found FIT format U-Boot\n");
 		load.bl_len = 1;
diff --git a/common/spl/spl_onenand.c b/common/spl/spl_onenand.c
index f80769a0277..53a8c6de89e 100644
--- a/common/spl/spl_onenand.c
+++ b/common/spl/spl_onenand.c
@@ -18,7 +18,7 @@
 static int spl_onenand_load_image(struct spl_image_info *spl_image,
 				  struct spl_boot_device *bootdev)
 {
-	struct image_header *header;
+	struct legacy_img_hdr *header;
 	int ret;
 
 	debug("spl: onenand\n");
diff --git a/common/spl/spl_ram.c b/common/spl/spl_ram.c
index d64710878cf..2b1ac191523 100644
--- a/common/spl/spl_ram.c
+++ b/common/spl/spl_ram.c
@@ -41,9 +41,9 @@ static ulong spl_ram_load_read(struct spl_load_info *load, ulong sector,
 static int spl_ram_load_image(struct spl_image_info *spl_image,
 			      struct spl_boot_device *bootdev)
 {
-	struct image_header *header;
+	struct legacy_img_hdr *header;
 
-	header = (struct image_header *)CONFIG_SPL_LOAD_FIT_ADDRESS;
+	header = (struct legacy_img_hdr *)CONFIG_SPL_LOAD_FIT_ADDRESS;
 
 	if (CONFIG_IS_ENABLED(IMAGE_PRE_LOAD)) {
 		unsigned long addr = (unsigned long)header;
@@ -53,7 +53,7 @@ static int spl_ram_load_image(struct spl_image_info *spl_image,
 			return ret;
 
 		addr += image_load_offset;
-		header = (struct image_header *)addr;
+		header = (struct legacy_img_hdr *)addr;
 	}
 
 #if CONFIG_IS_ENABLED(DFU)
@@ -87,7 +87,7 @@ static int spl_ram_load_image(struct spl_image_info *spl_image,
 			u_boot_pos = (ulong)spl_get_load_buffer(-sizeof(*header),
 								sizeof(*header));
 		}
-		header = (struct image_header *)map_sysmem(u_boot_pos, 0);
+		header = (struct legacy_img_hdr *)map_sysmem(u_boot_pos, 0);
 
 		spl_parse_image_header(spl_image, bootdev, header);
 	}
diff --git a/common/spl/spl_sata.c b/common/spl/spl_sata.c
index 1351d78612a..3067560bdf7 100644
--- a/common/spl/spl_sata.c
+++ b/common/spl/spl_sata.c
@@ -30,7 +30,7 @@ static int spl_sata_load_image_raw(struct spl_image_info *spl_image,
 		struct spl_boot_device *bootdev,
 		struct blk_desc *stor_dev, unsigned long sector)
 {
-	struct image_header *header;
+	struct legacy_img_hdr *header;
 	unsigned long count;
 	u32 image_size_sectors;
 	u32 image_offset_sectors;
diff --git a/common/spl/spl_semihosting.c b/common/spl/spl_semihosting.c
index df6aeb29512..5b5e842a11b 100644
--- a/common/spl/spl_semihosting.c
+++ b/common/spl/spl_semihosting.c
@@ -27,7 +27,7 @@ static int spl_smh_load_image(struct spl_image_info *spl_image,
 	const char *filename = CONFIG_SPL_FS_LOAD_PAYLOAD_NAME;
 	int ret;
 	long fd, len;
-	struct image_header *header =
+	struct legacy_img_hdr *header =
 		spl_get_load_buffer(-sizeof(*header), sizeof(*header));
 
 	fd = smh_open(filename, MODE_READ | MODE_BINARY);
@@ -43,7 +43,7 @@ static int spl_smh_load_image(struct spl_image_info *spl_image,
 	}
 	len = ret;
 
-	ret = smh_read_full(fd, header, sizeof(struct image_header));
+	ret = smh_read_full(fd, header, sizeof(struct legacy_img_hdr));
 	if (ret) {
 		log_debug("could not read image header: %d\n", ret);
 		goto out;
diff --git a/common/spl/spl_spi.c b/common/spl/spl_spi.c
index d959ad11458..da6742416ed 100644
--- a/common/spl/spl_spi.c
+++ b/common/spl/spl_spi.c
@@ -26,7 +26,7 @@
 static int spi_load_image_os(struct spl_image_info *spl_image,
 			     struct spl_boot_device *bootdev,
 			     struct spi_flash *flash,
-			     struct image_header *header)
+			     struct legacy_img_hdr *header)
 {
 	int err;
 
@@ -92,7 +92,7 @@ static int spl_spi_load_image(struct spl_image_info *spl_image,
 	int err = 0;
 	unsigned int payload_offs;
 	struct spi_flash *flash;
-	struct image_header *header;
+	struct legacy_img_hdr *header;
 	unsigned int sf_bus = spl_spi_boot_bus();
 	unsigned int sf_cs = spl_spi_boot_cs();
 
@@ -139,7 +139,7 @@ static int spl_spi_load_image(struct spl_image_info *spl_image,
 			if (err)
 				return err;
 			err = spl_parse_image_header(spl_image, bootdev,
-					(struct image_header *)CONFIG_SYS_LOAD_ADDR);
+					(struct legacy_img_hdr *)CONFIG_SYS_LOAD_ADDR);
 		} else if (IS_ENABLED(CONFIG_SPL_LOAD_FIT) &&
 			   image_get_magic(header) == FDT_MAGIC) {
 			struct spl_load_info load;
diff --git a/common/spl/spl_ubi.c b/common/spl/spl_ubi.c
index bdf5cc4c383..fb804f02089 100644
--- a/common/spl/spl_ubi.c
+++ b/common/spl/spl_ubi.c
@@ -15,7 +15,7 @@
 int spl_ubi_load_image(struct spl_image_info *spl_image,
 		       struct spl_boot_device *bootdev)
 {
-	struct image_header *header;
+	struct legacy_img_hdr *header;
 	struct ubispl_info info;
 	struct ubispl_load volumes[2];
 	int ret = 1;
@@ -54,7 +54,7 @@ int spl_ubi_load_image(struct spl_image_info *spl_image,
 
 		ret = ubispl_load_volumes(&info, volumes, 2);
 		if (!ret) {
-			header = (struct image_header *)volumes[0].load_addr;
+			header = (struct legacy_img_hdr *)volumes[0].load_addr;
 			spl_parse_image_header(spl_image, bootdev, header);
 			puts("Linux loaded.\n");
 			goto out;
diff --git a/common/spl/spl_xip.c b/common/spl/spl_xip.c
index e9a40b0ec79..1258d85e63d 100644
--- a/common/spl/spl_xip.c
+++ b/common/spl/spl_xip.c
@@ -25,6 +25,6 @@ static int spl_xip(struct spl_image_info *spl_image,
 	}
 #endif
 	return(spl_parse_image_header(spl_image, bootdev,
-	       (const struct image_header *)CONFIG_SYS_UBOOT_BASE));
+	       (const struct legacy_img_hdr *)CONFIG_SYS_UBOOT_BASE));
 }
 SPL_LOAD_IMAGE_METHOD("XIP", 0, BOOT_DEVICE_XIP, spl_xip);
diff --git a/common/spl/spl_ymodem.c b/common/spl/spl_ymodem.c
index fdd52610429..038b4438457 100644
--- a/common/spl/spl_ymodem.c
+++ b/common/spl/spl_ymodem.c
@@ -96,7 +96,7 @@ int spl_ymodem_load_image(struct spl_image_info *spl_image,
 	int ret;
 	connection_info_t info;
 	char buf[BUF_SIZE];
-	struct image_header *ih = NULL;
+	struct legacy_img_hdr *ih = NULL;
 	ulong addr = 0;
 
 	info.mode = xyzModem_ymodem;
@@ -111,9 +111,9 @@ int spl_ymodem_load_image(struct spl_image_info *spl_image,
 		goto end_stream;
 
 	if (IS_ENABLED(CONFIG_SPL_LOAD_FIT_FULL) &&
-	    image_get_magic((struct image_header *)buf) == FDT_MAGIC) {
+	    image_get_magic((struct legacy_img_hdr *)buf) == FDT_MAGIC) {
 		addr = CONFIG_SYS_LOAD_ADDR;
-		ih = (struct image_header *)addr;
+		ih = (struct legacy_img_hdr *)addr;
 
 		memcpy((void *)addr, buf, res);
 		size += res;
@@ -129,7 +129,7 @@ int spl_ymodem_load_image(struct spl_image_info *spl_image,
 		if (ret)
 			return ret;
 	} else if (IS_ENABLED(CONFIG_SPL_LOAD_FIT) &&
-	    image_get_magic((struct image_header *)buf) == FDT_MAGIC) {
+	    image_get_magic((struct legacy_img_hdr *)buf) == FDT_MAGIC) {
 		struct spl_load_info load;
 		struct ymodem_fit_info info;
 
@@ -147,7 +147,7 @@ int spl_ymodem_load_image(struct spl_image_info *spl_image,
 		while ((res = xyzModem_stream_read(buf, BUF_SIZE, &err)) > 0)
 			size += res;
 	} else {
-		ih = (struct image_header *)buf;
+		ih = (struct legacy_img_hdr *)buf;
 		ret = spl_parse_image_header(spl_image, bootdev, ih);
 		if (ret)
 			goto end_stream;
@@ -158,7 +158,7 @@ int spl_ymodem_load_image(struct spl_image_info *spl_image,
 #endif
 			addr = spl_image->load_addr;
 		memcpy((void *)addr, buf, res);
-		ih = (struct image_header *)addr;
+		ih = (struct legacy_img_hdr *)addr;
 		size += res;
 		addr += res;
 
@@ -177,7 +177,7 @@ end_stream:
 
 #ifdef CONFIG_SPL_GZIP
 	if (!(IS_ENABLED(CONFIG_SPL_LOAD_FIT) &&
-	      image_get_magic((struct image_header *)buf) == FDT_MAGIC) &&
+	      image_get_magic((struct legacy_img_hdr *)buf) == FDT_MAGIC) &&
 	    (ih->ih_comp == IH_COMP_GZIP)) {
 		if (gunzip((void *)(spl_image->load_addr + sizeof(*ih)),
 			   CONFIG_SYS_BOOTM_LEN,
diff --git a/common/splash_source.c b/common/splash_source.c
index 2c03cbdf928..87e55a54f8c 100644
--- a/common/splash_source.c
+++ b/common/splash_source.c
@@ -327,17 +327,17 @@ static int splash_load_fit(struct splash_location *location, u32 bmp_load_addr)
 	int external_splash_addr;
 	int external_splash_size;
 	bool is_splash_external = false;
-	struct image_header *img_header;
+	struct legacy_img_hdr *img_header;
 	const u32 *fit_header;
 	u32 fit_size;
-	const size_t header_size = sizeof(struct image_header);
+	const size_t header_size = sizeof(struct legacy_img_hdr);
 
 	/* Read in image header */
 	res = splash_storage_read_raw(location, bmp_load_addr, header_size);
 	if (res < 0)
 		return res;
 
-	img_header = (struct image_header *)bmp_load_addr;
+	img_header = (struct legacy_img_hdr *)bmp_load_addr;
 	if (image_get_magic(img_header) != FDT_MAGIC) {
 		printf("Could not find FDT magic\n");
 		return -EINVAL;
diff --git a/doc/uImage.FIT/source_file_format.txt b/doc/uImage.FIT/source_file_format.txt
index 68701118409..0a03c942bda 100644
--- a/doc/uImage.FIT/source_file_format.txt
+++ b/doc/uImage.FIT/source_file_format.txt
@@ -23,7 +23,7 @@ in the system memory and passed to bootm as a arguments. Some of them may be
 missing: FDT is not present for legacy platforms, ramdisk is always optional.
 Additionally, old uImage format has been extended to support multi sub-images
 but the support is limited by simple format of the legacy uImage structure.
-Single binary header 'struct image_header' is not flexible enough to cover all
+Single binary header 'struct legacy_img_hdr' is not flexible enough to cover all
 possible scenarios.
 
 All those factors combined clearly show that there is a need for new, more
diff --git a/drivers/fpga/socfpga_arria10.c b/drivers/fpga/socfpga_arria10.c
index d8089122af1..451d0b9b311 100644
--- a/drivers/fpga/socfpga_arria10.c
+++ b/drivers/fpga/socfpga_arria10.c
@@ -555,14 +555,14 @@ static int first_loading_rbf_to_buffer(struct udevice *dev,
 	/* Load image header into buffer */
 	ret = request_firmware_into_buf(dev,
 					fpga_loadfs->fpga_fsinfo->filename,
-					buffer_p, sizeof(struct image_header),
+					buffer_p, sizeof(struct legacy_img_hdr),
 					0);
 	if (ret < 0) {
 		debug("FPGA: Failed to read image header from flash.\n");
 		return -ENOENT;
 	}
 
-	if (image_get_magic((struct image_header *)buffer_p) != FDT_MAGIC) {
+	if (image_get_magic((struct legacy_img_hdr *)buffer_p) != FDT_MAGIC) {
 		debug("FPGA: No FDT magic was found.\n");
 		return -EBADF;
 	}
diff --git a/drivers/usb/gadget/f_sdp.c b/drivers/usb/gadget/f_sdp.c
index 0fa7230b992..3bfb772a71a 100644
--- a/drivers/usb/gadget/f_sdp.c
+++ b/drivers/usb/gadget/f_sdp.c
@@ -835,7 +835,7 @@ static int sdp_handle_in_ep(struct spl_image_info *spl_image,
 
 			printf("Found header at 0x%08x\n", sdp_func->jmp_address);
 
-			image_header_t *header =
+			struct legacy_img_hdr *header =
 				sdp_ptr(sdp_func->jmp_address);
 #ifdef CONFIG_SPL_LOAD_FIT
 			if (image_get_magic(header) == FDT_MAGIC) {
diff --git a/include/configs/uniphier.h b/include/configs/uniphier.h
index 15ae0844c1a..d9e95abcc12 100644
--- a/include/configs/uniphier.h
+++ b/include/configs/uniphier.h
@@ -169,7 +169,7 @@
 
 /* only for SPL */
 
-/* subtract sizeof(struct image_header) */
+/* subtract sizeof(struct legacy_img_hdr) */
 #define CONFIG_SYS_UBOOT_BASE			(0x130000 - 0x40)
 
 #endif /* __CONFIG_UNIPHIER_H__ */
diff --git a/include/image.h b/include/image.h
index e1a65cce7ba..b336cfa0842 100644
--- a/include/image.h
+++ b/include/image.h
@@ -263,7 +263,7 @@ enum {
  * Legacy format image header,
  * all data in network byte order (aka natural aka bigendian).
  */
-typedef struct image_header {
+struct legacy_img_hdr {
 	uint32_t	ih_magic;	/* Image Header Magic Number	*/
 	uint32_t	ih_hcrc;	/* Image Header CRC Checksum	*/
 	uint32_t	ih_time;	/* Image Creation Timestamp	*/
@@ -276,7 +276,7 @@ typedef struct image_header {
 	uint8_t		ih_type;	/* Image Type			*/
 	uint8_t		ih_comp;	/* Compression Type		*/
 	uint8_t		ih_name[IH_NMLEN];	/* Image Name		*/
-} image_header_t;
+};
 
 struct image_info {
 	ulong		start, end;		/* start/end of blob */
@@ -296,8 +296,8 @@ struct bootm_headers {
 	 * then boot_get_ramdisk() and get_fdt() will attempt to get
 	 * data from second and third component accordingly.
 	 */
-	image_header_t	*legacy_hdr_os;		/* image header pointer */
-	image_header_t	legacy_hdr_os_copy;	/* header copy */
+	struct legacy_img_hdr	*legacy_hdr_os;		/* image header pointer */
+	struct legacy_img_hdr	legacy_hdr_os_copy;	/* header copy */
 	ulong		legacy_hdr_valid;
 
 	/*
@@ -696,11 +696,11 @@ int boot_get_kbd(struct lmb *lmb, struct bd_info **kbd);
 /*******************************************************************/
 static inline uint32_t image_get_header_size(void)
 {
-	return (sizeof(image_header_t));
+	return sizeof(struct legacy_img_hdr);
 }
 
 #define image_get_hdr_l(f) \
-	static inline uint32_t image_get_##f(const image_header_t *hdr) \
+	static inline uint32_t image_get_##f(const struct legacy_img_hdr *hdr) \
 	{ \
 		return uimage_to_cpu(hdr->ih_##f); \
 	}
@@ -713,7 +713,7 @@ image_get_hdr_l(ep)		/* image_get_ep */
 image_get_hdr_l(dcrc)		/* image_get_dcrc */
 
 #define image_get_hdr_b(f) \
-	static inline uint8_t image_get_##f(const image_header_t *hdr) \
+	static inline uint8_t image_get_##f(const struct legacy_img_hdr *hdr) \
 	{ \
 		return hdr->ih_##f; \
 	}
@@ -722,12 +722,12 @@ image_get_hdr_b(arch)		/* image_get_arch */
 image_get_hdr_b(type)		/* image_get_type */
 image_get_hdr_b(comp)		/* image_get_comp */
 
-static inline char *image_get_name(const image_header_t *hdr)
+static inline char *image_get_name(const struct legacy_img_hdr *hdr)
 {
 	return (char *)hdr->ih_name;
 }
 
-static inline uint32_t image_get_data_size(const image_header_t *hdr)
+static inline uint32_t image_get_data_size(const struct legacy_img_hdr *hdr)
 {
 	return image_get_size(hdr);
 }
@@ -743,22 +743,23 @@ static inline uint32_t image_get_data_size(const image_header_t *hdr)
  * returns:
  *     image payload data start address
  */
-static inline ulong image_get_data(const image_header_t *hdr)
+static inline ulong image_get_data(const struct legacy_img_hdr *hdr)
 {
 	return ((ulong)hdr + image_get_header_size());
 }
 
-static inline uint32_t image_get_image_size(const image_header_t *hdr)
+static inline uint32_t image_get_image_size(const struct legacy_img_hdr *hdr)
 {
 	return (image_get_size(hdr) + image_get_header_size());
 }
-static inline ulong image_get_image_end(const image_header_t *hdr)
+
+static inline ulong image_get_image_end(const struct legacy_img_hdr *hdr)
 {
 	return ((ulong)hdr + image_get_image_size(hdr));
 }
 
 #define image_set_hdr_l(f) \
-	static inline void image_set_##f(image_header_t *hdr, uint32_t val) \
+	static inline void image_set_##f(struct legacy_img_hdr *hdr, uint32_t val) \
 	{ \
 		hdr->ih_##f = cpu_to_uimage(val); \
 	}
@@ -771,7 +772,7 @@ image_set_hdr_l(ep)		/* image_set_ep */
 image_set_hdr_l(dcrc)		/* image_set_dcrc */
 
 #define image_set_hdr_b(f) \
-	static inline void image_set_##f(image_header_t *hdr, uint8_t val) \
+	static inline void image_set_##f(struct legacy_img_hdr *hdr, uint8_t val) \
 	{ \
 		hdr->ih_##f = val; \
 	}
@@ -780,13 +781,13 @@ image_set_hdr_b(arch)		/* image_set_arch */
 image_set_hdr_b(type)		/* image_set_type */
 image_set_hdr_b(comp)		/* image_set_comp */
 
-static inline void image_set_name(image_header_t *hdr, const char *name)
+static inline void image_set_name(struct legacy_img_hdr *hdr, const char *name)
 {
 	strncpy(image_get_name(hdr), name, IH_NMLEN);
 }
 
-int image_check_hcrc(const image_header_t *hdr);
-int image_check_dcrc(const image_header_t *hdr);
+int image_check_hcrc(const struct legacy_img_hdr *hdr);
+int image_check_dcrc(const struct legacy_img_hdr *hdr);
 #ifndef USE_HOSTCC
 ulong env_get_bootm_low(void);
 phys_size_t env_get_bootm_size(void);
@@ -794,15 +795,17 @@ phys_size_t env_get_bootm_mapsize(void);
 #endif
 void memmove_wd(void *to, void *from, size_t len, ulong chunksz);
 
-static inline int image_check_magic(const image_header_t *hdr)
+static inline int image_check_magic(const struct legacy_img_hdr *hdr)
 {
 	return (image_get_magic(hdr) == IH_MAGIC);
 }
-static inline int image_check_type(const image_header_t *hdr, uint8_t type)
+
+static inline int image_check_type(const struct legacy_img_hdr *hdr, uint8_t type)
 {
 	return (image_get_type(hdr) == type);
 }
-static inline int image_check_arch(const image_header_t *hdr, uint8_t arch)
+
+static inline int image_check_arch(const struct legacy_img_hdr *hdr, uint8_t arch)
 {
 	/* Let's assume that sandbox can load any architecture */
 	if (!tools_build() && IS_ENABLED(CONFIG_SANDBOX))
@@ -810,19 +813,20 @@ static inline int image_check_arch(const image_header_t *hdr, uint8_t arch)
 	return (image_get_arch(hdr) == arch) ||
 		(image_get_arch(hdr) == IH_ARCH_ARM && arch == IH_ARCH_ARM64);
 }
-static inline int image_check_os(const image_header_t *hdr, uint8_t os)
+
+static inline int image_check_os(const struct legacy_img_hdr *hdr, uint8_t os)
 {
 	return (image_get_os(hdr) == os);
 }
 
-ulong image_multi_count(const image_header_t *hdr);
-void image_multi_getimg(const image_header_t *hdr, ulong idx,
+ulong image_multi_count(const struct legacy_img_hdr *hdr);
+void image_multi_getimg(const struct legacy_img_hdr *hdr, ulong idx,
 			ulong *data, ulong *len);
 
 void image_print_contents(const void *hdr);
 
 #ifndef USE_HOSTCC
-static inline int image_check_target_arch(const image_header_t *hdr)
+static inline int image_check_target_arch(const struct legacy_img_hdr *hdr)
 {
 #ifndef IH_ARCH_DEFAULT
 # error "please define IH_ARCH_DEFAULT in your arch asm/u-boot.h"
diff --git a/include/spl.h b/include/spl.h
index aac6648f946..0fc3686bbca 100644
--- a/include/spl.h
+++ b/include/spl.h
@@ -17,7 +17,7 @@
 #include <mmc.h>
 
 struct blk_desc;
-struct image_header;
+struct legacy_img_hdr;
 
 /* Value in r0 indicates we booted from U-Boot */
 #define UBOOT_NOT_LOADED_FROM_SPL	0x13578642
@@ -29,7 +29,7 @@ struct image_header;
 #define MMCSD_MODE_EMMCBOOT	3
 
 struct blk_desc;
-struct image_header;
+struct legacy_img_hdr;
 struct spl_boot_device;
 
 /*
@@ -476,7 +476,7 @@ void spl_set_header_raw_uboot(struct spl_image_info *spl_image);
  */
 int spl_parse_image_header(struct spl_image_info *spl_image,
 			   const struct spl_boot_device *bootdev,
-			   const struct image_header *header);
+			   const struct legacy_img_hdr *header);
 
 void spl_board_prepare_for_linux(void);
 
@@ -865,7 +865,7 @@ void spl_perform_fixups(struct spl_image_info *spl_image);
  * Returns memory area which can be populated by partial image data,
  * ie. uImage or fitImage header.
  */
-struct image_header *spl_get_load_buffer(ssize_t offset, size_t size);
+struct legacy_img_hdr *spl_get_load_buffer(ssize_t offset, size_t size);
 
 void spl_save_restore_data(void);
 #endif
diff --git a/include/tee/optee.h b/include/tee/optee.h
index 5412bc7386e..77729450bb6 100644
--- a/include/tee/optee.h
+++ b/include/tee/optee.h
@@ -30,7 +30,7 @@ struct optee_header {
 };
 
 static inline uint32_t
-optee_image_get_entry_point(const struct image_header *hdr)
+optee_image_get_entry_point(const struct legacy_img_hdr *hdr)
 {
 	struct optee_header *optee_hdr = (struct optee_header *)(hdr + 1);
 
@@ -38,7 +38,7 @@ optee_image_get_entry_point(const struct image_header *hdr)
 }
 
 static inline uint32_t
-optee_image_get_load_addr(const struct image_header *hdr)
+optee_image_get_load_addr(const struct legacy_img_hdr *hdr)
 {
 	return optee_image_get_entry_point(hdr) - sizeof(struct optee_header);
 }
diff --git a/test/image/spl_load.c b/test/image/spl_load.c
index df389e26f90..4e27ff460ab 100644
--- a/test/image/spl_load.c
+++ b/test/image/spl_load.c
@@ -49,7 +49,7 @@ int board_fit_config_name_match(const char *name)
 	return 0;
 }
 
-struct image_header *spl_get_load_buffer(ssize_t offset, size_t size)
+struct legacy_img_hdr *spl_get_load_buffer(ssize_t offset, size_t size)
 {
 	return map_sysmem(0x100000, 0);
 }
@@ -57,7 +57,7 @@ struct image_header *spl_get_load_buffer(ssize_t offset, size_t size)
 static int spl_test_load(struct unit_test_state *uts)
 {
 	struct spl_image_info image;
-	struct image_header *header;
+	struct legacy_img_hdr *header;
 	struct text_ctx text_ctx;
 	struct spl_load_info load;
 	char fname[256];
diff --git a/tools/binman/ftest.py b/tools/binman/ftest.py
index 5422940e07e..6b4ef725770 100644
--- a/tools/binman/ftest.py
+++ b/tools/binman/ftest.py
@@ -5761,7 +5761,7 @@ fdt         fdtmap                Extract the devicetree blob from the fdtmap
         # Check that the data appears in the file somewhere
         self.assertIn(U_BOOT_SPL_DATA, data)
 
-        # Get struct image_header -> ih_name
+        # Get struct legacy_img_hdr -> ih_name
         name = data[0x20:0x40]
 
         # Build the filename that we expect to be placed in there, by virtue of
@@ -5778,7 +5778,7 @@ fdt         fdtmap                Extract the devicetree blob from the fdtmap
         # Check that the data appears in the file somewhere
         self.assertIn(U_BOOT_SPL_DATA, data)
 
-        # Get struct image_header -> ih_name
+        # Get struct legacy_img_hdr -> ih_name
         name = data[0x20:0x40]
 
         # Build the filename that we expect to be placed in there, by virtue of
diff --git a/tools/default_image.c b/tools/default_image.c
index e164c0c27d1..4a067e65862 100644
--- a/tools/default_image.c
+++ b/tools/default_image.c
@@ -22,7 +22,7 @@
 #include <u-boot/crc.h>
 #include <imximage.h>
 
-static image_header_t header;
+static struct legacy_img_hdr header;
 
 static int image_check_image_types(uint8_t type)
 {
@@ -46,15 +46,15 @@ static int image_verify_header(unsigned char *ptr, int image_size,
 	uint32_t len;
 	const unsigned char *data;
 	uint32_t checksum;
-	image_header_t header;
-	image_header_t *hdr = &header;
+	struct legacy_img_hdr header;
+	struct legacy_img_hdr *hdr = &header;
 
 	/*
 	 * create copy of header so that we can blank out the
 	 * checksum field for checking - this can't be done
 	 * on the PROT_READ mapped data.
 	 */
-	memcpy(hdr, ptr, sizeof(image_header_t));
+	memcpy(hdr, ptr, sizeof(struct legacy_img_hdr));
 
 	if (be32_to_cpu(hdr->ih_magic) != IH_MAGIC) {
 		debug("%s: Bad Magic Number: \"%s\" is no valid image\n",
@@ -63,7 +63,7 @@ static int image_verify_header(unsigned char *ptr, int image_size,
 	}
 
 	data = (const unsigned char *)hdr;
-	len  = sizeof(image_header_t);
+	len  = sizeof(struct legacy_img_hdr);
 
 	checksum = be32_to_cpu(hdr->ih_hcrc);
 	hdr->ih_hcrc = cpu_to_be32(0);	/* clear for re-calculation */
@@ -74,8 +74,8 @@ static int image_verify_header(unsigned char *ptr, int image_size,
 		return -FDT_ERR_BADSTATE;
 	}
 
-	data = (const unsigned char *)ptr + sizeof(image_header_t);
-	len  = image_size - sizeof(image_header_t) ;
+	data = (const unsigned char *)ptr + sizeof(struct legacy_img_hdr);
+	len  = image_size - sizeof(struct legacy_img_hdr);
 
 	checksum = be32_to_cpu(hdr->ih_dcrc);
 	if (crc32(0, data, len) != checksum) {
@@ -94,13 +94,12 @@ static void image_set_header(void *ptr, struct stat *sbuf, int ifd,
 	uint32_t imagesize;
 	uint32_t ep;
 	uint32_t addr;
-
-	image_header_t * hdr = (image_header_t *)ptr;
+	struct legacy_img_hdr *hdr = (struct legacy_img_hdr *)ptr;
 
 	checksum = crc32(0,
 			(const unsigned char *)(ptr +
-				sizeof(image_header_t)),
-			sbuf->st_size - sizeof(image_header_t));
+				sizeof(struct legacy_img_hdr)),
+			sbuf->st_size - sizeof(struct legacy_img_hdr));
 
 	time = imagetool_get_source_date(params->cmdname, sbuf->st_mtime);
 	ep = params->ep;
@@ -108,11 +107,11 @@ static void image_set_header(void *ptr, struct stat *sbuf, int ifd,
 
 	if (params->type == IH_TYPE_FIRMWARE_IVT)
 		/* Add size of CSF minus IVT */
-		imagesize = sbuf->st_size - sizeof(image_header_t)
+		imagesize = sbuf->st_size - sizeof(struct legacy_img_hdr)
 			    + 0x2060 - sizeof(flash_header_v2_t);
 
 	else
-		imagesize = sbuf->st_size - sizeof(image_header_t);
+		imagesize = sbuf->st_size - sizeof(struct legacy_img_hdr);
 
 	if (params->os == IH_OS_TEE) {
 		addr = optee_image_get_load_addr(hdr);
@@ -134,14 +133,14 @@ static void image_set_header(void *ptr, struct stat *sbuf, int ifd,
 	image_set_name(hdr, params->imagename);
 
 	checksum = crc32(0, (const unsigned char *)hdr,
-				sizeof(image_header_t));
+				sizeof(struct legacy_img_hdr));
 
 	image_set_hcrc(hdr, checksum);
 }
 
 static int image_extract_subimage(void *ptr, struct image_tool_params *params)
 {
-	const image_header_t *hdr = (const image_header_t *)ptr;
+	const struct legacy_img_hdr *hdr = (const struct legacy_img_hdr *)ptr;
 	ulong file_data;
 	ulong file_len;
 
@@ -175,7 +174,7 @@ static int image_extract_subimage(void *ptr, struct image_tool_params *params)
 U_BOOT_IMAGE_TYPE(
 	defimage,
 	"Default Image support",
-	sizeof(image_header_t),
+	sizeof(struct legacy_img_hdr),
 	(void *)&header,
 	image_check_params,
 	image_verify_header,
diff --git a/tools/fit_image.c b/tools/fit_image.c
index 979f2411ee0..923a9755b70 100644
--- a/tools/fit_image.c
+++ b/tools/fit_image.c
@@ -22,7 +22,7 @@
 #include <version.h>
 #include <u-boot/crc.h>
 
-static image_header_t header;
+static struct legacy_img_hdr header;
 
 static int fit_add_file_data(struct image_tool_params *params, size_t size_inc,
 			     const char *tmpfile)
@@ -915,7 +915,7 @@ static int fit_check_params(struct image_tool_params *params)
 U_BOOT_IMAGE_TYPE(
 	fitimage,
 	"FIT Image support",
-	sizeof(image_header_t),
+	sizeof(struct legacy_img_hdr),
 	(void *)&header,
 	fit_check_params,
 	fit_verify_header,
diff --git a/tools/imx8mimage.c b/tools/imx8mimage.c
index a4699decf92..35d0a92bfdf 100644
--- a/tools/imx8mimage.c
+++ b/tools/imx8mimage.c
@@ -318,7 +318,7 @@ err_mmap:
 static int generate_ivt_for_fit(int fd, int fit_offset, uint32_t ep,
 				uint32_t *fit_load_addr)
 {
-	image_header_t image_header;
+	struct legacy_img_hdr image_header;
 	int ret;
 
 	uint32_t fit_size, load_addr;
@@ -330,8 +330,8 @@ static int generate_ivt_for_fit(int fd, int fit_offset, uint32_t ep,
 		exit(EXIT_FAILURE);
 	}
 
-	if (read(fd, (char *)&image_header, sizeof(image_header_t)) !=
-	    sizeof(image_header_t)) {
+	if (read(fd, (char *)&image_header, sizeof(struct legacy_img_hdr)) !=
+	    sizeof(struct legacy_img_hdr)) {
 		fprintf(stderr, "generate_ivt_for_fit read failed: %s\n",
 			strerror(errno));
 		exit(EXIT_FAILURE);
@@ -600,7 +600,7 @@ void build_image(int ofd)
 			close(sld_fd);
 
 			file_off = sld_header_off;
-			file_off += sbuf.st_size + sizeof(image_header_t);
+			file_off += sbuf.st_size + sizeof(struct legacy_img_hdr);
 		}
 	}
 
diff --git a/tools/mkimage.c b/tools/mkimage.c
index 597cb3a5ced..30c6df77081 100644
--- a/tools/mkimage.c
+++ b/tools/mkimage.c
@@ -845,7 +845,7 @@ copy_file (int ifd, const char *datafile, int pad)
 	if (params.xflag) {
 		unsigned char *p = NULL;
 		/*
-		 * XIP: do not append the image_header_t at the
+		 * XIP: do not append the struct legacy_img_hdr at the
 		 * beginning of the file, but consume the space
 		 * reserved for it.
 		 */
diff --git a/tools/mtk_image.c b/tools/mtk_image.c
index de5ce4d964c..0e031876c89 100644
--- a/tools/mtk_image.c
+++ b/tools/mtk_image.c
@@ -647,10 +647,10 @@ static uint32_t crc32be_cal(const void *data, size_t length)
 
 static int mtk_image_verify_mt7621_header(const uint8_t *ptr, int print)
 {
-	const image_header_t *hdr = (const image_header_t *)ptr;
+	const struct legacy_img_hdr *hdr = (const struct legacy_img_hdr *)ptr;
 	struct mt7621_nand_header *nhdr;
 	uint32_t spl_size, crcval;
-	image_header_t header;
+	struct legacy_img_hdr header;
 	int ret;
 
 	spl_size = image_get_size(hdr);
@@ -710,7 +710,7 @@ static int mtk_image_verify_mt7621_header(const uint8_t *ptr, int print)
 static int mtk_image_verify_header(unsigned char *ptr, int image_size,
 				   struct image_tool_params *params)
 {
-	image_header_t *hdr = (image_header_t *)ptr;
+	struct legacy_img_hdr *hdr = (struct legacy_img_hdr *)ptr;
 	union lk_hdr *lk = (union lk_hdr *)ptr;
 
 	/* nothing to verify for LK image header */
@@ -732,7 +732,7 @@ static int mtk_image_verify_header(unsigned char *ptr, int image_size,
 
 static void mtk_image_print_header(const void *ptr)
 {
-	image_header_t *hdr = (image_header_t *)ptr;
+	struct legacy_img_hdr *hdr = (struct legacy_img_hdr *)ptr;
 	union lk_hdr *lk = (union lk_hdr *)ptr;
 
 	if (le32_to_cpu(lk->magic) == LK_PART_MAGIC) {
@@ -914,7 +914,7 @@ static void mtk_image_set_nand_header(void *ptr, off_t filesize,
 static void mtk_image_set_mt7621_header(void *ptr, off_t filesize,
 					uint32_t loadaddr)
 {
-	image_header_t *hdr = (image_header_t *)ptr;
+	struct legacy_img_hdr *hdr = (struct legacy_img_hdr *)ptr;
 	struct mt7621_stage1_header *shdr;
 	struct mt7621_nand_header *nhdr;
 	uint32_t datasize, crcval;
-- 
2.37.2.672.g94769d06f0-goog


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

* [PATCH 05/21] event: Fix a typo in the EVENT help
  2022-08-31  3:07 [PATCH 00/21] dm: core: Support multiple device trees in ofnode Simon Glass
                   ` (3 preceding siblings ...)
  2022-08-31  3:08 ` [PATCH 04/21] treewide: Drop image_header_t typedef Simon Glass
@ 2022-08-31  3:08 ` Simon Glass
  2022-08-31  3:08 ` [PATCH 06/21] dm: core: Pass a root node to of_find_node_by_phandle() Simon Glass
                   ` (15 subsequent siblings)
  20 siblings, 0 replies; 23+ messages in thread
From: Simon Glass @ 2022-08-31  3:08 UTC (permalink / raw)
  To: U-Boot Mailing List
  Cc: Michal Simek, Marek Behún, Kishon Vijay Abraham I, Tom Rini,
	Simon Glass

Fix the help message.

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

 common/Kconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/common/Kconfig b/common/Kconfig
index e7914ca750a..5cfa63b0db1 100644
--- a/common/Kconfig
+++ b/common/Kconfig
@@ -551,7 +551,7 @@ config EVENT
 	help
 	  This enables sending and processing of events, to allow interested
 	  parties to be alerted when something happens. This is an attempt to
-	  step the flow of weak functions, hooks, functions in board_f.c
+	  stem the flow of weak functions, hooks, functions in board_f.c
 	  and board_r.c and the Kconfig options below.
 
 	  See doc/develop/event.rst for more information.
-- 
2.37.2.672.g94769d06f0-goog


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

* [PATCH 06/21] dm: core: Pass a root node to of_find_node_by_phandle()
  2022-08-31  3:07 [PATCH 00/21] dm: core: Support multiple device trees in ofnode Simon Glass
                   ` (4 preceding siblings ...)
  2022-08-31  3:08 ` [PATCH 05/21] event: Fix a typo in the EVENT help Simon Glass
@ 2022-08-31  3:08 ` Simon Glass
  2022-08-31  3:08 ` [PATCH 07/21] event: Pass the images to EVT_FT_FIXUP Simon Glass
                   ` (14 subsequent siblings)
  20 siblings, 0 replies; 23+ messages in thread
From: Simon Glass @ 2022-08-31  3:08 UTC (permalink / raw)
  To: U-Boot Mailing List
  Cc: Michal Simek, Marek Behún, Kishon Vijay Abraham I, Tom Rini,
	Simon Glass, Marek Vasut, Pavel Herrmann

This function currently assumes that the control FDT is used. Update it
to allow a root node to be passed, so it can work with any tree.

Also add a comment to ofnode_get_by_phandle() so that its purpose is
clear.

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

 drivers/core/of_access.c | 7 ++++---
 drivers/core/ofnode.c    | 2 +-
 include/dm/of_access.h   | 4 +++-
 include/dm/ofnode.h      | 2 ++
 4 files changed, 10 insertions(+), 5 deletions(-)

diff --git a/drivers/core/of_access.c b/drivers/core/of_access.c
index a52f5a6b18b..ee09bbb7550 100644
--- a/drivers/core/of_access.c
+++ b/drivers/core/of_access.c
@@ -445,14 +445,15 @@ struct device_node *of_find_node_by_prop_value(struct device_node *from,
 	return np;
 }
 
-struct device_node *of_find_node_by_phandle(phandle handle)
+struct device_node *of_find_node_by_phandle(struct device_node *root,
+					    phandle handle)
 {
 	struct device_node *np;
 
 	if (!handle)
 		return NULL;
 
-	for_each_of_allnodes(np)
+	for_each_of_allnodes_from(root, np)
 		if (np->phandle == handle)
 			break;
 	(void)of_node_get(np);
@@ -659,7 +660,7 @@ static int __of_parse_phandle_with_args(const struct device_node *np,
 			 * below.
 			 */
 			if (cells_name || cur_index == index) {
-				node = of_find_node_by_phandle(phandle);
+				node = of_find_node_by_phandle(NULL, phandle);
 				if (!node) {
 					debug("%s: could not find phandle\n",
 					      np->full_name);
diff --git a/drivers/core/ofnode.c b/drivers/core/ofnode.c
index 45ea84e9fb8..bf8eaf6d09a 100644
--- a/drivers/core/ofnode.c
+++ b/drivers/core/ofnode.c
@@ -329,7 +329,7 @@ ofnode ofnode_get_by_phandle(uint phandle)
 	ofnode node;
 
 	if (of_live_active())
-		node = np_to_ofnode(of_find_node_by_phandle(phandle));
+		node = np_to_ofnode(of_find_node_by_phandle(NULL, phandle));
 	else
 		node.of_offset = fdt_node_offset_by_phandle(gd->fdt_blob,
 							    phandle);
diff --git a/include/dm/of_access.h b/include/dm/of_access.h
index 5b7821d0a1b..c0ac91a416a 100644
--- a/include/dm/of_access.h
+++ b/include/dm/of_access.h
@@ -258,11 +258,13 @@ struct device_node *of_find_node_by_prop_value(struct device_node *from,
 /**
  * of_find_node_by_phandle() - Find a node given a phandle
  *
+ * @root:	root node to start from (NULL for default device tree)
  * @handle:	phandle of the node to find
  *
  * Return: node pointer, or NULL if not found
  */
-struct device_node *of_find_node_by_phandle(phandle handle);
+struct device_node *of_find_node_by_phandle(struct device_node *root,
+					    phandle handle);
 
 /**
  * of_read_u32() - Find and read a 32-bit integer from a property
diff --git a/include/dm/ofnode.h b/include/dm/ofnode.h
index 7ce1e4c6d91..018ee70c2ff 100644
--- a/include/dm/ofnode.h
+++ b/include/dm/ofnode.h
@@ -461,6 +461,8 @@ int ofnode_get_path(ofnode node, char *buf, int buflen);
 /**
  * ofnode_get_by_phandle() - get ofnode from phandle
  *
+ * This uses the default (control) device tree
+ *
  * @phandle:	phandle to look up
  * Return: ofnode reference to the phandle
  */
-- 
2.37.2.672.g94769d06f0-goog


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

* [PATCH 07/21] event: Pass the images to EVT_FT_FIXUP
  2022-08-31  3:07 [PATCH 00/21] dm: core: Support multiple device trees in ofnode Simon Glass
                   ` (5 preceding siblings ...)
  2022-08-31  3:08 ` [PATCH 06/21] dm: core: Pass a root node to of_find_node_by_phandle() Simon Glass
@ 2022-08-31  3:08 ` Simon Glass
  2022-08-31  3:08 ` [PATCH 08/21] dm: core: Allow adding ofnode subnodes Simon Glass
                   ` (13 subsequent siblings)
  20 siblings, 0 replies; 23+ messages in thread
From: Simon Glass @ 2022-08-31  3:08 UTC (permalink / raw)
  To: U-Boot Mailing List
  Cc: Michal Simek, Marek Behún, Kishon Vijay Abraham I, Tom Rini,
	Simon Glass, Alexandru Gagniuc, Artem Lapkin, Daniel Golle,
	Heinrich Schuchardt, Marek Vasut

Pass the boot images along as well, in case the fixups need to look at
them.

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

 boot/image-fdt.c | 1 +
 include/event.h  | 2 ++
 2 files changed, 3 insertions(+)

diff --git a/boot/image-fdt.c b/boot/image-fdt.c
index ca51796322d..884e089f2d8 100644
--- a/boot/image-fdt.c
+++ b/boot/image-fdt.c
@@ -669,6 +669,7 @@ int image_setup_libfdt(struct bootm_headers *images, void *blob,
 		struct event_ft_fixup fixup;
 
 		fixup.tree = oftree_default();
+		fixup.images = images;
 		ret = event_notify(EVT_FT_FIXUP, &fixup, sizeof(fixup));
 		if (ret) {
 			printf("ERROR: fdt fixup event failed: %d\n", ret);
diff --git a/include/event.h b/include/event.h
index e8f2f55c63d..720fe8ae695 100644
--- a/include/event.h
+++ b/include/event.h
@@ -60,9 +60,11 @@ union event_data {
 	 * struct event_ft_fixup - FDT fixup before booting
 	 *
 	 * @tree: tree to update
+	 * @images: images which are being booted
 	 */
 	struct event_ft_fixup {
 		oftree tree;
+		struct bootm_headers *images;
 	} ft_fixup;
 };
 
-- 
2.37.2.672.g94769d06f0-goog


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

* [PATCH 08/21] dm: core: Allow adding ofnode subnodes
  2022-08-31  3:07 [PATCH 00/21] dm: core: Support multiple device trees in ofnode Simon Glass
                   ` (6 preceding siblings ...)
  2022-08-31  3:08 ` [PATCH 07/21] event: Pass the images to EVT_FT_FIXUP Simon Glass
@ 2022-08-31  3:08 ` Simon Glass
  2022-09-01  7:07   ` Rasmus Villemoes
  2022-08-31  3:08 ` [PATCH 09/21] dm: core: Support writing a property to an empty node Simon Glass
                   ` (12 subsequent siblings)
  20 siblings, 1 reply; 23+ messages in thread
From: Simon Glass @ 2022-08-31  3:08 UTC (permalink / raw)
  To: U-Boot Mailing List
  Cc: Michal Simek, Marek Behún, Kishon Vijay Abraham I, Tom Rini,
	Simon Glass, Marek Vasut, Pavel Herrmann

Add this feature to the ofnode interface, supporting both livetree and
flattree.

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

 drivers/core/of_access.c | 50 ++++++++++++++++++++++++++++++++++++++++
 drivers/core/ofnode.c    | 30 ++++++++++++++++++++++++
 include/dm/of_access.h   | 12 ++++++++++
 include/dm/ofnode.h      | 12 ++++++++++
 test/dm/ofnode.c         | 17 ++++++++++++++
 5 files changed, 121 insertions(+)

diff --git a/drivers/core/of_access.c b/drivers/core/of_access.c
index ee09bbb7550..765b21cecdb 100644
--- a/drivers/core/of_access.c
+++ b/drivers/core/of_access.c
@@ -931,3 +931,53 @@ int of_write_prop(struct device_node *np, const char *propname, int len,
 
 	return 0;
 }
+
+int of_add_subnode(struct device_node *parent, const char *name, int len,
+		   struct device_node **childp)
+{
+	struct device_node *child, *new, *last_sibling = NULL;
+	char *new_name, *full_name;
+	int parent_fnl;
+
+	__for_each_child_of_node(parent, child) {
+		if (!strncmp(child->name, name, len) && strlen(name) == len)
+			return -EEXIST;
+		last_sibling = child;
+	}
+
+	/* Property does not exist -> append new property */
+	new = calloc(1, sizeof(struct device_node));
+	if (!new)
+		return -ENOMEM;
+
+	new_name = malloc(len + 1);
+	if (!name) {
+		free(new);
+		return -ENOMEM;
+	}
+	strlcpy(new_name, name, len + 1);
+	new->name = new_name;
+
+	parent_fnl = parent->name ? strlen(parent->full_name) : 0;
+	full_name = calloc(1, parent_fnl + 1 + len + 1);
+	if (!full_name) {
+		free(new_name);
+		free(new);
+		return -ENOMEM;
+	}
+	strcpy(full_name, parent->full_name);
+	full_name[parent_fnl] = '/';
+	strlcpy(&full_name[parent_fnl + 1], name, len + 1);
+	new->full_name = full_name;
+
+	/* Add as last sibling of the parent */
+	if (last_sibling)
+		last_sibling->sibling = new;
+	if (!parent->child)
+		parent->child = new;
+	new->parent = parent;
+
+	*childp = new;
+
+	return 0;
+}
diff --git a/drivers/core/ofnode.c b/drivers/core/ofnode.c
index bf8eaf6d09a..f01bfac8f69 100644
--- a/drivers/core/ofnode.c
+++ b/drivers/core/ofnode.c
@@ -1227,3 +1227,33 @@ phy_interface_t ofnode_read_phy_mode(ofnode node)
 
 	return PHY_INTERFACE_MODE_NA;
 }
+
+int ofnode_add_subnode(ofnode node, const char *name, ofnode *subnodep)
+{
+	ofnode subnode;
+	int ret;
+
+	assert(ofnode_valid(node));
+
+	if (ofnode_is_np(node)) {
+		struct device_node *np, *child;
+
+		np = (struct device_node *)ofnode_to_np(node);
+		ret = of_add_subnode(np, name, strlen(name), &child);
+		if (ret)
+			return ret;
+		subnode = np_to_ofnode(child);
+	} else {
+		int offset;
+
+		offset = fdt_add_subnode((void *)gd->fdt_blob,
+					 ofnode_to_offset(node), name);
+		if (offset < 0)
+			return offset == -FDT_ERR_EXISTS ? -EEXIST : 0;
+		subnode = offset_to_ofnode(offset);
+	}
+
+	*subnodep = subnode;
+
+	return 0;
+}
diff --git a/include/dm/of_access.h b/include/dm/of_access.h
index c0ac91a416a..20bf588be45 100644
--- a/include/dm/of_access.h
+++ b/include/dm/of_access.h
@@ -533,4 +533,16 @@ struct device_node *of_get_stdout(void);
 int of_write_prop(struct device_node *np, const char *propname, int len,
 		  const void *value);
 
+/**
+ * of_add_subnode() - add a new subnode to a node
+ *
+ * @node:	parent node to add to
+ * @name:	name of subnode
+ * @len:	length of name
+ * @subnodep:	returns pointer to new subnode
+ * Returns 0 if OK, -ve on error
+ */
+int of_add_subnode(struct device_node *node, const char *name, int len,
+		   struct device_node **subnodep);
+
 #endif
diff --git a/include/dm/ofnode.h b/include/dm/ofnode.h
index 018ee70c2ff..ebef8a6e2bb 100644
--- a/include/dm/ofnode.h
+++ b/include/dm/ofnode.h
@@ -1260,6 +1260,18 @@ static inline const char *ofnode_conf_read_str(const char *prop_name)
 {
 	return NULL;
 }
+
 #endif /* CONFIG_DM */
 
+/**
+ * of_add_subnode() - add a new subnode to a node
+ *
+ * @parent:	parent node to add to
+ * @name:	name of subnode
+ * @nodep:	returns pointer to new subnode
+ * Returns 0 if OK, -EEXIST if already exists, -ENOMEM if out of memory, other
+ * -ve on other error
+ */
+int ofnode_add_subnode(ofnode parent, const char *name, ofnode *nodep);
+
 #endif
diff --git a/test/dm/ofnode.c b/test/dm/ofnode.c
index f80993f8927..f5aabf42dbb 100644
--- a/test/dm/ofnode.c
+++ b/test/dm/ofnode.c
@@ -601,3 +601,20 @@ static int dm_test_ofnode_u32(struct unit_test_state *uts)
 }
 DM_TEST(dm_test_ofnode_u32,
 	UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT | UT_TESTF_LIVE_OR_FLAT);
+
+static int dm_test_ofnode_add_subnode(struct unit_test_state *uts)
+{
+	ofnode node, check, subnode;
+
+	node = ofnode_path("/lcd");
+	ut_assert(ofnode_valid(node));
+	ut_assertok(ofnode_add_subnode(node, "edmund", &subnode));
+	check = ofnode_path("/lcd/edmund");
+	ut_asserteq(check.of_offset, subnode.of_offset);
+
+	ut_asserteq(-EEXIST, ofnode_add_subnode(node, "edmund", &subnode));
+
+	return 0;
+}
+DM_TEST(dm_test_ofnode_add_subnode,
+	UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT | UT_TESTF_LIVE_OR_FLAT);
-- 
2.37.2.672.g94769d06f0-goog


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

* [PATCH 09/21] dm: core: Support writing a property to an empty node
  2022-08-31  3:07 [PATCH 00/21] dm: core: Support multiple device trees in ofnode Simon Glass
                   ` (7 preceding siblings ...)
  2022-08-31  3:08 ` [PATCH 08/21] dm: core: Allow adding ofnode subnodes Simon Glass
@ 2022-08-31  3:08 ` Simon Glass
  2022-08-31  3:08 ` [PATCH 10/21] dm: core: Drop the const from ofnode Simon Glass
                   ` (11 subsequent siblings)
  20 siblings, 0 replies; 23+ messages in thread
From: Simon Glass @ 2022-08-31  3:08 UTC (permalink / raw)
  To: U-Boot Mailing List
  Cc: Michal Simek, Marek Behún, Kishon Vijay Abraham I, Tom Rini,
	Simon Glass, Marek Vasut, Pavel Herrmann

At present this does not work with livetree. Fix it and add a test.

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

 drivers/core/of_access.c | 8 ++++----
 test/dm/ofnode.c         | 3 +++
 2 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/drivers/core/of_access.c b/drivers/core/of_access.c
index 765b21cecdb..cc5837a4a3b 100644
--- a/drivers/core/of_access.c
+++ b/drivers/core/of_access.c
@@ -909,9 +909,6 @@ int of_write_prop(struct device_node *np, const char *propname, int len,
 		pp_last = pp;
 	}
 
-	if (!pp_last)
-		return -ENOENT;
-
 	/* Property does not exist -> append new property */
 	new = malloc(sizeof(struct property));
 	if (!new)
@@ -927,7 +924,10 @@ int of_write_prop(struct device_node *np, const char *propname, int len,
 	new->length = len;
 	new->next = NULL;
 
-	pp_last->next = new;
+	if (pp_last)
+		pp_last->next = new;
+	else
+		np->properties = new;
 
 	return 0;
 }
diff --git a/test/dm/ofnode.c b/test/dm/ofnode.c
index f5aabf42dbb..76346e37d1f 100644
--- a/test/dm/ofnode.c
+++ b/test/dm/ofnode.c
@@ -612,6 +612,9 @@ static int dm_test_ofnode_add_subnode(struct unit_test_state *uts)
 	check = ofnode_path("/lcd/edmund");
 	ut_asserteq(check.of_offset, subnode.of_offset);
 
+	/* write to the empty node */
+	ut_assertok(ofnode_write_string(subnode, "compatible", "sandbox,usb"));
+
 	ut_asserteq(-EEXIST, ofnode_add_subnode(node, "edmund", &subnode));
 
 	return 0;
-- 
2.37.2.672.g94769d06f0-goog


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

* [PATCH 10/21] dm: core: Drop the const from ofnode
  2022-08-31  3:07 [PATCH 00/21] dm: core: Support multiple device trees in ofnode Simon Glass
                   ` (8 preceding siblings ...)
  2022-08-31  3:08 ` [PATCH 09/21] dm: core: Support writing a property to an empty node Simon Glass
@ 2022-08-31  3:08 ` Simon Glass
  2022-08-31  3:08 ` [PATCH 11/21] test: Make a copy of the device tree before running a test Simon Glass
                   ` (10 subsequent siblings)
  20 siblings, 0 replies; 23+ messages in thread
From: Simon Glass @ 2022-08-31  3:08 UTC (permalink / raw)
  To: U-Boot Mailing List
  Cc: Michal Simek, Marek Behún, Kishon Vijay Abraham I, Tom Rini,
	Simon Glass, Marek Vasut, Pavel Herrmann

Now that we support writing to ofnodes, the const is not accurate. Drop
it to avoid undesirable casting.

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

 drivers/core/ofnode.c    | 2 +-
 include/dm/ofnode.h      | 4 ++--
 include/dm/ofnode_decl.h | 2 +-
 3 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/core/ofnode.c b/drivers/core/ofnode.c
index f01bfac8f69..8da4784253d 100644
--- a/drivers/core/ofnode.c
+++ b/drivers/core/ofnode.c
@@ -206,7 +206,7 @@ ofnode ofnode_find_subnode(ofnode node, const char *subnode_name)
 	debug("%s: %s: ", __func__, subnode_name);
 
 	if (ofnode_is_np(node)) {
-		const struct device_node *np = ofnode_to_np(node);
+		struct device_node *np = ofnode_to_np(node);
 
 		for (np = np->child; np; np = np->sibling) {
 			if (!strcmp(subnode_name, np->name))
diff --git a/include/dm/ofnode.h b/include/dm/ofnode.h
index ebef8a6e2bb..3b7ef793057 100644
--- a/include/dm/ofnode.h
+++ b/include/dm/ofnode.h
@@ -35,7 +35,7 @@ struct ofnode_phandle_args {
  * @node: Reference containing struct device_node * (possibly invalid)
  * Return: pointer to device node (can be NULL)
  */
-static inline const struct device_node *ofnode_to_np(ofnode node)
+static inline struct device_node *ofnode_to_np(ofnode node)
 {
 #ifdef OF_CHECKS
 	if (!of_live_active())
@@ -117,7 +117,7 @@ static inline ofnode offset_to_ofnode(int of_offset)
  * @np: Live node pointer (can be NULL)
  * Return: reference to the associated node pointer
  */
-static inline ofnode np_to_ofnode(const struct device_node *np)
+static inline ofnode np_to_ofnode(struct device_node *np)
 {
 	ofnode node;
 
diff --git a/include/dm/ofnode_decl.h b/include/dm/ofnode_decl.h
index 266253d5e33..8d0d7885aa6 100644
--- a/include/dm/ofnode_decl.h
+++ b/include/dm/ofnode_decl.h
@@ -39,7 +39,7 @@
  *	is not a really a pointer to a node: it is an offset value. See above.
  */
 typedef union ofnode_union {
-	const struct device_node *np;
+	struct device_node *np;
 	long of_offset;
 } ofnode;
 
-- 
2.37.2.672.g94769d06f0-goog


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

* [PATCH 11/21] test: Make a copy of the device tree before running a test
  2022-08-31  3:07 [PATCH 00/21] dm: core: Support multiple device trees in ofnode Simon Glass
                   ` (9 preceding siblings ...)
  2022-08-31  3:08 ` [PATCH 10/21] dm: core: Drop the const from ofnode Simon Glass
@ 2022-08-31  3:08 ` Simon Glass
  2022-08-31  3:08 ` [PATCH 12/21] test: Detect a change in the device tree Simon Glass
                   ` (9 subsequent siblings)
  20 siblings, 0 replies; 23+ messages in thread
From: Simon Glass @ 2022-08-31  3:08 UTC (permalink / raw)
  To: U-Boot Mailing List
  Cc: Michal Simek, Marek Behún, Kishon Vijay Abraham I, Tom Rini,
	Simon Glass, Heinrich Schuchardt

When the flat device tree changes it can mess up the live tree since that
uses the flat tree for its strings. This affects only a few sandbox tests
which modify the device tree, but the number will grow as ofnode support
for writing improves.

While the control FDT is not intended to change while U-Boot is running,
some tests do so. For example, the ofnode interface only supports
modifying properties in the control FDT, so tests must use that.

To solve this problem, keep a copy of the FDT and restore it as needed
when the test is finished. The copy only happens on sandbox (except SPL
builds), to reduce memory usage and because these tests are not useful on
other boards. For other boards, a checksum is taken to ensure that nothing
changes.

It would be possible to always checksum the FDT on sandbox and only
restore it if needed, but this is slightly slower than restoring it every
time, at least with crc8.

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

 doc/develop/driver-model/livetree.rst | 17 ++-----
 include/test/test.h                   |  6 +++
 test/test-main.c                      | 69 +++++++++++++++++++++++++++
 3 files changed, 78 insertions(+), 14 deletions(-)

diff --git a/doc/develop/driver-model/livetree.rst b/doc/develop/driver-model/livetree.rst
index faf3eb5b5f0..4ef8c517325 100644
--- a/doc/develop/driver-model/livetree.rst
+++ b/doc/develop/driver-model/livetree.rst
@@ -235,20 +235,9 @@ tree either present or absent. This is to make sure that the flat tree functions
 work correctly even with OF_LIVE is enabled. But if a test modifies the flat
 device tree, then the live tree can become invalid. Any live tree tests that run
 after that point will use a corrupted tree, e.g. with an incorrect property name
-or worse. To deal with this we use a flag UT_TESTF_LIVE_OR_FLAT then ensures
-that tests which write to the flat tree are not run if OF_LIVE is enabled. Only
-the live tree version of the test is run, when OF_LIVE is enabled, with
-sandbox_flattree running the flat tree version.
-
-This is of course a work-around, even if a reasonable one. One solution to this
-problem would be to make a copy of the flat tree before the test and restore it
-afterwards, in the same memory location, so that the live tree pointers work
-again. Another would be to regenerate the live tree if a test modified the flat
-tree.
-
-Neither of these solutions is currently implemented, since the situation that
-causes the problem can only occur in sandbox tests, is somewhat esoteric and
-the UT_TESTF_LIVE_OR_FLAT flag deals with it in a reasonable way.
+or worse. To deal with this we take a copy of the device tree and restore it
+after any test that modifies it. Note that this copy is not made on other
+boards, only sandbox.
 
 
 Multiple livetrees
diff --git a/include/test/test.h b/include/test/test.h
index c888d68b1ed..ada0bb0a25d 100644
--- a/include/test/test.h
+++ b/include/test/test.h
@@ -20,6 +20,9 @@
  * @testdev: Test device
  * @force_fail_alloc: Force all memory allocs to fail
  * @skip_post_probe: Skip uclass post-probe processing
+ * @fdt_chksum: crc8 of the device tree contents
+ * @fdt_copy: Copy of the device tree
+ * @fdt_size: Size of the device-tree copy
  * @expect_str: Temporary string used to hold expected string value
  * @actual_str: Temporary string used to hold actual string value
  */
@@ -32,6 +35,9 @@ struct unit_test_state {
 	struct udevice *testdev;
 	int force_fail_alloc;
 	int skip_post_probe;
+	uint fdt_chksum;
+	void *fdt_copy;
+	uint fdt_size;
 	char expect_str[512];
 	char actual_str[512];
 };
diff --git a/test/test-main.c b/test/test-main.c
index 31837e57a8f..9dfa205faed 100644
--- a/test/test-main.c
+++ b/test/test-main.c
@@ -13,9 +13,45 @@
 #include <dm/uclass-internal.h>
 #include <test/test.h>
 #include <test/ut.h>
+#include <u-boot/crc.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
+/**
+ * enum fdtchk_t - what to do with the device tree (gd->fdt_blob)
+ *
+ * This affects what happens with the device tree before and after a test
+ *
+ * @FDTCHK_NONE: Do nothing
+ * @FDTCHK_CHECKSUM: Take a checksum of the FDT before the test runs and
+ *	compare it afterwards to detect any changes
+ * @FDTCHK_COPY: Make a copy of the FDT and restore it afterwards
+ */
+enum fdtchk_t {
+	FDTCHK_NONE,
+	FDTCHK_CHECKSUM,
+	FDTCHK_COPY,
+};
+
+/**
+ * fdt_action() - get the required action for the FDT
+ *
+ * @return the action that should be taken for this build
+ */
+static enum fdtchk_t fdt_action(void)
+{
+	/* Do a copy for sandbox (but only the U-Boot build, not SPL) */
+	if (CONFIG_IS_ENABLED(SANDBOX))
+		return FDTCHK_COPY;
+
+	/* For sandbox SPL builds, do nothing */
+	if (IS_ENABLED(CONFIG_SANDBOX))
+		return FDTCHK_NONE;
+
+	/* For all other boards, do a checksum */
+	return FDTCHK_CHECKSUM;
+}
+
 /* This is valid when a test is running, NULL otherwise */
 static struct unit_test_state *cur_test_state;
 
@@ -45,6 +81,9 @@ static int dm_test_pre_run(struct unit_test_state *uts)
 	uts->testdev = NULL;
 	uts->force_fail_alloc = false;
 	uts->skip_post_probe = false;
+	if (fdt_action() == FDTCHK_CHECKSUM)
+		uts->fdt_chksum = crc8(0, gd->fdt_blob,
+				       fdt_totalsize(gd->fdt_blob));
 	gd->dm_root = NULL;
 	if (CONFIG_IS_ENABLED(UT_DM) && !CONFIG_IS_ENABLED(OF_PLATDATA))
 		memset(dm_testdrv_op_count, '\0', sizeof(dm_testdrv_op_count));
@@ -62,6 +101,25 @@ static int dm_test_post_run(struct unit_test_state *uts)
 {
 	int id;
 
+	if (gd->fdt_blob) {
+		switch (fdt_action()) {
+		case FDTCHK_COPY:
+			memcpy((void *)gd->fdt_blob, uts->fdt_copy, uts->fdt_size);
+			break;
+		case FDTCHK_CHECKSUM: {
+			uint chksum;
+
+			chksum = crc8(0, gd->fdt_blob, fdt_totalsize(gd->fdt_blob));
+
+			if (chksum != uts->fdt_chksum)
+				printf("Device tree changed: cannot run live tree tests\n");
+			break;
+		}
+		case FDTCHK_NONE:
+			break;
+		}
+	}
+
 	/*
 	 * With of-platdata-inst the uclasses are created at build time. If we
 	 * destroy them we cannot get them back since uclass_add() is not
@@ -432,6 +490,15 @@ int ut_run_list(const char *category, const char *prefix,
 		printf("Running %d %s tests\n", count, category);
 
 	uts.of_root = gd_of_root();
+	if (fdt_action() == FDTCHK_COPY && gd->fdt_blob) {
+		uts.fdt_size = fdt_totalsize(gd->fdt_blob);
+		uts.fdt_copy = malloc(uts.fdt_size);
+		if (!uts.fdt_copy) {
+			printf("Out of memory for device tree copy\n");
+			return -ENOMEM;
+		}
+		memcpy(uts.fdt_copy, gd->fdt_blob, uts.fdt_size);
+	}
 	ret = ut_run_tests(&uts, prefix, tests, count, select_name);
 
 	if (ret == -ENOENT)
@@ -442,6 +509,8 @@ int ut_run_list(const char *category, const char *prefix,
 	/* Best efforts only...ignore errors */
 	if (has_dm_tests)
 		dm_test_restore(uts.of_root);
+	if (IS_ENABLED(CONFIG_SANDBOX))
+		free(uts.fdt_copy);
 
 	return ret;
 }
-- 
2.37.2.672.g94769d06f0-goog


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

* [PATCH 12/21] test: Detect a change in the device tree
  2022-08-31  3:07 [PATCH 00/21] dm: core: Support multiple device trees in ofnode Simon Glass
                   ` (10 preceding siblings ...)
  2022-08-31  3:08 ` [PATCH 11/21] test: Make a copy of the device tree before running a test Simon Glass
@ 2022-08-31  3:08 ` Simon Glass
  2022-08-31  3:08 ` [PATCH 13/21] test: Drop the UT_TESTF_LIVE_OR_FLAT flag Simon Glass
                   ` (8 subsequent siblings)
  20 siblings, 0 replies; 23+ messages in thread
From: Simon Glass @ 2022-08-31  3:08 UTC (permalink / raw)
  To: U-Boot Mailing List
  Cc: Michal Simek, Marek Behún, Kishon Vijay Abraham I, Tom Rini,
	Simon Glass, AKASHI Takahiro, Heinrich Schuchardt, Jason Liu,
	Rasmus Villemoes, Stefan Roese

If the device tree changes during a test and we cannot restore it, mark
it as such so that future tests which need the live tree are skipped.

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

 include/asm-generic/global_data.h |  4 ++++
 test/test-main.c                  | 19 ++++++++++++++++---
 2 files changed, 20 insertions(+), 3 deletions(-)

diff --git a/include/asm-generic/global_data.h b/include/asm-generic/global_data.h
index 805a6fd6797..717cde129a9 100644
--- a/include/asm-generic/global_data.h
+++ b/include/asm-generic/global_data.h
@@ -635,6 +635,10 @@ enum gd_flags {
 	 * @GD_FLG_SMP_READY: SMP initialization is complete
 	 */
 	GD_FLG_SMP_READY = 0x80000,
+	/*
+	 * @GD_FLG_FDT_CHANGED: Device tree change has been detected by tests
+	 */
+	GD_FLG_FDT_CHANGED = 0x100000,
 };
 
 #endif /* __ASSEMBLY__ */
diff --git a/test/test-main.c b/test/test-main.c
index 9dfa205faed..d285872d111 100644
--- a/test/test-main.c
+++ b/test/test-main.c
@@ -77,6 +77,10 @@ static int dm_test_pre_run(struct unit_test_state *uts)
 {
 	bool of_live = uts->of_live;
 
+	if (of_live && (gd->flags & GD_FLG_FDT_CHANGED)) {
+		printf("Cannot run live tree test as device tree changed\n");
+		return -EFAULT;
+	}
 	uts->root = NULL;
 	uts->testdev = NULL;
 	uts->force_fail_alloc = false;
@@ -110,9 +114,17 @@ static int dm_test_post_run(struct unit_test_state *uts)
 			uint chksum;
 
 			chksum = crc8(0, gd->fdt_blob, fdt_totalsize(gd->fdt_blob));
-
-			if (chksum != uts->fdt_chksum)
+			if (chksum != uts->fdt_chksum) {
+				/*
+				 * We cannot run any more tests that need the
+				 * live tree, since its strings point into the
+				 * flat tree, which has changed. This likely
+				 * means that at least some of the pointers from
+				 * the live tree point to different things
+				 */
 				printf("Device tree changed: cannot run live tree tests\n");
+				gd->flags |= GD_FLG_FDT_CHANGED;
+			}
 			break;
 		}
 		case FDTCHK_NONE:
@@ -411,7 +423,8 @@ static int ut_run_test_live_flat(struct unit_test_state *uts,
 	 * or it is a core test.
 	 */
 	if (!(test->flags & UT_TESTF_LIVE_TREE) &&
-	    (!runs || ut_test_run_on_flattree(test))) {
+	    (!runs || ut_test_run_on_flattree(test)) &&
+	    !(gd->flags & GD_FLG_FDT_CHANGED)) {
 		uts->of_live = false;
 		ut_assertok(ut_run_test(uts, test, test->name));
 		runs++;
-- 
2.37.2.672.g94769d06f0-goog


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

* [PATCH 13/21] test: Drop the UT_TESTF_LIVE_OR_FLAT flag
  2022-08-31  3:07 [PATCH 00/21] dm: core: Support multiple device trees in ofnode Simon Glass
                   ` (11 preceding siblings ...)
  2022-08-31  3:08 ` [PATCH 12/21] test: Detect a change in the device tree Simon Glass
@ 2022-08-31  3:08 ` Simon Glass
  2022-08-31  3:08 ` [PATCH 14/21] dm: core: Provide a way to reset the device tree Simon Glass
                   ` (7 subsequent siblings)
  20 siblings, 0 replies; 23+ messages in thread
From: Simon Glass @ 2022-08-31  3:08 UTC (permalink / raw)
  To: U-Boot Mailing List
  Cc: Michal Simek, Marek Behún, Kishon Vijay Abraham I, Tom Rini,
	Simon Glass, Heinrich Schuchardt

This was a workaround for a rare situation. Now that it will be more
common and we have a proper fix, drop the flag. We can run both types of
tests in the same sandbox executable, even if the flat device tree is
modified.

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

 include/test/test.h | 2 --
 test/dm/ofnode.c    | 8 +++-----
 test/test-main.c    | 3 +--
 3 files changed, 4 insertions(+), 9 deletions(-)

diff --git a/include/test/test.h b/include/test/test.h
index ada0bb0a25d..c028bbb8c89 100644
--- a/include/test/test.h
+++ b/include/test/test.h
@@ -52,8 +52,6 @@ enum {
 	UT_TESTF_CONSOLE_REC	= BIT(5),	/* needs console recording */
 	/* do extra driver model init and uninit */
 	UT_TESTF_DM		= BIT(6),
-	/* live or flat device tree, but not both in the same executable */
-	UT_TESTF_LIVE_OR_FLAT	= BIT(4),
 };
 
 /**
diff --git a/test/dm/ofnode.c b/test/dm/ofnode.c
index 76346e37d1f..a36fd104048 100644
--- a/test/dm/ofnode.c
+++ b/test/dm/ofnode.c
@@ -584,7 +584,7 @@ static int dm_test_ofnode_livetree_writing(struct unit_test_state *uts)
 	return 0;
 }
 DM_TEST(dm_test_ofnode_livetree_writing,
-	UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT | UT_TESTF_LIVE_OR_FLAT);
+	UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT);
 
 static int dm_test_ofnode_u32(struct unit_test_state *uts)
 {
@@ -599,8 +599,7 @@ static int dm_test_ofnode_u32(struct unit_test_state *uts)
 
 	return 0;
 }
-DM_TEST(dm_test_ofnode_u32,
-	UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT | UT_TESTF_LIVE_OR_FLAT);
+DM_TEST(dm_test_ofnode_u32, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT);
 
 static int dm_test_ofnode_add_subnode(struct unit_test_state *uts)
 {
@@ -619,5 +618,4 @@ static int dm_test_ofnode_add_subnode(struct unit_test_state *uts)
 
 	return 0;
 }
-DM_TEST(dm_test_ofnode_add_subnode,
-	UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT | UT_TESTF_LIVE_OR_FLAT);
+DM_TEST(dm_test_ofnode_add_subnode, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT);
diff --git a/test/test-main.c b/test/test-main.c
index d285872d111..97ba25d927c 100644
--- a/test/test-main.c
+++ b/test/test-main.c
@@ -410,8 +410,7 @@ static int ut_run_test_live_flat(struct unit_test_state *uts,
 	/* Run with the live tree if possible */
 	runs = 0;
 	if (CONFIG_IS_ENABLED(OF_LIVE)) {
-		if (!(test->flags &
-		    (UT_TESTF_FLAT_TREE | UT_TESTF_LIVE_OR_FLAT))) {
+		if (!(test->flags & UT_TESTF_FLAT_TREE)) {
 			uts->of_live = true;
 			ut_assertok(ut_run_test(uts, test, test->name));
 			runs++;
-- 
2.37.2.672.g94769d06f0-goog


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

* [PATCH 14/21] dm: core: Provide a way to reset the device tree
  2022-08-31  3:07 [PATCH 00/21] dm: core: Support multiple device trees in ofnode Simon Glass
                   ` (12 preceding siblings ...)
  2022-08-31  3:08 ` [PATCH 13/21] test: Drop the UT_TESTF_LIVE_OR_FLAT flag Simon Glass
@ 2022-08-31  3:08 ` Simon Glass
  2022-08-31  3:08 ` [PATCH 15/21] dm: core: Add an ofnode function to obtain the flat tree Simon Glass
                   ` (6 subsequent siblings)
  20 siblings, 0 replies; 23+ messages in thread
From: Simon Glass @ 2022-08-31  3:08 UTC (permalink / raw)
  To: U-Boot Mailing List
  Cc: Michal Simek, Marek Behún, Kishon Vijay Abraham I, Tom Rini,
	Simon Glass, Dzmitry Sankouski, Heinrich Schuchardt, Marek Vasut,
	Ovidiu Panait, Pavel Herrmann, Rasmus Villemoes, Rick Chen

At present there is only one device tree used by the ofnode functions,
except for some esoteric use of live tree. In preparation for supporting
more than one, add a way to reset the list of device trees.

For now this does nothing.

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

 common/board_r.c    | 2 ++
 include/dm/ofnode.h | 8 ++++++++
 lib/fdtdec.c        | 5 ++++-
 test/test-main.c    | 2 ++
 4 files changed, 16 insertions(+), 1 deletion(-)

diff --git a/common/board_r.c b/common/board_r.c
index 56eb60fa275..77e9ca0581f 100644
--- a/common/board_r.c
+++ b/common/board_r.c
@@ -233,6 +233,8 @@ static int initr_dm(void)
 {
 	int ret;
 
+	oftree_reset();
+
 	/* Save the pre-reloc driver model and start a new one */
 	gd->dm_root_f = gd->dm_root;
 	gd->dm_root = NULL;
diff --git a/include/dm/ofnode.h b/include/dm/ofnode.h
index 3b7ef793057..2b047c57d89 100644
--- a/include/dm/ofnode.h
+++ b/include/dm/ofnode.h
@@ -27,6 +27,14 @@ struct ofnode_phandle_args {
 	uint32_t args[OF_MAX_PHANDLE_ARGS];
 };
 
+/**
+ * oftree_reset() - reset the state of the oftree list
+ *
+ * Reset the oftree list so it can be started again. This should be called
+ * once the control FDT is in place, but before the ofnode interface is used.
+ */
+static inline void oftree_reset(void) {}
+
 /**
  * ofnode_to_np() - convert an ofnode to a live DT node pointer
  *
diff --git a/lib/fdtdec.c b/lib/fdtdec.c
index 96b6b71a606..ffe3993aa76 100644
--- a/lib/fdtdec.c
+++ b/lib/fdtdec.c
@@ -13,7 +13,6 @@
 #include <log.h>
 #include <malloc.h>
 #include <net.h>
-#include <dm/of_extra.h>
 #include <env.h>
 #include <errno.h>
 #include <fdtdec.h>
@@ -24,6 +23,8 @@
 #include <serial.h>
 #include <asm/global_data.h>
 #include <asm/sections.h>
+#include <dm/ofnode.h>
+#include <dm/of_extra.h>
 #include <linux/ctype.h>
 #include <linux/lzo.h>
 #include <linux/ioport.h>
@@ -1668,6 +1669,8 @@ int fdtdec_setup(void)
 	ret = fdtdec_prepare_fdt();
 	if (!ret)
 		ret = fdtdec_board_setup(gd->fdt_blob);
+	oftree_reset();
+
 	return ret;
 }
 
diff --git a/test/test-main.c b/test/test-main.c
index 97ba25d927c..beca15041e0 100644
--- a/test/test-main.c
+++ b/test/test-main.c
@@ -8,6 +8,7 @@
 #include <console.h>
 #include <dm.h>
 #include <event.h>
+#include <dm/ofnode.h>
 #include <dm/root.h>
 #include <dm/test.h>
 #include <dm/uclass-internal.h>
@@ -95,6 +96,7 @@ static int dm_test_pre_run(struct unit_test_state *uts)
 
 	/* Determine whether to make the live tree available */
 	gd_set_of_root(of_live ? uts->of_root : NULL);
+	oftree_reset();
 	ut_assertok(dm_init(of_live));
 	uts->root = dm_root();
 
-- 
2.37.2.672.g94769d06f0-goog


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

* [PATCH 15/21] dm: core: Add an ofnode function to obtain the flat tree
  2022-08-31  3:07 [PATCH 00/21] dm: core: Support multiple device trees in ofnode Simon Glass
                   ` (13 preceding siblings ...)
  2022-08-31  3:08 ` [PATCH 14/21] dm: core: Provide a way to reset the device tree Simon Glass
@ 2022-08-31  3:08 ` Simon Glass
  2022-08-31  3:08 ` [PATCH 16/21] dm: core: Add ofnode functions to obtain an oftree Simon Glass
                   ` (5 subsequent siblings)
  20 siblings, 0 replies; 23+ messages in thread
From: Simon Glass @ 2022-08-31  3:08 UTC (permalink / raw)
  To: U-Boot Mailing List
  Cc: Michal Simek, Marek Behún, Kishon Vijay Abraham I, Tom Rini,
	Simon Glass, Marek Vasut, Pavel Herrmann

The flat device tree is assumed to be the control FDT but this is not
always the case. Update the ofnode implementation to obtain the node via
an function call so we can eventually add support for selecting different
trees.

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

 drivers/core/ofnode.c | 93 ++++++++++++++++++++++++-------------------
 include/dm/ofnode.h   | 19 +++++++++
 2 files changed, 70 insertions(+), 42 deletions(-)

diff --git a/drivers/core/ofnode.c b/drivers/core/ofnode.c
index 8da4784253d..6ee114bd5a8 100644
--- a/drivers/core/ofnode.c
+++ b/drivers/core/ofnode.c
@@ -57,8 +57,8 @@ int ofnode_read_u32_index(ofnode node, const char *propname, int index,
 		return of_read_u32_index(ofnode_to_np(node), propname, index,
 					 outp);
 
-	cell = fdt_getprop(gd->fdt_blob, ofnode_to_offset(node), propname,
-			   &len);
+	cell = fdt_getprop(ofnode_to_fdt(node), ofnode_to_offset(node),
+			   propname, &len);
 	if (!cell) {
 		debug("(not found)\n");
 		return -EINVAL;
@@ -103,8 +103,8 @@ int ofnode_read_u64(ofnode node, const char *propname, u64 *outp)
 	if (ofnode_is_np(node))
 		return of_read_u64(ofnode_to_np(node), propname, outp);
 
-	cell = fdt_getprop(gd->fdt_blob, ofnode_to_offset(node), propname,
-			   &len);
+	cell = fdt_getprop(ofnode_to_fdt(node), ofnode_to_offset(node),
+			   propname, &len);
 	if (!cell || len < sizeof(*cell)) {
 		debug("(not found)\n");
 		return -EINVAL;
@@ -155,7 +155,7 @@ const void *ofnode_read_prop(ofnode node, const char *propname, int *sizep)
 			len = prop->length;
 		}
 	} else {
-		val = fdt_getprop(gd->fdt_blob, ofnode_to_offset(node),
+		val = fdt_getprop(ofnode_to_fdt(node), ofnode_to_offset(node),
 				  propname, &len);
 	}
 	if (!val) {
@@ -214,7 +214,7 @@ ofnode ofnode_find_subnode(ofnode node, const char *subnode_name)
 		}
 		subnode = np_to_ofnode(np);
 	} else {
-		int ooffset = fdt_subnode_offset(gd->fdt_blob,
+		int ooffset = fdt_subnode_offset(ofnode_to_fdt(node),
 				ofnode_to_offset(node), subnode_name);
 		subnode = offset_to_ofnode(ooffset);
 	}
@@ -234,7 +234,7 @@ int ofnode_read_u32_array(ofnode node, const char *propname,
 		return of_read_u32_array(ofnode_to_np(node), propname,
 					 out_values, sz);
 	} else {
-		return fdtdec_get_int_array(gd->fdt_blob,
+		return fdtdec_get_int_array(ofnode_to_fdt(node),
 					    ofnode_to_offset(node), propname,
 					    out_values, sz);
 	}
@@ -246,7 +246,7 @@ bool ofnode_is_enabled(ofnode node)
 	if (ofnode_is_np(node)) {
 		return of_device_is_available(ofnode_to_np(node));
 	} else {
-		return fdtdec_get_is_enabled(gd->fdt_blob,
+		return fdtdec_get_is_enabled(ofnode_to_fdt(node),
 					     ofnode_to_offset(node));
 	}
 }
@@ -258,7 +258,7 @@ ofnode ofnode_first_subnode(ofnode node)
 		return np_to_ofnode(node.np->child);
 
 	return offset_to_ofnode(
-		fdt_first_subnode(gd->fdt_blob, ofnode_to_offset(node)));
+		fdt_first_subnode(ofnode_to_fdt(node), ofnode_to_offset(node)));
 }
 
 ofnode ofnode_next_subnode(ofnode node)
@@ -268,7 +268,7 @@ ofnode ofnode_next_subnode(ofnode node)
 		return np_to_ofnode(node.np->sibling);
 
 	return offset_to_ofnode(
-		fdt_next_subnode(gd->fdt_blob, ofnode_to_offset(node)));
+		fdt_next_subnode(ofnode_to_fdt(node), ofnode_to_offset(node)));
 }
 #endif /* !DM_INLINE_OFNODE */
 
@@ -280,7 +280,7 @@ ofnode ofnode_get_parent(ofnode node)
 	if (ofnode_is_np(node))
 		parent = np_to_ofnode(of_get_parent(ofnode_to_np(node)));
 	else
-		parent.of_offset = fdt_parent_offset(gd->fdt_blob,
+		parent.of_offset = fdt_parent_offset(ofnode_to_fdt(node),
 						     ofnode_to_offset(node));
 
 	return parent;
@@ -296,7 +296,7 @@ const char *ofnode_get_name(ofnode node)
 	if (ofnode_is_np(node))
 		return strrchr(node.np->full_name, '/') + 1;
 
-	return fdt_get_name(gd->fdt_blob, ofnode_to_offset(node), NULL);
+	return fdt_get_name(ofnode_to_fdt(node), ofnode_to_offset(node), NULL);
 }
 
 int ofnode_get_path(ofnode node, char *buf, int buflen)
@@ -313,7 +313,7 @@ int ofnode_get_path(ofnode node, char *buf, int buflen)
 	} else {
 		int res;
 
-		res = fdt_get_path(gd->fdt_blob, ofnode_to_offset(node), buf,
+		res = fdt_get_path(ofnode_to_fdt(node), ofnode_to_offset(node), buf,
 				   buflen);
 		if (!res)
 			return res;
@@ -369,7 +369,7 @@ static fdt_addr_t __ofnode_get_addr_size_index(ofnode node, int index,
 	} else {
 		na = ofnode_read_simple_addr_cells(ofnode_get_parent(node));
 		ns = ofnode_read_simple_size_cells(ofnode_get_parent(node));
-		return fdtdec_get_addr_size_fixed(gd->fdt_blob,
+		return fdtdec_get_addr_size_fixed(ofnode_to_fdt(node),
 						  ofnode_to_offset(node), "reg",
 						  index, na, ns, size,
 						  translate);
@@ -417,7 +417,7 @@ int ofnode_stringlist_search(ofnode node, const char *property,
 	} else {
 		int ret;
 
-		ret = fdt_stringlist_search(gd->fdt_blob,
+		ret = fdt_stringlist_search(ofnode_to_fdt(node),
 					    ofnode_to_offset(node), property,
 					    string);
 		if (ret == -FDT_ERR_NOTFOUND)
@@ -438,7 +438,8 @@ int ofnode_read_string_index(ofnode node, const char *property, int index,
 	} else {
 		int len;
 
-		*outp = fdt_stringlist_get(gd->fdt_blob, ofnode_to_offset(node),
+		*outp = fdt_stringlist_get(ofnode_to_fdt(node),
+					   ofnode_to_offset(node),
 					   property, index, &len);
 		if (len < 0)
 			return -EINVAL;
@@ -451,7 +452,7 @@ int ofnode_read_string_count(ofnode node, const char *property)
 	if (ofnode_is_np(node)) {
 		return of_property_count_strings(ofnode_to_np(node), property);
 	} else {
-		return fdt_stringlist_count(gd->fdt_blob,
+		return fdt_stringlist_count(ofnode_to_fdt(node),
 					    ofnode_to_offset(node), property);
 	}
 }
@@ -520,7 +521,7 @@ int ofnode_parse_phandle_with_args(ofnode node, const char *list_name,
 		struct fdtdec_phandle_args args;
 		int ret;
 
-		ret = fdtdec_parse_phandle_with_args(gd->fdt_blob,
+		ret = fdtdec_parse_phandle_with_args(ofnode_to_fdt(node),
 						     ofnode_to_offset(node),
 						     list_name, cells_name,
 						     cell_count, index, &args);
@@ -539,7 +540,7 @@ int ofnode_count_phandle_with_args(ofnode node, const char *list_name,
 		return of_count_phandle_with_args(ofnode_to_np(node),
 				list_name, cells_name, cell_count);
 	else
-		return fdtdec_parse_phandle_with_args(gd->fdt_blob,
+		return fdtdec_parse_phandle_with_args(ofnode_to_fdt(node),
 				ofnode_to_offset(node), list_name, cells_name,
 				cell_count, -1, NULL);
 }
@@ -714,7 +715,7 @@ const void *ofnode_get_property(ofnode node, const char *propname, int *lenp)
 	if (ofnode_is_np(node))
 		return of_get_property(ofnode_to_np(node), propname, lenp);
 	else
-		return fdt_getprop(gd->fdt_blob, ofnode_to_offset(node),
+		return fdt_getprop(ofnode_to_fdt(node), ofnode_to_offset(node),
 				   propname, lenp);
 }
 
@@ -728,7 +729,7 @@ int ofnode_get_first_property(ofnode node, struct ofprop *prop)
 			return -FDT_ERR_NOTFOUND;
 	} else {
 		prop->offset =
-			fdt_first_property_offset(gd->fdt_blob,
+			fdt_first_property_offset(ofnode_to_fdt(node),
 						  ofnode_to_offset(prop->node));
 		if (prop->offset < 0)
 			return prop->offset;
@@ -745,8 +746,9 @@ int ofnode_get_next_property(struct ofprop *prop)
 		if (!prop->prop)
 			return -FDT_ERR_NOTFOUND;
 	} else {
-		prop->offset = fdt_next_property_offset(gd->fdt_blob,
-							prop->offset);
+		prop->offset =
+			fdt_next_property_offset(ofnode_to_fdt(prop->node),
+						 prop->offset);
 		if (prop->offset  < 0)
 			return prop->offset;
 	}
@@ -761,7 +763,7 @@ const void *ofnode_get_property_by_prop(const struct ofprop *prop,
 		return of_get_property_by_prop(ofnode_to_np(prop->node),
 					       prop->prop, propname, lenp);
 	else
-		return fdt_getprop_by_offset(gd->fdt_blob,
+		return fdt_getprop_by_offset(ofnode_to_fdt(prop->node),
 					     prop->offset,
 					     propname, lenp);
 }
@@ -771,7 +773,7 @@ bool ofnode_is_available(ofnode node)
 	if (ofnode_is_np(node))
 		return of_device_is_available(ofnode_to_np(node));
 	else
-		return fdtdec_get_is_enabled(gd->fdt_blob,
+		return fdtdec_get_is_enabled(ofnode_to_fdt(node),
 					     ofnode_to_offset(node));
 }
 
@@ -795,7 +797,7 @@ fdt_addr_t ofnode_get_addr_size(ofnode node, const char *property,
 		else
 			return of_read_number(prop, na);
 	} else {
-		return fdtdec_get_addr_size(gd->fdt_blob,
+		return fdtdec_get_addr_size(ofnode_to_fdt(node),
 					    ofnode_to_offset(node), property,
 					    sizep);
 	}
@@ -814,7 +816,7 @@ const uint8_t *ofnode_read_u8_array_ptr(ofnode node, const char *propname,
 		return (uint8_t *)prop;
 
 	} else {
-		return fdtdec_locate_byte_array(gd->fdt_blob,
+		return fdtdec_locate_byte_array(ofnode_to_fdt(node),
 				ofnode_to_offset(node), propname, sz);
 	}
 }
@@ -950,10 +952,10 @@ int ofnode_read_addr_cells(ofnode node)
 	if (ofnode_is_np(node)) {
 		return of_n_addr_cells(ofnode_to_np(node));
 	} else {
-		int parent = fdt_parent_offset(gd->fdt_blob,
+		int parent = fdt_parent_offset(ofnode_to_fdt(node),
 					       ofnode_to_offset(node));
 
-		return fdt_address_cells(gd->fdt_blob, parent);
+		return fdt_address_cells(ofnode_to_fdt(node), parent);
 	}
 }
 
@@ -962,10 +964,10 @@ int ofnode_read_size_cells(ofnode node)
 	if (ofnode_is_np(node)) {
 		return of_n_size_cells(ofnode_to_np(node));
 	} else {
-		int parent = fdt_parent_offset(gd->fdt_blob,
+		int parent = fdt_parent_offset(ofnode_to_fdt(node),
 					       ofnode_to_offset(node));
 
-		return fdt_size_cells(gd->fdt_blob, parent);
+		return fdt_size_cells(ofnode_to_fdt(node), parent);
 	}
 }
 
@@ -974,7 +976,8 @@ int ofnode_read_simple_addr_cells(ofnode node)
 	if (ofnode_is_np(node))
 		return of_simple_addr_cells(ofnode_to_np(node));
 	else
-		return fdt_address_cells(gd->fdt_blob, ofnode_to_offset(node));
+		return fdt_address_cells(ofnode_to_fdt(node),
+					 ofnode_to_offset(node));
 }
 
 int ofnode_read_simple_size_cells(ofnode node)
@@ -982,7 +985,8 @@ int ofnode_read_simple_size_cells(ofnode node)
 	if (ofnode_is_np(node))
 		return of_simple_size_cells(ofnode_to_np(node));
 	else
-		return fdt_size_cells(gd->fdt_blob, ofnode_to_offset(node));
+		return fdt_size_cells(ofnode_to_fdt(node),
+				      ofnode_to_offset(node));
 }
 
 bool ofnode_pre_reloc(ofnode node)
@@ -1019,7 +1023,8 @@ int ofnode_read_resource(ofnode node, uint index, struct resource *res)
 		struct fdt_resource fres;
 		int ret;
 
-		ret = fdt_get_resource(gd->fdt_blob, ofnode_to_offset(node),
+		ret = fdt_get_resource(ofnode_to_fdt(node),
+				       ofnode_to_offset(node),
 				       "reg", index, &fres);
 		if (ret < 0)
 			return -EINVAL;
@@ -1048,7 +1053,8 @@ u64 ofnode_translate_address(ofnode node, const fdt32_t *in_addr)
 	if (ofnode_is_np(node))
 		return of_translate_address(ofnode_to_np(node), in_addr);
 	else
-		return fdt_translate_address(gd->fdt_blob, ofnode_to_offset(node), in_addr);
+		return fdt_translate_address(ofnode_to_fdt(node),
+					     ofnode_to_offset(node), in_addr);
 }
 
 u64 ofnode_translate_dma_address(ofnode node, const fdt32_t *in_addr)
@@ -1056,7 +1062,8 @@ u64 ofnode_translate_dma_address(ofnode node, const fdt32_t *in_addr)
 	if (ofnode_is_np(node))
 		return of_translate_dma_address(ofnode_to_np(node), in_addr);
 	else
-		return fdt_translate_dma_address(gd->fdt_blob, ofnode_to_offset(node), in_addr);
+		return fdt_translate_dma_address(ofnode_to_fdt(node),
+						 ofnode_to_offset(node), in_addr);
 }
 
 int ofnode_get_dma_range(ofnode node, phys_addr_t *cpu, dma_addr_t *bus, u64 *size)
@@ -1064,7 +1071,8 @@ int ofnode_get_dma_range(ofnode node, phys_addr_t *cpu, dma_addr_t *bus, u64 *si
 	if (ofnode_is_np(node))
 		return of_get_dma_range(ofnode_to_np(node), cpu, bus, size);
 	else
-		return fdt_get_dma_range(gd->fdt_blob, ofnode_to_offset(node),
+		return fdt_get_dma_range(ofnode_to_fdt(node),
+					 ofnode_to_offset(node),
 					 cpu, bus, size);
 }
 
@@ -1074,7 +1082,7 @@ int ofnode_device_is_compatible(ofnode node, const char *compat)
 		return of_device_is_compatible(ofnode_to_np(node), compat,
 					       NULL, NULL);
 	else
-		return !fdt_node_check_compatible(gd->fdt_blob,
+		return !fdt_node_check_compatible(ofnode_to_fdt(node),
 						  ofnode_to_offset(node),
 						  compat);
 }
@@ -1087,7 +1095,8 @@ ofnode ofnode_by_compatible(ofnode from, const char *compat)
 			compat));
 	} else {
 		return offset_to_ofnode(fdt_node_offset_by_compatible(
-				gd->fdt_blob, ofnode_to_offset(from), compat));
+					ofnode_to_fdt(from),
+					ofnode_to_offset(from), compat));
 	}
 }
 
@@ -1100,7 +1109,7 @@ ofnode ofnode_by_prop_value(ofnode from, const char *propname,
 			propval, proplen));
 	} else {
 		return offset_to_ofnode(fdt_node_offset_by_prop_value(
-				gd->fdt_blob, ofnode_to_offset(from),
+				ofnode_to_fdt(from), ofnode_to_offset(from),
 				propname, propval, proplen));
 	}
 }
@@ -1111,7 +1120,7 @@ int ofnode_write_prop(ofnode node, const char *propname, const void *value,
 	if (of_live_active())
 		return of_write_prop(ofnode_to_npw(node), propname, len, value);
 	else
-		return fdt_setprop((void *)gd->fdt_blob, ofnode_to_offset(node),
+		return fdt_setprop(ofnode_to_fdt(node), ofnode_to_offset(node),
 				   propname, value, len);
 
 	return 0;
@@ -1246,7 +1255,7 @@ int ofnode_add_subnode(ofnode node, const char *name, ofnode *subnodep)
 	} else {
 		int offset;
 
-		offset = fdt_add_subnode((void *)gd->fdt_blob,
+		offset = fdt_add_subnode(ofnode_to_fdt(node),
 					 ofnode_to_offset(node), name);
 		if (offset < 0)
 			return offset == -FDT_ERR_EXISTS ? -EEXIST : 0;
diff --git a/include/dm/ofnode.h b/include/dm/ofnode.h
index 2b047c57d89..e879feab002 100644
--- a/include/dm/ofnode.h
+++ b/include/dm/ofnode.h
@@ -35,6 +35,25 @@ struct ofnode_phandle_args {
  */
 static inline void oftree_reset(void) {}
 
+/**
+ * ofnode_to_fdt() - convert an ofnode to a flat DT pointer
+ *
+ * This cannot be called if the reference contains a node pointer.
+ *
+ * @node: Reference containing offset (possibly invalid)
+ * Return: DT offset (can be NULL)
+ */
+static inline void *ofnode_to_fdt(ofnode node)
+{
+#ifdef OF_CHECKS
+	if (of_live_active())
+		return NULL;
+#endif
+
+	/* Use the control FDT by default */
+	return (void *)gd->fdt_blob;
+}
+
 /**
  * ofnode_to_np() - convert an ofnode to a live DT node pointer
  *
-- 
2.37.2.672.g94769d06f0-goog


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

* [PATCH 16/21] dm: core: Add ofnode functions to obtain an oftree
  2022-08-31  3:07 [PATCH 00/21] dm: core: Support multiple device trees in ofnode Simon Glass
                   ` (14 preceding siblings ...)
  2022-08-31  3:08 ` [PATCH 15/21] dm: core: Add an ofnode function to obtain the flat tree Simon Glass
@ 2022-08-31  3:08 ` Simon Glass
  2022-08-31  3:08 ` [PATCH 17/21] dm: core: Add a way to look up a phandle in " Simon Glass
                   ` (4 subsequent siblings)
  20 siblings, 0 replies; 23+ messages in thread
From: Simon Glass @ 2022-08-31  3:08 UTC (permalink / raw)
  To: U-Boot Mailing List
  Cc: Michal Simek, Marek Behún, Kishon Vijay Abraham I, Tom Rini,
	Simon Glass, Marek Vasut, Pavel Herrmann

At present dm_test_ofnode_root() does this manually. Add some inline
functions to handle it, so this code can be centralised.

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

 include/dm/ofnode.h | 31 +++++++++++++++++++++++++++++++
 test/dm/ofnode.c    |  4 ++--
 2 files changed, 33 insertions(+), 2 deletions(-)

diff --git a/include/dm/ofnode.h b/include/dm/ofnode.h
index e879feab002..d8d5082806e 100644
--- a/include/dm/ofnode.h
+++ b/include/dm/ofnode.h
@@ -238,6 +238,37 @@ static inline oftree oftree_default(void)
 	return tree;
 }
 
+/**
+ * oftree_from_np() - Returns an oftree from a node pointer
+ *
+ * @root: Root node of the tree
+ * Returns: reference to the given node
+ */
+static inline oftree oftree_from_np(struct device_node *root)
+{
+	oftree tree;
+
+	tree.np = root;
+
+	return tree;
+}
+
+/**
+ * oftree_from_fdt() - Returns an oftree from a flat device tree pointer
+ *
+ * @fdt: Device tree to use
+ *
+ * Returns: reference to the given node
+ */
+static inline oftree oftree_from_fdt(void *fdt)
+{
+	oftree tree;
+
+	tree.fdt = fdt;
+
+	return tree;
+}
+
 /**
  * ofnode_name_eq() - Check if the node name is equivalent to a given name
  *                    ignoring the unit address
diff --git a/test/dm/ofnode.c b/test/dm/ofnode.c
index a36fd104048..7f195a725a0 100644
--- a/test/dm/ofnode.c
+++ b/test/dm/ofnode.c
@@ -518,9 +518,9 @@ static int dm_test_ofnode_root(struct unit_test_state *uts)
 	ut_assertok(make_ofnode_fdt(uts, fdt, sizeof(fdt)));
 	if (of_live_active()) {
 		ut_assertok(unflatten_device_tree(fdt, &root));
-		tree.np = root;
+		tree = oftree_from_np(root);
 	} else {
-		tree.fdt = fdt;
+		tree = oftree_from_fdt(fdt);
 	}
 
 	/* Make sure they don't work on this new tree */
-- 
2.37.2.672.g94769d06f0-goog


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

* [PATCH 17/21] dm: core: Add a way to look up a phandle in an oftree
  2022-08-31  3:07 [PATCH 00/21] dm: core: Support multiple device trees in ofnode Simon Glass
                   ` (15 preceding siblings ...)
  2022-08-31  3:08 ` [PATCH 16/21] dm: core: Add ofnode functions to obtain an oftree Simon Glass
@ 2022-08-31  3:08 ` Simon Glass
  2022-08-31  3:08 ` [PATCH 18/21] dm: core: Allow obtaining a node offset in the same tree Simon Glass
                   ` (3 subsequent siblings)
  20 siblings, 0 replies; 23+ messages in thread
From: Simon Glass @ 2022-08-31  3:08 UTC (permalink / raw)
  To: U-Boot Mailing List
  Cc: Michal Simek, Marek Behún, Kishon Vijay Abraham I, Tom Rini,
	Simon Glass, Marek Vasut, Pavel Herrmann

When we have multiple trees, the ofnode logic needs to be told which one
to use. Create a new function which takes an oftree argument, along with
a helper to obtain the FDT pointer from an oftree.

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

 drivers/core/ofnode.c | 14 ++++++++++++++
 include/dm/ofnode.h   | 25 +++++++++++++++++++++++++
 test/dm/ofnode.c      |  2 ++
 3 files changed, 41 insertions(+)

diff --git a/drivers/core/ofnode.c b/drivers/core/ofnode.c
index 6ee114bd5a8..aceb809c1f2 100644
--- a/drivers/core/ofnode.c
+++ b/drivers/core/ofnode.c
@@ -337,6 +337,20 @@ ofnode ofnode_get_by_phandle(uint phandle)
 	return node;
 }
 
+ofnode oftree_get_by_phandle(oftree tree, uint phandle)
+{
+	ofnode node;
+
+	if (of_live_active())
+		node = np_to_ofnode(of_find_node_by_phandle(tree.np, phandle));
+	else
+		node.of_offset =
+			fdt_node_offset_by_phandle(oftree_lookup_fdt(tree),
+						   phandle);
+
+	return node;
+}
+
 static fdt_addr_t __ofnode_get_addr_size_index(ofnode node, int index,
 					       fdt_size_t *size, bool translate)
 {
diff --git a/include/dm/ofnode.h b/include/dm/ofnode.h
index d8d5082806e..ad196af2d45 100644
--- a/include/dm/ofnode.h
+++ b/include/dm/ofnode.h
@@ -120,6 +120,22 @@ static inline bool ofnode_valid(ofnode node)
 		return node.of_offset >= 0;
 }
 
+/**
+ * oftree_lookup_fdt() - object the FDT pointer from an oftree
+ *
+ * This can only be called when flat tree is enabled
+ *
+ * @tree: Tree to look at
+ * @return FDT pointer from the tree
+ */
+static inline void *oftree_lookup_fdt(oftree tree)
+{
+	if (of_live_active())
+		return NULL;
+	else
+		return tree.fdt;
+}
+
 /**
  * offset_to_ofnode() - convert a DT offset to an ofnode
  *
@@ -526,6 +542,15 @@ int ofnode_get_path(ofnode node, char *buf, int buflen);
  */
 ofnode ofnode_get_by_phandle(uint phandle);
 
+/**
+ * oftree_get_by_phandle() - get ofnode from phandle
+ *
+ * @tree:	tree to use
+ * @phandle:	phandle to look up
+ * Return: ofnode reference to the phandle
+ */
+ofnode oftree_get_by_phandle(oftree tree, uint phandle);
+
 /**
  * ofnode_read_size() - read the size of a property
  *
diff --git a/test/dm/ofnode.c b/test/dm/ofnode.c
index 7f195a725a0..6a5beadbadc 100644
--- a/test/dm/ofnode.c
+++ b/test/dm/ofnode.c
@@ -36,6 +36,8 @@ static int dm_test_ofnode_get_by_phandle(struct unit_test_state *uts)
 	/* test unknown phandle */
 	ut_assert(!ofnode_valid(ofnode_get_by_phandle(0x1000000)));
 
+	ut_assert(ofnode_valid(oftree_get_by_phandle(oftree_default(), 1)));
+
 	return 0;
 }
 DM_TEST(dm_test_ofnode_get_by_phandle, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT);
-- 
2.37.2.672.g94769d06f0-goog


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

* [PATCH 18/21] dm: core: Allow obtaining a node offset in the same tree
  2022-08-31  3:07 [PATCH 00/21] dm: core: Support multiple device trees in ofnode Simon Glass
                   ` (16 preceding siblings ...)
  2022-08-31  3:08 ` [PATCH 17/21] dm: core: Add a way to look up a phandle in " Simon Glass
@ 2022-08-31  3:08 ` Simon Glass
  2022-08-31  3:08 ` [PATCH 19/21] dm: core: Add definitions for multiple ofnode trees Simon Glass
                   ` (2 subsequent siblings)
  20 siblings, 0 replies; 23+ messages in thread
From: Simon Glass @ 2022-08-31  3:08 UTC (permalink / raw)
  To: U-Boot Mailing List
  Cc: Michal Simek, Marek Behún, Kishon Vijay Abraham I, Tom Rini,
	Simon Glass, Marek Vasut, Pavel Herrmann

In some cases we want to obtain an ofnode in the same tree as a different
ofnode, such as when looking up a subnode. At present this is trivial,
since there is only one tree. When there are multiple trees, this
implementation will change.

Also move the ofnode_to_offset() function up higher in the header file,
since we will need to provide a different implementation with multiple
trees.

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

 drivers/core/ofnode.c |  2 +-
 include/dm/ofnode.h   | 39 +++++++++++++++++++++++++++++----------
 2 files changed, 30 insertions(+), 11 deletions(-)

diff --git a/drivers/core/ofnode.c b/drivers/core/ofnode.c
index aceb809c1f2..a5c6e309615 100644
--- a/drivers/core/ofnode.c
+++ b/drivers/core/ofnode.c
@@ -1273,7 +1273,7 @@ int ofnode_add_subnode(ofnode node, const char *name, ofnode *subnodep)
 					 ofnode_to_offset(node), name);
 		if (offset < 0)
 			return offset == -FDT_ERR_EXISTS ? -EEXIST : 0;
-		subnode = offset_to_ofnode(offset);
+		subnode = noffset_to_ofnode(node, offset);
 	}
 
 	*subnodep = subnode;
diff --git a/include/dm/ofnode.h b/include/dm/ofnode.h
index ad196af2d45..a79909c12e1 100644
--- a/include/dm/ofnode.h
+++ b/include/dm/ofnode.h
@@ -54,6 +54,23 @@ static inline void *ofnode_to_fdt(ofnode node)
 	return (void *)gd->fdt_blob;
 }
 
+/**
+ * ofnode_to_offset() - convert an ofnode to a flat DT offset
+ *
+ * This cannot be called if the reference contains a node pointer.
+ *
+ * @node: Reference containing offset (possibly invalid)
+ * Return: DT offset (can be -1)
+ */
+static inline int ofnode_to_offset(ofnode node)
+{
+#ifdef OF_CHECKS
+	if (of_live_active())
+		return -1;
+#endif
+	return node.of_offset;
+}
+
 /**
  * ofnode_to_np() - convert an ofnode to a live DT node pointer
  *
@@ -90,20 +107,22 @@ static inline struct device_node *ofnode_to_npw(ofnode node)
 }
 
 /**
- * ofnode_to_offset() - convert an ofnode to a flat DT offset
+ * noffset_to_ofnode() - convert a DT offset to an ofnode
  *
- * This cannot be called if the reference contains a node pointer.
- *
- * @node: Reference containing offset (possibly invalid)
- * Return: DT offset (can be -1)
+ * @other_node: Node in the same tree to use as a reference
+ * @of_offset: DT offset (either valid, or -1)
+ * Return: reference to the associated DT offset
  */
-static inline int ofnode_to_offset(ofnode node)
+static inline ofnode noffset_to_ofnode(ofnode other_node, int of_offset)
 {
-#ifdef OF_CHECKS
+	ofnode node;
+
 	if (of_live_active())
-		return -1;
-#endif
-	return node.of_offset;
+		node.np = NULL;
+	else
+		node.of_offset = of_offset;
+
+	return node;
 }
 
 /**
-- 
2.37.2.672.g94769d06f0-goog


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

* [PATCH 19/21] dm: core: Add definitions for multiple ofnode trees
  2022-08-31  3:07 [PATCH 00/21] dm: core: Support multiple device trees in ofnode Simon Glass
                   ` (17 preceding siblings ...)
  2022-08-31  3:08 ` [PATCH 18/21] dm: core: Allow obtaining a node offset in the same tree Simon Glass
@ 2022-08-31  3:08 ` Simon Glass
  2022-08-31  3:08 ` [PATCH 20/21] dm: core: Reduce code size with dev_of_offset() Simon Glass
  2022-08-31  3:08 ` [PATCH 21/21] dm: core: Add the ofnode multi-tree implementation Simon Glass
  20 siblings, 0 replies; 23+ messages in thread
From: Simon Glass @ 2022-08-31  3:08 UTC (permalink / raw)
  To: U-Boot Mailing List
  Cc: Michal Simek, Marek Behún, Kishon Vijay Abraham I, Tom Rini,
	Simon Glass, Marek Vasut, Pavel Herrmann

At present, unless OF_LIVE is enabled, ofnode only supports access to one
device tree, the control FDT. This is because only the node offset is
encoded in ofnode, with the tree being implicit.

This makes ofnode (without OF_LIVE) unsuitable for device tree fixups, as
implemented by ft_board_setup() and other such functions.

To solve this, we can use the top bits of the node offset to hold a tree
ID.

Add the definitions for this.

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

 drivers/core/Kconfig     | 24 ++++++++++++++++++++++++
 include/dm/ofnode_decl.h | 29 +++++++++++++++++++++++++++--
 2 files changed, 51 insertions(+), 2 deletions(-)

diff --git a/drivers/core/Kconfig b/drivers/core/Kconfig
index 007dc6a1de3..7b5e0e2390e 100644
--- a/drivers/core/Kconfig
+++ b/drivers/core/Kconfig
@@ -400,6 +400,30 @@ config DM_DEV_READ_INLINE
 	bool
 	default y if !OF_LIVE
 
+config OFNODE_MULTI_TREE
+	bool "Allow the ofnode interface to access any tree"
+	default y if EVENT && !DM_DEV_READ_INLINE && !DM_INLINE_OFNODE
+	help
+	  Normally U-Boot makes use of its control FDT, the one used to bind
+	  devices and provide options. In some cases, U-Boot must also process
+	  a separate FDT, e.g. one provided by the operating system, which
+	  needs additions to the /chosen node.
+
+	  This works fine with live tree (OF_LIVE), but with flat tree the
+	  offset provided in ofnode is only useful with the control FDT. This
+	  option adds a 'tree ID' to the offset, so that multiple trees can
+	  be used. Call ofnode_path_root() to register a new tree.
+
+config OFNODE_MULTI_TREE_MAX
+	int "Maximum number of FDTs"
+	range 2 8
+	depends on OFNODE_MULTI_TREE
+	default 4
+	help
+	  Sets the maximum number of device trees which can be used with the
+	  ofnode interface when using flat trees (OF_LIVE). This is only
+	  available in U-Boot proper and only after relocation.
+
 config ACPIGEN
 	bool "Support ACPI table generation in driver model"
 	default y if SANDBOX || (GENERATE_ACPI_TABLE && !QEMU)
diff --git a/include/dm/ofnode_decl.h b/include/dm/ofnode_decl.h
index 8d0d7885aa6..f0ccdc529f8 100644
--- a/include/dm/ofnode_decl.h
+++ b/include/dm/ofnode_decl.h
@@ -31,8 +31,14 @@
  * this increases code size slightly due to the subtraction. Since it offers no
  * real benefit, the approach described here seems best.
  *
- * For now these points use constant types, since we don't allow writing
- * the DT.
+ * Where multiple trees are in use, this works without any trouble with live
+ * tree, except for aliases, such as ofnode_path("mmc0"), which only work on the
+ * control FDT. When the flat tree is in use, the trees are registered and a
+ * 'tree ID' is encoded into the top bits of @of_offset - see immediately below
+ * for the associated macro definitions. Note that 64-bit machines use the same
+ * encoding, even though there is more space available. This is partly because
+ * the FDT format contains 32-bit values for things like the string-table
+ * offset, therefore 64-bit offsets cannot be supported anyway.
  *
  * @np: Pointer to device node, used for live tree
  * @of_offset: Pointer into flat device tree, used for flat tree. Note that this
@@ -43,6 +49,25 @@ typedef union ofnode_union {
 	long of_offset;
 } ofnode;
 
+/* shift for the tree ID within of_offset */
+#define OF_TREE_SHIFT 28
+
+/* mask to obtain the device tree offset from of_offset */
+#define OF_TREE_MASK ((1 << OF_TREE_SHIFT) - 1)
+
+/* encode a tree ID and node offset into an of_offset value */
+#define OFTREE_NODE(tree_id, offs)	((tree_id) << OF_TREE_SHIFT | (offs))
+
+/* decode the node offset from an of_offset value */
+#define OFTREE_OFFSET(of_offs)		((of_offs) & OF_TREE_MASK)
+
+/* decode the tree ID from an of_offset value */
+#define OFTREE_TREE_ID(of_offs)		((of_offs) >> OF_TREE_SHIFT)
+
+/* encode a node offset in the tree given by another node's of_offset value */
+#define OFTREE_MAKE_NODE(other_of_offset, offs)	\
+		(((offs) & OF_TREE_MASK) | ((other_of_offset) & ~OF_TREE_MASK))
+
 /**
  * struct ofprop - reference to a property of a device tree node
  *
-- 
2.37.2.672.g94769d06f0-goog


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

* [PATCH 20/21] dm: core: Reduce code size with dev_of_offset()
  2022-08-31  3:07 [PATCH 00/21] dm: core: Support multiple device trees in ofnode Simon Glass
                   ` (18 preceding siblings ...)
  2022-08-31  3:08 ` [PATCH 19/21] dm: core: Add definitions for multiple ofnode trees Simon Glass
@ 2022-08-31  3:08 ` Simon Glass
  2022-08-31  3:08 ` [PATCH 21/21] dm: core: Add the ofnode multi-tree implementation Simon Glass
  20 siblings, 0 replies; 23+ messages in thread
From: Simon Glass @ 2022-08-31  3:08 UTC (permalink / raw)
  To: U-Boot Mailing List
  Cc: Michal Simek, Marek Behún, Kishon Vijay Abraham I, Tom Rini,
	Simon Glass, Marek Vasut, Pavel Herrmann

Update the function to mark it with the const attribute. Also avoid
calling it multiple times in the devfdt_get_addr_index() function.

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

 drivers/core/fdtaddr.c | 18 +++++++++---------
 include/dm/device.h    |  6 +++---
 2 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/drivers/core/fdtaddr.c b/drivers/core/fdtaddr.c
index c3a50a2b0c1..91bcd1a2c21 100644
--- a/drivers/core/fdtaddr.c
+++ b/drivers/core/fdtaddr.c
@@ -21,6 +21,8 @@ DECLARE_GLOBAL_DATA_PTR;
 fdt_addr_t devfdt_get_addr_index(const struct udevice *dev, int index)
 {
 #if CONFIG_IS_ENABLED(OF_REAL)
+	int offset = dev_of_offset(dev);
+	int parent = dev_of_offset(dev->parent);
 	fdt_addr_t addr;
 
 	if (CONFIG_IS_ENABLED(OF_TRANSLATE)) {
@@ -28,21 +30,19 @@ fdt_addr_t devfdt_get_addr_index(const struct udevice *dev, int index)
 		int len = 0;
 		int na, ns;
 
-		na = fdt_address_cells(gd->fdt_blob,
-				       dev_of_offset(dev->parent));
+		na = fdt_address_cells(gd->fdt_blob, parent);
 		if (na < 1) {
 			debug("bad #address-cells\n");
 			return FDT_ADDR_T_NONE;
 		}
 
-		ns = fdt_size_cells(gd->fdt_blob, dev_of_offset(dev->parent));
+		ns = fdt_size_cells(gd->fdt_blob, parent);
 		if (ns < 0) {
 			debug("bad #size-cells\n");
 			return FDT_ADDR_T_NONE;
 		}
 
-		reg = fdt_getprop(gd->fdt_blob, dev_of_offset(dev), "reg",
-				  &len);
+		reg = fdt_getprop(gd->fdt_blob, offset, "reg", &len);
 		if (!reg || (len <= (index * sizeof(fdt32_t) * (na + ns)))) {
 			debug("Req index out of range\n");
 			return FDT_ADDR_T_NONE;
@@ -56,7 +56,7 @@ fdt_addr_t devfdt_get_addr_index(const struct udevice *dev, int index)
 			 * bus setups.
 			 */
 			addr = fdt_translate_address((void *)gd->fdt_blob,
-						     dev_of_offset(dev), reg);
+						     offset, reg);
 		} else {
 			/* Non translatable if #size-cells == 0 */
 			addr = fdt_read_number(reg, na);
@@ -66,9 +66,9 @@ fdt_addr_t devfdt_get_addr_index(const struct udevice *dev, int index)
 		 * Use the "simple" translate function for less complex
 		 * bus setups.
 		 */
-		addr = fdtdec_get_addr_size_auto_parent(gd->fdt_blob,
-				dev_of_offset(dev->parent), dev_of_offset(dev),
-				"reg", index, NULL, false);
+		addr = fdtdec_get_addr_size_auto_parent(gd->fdt_blob, parent,
+							offset, "reg", index,
+							NULL, false);
 		if (CONFIG_IS_ENABLED(SIMPLE_BUS) && addr != FDT_ADDR_T_NONE) {
 			if (device_get_uclass_id(dev->parent) ==
 			    UCLASS_SIMPLE_BUS)
diff --git a/include/dm/device.h b/include/dm/device.h
index 12c6ba37ff3..f3f953c9afc 100644
--- a/include/dm/device.h
+++ b/include/dm/device.h
@@ -253,7 +253,7 @@ static inline void dev_bic_flags(struct udevice *dev, u32 bic)
  * @dev:	device to check
  * Return: reference of the device's DT node
  */
-static inline ofnode dev_ofnode(const struct udevice *dev)
+static inline __attribute_const__ ofnode dev_ofnode(const struct udevice *dev)
 {
 #if CONFIG_IS_ENABLED(OF_REAL)
 	return dev->node_;
@@ -273,7 +273,7 @@ static inline ofnode dev_ofnode(const struct udevice *dev)
 #define dev_get_dma_offset(_dev)		0
 #endif
 
-static inline int dev_of_offset(const struct udevice *dev)
+static inline __attribute_const__ int dev_of_offset(const struct udevice *dev)
 {
 #if CONFIG_IS_ENABLED(OF_REAL)
 	return ofnode_to_offset(dev_ofnode(dev));
@@ -282,7 +282,7 @@ static inline int dev_of_offset(const struct udevice *dev)
 #endif
 }
 
-static inline bool dev_has_ofnode(const struct udevice *dev)
+static inline __attribute_const__ bool dev_has_ofnode(const struct udevice *dev)
 {
 #if CONFIG_IS_ENABLED(OF_REAL)
 	return ofnode_valid(dev_ofnode(dev));
-- 
2.37.2.672.g94769d06f0-goog


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

* [PATCH 21/21] dm: core: Add the ofnode multi-tree implementation
  2022-08-31  3:07 [PATCH 00/21] dm: core: Support multiple device trees in ofnode Simon Glass
                   ` (19 preceding siblings ...)
  2022-08-31  3:08 ` [PATCH 20/21] dm: core: Reduce code size with dev_of_offset() Simon Glass
@ 2022-08-31  3:08 ` Simon Glass
  20 siblings, 0 replies; 23+ messages in thread
From: Simon Glass @ 2022-08-31  3:08 UTC (permalink / raw)
  To: U-Boot Mailing List
  Cc: Michal Simek, Marek Behún, Kishon Vijay Abraham I, Tom Rini,
	Simon Glass, Marek Vasut, Pavel Herrmann

Add the logic to redirect requests for the device tree through a function
which can look up the tree ID. This works by using the top bits of
ofnode.of_offset to encode a tree.

It is assumed that there will only be a few device trees used at runtime,
typically the control FDT (always tree ID 0) and possibly a separate FDT
to be passed the OS.

The maximum number of device trees supported at runtime is 8, with this
implementation. That would use bits 30:28 of the node-offset value,
meaning that the positive offset range is limited to bits 27:0, versus
30:1 with this feature disabled. That still allows a device tree of up
to 256MB, which should be enough for most FITs. Larger ones can be
supported by using external data with the FIT, or by enabling OF_LIVE.

Update the documentation a little.

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

 doc/develop/driver-model/livetree.rst |  13 +--
 drivers/core/ofnode.c                 | 124 +++++++++++++++++++++++++-
 include/dm/ofnode.h                   |  41 ++++++---
 3 files changed, 161 insertions(+), 17 deletions(-)

diff --git a/doc/develop/driver-model/livetree.rst b/doc/develop/driver-model/livetree.rst
index 4ef8c517325..76be89b9633 100644
--- a/doc/develop/driver-model/livetree.rst
+++ b/doc/develop/driver-model/livetree.rst
@@ -250,11 +250,14 @@ a flat tree.
 It would be helpful to use livetree for fixups, since adding a lot of nodes and
 properties would involve less memory copying and be more efficient. As a step
 towards this, an `oftree` type has been introduced. It is normally set to
-oftree_default() but can be set to other values. Eventually this should allow
-the use of FDT fixups using the ofnode interface, instead of the low-level
-libfdt one.
-
-See dm_test_ofnode_root() for some examples.
+oftree_default() but can be set to other values using oftree_from_fdt().
+So long as OF_LIVE is disabled, it is possible to do fixups using the ofnode
+interface. The OF_LIVE support required addition of the flattening step at the
+end.
+
+See dm_test_ofnode_root() for some examples. The ofnode_path_root() function
+causes a flat device tree to be 'registered' such that it can be used by the
+ofnode interface.
 
 
 Internal implementation
diff --git a/drivers/core/ofnode.c b/drivers/core/ofnode.c
index a5c6e309615..b2b4b8d54cc 100644
--- a/drivers/core/ofnode.c
+++ b/drivers/core/ofnode.c
@@ -4,6 +4,8 @@
  * Written by Simon Glass <sjg@chromium.org>
  */
 
+#define LOG_CATEGORY	LOGC_DT
+
 #include <common.h>
 #include <dm.h>
 #include <fdtdec.h>
@@ -18,6 +20,126 @@
 #include <linux/ioport.h>
 #include <asm/global_data.h>
 
+DECLARE_GLOBAL_DATA_PTR;
+
+#if CONFIG_IS_ENABLED(OFNODE_MULTI_TREE)
+static void *oftree_list[CONFIG_OFNODE_MULTI_TREE_MAX];
+static int oftree_count;
+
+void oftree_reset(void)
+{
+	if (gd->flags & GD_FLG_RELOC) {
+		oftree_count = 0;
+		oftree_list[oftree_count++] = (void *)gd->fdt_blob;
+	}
+}
+
+static int oftree_find(const void *fdt)
+{
+	int i;
+
+	for (i = 0; i < oftree_count; i++) {
+		if (fdt == oftree_list[i])
+			return i;
+	}
+
+	return -1;
+}
+
+static ofnode oftree_ensure(void *fdt, const char *path)
+{
+	int offset, i;
+	ofnode node;
+
+	if (gd->flags & GD_FLG_RELOC) {
+		i = oftree_find(fdt);
+		if (i == -1) {
+			if (oftree_count == CONFIG_OFNODE_MULTI_TREE_MAX) {
+				log_warning("Too many registered device trees (max %d)\n",
+					    CONFIG_OFNODE_MULTI_TREE_MAX);
+				return ofnode_null();
+			}
+
+			/* register the new tree */
+			i = oftree_count++;
+			oftree_list[i] = fdt;
+			log_debug("oftree: registered tree %d: %p\n", i, fdt);
+		}
+	} else {
+		if (fdt != gd->fdt_blob) {
+			log_debug("Cannot only access control FDT before relocation\n");
+			return ofnode_null();
+		}
+	}
+
+	offset = fdt_path_offset(fdt, path);
+	if (offset < 0) {
+		log_debug("Unable to find path '%s' in tree %p\n", path, fdt);
+		return ofnode_null();
+	}
+
+	node.of_offset = OFTREE_NODE(i, offset);
+
+	return node;
+}
+
+void *ofnode_lookup_fdt(ofnode node)
+{
+	if (gd->flags & GD_FLG_RELOC) {
+		uint i = OFTREE_TREE_ID(node.of_offset);
+
+		if (i > oftree_count) {
+			log_debug("Invalid tree ID %x\n", i);
+			return NULL;
+		}
+
+		return oftree_list[i];
+	} else {
+		return (void *)gd->fdt_blob;
+	}
+}
+
+void *ofnode_to_fdt(ofnode node)
+{
+#ifdef OF_CHECKS
+	if (of_live_active())
+		return NULL;
+#endif
+	if (CONFIG_IS_ENABLED(OFNODE_MULTI_TREE) && ofnode_valid(node))
+		return ofnode_lookup_fdt(node);
+
+	/* Use the control FDT by default */
+	return (void *)gd->fdt_blob;
+}
+
+/**
+ * ofnode_to_offset() - convert an ofnode to a flat DT offset
+ *
+ * This cannot be called if the reference contains a node pointer.
+ *
+ * @node: Reference containing offset (possibly invalid)
+ * Return: DT offset (can be -1)
+ */
+int ofnode_to_offset(ofnode node)
+{
+#ifdef OF_CHECKS
+	if (of_live_active())
+		return -1;
+#endif
+	if (CONFIG_IS_ENABLED(OFNODE_MULTI_TREE) && node.of_offset >= 0)
+		return OFTREE_OFFSET(node.of_offset);
+
+	return node.of_offset;
+}
+
+#else /* !OFNODE_MULTI_TREE */
+
+static ofnode oftree_ensure(void *fdt, const char *path)
+{
+	return offset_to_ofnode(fdt_path_offset(fdt, path));
+}
+#endif /* OFNODE_MULTI_TREE */
+
 bool ofnode_name_eq(ofnode node, const char *name)
 {
 	const char *node_name;
@@ -575,7 +697,7 @@ ofnode ofnode_path_root(oftree tree, const char *path)
 	else if (*path != '/' && tree.fdt != gd->fdt_blob)
 		return ofnode_null();  /* Aliases only on control FDT */
 	else
-		return offset_to_ofnode(fdt_path_offset(tree.fdt, path));
+		return oftree_ensure(tree.fdt, path);
 }
 
 const void *ofnode_read_chosen_prop(const char *propname, int *sizep)
diff --git a/include/dm/ofnode.h b/include/dm/ofnode.h
index a79909c12e1..4d614b0a6e3 100644
--- a/include/dm/ofnode.h
+++ b/include/dm/ofnode.h
@@ -27,13 +27,14 @@ struct ofnode_phandle_args {
 	uint32_t args[OF_MAX_PHANDLE_ARGS];
 };
 
+#if CONFIG_IS_ENABLED(OFNODE_MULTI_TREE)
 /**
  * oftree_reset() - reset the state of the oftree list
  *
  * Reset the oftree list so it can be started again. This should be called
  * once the control FDT is in place, but before the ofnode interface is used.
  */
-static inline void oftree_reset(void) {}
+void oftree_reset(void);
 
 /**
  * ofnode_to_fdt() - convert an ofnode to a flat DT pointer
@@ -43,26 +44,32 @@ static inline void oftree_reset(void) {}
  * @node: Reference containing offset (possibly invalid)
  * Return: DT offset (can be NULL)
  */
+__attribute_const__ void *ofnode_to_fdt(ofnode node);
+
+/**
+ * ofnode_to_offset() - convert an ofnode to a flat DT offset
+ *
+ * This cannot be called if the reference contains a node pointer.
+ *
+ * @node: Reference containing offset (possibly invalid)
+ * Return: DT offset (can be -1)
+ */
+__attribute_const__ int ofnode_to_offset(ofnode node);
+
+#else /* !OFNODE_MULTI_TREE */
+static inline void oftree_reset(void) {}
+
 static inline void *ofnode_to_fdt(ofnode node)
 {
 #ifdef OF_CHECKS
 	if (of_live_active())
 		return NULL;
 #endif
-
 	/* Use the control FDT by default */
 	return (void *)gd->fdt_blob;
 }
 
-/**
- * ofnode_to_offset() - convert an ofnode to a flat DT offset
- *
- * This cannot be called if the reference contains a node pointer.
- *
- * @node: Reference containing offset (possibly invalid)
- * Return: DT offset (can be -1)
- */
-static inline int ofnode_to_offset(ofnode node)
+static inline __attribute_const__ int ofnode_to_offset(ofnode node)
 {
 #ifdef OF_CHECKS
 	if (of_live_active())
@@ -70,6 +77,7 @@ static inline int ofnode_to_offset(ofnode node)
 #endif
 	return node.of_offset;
 }
+#endif /* OFNODE_MULTI_TREE */
 
 /**
  * ofnode_to_np() - convert an ofnode to a live DT node pointer
@@ -139,6 +147,17 @@ static inline bool ofnode_valid(ofnode node)
 		return node.of_offset >= 0;
 }
 
+/**
+ * ofnode_lookup_fdt() - look up the FDT for a node
+ *
+ * Given a node this returns a pointer to the device tree containing that node.
+ * This can only be called when the flat tree is in use
+ *
+ * @node: Node to look up, may be ofnode_null()
+ * @return associated device tree, or gd->fdt_blob if @node is ofnode_null()
+ */
+void *ofnode_lookup_fdt(ofnode node);
+
 /**
  * oftree_lookup_fdt() - object the FDT pointer from an oftree
  *
-- 
2.37.2.672.g94769d06f0-goog


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

* Re: [PATCH 08/21] dm: core: Allow adding ofnode subnodes
  2022-08-31  3:08 ` [PATCH 08/21] dm: core: Allow adding ofnode subnodes Simon Glass
@ 2022-09-01  7:07   ` Rasmus Villemoes
  0 siblings, 0 replies; 23+ messages in thread
From: Rasmus Villemoes @ 2022-09-01  7:07 UTC (permalink / raw)
  To: Simon Glass, U-Boot Mailing List
  Cc: Michal Simek, Marek Behún, Kishon Vijay Abraham I, Tom Rini,
	Marek Vasut, Pavel Herrmann

On 31/08/2022 05.08, Simon Glass wrote:
> Add this feature to the ofnode interface, supporting both livetree and
> flattree.
> 
> Signed-off-by: Simon Glass <sjg@chromium.org>
> ---
> 
>  drivers/core/of_access.c | 50 ++++++++++++++++++++++++++++++++++++++++
>  drivers/core/ofnode.c    | 30 ++++++++++++++++++++++++
>  include/dm/of_access.h   | 12 ++++++++++
>  include/dm/ofnode.h      | 12 ++++++++++
>  test/dm/ofnode.c         | 17 ++++++++++++++
>  5 files changed, 121 insertions(+)
> 
> diff --git a/drivers/core/of_access.c b/drivers/core/of_access.c
> index ee09bbb7550..765b21cecdb 100644
> --- a/drivers/core/of_access.c
> +++ b/drivers/core/of_access.c
> @@ -931,3 +931,53 @@ int of_write_prop(struct device_node *np, const char *propname, int len,
>  
>  	return 0;
>  }
> +
> +int of_add_subnode(struct device_node *parent, const char *name, int len,
> +		   struct device_node **childp)
> +{
> +	struct device_node *child, *new, *last_sibling = NULL;
> +	char *new_name, *full_name;
> +	int parent_fnl;
> +
> +	__for_each_child_of_node(parent, child) {
> +		if (!strncmp(child->name, name, len) && strlen(name) == len)

I'm confused. The documentation comment further down says that len is
the length of name. So why this check? And further, the only caller (at
least introduced here, haven't been through the whole series) indeed
passes strlen(name).

So why is that even a parameter? Can't of_add_subnode() just do
len=strlen(name) itself? And then of course the strlen(name)==len
condition goes away, and the strncmp() can just be spelled strcmp() -
which also looks much more natural when asking "does such a child node
already exist".

> +			return -EEXIST;

It seems natural to provide the existing node in *childp when -EEXIST.
Callers that want to error out on -EEXIST can just do that and ignore
that value, but callers that just wants to ensure there is a subnode
with the given name can avoid doing a find_subnode() upfront, which
should make much code much more compact.

> +		last_sibling = child;
> +	}
> +
> +	/* Property does not exist -> append new property */

s/property/[sub]node/, or just delete the comment, it's obvious.

> +	new = calloc(1, sizeof(struct device_node));
> +	if (!new)
> +		return -ENOMEM;
> +
> +	new_name = malloc(len + 1);
> +	if (!name) {

That's not the variable you want to test...

> +		free(new);
> +		return -ENOMEM;
> +	}
> +	strlcpy(new_name, name, len + 1);
> +	new->name = new_name;

new->name = memdup(name, len+1);
if (!new->name) {...}

is a bit shorter.

> +	parent_fnl = parent->name ? strlen(parent->full_name) : 0;
> +	full_name = calloc(1, parent_fnl + 1 + len + 1);
> +	if (!full_name) {
> +		free(new_name);
> +		free(new);
> +		return -ENOMEM;
> +	}
> +	strcpy(full_name, parent->full_name);

Confused. Above, we use parent->name as a condition for whether
parent->full_name exists (or at least whether we should compute its
strlen). Here we unconditionally access parent->full_name. I don't know
the rules for the root node, but I can kind of guess that it has ->name
NULL and ->full_name set to "". Perhaps that could be clarified in the
documentation for struct device_node?

And if I'm right, that means there's no point asking if parent->name is
NULL or not; strlen(parent->full_name) gives the right answer regardless.

Rasmus

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

end of thread, other threads:[~2022-09-01  7:07 UTC | newest]

Thread overview: 23+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-08-31  3:07 [PATCH 00/21] dm: core: Support multiple device trees in ofnode Simon Glass
2022-08-31  3:07 ` [PATCH 01/21] image: Fix BOOTM_STATE values Simon Glass
2022-08-31  3:07 ` [PATCH 02/21] treewide: Drop bootm_headers_t typedef Simon Glass
2022-08-31  3:07 ` [PATCH 03/21] treewide: Drop image_info_t typedef Simon Glass
2022-08-31  3:08 ` [PATCH 04/21] treewide: Drop image_header_t typedef Simon Glass
2022-08-31  3:08 ` [PATCH 05/21] event: Fix a typo in the EVENT help Simon Glass
2022-08-31  3:08 ` [PATCH 06/21] dm: core: Pass a root node to of_find_node_by_phandle() Simon Glass
2022-08-31  3:08 ` [PATCH 07/21] event: Pass the images to EVT_FT_FIXUP Simon Glass
2022-08-31  3:08 ` [PATCH 08/21] dm: core: Allow adding ofnode subnodes Simon Glass
2022-09-01  7:07   ` Rasmus Villemoes
2022-08-31  3:08 ` [PATCH 09/21] dm: core: Support writing a property to an empty node Simon Glass
2022-08-31  3:08 ` [PATCH 10/21] dm: core: Drop the const from ofnode Simon Glass
2022-08-31  3:08 ` [PATCH 11/21] test: Make a copy of the device tree before running a test Simon Glass
2022-08-31  3:08 ` [PATCH 12/21] test: Detect a change in the device tree Simon Glass
2022-08-31  3:08 ` [PATCH 13/21] test: Drop the UT_TESTF_LIVE_OR_FLAT flag Simon Glass
2022-08-31  3:08 ` [PATCH 14/21] dm: core: Provide a way to reset the device tree Simon Glass
2022-08-31  3:08 ` [PATCH 15/21] dm: core: Add an ofnode function to obtain the flat tree Simon Glass
2022-08-31  3:08 ` [PATCH 16/21] dm: core: Add ofnode functions to obtain an oftree Simon Glass
2022-08-31  3:08 ` [PATCH 17/21] dm: core: Add a way to look up a phandle in " Simon Glass
2022-08-31  3:08 ` [PATCH 18/21] dm: core: Allow obtaining a node offset in the same tree Simon Glass
2022-08-31  3:08 ` [PATCH 19/21] dm: core: Add definitions for multiple ofnode trees Simon Glass
2022-08-31  3:08 ` [PATCH 20/21] dm: core: Reduce code size with dev_of_offset() Simon Glass
2022-08-31  3:08 ` [PATCH 21/21] dm: core: Add the ofnode multi-tree implementation 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.