diff options
author | Simon Glass <sjg@chromium.org> | 2015-02-27 22:06:34 -0700 |
---|---|---|
committer | Simon Glass <sjg@chromium.org> | 2015-04-23 09:05:53 -0600 |
commit | b45122fdf5d314ef1f492b051fb104a7b48b8079 (patch) | |
tree | 172f0b1da254a3413a35607c5888b5780fb95da3 /lib/fdtdec.c | |
parent | 5a87c4174d18fe40dcc847ba36853a9f15cb3e1e (diff) | |
download | u-boot-b45122fdf5d314ef1f492b051fb104a7b48b8079.tar.gz u-boot-b45122fdf5d314ef1f492b051fb104a7b48b8079.tar.bz2 u-boot-b45122fdf5d314ef1f492b051fb104a7b48b8079.zip |
fdt: sandbox: Move setup code from board_f to fdtdec
We want to be able to set up the device tree in SPL, so move this code
to a common place.
Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'lib/fdtdec.c')
-rw-r--r-- | lib/fdtdec.c | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/lib/fdtdec.c b/lib/fdtdec.c index 577c60ed0d..d9dbc86164 100644 --- a/lib/fdtdec.c +++ b/lib/fdtdec.c @@ -9,6 +9,7 @@ #include <serial.h> #include <libfdt.h> #include <fdtdec.h> +#include <asm/sections.h> #include <linux/ctype.h> DECLARE_GLOBAL_DATA_PTR; @@ -1037,4 +1038,34 @@ int fdtdec_decode_memory_region(const void *blob, int config_node, return 0; } + +int setup_fdt(void) +{ +#ifdef CONFIG_OF_CONTROL +# ifdef CONFIG_OF_EMBED + /* Get a pointer to the FDT */ + gd->fdt_blob = __dtb_dt_begin; +# elif defined CONFIG_OF_SEPARATE +# ifdef CONFIG_SPL_BUILD + /* FDT is at end of BSS */ + gd->fdt_blob = (ulong *)&__bss_end; +# else + /* FDT is at end of image */ + gd->fdt_blob = (ulong *)&_end; +#endif +# elif defined(CONFIG_OF_HOSTFILE) + if (sandbox_read_fdt_from_file()) { + puts("Failed to read control FDT\n"); + return -1; + } +# endif +# ifndef CONFIG_SPL_BUILD + /* Allow the early environment to override the fdt address */ + gd->fdt_blob = (void *)getenv_ulong("fdtcontroladdr", 16, + (uintptr_t)gd->fdt_blob); +# endif #endif + return 0; +} + +#endif /* !USE_HOSTCC */ |