summaryrefslogtreecommitdiffstats
path: root/drivers/of
Commit message (Collapse)AuthorAgeFilesLines
* of: of_path: fix return in case of EPROBE_DEFERMarco Felsch2019-11-041-1/+1
| | | | | | | | | As said in commit 82eb3dff10 ("of_path: handle no driver for device") this case happens if the driver isn't probed yet. So we should return -EPROBE_DEFER to signal that. Signed-off-by: Marco Felsch <m.felsch@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* OF: gpio: don't warn if ignored GPIO flag matches the behaviorLucas Stach2019-11-041-2/+4
| | | | | | | | | | | | | | | Port of the upstream accepted change to the Linux kernel. Some devicetrees specify the ACTIVE_LOW flag in the fixed regulator GPIO handle. While this has always been ignored, it's consistent with the behavior of the regulator binding in the absence of the "enable-active-high" DT property. It doesn't make much sense to print a user visible warning for a configuration which is consistent, so only print the warning if the GPIO flag contradicts the behavior dictated by by the enable-active-high property. Signed-off-by: Lucas Stach <l.stach@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/remoteproc'Sascha Hauer2019-10-171-1/+2
|\
| * of: base: don't try to read cells_name property if no cells_name setOleksij Rempel2019-09-261-1/+2
| | | | | | | | | | | | | | | | | | Some device tree node parsed by of_count_phandle_with_args() have no #*-cells parameter. To make linux device trees work with barebox, we should accept cells_name set to NULL, so sync this behavior with linux. Signed-off-by: Oleksij Rempel <linux@rempel-privat.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | Merge branch 'for-next/of-overlay'Sascha Hauer2019-10-175-0/+638
|\ \
| * | dtc: optionally add add __symbols__ to build-in devicetreeMichael Tretter2019-09-161-0/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The devicetree overlay driver requires the __symbols__ node to resolve phandles to the base devicetree. If Barebox has to apply the overlay to the live devicetree, the build-in devicetree must be built with the __symbols__ node. It is configurable, because adding __symbols__ significantly increases the size of the devicetree binary. When configuring Barebox, a developer should be able to enable or disable devicetree overlay support and as this only affects the build-in devicetree, which is linked to the image anyway, use a Kconfig item for configuring the __symbols__. Signed-off-by: Michael Tretter <m.tretter@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | firmware: add support to load firmware from dt overlayMichael Tretter2019-09-162-1/+87
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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/+38
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-164-0/+498
| |/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-10/+131
| | | | | | | | | | | | | | of_diff compares two device trees against each other and prints a diff-like result. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | of: Fix memory hole in of_find_node_by_reproducible_name()Sascha Hauer2019-09-121-2/+10
|/ | | | | | | of_get_reproducible_name() returns an allocated string, so we must free it. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* OF: gpio: Add special quirk to parse regulator flagsOleksij Rempel2019-07-171-1/+34
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | To make fec work with devicetree on imx28-evk, partially port following kernel patch: |commit a603a2b8d86ee93ee2107da8ca75fd854fd4ff32 |Author: Linus Walleij <linus.walleij@linaro.org> |Date: Sat Dec 30 16:26:36 2017 +0100 | | gpio: of: Add special quirk to parse regulator flags | | While most GPIOs are indicated to be active low or open drain using | their twocell flags, we have legacy regulator bindings to take into | account. | | Add a quirk respecting the special boolean active-high and open | drain flags when parsing regulator nodes for GPIOs. | | This makes it possible to get rid of duplicated inversion semantics | handling in the regulator core and any regulator drivers parsing | and handling this separately. | | Unfortunately the old regulator inversion semantics are specified | such that the presence or absence of "enable-active-high" solely | controls the semantics, so we cannot deprecate this in favor | of the phandle-provided inversion flag, instead any such phandle | inversion flag provided in the second cell of a GPIO handle must be | actively ignored, so we print a warning to contain the situation | and make things easy for the users. | | Signed-off-by: Linus Walleij <linus.walleij@linaro.org> Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* of: partition: use NULL instead of never-read argumentAhmad Fatoum2019-05-241-3/+3
| | | | | | | | len isn't read afterward and of_get_property accepts NULL as third argument, so do it. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/zynqmp'Sascha Hauer2019-04-091-1/+5
|\
| * of: populate "/firmware" while populating device treeThomas Haemmerle2019-03-181-1/+5
| | | | | | | | | | | | | | | | | | | | | | The sub-nodes of "/firmware" are not populated, since it has no "compatible" property. Copy the behavior of Linux and call of_platform_populate() on the "/firmware" node to probe firmware drivers. Signed-off-by: Thomas Haemmerle <thomas.haemmerle@wolfvision.net> Signed-off-by: Michael Tretter <m.tretter@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | of: Fix reproducible names for #address-cells != 1Sascha Hauer2019-03-181-2/+2
|/ | | | | | | | | | | | | | For the new "fixed-partitions" binding we ignore the partitions subnode for creating reproducible names and set node to its parent. To get the number of address cells we must call of_n_addr_cells() before setting node to its parent though, not afterwards. With the current behaviour we always get OF_ROOT_NODE_ADDR_CELLS_DEFAULT (=1). This happens to work then the partitioned device is less than 4GiB in size. On bigger devices #address-cells = <2> is chosen by the mtd partition fixup code. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de> Reported-by: Bastian Krause <bst@pengutronix.de>
* Merge branch 'for-next/misc'Sascha Hauer2019-02-131-1/+11
|\
| * net: Phy: Update phy interface modes from LinuxSascha Hauer2019-02-061-1/+11
| | | | | | | | | | | | | | | | | | This syncs the phy interface modes with Linux and adds names that were previously missing. With this we no longer have holes in the phy mode name arrays and thus of_get_phy_mode no longer derefences NULL pointers when it finds such a hole. 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/+19
|/ | | | | | | | 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>
* Add initial RISC-V architecture supportAntony Pavlov2019-01-071-1/+1
| | | | | Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* of: Add .of suffix to device names from devicetreeSascha Hauer2018-12-071-2/+2
| | | | | | | | | | | | | | | | | | | | | | Previous implementation used to add a number to the device names for devices registered from the device tree which did not have a 'reg' property, thus a device node named "state" resulted in a device name "state.<x>". Current implementation skips that number and we get a device named "state". This conflicts with our barebox state implementation which tries to register a device named "state" itself. We could rename the state device nodes of all our device trees, but it causes less trouble to rename the devices. This adds a ".of" suffix to the device names for devices registered from the device tree which also has the nice effect that they now can easily be recognized. Fixes: 7e497d48acbd11 ("of: Port latest of_device_make_bus_id() implementation") Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de> Cc: Andrey Smirnov <andrew.smirnov@gmail.com> Cc: Jan Lübbe <jlu@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* of: partition: set ret for error casesOleksij Rempel2018-11-191-2/+2
| | | | | | | looks like it was forgotten. Signed-off-by: Oleksij Rempel <linux@rempel-privat.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/state'Sascha Hauer2018-11-091-0/+12
|\
| * of: fix reproducible node name for legacy vs. new partition bindingSascha Hauer2018-10-181-0/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | the of_reproducible_name mechanism is used to find a partition node from the barebox devicetree in the Linux devicetree. Unfortunately we have two different partition bindings. In the legacy one the partition nodes are directly under the hardware devicenode whereas in the new binding the partitions are under an additional partitions subnode. This means we get two different (not so) reproducible names when the barebox devicetree uses the legacy binding and the Linux devicetree uses the new binding (or the other way round). To get the same name then for these cases we drop the partitions subnode from the reproducible name. This makes the partition fixup in barebox-state work when the barebox devicetree uses another binding than the Linux devicetree. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de> Tested-by: Ulrich Ölmann <u.oelmann@pengutronix.de> Tested-by: Gavin Schenk <g.schenk@eckelmann.de
* | Merge branch 'for-next/net-switch-mv88e6xxx'Sascha Hauer2018-11-092-60/+24
|\ \
| * | of: Port latest of_device_make_bus_id() implementationAndrey Smirnov2018-10-181-58/+22
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Code implementing of_device_make_bus_id() in Barebox uses rather old implementation from Linux kernel and has a very significan limitation in that it will produce identical names for different DT nodes that happen to have the same node name as well as "reg" property. One such example, that tirggered this change, is "switch@0" nodes that can be found in dts/src/arm/vf610-zii-dev-rev-c.dts This commit replaces original code with the current Linux kernel implementation that traverses DT hierarchy from leaf node to its root concatenating node names in the process. Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | drivers: Introduce dev_set_name()Andrey Smirnov2018-10-181-6/+6
| | | | | | | | | | | | | | | | | | | | | | | | Introduce dev_set_name() in order to hide implementation details of setting device's name so it'd be easier to change it. Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | of: Demote "Bad cell count for" to debugAndrey Smirnov2018-10-181-2/+2
| |/ | | | | | | | | | | | | | | | | There are valid use-cases where getting OF_BAD_ADDR via that codepath is expected. In addition to that analogous code in Linux kernel uses pr_debug as well. Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | Merge branch 'for-next/misc'Sascha Hauer2018-11-091-1/+1
|\ \
| * | of: base: fix typoUlrich Ölmann2018-10-191-1/+1
| |/ | | | | | | | | Signed-off-by: Ulrich Ölmann <u.oelmann@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* / of: unflatten: access property properlySascha Hauer2018-10-301-1/+1
|/ | | | | | | | Properties have to be accessed with of_property_get_value() rather than accessing them directly from the devicenode. The accessor does the right thing when of_new_property_const() is used. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* drivers: of: Make use of devpath_to_name()Andrey Smirnov2018-06-251-4/+2
| | | | | 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-5/+0
| | | | | | | | 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/misc'Sascha Hauer2018-04-061-1/+1
|\
| * of: demote "no ranges" message to debug levelLucas Stach2018-03-191-1/+1
| | | | | | | | | | | | | | | | | | | | There are valid cases where there is no way to translate a OF node to a MMIO address via ranges, so do the same as the Linux kernel and don't print an error message in that case, but make it available as a debug message. Signed-off-by: Lucas Stach <l.stach@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | of: partition: fix typo when writing #address-cellsPhilipp Zabel2018-03-291-1/+1
|/ | | | | | | | | | | | On > 4 GiB eMMC devices, barebox writes a 32-bit address and a 64-bit size into the partition reg property, because #address-cells is accidentally written as '#addres-cells'. This causes a fallback to 32-bit address size. Fix the typo and thereby of_partition_fixup for 64-bit partitions. Fixes: a2fa18f9f483 ("mtd: of: Make used partition binding configurable") Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* of: Make locally used function staticSascha Hauer2018-03-051-1/+1
| | | | | | | __of_unflatten_dtb is only locally used and has no prototype in include/. Make it static. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* of: Make locally used function staticSascha Hauer2018-03-051-1/+1
| | | | | | | of_property_get_value is only locally used and has no prototype in include/. Make it static. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/of'Sascha Hauer2018-02-082-23/+120
|\
| * of: fdt: add of_unflatten_dtb_constSascha Hauer2018-01-311-2/+34
| | | | | | | | | | | | | | | | 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-21/+86
| | | | | | | | | | | | | | | | | | | | | | | | | | | | 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: mtd: partition: Use reproducible node names for fixupSascha Hauer2018-02-061-1/+4
| | | | | | | | | | | | | | | | | | | | The full names of device nodes are not as stable as we like them to be. Lately the leading zeroes in the i.MX6 device trees were removed which led to the result that we can no longer find the partition nodes in the to be fixed tree. Use reproducible names to overcome this. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | of: Add function to find the same node in another treeSascha Hauer2018-02-061-0/+63
|/ | | | | | | | | | | | 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: fix segfault in of_get_machine_compatible()Aleksander Morgado2018-01-301-0/+2
| | | | | | | | | | | | | | | | | | | | This is running the barebox sandbox: Thread 1 "barebox" received signal SIGSEGV, Segmentation fault. 0x0000555555579e2b in _strchr (s=s@entry=0x0, c=c@entry=44) at lib/string.c:251 251 for(; *s != (char) c; ++s) (gdb) bt #0 0x0000555555579e2b in _strchr (s=s@entry=0x0, c=c@entry=44) at lib/string.c:251 #1 0x000055555556fd91 in of_get_machine_compatible () at drivers/of/base.c:2380 #2 0x000055555556fda8 in of_init_hostname () at drivers/of/base.c:2389 #3 0x000055555555f9e6 in start_barebox () at common/startup.c:106 #4 0x00005555555a291a in main () (gdb) fr 1 #1 0x000055555556fd91 in of_get_machine_compatible () at drivers/of/base.c:2380 2380 p = strchr(name, ','); Signed-off-by: Aleksander Morgado <aleksander@aleksander.es> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* of: base: use root_node compatible as suggestion for a hostnameOleksij Rempel2018-01-171-0/+32
| | | | | | | | | | | | | | | | 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>
* Merge branch 'for-next/misc'Sascha Hauer2017-10-191-2/+0
|\
| * remove checks for xzalloc() returning NULLUwe Kleine-König2017-09-261-2/+0
| | | | | | | | | | | | | | xzalloc() either returns memory or panics, so checking for NULL is useless. Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | of: base: add function to copy a device tree nodeMichael Olbrich2017-10-171-0/+16
| | | | | | | | | | | | 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: populate clock providers before other devicesLucas Stach2017-10-161-1/+1
|/ | | | | | | | | Clocks are a basic resource, which may be needed early by other devices or even the bus driver (as is the case with the ARM AMBA bus). Register them before populating other devices. 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/+23
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |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>