Linux-2.6.12-rc2
[deliverable/linux.git] / arch / ppc64 / kernel / maple_setup.c
1 /*
2 * arch/ppc64/kernel/maple_setup.c
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
14 #define DEBUG
15
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>
21 #include <linux/mm.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>
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>
52 #include <asm/bitops.h>
53 #include <asm/io.h>
54 #include <asm/pci-bridge.h>
55 #include <asm/iommu.h>
56 #include <asm/machdep.h>
57 #include <asm/dma.h>
58 #include <asm/cputable.h>
59 #include <asm/time.h>
60 #include <asm/of_device.h>
61 #include <asm/lmb.h>
62
63 #include "mpic.h"
64
65 #ifdef DEBUG
66 #define DBG(fmt...) udbg_printf(fmt)
67 #else
68 #define DBG(fmt...)
69 #endif
70
71 extern int maple_set_rtc_time(struct rtc_time *tm);
72 extern void maple_get_rtc_time(struct rtc_time *tm);
73 extern void maple_get_boot_time(struct rtc_time *tm);
74 extern void maple_calibrate_decr(void);
75 extern void maple_pci_init(void);
76 extern void maple_pcibios_fixup(void);
77 extern int maple_pci_get_legacy_ide_irq(struct pci_dev *dev, int channel);
78 extern void generic_find_legacy_serial_ports(u64 *physport,
79 unsigned int *default_speed);
80
81
82 static void maple_restart(char *cmd)
83 {
84 }
85
86 static void maple_power_off(void)
87 {
88 }
89
90 static void maple_halt(void)
91 {
92 }
93
94 #ifdef CONFIG_SMP
95 struct smp_ops_t maple_smp_ops = {
96 .probe = smp_mpic_probe,
97 .message_pass = smp_mpic_message_pass,
98 .kick_cpu = smp_generic_kick_cpu,
99 .setup_cpu = smp_mpic_setup_cpu,
100 .give_timebase = smp_generic_give_timebase,
101 .take_timebase = smp_generic_take_timebase,
102 };
103 #endif /* CONFIG_SMP */
104
105 void __init maple_setup_arch(void)
106 {
107 /* init to some ~sane value until calibrate_delay() runs */
108 loops_per_jiffy = 50000000;
109
110 /* Setup SMP callback */
111 #ifdef CONFIG_SMP
112 smp_ops = &maple_smp_ops;
113 #endif
114 /* Lookup PCI hosts */
115 maple_pci_init();
116
117 #ifdef CONFIG_DUMMY_CONSOLE
118 conswitchp = &dummy_con;
119 #endif
120 }
121
122 /*
123 * Early initialization.
124 */
125 static void __init maple_init_early(void)
126 {
127 unsigned int default_speed;
128 u64 physport;
129
130 DBG(" -> maple_init_early\n");
131
132 /* Initialize hash table, from now on, we can take hash faults
133 * and call ioremap
134 */
135 hpte_init_native();
136
137 /* Find the serial port */
138 generic_find_legacy_serial_ports(&physport, &default_speed);
139
140 DBG("phys port addr: %lx\n", (long)physport);
141
142 if (physport) {
143 void *comport;
144 /* Map the uart for udbg. */
145 comport = (void *)__ioremap(physport, 16, _PAGE_NO_CACHE);
146 udbg_init_uart(comport, default_speed);
147
148 ppc_md.udbg_putc = udbg_putc;
149 ppc_md.udbg_getc = udbg_getc;
150 ppc_md.udbg_getc_poll = udbg_getc_poll;
151 DBG("Hello World !\n");
152 }
153
154 /* Setup interrupt mapping options */
155 ppc64_interrupt_controller = IC_OPEN_PIC;
156
157 iommu_init_early_u3();
158
159 DBG(" <- maple_init_early\n");
160 }
161
162
163 static __init void maple_init_IRQ(void)
164 {
165 struct device_node *root;
166 unsigned int *opprop;
167 unsigned long opic_addr;
168 struct mpic *mpic;
169 unsigned char senses[128];
170 int n;
171
172 DBG(" -> maple_init_IRQ\n");
173
174 /* XXX: Non standard, replace that with a proper openpic/mpic node
175 * in the device-tree. Find the Open PIC if present */
176 root = of_find_node_by_path("/");
177 opprop = (unsigned int *) get_property(root,
178 "platform-open-pic", NULL);
179 if (opprop == 0)
180 panic("OpenPIC not found !\n");
181
182 n = prom_n_addr_cells(root);
183 for (opic_addr = 0; n > 0; --n)
184 opic_addr = (opic_addr << 32) + *opprop++;
185 of_node_put(root);
186
187 /* Obtain sense values from device-tree */
188 prom_get_irq_senses(senses, 0, 128);
189
190 mpic = mpic_alloc(opic_addr,
191 MPIC_PRIMARY | MPIC_BIG_ENDIAN |
192 MPIC_BROKEN_U3 | MPIC_WANTS_RESET,
193 0, 0, 128, 128, senses, 128, "U3-MPIC");
194 BUG_ON(mpic == NULL);
195 mpic_init(mpic);
196
197 DBG(" <- maple_init_IRQ\n");
198 }
199
200 static void __init maple_progress(char *s, unsigned short hex)
201 {
202 printk("*** %04x : %s\n", hex, s ? s : "");
203 }
204
205
206 /*
207 * Called very early, MMU is off, device-tree isn't unflattened
208 */
209 static int __init maple_probe(int platform)
210 {
211 if (platform != PLATFORM_MAPLE)
212 return 0;
213 /*
214 * On U3, the DART (iommu) must be allocated now since it
215 * has an impact on htab_initialize (due to the large page it
216 * occupies having to be broken up so the DART itself is not
217 * part of the cacheable linar mapping
218 */
219 alloc_u3_dart_table();
220
221 return 1;
222 }
223
224 struct machdep_calls __initdata maple_md = {
225 .probe = maple_probe,
226 .setup_arch = maple_setup_arch,
227 .init_early = maple_init_early,
228 .init_IRQ = maple_init_IRQ,
229 .get_irq = mpic_get_irq,
230 .pcibios_fixup = maple_pcibios_fixup,
231 .pci_get_legacy_ide_irq = maple_pci_get_legacy_ide_irq,
232 .restart = maple_restart,
233 .power_off = maple_power_off,
234 .halt = maple_halt,
235 .get_boot_time = maple_get_boot_time,
236 .set_rtc_time = maple_set_rtc_time,
237 .get_rtc_time = maple_get_rtc_time,
238 .calibrate_decr = maple_calibrate_decr,
239 .progress = maple_progress,
240 };
This page took 0.044611 seconds and 5 git commands to generate.