[PATCH v1 1/2] rtc: ds1307: set one-minute alarm resolution for rx_8130

From: Emanuele Ghidoli
Date: Mon Jun 24 2024 - 06:26:19 EST


From: Emanuele Ghidoli <emanuele.ghidoli@xxxxxxxxxxx>

Set one-minute alarm resolution for the rx_8130 by setting the
RTC_FEATURE_ALARM_RES_MINUTE flag according to the hw capabilities.

Additionally, set the no_upd_irq flag to disable update interrupts,
as it is not possible to generate update IRQs.
hwclock fails reading the date and time if the no update irq flag
is not set and IRQs is defined in DT.

Signed-off-by: Emanuele Ghidoli <emanuele.ghidoli@xxxxxxxxxxx>
---
drivers/rtc/rtc-ds1307.c | 14 ++++++++++++--
1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/drivers/rtc/rtc-ds1307.c b/drivers/rtc/rtc-ds1307.c
index 506b7d1c2397..96e4d82ad915 100644
--- a/drivers/rtc/rtc-ds1307.c
+++ b/drivers/rtc/rtc-ds1307.c
@@ -181,6 +181,8 @@ struct ds1307 {

struct chip_desc {
unsigned alarm:1;
+ unsigned alarm_res_min:1;
+ unsigned no_upd_irq:1;
u16 nvram_offset;
u16 nvram_size;
u8 offset; /* register's offset */
@@ -1015,6 +1017,8 @@ static const struct chip_desc chips[last_ds_type] = {
},
[rx_8130] = {
.alarm = 1,
+ .alarm_res_min = 1,
+ .no_upd_irq = 1,
/* this is battery backed SRAM */
.nvram_offset = 0x20,
.nvram_size = 4, /* 32bit (4 word x 8 bit) */
@@ -1946,10 +1950,16 @@ static int ds1307_probe(struct i2c_client *client)
if (IS_ERR(ds1307->rtc))
return PTR_ERR(ds1307->rtc);

- if (want_irq || ds1307_can_wakeup_device)
+ if (want_irq || ds1307_can_wakeup_device) {
device_set_wakeup_capable(ds1307->dev, true);
- else
+ if (chip->alarm_res_min)
+ set_bit(RTC_FEATURE_ALARM_RES_MINUTE, ds1307->rtc->features);
+ } else {
clear_bit(RTC_FEATURE_ALARM, ds1307->rtc->features);
+ }
+
+ if (chip->no_upd_irq)
+ clear_bit(RTC_FEATURE_UPDATE_INTERRUPT, ds1307->rtc->features);

if (ds1307_can_wakeup_device && !want_irq) {
dev_info(ds1307->dev,
--
2.34.1