summaryrefslogtreecommitdiffstats
path: root/drivers/of
Commit message (Collapse)AuthorAgeFilesLines
* Merge branch 'for-next/pci'Sascha Hauer35 hours1-16/+181
|\
| * of: add of_property_read_variable_uxx_array()Sascha Hauer2024-04-041-16/+181
| | | | | | | | | | | | | | | | | | | | | | This adds of_property_read_variable_uxx_array() which allow to read arrays from properties with min/max size boundaries. Code is directly taken from Linux. We already had of_property_read_variable_u64_array(), but without min/max arguments. This one is updated to match the Kernel code. Link: https://lore.barebox.org/20240403080703.4098404-1-s.hauer@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | Merge branch 'for-next/nand'Sascha Hauer35 hours1-1/+0
|\ \
| * | mtd: nand: update to Linux-6.9-rc2Sascha Hauer5 days1-1/+0
| |/ | | | | | | | | Link: https://lore.barebox.org/20240416095313.1977242-5-s.hauer@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | of: do not copy properties if they already exist in the destinationJonas Richardsen2024-04-161-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Currently `of_copy_property` copies the given property even if a property with the same name already exists on the destination node. This leads to kernel warnings about duplicate properties: ``` [ 0.014063] Duplicate name in chosen, renamed to "stdout-path#1" [ 0.014093] Duplicate name in chosen, renamed to "bootargs#1" [ 0.014119] Duplicate name in chosen, renamed to "phandle#1" [ 0.014197] Duplicate name in reserved-memory, renamed to "#address-cells#1" [ 0.014226] Duplicate name in reserved-memory, renamed to "#size-cells#1" [ 0.014252] Duplicate name in reserved-memory, renamed to "ranges#1" [ 0.014278] Duplicate name in reserved-memory, renamed to "phandle#1" ``` Therefore, the function was changed to return an error if the property already exists in the destination. The change does not cause any regressions, because the only usage of this function occurs within `arch/arm/boards/raspberry-pi/rpi-common.c` where the original behaviour of the function is obviously unintended. Signed-off-by: Jonas Richardsen <jonasrichardsen@emlix.com> Link: https://lore.barebox.org/20240415122757.327312-1-jonasrichardsen@emlix.com Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | of: do not acccess 'prop->value' directlyEnrico Scholz2024-04-161-3/+3
|/ | | | | | | | | Use of_property_get_value() accessor. Else, wrong results are returned when working with fit images. Signed-off-by: Enrico Scholz <enrico.scholz@sigma-chemnitz.de> Link: https://lore.barebox.org/20240412162925.284747-1-enrico.scholz@sigma-chemnitz.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* dma: Fix compiler warningSascha Hauer2024-04-021-0/+2
| | | | | | | | | | | | of_dma_is_coherent() returns an undefined value on unexpected return values of of_dma_get_coherence(): drivers/of/platform.c: In function 'of_dma_is_coherent': drivers/of/platform.c:128:1: warning: control reaches end of non-void function [-Wreturn-type] This cannot be reached so just add a BUG() to silence the compiler. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* dma: correctly honour dma-noncoherent device tree propertyAhmad Fatoum2024-03-251-11/+23
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Most barebox platforms are either completely cache-coherent with respect to DMA or completely non-coherent. To avoid having to walk the device tree for non-existent dma-coherent and dma-noncohrent properties, barebox thus only does this when CONFIG_OF_DMA_COHERENCY is selected. CONFIG_OF_DMA_COHERENCY is to be selected by platforms that have mixed coherency for DMA masters. Forgetting to select this option can be annoying to debug, which is why devinfo will inform the user of default DMA coherency assignments: DMA Coherent: false (default) In order to allow devinfo to differentiate implicit default and explicit device tree DMA coherency configuration, the struct device::dma_coherent member is not of boolean type, but Instead an enumeration that besides coherent and non-coherent also encodes a DEV_DMA_COHERENCE_DEFAULT state. In practice though, a boolean was saved in this dma_coherent member, leading to any dma-noncoherent property being ignored and the default coherency setting being taken for the node. By fixing the type confusion, we restore working Ethernet on the StarFive JH7100, which is the only SoC we currently support that requires /soc/dma-noncohrent to be set for proper operation of its DMA masters. Fixes: fbdea8fd54fe ("of: populate new device_d::dma_coherent attribute") Reported-by: Antony Pavlov <antonynpavlov@gmail.com> Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20240322142424.981863-1-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/misc'Sascha Hauer2024-03-152-36/+152
|\
| * of: fdt: justify fdt_machine_is_compatible parsing only the root nodeAhmad Fatoum2024-03-131-0/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | fdt_machine_is_compatible() is a lightweight way to check the top-level compatible without unflattening the DT or pulling in libfdt. The lightness is due to parsing only the root node and looking for the compatible right away. This assumes that no child nodes of the root node precede the compatible property. This is mandated by the specification and dtc throws a syntax error when attempting to violate this. Add a comment referencing the specification to tell future readers why it should be ok for us to assume this. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20240313093145.3349370-1-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * of: partition: Also add partitions created by addpart to the boot dtbUwe Kleine-König2024-03-131-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | A partition added interactively using addpart was added in of_partition_fixup() before commit aec676b568 ("cdev: record whether partition is parsed from OF"). Restore that behaviour. To do that a new flag DEVFS_PARTITION_FOR_FIXUP is created that behaves very similar what DEVFS_PARTITION_FROM_OF did before. The only difference is that addpart makes use of it (and that stat uses a different string to describe it). Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Link: https://lore.barebox.org/20240312100918.604105-1-u.kleine-koenig@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * of: fdt: implement fdt_machine_is_compatibleAhmad Fatoum2024-03-051-0/+95
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When finding compatible bootloader spec files, barebox will unflatten each DTB in turn, allocating objects for each property and node, only to compare a single property and then free all the allocations again. Given that this operation is repeated for every device tree until a match is found, it's a good idea to be able to compare machine (top-level) compatibles without having to unflatten the whole FDT. Implemnt fdt_machine_is_compatible() that does just that. This intentionally opencodes the device tree iteration as to minimize code and runtime size. Using libfdt without LTO would be slower and bigger. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20240301130445.171385-3-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * of: fdt: factor out FDT header parsingAhmad Fatoum2024-03-041-33/+43
| | | | | | | | | | | | | | | | | | | | Follow-up commit will need to parse the FDT header without unflattening the whole device tree at the same time. Therefore split off the header verification into its own separate function. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20240301130445.171385-2-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | cdev: implement setter/getter for cdev device nodeAhmad Fatoum2024-03-052-8/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | A cdev has two device tree node pointers, one directly at struct cdev.device_node and another indirectly via cdev.dev->device_node. We may want to remove cdev::device_node in future, but till then to avoid users having to guess, which device_node is the correct one, add a helper to set and get the device tree node. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20240304190038.3486881-19-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | of: don't report failure to of_read_file twiceAhmad Fatoum2024-03-051-3/+1
| | | | | | | | | | | | | | | | | | of_read_file already prints to log messages when it fails, so duplicating the error message in the caller is needlessly verbose. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20240304190038.3486881-11-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | efi: payload: rename CONFIG_EFI_BOOTUP to CONFIG_EFI_PAYLOADAhmad Fatoum2024-03-051-1/+1
|/ | | | | | | | | | The symbol is internal, so we don't break anything by renaming it. CONFIG_EFI_PAYLOAD is clearer in intent, as BOOTUP doesn't clearly indificate whether barebox would act as EFI payload or as EFI loader. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20240304190038.3486881-9-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/misc'Sascha Hauer2024-02-211-10/+8
|\
| * deep-probe: return -EPROBE_DEFER when ensuring probe failsAhmad Fatoum2024-02-201-7/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | -ENODEV is a bad choice for an error code for of_device_ensure_probed. The function is either called from board code or from driver frameworks, which usually just propagate the error code with unintended consequences: - A board driver probe function returning -ENODEV is silently skipped - A driver framework function returning -ENODEV is often interpreted to mean that an optional resource is not specified (e.g. in DT). In both cases, the user isn't provided an error message and wrong behavior can crop up later. In my case, the XHCI driver would time out, because phy_get propagated of_device_ensure_probed's -ENODEV, which was understood to mean that no PHY is needed and not that the PHY is specified in the DT, but no driver was bound to it. Instead of -ENODEV, let's thus return -EPROBE_DEFER. This can be propagated up to the driver core, which on a deep probe system (the only ones where of_device_ensure_probed is not a no-op) will print a fat red error message. We could achieve the same with some other error code, but -EPROBE_DEFER is what a non-deep-probe system would return when probes are deferred indefinitely, so symmetry in the deep probe case fits well. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20240219172925.3798024-4-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * deep-probe: use IS_ERR_OR_NULL() instead of opencodingAhmad Fatoum2024-02-201-3/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | of_device_create_on_demand either returns a valid pointer, -ENODEV or NULL. of_device_create_on_demand is a recursive function, which either returns a valid pointer, ERR_PTR(-ENODEV) or NULL. Retuning either ERR_PTR(-ENODEV) or NULL is needed for its proper operation, but of_device_ensure_proped treats both the same, so use IS_ERR_OR_NULL() to make this apparent. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20240219172925.3798024-3-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | of: fdt: fix oob writes with large fdt propertiesStefan Kerkmann2024-02-011-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | OOB writes can be triggered when fdt->dt_size * 2 is still smaller than the property for which memory should be allocated. This can happen under rare circumstances when editing a fdt with the of_property command and a property is larger than 128k in size. This happend when editing a FIT image (which is a ftd) with the of_property command and the Kernel image was around 8M in size. The simplified call chain is the following: of_property -> of_flatten_dtb -> create new fdt with 64k in size (this is fixed) -> __of_flatten_dtb -> attempt to copy kernel image (8M) -> fdt_ensure_space -> allocate only 128k for fdt->dt -> memcopy 8M into fdt->dt buffer -> crash The fix is to grow fdt->dt to hold at least the new property. The power of 2 increment is untouched to keep the same behaviour otherwise. Signed-off-by: Stefan Kerkmann <s.kerkmann@pengutronix.de> Link: https://lore.barebox.org/20240201-fix-fdt-memory-safety-v2-2-267b7b8813fd@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | of: fdt: fix memory leak in fdt_ensure_spaceStefan Kerkmann2024-02-011-7/+21
|/ | | | | | | | | | If the reallocation failed the old memory remains allocated and is never freed, this is fixed by freeing the old memory on error. Signed-off-by: Stefan Kerkmann <s.kerkmann@pengutronix.de> Reviewed-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20240201-fix-fdt-memory-safety-v2-1-267b7b8813fd@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/layerscape'Sascha Hauer2024-01-232-11/+10
|\
| * of: populate new device_d::dma_coherent attributeAhmad Fatoum2024-01-111-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | So far, whether device DMA is coherent was a one-time global decision. This is insufficient, because some platforms: - are cache coherent, while the architecture isn't in general, e.g. barebox support for ARM with CONFIG_MMU=y assumes non-coherent DMA, but LS1046A can be fully coherent. - have a mix of devices that snoop caches and devices that don't (StarFive JH7100). To enable dev_dma_(map|unmap)_single to take the correct device-specific action with regards to cache maintenance, provide dev_is_dma_coherent() with semantics similar to what Linux provides. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20240110160112.4134162-8-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * dma: introduce CONFIG_OF_DMA_COHERENCYAhmad Fatoum2024-01-111-6/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Some architectures are either exclusively cache-coherent or not, but some others can have only some devices that snoop the bus, while the rest doesn't. This information can be encoded in the device tree, but we don't want to look this up in the device tree for the vast majority of platforms that are either completely coherent or aren't. Therefore provide a new CONFIG_OF_DMA_COHERENCY symbol for selections by platforms that require this functionality. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20240110160112.4134162-4-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * dma: rename OF_DMA_DEFAULT_COHERENT to ARCH_DMA_DEFAULT_COHERENTAhmad Fatoum2024-01-112-5/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The symbol is not visible and only used by of_dma_is_coherent, which has no current callers. It was added to extend devices with a DMA coherency attribute like done in Linux and was renamed there in commit c00a60d6f4a1 ("of: address: always use dma_default_coherent for default coherency"), so have barebox follow suit. No functional change. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20240110160112.4134162-2-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | partition: switch to using cdevfs_add_partitionAhmad Fatoum2024-01-081-8/+8
|/ | | | | | | | | | We already have a cdev, so it's wasteful to do a lookup by cdev name using devfs_add_partition. Use the newly exported cdevfs_add_partition helper directly instead. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20240103101629.2629497-5-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/op-tee'Sascha Hauer2023-12-181-6/+7
|\
| * deep-probe: skip on-demand platform dev creation for nodes without compatibleAhmad Fatoum2023-12-051-3/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | of_device_create_on_demand won't create a new device if the device tree node already has a device associated. What it will do however, is to create devices for all parent nodes in the device tree if they don't already exist. This is unnecessary and clutters the device list with nodes that won't ever be matched as they lack a compatible anyway. For example a reference to scmi_reg11 in below snippet: &{scmi/protocol@17} { reg = <0x17>; regulators { #address-cells = <0x1>; #size-cells = <0x0>; scmi_reg11: regulator@0 { reg = <0x0>; regulator-name = "reg11"; }; }; }; will result in creation of a device for the regulators node that serves no purpose whatsoever: `-- firmware.of `-- firmware:scmi.of `-- scmi_dev0 `-- firmware:scmi:protocol@17:regulators.of Avoid this by creating devices on demand only if they have a compatible. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20231127063559.2205776-4-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * deep-probe: don't panic when device can't be createdAhmad Fatoum2023-12-051-3/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | of_device_ensure_probed() already returns error codes, e.g. when of_device_create_on_demand attempts recreating a device with the same name. In some error cases though that shouldn't happen in normal operation, of_device_create_on_demand() returns NULL, which triggers a panic. During development, returning NULL can happen more often, so aborting barebox startup is unnecessarily harsh. Follow-up commit will add other ways for of_device_create_on_demand to return NULL, so the panic is even more out of place. Let's just return a silent error code instead. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20231127063559.2205776-3-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | of: early exit of_match_node if no better matches are possibleAhmad Fatoum2023-12-131-0/+3
| | | | | | | | | | | | | | | | | | | | The maximum score that can be returned by of_device_is_compatible is OF_DEVICE_COMPATIBLE_MAX_SCORE. Once that score is returned, there is no point in continuing with the string comparisons, so just early exit. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20231205113618.3966168-3-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | of: define macro for maximum of_device_is_compatible return valueAhmad Fatoum2023-12-131-2/+4
|/ | | | | | | | | | | | | | of_device_is_compatible() will return zero on mismatch and a positive value up to and including (INT_MAX / 2) on match. Knowledge of the upper bound can be useful to callers, because if inside a loop a maximum score was achieved, there's usually no point in continuing the search. Therefore add a macro for INT_MAX / 2 and document it for potential users. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20231205113618.3966168-2-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/prepare-optee'Sascha Hauer2023-11-271-0/+4
|\
| * of: add CONFIG_OF for Linux compatibilityAhmad Fatoum2023-11-231-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | barebox has CONFIG_OFTREE and CONFIG_OFDEVICE as separate definitions for good reason, because configurations parsing device trees, while not using them are possible. In Linux, there is no such distinction and CONFIG_OF is used as single option for this. Provide the same option in barebox as hidden symbol and select it from CONFIG_OFDEVICE to make porting a tiny bit easier. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20231122172951.376531-11-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | of: reserved-mem: add debug print for reservationsAhmad Fatoum2023-11-231-0/+4
|/ | | | | | | | | reserve_sdram_region can now involve cache maintenance, so add a debug print beforehand to aid debugging. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20231122173118.569620-1-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/of-reserve'Sascha Hauer2023-10-271-7/+24
|\
| * bootm: print memreserve map in verbose modeSascha Hauer2023-10-191-0/+23
| | | | | | | | | | | | | | | | There currently is no way to print the /memreserve/ map barebox boots the kernel with. As this contains useful debugging information sometimes print it along with the device tree when booting with -vv. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * fdt: Do not reserve device tree blobSascha Hauer2023-10-191-7/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | As a matter of fact the reservation is buggy. fdt_add_reserve_map() added the reservation for the address the fdt currently is placed, but the fdt is relocated in bootm_load_devicetree() later. This means we just add a reserve region for some arbitrary piece of memory which can equally well be removed. Linux doesn't require reserving the device tree blob. Some architectures use early_init_fdt_reserve_self() to mark the fdt as reserved, some like arm64 use architecture code to reserve the region, others like arm move the fdt away. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | of: fdt: fix possibles overflows during parsing of invalid DTsAhmad Fatoum2023-10-231-8/+40
| | | | | | | | | | | | | | | | | | | | | | barebox may end up doing out of bound accesses if certain offsets in parsed device trees exceed the total size of the flattened device tree being parsed. Add some checks to early abort the parsing of such invalid device trees. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20231020072316.2830850-3-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | of: platform: don't fail of_find_device_by_node() if no driver boundAhmad Fatoum2023-09-261-4/+2
|/ | | | | | | | | | | | | of_find_device_by_node() may be called by a driver following of_platform_populate in order to bind the children to drivers. It's thus wrong to return NULL when a device has been found, but no driver was registered. That also aligns the function with the expectation resulting from its name: A device is found and devices may be bound or not. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20230914073018.3462650-1-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* of_firmware: fix lookup of fpga managerMichael Tretter2023-08-181-1/+2
| | | | | | | | | | | | | | | | The of_parse_phandle() looks for the phandle in the root device tree, but as np is resolved for the target device tree, the phandle refers to the target device tree and may return a wrong node in the root tree. Therefore, we must ensure that we look for the manager-node in the target device tree, which is the root node of np, and look for the manager with that name. firmwaremgr_find_by_node already uses the name for the lookup. Signed-off-by: Michael Tretter <m.tretter@pengutronix.de> Link: https://lore.barebox.org/20230809100559.2505416-1-m.tretter@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* FIT: don't verify signature of non-signature nodesAhmad Fatoum2023-07-281-0/+15
| | | | | | | | | | | | | | | | | | | | | | | One would expect that all children of a configuration node are signature nodes, but OpenEmbedded's core kernel-fitimage.bbclass always generates a dummy hash-1 node into configurations with just an algo and no digest, which barebox would try to interpret as a FIT configuration leading to an error verifying the FIT image: ERROR: FIT: hashed-strings start not found in /configurations/conf-something/hash-1 Make it possible to boot such FIT images by only verifying nodes that are supposed to be signatures. This aligns us with U-Boot behavior, but introduces theoretical breakage for FIT images that have signature nodes with funny names. Given that everyone uses signature@1 or signature-1 and we even hardcode it as places and that the failure mode is to refuse boot of old images with new barebox version when FIT image verification is required, this is deemed acceptable. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20230727155726.2133700-1-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* fdt: copy terminating '\0' in lstrcpy()Enrico Scholz2023-07-261-4/+4
| | | | | | | | | | | | | | | On large string tables (>64K), a | fdt->strings = realloc(fdt->strings, fdt->str_size * 2); operation is executed. This 'realloc()' does not zero the memory so there is no guarantee that the strings will be terminated properly. Modify 'lstrcpy()' so that it also copies the terminating '\0'. Signed-off-by: Enrico Scholz <enrico.scholz@sigma-chemnitz.de> Link: https://lore.barebox.org/20230719181129.367413-1-enrico.scholz@sigma-chemnitz.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* treewide: Print device nodes with %pOFSascha Hauer2023-07-037-46/+40
| | | | | | | We have the %pOF format specifier for printing device nodes. Use it where appropriate. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/state'Sascha Hauer2023-06-223-26/+91
|\
| * of: export new of_cdev_find helperAhmad Fatoum2023-06-121-19/+40
| | | | | | | | | | | | | | | | | | | | | | | | | | __of_find_path goes through the hassle of determining the cdev, only to discard it again and return either zero or an error code. Follow up commits will need to get the cdev corresponding to a path in the DT. So let's make that easier by exporting a suitable helper function. Reviewed-by: Marco Felsch <m.felsch@pengutronix.de> Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20230607120714.3083182-16-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * cdev: record whether partition is parsed from OFAhmad Fatoum2023-06-081-2/+3
| | | | | | | | | | | | | | | | | | | | | | | | Later code will make it possible to define an on-disk-described partition in the DT as well. For this reason, we can't assume DEVFS_PARTITION_FROM_TABLE to mean !DT, so let's add a dedicated flag for that. Reviewed-by: Marco Felsch <m.felsch@pengutronix.de> Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20230607120714.3083182-11-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * of: of_path: always call of_partition_ensure_probed before resolvingAhmad Fatoum2023-06-081-0/+10
| | | | | | | | | | | | | | | | | | | | | | | | of_find_path may be called on a partition, whose parent device is not yet probed. state code solves that by calling of_partition_ensure_probed before of_find_path_by_node, but really we should be doing that for all calls to of_find_path. Do so. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Reviewed-by: Marco Felsch <m.felsch@pengutronix.de> Link: https://lore.barebox.org/20230607120714.3083182-7-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * of: partition: support of_partition_ensure_probed on parent deviceAhmad Fatoum2023-06-082-5/+38
| | | | | | | | | | | | | | | | | | | | | | | | barebox-state code uses of_partition_ensure_probed to resolve the backend property. We want to allow backend to point directly at a storage device instead of a partition. We can't determine whether a DT device is a storage device though before it's probed, so let's have of_partition_ensure_probed support either case. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20230607120714.3083182-5-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | Merge branch 'for-next/of-compat'Sascha Hauer2023-06-221-0/+3
|\ \
| * | commands: of_diff: simplify error handlingAhmad Fatoum2023-06-091-0/+3
| |/ | | | | | | | | | | | | | | | | | | | | | | The error check and message is duplicated for each argument and could be unified if we move it to get_tree instead. While at it, we limit argc to exactly 3 in case we want to add options in the future. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20230608134040.2123869-3-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>