aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/mach-realview
diff options
context:
space:
mode:
authorRussell King <rmk@dyn-67.arm.linux.org.uk>2009-05-16 07:14:21 -0400
committerRussell King <rmk+kernel@arm.linux.org.uk>2009-05-17 14:16:41 -0400
commitf32f4ce25745209f16a5a6cef7442144b596c68a (patch)
tree76083f10ee56c82177669bb100358ea2818f8f5a /arch/arm/mach-realview
parenta8cbcd92bd4bf893085eddf7f58e63ea98503d94 (diff)
[ARM] smp: allow re-use of realview localtimer TWD support
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Diffstat (limited to 'arch/arm/mach-realview')
-rw-r--r--arch/arm/mach-realview/Makefile3
-rw-r--r--arch/arm/mach-realview/core.h3
-rw-r--r--arch/arm/mach-realview/localtimer.c144
-rw-r--r--arch/arm/mach-realview/realview_eb.c1
-rw-r--r--arch/arm/mach-realview/realview_pb11mp.c1
5 files changed, 8 insertions, 144 deletions
diff --git a/arch/arm/mach-realview/Makefile b/arch/arm/mach-realview/Makefile
index 7bea8ffc4b59..e13d0947ad0b 100644
--- a/arch/arm/mach-realview/Makefile
+++ b/arch/arm/mach-realview/Makefile
@@ -7,5 +7,6 @@ obj-$(CONFIG_MACH_REALVIEW_EB) += realview_eb.o
7obj-$(CONFIG_MACH_REALVIEW_PB11MP) += realview_pb11mp.o 7obj-$(CONFIG_MACH_REALVIEW_PB11MP) += realview_pb11mp.o
8obj-$(CONFIG_MACH_REALVIEW_PB1176) += realview_pb1176.o 8obj-$(CONFIG_MACH_REALVIEW_PB1176) += realview_pb1176.o
9obj-$(CONFIG_MACH_REALVIEW_PBA8) += realview_pba8.o 9obj-$(CONFIG_MACH_REALVIEW_PBA8) += realview_pba8.o
10obj-$(CONFIG_SMP) += platsmp.o headsmp.o localtimer.o 10obj-$(CONFIG_SMP) += platsmp.o headsmp.o
11obj-$(CONFIG_HOTPLUG_CPU) += hotplug.o 11obj-$(CONFIG_HOTPLUG_CPU) += hotplug.o
12obj-$(CONFIG_LOCAL_TIMERS) += localtimer.o
diff --git a/arch/arm/mach-realview/core.h b/arch/arm/mach-realview/core.h
index 21c08637683b..59a337ba4be7 100644
--- a/arch/arm/mach-realview/core.h
+++ b/arch/arm/mach-realview/core.h
@@ -51,9 +51,6 @@ extern struct mmc_platform_data realview_mmc0_plat_data;
51extern struct mmc_platform_data realview_mmc1_plat_data; 51extern struct mmc_platform_data realview_mmc1_plat_data;
52extern struct clcd_board clcd_plat_data; 52extern struct clcd_board clcd_plat_data;
53extern void __iomem *gic_cpu_base_addr; 53extern void __iomem *gic_cpu_base_addr;
54#ifdef CONFIG_LOCAL_TIMERS
55extern void __iomem *twd_base;
56#endif
57extern void __iomem *timer0_va_base; 54extern void __iomem *timer0_va_base;
58extern void __iomem *timer1_va_base; 55extern void __iomem *timer1_va_base;
59extern void __iomem *timer2_va_base; 56extern void __iomem *timer2_va_base;
diff --git a/arch/arm/mach-realview/localtimer.c b/arch/arm/mach-realview/localtimer.c
index cd98e7acd94d..60b4e111f459 100644
--- a/arch/arm/mach-realview/localtimer.c
+++ b/arch/arm/mach-realview/localtimer.c
@@ -9,154 +9,18 @@
9 * published by the Free Software Foundation. 9 * published by the Free Software Foundation.
10 */ 10 */
11#include <linux/init.h> 11#include <linux/init.h>
12#include <linux/kernel.h>
13#include <linux/delay.h>
14#include <linux/smp.h> 12#include <linux/smp.h>
15#include <linux/jiffies.h>
16#include <linux/clockchips.h> 13#include <linux/clockchips.h>
17#include <linux/irq.h>
18#include <linux/io.h>
19 14
20#include <asm/hardware/arm_twd.h>
21#include <asm/hardware/gic.h>
22#include <mach/hardware.h>
23#include <asm/irq.h> 15#include <asm/irq.h>
24 16#include <asm/smp_twd.h>
25#ifdef CONFIG_LOCAL_TIMERS 17#include <asm/localtimer.h>
26
27/* set up by the platform code */
28void __iomem *twd_base;
29
30static unsigned long mpcore_timer_rate;
31
32static void local_timer_set_mode(enum clock_event_mode mode,
33 struct clock_event_device *evt)
34{
35 unsigned long ctrl;
36
37 switch(mode) {
38 case CLOCK_EVT_MODE_PERIODIC:
39 /* timer load already set up */
40 ctrl = TWD_TIMER_CONTROL_ENABLE | TWD_TIMER_CONTROL_IT_ENABLE
41 | TWD_TIMER_CONTROL_PERIODIC;
42 break;
43 case CLOCK_EVT_MODE_ONESHOT:
44 /* period set, and timer enabled in 'next_event' hook */
45 ctrl = TWD_TIMER_CONTROL_IT_ENABLE | TWD_TIMER_CONTROL_ONESHOT;
46 break;
47 case CLOCK_EVT_MODE_UNUSED:
48 case CLOCK_EVT_MODE_SHUTDOWN:
49 default:
50 ctrl = 0;
51 }
52
53 __raw_writel(ctrl, twd_base + TWD_TIMER_CONTROL);
54}
55
56static int local_timer_set_next_event(unsigned long evt,
57 struct clock_event_device *unused)
58{
59 unsigned long ctrl = __raw_readl(twd_base + TWD_TIMER_CONTROL);
60
61 __raw_writel(evt, twd_base + TWD_TIMER_COUNTER);
62 __raw_writel(ctrl | TWD_TIMER_CONTROL_ENABLE, twd_base + TWD_TIMER_CONTROL);
63
64 return 0;
65}
66
67/*
68 * local_timer_ack: checks for a local timer interrupt.
69 *
70 * If a local timer interrupt has occurred, acknowledge and return 1.
71 * Otherwise, return 0.
72 */
73int local_timer_ack(void)
74{
75 if (__raw_readl(twd_base + TWD_TIMER_INTSTAT)) {
76 __raw_writel(1, twd_base + TWD_TIMER_INTSTAT);
77 return 1;
78 }
79
80 return 0;
81}
82
83static void __cpuinit twd_calibrate_rate(void)
84{
85 unsigned long load, count;
86 u64 waitjiffies;
87
88 /*
89 * If this is the first time round, we need to work out how fast
90 * the timer ticks
91 */
92 if (mpcore_timer_rate == 0) {
93 printk("Calibrating local timer... ");
94
95 /* Wait for a tick to start */
96 waitjiffies = get_jiffies_64() + 1;
97
98 while (get_jiffies_64() < waitjiffies)
99 udelay(10);
100
101 /* OK, now the tick has started, let's get the timer going */
102 waitjiffies += 5;
103
104 /* enable, no interrupt or reload */
105 __raw_writel(0x1, twd_base + TWD_TIMER_CONTROL);
106
107 /* maximum value */
108 __raw_writel(0xFFFFFFFFU, twd_base + TWD_TIMER_COUNTER);
109
110 while (get_jiffies_64() < waitjiffies)
111 udelay(10);
112
113 count = __raw_readl(twd_base + TWD_TIMER_COUNTER);
114
115 mpcore_timer_rate = (0xFFFFFFFFU - count) * (HZ / 5);
116
117 printk("%lu.%02luMHz.\n", mpcore_timer_rate / 1000000,
118 (mpcore_timer_rate / 100000) % 100);
119 }
120
121 load = mpcore_timer_rate / HZ;
122
123 __raw_writel(load, twd_base + TWD_TIMER_LOAD);
124}
125 18
126/* 19/*
127 * Setup the local clock events for a CPU. 20 * Setup the local clock events for a CPU.
128 */ 21 */
129void __cpuinit local_timer_setup(struct clock_event_device *evt) 22void __cpuinit local_timer_setup(struct clock_event_device *evt)
130{ 23{
131 unsigned long flags; 24 evt->irq = IRQ_LOCALTIMER;
132 25 twd_timer_setup(evt);
133 twd_calibrate_rate();
134
135 evt->name = "local_timer";
136 evt->features = CLOCK_EVT_FEAT_PERIODIC | CLOCK_EVT_FEAT_ONESHOT;
137 evt->rating = 350;
138 evt->set_mode = local_timer_set_mode;
139 evt->set_next_event = local_timer_set_next_event;
140 evt->irq = IRQ_LOCALTIMER;
141 evt->shift = 20;
142 evt->mult = div_sc(mpcore_timer_rate, NSEC_PER_SEC, evt->shift);
143 evt->max_delta_ns = clockevent_delta2ns(0xffffffff, evt);
144 evt->min_delta_ns = clockevent_delta2ns(0xf, evt);
145
146 /* Make sure our local interrupt controller has this enabled */
147 local_irq_save(flags);
148 get_irq_chip(IRQ_LOCALTIMER)->unmask(IRQ_LOCALTIMER);
149 local_irq_restore(flags);
150
151 clockevents_register_device(evt);
152} 26}
153
154/*
155 * take a local timer down
156 */
157void __cpuexit local_timer_stop(void)
158{
159 __raw_writel(0, twd_base + TWD_TIMER_CONTROL);
160}
161
162#endif /* CONFIG_LOCAL_TIMERS */
diff --git a/arch/arm/mach-realview/realview_eb.c b/arch/arm/mach-realview/realview_eb.c
index c20fbef122b3..8dfa44e08a94 100644
--- a/arch/arm/mach-realview/realview_eb.c
+++ b/arch/arm/mach-realview/realview_eb.c
@@ -32,6 +32,7 @@
32#include <asm/hardware/gic.h> 32#include <asm/hardware/gic.h>
33#include <asm/hardware/icst307.h> 33#include <asm/hardware/icst307.h>
34#include <asm/hardware/cache-l2x0.h> 34#include <asm/hardware/cache-l2x0.h>
35#include <asm/localtimer.h>
35 36
36#include <asm/mach/arch.h> 37#include <asm/mach/arch.h>
37#include <asm/mach/map.h> 38#include <asm/mach/map.h>
diff --git a/arch/arm/mach-realview/realview_pb11mp.c b/arch/arm/mach-realview/realview_pb11mp.c
index ea1e60eca359..dc4b16943907 100644
--- a/arch/arm/mach-realview/realview_pb11mp.c
+++ b/arch/arm/mach-realview/realview_pb11mp.c
@@ -32,6 +32,7 @@
32#include <asm/hardware/gic.h> 32#include <asm/hardware/gic.h>
33#include <asm/hardware/icst307.h> 33#include <asm/hardware/icst307.h>
34#include <asm/hardware/cache-l2x0.h> 34#include <asm/hardware/cache-l2x0.h>
35#include <asm/localtimer.h>
35 36
36#include <asm/mach/arch.h> 37#include <asm/mach/arch.h>
37#include <asm/mach/flash.h> 38#include <asm/mach/flash.h>