2 * Smp support for CHRP machines.
4 * Written by Cort Dougan (cort@cs.nmt.edu) borrowing a great
5 * deal of code from the sparc and intel versions.
7 * Copyright (C) 1999 Cort Dougan <cort@cs.nmt.edu>
11 #include <linux/kernel.h>
12 #include <linux/sched.h>
13 #include <linux/smp.h>
14 #include <linux/interrupt.h>
15 #include <linux/kernel_stat.h>
16 #include <linux/delay.h>
17 #include <linux/init.h>
18 #include <linux/spinlock.h>
20 #include <asm/ptrace.h>
21 #include <asm/atomic.h>
24 #include <asm/pgtable.h>
25 #include <asm/sections.h>
29 #include <asm/residual.h>
31 #include <asm/machdep.h>
35 static void __devinit smp_chrp_kick_cpu(int nr)
37 *(unsigned long *)KERNELBASE = nr;
38 asm volatile("dcbf 0,%0"::"r"(KERNELBASE):"memory");
41 static void __devinit smp_chrp_setup_cpu(int cpu_nr)
43 mpic_setup_this_cpu();
46 static DEFINE_SPINLOCK(timebase_lock);
47 static unsigned int timebase_upper = 0, timebase_lower = 0;
49 void __devinit smp_chrp_give_timebase(void)
51 spin_lock(&timebase_lock);
52 rtas_call(rtas_token("freeze-time-base"), 0, 1, NULL);
53 timebase_upper = get_tbu();
54 timebase_lower = get_tbl();
55 spin_unlock(&timebase_lock);
57 while (timebase_upper || timebase_lower)
59 rtas_call(rtas_token("thaw-time-base"), 0, 1, NULL);
62 void __devinit smp_chrp_take_timebase(void)
64 while (!(timebase_upper || timebase_lower))
66 spin_lock(&timebase_lock);
67 set_tb(timebase_upper, timebase_lower);
70 spin_unlock(&timebase_lock);
71 printk("CPU %i taken timebase\n", smp_processor_id());
74 /* CHRP with openpic */
75 struct smp_ops_t chrp_smp_ops = {
76 .message_pass = smp_mpic_message_pass,
77 .probe = smp_mpic_probe,
78 .kick_cpu = smp_chrp_kick_cpu,
79 .setup_cpu = smp_chrp_setup_cpu,
80 .give_timebase = smp_chrp_give_timebase,
81 .take_timebase = smp_chrp_take_timebase,