[linux-sunxi] [PATCH 07/17] sunxi: support loading with SPL > 32KB

Samuel Holland samuel at sholland.org
Mon Jan 4 03:02:03 CET 2021


On 1/3/21 3:26 AM, Jernej Skrabec wrote:
> From: Andre Przywara <andre.przywara at arm.com>
> 
> H616 supports and needs bigger SPL than 32 KiB, mostly due to big DRAM
> driver and need for PMIC configuration, which pull several drivers which
> are not needed otherwise.
> 
> Signed-off-by: Andre Przywara <andre.przywara at arm.com>
> Signed-off-by: Jernej Skrabec <jernej.skrabec at siol.net>
> ---
>  arch/arm/mach-sunxi/board.c | 12 ++++++++++++
>  1 file changed, 12 insertions(+)
> 
> diff --git a/arch/arm/mach-sunxi/board.c b/arch/arm/mach-sunxi/board.c
> index 7a8b303f233c..296efd615769 100644
> --- a/arch/arm/mach-sunxi/board.c
> +++ b/arch/arm/mach-sunxi/board.c
> @@ -277,6 +277,14 @@ uint32_t sunxi_get_boot_device(void)
>  }
>  
>  #ifdef CONFIG_SPL_BUILD
> +static u32 sunxi_get_spl_size(void)
> +{
> +	if (!is_boot0_magic(SPL_ADDR + 4)) /* eGON.BT0 */
> +		return 32768;
In the context of the suggestion below, this case could return 0.

> +
> +	return readl(SPL_ADDR + 0x10);
> +}
> +
>  /*
>   * The eGON SPL image can be located at 8KB or at 128KB into an SD card or
>   * an eMMC device. The boot source has bit 4 set in the latter case.
> @@ -286,6 +294,7 @@ uint32_t sunxi_get_boot_device(void)
>  unsigned long spl_mmc_get_uboot_raw_sector(struct mmc *mmc)

As a side note, the prototype for this function was changed in commit
cf0082559698 ("spl: mmc: Fix spl_mmc_get_uboot_raw_sector()
implementation"), but nobody noticed since it is not in a header.

>  {
>  	unsigned long sector = CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR;
> +	u32 spl_size = sunxi_get_spl_size();
>  
>  	switch (sunxi_get_boot_source()) {
>  	case SUNXI_BOOTED_FROM_MMC0_HIGH:
> @@ -294,6 +303,9 @@ unsigned long spl_mmc_get_uboot_raw_sector(struct mmc *mmc)
>  		break;
>  	}
>  
> +	if (spl_size > 32768)
> +		sector += (spl_size - 32768) / 512;
> +

What I would suggest doing instead of this is setting
SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR=0x40,
SYS_MMCSD_RAW_MODE_U_BOOT_DATA_PART_OFFSET=0x10, and then before the
switch statement doing:

        sector = max(CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR,
                     spl_size / 512);

Not only does this get rid of the magic 32768 constant (which is
meaningless on new platforms), but it also works cleanly for eMMC boot
partitions (where there's no 0x10 sector offset).

>  	return sector;
>  }
>  
> 

Cheers,
Samuel


More information about the U-Boot mailing list