mirror of
https://github.com/edk2-porting/linux-next.git
synced 2024-12-15 00:34:10 +08:00
rtc: rv8803: factor out existing register initialization to function
The driver probe currently initializes some registers to non-POR values. These values are not reinstated if the RTC experiences voltage loss later on. Prepare for fixing this by factoring out the initialization to a separate function. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de> Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com> Link: https://lore.kernel.org/r/20220426071056.1187235-2-s.hauer@pengutronix.de
This commit is contained in:
parent
d2a632a8a1
commit
8c798e1ec1
@ -64,6 +64,7 @@ struct rv8803_data {
|
||||
struct rtc_device *rtc;
|
||||
struct mutex flags_lock;
|
||||
u8 ctrl;
|
||||
u8 backup;
|
||||
enum rv8803_type type;
|
||||
};
|
||||
|
||||
@ -498,18 +499,32 @@ static int rx8900_trickle_charger_init(struct rv8803_data *rv8803)
|
||||
if (err < 0)
|
||||
return err;
|
||||
|
||||
flags = ~(RX8900_FLAG_VDETOFF | RX8900_FLAG_SWOFF) & (u8)err;
|
||||
|
||||
if (of_property_read_bool(node, "epson,vdet-disable"))
|
||||
flags |= RX8900_FLAG_VDETOFF;
|
||||
|
||||
if (of_property_read_bool(node, "trickle-diode-disable"))
|
||||
flags |= RX8900_FLAG_SWOFF;
|
||||
flags = (u8)err;
|
||||
flags &= ~(RX8900_FLAG_VDETOFF | RX8900_FLAG_SWOFF);
|
||||
flags |= rv8803->backup;
|
||||
|
||||
return i2c_smbus_write_byte_data(rv8803->client, RX8900_BACKUP_CTRL,
|
||||
flags);
|
||||
}
|
||||
|
||||
/* configure registers with values different than the Power-On reset defaults */
|
||||
static int rv8803_regs_configure(struct rv8803_data *rv8803)
|
||||
{
|
||||
int err;
|
||||
|
||||
err = rv8803_write_reg(rv8803->client, RV8803_EXT, RV8803_EXT_WADA);
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
err = rx8900_trickle_charger_init(rv8803);
|
||||
if (err) {
|
||||
dev_err(&rv8803->client->dev, "failed to init charger\n");
|
||||
return err;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int rv8803_probe(struct i2c_client *client,
|
||||
const struct i2c_device_id *id)
|
||||
{
|
||||
@ -576,16 +591,16 @@ static int rv8803_probe(struct i2c_client *client,
|
||||
if (!client->irq)
|
||||
clear_bit(RTC_FEATURE_ALARM, rv8803->rtc->features);
|
||||
|
||||
err = rv8803_write_reg(rv8803->client, RV8803_EXT, RV8803_EXT_WADA);
|
||||
if (of_property_read_bool(client->dev.of_node, "epson,vdet-disable"))
|
||||
rv8803->backup |= RX8900_FLAG_VDETOFF;
|
||||
|
||||
if (of_property_read_bool(client->dev.of_node, "trickle-diode-disable"))
|
||||
rv8803->backup |= RX8900_FLAG_SWOFF;
|
||||
|
||||
err = rv8803_regs_configure(rv8803);
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
err = rx8900_trickle_charger_init(rv8803);
|
||||
if (err) {
|
||||
dev_err(&client->dev, "failed to init charger\n");
|
||||
return err;
|
||||
}
|
||||
|
||||
rv8803->rtc->ops = &rv8803_rtc_ops;
|
||||
rv8803->rtc->range_min = RTC_TIMESTAMP_BEGIN_2000;
|
||||
rv8803->rtc->range_max = RTC_TIMESTAMP_END_2099;
|
||||
|
Loading…
Reference in New Issue
Block a user