diff options
author | Catalin Marinas <catalin.marinas@arm.com> | 2008-12-01 09:54:57 -0500 |
---|---|---|
committer | Catalin Marinas <catalin.marinas@arm.com> | 2008-12-01 09:54:57 -0500 |
commit | ebac6546df7e8bd17f66f029c616ea9ee3c595ae (patch) | |
tree | 98801f44053407dc2990b16fbcfdbc5cb770416c /arch/arm/mach-realview/localtimer.c | |
parent | 4c3ea3717103ffcccfaebedb98c2dadfb54e0482 (diff) |
RealView: Use only the shadow mapping of ARM11MPCore local timers
All the cases where the local timer for a CPU is accessed happen on the
corresponding current CPU, hence no need to access the per-CPU local
timer mappings.
Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
Diffstat (limited to 'arch/arm/mach-realview/localtimer.c')
-rw-r--r-- | arch/arm/mach-realview/localtimer.c | 44 |
1 files changed, 19 insertions, 25 deletions
diff --git a/arch/arm/mach-realview/localtimer.c b/arch/arm/mach-realview/localtimer.c index 44d178cd5733..9019ef2e5611 100644 --- a/arch/arm/mach-realview/localtimer.c +++ b/arch/arm/mach-realview/localtimer.c | |||
@@ -38,18 +38,14 @@ void local_timer_interrupt(void) | |||
38 | 38 | ||
39 | #ifdef CONFIG_LOCAL_TIMERS | 39 | #ifdef CONFIG_LOCAL_TIMERS |
40 | 40 | ||
41 | #define TWD_BASE(cpu) (twd_base_addr + (cpu) * twd_size) | ||
42 | |||
43 | /* set up by the platform code */ | 41 | /* set up by the platform code */ |
44 | void __iomem *twd_base_addr; | 42 | void __iomem *twd_base; |
45 | unsigned int twd_size; | ||
46 | 43 | ||
47 | static unsigned long mpcore_timer_rate; | 44 | static unsigned long mpcore_timer_rate; |
48 | 45 | ||
49 | static void local_timer_set_mode(enum clock_event_mode mode, | 46 | static void local_timer_set_mode(enum clock_event_mode mode, |
50 | struct clock_event_device *clk) | 47 | struct clock_event_device *clk) |
51 | { | 48 | { |
52 | void __iomem *base = TWD_BASE(smp_processor_id()); | ||
53 | unsigned long ctrl; | 49 | unsigned long ctrl; |
54 | 50 | ||
55 | switch(mode) { | 51 | switch(mode) { |
@@ -68,17 +64,16 @@ static void local_timer_set_mode(enum clock_event_mode mode, | |||
68 | ctrl = 0; | 64 | ctrl = 0; |
69 | } | 65 | } |
70 | 66 | ||
71 | __raw_writel(ctrl, base + TWD_TIMER_CONTROL); | 67 | __raw_writel(ctrl, twd_base + TWD_TIMER_CONTROL); |
72 | } | 68 | } |
73 | 69 | ||
74 | static int local_timer_set_next_event(unsigned long evt, | 70 | static int local_timer_set_next_event(unsigned long evt, |
75 | struct clock_event_device *unused) | 71 | struct clock_event_device *unused) |
76 | { | 72 | { |
77 | void __iomem *base = TWD_BASE(smp_processor_id()); | 73 | unsigned long ctrl = __raw_readl(twd_base + TWD_TIMER_CONTROL); |
78 | unsigned long ctrl = __raw_readl(base + TWD_TIMER_CONTROL); | ||
79 | 74 | ||
80 | __raw_writel(evt, base + TWD_TIMER_COUNTER); | 75 | __raw_writel(evt, twd_base + TWD_TIMER_COUNTER); |
81 | __raw_writel(ctrl | TWD_TIMER_CONTROL_ENABLE, base + TWD_TIMER_CONTROL); | 76 | __raw_writel(ctrl | TWD_TIMER_CONTROL_ENABLE, twd_base + TWD_TIMER_CONTROL); |
82 | 77 | ||
83 | return 0; | 78 | return 0; |
84 | } | 79 | } |
@@ -91,19 +86,16 @@ static int local_timer_set_next_event(unsigned long evt, | |||
91 | */ | 86 | */ |
92 | int local_timer_ack(void) | 87 | int local_timer_ack(void) |
93 | { | 88 | { |
94 | void __iomem *base = TWD_BASE(smp_processor_id()); | 89 | if (__raw_readl(twd_base + TWD_TIMER_INTSTAT)) { |
95 | 90 | __raw_writel(1, twd_base + TWD_TIMER_INTSTAT); | |
96 | if (__raw_readl(base + TWD_TIMER_INTSTAT)) { | ||
97 | __raw_writel(1, base + TWD_TIMER_INTSTAT); | ||
98 | return 1; | 91 | return 1; |
99 | } | 92 | } |
100 | 93 | ||
101 | return 0; | 94 | return 0; |
102 | } | 95 | } |
103 | 96 | ||
104 | static void __cpuinit twd_calibrate_rate(unsigned int cpu) | 97 | static void __cpuinit twd_calibrate_rate(void) |
105 | { | 98 | { |
106 | void __iomem *base = TWD_BASE(cpu); | ||
107 | unsigned long load, count; | 99 | unsigned long load, count; |
108 | u64 waitjiffies; | 100 | u64 waitjiffies; |
109 | 101 | ||
@@ -124,15 +116,15 @@ static void __cpuinit twd_calibrate_rate(unsigned int cpu) | |||
124 | waitjiffies += 5; | 116 | waitjiffies += 5; |
125 | 117 | ||
126 | /* enable, no interrupt or reload */ | 118 | /* enable, no interrupt or reload */ |
127 | __raw_writel(0x1, base + TWD_TIMER_CONTROL); | 119 | __raw_writel(0x1, twd_base + TWD_TIMER_CONTROL); |
128 | 120 | ||
129 | /* maximum value */ | 121 | /* maximum value */ |
130 | __raw_writel(0xFFFFFFFFU, base + TWD_TIMER_COUNTER); | 122 | __raw_writel(0xFFFFFFFFU, twd_base + TWD_TIMER_COUNTER); |
131 | 123 | ||
132 | while (get_jiffies_64() < waitjiffies) | 124 | while (get_jiffies_64() < waitjiffies) |
133 | udelay(10); | 125 | udelay(10); |
134 | 126 | ||
135 | count = __raw_readl(base + TWD_TIMER_COUNTER); | 127 | count = __raw_readl(twd_base + TWD_TIMER_COUNTER); |
136 | 128 | ||
137 | mpcore_timer_rate = (0xFFFFFFFFU - count) * (HZ / 5); | 129 | mpcore_timer_rate = (0xFFFFFFFFU - count) * (HZ / 5); |
138 | 130 | ||
@@ -142,18 +134,19 @@ static void __cpuinit twd_calibrate_rate(unsigned int cpu) | |||
142 | 134 | ||
143 | load = mpcore_timer_rate / HZ; | 135 | load = mpcore_timer_rate / HZ; |
144 | 136 | ||
145 | __raw_writel(load, base + TWD_TIMER_LOAD); | 137 | __raw_writel(load, twd_base + TWD_TIMER_LOAD); |
146 | } | 138 | } |
147 | 139 | ||
148 | /* | 140 | /* |
149 | * Setup the local clock events for a CPU. | 141 | * Setup the local clock events for a CPU. |
150 | */ | 142 | */ |
151 | void __cpuinit local_timer_setup(unsigned int cpu) | 143 | void __cpuinit local_timer_setup(void) |
152 | { | 144 | { |
145 | unsigned int cpu = smp_processor_id(); | ||
153 | struct clock_event_device *clk = &per_cpu(local_clockevent, cpu); | 146 | struct clock_event_device *clk = &per_cpu(local_clockevent, cpu); |
154 | unsigned long flags; | 147 | unsigned long flags; |
155 | 148 | ||
156 | twd_calibrate_rate(cpu); | 149 | twd_calibrate_rate(); |
157 | 150 | ||
158 | clk->name = "local_timer"; | 151 | clk->name = "local_timer"; |
159 | clk->features = CLOCK_EVT_FEAT_PERIODIC | CLOCK_EVT_FEAT_ONESHOT; | 152 | clk->features = CLOCK_EVT_FEAT_PERIODIC | CLOCK_EVT_FEAT_ONESHOT; |
@@ -178,9 +171,9 @@ void __cpuinit local_timer_setup(unsigned int cpu) | |||
178 | /* | 171 | /* |
179 | * take a local timer down | 172 | * take a local timer down |
180 | */ | 173 | */ |
181 | void __cpuexit local_timer_stop(unsigned int cpu) | 174 | void __cpuexit local_timer_stop(void) |
182 | { | 175 | { |
183 | __raw_writel(0, TWD_BASE(cpu) + TWD_TIMER_CONTROL); | 176 | __raw_writel(0, twd_base + TWD_TIMER_CONTROL); |
184 | } | 177 | } |
185 | 178 | ||
186 | #else /* CONFIG_LOCAL_TIMERS */ | 179 | #else /* CONFIG_LOCAL_TIMERS */ |
@@ -190,8 +183,9 @@ static void dummy_timer_set_mode(enum clock_event_mode mode, | |||
190 | { | 183 | { |
191 | } | 184 | } |
192 | 185 | ||
193 | void __cpuinit local_timer_setup(unsigned int cpu) | 186 | void __cpuinit local_timer_setup(void) |
194 | { | 187 | { |
188 | unsigned int cpu = smp_processor_id(); | ||
195 | struct clock_event_device *clk = &per_cpu(local_clockevent, cpu); | 189 | struct clock_event_device *clk = &per_cpu(local_clockevent, cpu); |
196 | 190 | ||
197 | clk->name = "dummy_timer"; | 191 | clk->name = "dummy_timer"; |