diff options
Diffstat (limited to 'arch/powerpc/kernel/setup.c')
-rw-r--r-- | arch/powerpc/kernel/setup.c | 678 |
1 files changed, 678 insertions, 0 deletions
diff --git a/arch/powerpc/kernel/setup.c b/arch/powerpc/kernel/setup.c new file mode 100644 index 000000000000..27d7f828212b --- /dev/null +++ b/arch/powerpc/kernel/setup.c | |||
@@ -0,0 +1,678 @@ | |||
1 | /* | ||
2 | * Common prep/pmac/chrp boot and setup code. | ||
3 | */ | ||
4 | |||
5 | #include <linux/config.h> | ||
6 | #include <linux/module.h> | ||
7 | #include <linux/string.h> | ||
8 | #include <linux/sched.h> | ||
9 | #include <linux/init.h> | ||
10 | #include <linux/kernel.h> | ||
11 | #include <linux/reboot.h> | ||
12 | #include <linux/delay.h> | ||
13 | #include <linux/initrd.h> | ||
14 | #include <linux/ide.h> | ||
15 | #include <linux/tty.h> | ||
16 | #include <linux/bootmem.h> | ||
17 | #include <linux/seq_file.h> | ||
18 | #include <linux/root_dev.h> | ||
19 | #include <linux/cpu.h> | ||
20 | #include <linux/console.h> | ||
21 | |||
22 | #include <asm/residual.h> | ||
23 | #include <asm/io.h> | ||
24 | #include <asm/prom.h> | ||
25 | #include <asm/processor.h> | ||
26 | #include <asm/pgtable.h> | ||
27 | #include <asm/bootinfo.h> | ||
28 | #include <asm/setup.h> | ||
29 | #include <asm/amigappc.h> | ||
30 | #include <asm/smp.h> | ||
31 | #include <asm/elf.h> | ||
32 | #include <asm/cputable.h> | ||
33 | #include <asm/bootx.h> | ||
34 | #include <asm/btext.h> | ||
35 | #include <asm/machdep.h> | ||
36 | #include <asm/uaccess.h> | ||
37 | #include <asm/system.h> | ||
38 | #include <asm/pmac_feature.h> | ||
39 | #include <asm/sections.h> | ||
40 | #include <asm/nvram.h> | ||
41 | #include <asm/xmon.h> | ||
42 | #include <asm/ocp.h> | ||
43 | |||
44 | #define USES_PPC_SYS (defined(CONFIG_85xx) || defined(CONFIG_83xx) || \ | ||
45 | defined(CONFIG_MPC10X_BRIDGE) || defined(CONFIG_8260) || \ | ||
46 | defined(CONFIG_PPC_MPC52xx)) | ||
47 | |||
48 | #if USES_PPC_SYS | ||
49 | #include <asm/ppc_sys.h> | ||
50 | #endif | ||
51 | |||
52 | #if defined CONFIG_KGDB | ||
53 | #include <asm/kgdb.h> | ||
54 | #endif | ||
55 | |||
56 | extern void platform_init(void); | ||
57 | extern void bootx_init(unsigned long r4, unsigned long phys); | ||
58 | |||
59 | extern void ppc6xx_idle(void); | ||
60 | extern void power4_idle(void); | ||
61 | |||
62 | boot_infos_t *boot_infos; | ||
63 | struct ide_machdep_calls ppc_ide_md; | ||
64 | |||
65 | /* Used with the BI_MEMSIZE bootinfo parameter to store the memory | ||
66 | size value reported by the boot loader. */ | ||
67 | unsigned long boot_mem_size; | ||
68 | |||
69 | unsigned long ISA_DMA_THRESHOLD; | ||
70 | unsigned int DMA_MODE_READ; | ||
71 | unsigned int DMA_MODE_WRITE; | ||
72 | |||
73 | #ifdef CONFIG_PPC_MULTIPLATFORM | ||
74 | int _machine = 0; | ||
75 | |||
76 | extern void prep_init(void); | ||
77 | extern void pmac_init(void); | ||
78 | extern void chrp_init(void); | ||
79 | |||
80 | dev_t boot_dev; | ||
81 | #endif /* CONFIG_PPC_MULTIPLATFORM */ | ||
82 | |||
83 | #ifdef CONFIG_MAGIC_SYSRQ | ||
84 | unsigned long SYSRQ_KEY = 0x54; | ||
85 | #endif /* CONFIG_MAGIC_SYSRQ */ | ||
86 | |||
87 | #ifdef CONFIG_VGA_CONSOLE | ||
88 | unsigned long vgacon_remap_base; | ||
89 | #endif | ||
90 | |||
91 | struct machdep_calls ppc_md; | ||
92 | |||
93 | /* | ||
94 | * These are used in binfmt_elf.c to put aux entries on the stack | ||
95 | * for each elf executable being started. | ||
96 | */ | ||
97 | int dcache_bsize; | ||
98 | int icache_bsize; | ||
99 | int ucache_bsize; | ||
100 | |||
101 | #if defined(CONFIG_VGA_CONSOLE) || defined(CONFIG_FB_VGA16) || \ | ||
102 | defined(CONFIG_FB_VGA16_MODULE) || defined(CONFIG_FB_VESA) | ||
103 | struct screen_info screen_info = { | ||
104 | 0, 25, /* orig-x, orig-y */ | ||
105 | 0, /* unused */ | ||
106 | 0, /* orig-video-page */ | ||
107 | 0, /* orig-video-mode */ | ||
108 | 80, /* orig-video-cols */ | ||
109 | 0,0,0, /* ega_ax, ega_bx, ega_cx */ | ||
110 | 25, /* orig-video-lines */ | ||
111 | 1, /* orig-video-isVGA */ | ||
112 | 16 /* orig-video-points */ | ||
113 | }; | ||
114 | #endif /* CONFIG_VGA_CONSOLE || CONFIG_FB_VGA16 || CONFIG_FB_VESA */ | ||
115 | |||
116 | void machine_restart(char *cmd) | ||
117 | { | ||
118 | #ifdef CONFIG_NVRAM | ||
119 | nvram_sync(); | ||
120 | #endif | ||
121 | ppc_md.restart(cmd); | ||
122 | } | ||
123 | |||
124 | void machine_power_off(void) | ||
125 | { | ||
126 | #ifdef CONFIG_NVRAM | ||
127 | nvram_sync(); | ||
128 | #endif | ||
129 | ppc_md.power_off(); | ||
130 | } | ||
131 | |||
132 | void machine_halt(void) | ||
133 | { | ||
134 | #ifdef CONFIG_NVRAM | ||
135 | nvram_sync(); | ||
136 | #endif | ||
137 | ppc_md.halt(); | ||
138 | } | ||
139 | |||
140 | void (*pm_power_off)(void) = machine_power_off; | ||
141 | |||
142 | #ifdef CONFIG_TAU | ||
143 | extern u32 cpu_temp(unsigned long cpu); | ||
144 | extern u32 cpu_temp_both(unsigned long cpu); | ||
145 | #endif /* CONFIG_TAU */ | ||
146 | |||
147 | int show_cpuinfo(struct seq_file *m, void *v) | ||
148 | { | ||
149 | int i = (int) v - 1; | ||
150 | int err = 0; | ||
151 | unsigned int pvr; | ||
152 | unsigned short maj, min; | ||
153 | unsigned long lpj; | ||
154 | |||
155 | if (i >= NR_CPUS) { | ||
156 | /* Show summary information */ | ||
157 | #ifdef CONFIG_SMP | ||
158 | unsigned long bogosum = 0; | ||
159 | for (i = 0; i < NR_CPUS; ++i) | ||
160 | if (cpu_online(i)) | ||
161 | bogosum += cpu_data[i].loops_per_jiffy; | ||
162 | seq_printf(m, "total bogomips\t: %lu.%02lu\n", | ||
163 | bogosum/(500000/HZ), bogosum/(5000/HZ) % 100); | ||
164 | #endif /* CONFIG_SMP */ | ||
165 | |||
166 | if (ppc_md.show_cpuinfo != NULL) | ||
167 | err = ppc_md.show_cpuinfo(m); | ||
168 | return err; | ||
169 | } | ||
170 | |||
171 | #ifdef CONFIG_SMP | ||
172 | if (!cpu_online(i)) | ||
173 | return 0; | ||
174 | pvr = cpu_data[i].pvr; | ||
175 | lpj = cpu_data[i].loops_per_jiffy; | ||
176 | #else | ||
177 | pvr = mfspr(SPRN_PVR); | ||
178 | lpj = loops_per_jiffy; | ||
179 | #endif | ||
180 | |||
181 | seq_printf(m, "processor\t: %d\n", i); | ||
182 | seq_printf(m, "cpu\t\t: "); | ||
183 | |||
184 | if (cur_cpu_spec->pvr_mask) | ||
185 | seq_printf(m, "%s", cur_cpu_spec->cpu_name); | ||
186 | else | ||
187 | seq_printf(m, "unknown (%08x)", pvr); | ||
188 | #ifdef CONFIG_ALTIVEC | ||
189 | if (cur_cpu_spec->cpu_features & CPU_FTR_ALTIVEC) | ||
190 | seq_printf(m, ", altivec supported"); | ||
191 | #endif | ||
192 | seq_printf(m, "\n"); | ||
193 | |||
194 | #ifdef CONFIG_TAU | ||
195 | if (cur_cpu_spec->cpu_features & CPU_FTR_TAU) { | ||
196 | #ifdef CONFIG_TAU_AVERAGE | ||
197 | /* more straightforward, but potentially misleading */ | ||
198 | seq_printf(m, "temperature \t: %u C (uncalibrated)\n", | ||
199 | cpu_temp(i)); | ||
200 | #else | ||
201 | /* show the actual temp sensor range */ | ||
202 | u32 temp; | ||
203 | temp = cpu_temp_both(i); | ||
204 | seq_printf(m, "temperature \t: %u-%u C (uncalibrated)\n", | ||
205 | temp & 0xff, temp >> 16); | ||
206 | #endif | ||
207 | } | ||
208 | #endif /* CONFIG_TAU */ | ||
209 | |||
210 | if (ppc_md.show_percpuinfo != NULL) { | ||
211 | err = ppc_md.show_percpuinfo(m, i); | ||
212 | if (err) | ||
213 | return err; | ||
214 | } | ||
215 | |||
216 | /* If we are a Freescale core do a simple check so | ||
217 | * we dont have to keep adding cases in the future */ | ||
218 | if ((PVR_VER(pvr) & 0x8000) == 0x8000) { | ||
219 | maj = PVR_MAJ(pvr); | ||
220 | min = PVR_MIN(pvr); | ||
221 | } else { | ||
222 | switch (PVR_VER(pvr)) { | ||
223 | case 0x0020: /* 403 family */ | ||
224 | maj = PVR_MAJ(pvr) + 1; | ||
225 | min = PVR_MIN(pvr); | ||
226 | break; | ||
227 | case 0x1008: /* 740P/750P ?? */ | ||
228 | maj = ((pvr >> 8) & 0xFF) - 1; | ||
229 | min = pvr & 0xFF; | ||
230 | break; | ||
231 | default: | ||
232 | maj = (pvr >> 8) & 0xFF; | ||
233 | min = pvr & 0xFF; | ||
234 | break; | ||
235 | } | ||
236 | } | ||
237 | |||
238 | seq_printf(m, "revision\t: %hd.%hd (pvr %04x %04x)\n", | ||
239 | maj, min, PVR_VER(pvr), PVR_REV(pvr)); | ||
240 | |||
241 | seq_printf(m, "bogomips\t: %lu.%02lu\n", | ||
242 | lpj / (500000/HZ), (lpj / (5000/HZ)) % 100); | ||
243 | |||
244 | #if USES_PPC_SYS | ||
245 | if (cur_ppc_sys_spec->ppc_sys_name) | ||
246 | seq_printf(m, "chipset\t\t: %s\n", | ||
247 | cur_ppc_sys_spec->ppc_sys_name); | ||
248 | #endif | ||
249 | |||
250 | #ifdef CONFIG_SMP | ||
251 | seq_printf(m, "\n"); | ||
252 | #endif | ||
253 | |||
254 | return 0; | ||
255 | } | ||
256 | |||
257 | static void *c_start(struct seq_file *m, loff_t *pos) | ||
258 | { | ||
259 | int i = *pos; | ||
260 | |||
261 | return i <= NR_CPUS? (void *) (i + 1): NULL; | ||
262 | } | ||
263 | |||
264 | static void *c_next(struct seq_file *m, void *v, loff_t *pos) | ||
265 | { | ||
266 | ++*pos; | ||
267 | return c_start(m, pos); | ||
268 | } | ||
269 | |||
270 | static void c_stop(struct seq_file *m, void *v) | ||
271 | { | ||
272 | } | ||
273 | |||
274 | struct seq_operations cpuinfo_op = { | ||
275 | .start =c_start, | ||
276 | .next = c_next, | ||
277 | .stop = c_stop, | ||
278 | .show = show_cpuinfo, | ||
279 | }; | ||
280 | |||
281 | /* | ||
282 | * We're called here very early in the boot. We determine the machine | ||
283 | * type and call the appropriate low-level setup functions. | ||
284 | * -- Cort <cort@fsmlabs.com> | ||
285 | * | ||
286 | * Note that the kernel may be running at an address which is different | ||
287 | * from the address that it was linked at, so we must use RELOC/PTRRELOC | ||
288 | * to access static data (including strings). -- paulus | ||
289 | */ | ||
290 | unsigned long __init early_init(unsigned long dt_ptr) | ||
291 | { | ||
292 | unsigned long offset = reloc_offset(); | ||
293 | |||
294 | reloc_got2(offset); | ||
295 | |||
296 | /* | ||
297 | * Identify the CPU type and fix up code sections | ||
298 | * that depend on which cpu we have. | ||
299 | */ | ||
300 | identify_cpu(offset, 0); | ||
301 | do_cpu_ftr_fixups(offset); | ||
302 | |||
303 | #ifdef CONFIG_BOOTX_TEXT | ||
304 | btext_prepare_BAT(); | ||
305 | #endif | ||
306 | |||
307 | reloc_got2(-offset); | ||
308 | |||
309 | return KERNELBASE + offset; | ||
310 | } | ||
311 | |||
312 | #ifdef CONFIG_PPC_OF | ||
313 | /* | ||
314 | * Assume here that all clock rates are the same in a | ||
315 | * smp system. -- Cort | ||
316 | */ | ||
317 | int | ||
318 | of_show_percpuinfo(struct seq_file *m, int i) | ||
319 | { | ||
320 | struct device_node *cpu_node; | ||
321 | u32 *fp; | ||
322 | int s; | ||
323 | |||
324 | cpu_node = find_type_devices("cpu"); | ||
325 | if (!cpu_node) | ||
326 | return 0; | ||
327 | for (s = 0; s < i && cpu_node->next; s++) | ||
328 | cpu_node = cpu_node->next; | ||
329 | fp = (u32 *)get_property(cpu_node, "clock-frequency", NULL); | ||
330 | if (fp) | ||
331 | seq_printf(m, "clock\t\t: %dMHz\n", *fp / 1000000); | ||
332 | return 0; | ||
333 | } | ||
334 | |||
335 | void __init | ||
336 | intuit_machine_type(void) | ||
337 | { | ||
338 | char *model; | ||
339 | struct device_node *root; | ||
340 | |||
341 | /* ask the OF info if we're a chrp or pmac */ | ||
342 | root = find_path_device("/"); | ||
343 | if (root != 0) { | ||
344 | /* assume pmac unless proven to be chrp -- Cort */ | ||
345 | _machine = _MACH_Pmac; | ||
346 | model = get_property(root, "device_type", NULL); | ||
347 | if (model && !strncmp("chrp", model, 4)) | ||
348 | _machine = _MACH_chrp; | ||
349 | else { | ||
350 | model = get_property(root, "model", NULL); | ||
351 | if (model && !strncmp(model, "IBM", 3)) | ||
352 | _machine = _MACH_chrp; | ||
353 | } | ||
354 | } | ||
355 | } | ||
356 | #endif | ||
357 | |||
358 | #ifdef CONFIG_PPC_MULTIPLATFORM | ||
359 | /* | ||
360 | * The PPC_MULTIPLATFORM version of platform_init... | ||
361 | */ | ||
362 | void __init platform_init(void) | ||
363 | { | ||
364 | /* if we didn't get any bootinfo telling us what we are... */ | ||
365 | if (_machine == 0) { | ||
366 | /* prep boot loader tells us if we're prep or not */ | ||
367 | if ( *(unsigned long *)(KERNELBASE) == (0xdeadc0de) ) | ||
368 | _machine = _MACH_prep; | ||
369 | } | ||
370 | |||
371 | #ifdef CONFIG_PPC_PREP | ||
372 | /* not much more to do here, if prep */ | ||
373 | if (_machine == _MACH_prep) { | ||
374 | prep_init(); | ||
375 | return; | ||
376 | } | ||
377 | #endif | ||
378 | |||
379 | #ifdef CONFIG_ADB | ||
380 | if (strstr(cmd_line, "adb_sync")) { | ||
381 | extern int __adb_probe_sync; | ||
382 | __adb_probe_sync = 1; | ||
383 | } | ||
384 | #endif /* CONFIG_ADB */ | ||
385 | |||
386 | switch (_machine) { | ||
387 | #ifdef CONFIG_PPC_PMAC | ||
388 | case _MACH_Pmac: | ||
389 | pmac_init(); | ||
390 | break; | ||
391 | #endif | ||
392 | #ifdef CONFIG_PPC_CHRP | ||
393 | case _MACH_chrp: | ||
394 | chrp_init(); | ||
395 | break; | ||
396 | #endif | ||
397 | } | ||
398 | } | ||
399 | |||
400 | #ifdef CONFIG_SERIAL_CORE_CONSOLE | ||
401 | extern char *of_stdout_device; | ||
402 | |||
403 | static int __init set_preferred_console(void) | ||
404 | { | ||
405 | struct device_node *prom_stdout; | ||
406 | char *name; | ||
407 | int offset = 0; | ||
408 | |||
409 | if (of_stdout_device == NULL) | ||
410 | return -ENODEV; | ||
411 | |||
412 | /* The user has requested a console so this is already set up. */ | ||
413 | if (strstr(saved_command_line, "console=")) | ||
414 | return -EBUSY; | ||
415 | |||
416 | prom_stdout = find_path_device(of_stdout_device); | ||
417 | if (!prom_stdout) | ||
418 | return -ENODEV; | ||
419 | |||
420 | name = (char *)get_property(prom_stdout, "name", NULL); | ||
421 | if (!name) | ||
422 | return -ENODEV; | ||
423 | |||
424 | if (strcmp(name, "serial") == 0) { | ||
425 | int i; | ||
426 | u32 *reg = (u32 *)get_property(prom_stdout, "reg", &i); | ||
427 | if (i > 8) { | ||
428 | switch (reg[1]) { | ||
429 | case 0x3f8: | ||
430 | offset = 0; | ||
431 | break; | ||
432 | case 0x2f8: | ||
433 | offset = 1; | ||
434 | break; | ||
435 | case 0x898: | ||
436 | offset = 2; | ||
437 | break; | ||
438 | case 0x890: | ||
439 | offset = 3; | ||
440 | break; | ||
441 | default: | ||
442 | /* We dont recognise the serial port */ | ||
443 | return -ENODEV; | ||
444 | } | ||
445 | } | ||
446 | } else if (strcmp(name, "ch-a") == 0) | ||
447 | offset = 0; | ||
448 | else if (strcmp(name, "ch-b") == 0) | ||
449 | offset = 1; | ||
450 | else | ||
451 | return -ENODEV; | ||
452 | return add_preferred_console("ttyS", offset, NULL); | ||
453 | } | ||
454 | console_initcall(set_preferred_console); | ||
455 | #endif /* CONFIG_SERIAL_CORE_CONSOLE */ | ||
456 | #endif /* CONFIG_PPC_MULTIPLATFORM */ | ||
457 | |||
458 | struct bi_record *find_bootinfo(void) | ||
459 | { | ||
460 | struct bi_record *rec; | ||
461 | |||
462 | rec = (struct bi_record *)_ALIGN((ulong)__bss_start+(1<<20)-1,(1<<20)); | ||
463 | if ( rec->tag != BI_FIRST ) { | ||
464 | /* | ||
465 | * This 0x10000 offset is a terrible hack but it will go away when | ||
466 | * we have the bootloader handle all the relocation and | ||
467 | * prom calls -- Cort | ||
468 | */ | ||
469 | rec = (struct bi_record *)_ALIGN((ulong)__bss_start+0x10000+(1<<20)-1,(1<<20)); | ||
470 | if ( rec->tag != BI_FIRST ) | ||
471 | return NULL; | ||
472 | } | ||
473 | return rec; | ||
474 | } | ||
475 | |||
476 | /* | ||
477 | * Find out what kind of machine we're on and save any data we need | ||
478 | * from the early boot process (devtree is copied on pmac by prom_init()). | ||
479 | * This is called very early on the boot process, after a minimal | ||
480 | * MMU environment has been set up but before MMU_init is called. | ||
481 | */ | ||
482 | void __init machine_init(unsigned long dt_ptr, unsigned long phys) | ||
483 | { | ||
484 | early_init_devtree(__va(dt_ptr)); | ||
485 | |||
486 | #ifdef CONFIG_CMDLINE | ||
487 | strlcpy(cmd_line, CONFIG_CMDLINE, sizeof(cmd_line)); | ||
488 | #endif /* CONFIG_CMDLINE */ | ||
489 | |||
490 | #ifdef CONFIG_6xx | ||
491 | ppc_md.power_save = ppc6xx_idle; | ||
492 | #endif | ||
493 | #ifdef CONFIG_POWER4 | ||
494 | ppc_md.power_save = power4_idle; | ||
495 | #endif | ||
496 | |||
497 | platform_init(); | ||
498 | |||
499 | if (ppc_md.progress) | ||
500 | ppc_md.progress("id mach(): done", 0x200); | ||
501 | } | ||
502 | |||
503 | #ifdef CONFIG_BOOKE_WDT | ||
504 | /* Checks wdt=x and wdt_period=xx command-line option */ | ||
505 | int __init early_parse_wdt(char *p) | ||
506 | { | ||
507 | if (p && strncmp(p, "0", 1) != 0) | ||
508 | booke_wdt_enabled = 1; | ||
509 | |||
510 | return 0; | ||
511 | } | ||
512 | early_param("wdt", early_parse_wdt); | ||
513 | |||
514 | int __init early_parse_wdt_period (char *p) | ||
515 | { | ||
516 | if (p) | ||
517 | booke_wdt_period = simple_strtoul(p, NULL, 0); | ||
518 | |||
519 | return 0; | ||
520 | } | ||
521 | early_param("wdt_period", early_parse_wdt_period); | ||
522 | #endif /* CONFIG_BOOKE_WDT */ | ||
523 | |||
524 | /* Checks "l2cr=xxxx" command-line option */ | ||
525 | int __init ppc_setup_l2cr(char *str) | ||
526 | { | ||
527 | if (cpu_has_feature(CPU_FTR_L2CR)) { | ||
528 | unsigned long val = simple_strtoul(str, NULL, 0); | ||
529 | printk(KERN_INFO "l2cr set to %lx\n", val); | ||
530 | _set_L2CR(0); /* force invalidate by disable cache */ | ||
531 | _set_L2CR(val); /* and enable it */ | ||
532 | } | ||
533 | return 1; | ||
534 | } | ||
535 | __setup("l2cr=", ppc_setup_l2cr); | ||
536 | |||
537 | #ifdef CONFIG_GENERIC_NVRAM | ||
538 | |||
539 | /* Generic nvram hooks used by drivers/char/gen_nvram.c */ | ||
540 | unsigned char nvram_read_byte(int addr) | ||
541 | { | ||
542 | if (ppc_md.nvram_read_val) | ||
543 | return ppc_md.nvram_read_val(addr); | ||
544 | return 0xff; | ||
545 | } | ||
546 | EXPORT_SYMBOL(nvram_read_byte); | ||
547 | |||
548 | void nvram_write_byte(unsigned char val, int addr) | ||
549 | { | ||
550 | if (ppc_md.nvram_write_val) | ||
551 | ppc_md.nvram_write_val(addr, val); | ||
552 | } | ||
553 | EXPORT_SYMBOL(nvram_write_byte); | ||
554 | |||
555 | void nvram_sync(void) | ||
556 | { | ||
557 | if (ppc_md.nvram_sync) | ||
558 | ppc_md.nvram_sync(); | ||
559 | } | ||
560 | EXPORT_SYMBOL(nvram_sync); | ||
561 | |||
562 | #endif /* CONFIG_NVRAM */ | ||
563 | |||
564 | static struct cpu cpu_devices[NR_CPUS]; | ||
565 | |||
566 | int __init ppc_init(void) | ||
567 | { | ||
568 | int i; | ||
569 | |||
570 | /* clear the progress line */ | ||
571 | if ( ppc_md.progress ) ppc_md.progress(" ", 0xffff); | ||
572 | |||
573 | /* register CPU devices */ | ||
574 | for (i = 0; i < NR_CPUS; i++) | ||
575 | if (cpu_possible(i)) | ||
576 | register_cpu(&cpu_devices[i], i, NULL); | ||
577 | |||
578 | /* call platform init */ | ||
579 | if (ppc_md.init != NULL) { | ||
580 | ppc_md.init(); | ||
581 | } | ||
582 | return 0; | ||
583 | } | ||
584 | |||
585 | arch_initcall(ppc_init); | ||
586 | |||
587 | /* Warning, IO base is not yet inited */ | ||
588 | void __init setup_arch(char **cmdline_p) | ||
589 | { | ||
590 | extern char *klimit; | ||
591 | extern void do_init_bootmem(void); | ||
592 | |||
593 | /* so udelay does something sensible, assume <= 1000 bogomips */ | ||
594 | loops_per_jiffy = 500000000 / HZ; | ||
595 | |||
596 | #ifdef CONFIG_BOOTX_TEXT | ||
597 | map_boot_text(); | ||
598 | #endif | ||
599 | |||
600 | unflatten_device_tree(); | ||
601 | finish_device_tree(); | ||
602 | |||
603 | #ifdef CONFIG_PPC_MULTIPLATFORM | ||
604 | /* This could be called "early setup arch", it must be done | ||
605 | * now because xmon need it | ||
606 | */ | ||
607 | if (_machine == _MACH_Pmac) | ||
608 | pmac_feature_init(); /* New cool way */ | ||
609 | #endif | ||
610 | |||
611 | #ifdef CONFIG_XMON | ||
612 | xmon_map_scc(); | ||
613 | if (strstr(cmd_line, "xmon")) | ||
614 | xmon(NULL); | ||
615 | #endif /* CONFIG_XMON */ | ||
616 | if ( ppc_md.progress ) ppc_md.progress("setup_arch: enter", 0x3eab); | ||
617 | |||
618 | #if defined(CONFIG_KGDB) | ||
619 | if (ppc_md.kgdb_map_scc) | ||
620 | ppc_md.kgdb_map_scc(); | ||
621 | set_debug_traps(); | ||
622 | if (strstr(cmd_line, "gdb")) { | ||
623 | if (ppc_md.progress) | ||
624 | ppc_md.progress("setup_arch: kgdb breakpoint", 0x4000); | ||
625 | printk("kgdb breakpoint activated\n"); | ||
626 | breakpoint(); | ||
627 | } | ||
628 | #endif | ||
629 | |||
630 | /* | ||
631 | * Set cache line size based on type of cpu as a default. | ||
632 | * Systems with OF can look in the properties on the cpu node(s) | ||
633 | * for a possibly more accurate value. | ||
634 | */ | ||
635 | if (cpu_has_feature(CPU_FTR_SPLIT_ID_CACHE)) { | ||
636 | dcache_bsize = cur_cpu_spec->dcache_bsize; | ||
637 | icache_bsize = cur_cpu_spec->icache_bsize; | ||
638 | ucache_bsize = 0; | ||
639 | } else | ||
640 | ucache_bsize = dcache_bsize = icache_bsize | ||
641 | = cur_cpu_spec->dcache_bsize; | ||
642 | |||
643 | /* reboot on panic */ | ||
644 | panic_timeout = 180; | ||
645 | |||
646 | init_mm.start_code = PAGE_OFFSET; | ||
647 | init_mm.end_code = (unsigned long) _etext; | ||
648 | init_mm.end_data = (unsigned long) _edata; | ||
649 | init_mm.brk = (unsigned long) klimit; | ||
650 | |||
651 | /* Save unparsed command line copy for /proc/cmdline */ | ||
652 | strlcpy(saved_command_line, cmd_line, COMMAND_LINE_SIZE); | ||
653 | *cmdline_p = cmd_line; | ||
654 | |||
655 | parse_early_param(); | ||
656 | |||
657 | /* set up the bootmem stuff with available memory */ | ||
658 | do_init_bootmem(); | ||
659 | if ( ppc_md.progress ) ppc_md.progress("setup_arch: bootmem", 0x3eab); | ||
660 | |||
661 | #ifdef CONFIG_PPC_OCP | ||
662 | /* Initialize OCP device list */ | ||
663 | ocp_early_init(); | ||
664 | if ( ppc_md.progress ) ppc_md.progress("ocp: exit", 0x3eab); | ||
665 | #endif | ||
666 | |||
667 | #ifdef CONFIG_DUMMY_CONSOLE | ||
668 | conswitchp = &dummy_con; | ||
669 | #endif | ||
670 | |||
671 | ppc_md.setup_arch(); | ||
672 | if ( ppc_md.progress ) ppc_md.progress("arch: exit", 0x3eab); | ||
673 | |||
674 | paging_init(); | ||
675 | |||
676 | /* this is for modules since _machine can be a define -- Cort */ | ||
677 | ppc_md.ppc_machine = _machine; | ||
678 | } | ||