[COMMON] rtc: samsung: Add disabling clock control with AP rtc
authorKang KyungWoo <kwoo.kang@samsung.com>
Mon, 13 Jun 2016 12:07:13 +0000 (21:07 +0900)
committerJaehyoung Choi <jkkkkk.choi@samsung.com>
Wed, 9 May 2018 11:27:50 +0000 (20:27 +0900)
This patch is for disabling clock control for AP RTC.
At exynos8 series, we no longer need to control ap rtc clock due to
clock source has been changed.

Change-Id: I00806873df732937eb41f4db68d5ccf3fcde6a4d
Signed-off-by: Kang KyungWoo <kwoo.kang@samsung.com>
drivers/rtc/rtc-s3c.c

index c111e2c2b059fdcd322faf4d30e034ed9f332e12..4e10ae3a9a9c8cf95132cb567ed6adb47108a72f 100644 (file)
@@ -57,6 +57,7 @@ struct s3c_rtc {
 struct s3c_rtc_data {
        int max_user_freq;
        bool needs_src_clk;
+       bool clock_ctrl_disable;
 
        void (*irq_handler) (struct s3c_rtc *info, int mask);
        void (*set_freq) (struct s3c_rtc *info, int freq);
@@ -73,6 +74,9 @@ static int s3c_rtc_enable_clk(struct s3c_rtc *info)
        unsigned long irq_flags;
        int ret = 0;
 
+       if (info->data->clock_ctrl_disable)
+               return;
+
        spin_lock_irqsave(&info->alarm_clk_lock, irq_flags);
 
        if (info->clk_disabled) {
@@ -100,6 +104,9 @@ static void s3c_rtc_disable_clk(struct s3c_rtc *info)
 {
        unsigned long irq_flags;
 
+       if (info->data->clock_ctrl_disable)
+               return;
+
        spin_lock_irqsave(&info->alarm_clk_lock, irq_flags);
        if (!info->clk_disabled) {
                if (info->data->needs_src_clk)
@@ -467,6 +474,9 @@ static int s3c_rtc_remove(struct platform_device *pdev)
 
        s3c_rtc_setaie(info->dev, 0);
 
+       if (info->data->clock_ctrl_disable)
+               return 0;
+
        if (info->data->needs_src_clk)
                clk_unprepare(info->rtc_src_clk);
        clk_unprepare(info->rtc_clk);
@@ -528,36 +538,25 @@ static int s3c_rtc_probe(struct platform_device *pdev)
        if (IS_ERR(info->base))
                return PTR_ERR(info->base);
 
-       info->rtc_clk = devm_clk_get(&pdev->dev, "rtc");
-       if (IS_ERR(info->rtc_clk)) {
-               ret = PTR_ERR(info->rtc_clk);
-               if (ret != -EPROBE_DEFER)
+       if (!info->data->clock_ctrl_disable) {
+               info->rtc_clk = devm_clk_get(&pdev->dev, "rtc");
+               if (IS_ERR(info->rtc_clk)) {
                        dev_err(&pdev->dev, "failed to find rtc clock\n");
-               else
-                       dev_dbg(&pdev->dev, "probe deferred due to missing rtc clk\n");
-               return ret;
-       }
-       ret = clk_prepare_enable(info->rtc_clk);
-       if (ret)
-               return ret;
+                       return PTR_ERR(info->rtc_clk);
+               }
+               clk_prepare_enable(info->rtc_clk);
 
-       if (info->data->needs_src_clk) {
-               info->rtc_src_clk = devm_clk_get(&pdev->dev, "rtc_src");
-               if (IS_ERR(info->rtc_src_clk)) {
-                       ret = PTR_ERR(info->rtc_src_clk);
-                       if (ret != -EPROBE_DEFER)
+               if (info->data->needs_src_clk) {
+                       info->rtc_src_clk = devm_clk_get(&pdev->dev, "rtc_src");
+                       if (IS_ERR(info->rtc_src_clk)) {
                                dev_err(&pdev->dev,
                                        "failed to find rtc source clock\n");
-                       else
-                               dev_dbg(&pdev->dev,
-                                       "probe deferred due to missing rtc src clk\n");
-                       goto err_src_clk;
+                               clk_disable_unprepare(info->rtc_clk);
+                               return PTR_ERR(info->rtc_src_clk);
+                       }
+                       clk_prepare_enable(info->rtc_src_clk);
                }
-               ret = clk_prepare_enable(info->rtc_src_clk);
-               if (ret)
-                       goto err_src_clk;
        }
-
        /* check to see if everything is setup correctly */
        if (info->data->enable)
                info->data->enable(info);
@@ -615,6 +614,9 @@ err_nortc:
        if (info->data->disable)
                info->data->disable(info);
 
+       if (info->data->clock_ctrl_disable)
+               return ret;
+
        if (info->data->needs_src_clk)
                clk_disable_unprepare(info->rtc_src_clk);
 err_src_clk:
@@ -843,6 +845,18 @@ static struct s3c_rtc_data const s3c6410_rtc_data = {
        .disable                = s3c6410_rtc_disable,
 };
 
+static struct s3c_rtc_data const exynos8_rtc_data = {
+       .max_user_freq          = 32768,
+       .clock_ctrl_disable     = true,
+       .irq_handler            = s3c6410_rtc_irq,
+       .set_freq               = s3c6410_rtc_setfreq,
+       .enable_tick            = s3c6410_rtc_enable_tick,
+       .save_tick_cnt          = s3c6410_rtc_save_tick_cnt,
+       .restore_tick_cnt       = s3c6410_rtc_restore_tick_cnt,
+       .enable                 = s3c24xx_rtc_enable,
+       .disable                = s3c6410_rtc_disable,
+};
+
 static const struct of_device_id s3c_rtc_dt_match[] = {
        {
                .compatible = "samsung,s3c2410-rtc",
@@ -859,7 +873,11 @@ static const struct of_device_id s3c_rtc_dt_match[] = {
        }, {
                .compatible = "samsung,exynos3250-rtc",
                .data = &s3c6410_rtc_data,
+       }, {
+               .compatible = "samsung,exynos8-rtc",
+               .data = (void *)&exynos8_rtc_data,
        },
+
        { /* sentinel */ },
 };
 MODULE_DEVICE_TABLE(of, s3c_rtc_dt_match);