diff options
-rw-r--r-- | arch/arm/mach-netx/time.c | 42 |
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 | */ | ||
32 | static 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 | */ |
40 | static irqreturn_t | 33 | static 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 | |||
55 | static struct irqaction netx_timer_irq = { | 48 | static 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 | ||
54 | cycle_t netx_get_cycles(void) | ||
55 | { | ||
56 | return readl(NETX_GPIO_COUNTER_CURRENT(1)); | ||
57 | } | ||
58 | |||
59 | static 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 | ||
85 | struct sys_timer netx_timer = { | 104 | struct sys_timer netx_timer = { |
86 | .init = netx_timer_init, | 105 | .init = netx_timer_init, |
87 | .offset = netx_gettimeoffset, | ||
88 | }; | 106 | }; |