[COMMON] watchdog: s3c2410_wdt: change clock source to rate & gate clock
authorHyunki Koo <hyunki00.koo@samsung.com>
Thu, 24 Oct 2013 08:55:45 +0000 (17:55 +0900)
committerJaehyoung Choi <jkkkkk.choi@samsung.com>
Wed, 9 May 2018 11:27:47 +0000 (20:27 +0900)
In 4.9 kernel porting,
Conflict:
 - s3c2410wdt_set_min_max_timeout function. -> remove function
 - Clock change within probe function. -> Changed to this patch.

Clock for watchdog device is changed to open gate clock.
but there is no clockrate information in gate_watchdog clock.
so rate_watchdog clock is added to get clock rate

Change-Id: I8394ac129bd478f5de6913e8c98f12cdebf0d87e
Signed-off-by: Hyunki Koo <hyunki00.koo@samsung.com>
Signed-off-by: Changki Kim <changki.kim@samsung.com>
Signed-off-by: Kang KyungWoo <kwoo.kang@samsung.com>
Signed-off-by: Choi Jaehyoung <jkkkkk.choi@samsung.com>
Signed-off-by: Kyungwoo Kang <kwoo.kang@samsung.com>
drivers/watchdog/s3c2410_wdt.c

index 1c1fe16bdbe635d72b0a193e16655e6f9074d2a1..f4dac67d005a65f209a98b924ad252570b38b61d 100644 (file)
@@ -119,7 +119,8 @@ struct s3c2410_wdt_variant {
 
 struct s3c2410_wdt {
        struct device           *dev;
-       struct clk              *clock;
+       struct clk              *rate_clock;
+       struct clk              *gate_clock;
        void __iomem            *reg_base;
        unsigned int            count;
        spinlock_t              lock;
@@ -354,7 +355,7 @@ static int s3c2410wdt_set_heartbeat(struct watchdog_device *wdd,
                                    unsigned int timeout)
 {
        struct s3c2410_wdt *wdt = watchdog_get_drvdata(wdd);
-       unsigned long freq = clk_get_rate(wdt->clock);
+       unsigned long freq = clk_get_rate(wdt->rate_clock);
        unsigned int count;
        unsigned int divisor = 1;
        unsigned long wtcon;
@@ -647,21 +648,30 @@ static int s3c2410wdt_probe(struct platform_device *pdev)
                goto err;
        }
 
-       wdt->clock = devm_clk_get(dev, "watchdog");
-       if (IS_ERR(wdt->clock)) {
-               dev_err(dev, "failed to find watchdog clock source\n");
-               ret = PTR_ERR(wdt->clock);
+       DBG("probe: mapped reg_base=%p\n", wdt->reg_base);
+
+       wdt->rate_clock = devm_clk_get(dev, "rate_watchdog");
+       if (IS_ERR(wdt->rate_clock)) {
+               dev_err(dev, "failed to find watchdog rate clock source\n");
+               ret = PTR_ERR(wdt->rate_clock);
                goto err;
        }
 
-       ret = clk_prepare_enable(wdt->clock);
+       wdt->gate_clock = devm_clk_get(dev, "gate_watchdog");
+       if (IS_ERR(wdt->gate_clock)) {
+               dev_err(dev, "failed to find watchdog gate clock source\n");
+               ret = PTR_ERR(wdt->gate_clock);
+               goto err;
+       }
+
+       ret = clk_prepare_enable(wdt->gate_clock);
        if (ret < 0) {
-               dev_err(dev, "failed to enable clock\n");
+               dev_err(dev, "failed to enable gate clock\n");
                return ret;
        }
 
        wdt->wdt_device.min_timeout = 1;
-       wdt->wdt_device.max_timeout = s3c2410wdt_max_timeout(wdt->clock);
+       wdt->wdt_device.max_timeout = s3c2410wdt_max_timeout(wdt->rate_clock);
 
        ret = s3c2410wdt_cpufreq_register(wdt);
        if (ret < 0) {
@@ -753,8 +763,9 @@ static int s3c2410wdt_probe(struct platform_device *pdev)
        s3c2410wdt_cpufreq_deregister(wdt);
 
  err_clk:
-       clk_disable_unprepare(wdt->clock);
-
+       clk_disable_unprepare(wdt->gate_clock);
+       wdt->rate_clock = NULL;
+       wdt->gate_clock = NULL;
  err:
        return ret;
 }
@@ -772,7 +783,9 @@ static int s3c2410wdt_remove(struct platform_device *dev)
 
        s3c2410wdt_cpufreq_deregister(wdt);
 
-       clk_disable_unprepare(wdt->clock);
+       clk_disable_unprepare(wdt->rate_clock);
+       wdt->rate_clock = NULL;
+       wdt->gate_clock = NULL;
 
        return 0;
 }