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 v2 4/8] rtc: ds1307: apply DS13XX_TRICKLE_CHARGER_MAGIC only conditionally
Date: Thu, 17 Sep 2020 20:32:42 +0200 [thread overview]
Message-ID: <20200917183246.19446-5-bst@pengutronix.de> (raw)
In-Reply-To: <20200917183246.19446-1-bst@pengutronix.de>
DS13XX_TRICKLE_CHARGER_MAGIC sets the trickle-charge select (TCS) bits
(7..4). The datasheet of Maxim Integrated's DS1339 [1] for instance
reads:
"To prevent accidental enabling, only a pattern on 1010 enables the
trickle charger. All other patterns disable the trickle charger."
Since not all RTCs connected to a backup battery or supercap use these
bits DS13XX_TRICKLE_CHARGER_MAGIC should not get applied for all charger
setups unconditionally.
Epson's RX8130 is such an example: Instead of TCS bits "SMPTSEL1",
"SMPTSEL0", "CHGEN" and "INIEN" are expected as bit 7..4.
DS1339 and DS1340 are currently the only RTCs in the ds1307 driver that
apply DS13XX_TRICKLE_CHARGER_MAGIC to their setup register value. So
apply DS13XX_TRICKLE_CHARGER_MAGIC in do_trickle_setup_ds1339() which
is used by both RTCs.
[1] https://datasheets.maximintegrated.com/en/ds/DS1339-DS1339U.pdf
[2] https://support.epson.biz/td/api/doc_check.php?dl=app_RX8130CE
Signed-off-by: Bastian Krause <bst@pengutronix.de>
---
No changes since v1.
v1 notes:
No previous version.
---
drivers/rtc/rtc-ds1307.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/rtc/rtc-ds1307.c b/drivers/rtc/rtc-ds1307.c
index 54c85cdd019d..ff5242d10b21 100644
--- a/drivers/rtc/rtc-ds1307.c
+++ b/drivers/rtc/rtc-ds1307.c
@@ -507,6 +507,8 @@ static u8 do_trickle_setup_ds1339(struct ds1307 *ds1307, u32 ohms, bool diode)
u8 setup = (diode) ? DS1307_TRICKLE_CHARGER_DIODE :
DS1307_TRICKLE_CHARGER_NO_DIODE;
+ setup |= DS13XX_TRICKLE_CHARGER_MAGIC;
+
switch (ohms) {
case 250:
setup |= DS1307_TRICKLE_CHARGER_250_OHM;
@@ -1758,7 +1760,6 @@ static int ds1307_probe(struct i2c_client *client,
trickle_charger_setup = pdata->trickle_charger_setup;
if (trickle_charger_setup && chip->trickle_charger_reg) {
- trickle_charger_setup |= DS13XX_TRICKLE_CHARGER_MAGIC;
dev_dbg(ds1307->dev,
"writing trickle charger info 0x%x to 0x%x\n",
trickle_charger_setup, chip->trickle_charger_reg);
--
2.28.0
next prev parent reply other threads:[~2020-09-17 18:34 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-09-17 18:32 [PATCH v2 0/8] rtc: expand charge support, implement rx8130 charging Bastian Krause
2020-09-17 18:32 ` [PATCH v2 1/8] dt-bindings: rtc: let aux-voltage-chargeable supersede trickle-diode-disable Bastian Krause
2020-09-23 20:23 ` Rob Herring
2020-09-17 18:32 ` [PATCH v2 2/8] dt-bindings: rtc: ds1307: " Bastian Krause
2020-09-17 18:32 ` [PATCH v2 3/8] dt-bindings: rtc: ds1307: add rx8130 aux-voltage-chargeable support Bastian Krause
2020-09-17 18:32 ` Bastian Krause [this message]
2020-09-17 18:32 ` [PATCH v2 5/8] rtc: ds1307: introduce requires_trickle_resistor per chip Bastian Krause
2020-09-17 18:32 ` [PATCH v2 6/8] rtc: ds1307: store previous charge default " Bastian Krause
2020-09-17 18:32 ` [PATCH v2 7/8] rtc: ds1307: consider aux-voltage-chargeable Bastian Krause
2020-09-17 18:32 ` [PATCH v2 8/8] rtc: ds1307: enable rx8130's backup battery, make it chargeable optionally Bastian Krause
2020-09-24 7:59 ` [PATCH v2 0/8] rtc: expand charge support, implement rx8130 charging 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=20200917183246.19446-5-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).