summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYe Li <ye.li@nxp.com>2018-12-26 21:45:54 -0800
committerYe Li <ye.li@nxp.com>2019-01-16 02:17:43 -0800
commit4b2850ccfd8b387590c9fb4abfffdd0ac5cc8e58 (patch)
tree3d4022f8403ff249bc896ece5f713ae0b7bb1ab5
parentcf2acc5b7cde7c8af295e2e2424d83a63d8949f5 (diff)
MLK-20664-1 imx8qxp: spl: Enable SPL container support for NAND
Add the NAND support to SPL container parser and enable it for imx8qxp arm2 nand reworked board. The SPL NAND will read from nandfit mtdpart (128MB offset) to parsing the entire boot image and get the 3rd container from it. This requires burning tool (uuu) to program the entire boot image into nandfit. Signed-off-by: Ye Li <ye.li@nxp.com>
-rw-r--r--arch/arm/include/asm/arch-imx8/image.h2
-rw-r--r--arch/arm/mach-imx/imx8/parser.c31
-rw-r--r--common/spl/spl_nand.c16
-rw-r--r--include/configs/imx8qxp_arm2.h16
4 files changed, 53 insertions, 12 deletions
diff --git a/arch/arm/include/asm/arch-imx8/image.h b/arch/arm/include/asm/arch-imx8/image.h
index ce6bf67ff0d..2b21f8878ea 100644
--- a/arch/arm/include/asm/arch-imx8/image.h
+++ b/arch/arm/include/asm/arch-imx8/image.h
@@ -10,7 +10,7 @@
#define CONTAINER_HDR_EMMC_OFFSET 0
#define CONTAINER_HDR_MMCSD_OFFSET SZ_32K
#define CONTAINER_HDR_QSPI_OFFSET SZ_4K
-#define CONTAINER_HDR_NAND_OFFSET SZ_64M
+#define CONTAINER_HDR_NAND_OFFSET SZ_128M
struct container_hdr{
uint8_t version;
diff --git a/arch/arm/mach-imx/imx8/parser.c b/arch/arm/mach-imx/imx8/parser.c
index f7315cbf289..b8205d13f67 100644
--- a/arch/arm/mach-imx/imx8/parser.c
+++ b/arch/arm/mach-imx/imx8/parser.c
@@ -9,6 +9,7 @@
#include <dm.h>
#include <mmc.h>
#include <spi_flash.h>
+#include <nand.h>
#include <asm/arch/image.h>
#include <asm/arch/sys_proto.h>
#include <asm/mach-imx/sci/sci.h>
@@ -16,7 +17,8 @@
#define MMC_DEV 0
#define QSPI_DEV 1
-#define RAM_DEV 3
+#define NAND_DEV 2
+#define RAM_DEV 3
#define SEC_SECURE_RAM_BASE (0x31800000UL)
#define SEC_SECURE_RAM_END_BASE (SEC_SECURE_RAM_BASE + 0xFFFFUL)
@@ -39,7 +41,8 @@ static int read(u32 start, u32 len, void *load_addr)
{
int ret = -ENODEV;
- if (!device && current_dev_type != RAM_DEV) {
+ if (current_dev_type != NAND_DEV && current_dev_type != RAM_DEV
+ && !device) {
debug("No device selected\n");
return ret;
}
@@ -73,6 +76,15 @@ static int read(u32 start, u32 len, void *load_addr)
}
}
#endif
+#ifdef CONFIG_SPL_NAND_SUPPORT
+ if (current_dev_type == NAND_DEV) {
+ ret = nand_spl_load_image(start, len, load_addr);
+ if (ret != 0) {
+ debug("Read container image from NAND failed\n");
+ return -EIO;
+ }
+ }
+#endif
if (current_dev_type == RAM_DEV) {
memcpy(load_addr, (const void *)(ulong)start, len);
@@ -265,6 +277,21 @@ int spi_load_image_parse_container(struct spl_image_info *spl_image,
return ret;
}
+int nand_load_image_parse_container(struct spl_image_info *spl_image,
+ unsigned long offset)
+{
+ int ret = 0;
+
+ current_dev_type = NAND_DEV;
+ device = NULL;
+
+ start_offset = offset;
+
+ ret = read_auth_container(spl_image);
+
+ return ret;
+}
+
int sdp_load_image_parse_container(struct spl_image_info *spl_image,
unsigned long offset)
{
diff --git a/common/spl/spl_nand.c b/common/spl/spl_nand.c
index 93d4774fff9..91446dde5a2 100644
--- a/common/spl/spl_nand.c
+++ b/common/spl/spl_nand.c
@@ -12,12 +12,20 @@
#include <linux/libfdt_env.h>
#include <fdt.h>
-#if defined(CONFIG_SPL_NAND_RAW_ONLY)
+#ifdef CONFIG_PARSE_CONTAINER
+int __weak nand_load_image_parse_container(struct spl_image_info *spl_image,
+ unsigned long offset)
+{
+ return -EINVAL;
+}
+#endif
+
uint32_t __weak spl_nand_get_uboot_raw_page(void)
{
return CONFIG_SYS_NAND_U_BOOT_OFFS;
}
+#if defined(CONFIG_SPL_NAND_RAW_ONLY)
int spl_nand_load_image(struct spl_image_info *spl_image,
struct spl_boot_device *bootdev)
{
@@ -69,11 +77,15 @@ static int spl_nand_load_element(struct spl_image_info *spl_image,
load.read = spl_nand_fit_read;
return spl_load_simple_fit(spl_image, &load, offset, header);
} else {
+#ifdef CONFIG_PARSE_CONTAINER
+ return nand_load_image_parse_container(spl_image, offset);
+#else
err = spl_parse_image_header(spl_image, header);
if (err)
return err;
return nand_spl_load_image(offset, spl_image->size,
(void *)(ulong)spl_image->load_addr);
+#endif
}
}
@@ -144,7 +156,7 @@ static int spl_nand_load_image(struct spl_image_info *spl_image,
#endif
#endif
/* Load u-boot */
- err = spl_nand_load_element(spl_image, CONFIG_SYS_NAND_U_BOOT_OFFS,
+ err = spl_nand_load_element(spl_image, spl_nand_get_uboot_raw_page(),
header);
#ifdef CONFIG_SYS_NAND_U_BOOT_OFFS_REDUND
#if CONFIG_SYS_NAND_U_BOOT_OFFS != CONFIG_SYS_NAND_U_BOOT_OFFS_REDUND
diff --git a/include/configs/imx8qxp_arm2.h b/include/configs/imx8qxp_arm2.h
index 66392f2fc62..40ac31ca85d 100644
--- a/include/configs/imx8qxp_arm2.h
+++ b/include/configs/imx8qxp_arm2.h
@@ -14,6 +14,8 @@
#ifdef CONFIG_SPL_BUILD
+#define CONFIG_PARSE_CONTAINER
+
#ifdef CONFIG_QSPI_BOOT
#define CONFIG_SPL_SPI_LOAD
#endif
@@ -23,11 +25,13 @@
#define CONFIG_SYS_MONITOR_LEN (1024 * 1024)
#ifdef CONFIG_NAND_BOOT
+#ifndef CONFIG_PARSE_CONTAINER
#define CONFIG_SPL_NAND_RAW_ONLY
+#endif
#define CONFIG_SPL_NAND_SUPPORT
#define CONFIG_SPL_DMA_SUPPORT
#define CONFIG_SPL_NAND_MXS
-#define CONFIG_SYS_NAND_U_BOOT_OFFS (0x4000000) /*Put the FIT out of first 64MB boot area */
+#define CONFIG_SYS_NAND_U_BOOT_OFFS (0x8000000) /*Put the FIT out of first 128MB boot area */
#define CONFIG_SPL_NAND_BOOT
#define CONFIG_SYS_NAND_U_BOOT_DST 0x80000000
#define CONFIG_SYS_NAND_U_BOOT_SIZE (1024 * 1024 )
@@ -162,9 +166,7 @@
"m4boot_0=run loadm4image_0; dcache flush; bootaux ${loadaddr} 0\0" \
#ifdef CONFIG_NAND_BOOT
-#define MFG_NAND_PARTITION "mtdparts=gpmi-nand:128m(nandboot),32m(nandkernel),16m(nanddtb),8m(nandtee),-(nandrootfs) "
-#else
-#define MFG_NAND_PARTITION ""
+#define MFG_NAND_PARTITION "mtdparts=gpmi-nand:128m(nandboot),16m(nandfit),32m(nandkernel),16m(nanddtb),8m(nandtee),-(nandrootfs) "
#endif
#define CONFIG_MFG_ENV_SETTINGS \
@@ -175,7 +177,6 @@
"initrd_high=0xffffffffffffffff\0" \
"emmc_dev=0\0" \
"sd_dev=1\0" \
- "mtdparts=mtdparts=gpmi-nand:128m(nandboot),32m(nandkernel),16m(nanddtb),8m(nandtee),-(nandrootfs)\0"
/* Initial environment variables */
#ifdef CONFIG_NAND_BOOT
@@ -186,6 +187,7 @@
MFG_NAND_PARTITION \
"\0"\
"console=ttyLP0,115200 earlycon=lpuart32,0x5a060000,115200\0" \
+ "mtdparts=" MFG_NAND_PARTITION "\0" \
"fdt_addr=0x83000000\0"
#else
#define CONFIG_EXTRA_ENV_SETTINGS \
@@ -267,8 +269,8 @@
#ifdef CONFIG_NAND_BOOT
#define CONFIG_BOOTCOMMAND \
- "nand read ${loadaddr} 0x8000000 0x2000000;"\
- "nand read ${fdt_addr} 0xA000000 0x100000;"\
+ "nand read ${loadaddr} 0x9000000 0x2000000;"\
+ "nand read ${fdt_addr} 0xB000000 0x100000;"\
"booti ${loadaddr} - ${fdt_addr}"
#else
#define CONFIG_BOOTCOMMAND \