9
0
Fork 0
Commit Graph

152 Commits

Author SHA1 Message Date
Sebastian Hesselbarth b73f70bb1a OF: base: convert of_add_memory to OF API
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>
2013-07-05 08:26:57 +02:00
Sebastian Hesselbarth 3c84ded0f5 OF: remove device and resource pointer from struct device_node
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>
2013-07-05 08:26:57 +02:00
Sebastian Hesselbarth ffa50c1e60 OF: base: remove dead device related functions
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>
2013-07-05 08:26:57 +02:00
Sebastian Hesselbarth 4aa0506c95 OF: base: use of_platform_populate for probing
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>
2013-07-05 08:26:57 +02:00
Sebastian Hesselbarth 61bb8bfc7c OF: gpio: convert DT based gpio handling to new OF API
This creates a Linux OF API compatible counterpart of of_get_named_gpio_flags.
Existing of_get_named_gpio is converted to a static inline function, which is
in the corresponding of_gpio.h include. While at it, drivers/of/gpio.c is
also renamed to drivers/of/of_gpio.c to follow the of_ prefix naming scheme.
The new include is also added to existing users of of_get_named_gpio.

Signed-off-by: Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2013-07-05 08:26:57 +02:00
Sebastian Hesselbarth 483424e027 OF: import bus/device related functions from Linux OF API
This imports some bus and device related functions from Linux OF API
with some modifcations for Barebox.

Signed-off-by: Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2013-07-05 08:26:57 +02:00
Sebastian Hesselbarth 6fbaab1085 OF: base: move OF_ROOT_NODE_ defines to local OF code
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>
2013-07-05 08:26:57 +02:00
Sebastian Hesselbarth bfc5605e2f OF: convert of_translate_address to new API
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>
2013-07-05 08:26:57 +02:00
Sebastian Hesselbarth d0a6aaea6a OF: import address related functions from Linux OF API
This imports drivers/of/address.c from Linux with some minor modifications.
of_translate_address is not yet enabled and PCI and ISA related bus translations
have not been imported. Also, a corresponding include header is created with
prototypes and non-OF function stubs.

Signed-off-by: Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2013-07-05 08:26:57 +02:00
Sascha Hauer 8afe2cb4d4 Merge branch 'for-next-manual/oftree-linux-sync' 2013-07-02 07:08:46 +02:00
Sascha Hauer 22159db6b0 ARM: build dtbs depending on CONFIG_OFTREE
The upcoming multi image support will need devicetree binary
blobs even when there is no builtin dtb. Instead of depending
on CONFIG_BUILTIN_DTB depend on CONFIG_OFTREE and let this option
select DTC.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2013-06-26 23:42:47 +02:00
Sebastian Hesselbarth fff76d57d2 OF: base: use of_delete_property where applicable
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>
2013-06-24 19:15:11 +02:00
Sebastian Hesselbarth d4d586cbac OF: base: add sanity checks to of_new/delete_property
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>
2013-06-24 19:15:11 +02:00
Sebastian Hesselbarth 2e2265bfd4 OF: base: convert and remove device_node_for_nach_child
Remove device_node_for_nach_child and convert users to corresponding
imported OF API functions.

Signed-off-by: Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2013-06-20 21:22:19 +02:00
Sebastian Hesselbarth 097133af15 OF: base: remove of_find_child_by_name
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>
2013-06-20 21:22:15 +02:00
Sebastian Hesselbarth e520a8cc46 OF: base: remove of_tree_for_each_node from public API
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>
2013-06-20 21:20:55 +02:00
Sebastian Hesselbarth 2fe4a860eb OF: base: import property iterators from Linux OF API
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>
2013-06-20 21:20:55 +02:00
Sebastian Hesselbarth a0b6c0d00a OF: base: introduce property write for bool, u8, u16, and u64
This adds functions to set an array of or a single value for bool,
u8, u16, and u64 properties.

Signed-off-by: Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com>
2013-06-20 21:20:54 +02:00
Sebastian Hesselbarth 511ba46157 OF: base: import parse phandle functions from Linux OF API
This imports of_parse_phandle_with_args and of_count_phandle_with_args
from Linux OF API. The slightly different of_parse_phandles_with_args
is removed and all users are converted to reflect the API change.

Signed-off-by: Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com>
2013-06-20 21:20:54 +02:00
Sebastian Hesselbarth 083995f815 OF: base: import of_parse_phandle from Linux OF API
This imports of_parse_phandle from Linux OF API.

Signed-off-by: Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com>
2013-06-20 21:20:54 +02:00
Sebastian Hesselbarth 1d68e58532 OF: base: import of_property_read_* helpers from Linux OF API
This imports of_property_read_* helpers from Linux OF API to allow
to read all kinds of properties.

Signed-off-by: Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com>
2013-06-20 21:20:54 +02:00
Sebastian Hesselbarth 234be066c1 OF: base: import parent/child functions from Linux OF API
This imports of_get_parent, of_get_next_available_child, and
of_get_child_by_name and corresponding helpers from Linux OF API.
of_get_next_child is not imported but implemented as list iterator
instead. Also, of_get_child_count and of_get_available_child_count
are introduced.

Signed-off-by: Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com>
2013-06-20 21:20:54 +02:00
Sebastian Hesselbarth b45e2c0b47 OF: base: import of_find_node_with_property from Linux OF API
This imports of_find_node_with_property and corresponding helpers
from Linux OF API.

Signed-off-by: Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com>
2013-06-20 21:20:54 +02:00
Sebastian Hesselbarth 8b362a690b OF: base: import of_find_matching_node_and_match from Linux OF API
This imports of_find_matching_node_and_match and corresponding helpers
from Linux OF API.

Signed-off-by: Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com>
2013-06-20 21:20:54 +02:00
Sebastian Hesselbarth 464c393507 OF: base: import of_find_compatible_node from Linux OF API
This imports of_find_compatible_node and corresponding for_each_compatible_node
helper from Linux OF API.

Signed-off-by: Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com>
2013-06-20 21:20:54 +02:00
Sebastian Hesselbarth f8a1e2a5fd OF: base: import of_find_node_by_name from Linux OF API
This imports of_find_node_by_name and corresponding for_each_node_by_name
helper from Linux OF API.

Signed-off-by: Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com>
2013-06-20 21:20:54 +02:00
Sebastian Hesselbarth 80fc31dac3 OF: base: rename of_node_disabled to of_device_is_available
According to ePAPR 1.1 spec, device tree nodes status can be either
"okay", "disabled", "fail", or "fail-sss". Barebox already has a function
to check for "disabled" nodes, while Linux checks for "okay" or "ok".
To synchronize Barebox and Linux OF APIs, rename of_node_disabled to
of_device_is_available and check for "okay" instead of "disabled" as it
also makes "fail"ed devices unavailable.

Signed-off-by: Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com>
2013-06-20 21:20:54 +02:00
Sebastian Hesselbarth 0b79c3bb64 OF: base: sync of_find_node_by_path with linux OF API
Barebox of_find_node_by_path requires a node to be passed as start node
to start searching. Linux OF API does not pass this node and no current
user of it in barebox is passing anything else than the root node.
Therefore, we rename current function to of_find_node_by_path_from and
introduce a Linux OF API compatible of_find_node_by_path that always
passes the current root_node. Also, all current users of that function
are updated to reflect the API change.

Signed-off-by: Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2013-06-20 21:20:50 +02:00
Sebastian Hesselbarth 905f3ee7fb OF: base: sync of_find_property with linux OF API
To start synchronizing OF API of barebox with linux OF API, this adds
a length pointer to of_find_property. Also all current users of that
function are updated to reflect the API change.

Signed-off-by: Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com>
2013-06-20 17:18:01 +02:00
Sebastian Hesselbarth 03e0e78bf6 OF: base: convert strcmp to default string compare functions
Barebox compares compatible, node names, and property names with strcmp.
Linux by default compares compatible and node names with strcasecmp. To
avoid inconsitencies between Barebox and Linux dts files, we convert to
these default string compare functions.

Signed-off-by: Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com>
2013-06-20 17:17:54 +02:00
Sebastian Hesselbarth e7c057974e OF: base: export of_alias_scan
To prepare clean-up of OF API, we need to export of_alias_scan.

Signed-off-by: Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com>
2013-06-20 17:17:50 +02:00
Sebastian Hesselbarth 6818f0f382 OF: base: also update property length on of_property_write_u32
Current implementation of of_property_write_u32 does free old property
values and allocates new values depending on the size passed. While
copying the new values to the property, corresponding length is not
set. This makes of_property_write_u32 set the length of the new property
values and also adds a API header describing the function.

Signed-off-by: Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com>
2013-06-20 17:17:43 +02:00
Sebastian Hesselbarth ee63abaa06 OF: base: bail out early on missing matches for of_match_node
of_match_node checks for compatiblity between a set of matches and a
node. Neither the matches nor node pointer are checked for validity.
This adds the required checks to of_match_node.

Signed-off-by: Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com>
2013-06-20 17:17:37 +02:00
Sascha Hauer 1f23a43924 Merge branch 'for-next/of-i2c' 2013-06-02 16:28:34 +02:00
Sascha Hauer 5f56c35060 Merge branch 'for-next/of' 2013-06-02 16:28:34 +02:00
Sascha Hauer 08f2dda59f Merge branch 'for-next/mips'
Conflicts:
	include/of.h
2013-06-02 16:28:31 +02:00
Sascha Hauer 8f9044927d Merge branch 'for-next/mci'
Conflicts:
	include/driver.h
2013-06-02 16:28:21 +02:00
Sascha Hauer 75ea5f1c0f of: Add of_modalias_node function
Directly from the Kernel.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2013-05-31 15:53:11 +02:00
Sascha Hauer 08d78d50ae of: Also print disabled nodes
It's confusing to set the status of a node to disabled and afterwards
it's invisible. Similarly it's confusing to be able to enable invisible
nodes.

Also print disabled nodes.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2013-05-31 08:32:22 +02:00
Sascha Hauer afe3065206 of: do not scan aliases when no root node present
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2013-05-30 20:07:15 +02:00
Sascha Hauer 1f0a3175ec of: Add of_alias_get function
This is used to retrieve the name of the alias for a given
devicenode.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2013-05-30 12:18:28 +02:00
Sascha Hauer d5699b5556 Merge branch 'for-next/of' into for-next/imx-oftree 2013-05-23 09:19:09 +02:00
Sascha Hauer 2683e56174 fdt: Fix dt memreserve entry
The fdt reserve map needs address/size values, not address/end values
like accidently done for generating the reserve entry for the dt.

Reported-by: Jürgen Beisert <j.beisert@pengutronix.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2013-05-21 21:39:31 +02:00
Sascha Hauer d817fb6b86 of: populate devices based on "simple-bus" property
We used to populate the devices from the devicetree based on the
presence of the 'reg' property. This is incorrect since this only
allows us to probe devices with resources.
Instead use the 'simple-bus' property to see if we have iterate
deeper. This also registers devices with their buses as parents.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2013-05-20 15:53:06 +02:00
Sascha Hauer 0cb87c4d1e of: Add of_match_node function
To match a of_device_id arrays against a device_node. Same functionality
as in the kernel.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2013-05-20 15:53:06 +02:00
Sascha Hauer 580a508945 of: Call of_add_memory from of_probe
memory is always in /mem, so call of_add_memory from of_probe once
instead of in the recursive tree iteration. This makes it possible
to limit the device population to nodes with the "simple-bus" property
set.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2013-05-20 15:53:06 +02:00
Sascha Hauer 0761bf2d22 of: When checking for existing devices also check resource end
When registering devices from the devicetree we check if these
devices already exist. When doing this not only check the resource
start but also the resource end.
This helps with the probing of simple buses for which child nodes
often begin at the very same address as the parents.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2013-05-20 15:53:06 +02:00
Antony Pavlov 74c4acea0d of: separate out "generic" memory bank adding
This patch separates out the "generic" memory
segment registration function (of_add_memory_bank())
from of_add_memory().
The MIPS architecture has different view on memory
resources than the ARM and PPC architectures
so the "generic" of_add_memory_bank() is
unusable for the MIPS architecture.
We can add MIPS-specific of_add_memory_bank()
into arch/mips code.

Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2013-05-13 21:17:10 +02:00
Sascha Hauer 579b794b5d Merge branch 'for-next/of'
Conflicts:
	arch/arm/mach-imx/Makefile
2013-05-06 09:30:37 +02:00
Antony Pavlov 9b22b92393 of: fix typos
Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2013-04-26 07:28:02 +02:00
Uwe Kleine-König 97c636365e of: fix how an initrd is passed to Linux
Linux expects linux,initrd-end to contain the first unused address. As
this doesn't match the end semantic used by barebox (i.e. end contains
the last used address) adding one is necessary.

Without this change Linux fails for me to correctly extract a gzipped
cpio archive provided as initrd.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2013-04-26 07:27:08 +02:00
Sascha Hauer cd23160af8 of: partitions: create bb device for nand flashes
For nand flashes automatically create a bb device for each partion.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2013-04-22 09:25:37 +02:00
Sascha Hauer 66cd90abe7 of: partitions: pass struct cdev as argument
pass a struct cdev instead of the cdev name to of_parse_partitions.
This is available to the caller anyway and makes it easier to use
additional stuff from the cdev (like knowing whether it's a mtd
device).

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2013-04-22 09:25:33 +02:00
Sascha Hauer 812dc942d5 of: read resource names from devicetree
Resources can have names and these can also be specified in the
devicetree. Add support for it.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2013-04-22 09:23:58 +02:00
Sascha Hauer 6d1788ab34 of: Allow multiple resources in 'reg' property
Some devices need multiple resources in the reg property. This patch
adds support for it.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2013-04-22 09:23:50 +02:00
Sascha Hauer 266dea34a5 of: Add of_property_read_string_index()
Directly imported from the Kernel

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2013-04-22 09:23:35 +02:00
Sascha Hauer 8e9d9bc7e6 of: parse phandles before probing devices
The phandles have to be parsed completely before registering the devices
from the devicetree. Otherwise drivers can't rely on of_find_node_by_phandle
in their probe.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2013-04-22 09:23:23 +02:00
Sascha Hauer f72a4fd370 of/net: Add net related of helpers
of_get_phy_mode to parse the phy mode from the devicetree and
of_get_mac_address to parse a MAC address from the devicetree.
Directly taken from the Kernel.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2013-04-04 23:23:41 +02:00
Sascha Hauer e748e6c601 scripts: Add dtc
This adds the devicetree compiler to barebox. This is taken
without changes from Linux v3.8

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2013-03-12 18:43:25 +01:00
Sascha Hauer 14c290dabe of: make locally used functions static
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2013-03-06 11:41:29 +01:00
Sascha Hauer a51d06d679 of: remove unused libfdt
Now that we are completely independent of libfdt remove the unused
code.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2013-03-06 11:41:29 +01:00
Sascha Hauer 0ba9a2347a of: Add reservemap handling
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2013-03-06 11:41:29 +01:00
Sascha Hauer 1ad17a65c3 of: make value of property in of_new_property optional
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2013-03-06 11:41:28 +01:00
Sascha Hauer c2189e9f7e of: Add of property write functions for u32
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2013-03-06 11:41:28 +01:00
Sascha Hauer 3e797d7081 of: move flat devicetree functions to separate file
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2013-03-06 11:41:28 +01:00
Sascha Hauer b6a2800537 of: make OFDEVICE a user selectable option
OFDEVICE decides whether or not we compile in support for probing
devices from the devicetree. Let the user decide this explicitly.
This makes the oftree, of_node and of_property commands independent
of devicetree device support since being able to manipulate
devicetrees has nothing to do with probing devices from the devicetree.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2013-03-06 11:41:28 +01:00
Sascha Hauer e627bc2bc1 of: move OFTREE Kconfig option to drivers/of/
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2013-03-06 11:41:28 +01:00
Sascha Hauer 004cce1347 of: make flatten independent of libfdt
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2013-03-06 11:41:28 +01:00
Sascha Hauer 1d9859d5e7 of: make unflatten independent of libfdt
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2013-03-06 11:41:28 +01:00
Sascha Hauer 3b181a8109 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>
2013-03-06 11:41:28 +01:00
Sascha Hauer b26b7ef0f0 of: Add root node argument to of_find_node_by_path
This makes of_find_node_by_path usable with multiple trees.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2013-03-06 11:41:28 +01:00
Sascha Hauer 8a185a4ff2 of: let of_unflatten_dtb return the unflattened tree
In order to be able to handle multiple devicetrees, do not assume
the tree to be unflattened is the barebox internal one. Instead,
just return a pointer to it and assign the barebox internal root_node
external to the unflatten function.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2013-03-06 11:41:27 +01:00
Sascha Hauer 6be4759579 of: Add of_set_property and of_create_node
Add functions to create a new device node and to create/set
a new property based on the nodepath.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2013-03-06 11:41:27 +01:00
Sascha Hauer b50c00a61d of: remove allnodes list
The allnodes list makes it hard to handle multiple devicetrees. Having
a list to iterate over all nodes of a tree is still good to have though.
This patch uses the list_head of the root node as the head of the list.
This way the root node is no longer part of the list, but when iterating
over a tree the root node is not interesting anyway.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2013-03-06 11:41:27 +01:00
Sascha Hauer a7b46162b4 of: Let of_find_node_by_path iterate over tree
of_find_node_by_path iterates over the allnodes list. Depending on
where the node we look for is, this can be significantly slower than
using the tree structure to look for a node, so iterate over the tree
instead.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2013-03-06 11:41:27 +01:00
Sascha Hauer 38a717b393 of: removed unused variables
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2013-03-06 11:41:27 +01:00
Sascha Hauer a75b5c5d8e of: export of_find_child
of_find_child is a useful function. Export it and rename it to
of_find_child_by_name.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2013-03-06 11:41:27 +01:00
Sascha Hauer 69c54bc939 of: unflatten: allocate root node explicitly
By doing so of_new_node does not depend on the global root_node
anymore.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2013-03-06 11:41:27 +01:00
Sascha Hauer 831d83e922 Merge branch 'for-next/highbank' 2013-03-04 09:21:37 +01:00
Jean-Christophe PLAGNIOL-VILLARD 210bb761d8 of_add_memory: check the device_type is memory
Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2013-02-14 09:27:35 +01:00
Jean-Christophe PLAGNIOL-VILLARD 9acb6113f0 of: make of_add_memory available for other board
so when the first stage booloader of firmware provide the dtb
we can use it to probe the memory

also allow to print what we probe

Cc: Rob Herring <rob.herring@calxeda.com>
Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2013-02-14 09:27:26 +01:00
Jean-Christophe PLAGNIOL-VILLARD 8428a8c6e3 amba: add oftree probe support
move ARM_AMBA Kconfig to drivers/amba/Kconfig

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2013-02-12 20:31:44 +01:00
Sascha Hauer 555dc6cc60 of: speed up unflatten
We calculate the full path of the current node using fdt_get_path which
takes a lot of time since libfdt has to iterate over the dtb several times.
Speed this up by creating and using a of_find_child function which does
not have to iterate over the whole tree but only over its direct children.
On an i.MX51 board this speeds up unflatten the tree from 60ms to 3.7ms.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2013-01-19 11:48:17 +01:00
Sascha Hauer a2288e64b7 of: rename new_device_node to of_new_node and export it
of_new_node now takes the parent node and the name as argument and
creates a new node. This simplifies the caller and also makes the
function useful for others, so export it.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2013-01-19 11:48:17 +01:00
Sascha Hauer 517fcac5f0 of: add of_delete_property
This adds a function to delete a property from the currently loaded
devicetree. Also export new_property as of_new_property.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2013-01-19 11:48:17 +01:00
Sascha Hauer 9e824f30c2 of: unflatten: allow overlay dtbs
This implements overlaying a currently loaded dtb with another dtb.
We used to return -EBUSY when a oftree is currently loaded. Instead
of doing this, check if a node already exists before creating a new
one. Similarly, if a property already exists, just overwrite the
value instead of creating a new property.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2013-01-19 11:48:17 +01:00
Sascha Hauer 875430927d of: Add support for converting the unflattened tree back to a dtb
We already have support for unflattening the devicetree. This patch
adds support for converting it back to a dtb.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2013-01-19 11:48:17 +01:00
Sascha Hauer 86e787e845 of: rename of_parse_dtb to of_unflatten_dtb
The process of unflatten the device tree is known from the kernel,
so rename the function, because that's what it does.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2013-01-11 14:10:02 +01:00
Sascha Hauer 05ed875f35 of: return root node when looking for a node with path /
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2013-01-11 14:10:02 +01:00
Sascha Hauer 969120f125 of of_free: remove old node from allnodes list
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2013-01-11 14:10:02 +01:00
Sascha Hauer 818dccf28b of: of_free fixes
- Add missing prototype for of_free()
- When root node is freed set root_node to NULL
- (re)scan aliases after freeing a node. This is necessary because
  the freed node may be an alias or point to an alias

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2013-01-11 14:10:01 +01:00
Sascha Hauer 99bb8de76f of: Fix invalid path for of_find_node_by_path
When of_find_node_by_path is called with a non existing path we
return just some node. return NULL instead.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2013-01-11 14:10:01 +01:00
Sascha Hauer 05d251f15f Merge branch 'for-next/of'
Conflicts:
	drivers/of/base.c
	include/of.h
2012-11-16 14:02:44 +01:00
Sascha Hauer cce8e6ed41 Merge branch 'for-next/console' 2012-11-16 14:00:45 +01:00
Sascha Hauer e2fce6b92c of: Check for NULL pointer in of_find_property
The console layer calls of_device_is_stdout_path for a new console. When
we are booting without devicetree then of_chosen is NULL which makes barebox
crash. Check for a NULL pointer in of_find_property to prevent this.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2012-10-30 14:42:54 +01:00
Sascha Hauer 5b0fc19196 of gpio: Build gpio helper only when gpiolib is selected
Otherwise the functions needed by the helper won't be available.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2012-10-26 08:57:01 +02:00
Sascha Hauer 3510a4b0f5 console/of: evaluate linux,stdout-path property
When a linux,stdout-path property is given in the devicetree
activate the corresponding console.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2012-10-09 20:58:27 +02:00
Sascha Hauer efed496001 of: Add function to get the model name
This is useful for printing it during startup.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2012-10-09 20:57:10 +02:00
Sascha Hauer f59f5e8625 of: find and register memory during probe
This automatically registers the memory nodes in the devicetree.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2012-10-08 00:34:58 +02:00
Jean-Christophe PLAGNIOL-VILLARD 3c5327e660 switch all platform_bus device/driver registering to platform_driver/device_register
now register_driver and register_device are for bus only usage.

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
2012-10-04 15:19:12 +02:00