aboutsummaryrefslogtreecommitdiff
path: root/common/spl
AgeCommit message (Collapse)AuthorFilesLines
2024-05-20Restore patch series "arm: dts: am62-beagleplay: Fix Beagleplay Ethernet"WIP/20May2024-nextTom Rini26-33/+4
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 Rini26-4/+33
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-06global: Make <asm/global_data.h> include <asm/u-boot.h>Tom Rini7-7/+0
This follows the example of RISC-V where <asm/global_data.h> includes <asm/u-boot.h> directly as "gd" includes a reference to bd_info already and so the first must include the second anyhow. We then remove <asm/u-boot.h> from all of the places which include references to "gd" an so have <asm/global_data.h> already. Signed-off-by: Tom Rini <trini@konsulko.com>
2024-05-06common: Remove <common.h> and add needed includesTom Rini26-26/+4
Remove <common.h> from all "commmon/" files and when needed add missing include files directly. Signed-off-by: Tom Rini <trini@konsulko.com>
2024-04-02Merge branch 'next'Tom Rini2-1/+9
Merge in all changes from the next branch now that the release is out.
2024-03-26spl: riscv: opensbi: fix check of PAYLOAD_ARGS_ADDRRandolph1-1/+1
When Falcon Mode is enabled on RISC-V, use CONFIG_VAL to check PAYLOAD_ARGS_ADDR, not CONFIG_IS_ENABLED. Fixes: 10c4ab898c25 ("spl: riscv: falcon: move fdt blob to specified address") Signed-off-by: Randolph <randolph@andestech.com> Tested-by: Leo Yu-Chi Liang <ycliang@andestech.com>
2024-03-20spl: Improve error message for SPL memory allocationLeo Yu-Chi Liang1-1/+6
There could be two memory allocation scheme in SPL phase. Explicitly print the corresponding error message. Signed-off-by: Leo Yu-Chi Liang <ycliang@andestech.com>
2024-03-02log: fixup log_head after relocating global dataThomas Weißschuh1-0/+3
When `gd` is relocated during `spl_relocate_stack_gd()` the doubly-linked circular list in the `log_head` member is broken. The last element of the list should point back to the initial `list_head`, but as the initial `list_head` is moved the pointer becomes stale. As a result the loop in `log_dispatch` would never finish. Signed-off-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de>
2024-02-04spl: Make SPL_STACK available for ROCKCHIP_RK3036 without spl frameworkKever Yang1-1/+2
rk3036 soc has limit internal sram, and not able to support spl framework. Signed-off-by: Kever Yang <kever.yang@rock-chips.com>
2024-01-31spl: riscv: falcon: move fdt blob to specified addressRandolph2-1/+16
In Falcon Boot mode, the fdt blob should be move to the RAM from kernel BSS section. To avoid being cleared by BSS initialisation. SPL_PAYLOAD_ARGS_ADDR is the address where SPL copies. Signed-off-by: Randolph <randolph@andestech.com> Reviewed-by: Leo Yu-Chi Liang <ycliang@andestech.com>
2024-01-29Merge patch series "Move framebuffer reservation for SPL to RAM end"Tom Rini1-0/+19
Devarsh Thakkar <devarsht@ti.com> says: Move video memory reservation for SPL at end of RAM so that it does not interefere with reservations for next stage so that the next stage need not have holes in between for passed regions and instead it can maintain continuity in reservations. Also catch the bloblist before starting reservations to avoid the same problem. While at it, also fill missing fields in video handoff struct before passing it to next stage. This is as per discussions at : For moving SPL framebuffer reservation at end of RAM: https://lore.kernel.org/all/CAPnjgZ3xSoe_G3yrqwuAvoiVjUfZ+YQgkOR0ZTVXGT9VK8TwJg@mail.gmail.com/ For filling missing video handoff fields : https://lore.kernel.org/all/CAPnjgZ1Hs0rNf0JDirp6YPsOQ5=QqQSP9g9qRwLoOASUV8a4cw@mail.gmail.com/
2024-01-29spl: Enforce framebuffer reservation from end of RAMDevarsh Thakkar1-0/+19
Add an API which enforces framebuffer reservation from end of RAM. This is done so that next stage can directly skip this region before carrying out further reservations. Signed-off-by: Devarsh Thakkar <devarsht@ti.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2024-01-29sunxi: Consider SPL size limitations for FIT loadingSamuel Holland1-2/+1
Now that 32-bit SoCs can load U-Boot proper (and possibly other firmware) from a FIT, people can use that by enabling CONFIG_SPL_LOAD_FIT. However SPL_FIT_IMAGE_TINY is required to stay within the 24 or 32 KiB SPL size limit on early SoCs; for consistency, enable it everywhere. Signed-off-by: Samuel Holland <samuel@sholland.org> [Andre: drop unconditional FIT image enablement for all SoCs] Reviewed-by: Andre Przywara <andre.przywara@arm.com>
2024-01-29sunxi: spl: Disable padding from SPL_PAD_TOSamuel Holland1-2/+1
Starting with H6, Allwinner removed the artificial 32 KiB SPL size limit from the boot ROM. Now SPL size is only limited by the available SRAM. This limit ranges from 152 KiB on H6 to a whopping 2052 KiB on R329. To take advantage of this additional space, we must increase SPL_MAX_SIZE. Since we do not want to unnecessarily pad SPL out to these giant sizes, we must set SPL_PAD_TO to zero. This causes no problems because binman already takes care of appending the SPL payload at the right offset. Signed-off-by: Samuel Holland <samuel@sholland.org> Reviewed-by: Andre Przywara <andre.przywara@arm.com>
2024-01-08spl: binman: Disable u_boot_any symbols for i.MX93 boardsMathieu Othacehe3-3/+3
This is extending commit 6516c9b349b3 ("spl: binman: Disable u_boot_any symbols for i.MX8M boards") to i.MX93 boards. Signed-off-by: Mathieu Othacehe <m.othacehe@gmail.com>
2023-12-18Merge tag 'v2024.01-rc5' into nextTom Rini1-1/+1
Prepare v2024.01-rc5
2023-12-06sunxi: h616: (really) lower SPL stack address to avoid BROM dataAndre Przywara1-1/+1
When using the USB OTG FEL mode on the Allwinner H616, the BootROM stores some data at the end of SRAM C. This is also the location where we place the initial SPL stack, so it will overwrite this data. We still need the BROM code after running the SPL, so should leave that area alone. Interestingly this does not seem to have an adverse effect, I guess on the "way out" (when we return to FEL after the SPL has run), this data is not needed by the BROM, for just the trailing end of the USB operation. However this is still wrong, and we should not clobber BROM data. Lower the SPL stack address to be situated right below the swap buffers we use in sunxi-fel: that should be out of the way of everyone else. This obsoletes a previous commit (eb53e7743c8f) with the same name: that one was changing the address in an *unused* macro in sunxi_common.h, so the previous patch didn't have any effect at all. Fixes: eb53e7743c8f ("sunxi: h616: lower SPL stack address to avoid BROM data") Signed-off-by: Andre Przywara <andre.przywara@arm.com>
2023-11-20Merge tag 'v2024.01-rc3' into nextTom Rini1-1/+1
Prepare v2024.01-rc3
2023-11-17Merge branch '2023-11-16-assorted-updates' into nextTom Rini1-2/+2
- squashfs improvements, remove common.h in some places, assorted code fixes, fix a few CONFIG symbol names in Kconfig files, bring in linux's <linux/time.h> conversion functions, poplar updates, bcb improvements.
2023-11-16fs: ext4: Remove unused parameter from ext4_mountSean Anderson1-2/+2
The part_length parameter is not used. Remove it. Signed-off-by: Sean Anderson <seanga2@gmail.com>
2023-11-16spl: fat: Add option to disable DMA alignmentSean Anderson3-4/+24
If we don't DMA-align buffers we pass to FAT, it will align them itself. This behaviour likely should be deprecated in favor of CONFIG_BOUNCE_BUFFER, but that's a task for another series. For the meantime, don't bother aligning the buffer unless we had been doing so in the past. Signed-off-by: Sean Anderson <seanga2@gmail.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2023-11-16spl: spi: Consolidate spi_load_image_os into spl_spi_load_imageSean Anderson1-40/+14
spi_load_image_os performs almost the same steps as the non-falcon-boot path of spl_spi_load_image. The load address is different, and it also loads a device tree, but that's it. Refactor the boot process so that they can both use the same load function. Signed-off-by: Sean Anderson <seanga2@gmail.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2023-11-16spl: Convert spi to spl_loadSean Anderson1-67/+13
This converts the spi load method to use spl_load. The address used for LOAD_FIT_FULL may be different, but there are no in-tree users of that config. Since payload_offs is only used without OS_BOOT, we defer its initialization. Signed-off-by: Sean Anderson <seanga2@gmail.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2023-11-16spl: Convert semihosting to spl_loadSean Anderson1-46/+6
This converts the semihosting load method to use spl_load. As a result, it also adds support for LOAD_FIT_FULL and IMX images. Signed-off-by: Sean Anderson <seanga2@gmail.com>
2023-11-16spl: Convert NVMe to spl_loadSean Anderson1-55/+11
This converts the blk load method (used exclusively by NVMe) to use spl_load. As a consequence, it also adds support for LOAD_FIT_FULL and IMX images. Signed-off-by: Sean Anderson <seanga2@gmail.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2023-11-16spl: Convert nor to spl_loadSean Anderson2-94/+7
This converts the nor load method to use spl_load. As a result it also adds support for LOAD_FIT_FULL. Since this is the last caller of spl_load_legacy_img, it has been removed. We can't load FITs with external data with SPL_LOAD_FIT_FULL, so disable the test in that case. No boards enable SPL_NOR_SUPPORT and SPL_LOAD_FIT_FULL, so this is not a regression. Signed-off-by: Sean Anderson <seanga2@gmail.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2023-11-16spl: Convert net to spl_loadSean Anderson1-24/+5
This converts the net load method to use spl_load. As a result, it also adds support for LOAD_FIT_FULL and IMX images. Signed-off-by: Sean Anderson <seanga2@gmail.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2023-11-16spl: Convert nand to spl_loadSean Anderson1-54/+16
This converts the nand load method to use spl_load. nand_page_size may not be valid until after nand_spl_load_image is called (see e.g. fsl_ifc_spl), so we set bl_len in spl_nand_read. Since spl_load reads the header for us, we can remove that argument from spl_nand_load_element. There are two possible regressions which could result from this commit. First, we ask for a negative address from spl_get_load_buffer. That is, instead of header = spl_get_load_buffer(0, sizeof(*header)); we do header = spl_get_load_buffer(-sizeof(*header), sizeof(*header)); this could cause a problem if spl_get_load_buffer does not return valid memory for negative offsets. Second, we now set bl_len for legacy images. This can cause memory up to a bl_len - 1 before the image load address to be written, which might not have been the case before. If this turns out to be a problem, we can add an option for a bounce buffer. We can't load FITs with external data with SPL_LOAD_FIT_FULL, so disable the test in that case. No boards enable SPL_NAND_SUPPORT and SPL_LOAD_FIT_FULL, so this is not a regression. Signed-off-by: Sean Anderson <seanga2@gmail.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2023-11-16spl: Convert mmc to spl_loadSean Anderson2-82/+15
This converts the mmc loader to spl_load. Legacy images are handled by spl_load (via spl_parse_image_header), so mmc_load_legacy can be omitted. To accurately determine whether mmc_load_image_raw_sector is used (which might not be the case if SYS_MMCSD_FS_BOOT is enabled), we introduce a helper config SYS_MMCSD_RAW_MODE. This ensures we can inline spl_load correctly when a board only boots from filesystems. We still need to check for SPL_MMC, since some boards enable configure raw mode even without MMC support. Signed-off-by: Sean Anderson <seanga2@gmail.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2023-11-16spl: Convert fat to spl_loadSean Anderson1-38/+18
This converts the fat loader to use spl_load. Some platforms are very tight on space, so we take care to only include the code we really need. Signed-off-by: Sean Anderson <seanga2@gmail.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2023-11-16spl: Convert ext to use spl_loadSean Anderson1-18/+18
This converts the ext load method to use spl_load. As a consequence, it also adds support for FIT and IMX images. Signed-off-by: Sean Anderson <seanga2@gmail.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2023-11-16spl: Add generic spl_load functionSean Anderson1-0/+10
Implementers of SPL_LOAD_IMAGE_METHOD have to correctly determine what type of image is being loaded and then call the appropriate image load function correctly. This is tricky, because some image load functions expect the whole image to already be loaded (CONFIG_SPL_LOAD_FIT_FULL), some will load the image automatically using spl_load_info.read() (CONFIG_SPL_LOAD_FIT/CONFIG_SPL_LOAD_IMX_CONTAINER), and some just parse the header and expect the caller to do the actual loading afterwards (legacy/raw images). Load methods often only support a subset of the above methods, meaning that not all image types can be used with all load methods. Further, the code to invoke these functions is duplicated between different load functions. To address this problem, this commit introduces a "spl_load" function. It aims to handle image detection and correct invocation of each of the parse/load functions. Although this function generally results in a size reduction with several users, it tends to bloat boards with only a single user. This is generally because programmers open-coding the contents of this function can make optimizations based on the specific loader. For example, NOR flash is memory-mapped, so it never bothers calling load->read. The compiler can't really make these optimizations across translation units. LTO solves this, but it is only available on some arches. To address this, perform "pseudo-LTO" by inlining spl_load when there are one or fewer users. At the moment, there are no users, so define SPL_LOAD_USERS to be 0. Signed-off-by: Sean Anderson <seanga2@gmail.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2023-11-16spl: legacy: Split off LZMA decompression into its own functionSean Anderson1-35/+40
To allow for easier reuse of this functionality, split it off into its own function. Signed-off-by: Sean Anderson <seanga2@gmail.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2023-11-16spl: nand: Remove spl_nand_legacy_readSean Anderson1-18/+11
Now that spl_nand_fit_read works in units of bytes, it can be combined with spl_nand_legacy_read. Rename the resulting function spl_nand_read, since it is no longer FIT-specific. Signed-off-by: Sean Anderson <seanga2@gmail.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2023-11-16spl: Only support bl_len when we have toSean Anderson14-28/+40
Aligning addresses and sizes causes overhead which is unnecessary when we are not loading from block devices. Remove bl_len when it is not needed. For example, on iot2050 we save 144 bytes with this patch (once the rest of this series is applied): add/remove: 0/0 grow/shrink: 0/3 up/down: 0/-144 (-144) Function old new delta spl_load_simple_fit 920 904 -16 load_simple_fit 496 444 -52 spl_spi_load_image 384 308 -76 Total: Before=87431, After=87287, chg -0.16% We use panic() instead of BUILD_BUG_ON in spl_set_bl_len because we still need to be able to compile it for things like mmc_load_image_raw_sector, even if that function will not be used. Signed-off-by: Sean Anderson <seanga2@gmail.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2023-11-16spl: Remove filename from spl_load_infoSean Anderson7-14/+6
For filesystems, filename serves the same purpose as priv. However, spl_load_fit_image also uses it to determine whether to use a DMA-aligned buffer. This is beneficial for FAT, which uses a bounce-buffer if the destination is not DMA-aligned. However, this is unnecessary now that filesystems set bl_len to ARCH_DMA_MINALIGN instead. With this done, we can remove filename entirely. Signed-off-by: Sean Anderson <seanga2@gmail.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2023-11-16spl: Set FAT bl_len to ARCH_DMA_MINALIGNSean Anderson4-27/+9
Instead of relying on the presence of filename to determine whether we are dealing with a FAT filesystem (and should DMA-align the buffer), have FAT set bl_len to ARCH_DMA_MINALIGN instead. With this done, we can remove the special-case logic checking for the presence of filename. Because filesystems are not block-based, we may read less than the size passed to spl_load_info.read. This can happen if the file size is not DMA-aligned. This is fine as long as we read the amount we originally wanted to. Modify the conditions for callers of spl_load_info.read to check against the original, unaligned size to avoid failing spuriously. Signed-off-by: Sean Anderson <seanga2@gmail.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2023-11-16spl: Refactor spl_load_info->read to use units of bytesSean Anderson4-67/+61
Simplify things a bit for callers of spl_load_info->read by refactoring it to use units of bytes instead of bl_len. This generally simplifies the logic, as MMC is the only loader which actually works in sectors. It will also allow further refactoring to remove the special-case handling of filename. spl_load_legacy_img already works in units of bytes (oops) so it doesn't need to be changed. Signed-off-by: Sean Anderson <seanga2@gmail.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2023-11-16spl: Take advantage of bl_len's power-of-twonessSean Anderson2-5/+5
bl_len must be a power of two, so we can use ALIGN instead of roundup and similar tricks to avoid divisions. Signed-off-by: Sean Anderson <seanga2@gmail.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2023-11-16spl: Remove dev from spl_load_infoSean Anderson2-6/+6
dev and priv serve the same purpose, and are never set at the same time. Remove dev and convert all users to priv. While we're at it, reorder bl_len to be last for better alignment. Signed-off-by: Sean Anderson <seanga2@gmail.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2023-11-16spl: Remove NULL assignments in spl_load_infoSean Anderson5-10/+0
Remove NULL assignments to fields in spl_load_info when .load doesn't reference these fields. This can result in more efficient code. filename must stay even if it is unused, since load_simple_fit uses it. Signed-off-by: Sean Anderson <seanga2@gmail.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2023-11-16spl: semihosting: Don't close fd before spl_load_simple_fitSean Anderson1-12/+8
On real hardware, semihosting calls tend to have a large constant overhead (on the order of tens of milliseconds). Reduce the number of calls by one by reusing the existing fd in smh_fit_read, and closing it at the end of spl_smh_load_image. Signed-off-by: Sean Anderson <seanga2@gmail.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2023-11-16spl: Make SHOW_ERRORS depend on LIBCOMMONSean Anderson2-2/+2
The purpose of SHOW_ERRORS is to print extra information. Make it depend on LIBCOMMON to avoid having to check for two configs. Signed-off-by: Sean Anderson <seanga2@gmail.com> Reviewed-by: Tom Rini <trini@konsulko.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2023-11-16spl: blk_fs: Fix uninitialized return value when we can't get a blk_descSean Anderson1-1/+1
Initialize ret to avoid returning garbage if blk_get_devnum_by_uclass_id fails. Fixes: 8ce6a2e1757 ("spl: blk: Support loading images from fs") Signed-off-by: Sean Anderson <seanga2@gmail.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2023-11-16mtd: Rename SPL_MTD_SUPPORT to SPL_MTDSean Anderson1-1/+1
Rename SPL_MTD_SUPPORT to SPL_MTD in order to match MTD. This allows using CONFIG_IS_ENABLED to test for MTD support. Signed-off-by: Sean Anderson <seanga2@gmail.com>
2023-11-16spl: nand: Map memory before accessing itSean Anderson1-2/+5
In sandbox we must map memory before accessing it. Do so for the NAND load method. Signed-off-by: Sean Anderson <seanga2@gmail.com>
2023-11-16spl: nand: Set bl_len to page sizeSean Anderson1-8/+3
Since commit 34793598c83 ("mtd: nand: mxs_nand_spl: Remove the page aligned access") there are no longer any users of nand_get_mtd. However, it is still important to know what the page size is so we can allocate a large-enough buffer. If the image size is not page-aligned, we will go off the end of the buffer and clobber some memory. Introduce a new function nand_page_size which returns the page size. For most drivers it is easy to determine the page size. However, a few need to be modified since they only keep the page size around temporarily. It's possible that this patch could cause a regression on some platforms if the offset is non-aligned and there is invalid address space immediately before the load address. spl_load_legacy_img does not (except when compressing) respect bl_len, so only boards with SPL_LOAD_FIT (8 boards) or SPL_LOAD_IMX_CONTAINER (none in tree) would be affected. defconfig CONFIG_TEXT_BASE ======================= ================ am335x_evm 0x80800000 am43xx_evm 0x80800000 am43xx_evm_rtconly 0x80800000 am43xx_evm_usbhost_boot 0x80800000 am43xx_hs_evm 0x80800000 dra7xx_evm 0x80800000 gwventana_nand 0x17800000 imx8mn_bsh_smm_s2 0x40200000 All the sitara boards have DDR mapped at 0x80000000. gwventana is an i.MX6Q which has DDR at 0x10000000. I don't have the IMX8MNRM handy, but on the i.MX8M DDR starts at 0x40000000. Therefore all of these boards can handle a little underflow. Signed-off-by: Sean Anderson <seanga2@gmail.com>
2023-11-16spl: legacy: Honor bl_len when decompressingSean Anderson1-6/+12
When allocating a buffer to load compressed data into, we need to ensure we have enough space for over- and under-flow due to alignment. Otherwise we will clobber the malloc bookkeeping data. Calculate the correct amount of overhead and use it when determining the size. Signed-off-by: Sean Anderson <seanga2@gmail.com>
2023-11-16spl: nand: Fix NULL-pointer dereferenceSean Anderson1-1/+1
spl_nand_fit_read unconditionally accesses load->priv. Ensure it is set. Fixes: 00e180cc513 ("spl: nand: support loading i.MX container format file") Signed-off-by: Sean Anderson <seanga2@gmail.com>
2023-11-10tree-wide: Replace http:// link with https:// link for ti.comNishanth Menon1-1/+1
Replace instances of http://www.ti.com with https://www.ti.com Signed-off-by: Nishanth Menon <nm@ti.com>