2 * Maple (970 eval board) setup code
4 * (c) Copyright 2004 Benjamin Herrenschmidt (benh@kernel.crashing.org),
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.
16 #include <linux/init.h>
17 #include <linux/errno.h>
18 #include <linux/sched.h>
19 #include <linux/kernel.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>
26 #include <linux/a.out.h>
27 #include <linux/tty.h>
28 #include <linux/string.h>
29 #include <linux/delay.h>
30 #include <linux/ioport.h>
31 #include <linux/major.h>
32 #include <linux/initrd.h>
33 #include <linux/vt_kern.h>
34 #include <linux/console.h>
35 #include <linux/ide.h>
36 #include <linux/pci.h>
37 #include <linux/adb.h>
38 #include <linux/cuda.h>
39 #include <linux/pmu.h>
40 #include <linux/irq.h>
41 #include <linux/seq_file.h>
42 #include <linux/root_dev.h>
43 #include <linux/serial.h>
44 #include <linux/smp.h>
46 #include <asm/processor.h>
47 #include <asm/sections.h>
49 #include <asm/system.h>
50 #include <asm/pgtable.h>
51 #include <asm/bitops.h>
53 #include <asm/kexec.h>
54 #include <asm/pci-bridge.h>
55 #include <asm/iommu.h>
56 #include <asm/machdep.h>
58 #include <asm/cputable.h>
60 #include <asm/of_device.h>
68 #define DBG(fmt...) udbg_printf(fmt)
73 static unsigned long maple_find_nvram_base(void)
75 struct device_node *rtcs;
76 unsigned long result = 0;
78 /* find NVRAM device */
79 rtcs = of_find_compatible_node(NULL, "nvram", "AMD8111");
82 if (of_address_to_resource(rtcs, 0, &r)) {
83 printk(KERN_EMERG "Maple: Unable to translate NVRAM"
87 if (!(r.flags & IORESOURCE_IO)) {
88 printk(KERN_EMERG "Maple: NVRAM address isn't PIO!\n");
93 printk(KERN_EMERG "Maple: Unable to find NVRAM\n");
99 static void maple_restart(char *cmd)
101 unsigned int maple_nvram_base;
102 unsigned int maple_nvram_offset;
103 unsigned int maple_nvram_command;
104 struct device_node *sp;
106 maple_nvram_base = maple_find_nvram_base();
107 if (maple_nvram_base == 0)
110 /* find service processor device */
111 sp = of_find_node_by_name(NULL, "service-processor");
113 printk(KERN_EMERG "Maple: Unable to find Service Processor\n");
116 maple_nvram_offset = *(unsigned int*) get_property(sp,
117 "restart-addr", NULL);
118 maple_nvram_command = *(unsigned int*) get_property(sp,
119 "restart-value", NULL);
123 outb_p(maple_nvram_command, maple_nvram_base + maple_nvram_offset);
126 printk(KERN_EMERG "Maple: Manual Restart Required\n");
129 static void maple_power_off(void)
131 unsigned int maple_nvram_base;
132 unsigned int maple_nvram_offset;
133 unsigned int maple_nvram_command;
134 struct device_node *sp;
136 maple_nvram_base = maple_find_nvram_base();
137 if (maple_nvram_base == 0)
140 /* find service processor device */
141 sp = of_find_node_by_name(NULL, "service-processor");
143 printk(KERN_EMERG "Maple: Unable to find Service Processor\n");
146 maple_nvram_offset = *(unsigned int*) get_property(sp,
147 "power-off-addr", NULL);
148 maple_nvram_command = *(unsigned int*) get_property(sp,
149 "power-off-value", NULL);
153 outb_p(maple_nvram_command, maple_nvram_base + maple_nvram_offset);
156 printk(KERN_EMERG "Maple: Manual Power-Down Required\n");
159 static void maple_halt(void)
165 struct smp_ops_t maple_smp_ops = {
166 .probe = smp_mpic_probe,
167 .message_pass = smp_mpic_message_pass,
168 .kick_cpu = smp_generic_kick_cpu,
169 .setup_cpu = smp_mpic_setup_cpu,
170 .give_timebase = smp_generic_give_timebase,
171 .take_timebase = smp_generic_take_timebase,
173 #endif /* CONFIG_SMP */
175 void __init maple_setup_arch(void)
177 /* init to some ~sane value until calibrate_delay() runs */
178 loops_per_jiffy = 50000000;
180 /* Setup SMP callback */
182 smp_ops = &maple_smp_ops;
184 /* Lookup PCI hosts */
187 #ifdef CONFIG_DUMMY_CONSOLE
188 conswitchp = &dummy_con;
191 printk(KERN_DEBUG "Using native/NAP idle loop\n");
195 * Early initialization.
197 static void __init maple_init_early(void)
199 DBG(" -> maple_init_early\n");
201 /* Setup interrupt mapping options */
202 ppc64_interrupt_controller = IC_OPEN_PIC;
204 iommu_init_early_dart();
206 DBG(" <- maple_init_early\n");
210 static __init void maple_init_IRQ(void)
212 struct device_node *root;
213 unsigned int *opprop;
214 unsigned long opic_addr;
216 unsigned char senses[128];
219 DBG(" -> maple_init_IRQ\n");
221 /* XXX: Non standard, replace that with a proper openpic/mpic node
222 * in the device-tree. Find the Open PIC if present */
223 root = of_find_node_by_path("/");
224 opprop = (unsigned int *) get_property(root,
225 "platform-open-pic", NULL);
227 panic("OpenPIC not found !\n");
229 n = prom_n_addr_cells(root);
230 for (opic_addr = 0; n > 0; --n)
231 opic_addr = (opic_addr << 32) + *opprop++;
234 /* Obtain sense values from device-tree */
235 prom_get_irq_senses(senses, 0, 128);
237 mpic = mpic_alloc(opic_addr,
238 MPIC_PRIMARY | MPIC_BIG_ENDIAN |
239 MPIC_BROKEN_U3 | MPIC_WANTS_RESET,
240 0, 0, 128, 128, senses, 128, "U3-MPIC");
241 BUG_ON(mpic == NULL);
244 DBG(" <- maple_init_IRQ\n");
247 static void __init maple_progress(char *s, unsigned short hex)
249 printk("*** %04x : %s\n", hex, s ? s : "");
254 * Called very early, MMU is off, device-tree isn't unflattened
256 static int __init maple_probe(void)
258 unsigned long root = of_get_flat_dt_root();
260 if (!of_flat_dt_is_compatible(root, "Momentum,Maple") &&
261 !of_flat_dt_is_compatible(root, "Momentum,Apache"))
264 * On U3, the DART (iommu) must be allocated now since it
265 * has an impact on htab_initialize (due to the large page it
266 * occupies having to be broken up so the DART itself is not
267 * part of the cacheable linar mapping
276 define_machine(maple_md) {
278 .probe = maple_probe,
279 .setup_arch = maple_setup_arch,
280 .init_early = maple_init_early,
281 .init_IRQ = maple_init_IRQ,
282 .get_irq = mpic_get_irq,
283 .pcibios_fixup = maple_pcibios_fixup,
284 .pci_get_legacy_ide_irq = maple_pci_get_legacy_ide_irq,
285 .restart = maple_restart,
286 .power_off = maple_power_off,
288 .get_boot_time = maple_get_boot_time,
289 .set_rtc_time = maple_set_rtc_time,
290 .get_rtc_time = maple_get_rtc_time,
291 .calibrate_decr = generic_calibrate_decr,
292 .progress = maple_progress,
293 .power_save = power4_idle,
295 .machine_kexec = default_machine_kexec,
296 .machine_kexec_prepare = default_machine_kexec_prepare,
297 .machine_crash_shutdown = default_machine_crash_shutdown,