rtc: s3c: Control RTC's source clock
authorChanwoo Choi <cw00.choi@samsung.com>
Thu, 10 Jul 2014 09:07:32 +0000 (18:07 +0900)
committerChanho Park <chanho61.park@samsung.com>
Tue, 18 Nov 2014 03:00:13 +0000 (12:00 +0900)
This patch control source clock(32.768KHz) for RTC block. If source clock of RTC
is registerd on clock list of common clk framework, Exynos RTC drvier have to
control this clock.

Clock list for s3c-rtc device:
- rtc : CLK_RTC of CLK_GATE_IP_PERIR is gate clock for RTC.
- rtc_src_clk : XrtcXTI is 32.768.kHz source clock for RTC.

Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
drivers/rtc/rtc-s3c.c

index 0b495e8..8fff2d9 100644 (file)
@@ -47,6 +47,7 @@ struct s3c_rtc_drv_data {
  * of these rtc blocks in */
 
 static struct clk *rtc_clk;
+static struct clk *rtc_src_clk;
 static void __iomem *s3c_rtc_base;
 static int s3c_rtc_alarmno = NO_IRQ;
 static int s3c_rtc_tickno  = NO_IRQ;
@@ -425,6 +426,7 @@ static int s3c_rtc_remove(struct platform_device *dev)
 
        s3c_rtc_setaie(&dev->dev, 0);
 
+       clk_disable_unprepare(rtc_src_clk);
        clk_unprepare(rtc_clk);
        rtc_clk = NULL;
 
@@ -483,7 +485,7 @@ static int s3c_rtc_probe(struct platform_device *pdev)
 
        rtc_clk = devm_clk_get(&pdev->dev, "rtc");
        if (IS_ERR(rtc_clk)) {
-               dev_err(&pdev->dev, "failed to find rtc clock source\n");
+               dev_err(&pdev->dev, "failed to find rtc gate clock\n");
                ret = PTR_ERR(rtc_clk);
                rtc_clk = NULL;
                return ret;
@@ -491,6 +493,14 @@ static int s3c_rtc_probe(struct platform_device *pdev)
 
        clk_prepare_enable(rtc_clk);
 
+       rtc_src_clk = devm_clk_get(&pdev->dev, "rtc_src_clk");
+       if (IS_ERR(rtc_src_clk)) {
+               dev_warn(&pdev->dev, "failed to find rtc source clock\n");
+               rtc_src_clk = NULL;
+       }
+
+       clk_prepare_enable(rtc_src_clk);
+
        /* check to see if everything is setup correctly */
 
        s3c_rtc_enable(pdev, 1);
@@ -568,6 +578,7 @@ static int s3c_rtc_probe(struct platform_device *pdev)
 
  err_nortc:
        s3c_rtc_enable(pdev, 0);
+       clk_disable_unprepare(rtc_src_clk);
        clk_disable_unprepare(rtc_clk);
 
        return ret;