Skip to contentSkip to conversation

drivers: rtc: correctly set week day for mc146818

PATCH New Heinrich Schuchardt 2 participants 2 messages Jul 21, 2018 – Jul 30, 2018 Real time clock (RTC)

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drivers: rtc: correctly set week day for mc146818

The driver sets the weekday incorrectly when called by the 'date set' command.

Sunday is 1, Saturday is 7 unlike in U-Boot (see data sheet
https://www.nxp.com/docs/en/data-sheet/MC146818.pdf, table 3).

---
 drivers/rtc/mc146818.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/rtc/mc146818.c +2 -1
index 744c0f4d75..b98c39d821 100644
@@ -143,7 +143,8 @@ static int mc146818_set(struct rtc_time *tmp)
 
 	mc146818_write8(RTC_YEAR, bin2bcd(tmp->tm_year % 100));
 	mc146818_write8(RTC_MONTH, bin2bcd(tmp->tm_mon));
-	mc146818_write8(RTC_DAY_OF_WEEK, bin2bcd(tmp->tm_wday));
+	/* Sunday = 1, Saturday = 7 */
+	mc146818_write8(RTC_DAY_OF_WEEK, bin2bcd(tmp->tm_wday + 1));
 	mc146818_write8(RTC_DATE_OF_MONTH, bin2bcd(tmp->tm_mday));
 	mc146818_write8(RTC_HOURS, bin2bcd(tmp->tm_hour));
 	mc146818_write8(RTC_MINUTES, bin2bcd(tmp->tm_min));
Signature · 1 line
2.18.0
#1 lore raw

PATCH 1/1 drivers: rtc: correctly set week day for mc146818

Quoted 7 lines · Heinrich Schuchardt

The driver sets the weekday incorrectly when called by the 'date set' command.

Sunday is 1, Saturday is 7 unlike in U-Boot (see data sheet
https://www.nxp.com/docs/en/data-sheet/MC146818.pdf, table 3).

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20180730/7f9fb00f/attachment.sig>