MLK-20945-4 imx8: Update container parser for RAW NOR SPL
authorYe Li <ye.li@nxp.com>
Tue, 19 Feb 2019 08:03:04 +0000 (00:03 -0800)
committerYe Li <ye.li@nxp.com>
Fri, 24 May 2019 11:28:18 +0000 (04:28 -0700)
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 <ye.li@nxp.com>
(cherry picked from commit 7ea7a16fd892558098fb8cbea134ac275d1220d3)

arch/arm/mach-imx/imx8/Makefile
arch/arm/mach-imx/imx8/image.c
arch/arm/mach-imx/imx8/parser.c
common/spl/spl_nor.c

index ed355c3..0be2af8 100644 (file)
@@ -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
index 877aa15..6bae8de 100644 (file)
@@ -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
index 6f9fc0a..31129b4 100644 (file)
@@ -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;
+}
index 969e319..65e3060 100644 (file)
@@ -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;
 }