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 <[email protected]>
Cc: Fabio Estevam <[email protected]>
Cc: Flavio Suligoi <[email protected]>
Cc: Harald Seiler <[email protected]>
Cc: Igor Opaniuk <[email protected]>
Cc: Marcel Ziswiler <[email protected]>
Cc: Oleksandr Suvorov <[email protected]>
Cc: Peng Fan <[email protected]>
Cc: Stefano Babic <[email protected]>
---
 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 3502602fbb..b5c12105a9 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@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 5d17f397cb..4d34622465 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 1403067130..61e89633cd 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
-- 
2.25.1

Reply via email to