From: Alexandre Belloni <alexandre.belloni@bootlin.com>
To: Sean Anderson <sean.anderson@seco.com>
Cc: Alessandro Zummo <a.zummo@towertech.it>,
linux-rtc@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] rtc: abx80x: Don't warn about oscillator failure after PoR
Date: Fri, 7 Oct 2022 20:57:40 +0200 [thread overview]
Message-ID: <Y0B2pNv8otKkLs1D@mail.local> (raw)
In-Reply-To: <20221007163712.2193966-1-sean.anderson@seco.com>
Hi,
On 07/10/2022 12:37:12-0400, Sean Anderson wrote:
> According to the datasheet, the "oscillator failure" bit is set
>
> > ...on a power on reset, when both the system and battery voltages have
> > dropped below acceptable levels. It is also set if an Oscillator Failure
> > occurs....
>
> From testing, this bit is also set if a software reset is initiated.
>
> This bit has a confusing name; it really tells us whether the time data
> is valid. We clear it when writing the time. If it is still set, that
> means there is a persistent issue (such as an oscillator failure),
> instead of a transient one (such as power loss).
>
> Because there are several other reasons which might cause this bit
> to be set (including booting for the first time or a battery failure),
> do not warn about oscillator failures willy-nilly. This may cause system
> integrators to waste time looking into the wrong line of investigation.
>
> Signed-off-by: Sean Anderson <sean.anderson@seco.com>
> ---
>
> drivers/rtc/rtc-abx80x.c | 17 ++++++++++++++++-
> 1 file changed, 16 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/rtc/rtc-abx80x.c b/drivers/rtc/rtc-abx80x.c
> index 9b0138d07232..1eb752e4e39d 100644
> --- a/drivers/rtc/rtc-abx80x.c
> +++ b/drivers/rtc/rtc-abx80x.c
> @@ -115,6 +115,7 @@ struct abx80x_priv {
> struct rtc_device *rtc;
> struct i2c_client *client;
> struct watchdog_device wdog;
> + bool wrote_time;
> };
>
> static int abx80x_write_config_key(struct i2c_client *client, u8 key)
> @@ -167,6 +168,7 @@ static int abx80x_enable_trickle_charger(struct i2c_client *client,
> static int abx80x_rtc_read_time(struct device *dev, struct rtc_time *tm)
> {
> struct i2c_client *client = to_i2c_client(dev);
> + struct abx80x_priv *priv = i2c_get_clientdata(client);
> unsigned char buf[8];
> int err, flags, rc_mode = 0;
>
> @@ -181,7 +183,18 @@ static int abx80x_rtc_read_time(struct device *dev, struct rtc_time *tm)
> return flags;
>
> if (flags & ABX8XX_OSS_OF) {
> - dev_err(dev, "Oscillator failure, data is invalid.\n");
Simply remove the line.
> + /*
> + * The OF bit can be set either because of a reset
> + * (PoR/Software reset) or because of an oscillator
> + * failure. Effectively, it indicates that the stored
> + * time is invalid. When we write the time, we clear
> + * this bit. If it stays set, then this indicates an
> + * oscillator failure.
> + */
> + if (priv->wrote_time)
> + dev_err(dev, "Oscillator failure\n");
> + else
> + dev_info(dev, "Time data invalid\n");
> return -EINVAL;
> }
> }
> @@ -207,6 +220,7 @@ static int abx80x_rtc_read_time(struct device *dev, struct rtc_time *tm)
> static int abx80x_rtc_set_time(struct device *dev, struct rtc_time *tm)
> {
> struct i2c_client *client = to_i2c_client(dev);
> + struct abx80x_priv *priv = i2c_get_clientdata(client);
> unsigned char buf[8];
> int err, flags;
>
> @@ -240,6 +254,7 @@ static int abx80x_rtc_set_time(struct device *dev, struct rtc_time *tm)
> dev_err(&client->dev, "Unable to write oscillator status register\n");
> return err;
> }
> + priv->wrote_time = true;
>
> return 0;
> }
> --
> 2.35.1.1320.gc452695387.dirty
>
--
Alexandre Belloni, co-owner and COO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
next prev parent reply other threads:[~2022-10-07 18:57 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-10-07 16:37 [PATCH] rtc: abx80x: Don't warn about oscillator failure after PoR Sean Anderson
2022-10-07 18:57 ` Alexandre Belloni [this message]
2022-10-07 19:05 ` Sean Anderson
2022-10-26 21:17 ` Sean Anderson
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=Y0B2pNv8otKkLs1D@mail.local \
--to=alexandre.belloni@bootlin.com \
--cc=a.zummo@towertech.it \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-rtc@vger.kernel.org \
--cc=sean.anderson@seco.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