linux-sh.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] clocksource: sh_tmu: __clocksource_updatefreq_hz() update
@ 2011-04-25 13:38 Magnus Damm
  2011-04-28 20:55 ` [PATCH] clocksource: sh_tmu: __clocksource_updatefreq_hz() john stultz
  0 siblings, 1 reply; 3+ messages in thread
From: Magnus Damm @ 2011-04-25 13:38 UTC (permalink / raw)
  To: linux-kernel; +Cc: johnstul, Magnus Damm, lethal, linux-sh

From: Magnus Damm <damm@opensource.se>

This patch updates the clocksource part of the TMU driver
to make use of the __clocksource_updatefreq_hz() function.

Without this patch the old code uses clocksource_register()
together with a hack that assumes a never changing clock rate
(see clk_enable(), clk_get_rate() and clk_disable()).

The patch uses clocksource_register_hz() with 1 Hz as initial
value, then lets the ->enable() callback update the value
with __clocksource_updatefreq_hz() once the struct clk has
been enabled and the frequency is stable.

Signed-off-by: Magnus Damm <damm@opensource.se>
---

 Thanks to John Stultz for the framework changes and the
 initial implementation.

 Tested on the sh7372 Mackerel board with TMU00 and TMU01.

 drivers/clocksource/sh_tmu.c |   19 ++++++++-----------
 1 file changed, 8 insertions(+), 11 deletions(-)

--- 0001/drivers/clocksource/sh_tmu.c
+++ work/drivers/clocksource/sh_tmu.c	2011-04-25 15:07:41.000000000 +0900
@@ -199,8 +199,12 @@ static cycle_t sh_tmu_clocksource_read(s
 static int sh_tmu_clocksource_enable(struct clocksource *cs)
 {
 	struct sh_tmu_priv *p = cs_to_sh_tmu(cs);
+	int ret;
 
-	return sh_tmu_enable(p);
+	ret = sh_tmu_enable(p);
+	if (!ret)
+		__clocksource_updatefreq_hz(cs, p->rate);
+	return ret;
 }
 
 static void sh_tmu_clocksource_disable(struct clocksource *cs)
@@ -221,17 +225,10 @@ static int sh_tmu_register_clocksource(s
 	cs->mask = CLOCKSOURCE_MASK(32);
 	cs->flags = CLOCK_SOURCE_IS_CONTINUOUS;
 
-	/* clk_get_rate() needs an enabled clock */
-	clk_enable(p->clk);
-	/* channel will be configured at parent clock / 4 */
-	p->rate = clk_get_rate(p->clk) / 4;
-	clk_disable(p->clk);
-	/* TODO: calculate good shift from rate and counter bit width */
-	cs->shift = 10;
-	cs->mult = clocksource_hz2mult(p->rate, cs->shift);
-
 	dev_info(&p->pdev->dev, "used as clock source\n");
-	clocksource_register(cs);
+
+	/* Register with dummy 1 Hz value, gets updated in ->enable() */
+	clocksource_register_hz(cs, 1);
 	return 0;
 }
 

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] clocksource: sh_tmu: __clocksource_updatefreq_hz()
  2011-04-25 13:38 [PATCH] clocksource: sh_tmu: __clocksource_updatefreq_hz() update Magnus Damm
@ 2011-04-28 20:55 ` john stultz
  2011-05-23  5:38   ` [PATCH] clocksource: sh_tmu: __clocksource_updatefreq_hz() update Paul Mundt
  0 siblings, 1 reply; 3+ messages in thread
From: john stultz @ 2011-04-28 20:55 UTC (permalink / raw)
  To: Magnus Damm; +Cc: linux-kernel, lethal, linux-sh

On Mon, 2011-04-25 at 22:38 +0900, Magnus Damm wrote:
> From: Magnus Damm <damm@opensource.se>
> 
> This patch updates the clocksource part of the TMU driver
> to make use of the __clocksource_updatefreq_hz() function.
> 
> Without this patch the old code uses clocksource_register()
> together with a hack that assumes a never changing clock rate
> (see clk_enable(), clk_get_rate() and clk_disable()).
> 
> The patch uses clocksource_register_hz() with 1 Hz as initial
> value, then lets the ->enable() callback update the value
> with __clocksource_updatefreq_hz() once the struct clk has
> been enabled and the frequency is stable.
> 
> Signed-off-by: Magnus Damm <damm@opensource.se>

Acked-by: John Stultz <johnstul@us.ibm.com>

If these don't get picked up for 2.6.40, I'll queue them myself.

thanks
-john


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] clocksource: sh_tmu: __clocksource_updatefreq_hz() update
  2011-04-28 20:55 ` [PATCH] clocksource: sh_tmu: __clocksource_updatefreq_hz() john stultz
@ 2011-05-23  5:38   ` Paul Mundt
  0 siblings, 0 replies; 3+ messages in thread
From: Paul Mundt @ 2011-05-23  5:38 UTC (permalink / raw)
  To: john stultz; +Cc: Magnus Damm, linux-kernel, linux-sh

On Thu, Apr 28, 2011 at 01:55:43PM -0700, john stultz wrote:
> On Mon, 2011-04-25 at 22:38 +0900, Magnus Damm wrote:
> > From: Magnus Damm <damm@opensource.se>
> > 
> > This patch updates the clocksource part of the TMU driver
> > to make use of the __clocksource_updatefreq_hz() function.
> > 
> > Without this patch the old code uses clocksource_register()
> > together with a hack that assumes a never changing clock rate
> > (see clk_enable(), clk_get_rate() and clk_disable()).
> > 
> > The patch uses clocksource_register_hz() with 1 Hz as initial
> > value, then lets the ->enable() callback update the value
> > with __clocksource_updatefreq_hz() once the struct clk has
> > been enabled and the frequency is stable.
> > 
> > Signed-off-by: Magnus Damm <damm@opensource.se>
> 
> Acked-by: John Stultz <johnstul@us.ibm.com>
> 
> If these don't get picked up for 2.6.40, I'll queue them myself.
> 
I've queued them all now, with your Acks, thanks.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2011-05-23  5:38 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-04-25 13:38 [PATCH] clocksource: sh_tmu: __clocksource_updatefreq_hz() update Magnus Damm
2011-04-28 20:55 ` [PATCH] clocksource: sh_tmu: __clocksource_updatefreq_hz() john stultz
2011-05-23  5:38   ` [PATCH] clocksource: sh_tmu: __clocksource_updatefreq_hz() update Paul Mundt

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).