[PATCH 1/5] ARM: imx: Do not define do_reset() if sysreset is enabled

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

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

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@denx.de Cc: Fabio Estevam festevam@gmail.com Cc: Flavio Suligoi f.suligoi@asem.it Cc: Harald Seiler hws@denx.de Cc: Igor Opaniuk igor.opaniuk@toradex.com Cc: Marcel Ziswiler marcel.ziswiler@toradex.com Cc: Oleksandr Suvorov oleksandr.suvorov@toradex.com Cc: Peng Fan peng.fan@nxp.com Cc: Stefano Babic sbabic@denx.de --- 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 8d61597e0c..4419679d4c 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@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 7aed14c52b..45417b2446 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 e3f99896a6..bfc7b90bc9 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

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@denx.de Cc: Fabio Estevam festevam@gmail.com Cc: Flavio Suligoi f.suligoi@asem.it Cc: Harald Seiler hws@denx.de Cc: Igor Opaniuk igor.opaniuk@toradex.com Cc: Marcel Ziswiler marcel.ziswiler@toradex.com Cc: Oleksandr Suvorov oleksandr.suvorov@toradex.com Cc: Peng Fan peng.fan@nxp.com Cc: Stefano Babic sbabic@denx.de --- 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 4675ada0a0..24a93ac2d6 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@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 0b20668e2b..39c1dae684 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 b181543df5..e9163ec7ca 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

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

Hello Marek,
On Tue, 2020-04-28 at 16:22 +0200, Marek Vasut wrote:
The SPL can also be compiled with sysreset drivers just fine, so update the condition to cater for that option.
Me and Claudius solved the same problem in a different way a while back (see [1] and [2]).
The two approaches overlap but both contain some unique code that is useful. I'll merge the two patchsets and send them anew if that is ok with you.
[1]: https://lists.denx.de/pipermail/u-boot/2020-March/401935.html [2]: https://patchwork.ozlabs.org/project/uboot/list/?series=162379
Signed-off-by: Marek Vasut marex@denx.de Cc: Fabio Estevam festevam@gmail.com Cc: Flavio Suligoi f.suligoi@asem.it Cc: Harald Seiler hws@denx.de Cc: Igor Opaniuk igor.opaniuk@toradex.com Cc: Marcel Ziswiler marcel.ziswiler@toradex.com Cc: Oleksandr Suvorov oleksandr.suvorov@toradex.com Cc: Peng Fan peng.fan@nxp.com Cc: Stefano Babic sbabic@denx.de
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 7fcbd53f30..0f17252e80 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;

On 4/28/20 11:23 PM, Harald Seiler wrote:
Hello Marek,
Hi,
On Tue, 2020-04-28 at 16:22 +0200, Marek Vasut wrote:
The SPL can also be compiled with sysreset drivers just fine, so update the condition to cater for that option.
Me and Claudius solved the same problem in a different way a while back (see [1] and [2]).
The two approaches overlap but both contain some unique code that is useful. I'll merge the two patchsets and send them anew if that is ok with you.
Can you be more specific about what is your plan ?
Since the MX8M already has DM enabled in SPL for quite a few things and has enough SRAM space left, I would be inclined to just go with DM-based implementation of the reset over a non-DM one.

Hello Marek,
On Wed, 2020-04-29 at 00:26 +0200, Marek Vasut wrote:
On 4/28/20 11:23 PM, Harald Seiler wrote:
Hello Marek,
Hi,
On Tue, 2020-04-28 at 16:22 +0200, Marek Vasut wrote:
The SPL can also be compiled with sysreset drivers just fine, so update the condition to cater for that option.
Me and Claudius solved the same problem in a different way a while back (see [1] and [2]).
The two approaches overlap but both contain some unique code that is useful. I'll merge the two patchsets and send them anew if that is ok with you.
Can you be more specific about what is your plan ?
Since the MX8M already has DM enabled in SPL for quite a few things and has enough SRAM space left, I would be inclined to just go with DM-based implementation of the reset over a non-DM one.
For me personally, the patch I care most about is the first of Claudius and my series ("ARM: reset: use do_reset in SPL/TPL if SYSRESET was not enabled for them") [1]. It is necessary to make SPL_USB_SDP_SUPPORT work on the DH imx6 board (which does not use SYSRESET in SPL at the moment).
As this patch breaks the imx8m* boards in their present form, we tried fixing them in their current non-DM state in "imx: imx8m*: Remove do_reset from board files" [2] and "imx: imx8m: Don't use the addr parameter of reset_cpu" [3]. These patches are theoretically superseeded by your series which solves the problem much better and more future-proof. But I think it would not hurt to pull in Claudius and my changes as well so the non-DM version isn't lying around, silently broken.
Additionally, "imx: imx8m: Don't use the addr parameter of reset_cpu" [3] is groundwork for removing this addr parameter altogether from the whole tree which I want to do after this imx8 story is over.
So to summarize, the final state I'd want is this:
- "ARM: reset: use do_reset in SPL/TPL if SYSRESET was not enabled for them" is applied for my own needs. - No board defines do_reset(). - The imx8m boards use DM_SYSRESET in SPL (from your patches). - The non-DM reset code for imx8 is also fixed, even though it is not used in any mainline board anymore.
[1]: https://patchwork.ozlabs.org/project/uboot/patch/62c163018998fcf476f0ad2edf8... [2]: https://patchwork.ozlabs.org/project/uboot/patch/25277ba3658920ff3be74640204... [3]: https://patchwork.ozlabs.org/project/uboot/patch/b31a2cbb66950bff2e09ab07b71...

On 4/29/20 10:57 AM, Harald Seiler wrote:
Hello Marek,
Hi,
On Wed, 2020-04-29 at 00:26 +0200, Marek Vasut wrote:
On 4/28/20 11:23 PM, Harald Seiler wrote:
Hello Marek,
Hi,
On Tue, 2020-04-28 at 16:22 +0200, Marek Vasut wrote:
The SPL can also be compiled with sysreset drivers just fine, so update the condition to cater for that option.
Me and Claudius solved the same problem in a different way a while back (see [1] and [2]).
The two approaches overlap but both contain some unique code that is useful. I'll merge the two patchsets and send them anew if that is ok with you.
Can you be more specific about what is your plan ?
Since the MX8M already has DM enabled in SPL for quite a few things and has enough SRAM space left, I would be inclined to just go with DM-based implementation of the reset over a non-DM one.
For me personally, the patch I care most about is the first of Claudius and my series ("ARM: reset: use do_reset in SPL/TPL if SYSRESET was not enabled for them") [1]. It is necessary to make SPL_USB_SDP_SUPPORT work on the DH imx6 board (which does not use SYSRESET in SPL at the moment).
As this patch breaks the imx8m* boards in their present form, we tried fixing them in their current non-DM state in "imx: imx8m*: Remove do_reset from board files" [2] and "imx: imx8m: Don't use the addr parameter of reset_cpu" [3]. These patches are theoretically superseeded by your series which solves the problem much better and more future-proof. But I think it would not hurt to pull in Claudius and my changes as well so the non-DM version isn't lying around, silently broken.
Additionally, "imx: imx8m: Don't use the addr parameter of reset_cpu" [3] is groundwork for removing this addr parameter altogether from the whole tree which I want to do after this imx8 story is over.
So to summarize, the final state I'd want is this:
- "ARM: reset: use do_reset in SPL/TPL if SYSRESET was not enabled for them" is applied for my own needs. - No board defines do_reset(). - The imx8m boards use DM_SYSRESET in SPL (from your patches). - The non-DM reset code for imx8 is also fixed, even though it is not used in any mainline board anymore.
All right, I totally forgot about the MX6 SDP. So go ahead, prepare a series and let's see how that looks.
participants (2)
-
Harald Seiler
-
Marek Vasut