aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2012-03-28 10:08:24 +0000
committerAlbert ARIBAUD <albert.u.boot@aribaud.net>2012-03-29 08:12:49 +0200
commit9a263e55dc00f3277d8e82c906ee5c7a1dca0ba5 (patch)
tree01817ce4e4756f0b7b57cead40f06b59639d589d /lib
parent87f938c9f7372f587a43fe7babcb171ee0a0672f (diff)
fdt: Avoid early panic() when there is no FDT present
CONFIG_OF_CONTROL requires a valid device tree. However, we cannot call panic() before the console is set up since the message does not appear, and we get a silent failure. Remove the panic from fdtdec_check_fdt() and provide a new function to prepare the fdt for use. This will be called after the console is ready. Signed-off-by: Simon Glass <sjg@chromium.org> Signed-off-by: Tom Warren <twarren@nvidia.com>
Diffstat (limited to 'lib')
-rw-r--r--lib/fdtdec.c24
1 files changed, 19 insertions, 5 deletions
diff --git a/lib/fdtdec.c b/lib/fdtdec.c
index 4ca442a2a..5239e7947 100644
--- a/lib/fdtdec.c
+++ b/lib/fdtdec.c
@@ -262,17 +262,31 @@ int fdtdec_find_aliases_for_id(const void *blob, const char *name,
return num_found;
}
+int fdtdec_check_fdt(void)
+{
+ /*
+ * We must have an FDT, but we cannot panic() yet since the console
+ * is not ready. So for now, just assert(). Boards which need an early
+ * FDT (prior to console ready) will need to make their own
+ * arrangements and do their own checks.
+ */
+ assert(!fdtdec_prepare_fdt());
+ return 0;
+}
+
/*
* This function is a little odd in that it accesses global data. At some
* point if the architecture board.c files merge this will make more sense.
* Even now, it is common code.
*/
-int fdtdec_check_fdt(void)
+int fdtdec_prepare_fdt(void)
{
- /* We must have an fdt */
- if (((uintptr_t)gd->fdt_blob & 3) || fdt_check_header(gd->fdt_blob))
- panic("No valid fdt found - please append one to U-Boot\n"
- "binary or define CONFIG_OF_EMBED\n");
+ if (((uintptr_t)gd->fdt_blob & 3) || fdt_check_header(gd->fdt_blob)) {
+ printf("No valid FDT found - please append one to U-Boot "
+ "binary, use u-boot-dtb.bin or define "
+ "CONFIG_OF_EMBED\n");
+ return -1;
+ }
return 0;
}