From: Bastian Krause <bst@pengutronix.de>
To: linux-rtc@vger.kernel.org
Cc: devicetree@vger.kernel.org,
Alessandro Zummo <a.zummo@towertech.it>,
Alexandre Belloni <alexandre.belloni@bootlin.com>,
Rob Herring <robh+dt@kernel.org>,
Arnaud Ebalard <arno@natisbad.org>, Marek Vasut <marex@denx.de>,
kernel@pengutronix.de, Bastian Krause <bst@pengutronix.de>
Subject: [PATCH 6/8] rtc: ds1307: store previous charge default per chip
Date: Mon, 7 Sep 2020 16:27:25 +0200 [thread overview]
Message-ID: <20200907142727.26472-7-bst@pengutronix.de> (raw)
In-Reply-To: <20200907142727.26472-1-bst@pengutronix.de>
Some RTC's batteries and supercaps were charged by default until now.
In contrast other RTCs allow charging but the driver did not configure
them to do so until now. These must not be charged by default to stay
backwards compatible.
In order to do that, store the charge default per chip.
Signed-off-by: Bastian Krause <bst@pengutronix.de>
---
No previous version.
---
drivers/rtc/rtc-ds1307.c | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/drivers/rtc/rtc-ds1307.c b/drivers/rtc/rtc-ds1307.c
index 7983438b677a..270621e1c9cf 100644
--- a/drivers/rtc/rtc-ds1307.c
+++ b/drivers/rtc/rtc-ds1307.c
@@ -194,6 +194,11 @@ struct chip_desc {
* the resistor between Vcc and Vbackup?
*/
bool requires_trickle_resistor;
+ /* Some RTC's batteries and supercaps were charged by default, others
+ * allow charging but were not configured previously to do so.
+ * Remember this behavior to stay backwards compatible.
+ */
+ bool charge_default;
};
static const struct chip_desc chips[last_ds_type];
@@ -986,6 +991,7 @@ static const struct chip_desc chips[last_ds_type] = {
.trickle_charger_reg = 0x10,
.do_trickle_setup = &do_trickle_setup_ds1339,
.requires_trickle_resistor = true,
+ .charge_default = true,
},
[ds_1340] = {
.century_reg = DS1307_REG_HOUR,
@@ -994,6 +1000,7 @@ static const struct chip_desc chips[last_ds_type] = {
.do_trickle_setup = &do_trickle_setup_ds1339,
.trickle_charger_reg = 0x08,
.requires_trickle_resistor = true,
+ .charge_default = true,
},
[ds_1341] = {
.century_reg = DS1307_REG_MONTH,
@@ -1302,7 +1309,7 @@ static u8 ds1307_trickle_init(struct ds1307 *ds1307,
const struct chip_desc *chip)
{
u32 ohms;
- bool diode = true;
+ bool diode = chip->charge_default;
if (!chip->do_trickle_setup)
return 0;
--
2.28.0
next prev parent reply other threads:[~2020-09-07 16:30 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-09-07 14:27 [PATCH 0/8] rtc: expand charge support, implement rx8130 charging Bastian Krause
2020-09-07 14:27 ` [PATCH 1/8] dt-bindings: rtc: let aux-voltage-chargeable supersede trickle-diode-disable Bastian Krause
2020-09-08 20:22 ` Rob Herring
2020-09-07 14:27 ` [PATCH 2/8] dt-bindings: rtc: ds1307: " Bastian Krause
2020-09-15 16:00 ` Rob Herring
2020-09-07 14:27 ` [PATCH 3/8] dt-bindings: rtc: ds1307: add rx8130 aux-voltage-chargeable support Bastian Krause
2020-09-15 16:00 ` Rob Herring
2020-09-07 14:27 ` [PATCH 4/8] rtc: ds1307: apply DS13XX_TRICKLE_CHARGER_MAGIC only conditionally Bastian Krause
2020-09-07 14:27 ` [PATCH 5/8] rtc: ds1307: introduce requires_trickle_resistor per chip Bastian Krause
2020-09-07 14:27 ` Bastian Krause [this message]
2020-09-07 14:27 ` [PATCH 7/8] rtc: ds1307: consider aux-voltage-chargeable Bastian Krause
2020-09-07 14:27 ` [PATCH 8/8] rtc: ds1307: enable rx8130's backup battery, make it chargeable optionally Bastian Krause
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=20200907142727.26472-7-bst@pengutronix.de \
--to=bst@pengutronix.de \
--cc=a.zummo@towertech.it \
--cc=alexandre.belloni@bootlin.com \
--cc=arno@natisbad.org \
--cc=devicetree@vger.kernel.org \
--cc=kernel@pengutronix.de \
--cc=linux-rtc@vger.kernel.org \
--cc=marex@denx.de \
--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).