powerpc: Convert to new irq_* function names
[deliverable/linux.git] / arch / powerpc / platforms / 85xx / ksi8560.c
1 /*
2 * Board setup routines for the Emerson KSI8560
3 *
4 * Author: Alexandr Smirnov <asmirnov@ru.mvista.com>
5 *
6 * Based on mpc85xx_ads.c maintained by Kumar Gala
7 *
8 * 2008 (c) MontaVista, Software, Inc. This file is licensed under
9 * the terms of the GNU General Public License version 2. This program
10 * is licensed "as is" without any warranty of any kind, whether express
11 * or implied.
12 *
13 */
14
15 #include <linux/stddef.h>
16 #include <linux/kernel.h>
17 #include <linux/pci.h>
18 #include <linux/kdev_t.h>
19 #include <linux/delay.h>
20 #include <linux/seq_file.h>
21 #include <linux/of_platform.h>
22
23 #include <asm/system.h>
24 #include <asm/time.h>
25 #include <asm/machdep.h>
26 #include <asm/pci-bridge.h>
27 #include <asm/mpic.h>
28 #include <mm/mmu_decl.h>
29 #include <asm/udbg.h>
30 #include <asm/prom.h>
31
32 #include <sysdev/fsl_soc.h>
33 #include <sysdev/fsl_pci.h>
34
35 #include <asm/cpm2.h>
36 #include <sysdev/cpm2_pic.h>
37
38
39 #define KSI8560_CPLD_HVR 0x04 /* Hardware Version Register */
40 #define KSI8560_CPLD_PVR 0x08 /* PLD Version Register */
41 #define KSI8560_CPLD_RCR1 0x30 /* Reset Command Register 1 */
42
43 #define KSI8560_CPLD_RCR1_CPUHR 0x80 /* CPU Hard Reset */
44
45 static void __iomem *cpld_base = NULL;
46
47 static void machine_restart(char *cmd)
48 {
49 if (cpld_base)
50 out_8(cpld_base + KSI8560_CPLD_RCR1, KSI8560_CPLD_RCR1_CPUHR);
51 else
52 printk(KERN_ERR "Can't find CPLD base, hang forever\n");
53
54 for (;;);
55 }
56
57 static void cpm2_cascade(unsigned int irq, struct irq_desc *desc)
58 {
59 struct irq_chip *chip = irq_desc_get_chip(desc);
60 int cascade_irq;
61
62 while ((cascade_irq = cpm2_get_irq()) >= 0)
63 generic_handle_irq(cascade_irq);
64
65 chip->irq_eoi(&desc->irq_data);
66 }
67
68 static void __init ksi8560_pic_init(void)
69 {
70 struct mpic *mpic;
71 struct resource r;
72 struct device_node *np;
73 #ifdef CONFIG_CPM2
74 int irq;
75 #endif
76
77 np = of_find_node_by_type(NULL, "open-pic");
78
79 if (np == NULL) {
80 printk(KERN_ERR "Could not find open-pic node\n");
81 return;
82 }
83
84 if (of_address_to_resource(np, 0, &r)) {
85 printk(KERN_ERR "Could not map mpic register space\n");
86 of_node_put(np);
87 return;
88 }
89
90 mpic = mpic_alloc(np, r.start,
91 MPIC_PRIMARY | MPIC_WANTS_RESET | MPIC_BIG_ENDIAN,
92 0, 256, " OpenPIC ");
93 BUG_ON(mpic == NULL);
94 of_node_put(np);
95
96 mpic_init(mpic);
97
98 #ifdef CONFIG_CPM2
99 /* Setup CPM2 PIC */
100 np = of_find_compatible_node(NULL, NULL, "fsl,cpm2-pic");
101 if (np == NULL) {
102 printk(KERN_ERR "PIC init: can not find fsl,cpm2-pic node\n");
103 return;
104 }
105 irq = irq_of_parse_and_map(np, 0);
106
107 cpm2_pic_init(np);
108 of_node_put(np);
109 irq_set_chained_handler(irq, cpm2_cascade);
110 #endif
111 }
112
113 #ifdef CONFIG_CPM2
114 /*
115 * Setup I/O ports
116 */
117 struct cpm_pin {
118 int port, pin, flags;
119 };
120
121 static struct cpm_pin __initdata ksi8560_pins[] = {
122 /* SCC1 */
123 {3, 29, CPM_PIN_OUTPUT | CPM_PIN_PRIMARY},
124 {3, 30, CPM_PIN_OUTPUT | CPM_PIN_SECONDARY},
125 {3, 31, CPM_PIN_INPUT | CPM_PIN_PRIMARY},
126
127 /* SCC2 */
128 {3, 26, CPM_PIN_OUTPUT | CPM_PIN_PRIMARY},
129 {3, 27, CPM_PIN_OUTPUT | CPM_PIN_PRIMARY},
130 {3, 28, CPM_PIN_INPUT | CPM_PIN_PRIMARY},
131
132 /* FCC1 */
133 {0, 14, CPM_PIN_INPUT | CPM_PIN_PRIMARY},
134 {0, 15, CPM_PIN_INPUT | CPM_PIN_PRIMARY},
135 {0, 16, CPM_PIN_INPUT | CPM_PIN_PRIMARY},
136 {0, 17, CPM_PIN_INPUT | CPM_PIN_PRIMARY},
137 {0, 18, CPM_PIN_OUTPUT | CPM_PIN_PRIMARY},
138 {0, 19, CPM_PIN_OUTPUT | CPM_PIN_PRIMARY},
139 {0, 20, CPM_PIN_OUTPUT | CPM_PIN_PRIMARY},
140 {0, 21, CPM_PIN_OUTPUT | CPM_PIN_PRIMARY},
141 {0, 26, CPM_PIN_INPUT | CPM_PIN_SECONDARY},
142 {0, 27, CPM_PIN_INPUT | CPM_PIN_SECONDARY},
143 {0, 28, CPM_PIN_OUTPUT | CPM_PIN_SECONDARY},
144 {0, 29, CPM_PIN_OUTPUT | CPM_PIN_SECONDARY},
145 {0, 30, CPM_PIN_INPUT | CPM_PIN_SECONDARY},
146 {0, 31, CPM_PIN_INPUT | CPM_PIN_SECONDARY},
147 {2, 23, CPM_PIN_INPUT | CPM_PIN_PRIMARY}, /* CLK9 */
148 {2, 22, CPM_PIN_INPUT | CPM_PIN_PRIMARY}, /* CLK10 */
149
150 };
151
152 static void __init init_ioports(void)
153 {
154 int i;
155
156 for (i = 0; i < ARRAY_SIZE(ksi8560_pins); i++) {
157 struct cpm_pin *pin = &ksi8560_pins[i];
158 cpm2_set_pin(pin->port, pin->pin, pin->flags);
159 }
160
161 cpm2_clk_setup(CPM_CLK_SCC1, CPM_BRG1, CPM_CLK_RX);
162 cpm2_clk_setup(CPM_CLK_SCC1, CPM_BRG1, CPM_CLK_TX);
163 cpm2_clk_setup(CPM_CLK_SCC2, CPM_BRG2, CPM_CLK_RX);
164 cpm2_clk_setup(CPM_CLK_SCC2, CPM_BRG2, CPM_CLK_TX);
165 cpm2_clk_setup(CPM_CLK_FCC1, CPM_CLK9, CPM_CLK_RX);
166 cpm2_clk_setup(CPM_CLK_FCC1, CPM_CLK10, CPM_CLK_TX);
167 }
168 #endif
169
170 /*
171 * Setup the architecture
172 */
173 static void __init ksi8560_setup_arch(void)
174 {
175 struct device_node *cpld;
176
177 cpld = of_find_compatible_node(NULL, NULL, "emerson,KSI8560-cpld");
178 if (cpld)
179 cpld_base = of_iomap(cpld, 0);
180 else
181 printk(KERN_ERR "Can't find CPLD in device tree\n");
182
183 if (ppc_md.progress)
184 ppc_md.progress("ksi8560_setup_arch()", 0);
185
186 #ifdef CONFIG_CPM2
187 cpm2_reset();
188 init_ioports();
189 #endif
190 }
191
192 static void ksi8560_show_cpuinfo(struct seq_file *m)
193 {
194 uint pvid, svid, phid1;
195
196 pvid = mfspr(SPRN_PVR);
197 svid = mfspr(SPRN_SVR);
198
199 seq_printf(m, "Vendor\t\t: Emerson Network Power\n");
200 seq_printf(m, "Board\t\t: KSI8560\n");
201
202 if (cpld_base) {
203 seq_printf(m, "Hardware rev\t: %d\n",
204 in_8(cpld_base + KSI8560_CPLD_HVR));
205 seq_printf(m, "CPLD rev\t: %d\n",
206 in_8(cpld_base + KSI8560_CPLD_PVR));
207 } else
208 seq_printf(m, "Unknown Hardware and CPLD revs\n");
209
210 seq_printf(m, "PVR\t\t: 0x%x\n", pvid);
211 seq_printf(m, "SVR\t\t: 0x%x\n", svid);
212
213 /* Display cpu Pll setting */
214 phid1 = mfspr(SPRN_HID1);
215 seq_printf(m, "PLL setting\t: 0x%x\n", ((phid1 >> 24) & 0x3f));
216 }
217
218 static struct of_device_id __initdata of_bus_ids[] = {
219 { .type = "soc", },
220 { .type = "simple-bus", },
221 { .name = "cpm", },
222 { .name = "localbus", },
223 { .compatible = "gianfar", },
224 {},
225 };
226
227 static int __init declare_of_platform_devices(void)
228 {
229 of_platform_bus_probe(NULL, of_bus_ids, NULL);
230
231 return 0;
232 }
233 machine_device_initcall(ksi8560, declare_of_platform_devices);
234
235 /*
236 * Called very early, device-tree isn't unflattened
237 */
238 static int __init ksi8560_probe(void)
239 {
240 unsigned long root = of_get_flat_dt_root();
241
242 return of_flat_dt_is_compatible(root, "emerson,KSI8560");
243 }
244
245 define_machine(ksi8560) {
246 .name = "KSI8560",
247 .probe = ksi8560_probe,
248 .setup_arch = ksi8560_setup_arch,
249 .init_IRQ = ksi8560_pic_init,
250 .show_cpuinfo = ksi8560_show_cpuinfo,
251 .get_irq = mpic_get_irq,
252 .restart = machine_restart,
253 .calibrate_decr = generic_calibrate_decr,
254 };
This page took 0.0385 seconds and 5 git commands to generate.