aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/mach-netx
diff options
context:
space:
mode:
authorSascha Hauer <sascha@saschahauer.de>2006-12-12 03:23:45 -0500
committerRussell King <rmk+kernel@arm.linux.org.uk>2006-12-13 09:37:27 -0500
commit1a815aed1e03c73fcd0390109c7da9c69dc97490 (patch)
tree15968b06ef64f63a3f1877804671a2a4fd0c7b69 /arch/arm/mach-netx
parentc80204e5d67d1452ac0b761d980f1651dc2c66dc (diff)
[ARM] 4013/1: clocksource driver for netx
Add a clocksource driver for netx systems Signed-off-by: Luotao Fu <lfu@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de> Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Diffstat (limited to 'arch/arm/mach-netx')
-rw-r--r--arch/arm/mach-netx/time.c42
1 files changed, 30 insertions, 12 deletions
diff --git a/arch/arm/mach-netx/time.c b/arch/arm/mach-netx/time.c
index 0993336c0b55..5773b55ef4a6 100644
--- a/arch/arm/mach-netx/time.c
+++ b/arch/arm/mach-netx/time.c
@@ -19,6 +19,8 @@
19 19
20#include <linux/init.h> 20#include <linux/init.h>
21#include <linux/interrupt.h> 21#include <linux/interrupt.h>
22#include <linux/irq.h>
23#include <linux/clocksource.h>
22 24
23#include <asm/hardware.h> 25#include <asm/hardware.h>
24#include <asm/io.h> 26#include <asm/io.h>
@@ -26,15 +28,6 @@
26#include <asm/arch/netx-regs.h> 28#include <asm/arch/netx-regs.h>
27 29
28/* 30/*
29 * Returns number of us since last clock interrupt. Note that interrupts
30 * will have been disabled by do_gettimeoffset()
31 */
32static unsigned long netx_gettimeoffset(void)
33{
34 return readl(NETX_GPIO_COUNTER_CURRENT(0)) / 100;
35}
36
37/*
38 * IRQ handler for the timer 31 * IRQ handler for the timer
39 */ 32 */
40static irqreturn_t 33static irqreturn_t
@@ -43,6 +36,7 @@ netx_timer_interrupt(int irq, void *dev_id)
43 write_seqlock(&xtime_lock); 36 write_seqlock(&xtime_lock);
44 37
45 timer_tick(); 38 timer_tick();
39
46 write_sequnlock(&xtime_lock); 40 write_sequnlock(&xtime_lock);
47 41
48 /* acknowledge interrupt */ 42 /* acknowledge interrupt */
@@ -51,13 +45,26 @@ netx_timer_interrupt(int irq, void *dev_id)
51 return IRQ_HANDLED; 45 return IRQ_HANDLED;
52} 46}
53 47
54
55static struct irqaction netx_timer_irq = { 48static struct irqaction netx_timer_irq = {
56 .name = "NetX Timer Tick", 49 .name = "NetX Timer Tick",
57 .flags = IRQF_DISABLED | IRQF_TIMER, 50 .flags = IRQF_DISABLED | IRQF_TIMER,
58 .handler = netx_timer_interrupt, 51 .handler = netx_timer_interrupt,
59}; 52};
60 53
54cycle_t netx_get_cycles(void)
55{
56 return readl(NETX_GPIO_COUNTER_CURRENT(1));
57}
58
59static struct clocksource clocksource_netx = {
60 .name = "netx_timer",
61 .rating = 200,
62 .read = netx_get_cycles,
63 .mask = CLOCKSOURCE_MASK(32),
64 .shift = 20,
65 .is_continuous = 1,
66};
67
61/* 68/*
62 * Set up timer interrupt 69 * Set up timer interrupt
63 */ 70 */
@@ -80,9 +87,20 @@ static void __init netx_timer_init(void)
80 NETX_GPIO_COUNTER_CTRL(0)); 87 NETX_GPIO_COUNTER_CTRL(0));
81 88
82 setup_irq(NETX_IRQ_TIMER0, &netx_timer_irq); 89 setup_irq(NETX_IRQ_TIMER0, &netx_timer_irq);
90
91 /* Setup timer one for clocksource */
92 writel(0, NETX_GPIO_COUNTER_CTRL(1));
93 writel(0, NETX_GPIO_COUNTER_CURRENT(1));
94 writel(0xFFFFFFFF, NETX_GPIO_COUNTER_MAX(1));
95
96 writel(NETX_GPIO_COUNTER_CTRL_RUN,
97 NETX_GPIO_COUNTER_CTRL(1));
98
99 clocksource_netx.mult =
100 clocksource_hz2mult(CLOCK_TICK_RATE, clocksource_netx.shift);
101 clocksource_register(&clocksource_netx);
83} 102}
84 103
85struct sys_timer netx_timer = { 104struct sys_timer netx_timer = {
86 .init = netx_timer_init, 105 .init = netx_timer_init,
87 .offset = netx_gettimeoffset,
88}; 106};