aboutsummaryrefslogtreecommitdiffstats
path: root/arch/powerpc/platforms/chrp/smp.c
diff options
context:
space:
mode:
authorPaul Mackerras <paulus@samba.org>2005-10-26 07:45:56 -0400
committerPaul Mackerras <paulus@samba.org>2005-10-26 07:45:56 -0400
commitbbd0abda9cc689a54df509aae00000bbb2a1a7d1 (patch)
treed04e8f196f65f5598300485e654e5e90a6160aa6 /arch/powerpc/platforms/chrp/smp.c
parent303d72a0006c65bb8d16199c75a26338ce723811 (diff)
powerpc: Merge 32-bit CHRP support.
SMP still needs more work but UP gets as far as starting userspace at least. This uses the 64-bit-style code for spinning up the cpus. Signed-off-by: Paul Mackerras <paulus@samba.org>
Diffstat (limited to 'arch/powerpc/platforms/chrp/smp.c')
-rw-r--r--arch/powerpc/platforms/chrp/smp.c94
1 files changed, 94 insertions, 0 deletions
diff --git a/arch/powerpc/platforms/chrp/smp.c b/arch/powerpc/platforms/chrp/smp.c
new file mode 100644
index 000000000000..bf68282670dd
--- /dev/null
+++ b/arch/powerpc/platforms/chrp/smp.c
@@ -0,0 +1,94 @@
1/*
2 * Smp support for CHRP machines.
3 *
4 * Written by Cort Dougan (cort@cs.nmt.edu) borrowing a great
5 * deal of code from the sparc and intel versions.
6 *
7 * Copyright (C) 1999 Cort Dougan <cort@cs.nmt.edu>
8 *
9 */
10
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>
21
22#include <asm/ptrace.h>
23#include <asm/atomic.h>
24#include <asm/irq.h>
25#include <asm/page.h>
26#include <asm/pgtable.h>
27#include <asm/sections.h>
28#include <asm/io.h>
29#include <asm/prom.h>
30#include <asm/smp.h>
31#include <asm/residual.h>
32#include <asm/time.h>
33#include <asm/open_pic.h>
34#include <asm/machdep.h>
35
36extern unsigned long smp_chrp_cpu_nr;
37
38static int __init smp_chrp_probe(void)
39{
40 if (smp_chrp_cpu_nr > 1)
41 openpic_request_IPIs();
42
43 return smp_chrp_cpu_nr;
44}
45
46static void __devinit smp_chrp_kick_cpu(int nr)
47{
48 *(unsigned long *)KERNELBASE = nr;
49 asm volatile("dcbf 0,%0"::"r"(KERNELBASE):"memory");
50}
51
52static void __devinit smp_chrp_setup_cpu(int cpu_nr)
53{
54 if (OpenPIC_Addr)
55 do_openpic_setup_cpu();
56}
57
58static DEFINE_SPINLOCK(timebase_lock);
59static unsigned int timebase_upper = 0, timebase_lower = 0;
60
61void __devinit smp_chrp_give_timebase(void)
62{
63 spin_lock(&timebase_lock);
64 rtas_call(rtas_token("freeze-time-base"), 0, 1, NULL);
65 timebase_upper = get_tbu();
66 timebase_lower = get_tbl();
67 spin_unlock(&timebase_lock);
68
69 while (timebase_upper || timebase_lower)
70 barrier();
71 rtas_call(rtas_token("thaw-time-base"), 0, 1, NULL);
72}
73
74void __devinit smp_chrp_take_timebase(void)
75{
76 while (!(timebase_upper || timebase_lower))
77 barrier();
78 spin_lock(&timebase_lock);
79 set_tb(timebase_upper, timebase_lower);
80 timebase_upper = 0;
81 timebase_lower = 0;
82 spin_unlock(&timebase_lock);
83 printk("CPU %i taken timebase\n", smp_processor_id());
84}
85
86/* CHRP with openpic */
87struct smp_ops_t chrp_smp_ops = {
88 .message_pass = smp_openpic_message_pass,
89 .probe = smp_chrp_probe,
90 .kick_cpu = smp_chrp_kick_cpu,
91 .setup_cpu = smp_chrp_setup_cpu,
92 .give_timebase = smp_chrp_give_timebase,
93 .take_timebase = smp_chrp_take_timebase,
94};