public inbox for linux-omap@vger.kernel.org
 help / color / mirror / Atom feed
From: Santosh <santosh.shilimkar@ti.com>
To: Tarun Kanti DebBarma <tarun.kanti@ti.com>
Cc: linux-omap@vger.kernel.org, khilman@ti.com, tony@atomide.com,
	linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH v14 REPOST 12/12] OMAP: dmtimer: Off mode support
Date: Fri, 26 Aug 2011 21:34:33 +0530	[thread overview]
Message-ID: <4E57C411.3050906@ti.com> (raw)
In-Reply-To: <1310731501-13078-13-git-send-email-tarun.kanti@ti.com>

On Friday 15 July 2011 05:35 PM, Tarun Kanti DebBarma wrote:
> Clock is enabled only when timer is started and disabled when the the timer
> is stopped. Therefore before accessing registers in functions clock is enabled
> and then disabled back at the end of access.
> Context save and restore functions are called as needed based upon whether the
> context is lost or not.
>
> Signed-off-by: Tarun Kanti DebBarma<tarun.kanti@ti.com>
> ---
>   arch/arm/mach-omap2/timer.c               |   17 +++++
>   arch/arm/plat-omap/dmtimer.c              |   97 +++++++++++++++++++++++++++--
>   arch/arm/plat-omap/include/plat/dmtimer.h |    9 +++
>   3 files changed, 118 insertions(+), 5 deletions(-)
>
> diff --git a/arch/arm/mach-omap2/timer.c b/arch/arm/mach-omap2/timer.c
> index 9d47300..d1c6219 100644
> --- a/arch/arm/mach-omap2/timer.c
> +++ b/arch/arm/mach-omap2/timer.c
> @@ -44,6 +44,9 @@
>   #include<plat/common.h>
>   #include<plat/omap_hwmod.h>
>   #include<plat/omap_device.h>
> +#include<plat/omap-pm.h>
> +
> +#include "powerdomain.h"
>
>   /* Parent clocks, eventually these will come from the clock framework */
>
> @@ -409,6 +412,16 @@ static int omap2_dm_timer_set_src(struct platform_device *pdev, int source)
>   	return ret;
>   }
>
> +#ifdef CONFIG_PM
> +static int omap_timer_get_context_loss(struct device *dev)
> +{
> +	return omap_pm_get_dev_context_loss_count(dev);
> +}
> +
> +#else
> +#define omap_gpio_get_context_loss NULL
> +#endif
> +
>   struct omap_device_pm_latency omap2_dmtimer_latency[] = {
>   	{
>   		.deactivate_func = omap_device_idle_hwmods,
> @@ -437,6 +450,7 @@ static int __init omap_timer_init(struct omap_hwmod *oh, void *unused)
>   	struct dmtimer_platform_data *pdata;
>   	struct omap_device *od;
>   	struct omap_timer_capability_dev_attr *timer_dev_attr;
> +	struct powerdomain *pwrdm;
>
>   	pr_debug("%s: %s\n", __func__, oh->name);
>
> @@ -466,6 +480,9 @@ static int __init omap_timer_init(struct omap_hwmod *oh, void *unused)
>
>   	pdata->set_timer_src = omap2_dm_timer_set_src;
>   	pdata->timer_ip_type = oh->class->rev;
> +	pwrdm = omap_hwmod_get_pwrdm(oh);
> +	pdata->loses_context = pwrdm_can_ever_lose_context(pwrdm);
> +	pdata->get_context_loss_count = omap_timer_get_context_loss;
>
>   	od = omap_device_build(name, id, oh, pdata, sizeof(*pdata),
>   			omap2_dmtimer_latency,
> diff --git a/arch/arm/plat-omap/dmtimer.c b/arch/arm/plat-omap/dmtimer.c
> index cdef48b..db14d7f 100644
> --- a/arch/arm/plat-omap/dmtimer.c
> +++ b/arch/arm/plat-omap/dmtimer.c
> @@ -151,12 +151,14 @@ static void omap_dm_timer_wait_for_reset(struct omap_dm_timer *timer)
>
>   static void omap_dm_timer_reset(struct omap_dm_timer *timer)
>   {
> +	omap_dm_timer_enable(timer);
>   	if (timer->pdev->id != 1) {
>   		omap_dm_timer_write_reg(timer, OMAP_TIMER_IF_CTRL_REG, 0x06);
>   		omap_dm_timer_wait_for_reset(timer);
>   	}
>
>   	__omap_dm_timer_reset(timer->io_base, 0, 0, timer->func_offset);
> +	omap_dm_timer_disable(timer);
>   	timer->posted = 1;
>   }
>
> @@ -171,14 +173,13 @@ void omap_dm_timer_prepare(struct omap_dm_timer *timer)
>   		return;
>   	}
>
> -	omap_dm_timer_enable(timer);
> -
>   	if (pdata->needs_manual_reset)
>   		omap_dm_timer_reset(timer);
>
>   	omap_dm_timer_set_source(timer, OMAP_TIMER_SRC_32_KHZ);
>
>   	timer->posted = 1;
> +	timer->context_changed = true;
You should protect these variables from races.

>   }
>
>   struct omap_dm_timer *omap_dm_timer_request(void)
> @@ -230,7 +231,6 @@ EXPORT_SYMBOL_GPL(omap_dm_timer_request_specific);
>
>   void omap_dm_timer_free(struct omap_dm_timer *timer)
>   {
> -	omap_dm_timer_disable(timer);
>   	clk_put(timer->fclk);
>
>   	WARN_ON(!timer->reserved);
> @@ -311,6 +311,11 @@ EXPORT_SYMBOL_GPL(omap_dm_timer_modify_idlect_mask);
>
>   void omap_dm_timer_trigger(struct omap_dm_timer *timer)
>   {
> +	if (unlikely(!timer->reserved)) {
> +		pr_err("%s: timer%d not enabled.\n", __func__, timer->id);
> +		return;
> +	}
> +
>   	omap_dm_timer_write_reg(timer, OMAP_TIMER_TRIGGER_REG, 0);
>   }
>   EXPORT_SYMBOL_GPL(omap_dm_timer_trigger);
> @@ -319,6 +324,20 @@ void omap_dm_timer_start(struct omap_dm_timer *timer)
>   {
>   	u32 l;
>
> +	omap_dm_timer_enable(timer);
> +
> +	if (timer->loses_context) {
> +		u32 ctx_loss_cnt_after;
> +
> +		ctx_loss_cnt_after =
> +			timer->get_context_loss_count(&timer->pdev->dev);
> +		if ((ctx_loss_cnt_after != timer->ctx_loss_count)&&
> +					timer->context_saved) {
> +			omap_timer_restore_context(timer);
> +			timer->context_saved = false;
Ditto. It applies to rest of the patch.

Rest look ok.

Regards
Santosh


      reply	other threads:[~2011-08-26 16:04 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-07-15 12:04 [PATCH v14 REPOST 00/12] dmtimer adaptation to platform_driver Tarun Kanti DebBarma
2011-07-15 12:04 ` [PATCH v14 REPOST 01/12] OMAP2+: dmtimer: add device names to flck nodes Tarun Kanti DebBarma
2011-08-26 14:15   ` Santosh
2011-07-15 12:04 ` [PATCH v14 REPOST 02/12] OMAP4: hwmod data: add dmtimer version information Tarun Kanti DebBarma
2011-08-26 15:21   ` Santosh
2011-07-15 12:04 ` [PATCH v14 REPOST 03/12] OMAP1: dmtimer: conversion to platform devices Tarun Kanti DebBarma
2011-08-26 14:26   ` Santosh
2011-07-15 12:04 ` [PATCH v14 REPOST 04/12] OMAP2+: dmtimer: convert " Tarun Kanti DebBarma
2011-08-26 14:33   ` Santosh
2011-07-15 12:04 ` [PATCH v14 REPOST 05/12] OMAP: dmtimer: platform driver Tarun Kanti DebBarma
2011-08-26 14:34   ` Santosh
2011-07-15 12:04 ` [PATCH v14 REPOST 06/12] OMAP: dmtimer: switch-over to platform device driver Tarun Kanti DebBarma
2011-08-26 15:20   ` Santosh
2011-07-15 12:04 ` [PATCH v14 REPOST 07/12] OMAP: dmtimer: pm_runtime support Tarun Kanti DebBarma
2011-08-26 15:27   ` Santosh
2011-08-26 16:23     ` Kevin Hilman
2011-08-26 16:34       ` Santosh
2011-07-15 12:04 ` [PATCH v14 REPOST 08/12] OMAP: dmtimer: add timeout to low-level routines Tarun Kanti DebBarma
2011-08-26 15:30   ` Santosh
2011-07-15 12:04 ` [PATCH v14 REPOST 09/12] OMAP: dmtimer: use mutex instead of spinlock Tarun Kanti DebBarma
2011-08-26 15:34   ` Santosh
2011-08-26 16:09     ` Santosh
2011-07-15 12:04 ` [PATCH v14 REPOST 10/12] OMAP: dmtimer: mark clocksource and clockevent timers reserved Tarun Kanti DebBarma
2011-08-26 15:44   ` Santosh
2011-07-15 12:05 ` [PATCH v14 REPOST 11/12] OMAP: dmtimer: add context save/restore routines Tarun Kanti DebBarma
2011-08-26 15:46   ` Santosh
2011-07-15 12:05 ` [PATCH v14 REPOST 12/12] OMAP: dmtimer: Off mode support Tarun Kanti DebBarma
2011-08-26 16:04   ` Santosh [this message]

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=4E57C411.3050906@ti.com \
    --to=santosh.shilimkar@ti.com \
    --cc=khilman@ti.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-omap@vger.kernel.org \
    --cc=tarun.kanti@ti.com \
    --cc=tony@atomide.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox