aboutsummaryrefslogtreecommitdiffstats
path: root/arch/powerpc/kernel/setup_32.c
diff options
context:
space:
mode:
authorPaul Mackerras <paulus@samba.org>2005-10-26 03:11:18 -0400
committerPaul Mackerras <paulus@samba.org>2005-10-26 03:11:18 -0400
commit03501dab035ab7da5e1373f5e130cfd6346d3f21 (patch)
tree53f8299442806612d8d2a73361b754063ce043fa /arch/powerpc/kernel/setup_32.c
parent033ef338b6e007dc081c6282a4f2a9dd761f8cd2 (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/kernel/setup_32.c')
-rw-r--r--arch/powerpc/kernel/setup_32.c249
1 files changed, 4 insertions, 245 deletions
diff --git a/arch/powerpc/kernel/setup_32.c b/arch/powerpc/kernel/setup_32.c
index c6a67c65852..295d5c77f02 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
111void machine_restart(char *cmd)
112{
113#ifdef CONFIG_NVRAM
114 nvram_sync();
115#endif
116 ppc_md.restart(cmd);
117}
118
119void machine_power_off(void)
120{
121#ifdef CONFIG_NVRAM
122 nvram_sync();
123#endif
124 ppc_md.power_off();
125}
126
127void machine_halt(void)
128{
129#ifdef CONFIG_NVRAM
130 nvram_sync();
131#endif
132 ppc_md.halt();
133}
134
135void (*pm_power_off)(void) = machine_power_off;
136
137#ifdef CONFIG_TAU
138extern u32 cpu_temp(unsigned long cpu);
139extern u32 cpu_temp_both(unsigned long cpu);
140#endif /* CONFIG_TAU */
141
142int 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
249static 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
256static void *c_next(struct seq_file *m, void *v, loff_t *pos)
257{
258 ++*pos;
259 return c_start(m, pos);
260}
261
262static void c_stop(struct seq_file *m, void *v)
263{
264}
265
266struct 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
301void __init
302intuit_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
367extern char *of_stdout_device;
368
369static 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}
420console_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 */