summaryrefslogtreecommitdiffstats
path: root/drivers/of
Commit message (Collapse)AuthorAgeFilesLines
* Revert "clk: handle CLK_OF_DECLARE in deep probe"Sascha Hauer2022-01-181-4/+1
| | | | | | | | | | | | | | This issue is now solved differently in: | commit 2f9aeab92f51d7b224468f6cd62d7cbbb05ceb1e (master) | Author: Lucas Stach <dev@lynxeye.de> | Date: Sun Jan 16 22:32:19 2022 +0100 | | clk: ignore of_device_ensure_probed error in clock lookup This reverts commit bd516e38dd1490cb83b58f8f7914912f3a702978. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* of: add trailing 0 in of_property_sprintf()Ahmad Fatoum2022-01-141-0/+2
| | | | | | | | | Otherwise, tools like of_dump will consider the output to be byte arrays. Signed-off-by: Ahmad Fatoum <ahmad@a3f.at> Link: https://lore.barebox.org/20220114085735.731631-1-ahmad@a3f.at Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/misc'Sascha Hauer2021-12-1518-40/+52
|\
| * commands: of_diff: don't mix tabs and spaces for indentationAhmad Fatoum2021-12-131-13/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Nodes are indented with spaces, while properties are indented with tabs, leading to discrepancies when the indentation doesn't start at a tab stop, like when using of_diff: chosen { + barebox-version = "barebox-2021.06.0-20210716-2"; + reset-source = "POR"; + reset-source-instance = <0x0>; + subnode { Fix this by using spaces throughout. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20211209105739.3517998-1-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * of: make of_dump abortable by ctrlc()Ahmad Fatoum2021-12-131-3/+10
| | | | | | | | | | | | | | | | | | | | Some device trees can be quite long, e.g. because they contain all possible pinmux entries. Writing that out over serial can take quite a while. Check for ctrlc() between nodes to make these less annoying. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20211209105727.3517863-1-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * of: overlay: rescan aliases calling of_overlay_apply_tree on live treeAhmad Fatoum2021-12-071-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Couple of drivers in-tree, like state, depend on aliases for correct operation. If state node is added via overlay and oftree -p is called, driver would start probing, but fail because aliases weren't reloaded. Fix this corner case by always just calling of_alias_scan() on every successful of_overlay_apply_tree to the live tree. No functional change yet, as the only user of this function is overlay application code of ARM QEMU machine, which happens at pure_initcall level, making of_alias_scan a no-op. Follow-up commit will move overlay application to happen after device tree is registered, necessitating this change. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20211125161042.3829996-4-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * of: base: improve documentation of global exportsAhmad Fatoum2021-11-301-4/+8
| | | | | | | | | | | | | | | | | | Most comments are probably from the initial Linux port. Fix some discrepancies and add docs for barebox-specific of_probe. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20211125160637.3828394-2-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * of: skip machine device creation on subsequent of_probeAhmad Fatoum2021-11-301-1/+4
| | | | | | | | | | | | | | | | | | | | | | | | of_probe may be called more than once, e.g. after oftree -p or by board code after fixing up device tree. This currently leads to a harmless, but annoying error message about machine already being registered. Avoid this by creating the device only once. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20211125160637.3828394-1-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * of: address: mark 64-bit PCI resources explicitly as suchAhmad Fatoum2021-11-221-1/+3
| | | | | | | | | | | | | | | | | | | | | | | | Eventually, we shouldn't need this, when all code can deal with 64-bit addresses. For now, PCI drivers, when given the choice between 32-bit and 64-bit resources, should select the 32-bit one. This patch makes the resources straight forward to compare. Signed-off-by: Ahmad Fatoum <ahmad@a3f.at> Link: https://lore.barebox.org/20211118062546.1380928-1-ahmad@a3f.at Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * drivers: migrate "GPL-2.0" license identifiers to SPDX 2.0Roland Hieber2021-11-2218-18/+18
| | | | | | | | | | | | | | | | | | | | "GPL-2.0-only" was introduced in SPDX 2.0, and the old identifier "GPL-2.0" is now considered deprecated; see <https://spdx.org/licenses>. Fixes: 28f4a6a4df76f0f1581d (2021-10-30, "drivers: add missing SPDX-License-Identifier") Signed-off-by: Roland Hieber <rhi@pengutronix.de> Link: https://lore.barebox.org/20211117113851.2022669-2-rhi@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | of: implement new of_property_sprintfAhmad Fatoum2021-12-141-10/+47
|/ | | | | | | | | | | Board code may compute values for device tree properties and write them as strings. Make this easier by adding a of_property_write_string variant that does formatted output. This also saves an allocation, because asprintf buffer is reused. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20211209105708.3517684-3-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/spdx'Sascha Hauer2021-11-1515-70/+17
|\
| * drivers: add missing SPDX-License-IdentifierAhmad Fatoum2021-11-0115-70/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This adds the suitable SPDX-License-Identifier to all files in drivers/ that previously lacked one. To aid manual inspection, following heuristics can be used: * No changes outside of comments/whitespace: git show -U0 HEAD | rg -v '^(@@|diff|index)|[-+]([-+]|//|#|[\s/]\*)' * -or-later come in pairs: git show --inter-hunk-context=19 HEAD | \ perl -0777 -F'/^@/gm' -ne 'for (@F) { @m = /later/g; print if @m & 1 }' Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20211030175632.2276077-4-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | Merge branch 'for-next/rockchip'Sascha Hauer2021-11-151-1/+4
|\ \
| * | clk: handle CLK_OF_DECLARE in deep probeAhmad Fatoum2021-11-101-1/+4
| |/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | An assigned-clock-parents referring to a fixed-clock will result in a warning: WARNING: clk: couldn't get parent clock 0 for /ethernet@fe300000 That's because the device for the fixed clock is created on demand and even after ensuring probe, no driver will have bound against it as CLK_OF_DECLARE operates outside the driver model. Fix this by creating devices and binding the dummy driver while iterating over the CLK_OF_DECLARE list. No functional change for systems not enabling deep-probe. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20211108075209.2366770-7-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* / of: partitions: Skip fixup for devices with no partitionsTrent Piepho2021-10-121-0/+3
|/ | | | | | | | | | | | | | | | | If the device has no partitions, e.g. most EEPROM or OTP memory, of_partition_fixup() can exit early, before trying to find the kernel dt node and calling of_fixup_partitions(). This avoids spurious error messages when the kernel dt node doesn't exist. E.g., for an EEPROM in the Barebox dtb but not in the kernel dtb, Barebox will display an error about being unable to fixup the kernel dt node, however, if it had found the node it would just return without doing anything since the partition list is empty, so really there is no error. Signed-off-by: Trent Piepho <trent.piepho@igorinstitute.com> Link: https://lore.barebox.org/20211011191933.857941-1-trent.piepho@igorinstitute.com Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* of: overlay: don't do fixups on empty global.of.overlay.dirAhmad Fatoum2021-10-041-0/+3
| | | | | | | | | | | | | | | | | | | | | | | $global.of.overlay.dir is dynamically prepended with the root of the device currently being booted. This allows use of relative paths. Because $global.of.overlay.filepattern is * by default, this means that all files in the root of the device will be considered overlays and barebox will try to unflatten them leading to an error message on boot: ERROR: of_overlay: Failed to unflatten /mnt/mmc0.4//.root_is_rw: Invalid argument Fix this by not doing any fixups at all on empty global.of.overlay.dir. If for whatever reason, a user wants overlays at /, they can global.of.overlay.dir=. Fixes: 124c64af0982 ("overlay: Add filters to choose which overlays to apply") Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20210831161139.2988-1-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* of: partition: implement of_partition_ensure_probedAhmad Fatoum2021-07-181-0/+11
| | | | | | | | | | | | | | The device tree nodes for both barebox environment and state can have phandles that reference partitions. Environment runs at late_initcall level, so deep probe will have populated the device by the time the probe is called. barebox-state however is probed at device_initcall level and thus must take care itself to ensure the partition provider is probed. Add a new of_partition_ensure_probed that does this. It can handle both legacy and new style (fixed) partitions. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20210628064517.28636-4-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/nvmem'Sascha Hauer2021-07-183-18/+88
|\
| * of: of_net: sync of_get_mac_address with Linux for NVMEM supportAhmad Fatoum2021-06-221-14/+64
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We don't use of_get_mac_address anywhere, but it can come in handy as a last resort before barebox generates a random MAC address. With the existing implementation, that MAC address is written literally into the DT, so it's mainly useful when barebox is booted with an external device tree. The kernel implementation adds support for parsing the MAC address out of a revered mac-address nvmem cell, which is much more prevalent. Sync the implementation with Linux v5.13 in preparation for using it. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20210619034516.6737-12-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * nvmem: add support for nvmem-cells bindingAhmad Fatoum2021-06-211-0/+7
| | | | | | | | | | | | | | | | | | | | | | | | Recently, nvmem cell and MTD partition bindings were made to coexist: Partitions can now be compatible = "nvmem-cells"; which registers a NVMEM provider and interprets its child nodes as cells. Teach barebox about this. This allows fetching NVMEM cells from MTD partitions and hostfiles. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20210619034516.6737-5-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * nvmem: add support for new read-only memory (rmem) bindingAhmad Fatoum2021-06-211-4/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | Only upstream user of this binding is the raspberry pi 4 DT, where it's used to pass along bootloader-provided info to Linux. We have instances in barebox, where a previous stage bootloader passes along a memory region with info for barebox to interpret. This could in future be modelled as nvmem-rmem nodes. The binding is also quite handy for debugging. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20210619034516.6737-4-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | Merge branch 'for-next/firmware'Sascha Hauer2021-07-185-51/+467
|\ \
| * | of_firmware: Fix handling of firmware-name propertySascha Hauer2021-06-281-5/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The fpga-region binding states that the firmware-name property must be in the same node as the fpga-region compatible, so checking for this compatible when walking up the parents is wrong. Instead, only test for it in the target node. Also, when the current node is not a fpga-region we must return successfully. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de> Link: https://lore.barebox.org/20210624085223.14616-19-s.hauer@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | overlay: Add filters to choose which overlays to applySascha Hauer2021-06-281-1/+313
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This adds a filter mechanism to choose which overlays to apply. Filters can either match on the filename or on the content of an overlay. Two generic filters are registered, one matching filename patterns given in global.of.overlay.filepattern, the other matching device tree compatibles given in global.of.overlay.compatible. Other board or SoC specific filters can be registered and activated using the global.of.overlay.filter variable. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de> Link: https://lore.barebox.org/20210624085223.14616-15-s.hauer@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | blspec: Rework firmware loadSascha Hauer2021-06-282-24/+92
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Applying overlays in blspec currently works in two steps. First of_firmware_load_overlay() is called which doesn't load an overlay, but instead loads firmware when one is needed by the overlay. This is done on the live tree, because that was needed to find the firmware manager. The second step is to call of_register_overlay() to apply the overlay to the kernel device tree when the fixups are executed. Instead of using a separate step to load the firmware, load the firmware as part of the of_fixups. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de> Link: https://lore.barebox.org/20210624085223.14616-14-s.hauer@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | firmware: Load from global search pathSascha Hauer2021-06-251-21/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We have a global firmware search path, so use it. This removes the path argument from of_firmware_load_overlay(). blspec already extends the global firmware search path, so the path is not needed there. The of_overlay command has an option for specifying the search path, this is removed here, the global search path has to be used instead. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de> Link: https://lore.barebox.org/20210624085223.14616-13-s.hauer@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | overlay: Add of_overlay_apply_file()Sascha Hauer2021-06-251-0/+38
| | | | | | | | | | | | | | | | | | | | | | | | | | | A shortcut to of_overlay_apply_tree() which takes a filename rather than an unflattened device tree. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de> Link: https://lore.barebox.org/20210624085223.14616-12-s.hauer@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | fdt: Check blob size during unflatteningSascha Hauer2021-06-252-6/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | of_unflatten_dtb() doesn't check the size of the device tree blob passed to it. Add a size argument end add checks for the size. Some callers have no idea of the buffer size themselves, INT_MAX is passed in these cases. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de> Link: https://lore.barebox.org/20210624085223.14616-4-s.hauer@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | of: Add function to duplicate a device treeSascha Hauer2021-06-251-0/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This adds of_dup() to duplicate a device tree. Previously of_copy_node() was used for this, but of_copy_node() has issues with potentially duplicated phandle values when the new tree is inserted to an existing tree, that is when the parent argument of of_copy_node() is non NULL. All users of of_copy_node() with a NULL parent argument are converted to of_dup() which is safe to use leaving only the problematic users of of_copy_node(). Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de> Link: https://lore.barebox.org/20210624085223.14616-3-s.hauer@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | of: of_copy_node(): Copy phandles as wellSascha Hauer2021-06-251-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | of_copy_node() has to copy the phandles as well, because otherwise the phandles in the copied tree become invalid. This is not entirely correct because when of_copy_node() is used to copy one tree as a subtree of another tree then we might get duplicated phandles which will result in a corrupted tree. This is also an issue already without this patch, because the phandle of a node is not only stored in the phandle member of a struct device_node, but also as a separate phandle property in the tree itself. The phandle property is copied before this patch, so we can equally well also copy the phandle member of struct device_node. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de> Link: https://lore.barebox.org/20210624085223.14616-2-s.hauer@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | of: kconfig: of_overlay uses firmwaremgr_load_fileSteffen Trumtrar2021-06-211-0/+1
| |/ | | | | | | | | | | | | | | | | As of_firmware.c uses the firmwaremgr_load_file function, it depends on FIRMWARE. Signed-off-by: Steffen Trumtrar <str@pengutronix.de> Link: https://lore.barebox.org/20210616063246.14900-6-s.trumtrar@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | OF: gpio: drop duplicate of_device_ensure_probedAhmad Fatoum2021-06-281-4/+0
| | | | | | | | | | | | | | | | | | of_find_device_by_node already calls of_device_ensure_probed first thing, so drop the first instance. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20210628070307.13498-1-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | console: respect baudrate specified in device-tree stdout-pathAhmad Fatoum2021-06-282-6/+15
| | | | | | | | | | | | | | | | | | | | | | | | stdout-path in the device tree can have a suffix indicating line settings. The baud rate contained within was so far ignored by barebox. Change this so barebox first consults the stdout-path alias before falling back to CONFIG_BAUDRATE. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20210628051934.9604-2-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | string: implement strchrnulAhmad Fatoum2021-06-281-4/+1
| | | | | | | | | | | | | | | | | | | | We have at least two places opencoding strchrnul, one of them needlessly iterating twice instead of once over the string. Replace both by calling a common single pass implementation. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20210628051934.9604-1-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | of: Fix deep-probe triggering when removing nodesSascha Hauer2021-06-251-5/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | During deletion of device nodes of_find_device_by_node() is called in order to set the device_node pointer of the device corresponding to the to-be-deleted node to NULL. This is not necessary anymore as the live tree should not be deleted. This fixes problems with deep-probe support. of_find_device_by_node() calls of_device_ensure_probed(), but this may only be called on the live tree, not on arbitrary nodes that shall be deleted. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de> Link: https://lore.barebox.org/20210625140206.2000-2-s.hauer@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | of: refuse to delete root node of live treeSascha Hauer2021-06-251-3/+5
| | | | | | | | | | | | | | | | | | | | | | | | The root node of the live tree should never be deleted, so refuse to do so and print an error message. Deleting the live tree was possible with the oftree -f command which was removed in c39c70bac5 ("commands: oftree: kill oftree -f"). As this no longer exists we also do not need the of_set_root_node(NULL) part anymore. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de> Link: https://lore.barebox.org/20210625140206.2000-1-s.hauer@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | of: Add dummy driverSascha Hauer2021-06-251-0/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | With deep probe support we decide that a device for a new device node is available when the device has a driver. It sometimes happens that a consumer of a device node doesn't point to the node to which the driver is attached to, but instead a subnode, like this: usb2phy0: usb2-phy@fe8a0000 { compatible = "rockchip,rk3568-usb2phy"; u2phy0_host: host-port { status = "disabled"; }; }; usbhost_dwc3: dwc3@fd000000 { compatible = "snps,dwc3"; phys = <&u2phy0_host>; phy-names = "usb2-phy"; }; of_device_ensure_probed() would now expect a driver for the &u2phy0_host node, but the driver is attached to the &usb2phy0 node. This patch adds of_platform_device_dummy_drv() which can be used in such situations. When called on the &u2phy0_host it will attach a dummy driver to it so that deep probe is happy. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de> Link: https://lore.barebox.org/20210625072540.32717-20-s.hauer@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | common: Explicitly probe consoles earlier with deep probeSascha Hauer2021-06-251-0/+17
| | | | | | | | | | | | | | | | | | | | | | With deep probe support the device providing the console can come quite late in the probe order. Make sure it's probed at postconsole_initcall time as it used to be without deep probe support so that we get output earlier. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de> Link: https://lore.barebox.org/20210625072540.32717-12-s.hauer@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | common: add initial barebox deep-probe supportMarco Felsch2021-06-253-4/+184
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The barebox 'deep probe' or 'probe on demand' mechanism is the answer of unwanted -EPROBE_DEFER failures. The EPROBE_DEFER error code was introduced by commit ab3da15bc14c ("base: Introduce deferred probing") and since then it causes a few problems. The error is returned if either the device is not yet present or the driver is not yet registered. This makes sense on linux systems where modules and hot-plug devices are used very often but not for barebox. The module support is rarely used and devices aren't hot pluggable. The current barebox behaviour populates all devices before the drivers are registered so all devices are present during the driver registration. So the driver probe() function gets called immediately after the driver registration and causes the -EPROBE_DEFER error if this driver depends on an other not yet registered driver. To get rid of the EPROBE_DEFER error code we need to reorder the device population and the driver registration. All drivers must be registered first. In an ideal world all driver can be registered by the same initcall level. Then devices are getting populated which causes calling the driver probe() function but this time resources/devices are created on demand if not yet available. Dependencies between devices are normally expressed as references to other device nodes. With deep probe barebox provides helper functions which take a device node and probe the device behind that node if necessary. This means instead of returning -EPROBE_DEFER, we can now make the desired resources available once we need them. If the resource can't be created we are returning -ENODEV since we are not supporting hot-plugging. Dropping EPROBE_DEFER is the long-term goal, avoid initcall shifting is the short-term goal. Call it deep-probe since the on-demand device creation can create very deep stacks. This commit adds the initial support for: spi, i2c, reset, regulator, gpio and clk resource on-demand creation. The deep-probe mechanism must be enabled for each board to avoid breaking changes using deep_probe_enable(). This can be changed later after all boards are converted to the new mechanism. Signed-off-by: Marco Felsch <m.felsch@pengutronix.de> Link: https://lore.pengutronix.de/20201021115813.31645-8-m.felsch@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de> Link: https://lore.barebox.org/20210625072540.32717-10-s.hauer@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | of: implement of_get_stdoutpath()Sascha Hauer2021-06-251-5/+10
| | | | | | | | | | | | | | | | | | | | | | For deep probe support it will be useful to have a function to get the node corresponding to the stdoutpath. of_device_is_stdout_path() already has that functionality in it, so make a separate funcion from it. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de> Link: https://lore.barebox.org/20210625072540.32717-8-s.hauer@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | of: Set of_chosen and of_model earlierSascha Hauer2021-06-251-9/+9
| | | | | | | | | | | | | | | | | | of_chosen and of_model can be set once we have the device tree root node, no need to wait until we probe the tree. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de> Link: https://lore.barebox.org/20210625072540.32717-7-s.hauer@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | of: base: move clock init from of_probe() to barebox_register_of()Marco Felsch2021-06-251-2/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is required for the new deep-probe mechanism. Barebox deep-probe calls of_probe() very late and so clock drivers using the old CLK_OF_DECLARE_DRIVER() mechanism are added very late. This would break the deep-probe approach. Move of_clk_init() and call it right before of_probe() should have no impact because of_clk_init() depends only on an unflatten dtb. Signed-off-by: Marco Felsch <m.felsch@pengutronix.de> Link: https://lore.pengutronix.de/20201021115813.31645-6-m.felsch@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de> Link: https://lore.barebox.org/20210625072540.32717-6-s.hauer@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | of: base: move memory init from DT to initcallLucas Stach2021-06-251-4/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Instead of calling it from of_probe, convert it to a initcall at the appropriate level. This allows to move of_probe to later in the init sequence while keeping the memory init at the same place, which is important as many other drivers need the valid memory area to be set up properly. Signed-off-by: Lucas Stach <dev@lynxeye.de> Signed-off-by: Marco Felsch <m.felsch@pengutronix.de> Link: https://lore.pengutronix.de/20201021115813.31645-5-m.felsch@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de> Link: https://lore.barebox.org/20210625072540.32717-5-s.hauer@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | of: platform: Keep track of populated platform devicesMarco Felsch2021-06-251-1/+19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Linux does not allow to populate the same of device more than once. Linux uses the OF_POPULATED flag for that purpose. Align the logic with the current linux state with the exception that we are returning the already created device. This is needed for the later added deep-probe mechanism. Signed-off-by: Marco Felsch <m.felsch@pengutronix.de> Link: https://lore.pengutronix.de/20201021115813.31645-4-m.felsch@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de> Link: https://lore.barebox.org/20210625072540.32717-4-s.hauer@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | of: platform: remove check of already added devicesMarco Felsch2021-06-251-30/+1
|/ | | | | | | | | | | | | | | | | | This check is a relict of the early barebox device tree days, where devices were added by machine and/or board code too. The check ensured too not populate the same device twice. Nowadays _real_ hardware devices (devices with hardware resources) which are not auto enumerable should only be added using the device tree. Remove the check to cleanup the code and to remove looping over each device every time of_platform_device_create() is called instead of keeping it for legacy boards/machines. Those legacy boards/machines should be converted instead. Signed-off-by: Marco Felsch <m.felsch@pengutronix.de> Link: https://lore.pengutronix.de/20201021115813.31645-3-m.felsch@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de> Link: https://lore.barebox.org/20210625072540.32717-3-s.hauer@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/overlapping-memory-banks'Sascha Hauer2021-06-162-15/+30
|\
| * of: warn about of_add_memory_bank errorsAhmad Fatoum2021-06-022-8/+21
| | | | | | | | | | | | | | | | | | | | | | | | 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-7/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* | Merge branch 'for-next/net'Sascha Hauer2021-06-161-0/+7
|\ \