summaryrefslogtreecommitdiffstats
path: root/include/of.h
Commit message (Collapse)AuthorAgeFilesLines
* common: oftree: Add function to register set status fixupTeresa Remmet2016-03-011-0/+1
| | | | | | | | Added a function to register a fixup to enable or disable device tree nodes. Signed-off-by: Teresa Remmet <t.remmet@phytec.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* of: Add of_property_for_each_phandle() iteratorTrent Piepho2016-01-081-0/+11
| | | | | | | | | | | This is like of_property_for_each_{string,u32} but loops over a list of phandles instead of strings or ints. Returns the node the handle points to as that's generally more useful than the handle value itself. Signed-off-by: Trent Piepho <tpiepho@kymetacorp.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* of: Add for_each_compatible_node_from iteratorTrent Piepho2016-01-081-2/+6
| | | | | | | | | | | | | | | | The existing iterator for_each_compatible_node() searches for each compatible node starting from the root of the loaded device tree. This means it only works on the barebox device tree and not the tree to be passed to the Linux kernel, which is what an of_fixup would probably want to use. This adds for_each_compatible_node_from(), which takes an additional parameter of a root to search from. This could be the device tree to be used for the kernel. It could also be used to search just a subtree. Signed-off-by: Trent Piepho <tpiepho@kymetacorp.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* of_path: add of_find_path_by_node()Marc Kleine-Budde2015-11-271-0/+1
| | | | | | | | | This patch adds the function of_find_path_by_node(), which is similar to of_find_path(), but it translates a device tree node into a barebox device path directly. Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* of: base: implement of_get_next_childSascha Hauer2015-07-131-0/+8
| | | | Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* of: export of_platform_device_createSascha Hauer2015-07-021-0/+2
| | | | Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* of: add a function to remove an of_fixupUwe Kleine-König2015-05-181-0/+1
| | | | | | | | | This function is needed when a device that already registered a fixup in the probe routine fails later to probe completely. Without unregistering the fixup the function might later be called with invalid data. Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/of-device-id'Sascha Hauer2015-05-061-1/+1
|\
| * of: use 'const void *' for struct of_device_id.dataAntony Pavlov2015-04-301-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Since 2011 barebox' of_device_id struct uses unsigned long type for data field: struct of_device_id { char *compatible; unsigned long data; }; Almost always struct of_device_id.data field are used as pointer and need 'unsigned long' casting. E.g. see 'git grep -A 4 of_device_id drivers/' output: drivers/ata/sata-imx.c:static __maybe_unused struct of_device_id imx_sata_dt_ids[] = { drivers/ata/sata-imx.c- { drivers/ata/sata-imx.c- .compatible = "fsl,imx6q-ahci", drivers/ata/sata-imx.c- .data = (unsigned long)&data_imx6, drivers/ata/sata-imx.c- }, { Here is of_device_id struct in linux kernel v4.0: struct of_device_id { char name[32]; char type[32]; char compatible[128]; const void *data; }; Changing of_device_id.data type to 'const void *data' will increase barebox' linux kernel compatibility and decrease number of 'unsigned long' casts. Part of the patch was done using the 'coccinelle' tool with the following semantic patch: @rule1@ identifier dev; identifier type; identifier func; @@ func(...) { <... - dev_get_drvdata(dev, (unsigned long *)&type) + dev_get_drvdata(dev, (const void **)&type) ...> } @rule2@ identifier dev; identifier type; identifier func; identifier data; @@ func(...) { <... - dev_get_drvdata(dev, (unsigned long *)&type->data) + dev_get_drvdata(dev, (const void **)&type->data) ...> } Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | of_path: of_find_path(): add possibility to return .bb deviceMarc Kleine-Budde2015-04-231-1/+2
| | | | | | | | | | | | | | | | | | This patch adds a flags argument to the of_find_path() function. The only flag defined for now is OF_FIND_PATH_FLAGS_BB. When used on NAND devices, the function returns the bad block aware device (the ".bb" device). Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | include: add includes includes to make fdt.h, of.h and state.h self containedMarc Kleine-Budde2015-04-171-0/+2
|/ | | | | | | | | | | | | Otherwise compilation may fail with: include/fdt.h:11:15: error: unknown type name 'uint64_t' static inline uint64_t fdt64_to_cpu(uint64_t x) include/of.h:22:19: error: field 'list' has incomplete type struct list_head list; Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/sandbox-of'Sascha Hauer2015-03-061-5/+23
|\
| * of: add no-op functions for of_find_node_by_alias() and ↵Marc Kleine-Budde2015-03-031-4/+16
| | | | | | | | | | | | | | of_find_node_by_path_or_alias() Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * of: add no-op function for of_register_fixup()Marc Kleine-Budde2015-03-031-1/+7
| | | | | | | | | | Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | of: Add for_each_child_of_node_safeSascha Hauer2015-02-121-0/+2
|/ | | | | | Needed for iterating over child nodes and deleting the children. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* fdt: of_unflatten_dtb can work on const dataJan Luebbe2014-12-041-1/+1
| | | | | Signed-off-by: Jan Luebbe <jlu@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* of: Add of_device_enable_and_register functionsTeresa Gámez2014-11-031-0/+14
| | | | | | | | | | | Function to enable and register a disabled device. The devices can be registered using the device node with of_device_enable_and_register() or with the device node name/path by using the of_device_enable_and_register_by_name() function. Signed-off-by: Teresa Gámez <t.gamez@phytec.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* of: Added of_set_property_to_child_phandleTeresa Gámez2014-10-011-0/+1
| | | | | | | | 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>
* of: base: Add of_parse_phandle_fromTeresa Gámez2014-10-011-0/+11
| | | | | | | 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>
* of: base: Add of_find_node_by_phandle_fromTeresa Gámez2014-10-011-0/+8
| | | | | | | | 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>
* of: base: Add for_each_node_by_name_fromTeresa Gámez2014-10-011-0/+3
| | | | | | | | Added for_each_node_by_name_from() to be able to pass external root node. Signed-off-by: Teresa Gámez <t.gamez@phytec.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* of: Drop devicetree merge supportSascha Hauer2014-05-221-1/+1
| | | | | | | | | | | | I assume I am the only person knowing that barebox is able to merge devicetrees. This feature seems broken for a while now since trying to merge devicetress results in: unflatten: too many end nodes Remove this feature to save the complexity. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/rpi'Sascha Hauer2013-11-071-1/+1
|\
| * of: Add a context pointer to fixup functionsSascha Hauer2013-11-061-1/+1
| | | | | | | | | | | | | | If drivers want to fixup their specific instance they need some context to know which instance they have to fixup. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | of: simplify phandle lookupSascha Hauer2013-10-221-1/+0
|/ | | | | | | | | 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>
* of: base: import of_find_node_by_typeRenaud Barbier2013-09-051-0/+2
| | | | | | | | | | | | 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>
* of: introduce some new helpersSascha Hauer2013-08-141-0/+14
| | | | | | | | | | | 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>
* Add configurability via devicetreeSascha Hauer2013-07-181-0/+2
| | | | | | | | | | | | | | | | | | This adds the possibility to configure the place for the environment from the devicetree and to partition devices from the devicetree. Configuration has the general form of devices with a regular compatible property. This allows to later add additional drivers or drivers with different behaviour (for example to add support for redundant environment). The configuration is all in the /chosen/barebox/ hierarchy of the devicetree. This separates the configuration from the hardware description. Also it makes it possible to store the configuration in a completely separate devicetree (or devicetree overlay). For the same reason all configuration is done using nodepathes rather than phandles. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* of: Add convenience functions to en/disable devicenodesSascha Hauer2013-07-181-0/+5
| | | | | | | These functions allow to manipulate the "status" property of devicenodes effectively enabling/disabling devices. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* of: partitions: factor out function to parse a single partitionSascha Hauer2013-07-151-0/+1
| | | | | | To make it usable for other code. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* of: export of_default_bus_match_tableSascha Hauer2013-07-151-0/+2
| | | | | | For code which wants to call of_platform_populate. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* OF: base: rename of_free to of_delete_nodeSebastian Hesselbarth2013-07-051-2/+2
| | | | | | | | | 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>
* OF: remove device and resource pointer from struct device_nodeSebastian Hesselbarth2013-07-051-3/+0
| | | | | | | | | 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>
* OF: gpio: convert DT based gpio handling to new OF APISebastian Hesselbarth2013-07-051-3/+0
| | | | | | | | | | | 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>
* OF: import bus/device related functions from Linux OF APISebastian Hesselbarth2013-07-051-0/+18
| | | | | | | | 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>
* OF: base: move OF_ROOT_NODE_ defines to local OF codeSebastian Hesselbarth2013-07-051-3/+0
| | | | | | | | 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>
* OF: convert of_translate_address to new APISebastian Hesselbarth2013-07-051-2/+0
| | | | | | | | | | 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>
* OF: base: cleanup base function includeSebastian Hesselbarth2013-06-201-29/+109
| | | | | | | This cleans up include/of.h by moving some function prototypes below CONFIG_OFTREE and provide bogus stubs for !CONFIG_OFTREE. Signed-off-by: Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com>
* OF: base: convert and remove device_node_for_nach_childSebastian Hesselbarth2013-06-201-3/+0
| | | | | | | | 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>
* OF: base: remove of_find_child_by_nameSebastian Hesselbarth2013-06-201-2/+0
| | | | | | | 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>
* OF: base: remove of_tree_for_each_node from public APISebastian Hesselbarth2013-06-201-8/+0
| | | | | | | | 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>
* OF: base: import property iterators from Linux OF APISebastian Hesselbarth2013-06-201-0/+43
| | | | | | | 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>
* OF: base: introduce property write for bool, u8, u16, and u64Sebastian Hesselbarth2013-06-201-11/+71
| | | | | | | 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>
* OF: base: import parse phandle functions from Linux OF APISebastian Hesselbarth2013-06-201-5/+25
| | | | | | | | 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>
* OF: base: import of_parse_phandle from Linux OF APISebastian Hesselbarth2013-06-201-0/+10
| | | | | | This imports of_parse_phandle from Linux OF API. Signed-off-by: Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com>
* OF: base: import of_property_read_* helpers from Linux OF APISebastian Hesselbarth2013-06-201-15/+117
| | | | | | | 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>
* OF: base: import parent/child functions from Linux OF APISebastian Hesselbarth2013-06-201-0/+41
| | | | | | | | | | 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>
* OF: base: import of_find_node_with_property from Linux OF APISebastian Hesselbarth2013-06-201-0/+11
| | | | | | | This imports of_find_node_with_property and corresponding helpers from Linux OF API. Signed-off-by: Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com>
* OF: base: import of_find_matching_node_and_match from Linux OF APISebastian Hesselbarth2013-06-201-0/+24
| | | | | | | This imports of_find_matching_node_and_match and corresponding helpers from Linux OF API. Signed-off-by: Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com>
* OF: base: import of_find_compatible_node from Linux OF APISebastian Hesselbarth2013-06-201-0/+13
| | | | | | | 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>