From: Ye Li Date: Tue, 19 Feb 2019 08:03:04 +0000 (-0800) Subject: MLK-20945-4 imx8: Update container parser for RAW NOR SPL X-Git-Tag: rel_imx_4.19.35_1.1.0~574 X-Git-Url: https://git.somdevices.com/?a=commitdiff_plain;h=bf75fe90520aaab06f69156f8715b525f2c8bf5c;p=u-boot.git MLK-20945-4 imx8: Update container parser for RAW NOR SPL Since FSPI is assigned to M4 partition, A core only can read it from its memory-map address. So we have to enable SPL NOR which won't access flexspi driver. Update SPL container parser for the RAW NOR support. Signed-off-by: Ye Li (cherry picked from commit 7ea7a16fd892558098fb8cbea134ac275d1220d3) --- diff --git a/arch/arm/mach-imx/imx8/Makefile b/arch/arm/mach-imx/imx8/Makefile index ed355c3c8c..0be2af83d0 100644 --- a/arch/arm/mach-imx/imx8/Makefile +++ b/arch/arm/mach-imx/imx8/Makefile @@ -6,7 +6,7 @@ obj-y += cpu.o iomux.o fuse.o lpcg.o clock.o obj-y += lowlevel_init.o -obj-y += image.o +obj-$(CONFIG_SPL_BUILD) += image.o obj-$(CONFIG_SPL_BUILD) += parser.o ifneq ($(CONFIG_SPL_BUILD),y) obj-y += partition.o diff --git a/arch/arm/mach-imx/imx8/image.c b/arch/arm/mach-imx/imx8/image.c index 877aa15b6a..6bae8debb0 100644 --- a/arch/arm/mach-imx/imx8/image.c +++ b/arch/arm/mach-imx/imx8/image.c @@ -17,6 +17,7 @@ #define MMC_DEV 0 #define QSPI_DEV 1 #define NAND_DEV 2 +#define QSPI_NOR_DEV 3 static int __get_container_size(ulong addr) { @@ -103,6 +104,12 @@ static int get_container_size(void *dev, int dev_type, unsigned long offset) } #endif +#ifdef CONFIG_SPL_NOR_SUPPORT + if (dev_type == QSPI_NOR_DEV) { + memcpy(buf, (const void *)offset, CONTAINER_HDR_ALIGNMENT); + } +#endif + ret = __get_container_size((ulong)buf); free(buf); @@ -134,6 +141,8 @@ static unsigned long get_boot_device_offset(void *dev, int dev_type) offset = CONTAINER_HDR_QSPI_OFFSET; } else if (dev_type == NAND_DEV) { offset = CONTAINER_HDR_NAND_OFFSET; + } else if (dev_type == QSPI_NOR_DEV) { + offset = CONTAINER_HDR_QSPI_OFFSET + 0x08000000; } return offset; @@ -207,3 +216,25 @@ uint32_t spl_nand_get_uboot_raw_page(void) return end; } #endif + +#ifdef CONFIG_SPL_NOR_SUPPORT +unsigned long spl_nor_get_uboot_base(void) +{ + int end; + + /* Calculate the image set end, + * if it is less than CONFIG_SYS_UBOOT_BASE(0x8281000), + * we use CONFIG_SYS_UBOOT_BASE + * Otherwise, use the calculated address + */ + end = get_imageset_end((void *)NULL, QSPI_NOR_DEV); + if (end <= CONFIG_SYS_UBOOT_BASE) + end = CONFIG_SYS_UBOOT_BASE; + else + end = ROUND(end, SZ_1K); + + printf("Load image from NOR 0x%x\n", end); + + return end; +} +#endif diff --git a/arch/arm/mach-imx/imx8/parser.c b/arch/arm/mach-imx/imx8/parser.c index 6f9fc0a2bf..31129b4fd9 100644 --- a/arch/arm/mach-imx/imx8/parser.c +++ b/arch/arm/mach-imx/imx8/parser.c @@ -318,3 +318,18 @@ int sdp_load_image_parse_container(struct spl_image_info *spl_image, return ret; } + +int __weak nor_load_image_parse_container(struct spl_image_info *spl_image, + unsigned long offset) +{ + int ret = 0; + + current_dev_type = RAM_DEV; + device = NULL; + + start_offset = offset; + + ret = read_auth_container(spl_image); + + return ret; +} diff --git a/common/spl/spl_nor.c b/common/spl/spl_nor.c index 969e319de0..65e30608ba 100644 --- a/common/spl/spl_nor.c +++ b/common/spl/spl_nor.c @@ -18,6 +18,19 @@ static ulong spl_nor_load_read(struct spl_load_info *load, ulong sector, } #endif +unsigned long __weak spl_nor_get_uboot_base(void) +{ + return CONFIG_SYS_UBOOT_BASE; +} + +#ifdef CONFIG_PARSE_CONTAINER +int __weak nor_load_image_parse_container(struct spl_image_info *spl_image, + unsigned long offset) +{ + return -EINVAL; +} +#endif + static int spl_nor_load_image(struct spl_image_info *spl_image, struct spl_boot_device *bootdev) { @@ -80,26 +93,33 @@ static int spl_nor_load_image(struct spl_image_info *spl_image, * defined location in SDRAM */ #ifdef CONFIG_SPL_LOAD_FIT - header = (const struct image_header *)CONFIG_SYS_UBOOT_BASE; + header = (const struct image_header *)spl_nor_get_uboot_base(); if (image_get_magic(header) == FDT_MAGIC) { debug("Found FIT format U-Boot\n"); load.bl_len = 1; load.read = spl_nor_load_read; ret = spl_load_simple_fit(spl_image, &load, - CONFIG_SYS_UBOOT_BASE, + spl_nor_get_uboot_base(), (void *)header); return ret; } #endif + +#ifdef CONFIG_PARSE_CONTAINER + ret = nor_load_image_parse_container(spl_image, + spl_nor_get_uboot_base()); + return ret; +#else ret = spl_parse_image_header(spl_image, - (const struct image_header *)CONFIG_SYS_UBOOT_BASE); + (const struct image_header *)spl_nor_get_uboot_base()); if (ret) return ret; memcpy((void *)(unsigned long)spl_image->load_addr, - (void *)(CONFIG_SYS_UBOOT_BASE + sizeof(struct image_header)), + (void *)(spl_nor_get_uboot_base() + sizeof(struct image_header)), spl_image->size); +#endif return 0; }