@@ -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