diff mbox series

[6/8] ARM: imx8m: Fix reset in SPL on NXP iMX8MP EVK

Message ID 20200429130428.124788-7-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/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(-)

Comments

Stefano Babic May 1, 2020, 4:31 p.m. UTC | #1
> 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>
Applied to u-boot-imx, master, thanks !

Best regards,
Stefano Babic
Fabio Estevam May 4, 2020, 2:27 p.m. UTC | #2
Hi,

On Wed, Apr 29, 2020 at 10:05 AM 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>

I noticed that this patch breaks the boot on i.MX8MP EVK. Only the
following line is printed on boot:

U-Boot SPL 2020.07-rc1-00014-g8142a97d54 (May 04 2020 - 11:15:50 -0300)

If I revert this patch I can boot it again:

U-Boot SPL 2020.07-rc1-00015-g02cd8db94f (May 04 2020 - 11:17:25 -0300)
Normal Boot
Failed to find clock node. Check device tree
WDT:   Not found!
Trying to boot from BOOTROM
image offset 0x8000, pagesize 0x200, ivt offset 0x0


U-Boot 2020.07-rc1-00015-g02cd8db94f (May 04 2020 - 11:17:25 -0300)

CPU:   Freescale i.MX8MP rev1.0 at 1000 MHz
Reset cause: POR
Model: NXP i.MX8MPlus EVK board
DRAM:  6 GiB
MMC:   FSL_SDHC: 1, FSL_SDHC: 2
Loading Environment from MMC... OK
In:    serial
Out:   serial
Err:   serial
Net:   No ethernet found.
Hit any key to stop autoboot:  0
u-boot=>

The "Failed to find clock node. Check device tree" looks suspicious.

Any ideas?
Marek Vasut May 4, 2020, 2:32 p.m. UTC | #3
On 5/4/20 4:27 PM, Fabio Estevam wrote:
> Hi,
> 
> On Wed, Apr 29, 2020 at 10:05 AM 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>
> 
> I noticed that this patch breaks the boot on i.MX8MP EVK. Only the
> following line is printed on boot:
> 
> U-Boot SPL 2020.07-rc1-00014-g8142a97d54 (May 04 2020 - 11:15:50 -0300)
> 
> If I revert this patch I can boot it again:
> 
> U-Boot SPL 2020.07-rc1-00015-g02cd8db94f (May 04 2020 - 11:17:25 -0300)
> Normal Boot
> Failed to find clock node. Check device tree
> WDT:   Not found!
> Trying to boot from BOOTROM
> image offset 0x8000, pagesize 0x200, ivt offset 0x0
> 
> 
> U-Boot 2020.07-rc1-00015-g02cd8db94f (May 04 2020 - 11:17:25 -0300)
> 
> CPU:   Freescale i.MX8MP rev1.0 at 1000 MHz
> Reset cause: POR
> Model: NXP i.MX8MPlus EVK board
> DRAM:  6 GiB
> MMC:   FSL_SDHC: 1, FSL_SDHC: 2
> Loading Environment from MMC... OK
> In:    serial
> Out:   serial
> Err:   serial
> Net:   No ethernet found.
> Hit any key to stop autoboot:  0
> u-boot=>
> 
> The "Failed to find clock node. Check device tree" looks suspicious.

The "WDT: not found!" is probably the root cause of your problem.
Maybe the WDT driver fails to probe because it can't resolve it's clock
phandle ("Failed to find clock node")? So maybe you need to fix your
clock in SPL.
Harald Seiler May 4, 2020, 3:05 p.m. UTC | #4
Hello,

On Mon, 2020-05-04 at 16:32 +0200, Marek Vasut wrote:
> On 5/4/20 4:27 PM, Fabio Estevam wrote:
> > Hi,
> > 
> > On Wed, Apr 29, 2020 at 10:05 AM 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>
> > 
> > I noticed that this patch breaks the boot on i.MX8MP EVK. Only the
> > following line is printed on boot:
> > 
> > U-Boot SPL 2020.07-rc1-00014-g8142a97d54 (May 04 2020 - 11:15:50 -0300)
> > 
> > If I revert this patch I can boot it again:
> > 
> > U-Boot SPL 2020.07-rc1-00015-g02cd8db94f (May 04 2020 - 11:17:25 -0300)
> > Normal Boot
> > Failed to find clock node. Check device tree
> > WDT:   Not found!
> > Trying to boot from BOOTROM
> > image offset 0x8000, pagesize 0x200, ivt offset 0x0
> > 
> > 
> > U-Boot 2020.07-rc1-00015-g02cd8db94f (May 04 2020 - 11:17:25 -0300)
> > 
> > CPU:   Freescale i.MX8MP rev1.0 at 1000 MHz
> > Reset cause: POR
> > Model: NXP i.MX8MPlus EVK board
> > DRAM:  6 GiB
> > MMC:   FSL_SDHC: 1, FSL_SDHC: 2
> > Loading Environment from MMC... OK
> > In:    serial
> > Out:   serial
> > Err:   serial
> > Net:   No ethernet found.
> > Hit any key to stop autoboot:  0
> > u-boot=>
> > 
> > The "Failed to find clock node. Check device tree" looks suspicious.
> 
> The "WDT: not found!" is probably the root cause of your problem.
> Maybe the WDT driver fails to probe because it can't resolve it's clock
> phandle ("Failed to find clock node")? So maybe you need to fix your
> clock in SPL.

"Failed to find clock node. Check device tree" comes from spl_board_init()
in board/freescale/imx8mp_evk/spl.c; line 56:

	ret = uclass_get_device_by_name(UCLASS_CLK,
					"clock-controller at 30380000",
					&dev);

I see that wdog1 references the same clock here:

arch/arm/dts/imx8mp.dtsi; line 222:

        wdog1: watchdog at 30280000 {
        	compatible = "fsl,imx8mp-wdt", "fsl,imx21-wdt";
        	reg = <0x30280000 0x10000>;
        	interrupts = <GIC_SPI 78 IRQ_TYPE_LEVEL_HIGH>;
        	clocks = <&clk IMX8MP_CLK_WDOG1_ROOT>;
        	status = "disabled";
        };

So the two issues are very likely related.  The relevant clock's node is
also enabled for SPL so I think the driver might be missing here.  Maybe
you need to add 

    CONFIG_SPL_CLK_IMX8MP=y

to your defconfig?
diff mbox series

Patch

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