dm: Add support for handling old u-boot,dm- tags
Add a CONFIG option to deal with this automatically, printing a warning when U-Boot starts up. This can be useful if the device tree comes from another project. We will maintain this through the 2023.07 release, providing 6 months for people to notice. Signed-off-by: Simon Glass <sjg@chromium.org> Version 4: Acked-by: Michal Simek <michal.simek@amd.com>
This commit is contained in:
parent
7703efbc99
commit
c74e03417b
5 changed files with 50 additions and 6 deletions
|
@ -569,6 +569,13 @@ static int dm_announce(void)
|
||||||
printf("Warning: Unexpected devicetree source (not from a prior stage)");
|
printf("Warning: Unexpected devicetree source (not from a prior stage)");
|
||||||
printf("Warning: U-Boot may not function properly\n");
|
printf("Warning: U-Boot may not function properly\n");
|
||||||
}
|
}
|
||||||
|
if (IS_ENABLED(CONFIG_OF_TAG_MIGRATE) &&
|
||||||
|
(gd->flags & GD_FLG_OF_TAG_MIGRATE))
|
||||||
|
/*
|
||||||
|
* U-Boot will silently fail to work after 2023.07 if
|
||||||
|
* there are old tags present
|
||||||
|
*/
|
||||||
|
printf("Warning: Device tree includes old 'u-boot,dm-' tags: please fix by 2023.07!\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -1330,6 +1330,18 @@ bool ofnode_pre_reloc(ofnode node)
|
||||||
ofnode_read_bool(node, "u-boot,dm-tpl"))
|
ofnode_read_bool(node, "u-boot,dm-tpl"))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
if (IS_ENABLED(CONFIG_OF_TAG_MIGRATE)) {
|
||||||
|
/* detect and handle old tags */
|
||||||
|
if (ofnode_read_bool(node, "u-boot,dm-pre-reloc") ||
|
||||||
|
ofnode_read_bool(node, "u-boot,dm-pre-proper") ||
|
||||||
|
ofnode_read_bool(node, "u-boot,dm-spl") ||
|
||||||
|
ofnode_read_bool(node, "u-boot,dm-tpl") ||
|
||||||
|
ofnode_read_bool(node, "u-boot,dm-vpl")) {
|
||||||
|
gd->flags |= GD_FLG_OF_TAG_MIGRATE;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
10
dts/Kconfig
10
dts/Kconfig
|
@ -342,6 +342,16 @@ config SPL_MULTI_DTB_FIT_USER_DEF_ADDR
|
||||||
at compilation time. This is the address of this area. It must be
|
at compilation time. This is the address of this area. It must be
|
||||||
aligned on 2-byte boundary.
|
aligned on 2-byte boundary.
|
||||||
|
|
||||||
|
config OF_TAG_MIGRATE
|
||||||
|
bool "Ease migration from old device trees with u-boot,dm- tags"
|
||||||
|
default y
|
||||||
|
help
|
||||||
|
U-Boot moved over to use new tags to mark device tree nodes which need
|
||||||
|
to be processed in SPL, before relocation, etc. Enable this option to
|
||||||
|
detect old tags and handle them.
|
||||||
|
|
||||||
|
Note: This option will be removed after the 2023.07 release.
|
||||||
|
|
||||||
config OF_SPL_REMOVE_PROPS
|
config OF_SPL_REMOVE_PROPS
|
||||||
string "List of device tree properties to drop for SPL"
|
string "List of device tree properties to drop for SPL"
|
||||||
depends on SPL_OF_CONTROL
|
depends on SPL_OF_CONTROL
|
||||||
|
|
|
@ -650,6 +650,10 @@ enum gd_flags {
|
||||||
* @GD_FLG_FDT_CHANGED: Device tree change has been detected by tests
|
* @GD_FLG_FDT_CHANGED: Device tree change has been detected by tests
|
||||||
*/
|
*/
|
||||||
GD_FLG_FDT_CHANGED = 0x100000,
|
GD_FLG_FDT_CHANGED = 0x100000,
|
||||||
|
/**
|
||||||
|
* @GD_FLG_OF_TAG_MIGRATE: Device tree has old u-boot,dm- tags
|
||||||
|
*/
|
||||||
|
GD_FLG_OF_TAG_MIGRATE = 0x200000,
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* __ASSEMBLY__ */
|
#endif /* __ASSEMBLY__ */
|
||||||
|
|
|
@ -585,24 +585,35 @@ cmd_mkimage = $(objtree)/tools/mkimage $(MKIMAGEFLAGS_$(@F)) -d $< $@ \
|
||||||
# ---------------------------------------------------------------------------
|
# ---------------------------------------------------------------------------
|
||||||
# Pass the original device tree file through fdtgrep twice. The first pass
|
# Pass the original device tree file through fdtgrep twice. The first pass
|
||||||
# removes any unwanted nodes (i.e. those which don't have the
|
# removes any unwanted nodes (i.e. those which don't have the
|
||||||
# 'u-boot,dm-pre-reloc' property and thus are not needed by SPL. The second
|
# 'bootph-all' property and thus are not needed by SPL. The second
|
||||||
# pass removes various unused properties from the remaining nodes.
|
# pass removes various unused properties from the remaining nodes.
|
||||||
# The output is typically a much smaller device tree file.
|
# The output is typically a much smaller device tree file.
|
||||||
|
|
||||||
|
ifdef CONFIG_OF_TAG_MIGRATE
|
||||||
|
# Support the old tags for a migration period
|
||||||
|
migrate_tpl := -b u-boot,dm-pre-reloc -b u-boot,dm-tpl
|
||||||
|
migrate_vpl := -b u-boot,dm-pre-reloc -b u-boot,dm-vpl
|
||||||
|
migrate_spl := -b u-boot,dm-pre-reloc -b u-boot,dm-spl
|
||||||
|
migrate_all := -P u-boot,dm-pre-reloc \
|
||||||
|
-P u-boot,dm-spl -P u-boot,dm-tpl -P u-boot,dm-vpl
|
||||||
|
endif
|
||||||
|
|
||||||
ifeq ($(CONFIG_VPL_BUILD),y)
|
ifeq ($(CONFIG_VPL_BUILD),y)
|
||||||
fdtgrep_props := -b u-boot,dm-pre-reloc -b u-boot,dm-vpl
|
fdtgrep_props := -b bootph-all -b bootph-verify $(migrate_vpl)
|
||||||
else
|
else
|
||||||
ifeq ($(CONFIG_TPL_BUILD),y)
|
ifeq ($(CONFIG_TPL_BUILD),y)
|
||||||
fdtgrep_props := -b u-boot,dm-pre-reloc -b u-boot,dm-tpl
|
fdtgrep_props := -b bootph-all -b bootph-pre-sram $(migrate_tpl)
|
||||||
else
|
else
|
||||||
fdtgrep_props := -b u-boot,dm-pre-reloc -b u-boot,dm-spl
|
fdtgrep_props := -b bootph-all -b bootph-pre-ram $(migrate_spl)
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
quiet_cmd_fdtgrep = FDTGREP $@
|
quiet_cmd_fdtgrep = FDTGREP $@
|
||||||
cmd_fdtgrep = $(objtree)/tools/fdtgrep $(fdtgrep_props) -RT $< \
|
cmd_fdtgrep = $(objtree)/tools/fdtgrep $(fdtgrep_props) -RT $< \
|
||||||
-n /chosen -n /config -O dtb | \
|
-n /chosen -n /config -O dtb | \
|
||||||
$(objtree)/tools/fdtgrep -r -O dtb - -o $@ \
|
$(objtree)/tools/fdtgrep -r -O dtb - -o $@ \
|
||||||
-P u-boot,dm-pre-reloc -P u-boot,dm-spl -P u-boot,dm-tpl \
|
-P bootph-all -P bootph-pre-ram -P bootph-pre-sram \
|
||||||
-P u-boot,dm-vpl \
|
-P bootph-verify \
|
||||||
|
$(migrate_all) \
|
||||||
$(addprefix -P ,$(subst $\",,$(CONFIG_OF_SPL_REMOVE_PROPS)))
|
$(addprefix -P ,$(subst $\",,$(CONFIG_OF_SPL_REMOVE_PROPS)))
|
||||||
|
|
||||||
# fdt_rm_props
|
# fdt_rm_props
|
||||||
|
|
Loading…
Reference in a new issue