All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] arm: Configure reference clock for Versatile Express timers
@ 2011-01-18 16:39 Pawel Moll
  2011-01-18 17:44 ` Russell King - ARM Linux
  0 siblings, 1 reply; 5+ messages in thread
From: Pawel Moll @ 2011-01-18 16:39 UTC (permalink / raw)
  To: linux-arm-kernel

Timers on Versatile Express mainboard are used as system clock/event
sources. Driver assumes that they are clocked with 1MHz signal.
Old V2M firmware apparently configured it by default, but on newer
boards one can observe that "sleep 1" command takes over 30 seconds
to finish, as the timers are fed with 32kHz instead...

This patch performs required magic and also removes code clearing
timer's control registers, as exactly the same operations are
performed by the timer driver few jiffies later.

Signed-off-by: Pawel Moll <pawel.moll@arm.com>
Tested-by: Will Deacon <will.deacon@arm.com>
---
 arch/arm/mach-vexpress/v2m.c |   10 ++++++++--
 1 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/arch/arm/mach-vexpress/v2m.c b/arch/arm/mach-vexpress/v2m.c
index a9ed342..6edace3 100644
--- a/arch/arm/mach-vexpress/v2m.c
+++ b/arch/arm/mach-vexpress/v2m.c
@@ -19,6 +19,7 @@
 #include <asm/mach/time.h>
 #include <asm/hardware/arm_timer.h>
 #include <asm/hardware/timer-sp.h>
+#include <asm/hardware/sp810.h>
 
 #include <mach/motherboard.h>
 
@@ -50,10 +51,15 @@ void __init v2m_map_io(struct map_desc *tile, size_t num)
 
 static void __init v2m_timer_init(void)
 {
+	u32 scctrl;
+
 	versatile_sched_clock_init(MMIO_P2V(V2M_SYS_24MHZ), 24000000);
 
-	writel(0, MMIO_P2V(V2M_TIMER0) + TIMER_CTRL);
-	writel(0, MMIO_P2V(V2M_TIMER1) + TIMER_CTRL);
+	/* Select 1MHz TIMCLK as the reference clock for SP804 timers */
+	scctrl = readl(MMIO_P2V(V2M_SYSCTL + SCCTRL));
+	scctrl |= (1 << 15);    /* TIMCLK is used for timer 0 */
+	scctrl |= (1 << 17);    /* TIMCLK is used for timer 1 */
+	writel(scctrl, MMIO_P2V(V2M_SYSCTL + SCCTRL));
 
 	sp804_clocksource_init(MMIO_P2V(V2M_TIMER1));
 	sp804_clockevents_init(MMIO_P2V(V2M_TIMER0), IRQ_V2M_TIMER0);
-- 
1.6.3.3

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

* [PATCH] arm: Configure reference clock for Versatile Express timers
  2011-01-18 16:39 [PATCH] arm: Configure reference clock for Versatile Express timers Pawel Moll
@ 2011-01-18 17:44 ` Russell King - ARM Linux
  2011-01-18 18:02   ` Pawel Moll
  0 siblings, 1 reply; 5+ messages in thread
From: Russell King - ARM Linux @ 2011-01-18 17:44 UTC (permalink / raw)
  To: linux-arm-kernel

On Tue, Jan 18, 2011 at 04:39:33PM +0000, Pawel Moll wrote:
> Timers on Versatile Express mainboard are used as system clock/event
> sources. Driver assumes that they are clocked with 1MHz signal.
> Old V2M firmware apparently configured it by default, but on newer
> boards one can observe that "sleep 1" command takes over 30 seconds
> to finish, as the timers are fed with 32kHz instead...
> 
> This patch performs required magic and also removes code clearing
> timer's control registers, as exactly the same operations are
> performed by the timer driver few jiffies later.

It would be nice if these registers were documented...

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

* [PATCH] arm: Configure reference clock for Versatile Express timers
  2011-01-18 17:44 ` Russell King - ARM Linux
@ 2011-01-18 18:02   ` Pawel Moll
  2011-01-18 18:18     ` Russell King - ARM Linux
  0 siblings, 1 reply; 5+ messages in thread
From: Pawel Moll @ 2011-01-18 18:02 UTC (permalink / raw)
  To: linux-arm-kernel

> This patch performs required magic and also removes code clearing
> > timer's control registers, as exactly the same operations are
> > performed by the timer driver few jiffies later.
> It would be nice if these registers were documented...

The best I can do is to create some more meaningful constants.

V2 to follow...

Pawe?

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

* [PATCH] arm: Configure reference clock for Versatile Express timers
  2011-01-18 18:02   ` Pawel Moll
@ 2011-01-18 18:18     ` Russell King - ARM Linux
  2011-01-18 18:28       ` Pawel Moll
  0 siblings, 1 reply; 5+ messages in thread
From: Russell King - ARM Linux @ 2011-01-18 18:18 UTC (permalink / raw)
  To: linux-arm-kernel

On Tue, Jan 18, 2011 at 06:02:56PM -0000, Pawel Moll wrote:
> > This patch performs required magic and also removes code clearing
> > > timer's control registers, as exactly the same operations are
> > > performed by the timer driver few jiffies later.
> > It would be nice if these registers were documented...
> 
> The best I can do is to create some more meaningful constants.

I was actually referring to the manuals - last time I looked these
register bits are not documented in the user guide for the system.
DUI0447A, 4.4.9: "You can, however, use the System Controller to change
the timer reference from 32.768kHz to 1MHz."

The only other reference to "System Controller" is at the beginning of
the document in the preface: "ARM PrimeCell System Controller (SP810)
Technical Reference Manual (ARM DDI 0254)".

Section 4.4.1 refers to the memory map, which tells me that the System
Control ARM SP810 is at CS7 + 0x1000.

Section 4.2 is titled "System control registers" but actually describes
the "System registers" described in table 4-1.  4.3 describes those
system registers.  4.4 describes the other peripherals.

DDI0254 is not published, so there's nothing on the register layout.

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

* [PATCH] arm: Configure reference clock for Versatile Express timers
  2011-01-18 18:18     ` Russell King - ARM Linux
@ 2011-01-18 18:28       ` Pawel Moll
  0 siblings, 0 replies; 5+ messages in thread
From: Pawel Moll @ 2011-01-18 18:28 UTC (permalink / raw)
  To: linux-arm-kernel

> The only other reference to "System Controller" is at the beginning
> of the document in the preface: "ARM PrimeCell System Controller
> (SP810) Technical Reference Manual (ARM DDI 0254)".
> 
> DDI0254 is not published, so there's nothing on the register
> layout.

It's exactly the DDI0254 that contains the information, but - as you have pointed out - it's marked as obsolete and not available any more. Don't really know the reason... 

I spent quite a lot of time investigating the problem and it appears that this cell is of little use these days - the only useful function is the timers reference clock muxer. I didn't even know that there the header file with its register offsets exist at all :-) before Will pointed this out...

So - as I said - the named constants are the best I can do.

Cheers!

Pawe?

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

end of thread, other threads:[~2011-01-18 18:28 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-01-18 16:39 [PATCH] arm: Configure reference clock for Versatile Express timers Pawel Moll
2011-01-18 17:44 ` Russell King - ARM Linux
2011-01-18 18:02   ` Pawel Moll
2011-01-18 18:18     ` Russell King - ARM Linux
2011-01-18 18:28       ` Pawel Moll

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.