diff options
author | Andrey Smirnov <andrew.smirnov@gmail.com> | 2018-05-17 14:29:16 -0700 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2018-05-18 08:31:32 +0200 |
commit | 89677d11e714464d430f9dc09a21fb349d3fb931 (patch) | |
tree | fcb499c0bc24caa0dfc0ce1de5f1961e5ce86093 /common | |
parent | bb64685c7dc96a14d4ec5d7b2355e40343cf094a (diff) | |
download | barebox-89677d11e714464d430f9dc09a21fb349d3fb931.tar.gz barebox-89677d11e714464d430f9dc09a21fb349d3fb931.tar.xz |
common: oftree: Pass bootsource and bootsource instance to kernel
Pass barebox-detected bootsource to Linux to make it availible to
Linux userspace. That information is passed as full path to the node
corresponding to the bootsource and is placed under /chosen/bootsource
and it can be read under Linux in
/sys/firmware/devicetree/base/chosen/bootsource
Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'common')
-rw-r--r-- | common/oftree.c | 28 |
1 files changed, 27 insertions, 1 deletions
diff --git a/common/oftree.c b/common/oftree.c index 8a2ede4c60..a38dfff293 100644 --- a/common/oftree.c +++ b/common/oftree.c @@ -11,6 +11,7 @@ #include <getopt.h> #include <init.h> #include <boot.h> +#include <bootsource.h> #include <i2c/i2c.h> #define MAX_LEVEL 32 /* how deeply nested we will go */ @@ -114,6 +115,29 @@ void of_print_cmdline(struct device_node *root) printf("commandline: %s\n", cmdline); } +static int of_fixup_bootargs_bootsource(struct device_node *root, + struct device_node *chosen) +{ + char *alias_name = bootsource_get_alias_name(); + struct device_node *bootsource; + int ret = 0; + + if (!alias_name) + return 0; + + bootsource = of_find_node_by_alias(root, alias_name); + /* + * If kernel DTB doesn't have the appropriate alias set up, + * give up and exit early. No error is reported. + */ + if (bootsource) + ret = of_set_property(chosen, "bootsource", bootsource->full_name, + strlen(bootsource->full_name) + 1, true); + + free(alias_name); + return ret; +} + static int of_fixup_bootargs(struct device_node *root, void *unused) { struct device_node *node; @@ -131,8 +155,10 @@ static int of_fixup_bootargs(struct device_node *root, void *unused) of_property_write_string(node, "barebox-version", release_string); err = of_property_write_string(node, "bootargs", str); + if (err) + return err; - return err; + return of_fixup_bootargs_bootsource(root, node); } static int of_register_bootargs_fixup(void) |