diff options
author | Sascha Hauer <s.hauer@pengutronix.de> | 2012-10-07 00:15:17 +0200 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2012-10-09 20:58:27 +0200 |
commit | 3510a4b0f596e87c0e810abd8773eb09404bc9ac (patch) | |
tree | b2060de3a194aab7d47a5843b2a4a2893187fd5b | |
parent | b3dbaa9a60bb9a2bce9db50941450a6fd1dc6e19 (diff) | |
download | barebox-3510a4b0f596e87c0e810abd8773eb09404bc9ac.tar.gz barebox-3510a4b0f596e87c0e810abd8773eb09404bc9ac.tar.xz |
console/of: evaluate linux,stdout-path property
When a linux,stdout-path property is given in the devicetree
activate the corresponding console.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
-rw-r--r-- | common/console.c | 3 | ||||
-rw-r--r-- | drivers/of/base.c | 23 | ||||
-rw-r--r-- | include/of.h | 6 |
3 files changed, 32 insertions, 0 deletions
diff --git a/common/console.c b/common/console.c index 069e66e4bc..b4b3a9997f 100644 --- a/common/console.c +++ b/common/console.c @@ -164,6 +164,9 @@ int console_register(struct console_device *newcdev) activate = 1; } + if (newcdev->dev && of_device_is_stdout_path(newcdev->dev)) + activate = 1; + list_add_tail(&newcdev->list, &console_list); if (activate) diff --git a/drivers/of/base.c b/drivers/of/base.c index fd152d65d9..20daddb86d 100644 --- a/drivers/of/base.c +++ b/drivers/of/base.c @@ -711,11 +711,15 @@ static void __of_probe(struct device_node *node) __of_probe(n); } +struct device_node *of_chosen; + int of_probe(void) { if(!root_node) return -ENODEV; + of_chosen = of_find_node_by_path("/chosen"); + __of_probe(root_node); return 0; @@ -800,3 +804,22 @@ int of_parse_dtb(struct fdt_header *fdt) return 0; } + +int of_device_is_stdout_path(struct device_d *dev) +{ + struct device_node *dn; + const char *name; + + name = of_get_property(of_chosen, "linux,stdout-path", NULL); + if (name == NULL) + return 0; + dn = of_find_node_by_path(name); + + if (!dn) + return 0; + + if (dn == dev->device_node) + return 1; + + return 0; +} diff --git a/include/of.h b/include/of.h index 7b6a23ad71..e6342b667c 100644 --- a/include/of.h +++ b/include/of.h @@ -114,6 +114,7 @@ int of_parse_partitions(const char *cdevname, struct device_node *of_get_root_node(void); int of_alias_get_id(struct device_node *np, const char *stem); +int of_device_is_stdout_path(struct device_d *dev); #else static inline int of_parse_partitions(const char *cdevname, struct device_node *node) @@ -130,6 +131,11 @@ static inline int of_alias_get_id(struct device_node *np, const char *stem) { return -ENOENT; } + +static inline int of_device_is_stdout_path(struct device_d *dev) +{ + return 0; +} #endif #endif /* __OF_H */ |