aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/kernel
diff options
context:
space:
mode:
authorRussell King <rmk+kernel@arm.linux.org.uk>2010-07-31 09:20:02 -0400
committerRussell King <rmk+kernel@arm.linux.org.uk>2010-07-31 09:20:02 -0400
commitceb0885d3b01bb2e2f18765770e212914f2864be (patch)
tree0952c90cd49704a9172e985ca491d79b60c40bc8 /arch/arm/kernel
parentb31fc7af78e17b0203e1cd5a195c590e8adeae0d (diff)
parent08458ef6eede6cf7d5a33c3a7c8bcdc3943012c2 (diff)
Merge branch 'misc' into devel
Conflicts: arch/arm/mm/init.c
Diffstat (limited to 'arch/arm/kernel')
-rw-r--r--arch/arm/kernel/machine_kexec.c10
-rw-r--r--arch/arm/kernel/process.c29
-rw-r--r--arch/arm/kernel/smp.c17
-rw-r--r--arch/arm/kernel/smp_twd.c3
-rw-r--r--arch/arm/kernel/tcm.c118
5 files changed, 116 insertions, 61 deletions
diff --git a/arch/arm/kernel/machine_kexec.c b/arch/arm/kernel/machine_kexec.c
index 81e989858d42..1fc74cbd1a19 100644
--- a/arch/arm/kernel/machine_kexec.c
+++ b/arch/arm/kernel/machine_kexec.c
@@ -37,10 +37,6 @@ void machine_kexec_cleanup(struct kimage *image)
37{ 37{
38} 38}
39 39
40void machine_shutdown(void)
41{
42}
43
44void machine_crash_shutdown(struct pt_regs *regs) 40void machine_crash_shutdown(struct pt_regs *regs)
45{ 41{
46 local_irq_disable(); 42 local_irq_disable();
@@ -78,7 +74,11 @@ void machine_kexec(struct kimage *image)
78 (unsigned long) reboot_code_buffer + KEXEC_CONTROL_PAGE_SIZE); 74 (unsigned long) reboot_code_buffer + KEXEC_CONTROL_PAGE_SIZE);
79 printk(KERN_INFO "Bye!\n"); 75 printk(KERN_INFO "Bye!\n");
80 76
81 cpu_proc_fin(); 77 local_irq_disable();
78 local_fiq_disable();
82 setup_mm_for_reboot(0); /* mode is not used, so just pass 0*/ 79 setup_mm_for_reboot(0); /* mode is not used, so just pass 0*/
80 flush_cache_all();
81 cpu_proc_fin();
82 flush_cache_all();
83 cpu_reset(reboot_code_buffer_phys); 83 cpu_reset(reboot_code_buffer_phys);
84} 84}
diff --git a/arch/arm/kernel/process.c b/arch/arm/kernel/process.c
index a4a9cc88bec7..2e2ec97cc50c 100644
--- a/arch/arm/kernel/process.c
+++ b/arch/arm/kernel/process.c
@@ -29,6 +29,7 @@
29#include <linux/utsname.h> 29#include <linux/utsname.h>
30#include <linux/uaccess.h> 30#include <linux/uaccess.h>
31 31
32#include <asm/cacheflush.h>
32#include <asm/leds.h> 33#include <asm/leds.h>
33#include <asm/processor.h> 34#include <asm/processor.h>
34#include <asm/system.h> 35#include <asm/system.h>
@@ -84,10 +85,9 @@ __setup("hlt", hlt_setup);
84 85
85void arm_machine_restart(char mode, const char *cmd) 86void arm_machine_restart(char mode, const char *cmd)
86{ 87{
87 /* 88 /* Disable interrupts first */
88 * Clean and disable cache, and turn off interrupts 89 local_irq_disable();
89 */ 90 local_fiq_disable();
90 cpu_proc_fin();
91 91
92 /* 92 /*
93 * Tell the mm system that we are going to reboot - 93 * Tell the mm system that we are going to reboot -
@@ -96,6 +96,15 @@ void arm_machine_restart(char mode, const char *cmd)
96 */ 96 */
97 setup_mm_for_reboot(mode); 97 setup_mm_for_reboot(mode);
98 98
99 /* Clean and invalidate caches */
100 flush_cache_all();
101
102 /* Turn off caching */
103 cpu_proc_fin();
104
105 /* Push out any further dirty data, and ensure cache is empty */
106 flush_cache_all();
107
99 /* 108 /*
100 * Now call the architecture specific reboot code. 109 * Now call the architecture specific reboot code.
101 */ 110 */
@@ -189,19 +198,29 @@ int __init reboot_setup(char *str)
189 198
190__setup("reboot=", reboot_setup); 199__setup("reboot=", reboot_setup);
191 200
192void machine_halt(void) 201void machine_shutdown(void)
193{ 202{
203#ifdef CONFIG_SMP
204 smp_send_stop();
205#endif
194} 206}
195 207
208void machine_halt(void)
209{
210 machine_shutdown();
211 while (1);
212}
196 213
197void machine_power_off(void) 214void machine_power_off(void)
198{ 215{
216 machine_shutdown();
199 if (pm_power_off) 217 if (pm_power_off)
200 pm_power_off(); 218 pm_power_off();
201} 219}
202 220
203void machine_restart(char *cmd) 221void machine_restart(char *cmd)
204{ 222{
223 machine_shutdown();
205 arm_pm_restart(reboot_mode, cmd); 224 arm_pm_restart(reboot_mode, cmd);
206} 225}
207 226
diff --git a/arch/arm/kernel/smp.c b/arch/arm/kernel/smp.c
index b8c3d0f689d9..40dc74f2b27f 100644
--- a/arch/arm/kernel/smp.c
+++ b/arch/arm/kernel/smp.c
@@ -429,7 +429,11 @@ static void smp_timer_broadcast(const struct cpumask *mask)
429{ 429{
430 send_ipi_message(mask, IPI_TIMER); 430 send_ipi_message(mask, IPI_TIMER);
431} 431}
432#else
433#define smp_timer_broadcast NULL
434#endif
432 435
436#ifndef CONFIG_LOCAL_TIMERS
433static void broadcast_timer_set_mode(enum clock_event_mode mode, 437static void broadcast_timer_set_mode(enum clock_event_mode mode,
434 struct clock_event_device *evt) 438 struct clock_event_device *evt)
435{ 439{
@@ -444,7 +448,6 @@ static void local_timer_setup(struct clock_event_device *evt)
444 evt->rating = 400; 448 evt->rating = 400;
445 evt->mult = 1; 449 evt->mult = 1;
446 evt->set_mode = broadcast_timer_set_mode; 450 evt->set_mode = broadcast_timer_set_mode;
447 evt->broadcast = smp_timer_broadcast;
448 451
449 clockevents_register_device(evt); 452 clockevents_register_device(evt);
450} 453}
@@ -456,6 +459,7 @@ void __cpuinit percpu_timer_setup(void)
456 struct clock_event_device *evt = &per_cpu(percpu_clockevent, cpu); 459 struct clock_event_device *evt = &per_cpu(percpu_clockevent, cpu);
457 460
458 evt->cpumask = cpumask_of(cpu); 461 evt->cpumask = cpumask_of(cpu);
462 evt->broadcast = smp_timer_broadcast;
459 463
460 local_timer_setup(evt); 464 local_timer_setup(evt);
461} 465}
@@ -467,10 +471,13 @@ static DEFINE_SPINLOCK(stop_lock);
467 */ 471 */
468static void ipi_cpu_stop(unsigned int cpu) 472static void ipi_cpu_stop(unsigned int cpu)
469{ 473{
470 spin_lock(&stop_lock); 474 if (system_state == SYSTEM_BOOTING ||
471 printk(KERN_CRIT "CPU%u: stopping\n", cpu); 475 system_state == SYSTEM_RUNNING) {
472 dump_stack(); 476 spin_lock(&stop_lock);
473 spin_unlock(&stop_lock); 477 printk(KERN_CRIT "CPU%u: stopping\n", cpu);
478 dump_stack();
479 spin_unlock(&stop_lock);
480 }
474 481
475 set_cpu_online(cpu, false); 482 set_cpu_online(cpu, false);
476 483
diff --git a/arch/arm/kernel/smp_twd.c b/arch/arm/kernel/smp_twd.c
index 7c5f0c024db7..35882fbf37f9 100644
--- a/arch/arm/kernel/smp_twd.c
+++ b/arch/arm/kernel/smp_twd.c
@@ -132,7 +132,8 @@ void __cpuinit twd_timer_setup(struct clock_event_device *clk)
132 twd_calibrate_rate(); 132 twd_calibrate_rate();
133 133
134 clk->name = "local_timer"; 134 clk->name = "local_timer";
135 clk->features = CLOCK_EVT_FEAT_PERIODIC | CLOCK_EVT_FEAT_ONESHOT; 135 clk->features = CLOCK_EVT_FEAT_PERIODIC | CLOCK_EVT_FEAT_ONESHOT |
136 CLOCK_EVT_FEAT_C3STOP;
136 clk->rating = 350; 137 clk->rating = 350;
137 clk->set_mode = twd_set_mode; 138 clk->set_mode = twd_set_mode;
138 clk->set_next_event = twd_set_next_event; 139 clk->set_next_event = twd_set_next_event;
diff --git a/arch/arm/kernel/tcm.c b/arch/arm/kernel/tcm.c
index e50303868f1b..26685c2f7a49 100644
--- a/arch/arm/kernel/tcm.c
+++ b/arch/arm/kernel/tcm.c
@@ -13,38 +13,35 @@
13#include <linux/ioport.h> 13#include <linux/ioport.h>
14#include <linux/genalloc.h> 14#include <linux/genalloc.h>
15#include <linux/string.h> /* memcpy */ 15#include <linux/string.h> /* memcpy */
16#include <asm/page.h> /* PAGE_SHIFT */
17#include <asm/cputype.h> 16#include <asm/cputype.h>
18#include <asm/mach/map.h> 17#include <asm/mach/map.h>
19#include <mach/memory.h> 18#include <mach/memory.h>
20#include "tcm.h" 19#include "tcm.h"
21 20
22/* Scream and warn about misuse */
23#if !defined(ITCM_OFFSET) || !defined(ITCM_END) || \
24 !defined(DTCM_OFFSET) || !defined(DTCM_END)
25#error "TCM support selected but offsets not defined!"
26#endif
27
28static struct gen_pool *tcm_pool; 21static struct gen_pool *tcm_pool;
29 22
30/* TCM section definitions from the linker */ 23/* TCM section definitions from the linker */
31extern char __itcm_start, __sitcm_text, __eitcm_text; 24extern char __itcm_start, __sitcm_text, __eitcm_text;
32extern char __dtcm_start, __sdtcm_data, __edtcm_data; 25extern char __dtcm_start, __sdtcm_data, __edtcm_data;
33 26
27/* These will be increased as we run */
28u32 dtcm_end = DTCM_OFFSET;
29u32 itcm_end = ITCM_OFFSET;
30
34/* 31/*
35 * TCM memory resources 32 * TCM memory resources
36 */ 33 */
37static struct resource dtcm_res = { 34static struct resource dtcm_res = {
38 .name = "DTCM RAM", 35 .name = "DTCM RAM",
39 .start = DTCM_OFFSET, 36 .start = DTCM_OFFSET,
40 .end = DTCM_END, 37 .end = DTCM_OFFSET,
41 .flags = IORESOURCE_MEM 38 .flags = IORESOURCE_MEM
42}; 39};
43 40
44static struct resource itcm_res = { 41static struct resource itcm_res = {
45 .name = "ITCM RAM", 42 .name = "ITCM RAM",
46 .start = ITCM_OFFSET, 43 .start = ITCM_OFFSET,
47 .end = ITCM_END, 44 .end = ITCM_OFFSET,
48 .flags = IORESOURCE_MEM 45 .flags = IORESOURCE_MEM
49}; 46};
50 47
@@ -52,8 +49,8 @@ static struct map_desc dtcm_iomap[] __initdata = {
52 { 49 {
53 .virtual = DTCM_OFFSET, 50 .virtual = DTCM_OFFSET,
54 .pfn = __phys_to_pfn(DTCM_OFFSET), 51 .pfn = __phys_to_pfn(DTCM_OFFSET),
55 .length = (DTCM_END - DTCM_OFFSET + 1), 52 .length = 0,
56 .type = MT_UNCACHED 53 .type = MT_MEMORY_DTCM
57 } 54 }
58}; 55};
59 56
@@ -61,8 +58,8 @@ static struct map_desc itcm_iomap[] __initdata = {
61 { 58 {
62 .virtual = ITCM_OFFSET, 59 .virtual = ITCM_OFFSET,
63 .pfn = __phys_to_pfn(ITCM_OFFSET), 60 .pfn = __phys_to_pfn(ITCM_OFFSET),
64 .length = (ITCM_END - ITCM_OFFSET + 1), 61 .length = 0,
65 .type = MT_UNCACHED 62 .type = MT_MEMORY_ITCM
66 } 63 }
67}; 64};
68 65
@@ -93,14 +90,24 @@ void tcm_free(void *addr, size_t len)
93} 90}
94EXPORT_SYMBOL(tcm_free); 91EXPORT_SYMBOL(tcm_free);
95 92
96 93static int __init setup_tcm_bank(u8 type, u8 bank, u8 banks,
97static void __init setup_tcm_bank(u8 type, u32 offset, u32 expected_size) 94 u32 *offset)
98{ 95{
99 const int tcm_sizes[16] = { 0, -1, -1, 4, 8, 16, 32, 64, 128, 96 const int tcm_sizes[16] = { 0, -1, -1, 4, 8, 16, 32, 64, 128,
100 256, 512, 1024, -1, -1, -1, -1 }; 97 256, 512, 1024, -1, -1, -1, -1 };
101 u32 tcm_region; 98 u32 tcm_region;
102 int tcm_size; 99 int tcm_size;
103 100
101 /*
102 * If there are more than one TCM bank of this type,
103 * select the TCM bank to operate on in the TCM selection
104 * register.
105 */
106 if (banks > 1)
107 asm("mcr p15, 0, %0, c9, c2, 0"
108 : /* No output operands */
109 : "r" (bank));
110
104 /* Read the special TCM region register c9, 0 */ 111 /* Read the special TCM region register c9, 0 */
105 if (!type) 112 if (!type)
106 asm("mrc p15, 0, %0, c9, c1, 0" 113 asm("mrc p15, 0, %0, c9, c1, 0"
@@ -111,26 +118,24 @@ static void __init setup_tcm_bank(u8 type, u32 offset, u32 expected_size)
111 118
112 tcm_size = tcm_sizes[(tcm_region >> 2) & 0x0f]; 119 tcm_size = tcm_sizes[(tcm_region >> 2) & 0x0f];
113 if (tcm_size < 0) { 120 if (tcm_size < 0) {
114 pr_err("CPU: %sTCM of unknown size!\n", 121 pr_err("CPU: %sTCM%d of unknown size\n",
115 type ? "I" : "D"); 122 type ? "I" : "D", bank);
123 return -EINVAL;
124 } else if (tcm_size > 32) {
125 pr_err("CPU: %sTCM%d larger than 32k found\n",
126 type ? "I" : "D", bank);
127 return -EINVAL;
116 } else { 128 } else {
117 pr_info("CPU: found %sTCM %dk @ %08x, %senabled\n", 129 pr_info("CPU: found %sTCM%d %dk @ %08x, %senabled\n",
118 type ? "I" : "D", 130 type ? "I" : "D",
131 bank,
119 tcm_size, 132 tcm_size,
120 (tcm_region & 0xfffff000U), 133 (tcm_region & 0xfffff000U),
121 (tcm_region & 1) ? "" : "not "); 134 (tcm_region & 1) ? "" : "not ");
122 } 135 }
123 136
124 if (tcm_size != expected_size) {
125 pr_crit("CPU: %sTCM was detected %dk but expected %dk!\n",
126 type ? "I" : "D",
127 tcm_size,
128 expected_size);
129 /* Adjust to the expected size? what can we do... */
130 }
131
132 /* Force move the TCM bank to where we want it, enable */ 137 /* Force move the TCM bank to where we want it, enable */
133 tcm_region = offset | (tcm_region & 0x00000ffeU) | 1; 138 tcm_region = *offset | (tcm_region & 0x00000ffeU) | 1;
134 139
135 if (!type) 140 if (!type)
136 asm("mcr p15, 0, %0, c9, c1, 0" 141 asm("mcr p15, 0, %0, c9, c1, 0"
@@ -141,10 +146,15 @@ static void __init setup_tcm_bank(u8 type, u32 offset, u32 expected_size)
141 : /* No output operands */ 146 : /* No output operands */
142 : "r" (tcm_region)); 147 : "r" (tcm_region));
143 148
144 pr_debug("CPU: moved %sTCM %dk to %08x, enabled\n", 149 /* Increase offset */
145 type ? "I" : "D", 150 *offset += (tcm_size << 10);
146 tcm_size, 151
147 (tcm_region & 0xfffff000U)); 152 pr_info("CPU: moved %sTCM%d %dk to %08x, enabled\n",
153 type ? "I" : "D",
154 bank,
155 tcm_size,
156 (tcm_region & 0xfffff000U));
157 return 0;
148} 158}
149 159
150/* 160/*
@@ -153,34 +163,52 @@ static void __init setup_tcm_bank(u8 type, u32 offset, u32 expected_size)
153void __init tcm_init(void) 163void __init tcm_init(void)
154{ 164{
155 u32 tcm_status = read_cpuid_tcmstatus(); 165 u32 tcm_status = read_cpuid_tcmstatus();
166 u8 dtcm_banks = (tcm_status >> 16) & 0x03;
167 u8 itcm_banks = (tcm_status & 0x03);
156 char *start; 168 char *start;
157 char *end; 169 char *end;
158 char *ram; 170 char *ram;
171 int ret;
172 int i;
159 173
160 /* Setup DTCM if present */ 174 /* Setup DTCM if present */
161 if (tcm_status & (1 << 16)) { 175 if (dtcm_banks > 0) {
162 setup_tcm_bank(0, DTCM_OFFSET, 176 for (i = 0; i < dtcm_banks; i++) {
163 (DTCM_END - DTCM_OFFSET + 1) >> 10); 177 ret = setup_tcm_bank(0, i, dtcm_banks, &dtcm_end);
178 if (ret)
179 return;
180 }
181 dtcm_res.end = dtcm_end - 1;
164 request_resource(&iomem_resource, &dtcm_res); 182 request_resource(&iomem_resource, &dtcm_res);
183 dtcm_iomap[0].length = dtcm_end - DTCM_OFFSET;
165 iotable_init(dtcm_iomap, 1); 184 iotable_init(dtcm_iomap, 1);
166 /* Copy data from RAM to DTCM */ 185 /* Copy data from RAM to DTCM */
167 start = &__sdtcm_data; 186 start = &__sdtcm_data;
168 end = &__edtcm_data; 187 end = &__edtcm_data;
169 ram = &__dtcm_start; 188 ram = &__dtcm_start;
189 /* This means you compiled more code than fits into DTCM */
190 BUG_ON((end - start) > (dtcm_end - DTCM_OFFSET));
170 memcpy(start, ram, (end-start)); 191 memcpy(start, ram, (end-start));
171 pr_debug("CPU DTCM: copied data from %p - %p\n", start, end); 192 pr_debug("CPU DTCM: copied data from %p - %p\n", start, end);
172 } 193 }
173 194
174 /* Setup ITCM if present */ 195 /* Setup ITCM if present */
175 if (tcm_status & 1) { 196 if (itcm_banks > 0) {
176 setup_tcm_bank(1, ITCM_OFFSET, 197 for (i = 0; i < itcm_banks; i++) {
177 (ITCM_END - ITCM_OFFSET + 1) >> 10); 198 ret = setup_tcm_bank(1, i, itcm_banks, &itcm_end);
199 if (ret)
200 return;
201 }
202 itcm_res.end = itcm_end - 1;
178 request_resource(&iomem_resource, &itcm_res); 203 request_resource(&iomem_resource, &itcm_res);
204 itcm_iomap[0].length = itcm_end - ITCM_OFFSET;
179 iotable_init(itcm_iomap, 1); 205 iotable_init(itcm_iomap, 1);
180 /* Copy code from RAM to ITCM */ 206 /* Copy code from RAM to ITCM */
181 start = &__sitcm_text; 207 start = &__sitcm_text;
182 end = &__eitcm_text; 208 end = &__eitcm_text;
183 ram = &__itcm_start; 209 ram = &__itcm_start;
210 /* This means you compiled more code than fits into ITCM */
211 BUG_ON((end - start) > (itcm_end - ITCM_OFFSET));
184 memcpy(start, ram, (end-start)); 212 memcpy(start, ram, (end-start));
185 pr_debug("CPU ITCM: copied code from %p - %p\n", start, end); 213 pr_debug("CPU ITCM: copied code from %p - %p\n", start, end);
186 } 214 }
@@ -208,10 +236,10 @@ static int __init setup_tcm_pool(void)
208 pr_debug("Setting up TCM memory pool\n"); 236 pr_debug("Setting up TCM memory pool\n");
209 237
210 /* Add the rest of DTCM to the TCM pool */ 238 /* Add the rest of DTCM to the TCM pool */
211 if (tcm_status & (1 << 16)) { 239 if (tcm_status & (0x03 << 16)) {
212 if (dtcm_pool_start < DTCM_END) { 240 if (dtcm_pool_start < dtcm_end) {
213 ret = gen_pool_add(tcm_pool, dtcm_pool_start, 241 ret = gen_pool_add(tcm_pool, dtcm_pool_start,
214 DTCM_END - dtcm_pool_start + 1, -1); 242 dtcm_end - dtcm_pool_start, -1);
215 if (ret) { 243 if (ret) {
216 pr_err("CPU DTCM: could not add DTCM " \ 244 pr_err("CPU DTCM: could not add DTCM " \
217 "remainder to pool!\n"); 245 "remainder to pool!\n");
@@ -219,16 +247,16 @@ static int __init setup_tcm_pool(void)
219 } 247 }
220 pr_debug("CPU DTCM: Added %08x bytes @ %08x to " \ 248 pr_debug("CPU DTCM: Added %08x bytes @ %08x to " \
221 "the TCM memory pool\n", 249 "the TCM memory pool\n",
222 DTCM_END - dtcm_pool_start + 1, 250 dtcm_end - dtcm_pool_start,
223 dtcm_pool_start); 251 dtcm_pool_start);
224 } 252 }
225 } 253 }
226 254
227 /* Add the rest of ITCM to the TCM pool */ 255 /* Add the rest of ITCM to the TCM pool */
228 if (tcm_status & 1) { 256 if (tcm_status & 0x03) {
229 if (itcm_pool_start < ITCM_END) { 257 if (itcm_pool_start < itcm_end) {
230 ret = gen_pool_add(tcm_pool, itcm_pool_start, 258 ret = gen_pool_add(tcm_pool, itcm_pool_start,
231 ITCM_END - itcm_pool_start + 1, -1); 259 itcm_end - itcm_pool_start, -1);
232 if (ret) { 260 if (ret) {
233 pr_err("CPU ITCM: could not add ITCM " \ 261 pr_err("CPU ITCM: could not add ITCM " \
234 "remainder to pool!\n"); 262 "remainder to pool!\n");
@@ -236,7 +264,7 @@ static int __init setup_tcm_pool(void)
236 } 264 }
237 pr_debug("CPU ITCM: Added %08x bytes @ %08x to " \ 265 pr_debug("CPU ITCM: Added %08x bytes @ %08x to " \
238 "the TCM memory pool\n", 266 "the TCM memory pool\n",
239 ITCM_END - itcm_pool_start + 1, 267 itcm_end - itcm_pool_start,
240 itcm_pool_start); 268 itcm_pool_start);
241 } 269 }
242 } 270 }