diff mbox series

[U-Boot,1/1] drivers: rtc: correctly set week day for mc146818

Message ID 20180721164020.26150-1-xypron.glpk@gmx.de
State Accepted
Commit c5b53baeaa1ba32bdbfd492c1dc38b6f2b64484a
Delegated to: Tom Rini
Headers show
Series [U-Boot,1/1] drivers: rtc: correctly set week day for mc146818 | expand

Commit Message

Heinrich Schuchardt July 21, 2018, 4:40 p.m. UTC
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).

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
---
 drivers/rtc/mc146818.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Tom Rini July 30, 2018, 8:01 p.m. UTC | #1
On Sat, Jul 21, 2018 at 06:40:20PM +0200, Heinrich Schuchardt wrote:

> 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).
> 
> Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>

Applied to u-boot/master, thanks!
diff mbox series

Patch

diff --git a/drivers/rtc/mc146818.c b/drivers/rtc/mc146818.c
index 744c0f4d75..b98c39d821 100644
--- a/drivers/rtc/mc146818.c
+++ b/drivers/rtc/mc146818.c
@@ -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));