Commit f8176e0b authored by Ahmad Fatoum's avatar Ahmad Fatoum Committed by Alexandre Belloni

rtc: rv8803: initialize registers on post-probe voltage loss

The driver probe currently initializes some registers to non-POR
values. These values are not reinstated if the RTC experiences voltage
loss later on. Fix this.
Signed-off-by: default avatarAhmad Fatoum <a.fatoum@pengutronix.de>
Signed-off-by: default avatarSascha Hauer <s.hauer@pengutronix.de>
Signed-off-by: default avatarAlexandre Belloni <alexandre.belloni@bootlin.com>
Link: https://lore.kernel.org/r/20220426071056.1187235-3-s.hauer@pengutronix.de
parent 8c798e1e
...@@ -137,6 +137,13 @@ static int rv8803_write_regs(const struct i2c_client *client, ...@@ -137,6 +137,13 @@ static int rv8803_write_regs(const struct i2c_client *client,
return ret; return ret;
} }
static int rv8803_regs_configure(struct rv8803_data *rv8803);
static int rv8803_regs_reset(struct rv8803_data *rv8803)
{
return rv8803_regs_configure(rv8803);
}
static irqreturn_t rv8803_handle_irq(int irq, void *dev_id) static irqreturn_t rv8803_handle_irq(int irq, void *dev_id)
{ {
struct i2c_client *client = dev_id; struct i2c_client *client = dev_id;
...@@ -270,6 +277,12 @@ static int rv8803_set_time(struct device *dev, struct rtc_time *tm) ...@@ -270,6 +277,12 @@ static int rv8803_set_time(struct device *dev, struct rtc_time *tm)
return flags; return flags;
} }
if (flags & RV8803_FLAG_V2F) {
ret = rv8803_regs_reset(rv8803);
if (ret)
return ret;
}
ret = rv8803_write_reg(rv8803->client, RV8803_FLAG, ret = rv8803_write_reg(rv8803->client, RV8803_FLAG,
flags & ~(RV8803_FLAG_V1F | RV8803_FLAG_V2F)); flags & ~(RV8803_FLAG_V1F | RV8803_FLAG_V2F));
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment