[U-Boot] [PATCH 08/11] fdt: Add ft_system_setup() function for system device tree additions
Simon Glass
sjg at chromium.org
Wed Oct 15 10:05:38 CEST 2014
Add an additional function for adding information to the device tree before
booting. This permits additions which are not board-specific.
Signed-off-by: Simon Glass <sjg at chromium.org>
---
README | 9 ++++++++-
common/cmd_fdt.c | 15 +++++++++++++++
common/image-fdt.c | 6 ++++++
include/fdt_support.h | 12 ++++++++++++
include/image.h | 6 ++++++
5 files changed, 47 insertions(+), 1 deletion(-)
diff --git a/README b/README
index 46def00..6ecb3e0 100644
--- a/README
+++ b/README
@@ -670,6 +670,13 @@ The following options need to be configured:
Board code has addition modification that it wants to make
to the flat device tree before handing it off to the kernel
+ CONFIG_OF_SYSTEM_SETUP
+
+ Other code has addition modification that it wants to make
+ to the flat device tree before handing it off to the kernel
+ This causes ft_board_setup() to be called before booting the
+ kernel.
+
CONFIG_OF_BOOT_CPU
This define fills in the correct boot CPU in the boot
@@ -3401,7 +3408,7 @@ FIT uImage format:
to 128 or 256, although it does not have to be power of 2).
default: 4096
-
+
CONFIG_MTD_UBI_BEB_LIMIT
This option specifies the maximum bad physical eraseblocks UBI
expects on the MTD device (per 1024 eraseblocks). If the
diff --git a/common/cmd_fdt.c b/common/cmd_fdt.c
index 51341ac..ece8bce 100644
--- a/common/cmd_fdt.c
+++ b/common/cmd_fdt.c
@@ -576,6 +576,18 @@ static int do_fdt(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
}
}
#endif
+#ifdef CONFIG_OF_SYSTEM_SETUP
+ /* Call the board-specific fixup routine */
+ else if (strncmp(argv[1], "sys", 3) == 0) {
+ int err = ft_system_setup(working_fdt, gd->bd);
+
+ if (err) {
+ printf("Failed to add system information to FDT: %s\n",
+ fdt_strerror(err));
+ return CMD_RET_FAILURE;
+ }
+ }
+#endif
/* Create a chosen node */
else if (strncmp(argv[1], "cho", 3) == 0) {
unsigned long initrd_start = 0, initrd_end = 0;
@@ -1015,6 +1027,9 @@ static char fdt_help_text[] =
#ifdef CONFIG_OF_BOARD_SETUP
"fdt boardsetup - Do board-specific set up\n"
#endif
+#ifdef CONFIG_OF_SYSTEM_SETUP
+ "fdt systemsetup - Do system-specific set up\n"
+#endif
"fdt move <fdt> <newaddr> <length> - Copy the fdt to <addr> and make it active\n"
"fdt resize - Resize fdt to size + padding to 4k addr\n"
"fdt print <path> [<prop>] - Recursive print starting at <path>\n"
diff --git a/common/image-fdt.c b/common/image-fdt.c
index 8fbb0d0..8211ab4 100644
--- a/common/image-fdt.c
+++ b/common/image-fdt.c
@@ -476,6 +476,12 @@ int image_setup_libfdt(bootm_headers_t *images, void *blob,
goto err;
}
}
+ if (IMAGE_OF_SYSTEM_SETUP) {
+ if (ft_system_setup(blob, gd->bd)) {
+ printf("ERROR: system-specific fdt fixup failed\n");
+ goto err;
+ }
+ }
fdt_fixup_ethernet(blob);
/* Delete the old LMB reservation */
diff --git a/include/fdt_support.h b/include/fdt_support.h
index f65ebfa..f916171 100644
--- a/include/fdt_support.h
+++ b/include/fdt_support.h
@@ -98,6 +98,18 @@ void ft_board_setup_ex(void *blob, bd_t *bd);
void ft_cpu_setup(void *blob, bd_t *bd);
void ft_pci_setup(void *blob, bd_t *bd);
+/**
+ * Add system-specific data to the FDT before booting the OS.
+ *
+ * Use CONFIG_SYS_FDT_PAD to ensure there is sufficient space.
+ * This function is called if CONFIG_OF_SYSTEM_SETUP is defined
+ *
+ * @param blob FDT blob to update
+ * @param bd_t Pointer to board data
+ * @return 0 if ok, or -FDT_ERR_... on error
+ */
+int ft_system_setup(void *blob, bd_t *bd);
+
void set_working_fdt_addr(void *addr);
int fdt_shrink_to_minimum(void *blob);
int fdt_increase_size(void *fdt, int add_len);
diff --git a/include/image.h b/include/image.h
index 4347532..2896716 100644
--- a/include/image.h
+++ b/include/image.h
@@ -119,6 +119,12 @@ struct lmb;
# define IMAGE_OF_BOARD_SETUP 0
#endif
+#ifdef CONFIG_OF_SYSTEM_SETUP
+# define IMAGE_OF_SYSTEM_SETUP 1
+#else
+# define IMAGE_OF_SYSTEM_SETUP 0
+#endif
+
/*
* Operating System Codes
*/
--
2.1.0.rc2.206.gedb03e5
More information about the U-Boot
mailing list