[PATCH 1/2] drivers: rtc: max313xx: Fix setting years 2100-2199

An invalid calculation made setting years 2100-2199 impossible.
Signed-off-by: Mark Tomlinson mark.tomlinson@alliedtelesis.co.nz Cc: Chris Packham judge.packham@gmail.com --- drivers/rtc/max313xx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/rtc/max313xx.c b/drivers/rtc/max313xx.c index 60400235dd0..ccfd6b6d0e2 100644 --- a/drivers/rtc/max313xx.c +++ b/drivers/rtc/max313xx.c @@ -285,7 +285,7 @@ static int max313xx_set_time(struct udevice *dev, const struct rtc_time *t) regs[5] = bin2bcd(t->tm_mon); regs[6] = bin2bcd((t->tm_year - 2000) % 100);
- if ((t->tm_year - 2000) >= 200) + if (t->tm_year >= 2100) regs[5] |= FIELD_PREP(MAX313XX_MONTH_CENTURY, 1);
ret = dm_i2c_write(dev, rtc->chip->sec_reg, regs, 7);

When setting the time on the MAX31343, the time is not updated for one second, and reading the time in this interval will give the old time. Wait one second after writing so that the date command will show the correct time when setting the clock.
Signed-off-by: Mark Tomlinson mark.tomlinson@alliedtelesis.co.nz Cc: Chris Packham judge.packham@gmail.com --- drivers/rtc/max313xx.c | 5 +++++ 1 file changed, 5 insertions(+)
diff --git a/drivers/rtc/max313xx.c b/drivers/rtc/max313xx.c index ccfd6b6d0e2..2cb3f245041 100644 --- a/drivers/rtc/max313xx.c +++ b/drivers/rtc/max313xx.c @@ -307,6 +307,11 @@ static int max313xx_set_time(struct udevice *dev, const struct rtc_time *t) if (ret) return ret;
+ break; + case ID_MAX31343: + /* Time is not updated for 1 second after writing */ + /* Sleep here so the date command shows the new time */ + mdelay(1000); break; default: break;

On 20/01/2025 14:59, Mark Tomlinson wrote:
When setting the time on the MAX31343, the time is not updated for one second, and reading the time in this interval will give the old time. Wait one second after writing so that the date command will show the correct time when setting the clock.
Signed-off-by: Mark Tomlinson mark.tomlinson@alliedtelesis.co.nz Cc: Chris Packham judge.packham@gmail.com
Reviewed-by: Chris Packham judge.packham@gmail.com
drivers/rtc/max313xx.c | 5 +++++ 1 file changed, 5 insertions(+)
diff --git a/drivers/rtc/max313xx.c b/drivers/rtc/max313xx.c index ccfd6b6d0e2..2cb3f245041 100644 --- a/drivers/rtc/max313xx.c +++ b/drivers/rtc/max313xx.c @@ -307,6 +307,11 @@ static int max313xx_set_time(struct udevice *dev, const struct rtc_time *t) if (ret) return ret;
break;
- case ID_MAX31343:
/* Time is not updated for 1 second after writing */
/* Sleep here so the date command shows the new time */
break; default: break;mdelay(1000);

Replying from my work email because gmail seems to be discarding messages
On 20/01/2025 14:59, Mark Tomlinson wrote:
An invalid calculation made setting years 2100-2199 impossible.
Signed-off-by: Mark Tomlinson mark.tomlinson@alliedtelesis.co.nz Cc: Chris Packham judge.packham@gmail.com
Reviewed-by: Chris Packham judge.packham@gmail.com
drivers/rtc/max313xx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/rtc/max313xx.c b/drivers/rtc/max313xx.c index 60400235dd0..ccfd6b6d0e2 100644 --- a/drivers/rtc/max313xx.c +++ b/drivers/rtc/max313xx.c @@ -285,7 +285,7 @@ static int max313xx_set_time(struct udevice *dev, const struct rtc_time *t) regs[5] = bin2bcd(t->tm_mon); regs[6] = bin2bcd((t->tm_year - 2000) % 100);
- if ((t->tm_year - 2000) >= 200)
if (t->tm_year >= 2100) regs[5] |= FIELD_PREP(MAX313XX_MONTH_CENTURY, 1);
ret = dm_i2c_write(dev, rtc->chip->sec_reg, regs, 7);
participants (3)
-
Chris Packham
-
Mark Tomlinson
-
Tom Rini