diff mbox

[PATCHv3,14/17] dmtimer pm_runtime support

Message ID 1285059347-26643-1-git-send-email-tarun.kanti@ti.com (mailing list archive)
State Superseded
Delegated to: Kevin Hilman
Headers show

Commit Message

Tarun Kanti DebBarma Sept. 21, 2010, 8:55 a.m. UTC
None
diff mbox

Patch

diff --git a/arch/arm/plat-omap/dmtimer.c b/arch/arm/plat-omap/dmtimer.c
index 360a751..9da527f 100644
--- a/arch/arm/plat-omap/dmtimer.c
+++ b/arch/arm/plat-omap/dmtimer.c
@@ -351,18 +351,28 @@  EXPORT_SYMBOL_GPL(omap_dm_timer_free);
 
 void omap_dm_timer_enable(struct omap_dm_timer *timer)
 {
+	struct dmtimer_platform_data *pdata = timer->pdev->dev.platform_data;
 	struct clk *timer_clk;
 
 	if (timer->enabled)
 		return;
 
-	timer_clk = clk_get(&timer->pdev->dev, "fck");
-	if (IS_ERR(timer_clk)) {
-		dev_err(&timer->pdev->dev,
-		"ERROR: no clk pointer to enable\n");
-		return;
-	} else
-		clk_enable(timer_clk);
+	if (unlikely(pdata->is_early_init)) {
+		timer_clk = clk_get(&timer->pdev->dev, "fck");
+		if (IS_ERR(timer_clk)) {
+			dev_err(&timer->pdev->dev,
+			"ERROR: no clk pointer to enable\n");
+			return;
+		} else
+			clk_enable(timer_clk);
+	} else {
+		if (pm_runtime_get_sync(&timer->pdev->dev)) {
+			dev_warn(&timer->pdev->dev,
+			"%s: pm_runtime_get_sync FAILED\n",
+			__func__);
+			return;
+		}
+	}
 
 	timer->enabled = 1;
 }
@@ -370,18 +380,28 @@  EXPORT_SYMBOL_GPL(omap_dm_timer_enable);
 
 void omap_dm_timer_disable(struct omap_dm_timer *timer)
 {
+	struct dmtimer_platform_data *pdata = timer->pdev->dev.platform_data;
 	struct clk *timer_clk;
 
 	if (!timer->enabled)
 		return;
 
-	timer_clk = clk_get(&timer->pdev->dev, "fck");
-	if (IS_ERR(timer_clk)) {
-		dev_err(&timer->pdev->dev,
-		"ERROR: no clk pointer to disable\n");
-		return;
-	} else
-		clk_disable(timer_clk);
+	if (unlikely(pdata->is_early_init)) {
+		timer_clk = clk_get(&timer->pdev->dev, "fck");
+		if (IS_ERR(timer_clk)) {
+			dev_err(&timer->pdev->dev,
+			"ERROR: no clk pointer to disable\n");
+			return;
+		} else
+			clk_disable(timer_clk);
+	} else {
+		if (pm_runtime_put_sync(&timer->pdev->dev)) {
+			dev_warn(&timer->pdev->dev,
+			"%s: pm_runtime_put_sync FAILED\n",
+			__func__);
+			return;
+		}
+	}
 
 	timer->enabled = 0;
 }
@@ -503,13 +523,20 @@  int omap_dm_timer_set_source(struct omap_dm_timer *timer, int source)
 	if (source < 0 || source >= NR_CLK_SOURCES)
 		return -EINVAL;
 
-	timer_clk = clk_get(&timer->pdev->dev, "fck");
-	if (IS_ERR(timer_clk)) {
-		dev_err(&timer->pdev->dev,
-		"ERROR: no clk pointer to disable\n");
-		return -EINVAL;
-	} else
-		clk_disable(timer_clk); /* enabled in hwmod */
+	if (unlikely(pdata->is_early_init)) {
+		timer_clk = clk_get(&timer->pdev->dev, "fck");
+		if (IS_ERR(timer_clk)) {
+			dev_err(&timer->pdev->dev,
+			"ERROR: no clk pointer to disable\n");
+			return -EINVAL;
+		} else
+			clk_disable(timer_clk); /* enabled in hwmod */
+	} else {
+		if (pm_runtime_put_sync(&timer->pdev->dev))
+			dev_warn(&timer->pdev->dev,
+			"%s: pm_runtime_put_sync FAILED\n",
+			__func__);
+	}
 
 	/*
 	 * change the timer clock source and