aboutsummaryrefslogtreecommitdiff
path: root/drivers/core
AgeCommit message (Collapse)Author
2024-07-26dm: core: scan reserved-memory nodesCaleb Connolly
Qualcomm platforms may have drivers that bind to reserved memory nodes (cmd-db [1] and smem [2]) which are relevant to U-Boot. Include /reserved-memory in dm_extended_scan() so that these will be handled correctly. [1]: https://www.kernel.org/doc/Documentation/devicetree/bindings/reserved-memory/qcom%2Ccmd-db.yaml [2]: https://www.kernel.org/doc/Documentation/devicetree/bindings/soc/qcom/qcom%2Csmem.yaml Reviewed-by: Simon Glass <sjg@chromium.org> Signed-off-by: Caleb Connolly <caleb.connolly@linaro.org>
2024-07-22drivers: core: Remove duplicate newlinesMarek Vasut
Drop all duplicate newlines. No functional change. Signed-off-by: Marek Vasut <marek.vasut+renesas@mailbox.org>
2024-07-04dm: core: Enhance comments on bind_drivers_pass()Simon Glass
This part of driver model is a little subtle, so add some more comments to promote better understanding. Signed-off-by: Simon Glass <sjg@chromium.org>
2024-07-03dm: core: fix typo in SPL_DM_WARN prompt textQuentin Schulz
It should read "in SPL" and not "wuth SPL". Signed-off-by: Quentin Schulz <quentin.schulz@cherry.de> Reviewed-by: Simon Glass <sjg@chromium.org>
2024-07-03dm: core: migrate debug() messages to use dm_warnQuentin Schulz
Prior to that, seeing the debug() messages required to enable DM_DEBUG which defines DEBUG (and then _DEBUG) which in turn makes failing assert() calls reset U-Boot which isn't necessarily what is desired. Instead, let's migrate to dm_warn which is using log_debug when unset or log_warn when set. While at it, reword the DM_DEBUG symbol in Kconfig to explain what it now actually does. Signed-off-by: Quentin Schulz <quentin.schulz@cherry.de> Reviewed-by: Simon Glass <sjg@chromium.org>
2024-07-03dm: core: fix signedness in debug messagesQuentin Schulz
outp always point to an unsigned type in ofnode_read_u* functions but the format specifier is currently always using signed type. This is an issue since the signed type can only contain half of the unsigned type values above 0. However, this now breaks another usecase. Indeed, ofnode_read_s32_default is actually passing an s32 but it'll be printed as a u32 instead. But since the function is called u32, it makes more sense to have it print an unsigned value. This was discovered because arm,smc-id = <0x82000010>; on RK3588S is above the max signed value and therefore would return a negative signed decimal value instead of its proper unsigned one. Fixes: fa12dfa08a7b ("dm: core: support reading a single indexed u64 value") Fixes: 4bb7075c830c ("dm: core: support reading a single indexed u32 value") Fixes: 7e5196c409f1 ("dm: core: Add ofnode function to read a 64-bit int") Fixes: 9e51204527dc ("dm: core: Add operations on device tree references") Signed-off-by: Quentin Schulz <quentin.schulz@cherry.de> Reviewed-by: Simon Glass <sjg@chromium.org>
2024-07-03dm: core: fix misleading debug message when matching compatibleQuentin Schulz
A driver can have multiple compatible. When the id->compatible matches for that driver, the first compatible supported by the driver is currently returned, which gives the following confusing message: - found match at 'rk3588_syscon': 'rockchip,rk3588-sys-grf' matches 'rockchip,rk3588-pmugrf' Considering that the compatible passed in argument is necessarily the one that exactly matched to enter this code path, there's no need to do some elaborate logic, just print the driver name and the compatible passed in argument. Fixes: d3e773613b6d ("dm: core: Use U-Boot logging instead of pr_debug()") Signed-off-by: Quentin Schulz <quentin.schulz@cherry.de> Reviewed-by: Simon Glass <sjg@chromium.org>
2024-06-24Merge tag 'v2024.07-rc5' into nextTom Rini
Prepare v2024.07-rc5
2024-06-13dm: typo prbingHeinrich Schuchardt
%s/prbing/probing/ Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com> Reviewed-by: Quentin Schulz <quentin.schulz@cherry.de> Reviewed-by: Igor Opaniuk <igor.opaniuk@gmail.com>
2024-05-20Restore patch series "arm: dts: am62-beagleplay: Fix Beagleplay Ethernet"Tom Rini
As part of bringing the master branch back in to next, we need to allow for all of these changes to exist here. Reported-by: Jonas Karlman <jonas@kwiboo.se> Signed-off-by: Tom Rini <trini@konsulko.com>
2024-05-19Revert "Merge patch series "arm: dts: am62-beagleplay: Fix Beagleplay Ethernet""Tom Rini
When bringing in the series 'arm: dts: am62-beagleplay: Fix Beagleplay Ethernet"' I failed to notice that b4 noticed it was based on next and so took that as the base commit and merged that part of next to master. This reverts commit c8ffd1356d42223cbb8c86280a083cc3c93e6426, reversing changes made to 2ee6f3a5f7550de3599faef9704e166e5dcace35. Reported-by: Jonas Karlman <jonas@kwiboo.se> Signed-off-by: Tom Rini <trini@konsulko.com>
2024-05-07core: Remove <common.h> and add needed includesTom Rini
Remove <common.h> from this driver directory and when needed add missing include files directly. Signed-off-by: Tom Rini <trini@konsulko.com>
2024-03-04dm: core: Fix address translation in devfdt_get_addr_index()Jonas Karlman
During address translation #address/size-cells props are expected to apply to child nodes. However, devfdt_get_addr_index() incorrectly use the parent offset of the udevice parent instead of getting the offset of the node parent. This will work in most cases when there is only one udevice tied to a node. On e.g. an Orange Pi R1 Plus TLS board the dwc3-generic (parent) and dwc3-generic-host (child) udevice is tied to the same node. In that case both the offset and parent values end up being the same. As a result, the #address/size-cells props intended for child nodes incorrectly gets applied to the node itself resulting in wrong addr being returned, 0x0 instead of 0xff600000. The following can be seen on console: dwc3-generic-host usb@ff600000: this is not a DesignWare USB3 DRD Core dwc3-generic-host usb@ff600000: failed to initialize core Fix this by using the offset of the parent node and not the offset to the node the parent udevice is tied to. Signed-off-by: Jonas Karlman <jonas@kwiboo.se>
2023-12-13fdt: Check for a valid fdt in oftree_ensure()Simon Glass
Check the header before starting to use it, since this could provide very confusing later, when ofnode calls start to fail. Signed-off-by: Simon Glass <sjg@chromium.org>
2023-11-20Merge tag 'v2024.01-rc3' into nextTom Rini
Prepare v2024.01-rc3
2023-11-16dm: core: Correct reference to DM_SPL in SPL_DM_STATSSimon Glass
This does not existing anymore. Update SPL_DM_STATS to use the correct Kconfig option, which is SPL_DM Signed-off-by: Simon Glass <sjg@chromium.org>
2023-11-14dm: Do not enable debug messages by defaultHeinrich Schuchardt
CONFIG_DM_WARN has a text indicating that these messages should only provided when debugging. This implies that the setting must be default no. We should still create debug messages. Reported-by: Andre Przywara <andre.przywara@arm.com> Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2023-11-07serial: zynqmp: Fetch baudrate from dtb and updateAlgapally Santosh Sagar
The baudrate configured in .config is taken by default by serial. If change of baudrate is required then the .config needs to changed and u-boot recompilation is required or the u-boot environment needs to be updated. To avoid this, support is added to fetch the baudrate directly from the device tree file and update. The serial, prints the log with the configured baudrate in the dtb. The commit c4df0f6f315c ("arm: mvebu: Espressobin: Set default value for $fdtfile env variable") is taken as reference for changing the default environment variable. The default environment stores the default baudrate value, When default baudrate and dtb baudrate are not same glitches are seen on the serial. So, the environment also needs to be updated with the dtb baudrate to avoid the glitches on the serial. Also add test to cover this new function. Signed-off-by: Algapally Santosh Sagar <santoshsagar.algapally@amd.com> Signed-off-by: Venkatesh Yadav Abbarapu <venkatesh.abbarapu@amd.com> Link: https://lore.kernel.org/r/20230921112043.3144726-3-venkatesh.abbarapu@amd.com Signed-off-by: Michal Simek <michal.simek@amd.com>
2023-10-17lib: acpi: Fix linking SPL when ACPIGEN is enabledSean Anderson
lib/acpi/acpigen.o is only compiled into SPL when SPL_ACPIGEN is enabled. Update several files which reference these functions accordingly. Signed-off-by: Sean Anderson <seanga2@gmail.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2023-10-17spl: Allow enabling SPL_OF_REAL and SPL_OF_PLATDATA at the same timeSean Anderson
Sandbox unit tests in U-Boot proper load a test device tree to have some devices to work with. In order to do the same in SPL, we must enable SPL_OF_REAL. However, we already have SPL_OF_PLATDATA enabled. When generating platdata from a devicetree, it is expected that we will not need devicetree access functions (even though SPL_OF_CONTROL is enabled). This expectation does not hold for sandbox, so allow user control of SPL_OF_REAL. There are several places in the tree where conditions involving OF_PLATDATA or OF_REAL no longer function correctly when both of these options can be selected at the same time. Adjust these conditions accordingly. Signed-off-by: Sean Anderson <seanga2@gmail.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2023-10-13core: introduce dev_read_addr_name[_size]_ptr() functionsMatthias Schiffer
Same as dev_read_addr_name[_size](), but returns a pointer, cast through map_sysmem(). Signed-off-by: Matthias Schiffer <matthias.schiffer@ew.tq-group.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2023-10-13core: return FDT_ADDR_T_NONE from devfdt_get_addr_[size_]name() on errorsMatthias Schiffer
Checking for the error cast to fdt_addr_t is rather awkward - IS_ERR() can be used, but it's not really made to be used on fdt_addr_t, which may not even be the same size as a native pointer. Most places in U-Boot only check for FDT_ADDR_T_NONE; let's adjust the error return to match the expectation. Signed-off-by: Matthias Schiffer <matthias.schiffer@ew.tq-group.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2023-10-06pci: serial: Support reading PCI-register size with baseSimon Glass
The PCI helpers read only the base address for a PCI region. In some cases the size is needed as well, e.g. to pass along to a driver which needs to know the size of its register area. Update the functions to allow the size to be returned. For serial, record the information and provided it with the serial_info() call. A limitation still exists in that the size is not available when OF_LIVE is enabled, so take account of that in the tests. Signed-off-by: Simon Glass <sjg@chromium.org>
2023-10-06dm: core: Support writing a 64-bit valueSimon Glass
Add support for writing a single 64-bit value into a property. Repurpose the existing tests to handle this case too. Signed-off-by: Simon Glass <sjg@chromium.org>
2023-10-06dm: core: Support writing a booleanSimon Glass
Add functions to write a boolean property. This involves deleting it if the value is false. Add a new ofnode_has_property() as well. Add a comment about the behaviour of of_read_property() when the property value is empty. Signed-off-by: Simon Glass <sjg@chromium.org>
2023-10-06dm: core: Add a way to convert a devicetree to a dtbSimon Glass
Add a way to flatten a devicetree into binary form. For livetree this involves generating the devicetree using fdt_property() and other calls. For flattree it simply involves providing the buffer containing the tree. Signed-off-by: Simon Glass <sjg@chromium.org>
2023-10-06dm: core: Add a way to delete a nodeSimon Glass
Add a function to delete a node in an existing tree. Signed-off-by: Simon Glass <sjg@chromium.org>
2023-10-06dm: core: Add a way to copy a nodeSimon Glass
Add a function to copy a node to another place under a new name. This is useful at least for testing, since copying a test node with existing properties is easier than writing the code to generate it all afresh. Signed-off-by: Simon Glass <sjg@chromium.org>
2023-10-06dm: core: Add a function to create an empty treeSimon Glass
Provide a function to create a new, empty tree. Signed-off-by: Simon Glass <sjg@chromium.org>
2023-10-06dm: core: Reverse the argument order in ofnode_copy_props()Simon Glass
Follow the order used by memcpy() as it may be less confusing. Signed-off-by: Simon Glass <sjg@chromium.org>
2023-10-06dm: core: Correct help in TPL_DM and VPL_DMSimon Glass
There are copying errors in the help. Fix these. Signed-off-by: Simon Glass <sjg@chromium.org>
2023-10-06spl: Use CONFIG_SPL... instead of CONFIG_..._SPL_...Simon Glass
We like to put the SPL first so it is clear that it relates to SPL. Rename various malloc-related options which have crept in, to stick to this convention. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Marcel Ziswiler <marcel.ziswiler@toradex.com> Reviewed-by: Martyn Welch <martyn.welch@collabora.com> Reviewed-by: Svyatoslav Ryhel <clamor95@gmail.com>
2023-10-04dm: core: Adjust dump-sorting to get stats only when neededSimon Glass
If we are not sorting the tree we don't need to get the stats. Adjust the code to avoid the wasted time. Signed-off-by: Simon Glass <sjg@chromium.org>
2023-09-24Merge tag 'dm-next-23sep23' of ↵Tom Rini
https://source.denx.de/u-boot/custodians/u-boot-dm into next buildman file-keeping and build-progress improvements dm tree enhancement adjust meaning of bootph-pre-ram/sram
2023-09-24common: Drop linux/printk.h from common headerSimon Glass
This old patch was marked as deferred. Bring it back to life, to continue towards the removal of common.h Move this out of the common header and include it only where needed. Signed-off-by: Simon Glass <sjg@chromium.org>
2023-09-23cmd: dm: allow for selecting uclass and deviceAKASHI Takahiro
The output from "dm tree" or "dm uclass" is a bit annoying if the number of devices available on the system is huge. (This is especially true on sandbox when I debug some DM code.) With this patch, we can specify the uclass name or the device name that we are interested in in order to limit the output. For instance, => dm uclass usb uclass 121: usb 0 usb@1 @ 0bcff8b0, seq 1 uclass 124: usb => dm tree usb:usb@1 Class Index Probed Driver Name ----------------------------------------------------------- usb 0 [ ] usb_sandbox usb@1 usb_hub 0 [ ] usb_hub `-- hub usb_emul 0 [ ] usb_sandbox_hub `-- hub-emul usb_emul 1 [ ] usb_sandbox_flash |-- flash-stick@0 usb_emul 2 [ ] usb_sandbox_flash |-- flash-stick@1 usb_emul 3 [ ] usb_sandbox_flash |-- flash-stick@2 usb_emul 4 [ ] usb_sandbox_keyb `-- keyb@3 If you want forward-matching against a uclass or udevice name, you can specify "-e" option. => dm uclass -e usb uclass 15: usb_emul 0 hub-emul @ 0bcffb00, seq 0 1 flash-stick@0 @ 0bcffc30, seq 1 2 flash-stick@1 @ 0bcffdc0, seq 2 3 flash-stick@2 @ 0bcfff50, seq 3 4 keyb@3 @ 0bd000e0, seq 4 uclass 64: usb_mass_storage uclass 121: usb 0 usb@1 @ 0bcff8b0, seq 1 uclass 122: usb_dev_generic uclass 123: usb_hub 0 hub @ 0bcff9b0, seq 0 uclass 124: usb => dm tree -e usb Class Index Probed Driver Name ----------------------------------------------------------- usb 0 [ ] usb_sandbox usb@1 usb_hub 0 [ ] usb_hub `-- hub usb_emul 0 [ ] usb_sandbox_hub `-- hub-emul usb_emul 1 [ ] usb_sandbox_flash |-- flash-stick@0 usb_emul 2 [ ] usb_sandbox_flash |-- flash-stick@1 usb_emul 3 [ ] usb_sandbox_flash |-- flash-stick@2 usb_emul 4 [ ] usb_sandbox_keyb `-- keyb@3 Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org> Reviewed-by: Simon Glass <sjg@chromium.org>
2023-09-23dm: core: Report bootph-pre-ram/sram node as pre-reloc after relocationJonas Karlman
Nodes with bootph-pre-sram/ram props are bound in multiple phases: 1. At TPL (bootph-pre-sram) or SPL (bootph-pre-ram) phase 2. At U-Boot proper pre-relocation phase 3. At U-Boot proper normal phase However the binding and U-Boot Driver Model documentation indicate that only nodes marked with bootph-all or bootph-some-ram should be bound in the U-Boot proper pre-relocation phase. Change ofnode_pre_reloc to report a node with bootph-pre-ram/sram prop with a pre-reloc status only after U-Boot proper pre-relocation phase. Also update the ofnode_pre_reloc documentation to closer reflect the binding and driver model documentation. This changes behavior of what nodes are bound in the U-Boot proper pre-relocation phase. Change to bootph-all or add bootph-some-ram prop to restore prior behavior. Signed-off-by: Jonas Karlman <jonas@kwiboo.se> Reviewed-by: Simon Glass <sjg@chromium.org>
2023-09-21dm: core: ofnode: Fix error message in ofnode_read_bootscript_address/flash()Michal Simek
Missing u-boot node shouldn't be visible in bootlog without debug enabled that's why change message from printf to debug. Signed-off-by: Michal Simek <michal.simek@amd.com> Link: https://lore.kernel.org/r/ff62e980237ab271cf05facfbc306e85914a8c6e.1694438999.git.michal.simek@amd.com
2023-09-21dm: core: ofnode: Add ofnode_read_bootscript_flash()Michal Simek
ofnode_read_bootscript_flash() reads bootscript address from /options/u-boot DT node. bootscr-flash-offset and bootscr-flash-size properties are read and values are filled. When bootscr-flash-size is not defined, bootscr-flash-offset property is unusable that's why cleaned. Both of these properties should be defined to function properly. Also add test to cover this new function. Reviewed-by: Simon Glass <sjg@chromium.org> Signed-off-by: Michal Simek <michal.simek@amd.com> Link: https://lore.kernel.org/r/08a3e6c09cce13287c69ad370e409e7f1766b406.1693465465.git.michal.simek@amd.com
2023-09-21dm: core: ofnode: Add ofnode_read_bootscript_address()Michal Simek
ofnode_read_bootscript_address() reads bootscript address from /options/u-boot DT node. bootscr-address or bootscr-ram-offset properties are read and values are filled. bootscr-address has higher priority than bootscr-ram-offset and the only one should be described in DT. Also add test to cover this new function. Reviewed-by: Simon Glass <sjg@chromium.org> Signed-off-by: Michal Simek <michal.simek@amd.com> Link: https://lore.kernel.org/r/23be3838502efef61803c90ef6e8b32bbd6ede41.1693465140.git.michal.simek@amd.com
2023-09-21dm: core: support reading a single indexed u64 valueMichal Simek
Add helper function to allow reading a single indexed u64 value from a device-tree property containing multiple u64 values, that is an array of u64's. Co-developed-by: Ashok Reddy Soma <ashok.reddy.soma@amd.com> Signed-off-by: Ashok Reddy Soma <ashok.reddy.soma@amd.com> Reviewed-by: Simon Glass <sjg@chromium.org> Signed-off-by: Michal Simek <michal.simek@amd.com> Link: https://lore.kernel.org/r/08043c8d204d0068f04c27de86afe78c75c50b69.1692956263.git.michal.simek@amd.com
2023-09-14dm: Remove unused NEEDS_MANUAL_RELOC code bitsMarek Vasut
The last user of the NEEDS_MANUAL_RELOC has been removed in commit 26af162ac8f8 ("arch: m68k: Implement relocation") Remove now unused NEEDS_MANUAL_RELOC code. Signed-off-by: Marek Vasut <marek.vasut+renesas@mailbox.org>
2023-09-04Merge tag 'v2023.10-rc4' into nextTom Rini
Prepare v2023.10-rc4
2023-08-25dm: core: Correct error handling when event failsSimon Glass
Follow the correct path in device_probe() when and event handler fails. This avoids getting into a strange state where the device appears to be activated but is not. Signed-off-by: Simon Glass <sjg@chromium.org>
2023-08-22dm: event: add EVT_DM_POST_INIT_R event typeChanho Park
This patch introduces EVT_DM_POST_INIT_R event type for handling hooks after relocation. Fixes: 55171aedda88 ("dm: Emit the arch_cpu_init_dm() even only before relocation") Suggested-by: Simon Glass <sjg@chromium.org> Cc: Bin Meng <bmeng.cn@gmail.com> Signed-off-by: Chanho Park <chanho61.park@samsung.com> Tested-by: Milan P. Stanić <mps@arvanta.net> Reviewed-by: Simon Glass <sjg@chromium.org> Tested-by: Roland Ruckerbauer <mail@ruabmbua.dev> Tested-by: Roland Ruckerbauer <mail@ruabmbua.dev> Fixed missing event name in event.c: Signed-off-by: Simon Glass <sjg@chromium.org>
2023-08-08fdt: off by one in ofnode_lookup_fdt()Dan Carpenter
The "oftree_count" is the number of entries which have been set in the oftree_list[] array. If all the entries have been initialized then this off by one would result in reading one element beyond the end of the array. Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org> Reviewed-by: Simon Glass <sjg@chromium.org>
2023-07-28core: read: add dev_read_addr_size_index_ptr functionJonas Karlman
Add dev_read_addr_size_index_ptr function with the same functionality as dev_read_addr_size_index, but instead a return pointer is given. Use map_sysmem() function as cast for the return. Signed-off-by: Jonas Karlman <jonas@kwiboo.se> Reviewed-by: Kever Yang <kever.yang@rock-chips.com>
2023-07-20core: read: fix dev_read_addr_size()John Keeping
The behaviour of dev_read_addr_size() is surprising as it does not handle #address-cells and #size-cells but instead hardcodes the values based on sizeof(fdt_addr_t). This is different from dev_read_addr_size_index() and dev_read_addr_size_name() both of which do read the cell sizes from the device tree. Since dev_read_addr_size() is only used by a single driver and this driver is broken when CONFIG_FDT_64BIT does not match the address size in the device tree, fix the function to behave like all of the other similarly named functions. Drop the property name argument as the only caller passes "reg" and this is the expected property name matching the other similarly named functions. Signed-off-by: John Keeping <john@metanate.com> Reviewed-by: Simon Glass <sjg@chromium.org> Tested-by: Simon Glass <sjg@chromium.org> # chromebook_jerry Tested-by: Simon Glass <sjg@chromium.org> # chromebook_bob
2023-07-20dm: core: of_access: fix return value in of_property_match_stringEugen Hristev
of_property_match_string calls of_find_property to search for the string property. If the device node does not exist, of_find_property returns NULL, and of_property_match_string returns -EINVAL, which is correct. However, if the device node exists, but the property is not found, of_find_property still returns NULL, but it will place -FDT_ERR_NOTFOUND in the *lenp variable. of_property_match_string does not use the lenp parameter, thus this error case is being lost, and treated as if the node is NULL, and returns -EINVAL, which is incorrect. The callers of of_property_match_string treat the error differently if the return value is -EINVAL or -ENOENT, e.g. in dwc3 driver: ret = generic_phy_get_by_name(dev, "usb3-phy", &phy); if (!ret) { ret = generic_phy_init(&phy); if (ret) return ret; } else if (ret != -ENOENT && ret != -ENODATA) { debug("could not get phy (err %d)\n", ret); return ret; } else { phy.dev = NULL; } So the caller drivers will just consider the property missing if -ENOENT is returned, versus the case of -EINVAL, which means something else. To fix this situation, changed the code to call the of_find_property with the right third argument to catch this error code and treat it accordingly. Signed-off-by: Eugen Hristev <eugen.hristev@collabora.com>
2023-07-14fdt: Allow more general use of livetreeSimon Glass
At present livetree can only be used for the control FDT. It is useful to be able to use the ofnode API for other FDTs, e.g. those used by the upcoming configuration editor. We already have most of the support present, and tests can be marked with the UT_TESTF_OTHER_FDT flag to use another FDT as a special case. But with this change, the functionality becomes more generally available. Plumb in the require support. Signed-off-by: Simon Glass <sjg@chromium.org>