From mboxrd@z Thu Jan 1 00:00:00 1970 From: Dario Binacchi Date: Fri, 7 May 2021 06:15:08 +0200 Subject: [PATCH 7/7] rtc: davinci: fix date loaded on reset In-Reply-To: <20210507041509.4928-1-dariobin@libero.it> References: <20210507041509.4928-1-dariobin@libero.it> Message-ID: <20210507041509.4928-8-dariobin@libero.it> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de On reset, the RTC loads the 2000-01-01 date with a wrong day of the week (Sunday instead of Saturday). Signed-off-by: Dario Binacchi --- drivers/rtc/davinci.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/drivers/rtc/davinci.c b/drivers/rtc/davinci.c index b0a077cba7..88fd56b1ba 100644 --- a/drivers/rtc/davinci.c +++ b/drivers/rtc/davinci.c @@ -335,6 +335,7 @@ static int omap_rtc_remove(struct udevice *dev) static int omap_rtc_probe(struct udevice *dev) { struct omap_rtc_priv *priv = dev_get_priv(dev); + struct rtc_time tm; u8 reg, mask, new_ctrl; priv->dev = dev; @@ -425,6 +426,15 @@ static int omap_rtc_probe(struct udevice *dev) } omap_rtc_lock(priv); + + if (omap_rtc_get(dev, &tm)) { + dev_err(dev, "failed to get datetime\n"); + } else if (tm.tm_year == 2000 && tm.tm_mon == 1 && tm.tm_mday == 1 && + tm.tm_wday == 0) { + tm.tm_wday = 6; + omap_rtc_set(dev, &tm); + } + return 0; } -- 2.17.1