From patchwork Wed Feb 16 13:00:19 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tarun Kanti DebBarma X-Patchwork-Id: 567241 X-Patchwork-Delegate: tony@atomide.com Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id p1GCvs4m027592 for ; Wed, 16 Feb 2011 12:57:59 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754156Ab1BPM54 (ORCPT ); Wed, 16 Feb 2011 07:57:56 -0500 Received: from comal.ext.ti.com ([198.47.26.152]:32920 "EHLO comal.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753955Ab1BPM5y (ORCPT ); Wed, 16 Feb 2011 07:57:54 -0500 Received: from dbdp31.itg.ti.com ([172.24.170.98]) by comal.ext.ti.com (8.13.7/8.13.7) with ESMTP id p1GCvowm023887 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Wed, 16 Feb 2011 06:57:53 -0600 Received: from localhost.localdomain (localhost [127.0.0.1]) by dbdp31.itg.ti.com (8.13.8/8.13.8) with ESMTP id p1GCvk1s014270; Wed, 16 Feb 2011 18:27:49 +0530 (IST) From: Tarun Kanti DebBarma To: linux-omap@vger.kernel.org Cc: khilman@ti.com, Tarun Kanti DebBarma , Partha Basak Subject: [PATCH v10 10/11] OMAP: dmtimer: pm_runtime support Date: Wed, 16 Feb 2011 18:30:19 +0530 Message-Id: <1297861220-831-11-git-send-email-tarun.kanti@ti.com> X-Mailer: git-send-email 1.6.0.4 In-Reply-To: <1297861220-831-1-git-send-email-tarun.kanti@ti.com> References: <1297861220-831-1-git-send-email-tarun.kanti@ti.com> Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter1.kernel.org [140.211.167.41]); Wed, 16 Feb 2011 12:57:59 +0000 (UTC) diff --git a/arch/arm/plat-omap/dmtimer.c b/arch/arm/plat-omap/dmtimer.c index 53f5205..fcac422 100644 --- a/arch/arm/plat-omap/dmtimer.c +++ b/arch/arm/plat-omap/dmtimer.c @@ -39,6 +39,7 @@ #include #include #include +#include #include #include #include @@ -211,13 +212,16 @@ static void omap_dm_timer_prepare(struct omap_dm_timer *timer) { struct dmtimer_platform_data *pdata = timer->pdev->dev.platform_data; - timer->fclk = clk_get(&timer->pdev->dev, "fck"); - if (WARN_ON_ONCE(IS_ERR_OR_NULL(timer->fclk))) { - dev_err(&timer->pdev->dev, ": No fclk handle.\n"); - return; + if (!pdata->is_omap16xx) { + timer->fclk = clk_get(&timer->pdev->dev, "fck"); + if (WARN_ON_ONCE(IS_ERR_OR_NULL(timer->fclk))) { + dev_err(&timer->pdev->dev, ": No fclk handle.\n"); + return; + } } - omap_dm_timer_enable(timer); + if (!pdata->is_omap16xx) + omap_dm_timer_enable(timer); if (pdata->dm_timer_reset) pdata->dm_timer_reset(timer); @@ -292,10 +296,22 @@ 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; + if (timer->enabled) return; - clk_enable(timer->fclk); + if (unlikely(pdata->is_early_init)) { + clk_enable(timer->fclk); + timer->enabled = 1; + return; + } + + if (pm_runtime_get_sync(&timer->pdev->dev) < 0) { + dev_err(&timer->pdev->dev, "%s: pm_runtime_get_sync() FAILED\n", + __func__); + return; + } timer->enabled = 1; } @@ -303,10 +319,22 @@ 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; + if (!timer->enabled) return; - clk_disable(timer->fclk); + if (unlikely(pdata->is_early_init)) { + clk_disable(timer->fclk); + timer->enabled = 0; + return; + } + + if (pm_runtime_put_sync(&timer->pdev->dev) < 0) { + dev_err(&timer->pdev->dev, "%s: pm_runtime_put_sync() FAILED\n", + __func__); + return; + } timer->enabled = 0; } @@ -425,10 +453,12 @@ int omap_dm_timer_set_source(struct omap_dm_timer *timer, int source) if (source < 0 || source >= 3) return -EINVAL; - omap_dm_timer_disable(timer); + if (!pdata->is_omap16xx) + omap_dm_timer_disable(timer); /* change the timer clock source */ ret = pdata->set_timer_src(timer->pdev, source); - omap_dm_timer_enable(timer); + if (!pdata->is_omap16xx) + omap_dm_timer_enable(timer); /* * When the functional clock disappears, too quick writes seem @@ -600,11 +630,26 @@ static int __devinit omap_dm_timer_probe(struct platform_device *pdev) return -ENODEV; } + /* + * OMAP2+ + * Early timers are already registered and in list. + * What we need to do during second phase of probe + * is to assign the newly allocated/configured pdev + * to timer->pdev. We also call pm_runtime_enable() + * for each device because it could not be called + * during early boot because pm_runtime framework + * was not yet up and running. + */ spin_lock_irqsave(&dm_timer_lock, flags); list_for_each_entry(timer, &omap_timer_list, node) if (!pdata->is_early_init && timer->id == pdev->id) { timer->pdev = pdev; spin_unlock_irqrestore(&dm_timer_lock, flags); + pm_runtime_enable(&pdev->dev); + /* update PM runtime for active early timers */ + if (timer->reserved) + pm_runtime_get_sync(&pdev->dev); + dev_dbg(&pdev->dev, "Regular Probed\n"); return 0; }