summaryrefslogtreecommitdiffstats
path: root/include/of.h
Commit message (Collapse)AuthorAgeFilesLines
* drivers: of: Add function to enable and register a device by aliasTeresa Remmet2019-02-131-0/+8
| | | | | | | | In some cases node names are not unique and passing the full path is really long. So make add a new device by passing the alias string possible. Signed-off-by: Teresa Remmet <t.remmet@phytec.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* mdio_bus: Allow for non PHY-devices on MDIO busesAndrey Smirnov2018-10-231-0/+6
| | | | | | | | | | | | | | Instead of just creating a simple PHY device for every child of MDIO bus node, add code to check if any of them have "compatible" property set, as well as code to create a proper platform device for such cases. This change is useful for when MDIO bus and some of Ethernet ports are connected to a switch or some other MDIO device that doesn't behave like a generic PHY and can't be probed via its PHY ID. Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* of: Make of_property_get_value() publicAndrey Smirnov2018-05-181-0/+6
| | | | | | | | Make of_property_get_value() public, so it can be used in other part of the system. Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/of'Sascha Hauer2018-02-081-0/+5
|\
| * of: fdt: add of_unflatten_dtb_constSascha Hauer2018-01-311-0/+1
| | | | | | | | | | | | | | | | This adds a variant of of_unflatten_dtb() which uses the property data directly from the input tree rather than copying it. This is mainly useful for a single user: FIT images. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * of: Allow for const propertiesSascha Hauer2018-01-311-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | This adds support for const properties. We add a const void *value_const to struct property which will not be modified. The value of a property should no longer be used directly, but with the of_property_get_value() accessor which picks the right value. With this we can unflatten dtbs and use the property values directly from the dtb instead of copying them. This is useful for device trees which (ab)use properties to store huge data files, aka FIT images. To create a property whose value is not copied but used from the original input data we introduce of_new_property_const(). Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | of: Add function to find the same node in another treeSascha Hauer2018-02-061-1/+4
|/ | | | | | | | | | | | For our device tree fixups we have to find a node corresponding to another node in another device tree. We used to use the full name to match the nodes, but this falls apart when nodes get renamed or for example a new bus hierarchy is introduced. To make this more robust we create reproducible names from device nodes which mostly depend on the address in MMIO space, the reg property and as a last resort the name of the device node. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* of: base: use root_node compatible as suggestion for a hostnameOleksij Rempel2018-01-171-0/+1
| | | | | | | | | | | | | | | | on some SoCs we can use generic PLL and RAM initialization. In this cases we create board file only to provide a host name. With this patch host name will be created from device tree compatible. For example: compatible = "board_vendor,board", "chip_vendor,soc" the host name will be: "board" This function will not overwrite a host name which is already set by board or machine code. Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* common: oftree: Add autoenable functionalityDaniel Schultz2017-11-071-0/+14
| | | | | | | | | | This patch adds an API to automatically enable either hardware components with existing device drivers or i2c clients. All functions take a device tree path to find the hardware and will fix up the node status in the kernel device tree, if it's accessible. Signed-off-by: Daniel Schultz <d.schultz@phytec.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* of: base: add function to copy a device tree nodeMichael Olbrich2017-10-171-0/+2
| | | | | | Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de> Signed-off-by: Lucas Stach <l.stach@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* of: base: port of_device_is_big_endian from linuxOleksij Rempel2017-09-081-0/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |commit 37786c7fee40771d13901de129af7e084ed48b55 |Author: Kevin Cernekee <cernekee@gmail.com> |Date: Thu Apr 9 13:05:14 2015 -0700 | | of: Add helper function to check MMIO register endianness | | SoC peripherals can come in several different flavors: | | - little-endian: registers always need to be accessed in LE mode (so the | kernel should perform a swap if the CPU is running BE) | | - big-endian: registers always need to be accessed in BE mode (so the | kernel should perform a swap if the CPU is running LE) | | - native-endian: the bus will automatically swap accesses, so the kernel | should never swap | | Introduce a function that checks an OF device node to see whether it | contains a "big-endian" or "native-endian" property. For the former case, | always return true. For the latter case, return true iff the kernel was | built for BE (implying that the BE MMIO accessors do not perform a swap). | Otherwise return false, assuming LE registers. | | LE registers are assumed by default because most existing drivers (libahci, | serial8250, usb) always use readl/writel in the absence of instructions | to the contrary, so that will be our fallback. Signed-off-by: Oleksij Rempel <linux@rempel-privat.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* of: of_path: add of_find_node_by_devpath()Sascha Hauer2017-03-311-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | We already have of_find_path_by_node() which finds a device path for a given device node. This is used by the state framework to find its backend path. This path has to be translated back to a device node when Linux is started. The current approach turned out to be too simple: We assumed that the node path is the same in the tree Linux is started with. This is not true in several cases: - partition nodes should have the name "partition@<offset>", but in several trees they have "partition@<num>" - There are two different partition bindings: The legacy binding and the new one with an additional partitions subnode which has a compatible = "fixed-partitions" property. The node path only stays the same when the internal tree uses the same bindings and node names as the tree Linux is started with. To overcome this limitation we create of_find_node_by_devpath() which converts the device path back to a device node. It does so by finding the device node of the hardware device rather than the partition node. It then parses over the partitions in this device node with the known bindings looking for a partition which matches in offset and size to the barebox partition. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* of: partition: Move of_mtd_fixup to drivers/of/Sascha Hauer2017-03-301-0/+6
| | | | | | | | Move the fixup code where the parser code is already. Since the code will not only be used for mtd in the future drivers/of/ is a better place than drivers/mtd/. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* of: Add of_property_write_string()Sascha Hauer2017-03-301-0/+8
| | | | | | | Setting a property to a string is used many times. Create a convenience function for it. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* of: provide for_each_matching_node_fromUwe Kleine-König2017-01-171-2/+4
| | | | | | | | This is for_each_matching_node for a given root similar to the other ..._from functions. Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* of: base: import of_get_cpu_node() from linux-v4.7-rc2Antony Pavlov2016-07-071-0/+10
| | | | | Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* 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>