From 7e962cb132d6056b0a6f75eee2d800c9422da961 Mon Sep 17 00:00:00 2001 From: Pali Rohár Date: Mon, 1 Aug 2022 15:31:45 +0200 Subject: board: freescale: p1_p2_rdb_pc: Avoid usage of CPLD's system reset register CPLD's system reset register is buggy and requires workaround in U-Boot. So use this kind of board reset only when there is no other reset option. Introduce a new board_reset_last() callback which is last-stage board-specific reset and implement CPLD's system reset in this new board_reset_last() callback instead of board_reset() callback. Fixes: 20fb58fc5a1c ("board: freescale: p1_p2_rdb_pc: Implement board_reset()") Signed-off-by: Pali Rohár Signed-off-by: Peng Fan --- arch/powerpc/cpu/mpc85xx/cpu.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'arch/powerpc/cpu') diff --git a/arch/powerpc/cpu/mpc85xx/cpu.c b/arch/powerpc/cpu/mpc85xx/cpu.c index 1b6cdc4df02..3a503b9b4f2 100644 --- a/arch/powerpc/cpu/mpc85xx/cpu.c +++ b/arch/powerpc/cpu/mpc85xx/cpu.c @@ -45,6 +45,7 @@ __board_reset(void) /* Do nothing */ } void board_reset(void) __attribute__((weak, alias("__board_reset"))); +void board_reset_last(void) __attribute__((weak, alias("__board_reset"))); int checkcpu (void) { @@ -325,6 +326,9 @@ int do_reset(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) /* Next try asserting HRESET_REQ */ out_be32(&gur->rstcr, 0x2); udelay(100); + + /* Attempt last-stage board-specific reset */ + board_reset_last(); #endif return 1; -- cgit v1.2.3 From 44366be10a9386a8887124a77a7d06169c3aa1f3 Mon Sep 17 00:00:00 2001 From: Pali Rohár Date: Mon, 1 Aug 2022 15:31:46 +0200 Subject: board: freescale: p1_p2_rdb_pc: Turn off watchdog before reset P1/P2 RDB boards have external max6370 watchdog connected to CPLD and this watchdog is not deactivated on board reset. So if it is active during board reset, it can trigger another reset when CPU is booting U-Boot. To prevent possible infinite reset loop caused by external watchdog, turn it off before reset. Do it via a new board_reset_prepare() callback which is called from do_reset() function before any reset sequence. Signed-off-by: Pali Rohár Signed-off-by: Peng Fan --- arch/powerpc/cpu/mpc85xx/cpu.c | 4 ++++ board/freescale/p1_p2_rdb_pc/p1_p2_rdb_pc.c | 12 ++++++++++++ 2 files changed, 16 insertions(+) (limited to 'arch/powerpc/cpu') diff --git a/arch/powerpc/cpu/mpc85xx/cpu.c b/arch/powerpc/cpu/mpc85xx/cpu.c index 3a503b9b4f2..14d5c560bf8 100644 --- a/arch/powerpc/cpu/mpc85xx/cpu.c +++ b/arch/powerpc/cpu/mpc85xx/cpu.c @@ -44,6 +44,7 @@ __board_reset(void) { /* Do nothing */ } +void board_reset_prepare(void) __attribute__((weak, alias("__board_reset"))); void board_reset(void) __attribute__((weak, alias("__board_reset"))); void board_reset_last(void) __attribute__((weak, alias("__board_reset"))); @@ -320,6 +321,9 @@ int do_reset(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) #else volatile ccsr_gur_t *gur = (void *)(CONFIG_SYS_MPC85xx_GUTS_ADDR); + /* Call board-specific preparation for reset */ + board_reset_prepare(); + /* Attempt board-specific reset */ board_reset(); diff --git a/board/freescale/p1_p2_rdb_pc/p1_p2_rdb_pc.c b/board/freescale/p1_p2_rdb_pc/p1_p2_rdb_pc.c index e690fb4fbce..25906d3fc01 100644 --- a/board/freescale/p1_p2_rdb_pc/p1_p2_rdb_pc.c +++ b/board/freescale/p1_p2_rdb_pc/p1_p2_rdb_pc.c @@ -83,6 +83,18 @@ struct cpld_data { #define CPLD_FXS_LED 0x0F #define CPLD_SYS_RST 0x00 +void board_reset_prepare(void) +{ + /* + * During reset preparation, turn off external watchdog. + * This ensures that external watchdog does not trigger + * another reset or possible infinite reset loop. + */ + struct cpld_data *cpld_data = (void *)(CONFIG_SYS_CPLD_BASE); + out_8(&cpld_data->wd_cfg, CPLD_WD_CFG); + in_8(&cpld_data->wd_cfg); /* Read back to sync write */ +} + void board_reset_last(void) { struct cpld_data *cpld_data = (void *)(CONFIG_SYS_CPLD_BASE); -- cgit v1.2.3 From 1e1d12adbc7bad37ea42351835ba864d5089f76c Mon Sep 17 00:00:00 2001 From: Marek Behún Date: Thu, 15 Sep 2022 16:08:27 +0200 Subject: powerpc: mpc85xx: Fix check for CONFIG_SDCARD Commit d433c74eecdc ("Convert CONFIG_SDCARD et al to Kconfig") converted SYS_EXTRA_OPTIONS=SDCARD or SPIFLASH to config options CONFIG_SDCARD and CONFIG_SPIFLASH, but left one occurance unchanged. Fix this. Fixes: d433c74eecdc ("Convert CONFIG_SDCARD et al to Kconfig") Signed-off-by: Marek Behún Reviewed-by: Pali Rohár --- arch/powerpc/cpu/mpc85xx/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'arch/powerpc/cpu') diff --git a/arch/powerpc/cpu/mpc85xx/Kconfig b/arch/powerpc/cpu/mpc85xx/Kconfig index 085ddd8439f..27f069a1fb3 100644 --- a/arch/powerpc/cpu/mpc85xx/Kconfig +++ b/arch/powerpc/cpu/mpc85xx/Kconfig @@ -15,7 +15,7 @@ config CMD_ERRATA config FSL_PREPBL_ESDHC_BOOT_SECTOR bool "Generate QorIQ pre-PBL eSDHC boot sector" depends on MPC85xx - depends on SYS_EXTRA_OPTIONS = SDCARD + depends on SDCARD help With this option final image would have prepended QorIQ pre-PBL eSDHC boot sector suitable for SD card images. This boot sector instruct -- cgit v1.2.3 From 7696b80ec5e90ec3c2fa759cfe129918ce0e0a26 Mon Sep 17 00:00:00 2001 From: Pali Rohár Date: Fri, 5 Aug 2022 22:09:40 +0200 Subject: powerpc: mpc85xx: Fix loading U-Boot proper from SD card in SPL Change 8-byte alignment of SPL binary to just 4-byte alignment as objcopy trims trailing zero bytes when converting ELF file to RAW binary. This is same fix for SPL linker script as was done fix for U-Boot linker script in commit e8c0e0064c8a ("powerpc: mpc85xx: Fix CONFIG_OF_SEPARATE support"). It is required for the patch "mmc: fsl_esdhc_spl: Add support for builds without CONFIG_SYS_MMC_U_BOOT_OFFS" which triggered this issue in SPL. Signed-off-by: Pali Rohár Signed-off-by: Marek Behún --- arch/powerpc/cpu/mpc85xx/u-boot-spl.lds | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'arch/powerpc/cpu') diff --git a/arch/powerpc/cpu/mpc85xx/u-boot-spl.lds b/arch/powerpc/cpu/mpc85xx/u-boot-spl.lds index e8815374523..89df4b5f6f0 100644 --- a/arch/powerpc/cpu/mpc85xx/u-boot-spl.lds +++ b/arch/powerpc/cpu/mpc85xx/u-boot-spl.lds @@ -58,7 +58,7 @@ SECTIONS __ex_table : { *(__ex_table) } __stop___ex_table = .; - . = ALIGN(8); + . = ALIGN(4); __init_begin = .; __init_end = .; _end = .; -- cgit v1.2.3 From 5a428e751044525f95d15f180188cc7433648b82 Mon Sep 17 00:00:00 2001 From: Pali Rohár Date: Fri, 5 Aug 2022 22:09:41 +0200 Subject: mmc: fsl_esdhc_spl: Add support for builds without CONFIG_SYS_MMC_U_BOOT_OFFS When fixed offset via CONFIG_SYS_MMC_U_BOOT_OFFS is not specified then expects that U-Boot proper is placed immediately after SPL without any additional padding. This allows to generate smaller SPL+U-Boot final binary as it is not required to specify fixed offset to U-Boot proper at SPL compile time. In this case offset to U-Boot proper is calculated at SPL compile time in linker script. Signed-off-by: Pali Rohár Reviewed-by: Jaehoon Chung Signed-off-by: Marek Behún --- arch/powerpc/cpu/mpc85xx/u-boot-spl.lds | 10 ++++++++++ drivers/mmc/fsl_esdhc_spl.c | 8 ++++++++ 2 files changed, 18 insertions(+) (limited to 'arch/powerpc/cpu') diff --git a/arch/powerpc/cpu/mpc85xx/u-boot-spl.lds b/arch/powerpc/cpu/mpc85xx/u-boot-spl.lds index 89df4b5f6f0..a36aa1793dd 100644 --- a/arch/powerpc/cpu/mpc85xx/u-boot-spl.lds +++ b/arch/powerpc/cpu/mpc85xx/u-boot-spl.lds @@ -62,6 +62,13 @@ SECTIONS __init_begin = .; __init_end = .; _end = .; + +#ifndef KEEP_RESET_VECTOR +#if defined(CONFIG_SD_BOOT) && !defined(CONFIG_SYS_MMC_U_BOOT_OFFS) + mmc_u_boot_offs = .; +#endif +#endif + #ifdef CONFIG_SPL_SKIP_RELOCATE . = ALIGN(4); __bss_start = .; @@ -94,6 +101,9 @@ SECTIONS .resetvec IMAGE_TEXT_BASE + RESET_VECTOR_OFFSET : { KEEP(*(.resetvec)) } = 0xffff +#if defined(CONFIG_SD_BOOT) && !defined(CONFIG_SYS_MMC_U_BOOT_OFFS) + mmc_u_boot_offs = .; +#endif #endif #ifndef CONFIG_SPL_SKIP_RELOCATE diff --git a/drivers/mmc/fsl_esdhc_spl.c b/drivers/mmc/fsl_esdhc_spl.c index dd6d5fa81ea..aa00d7e2014 100644 --- a/drivers/mmc/fsl_esdhc_spl.c +++ b/drivers/mmc/fsl_esdhc_spl.c @@ -9,6 +9,10 @@ #include #include +#ifndef CONFIG_SYS_MMC_U_BOOT_OFFS +extern uchar mmc_u_boot_offs[]; +#endif + /* * The environment variables are written to just after the u-boot image * on SDCard, so we must read the MBR to get the start address and code @@ -149,7 +153,11 @@ again: val = *(tmp_buf + blk_off + ESDHC_BOOT_IMAGE_ADDR + i); offset = (offset << 8) + val; } +#ifndef CONFIG_SYS_MMC_U_BOOT_OFFS + offset += (ulong)&mmc_u_boot_offs - CONFIG_SPL_TEXT_BASE; +#else offset += CONFIG_SYS_MMC_U_BOOT_OFFS; +#endif #endif /* * Load U-Boot image from mmc into RAM -- cgit v1.2.3 From a0759684e015bd7252be3af508c0fcfdbb8ec5dc Mon Sep 17 00:00:00 2001 From: Marek Behún Date: Mon, 19 Sep 2022 11:32:08 +0200 Subject: powerpc: mpc85xx: Fix incorrect application of patch I messed up application of patch 5a428e751044 ("mmc: fsl_esdhc_spl: Add support for builds without CONFIG_SYS_MMC_U_BOOT_OFFS"). I took it from a work-in-progress branch where I changed usage of CONFIG_SDCARD to CONFIG_SD_BOOT and refactored SYS_MPC85XX_NO_RESETVEC mess. But these changes aren't in master yet. Fix the wrong usage of these macros. Fixes: 5a428e751044 ("mmc: fsl_esdhc_spl: Add support for builds without CONFIG_SYS_MMC_U_BOOT_OFFS") Signed-off-by: Marek Behún Reviewed-by: Pali Rohár --- arch/powerpc/cpu/mpc85xx/u-boot-spl.lds | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'arch/powerpc/cpu') diff --git a/arch/powerpc/cpu/mpc85xx/u-boot-spl.lds b/arch/powerpc/cpu/mpc85xx/u-boot-spl.lds index a36aa1793dd..f28826c5d1a 100644 --- a/arch/powerpc/cpu/mpc85xx/u-boot-spl.lds +++ b/arch/powerpc/cpu/mpc85xx/u-boot-spl.lds @@ -63,8 +63,8 @@ SECTIONS __init_end = .; _end = .; -#ifndef KEEP_RESET_VECTOR -#if defined(CONFIG_SD_BOOT) && !defined(CONFIG_SYS_MMC_U_BOOT_OFFS) +#if CONFIG_IS_ENABLED(SYS_MPC85XX_NO_RESETVEC) +#if defined(CONFIG_SDCARD) && !defined(CONFIG_SYS_MMC_U_BOOT_OFFS) mmc_u_boot_offs = .; #endif #endif @@ -101,7 +101,7 @@ SECTIONS .resetvec IMAGE_TEXT_BASE + RESET_VECTOR_OFFSET : { KEEP(*(.resetvec)) } = 0xffff -#if defined(CONFIG_SD_BOOT) && !defined(CONFIG_SYS_MMC_U_BOOT_OFFS) +#if defined(CONFIG_SDCARD) && !defined(CONFIG_SYS_MMC_U_BOOT_OFFS) mmc_u_boot_offs = .; #endif #endif -- cgit v1.2.3