]> git.proxmox.com Git - mirror_ubuntu-hirsute-kernel.git/commitdiff
rtc: ds1307: store previous charge default per chip
authorBastian Krause <bst@pengutronix.de>
Thu, 17 Sep 2020 18:32:44 +0000 (20:32 +0200)
committerAlexandre Belloni <alexandre.belloni@bootlin.com>
Thu, 24 Sep 2020 07:56:04 +0000 (09:56 +0200)
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
drivers/rtc/rtc-ds1307.c

index 64fa1318817c8a43cec008b4161d7a92c16bac2f..fdd6f9fda6f9fabcb03190acf587762220650c3e 100644 (file)
@@ -195,6 +195,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];
@@ -991,6 +996,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,
@@ -999,6 +1005,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,
@@ -1307,7 +1314,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;