summaryrefslogtreecommitdiff
path: root/drivers/core
AgeCommit message (Collapse)AuthorFilesLines
2022-12-02dm: core: Fix iteration over driver_info recordsPaul Barker1-3/+3
We should only perform additional iteration steps when needed to initialize the parent of a device. Other binding errors (such as a missing driver) should not lead to additional iteration steps. Unnecessary iteration steps can cause issues when memory is tightly constrained (such as in the TPL/SPL) since device_bind_by_name() unconditionally allocates memory for a struct udevice. On the SanCloud BBE this led to boot failure caused by memory exhaustion in the SPL when booting from SPI flash. Signed-off-by: Paul Barker <paul.barker@sancloud.com>
2022-11-22net: phy: Fix ethernet-phy-id <dot> in the codeMichal Simek1-2/+2
Use dot instead of comma. The fix doesn't affect anything but it is good to be aligned with used pattern. The first is used only for string size calculation and the second change is in the comment. Fixes: db681d4929ca ("net: phy: Add new read ethernet phy id function") Signed-off-by: Michal Simek <michal.simek@amd.com>
2022-10-29dm: core: Do not stop uclass iteration on errorMichal Suchanek1-12/+18
When probing a device fails NULL pointer is returned, and following devices in uclass list cannot be iterated. Skip to next device on error instead. With that the only condition under which these simple iteration functions return error is when the dm is not initialized at uclass_get time. This is not all that interesting, change return type to void. Fixes: 6494d708bf ("dm: Add base driver model support") Signed-off-by: Michal Suchanek <msuchanek@suse.de> Reviewed-by: Simon Glass <sjg@chromium.org>
2022-10-29dm: tpl: Add fdt address translation support in TPLWilliam Zhang1-0/+14
This is needed in the platforms that use "ranges" node property for address translation in their dts for TPL. Signed-off-by: William Zhang <william.zhang@broadcom.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2022-10-29dm: core: Fix lists_bind_fdt() using non-existent of_matchSimon Glass1-1/+3
The call to device_bind_with_driver_data() passes id->data but if the entry has no of_match then the id has not been set by the selected driver. Normally this passes unnoticed since a previous driver likely had an of_match value, so the id is set to that. Of course it is not correct to pass the id->data from a different driver. With clang-14 the driver ordering is such that the id is never actually set in the 'bind /usb@1 usb_ether' line in test_bind_unbind_with_node() thus causing a crash. Fix this by passing 0 if the of_match for a driver does not exist. Signed-off-by: Simon Glass <sjg@chromium.org>
2022-10-21core: Enable DM by defaultTom Rini1-1/+1
There are no longer any platforms which do not enable DM, move this to a def_bool y and remove the check in the Makefile. Cc: Simon Glass <sjg@chromium.org> Signed-off-by: Tom Rini <trini@konsulko.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2022-10-18dm: core: Switch uclass_*_device_err to use uclass_*_device_checkMichal Suchanek1-14/+14
The _err variant iterators use the simple iterators without suffix as basis. However, there is no user that uclass_next_device_err for iteration, many users of uclass_first_device_err use it to get the first and (assumed) only device of an uclass, and a couple that use uclass_next_device_err to get the device following a known device in the uclass list. While there are some truly singleton device classes in which more than one device cannot exist these are quite rare, and most classes can have multiple devices even if it is not the case on the SoC's EVB. In a later patch the simple iterators will be updated to not stop on error and return next device instead. With this in many cases the code that expects the first device or an error if it fails to probe may get the next device instead. Use the _check iterators as the basis of _err iterators to preserve the old behavior. Signed-off-by: Michal Suchanek <msuchanek@suse.de> Reviewed-by: Simon Glass <sjg@chromium.org>
2022-10-18dm: core: Fix uclass_probe_all to really probe all devicesMichal Suchanek1-7/+5
uclass_probe_all uses uclass_first_device/uclass_next_device assigning the return value. The interface for getting meaningful error is uclass_first_device_check/uclass_next_device_check, use it. Also do not stop iteration when an error is encountered. Probing all devices includes those that happen to be after a failing device in the uclass order. Fixes: a59153dfeb ("dm: core: add function uclass_probe_all() to probe all devices") Signed-off-by: Michal Suchanek <msuchanek@suse.de> Reviewed-by: Simon Glass <sjg@chromium.org>
2022-10-18dm: regmap: Disable range checks in SPLSimon Glass1-2/+21
A recent change to regmap breaks building of phycore-rk3288 for me. The difference is only a few bytes. Somehow CI seems to pass, even though it fails when I run docker locally. But it prevents me from sending any more pull requests. In any case this board is clearly near the limit. We could revert the offending change, but it is needed for sandbox tests. Instead, add a way to drop the range checks in SPL, since they end up doing nothing if everything is working as expected. This makes phycore-rk3288 build again for me and reduces the size of SPL slightly for a number of boards. Signed-off-by: Simon Glass <sjg@chromium.org> Fixes: 947d4f132b4 ("regmap: fix range checks")
2022-10-06regmap: fix range checksHeinrich Schuchardt1-2/+2
On the 32bit ARM sandbox 'dm ut dm_test_devm_regmap' fails with an abort. This is due to incorrect range checks. On 32-bit systems the size of size_t and int is both 32 bit. The expression (offset + val_len) is bound to overflow if offset == -1. Add an overflow check. Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2022-09-30dm: core: Support copying properties with ofnodeSimon Glass1-0/+24
Add a function to copy properties from one node to another. Signed-off-by: Simon Glass <sjg@chromium.org>
2022-09-30dm: core: Allow copying ofnode property data when writingSimon Glass1-8/+21
At present ofnode_write_prop() is inconsistent between livetree and flattree, in that livetree requires the caller to ensure the property value is stable (e.g. in rodata or allocated) but flattree does not, since it makes a copy. This makes the API call a bit painful to use, since the caller must do different things depending on OF_LIVE. Add a new 'copy' argument which tells the function to make a copy if needed. Add some tests to cover this behaviour. Signed-off-by: Simon Glass <sjg@chromium.org>
2022-09-30dm: core: Complete phandle implementation using the other FDTSimon Glass1-2/+2
We need to be able to look up phandles in any FDT, not just the control FDT. Use the 'other' FDT to test this, with a helper function which gets this as an oftree that can then we used as needed. Add a few more tests and some comments at the top of the file, to explain what is going on. Signed-off-by: Simon Glass <sjg@chromium.org>
2022-09-30dm: core: Add the ofnode multi-tree implementationSimon Glass1-4/+166
Add the logic to redirect requests for the device tree through a function which can look up the tree ID. This works by using the top bits of ofnode.of_offset to encode a tree. It is assumed that there will only be a few device trees used at runtime, typically the control FDT (always tree ID 0) and possibly a separate FDT to be passed the OS. The maximum number of device trees supported at runtime is 8, with this implementation. That would use bits 30:28 of the node-offset value, meaning that the positive offset range is limited to bits 27:0, versus 30:1 with this feature disabled. That still allows a device tree of up to 256MB, which should be enough for most FITs. Larger ones can be supported by using external data with the FIT, or by enabling OF_LIVE. Update the documentation a little and fix up the comment for ofnode_valid(). Signed-off-by: Simon Glass <sjg@chromium.org>
2022-09-30dm: core: Add definitions for multiple ofnode treesSimon Glass1-0/+24
At present, unless OF_LIVE is enabled, ofnode only supports access to one device tree, the control FDT. This is because only the node offset is encoded in ofnode, with the tree being implicit. This makes ofnode (without OF_LIVE) unsuitable for device tree fixups, as implemented by ft_board_setup() and other such functions. To solve this, we can use the top bits of the node offset to hold a tree ID. Add the definitions for this. Signed-off-by: Simon Glass <sjg@chromium.org>
2022-09-30dm: core: Split ofnode_path_root() into two functionsSimon Glass1-5/+37
This function turns out to be a little confusing since it looks up a path and also registers the tree. Split it into two, one that gets the root node and one that looks up a path, so the purpose is clear. Registering the tree will happen in a function to be added in a later patch, called oftree_from_fdt(). Signed-off-by: Simon Glass <sjg@chromium.org>
2022-09-30dm: core: Allow obtaining a node offset in the same treeSimon Glass1-9/+10
In some cases we want to obtain an ofnode in the same tree as a different ofnode, such as when looking up a subnode. At present this is trivial, since there is only one tree. When there are multiple trees, this implementation will change. Also move the ofnode_to_offset() function up higher in the header file, since we will need to provide a different implementation with multiple trees. Signed-off-by: Simon Glass <sjg@chromium.org>
2022-09-30dm: core: Add a way to look up a phandle in an oftreeSimon Glass1-0/+14
When we have multiple trees, the ofnode logic needs to be told which one to use. Create a new function which takes an oftree argument, along with a helper to obtain the FDT pointer from an oftree. Signed-off-by: Simon Glass <sjg@chromium.org>
2022-09-30dm: core: Add an ofnode function to obtain the flat treeSimon Glass1-41/+50
The flat device tree is assumed to be the control FDT but this is not always the case. Update the ofnode implementation to obtain the node via an function call so we can eventually add support for selecting different trees. Signed-off-by: Simon Glass <sjg@chromium.org>
2022-09-30dm: core: Expand integer-reading testsSimon Glass2-7/+15
The current tests do not cover all the behaviour. Add some more. Tidy up a few inconsistencies between livetree and flattree which come to light with these tests. Also drop the -ENODATA error since it is never actually returned. Signed-off-by: Simon Glass <sjg@chromium.org>
2022-09-29dm: core: Drop ofnode_is_available()Simon Glass1-9/+0
This function is also available as ofnode_is_enabled(), so use that instead. Signed-off-by: Simon Glass <sjg@chromium.org>
2022-09-29dm: core: Avoid creating a name property when unflatteningSimon Glass1-1/+1
The current implementation creates a 'name' value for every node. This is not needed for the latest device tree format, which includes a name in the node header. Adjust the code to point the name at the node header instead. Also simplify ofnode_get_name(), now that we can rely on it to set the name correctly. Update the comment to make it clear what name the root node has. Signed-off-by: Simon Glass <sjg@chromium.org>
2022-09-29dm: core: Rename ofnode_get_property_by_prop()Simon Glass2-3/+3
The current name is quite unwieldy. Change it to use an ofprop_ prefix and shorten it. Fix the return-value comment while we are here. Signed-off-by: Simon Glass <sjg@chromium.org>
2022-09-29dm: core: Rename ofnode_get_first/next_property()Simon Glass2-4/+4
Drop the 'get' in these names since it does not fit with the rest of the API. Signed-off-by: Simon Glass <sjg@chromium.org>
2022-09-29dm: core: Reduce code size with dev_of_offset()Simon Glass1-9/+9
Update the function to mark it with the const attribute. Also avoid calling it multiple times in the devfdt_get_addr_index() function. Signed-off-by: Simon Glass <sjg@chromium.org>
2022-09-29dm: core: Drop the const from ofnodeSimon Glass1-2/+2
Now that we support writing to ofnodes, the const is not accurate. Drop it to avoid undesirable casting. Also drop the ofnode_to_npw() which is now the same as ofnode_to_np(). Signed-off-by: Simon Glass <sjg@chromium.org>
2022-09-29dm: core: Support writing a property to an empty nodeSimon Glass1-4/+4
At present this does not work with livetree. Fix it and add a test. Signed-off-by: Simon Glass <sjg@chromium.org>
2022-09-29dm: core: Allow adding ofnode subnodesSimon Glass2-0/+98
Add this feature to the ofnode interface, supporting both livetree and flattree. If the node exists it is returned, along with a -EEXIST error. Update the functions it calls to handle this too. Signed-off-by: Simon Glass <sjg@chromium.org>
2022-09-29dm: core: Pass a root node to of_find_node_by_phandle()Simon Glass2-4/+5
This function currently assumes that the control FDT is used. Update it to allow a root node to be passed, so it can work with any tree. Also add a comment to ofnode_get_by_phandle() so that its purpose is clear. Signed-off-by: Simon Glass <sjg@chromium.org>
2022-09-14dm: core: Add functions to read 8/16-bit integersStefan Herbrechtsmeier3-0/+121
Add functions to read 8/16-bit integers like the existing functions for 32/64-bit to simplify read of 8/16-bit integers from device tree properties. Signed-off-by: Stefan Herbrechtsmeier <stefan.herbrechtsmeier@weidmueller.com> Reviewed-by: Marek Vasut <marex@denx.de> Reviewed-by: Simon Glass <sjg@chromium.org> Reviewed-by: Simon Glass <sjg@chromium.org>
2022-08-12dm: core: Add support for writing u32 with ofnodeSimon Glass1-0/+15
Add a new function to write an integer to an ofnode (live tree or flat tree). Signed-off-by: Simon Glass <sjg@chromium.org>
2022-08-12dm: core: Allow writing to a flat tree with ofnodeSimon Glass2-46/+48
In generally it is not permitted to implement an ofnode function only for flat tree or live tree. Both must be supported. Also the code for live tree access should be in of_access.c rather than ofnode.c which is really just for holding the API-conversion code. Update ofnode_write_prop() accordingly and fix the test so it can work with flat tree too. Signed-off-by: Simon Glass <sjg@chromium.org>
2022-08-12dm: core: Swap parameters of ofnode_write_prop()Simon Glass1-3/+3
It is normal for the length to come after the value in libfdt. Follow this same convention with ofnode. Signed-off-by: Simon Glass <sjg@chromium.org>
2022-08-12dm: core: Introduce support for multiple treesSimon Glass2-4/+21
At present ofnode only works with a single device tree, for the most part. This is the control FDT used by U-Boot. When booting an OS we may obtain a different device tree and want to modify it. Add some initial support for this into the ofnode API. Note that we don't permit aliases in this other device tree, since the of_access implementation maintains a list of aliases collected at start-up. Also, we don't need aliases to do fixups in the other FDT. So make sure that flat tree and live tree processing are consistent in this area. Signed-off-by: Simon Glass <sjg@chromium.org>
2022-08-10common: Drop display_options.h from common headerSimon Glass1-0/+1
Move this out of the common header and include it only where needed. Signed-off-by: Simon Glass <sjg@chromium.org>
2022-07-26dm: fix mis-word in SPL_DM descriptionOleksandr Suvorov1-1/+1
Replace logically correct word in the description. Fixes: 91a91ff804d ("dm: Add Kconfig options for driver model SPL support") Signed-off-by: Oleksandr Suvorov <oleksandr.suvorov@foundries.io> Reviewed-by: Simon Glass <sjg@chromium.org>
2022-07-26dm: fix logic of lists_bind_fdt()Heinrich Schuchardt1-2/+6
If parameter drv of lists_bind_fdt() is specified, we shall bind only to this very driver and to no other. If the driver drv has an of_match property, we shall only bind to the driver if it matches the compatible string of the device. Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2022-07-26dm: avoid NULL dereference in lists_bind_fdt()Heinrich Schuchardt1-3/+4
If parameter drv of lists_bind_fdt() is specified, we want to bind to this specific driver even if its field of_match is NULL. If entry->of_match is NULL, we should not dereference it in a debug statement. Fixes: d3e773613b6d ("dm: core: Use U-Boot logging instead of pr_debug()") Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2022-07-26dm: avoid NULL dereference in add_item()Heinrich Schuchardt1-2/+2
acpi_add_other_item() passes dev = NULL. Instead of dev->name write the string "other" to the debug log: ACPI: Writing ACPI tables at 1fd3000 0base: writing table '<NULL>' * other: Added type 3, 0000000011fd4000, size 240 1facs: writing table 'FACS' * other: Added type 3, 0000000011fd4240, size 40 5csrt: writing table 'CSRT' * other: Added type 3, 0000000011fd4280, size 30 Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2022-07-08Merge tag 'dm-pull-28jun22' of ↵Tom Rini7-21/+257
https://source.denx.de/u-boot/custodians/u-boot-dm into next nman external-symbol improvements Driver model memory-usage reporting patman test-reporting improvements Add bloblist design goals
2022-06-29tpl: Ensure all TPL symbols in Kconfig have some TPL dependencyTom Rini1-1/+1
Tighten up symbol dependencies in a number of places. Ensure that a TPL specific option has at least a direct dependency on TPL. In places where it's clear that we depend on something more specific, use that dependency instead. Reported-by: Pali Rohár <pali@kernel.org> Signed-off-by: Tom Rini <trini@konsulko.com>
2022-06-28dm: spl: Allow SPL to show memory usageSimon Glass1-0/+10
Add an option to tell SPL to show memory usage for driver model just before it boots into the next phase. Signed-off-by: Simon Glass <sjg@chromium.org>
2022-06-28dm: core: Add a command to show driver model statisticsSimon Glass3-0/+102
This command shows the memory used by driver model along with various hints as to what it might be if some 'core' tags were moved to use the tag list instead of a core (i.e. always-there) pointer. This may help with future work to reduce memory usage. Signed-off-by: Simon Glass <sjg@chromium.org>
2022-06-28dm: core: Add a way to collect memory usageSimon Glass2-0/+64
Add a function for collecting the amount of memory used by driver model, including devices, uclasses and attached data and tags. This information can provide insights into how to reduce the memory required by driver model. Future work may look at execution speed also. Signed-off-by: Simon Glass <sjg@chromium.org>
2022-06-28dm: core: Support accessing core tagsSimon Glass1-0/+65
At present tag numbers are only allocated for non-core data, meaning that the 'core' data, like priv and plat, are accessed through dedicated functions. For debugging and consistency it is convenient to use tags for this 'core' data too. Add support for this, with new tag numbers and functions to access the pointer and size for each. Update one of the test drivers so that the uclass-private data can be tested here. There is some code duplication with functions like device_alloc_priv() but this is not addressed for now. At some point, some rationalisation may help to reduce code size, but more thought it needed on that. Signed-off-by: Simon Glass <sjg@chromium.org>
2022-06-28dm: core: Fix addresses in the dm static commandSimon Glass1-4/+2
This command converts pointers to addresses, but the pointers being converted are in the image's rodata region. For sandbox this means it is not in DRAM so it does not make sense to do this conversion. Fix this by showing a simple pointer instead. Drop the unnecessary @ and hex prefixes. Signed-off-by: Simon Glass <sjg@chromium.org>
2022-06-28dm: core: Rename dm_dump_all()Simon Glass1-1/+1
This is not a good name anymore as it does not dump everything. Rename it to dm_dump_tree() to avoid confusion. Signed-off-by: Simon Glass <sjg@chromium.org>
2022-06-28dm: fix formatting of uclass dumpHeinrich Schuchardt1-2/+0
Insert an empty line after each uclass independent of whether it has devices or not. Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
2022-06-28dm: core: Use device_foreach_child where possibleSean Anderson4-15/+14
We have some nice macros for iterating over devices in device.h, but they are not used by the driver core. Convert all the users I could find. Signed-off-by: Sean Anderson <seanga2@gmail.com>
2022-06-27Merge tag 'xilinx-for-v2022.10' of ↵Tom Rini1-5/+0
https://source.denx.de/u-boot/custodians/u-boot-microblaze into next Xilinx changes for v2022.10 cpu: - Add driver for microblaze cpu net: - Add support for DM_ETH_PHY to AXI emac and emaclite xilinx: - Switch platforms to DM_ETH_PHY - DT chagnes in ZynqMP and Zynq - Enable support for SquashFS zynqmp: - Add support for KR260 boards - Move BSS from address 0 - Move platform identification from board code to soc driver - Improve zynqmp_psu_init_minimize versal: - Enable loading app at EL1 serial: - Setup default address and clock rates for DEBUG uarts pinctrl: - Add support for tri state and output enable properties relocate-rela: - Clean relocate-rela implementation for ARM64 - Add support for Microblaze microblaze: - Add support for runtime relocation - Rework cache handling (wiring, Kconfig) based on cpuinfo - Remove interrupt support timer: - Extract axi timer driver from Microblaze to generic location