diff options
author | Bastian Krause <bst@pengutronix.de> | 2020-09-17 20:32:45 +0200 |
---|---|---|
committer | Oleksandr Suvorov <oleksandr.suvorov@toradex.com> | 2021-01-28 14:48:14 +0200 |
commit | 89bc964587d262e07291f1fc92d36c955206b969 (patch) | |
tree | 324d74b862074d74fd324ea3f8eb3af3fa57b7dd /drivers/rtc | |
parent | a6f586c2c3f2afad94b2257eab935e728e76e08f (diff) |
rtc: ds1307: consider aux-voltage-chargeable
Prefer aux-voltage-chargeable over trickle-diode-disable and set diode
accordingly. This is then passed to the chip's appropriate charge setup
function.
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-8-bst@pengutronix.de
(cherry picked from commit 0874734e09af5cc05439dbe2c8ff704f14d679f5)
Diffstat (limited to 'drivers/rtc')
-rw-r--r-- | drivers/rtc/rtc-ds1307.c | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/drivers/rtc/rtc-ds1307.c b/drivers/rtc/rtc-ds1307.c index 5da1a5ca2647..4e5f64ad54b2 100644 --- a/drivers/rtc/rtc-ds1307.c +++ b/drivers/rtc/rtc-ds1307.c @@ -1225,7 +1225,7 @@ static int ds1307_nvram_write(void *priv, unsigned int offset, void *val, static u8 ds1307_trickle_init(struct ds1307 *ds1307, const struct chip_desc *chip) { - u32 ohms; + u32 ohms, chargeable; bool diode = chip->charge_default; if (!chip->do_trickle_setup) @@ -1235,8 +1235,27 @@ static u8 ds1307_trickle_init(struct ds1307 *ds1307, &ohms) && chip->requires_trickle_resistor) return 0; - if (device_property_read_bool(ds1307->dev, "trickle-diode-disable")) + /* aux-voltage-chargeable takes precedence over the deprecated + * trickle-diode-disable + */ + if (!device_property_read_u32(ds1307->dev, "aux-voltage-chargeable", + &chargeable)) { + switch (chargeable) { + case 0: + diode = false; + break; + case 1: + diode = true; + break; + default: + dev_warn(ds1307->dev, + "unsupported aux-voltage-chargeable value\n"); + break; + } + } else if (device_property_read_bool(ds1307->dev, + "trickle-diode-disable")) { diode = false; + } return chip->do_trickle_setup(ds1307, ohms, diode); } |