]> rtime.felk.cvut.cz Git - vajnamar/linux-xlnx.git/commitdiff
rtc: Enable RTC switching to battery power when VCC_PSAUX is N/A
authorAnurag Kumar Vulisha <anurag.kumar.vulisha@xilinx.com>
Wed, 28 Oct 2015 09:17:54 +0000 (14:47 +0530)
committerMichal Simek <michal.simek@xilinx.com>
Thu, 29 Oct 2015 07:12:17 +0000 (08:12 +0100)
In order to conserve battery energy, during the PS operation,
it is expected that the supply for the battery-powered domain
to be switched from the battery (VCC_PSBATT) to (VCC_PSAUX) and
automatically be switched back to battery when VCC_PSAUX voltage
drops below a limit, doing so prevents the logic within
the battery-powered domain from functioning incorrectly.

This patch enables that feature.

Signed-off-by: Anurag Kumar Vulisha <anuragku@xilinx.com>
Signed-off-by: Michal Simek <michal.simek@xilinx.com>
drivers/rtc/rtc-zynqmp.c

index e442746b662877617044ddba0c9d5862ec11cde9..cd3a91a3ca3466a355bd10a93edf7b3d6c7c8da3 100644 (file)
@@ -45,6 +45,7 @@
 #define RTC_INT_SEC            BIT(0)
 #define RTC_INT_ALRM           BIT(1)
 #define RTC_OSC_EN             BIT(24)
+#define RTC_BATT_EN            BIT(31)
 
 #define RTC_CALIB_DEF          0x198233
 #define RTC_CALIB_MASK         0x1FFFFF
@@ -114,6 +115,13 @@ static int xlnx_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alrm)
 
 static void xlnx_init_rtc(struct xlnx_rtc_dev *xrtcdev, u32 calibval)
 {
+       u32 rtc_ctrl;
+
+       /* Enable RTC switch to battery when VCC_PSAUX is not available */
+       rtc_ctrl = readl(xrtcdev->reg_base + RTC_CTRL);
+       rtc_ctrl |= RTC_BATT_EN;
+       writel(rtc_ctrl, xrtcdev->reg_base + RTC_CTRL);
+
        /*
         * Based on crystal freq of 33.330 KHz
         * set the secounds counter and enable, set fractions counter