diff mbox series

[v1] wdt: nuvoton: add expire function for generic reset

Message ID 20220913061924.5502-1-JJLIU0@nuvoton.com
State Accepted
Delegated to: Stefan Roese
Headers show
Series [v1] wdt: nuvoton: add expire function for generic reset | expand

Commit Message

Jim Liu Sept. 13, 2022, 6:19 a.m. UTC
Add expire_now function for generic sysreset request

Signed-off-by: Jim Liu <JJLIU0@nuvoton.com>
---
 drivers/watchdog/npcm_wdt.c | 6 ++++++
 1 file changed, 6 insertions(+)

Comments

Stefan Roese Sept. 14, 2022, 6:26 a.m. UTC | #1
On 13.09.22 08:19, Jim Liu wrote:
> Add expire_now function for generic sysreset request
> 
> Signed-off-by: Jim Liu <JJLIU0@nuvoton.com>
> ---
>   drivers/watchdog/npcm_wdt.c | 6 ++++++
>   1 file changed, 6 insertions(+)
> 
> diff --git a/drivers/watchdog/npcm_wdt.c b/drivers/watchdog/npcm_wdt.c
> index 256020f5d3..e56aa0ebe1 100644
> --- a/drivers/watchdog/npcm_wdt.c
> +++ b/drivers/watchdog/npcm_wdt.c
> @@ -75,6 +75,11 @@ static int npcm_wdt_reset(struct udevice *dev)
>   	return 0;
>   }
>   
> +static int npcm_wdt_expire_now(struct udevice *dev, ulong flags)
> +{
> +	return npcm_wdt_reset(dev);
> +}
> +

Does this really work? You are calling the watchdog reset function here
in the expire function, which will just reset / trigger the WDT. I would
not expect that this will expire the WDT and result in a CPU / SoC
reset.

Thanks,
Stefan

>   static int npcm_wdt_of_to_plat(struct udevice *dev)
>   {
>   	struct npcm_wdt_priv *priv = dev_get_priv(dev);
> @@ -87,6 +92,7 @@ static int npcm_wdt_of_to_plat(struct udevice *dev)
>   }
>   
>   static const struct wdt_ops npcm_wdt_ops = {
> +	.expire_now = npcm_wdt_expire_now,
>   	.start = npcm_wdt_start,
>   	.reset = npcm_wdt_reset,
>   	.stop = npcm_wdt_stop,

Viele Grüße,
Stefan Roese
Jim Liu Sept. 15, 2022, 2:35 a.m. UTC | #2
Hi  Stefan Roese

Thanks for your review.
Here is my log from uboot master.
And i add the debug log as below:

-----------------------------------------------
U-Boot 2022.10-rc4-00038-ge3fce5e560-dirty (Sep 15 2022 - 09:58:25 +0800)

CPU: NPCM750 A1 @ Model: Nuvoton npcm750 Development Board (Device Tree)
DRAM:  464 MiB
RNG: NPCM RNG module bind OK
OTP: NPCM OTP module bind OK
AES: NPCM AES module bind OK
SHA: NPCM SHA module bind OK
Core:  210 devices, 22 uclasses, devicetree: separate
WDT:   Started watchdog@801C without servicing (60s timeout)
MMC:   sdhci0@f0842000: 0
Loading Environment from SPIFlash... SF: Detected mx66l51235l with
page size 256 Bytes, erase size 64 KiB, total 64 MiB
OK
In:    serial@1000
Out:   serial@1000
Err:   serial@1000
Net:   eth0: eth@f0802000, eth1: eth@f0825000
Hit any key to stop autoboot:  0
U-Boot>reset
resetting ...
jim[wdt_reboot_request]
jim[npcm_wdt_expire_now]
jim[npcm_wdt_reset]

>================================================
> BootBlock by Nuvoton Technology Corp. Ver 10.10.17
>================================================

BB Basic
Mar 24 2021
12:06:08




>CORSTC         = 0x4fff9f9d
>WD0RCR         = 0x4fff9f9d
>WD1RCR         = 0x4fff9f9d
>WD2RCR         = 0x4fff9f9d
>SWRSTC1        = 0x4fff9f9d
>SWRSTC2        = 0x4fff9f9d
>SWRSTC3        = 0x4fff9f9d
----------------------------------------------------

If you have any suggestions, please provide  to me.
I will follow to modify it.

Best regards,
Jim

On Thu, Sep 15, 2022 at 10:23 AM JJLIU0@nuvoton.com <JJLIU0@nuvoton.com> wrote:
>
>
>
> -----Original Message-----
> From: Stefan Roese <sr@denx.de>
> Sent: Wednesday, September 14, 2022 2:27 PM
> To: Jim Liu <jim.t90615@gmail.com>; CS20 JJLiu0 <JJLIU0@nuvoton.com>; CS20 YSChu <YSCHU@nuvoton.com>; CS20 KWLiu <KWLIU@nuvoton.com>
> Cc: u-boot@lists.denx.de
> Subject: Re: [PATCH v1] wdt: nuvoton: add expire function for generic reset
>
> On 13.09.22 08:19, Jim Liu wrote:
> > Add expire_now function for generic sysreset request
> >
> > Signed-off-by: Jim Liu <JJLIU0@nuvoton.com>
> > ---
> >   drivers/watchdog/npcm_wdt.c | 6 ++++++
> >   1 file changed, 6 insertions(+)
> >
> > diff --git a/drivers/watchdog/npcm_wdt.c b/drivers/watchdog/npcm_wdt.c
> > index 256020f5d3..e56aa0ebe1 100644
> > --- a/drivers/watchdog/npcm_wdt.c
> > +++ b/drivers/watchdog/npcm_wdt.c
> > @@ -75,6 +75,11 @@ static int npcm_wdt_reset(struct udevice *dev)
> >       return 0;
> >   }
> >
> > +static int npcm_wdt_expire_now(struct udevice *dev, ulong flags) {
> > +     return npcm_wdt_reset(dev);
> > +}
> > +
>
> Does this really work? You are calling the watchdog reset function here in the expire function, which will just reset / trigger the WDT. I would not expect that this will expire the WDT and result in a CPU / SoC reset.
>
> Thanks,
> Stefan
>
> >   static int npcm_wdt_of_to_plat(struct udevice *dev)
> >   {
> >       struct npcm_wdt_priv *priv = dev_get_priv(dev); @@ -87,6 +92,7 @@
> > static int npcm_wdt_of_to_plat(struct udevice *dev)
> >   }
> >
> >   static const struct wdt_ops npcm_wdt_ops = {
> > +     .expire_now = npcm_wdt_expire_now,
> >       .start = npcm_wdt_start,
> >       .reset = npcm_wdt_reset,
> >       .stop = npcm_wdt_stop,
>
> Viele Grüße,
> Stefan Roese
>
> --
> DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
> HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
> Phone: (+49)-8142-66989-51 Fax: (+49)-8142-66989-80 Email: sr@denx.de
> ________________________________
> ________________________________
>  The privileged confidential information contained in this email is intended for use only by the addressees as indicated by the original sender of this email. If you are not the addressee indicated in this email or are not responsible for delivery of the email to such a person, please kindly reply to the sender indicating this fact and delete all copies of it from your computer and network server immediately. Your cooperation is highly appreciated. It is advised that any unauthorized use of confidential information of Nuvoton is strictly prohibited; and any information in this email irrelevant to the official business of Nuvoton shall be deemed as neither given nor endorsed by Nuvoton.
Stefan Roese Sept. 15, 2022, 5:02 a.m. UTC | #3
Hi Jim,

On 15.09.22 04:35, Jim Liu wrote:
> Hi  Stefan Roese
> 
> Thanks for your review.
> Here is my log from uboot master.
> And i add the debug log as below:
> 
> -----------------------------------------------
> U-Boot 2022.10-rc4-00038-ge3fce5e560-dirty (Sep 15 2022 - 09:58:25 +0800)
> 
> CPU: NPCM750 A1 @ Model: Nuvoton npcm750 Development Board (Device Tree)
> DRAM:  464 MiB
> RNG: NPCM RNG module bind OK
> OTP: NPCM OTP module bind OK
> AES: NPCM AES module bind OK
> SHA: NPCM SHA module bind OK
> Core:  210 devices, 22 uclasses, devicetree: separate
> WDT:   Started watchdog@801C without servicing (60s timeout)
> MMC:   sdhci0@f0842000: 0
> Loading Environment from SPIFlash... SF: Detected mx66l51235l with
> page size 256 Bytes, erase size 64 KiB, total 64 MiB
> OK
> In:    serial@1000
> Out:   serial@1000
> Err:   serial@1000
> Net:   eth0: eth@f0802000, eth1: eth@f0825000
> Hit any key to stop autoboot:  0
> U-Boot>reset
> resetting ...
> jim[wdt_reboot_request]
> jim[npcm_wdt_expire_now]
> jim[npcm_wdt_reset]

Interesting. Thanks for sending this log. And what does "wdt
expire" say?

Thanks,
Stefan

>> ================================================
>> BootBlock by Nuvoton Technology Corp. Ver 10.10.17
>> ================================================
> 
> BB Basic
> Mar 24 2021
> 12:06:08
> 
> 
> 
> 
>> CORSTC         = 0x4fff9f9d
>> WD0RCR         = 0x4fff9f9d
>> WD1RCR         = 0x4fff9f9d
>> WD2RCR         = 0x4fff9f9d
>> SWRSTC1        = 0x4fff9f9d
>> SWRSTC2        = 0x4fff9f9d
>> SWRSTC3        = 0x4fff9f9d
> ----------------------------------------------------
> 
> If you have any suggestions, please provide  to me.
> I will follow to modify it.
> 
> Best regards,
> Jim
> 
> On Thu, Sep 15, 2022 at 10:23 AM JJLIU0@nuvoton.com <JJLIU0@nuvoton.com> wrote:
>>
>>
>>
>> -----Original Message-----
>> From: Stefan Roese <sr@denx.de>
>> Sent: Wednesday, September 14, 2022 2:27 PM
>> To: Jim Liu <jim.t90615@gmail.com>; CS20 JJLiu0 <JJLIU0@nuvoton.com>; CS20 YSChu <YSCHU@nuvoton.com>; CS20 KWLiu <KWLIU@nuvoton.com>
>> Cc: u-boot@lists.denx.de
>> Subject: Re: [PATCH v1] wdt: nuvoton: add expire function for generic reset
>>
>> On 13.09.22 08:19, Jim Liu wrote:
>>> Add expire_now function for generic sysreset request
>>>
>>> Signed-off-by: Jim Liu <JJLIU0@nuvoton.com>
>>> ---
>>>    drivers/watchdog/npcm_wdt.c | 6 ++++++
>>>    1 file changed, 6 insertions(+)
>>>
>>> diff --git a/drivers/watchdog/npcm_wdt.c b/drivers/watchdog/npcm_wdt.c
>>> index 256020f5d3..e56aa0ebe1 100644
>>> --- a/drivers/watchdog/npcm_wdt.c
>>> +++ b/drivers/watchdog/npcm_wdt.c
>>> @@ -75,6 +75,11 @@ static int npcm_wdt_reset(struct udevice *dev)
>>>        return 0;
>>>    }
>>>
>>> +static int npcm_wdt_expire_now(struct udevice *dev, ulong flags) {
>>> +     return npcm_wdt_reset(dev);
>>> +}
>>> +
>>
>> Does this really work? You are calling the watchdog reset function here in the expire function, which will just reset / trigger the WDT. I would not expect that this will expire the WDT and result in a CPU / SoC reset.
>>
>> Thanks,
>> Stefan
>>
>>>    static int npcm_wdt_of_to_plat(struct udevice *dev)
>>>    {
>>>        struct npcm_wdt_priv *priv = dev_get_priv(dev); @@ -87,6 +92,7 @@
>>> static int npcm_wdt_of_to_plat(struct udevice *dev)
>>>    }
>>>
>>>    static const struct wdt_ops npcm_wdt_ops = {
>>> +     .expire_now = npcm_wdt_expire_now,
>>>        .start = npcm_wdt_start,
>>>        .reset = npcm_wdt_reset,
>>>        .stop = npcm_wdt_stop,
>>
>> Viele Grüße,
>> Stefan Roese
>>
>> --
>> DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
>> HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
>> Phone: (+49)-8142-66989-51 Fax: (+49)-8142-66989-80 Email: sr@denx.de
>> ________________________________
>> ________________________________
>>   The privileged confidential information contained in this email is intended for use only by the addressees as indicated by the original sender of this email. If you are not the addressee indicated in this email or are not responsible for delivery of the email to such a person, please kindly reply to the sender indicating this fact and delete all copies of it from your computer and network server immediately. Your cooperation is highly appreciated. It is advised that any unauthorized use of confidential information of Nuvoton is strictly prohibited; and any information in this email irrelevant to the official business of Nuvoton shall be deemed as neither given nor endorsed by Nuvoton.

Viele Grüße,
Stefan Roese
Jim Liu Sept. 15, 2022, 5:48 a.m. UTC | #4
Hi Stefan Roese

Thanks for the quick reply.
sorry for the topic naming.
my mean is i add a npcm_wdt_expire_now function to support sysreset .

Best regards,
Jim

On Thu, Sep 15, 2022 at 1:02 PM Stefan Roese <sr@denx.de> wrote:
>
> Hi Jim,
>
> On 15.09.22 04:35, Jim Liu wrote:
> > Hi  Stefan Roese
> >
> > Thanks for your review.
> > Here is my log from uboot master.
> > And i add the debug log as below:
> >
> > -----------------------------------------------
> > U-Boot 2022.10-rc4-00038-ge3fce5e560-dirty (Sep 15 2022 - 09:58:25 +0800)
> >
> > CPU: NPCM750 A1 @ Model: Nuvoton npcm750 Development Board (Device Tree)
> > DRAM:  464 MiB
> > RNG: NPCM RNG module bind OK
> > OTP: NPCM OTP module bind OK
> > AES: NPCM AES module bind OK
> > SHA: NPCM SHA module bind OK
> > Core:  210 devices, 22 uclasses, devicetree: separate
> > WDT:   Started watchdog@801C without servicing (60s timeout)
> > MMC:   sdhci0@f0842000: 0
> > Loading Environment from SPIFlash... SF: Detected mx66l51235l with
> > page size 256 Bytes, erase size 64 KiB, total 64 MiB
> > OK
> > In:    serial@1000
> > Out:   serial@1000
> > Err:   serial@1000
> > Net:   eth0: eth@f0802000, eth1: eth@f0825000
> > Hit any key to stop autoboot:  0
> > U-Boot>reset
> > resetting ...
> > jim[wdt_reboot_request]
> > jim[npcm_wdt_expire_now]
> > jim[npcm_wdt_reset]
>
> Interesting. Thanks for sending this log. And what does "wdt
> expire" say?
>
> Thanks,
> Stefan
>
> >> ================================================
> >> BootBlock by Nuvoton Technology Corp. Ver 10.10.17
> >> ================================================
> >
> > BB Basic
> > Mar 24 2021
> > 12:06:08
> >
> >
> >
> >
> >> CORSTC         = 0x4fff9f9d
> >> WD0RCR         = 0x4fff9f9d
> >> WD1RCR         = 0x4fff9f9d
> >> WD2RCR         = 0x4fff9f9d
> >> SWRSTC1        = 0x4fff9f9d
> >> SWRSTC2        = 0x4fff9f9d
> >> SWRSTC3        = 0x4fff9f9d
> > ----------------------------------------------------
> >
> > If you have any suggestions, please provide  to me.
> > I will follow to modify it.
> >
> > Best regards,
> > Jim
> >
> > On Thu, Sep 15, 2022 at 10:23 AM JJLIU0@nuvoton.com <JJLIU0@nuvoton.com> wrote:
> >>
> >>
> >>
> >> -----Original Message-----
> >> From: Stefan Roese <sr@denx.de>
> >> Sent: Wednesday, September 14, 2022 2:27 PM
> >> To: Jim Liu <jim.t90615@gmail.com>; CS20 JJLiu0 <JJLIU0@nuvoton.com>; CS20 YSChu <YSCHU@nuvoton.com>; CS20 KWLiu <KWLIU@nuvoton.com>
> >> Cc: u-boot@lists.denx.de
> >> Subject: Re: [PATCH v1] wdt: nuvoton: add expire function for generic reset
> >>
> >> On 13.09.22 08:19, Jim Liu wrote:
> >>> Add expire_now function for generic sysreset request
> >>>
> >>> Signed-off-by: Jim Liu <JJLIU0@nuvoton.com>
> >>> ---
> >>>    drivers/watchdog/npcm_wdt.c | 6 ++++++
> >>>    1 file changed, 6 insertions(+)
> >>>
> >>> diff --git a/drivers/watchdog/npcm_wdt.c b/drivers/watchdog/npcm_wdt.c
> >>> index 256020f5d3..e56aa0ebe1 100644
> >>> --- a/drivers/watchdog/npcm_wdt.c
> >>> +++ b/drivers/watchdog/npcm_wdt.c
> >>> @@ -75,6 +75,11 @@ static int npcm_wdt_reset(struct udevice *dev)
> >>>        return 0;
> >>>    }
> >>>
> >>> +static int npcm_wdt_expire_now(struct udevice *dev, ulong flags) {
> >>> +     return npcm_wdt_reset(dev);
> >>> +}
> >>> +
> >>
> >> Does this really work? You are calling the watchdog reset function here in the expire function, which will just reset / trigger the WDT. I would not expect that this will expire the WDT and result in a CPU / SoC reset.
> >>
> >> Thanks,
> >> Stefan
> >>
> >>>    static int npcm_wdt_of_to_plat(struct udevice *dev)
> >>>    {
> >>>        struct npcm_wdt_priv *priv = dev_get_priv(dev); @@ -87,6 +92,7 @@
> >>> static int npcm_wdt_of_to_plat(struct udevice *dev)
> >>>    }
> >>>
> >>>    static const struct wdt_ops npcm_wdt_ops = {
> >>> +     .expire_now = npcm_wdt_expire_now,
> >>>        .start = npcm_wdt_start,
> >>>        .reset = npcm_wdt_reset,
> >>>        .stop = npcm_wdt_stop,
> >>
> >> Viele Grüße,
> >> Stefan Roese
> >>
> >> --
> >> DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
> >> HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
> >> Phone: (+49)-8142-66989-51 Fax: (+49)-8142-66989-80 Email: sr@denx.de
> >> ________________________________
> >> ________________________________
> >>   The privileged confidential information contained in this email is intended for use only by the addressees as indicated by the original sender of this email. If you are not the addressee indicated in this email or are not responsible for delivery of the email to such a person, please kindly reply to the sender indicating this fact and delete all copies of it from your computer and network server immediately. Your cooperation is highly appreciated. It is advised that any unauthorized use of confidential information of Nuvoton is strictly prohibited; and any information in this email irrelevant to the official business of Nuvoton shall be deemed as neither given nor endorsed by Nuvoton.
>
> Viele Grüße,
> Stefan Roese
>
> --
> DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
> HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
> Phone: (+49)-8142-66989-51 Fax: (+49)-8142-66989-80 Email: sr@denx.de
Stefan Roese Oct. 24, 2022, 11:39 a.m. UTC | #5
On 13.09.22 08:19, Jim Liu wrote:
> Add expire_now function for generic sysreset request
> 
> Signed-off-by: Jim Liu <JJLIU0@nuvoton.com>

Applied to u-boot-watchdog/master

Thanks,
Stefan

> ---
>   drivers/watchdog/npcm_wdt.c | 6 ++++++
>   1 file changed, 6 insertions(+)
> 
> diff --git a/drivers/watchdog/npcm_wdt.c b/drivers/watchdog/npcm_wdt.c
> index 256020f5d3..e56aa0ebe1 100644
> --- a/drivers/watchdog/npcm_wdt.c
> +++ b/drivers/watchdog/npcm_wdt.c
> @@ -75,6 +75,11 @@ static int npcm_wdt_reset(struct udevice *dev)
>   	return 0;
>   }
>   
> +static int npcm_wdt_expire_now(struct udevice *dev, ulong flags)
> +{
> +	return npcm_wdt_reset(dev);
> +}
> +
>   static int npcm_wdt_of_to_plat(struct udevice *dev)
>   {
>   	struct npcm_wdt_priv *priv = dev_get_priv(dev);
> @@ -87,6 +92,7 @@ static int npcm_wdt_of_to_plat(struct udevice *dev)
>   }
>   
>   static const struct wdt_ops npcm_wdt_ops = {
> +	.expire_now = npcm_wdt_expire_now,
>   	.start = npcm_wdt_start,
>   	.reset = npcm_wdt_reset,
>   	.stop = npcm_wdt_stop,

Viele Grüße,
Stefan Roese
diff mbox series

Patch

diff --git a/drivers/watchdog/npcm_wdt.c b/drivers/watchdog/npcm_wdt.c
index 256020f5d3..e56aa0ebe1 100644
--- a/drivers/watchdog/npcm_wdt.c
+++ b/drivers/watchdog/npcm_wdt.c
@@ -75,6 +75,11 @@  static int npcm_wdt_reset(struct udevice *dev)
 	return 0;
 }
 
+static int npcm_wdt_expire_now(struct udevice *dev, ulong flags)
+{
+	return npcm_wdt_reset(dev);
+}
+
 static int npcm_wdt_of_to_plat(struct udevice *dev)
 {
 	struct npcm_wdt_priv *priv = dev_get_priv(dev);
@@ -87,6 +92,7 @@  static int npcm_wdt_of_to_plat(struct udevice *dev)
 }
 
 static const struct wdt_ops npcm_wdt_ops = {
+	.expire_now = npcm_wdt_expire_now,
 	.start = npcm_wdt_start,
 	.reset = npcm_wdt_reset,
 	.stop = npcm_wdt_stop,