aboutsummaryrefslogtreecommitdiffstats
path: root/lib/fdtdec.c
Commit message (Collapse)AuthorAgeFilesLines
* Merge patch series "Keep the access to dtb_dt_embedded() within fdtdec"Tom Rini2024-12-311-2/+24
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | Evgeny Bachinin <EABachinin@salutedevices.com> says: The 1st patch addresses comments from the post-review, available by link [1]. The 2nd patch fixes problems of dtb_dt_embedded() with checkpatch. Links: [1] https://lore.kernel.org/u-boot/CAFLszTgEKamsa6FTnjzrEWQBLkqAR7EBbZqffx09AKgQ7ppuVA@mail.gmail.com/#t Link: https://lore.kernel.org/r/20241211-dtb_dt_embedded_within_fdtdec-v1-0-7840469f0084@salutedevices.com
| * fdtdec: dtb_dt_embedded: replace ifdefs by IS_ENABLED()Evgeny Bachinin2024-12-311-9/+9
| | | | | | | | | | | | | | | | | | | | | | | | Patch fixes the checkpatch warnings like: ``` WARNING: Use 'if (IS_ENABLED(CONFIG...))' instead of '#if or #ifdef' #94: FILE: lib/fdtdec.c:102: +#ifdef CONFIG_OF_EMBED ``` Signed-off-by: Evgeny Bachinin <EABachinin@salutedevices.com> Reviewed-by: Simon Glass <sjg@chromium.org>
| * fdtdec: encapsulate dtb_dt_embedded() withinEvgeny Bachinin2024-12-311-2/+24
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Patch keeps the access to dtb_dt_embedded() within fdtdec API, by means of new API function introduction. This new function is a common place for updating appropriate global_data fields for OF_EMBED case. Also, the consequence of the patch is movement of '___dtb_dt_*begin' symbols' declaration from header file, because nobody used symbols outside the lib/fdtdec.c. Signed-off-by: Evgeny Bachinin <EABachinin@salutedevices.com> Suggested-by: Simon Glass <sjg@chromium.org> Reviewed-by: Simon Glass <sjg@chromium.org>
* | fdt: Swap the signature for board_fdt_blob_setup()Simon Glass2024-12-181-4/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This returns a devicetree and updates a parameter with an error code. Swap it, since this fits better with the way U-Boot normally works. It also (more easily) allows leaving the existing pointer unchanged. No yaks were harmed in this change, but there is a very small code-size reduction. For sifive, the OF_BOARD option must be set for the function to be called, so there is no point in checking it again. Also OF_SEPARATE is defined always. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Matthias Brugger <mbrugger@suse.com> Reviewed-by: Patrice Chotard <patrice.chotard@foss.st.com> [trini: Update total_compute] Signed-off-by: Tom Rini <trini@konsulko.com>
* | fdt: Correct condition for receiving bloblistSimon Glass2024-12-181-1/+1
|/ | | | | | | | The condition for receiving a bloblist from TPL is reversed. This was only noticed are the other fixes landed. Fix it. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Matthias Brugger <mbrugger@suse.com>
* lib: fdtdec: Parse the gzip/lzo headers only when dependencies have metLad Prabhakar2024-10-171-2/+2
| | | | | | | | | | | It might happen that CONFIG_GZIP and CONFIG_LZO are enabled but we might have CONFIG_MULTI_DTB_FIT_LZO enabled in this case in the code path of uncompress_blob() we parse the gzip headers first which results in `Error: Bad gzipped data` being printed. To avoid this parse the gzip/lzo headers only when dependencies have met. Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com> Reviewed-by: Tom Rini <trini@konsulko.com>
* Merge patch series "Tidy up use of 'SPL' and CONFIG_SPL_BUILD"WIP/11Oct2024Tom Rini2024-10-111-4/+4
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Simon Glass <sjg@chromium.org> says: When the SPL build-phase was first created it was designed to solve a particular problem (the need to init SDRAM so that U-Boot proper could be loaded). It has since expanded to become an important part of U-Boot, with three phases now present: TPL, VPL and SPL Due to this history, the term 'SPL' is used to mean both a particular phase (the one before U-Boot proper) and all the non-proper phases. This has become confusing. For a similar reason CONFIG_SPL_BUILD is set to 'y' for all 'SPL' phases, not just SPL. So code which can only be compiled for actual SPL, for example, must use something like this: #if defined(CONFIG_SPL_BUILD) && !defined(CONFIG_TPL_BUILD) In Makefiles we have similar issues. SPL_ has been used as a variable which expands to either SPL_ or nothing, to chose between options like CONFIG_BLK and CONFIG_SPL_BLK. When TPL appeared, a new SPL_TPL variable was created which expanded to 'SPL_', 'TPL_' or nothing. Later it was updated to support 'VPL_' as well. This series starts a change in terminology and usage to resolve the above issues: - The word 'xPL' is used instead of 'SPL' to mean a non-proper build - A new CONFIG_XPL_BUILD define indicates that the current build is an 'xPL' build - The existing CONFIG_SPL_BUILD is changed to mean SPL; it is not now defined for TPL and VPL phases - The existing SPL_ Makefile variable is renamed to SPL_ - The existing SPL_TPL Makefile variable is renamed to PHASE_ It should be noted that xpl_phase() can generally be used instead of the above CONFIGs without a code-space or run-time penalty. This series does not attempt to convert all of U-Boot to use this new terminology but it makes a start. In particular, renaming spl.h and common/spl seems like a bridge too far at this point. The series is fully bisectable. It has also been checked to ensure there are no code-size changes on any commit.
| * global: Use CONFIG_XPL_BUILD instead of CONFIG_SPL_BUILDSimon Glass2024-10-111-2/+2
| | | | | | | | | | | | | | | | | | Complete this rename for all directories outside arch/ board/ drivers/ and include/ Use the new symbol to refer to any 'SPL' build, including TPL and VPL Signed-off-by: Simon Glass <sjg@chromium.org>
| * xpl: Rename spl_next_phase() and spl_prev_phase()Simon Glass2024-10-111-1/+1
| | | | | | | | | | | | Rename this to use the xpl prefix. Signed-off-by: Simon Glass <sjg@chromium.org>
| * xpl: Rename spl_phase() to xpl_phase()Simon Glass2024-10-111-1/+1
| | | | | | | | | | | | Rename this function to indicate that it refers to any xPL phase. Signed-off-by: Simon Glass <sjg@chromium.org>
* | fdtdec: Support separate BSS for all XPL buildsSimon Glass2024-10-031-1/+1
|/ | | | | | | Adjust the condition so that separate BSS can be deselected for TPL and VPL. Signed-off-by: Simon Glass <sjg@chromium.org>
* fdt: Don't overwrite bloblist devicetreeSimon Glass2024-08-091-0/+1
| | | | | | | | | | | When the devicetree comes from a bloblist, it is currently overwritten by the appended one, if present. It should be preserved. Adjust the logic to support this. Fixes: 70fe2385943 ("fdt: Allow the devicetree to come from a bloblist") Signed-off-by: Simon Glass <sjg@chromium.org>
* fdt: Correct condition for bloblist existingSimon Glass2024-08-051-2/+10
| | | | | | | | | | | | | | On some boards, the bloblist is created in SPL once SDRAM is ready. It cannot be accessed until that point, so is not available early in SPL. Add a condition to avoid a hang in this case. This fixes a hang in chromebook_coral Fixes: 70fe2385943 ("fdt: Allow the devicetree to come from a bloblist") Signed-off-by: Simon Glass <sjg@chromium.org> Acked-by: Raymond Mao <raymond.mao@linaro.org>
* lib: Remove duplicate newlinesMarek Vasut2024-07-151-1/+0
| | | | | | Drop all duplicate newlines. No functional change. Signed-off-by: Marek Vasut <marek.vasut+renesas@mailbox.org>
* fdt: Allow the devicetree to come from a bloblistSimon Glass2024-01-071-10/+34
| | | | | | | | | | | | Standard passage provides for a bloblist to be passed from one firmware phase to the next. That can be used to pass the devicetree along as well. Add an option to support this. Tests for this will be added as part of the Universal Payload work. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Tom Rini <trini@konsulko.com> Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
* lib: Remove <common.h> inclusion from these filesWIP/2023-12-21-header-inclusion-cleanupTom Rini2023-12-211-1/+0
| | | | | | | | | | After some header file cleanups to add missing include files, remove common.h from all files in the lib directory. This primarily means just dropping the line but in a few cases we need to add in other header files now. Reviewed-by: Simon Glass <sjg@chromium.org> Signed-off-by: Tom Rini <trini@konsulko.com>
* treewide: unify the linker symbol reference formatShiji Yang2023-08-091-3/+3
| | | | | | | | | | | Now all linker symbols are declared as type char[]. Though we can reference the address via both the array name 'var' and its address '&var'. It's better to unify them to avoid confusing developers. This patch converts all '&var' linker symbol refrences to the most commonly used format 'var'. Signed-off-by: Shiji Yang <yangshiji66@outlook.com> Reviewed-by: Tom Rini <trini@konsulko.com>
* Merge branch 'master' of https://source.denx.de/u-boot/custodians/u-boot-sunxiWIP/30Apr2023Tom Rini2023-04-301-1/+0
|\ | | | | | | | | | | | | | | | | | | | | | | | | Please pull the second part of the sunxi pull request for this cycle. Another bunch of patches that replace old-school U-Boot hacks with proper DM based code, this time for the raw NAND flash driver, and the USB PHY VBUS detection code. Plus two smaller patches that were sitting in my inbox for a while. Gitlab CI passed. In lack of some supported board with NAND flash I couldn't really test this part, but apparently this was tested by the reviewer. I briefly ran the branch on some boards with USB-OTG, and this still worked.
| * mtd: nand: sunxi: Convert from fdtdec to ofnodeSamuel Holland2023-04-281-1/+0
| | | | | | | | | | | | | | | | | | | | | | | | As a first step toward converting this driver to the driver model, use the ofnode abstraction to replace direct references to the FDT blob. Using ofnode_read_u32_index removes an extra pair of loops and makes the allwinner,rb property optional, matching the devicetree binding. Signed-off-by: Samuel Holland <samuel@sholland.org> Acked-by: Andre Przywara <andre.przywara@arm.com> Signed-off-by: Andre Przywara <andre.przywara@arm.com>
* | fdt: Indicate that people should use the ofnode APISimon Glass2023-04-281-0/+3
|/ | | | | | Add a note to the comment at the top of this file. Signed-off-by: Simon Glass <sjg@chromium.org>
* Revert "fdtdec: drop needlessly convoluted CONFIG_PHANDLE_CHECK_SEQ"Simon Glass2023-01-181-2/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | The fdt_path_offset() function is slow since it must scan the tree. This substantial overhead now applies to all boards. The original code may not be ideal but it is fit for purpose and is only needed on a few boards. Reverting this reduces time to set up driver model by about 30ms. Before revert: Accumulated time: 47,170 dm_r 53,237 dm_spl 572,986 dm_f Accumulated time: 44,598 dm_r 50,347 dm_spl 549,133 dm_f This reverts commit 26f981f295d00351b6f0c69b5317b254b2361cc0. Signed-off-by: Simon Glass <sjg@chromium.org>
* fdt: Check for overlapping data and FDTSimon Glass2023-01-181-0/+23
| | | | | | | | If the FDT overlaps with the data region of the image, or with the stack, it can become corrupted before relocation. Add a check for this, behind a debug flag, as it can be very confusing and time-consuming to debug. Signed-off-by: Simon Glass <sjg@chromium.org>
* fdt: Pass the device tree to fdtdec_prepare_fdt()Simon Glass2023-01-181-11/+11
| | | | | | | This function uses gd->fdt_blob a lot and cannot be used to check any other device tree. Use a parameter instead. Signed-off-by: Simon Glass <sjg@chromium.org>
* fdt: Drop ifdefs in fdtdec_prepare_fdt()Simon Glass2023-01-181-15/+17
| | | | | | | | | This function is a bit messy with several #ifdefs. Convert them to use C for the conditions. Rewrite the function comment since most of it is stale. Signed-off-by: Simon Glass <sjg@chromium.org>
* fdt: Avoid exporting fdtdec_prepare_fdt()Simon Glass2023-01-181-13/+13
| | | | | | This function is not used outside this file. Make it static. Signed-off-by: Simon Glass <sjg@chromium.org>
* dm: core: Provide a way to reset the device treeSimon Glass2022-09-291-1/+4
| | | | | | | | | | At present there is only one device tree used by the ofnode functions, except for some esoteric use of live tree. In preparation for supporting more than one, add a way to reset the list of device trees. For now this does nothing. Signed-off-by: Simon Glass <sjg@chromium.org>
* dm: core: Drop ofnode_is_available()Simon Glass2022-09-291-1/+1
| | | | | | | This function is also available as ofnode_is_enabled(), so use that instead. Signed-off-by: Simon Glass <sjg@chromium.org>
* common: Drop display_options.h from common headerSimon Glass2022-08-101-0/+1
| | | | | | Move this out of the common header and include it only where needed. Signed-off-by: Simon Glass <sjg@chromium.org>
* fdtdec: drop needlessly convoluted CONFIG_PHANDLE_CHECK_SEQRasmus Villemoes2022-06-061-5/+2
| | | | | | | | | | | | | | | | | | | | | | Asking if the alias we found actually points at the device tree node we passed in (in the guise of its offset from blob) can be done simply by asking if the fdt_path_offset() of the alias' path is identical to offset. In fact, the current method suffers from the possibility of false negatives: dtc does not necessarily emit a phandle property for a node just because it is referenced in /aliases; it only emits a phandle property for a node if it is referenced in <angle brackets> somewhere. So if both the node we passed in and the alias node we're considering don't have phandles, fdt_get_phandle() returns 0 for both. Since the proper check is so simple, there's no reason to hide that behind a config option (and if one really wanted that, it should be called something else because there's no need to involve phandle in the check). Signed-off-by: Rasmus Villemoes <rasmus.villemoes@prevas.dk> Acked-by: Aswath Govindraju <a-govindraju@ti.com>
* nds32: Remove the architectureWIP/25Apr2022Tom Rini2022-04-251-7/+0
| | | | | | | | | As removal of nds32 has been ack'd for the Linux kernel, remove support here as well. Cc: Rick Chen <rick@andestech.com> Signed-off-by: Tom Rini <trini@konsulko.com> Reviewed-by: Rick Chen <rick@andestech.com>
* fdt: Fix TPL SEPARATE_BSS check when locating DTBAndrew Abbott2022-04-221-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Commit 690af71850149bf242502f688eca80fb302d1f76 changed this condition from an explicit IS_ENABLED(CONFIG_SPL_SEPARATE_BSS) to CONFIG_IS_ENABLED(SEPARATE_BSS) The documentation for CONFIG_IS_ENABLED() in include/linux/kconfig.h implies that we will get the correct behaviour, but the actual behaviour differs such that this condition is now always false. This stopped TPL being able to load the device tree blob at least on the ROCKPro64 board (RK3399 SoC), since the wrong device tree location was chosen. The issues causing this behaviour with CONFIG_IS_ENABLED() are: 1. The documentation implies that CONFIG_SPL_BUILD => CONFIG_SPL_<option> is considered before the TPL equivalent. Actually, the TPL options have higher priority - see definition of _CONFIG_PREFIX. 2. The documentation implies a fallthrough, eg. if CONFIG_SPL_BUILD is defined but the CONFIG_SPL_<option> is not, then it will proceed to check if CONFIG_TPL_BUILD Actually, if CONFIG_TPL_BUILD is defined, then it stops there and CONFIG_SPL_BUILD is not considered - see definition of _CONFIG_PREFIX. During TPL build, at least for the ROCKPro64, both CONFIG_TPL_BUILD and CONFIG_SPL_BUILD are defined, but because of the above, only TPL options are considered. Since there is no CONFIG_TPL_SEPARATE_BSS, this fails. Fixes: 690af71850 ("fdt: Correct condition for SEPARATE_BSS") Signed-off-by: Andrew Abbott <andrew@mirx.dev>
* fdt: sandbox: Avoid looking for an appended device treeSimon Glass2022-04-061-0/+3
| | | | | | | We don't use an appended tree for sandbox and the required symbols are not present. Add a condition to avoid a build error. Signed-off-by: Simon Glass <sjg@chromium.org>
* fdt: Correct condition for SEPARATE_BSSSimon Glass2022-04-061-1/+1
| | | | | | This may have different settings for SPL and TPL. Correct the condition. Signed-off-by: Simon Glass <sjg@chromium.org>
* doc: replace @return by Return:Heinrich Schuchardt2022-01-191-2/+2
| | | | | | | | | | | | Sphinx expects Return: and not @return to indicate a return value. find . -name '*.c' -exec \ sed -i 's/^\(\s\)\*\(\s*\)@return\(\s\)/\1*\2Return:\3/' {} \; find . -name '*.h' -exec \ sed -i 's/^\(\s\)\*\(\s*\)@return\(\s\)/\1*\2Return:\3/' {} \; Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
* fdt: Add a Kconfig for boards with a prior stageSimon Glass2021-12-231-0/+1
| | | | | | | | | | | | | | | | | | | | When U-Boot is started from another firmware program, not just a prior phase of U-Boot, special behaviour is typically used. In particular, the device tree may come from that prior stage. At present this is sort-of indicated by OF_BOARD, although the correlation is not 1:1, since that option simply means that the board has a custom mechanism for obtaining the device tree. For example, sandbox defines OF_BOARD. Also the board_fdt_blob_setup() function can in fact make use of the devicetree in U-Boot if it wishes, as used by dragonboard410c until very recently. Add an explicit Kconfig for this situation. Update the OF_BOARD option to more-accurately reflect what it is doing, e.g. for sandbox. Drop the docs in the README as it is out of date. Signed-off-by: Simon Glass <sjg@chromium.org>
* fdt: Report the devicetree sourceSimon Glass2021-12-231-0/+13
| | | | | | | | | | | | | | | | | | | It can be confusing to figure out where the devicetree came from. It seems important enough to warrant a message during boot. Add information about the number of devices and uclasses too since it is helpful to have some idea what is going on with driver model. Report the devicetree source in bdinfo too. This looks something like this, with > marking the new line. U-Boot 2021.10-00190 (Oct 30 2021 - 09:01:29 -0600) DRAM: 128 MiB > Core: 42 devices, 11 uclasses, devicetree: passage Flash: 64 MiB Signed-off-by: Simon Glass <sjg@chromium.org>
* fdt: Record where the devicetree came fromSimon Glass2021-12-231-5/+15
| | | | | | Keep track of where the devicetree came from, so we can report this later. Signed-off-by: Simon Glass <sjg@chromium.org>
* fdt: Don't call board_fdt_blob_setup() without OF_BOARDSimon Glass2021-12-231-9/+12
| | | | | | | | | | | | | | At present this override function is called even when OF_BOARD is not enabled. This makes it impossible to disable this feature and in fact makes the OF_BOARD option useless. Reinstate its intended purpose, so that it is possible to switch between the appended devicetree and one provided by the board's custom function. A follower patch adds warnings for this scenario, but for now we don't have a Kconfig that definitively tells us that OF_BOARD should be used. Signed-off-by: Simon Glass <sjg@chromium.org>
* fdt: Drop remaining preprocessor macros in fdtdec_setup()Simon Glass2021-12-231-9/+11
| | | | | | | We only have two choices for obtaining the devicetree. Simplify the code to make that clear. Signed-off-by: Simon Glass <sjg@chromium.org>
* fdt: Drop OF_CONTROL check in fdtdec_setup()Simon Glass2021-12-231-5/+3
| | | | | | | | | | This function should only be called when OF_CONTROL is enabled. It fails in fdtdec_prepare_fdt() anyway, since gd->fdt_blob stays as NULL if OF_CONTROL is not enabled. Drop this useless check. Signed-off-by: Simon Glass <sjg@chromium.org>
* fdt: Use if() for fdtcontroladdr checkSimon Glass2021-12-231-5/+4
| | | | | | Change this to use if() instead of #if Signed-off-by: Simon Glass <sjg@chromium.org>
* fdt: Drop #ifdef around board_fdt_blob_setup()Simon Glass2021-12-231-2/+0
| | | | | | This serves no purpose. Drop it. Signed-off-by: Simon Glass <sjg@chromium.org>
* fdt: Drop CONFIG_SPL_BUILD check in fdtdec_setup()Simon Glass2021-12-231-5/+1
| | | | | | Move this to the header file to clean up the C code. Signed-off-by: Simon Glass <sjg@chromium.org>
* fdt: Drop #ifdefs with MULTI_DTB_FITSimon Glass2021-12-231-20/+11
| | | | | | Refactor the code to drop the #ifdefs for this feature. Signed-off-by: Simon Glass <sjg@chromium.org>
* fdt: Move MULTI_DTB_FIT handling out of fdtdec_setup()Simon Glass2021-12-231-24/+38
| | | | | | | | This logic is a bit convoluted for one function. Move the mulit-FIT part into its own function. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
* sandbox: Remove OF_HOSTFILEWIP/27Oct2021Ilias Apalodimas2021-10-271-7/+7
| | | | | | | | | | | | | | | OF_HOSTFILE is used on sandbox configs only. Although it's pretty unique and not causing any confusions, we are better of having simpler config options for the DTB. So let's replace that with the existing OF_BOARD. U-Boot would then have only three config options for the DTB origin. - OF_SEPARATE, build separately from U-Boot - OF_BOARD, board specific way of providing the DTB - OF_EMBED embedded in the u-boot binary(should not be used in production Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org> Reviewed-by: Simon Glass <sjg@chromium.org>
* treewide: Remove OF_PRIOR_STAGEWIP/bisect-testingIlias Apalodimas2021-10-181-2/+0
| | | | | | | | | The previous patches removed OF_PRIOR_STAGE from the last consumers of the Kconfig option. Cleanup any references to it in documentation, code and configuration options. Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org> Reviewed-by: Simon Glass <sjg@chromium.org>
* fdtdec: Support reserved-memory flagsThierry Reding2021-10-131-10/+18
| | | | | | | | | | | | | Reserved memory nodes can have additional flags. Support reading and writing these flags to ensure that reserved memory nodes can be properly parsed and emitted. This converts support for the existing "no-map" flag to avoid extending the argument list for fdtdec_add_reserved_memory() to excessive length. Signed-off-by: Thierry Reding <treding@nvidia.com> Reviewed-by: Simon Glass <sjg@chromium.org> Signed-off-by: Tom Warren <twarren@nvidia.com>
* fdtdec: Reorder fdtdec_set_carveout() parameters for consistencyThierry Reding2021-10-131-3/+3
| | | | | | | | | | The fdtdec_set_carveout() function's parameters are inconsistent with the parameters passed to fdtdec_add_reserved_memory(). Fix up the order to make it more consistent. Signed-off-by: Thierry Reding <treding@nvidia.com> Reviewed-by: Simon Glass <sjg@chromium.org> Signed-off-by: Tom Warren <twarren@nvidia.com>
* fdtdec: Support compatible string list for reserved memoryThierry Reding2021-10-131-2/+67
| | | | | | | | | | Reserved memory nodes can have a compatible string list to identify the type of reserved memory that they represent. Support specifying an optional compatible string list when creating these nodes. Signed-off-by: Thierry Reding <treding@nvidia.com> Reviewed-by: Simon Glass <sjg@chromium.org> Signed-off-by: Tom Warren <twarren@nvidia.com>