Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
| 2 | * This program is free software; you can redistribute it and/or modify it |
| 3 | * under the terms of the GNU General Public License as published by the |
| 4 | * Free Software Foundation; either version 2 of the License, or (at your |
| 5 | * option) any later version. |
| 6 | * |
| 7 | * Copyright (C) 2003, 2004 PMC-Sierra Inc. |
| 8 | * Author: Manish Lachwani (lachwani@pmc-sierra.com) |
| 9 | * Copyright (C) 2004 Ralf Baechle |
| 10 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 11 | #include <linux/init.h> |
| 12 | #include <linux/sched.h> |
| 13 | #include <linux/mm.h> |
| 14 | #include <linux/delay.h> |
Ralf Baechle | fcdb27a | 2006-01-18 17:37:07 +0000 | [diff] [blame] | 15 | #include <linux/pm.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 16 | #include <linux/smp.h> |
| 17 | |
| 18 | #include <asm/io.h> |
| 19 | #include <asm/pgtable.h> |
| 20 | #include <asm/processor.h> |
| 21 | #include <asm/reboot.h> |
Ralf Baechle | 87353d8 | 2007-11-19 12:23:51 +0000 | [diff] [blame] | 22 | #include <asm/smp-ops.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 23 | #include <asm/system.h> |
| 24 | #include <asm/bootinfo.h> |
| 25 | #include <asm/pmon.h> |
| 26 | |
| 27 | #ifdef CONFIG_SMP |
| 28 | extern void prom_grab_secondary(void); |
| 29 | #else |
| 30 | #define prom_grab_secondary() do { } while (0) |
| 31 | #endif |
| 32 | |
| 33 | #include "setup.h" |
| 34 | |
| 35 | struct callvectors *debug_vectors; |
| 36 | |
| 37 | extern unsigned long yosemite_base; |
Ralf Baechle | 348c913 | 2007-07-28 11:46:15 +0100 | [diff] [blame] | 38 | extern unsigned long cpu_clock_freq; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 39 | |
| 40 | const char *get_system_type(void) |
| 41 | { |
| 42 | return "PMC-Sierra Yosemite"; |
| 43 | } |
| 44 | |
| 45 | static void prom_cpu0_exit(void *arg) |
| 46 | { |
| 47 | void *nvram = (void *) YOSEMITE_RTC_BASE; |
| 48 | |
| 49 | /* Ask the NVRAM/RTC/watchdog chip to assert reset in 1/16 second */ |
| 50 | writeb(0x84, nvram + 0xff7); |
| 51 | |
| 52 | /* wait for the watchdog to go off */ |
| 53 | mdelay(100 + (1000 / 16)); |
| 54 | |
| 55 | /* if the watchdog fails for some reason, let people know */ |
| 56 | printk(KERN_NOTICE "Watchdog reset failed\n"); |
| 57 | } |
| 58 | |
| 59 | /* |
| 60 | * Reset the NVRAM over the local bus |
| 61 | */ |
| 62 | static void prom_exit(void) |
| 63 | { |
| 64 | #ifdef CONFIG_SMP |
| 65 | if (smp_processor_id()) |
| 66 | /* CPU 1 */ |
Jens Axboe | 8691e5a | 2008-06-06 11:18:06 +0200 | [diff] [blame] | 67 | smp_call_function(prom_cpu0_exit, NULL, 1); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 68 | #endif |
| 69 | prom_cpu0_exit(NULL); |
| 70 | } |
| 71 | |
| 72 | /* |
| 73 | * Halt the system |
| 74 | */ |
| 75 | static void prom_halt(void) |
| 76 | { |
| 77 | printk(KERN_NOTICE "\n** You can safely turn off the power\n"); |
| 78 | while (1) |
| 79 | __asm__(".set\tmips3\n\t" "wait\n\t" ".set\tmips0"); |
| 80 | } |
| 81 | |
Ralf Baechle | 87353d8 | 2007-11-19 12:23:51 +0000 | [diff] [blame] | 82 | extern struct plat_smp_ops yos_smp_ops; |
| 83 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 84 | /* |
| 85 | * Init routine which accepts the variables from PMON |
| 86 | */ |
| 87 | void __init prom_init(void) |
| 88 | { |
| 89 | int argc = fw_arg0; |
| 90 | char **arg = (char **) fw_arg1; |
| 91 | char **env = (char **) fw_arg2; |
| 92 | struct callvectors *cv = (struct callvectors *) fw_arg3; |
| 93 | int i = 0; |
| 94 | |
| 95 | /* Callbacks for halt, restart */ |
| 96 | _machine_restart = (void (*)(char *)) prom_exit; |
| 97 | _machine_halt = prom_halt; |
Ralf Baechle | fcdb27a | 2006-01-18 17:37:07 +0000 | [diff] [blame] | 98 | pm_power_off = prom_halt; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 99 | |
| 100 | debug_vectors = cv; |
| 101 | arcs_cmdline[0] = '\0'; |
| 102 | |
| 103 | /* Get the boot parameters */ |
| 104 | for (i = 1; i < argc; i++) { |
| 105 | if (strlen(arcs_cmdline) + strlen(arg[i] + 1) >= |
| 106 | sizeof(arcs_cmdline)) |
| 107 | break; |
| 108 | |
| 109 | strcat(arcs_cmdline, arg[i]); |
| 110 | strcat(arcs_cmdline, " "); |
| 111 | } |
| 112 | |
| 113 | #ifdef CONFIG_SERIAL_8250_CONSOLE |
| 114 | if ((strstr(arcs_cmdline, "console=ttyS")) == NULL) |
| 115 | strcat(arcs_cmdline, "console=ttyS0,115200"); |
| 116 | #endif |
| 117 | |
| 118 | while (*env) { |
| 119 | if (strncmp("ocd_base", *env, strlen("ocd_base")) == 0) |
| 120 | yosemite_base = |
| 121 | simple_strtol(*env + strlen("ocd_base="), NULL, |
| 122 | 16); |
| 123 | |
| 124 | if (strncmp("cpuclock", *env, strlen("cpuclock")) == 0) |
Ralf Baechle | 348c913 | 2007-07-28 11:46:15 +0100 | [diff] [blame] | 125 | cpu_clock_freq = |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 126 | simple_strtol(*env + strlen("cpuclock="), NULL, |
| 127 | 10); |
| 128 | |
| 129 | env++; |
| 130 | } |
| 131 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 132 | prom_grab_secondary(); |
Ralf Baechle | 87353d8 | 2007-11-19 12:23:51 +0000 | [diff] [blame] | 133 | |
| 134 | register_smp_ops(&yos_smp_ops); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 135 | } |
| 136 | |
Atsushi Nemoto | c44e8d5 | 2006-12-30 00:43:59 +0900 | [diff] [blame] | 137 | void __init prom_free_prom_memory(void) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 138 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 139 | } |
| 140 | |
| 141 | void __init prom_fixup_mem_map(unsigned long start, unsigned long end) |
| 142 | { |
| 143 | } |