From 8b4e94238a7a709ad15460b96d85e08ff8f4fdaa Mon Sep 17 00:00:00 2001 From: Ye Li Date: Tue, 12 Dec 2017 00:02:19 -0600 Subject: [PATCH] MLK-17153-2 imx8mq_arm2: Resolve malloc memory problem for SPL NAND boot When using SPL NAND boot, the required malloc memory is larger than SD/eMMC boot. Since we have used out OCRAM (for ATF) and OCRAM_S, there is no enough memory could be allocated. The solution is moving the malloc memory pool to DDR. The malloc pool is initialized in board_init_r, so we moved the VDD_DRAM adjustment and DDR init to board_init_f. Then the DDR can setup before memory pool initialization. Because the i2c and PMIC driver needs to malloc data, this change has to enable malloc_f pool by setting CONFIG_MALLOC_F_ADDR to previous malloc address on OCRAM_S. Signed-off-by: Ye Li Reviewed-by: Peng Fan (cherry picked from commit ab1895fb5e38d216ff86de292a44776099d159ab) (cherry picked from commit de084efbc91de971f10c745bbc94f960cdb813a9) --- board/freescale/imx8mq_arm2/spl.c | 28 ++++++++++++++++++---------- include/configs/imx8mq_arm2.h | 6 ++++-- 2 files changed, 22 insertions(+), 12 deletions(-) diff --git a/board/freescale/imx8mq_arm2/spl.c b/board/freescale/imx8mq_arm2/spl.c index fe097501ed..6b095ae7e9 100644 --- a/board/freescale/imx8mq_arm2/spl.c +++ b/board/freescale/imx8mq_arm2/spl.c @@ -197,16 +197,6 @@ int power_init_board(void) void spl_board_init(void) { - enable_tzc380(); - - /* Adjust pmic voltage to 1.0V for 800M */ - setup_i2c(0, CONFIG_SYS_I2C_SPEED, 0x7f, &i2c_pad_info1); - - power_init_board(); - - /* DDR initialization */ - spl_dram_init(); - /* Serial download mode */ if (is_usb_boot()) { puts("Back to ROM, SDP\n"); @@ -227,6 +217,8 @@ int board_fit_config_name_match(const char *name) void board_init_f(ulong dummy) { + int ret; + /* Clear global data */ memset((void *)gd, 0, sizeof(gd_t)); @@ -243,5 +235,21 @@ void board_init_f(ulong dummy) /* Clear the BSS. */ memset(__bss_start, 0, __bss_end - __bss_start); + ret = spl_init(); + if (ret) { + debug("spl_init() failed: %d\n", ret); + hang(); + } + + enable_tzc380(); + + /* Adjust pmic voltage VDD_DRAM to 1.0V for DRAM RUN >= 2400MHZ */ + setup_i2c(0, CONFIG_SYS_I2C_SPEED, 0x7f, &i2c_pad_info1); + + power_init_board(); + + /* DDR initialization */ + spl_dram_init(); + board_init_r(NULL, 0); } diff --git a/include/configs/imx8mq_arm2.h b/include/configs/imx8mq_arm2.h index 02bb9ad76f..0dee1ab270 100644 --- a/include/configs/imx8mq_arm2.h +++ b/include/configs/imx8mq_arm2.h @@ -35,11 +35,13 @@ #define CONFIG_SPL_MMC_SUPPORT #define CONFIG_SPL_BSS_START_ADDR 0x00180000 #define CONFIG_SPL_BSS_MAX_SIZE 0x2000 /* 8 KB */ -#define CONFIG_SYS_SPL_MALLOC_START 0x00182000 -#define CONFIG_SYS_SPL_MALLOC_SIZE 0x2000 /* 8 KB */ +#define CONFIG_SYS_SPL_MALLOC_START 0x42200000 +#define CONFIG_SYS_SPL_MALLOC_SIZE 0x80000 /* 512 KB */ #define CONFIG_SYS_ICACHE_OFF #define CONFIG_SYS_DCACHE_OFF +#define CONFIG_MALLOC_F_ADDR 0x182000 /* malloc f used before GD_FLG_FULL_MALLOC_INIT set */ + #define CONFIG_SPL_ABORT_ON_RAW_IMAGE /* For RAW image gives a error info not panic */ #undef CONFIG_DM_MMC -- 2.17.1