summaryrefslogtreecommitdiff
path: root/drivers/rtc
diff options
context:
space:
mode:
authorBastian Krause <bst@pengutronix.de>2020-09-17 20:32:44 +0200
committerMax Krummenacher <max.krummenacher@toradex.com>2020-11-06 14:56:37 +0100
commit9c1a6aef82c797b32a43b863f472346a7b4c6f70 (patch)
treedce94fc888b7f5335c841400317c2cd3c0088bdc /drivers/rtc
parent3f8adc6dc4578faf1dbafa7acc3d481c0d6a1f41 (diff)
rtc: ds1307: store previous charge default per chip
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> Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com> Link: https://lore.kernel.org/r/20200917183246.19446-7-bst@pengutronix.de (cherry picked from commit 95a74cbb21a2431dd2fd8918fa26113629b6e13e)
Diffstat (limited to 'drivers/rtc')
-rw-r--r--drivers/rtc/rtc-ds1307.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/drivers/rtc/rtc-ds1307.c b/drivers/rtc/rtc-ds1307.c
index 4a33463edd61..5da1a5ca2647 100644
--- a/drivers/rtc/rtc-ds1307.c
+++ b/drivers/rtc/rtc-ds1307.c
@@ -184,6 +184,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];
@@ -903,6 +908,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,
@@ -911,6 +917,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,
@@ -1219,7 +1226,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;