MLK-13702 rtc: snvs: make sure set time is working for i.mx7ulp
authorAnson Huang <Anson.Huang@nxp.com>
Mon, 9 Jan 2017 10:14:29 +0000 (18:14 +0800)
committerNitin Garg <nitin.garg@nxp.com>
Mon, 19 Mar 2018 19:58:05 +0000 (14:58 -0500)
On i.MX7ULP, only waiting for enable bit of SNVS RTC clear is
NOT enough for RTC time program, need to add at least 12us delay,
here adds 38us margins to make sure RTC time can be changed, and
this is NOT harmful for other i.MX.

Signed-off-by: Anson Huang <Anson.Huang@nxp.com>
drivers/rtc/rtc-snvs.c

index bbb238e..e636493 100644 (file)
@@ -1,5 +1,6 @@
 /*
  * Copyright (C) 2011-2016 Freescale Semiconductor, Inc.
+ * Copyright 2017 NXP
  *
  * The code contained herein is licensed under the GNU General Public
  * License. You may obtain a copy of the GNU General Public License
@@ -18,6 +19,7 @@
 #include <linux/platform_device.h>
 #include <linux/rtc.h>
 #include <linux/clk.h>
+#include <linux/delay.h>
 #include <linux/mfd/syscon.h>
 #include <linux/regmap.h>
 
@@ -143,6 +145,8 @@ static int snvs_rtc_set_time(struct device *dev, struct rtc_time *tm)
        /* Disable RTC first */
        snvs_rtc_enable(data, false);
 
+       udelay(50);
+
        /* Write 32-bit time to 47-bit timer, leaving 15 LSBs blank */
        regmap_write(data->regmap, data->offset + SNVS_LPSRTCLR, time << CNTR_TO_SECS_SH);
        regmap_write(data->regmap, data->offset + SNVS_LPSRTCMR, time >> (32 - CNTR_TO_SECS_SH));