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/config.h>
12 #include <linux/kernel.h>
13 #include <linux/sched.h>
14 #include <linux/smp.h>
15 #include <linux/smp_lock.h>
16 #include <linux/interrupt.h>
17 #include <linux/kernel_stat.h>
18 #include <linux/delay.h>
19 #include <linux/init.h>
20 #include <linux/spinlock.h>
22 #include <asm/ptrace.h>
23 #include <asm/atomic.h>
26 #include <asm/pgtable.h>
27 #include <asm/sections.h>
31 #include <asm/residual.h>
33 #include <asm/open_pic.h>
34 #include <asm/machdep.h>
36 extern unsigned long smp_chrp_cpu_nr
;
41 if (smp_chrp_cpu_nr
> 1)
42 openpic_request_IPIs();
44 return smp_chrp_cpu_nr
;
48 smp_chrp_kick_cpu(int nr
)
50 *(unsigned long *)KERNELBASE
= nr
;
51 asm volatile("dcbf 0,%0"::"r"(KERNELBASE
):"memory");
55 smp_chrp_setup_cpu(int cpu_nr
)
58 do_openpic_setup_cpu();
61 static DEFINE_SPINLOCK(timebase_lock
);
62 static unsigned int timebase_upper
= 0, timebase_lower
= 0;
65 smp_chrp_give_timebase(void)
67 spin_lock(&timebase_lock
);
68 call_rtas("freeze-time-base", 0, 1, NULL
);
69 timebase_upper
= get_tbu();
70 timebase_lower
= get_tbl();
71 spin_unlock(&timebase_lock
);
73 while (timebase_upper
|| timebase_lower
)
75 call_rtas("thaw-time-base", 0, 1, NULL
);
79 smp_chrp_take_timebase(void)
81 while (!(timebase_upper
|| timebase_lower
))
83 spin_lock(&timebase_lock
);
84 set_tb(timebase_upper
, timebase_lower
);
87 spin_unlock(&timebase_lock
);
88 printk("CPU %i taken timebase\n", smp_processor_id());
91 /* CHRP with openpic */
92 struct smp_ops_t chrp_smp_ops
= {
93 .message_pass
= smp_openpic_message_pass
,
94 .probe
= smp_chrp_probe
,
95 .kick_cpu
= smp_chrp_kick_cpu
,
96 .setup_cpu
= smp_chrp_setup_cpu
,
97 .give_timebase
= smp_chrp_give_timebase
,
98 .take_timebase
= smp_chrp_take_timebase
,