From patchwork Wed Apr 29 13:04:21 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Harald Seiler X-Patchwork-Id: 238876 List-Id: U-Boot discussion From: hws at denx.de (Harald Seiler) Date: Wed, 29 Apr 2020 15:04:21 +0200 Subject: [PATCH 1/8] ARM: imx8m: Do not define do_reset() if sysreset is enabled In-Reply-To: <20200429130428.124788-1-hws@denx.de> References: <20200429130428.124788-1-hws@denx.de> Message-ID: <20200429130428.124788-2-hws@denx.de> From: Marek Vasut The SPL can also be compiled with sysreset drivers just fine, so update the condition to cater for that option. Signed-off-by: Marek Vasut Cc: Fabio Estevam Cc: Flavio Suligoi Cc: Harald Seiler Cc: Igor Opaniuk Cc: Marcel Ziswiler Cc: Oleksandr Suvorov Cc: Peng Fan Cc: Stefano Babic --- arch/arm/mach-imx/imx8m/soc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/arm/mach-imx/imx8m/soc.c b/arch/arm/mach-imx/imx8m/soc.c index 7fcbd53f3020..0f17252e80b7 100644 --- a/arch/arm/mach-imx/imx8m/soc.c +++ b/arch/arm/mach-imx/imx8m/soc.c @@ -382,7 +382,7 @@ int ft_system_setup(void *blob, bd_t *bd) } #endif -#if defined(CONFIG_SPL_BUILD) || !defined(CONFIG_SYSRESET) +#if !CONFIG_IS_ENABLED(SYSRESET) void reset_cpu(ulong addr) { struct watchdog_regs *wdog = (struct watchdog_regs *)addr; From patchwork Wed Apr 29 13:04:22 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Harald Seiler X-Patchwork-Id: 238877 List-Id: U-Boot discussion From: hws at denx.de (Harald Seiler) Date: Wed, 29 Apr 2020 15:04:22 +0200 Subject: [PATCH 2/8] ARM: imx8m: Fix indentation of reset_cpu() function In-Reply-To: <20200429130428.124788-1-hws@denx.de> References: <20200429130428.124788-1-hws@denx.de> Message-ID: <20200429130428.124788-3-hws@denx.de> Use proper code-style, tabs instead of spaces for indentation. Signed-off-by: Harald Seiler --- arch/arm/mach-imx/imx8m/soc.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/arch/arm/mach-imx/imx8m/soc.c b/arch/arm/mach-imx/imx8m/soc.c index 0f17252e80b7..5b3fbe712c6b 100644 --- a/arch/arm/mach-imx/imx8m/soc.c +++ b/arch/arm/mach-imx/imx8m/soc.c @@ -385,18 +385,18 @@ int ft_system_setup(void *blob, bd_t *bd) #if !CONFIG_IS_ENABLED(SYSRESET) void reset_cpu(ulong addr) { - struct watchdog_regs *wdog = (struct watchdog_regs *)addr; + struct watchdog_regs *wdog = (struct watchdog_regs *)addr; - if (!addr) - wdog = (struct watchdog_regs *)WDOG1_BASE_ADDR; + if (!addr) + wdog = (struct watchdog_regs *)WDOG1_BASE_ADDR; - /* Clear WDA to trigger WDOG_B immediately */ - writew((WCR_WDE | WCR_SRS), &wdog->wcr); + /* Clear WDA to trigger WDOG_B immediately */ + writew((WCR_WDE | WCR_SRS), &wdog->wcr); - while (1) { - /* - * spin for .5 seconds before reset - */ - } + while (1) { + /* + * spin for .5 seconds before reset + */ + } } #endif From patchwork Wed Apr 29 13:04:23 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Harald Seiler X-Patchwork-Id: 238878 List-Id: U-Boot discussion From: hws at denx.de (Harald Seiler) Date: Wed, 29 Apr 2020 15:04:23 +0200 Subject: [PATCH 3/8] ARM: imx8m: Don't use the addr parameter of reset_cpu() In-Reply-To: <20200429130428.124788-1-hws@denx.de> References: <20200429130428.124788-1-hws@denx.de> Message-ID: <20200429130428.124788-4-hws@denx.de> From: Claudius Heine imx8m has the only implementation of reset_cpu() which does not ignore the addr parameter and instead gives it some meaning as the base address of watchdog registers. This breaks convention with the rest of U-Boot where the parameter is ignored and callers are passing in 0. Fixes: d2041725e84b ("imx8m: restrict reset_cpu") Co-developed-by: Harald Seiler Signed-off-by: Harald Seiler Signed-off-by: Claudius Heine --- arch/arm/mach-imx/imx8m/soc.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/arch/arm/mach-imx/imx8m/soc.c b/arch/arm/mach-imx/imx8m/soc.c index 5b3fbe712c6b..2fe1fa75fb05 100644 --- a/arch/arm/mach-imx/imx8m/soc.c +++ b/arch/arm/mach-imx/imx8m/soc.c @@ -385,10 +385,7 @@ int ft_system_setup(void *blob, bd_t *bd) #if !CONFIG_IS_ENABLED(SYSRESET) void reset_cpu(ulong addr) { - struct watchdog_regs *wdog = (struct watchdog_regs *)addr; - - if (!addr) - wdog = (struct watchdog_regs *)WDOG1_BASE_ADDR; + struct watchdog_regs *wdog = (struct watchdog_regs *)WDOG1_BASE_ADDR; /* Clear WDA to trigger WDOG_B immediately */ writew((WCR_WDE | WCR_SRS), &wdog->wcr); From patchwork Wed Apr 29 13:04:24 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Harald Seiler X-Patchwork-Id: 238880 List-Id: U-Boot discussion From: hws at denx.de (Harald Seiler) Date: Wed, 29 Apr 2020 15:04:24 +0200 Subject: [PATCH 4/8] ARM: imx8m: Fix reset in SPL on NXP iMX8MM EVK In-Reply-To: <20200429130428.124788-1-hws@denx.de> References: <20200429130428.124788-1-hws@denx.de> Message-ID: <20200429130428.124788-5-hws@denx.de> From: Marek Vasut Board files should not re-implement do_reset() to work around this function not being defined in for specific configurations. Rather, the fix is to compile in drivers which implement this properly. This patch enables sysreset and watchdog drivers in SPL and ties them together to implement the same as the do_reset() hack in the board file, except correctly in the DM/DT framework. Signed-off-by: Marek Vasut Cc: Fabio Estevam Cc: Flavio Suligoi Cc: Harald Seiler Cc: Igor Opaniuk Cc: Marcel Ziswiler Cc: Oleksandr Suvorov Cc: Peng Fan Cc: Stefano Babic --- arch/arm/dts/imx8mm-evk-u-boot.dtsi | 12 ++++++++++++ board/freescale/imx8mm_evk/spl.c | 9 --------- configs/imx8mm_evk_defconfig | 5 +++++ 3 files changed, 17 insertions(+), 9 deletions(-) diff --git a/arch/arm/dts/imx8mm-evk-u-boot.dtsi b/arch/arm/dts/imx8mm-evk-u-boot.dtsi index 3502602fbb86..b5c12105a9d1 100644 --- a/arch/arm/dts/imx8mm-evk-u-boot.dtsi +++ b/arch/arm/dts/imx8mm-evk-u-boot.dtsi @@ -3,6 +3,14 @@ * Copyright 2019 NXP */ +/ { + wdt-reboot { + compatible = "wdt-reboot"; + wdt = <&wdog1>; + u-boot,dm-spl; + }; +}; + &{/soc at 0} { u-boot,dm-pre-reloc; u-boot,dm-spl; @@ -117,3 +125,7 @@ &fec1 { phy-reset-gpios = <&gpio4 22 GPIO_ACTIVE_LOW>; }; + +&wdog1 { + u-boot,dm-spl; +}; diff --git a/board/freescale/imx8mm_evk/spl.c b/board/freescale/imx8mm_evk/spl.c index 5d17f397cb68..4d34622465b3 100644 --- a/board/freescale/imx8mm_evk/spl.c +++ b/board/freescale/imx8mm_evk/spl.c @@ -161,12 +161,3 @@ void board_init_f(ulong dummy) board_init_r(NULL, 0); } - -int do_reset(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) -{ - puts ("resetting ...\n"); - - reset_cpu(WDOG1_BASE_ADDR); - - return 0; -} diff --git a/configs/imx8mm_evk_defconfig b/configs/imx8mm_evk_defconfig index d988507bc330..120c76633066 100644 --- a/configs/imx8mm_evk_defconfig +++ b/configs/imx8mm_evk_defconfig @@ -30,6 +30,7 @@ CONFIG_SPL_BOARD_INIT=y CONFIG_SPL_SEPARATE_BSS=y CONFIG_SPL_I2C_SUPPORT=y CONFIG_SPL_POWER_SUPPORT=y +CONFIG_SPL_WATCHDOG_SUPPORT=y CONFIG_HUSH_PARSER=y CONFIG_SYS_PROMPT="u-boot=> " # CONFIG_CMD_EXPORTENV is not set @@ -82,5 +83,9 @@ CONFIG_DM_REGULATOR_FIXED=y CONFIG_DM_REGULATOR_GPIO=y CONFIG_MXC_UART=y CONFIG_SYSRESET=y +CONFIG_SPL_SYSRESET=y CONFIG_SYSRESET_PSCI=y +CONFIG_SYSRESET_WATCHDOG=y CONFIG_DM_THERMAL=y +# CONFIG_WATCHDOG is not set +CONFIG_IMX_WATCHDOG=y From patchwork Wed Apr 29 13:04:25 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Harald Seiler X-Patchwork-Id: 238881 List-Id: U-Boot discussion From: hws at denx.de (Harald Seiler) Date: Wed, 29 Apr 2020 15:04:25 +0200 Subject: [PATCH 5/8] ARM: imx8m: Fix reset in SPL on NXP iMX8MN EVK In-Reply-To: <20200429130428.124788-1-hws@denx.de> References: <20200429130428.124788-1-hws@denx.de> Message-ID: <20200429130428.124788-6-hws@denx.de> From: Marek Vasut Board files should not re-implement do_reset() to work around this function not being defined in for specific configurations. Rather, the fix is to compile in drivers which implement this properly. This patch enables sysreset and watchdog drivers in SPL and ties them together to implement the same as the do_reset() hack in the board file, except correctly in the DM/DT framework. Signed-off-by: Marek Vasut Cc: Fabio Estevam Cc: Flavio Suligoi Cc: Harald Seiler Cc: Igor Opaniuk Cc: Marcel Ziswiler Cc: Oleksandr Suvorov Cc: Peng Fan Cc: Stefano Babic --- arch/arm/dts/imx8mn-ddr4-evk-u-boot.dtsi | 12 ++++++++++++ board/freescale/imx8mn_evk/spl.c | 9 --------- configs/imx8mn_ddr4_evk_defconfig | 5 +++++ 3 files changed, 17 insertions(+), 9 deletions(-) diff --git a/arch/arm/dts/imx8mn-ddr4-evk-u-boot.dtsi b/arch/arm/dts/imx8mn-ddr4-evk-u-boot.dtsi index 8d61597e0ce0..4419679d4c66 100644 --- a/arch/arm/dts/imx8mn-ddr4-evk-u-boot.dtsi +++ b/arch/arm/dts/imx8mn-ddr4-evk-u-boot.dtsi @@ -3,6 +3,14 @@ * Copyright 2019 NXP */ +/ { + wdt-reboot { + compatible = "wdt-reboot"; + wdt = <&wdog1>; + u-boot,dm-spl; + }; +}; + &{/soc at 0} { u-boot,dm-pre-reloc; u-boot,dm-spl; @@ -90,3 +98,7 @@ &usdhc3 { u-boot,dm-spl; }; + +&wdog1 { + u-boot,dm-spl; +}; diff --git a/board/freescale/imx8mn_evk/spl.c b/board/freescale/imx8mn_evk/spl.c index 7aed14c52b68..45417b24464d 100644 --- a/board/freescale/imx8mn_evk/spl.c +++ b/board/freescale/imx8mn_evk/spl.c @@ -114,12 +114,3 @@ void board_init_f(ulong dummy) board_init_r(NULL, 0); } - -int do_reset(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) -{ - puts("resetting ...\n"); - - reset_cpu(WDOG1_BASE_ADDR); - - return 0; -} diff --git a/configs/imx8mn_ddr4_evk_defconfig b/configs/imx8mn_ddr4_evk_defconfig index f7485ab27270..224aeb6f0dfa 100644 --- a/configs/imx8mn_ddr4_evk_defconfig +++ b/configs/imx8mn_ddr4_evk_defconfig @@ -32,6 +32,7 @@ CONFIG_SPL_BOARD_INIT=y CONFIG_SPL_BOOTROM_SUPPORT=y CONFIG_SPL_SEPARATE_BSS=y CONFIG_SPL_I2C_SUPPORT=y +CONFIG_SPL_WATCHDOG_SUPPORT=y CONFIG_HUSH_PARSER=y CONFIG_SYS_PROMPT="u-boot=> " # CONFIG_CMD_EXPORTENV is not set @@ -76,5 +77,9 @@ CONFIG_DM_REGULATOR_FIXED=y CONFIG_DM_REGULATOR_GPIO=y CONFIG_MXC_UART=y CONFIG_SYSRESET=y +CONFIG_SPL_SYSRESET=y CONFIG_SYSRESET_PSCI=y +CONFIG_SYSRESET_WATCHDOG=y CONFIG_DM_THERMAL=y +# CONFIG_WATCHDOG is not set +CONFIG_IMX_WATCHDOG=y From patchwork Wed Apr 29 13:04:26 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Harald Seiler X-Patchwork-Id: 238882 List-Id: U-Boot discussion From: hws at denx.de (Harald Seiler) Date: Wed, 29 Apr 2020 15:04:26 +0200 Subject: [PATCH 6/8] ARM: imx8m: Fix reset in SPL on NXP iMX8MP EVK In-Reply-To: <20200429130428.124788-1-hws@denx.de> References: <20200429130428.124788-1-hws@denx.de> Message-ID: <20200429130428.124788-7-hws@denx.de> From: Marek Vasut Board files should not re-implement do_reset() to work around this function not being defined in for specific configurations. Rather, the fix is to compile in drivers which implement this properly. This patch enables sysreset and watchdog drivers in SPL and ties them together to implement the same as the do_reset() hack in the board file, except correctly in the DM/DT framework. Signed-off-by: Marek Vasut Cc: Fabio Estevam Cc: Flavio Suligoi Cc: Harald Seiler Cc: Igor Opaniuk Cc: Marcel Ziswiler Cc: Oleksandr Suvorov Cc: Peng Fan Cc: Stefano Babic --- arch/arm/dts/imx8mp-evk-u-boot.dtsi | 12 ++++++++++++ board/freescale/imx8mp_evk/spl.c | 9 --------- configs/imx8mp_evk_defconfig | 4 ++++ 3 files changed, 16 insertions(+), 9 deletions(-) diff --git a/arch/arm/dts/imx8mp-evk-u-boot.dtsi b/arch/arm/dts/imx8mp-evk-u-boot.dtsi index 4675ada0a0a9..24a93ac2d690 100644 --- a/arch/arm/dts/imx8mp-evk-u-boot.dtsi +++ b/arch/arm/dts/imx8mp-evk-u-boot.dtsi @@ -3,6 +3,14 @@ * Copyright 2019 NXP */ +/ { + wdt-reboot { + compatible = "wdt-reboot"; + wdt = <&wdog1>; + u-boot,dm-spl; + }; +}; + &{/soc at 0} { u-boot,dm-pre-reloc; u-boot,dm-spl; @@ -119,3 +127,7 @@ &usdhc3 { u-boot,dm-spl; }; + +&wdog1 { + u-boot,dm-spl; +}; diff --git a/board/freescale/imx8mp_evk/spl.c b/board/freescale/imx8mp_evk/spl.c index 0b20668e2b30..39c1dae684ac 100644 --- a/board/freescale/imx8mp_evk/spl.c +++ b/board/freescale/imx8mp_evk/spl.c @@ -149,12 +149,3 @@ void board_init_f(ulong dummy) board_init_r(NULL, 0); } - -int do_reset(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) -{ - puts("resetting ...\n"); - - reset_cpu(WDOG1_BASE_ADDR); - - return 0; -} diff --git a/configs/imx8mp_evk_defconfig b/configs/imx8mp_evk_defconfig index ce6b342c3672..09ed7a89c9aa 100644 --- a/configs/imx8mp_evk_defconfig +++ b/configs/imx8mp_evk_defconfig @@ -81,4 +81,8 @@ CONFIG_DM_REGULATOR_FIXED=y CONFIG_DM_REGULATOR_GPIO=y CONFIG_MXC_UART=y CONFIG_SYSRESET=y +CONFIG_SPL_SYSRESET=y CONFIG_SYSRESET_PSCI=y +CONFIG_SYSRESET_WATCHDOG=y +# CONFIG_WATCHDOG is not set +CONFIG_IMX_WATCHDOG=y From patchwork Wed Apr 29 13:04:27 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Harald Seiler X-Patchwork-Id: 238879 List-Id: U-Boot discussion From: hws at denx.de (Harald Seiler) Date: Wed, 29 Apr 2020 15:04:27 +0200 Subject: [PATCH 7/8] ARM: imx8m: Fix reset in SPL on Toradex iMX8MM Verdin In-Reply-To: <20200429130428.124788-1-hws@denx.de> References: <20200429130428.124788-1-hws@denx.de> Message-ID: <20200429130428.124788-8-hws@denx.de> From: Marek Vasut Board files should not re-implement do_reset() to work around this function not being defined in for specific configurations. Rather, the fix is to compile in drivers which implement this properly. This patch enables sysreset and watchdog drivers in SPL and ties them together to implement the same as the do_reset() hack in the board file, except correctly in the DM/DT framework. Signed-off-by: Marek Vasut Cc: Fabio Estevam Cc: Flavio Suligoi Cc: Harald Seiler Cc: Igor Opaniuk Cc: Marcel Ziswiler Cc: Oleksandr Suvorov Cc: Peng Fan Cc: Stefano Babic Reviewed-by: Oleksandr Suvorov Acked-by: Igor Opaniuk Acked-by: Igor Opaniuk --- arch/arm/dts/imx8mm-verdin-u-boot.dtsi | 12 ++++++++++++ board/toradex/verdin-imx8mm/spl.c | 9 --------- configs/verdin-imx8mm_defconfig | 5 +++++ 3 files changed, 17 insertions(+), 9 deletions(-) diff --git a/arch/arm/dts/imx8mm-verdin-u-boot.dtsi b/arch/arm/dts/imx8mm-verdin-u-boot.dtsi index e60b9faee442..fe6bb9bf03cf 100644 --- a/arch/arm/dts/imx8mm-verdin-u-boot.dtsi +++ b/arch/arm/dts/imx8mm-verdin-u-boot.dtsi @@ -3,6 +3,14 @@ * Copyright 2020 Toradex */ +/ { + wdt-reboot { + compatible = "wdt-reboot"; + wdt = <&wdog1>; + u-boot,dm-spl; + }; +}; + &aips1 { u-boot,dm-spl; u-boot,dm-pre-reloc; @@ -105,3 +113,7 @@ &usdhc3 { u-boot,dm-spl; }; + +&wdog1 { + u-boot,dm-spl; +}; diff --git a/board/toradex/verdin-imx8mm/spl.c b/board/toradex/verdin-imx8mm/spl.c index a5dc54082054..dc5bd84f332e 100644 --- a/board/toradex/verdin-imx8mm/spl.c +++ b/board/toradex/verdin-imx8mm/spl.c @@ -169,12 +169,3 @@ void board_init_f(ulong dummy) board_init_r(NULL, 0); } - -int do_reset(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) -{ - puts("resetting ...\n"); - - reset_cpu(WDOG1_BASE_ADDR); - - return 0; -} diff --git a/configs/verdin-imx8mm_defconfig b/configs/verdin-imx8mm_defconfig index 590750e9b2d1..21f6aa308208 100644 --- a/configs/verdin-imx8mm_defconfig +++ b/configs/verdin-imx8mm_defconfig @@ -38,6 +38,7 @@ CONFIG_SPL_SEPARATE_BSS=y CONFIG_SPL_I2C_SUPPORT=y CONFIG_SPL_POWER_SUPPORT=y CONFIG_SPL_USB_HOST_SUPPORT=y +CONFIG_SPL_WATCHDOG_SUPPORT=y CONFIG_SYS_PROMPT="Verdin iMX8MM # " # CONFIG_BOOTM_NETBSD is not set CONFIG_CMD_ASKENV=y @@ -94,5 +95,9 @@ CONFIG_DM_REGULATOR_FIXED=y CONFIG_DM_REGULATOR_GPIO=y CONFIG_MXC_UART=y CONFIG_SYSRESET=y +CONFIG_SPL_SYSRESET=y CONFIG_SYSRESET_PSCI=y +CONFIG_SYSRESET_WATCHDOG=y CONFIG_DM_THERMAL=y +# CONFIG_WATCHDOG is not set +CONFIG_IMX_WATCHDOG=y From patchwork Wed Apr 29 13:04:28 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Harald Seiler X-Patchwork-Id: 238883 List-Id: U-Boot discussion From: hws at denx.de (Harald Seiler) Date: Wed, 29 Apr 2020 15:04:28 +0200 Subject: [PATCH 8/8] ARM: reset: use do_reset in SPL/TPL if SYSRESET was not enabled for them In-Reply-To: <20200429130428.124788-1-hws@denx.de> References: <20200429130428.124788-1-hws@denx.de> Message-ID: <20200429130428.124788-9-hws@denx.de> From: Claudius Heine In case CONFIG_SYSRESET is set, do_reset() from reset.c will not be available anywere, even if SYSRESET is disabled for SPL/TPL. do_reset() is called from SPL for instance from the panic handler and PANIC_HANG is not set Signed-off-by: Claudius Heine --- arch/arm/lib/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/arm/lib/Makefile b/arch/arm/lib/Makefile index 8482f5446c5c..b839aa7a5096 100644 --- a/arch/arm/lib/Makefile +++ b/arch/arm/lib/Makefile @@ -57,7 +57,7 @@ obj-y += interrupts_64.o else obj-y += interrupts.o endif -ifndef CONFIG_SYSRESET +ifndef CONFIG_$(SPL_TPL_)SYSRESET obj-y += reset.o endif