diff options
author | Sascha Hauer <s.hauer@pengutronix.de> | 2020-10-14 12:46:52 +0200 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2020-10-14 12:46:52 +0200 |
commit | bee1da7fcc005edab18fde60fd2ce956d12c5e18 (patch) | |
tree | 77d02747d657192acb10500f979b83e20d0447a3 /drivers | |
parent | c29ce8d93f9403c3ce6ccc5e82fb7a7be41d6659 (diff) | |
parent | 765ecaf52b834278a2449fcb097754a3aae9aa96 (diff) | |
download | barebox-bee1da7fcc005edab18fde60fd2ce956d12c5e18.tar.gz barebox-bee1da7fcc005edab18fde60fd2ce956d12c5e18.tar.xz |
Merge branch 'for-next/sandbox' into master
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/of/base.c | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/drivers/of/base.c b/drivers/of/base.c index 63cc2e586c..5b45c2023f 100644 --- a/drivers/of/base.c +++ b/drivers/of/base.c @@ -894,6 +894,43 @@ int of_property_read_u64(const struct device_node *np, const char *propname, EXPORT_SYMBOL_GPL(of_property_read_u64); /** + * of_property_read_u64_array - Find and read an array of 64 bit integers + * from a property. + * + * @np: device node from which the property value is to be read. + * @propname: name of the property to be searched. + * @out_value: pointer to return value, modified only if return value is 0. + * @sz: number of array elements to read + * + * Search for a property in a device node and read 64-bit value(s) from + * it. Returns 0 on success, -EINVAL if the property does not exist, + * -ENODATA if property does not have a value, and -EOVERFLOW if the + * property data isn't large enough. + * + * The out_value is modified only if a valid u64 value can be decoded. + */ +int of_property_read_variable_u64_array(const struct device_node *np, + const char *propname, u64 *out_values, + size_t sz) +{ + size_t count; + const __be32 *val = of_find_property_value_of_size(np, propname, + (sz * sizeof(*out_values))); + + if (IS_ERR(val)) + return PTR_ERR(val); + + count = sz; + while (count--) { + *out_values++ = of_read_number(val, 2); + val += 2; + } + + return sz; +} +EXPORT_SYMBOL_GPL(of_property_read_variable_u64_array); + +/** * of_property_read_string - Find and read a string from a property * @np: device node from which the property value is to be read. * @propname: name of the property to be searched. @@ -1615,6 +1652,34 @@ int of_set_root_node(struct device_node *node) return 0; } +void barebox_register_of(struct device_node *root) +{ + if (root_node) + return; + + of_fix_tree(root); + of_set_root_node(root); + + if (IS_ENABLED(CONFIG_OFDEVICE)) + of_probe(); +} + +void barebox_register_fdt(const void *dtb) +{ + struct device_node *root; + + if (root_node) + return; + + root = of_unflatten_dtb(dtb); + if (IS_ERR(root)) { + pr_err("Cannot unflatten dtb: %pe\n", root); + return; + } + + barebox_register_of(root); +} + /** * of_device_is_available - check if a device is available for use * |