linux-rtc.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Bastian Krause <bst@pengutronix.de>
To: linux-rtc@vger.kernel.org
Cc: 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>,
	devicetree@vger.kernel.org, kernel@pengutronix.de,
	Bastian Krause <bst@pengutronix.de>
Subject: [PATCH 3/3] rtc: ds1307: make backup battery chargeable optionally
Date: Wed, 15 Apr 2020 18:37:01 +0200	[thread overview]
Message-ID: <20200415163701.21989-3-bst@pengutronix.de> (raw)
In-Reply-To: <20200415163701.21989-1-bst@pengutronix.de>

RX8130_REG_CONTROL1_CHGEN decides whether the battery or the
supercap should be charged or not. Introduce a new dt binding for that.

Signed-off-by: Bastian Krause <bst@pengutronix.de>
---
 drivers/rtc/rtc-ds1307.c | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/drivers/rtc/rtc-ds1307.c b/drivers/rtc/rtc-ds1307.c
index 5f0df60a71d1..451708402c3e 100644
--- a/drivers/rtc/rtc-ds1307.c
+++ b/drivers/rtc/rtc-ds1307.c
@@ -124,6 +124,7 @@ enum ds_type {
 #define RX8130_REG_CONTROL0_AIE		BIT(3)
 #define RX8130_REG_CONTROL1		0x1f
 #define RX8130_REG_CONTROL1_INIEN	BIT(4)
+#define RX8130_REG_CONTROL1_CHGEN	BIT(5)
 
 #define MCP794XX_REG_CONTROL		0x07
 #	define MCP794XX_BIT_ALM0_EN	0x10
@@ -1708,6 +1709,7 @@ static int ds1307_probe(struct i2c_client *client,
 	const struct chip_desc	*chip;
 	bool			want_irq;
 	bool			ds1307_can_wakeup_device = false;
+	bool			enable_bb_charging = false;
 	unsigned char		regs[8];
 	struct ds1307_platform_data *pdata = dev_get_platdata(&client->dev);
 	u8			trickle_charger_setup = 0;
@@ -1774,6 +1776,9 @@ static int ds1307_probe(struct i2c_client *client,
 	if (chip->alarm && of_property_read_bool(client->dev.of_node,
 						 "wakeup-source"))
 		ds1307_can_wakeup_device = true;
+
+	enable_bb_charging = of_property_read_bool(client->dev.of_node,
+						   "aux-voltage-chargeable");
 #endif
 
 	switch (ds1307->type) {
@@ -1879,8 +1884,13 @@ static int ds1307_probe(struct i2c_client *client,
 		break;
 	case rx_8130:
 		/* make sure that the backup battery is enabled */
-		regmap_write(ds1307->regmap, RX8130_REG_CONTROL1,
-			     RX8130_REG_CONTROL1_INIEN);
+		regs[0] = RX8130_REG_CONTROL1_INIEN;
+
+		/* set chargeable flag */
+		if (enable_bb_charging)
+			regs[0] |= RX8130_REG_CONTROL1_CHGEN;
+
+		regmap_write(ds1307->regmap, RX8130_REG_CONTROL1, regs[0]);
 		break;
 	default:
 		break;
-- 
2.26.0.rc2


      parent reply	other threads:[~2020-04-15 16:37 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-15 16:36 [RESEND PATCH v2 1/3] rtc: ds1307: Enable battery backup on RX8130 Bastian Krause
2020-04-15 16:37 ` [PATCH 2/3] dt-bindings: rtc: add chargeable flag for rx8130 Bastian Krause
2020-04-15 16:44   ` Uwe Kleine-König
2020-04-15 18:56   ` Alexandre Belloni
2020-08-24 11:31     ` Bastian Krause
2020-08-24 13:32       ` Bastian Krause
2020-08-25 15:32         ` Alexandre Belloni
2020-08-26  8:13           ` Bastian Krause
2020-09-02 19:18             ` Alexandre Belloni
2020-04-15 16:37 ` Bastian Krause [this message]

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=20200415163701.21989-3-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).