diff options
author | Paul Mackerras <paulus@samba.org> | 2005-10-26 03:11:18 -0400 |
---|---|---|
committer | Paul Mackerras <paulus@samba.org> | 2005-10-26 03:11:18 -0400 |
commit | 03501dab035ab7da5e1373f5e130cfd6346d3f21 (patch) | |
tree | 53f8299442806612d8d2a73361b754063ce043fa /arch/powerpc | |
parent | 033ef338b6e007dc081c6282a4f2a9dd761f8cd2 (diff) |
powerpc: Pull common bits of setup_{32,64}.c into setup-common.c
This creates a new arch/powerpc/kernel/setup-common.c with various
bits that setup_32.c and setup_64.c had in common - functions like
machine_shutdown/restart/power_off, show_cpuinfo, set_preferred_console
etc.
Signed-off-by: Paul Mackerras <paulus@samba.org>
Diffstat (limited to 'arch/powerpc')
-rw-r--r-- | arch/powerpc/kernel/Makefile | 2 | ||||
-rw-r--r-- | arch/powerpc/kernel/ppc_ksyms.c | 2 | ||||
-rw-r--r-- | arch/powerpc/kernel/setup-common.c | 412 | ||||
-rw-r--r-- | arch/powerpc/kernel/setup_32.c | 249 |
4 files changed, 417 insertions, 248 deletions
diff --git a/arch/powerpc/kernel/Makefile b/arch/powerpc/kernel/Makefile index eaedb7e63315..30101762f7c0 100644 --- a/arch/powerpc/kernel/Makefile +++ b/arch/powerpc/kernel/Makefile | |||
@@ -32,7 +32,7 @@ extra-$(CONFIG_PPC_FPU) += fpu.o | |||
32 | extra-y += vmlinux.lds | 32 | extra-y += vmlinux.lds |
33 | 33 | ||
34 | obj-y += process.o init_task.o time.o \ | 34 | obj-y += process.o init_task.o time.o \ |
35 | prom.o systbl.o traps.o | 35 | prom.o systbl.o traps.o setup-common.o |
36 | obj-$(CONFIG_PPC32) += entry_32.o idle_6xx.o setup_32.o misc_32.o | 36 | obj-$(CONFIG_PPC32) += entry_32.o idle_6xx.o setup_32.o misc_32.o |
37 | obj-$(CONFIG_PPC64) += setup_64.o misc_64.o | 37 | obj-$(CONFIG_PPC64) += setup_64.o misc_64.o |
38 | obj-$(CONFIG_PPC_OF) += prom_init.o | 38 | obj-$(CONFIG_PPC_OF) += prom_init.o |
diff --git a/arch/powerpc/kernel/ppc_ksyms.c b/arch/powerpc/kernel/ppc_ksyms.c index 254bf9c0b5bb..5f3a12bb8961 100644 --- a/arch/powerpc/kernel/ppc_ksyms.c +++ b/arch/powerpc/kernel/ppc_ksyms.c | |||
@@ -14,7 +14,6 @@ | |||
14 | #include <linux/pci.h> | 14 | #include <linux/pci.h> |
15 | #include <linux/delay.h> | 15 | #include <linux/delay.h> |
16 | #include <linux/ide.h> | 16 | #include <linux/ide.h> |
17 | #include <linux/pm.h> | ||
18 | #include <linux/bitops.h> | 17 | #include <linux/bitops.h> |
19 | 18 | ||
20 | #include <asm/page.h> | 19 | #include <asm/page.h> |
@@ -231,7 +230,6 @@ EXPORT_SYMBOL(screen_info); | |||
231 | #endif | 230 | #endif |
232 | 231 | ||
233 | #ifdef CONFIG_PPC32 | 232 | #ifdef CONFIG_PPC32 |
234 | EXPORT_SYMBOL(pm_power_off); | ||
235 | EXPORT_SYMBOL(__delay); | 233 | EXPORT_SYMBOL(__delay); |
236 | EXPORT_SYMBOL(timer_interrupt); | 234 | EXPORT_SYMBOL(timer_interrupt); |
237 | EXPORT_SYMBOL(irq_desc); | 235 | EXPORT_SYMBOL(irq_desc); |
diff --git a/arch/powerpc/kernel/setup-common.c b/arch/powerpc/kernel/setup-common.c new file mode 100644 index 000000000000..d4f0a4c3b5bc --- /dev/null +++ b/arch/powerpc/kernel/setup-common.c | |||
@@ -0,0 +1,412 @@ | |||
1 | /* | ||
2 | * Common boot and setup code for both 32-bit and 64-bit. | ||
3 | * Extracted from arch/powerpc/kernel/setup_64.c. | ||
4 | * | ||
5 | * Copyright (C) 2001 PPC64 Team, IBM Corp | ||
6 | * | ||
7 | * This program is free software; you can redistribute it and/or | ||
8 | * modify it under the terms of the GNU General Public License | ||
9 | * as published by the Free Software Foundation; either version | ||
10 | * 2 of the License, or (at your option) any later version. | ||
11 | */ | ||
12 | #include <linux/config.h> | ||
13 | #include <linux/module.h> | ||
14 | #include <linux/string.h> | ||
15 | #include <linux/sched.h> | ||
16 | #include <linux/init.h> | ||
17 | #include <linux/kernel.h> | ||
18 | #include <linux/reboot.h> | ||
19 | #include <linux/delay.h> | ||
20 | #include <linux/initrd.h> | ||
21 | #include <linux/ide.h> | ||
22 | #include <linux/seq_file.h> | ||
23 | #include <linux/ioport.h> | ||
24 | #include <linux/console.h> | ||
25 | #include <linux/utsname.h> | ||
26 | #include <linux/tty.h> | ||
27 | #include <linux/root_dev.h> | ||
28 | #include <linux/notifier.h> | ||
29 | #include <linux/cpu.h> | ||
30 | #include <linux/unistd.h> | ||
31 | #include <linux/serial.h> | ||
32 | #include <linux/serial_8250.h> | ||
33 | #include <asm/io.h> | ||
34 | #include <asm/prom.h> | ||
35 | #include <asm/processor.h> | ||
36 | #include <asm/pgtable.h> | ||
37 | #include <asm/bootinfo.h> | ||
38 | #include <asm/smp.h> | ||
39 | #include <asm/elf.h> | ||
40 | #include <asm/machdep.h> | ||
41 | #include <asm/time.h> | ||
42 | #include <asm/cputable.h> | ||
43 | #include <asm/sections.h> | ||
44 | #include <asm/btext.h> | ||
45 | #include <asm/nvram.h> | ||
46 | #include <asm/setup.h> | ||
47 | #include <asm/system.h> | ||
48 | #include <asm/rtas.h> | ||
49 | #include <asm/iommu.h> | ||
50 | #include <asm/serial.h> | ||
51 | #include <asm/cache.h> | ||
52 | #include <asm/page.h> | ||
53 | #include <asm/mmu.h> | ||
54 | #include <asm/lmb.h> | ||
55 | |||
56 | #undef DEBUG | ||
57 | |||
58 | #ifdef DEBUG | ||
59 | #define DBG(fmt...) udbg_printf(fmt) | ||
60 | #else | ||
61 | #define DBG(fmt...) | ||
62 | #endif | ||
63 | |||
64 | /* | ||
65 | * This still seems to be needed... -- paulus | ||
66 | */ | ||
67 | struct screen_info screen_info = { | ||
68 | .orig_x = 0, | ||
69 | .orig_y = 25, | ||
70 | .orig_video_cols = 80, | ||
71 | .orig_video_lines = 25, | ||
72 | .orig_video_isVGA = 1, | ||
73 | .orig_video_points = 16 | ||
74 | }; | ||
75 | |||
76 | #ifdef __DO_IRQ_CANON | ||
77 | /* XXX should go elsewhere eventually */ | ||
78 | int ppc_do_canonicalize_irqs; | ||
79 | EXPORT_SYMBOL(ppc_do_canonicalize_irqs); | ||
80 | #endif | ||
81 | |||
82 | /* also used by kexec */ | ||
83 | void machine_shutdown(void) | ||
84 | { | ||
85 | if (ppc_md.nvram_sync) | ||
86 | ppc_md.nvram_sync(); | ||
87 | } | ||
88 | |||
89 | void machine_restart(char *cmd) | ||
90 | { | ||
91 | machine_shutdown(); | ||
92 | ppc_md.restart(cmd); | ||
93 | #ifdef CONFIG_SMP | ||
94 | smp_send_stop(); | ||
95 | #endif | ||
96 | printk(KERN_EMERG "System Halted, OK to turn off power\n"); | ||
97 | local_irq_disable(); | ||
98 | while (1) ; | ||
99 | } | ||
100 | |||
101 | void machine_power_off(void) | ||
102 | { | ||
103 | machine_shutdown(); | ||
104 | ppc_md.power_off(); | ||
105 | #ifdef CONFIG_SMP | ||
106 | smp_send_stop(); | ||
107 | #endif | ||
108 | printk(KERN_EMERG "System Halted, OK to turn off power\n"); | ||
109 | local_irq_disable(); | ||
110 | while (1) ; | ||
111 | } | ||
112 | /* Used by the G5 thermal driver */ | ||
113 | EXPORT_SYMBOL_GPL(machine_power_off); | ||
114 | |||
115 | void (*pm_power_off)(void) = machine_power_off; | ||
116 | EXPORT_SYMBOL_GPL(pm_power_off); | ||
117 | |||
118 | void machine_halt(void) | ||
119 | { | ||
120 | machine_shutdown(); | ||
121 | ppc_md.halt(); | ||
122 | #ifdef CONFIG_SMP | ||
123 | smp_send_stop(); | ||
124 | #endif | ||
125 | printk(KERN_EMERG "System Halted, OK to turn off power\n"); | ||
126 | local_irq_disable(); | ||
127 | while (1) ; | ||
128 | } | ||
129 | |||
130 | |||
131 | #ifdef CONFIG_TAU | ||
132 | extern u32 cpu_temp(unsigned long cpu); | ||
133 | extern u32 cpu_temp_both(unsigned long cpu); | ||
134 | #endif /* CONFIG_TAU */ | ||
135 | |||
136 | #ifdef CONFIG_SMP | ||
137 | DEFINE_PER_CPU(unsigned int, pvr); | ||
138 | #endif | ||
139 | |||
140 | static int show_cpuinfo(struct seq_file *m, void *v) | ||
141 | { | ||
142 | unsigned long cpu_id = (unsigned long)v - 1; | ||
143 | unsigned int pvr; | ||
144 | unsigned short maj; | ||
145 | unsigned short min; | ||
146 | |||
147 | if (cpu_id == NR_CPUS) { | ||
148 | #if defined(CONFIG_SMP) && defined(CONFIG_PPC32) | ||
149 | unsigned long bogosum = 0; | ||
150 | int i; | ||
151 | for (i = 0; i < NR_CPUS; ++i) | ||
152 | if (cpu_online(i)) | ||
153 | bogosum += loops_per_jiffy; | ||
154 | seq_printf(m, "total bogomips\t: %lu.%02lu\n", | ||
155 | bogosum/(500000/HZ), bogosum/(5000/HZ) % 100); | ||
156 | #endif /* CONFIG_SMP && CONFIG_PPC32 */ | ||
157 | seq_printf(m, "timebase\t: %lu\n", ppc_tb_freq); | ||
158 | |||
159 | if (ppc_md.show_cpuinfo != NULL) | ||
160 | ppc_md.show_cpuinfo(m); | ||
161 | |||
162 | return 0; | ||
163 | } | ||
164 | |||
165 | /* We only show online cpus: disable preempt (overzealous, I | ||
166 | * knew) to prevent cpu going down. */ | ||
167 | preempt_disable(); | ||
168 | if (!cpu_online(cpu_id)) { | ||
169 | preempt_enable(); | ||
170 | return 0; | ||
171 | } | ||
172 | |||
173 | #ifdef CONFIG_SMP | ||
174 | #ifdef CONFIG_PPC64 /* XXX for now */ | ||
175 | pvr = per_cpu(pvr, cpu_id); | ||
176 | #else | ||
177 | pvr = cpu_data[cpu_id].pvr; | ||
178 | #endif | ||
179 | #else | ||
180 | pvr = mfspr(SPRN_PVR); | ||
181 | #endif | ||
182 | maj = (pvr >> 8) & 0xFF; | ||
183 | min = pvr & 0xFF; | ||
184 | |||
185 | seq_printf(m, "processor\t: %lu\n", cpu_id); | ||
186 | seq_printf(m, "cpu\t\t: "); | ||
187 | |||
188 | if (cur_cpu_spec->pvr_mask) | ||
189 | seq_printf(m, "%s", cur_cpu_spec->cpu_name); | ||
190 | else | ||
191 | seq_printf(m, "unknown (%08x)", pvr); | ||
192 | |||
193 | #ifdef CONFIG_ALTIVEC | ||
194 | if (cpu_has_feature(CPU_FTR_ALTIVEC)) | ||
195 | seq_printf(m, ", altivec supported"); | ||
196 | #endif /* CONFIG_ALTIVEC */ | ||
197 | |||
198 | seq_printf(m, "\n"); | ||
199 | |||
200 | #ifdef CONFIG_TAU | ||
201 | if (cur_cpu_spec->cpu_features & CPU_FTR_TAU) { | ||
202 | #ifdef CONFIG_TAU_AVERAGE | ||
203 | /* more straightforward, but potentially misleading */ | ||
204 | seq_printf(m, "temperature \t: %u C (uncalibrated)\n", | ||
205 | cpu_temp(i)); | ||
206 | #else | ||
207 | /* show the actual temp sensor range */ | ||
208 | u32 temp; | ||
209 | temp = cpu_temp_both(i); | ||
210 | seq_printf(m, "temperature \t: %u-%u C (uncalibrated)\n", | ||
211 | temp & 0xff, temp >> 16); | ||
212 | #endif | ||
213 | } | ||
214 | #endif /* CONFIG_TAU */ | ||
215 | |||
216 | /* | ||
217 | * Assume here that all clock rates are the same in a | ||
218 | * smp system. -- Cort | ||
219 | */ | ||
220 | if (ppc_proc_freq) | ||
221 | seq_printf(m, "clock\t\t: %lu.%06luMHz\n", | ||
222 | ppc_proc_freq / 1000000, ppc_proc_freq % 1000000); | ||
223 | |||
224 | if (ppc_md.show_percpuinfo != NULL) | ||
225 | ppc_md.show_percpuinfo(m, cpu_id); | ||
226 | |||
227 | /* If we are a Freescale core do a simple check so | ||
228 | * we dont have to keep adding cases in the future */ | ||
229 | if (PVR_VER(pvr) & 0x8000) { | ||
230 | maj = PVR_MAJ(pvr); | ||
231 | min = PVR_MIN(pvr); | ||
232 | } else { | ||
233 | switch (PVR_VER(pvr)) { | ||
234 | case 0x0020: /* 403 family */ | ||
235 | maj = PVR_MAJ(pvr) + 1; | ||
236 | min = PVR_MIN(pvr); | ||
237 | break; | ||
238 | case 0x1008: /* 740P/750P ?? */ | ||
239 | maj = ((pvr >> 8) & 0xFF) - 1; | ||
240 | min = pvr & 0xFF; | ||
241 | break; | ||
242 | default: | ||
243 | maj = (pvr >> 8) & 0xFF; | ||
244 | min = pvr & 0xFF; | ||
245 | break; | ||
246 | } | ||
247 | } | ||
248 | |||
249 | seq_printf(m, "revision\t: %hd.%hd (pvr %04x %04x)\n", | ||
250 | maj, min, PVR_VER(pvr), PVR_REV(pvr)); | ||
251 | |||
252 | #ifdef CONFIG_PPC32 | ||
253 | seq_printf(m, "bogomips\t: %lu.%02lu\n", | ||
254 | loops_per_jiffy / (500000/HZ), | ||
255 | (loops_per_jiffy / (5000/HZ)) % 100); | ||
256 | #endif | ||
257 | |||
258 | #ifdef CONFIG_SMP | ||
259 | seq_printf(m, "\n"); | ||
260 | #endif | ||
261 | |||
262 | preempt_enable(); | ||
263 | return 0; | ||
264 | } | ||
265 | |||
266 | static void *c_start(struct seq_file *m, loff_t *pos) | ||
267 | { | ||
268 | unsigned long i = *pos; | ||
269 | |||
270 | return i <= NR_CPUS ? (void *)(i + 1) : NULL; | ||
271 | } | ||
272 | |||
273 | static void *c_next(struct seq_file *m, void *v, loff_t *pos) | ||
274 | { | ||
275 | ++*pos; | ||
276 | return c_start(m, pos); | ||
277 | } | ||
278 | |||
279 | static void c_stop(struct seq_file *m, void *v) | ||
280 | { | ||
281 | } | ||
282 | |||
283 | struct seq_operations cpuinfo_op = { | ||
284 | .start =c_start, | ||
285 | .next = c_next, | ||
286 | .stop = c_stop, | ||
287 | .show = show_cpuinfo, | ||
288 | }; | ||
289 | |||
290 | #ifdef CONFIG_PPC_MULTIPLATFORM | ||
291 | static int __init set_preferred_console(void) | ||
292 | { | ||
293 | struct device_node *prom_stdout = NULL; | ||
294 | char *name; | ||
295 | u32 *spd; | ||
296 | int offset = 0; | ||
297 | |||
298 | DBG(" -> set_preferred_console()\n"); | ||
299 | |||
300 | /* The user has requested a console so this is already set up. */ | ||
301 | if (strstr(saved_command_line, "console=")) { | ||
302 | DBG(" console was specified !\n"); | ||
303 | return -EBUSY; | ||
304 | } | ||
305 | |||
306 | if (!of_chosen) { | ||
307 | DBG(" of_chosen is NULL !\n"); | ||
308 | return -ENODEV; | ||
309 | } | ||
310 | /* We are getting a weird phandle from OF ... */ | ||
311 | /* ... So use the full path instead */ | ||
312 | name = (char *)get_property(of_chosen, "linux,stdout-path", NULL); | ||
313 | if (name == NULL) { | ||
314 | DBG(" no linux,stdout-path !\n"); | ||
315 | return -ENODEV; | ||
316 | } | ||
317 | prom_stdout = of_find_node_by_path(name); | ||
318 | if (!prom_stdout) { | ||
319 | DBG(" can't find stdout package %s !\n", name); | ||
320 | return -ENODEV; | ||
321 | } | ||
322 | DBG("stdout is %s\n", prom_stdout->full_name); | ||
323 | |||
324 | name = (char *)get_property(prom_stdout, "name", NULL); | ||
325 | if (!name) { | ||
326 | DBG(" stdout package has no name !\n"); | ||
327 | goto not_found; | ||
328 | } | ||
329 | spd = (u32 *)get_property(prom_stdout, "current-speed", NULL); | ||
330 | |||
331 | if (0) | ||
332 | ; | ||
333 | #ifdef CONFIG_SERIAL_8250_CONSOLE | ||
334 | else if (strcmp(name, "serial") == 0) { | ||
335 | int i; | ||
336 | u32 *reg = (u32 *)get_property(prom_stdout, "reg", &i); | ||
337 | if (i > 8) { | ||
338 | switch (reg[1]) { | ||
339 | case 0x3f8: | ||
340 | offset = 0; | ||
341 | break; | ||
342 | case 0x2f8: | ||
343 | offset = 1; | ||
344 | break; | ||
345 | case 0x898: | ||
346 | offset = 2; | ||
347 | break; | ||
348 | case 0x890: | ||
349 | offset = 3; | ||
350 | break; | ||
351 | default: | ||
352 | /* We dont recognise the serial port */ | ||
353 | goto not_found; | ||
354 | } | ||
355 | } | ||
356 | } | ||
357 | #endif /* CONFIG_SERIAL_8250_CONSOLE */ | ||
358 | #ifdef CONFIG_PPC_PSERIES | ||
359 | else if (strcmp(name, "vty") == 0) { | ||
360 | u32 *reg = (u32 *)get_property(prom_stdout, "reg", NULL); | ||
361 | char *compat = (char *)get_property(prom_stdout, "compatible", NULL); | ||
362 | |||
363 | if (reg && compat && (strcmp(compat, "hvterm-protocol") == 0)) { | ||
364 | /* Host Virtual Serial Interface */ | ||
365 | int offset; | ||
366 | switch (reg[0]) { | ||
367 | case 0x30000000: | ||
368 | offset = 0; | ||
369 | break; | ||
370 | case 0x30000001: | ||
371 | offset = 1; | ||
372 | break; | ||
373 | default: | ||
374 | goto not_found; | ||
375 | } | ||
376 | of_node_put(prom_stdout); | ||
377 | DBG("Found hvsi console at offset %d\n", offset); | ||
378 | return add_preferred_console("hvsi", offset, NULL); | ||
379 | } else { | ||
380 | /* pSeries LPAR virtual console */ | ||
381 | of_node_put(prom_stdout); | ||
382 | DBG("Found hvc console\n"); | ||
383 | return add_preferred_console("hvc", 0, NULL); | ||
384 | } | ||
385 | } | ||
386 | #endif /* CONFIG_PPC_PSERIES */ | ||
387 | #ifdef CONFIG_SERIAL_PMACZILOG_CONSOLE | ||
388 | else if (strcmp(name, "ch-a") == 0) | ||
389 | offset = 0; | ||
390 | else if (strcmp(name, "ch-b") == 0) | ||
391 | offset = 1; | ||
392 | #endif /* CONFIG_SERIAL_PMACZILOG_CONSOLE */ | ||
393 | else | ||
394 | goto not_found; | ||
395 | of_node_put(prom_stdout); | ||
396 | |||
397 | DBG("Found serial console at ttyS%d\n", offset); | ||
398 | |||
399 | if (spd) { | ||
400 | static char __initdata opt[16]; | ||
401 | sprintf(opt, "%d", *spd); | ||
402 | return add_preferred_console("ttyS", offset, opt); | ||
403 | } else | ||
404 | return add_preferred_console("ttyS", offset, NULL); | ||
405 | |||
406 | not_found: | ||
407 | DBG("No preferred console found !\n"); | ||
408 | of_node_put(prom_stdout); | ||
409 | return -ENODEV; | ||
410 | } | ||
411 | console_initcall(set_preferred_console); | ||
412 | #endif /* CONFIG_PPC_MULTIPLATFORM */ | ||
diff --git a/arch/powerpc/kernel/setup_32.c b/arch/powerpc/kernel/setup_32.c index c6a67c65852a..295d5c77f020 100644 --- a/arch/powerpc/kernel/setup_32.c +++ b/arch/powerpc/kernel/setup_32.c | |||
@@ -41,6 +41,8 @@ | |||
41 | #include <asm/xmon.h> | 41 | #include <asm/xmon.h> |
42 | #include <asm/time.h> | 42 | #include <asm/time.h> |
43 | 43 | ||
44 | #define DBG(fmt...) | ||
45 | |||
44 | #if defined CONFIG_KGDB | 46 | #if defined CONFIG_KGDB |
45 | #include <asm/kgdb.h> | 47 | #include <asm/kgdb.h> |
46 | #endif | 48 | #endif |
@@ -108,168 +110,6 @@ struct screen_info screen_info = { | |||
108 | }; | 110 | }; |
109 | #endif /* CONFIG_VGA_CONSOLE || CONFIG_FB_VGA16 || CONFIG_FB_VESA */ | 111 | #endif /* CONFIG_VGA_CONSOLE || CONFIG_FB_VGA16 || CONFIG_FB_VESA */ |
110 | 112 | ||
111 | void machine_restart(char *cmd) | ||
112 | { | ||
113 | #ifdef CONFIG_NVRAM | ||
114 | nvram_sync(); | ||
115 | #endif | ||
116 | ppc_md.restart(cmd); | ||
117 | } | ||
118 | |||
119 | void machine_power_off(void) | ||
120 | { | ||
121 | #ifdef CONFIG_NVRAM | ||
122 | nvram_sync(); | ||
123 | #endif | ||
124 | ppc_md.power_off(); | ||
125 | } | ||
126 | |||
127 | void machine_halt(void) | ||
128 | { | ||
129 | #ifdef CONFIG_NVRAM | ||
130 | nvram_sync(); | ||
131 | #endif | ||
132 | ppc_md.halt(); | ||
133 | } | ||
134 | |||
135 | void (*pm_power_off)(void) = machine_power_off; | ||
136 | |||
137 | #ifdef CONFIG_TAU | ||
138 | extern u32 cpu_temp(unsigned long cpu); | ||
139 | extern u32 cpu_temp_both(unsigned long cpu); | ||
140 | #endif /* CONFIG_TAU */ | ||
141 | |||
142 | int show_cpuinfo(struct seq_file *m, void *v) | ||
143 | { | ||
144 | int i = (int) v - 1; | ||
145 | unsigned int pvr; | ||
146 | unsigned short maj, min; | ||
147 | unsigned long lpj; | ||
148 | |||
149 | if (i >= NR_CPUS) { | ||
150 | /* Show summary information */ | ||
151 | #ifdef CONFIG_SMP | ||
152 | unsigned long bogosum = 0; | ||
153 | for (i = 0; i < NR_CPUS; ++i) | ||
154 | if (cpu_online(i)) | ||
155 | bogosum += cpu_data[i].loops_per_jiffy; | ||
156 | seq_printf(m, "total bogomips\t: %lu.%02lu\n", | ||
157 | bogosum/(500000/HZ), bogosum/(5000/HZ) % 100); | ||
158 | #endif /* CONFIG_SMP */ | ||
159 | |||
160 | if (ppc_md.show_cpuinfo != NULL) | ||
161 | ppc_md.show_cpuinfo(m); | ||
162 | return 0; | ||
163 | } | ||
164 | |||
165 | #ifdef CONFIG_SMP | ||
166 | if (!cpu_online(i)) | ||
167 | return 0; | ||
168 | pvr = cpu_data[i].pvr; | ||
169 | lpj = cpu_data[i].loops_per_jiffy; | ||
170 | #else | ||
171 | pvr = mfspr(SPRN_PVR); | ||
172 | lpj = loops_per_jiffy; | ||
173 | #endif | ||
174 | |||
175 | seq_printf(m, "processor\t: %d\n", i); | ||
176 | seq_printf(m, "cpu\t\t: "); | ||
177 | |||
178 | if (cur_cpu_spec->pvr_mask) | ||
179 | seq_printf(m, "%s", cur_cpu_spec->cpu_name); | ||
180 | else | ||
181 | seq_printf(m, "unknown (%08x)", pvr); | ||
182 | #ifdef CONFIG_ALTIVEC | ||
183 | if (cur_cpu_spec->cpu_features & CPU_FTR_ALTIVEC) | ||
184 | seq_printf(m, ", altivec supported"); | ||
185 | #endif | ||
186 | seq_printf(m, "\n"); | ||
187 | |||
188 | #ifdef CONFIG_TAU | ||
189 | if (cur_cpu_spec->cpu_features & CPU_FTR_TAU) { | ||
190 | #ifdef CONFIG_TAU_AVERAGE | ||
191 | /* more straightforward, but potentially misleading */ | ||
192 | seq_printf(m, "temperature \t: %u C (uncalibrated)\n", | ||
193 | cpu_temp(i)); | ||
194 | #else | ||
195 | /* show the actual temp sensor range */ | ||
196 | u32 temp; | ||
197 | temp = cpu_temp_both(i); | ||
198 | seq_printf(m, "temperature \t: %u-%u C (uncalibrated)\n", | ||
199 | temp & 0xff, temp >> 16); | ||
200 | #endif | ||
201 | } | ||
202 | #endif /* CONFIG_TAU */ | ||
203 | |||
204 | if (ppc_md.show_percpuinfo != NULL) | ||
205 | ppc_md.show_percpuinfo(m, i); | ||
206 | |||
207 | /* If we are a Freescale core do a simple check so | ||
208 | * we dont have to keep adding cases in the future */ | ||
209 | if (PVR_VER(pvr) & 0x8000) { | ||
210 | maj = PVR_MAJ(pvr); | ||
211 | min = PVR_MIN(pvr); | ||
212 | } else { | ||
213 | switch (PVR_VER(pvr)) { | ||
214 | case 0x0020: /* 403 family */ | ||
215 | maj = PVR_MAJ(pvr) + 1; | ||
216 | min = PVR_MIN(pvr); | ||
217 | break; | ||
218 | case 0x1008: /* 740P/750P ?? */ | ||
219 | maj = ((pvr >> 8) & 0xFF) - 1; | ||
220 | min = pvr & 0xFF; | ||
221 | break; | ||
222 | default: | ||
223 | maj = (pvr >> 8) & 0xFF; | ||
224 | min = pvr & 0xFF; | ||
225 | break; | ||
226 | } | ||
227 | } | ||
228 | |||
229 | /* | ||
230 | * Assume here that all clock rates are the same in a | ||
231 | * smp system. -- Cort | ||
232 | */ | ||
233 | seq_printf(m, "clock\t\t: %lu.%06luMHz\n", ppc_proc_freq / 1000000, | ||
234 | ppc_proc_freq % 1000000); | ||
235 | |||
236 | seq_printf(m, "revision\t: %hd.%hd (pvr %04x %04x)\n", | ||
237 | maj, min, PVR_VER(pvr), PVR_REV(pvr)); | ||
238 | |||
239 | seq_printf(m, "bogomips\t: %lu.%02lu\n", | ||
240 | lpj / (500000/HZ), (lpj / (5000/HZ)) % 100); | ||
241 | |||
242 | #ifdef CONFIG_SMP | ||
243 | seq_printf(m, "\n"); | ||
244 | #endif | ||
245 | |||
246 | return 0; | ||
247 | } | ||
248 | |||
249 | static void *c_start(struct seq_file *m, loff_t *pos) | ||
250 | { | ||
251 | int i = *pos; | ||
252 | |||
253 | return i <= NR_CPUS? (void *) (i + 1): NULL; | ||
254 | } | ||
255 | |||
256 | static void *c_next(struct seq_file *m, void *v, loff_t *pos) | ||
257 | { | ||
258 | ++*pos; | ||
259 | return c_start(m, pos); | ||
260 | } | ||
261 | |||
262 | static void c_stop(struct seq_file *m, void *v) | ||
263 | { | ||
264 | } | ||
265 | |||
266 | struct seq_operations cpuinfo_op = { | ||
267 | .start =c_start, | ||
268 | .next = c_next, | ||
269 | .stop = c_stop, | ||
270 | .show = show_cpuinfo, | ||
271 | }; | ||
272 | |||
273 | /* | 113 | /* |
274 | * We're called here very early in the boot. We determine the machine | 114 | * We're called here very early in the boot. We determine the machine |
275 | * type and call the appropriate low-level setup functions. | 115 | * type and call the appropriate low-level setup functions. |
@@ -297,30 +137,6 @@ unsigned long __init early_init(unsigned long dt_ptr) | |||
297 | return KERNELBASE + offset; | 137 | return KERNELBASE + offset; |
298 | } | 138 | } |
299 | 139 | ||
300 | #ifdef CONFIG_PPC_OF | ||
301 | void __init | ||
302 | intuit_machine_type(void) | ||
303 | { | ||
304 | char *model; | ||
305 | struct device_node *root; | ||
306 | |||
307 | /* ask the OF info if we're a chrp or pmac */ | ||
308 | root = find_path_device("/"); | ||
309 | if (root != 0) { | ||
310 | /* assume pmac unless proven to be chrp -- Cort */ | ||
311 | _machine = _MACH_Pmac; | ||
312 | model = get_property(root, "device_type", NULL); | ||
313 | if (model && !strncmp("chrp", model, 4)) | ||
314 | _machine = _MACH_chrp; | ||
315 | else { | ||
316 | model = get_property(root, "model", NULL); | ||
317 | if (model && !strncmp(model, "IBM", 3)) | ||
318 | _machine = _MACH_chrp; | ||
319 | } | ||
320 | } | ||
321 | } | ||
322 | #endif | ||
323 | |||
324 | #ifdef CONFIG_PPC_MULTIPLATFORM | 140 | #ifdef CONFIG_PPC_MULTIPLATFORM |
325 | /* | 141 | /* |
326 | * The PPC_MULTIPLATFORM version of platform_init... | 142 | * The PPC_MULTIPLATFORM version of platform_init... |
@@ -362,64 +178,7 @@ void __init platform_init(void) | |||
362 | #endif | 178 | #endif |
363 | } | 179 | } |
364 | } | 180 | } |
365 | 181 | #endif | |
366 | #ifdef CONFIG_SERIAL_CORE_CONSOLE | ||
367 | extern char *of_stdout_device; | ||
368 | |||
369 | static int __init set_preferred_console(void) | ||
370 | { | ||
371 | struct device_node *prom_stdout; | ||
372 | char *name; | ||
373 | int offset = 0; | ||
374 | |||
375 | if (of_stdout_device == NULL) | ||
376 | return -ENODEV; | ||
377 | |||
378 | /* The user has requested a console so this is already set up. */ | ||
379 | if (strstr(saved_command_line, "console=")) | ||
380 | return -EBUSY; | ||
381 | |||
382 | prom_stdout = find_path_device(of_stdout_device); | ||
383 | if (!prom_stdout) | ||
384 | return -ENODEV; | ||
385 | |||
386 | name = (char *)get_property(prom_stdout, "name", NULL); | ||
387 | if (!name) | ||
388 | return -ENODEV; | ||
389 | |||
390 | if (strcmp(name, "serial") == 0) { | ||
391 | int i; | ||
392 | u32 *reg = (u32 *)get_property(prom_stdout, "reg", &i); | ||
393 | if (i > 8) { | ||
394 | switch (reg[1]) { | ||
395 | case 0x3f8: | ||
396 | offset = 0; | ||
397 | break; | ||
398 | case 0x2f8: | ||
399 | offset = 1; | ||
400 | break; | ||
401 | case 0x898: | ||
402 | offset = 2; | ||
403 | break; | ||
404 | case 0x890: | ||
405 | offset = 3; | ||
406 | break; | ||
407 | default: | ||
408 | /* We dont recognise the serial port */ | ||
409 | return -ENODEV; | ||
410 | } | ||
411 | } | ||
412 | } else if (strcmp(name, "ch-a") == 0) | ||
413 | offset = 0; | ||
414 | else if (strcmp(name, "ch-b") == 0) | ||
415 | offset = 1; | ||
416 | else | ||
417 | return -ENODEV; | ||
418 | return add_preferred_console("ttyS", offset, NULL); | ||
419 | } | ||
420 | console_initcall(set_preferred_console); | ||
421 | #endif /* CONFIG_SERIAL_CORE_CONSOLE */ | ||
422 | #endif /* CONFIG_PPC_MULTIPLATFORM */ | ||
423 | 182 | ||
424 | /* | 183 | /* |
425 | * Find out what kind of machine we're on and save any data we need | 184 | * Find out what kind of machine we're on and save any data we need |
@@ -545,7 +304,7 @@ void __init setup_arch(char **cmdline_p) | |||
545 | init_boot_display(); | 304 | init_boot_display(); |
546 | #endif | 305 | #endif |
547 | 306 | ||
548 | #ifdef CONFIG_PPC_MULTIPLATFORM | 307 | #ifdef CONFIG_PPC_PMAC |
549 | /* This could be called "early setup arch", it must be done | 308 | /* This could be called "early setup arch", it must be done |
550 | * now because xmon need it | 309 | * now because xmon need it |
551 | */ | 310 | */ |