blob: db214cd4c8220ebad46e845f47de857fc7088d47 [file] [log] [blame]
Poonam Aggrwalfb8e3e12009-08-07 21:05:16 +05301/*
2 * MPC85xx RDB Board Setup
3 *
Zhicheng Fan7e6af142012-02-10 14:48:15 +08004 * Copyright 2009,2012 Freescale Semiconductor Inc.
Poonam Aggrwalfb8e3e12009-08-07 21:05:16 +05305 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation; either version 2 of the License, or (at your
9 * option) any later version.
10 */
11
12#include <linux/stddef.h>
13#include <linux/kernel.h>
14#include <linux/pci.h>
15#include <linux/kdev_t.h>
16#include <linux/delay.h>
17#include <linux/seq_file.h>
18#include <linux/interrupt.h>
19#include <linux/of_platform.h>
20
21#include <asm/system.h>
22#include <asm/time.h>
23#include <asm/machdep.h>
24#include <asm/pci-bridge.h>
25#include <mm/mmu_decl.h>
26#include <asm/prom.h>
27#include <asm/udbg.h>
28#include <asm/mpic.h>
Zhicheng Fan04e358d2012-02-22 13:44:06 +080029#include <asm/qe.h>
30#include <asm/qe_ic.h>
31#include <asm/fsl_guts.h>
Poonam Aggrwalfb8e3e12009-08-07 21:05:16 +053032
33#include <sysdev/fsl_soc.h>
34#include <sysdev/fsl_pci.h>
Kyle Moffett582d3e02011-12-02 06:27:58 +000035#include "smp.h"
Poonam Aggrwalfb8e3e12009-08-07 21:05:16 +053036
Dmitry Eremin-Solenikov543a07b2011-11-17 21:56:16 +040037#include "mpc85xx.h"
38
Poonam Aggrwalfb8e3e12009-08-07 21:05:16 +053039#undef DEBUG
40
41#ifdef DEBUG
42#define DBG(fmt, args...) printk(KERN_ERR "%s: " fmt, __func__, ## args)
43#else
44#define DBG(fmt, args...)
45#endif
46
47
48void __init mpc85xx_rdb_pic_init(void)
49{
50 struct mpic *mpic;
Poonam Aggrwaldc2e6732009-09-19 22:43:56 +053051 unsigned long root = of_get_flat_dt_root();
Poonam Aggrwalfb8e3e12009-08-07 21:05:16 +053052
Zhicheng Fan04e358d2012-02-22 13:44:06 +080053#ifdef CONFIG_QUICC_ENGINE
54 struct device_node *np;
55#endif
56
Fabio Baltieria63e23b2011-07-12 09:49:43 +020057 if (of_flat_dt_is_compatible(root, "fsl,MPC85XXRDB-CAMP")) {
Kyle Moffette55d7f72011-12-22 10:19:14 +000058 mpic = mpic_alloc(NULL, 0, MPIC_NO_RESET |
Kyle Moffett50196092011-12-22 10:19:12 +000059 MPIC_BIG_ENDIAN |
Fabio Baltieria63e23b2011-07-12 09:49:43 +020060 MPIC_SINGLE_DEST_CPU,
Poonam Aggrwaldc2e6732009-09-19 22:43:56 +053061 0, 256, " OpenPIC ");
62 } else {
Kyle Moffett996983b2011-12-02 06:28:02 +000063 mpic = mpic_alloc(NULL, 0,
Kyle Moffett50196092011-12-22 10:19:12 +000064 MPIC_BIG_ENDIAN |
Poonam Aggrwalfb8e3e12009-08-07 21:05:16 +053065 MPIC_SINGLE_DEST_CPU,
66 0, 256, " OpenPIC ");
Poonam Aggrwaldc2e6732009-09-19 22:43:56 +053067 }
Poonam Aggrwalfb8e3e12009-08-07 21:05:16 +053068
69 BUG_ON(mpic == NULL);
Poonam Aggrwalfb8e3e12009-08-07 21:05:16 +053070 mpic_init(mpic);
Zhicheng Fan04e358d2012-02-22 13:44:06 +080071
72#ifdef CONFIG_QUICC_ENGINE
73 np = of_find_compatible_node(NULL, NULL, "fsl,qe-ic");
74 if (np) {
75 qe_ic_init(np, 0, qe_ic_cascade_low_mpic,
76 qe_ic_cascade_high_mpic);
77 of_node_put(np);
78
79 } else
80 pr_err("%s: Could not find qe-ic node\n", __func__);
81#endif
82
Poonam Aggrwalfb8e3e12009-08-07 21:05:16 +053083}
84
85/*
86 * Setup the architecture
87 */
Poonam Aggrwalfb8e3e12009-08-07 21:05:16 +053088static void __init mpc85xx_rdb_setup_arch(void)
89{
Zhicheng Fan04e358d2012-02-22 13:44:06 +080090#if defined(CONFIG_PCI) || defined(CONFIG_QUICC_ENGINE)
Poonam Aggrwalfb8e3e12009-08-07 21:05:16 +053091 struct device_node *np;
92#endif
93
94 if (ppc_md.progress)
95 ppc_md.progress("mpc85xx_rdb_setup_arch()", 0);
96
97#ifdef CONFIG_PCI
98 for_each_node_by_type(np, "pci") {
99 if (of_device_is_compatible(np, "fsl,mpc8548-pcie"))
100 fsl_add_bridge(np, 0);
101 }
102
103#endif
104
Poonam Aggrwalfb8e3e12009-08-07 21:05:16 +0530105 mpc85xx_smp_init();
Zhicheng Fan04e358d2012-02-22 13:44:06 +0800106
107#ifdef CONFIG_QUICC_ENGINE
108 np = of_find_compatible_node(NULL, NULL, "fsl,qe");
109 if (!np) {
110 pr_err("%s: Could not find Quicc Engine node\n", __func__);
111 goto qe_fail;
112 }
113
114 qe_reset();
115 of_node_put(np);
116
117 np = of_find_node_by_name(NULL, "par_io");
118 if (np) {
119 struct device_node *ucc;
120
121 par_io_init(np);
122 of_node_put(np);
123
124 for_each_node_by_name(ucc, "ucc")
125 par_io_of_config(ucc);
126
127 }
128#if defined(CONFIG_UCC_GETH) || defined(CONFIG_SERIAL_QE)
129 if (machine_is(p1025_rdb)) {
130
131 struct ccsr_guts_85xx __iomem *guts;
132
133 np = of_find_node_by_name(NULL, "global-utilities");
134 if (np) {
135 guts = of_iomap(np, 0);
136 if (!guts) {
137
138 pr_err("mpc85xx-rdb: could not map global utilities register\n");
139
140 } else {
141 /* P1025 has pins muxed for QE and other functions. To
142 * enable QE UEC mode, we need to set bit QE0 for UCC1
143 * in Eth mode, QE0 and QE3 for UCC5 in Eth mode, QE9
144 * and QE12 for QE MII management singals in PMUXCR
145 * register.
146 */
147 setbits32(&guts->pmuxcr, MPC85xx_PMUXCR_QE(0) |
148 MPC85xx_PMUXCR_QE(3) |
149 MPC85xx_PMUXCR_QE(9) |
150 MPC85xx_PMUXCR_QE(12));
151 iounmap(guts);
152 }
153 of_node_put(np);
154 }
155
156 }
157#endif
158
159qe_fail:
160#endif /* CONFIG_QUICC_ENGINE */
161
Poonam Aggrwalfb8e3e12009-08-07 21:05:16 +0530162 printk(KERN_INFO "MPC85xx RDB board from Freescale Semiconductor\n");
163}
164
Dmitry Eremin-Solenikov46d026a2011-11-17 21:56:17 +0400165machine_device_initcall(p2020_rdb, mpc85xx_common_publish_devices);
Tang Yuantian35ce1b52011-12-28 11:41:47 +0800166machine_device_initcall(p2020_rdb_pc, mpc85xx_common_publish_devices);
Jerry Huangd1fb1062012-03-14 17:08:27 +0800167machine_device_initcall(p1020_mbg_pc, mpc85xx_common_publish_devices);
Dmitry Eremin-Solenikov46d026a2011-11-17 21:56:17 +0400168machine_device_initcall(p1020_rdb, mpc85xx_common_publish_devices);
Zhicheng Fan7e6af142012-02-10 14:48:15 +0800169machine_device_initcall(p1020_rdb_pc, mpc85xx_common_publish_devices);
Jerry Huang1a244b82012-03-14 17:08:28 +0800170machine_device_initcall(p1020_utm_pc, mpc85xx_common_publish_devices);
Xu Jiuchengb73bdf42012-01-17 16:01:30 +0800171machine_device_initcall(p1021_rdb_pc, mpc85xx_common_publish_devices);
Zhicheng Fan68867802012-02-13 22:06:22 +0000172machine_device_initcall(p1025_rdb, mpc85xx_common_publish_devices);
Poonam Aggrwalfb8e3e12009-08-07 21:05:16 +0530173
174/*
175 * Called very early, device-tree isn't unflattened
176 */
177static int __init p2020_rdb_probe(void)
178{
179 unsigned long root = of_get_flat_dt_root();
180
181 if (of_flat_dt_is_compatible(root, "fsl,P2020RDB"))
182 return 1;
183 return 0;
184}
185
Poonam Aggrwal52dffd72009-09-25 09:50:28 +0530186static int __init p1020_rdb_probe(void)
187{
188 unsigned long root = of_get_flat_dt_root();
189
190 if (of_flat_dt_is_compatible(root, "fsl,P1020RDB"))
191 return 1;
192 return 0;
193}
194
Zhicheng Fan7e6af142012-02-10 14:48:15 +0800195static int __init p1020_rdb_pc_probe(void)
196{
197 unsigned long root = of_get_flat_dt_root();
198
199 return of_flat_dt_is_compatible(root, "fsl,P1020RDB-PC");
200}
201
Xu Jiuchengb73bdf42012-01-17 16:01:30 +0800202static int __init p1021_rdb_pc_probe(void)
203{
204 unsigned long root = of_get_flat_dt_root();
205
206 if (of_flat_dt_is_compatible(root, "fsl,P1021RDB-PC"))
207 return 1;
208 return 0;
209}
210
Tang Yuantian35ce1b52011-12-28 11:41:47 +0800211static int __init p2020_rdb_pc_probe(void)
212{
213 unsigned long root = of_get_flat_dt_root();
214
215 if (of_flat_dt_is_compatible(root, "fsl,P2020RDB-PC"))
216 return 1;
217 return 0;
218}
219
Zhicheng Fan68867802012-02-13 22:06:22 +0000220static int __init p1025_rdb_probe(void)
221{
222 unsigned long root = of_get_flat_dt_root();
223
224 return of_flat_dt_is_compatible(root, "fsl,P1025RDB");
225}
226
Jerry Huangd1fb1062012-03-14 17:08:27 +0800227static int __init p1020_mbg_pc_probe(void)
228{
229 unsigned long root = of_get_flat_dt_root();
230
231 return of_flat_dt_is_compatible(root, "fsl,P1020MBG-PC");
232}
233
Jerry Huang1a244b82012-03-14 17:08:28 +0800234static int __init p1020_utm_pc_probe(void)
235{
236 unsigned long root = of_get_flat_dt_root();
237
238 return of_flat_dt_is_compatible(root, "fsl,P1020UTM-PC");
239}
240
Poonam Aggrwalfb8e3e12009-08-07 21:05:16 +0530241define_machine(p2020_rdb) {
242 .name = "P2020 RDB",
243 .probe = p2020_rdb_probe,
244 .setup_arch = mpc85xx_rdb_setup_arch,
245 .init_IRQ = mpc85xx_rdb_pic_init,
246#ifdef CONFIG_PCI
247 .pcibios_fixup_bus = fsl_pcibios_fixup_bus,
248#endif
249 .get_irq = mpic_get_irq,
250 .restart = fsl_rstcr_restart,
251 .calibrate_decr = generic_calibrate_decr,
252 .progress = udbg_progress,
253};
Poonam Aggrwal52dffd72009-09-25 09:50:28 +0530254
255define_machine(p1020_rdb) {
256 .name = "P1020 RDB",
257 .probe = p1020_rdb_probe,
258 .setup_arch = mpc85xx_rdb_setup_arch,
259 .init_IRQ = mpc85xx_rdb_pic_init,
260#ifdef CONFIG_PCI
261 .pcibios_fixup_bus = fsl_pcibios_fixup_bus,
262#endif
263 .get_irq = mpic_get_irq,
264 .restart = fsl_rstcr_restart,
265 .calibrate_decr = generic_calibrate_decr,
266 .progress = udbg_progress,
267};
Xu Jiuchengb73bdf42012-01-17 16:01:30 +0800268
269define_machine(p1021_rdb_pc) {
270 .name = "P1021 RDB-PC",
271 .probe = p1021_rdb_pc_probe,
272 .setup_arch = mpc85xx_rdb_setup_arch,
273 .init_IRQ = mpc85xx_rdb_pic_init,
274#ifdef CONFIG_PCI
275 .pcibios_fixup_bus = fsl_pcibios_fixup_bus,
276#endif
277 .get_irq = mpic_get_irq,
278 .restart = fsl_rstcr_restart,
279 .calibrate_decr = generic_calibrate_decr,
280 .progress = udbg_progress,
281};
Tang Yuantian35ce1b52011-12-28 11:41:47 +0800282
283define_machine(p2020_rdb_pc) {
284 .name = "P2020RDB-PC",
285 .probe = p2020_rdb_pc_probe,
286 .setup_arch = mpc85xx_rdb_setup_arch,
287 .init_IRQ = mpc85xx_rdb_pic_init,
288#ifdef CONFIG_PCI
289 .pcibios_fixup_bus = fsl_pcibios_fixup_bus,
290#endif
291 .get_irq = mpic_get_irq,
292 .restart = fsl_rstcr_restart,
293 .calibrate_decr = generic_calibrate_decr,
294 .progress = udbg_progress,
295};
Zhicheng Fan68867802012-02-13 22:06:22 +0000296
297define_machine(p1025_rdb) {
298 .name = "P1025 RDB",
299 .probe = p1025_rdb_probe,
300 .setup_arch = mpc85xx_rdb_setup_arch,
301 .init_IRQ = mpc85xx_rdb_pic_init,
302#ifdef CONFIG_PCI
303 .pcibios_fixup_bus = fsl_pcibios_fixup_bus,
304#endif
305 .get_irq = mpic_get_irq,
306 .restart = fsl_rstcr_restart,
307 .calibrate_decr = generic_calibrate_decr,
308 .progress = udbg_progress,
309};
Jerry Huangd1fb1062012-03-14 17:08:27 +0800310
311define_machine(p1020_mbg_pc) {
312 .name = "P1020 MBG-PC",
313 .probe = p1020_mbg_pc_probe,
314 .setup_arch = mpc85xx_rdb_setup_arch,
315 .init_IRQ = mpc85xx_rdb_pic_init,
316#ifdef CONFIG_PCI
317 .pcibios_fixup_bus = fsl_pcibios_fixup_bus,
318#endif
319 .get_irq = mpic_get_irq,
320 .restart = fsl_rstcr_restart,
321 .calibrate_decr = generic_calibrate_decr,
322 .progress = udbg_progress,
323};
Jerry Huang1a244b82012-03-14 17:08:28 +0800324
325define_machine(p1020_utm_pc) {
326 .name = "P1020 UTM-PC",
327 .probe = p1020_utm_pc_probe,
328 .setup_arch = mpc85xx_rdb_setup_arch,
329 .init_IRQ = mpc85xx_rdb_pic_init,
330#ifdef CONFIG_PCI
331 .pcibios_fixup_bus = fsl_pcibios_fixup_bus,
332#endif
333 .get_irq = mpic_get_irq,
334 .restart = fsl_rstcr_restart,
335 .calibrate_decr = generic_calibrate_decr,
336 .progress = udbg_progress,
337};
Zhicheng Fan7e6af142012-02-10 14:48:15 +0800338
339define_machine(p1020_rdb_pc) {
340 .name = "P1020RDB-PC",
341 .probe = p1020_rdb_pc_probe,
342 .setup_arch = mpc85xx_rdb_setup_arch,
343 .init_IRQ = mpc85xx_rdb_pic_init,
344#ifdef CONFIG_PCI
345 .pcibios_fixup_bus = fsl_pcibios_fixup_bus,
346#endif
347 .get_irq = mpic_get_irq,
348 .restart = fsl_rstcr_restart,
349 .calibrate_decr = generic_calibrate_decr,
350 .progress = udbg_progress,
351};