From 0b19c665d5fe6a19f928f79d888562f84274c42d Mon Sep 17 00:00:00 2001 From: Abel Vesa Date: Fri, 28 Sep 2018 18:02:49 +0300 Subject: MLK-19789 mach-imx: imx8: Make the eMMC container offset SOC dependant This is a hack for imx8qm-mek, since the offset of the flash.bin image on eMMC differs when compared to imx8qxp-mek. Basically, the default value is 32K, but for 8qm-mek it's 0. This can go away once the qm and qxp get aligned (again) from this point of view. Signed-off-by: Abel Vesa Reviewed-by: Ye Li (cherry picked from commit e9f87deae7e8cb3e71012f85c488e0a0d108762a) --- arch/arm/include/asm/arch-imx8/image.h | 1 + arch/arm/mach-imx/imx8/image.c | 38 +++++++++++++++++++++++++++------- 2 files changed, 32 insertions(+), 7 deletions(-) diff --git a/arch/arm/include/asm/arch-imx8/image.h b/arch/arm/include/asm/arch-imx8/image.h index 2958b49771..22592bcdc8 100644 --- a/arch/arm/include/asm/arch-imx8/image.h +++ b/arch/arm/include/asm/arch-imx8/image.h @@ -7,6 +7,7 @@ #define HASH_MAX_LEN 64 #define CONTAINER_HDR_ALIGNMENT 0x400 +#define CONTAINER_HDR_EMMC_OFFSET 0 #define CONTAINER_HDR_MMCSD_OFFSET SZ_32K #define CONTAINER_HDR_QSPI_OFFSET SZ_4K diff --git a/arch/arm/mach-imx/imx8/image.c b/arch/arm/mach-imx/imx8/image.c index a274433913..e4417ad1a9 100644 --- a/arch/arm/mach-imx/imx8/image.c +++ b/arch/arm/mach-imx/imx8/image.c @@ -10,6 +10,8 @@ #include #include #include +#include +#include #define MMC_DEV 0 #define QSPI_DEV 1 @@ -92,18 +94,40 @@ static int get_container_size(void *dev, int dev_type, unsigned long offset) return ret; } +static unsigned long get_boot_device_offset(void *dev, int dev_type) +{ + unsigned long offset = 0; + if (dev_type == MMC_DEV) { + struct mmc *mmc = (struct mmc*)dev; + + if (IS_SD(mmc) || mmc->part_config == MMCPART_NOAVAILABLE) { + offset = CONTAINER_HDR_MMCSD_OFFSET; + } else { + u8 part = EXT_CSD_EXTRACT_BOOT_PART(mmc->part_config); + + if (part == 1 || part == 2) { + if (is_imx8qxp() && is_soc_rev(CHIP_REV_B)) + offset = CONTAINER_HDR_MMCSD_OFFSET; + else + offset = CONTAINER_HDR_EMMC_OFFSET; + } else { + offset = CONTAINER_HDR_MMCSD_OFFSET; + } + } + } else if (dev_type == QSPI_DEV) { + offset = CONTAINER_HDR_QSPI_OFFSET; + } + + return offset; +} + static int get_imageset_end(void *dev, int dev_type) { unsigned long offset1 = 0, offset2 = 0; int value_container[2]; - if (dev_type == MMC_DEV) { - offset1 = CONTAINER_HDR_MMCSD_OFFSET; - offset2 = CONTAINER_HDR_ALIGNMENT + offset1; - } else if (dev_type == QSPI_DEV) { - offset1 = CONTAINER_HDR_QSPI_OFFSET; - offset2 = CONTAINER_HDR_ALIGNMENT + offset1; - } + offset1 = get_boot_device_offset(dev, dev_type); + offset2 = CONTAINER_HDR_ALIGNMENT + offset1; value_container[0] = get_container_size(dev, dev_type, offset1); if (value_container[0] < 0) { -- cgit v1.2.3