13 #include <linux/stddef.h>
14 #include <linux/kernel.h>
18 #include <linux/kexec.h>
22 #include <asm/machdep.h>
23 #include <asm/pgtable.h>
26 #include <asm/cacheflush.h>
43 static struct ccsr_guts
__iomem *guts;
48 static void mpc85xx_timebase_freeze(
int freeze)
52 mask = CCSR_GUTS_DEVDISR_TB0 | CCSR_GUTS_DEVDISR_TB1;
54 setbits32(&guts->devdisr, mask);
56 clrbits32(&guts->devdisr, mask);
61 static void mpc85xx_give_timebase(
void)
71 mpc85xx_timebase_freeze(1);
79 mpc85xx_timebase_freeze(0);
84 static void mpc85xx_take_timebase(
void)
94 set_tb(timebase >> 32, timebase & 0xffffffff);
101 #ifdef CONFIG_HOTPLUG_CPU
102 static void __cpuinit smp_85xx_mach_cpu_die(
void)
109 generic_set_cpu_dead(cpu);
115 tmp = (
mfspr(SPRN_HID0) & ~(HID0_DOZE|HID0_SLEEP)) | HID0_NAP;
116 mtspr(SPRN_HID0, tmp);
134 const u64 *cpu_rel_addr;
137 int hw_cpu = get_hard_smp_processor_id(nr);
144 pr_debug(
"smp_85xx_kick_cpu: kick CPU #%d\n", nr);
149 if (cpu_rel_addr ==
NULL) {
160 ioremappable = *cpu_rel_addr >
virt_to_phys(high_memory);
164 spin_table =
ioremap(*cpu_rel_addr,
171 #ifdef CONFIG_HOTPLUG_CPU
173 generic_set_cpu_up(nr);
187 pr_err(
"%s: timeout waiting for core %d to reset\n",
194 __secondary_hold_acknowledge = -1;
205 if (!spin_event_timeout(__secondary_hold_acknowledge == hw_cpu,
207 pr_err(
"%s: timeout waiting for core %d to ack\n",
214 smp_generic_kick_cpu(nr);
217 out_be64((
u64 *)(&spin_table->addr_h),
218 __pa((
u64)*((
unsigned long long *)generic_secondary_smp_init)));
234 .kick_cpu = smp_85xx_kick_cpu,
235 #ifdef CONFIG_HOTPLUG_CPU
236 .cpu_disable = generic_cpu_disable,
237 .cpu_die = generic_cpu_die,
248 void mpc85xx_smp_kexec_cpu_down(
int crash_shutdown,
int secondary)
259 static void mpc85xx_smp_kexec_down(
void *
arg)
261 if (
ppc_md.kexec_cpu_down)
262 ppc_md.kexec_cpu_down(0,1);
265 static void map_and_flush(
unsigned long paddr)
268 unsigned long kaddr = (
unsigned long)
kmap(page);
280 static void mpc85xx_smp_flush_dcache_kexec(
struct kimage *
image)
286 if (image->type == KEXEC_TYPE_DEFAULT) {
288 for (ptr = &image->head; (entry = *ptr) && !(entry & IND_DONE);
289 ptr = (entry & IND_INDIRECTION) ?
291 if (!(entry & IND_DESTINATION)) {
292 map_and_flush(entry);
296 map_and_flush(entry);
299 for (i = 0; i < image->nr_segments; i++) {
301 for (paddr = seg->
mem; paddr < seg->
mem + seg->
memsz;
303 map_and_flush(paddr);
310 (
unsigned long)image +
sizeof(*image));
313 static void mpc85xx_smp_machine_kexec(
struct kimage *image)
318 mpc85xx_smp_flush_dcache_kexec(image);
320 if (image->type == KEXEC_TYPE_DEFAULT)
323 while ( (
atomic_read(&kexec_down_cpus) != (num_cpus - 1)) &&
342 static void __cpuinit smp_85xx_setup_cpu(
int cpu_nr)
344 if (smp_85xx_ops.probe == smp_mpic_probe)
351 static const struct of_device_id mpc85xx_smp_guts_ids[] = {
352 { .compatible =
"fsl,mpc8572-guts", },
353 { .compatible =
"fsl,p1020-guts", },
354 { .compatible =
"fsl,p1021-guts", },
355 { .compatible =
"fsl,p1022-guts", },
356 { .compatible =
"fsl,p1023-guts", },
357 { .compatible =
"fsl,p2020-guts", },
365 smp_85xx_ops.setup_cpu = smp_85xx_setup_cpu;
369 smp_85xx_ops.probe = smp_mpic_probe;
370 smp_85xx_ops.message_pass = smp_mpic_message_pass;
378 smp_85xx_ops.message_pass =
NULL;
387 pr_err(
"%s: Could not map guts node address\n",
391 smp_85xx_ops.give_timebase = mpc85xx_give_timebase;
392 smp_85xx_ops.take_timebase = mpc85xx_take_timebase;
393 #ifdef CONFIG_HOTPLUG_CPU
394 ppc_md.cpu_die = smp_85xx_mach_cpu_die;
401 ppc_md.kexec_cpu_down = mpc85xx_smp_kexec_cpu_down;
402 ppc_md.machine_kexec = mpc85xx_smp_machine_kexec;