mmc: fsl_esdhc_spl: Add support for builds without CONFIG_SYS_MMC_U_BOOT_OFFS
authorPali Rohár <pali@kernel.org>
Fri, 5 Aug 2022 20:09:41 +0000 (22:09 +0200)
committerMarek Behún <kabel@kernel.org>
Fri, 16 Sep 2022 16:46:14 +0000 (18:46 +0200)
When fixed offset via CONFIG_SYS_MMC_U_BOOT_OFFS is not specified then
expects that U-Boot proper is placed immediately after SPL without any
additional padding.

This allows to generate smaller SPL+U-Boot final binary as it is not
required to specify fixed offset to U-Boot proper at SPL compile time.

In this case offset to U-Boot proper is calculated at SPL compile time in
linker script.

Signed-off-by: Pali Rohár <pali@kernel.org>
Reviewed-by: Jaehoon Chung <jh80.chung@samsung.com>
Signed-off-by: Marek Behún <kabel@kernel.org>
arch/powerpc/cpu/mpc85xx/u-boot-spl.lds
drivers/mmc/fsl_esdhc_spl.c

index 89df4b5..a36aa17 100644 (file)
@@ -62,6 +62,13 @@ SECTIONS
        __init_begin = .;
        __init_end = .;
        _end = .;
+
+#ifndef KEEP_RESET_VECTOR
+#if defined(CONFIG_SD_BOOT) && !defined(CONFIG_SYS_MMC_U_BOOT_OFFS)
+       mmc_u_boot_offs = .;
+#endif
+#endif
+
 #ifdef CONFIG_SPL_SKIP_RELOCATE
        . = ALIGN(4);
        __bss_start = .;
@@ -94,6 +101,9 @@ SECTIONS
        .resetvec IMAGE_TEXT_BASE + RESET_VECTOR_OFFSET : {
                KEEP(*(.resetvec))
        } = 0xffff
+#if defined(CONFIG_SD_BOOT) && !defined(CONFIG_SYS_MMC_U_BOOT_OFFS)
+       mmc_u_boot_offs = .;
+#endif
 #endif
 
 #ifndef CONFIG_SPL_SKIP_RELOCATE
index dd6d5fa..aa00d7e 100644 (file)
@@ -9,6 +9,10 @@
 #include <mmc.h>
 #include <malloc.h>
 
+#ifndef CONFIG_SYS_MMC_U_BOOT_OFFS
+extern uchar mmc_u_boot_offs[];
+#endif
+
 /*
  * The environment variables are written to just after the u-boot image
  * on SDCard, so we must read the MBR to get the start address and code
@@ -149,8 +153,12 @@ again:
                val = *(tmp_buf + blk_off + ESDHC_BOOT_IMAGE_ADDR + i);
                offset = (offset << 8) + val;
        }
+#ifndef CONFIG_SYS_MMC_U_BOOT_OFFS
+       offset += (ulong)&mmc_u_boot_offs - CONFIG_SPL_TEXT_BASE;
+#else
        offset += CONFIG_SYS_MMC_U_BOOT_OFFS;
 #endif
+#endif
        /*
        * Load U-Boot image from mmc into RAM
        */