@@ -246,6 +246,30 @@ int dt_get_bootargs(const char **bootargs)
return 0;
}
+int dt_get_default_console_node(void)
+{
+ const struct fdt_property *prop;
+ int node, len;
+
+ node = fdt_path_offset(fdt, "/chosen");
+ if (node < 0)
+ return node;
+
+ prop = fdt_get_property(fdt, node, "stdout-path", &len);
+ if (!prop) {
+ prop = fdt_get_property(fdt, node, "linux,stdout-path", &len);
+ if (!prop)
+ return len;
+ }
+
+ if (len == 0) {
+ /* When it's useless pretend we didn't find it. */
+ return -FDT_ERR_NOTFOUND;
+ }
+
+ return fdt_path_offset(fdt, prop->data);
+}
+
int dt_init(const void *fdt_ptr)
{
struct dt_bus *defbus = (struct dt_bus *)&dt_default_bus;
@@ -215,6 +215,15 @@ extern int dt_get_reg(int fdtnode, int regidx, struct dt_reg *reg);
extern int dt_get_bootargs(const char **bootargs);
/*
+ * dt_get_default_console_node gets the node of the path stored in
+ * /chosen/stdout-path (or the deprecated /chosen/linux,stdout-path)
+ * returns
+ * - the node (>= 0) on success
+ * - a negative FDT_ERR_* value on failure
+ */
+extern int dt_get_default_console_node(void);
+
+/*
* dt_get_memory_params gets the memory parameters from the /memory node(s)
* storing each memory region ("address size" tuple) in consecutive entries
* of @regs, up to @nr_regs
Signed-off-by: Andrew Jones <drjones@redhat.com> --- lib/devicetree.c | 24 ++++++++++++++++++++++++ lib/devicetree.h | 9 +++++++++ 2 files changed, 33 insertions(+)