of_tree_for_each_node_from() is supposed to iterate over all DT nodes
after the one pointed by the from parameter, but with the current
of_next_node() implementation we cannot access the root node.
Patch of_next_node() to point to root_node when from is NULL.
Doing that also simplifies users of of_tree_for_each_node_from() which
were duplicating the logic to point to the root_node when from is NULL.
Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Our asprintf and vasprintf have different prototypes than the glibc
functions. This causes trouble when we want to share barebox code
with userspace code. Change the prototypes for (v)asprintf to match
the glibc prototypes. Since the current (v)asprintf are convenient
to use change the existing functions to b(v)asprintf.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
of_alias_get assumed that a DT path is always the full node path,
whic is not necessarily the case, as there are other valid path
descriptions. All of them are handled by of_find_node_by_path.
As there is already a preparsed list with all DT aliases that handles
this case properly we can simply reuse that one.
Signed-off-by: Lucas Stach <dev@lynxeye.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
This file originates in Linux. Linux has it under include/linux/
directory since commit dccd2304cc90.
Let's move it to the same place as well in barebox.
This commit was generated by the following commands:
find -name '*.[chS]' | xargs sed -i -e 's:<sizes.h>:<linux/sizes.h>:'
git mv include/sizes.h include/linux/
Signed-off-by: Masahiro Yamada <yamada.m@jp.panasonic.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Set a property to a phandle of a child node. This may be used
for selections like display-timings.
Signed-off-by: Teresa Gámez <t.gamez@phytec.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Added of_parse_phandle_from() to be able to use external root nodes.
Signed-off-by: Teresa Gámez <t.gamez@phytec.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Added of_find_node_by_phandle_from() to find nodes by
phandle with a given root node.
Signed-off-by: Teresa Gámez <t.gamez@phytec.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
ePAPR 1.1 specifies the "stdout-path" property, but barebox currently
only handles the "linux,stdout-path" property. Add parsing for the new
property name.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
drivers/of/base.c:70:20: warning: symbol 'root_node' was not declared. Should it be static?
drivers/of/base.c:72:20: warning: symbol 'of_aliases' was not declared. Should it be static?
drivers/of/base.c:1724:20: warning: symbol 'of_chosen' was not declared. Should it be static?
drivers/of/base.c:1725:12: warning: symbol 'of_model' was not declared. Should it be static?
Signed-off-by: Alexander Shiyan <shc_work@mail.ru>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Let of_find_node_by_path_or_alias also find a node starting with an alias
followed by a path like "i2c0/tps@24"
Signed-off-by: Jan Weitzel <j.weitzel@phytec.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
This adds a call to of_clk_init right after platform devices have been
populated.
Signed-off-by: Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Instead of populating an extra list containing all phandles just iterate
over the whole tree. This is done as preparation for more dynamic devicetrees
where parts are loaded at runtime. Here we don't want to keep the list of
phandles in sync.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Import of_find_node_by_type from Linux drivers/of/base.c -
commit id d8dfad3.
This function retrieves a node pointer based on the "device_type"
property of the node.
This is used by device tree update functions in PPC support.
Signed-off-by: Renaud Barbier <renaud.barbier@ge.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Instead of calling of_get_model() in barebox_get_model() add a
barebox_set_model() and use it to set the boardinfo once it's
available from the devicetree.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Otherwise only the internal DT is modified, not necessarily the one passed
to the kernel.
Signed-off-by: David Jander <david@protonic.nl>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
of_get_tree_max_phandle - get the maximum phandle of a tree. Needed for
creating new phandles without conflicts.
of_node_create_phandle - create a phandle for a node which doesn't have one.
of_find_node_by_alias - find a node by alias name
of_find_node_by_path_or_alias - find a node by full path or alias name
of_find_root_node - find the root node for a given device node
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Our devicetree printing is close to correct dts syntax, so fix
some remaining differences:
- Use an equal sign instead of a colon to separate a poperty name and
a value
- Add a semicolon at the end of properties
- Make sure we do not print a separator for empty properties
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
These functions allow to manipulate the "status" property of
devicenodes effectively enabling/disabling devices.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
This adds initialization of from device node with root_node if NULL
is passed. This corresponds to the behavior of all other node iterators.
Signed-off-by: Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
of_get_next_available_child does not iterate but always tries the
same node over and over again. This first prepares the entry and
then uses list_for_each_entry_continue, instead of for_each_child_of_node
before.
Signed-off-by: Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
of_find_node_by_name suffers from infinite looping, because it
does not check for root node of the tree iterated over. This
fixes this by checking for node->parent to determine whether
the last node has been reached.
Since of_tree_for_each_node does not iterate over the whole tree,
but only over the remaining nodes, rename it to
of_tree_for_each_node_from.
Reported-by: NISHIMOTO Hiroki <hiroki.nishimoto.if@gmail.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
of_free is misleading about the actual purpose of the function. There is
already a of_create_node counterpart, so rename of_free to of_create_node
and update all users accordingly.
Signed-off-by: Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Convert of_add_memory parsing to make use of of_address_to_resource
instead of parsing memory ranges itself. This makes some functions
dead code which are also removed.
Signed-off-by: Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
struct device_node has its own resources and a pointer to associated
device_d. With recent platform related OF code, we can convert the
only user of it and remove those pointers from struct device_node.
Signed-off-by: Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
With recent conversion to of_platfrom_populate_some functions are now
dead code and can be removed.
Signed-off-by: Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
With recent bus/device related functions in OF API, we can now
convert to use of_platform_populate.
Signed-off-by: Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
OF_ROOT_NODE_* defines should not be used outside of base.c. Move them
to drivers/of/base.c to ensure they will not be used elsewhere.
Signed-off-by: Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
This converts existing of_translate_address to recently added API. In
contrast to existing behavior, the new function honors ranges properties
properly. It now allows reg properties to be set as offset with respect
to the correspoding parent node.
Signed-off-by: Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
This patch makes OF API use of_delete_property where applicable instead
of freeing allocated data in different places.
Signed-off-by: Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
This adds some sanity checks to of_new_property and of_delete_property.
Also, value pointer is always allocated even with zero length to allow
empty properties to be distinguished from non-existing properties.
Finally, data passed to of_new_property is only copied if non-NULL.
Signed-off-by: Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
With of_get_child_by_name from Linux API, we can now convert and remove
of_find_child_by_name.
Signed-off-by: Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com>
This patch converts users of of_tree_for_each_node to recently added
for_eacg_compatible_node helper. Also of_tree_for_each_node is removed
from public OF API.
Signed-off-by: Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com>
This imports of_prop_next_u32, of_prop_next_string, and the corresponding
for_property_for_each_ helpers from Linux OF API.
Signed-off-by: Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com>