aboutsummaryrefslogtreecommitdiffstats
path: root/target/linux/mvebu/patches-4.14/421-rtc-armada38x-reset-after-rtc-power-loss.patch
diff options
context:
space:
mode:
authorRosen Penev <rosenp@gmail.com>2018-09-08 21:23:57 -0700
committerJohn Crispin <john@phrozen.org>2018-09-10 09:11:31 +0200
commit6a2ee91267a09fd77dee70cf3b0ba8b9b905476f (patch)
treeb5a0e086431c7d8c13454cca99fc5303bc4a71dc /target/linux/mvebu/patches-4.14/421-rtc-armada38x-reset-after-rtc-power-loss.patch
parenta9aa25c8b6f2e694d5bc0b14fe84eac6fffeb23a (diff)
downloadupstream-6a2ee91267a09fd77dee70cf3b0ba8b9b905476f.tar.gz
upstream-6a2ee91267a09fd77dee70cf3b0ba8b9b905476f.tar.bz2
upstream-6a2ee91267a09fd77dee70cf3b0ba8b9b905476f.zip
mvebu: Replace RTC initialization patch with upstreamed version
While we're at it, rename the patches to their proper git format-patch name. Tested on a Turris Omnia. Signed-off-by: Rosen Penev <rosenp@gmail.com>
Diffstat (limited to 'target/linux/mvebu/patches-4.14/421-rtc-armada38x-reset-after-rtc-power-loss.patch')
-rw-r--r--target/linux/mvebu/patches-4.14/421-rtc-armada38x-reset-after-rtc-power-loss.patch78
1 files changed, 78 insertions, 0 deletions
diff --git a/target/linux/mvebu/patches-4.14/421-rtc-armada38x-reset-after-rtc-power-loss.patch b/target/linux/mvebu/patches-4.14/421-rtc-armada38x-reset-after-rtc-power-loss.patch
new file mode 100644
index 0000000000..e9291c456f
--- /dev/null
+++ b/target/linux/mvebu/patches-4.14/421-rtc-armada38x-reset-after-rtc-power-loss.patch
@@ -0,0 +1,78 @@
+From 1a990fefb641398fb580a0ea0be99b0ff27cbb9b Mon Sep 17 00:00:00 2001
+From: Baruch Siach <baruch@tkos.co.il>
+Date: Thu, 21 Jun 2018 20:40:23 +0300
+Subject: [PATCH] rtc: armada38x: reset after rtc power loss
+
+When the RTC block looses power it needs a reset sequence to make it
+usable again. Otherwise, writes to the time register have no effect.
+
+This reset sequence combines information from the mvebu_rtc driver in
+the Marvell provided U-Boot, and the SolidRun provided U-Boot repo.
+
+Tested on the Armada 388 based SolidRun Clearfog Base.
+
+Signed-off-by: Baruch Siach <baruch@tkos.co.il>
+Acked-by: Gregory CLEMENT <gregory.clement@bootlin.com>
+Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
+---
+ drivers/rtc/rtc-armada38x.c | 23 +++++++++++++++++++++++
+ 1 file changed, 23 insertions(+)
+
+diff --git a/drivers/rtc/rtc-armada38x.c b/drivers/rtc/rtc-armada38x.c
+index 1e4978c..bde53c8c 100644
+--- a/drivers/rtc/rtc-armada38x.c
++++ b/drivers/rtc/rtc-armada38x.c
+@@ -30,6 +30,8 @@
+ #define RTC_IRQ_FREQ_1HZ BIT(2)
+ #define RTC_CCR 0x18
+ #define RTC_CCR_MODE BIT(15)
++#define RTC_CONF_TEST 0x1C
++#define RTC_NOMINAL_TIMING BIT(13)
+
+ #define RTC_TIME 0xC
+ #define RTC_ALARM1 0x10
+@@ -75,6 +77,7 @@ struct armada38x_rtc {
+ void __iomem *regs_soc;
+ spinlock_t lock;
+ int irq;
++ bool initialized;
+ struct value_to_freq *val_to_freq;
+ struct armada38x_rtc_data *data;
+ };
+@@ -226,6 +229,23 @@ static int armada38x_rtc_read_time(struct device *dev, struct rtc_time *tm)
+ return 0;
+ }
+
++static void armada38x_rtc_reset(struct armada38x_rtc *rtc)
++{
++ u32 reg;
++
++ reg = rtc->data->read_rtc_reg(rtc, RTC_CONF_TEST);
++ /* If bits [7:0] are non-zero, assume RTC was uninitialized */
++ if (reg & 0xff) {
++ rtc_delayed_write(0, rtc, RTC_CONF_TEST);
++ msleep(500); /* Oscillator startup time */
++ rtc_delayed_write(0, rtc, RTC_TIME);
++ rtc_delayed_write(SOC_RTC_ALARM1 | SOC_RTC_ALARM2, rtc,
++ RTC_STATUS);
++ rtc_delayed_write(RTC_NOMINAL_TIMING, rtc, RTC_CCR);
++ }
++ rtc->initialized = true;
++}
++
+ static int armada38x_rtc_set_time(struct device *dev, struct rtc_time *tm)
+ {
+ struct armada38x_rtc *rtc = dev_get_drvdata(dev);
+@@ -237,6 +257,9 @@ static int armada38x_rtc_set_time(struct device *dev, struct rtc_time *tm)
+ if (ret)
+ goto out;
+
++ if (!rtc->initialized)
++ armada38x_rtc_reset(rtc);
++
+ spin_lock_irqsave(&rtc->lock, flags);
+ rtc_delayed_write(time, rtc, RTC_TIME);
+ spin_unlock_irqrestore(&rtc->lock, flags);
+--
+2.7.4
+