--- a/drivers/rtc/rtc-armada38x.c	2017-12-11 19:43:10.413872736 +0200
+++ b/drivers/rtc/rtc-armada38x.c	2017-12-11 19:55:57.225878308 +0200
@@ -30,6 +30,9 @@
 #define RTC_IRQ_FREQ_1HZ	    BIT(2)
 #define RTC_CCR		    0x18
 #define RTC_CCR_MODE		    BIT(15)
+#define RTC_CCR_NORMAL_PPB	    0x2000
+#define RTC_TEST_CONF	    0x1c
+#define RTC_TEST_CONF_MASK	    0xff
 
 #define RTC_TIME	    0xC
 #define RTC_ALARM1	    0x10
@@ -216,14 +219,18 @@
 {
 	struct armada38x_rtc *rtc = dev_get_drvdata(dev);
 	unsigned long time, flags;
+	int ret = 0;
+	u32 reg;
 
 	spin_lock_irqsave(&rtc->lock, flags);
-	time = rtc->data->read_rtc_reg(rtc, RTC_TIME);
+	reg = rtc->data->read_rtc_reg(rtc, RTC_TEST_CONF);
+	if (reg & RTC_TEST_CONF_MASK) ret = -EPERM;
+	else time = rtc->data->read_rtc_reg(rtc, RTC_TIME);
 	spin_unlock_irqrestore(&rtc->lock, flags);
 
 	rtc_time_to_tm(time, tm);
 
-	return 0;
+	return ret;
 }
 
 static int armada38x_rtc_set_time(struct device *dev, struct rtc_time *tm)
@@ -231,12 +238,21 @@
 	struct armada38x_rtc *rtc = dev_get_drvdata(dev);
 	int ret = 0;
 	unsigned long time, flags;
+	u32 reg;
 
 	ret = rtc_tm_to_time(tm, &time);
 
 	if (ret)
 		goto out;
 
+	reg = rtc->data->read_rtc_reg(rtc, RTC_TEST_CONF);
+	if (reg & RTC_TEST_CONF_MASK) {
+		rtc_delayed_write(0, rtc, RTC_TEST_CONF);
+		rtc_delayed_write(0, rtc, RTC_TIME);
+		rtc_delayed_write((RTC_STATUS_ALARM1 | RTC_STATUS_ALARM2),
+			rtc, RTC_STATUS);
+		rtc_delayed_write(RTC_CCR_NORMAL_PPB, rtc, RTC_CCR);
+	}
 	spin_lock_irqsave(&rtc->lock, flags);
 	rtc_delayed_write(time, rtc, RTC_TIME);
 	spin_unlock_irqrestore(&rtc->lock, flags);