From: Alexandre Belloni <alexandre.belloni@bootlin.com>
To: Rasmus Villemoes <linux@rasmusvillemoes.dk>
Cc: Alessandro Zummo <a.zummo@towertech.it>,
Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
devicetree@vger.kernel.org, Rob Herring <robh+dt@kernel.org>,
Krzysztof Kozlowski <krzysztof.kozlowski+dt@linaro.org>,
Conor Dooley <conor+dt@kernel.org>,
linux-rtc@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 6/8] rtc: isl12022: trigger battery level detection during probe
Date: Tue, 13 Jun 2023 10:58:54 +0200 [thread overview]
Message-ID: <2023061308585481c7cb97@mail.local> (raw)
In-Reply-To: <f3dc01bc-cdd1-ab0c-5891-083f6d255a4c@rasmusvillemoes.dk>
On 13/06/2023 09:44:55+0200, Rasmus Villemoes wrote:
> On 12/06/2023 16.15, Alexandre Belloni wrote:
> > On 12/06/2023 13:30:56+0200, Rasmus Villemoes wrote:
> >> Since the meaning of the SR_LBAT85 and SR_LBAT75 bits are different in
> >> battery backup mode, they may very well be set after power on, and
> >> stay set for up to a minute (i.e. until the battery detection in VDD
> >> mode happens when the seconds counter hits 59). This would mean that
> >> userspace doing a ioctl(RTC_VL_READ) early on could get a false
> >> positive.
> >>
> >> The battery level detection can also be triggered by explicitly
> >> writing a 1 to the TSE bit in the BETA register. Do that once during
> >> boot (well, probe), and emit a single warning to the kernel log if the
> >> battery is already low.
> >>
> >> Signed-off-by: Rasmus Villemoes <linux@rasmusvillemoes.dk>
> >> ---
> >> drivers/rtc/rtc-isl12022.c | 19 ++++++++++++++++++-
> >> 1 file changed, 18 insertions(+), 1 deletion(-)
> >>
> >> diff --git a/drivers/rtc/rtc-isl12022.c b/drivers/rtc/rtc-isl12022.c
> >> index 1b6659a9b33a..690dbb446d1a 100644
> >> --- a/drivers/rtc/rtc-isl12022.c
> >> +++ b/drivers/rtc/rtc-isl12022.c
> >> @@ -280,8 +280,25 @@ static void isl12022_set_trip_levels(struct device *dev)
> >> mask = ISL12022_REG_VB85_MASK | ISL12022_REG_VB75_MASK;
> >>
> >> ret = regmap_update_bits(regmap, ISL12022_REG_PWR_VBAT, mask, val);
> >> - if (ret)
> >> + if (ret) {
> >> dev_warn(dev, "unable to set battery alarm levels: %d\n", ret);
> >> + return;
> >> + }
> >> +
> >> + ret = regmap_write_bits(regmap, ISL12022_REG_BETA,
> >> + ISL12022_BETA_TSE, ISL12022_BETA_TSE);
> >> + if (ret) {
> >> + dev_warn(dev, "unable to trigger battery level detection: %d\n", ret);
> >
> > This is too verbose, there is no action for the user upon getting this
> > message.
>
> OK.
>
> > Setting TSE also enables temperature compensation, which may be an
> > undesirable side effect. Shouldn't this be reverted if necessary?
>
> Well, I can't imagine the board designer not wanting/expecting
> temperature compensation to be enabled since they've spent the $$ on
> using a part with that capability. Also, we anyway set TSE if
> CONFIG_HWMON so that the TEMP registers get updated once per minute.
>
> If you insist I'll do the proper logic to set it back to 0 if it wasn't
> set beforehand, but I prefer to just keep it as-is.
>
Ok, fine
> >
> >> + return;
> >> + }
> >> +
> >> + ret = isl12022_read_sr(regmap);
> >> + if (ret < 0) {
> >> + dev_warn(dev, "unable to read status register: %d\n", ret);
> >> + } else if (ret & (ISL12022_SR_LBAT85 | ISL12022_SR_LBAT75)) {
> >> + dev_warn(dev, "battery voltage is below %u%%\n",
> >> + (ret & ISL12022_SR_LBAT75) ? 75 : 85);
> >
> > This message is useless, I'd drop the whole block.
>
> I only added this as "compensation" for ripping out the warning in 1/8,
> since I assumed somebody actually wanted at least one warning in the
> kernel log if the battery is low.
>
No need, I had a patch removing the message anyway.
> I/we are not going to scrape dmesg but will use the ioctl() to monitor
> the battery, so I'm perfectly happy to just remove this. That will also
> make the question of how long to wait after setting TSE moot, since
> certainly userspace won't be able to issue the ioctl() soon enough to
> see stale values in the LBAT bits.
>
Exactly.
> Rasmus
>
--
Alexandre Belloni, co-owner and COO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
next prev parent reply other threads:[~2023-06-13 8:59 UTC|newest]
Thread overview: 78+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-06-12 11:30 [PATCH 0/8] rtc: isl12022: battery backup voltage and clock support Rasmus Villemoes
2023-06-12 11:30 ` [PATCH 1/8] rtc: isl12022: remove wrong warning for low battery level Rasmus Villemoes
2023-06-12 11:30 ` [PATCH 2/8] dt-bindings: rtc: Move isil,isl12022 from trivial-rtc.yaml into own schema file Rasmus Villemoes
2023-06-12 12:26 ` Rob Herring
2023-06-12 12:36 ` Rasmus Villemoes
2023-06-12 13:54 ` Alexandre Belloni
2023-06-12 14:20 ` Rob Herring
2023-06-13 8:13 ` Rasmus Villemoes
2023-06-12 11:30 ` [PATCH 3/8] dt-bindings: rtc: isl12022: add bindings for battery alarm trip levels Rasmus Villemoes
2023-06-12 11:30 ` [PATCH 4/8] rtc: isl12022: add support for trip level DT bindings Rasmus Villemoes
2023-06-12 15:44 ` Andy Shevchenko
2023-06-12 18:10 ` kernel test robot
2023-06-12 18:58 ` kernel test robot
2023-06-12 11:30 ` [PATCH 5/8] rtc: isl12022: implement RTC_VL_READ and RTC_VL_CLR ioctls Rasmus Villemoes
2023-06-12 14:07 ` Alexandre Belloni
2023-06-13 7:27 ` Rasmus Villemoes
2023-06-12 15:48 ` Andy Shevchenko
2023-06-12 16:10 ` Alexandre Belloni
2023-06-13 7:53 ` Rasmus Villemoes
2023-06-13 9:00 ` Alexandre Belloni
2023-06-12 11:30 ` [PATCH 6/8] rtc: isl12022: trigger battery level detection during probe Rasmus Villemoes
2023-06-12 12:30 ` Rasmus Villemoes
2023-06-12 14:17 ` Alexandre Belloni
2023-06-13 7:51 ` Rasmus Villemoes
2023-06-12 14:15 ` Alexandre Belloni
2023-06-13 7:44 ` Rasmus Villemoes
2023-06-13 8:58 ` Alexandre Belloni [this message]
2023-06-12 11:30 ` [PATCH 7/8] dt-bindings: rtc: isl12022: add #clock-cells property Rasmus Villemoes
2023-06-13 7:41 ` Krzysztof Kozlowski
2023-06-12 11:30 ` [PATCH 8/8] rtc: isl12022: implement support for the #clock-cells DT property Rasmus Villemoes
2023-06-13 13:00 ` [PATCH v2 0/8] rtc: isl12022: battery backup voltage and clock support Rasmus Villemoes
2023-06-13 13:00 ` [PATCH v2 1/8] rtc: isl12022: remove wrong warning for low battery level Rasmus Villemoes
2023-06-13 13:00 ` [PATCH v2 2/8] dt-bindings: rtc: Move isil,isl12022 from trivial-rtc.yaml into own schema file Rasmus Villemoes
2023-06-13 19:06 ` Krzysztof Kozlowski
2023-06-13 13:00 ` [PATCH v2 3/8] dt-bindings: rtc: isl12022: add bindings for battery alarm trip levels Rasmus Villemoes
2023-06-13 19:09 ` Krzysztof Kozlowski
2023-06-13 19:51 ` Rasmus Villemoes
2023-06-13 21:37 ` Krzysztof Kozlowski
2023-06-13 13:00 ` [PATCH v2 4/8] rtc: isl12022: add support for trip level DT bindings Rasmus Villemoes
2023-06-13 13:00 ` [PATCH v2 5/8] rtc: isl12022: implement RTC_VL_READ ioctl Rasmus Villemoes
2023-06-13 15:20 ` Andy Shevchenko
2023-06-13 21:26 ` Alexandre Belloni
2023-06-14 12:16 ` Andy Shevchenko
2023-06-14 13:50 ` Alexandre Belloni
2023-06-14 15:13 ` Andy Shevchenko
2023-06-15 10:53 ` Rasmus Villemoes
2023-06-15 10:58 ` Andy Shevchenko
2023-06-13 13:00 ` [PATCH v2 6/8] rtc: isl12022: trigger battery level detection during probe Rasmus Villemoes
2023-06-13 13:00 ` [PATCH v2 7/8] dt-bindings: rtc: isl12022: add #clock-cells property Rasmus Villemoes
2023-06-13 19:10 ` Krzysztof Kozlowski
2023-06-13 20:25 ` Rasmus Villemoes
2023-06-13 21:38 ` Krzysztof Kozlowski
2023-06-13 13:00 ` [PATCH v2 8/8] rtc: isl12022: implement support for the #clock-cells DT property Rasmus Villemoes
2023-06-13 15:25 ` Andy Shevchenko
2023-06-14 10:51 ` Rasmus Villemoes
2023-06-14 12:13 ` Andy Shevchenko
2023-06-13 19:10 ` kernel test robot
2023-06-14 5:27 ` kernel test robot
2023-06-13 15:26 ` [PATCH v2 0/8] rtc: isl12022: battery backup voltage and clock support Andy Shevchenko
2023-06-13 19:06 ` Krzysztof Kozlowski
2023-06-15 11:03 ` Rasmus Villemoes
2023-06-15 10:58 ` [PATCH v3 " Rasmus Villemoes
2023-06-15 10:58 ` [PATCH v3 1/8] rtc: isl12022: remove wrong warning for low battery level Rasmus Villemoes
2023-06-15 10:58 ` [PATCH v3 2/8] dt-bindings: rtc: Move isil,isl12022 from trivial-rtc.yaml into own schema file Rasmus Villemoes
2023-06-15 10:58 ` [PATCH v3 3/8] dt-bindings: rtc: isl12022: add bindings for battery alarm trip levels Rasmus Villemoes
2023-06-17 8:12 ` Krzysztof Kozlowski
2023-06-15 10:58 ` [PATCH v3 4/8] rtc: isl12022: add support for trip level DT binding Rasmus Villemoes
2023-06-15 11:11 ` Andy Shevchenko
2023-06-19 7:27 ` Rasmus Villemoes
2023-06-15 10:58 ` [PATCH v3 5/8] rtc: isl12022: implement RTC_VL_READ ioctl Rasmus Villemoes
2023-06-15 10:58 ` [PATCH v3 6/8] rtc: isl12022: trigger battery level detection during probe Rasmus Villemoes
2023-06-15 10:58 ` [PATCH v3 7/8] dt-bindings: rtc: isl12022: add #clock-cells property Rasmus Villemoes
2023-06-17 8:13 ` Krzysztof Kozlowski
2023-06-15 10:58 ` [PATCH v3 8/8] rtc: isl12022: implement support for the #clock-cells DT property Rasmus Villemoes
2023-07-28 14:31 ` [PATCH v3 0/8] rtc: isl12022: battery backup voltage and clock support Rasmus Villemoes
2023-08-03 6:45 ` Rasmus Villemoes
2023-08-09 12:28 ` Rasmus Villemoes
2023-08-15 23:28 ` Alexandre Belloni
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=2023061308585481c7cb97@mail.local \
--to=alexandre.belloni@bootlin.com \
--cc=a.zummo@towertech.it \
--cc=andriy.shevchenko@linux.intel.com \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=krzysztof.kozlowski+dt@linaro.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-rtc@vger.kernel.org \
--cc=linux@rasmusvillemoes.dk \
--cc=robh+dt@kernel.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).