[U-Boot] [PATCH 1/1] drivers: rtc: correct week day for mc146818
Heinrich Schuchardt
xypron.glpk at gmx.de
Sat Jul 7 21:26:19 UTC 2018
For qemu-x86 the date command produces wrong days of the week:
Date: 2018-07-06 (Saturday) Time: 18:02:03
Date: 2018-07-07 (unknown day) Time: 21:02:06
According to a comment in the Linux driver the mc146818 only updates the
day of the week if the register value is non-zero.
Sunday is 1, saturday is 7 unlike in U-Boot (see data sheet
https://www.nxp.com/docs/en/data-sheet/MC146818.pdf).
So let's use our library function to determine the day of the week.
Signed-off-by: Heinrich Schuchardt <xypron.glpk at gmx.de>
---
drivers/rtc/mc146818.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/drivers/rtc/mc146818.c b/drivers/rtc/mc146818.c
index 444d4baf0b..1d25c03559 100644
--- a/drivers/rtc/mc146818.c
+++ b/drivers/rtc/mc146818.c
@@ -109,7 +109,11 @@ static int mc146818_get(struct rtc_time *tmp)
tmp->tm_mday = bcd2bin(mday & 0x3f);
tmp->tm_mon = bcd2bin(mon & 0x1f);
tmp->tm_year = bcd2bin(year);
- tmp->tm_wday = bcd2bin(wday & 0x07);
+ /*
+ * The mc146818 only updates wday if it is non-zero, sunday is 1
+ * saturday is 7. So let's use our library routine.
+ */
+ tmp->tm->wday = rtc_calc_weekday(struct rtc_time *tm);
if (tmp->tm_year < 70)
tmp->tm_year += 2000;
--
2.18.0
More information about the U-Boot
mailing list