diff options
author | Sascha Hauer <s.hauer@pengutronix.de> | 2013-03-03 12:52:21 +0100 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2013-03-06 11:41:28 +0100 |
commit | 3b181a81091d51684f487470da27c56c87e5ecce (patch) | |
tree | c97a62d64ce91d39155d24cb264275f75e8439fd /drivers/of | |
parent | 43327fe3745bc044dee8b88b1d3593c53e721b4a (diff) | |
download | barebox-3b181a81091d51684f487470da27c56c87e5ecce.tar.gz barebox-3b181a81091d51684f487470da27c56c87e5ecce.tar.xz |
of: Add initrd helper
Add a helper to set the initrd properties in the unflattened tree.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'drivers/of')
-rw-r--r-- | drivers/of/base.c | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/drivers/of/base.c b/drivers/of/base.c index 721db29537..4dbe11ec1d 100644 --- a/drivers/of/base.c +++ b/drivers/of/base.c @@ -1201,3 +1201,42 @@ int of_device_is_stdout_path(struct device_d *dev) return 0; } + +/** + * of_add_initrd - add initrd properties to the devicetree + * @root - the root node of the tree + * @start - physical start address of the initrd image + * @end - physical end address of the initrd image + * + * Add initrd properties to the devicetree, or, if end is 0, + * delete them. + */ +int of_add_initrd(struct device_node *root, resource_size_t start, + resource_size_t end) +{ + struct device_node *chosen; + __be32 buf[2]; + + chosen = of_find_node_by_path(root, "/chosen"); + if (!chosen) + return -EINVAL; + + if (end) { + of_write_number(buf, start, 2); + of_set_property(chosen, "linux,initrd-start", buf, 8, 1); + of_write_number(buf, end, 2); + of_set_property(chosen, "linux,initrd-end", buf, 8, 1); + } else { + struct property *pp; + + pp = of_find_property(chosen, "linux,initrd-start"); + if (pp) + of_delete_property(pp); + + pp = of_find_property(chosen, "linux,initrd-end"); + if (pp) + of_delete_property(pp); + } + + return 0; +} |