summaryrefslogtreecommitdiff
path: root/common/spl/spl.c
Commit message (Collapse)AuthorAgeLines
* Revert "armv8: release slave cores from CPU_RELEASE_ADDR"Masahiro Yamada2017-01-28-8/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This reverts commit 8c36e99f211104fd7dcbf0669a35a47ce5e154f5. There is misunderstanding in commit 8c36e99f2111 ("armv8: release slave cores from CPU_RELEASE_ADDR"). How to bring the slave cores into U-Boot proper is platform-specific. So, it should be cared in SoC/board files instead of common/spl/spl.c. As you see SPL is the acronym of Secondary Program Loader, there is generally something that runs before SPL (the First one is usually Boot ROM). How to wake up slave cores from the Boot ROM is really SoC specific. So, the intention for the spin table support is to bring the slave cores into U-Boot proper in an SoC specific manner. (this must be done after relocation. see below.) If you bring the slaves into SPL, it is SoC own code responsibility to transfer them to U-Boot proper. The Spin Table defines the interface between a boot-loader and Linux kernel. It is unrelated to the interface between SPL and U-Boot proper. One more thing is missing in the commit; spl_image->entry_point points to the entry address of U-Boot *before* relocation. U-Boot relocates itself between board_init_f() and board_init_r(). This means the master CPU sees the different copy of the spin code than the slave CPUs enter. The spin_table_update_dt() protects the code *after* relocation. As a result, the slave CPUs spin in unprotected code, which leads to unstable behavior. Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com> Reviewed-by: Simon Glass <sjg@chromium.org>
* spl: Remove overwrite of relocated malloc limitAndrew F. Davis2017-01-28-1/+6
| | | | | | | | | | | spl_init on some boards is called after stack and heap relocation, on some platforms spl_relocate_stack_gd is called to handle setting the limit to its value CONFIG_SPL_STACK_R_MALLOC_SIMPLE_LEN when simple SPL malloc is enabled during relocation. spl_init should then not re-assign the old pre-relocation limit when this is defined. Signed-off-by: Andrew F. Davis <afd@ti.com> Reviewed-by: Tom Rini <trini@konsulko.com>
* spl: Add some missing newlinesAndrew F. Davis2017-01-20-2/+2
| | | | | | Signed-off-by: Andrew F. Davis <afd@ti.com> Acked-by: Lokesh Vutla <lokeshvutla@ti.com> Acked-by: Michal Simek <michal.simek@xilinx.com>
* armv8: release slave cores from CPU_RELEASE_ADDROded Gabbay2017-01-14-0/+8
| | | | | | | | | | | | | | | | | | | | | | | When using ARMv8 with ARMV8_SPIN_TABLE=y, we want the slave cores to wait on spin_table_cpu_release_addr, until the Linux kernel will "wake" them by writing to that location. The address of spin_table_cpu_release_addr is transferred to the kernel using the device tree that is updated by spin_table_update_dt(). However, if we also use SPL, then the slave cores are stuck at CPU_RELEASE_ADDR instead and as a result, never wake up. This patch releases the slave cores by writing spl_image->entry_point to CPU_RELEASE_ADDR location before the end of the SPL code (at jump_to_image_no_args()). That way, the slave cores will start to execute the u-boot and will get to the spin-table code and wait on the correct address (spin_table_cpu_release_addr). Signed-off-by: Oded Gabbay <oded.gabbay@gmail.com> Cc: Simon Glass <sjg@chromium.org> Reviewed-by: Simon Glass <sjg@chromium.org>
* spl: move RAM boot support in separate fileStefan Agner2017-01-14-58/+0
| | | | | | | | Add a new top-level config option so support booting an image stored in RAM. This allows to move the RAM boot support into a sparate file and having a single condition to compile that file. Signed-off-by: Stefan Agner <stefan.agner@toradex.com>
* Kconfig: CONFIG_OF_PLATDATA doesn't really existTom Rini2017-01-14-1/+1
| | | | | | | There is no CONFIG_OF_PLATDATA, only CONFIG_SPL_OF_PLATDATA, so rename the two references to CONFIG_OF_PLATDATA to CONFIG_SPL_OF_PLATDATA. Signed-off-by: Tom Rini <trini@konsulko.com>
* SPL: make struct spl_image 64-bit safeAndre Przywara2017-01-04-4/+4
| | | | | | | | | | | | | | Since entry_point and load_addr are addresses, they should be represented as longs to cover the whole address space and to avoid warning when compiling the SPL in 64-bit. Also adjust debug prints to add the 'l' specifier, where needed. Signed-off-by: Andre Przywara <andre.przywara@arm.com> Reviewed-by: Alexander Graf <agraf@suse.de> Reviewed-by: Simon Glass <sjg@chromium.org> Reviewed-by: Tom Rini <trini@konsulko.com> Acked-by: Maxime Ripard <maxime.ripard@free-electrons.com> Reviewed-by: Jagan Teki <jagan@openedev.com>
* spl: Drop announce_boot_device()Simon Glass2016-12-09-83/+3
| | | | | | This task can be handled by inline code now. Drop this function. Signed-off-by: Simon Glass <sjg@chromium.org>
* spl: Pass the loader into spl_load_image()Simon Glass2016-12-09-4/+4
| | | | | | | Rather than have this function figure out the correct loader again, pass it in as a parameter. Signed-off-by: Simon Glass <sjg@chromium.org>
* spl: Move the loading code into its own functionSimon Glass2016-12-09-12/+29
| | | | | | | Create a boot_from_devices() function to handle trying each device. This helps to reduce the size of the already-large board_init_r() function. Signed-off-by: Simon Glass <sjg@chromium.org>
* spl: Add a name to the SPL load-image methodsSimon Glass2016-12-09-2/+2
| | | | | | | | | | | It is useful to name each method so that we can print out this name when using the method. Currently this happens using a separate function. In preparation for unifying this, add a name to each method. The name is only available if we have libcommon support (i.e can use printf()). Signed-off-by: Simon Glass <sjg@chromium.org>
* dm: core: Handle global_data moving in SPLSimon Glass2016-12-02-0/+3
| | | | | | | | | | | | | When CONFIG_SPL_STACK_R is enabled, and spl_init() is called before board_init_r(), spl_relocate_stack_gd() will move global_data to a new place in memory. This affects driver model since it uses a list for the uclasses. Unless this is updated the list will become invalid. When looking for a non-existent uclass, such as when adding a new one, the loop in uclass_find() may continue forever, thus causing a hang. Add a function to correct this rather obscure bug. Signed-off-by: Simon Glass <sjg@chromium.org>
* spl: add RAM boot device only if it is actually definedStefan Agner2016-11-28-0/+2
| | | | | | | | | | | | Some devices (e.g. dra7xx) support loading to RAM using DFU without having direct boot from RAM support. Make sure the linker list does not contain BOOT_DEVICE_RAM if CONFIG_SPL_RAM_DEVICE is not enabled. Fixes: 98136b2f26fa ("spl: Convert spl_ram_load_image() to use linker list") Signed-off-by: Stefan Agner <stefan.agner@toradex.com> Acked-by: Lukasz Majewski <l.majewski@samsung.com>
* spl: Make spl_boot_list a local variableSimon Glass2016-10-06-12/+12
| | | | | | | | | | | There is no need for this to be in the BSS region. By moving it we can delay use of BSS in SPL. This is useful for machines where the BSS region is not in writeable space. On 64-bit x86, SPL runs from SPI flash and it is easier to eliminate BSS use than link SPL to run with BSS at a particular cache-as-RAM (CAR) address. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Tom Rini <trini@konsulko.com>
* spl: Update spl_load_simple_fit() to take an spl_image paramSimon Glass2016-10-06-1/+1
| | | | | | | Upda the SPL FIT code to use the spl_image parameter. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Tom Rini <trini@konsulko.com>
* spl: Pass spl_image as a parameter to load_image() methodsSimon Glass2016-10-06-3/+4
| | | | | | | | | Rather than having a global variable, pass the spl_image as a parameter. This avoids BSS use, and makes it clearer what the function is actually doing. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Tom Rini <trini@konsulko.com>
* spl: Convert spl_board_load_image() to use linker listSimon Glass2016-10-06-11/+2
| | | | | | | | Add a linker list declaration for this method and remove the explicit switch() code. Update existing users. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Tom Rini <trini@konsulko.com>
* spl: Convert spl_net_load_image() to use linker listSimon Glass2016-10-06-13/+0
| | | | | | | | | Add a linker list declaration for this method and remove the explicit switch() code. We need two variants - one for BOOT_DEVICE_CPGMAC and one for BOOT_DEVICE_USBETH. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Tom Rini <trini@konsulko.com>
* spl: Convert spl_spi_load_image() to use linker listSimon Glass2016-10-06-4/+0
| | | | | | | | Add a linker list declaration for this method and remove the explicit switch() code. Also set up the sunxi function. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Tom Rini <trini@konsulko.com>
* spl: Convert spl_sata_load_image() to use linker listSimon Glass2016-10-06-4/+0
| | | | | | | | Add a linker list declaration for this method and remove the explicit switch() code. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Tom Rini <trini@konsulko.com>
* spl: Convert spl_usb_load_image() to use linker listSimon Glass2016-10-06-3/+0
| | | | | | | | Add a linker list declaration for this method and remove the explicit switch() code. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Tom Rini <trini@konsulko.com>
* spl: Convert spl_ymodem_load_image() to use linker listSimon Glass2016-10-06-4/+0
| | | | | | | | Add a linker list declaration for this method and remove the explicit switch() code. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Tom Rini <trini@konsulko.com>
* spl: Convert spl_nor_load_image() to use linker listSimon Glass2016-10-06-4/+0
| | | | | | | | Add a linker list declaration for this method and remove the explicit switch() code. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Tom Rini <trini@konsulko.com>
* spl: Convert spl_onenand_load_image() to use linker listSimon Glass2016-10-06-4/+0
| | | | | | | | Add a linker list declaration for this method and remove the explicit switch() code. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Tom Rini <trini@konsulko.com>
* spl: Convert spl_nand_load_image() to use linker listSimon Glass2016-10-06-4/+0
| | | | | | | | Add a linker list declaration for this method and remove the explicit switch() code. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Tom Rini <trini@konsulko.com>
* spl: Convert spl_ubi_load_image() to use linker listSimon Glass2016-10-06-6/+0
| | | | | | | | Add a linker list declaration for this method and remove the explicit switch() code. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Tom Rini <trini@konsulko.com>
* spl: Convert spl_mmc_load_image() to use linker listSimon Glass2016-10-06-6/+0
| | | | | | | | Add a linker list declaration for this method and remove the explicit switch() code. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Tom Rini <trini@konsulko.com>
* spl: Convert spl_ram_load_image() to use linker listSimon Glass2016-10-06-9/+9
| | | | | | | | | | Add a linker list declaration for this method and remove the explicit switch() code. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Tom Rini <trini@konsulko.com> [trini: Include updating the DFU case] Signed-off-by: Tom Rini <trini@konsulko.com>
* spl: Add a way to declare an SPL image loaderSimon Glass2016-10-06-0/+20
| | | | | | | | Add a linker list macro which can be used to declare an SPL image loader. Update spl_load_image() to search available loaders for the correct one. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Tom Rini <trini@konsulko.com>
* spl: Convert boot_device into a structSimon Glass2016-10-06-17/+22
| | | | | | | | | | | At present some spl_xxx_load_image() functions take a parameter and some don't. Of those that do, most take an integer but one takes a string. Convert this parameter into a struct so that we can pass all functions the same thing. This will allow us to use a common function signature. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Tom Rini <trini@konsulko.com>
* spl: Add a parameter to jump_to_image_linux()Simon Glass2016-10-06-1/+2
| | | | | | | | Instead of using the global spl_image variable, pass the required struct in as an argument. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Tom Rini <trini@konsulko.com>
* spl: Add a parameter to spl_parse_image_header()Simon Glass2016-10-06-20/+21
| | | | | | | | Instead of using the global spl_image variable, pass the required struct in as an argument. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Tom Rini <trini@konsulko.com>
* spl: Add a parameter to spl_set_header_raw_uboot()Simon Glass2016-10-06-7/+7
| | | | | | | | Rather than act on the global variable, pass the required struct in as a parameter. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Tom Rini <trini@konsulko.com>
* dra7x: boot: add dfu bootmode supportB, Ravi2016-09-27-1/+9
| | | | | | | | This patch enables the DFU boot mode support for dra7x platform. Signed-off-by: Ravi Babu <ravibabu@ti.com> Reviewed-by: Tom Rini <trini@konsulko.com>
* spl: Rework image header parse to allow abort on raw image and os bootPaul Kocialkowski2016-09-06-4/+7
| | | | | | | | | This reworks spl_set_header_raw_uboot to allow having both os boot (which comes with a valid header) and aborting when no valid header is found (thus excluding raw u-boot.bin images). Signed-off-by: Paul Kocialkowski <contact@paulk.fr> Reviewed-by: Tom Rini <trini@konsulko.com>
* spl: zImage support in Falcon modeLadislav Michl2016-07-22-0/+23
| | | | | | | | Other payload than uImage is currently considered to be raw U-Boot image. Check also for zImage in Falcon mode. Signed-off-by: Ladislav Michl <ladis@linux-mips.org> Reviewed-by: Heiko Schocher <hs@denx.de>
* spl: support loading from UBI volumesLadislav Michl2016-07-22-0/+6
| | | | | | | | Add support for loading from UBI volumes on the top of NAND and OneNAND. Signed-off-by: Ladislav Michl <ladis@linux-mips.org> Reviewed-by: Heiko Schocher <hs@denx.de>
* Merge branch 'master' of http://git.denx.de/u-boot-sunxiTom Rini2016-07-15-2/+2
|\
| * sunxi: Support booting from SPI flashSiarhei Siamashka2016-07-15-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Allwinner devices support SPI flash as one of the possible bootable media type. The SPI flash chip needs to be connected to SPI0 pins (port C) to make this work. More information is available at: https://linux-sunxi.org/Bootable_SPI_flash This patch adds the initial support for booting from SPI flash. The existing SPI frameworks are not used in order to reduce the SPL code size. Right now the SPL size grows by ~370 bytes when CONFIG_SPL_SPI_SUNXI option is enabled. While there are no popular Allwinner devices with SPI flash at the moment, testing can be done using a SPI flash module (it can be bought for ~2$ on ebay) and jumper wires with the boards, which expose relevant pins on the expansion header. The SPI flash chips themselves are very cheap (some prices are even listed as low as 4 cents) and should not cost much if somebody decides to design a development board with an SPI flash chip soldered on the PCB. Another nice feature of the SPI flash is that it can be safely accessed in a device-independent way (since we know that the boot ROM is already probing these pins during the boot time). And if, for example, Olimex boards opted to use SPI flash instead of EEPROM, then they would have been able to have U-Boot installed in the SPI flash now and boot the rest of the system from the SATA hard drive. Hopefully we may see new interesting Allwinner based development boards in the future, now that the software support for the SPI flash is in a better shape :-) Testing can be done by enabling the CONFIG_SPL_SPI_SUNXI option in a board defconfig, then building U-Boot and finally flashing the resulting u-boot-sunxi-with-spl.bin binary over USB OTG with a help of the sunxi-fel tool: sunxi-fel spiflash-write 0 u-boot-sunxi-with-spl.bin The device needs to be switched into FEL (USB recovery) mode first. The most suitable boards for testing are Orange Pi PC and Pine64. Because these boards are cheap, have no built-in NAND/eMMC and expose SPI0 pins on the Raspberry Pi compatible expansion header. The A13-OLinuXino-Micro board also can be used. Signed-off-by: Siarhei Siamashka <siarhei.siamashka@gmail.com> Reviewed-by: Simon Glass <sjg@chromium.org> Signed-off-by: Hans de Goede <hdegoede@redhat.com>
* | dm: spl: Bind in all devices in SPL with of-platdataSimon Glass2016-07-14-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | When CONFIG_OF_PLATDATA is enabled, we cannot use the u-boot,dm-pre-reloc device tree property since the device tree is not available. However, dt-platdata.c only includes devices which would have been present in the device tree, and we can assume that all such devices are needed for SPL. If they were not needed, they would have been omitted to save space. So in this case, bind all devices regardless of the u-boot,dm-pre-reloc setting. This avoids needing to add a DM_FLAG_PRE_RELOC to every driver, thus affecting U-Boot proper also. Signed-off-by: Simon Glass <sjg@chromium.org>
* | dm: spl: Don't set up device tree with of-platdataSimon Glass2016-07-14-1/+1
| | | | | | | | | | | | When this feature is enabled, we should not access the device tree. Signed-off-by: Simon Glass <sjg@chromium.org>
* | spl: Drop include of i2c.hSimon Glass2016-07-14-1/+0
|/ | | | | | This file does not appear to use I2C, so drop this include. Signed-off-by: Simon Glass <sjg@chromium.org>
* bootstage: call show_boot_progress also in SPLHeiko Schocher2016-06-09-0/+5
| | | | | | show_boot_progress() is now called from SPL also. Signed-off-by: Heiko Schocher <hs@denx.de>
* Merge branch 'master' of git://git.denx.de/u-boot-socfpgaTom Rini2016-06-02-3/+0
|\
| * spl: Remove bogus GD_FLG_SPL_INIT checkMarek Vasut2016-06-01-3/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Remove the check for GD_FLG_SPL_INIT in spl_relocate_stack_gd(). The check will always fail. This is because spl_relocate_stack_gd() is called from ARM's crt0.S and it is called before board_init_r(). The board_init_r() calls spl_init(), which sets the GD_FLG_SPL_INIT flag. Note that reserving the malloc area in RAM is not a problem even if the GD_FLG_SPL_INIT flag is not set. Signed-off-by: Marek Vasut <marex@denx.de> Cc: Chin Liang See <clsee@altera.com> Cc: Dinh Nguyen <dinguyen@opensource.altera.com> Cc: Hans de Goede <hdegoede@redhat.com> Cc: Pavel Machek <pavel@denx.de> Cc: Stefan Roese <sr@denx.de> Cc: Stephen Warren <swarren@nvidia.com>
* | spl: Allow settings malloc_f base addressMarek Vasut2016-06-02-0/+3
|/ | | | | | | | | | Allow configuring the begining of the malloc_f area in SPL. This patch uses the same CONFIG_MALLOC_F_ADDR established by the sandbox. Signed-off-by: Marek Vasut <marex@denx.de> Cc: Tom Rini <trini@konsulko.com> Cc: Simon Glass <sjg@chromium.org>
* SPL: FIT: Enable SPL_FIT_LOAD in RAM based boot modeMichal Simek2016-05-24-9/+36
| | | | | | | | | | Support loading FIT in SPL for RAM bootmode. CONFIG_SPL_LOAD_FIT_ADRESS points to address where FIT image is stored in memory. Signed-off-by: Michal Simek <michal.simek@xilinx.com> Reviewed-by: Simon Glass <sjg@chromium.org> Reviewed-by: Lokesh Vutla <lokeshvutla@ti.com>
* spl: Introduce new function spl_board_prepare_for_bootMichal Simek2016-05-24-0/+6
| | | | | | | | | Call this function before passing control from SPL. For fpga case it is necessary to enable for example level shifters when bitstream is programmed. Signed-off-by: Michal Simek <michal.simek@xilinx.com> Reviewed-by: Simon Glass <sjg@chromium.org>
* SPL: Add CONFIG_SPL_ABORT_ON_RAW_IMAGEMarek Vasut2016-05-17-0/+3
| | | | | | | | | | | | | When defined, SPL will proceed to another boot method if the image it has loaded does not have a signature. This is useful if the subsequent boot methods are much more complex. Signed-off-by: Marek Vasut <marex@denx.de> Cc: Tom Rini <trini@konsulko.com> Cc: Stefano Babic <sbabic@denx.de> Cc: Peng Fan <van.freenix@gmail.com> Cc: Fabio Estevam <fabio.estevam@nxp.com>
* SPL: Let spl_parse_image_header() return valueMarek Vasut2016-05-17-1/+2
| | | | | | | | | | | Allow the spl_parse_image_header() to return value. This is convenient for controlling the SPL boot flow if the loaded image is corrupted. Signed-off-by: Marek Vasut <marex@denx.de> Cc: Fabio Estevam <fabio.estevam@nxp.com> Cc: Peng Fan <van.freenix@gmail.com> Cc: Stefano Babic <sbabic@denx.de> Cc: Tom Rini <trini@konsulko.com>