diff mbox series

[7/8] ARM: imx8m: Fix reset in SPL on Toradex iMX8MM Verdin

Message ID 20200429130428.124788-8-hws@denx.de
State New
Headers show
Series ARM: imx: Fix reset in SPL | expand

Commit Message

Harald Seiler April 29, 2020, 1:04 p.m. UTC
From: Marek Vasut <marex at denx.de>

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 <marex at denx.de>
Cc: Fabio Estevam <festevam at gmail.com>
Cc: Flavio Suligoi <f.suligoi at asem.it>
Cc: Harald Seiler <hws at denx.de>
Cc: Igor Opaniuk <igor.opaniuk at toradex.com>
Cc: Marcel Ziswiler <marcel.ziswiler at toradex.com>
Cc: Oleksandr Suvorov <oleksandr.suvorov at toradex.com>
Cc: Peng Fan <peng.fan at nxp.com>
Cc: Stefano Babic <sbabic at denx.de>
---
 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(-)

Comments

Oleksandr Suvorov April 29, 2020, 2:13 p.m. UTC | #1
On Wed, Apr 29, 2020 at 4:05 PM Harald Seiler <hws at denx.de> wrote:
>
> From: Marek Vasut <marex at denx.de>
>
> 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 <marex at denx.de>
> Cc: Fabio Estevam <festevam at gmail.com>
> Cc: Flavio Suligoi <f.suligoi at asem.it>
> Cc: Harald Seiler <hws at denx.de>
> Cc: Igor Opaniuk <igor.opaniuk at toradex.com>
> Cc: Marcel Ziswiler <marcel.ziswiler at toradex.com>
> Cc: Oleksandr Suvorov <oleksandr.suvorov at toradex.com>
> Cc: Peng Fan <peng.fan at nxp.com>
> Cc: Stefano Babic <sbabic at denx.de>

Thanks, Harald!

Reviewed-by: Oleksandr Suvorov <oleksandr.suvorov at toradex.com>

> ---
>  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
> --
> 2.26.2
>
Igor Opaniuk April 29, 2020, 3:46 p.m. UTC | #2
Hello Herald,

On Wed, Apr 29, 2020 at 4:06 PM Harald Seiler <hws at denx.de> wrote:
>
> From: Marek Vasut <marex at denx.de>
>
> 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 <marex at denx.de>
> Cc: Fabio Estevam <festevam at gmail.com>
> Cc: Flavio Suligoi <f.suligoi at asem.it>
> Cc: Harald Seiler <hws at denx.de>
> Cc: Igor Opaniuk <igor.opaniuk at toradex.com>
> Cc: Marcel Ziswiler <marcel.ziswiler at toradex.com>
> Cc: Oleksandr Suvorov <oleksandr.suvorov at toradex.com>
> Cc: Peng Fan <peng.fan at nxp.com>
> Cc: Stefano Babic <sbabic at denx.de>
> ---
>  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
> --
> 2.26.2
>

Acked-by: Igor Opaniuk <igor.opaniuk at toradex.com>
Igor Opaniuk April 29, 2020, 3:48 p.m. UTC | #3
Harald,

sorry for the typo in the previous email.

On Wed, Apr 29, 2020 at 4:06 PM Harald Seiler <hws at denx.de> wrote:
>
> From: Marek Vasut <marex at denx.de>
>
> 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 <marex at denx.de>
> Cc: Fabio Estevam <festevam at gmail.com>
> Cc: Flavio Suligoi <f.suligoi at asem.it>
> Cc: Harald Seiler <hws at denx.de>
> Cc: Igor Opaniuk <igor.opaniuk at toradex.com>
> Cc: Marcel Ziswiler <marcel.ziswiler at toradex.com>
> Cc: Oleksandr Suvorov <oleksandr.suvorov at toradex.com>
> Cc: Peng Fan <peng.fan at nxp.com>
> Cc: Stefano Babic <sbabic at denx.de>
> ---
>  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
> --
> 2.26.2
>

Acked-by: Igor Opaniuk <igor.opaniuk at toradex.com>

Thanks!
Stefano Babic May 1, 2020, 4:31 p.m. UTC | #4
> From: Marek Vasut <marex at denx.de>
> 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 <marex at denx.de>
> Cc: Fabio Estevam <festevam at gmail.com>
> Cc: Flavio Suligoi <f.suligoi at asem.it>
> Cc: Harald Seiler <hws at denx.de>
> Cc: Igor Opaniuk <igor.opaniuk at toradex.com>
> Cc: Marcel Ziswiler <marcel.ziswiler at toradex.com>
> Cc: Oleksandr Suvorov <oleksandr.suvorov at toradex.com>
> Cc: Peng Fan <peng.fan at nxp.com>
> Cc: Stefano Babic <sbabic at denx.de>
> Reviewed-by: Oleksandr Suvorov <oleksandr.suvorov at toradex.com>
> Acked-by: Igor Opaniuk <igor.opaniuk at toradex.com>
> Acked-by: Igor Opaniuk <igor.opaniuk at toradex.com>
Applied to u-boot-imx, master, thanks !

Best regards,
Stefano Babic
diff mbox series

Patch

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