summaryrefslogtreecommitdiff
path: root/include/of.h
Commit message (Collapse)AuthorAgeFilesLines
* Merge branch 'for-next/overlapping-memory-banks'Sascha Hauer2021-06-161-3/+3
|\
| * of: warn about of_add_memory_bank errorsAhmad Fatoum2021-06-021-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | Now that errors from of_probe are propagated to the respective initcalls registering the device tree, propagate of_add_memory_bank errors as well. This ensures that clashes of device-tree added regions with previous ones don't go unnoticed. This can e.g. be the case if a device tree happens to have both /memory@X { }; and /memory { }; nodes. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20210531071239.30653-5-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * of: propagate errors inside barebox_register_{of, fdt} into initcallsAhmad Fatoum2021-06-021-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Errors during device tree registration, while uncommon, are really annoying, because the system may limp along and it's not clear where the misbehavior originates from. Failing the initcall of the device tree would improve user experience in that error case. There is intentionally no early exit on error cases to give barebox a chance to probe the serial driver to actually report errors when DEBUG_LL is disabled. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20210531071239.30653-4-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | of: base: constify some property pointersTrent Piepho2021-06-021-5/+5
| | | | | | | | | | | | | | | | | | Make the propery pointers in a few OF functions that read data const. They don't modify the property. Signed-off-by: Trent Piepho <tpiepho@gmail.com> Link: https://lore.barebox.org/20210529062541.1123023-1-tpiepho@gmail.com Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | commands: of_dump: implement -p for printing properties onlyAhmad Fatoum2021-05-311-0/+1
|/ | | | | | | | | | | | | | Some boards rewrite root node properties like compatible and serial-number. Checking them can be annoying, because the properties have usually long scrolled by, by the time the device tree was completely dumped. Add a -p option to print only properties. -p -n (print only node names AND only properties) is interpreted to cancel each other out, so the whole device tree is dumped normally. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20210527124406.22121-1-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/rpi'Sascha Hauer2020-12-111-0/+1
|\
| * ARM: rpi: Add Raspberry Pi Zero W mini-uart supportAhmad Fatoum2020-12-101-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | Unlike the Raspberry Pi 1 and Raspberry Pi Zero, the Raspberry Pi Zero W has its console pins on the header connected to the mini-uart, not the PL011. The secondary PL011 UART is connected to the bluetooth module. Set the mini-uart as default console and disable the PL011. That way we can use the Raspberry Pi 1 image for the Zero W as well. Signed-off-by: Ahmad Fatoum <ahmad@a3f.at> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | Merge branch 'for-next/mtd'Sascha Hauer2020-12-111-0/+17
|\ \
| * | of: partitions: export of_fixup_partitionsSascha Hauer2020-11-251-0/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | of_partitions_register_fixup() tries to automatically determine the node to fixup. Sometimes this doesn't work, so add of_fixup_partitions() that can called at fixup time with a device node determined by subsystem or driver code. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | of: Add no-op wrappers for of reproducible name functionsSascha Hauer2020-11-251-0/+11
| |/ | | | | | | Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | watchdog: implement watchdog_get_alias_id_fromAhmad Fatoum2020-11-301-0/+8
|/ | | | | | | | | | | | | | | On device-tree enabled platforms, the Linux kernel will first attempt to use watchdog%d as watchdog name, where %d is the alias id. Add a function that given a barebox struct watchdog and the device tree root node of the kernel device tree, computes the corresponding kernel alias id. This may then later be used to pass an appropriate argument on the kernel command line. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/sandbox' into masterSascha Hauer2020-10-141-0/+43
|\
| * of: implement of_property_read_u64_arrayAhmad Fatoum2020-10-131-0/+41
| | | | | | | | | | | | | | | | | | For reading reg with #address-cells and #size-cells of 2, an of_property_read_u64_array can be quite convenient. Add one. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * of: Add common device tree register functionSascha Hauer2020-10-121-0/+2
| | | | | | | | | | | | | | | | The different architectures duplicate some code around unflattening and registering the device tree. Add common functions to reduce this duplication. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | Merge branch 'for-next/reboot-mode' into masterSascha Hauer2020-10-141-0/+2
|\ \
| * | drivers: add reboot-mode infrastructureAhmad Fatoum2020-09-291-0/+2
| |/ | | | | | | | | | | | | | | | | | | | | Reboot modes provide a well-defined way to exchange information between different stage of the boot process. When configured, users can type `reboot bootloader` in the OS and barebox can read it out a device parameter. Likewise barebox can write a reboot mode for the BootROM to evaluate and then reset to fall into a serial recovery mode for example. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | of: implement of_property_write_strings for multiple stringsAhmad Fatoum2020-10-021-0/+2
|/ | | | | | | | | | | | | | | | | The current way to set a property with multiple values (e.g. compatible strings) is to have char properties[] = "st,stm32mp157c-dk2\0st,stm32mp157"; of_set_property(np, "compatible", properties, sizeof(properties), 1); Add a new helper to make this easier at the cost of one runtime reallocation: of_property_write_strings(np, "compatible, "st,stm32mp157c-dk2", "st,stm32mp157", NULL); Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Revert "of: Add of_property_for_each_phandle() iterator"Ahmad Fatoum2020-07-051-11/+0
| | | | | | | | | | | | | | | Codebase is meant to be gnu89, but this was only enforced starting with bc4840e98b94 ("kbuild: add -Wmissing-prototypes and -std=gnu89 to KBUILD_HOSTCFLAGS"). Since then, use of this macro would yield a compile error, because of the initialization inside the for-loop, which is a C99 feature. There hasn't been any users for the macro since it was added in 2016, thus drop it. This reverts commit d5f9415b04846661522141ea428f74e3c618fa9e. Cc: Trent Piepho <tpiepho@kymetacorp.com> Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* of: refactor of_read_number for clarityAhmad Fatoum2020-05-041-2/+2
| | | | | | | | | | | | | | | | While the code is correct, less sophisticated static analyzers (and users operating them..) trip over it, because they don't see that the be32_to_cpu argument is evaluated multiple times only if it's constant. Moving the side effect out: - Lets us avoid the false positive - Aligns us with what Linux does - Makes the code IMO a bit clearer Do so. Signed-off-by: Ahmad Fatoum <ahmad@a3f.at> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/pwm'Sascha Hauer2020-04-161-0/+8
|\
| * of: introduce of_property_count_elems_of_sizeAhmad Fatoum2020-03-311-0/+8
| | | | | | | | | | | | | | Import the Linux helper, so code using it may be more easily ported. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | of: port Linux of_get_compatible_child helperAhmad Fatoum2020-04-151-0/+8
|/ | | | | | | | Incoming Linux code port makes use of the helper. Add it now instead of having to open-code it later. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* include: add SPDX GPL-2.0-only license tags for files without licensing ↵Roland Hieber2020-02-171-0/+1
| | | | | | | | | | | information According to our /README, GPL-2.0-only applies for the whole project except noted otherwise. Signed-off-by: Roland Hieber <rohieb@rohieb.name> Reviewed-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* of: Add of_bus_n_xxx_cells()Sascha Hauer2019-12-201-0/+12
| | | | | | Added straight from the Kernel. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* of: Add of_property_read_string_array()Sascha Hauer2019-11-271-13/+70
| | | | | | | | | | of_property_read_string_array() is used to read a multistring device tree property into an array of strings. This is taken from the kernel. It is implemented around of_property_read_string_helper() which can be used to implement of_property_count_strings() and of_property_read_string_index() as well. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/of-overlay'Sascha Hauer2019-10-171-0/+47
|\
| * firmware: add support to load firmware from dt overlayMichael Tretter2019-09-161-0/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | fpga-region device tree nodes have the firmware-name property that contains the file name of firmware in the firmware search path (but not the path) that shall be loaded before the overlay is applied. Add the of_firmware_load_overlay() function that accepts an overlay and a firmware search path, finds the responsible firmware_mgr and loads the firmware. Signed-off-by: Michael Tretter <m.tretter@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * of: add iterator for overlaysMichael Tretter2019-09-161-0/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | Device tree overlays (the dto files) may contain multiple fragments for different target nodes. Each fragment contains a __overlay__ node that is applied to target node specified in the fragment. Add a helper to call a function for each fragment in a device tree overlay to avoid having device tree overlay internal information in other modules. Signed-off-by: Michael Tretter <m.tretter@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * of: add support for devicetree overlaysMichael Tretter2019-09-161-0/+27
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The devicetree overlay support is based on the Linux driver for device tree overlays, but many features that are not required in Barebox are left out. Unlike Linux, which applies the overlay to the live devicetree, Barebox registers a fixup for the overlay which is applied with other fixups to whatever tree is fixed. This is necessary to apply the overlay to devicetrees that are passed to Linux, which might differ from the devicetree that is currently live in Barebox. Signed-off-by: Michael Tretter <m.tretter@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | of: add of_diff()Sascha Hauer2019-09-121-0/+1
|/ | | | | | | of_diff compares two device trees against each other and prints a diff-like result. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* 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>