blob: 6a2754c4f10641f817576c456b11abf9f74186a2 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
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 Torvalds1da177e2005-04-16 15:20:36 -070011#include <linux/init.h>
12#include <linux/sched.h>
13#include <linux/mm.h>
14#include <linux/delay.h>
Ralf Baechlefcdb27a2006-01-18 17:37:07 +000015#include <linux/pm.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070016#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 Baechle87353d82007-11-19 12:23:51 +000022#include <asm/smp-ops.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070023#include <asm/bootinfo.h>
24#include <asm/pmon.h>
25
26#ifdef CONFIG_SMP
27extern void prom_grab_secondary(void);
28#else
29#define prom_grab_secondary() do { } while (0)
30#endif
31
32#include "setup.h"
33
34struct callvectors *debug_vectors;
35
36extern unsigned long yosemite_base;
Ralf Baechle348c9132007-07-28 11:46:15 +010037extern unsigned long cpu_clock_freq;
Linus Torvalds1da177e2005-04-16 15:20:36 -070038
39const char *get_system_type(void)
40{
41 return "PMC-Sierra Yosemite";
42}
43
44static void prom_cpu0_exit(void *arg)
45{
46 void *nvram = (void *) YOSEMITE_RTC_BASE;
47
48 /* Ask the NVRAM/RTC/watchdog chip to assert reset in 1/16 second */
49 writeb(0x84, nvram + 0xff7);
50
51 /* wait for the watchdog to go off */
52 mdelay(100 + (1000 / 16));
53
54 /* if the watchdog fails for some reason, let people know */
55 printk(KERN_NOTICE "Watchdog reset failed\n");
56}
57
58/*
59 * Reset the NVRAM over the local bus
60 */
61static void prom_exit(void)
62{
63#ifdef CONFIG_SMP
64 if (smp_processor_id())
65 /* CPU 1 */
Jens Axboe8691e5a2008-06-06 11:18:06 +020066 smp_call_function(prom_cpu0_exit, NULL, 1);
Linus Torvalds1da177e2005-04-16 15:20:36 -070067#endif
68 prom_cpu0_exit(NULL);
69}
70
71/*
72 * Halt the system
73 */
74static void prom_halt(void)
75{
76 printk(KERN_NOTICE "\n** You can safely turn off the power\n");
77 while (1)
78 __asm__(".set\tmips3\n\t" "wait\n\t" ".set\tmips0");
79}
80
Ralf Baechle87353d82007-11-19 12:23:51 +000081extern struct plat_smp_ops yos_smp_ops;
82
Linus Torvalds1da177e2005-04-16 15:20:36 -070083/*
84 * Init routine which accepts the variables from PMON
85 */
86void __init prom_init(void)
87{
88 int argc = fw_arg0;
89 char **arg = (char **) fw_arg1;
90 char **env = (char **) fw_arg2;
91 struct callvectors *cv = (struct callvectors *) fw_arg3;
92 int i = 0;
93
94 /* Callbacks for halt, restart */
95 _machine_restart = (void (*)(char *)) prom_exit;
96 _machine_halt = prom_halt;
Ralf Baechlefcdb27a2006-01-18 17:37:07 +000097 pm_power_off = prom_halt;
Linus Torvalds1da177e2005-04-16 15:20:36 -070098
99 debug_vectors = cv;
100 arcs_cmdline[0] = '\0';
101
102 /* Get the boot parameters */
103 for (i = 1; i < argc; i++) {
Thomas Jarosch617d1012011-10-29 15:45:56 +0200104 if (strlen(arcs_cmdline) + strlen(arg[i]) + 1 >=
Linus Torvalds1da177e2005-04-16 15:20:36 -0700105 sizeof(arcs_cmdline))
106 break;
107
108 strcat(arcs_cmdline, arg[i]);
109 strcat(arcs_cmdline, " ");
110 }
111
112#ifdef CONFIG_SERIAL_8250_CONSOLE
113 if ((strstr(arcs_cmdline, "console=ttyS")) == NULL)
114 strcat(arcs_cmdline, "console=ttyS0,115200");
115#endif
116
117 while (*env) {
118 if (strncmp("ocd_base", *env, strlen("ocd_base")) == 0)
119 yosemite_base =
120 simple_strtol(*env + strlen("ocd_base="), NULL,
121 16);
122
123 if (strncmp("cpuclock", *env, strlen("cpuclock")) == 0)
Ralf Baechle348c9132007-07-28 11:46:15 +0100124 cpu_clock_freq =
Linus Torvalds1da177e2005-04-16 15:20:36 -0700125 simple_strtol(*env + strlen("cpuclock="), NULL,
126 10);
127
128 env++;
129 }
130
Linus Torvalds1da177e2005-04-16 15:20:36 -0700131 prom_grab_secondary();
Ralf Baechle87353d82007-11-19 12:23:51 +0000132
133 register_smp_ops(&yos_smp_ops);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700134}
135
Atsushi Nemotoc44e8d52006-12-30 00:43:59 +0900136void __init prom_free_prom_memory(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700137{
Linus Torvalds1da177e2005-04-16 15:20:36 -0700138}
139
140void __init prom_fixup_mem_map(unsigned long start, unsigned long end)
141{
142}