aboutsummaryrefslogtreecommitdiff
path: root/drivers/core/of_access.c
AgeCommit message (Collapse)AuthorFilesLines
2021-02-02common: Drop asm/global_data.h from common headerSimon Glass1-0/+1
Move this out of the common header and include it only where needed. In a number of cases this requires adding "struct udevice;" to avoid adding another large header or in other cases replacing / adding missing header files that had been pulled in, very indirectly. Finally, we have a few cases where we did not need to include <asm/global_data.h> at all, so remove that include. Signed-off-by: Simon Glass <sjg@chromium.org> Signed-off-by: Tom Rini <trini@konsulko.com>
2020-10-06dm: add cells_count parameter in *_count_phandle_with_argsPatrick Delaunay1-3/+4
The cell_count argument is required when cells_name is NULL. This patch adds this parameter in live tree API - of_count_phandle_with_args - ofnode_count_phandle_with_args - dev_count_phandle_with_args This parameter solves issue when these API is used to count the number of element of a cell without cell name. This parameter allow to force the size cell. For example: count = dev_count_phandle_with_args(dev, "array", NULL, 3); Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2020-09-22dm: add cells_count parameter in live DT APIs of_parse_phandle_with_argsPatrick Delaunay1-3/+4
In the live tree API ofnode_parse_phandle_with_args, the cell_count argument must be used when cells_name is NULL. But this argument is not provided to the live DT function of_parse_phandle_with_args even it is provided to fdtdec_parse_phandle_with_args. This patch adds support of the cells_count parameter in dev_ and of_node API to allow migration and support of live DT: - of_parse_phandle_with_args Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2020-05-18common: Drop linux/bug.h from common headerSimon Glass1-0/+1
Move this uncommon header out of the common header. Signed-off-by: Simon Glass <sjg@chromium.org>
2020-05-18common: Drop log.h from common headerSimon Glass1-0/+1
Move this header out of the common header. Signed-off-by: Simon Glass <sjg@chromium.org>
2020-04-16dm: core: add ofnode and dev function to iterate on node propertyPatrick Delaunay1-0/+32
Add functions to iterate on all property with livetree - dev_read_first_prop - dev_read_next_prop - dev_read_prop_by_prop and - ofnode_get_first_property - ofnode_get_next_property - ofnode_get_property_by_prop And helper: dev_for_each_property For example: struct ofprop property; dev_for_each_property(property, config) { value = dev_read_prop_by_prop(&property, &propname, &len); or: for (res = ofnode_get_first_property(node, &property); !res; res = ofnode_get_next_property(&property)) { value = ofnode_get_property_by_prop(&property, &propname, &len); .... } Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2020-04-16dm: core: refactor functions reading an u32 from dtDario Binacchi1-15/+1
Now reading a 32 bit value from a device-tree property can be expressed as reading the first element of an array with a single value. Signed-off-by: Dario Binacchi <dariobin@libero.it> Reviewed-by: Simon Glass <sjg@chromium.org>
2020-04-16dm: core: support reading a single indexed u32 valueDario Binacchi1-0/+22
The patch adds helper functions to allow reading a single indexed u32 value from a device-tree property containing multiple u32 values, that is an array of integers. Signed-off-by: Dario Binacchi <dariobin@libero.it> Reviewed-by: Simon Glass <sjg@chromium.org>
2020-04-16dm: core: remove redundant assignmentHeinrich Schuchardt1-1/+1
Variable count is initialized at the start of every round of the while loop and it is not used after the while loop. So there is no need to initialize it beforehand. Identified by cppcheck. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Reviewed-by: Simon Glass <sjg@chromium.org>
2020-02-05dm: core: Create a new header file for 'compat' featuresSimon Glass1-0/+1
At present dm/device.h includes the linux-compatible features. This requires including linux/compat.h which in turn includes a lot of headers. One of these is malloc.h which we thus end up including in every file in U-Boot. Apart from the inefficiency of this, it is problematic for sandbox which needs to use the system malloc() in some files. Move the compatibility features into a separate header file. Signed-off-by: Simon Glass <sjg@chromium.org>
2019-02-08dm: core: Add of_alias_get_highest_id()Michal Simek1-0/+18
The same functionality was added to Linux for i2c bus registration with this commit message: " of: base: add function to get highest id of an alias stem I2C supports adding adapters using either a dynamic or fixed id. The latter is provided by aliases in the DT case. To prevent id collisions of those two types, install this function which gives us the highest fixed id, so we can then let the dynamically created ones come after this highest number. Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com> Acked-by: Rob Herring <robh@kernel.org> Signed-off-by: Wolfram Sang <wsa@the-dreams.de> " Add it also to U-Boot for DM I2C support. Signed-off-by: Michal Simek <michal.simek@xilinx.com> Reviewed-by: Heiko Schocher <hs@denx.de> Reviewed-by: Simon Glass <sjg@chromium.org>
2018-09-18ofnode: add ofnode_by_prop_value()Jens Wiklander1-0/+27
Adds ofnode_by_prop_value() to search for nodes with a given property and value, an ofnode version of fdt_node_offset_by_prop_value(). Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org> Reviewed-by: Simon Glass <sjg@chromium.org>
2018-07-09dm: core: Add ofnode function to read a 64-bit intSimon Glass1-0/+20
We have a 32-bit version of this function. Add a 64-bit version as well so we can easily read 64-bit ints from the device tree. Signed-off-by: Simon Glass <sjg@chromium.org>
2018-05-07SPDX: Convert all of our single license tags to Linux Kernel styleTom Rini1-2/+1
When U-Boot started using SPDX tags we were among the early adopters and there weren't a lot of other examples to borrow from. So we picked the area of the file that usually had a full license text and replaced it with an appropriate SPDX-License-Identifier: entry. Since then, the Linux Kernel has adopted SPDX tags and they place it as the very first line in a file (except where shebangs are used, then it's second line) and with slightly different comment styles than us. In part due to community overlap, in part due to better tag visibility and in part for other minor reasons, switch over to that style. This commit changes all instances where we have a single declared license in the tag as both the before and after are identical in tag contents. There's also a few places where I found we did not have a tag and have introduced one. Signed-off-by: Tom Rini <trini@konsulko.com>
2018-03-05libfdt: move headers to <linux/libfdt.h> and <linux/libfdt_env.h>Masahiro Yamada1-1/+1
Thomas reported U-Boot failed to build host tools if libfdt-devel package is installed because tools include libfdt headers from /usr/include/ instead of using internal ones. This commit moves the header code: include/libfdt.h -> include/linux/libfdt.h include/libfdt_env.h -> include/linux/libfdt_env.h and replaces include directives: #include <libfdt.h> -> #include <linux/libfdt.h> #include <libfdt_env.h> -> #include <linux/libfdt_env.h> Reported-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com> Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
2017-07-28dm: core: add ofnode_count_phandle_with_args()Patrice Chotard1-0/+7
This function is usefull to get phandle number contained in a property list. For example, this allows to allocate the right amount of memory to keep clock's reference contained into the "clocks" property. To implement it, either of_count_phandle_with_args() or fdtdec_parse_phandle_with_args() are used respectively for live tree and flat tree. By passing index = -1, these 2 functions returns the number of phandle contained into the property list. Add also the dev_count_phandle_with_args() based on ofnode_count_phandle_with_args() Signed-off-by: Patrice Chotard <patrice.chotard@st.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2017-07-11dm: core: Add functions to obtain node's address/size cellsSimon Glass1-0/+24
The of_n_addr_cells() and of_n_size_cells() functions are useful for getting the size of addresses in a node, but in a few places U-Boot needs to obtain the actual property value for a node without walking up the stack. Add functions for this and just the existing code to use it. Add a comment to the existing ofnode functions which do not do the right thing with a flat tree. This fixes a problem reading PCI addresses. Signed-off-by: Simon Glass <sjg@chromium.org> Tested-by: Marcel Ziswiler <marcel.ziswiler@toradex.com> Tested-on: Beaver, Jetson-TK1
2017-06-12dm: core: Supress dead-code warning in __of_get_next_child()Simon Glass1-0/+6
Suppress a warning on next = next->sibling. Signed-off-by: Simon Glass <sjg@chromium.org> Reported-by: Coverity (CID: 163245) Fixes 644ec0a (dm: core: Add livetree access functions)
2017-06-01dm: core: Add livetree access functionsSimon Glass1-0/+735
Add a basic assortment of functions to access the live device tree. These come from Linux v4.9 and are modified for U-Boot to the minimum extent possible. While these functions are now very stable in Linux, it will be possible to merge in fixes if needed. Signed-off-by: Simon Glass <sjg@chromium.org>