This source file includes following definitions.
- maple_find_nvram_base
- maple_restart
- maple_power_off
- maple_halt
- maple_use_rtas_reboot_and_halt_if_present
- maple_setup_arch
- maple_init_IRQ
- maple_progress
- maple_probe
- maple_cpc925_edac_setup
- define_machine
1
2
3
4
5
6
7
8
9 #undef DEBUG
10
11 #include <linux/init.h>
12 #include <linux/errno.h>
13 #include <linux/sched.h>
14 #include <linux/kernel.h>
15 #include <linux/export.h>
16 #include <linux/mm.h>
17 #include <linux/stddef.h>
18 #include <linux/unistd.h>
19 #include <linux/ptrace.h>
20 #include <linux/user.h>
21 #include <linux/tty.h>
22 #include <linux/string.h>
23 #include <linux/delay.h>
24 #include <linux/ioport.h>
25 #include <linux/major.h>
26 #include <linux/initrd.h>
27 #include <linux/vt_kern.h>
28 #include <linux/console.h>
29 #include <linux/pci.h>
30 #include <linux/adb.h>
31 #include <linux/cuda.h>
32 #include <linux/pmu.h>
33 #include <linux/irq.h>
34 #include <linux/seq_file.h>
35 #include <linux/root_dev.h>
36 #include <linux/serial.h>
37 #include <linux/smp.h>
38 #include <linux/bitops.h>
39 #include <linux/of_device.h>
40 #include <linux/memblock.h>
41
42 #include <asm/processor.h>
43 #include <asm/sections.h>
44 #include <asm/prom.h>
45 #include <asm/pgtable.h>
46 #include <asm/io.h>
47 #include <asm/pci-bridge.h>
48 #include <asm/iommu.h>
49 #include <asm/machdep.h>
50 #include <asm/dma.h>
51 #include <asm/cputable.h>
52 #include <asm/time.h>
53 #include <asm/mpic.h>
54 #include <asm/rtas.h>
55 #include <asm/udbg.h>
56 #include <asm/nvram.h>
57
58 #include "maple.h"
59
60 #ifdef DEBUG
61 #define DBG(fmt...) udbg_printf(fmt)
62 #else
63 #define DBG(fmt...)
64 #endif
65
66 static unsigned long maple_find_nvram_base(void)
67 {
68 struct device_node *rtcs;
69 unsigned long result = 0;
70
71
72 rtcs = of_find_compatible_node(NULL, "nvram", "AMD8111");
73 if (rtcs) {
74 struct resource r;
75 if (of_address_to_resource(rtcs, 0, &r)) {
76 printk(KERN_EMERG "Maple: Unable to translate NVRAM"
77 " address\n");
78 goto bail;
79 }
80 if (!(r.flags & IORESOURCE_IO)) {
81 printk(KERN_EMERG "Maple: NVRAM address isn't PIO!\n");
82 goto bail;
83 }
84 result = r.start;
85 } else
86 printk(KERN_EMERG "Maple: Unable to find NVRAM\n");
87 bail:
88 of_node_put(rtcs);
89 return result;
90 }
91
92 static void __noreturn maple_restart(char *cmd)
93 {
94 unsigned int maple_nvram_base;
95 const unsigned int *maple_nvram_offset, *maple_nvram_command;
96 struct device_node *sp;
97
98 maple_nvram_base = maple_find_nvram_base();
99 if (maple_nvram_base == 0)
100 goto fail;
101
102
103 sp = of_find_node_by_name(NULL, "service-processor");
104 if (!sp) {
105 printk(KERN_EMERG "Maple: Unable to find Service Processor\n");
106 goto fail;
107 }
108 maple_nvram_offset = of_get_property(sp, "restart-addr", NULL);
109 maple_nvram_command = of_get_property(sp, "restart-value", NULL);
110 of_node_put(sp);
111
112
113 outb_p(*maple_nvram_command, maple_nvram_base + *maple_nvram_offset);
114 for (;;) ;
115 fail:
116 printk(KERN_EMERG "Maple: Manual Restart Required\n");
117 for (;;) ;
118 }
119
120 static void __noreturn maple_power_off(void)
121 {
122 unsigned int maple_nvram_base;
123 const unsigned int *maple_nvram_offset, *maple_nvram_command;
124 struct device_node *sp;
125
126 maple_nvram_base = maple_find_nvram_base();
127 if (maple_nvram_base == 0)
128 goto fail;
129
130
131 sp = of_find_node_by_name(NULL, "service-processor");
132 if (!sp) {
133 printk(KERN_EMERG "Maple: Unable to find Service Processor\n");
134 goto fail;
135 }
136 maple_nvram_offset = of_get_property(sp, "power-off-addr", NULL);
137 maple_nvram_command = of_get_property(sp, "power-off-value", NULL);
138 of_node_put(sp);
139
140
141 outb_p(*maple_nvram_command, maple_nvram_base + *maple_nvram_offset);
142 for (;;) ;
143 fail:
144 printk(KERN_EMERG "Maple: Manual Power-Down Required\n");
145 for (;;) ;
146 }
147
148 static void __noreturn maple_halt(void)
149 {
150 maple_power_off();
151 }
152
153 #ifdef CONFIG_SMP
154 static struct smp_ops_t maple_smp_ops = {
155 .probe = smp_mpic_probe,
156 .message_pass = smp_mpic_message_pass,
157 .kick_cpu = smp_generic_kick_cpu,
158 .setup_cpu = smp_mpic_setup_cpu,
159 .give_timebase = smp_generic_give_timebase,
160 .take_timebase = smp_generic_take_timebase,
161 };
162 #endif
163
164 static void __init maple_use_rtas_reboot_and_halt_if_present(void)
165 {
166 if (rtas_service_present("system-reboot") &&
167 rtas_service_present("power-off")) {
168 ppc_md.restart = rtas_restart;
169 pm_power_off = rtas_power_off;
170 ppc_md.halt = rtas_halt;
171 }
172 }
173
174 static void __init maple_setup_arch(void)
175 {
176
177 loops_per_jiffy = 50000000;
178
179
180 #ifdef CONFIG_SMP
181 smp_ops = &maple_smp_ops;
182 #endif
183
184 maple_pci_init();
185
186 #ifdef CONFIG_DUMMY_CONSOLE
187 conswitchp = &dummy_con;
188 #endif
189 maple_use_rtas_reboot_and_halt_if_present();
190
191 printk(KERN_DEBUG "Using native/NAP idle loop\n");
192
193 mmio_nvram_init();
194 }
195
196
197
198
199
200
201 static void __init maple_init_IRQ(void)
202 {
203 struct device_node *root, *np, *mpic_node = NULL;
204 const unsigned int *opprop;
205 unsigned long openpic_addr = 0;
206 int naddr, n, i, opplen, has_isus = 0;
207 struct mpic *mpic;
208 unsigned int flags = 0;
209
210
211
212
213
214
215 for_each_node_by_type(np, "interrupt-controller")
216 if (of_device_is_compatible(np, "open-pic")) {
217 mpic_node = np;
218 break;
219 }
220 if (mpic_node == NULL)
221 for_each_node_by_type(np, "open-pic") {
222 mpic_node = np;
223 break;
224 }
225 if (mpic_node == NULL) {
226 printk(KERN_ERR
227 "Failed to locate the MPIC interrupt controller\n");
228 return;
229 }
230
231
232 root = of_find_node_by_path("/");
233 naddr = of_n_addr_cells(root);
234 opprop = of_get_property(root, "platform-open-pic", &opplen);
235 if (opprop != 0) {
236 openpic_addr = of_read_number(opprop, naddr);
237 has_isus = (opplen > naddr);
238 printk(KERN_DEBUG "OpenPIC addr: %lx, has ISUs: %d\n",
239 openpic_addr, has_isus);
240 }
241
242 BUG_ON(openpic_addr == 0);
243
244
245 if (of_get_property(np, "big-endian", NULL) != NULL)
246 flags |= MPIC_BIG_ENDIAN;
247
248
249 flags |= MPIC_U3_HT_IRQS;
250
251 flags |= MPIC_BIG_ENDIAN;
252
253
254
255
256
257 mpic = mpic_alloc(mpic_node, openpic_addr, flags,
258 0, 0, " MPIC ");
259 BUG_ON(mpic == NULL);
260
261
262 opplen /= sizeof(u32);
263 for (n = 0, i = naddr; i < opplen; i += naddr, n++) {
264 unsigned long isuaddr = of_read_number(opprop + i, naddr);
265 mpic_assign_isu(mpic, n, isuaddr);
266 }
267
268
269 mpic_init(mpic);
270 ppc_md.get_irq = mpic_get_irq;
271 of_node_put(mpic_node);
272 of_node_put(root);
273 }
274
275 static void __init maple_progress(char *s, unsigned short hex)
276 {
277 printk("*** %04x : %s\n", hex, s ? s : "");
278 }
279
280
281
282
283
284 static int __init maple_probe(void)
285 {
286 if (!of_machine_is_compatible("Momentum,Maple") &&
287 !of_machine_is_compatible("Momentum,Apache"))
288 return 0;
289
290 pm_power_off = maple_power_off;
291
292 iommu_init_early_dart(&maple_pci_controller_ops);
293
294 return 1;
295 }
296
297 #ifdef CONFIG_EDAC
298
299
300
301
302 static int __init maple_cpc925_edac_setup(void)
303 {
304 struct platform_device *pdev;
305 struct device_node *np = NULL;
306 struct resource r;
307 int ret;
308 volatile void __iomem *mem;
309 u32 rev;
310
311 np = of_find_node_by_type(NULL, "memory-controller");
312 if (!np) {
313 printk(KERN_ERR "%s: Unable to find memory-controller node\n",
314 __func__);
315 return -ENODEV;
316 }
317
318 ret = of_address_to_resource(np, 0, &r);
319 of_node_put(np);
320
321 if (ret < 0) {
322 printk(KERN_ERR "%s: Unable to get memory-controller reg\n",
323 __func__);
324 return -ENODEV;
325 }
326
327 mem = ioremap(r.start, resource_size(&r));
328 if (!mem) {
329 printk(KERN_ERR "%s: Unable to map memory-controller memory\n",
330 __func__);
331 return -ENOMEM;
332 }
333
334 rev = __raw_readl(mem);
335 iounmap(mem);
336
337 if (rev < 0x34 || rev > 0x3f) {
338 printk(KERN_ERR "%s: Non-CPC925(U3H) bridge revision: %02x\n",
339 __func__, rev);
340 return 0;
341 }
342
343 pdev = platform_device_register_simple("cpc925_edac", 0, &r, 1);
344 if (IS_ERR(pdev))
345 return PTR_ERR(pdev);
346
347 printk(KERN_INFO "%s: CPC925 platform device created\n", __func__);
348
349 return 0;
350 }
351 machine_device_initcall(maple, maple_cpc925_edac_setup);
352 #endif
353
354 define_machine(maple) {
355 .name = "Maple",
356 .probe = maple_probe,
357 .setup_arch = maple_setup_arch,
358 .init_IRQ = maple_init_IRQ,
359 .pci_irq_fixup = maple_pci_irq_fixup,
360 .pci_get_legacy_ide_irq = maple_pci_get_legacy_ide_irq,
361 .restart = maple_restart,
362 .halt = maple_halt,
363 .get_boot_time = maple_get_boot_time,
364 .set_rtc_time = maple_set_rtc_time,
365 .get_rtc_time = maple_get_rtc_time,
366 .calibrate_decr = generic_calibrate_decr,
367 .progress = maple_progress,
368 .power_save = power4_idle,
369 };