summaryrefslogtreecommitdiff
path: root/common/fdt_support.c
diff options
context:
space:
mode:
authorKumar Gala <galak@kernel.crashing.org>2007-11-26 17:06:15 -0600
committerGerald Van Baren <vanbaren@cideas.com>2007-12-07 20:51:25 -0500
commit151c8b09b35eebe8fd9139cb6c1d91c27b22f058 (patch)
tree44da4df32b99bb96a5f12e0573eabd1d3c3089a6 /common/fdt_support.c
parent3c9272813fad84c691d0e4989bb18a3ffebdebfc (diff)
downloadu-boot-imx-151c8b09b35eebe8fd9139cb6c1d91c27b22f058.zip
u-boot-imx-151c8b09b35eebe8fd9139cb6c1d91c27b22f058.tar.gz
u-boot-imx-151c8b09b35eebe8fd9139cb6c1d91c27b22f058.tar.bz2
Added fdt_fixup_stdout that uses aliases to set linux,stdout-path
We use a combination of the serialN alias and CONFIG_CONS_INDEX to determine which serial alias we should set linux,stdout-path to. Signed-off-by: Kumar Gala <galak@kernel.crashing.org>
Diffstat (limited to 'common/fdt_support.c')
-rw-r--r--common/fdt_support.c43
1 files changed, 43 insertions, 0 deletions
diff --git a/common/fdt_support.c b/common/fdt_support.c
index 808ec70..d05d656 100644
--- a/common/fdt_support.c
+++ b/common/fdt_support.c
@@ -28,6 +28,7 @@
#include <fdt.h>
#include <libfdt.h>
#include <fdt_support.h>
+#include <exports.h>
/*
* Global data (for the gd->bd)
@@ -67,6 +68,43 @@ int fdt_find_and_setprop(void *fdt, const char *node, const char *prop,
return fdt_setprop(fdt, nodeoff, prop, val, len);
}
+#ifdef CONFIG_OF_STDOUT_VIA_ALIAS
+static int fdt_fixup_stdout(void *fdt, int choosenoff)
+{
+ int err = 0;
+#ifdef CONFIG_CONS_INDEX
+ int node;
+ char sername[9] = { 0 };
+ const char *path;
+
+ sprintf(sername, "serial%d", CONFIG_CONS_INDEX - 1);
+
+ err = node = fdt_path_offset(fdt, "/aliases");
+ if (node >= 0) {
+ int len;
+ path = fdt_getprop(fdt, node, sername, &len);
+ if (path) {
+ char *p = malloc(len);
+ err = -FDT_ERR_NOSPACE;
+ if (p) {
+ memcpy(p, path, len);
+ err = fdt_setprop(fdt, choosenoff,
+ "linux,stdout-path", p, len);
+ free(p);
+ }
+ } else {
+ err = len;
+ }
+ }
+#endif
+ if (err < 0)
+ printf("WARNING: could not set linux,stdout-path %s.\n",
+ fdt_strerror(err));
+
+ return err;
+}
+#endif
+
int fdt_chosen(void *fdt, ulong initrd_start, ulong initrd_end, int force)
{
int nodeoffset;
@@ -157,6 +195,11 @@ int fdt_chosen(void *fdt, ulong initrd_start, ulong initrd_end, int force)
printf("WARNING: could not set linux,initrd-end %s.\n",
fdt_strerror(err));
}
+
+#ifdef CONFIG_OF_STDOUT_VIA_ALIAS
+ err = fdt_fixup_stdout(fdt, nodeoffset);
+#endif
+
#ifdef OF_STDOUT_PATH
err = fdt_setprop(fdt, nodeoffset,
"linux,stdout-path", OF_STDOUT_PATH, strlen(OF_STDOUT_PATH)+1);