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/config.h>
17 #include <linux/init.h>
18 #include <linux/errno.h>
19 #include <linux/sched.h>
20 #include <linux/kernel.h>
22 #include <linux/stddef.h>
23 #include <linux/unistd.h>
24 #include <linux/ptrace.h>
25 #include <linux/slab.h>
26 #include <linux/user.h>
27 #include <linux/a.out.h>
28 #include <linux/tty.h>
29 #include <linux/string.h>
30 #include <linux/delay.h>
31 #include <linux/ioport.h>
32 #include <linux/major.h>
33 #include <linux/initrd.h>
34 #include <linux/vt_kern.h>
35 #include <linux/console.h>
36 #include <linux/ide.h>
37 #include <linux/pci.h>
38 #include <linux/adb.h>
39 #include <linux/cuda.h>
40 #include <linux/pmu.h>
41 #include <linux/irq.h>
42 #include <linux/seq_file.h>
43 #include <linux/root_dev.h>
44 #include <linux/serial.h>
45 #include <linux/smp.h>
47 #include <asm/processor.h>
48 #include <asm/sections.h>
50 #include <asm/system.h>
51 #include <asm/pgtable.h>
52 #include <asm/bitops.h>
54 #include <asm/kexec.h>
55 #include <asm/pci-bridge.h>
56 #include <asm/iommu.h>
57 #include <asm/machdep.h>
59 #include <asm/cputable.h>
61 #include <asm/of_device.h>
69 #define DBG(fmt...) udbg_printf(fmt)
74 static unsigned long maple_find_nvram_base(void)
76 struct device_node
*rtcs
;
77 unsigned long result
= 0;
79 /* find NVRAM device */
80 rtcs
= of_find_compatible_node(NULL
, "nvram", "AMD8111");
83 if (of_address_to_resource(rtcs
, 0, &r
)) {
84 printk(KERN_EMERG
"Maple: Unable to translate NVRAM"
88 if (!(r
.flags
& IORESOURCE_IO
)) {
89 printk(KERN_EMERG
"Maple: NVRAM address isn't PIO!\n");
94 printk(KERN_EMERG
"Maple: Unable to find NVRAM\n");
100 static void maple_restart(char *cmd
)
102 unsigned int maple_nvram_base
;
103 unsigned int maple_nvram_offset
;
104 unsigned int maple_nvram_command
;
105 struct device_node
*sp
;
107 maple_nvram_base
= maple_find_nvram_base();
108 if (maple_nvram_base
== 0)
111 /* find service processor device */
112 sp
= of_find_node_by_name(NULL
, "service-processor");
114 printk(KERN_EMERG
"Maple: Unable to find Service Processor\n");
117 maple_nvram_offset
= *(unsigned int*) get_property(sp
,
118 "restart-addr", NULL
);
119 maple_nvram_command
= *(unsigned int*) get_property(sp
,
120 "restart-value", NULL
);
124 outb_p(maple_nvram_command
, maple_nvram_base
+ maple_nvram_offset
);
127 printk(KERN_EMERG
"Maple: Manual Restart Required\n");
130 static void maple_power_off(void)
132 unsigned int maple_nvram_base
;
133 unsigned int maple_nvram_offset
;
134 unsigned int maple_nvram_command
;
135 struct device_node
*sp
;
137 maple_nvram_base
= maple_find_nvram_base();
138 if (maple_nvram_base
== 0)
141 /* find service processor device */
142 sp
= of_find_node_by_name(NULL
, "service-processor");
144 printk(KERN_EMERG
"Maple: Unable to find Service Processor\n");
147 maple_nvram_offset
= *(unsigned int*) get_property(sp
,
148 "power-off-addr", NULL
);
149 maple_nvram_command
= *(unsigned int*) get_property(sp
,
150 "power-off-value", NULL
);
154 outb_p(maple_nvram_command
, maple_nvram_base
+ maple_nvram_offset
);
157 printk(KERN_EMERG
"Maple: Manual Power-Down Required\n");
160 static void maple_halt(void)
166 struct smp_ops_t maple_smp_ops
= {
167 .probe
= smp_mpic_probe
,
168 .message_pass
= smp_mpic_message_pass
,
169 .kick_cpu
= smp_generic_kick_cpu
,
170 .setup_cpu
= smp_mpic_setup_cpu
,
171 .give_timebase
= smp_generic_give_timebase
,
172 .take_timebase
= smp_generic_take_timebase
,
174 #endif /* CONFIG_SMP */
176 void __init
maple_setup_arch(void)
178 /* init to some ~sane value until calibrate_delay() runs */
179 loops_per_jiffy
= 50000000;
181 /* Setup SMP callback */
183 smp_ops
= &maple_smp_ops
;
185 /* Lookup PCI hosts */
188 #ifdef CONFIG_DUMMY_CONSOLE
189 conswitchp
= &dummy_con
;
192 printk(KERN_INFO
"Using native/NAP idle loop\n");
196 * Early initialization.
198 static void __init
maple_init_early(void)
200 DBG(" -> maple_init_early\n");
202 /* Initialize hash table, from now on, we can take hash faults
207 /* Setup interrupt mapping options */
208 ppc64_interrupt_controller
= IC_OPEN_PIC
;
210 iommu_init_early_dart();
212 DBG(" <- maple_init_early\n");
216 static __init
void maple_init_IRQ(void)
218 struct device_node
*root
;
219 unsigned int *opprop
;
220 unsigned long opic_addr
;
222 unsigned char senses
[128];
225 DBG(" -> maple_init_IRQ\n");
227 /* XXX: Non standard, replace that with a proper openpic/mpic node
228 * in the device-tree. Find the Open PIC if present */
229 root
= of_find_node_by_path("/");
230 opprop
= (unsigned int *) get_property(root
,
231 "platform-open-pic", NULL
);
233 panic("OpenPIC not found !\n");
235 n
= prom_n_addr_cells(root
);
236 for (opic_addr
= 0; n
> 0; --n
)
237 opic_addr
= (opic_addr
<< 32) + *opprop
++;
240 /* Obtain sense values from device-tree */
241 prom_get_irq_senses(senses
, 0, 128);
243 mpic
= mpic_alloc(opic_addr
,
244 MPIC_PRIMARY
| MPIC_BIG_ENDIAN
|
245 MPIC_BROKEN_U3
| MPIC_WANTS_RESET
,
246 0, 0, 128, 128, senses
, 128, "U3-MPIC");
247 BUG_ON(mpic
== NULL
);
250 DBG(" <- maple_init_IRQ\n");
253 static void __init
maple_progress(char *s
, unsigned short hex
)
255 printk("*** %04x : %s\n", hex
, s
? s
: "");
260 * Called very early, MMU is off, device-tree isn't unflattened
262 static int __init
maple_probe(void)
264 unsigned long root
= of_get_flat_dt_root();
265 if (!of_flat_dt_is_compatible(root
, "Momentum,Maple"))
268 * On U3, the DART (iommu) must be allocated now since it
269 * has an impact on htab_initialize (due to the large page it
270 * occupies having to be broken up so the DART itself is not
271 * part of the cacheable linar mapping
278 define_machine(maple_md
) {
280 .probe
= maple_probe
,
281 .setup_arch
= maple_setup_arch
,
282 .init_early
= maple_init_early
,
283 .init_IRQ
= maple_init_IRQ
,
284 .get_irq
= mpic_get_irq
,
285 .pcibios_fixup
= maple_pcibios_fixup
,
286 .pci_get_legacy_ide_irq
= maple_pci_get_legacy_ide_irq
,
287 .restart
= maple_restart
,
288 .power_off
= maple_power_off
,
290 .get_boot_time
= maple_get_boot_time
,
291 .set_rtc_time
= maple_set_rtc_time
,
292 .get_rtc_time
= maple_get_rtc_time
,
293 .calibrate_decr
= generic_calibrate_decr
,
294 .progress
= maple_progress
,
295 .power_save
= power4_idle
,
297 .machine_kexec
= default_machine_kexec
,
298 .machine_kexec_prepare
= default_machine_kexec_prepare
,
299 .machine_crash_shutdown
= default_machine_crash_shutdown
,