linux-rtc.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Guenter Roeck <linux@roeck-us.net>
To: "Martin Hundebøll" <martin@geanix.com>,
	"Alessandro Zummo" <a.zummo@towertech.it>,
	"Alexandre Belloni" <alexandre.belloni@bootlin.com>,
	linux-rtc@vger.kernel.org
Cc: Bruno Thomsen <bruno.thomsen@gmail.com>, linux-watchdog@vger.kernel.org
Subject: Re: [PATCH] rtc: pcf2127: handle boot-enabled watchdog feature
Date: Thu, 3 Oct 2019 06:56:18 -0700	[thread overview]
Message-ID: <0c34943c-71be-d85f-a523-33a6636cf463@roeck-us.net> (raw)
In-Reply-To: <e06a5204-fb47-79d1-f848-f6d92684a9b1@geanix.com>

On 10/3/19 6:27 AM, Martin Hundebøll wrote:
> On 10/3/19 3:05 PM, Guenter Roeck wrote:
>> On 10/3/19 5:48 AM, Martin Hundebøll wrote:
>>> Linux should handle when the pcf2127 watchdog feature is enabled by the
>>> bootloader. This is done by checking the watchdog timer value during
>>> init, and set the WDOG_HW_RUNNING flag if the value differs from zero.
>>>
>>> Signed-off-by: Martin Hundebøll <martin@geanix.com>
>>> ---
>>>   drivers/rtc/rtc-pcf2127.c | 14 +++++++++++++-
>>>   1 file changed, 13 insertions(+), 1 deletion(-)
>>>
>>> diff --git a/drivers/rtc/rtc-pcf2127.c b/drivers/rtc/rtc-pcf2127.c
>>> index cb3472f..0fd3f3e 100644
>>> --- a/drivers/rtc/rtc-pcf2127.c
>>> +++ b/drivers/rtc/rtc-pcf2127.c
>>> @@ -290,6 +290,8 @@ static int pcf2127_wdt_active_ping(struct watchdog_device *wdd)
>>>   static int pcf2127_wdt_start(struct watchdog_device *wdd)
>>>   {
>>> +    set_bit(WDOG_HW_RUNNING, &wdd->status);
>>> +
>>
>> The start function should not set this bit.
> 
> Okay, guess we should update other drivers to not do this as well:
> 
> dw_wdt.c
>   (sets the bit in dw_wdt_stop() )

This is correct as-is because the watchdog can not be stopped.

> gpio_wdt.c

Looks like it.

> imx2_wdt.c
> 
The background was that there is no stop function. But you
are correct, it is unnecessary, since the watchdog core will
set the bit if an attempt is made to stop the watchdog and
there is no stop function.

> mpc8xxx_wdt.c
> 
Same as above.

> rave-sp-wdt.c
> 
> sprd_wdt.c

Correct, not needed.

Patches welcome. And, I guess, we need to update the documentation
to clarify the use of this flag.

Thanks,
Guenter

> 
> // Martin
> 
>>
>> Guenter
>>
>>>       return pcf2127_wdt_ping(wdd);
>>>   }
>>> @@ -420,6 +422,7 @@ static int pcf2127_probe(struct device *dev, struct regmap *regmap,
>>>               const char *name, bool has_nvmem)
>>>   {
>>>       struct pcf2127 *pcf2127;
>>> +    u32 wdd_timeout;
>>>       int ret = 0;
>>>       dev_dbg(dev, "%s\n", __func__);
>>> @@ -462,7 +465,6 @@ static int pcf2127_probe(struct device *dev, struct regmap *regmap,
>>>       /*
>>>        * Watchdog timer enabled and reset pin /RST activated when timed out.
>>>        * Select 1Hz clock source for watchdog timer.
>>> -     * Timer is not started until WD_VAL is loaded with a valid value.
>>>        * Note: Countdown timer disabled and not available.
>>>        */
>>>       ret = regmap_update_bits(pcf2127->regmap, PCF2127_REG_WD_CTL,
>>> @@ -478,6 +480,16 @@ static int pcf2127_probe(struct device *dev, struct regmap *regmap,
>>>           return ret;
>>>       }
>>> +    /* Test if watchdog timer is started by bootloader */
>>> +    ret = regmap_read(pcf2127->regmap, PCF2127_REG_WD_VAL, &wdd_timeout);
>>> +    if (ret) {
>>> +        dev_err(dev, "%s: watchdog value (wd_wal) failed\n", __func__);
>>> +        return ret;
>>> +    }
>>> +
>>> +    if (wdd_timeout)
>>> +        set_bit(WDOG_HW_RUNNING, &pcf2127->wdd.status);
>>> +
>>>       ret = devm_watchdog_register_device(dev, &pcf2127->wdd);
>>>       if (ret)
>>>           return ret;
>>>
>>
> 


  reply	other threads:[~2019-10-03 13:56 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-03 12:48 [PATCH] rtc: pcf2127: handle boot-enabled watchdog feature Martin Hundebøll
2019-10-03 13:05 ` Guenter Roeck
2019-10-03 13:27   ` Martin Hundebøll
2019-10-03 13:56     ` Guenter Roeck [this message]
2019-10-03 13:33 ` [PATCHv2] " Martin Hundebøll
2019-10-03 13:57   ` Guenter Roeck
2019-10-03 21:44   ` Alexandre Belloni
2019-10-06  9:07   ` Bruno Thomsen
2019-10-06 14:29     ` Guenter Roeck
2019-10-06 15:58       ` Martin Hundebøll
2019-10-06 16:19         ` Guenter Roeck
2019-10-07 10:49           ` Bruno Thomsen
2019-10-07 12:31             ` Guenter Roeck
2019-10-21  8:08   ` [PATCHv3] " Martin Hundebøll
2019-10-21  8:33     ` Alexandre Belloni
2019-10-21 16:12     ` 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=0c34943c-71be-d85f-a523-33a6636cf463@roeck-us.net \
    --to=linux@roeck-us.net \
    --cc=a.zummo@towertech.it \
    --cc=alexandre.belloni@bootlin.com \
    --cc=bruno.thomsen@gmail.com \
    --cc=linux-rtc@vger.kernel.org \
    --cc=linux-watchdog@vger.kernel.org \
    --cc=martin@geanix.com \
    /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).