All of lore.kernel.org
 help / color / mirror / Atom feed
From: Kevin Hilman <khilman@ti.com>
To: Tarun Kanti DebBarma <tarun.kanti@ti.com>
Cc: linux-omap@vger.kernel.org, Partha Basak <p-basak2@ti.com>
Subject: Re: [PATCH v9 10/11] OMAP: dmtimer: pm_runtime support
Date: Tue, 15 Feb 2011 09:14:40 -0800	[thread overview]
Message-ID: <8762slte2n.fsf@ti.com> (raw)
In-Reply-To: <1297423040-19917-11-git-send-email-tarun.kanti@ti.com> (Tarun Kanti DebBarma's message of "Fri, 11 Feb 2011 16:47:19 +0530")

Tarun Kanti DebBarma <tarun.kanti@ti.com> writes:

> Add pm_runtime support to dmtimer. Since dmtimer is used during
> early boot before pm_runtime is initialized completely there are
> provisions to enable/disable clocks directly in the code during
> early boot.
>
> Signed-off-by: Tarun Kanti DebBarma <tarun.kanti@ti.com>
> [p-basak2@ti.com: added pm_runtime logic in probe()]
> Signed-off-by: Partha Basak <p-basak2@ti.com>
> Reviewed-by: Varadarajan, Charulatha <charu@ti.com>
> Acked-by: Cousson, Benoit <b-cousson@ti.com>
> ---
>  arch/arm/plat-omap/dmtimer.c |   60 +++++++++++++++++++++++++++++++++++------
>  1 files changed, 51 insertions(+), 9 deletions(-)
>
> diff --git a/arch/arm/plat-omap/dmtimer.c b/arch/arm/plat-omap/dmtimer.c
> index ed4aada..4de473b 100644
> --- a/arch/arm/plat-omap/dmtimer.c
> +++ b/arch/arm/plat-omap/dmtimer.c
> @@ -39,6 +39,7 @@
>  #include <linux/delay.h>
>  #include <linux/io.h>
>  #include <linux/slab.h>
> +#include <linux/pm_runtime.h>
>  #include <linux/err.h>
>  #include <linux/platform_device.h>
>  #include <plat/dmtimer.h>
> @@ -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);
> @@ -289,10 +293,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;
>  }
> @@ -300,10 +316,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;
>  }
> @@ -422,10 +450,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
> @@ -597,11 +627,21 @@ static int __devinit omap_dm_timer_probe(struct platform_device *pdev)
>  		return -ENODEV;
>  	}
>  
> +	/* OMAP2+

please fix multi-line comment style

> +	 * 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);
>  			dev_dbg(&pdev->dev, "Regular Probed\n");
>  			return 0;
>  		}

> @@ -652,6 +692,8 @@ static int __devinit omap_dm_timer_probe(struct platform_device *pdev)
>  		pdata->dm_timer_read_reg = omap_dm_timer_read_reg;
>  		pdata->dm_timer_write_reg = omap_dm_timer_write_reg;
>  		pdata->is_early_init = 0;
> +		pm_runtime_enable(&pdev->dev);
> +		dev_dbg(&pdev->dev, " pm_runtime enabled\n");
>  	}
>  
>  	timer->id = pdev->id;

Somehow, you need to also update runtime PM for early timers that were
enabled.  For the PM runtime userspace info to be correct, I think you
also need to do a 'get' here if the timer has also been enabled.

Otherwise, upon boot, checking runtime PM sysfs it looks like no timers
are active, or ever have been active:


/ # cat /sys/devices/platform/omap/omap_timer.*/power/runtime_status            
suspended                                                                       
suspended                                                                       
suspended                                                                       
suspended                                                                       
suspended                                                                       
suspended                                                                       
suspended                                                                       
suspended                                                                       
suspended                                                                       
suspended                                                                       
suspended                                                                       
suspended                                                                       
/ # cat /sys/devices/platform/omap/omap_timer.*/power/runtime_active_time       
0                                                                               
0                                                                               
0                                                                               
0                                                                               
0                                                                               
0                                                                               
0                                                                               
0                                                                               
0                                                                               
0                                                                               
0                                                                               
0                                                                               
/ # 

Kevin

  reply	other threads:[~2011-02-15 17:14 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-02-11 11:17 [PATCH v9 00/11] dmtimer adaptation to platform_driver Tarun Kanti DebBarma
2011-02-11 11:17 ` [PATCH v9 01/11] OMAP2+: dmtimer: add device names to flck nodes Tarun Kanti DebBarma
2011-02-11 11:17 ` [PATCH v9 02/11] OMAP2420: hwmod data: add dmtimer Tarun Kanti DebBarma
2011-02-11 11:17 ` [PATCH v9 03/11] OMAP2430: " Tarun Kanti DebBarma
2011-02-11 11:17 ` [PATCH v9 04/11] OMAP3: " Tarun Kanti DebBarma
2011-02-11 11:17 ` [PATCH v9 05/11] OMAP4: " Tarun Kanti DebBarma
2011-02-14 16:26   ` Cousson, Benoit
2011-02-11 11:17 ` [PATCH v9 06/11] OMAP1: dmtimer: conversion to platform devices Tarun Kanti DebBarma
2011-02-11 11:17 ` [PATCH v9 07/11] OMAP2+: dmtimer: convert " Tarun Kanti DebBarma
2011-02-11 11:17 ` [PATCH v9 08/11] OMAP: dmtimer: platform driver Tarun Kanti DebBarma
2011-02-11 11:17 ` [PATCH v9 09/11] OMAP: dmtimer: switch-over to platform device driver Tarun Kanti DebBarma
2011-02-11 11:17 ` [PATCH v9 10/11] OMAP: dmtimer: pm_runtime support Tarun Kanti DebBarma
2011-02-15 17:14   ` Kevin Hilman [this message]
2011-02-16 10:24     ` DebBarma, Tarun Kanti
2011-02-11 11:17 ` [PATCH v9 11/11] OMAP: dmtimer: add timeout to low-level routines Tarun Kanti DebBarma

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=8762slte2n.fsf@ti.com \
    --to=khilman@ti.com \
    --cc=linux-omap@vger.kernel.org \
    --cc=p-basak2@ti.com \
    --cc=tarun.kanti@ti.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.