diff options
author | Linus Torvalds <torvalds@ppc970.osdl.org> | 2005-04-16 18:20:36 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@ppc970.osdl.org> | 2005-04-16 18:20:36 -0400 |
commit | 1da177e4c3f41524e886b7f1b8a0c1fc7321cac2 (patch) | |
tree | 0bba044c4ce775e45a88a51686b5d9f90697ea9d /arch/ppc/platforms/chrp_smp.c |
Linux-2.6.12-rc2
Initial git repository build. I'm not bothering with the full history,
even though we have it. We can create a separate "historical" git
archive of that later if we want to, and in the meantime it's about
3.2GB when imported into git - space that would just make the early
git days unnecessarily complicated, when we don't have a lot of good
infrastructure for it.
Let it rip!
Diffstat (limited to 'arch/ppc/platforms/chrp_smp.c')
-rw-r--r-- | arch/ppc/platforms/chrp_smp.c | 98 |
1 files changed, 98 insertions, 0 deletions
diff --git a/arch/ppc/platforms/chrp_smp.c b/arch/ppc/platforms/chrp_smp.c new file mode 100644 index 00000000000..0ea1f7d9e46 --- /dev/null +++ b/arch/ppc/platforms/chrp_smp.c | |||
@@ -0,0 +1,98 @@ | |||
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 | |||
35 | extern unsigned long smp_chrp_cpu_nr; | ||
36 | |||
37 | static int __init | ||
38 | 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 | |||
46 | static void __devinit | ||
47 | smp_chrp_kick_cpu(int nr) | ||
48 | { | ||
49 | *(unsigned long *)KERNELBASE = nr; | ||
50 | asm volatile("dcbf 0,%0"::"r"(KERNELBASE):"memory"); | ||
51 | } | ||
52 | |||
53 | static void __devinit | ||
54 | smp_chrp_setup_cpu(int cpu_nr) | ||
55 | { | ||
56 | if (OpenPIC_Addr) | ||
57 | do_openpic_setup_cpu(); | ||
58 | } | ||
59 | |||
60 | static DEFINE_SPINLOCK(timebase_lock); | ||
61 | static unsigned int timebase_upper = 0, timebase_lower = 0; | ||
62 | |||
63 | void __devinit | ||
64 | smp_chrp_give_timebase(void) | ||
65 | { | ||
66 | spin_lock(&timebase_lock); | ||
67 | call_rtas("freeze-time-base", 0, 1, NULL); | ||
68 | timebase_upper = get_tbu(); | ||
69 | timebase_lower = get_tbl(); | ||
70 | spin_unlock(&timebase_lock); | ||
71 | |||
72 | while (timebase_upper || timebase_lower) | ||
73 | barrier(); | ||
74 | call_rtas("thaw-time-base", 0, 1, NULL); | ||
75 | } | ||
76 | |||
77 | void __devinit | ||
78 | smp_chrp_take_timebase(void) | ||
79 | { | ||
80 | while (!(timebase_upper || timebase_lower)) | ||
81 | barrier(); | ||
82 | spin_lock(&timebase_lock); | ||
83 | set_tb(timebase_upper, timebase_lower); | ||
84 | timebase_upper = 0; | ||
85 | timebase_lower = 0; | ||
86 | spin_unlock(&timebase_lock); | ||
87 | printk("CPU %i taken timebase\n", smp_processor_id()); | ||
88 | } | ||
89 | |||
90 | /* CHRP with openpic */ | ||
91 | struct smp_ops_t chrp_smp_ops __chrpdata = { | ||
92 | .message_pass = smp_openpic_message_pass, | ||
93 | .probe = smp_chrp_probe, | ||
94 | .kick_cpu = smp_chrp_kick_cpu, | ||
95 | .setup_cpu = smp_chrp_setup_cpu, | ||
96 | .give_timebase = smp_chrp_give_timebase, | ||
97 | .take_timebase = smp_chrp_take_timebase, | ||
98 | }; | ||