VServer 1.9.2 (patch-2.6.8.1-vs1.9.2.diff)
[linux-2.6.git] / arch / mips / pmc-sierra / yosemite / prom.c
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 PMC-Sierra Inc.
8  * Author: Manish Lachwani (lachwani@pmc-sierra.com)
9  */
10 #include <linux/init.h>
11 #include <linux/sched.h>
12 #include <linux/mm.h>
13 #include <linux/delay.h>
14 #include <linux/smp.h>
15
16 #include <asm/io.h>
17 #include <asm/pgtable.h>
18 #include <asm/processor.h>
19 #include <asm/reboot.h>
20 #include <asm/system.h>
21 #include <asm/bootinfo.h>
22 #include <asm/pmon.h>
23
24 #include "setup.h"
25
26 struct callvectors *debug_vectors;
27
28 extern unsigned long yosemite_base;
29 extern unsigned long cpu_clock;
30
31 const char *get_system_type(void)
32 {
33         return "PMC-Sierra Yosemite";
34 }
35
36 static void prom_cpu0_exit(void *arg)
37 {
38         void *nvram = (void *) YOSEMITE_NVRAM_BASE_ADDR;
39
40         /* Ask the NVRAM/RTC/watchdog chip to assert reset in 1/16 second */
41         writeb(0x84, nvram + 0xff7);
42
43         /* wait for the watchdog to go off */
44         mdelay(100 + (1000 / 16));
45
46         /* if the watchdog fails for some reason, let people know */
47         printk(KERN_NOTICE "Watchdog reset failed\n");
48 }
49
50 /*
51  * Reset the NVRAM over the local bus
52  */
53 static void prom_exit(void)
54 {
55 #ifdef CONFIG_SMP
56         if (smp_processor_id())
57                 /* CPU 1 */
58                 smp_call_function(prom_cpu0_exit, NULL, 1, 1);
59 #endif
60         prom_cpu0_exit(NULL);
61 }
62
63 /*
64  * Halt the system
65  */
66 static void prom_halt(void)
67 {
68         printk(KERN_NOTICE "\n** You can safely turn off the power\n");
69         while (1)
70                 __asm__(".set\tmips3\n\t" "wait\n\t" ".set\tmips0");
71 }
72
73 /*
74  * Init routine which accepts the variables from PMON
75  */
76 void __init prom_init(void)
77 {
78         int argc = fw_arg0;
79         char **arg = (char **) fw_arg1;
80         char **env = (char **) fw_arg2;
81         struct callvectors *cv = (struct callvectors *) fw_arg3;
82         int i = 0;
83
84         /* Callbacks for halt, restart */
85         _machine_restart = (void (*)(char *)) prom_exit;
86         _machine_halt = prom_halt;
87         _machine_power_off = prom_halt;
88
89 #ifdef CONFIG_MIPS32
90
91         debug_vectors = cv;
92         arcs_cmdline[0] = '\0';
93
94         /* Get the boot parameters */
95         for (i = 1; i < argc; i++) {
96                 if (strlen(arcs_cmdline) + strlen(arg[i] + 1) >=
97                     sizeof(arcs_cmdline))
98                         break;
99
100                 strcat(arcs_cmdline, arg[i]);
101                 strcat(arcs_cmdline, " ");
102         }
103
104         while (*env) {
105                 if (strncmp("ocd_base", *env, strlen("ocd_base")) == 0)
106                         yosemite_base =
107                             simple_strtol(*env + strlen("ocd_base="), NULL,
108                                           16);
109
110                 if (strncmp("cpuclock", *env, strlen("cpuclock")) == 0)
111                         cpu_clock =
112                             simple_strtol(*env + strlen("cpuclock="), NULL,
113                                           10);
114
115                 env++;
116         }
117 #endif /* CONFIG_MIPS32 */
118
119 #ifdef CONFIG_MIPS64
120
121         /* Do nothing for the 64-bit for now. Just implement for the 32-bit */
122
123 #endif /* CONFIG_MIPS64 */
124
125         mips_machgroup = MACH_GROUP_TITAN;
126         mips_machtype = MACH_TITAN_YOSEMITE;
127 }
128
129 void __init prom_free_prom_memory(void)
130 {
131 }
132
133 void __init prom_fixup_mem_map(unsigned long start, unsigned long end)
134 {
135 }