diff options
Diffstat (limited to 'arch/ppc/kernel/setup.c')
-rw-r--r-- | arch/ppc/kernel/setup.c | 254 |
1 files changed, 7 insertions, 247 deletions
diff --git a/arch/ppc/kernel/setup.c b/arch/ppc/kernel/setup.c index 53e9deacee82..7eb91a2e818a 100644 --- a/arch/ppc/kernel/setup.c +++ b/arch/ppc/kernel/setup.c | |||
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | * Common prep/chrp boot and setup code. | 2 | * Common prep boot and setup code. |
3 | */ | 3 | */ |
4 | 4 | ||
5 | #include <linux/config.h> | 5 | #include <linux/config.h> |
@@ -72,17 +72,12 @@ unsigned long ISA_DMA_THRESHOLD; | |||
72 | unsigned int DMA_MODE_READ; | 72 | unsigned int DMA_MODE_READ; |
73 | unsigned int DMA_MODE_WRITE; | 73 | unsigned int DMA_MODE_WRITE; |
74 | 74 | ||
75 | #ifdef CONFIG_PPC_MULTIPLATFORM | 75 | #ifdef CONFIG_PPC_PREP |
76 | int _machine = 0; | ||
77 | EXPORT_SYMBOL(_machine); | ||
78 | |||
79 | extern void prep_init(unsigned long r3, unsigned long r4, | 76 | extern void prep_init(unsigned long r3, unsigned long r4, |
80 | unsigned long r5, unsigned long r6, unsigned long r7); | 77 | unsigned long r5, unsigned long r6, unsigned long r7); |
81 | extern void chrp_init(unsigned long r3, unsigned long r4, | ||
82 | unsigned long r5, unsigned long r6, unsigned long r7); | ||
83 | 78 | ||
84 | dev_t boot_dev; | 79 | dev_t boot_dev; |
85 | #endif /* CONFIG_PPC_MULTIPLATFORM */ | 80 | #endif /* CONFIG_PPC_PREP */ |
86 | 81 | ||
87 | int have_of; | 82 | int have_of; |
88 | EXPORT_SYMBOL(have_of); | 83 | EXPORT_SYMBOL(have_of); |
@@ -319,72 +314,12 @@ early_init(int r3, int r4, int r5) | |||
319 | identify_cpu(offset, 0); | 314 | identify_cpu(offset, 0); |
320 | do_cpu_ftr_fixups(offset); | 315 | do_cpu_ftr_fixups(offset); |
321 | 316 | ||
322 | #if defined(CONFIG_PPC_OF) | ||
323 | reloc_got2(offset); | ||
324 | |||
325 | /* | ||
326 | * don't do anything on prep | ||
327 | * for now, don't use bootinfo because it breaks yaboot 0.5 | ||
328 | * and assume that if we didn't find a magic number, we have OF | ||
329 | */ | ||
330 | if (*(unsigned long *)(0) != 0xdeadc0de) | ||
331 | phys = prom_init(r3, r4, (prom_entry)r5); | ||
332 | |||
333 | reloc_got2(-offset); | ||
334 | #endif | ||
335 | |||
336 | return phys; | 317 | return phys; |
337 | } | 318 | } |
338 | 319 | ||
339 | #ifdef CONFIG_PPC_OF | 320 | #ifdef CONFIG_PPC_PREP |
340 | /* | ||
341 | * Assume here that all clock rates are the same in a | ||
342 | * smp system. -- Cort | ||
343 | */ | ||
344 | int | ||
345 | of_show_percpuinfo(struct seq_file *m, int i) | ||
346 | { | ||
347 | struct device_node *cpu_node; | ||
348 | u32 *fp; | ||
349 | int s; | ||
350 | |||
351 | cpu_node = find_type_devices("cpu"); | ||
352 | if (!cpu_node) | ||
353 | return 0; | ||
354 | for (s = 0; s < i && cpu_node->next; s++) | ||
355 | cpu_node = cpu_node->next; | ||
356 | fp = (u32 *)get_property(cpu_node, "clock-frequency", NULL); | ||
357 | if (fp) | ||
358 | seq_printf(m, "clock\t\t: %dMHz\n", *fp / 1000000); | ||
359 | return 0; | ||
360 | } | ||
361 | |||
362 | void __init | ||
363 | intuit_machine_type(void) | ||
364 | { | ||
365 | char *model; | ||
366 | struct device_node *root; | ||
367 | |||
368 | /* ask the OF info if we're a chrp or pmac */ | ||
369 | root = find_path_device("/"); | ||
370 | if (root != 0) { | ||
371 | /* assume pmac unless proven to be chrp -- Cort */ | ||
372 | _machine = _MACH_Pmac; | ||
373 | model = get_property(root, "device_type", NULL); | ||
374 | if (model && !strncmp("chrp", model, 4)) | ||
375 | _machine = _MACH_chrp; | ||
376 | else { | ||
377 | model = get_property(root, "model", NULL); | ||
378 | if (model && !strncmp(model, "IBM", 3)) | ||
379 | _machine = _MACH_chrp; | ||
380 | } | ||
381 | } | ||
382 | } | ||
383 | #endif | ||
384 | |||
385 | #ifdef CONFIG_PPC_MULTIPLATFORM | ||
386 | /* | 321 | /* |
387 | * The PPC_MULTIPLATFORM version of platform_init... | 322 | * The PPC_PREP version of platform_init... |
388 | */ | 323 | */ |
389 | void __init | 324 | void __init |
390 | platform_init(unsigned long r3, unsigned long r4, unsigned long r5, | 325 | platform_init(unsigned long r3, unsigned long r4, unsigned long r5, |
@@ -399,161 +334,9 @@ platform_init(unsigned long r3, unsigned long r4, unsigned long r5, | |||
399 | 334 | ||
400 | parse_bootinfo(find_bootinfo()); | 335 | parse_bootinfo(find_bootinfo()); |
401 | 336 | ||
402 | /* if we didn't get any bootinfo telling us what we are... */ | 337 | prep_init(r3, r4, r5, r6, r7); |
403 | if (_machine == 0) { | ||
404 | /* prep boot loader tells us if we're prep or not */ | ||
405 | if ( *(unsigned long *)(KERNELBASE) == (0xdeadc0de) ) | ||
406 | _machine = _MACH_prep; | ||
407 | } | ||
408 | |||
409 | #ifdef CONFIG_PPC_PREP | ||
410 | /* not much more to do here, if prep */ | ||
411 | if (_machine == _MACH_prep) { | ||
412 | prep_init(r3, r4, r5, r6, r7); | ||
413 | return; | ||
414 | } | ||
415 | #endif | ||
416 | |||
417 | #ifdef CONFIG_PPC_OF | ||
418 | have_of = 1; | ||
419 | |||
420 | /* prom_init has already been called from __start */ | ||
421 | if (boot_infos) | ||
422 | relocate_nodes(); | ||
423 | |||
424 | /* If we aren't PReP, we can find out if we're Pmac | ||
425 | * or CHRP with this. */ | ||
426 | if (_machine == 0) | ||
427 | intuit_machine_type(); | ||
428 | |||
429 | /* finish_device_tree may need _machine defined. */ | ||
430 | finish_device_tree(); | ||
431 | |||
432 | /* | ||
433 | * If we were booted via quik, r3 points to the physical | ||
434 | * address of the command-line parameters. | ||
435 | * If we were booted from an xcoff image (i.e. netbooted or | ||
436 | * booted from floppy), we get the command line from the | ||
437 | * bootargs property of the /chosen node. | ||
438 | * If an initial ramdisk is present, r3 and r4 | ||
439 | * are used for initrd_start and initrd_size, | ||
440 | * otherwise they contain 0xdeadbeef. | ||
441 | */ | ||
442 | if (r3 >= 0x4000 && r3 < 0x800000 && r4 == 0) { | ||
443 | strlcpy(cmd_line, (char *)r3 + KERNELBASE, | ||
444 | sizeof(cmd_line)); | ||
445 | } else if (boot_infos != 0) { | ||
446 | /* booted by BootX - check for ramdisk */ | ||
447 | if (boot_infos->kernelParamsOffset != 0) | ||
448 | strlcpy(cmd_line, (char *) boot_infos | ||
449 | + boot_infos->kernelParamsOffset, | ||
450 | sizeof(cmd_line)); | ||
451 | #ifdef CONFIG_BLK_DEV_INITRD | ||
452 | if (boot_infos->ramDisk) { | ||
453 | initrd_start = (unsigned long) boot_infos | ||
454 | + boot_infos->ramDisk; | ||
455 | initrd_end = initrd_start + boot_infos->ramDiskSize; | ||
456 | initrd_below_start_ok = 1; | ||
457 | } | ||
458 | #endif | ||
459 | } else { | ||
460 | struct device_node *chosen; | ||
461 | char *p; | ||
462 | |||
463 | #ifdef CONFIG_BLK_DEV_INITRD | ||
464 | if (r3 && r4 && r4 != 0xdeadbeef) { | ||
465 | if (r3 < KERNELBASE) | ||
466 | r3 += KERNELBASE; | ||
467 | initrd_start = r3; | ||
468 | initrd_end = r3 + r4; | ||
469 | ROOT_DEV = Root_RAM0; | ||
470 | initrd_below_start_ok = 1; | ||
471 | } | ||
472 | #endif | ||
473 | chosen = find_devices("chosen"); | ||
474 | if (chosen != NULL) { | ||
475 | p = get_property(chosen, "bootargs", NULL); | ||
476 | if (p && *p) { | ||
477 | strlcpy(cmd_line, p, sizeof(cmd_line)); | ||
478 | } | ||
479 | } | ||
480 | } | ||
481 | #ifdef CONFIG_ADB | ||
482 | if (strstr(cmd_line, "adb_sync")) { | ||
483 | extern int __adb_probe_sync; | ||
484 | __adb_probe_sync = 1; | ||
485 | } | ||
486 | #endif /* CONFIG_ADB */ | ||
487 | |||
488 | switch (_machine) { | ||
489 | #ifdef CONFIG_PPC_CHRP | ||
490 | case _MACH_chrp: | ||
491 | chrp_init(r3, r4, r5, r6, r7); | ||
492 | break; | ||
493 | #endif | ||
494 | } | ||
495 | #endif /* CONFIG_PPC_OF */ | ||
496 | } | 338 | } |
497 | #endif /* CONFIG_PPC_MULTIPLATFORM */ | 339 | #endif /* CONFIG_PPC_PREP */ |
498 | |||
499 | #ifdef CONFIG_PPC_OF | ||
500 | #ifdef CONFIG_SERIAL_CORE_CONSOLE | ||
501 | extern char *of_stdout_device; | ||
502 | |||
503 | static int __init set_preferred_console(void) | ||
504 | { | ||
505 | struct device_node *prom_stdout; | ||
506 | char *name; | ||
507 | int offset = 0; | ||
508 | |||
509 | if (of_stdout_device == NULL) | ||
510 | return -ENODEV; | ||
511 | |||
512 | /* The user has requested a console so this is already set up. */ | ||
513 | if (strstr(saved_command_line, "console=")) | ||
514 | return -EBUSY; | ||
515 | |||
516 | prom_stdout = find_path_device(of_stdout_device); | ||
517 | if (!prom_stdout) | ||
518 | return -ENODEV; | ||
519 | |||
520 | name = (char *)get_property(prom_stdout, "name", NULL); | ||
521 | if (!name) | ||
522 | return -ENODEV; | ||
523 | |||
524 | if (strcmp(name, "serial") == 0) { | ||
525 | int i; | ||
526 | u32 *reg = (u32 *)get_property(prom_stdout, "reg", &i); | ||
527 | if (i > 8) { | ||
528 | switch (reg[1]) { | ||
529 | case 0x3f8: | ||
530 | offset = 0; | ||
531 | break; | ||
532 | case 0x2f8: | ||
533 | offset = 1; | ||
534 | break; | ||
535 | case 0x898: | ||
536 | offset = 2; | ||
537 | break; | ||
538 | case 0x890: | ||
539 | offset = 3; | ||
540 | break; | ||
541 | default: | ||
542 | /* We dont recognise the serial port */ | ||
543 | return -ENODEV; | ||
544 | } | ||
545 | } | ||
546 | } else if (strcmp(name, "ch-a") == 0) | ||
547 | offset = 0; | ||
548 | else if (strcmp(name, "ch-b") == 0) | ||
549 | offset = 1; | ||
550 | else | ||
551 | return -ENODEV; | ||
552 | return add_preferred_console("ttyS", offset, NULL); | ||
553 | } | ||
554 | console_initcall(set_preferred_console); | ||
555 | #endif /* CONFIG_SERIAL_CORE_CONSOLE */ | ||
556 | #endif /* CONFIG_PPC_OF */ | ||
557 | 340 | ||
558 | struct bi_record *find_bootinfo(void) | 341 | struct bi_record *find_bootinfo(void) |
559 | { | 342 | { |
@@ -589,23 +372,6 @@ void parse_bootinfo(struct bi_record *rec) | |||
589 | initrd_end = data[0] + data[1] + KERNELBASE; | 372 | initrd_end = data[0] + data[1] + KERNELBASE; |
590 | break; | 373 | break; |
591 | #endif /* CONFIG_BLK_DEV_INITRD */ | 374 | #endif /* CONFIG_BLK_DEV_INITRD */ |
592 | #ifdef CONFIG_PPC_MULTIPLATFORM | ||
593 | case BI_MACHTYPE: | ||
594 | /* Machine types changed with the merge. Since the | ||
595 | * bootinfo are now deprecated, we can just hard code | ||
596 | * the appropriate conversion here for when we are | ||
597 | * called with yaboot which passes us a machine type | ||
598 | * this way. | ||
599 | */ | ||
600 | switch(data[0]) { | ||
601 | case 1: _machine = _MACH_prep; break; | ||
602 | case 2: _machine = _MACH_Pmac; break; | ||
603 | case 4: _machine = _MACH_chrp; break; | ||
604 | default: | ||
605 | _machine = data[0]; | ||
606 | } | ||
607 | break; | ||
608 | #endif | ||
609 | case BI_MEMSIZE: | 375 | case BI_MEMSIZE: |
610 | boot_mem_size = data[0]; | 376 | boot_mem_size = data[0]; |
611 | break; | 377 | break; |
@@ -631,9 +397,6 @@ machine_init(unsigned long r3, unsigned long r4, unsigned long r5, | |||
631 | #ifdef CONFIG_6xx | 397 | #ifdef CONFIG_6xx |
632 | ppc_md.power_save = ppc6xx_idle; | 398 | ppc_md.power_save = ppc6xx_idle; |
633 | #endif | 399 | #endif |
634 | #ifdef CONFIG_POWER4 | ||
635 | ppc_md.power_save = power4_idle; | ||
636 | #endif | ||
637 | 400 | ||
638 | platform_init(r3, r4, r5, r6, r7); | 401 | platform_init(r3, r4, r5, r6, r7); |
639 | 402 | ||
@@ -799,7 +562,4 @@ void __init setup_arch(char **cmdline_p) | |||
799 | if ( ppc_md.progress ) ppc_md.progress("arch: exit", 0x3eab); | 562 | if ( ppc_md.progress ) ppc_md.progress("arch: exit", 0x3eab); |
800 | 563 | ||
801 | paging_init(); | 564 | paging_init(); |
802 | |||
803 | /* this is for modules since _machine can be a define -- Cort */ | ||
804 | ppc_md.ppc_machine = _machine; | ||
805 | } | 565 | } |