linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: alexandre.belloni@free-electrons.com (Alexandre Belloni)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v2 2/3] watchdog: sama5d4: Fix setting timeout when watchdog is disabled
Date: Fri, 17 Feb 2017 16:16:50 +0100	[thread overview]
Message-ID: <20170217151625.hv2vn5imx2kyeftt@piout.net> (raw)
In-Reply-To: <968ef53e-c3c4-5322-020a-8382ce367931@roeck-us.net>

On 17/02/2017 at 06:40:33 -0800, Guenter Roeck wrote:
> On 02/16/2017 11:30 AM, Alexandre Belloni wrote:
> > The datasheet states: "When setting the WDDIS bit, and while it is set, the
> > fields WDV and WDD must not be modified."
> > 
> > Ensure WDDIS is not set when changing the timeout and set it afterwards if
> > the watchdog was disabled.
> > 
> > Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
> > ---
> > Changes in v2:
> >  - new patch
> >  drivers/watchdog/sama5d4_wdt.c | 9 ++++++++-
> >  1 file changed, 8 insertions(+), 1 deletion(-)
> > 
> > diff --git a/drivers/watchdog/sama5d4_wdt.c b/drivers/watchdog/sama5d4_wdt.c
> > index 2c6f5a70ae67..2a60251806d2 100644
> > --- a/drivers/watchdog/sama5d4_wdt.c
> > +++ b/drivers/watchdog/sama5d4_wdt.c
> > @@ -90,11 +90,18 @@ static int sama5d4_wdt_set_timeout(struct watchdog_device *wdd,
> >  	u32 reg;
> > 
> >  	reg = wdt_read(wdt, AT91_WDT_MR);
> > +
> > +	if (reg & AT91_WDT_WDDIS)
> > +		wdt_write(wdt, AT91_WDT_MR, reg & ~AT91_WDT_WDDIS);
> > +
> >  	reg &= ~AT91_WDT_WDV;
> >  	reg &= ~AT91_WDT_WDD;
> >  	reg |= AT91_WDT_SET_WDV(value);
> >  	reg |= AT91_WDT_SET_WDD(value);
> > -	wdt_write(wdt, AT91_WDT_MR, reg);
> > +	wdt_write(wdt, AT91_WDT_MR, reg & ~AT91_WDT_WDDIS);
> > +
> > +	if (reg & AT91_WDT_WDDIS)
> > +		wdt_write(wdt, AT91_WDT_MR, reg);
> > 
> That means if the watchdog is running, the timeout would not be updated.
> It should be updated no matter if it is running or not.
> 

No, it is enabling the watchdog, then changing WDV and WDD and finally
disabling the watchdog if necessary. So, WDV and WDD are always changed.

-- 
Alexandre Belloni, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com

  reply	other threads:[~2017-02-17 15:16 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-02-16 19:30 [PATCH v2 1/3] watchdog: sama5d4: Cleanup init Alexandre Belloni
2017-02-16 19:30 ` [PATCH v2 2/3] watchdog: sama5d4: Fix setting timeout when watchdog is disabled Alexandre Belloni
2017-02-17 14:40   ` Guenter Roeck
2017-02-17 15:16     ` Alexandre Belloni [this message]
2017-02-19 16:57       ` Guenter Roeck
2017-02-19 23:52         ` Alexandre Belloni
2017-02-20  4:46           ` Guenter Roeck
2017-03-02 17:35             ` Alexandre Belloni
2017-02-16 19:30 ` [PATCH v2 3/3] watchdog: sama5d4: Implement resume hook Alexandre Belloni
2017-02-17 14:47   ` Guenter Roeck
2017-02-17 15:22     ` Alexandre Belloni
2017-02-19 17:05       ` Guenter Roeck
2017-02-17 14:48 ` [PATCH v2 1/3] watchdog: sama5d4: Cleanup init Guenter Roeck
2017-02-17 15:35   ` Alexandre Belloni
2017-02-19 16:53     ` Guenter Roeck

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170217151625.hv2vn5imx2kyeftt@piout.net \
    --to=alexandre.belloni@free-electrons.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).