powerpc: Remove default kexec/crash_kernel ops assignments
[deliverable/linux.git] / arch / powerpc / platforms / maple / setup.c
CommitLineData
1da177e4 1/*
0cb7b2af 2 * Maple (970 eval board) setup code
1da177e4
LT
3 *
4 * (c) Copyright 2004 Benjamin Herrenschmidt (benh@kernel.crashing.org),
5 * IBM Corp.
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version
10 * 2 of the License, or (at your option) any later version.
11 *
12 */
13
980a6513 14#undef DEBUG
1da177e4 15
1da177e4
LT
16#include <linux/init.h>
17#include <linux/errno.h>
18#include <linux/sched.h>
19#include <linux/kernel.h>
20#include <linux/mm.h>
21#include <linux/stddef.h>
22#include <linux/unistd.h>
23#include <linux/ptrace.h>
24#include <linux/slab.h>
25#include <linux/user.h>
1da177e4
LT
26#include <linux/tty.h>
27#include <linux/string.h>
28#include <linux/delay.h>
29#include <linux/ioport.h>
30#include <linux/major.h>
31#include <linux/initrd.h>
32#include <linux/vt_kern.h>
33#include <linux/console.h>
1da177e4
LT
34#include <linux/pci.h>
35#include <linux/adb.h>
36#include <linux/cuda.h>
37#include <linux/pmu.h>
38#include <linux/irq.h>
39#include <linux/seq_file.h>
40#include <linux/root_dev.h>
41#include <linux/serial.h>
42#include <linux/smp.h>
1977f032 43#include <linux/bitops.h>
0173d422 44#include <linux/of_device.h>
d9b2b2a2 45#include <linux/lmb.h>
1da177e4
LT
46
47#include <asm/processor.h>
48#include <asm/sections.h>
49#include <asm/prom.h>
50#include <asm/system.h>
51#include <asm/pgtable.h>
1da177e4
LT
52#include <asm/io.h>
53#include <asm/pci-bridge.h>
54#include <asm/iommu.h>
55#include <asm/machdep.h>
56#include <asm/dma.h>
57#include <asm/cputable.h>
58#include <asm/time.h>
bbeb3f4c 59#include <asm/mpic.h>
9e254c45 60#include <asm/rtas.h>
40ef8cbc 61#include <asm/udbg.h>
4297c986 62#include <asm/nvram.h>
1da177e4 63
0cb7b2af
PM
64#include "maple.h"
65
1da177e4
LT
66#ifdef DEBUG
67#define DBG(fmt...) udbg_printf(fmt)
68#else
69#define DBG(fmt...)
70#endif
71
4c882b01
BH
72static unsigned long maple_find_nvram_base(void)
73{
74 struct device_node *rtcs;
75 unsigned long result = 0;
76
77 /* find NVRAM device */
78 rtcs = of_find_compatible_node(NULL, "nvram", "AMD8111");
79 if (rtcs) {
80 struct resource r;
81 if (of_address_to_resource(rtcs, 0, &r)) {
82 printk(KERN_EMERG "Maple: Unable to translate NVRAM"
83 " address\n");
84 goto bail;
85 }
86 if (!(r.flags & IORESOURCE_IO)) {
87 printk(KERN_EMERG "Maple: NVRAM address isn't PIO!\n");
88 goto bail;
89 }
90 result = r.start;
91 } else
92 printk(KERN_EMERG "Maple: Unable to find NVRAM\n");
93 bail:
94 of_node_put(rtcs);
95 return result;
96}
97
1da177e4
LT
98static void maple_restart(char *cmd)
99{
d7152fe1 100 unsigned int maple_nvram_base;
eeb2b723 101 const unsigned int *maple_nvram_offset, *maple_nvram_command;
4c882b01 102 struct device_node *sp;
d7152fe1 103
4c882b01
BH
104 maple_nvram_base = maple_find_nvram_base();
105 if (maple_nvram_base == 0)
106 goto fail;
d7152fe1
DG
107
108 /* find service processor device */
4c882b01
BH
109 sp = of_find_node_by_name(NULL, "service-processor");
110 if (!sp) {
d7152fe1 111 printk(KERN_EMERG "Maple: Unable to find Service Processor\n");
4c882b01 112 goto fail;
d7152fe1 113 }
e2eb6392
SR
114 maple_nvram_offset = of_get_property(sp, "restart-addr", NULL);
115 maple_nvram_command = of_get_property(sp, "restart-value", NULL);
4c882b01 116 of_node_put(sp);
d7152fe1
DG
117
118 /* send command */
eeb2b723 119 outb_p(*maple_nvram_command, maple_nvram_base + *maple_nvram_offset);
d7152fe1 120 for (;;) ;
4c882b01
BH
121 fail:
122 printk(KERN_EMERG "Maple: Manual Restart Required\n");
1da177e4
LT
123}
124
125static void maple_power_off(void)
126{
d7152fe1 127 unsigned int maple_nvram_base;
eeb2b723 128 const unsigned int *maple_nvram_offset, *maple_nvram_command;
4c882b01 129 struct device_node *sp;
d7152fe1 130
4c882b01
BH
131 maple_nvram_base = maple_find_nvram_base();
132 if (maple_nvram_base == 0)
133 goto fail;
d7152fe1
DG
134
135 /* find service processor device */
4c882b01
BH
136 sp = of_find_node_by_name(NULL, "service-processor");
137 if (!sp) {
d7152fe1 138 printk(KERN_EMERG "Maple: Unable to find Service Processor\n");
4c882b01 139 goto fail;
d7152fe1 140 }
e2eb6392
SR
141 maple_nvram_offset = of_get_property(sp, "power-off-addr", NULL);
142 maple_nvram_command = of_get_property(sp, "power-off-value", NULL);
4c882b01 143 of_node_put(sp);
d7152fe1
DG
144
145 /* send command */
eeb2b723 146 outb_p(*maple_nvram_command, maple_nvram_base + *maple_nvram_offset);
d7152fe1 147 for (;;) ;
4c882b01
BH
148 fail:
149 printk(KERN_EMERG "Maple: Manual Power-Down Required\n");
1da177e4
LT
150}
151
152static void maple_halt(void)
153{
d7152fe1 154 maple_power_off();
1da177e4
LT
155}
156
157#ifdef CONFIG_SMP
158struct smp_ops_t maple_smp_ops = {
159 .probe = smp_mpic_probe,
160 .message_pass = smp_mpic_message_pass,
161 .kick_cpu = smp_generic_kick_cpu,
162 .setup_cpu = smp_mpic_setup_cpu,
163 .give_timebase = smp_generic_give_timebase,
164 .take_timebase = smp_generic_take_timebase,
165};
166#endif /* CONFIG_SMP */
167
9e254c45
NL
168static void __init maple_use_rtas_reboot_and_halt_if_present(void)
169{
170 if (rtas_service_present("system-reboot") &&
171 rtas_service_present("power-off")) {
172 ppc_md.restart = rtas_restart;
173 ppc_md.power_off = rtas_power_off;
174 ppc_md.halt = rtas_halt;
175 }
176}
177
1da177e4
LT
178void __init maple_setup_arch(void)
179{
180 /* init to some ~sane value until calibrate_delay() runs */
181 loops_per_jiffy = 50000000;
182
183 /* Setup SMP callback */
184#ifdef CONFIG_SMP
185 smp_ops = &maple_smp_ops;
186#endif
187 /* Lookup PCI hosts */
188 maple_pci_init();
189
190#ifdef CONFIG_DUMMY_CONSOLE
191 conswitchp = &dummy_con;
192#endif
9e254c45 193 maple_use_rtas_reboot_and_halt_if_present();
62d60e9f 194
4baaf0cf 195 printk(KERN_DEBUG "Using native/NAP idle loop\n");
4297c986
NL
196
197 mmio_nvram_init();
1da177e4
LT
198}
199
200/*
201 * Early initialization.
202 */
203static void __init maple_init_early(void)
204{
1da177e4
LT
205 DBG(" -> maple_init_early\n");
206
1beb6a7d 207 iommu_init_early_dart();
1da177e4
LT
208
209 DBG(" <- maple_init_early\n");
210}
211
0ebfff14
BH
212/*
213 * This is almost identical to pSeries and CHRP. We need to make that
214 * code generic at one point, with appropriate bits in the device-tree to
215 * identify the presence of an HT APIC
216 */
217static void __init maple_init_IRQ(void)
1da177e4 218{
0ebfff14 219 struct device_node *root, *np, *mpic_node = NULL;
eeb2b723 220 const unsigned int *opprop;
0ebfff14
BH
221 unsigned long openpic_addr = 0;
222 int naddr, n, i, opplen, has_isus = 0;
1da177e4 223 struct mpic *mpic;
0ebfff14 224 unsigned int flags = MPIC_PRIMARY;
1da177e4 225
0ebfff14
BH
226 /* Locate MPIC in the device-tree. Note that there is a bug
227 * in Maple device-tree where the type of the controller is
228 * open-pic and not interrupt-controller
229 */
96278d21
SB
230
231 for_each_node_by_type(np, "interrupt-controller")
55b61fec 232 if (of_device_is_compatible(np, "open-pic")) {
96278d21
SB
233 mpic_node = np;
234 break;
235 }
236 if (mpic_node == NULL)
237 for_each_node_by_type(np, "open-pic") {
238 mpic_node = np;
239 break;
240 }
0ebfff14
BH
241 if (mpic_node == NULL) {
242 printk(KERN_ERR
243 "Failed to locate the MPIC interrupt controller\n");
244 return;
245 }
1da177e4 246
0ebfff14 247 /* Find address list in /platform-open-pic */
1da177e4 248 root = of_find_node_by_path("/");
a8bda5dd 249 naddr = of_n_addr_cells(root);
e2eb6392 250 opprop = of_get_property(root, "platform-open-pic", &opplen);
0ebfff14
BH
251 if (opprop != 0) {
252 openpic_addr = of_read_number(opprop, naddr);
253 has_isus = (opplen > naddr);
254 printk(KERN_DEBUG "OpenPIC addr: %lx, has ISUs: %d\n",
255 openpic_addr, has_isus);
256 }
1da177e4 257
0ebfff14 258 BUG_ON(openpic_addr == 0);
1da177e4 259
0ebfff14 260 /* Check for a big endian MPIC */
e2eb6392 261 if (of_get_property(np, "big-endian", NULL) != NULL)
0ebfff14
BH
262 flags |= MPIC_BIG_ENDIAN;
263
264 /* XXX Maple specific bits */
6cfef5b2 265 flags |= MPIC_U3_HT_IRQS | MPIC_WANTS_RESET;
d319a03b
SB
266 /* All U3/U4 are big-endian, older SLOF firmware doesn't encode this */
267 flags |= MPIC_BIG_ENDIAN;
0ebfff14
BH
268
269 /* Setup the openpic driver. More device-tree junks, we hard code no
270 * ISUs for now. I'll have to revisit some stuffs with the folks doing
271 * the firmware for those
272 */
273 mpic = mpic_alloc(mpic_node, openpic_addr, flags,
274 /*has_isus ? 16 :*/ 0, 0, " MPIC ");
1da177e4 275 BUG_ON(mpic == NULL);
1da177e4 276
0ebfff14
BH
277 /* Add ISUs */
278 opplen /= sizeof(u32);
279 for (n = 0, i = naddr; i < opplen; i += naddr, n++) {
280 unsigned long isuaddr = of_read_number(opprop + i, naddr);
281 mpic_assign_isu(mpic, n, isuaddr);
282 }
283
284 /* All ISUs are setup, complete initialization */
285 mpic_init(mpic);
286 ppc_md.get_irq = mpic_get_irq;
287 of_node_put(mpic_node);
288 of_node_put(root);
1da177e4
LT
289}
290
291static void __init maple_progress(char *s, unsigned short hex)
292{
293 printk("*** %04x : %s\n", hex, s ? s : "");
294}
295
296
297/*
298 * Called very early, MMU is off, device-tree isn't unflattened
299 */
e8222502 300static int __init maple_probe(void)
1da177e4 301{
e8222502 302 unsigned long root = of_get_flat_dt_root();
980a6513
BH
303
304 if (!of_flat_dt_is_compatible(root, "Momentum,Maple") &&
305 !of_flat_dt_is_compatible(root, "Momentum,Apache"))
1da177e4
LT
306 return 0;
307 /*
308 * On U3, the DART (iommu) must be allocated now since it
309 * has an impact on htab_initialize (due to the large page it
310 * occupies having to be broken up so the DART itself is not
311 * part of the cacheable linar mapping
312 */
1beb6a7d 313 alloc_dart_table();
1da177e4 314
7d0daae4
ME
315 hpte_init_native();
316
1da177e4
LT
317 return 1;
318}
319
53378c28 320define_machine(maple) {
e8222502 321 .name = "Maple",
1da177e4
LT
322 .probe = maple_probe,
323 .setup_arch = maple_setup_arch,
324 .init_early = maple_init_early,
325 .init_IRQ = maple_init_IRQ,
f90bb153 326 .pci_irq_fixup = maple_pci_irq_fixup,
1da177e4
LT
327 .pci_get_legacy_ide_irq = maple_pci_get_legacy_ide_irq,
328 .restart = maple_restart,
329 .power_off = maple_power_off,
330 .halt = maple_halt,
331 .get_boot_time = maple_get_boot_time,
332 .set_rtc_time = maple_set_rtc_time,
333 .get_rtc_time = maple_get_rtc_time,
10f7e7c1 334 .calibrate_decr = generic_calibrate_decr,
1da177e4 335 .progress = maple_progress,
a0652fc9 336 .power_save = power4_idle,
1da177e4 337};
This page took 0.339414 seconds and 5 git commands to generate.