Skip to content

Commit a7464a0

Browse files
tpamborkartben
authored andcommitted
drivers: rtc: rv3028: explicitly init control registers
The driver on init currently only updates control register bits that differ from their reset values, implicitly assuming that all other bits are still in their default state. This assumption can break if the registers were previously modified, e.g. 12-hour mode was selected, leading to invalid time readings such as 32:57:12 from rtc_get_time(). Fix this by explicitly programming all control register fields to the configuration expected by the driver, instead of relying on the hardware reset state. Signed-off-by: Tim Pambor <tim.pambor@codewrights.de>
1 parent f91c8a4 commit a7464a0

1 file changed

Lines changed: 3 additions & 7 deletions

File tree

drivers/rtc/rtc_rv3028.c

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -954,17 +954,13 @@ static int rv3028_init(const struct device *dev)
954954
return -ENODEV;
955955
}
956956

957-
err = rv3028_update_reg8(dev, RV3028_REG_CONTROL1, RV3028_CONTROL1_WADA,
958-
RV3028_CONTROL1_WADA);
957+
err = rv3028_write_reg8(dev, RV3028_REG_CONTROL1, RV3028_CONTROL1_WADA);
959958
if (err) {
960959
return -ENODEV;
961960
}
962961

963-
/* Disable the alarms */
964-
err = rv3028_update_reg8(dev,
965-
RV3028_REG_CONTROL2,
966-
RV3028_CONTROL2_AIE | RV3028_CONTROL2_UIE,
967-
0);
962+
/* Disable interrupts and use 24 hour mode */
963+
err = rv3028_write_reg8(dev, RV3028_REG_CONTROL2, 0);
968964
if (err) {
969965
return -ENODEV;
970966
}

0 commit comments

Comments
 (0)