blob: 9feccbbd4d96ce9998b4071543f7f528ecc1cfdb [file] [log] [blame]
Poonam Aggrwalfb8e3e12009-08-07 21:05:16 +05301/*
2 * MPC85xx RDB Board Setup
3 *
4 * Copyright 2009 Freescale Semiconductor Inc.
5 *
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>
29
30#include <sysdev/fsl_soc.h>
31#include <sysdev/fsl_pci.h>
32
Dmitry Eremin-Solenikov543a07b2011-11-17 21:56:16 +040033#include "mpc85xx.h"
34
Poonam Aggrwalfb8e3e12009-08-07 21:05:16 +053035#undef DEBUG
36
37#ifdef DEBUG
38#define DBG(fmt, args...) printk(KERN_ERR "%s: " fmt, __func__, ## args)
39#else
40#define DBG(fmt, args...)
41#endif
42
43
44void __init mpc85xx_rdb_pic_init(void)
45{
46 struct mpic *mpic;
47 struct resource r;
48 struct device_node *np;
Poonam Aggrwaldc2e6732009-09-19 22:43:56 +053049 unsigned long root = of_get_flat_dt_root();
Poonam Aggrwalfb8e3e12009-08-07 21:05:16 +053050
51 np = of_find_node_by_type(NULL, "open-pic");
52 if (np == NULL) {
53 printk(KERN_ERR "Could not find open-pic node\n");
54 return;
55 }
56
57 if (of_address_to_resource(np, 0, &r)) {
58 printk(KERN_ERR "Failed to map mpic register space\n");
59 of_node_put(np);
60 return;
61 }
62
Fabio Baltieria63e23b2011-07-12 09:49:43 +020063 if (of_flat_dt_is_compatible(root, "fsl,MPC85XXRDB-CAMP")) {
Poonam Aggrwaldc2e6732009-09-19 22:43:56 +053064 mpic = mpic_alloc(np, r.start,
65 MPIC_PRIMARY |
Fabio Baltieria63e23b2011-07-12 09:49:43 +020066 MPIC_BIG_ENDIAN | MPIC_BROKEN_FRR_NIRQS |
67 MPIC_SINGLE_DEST_CPU,
Poonam Aggrwaldc2e6732009-09-19 22:43:56 +053068 0, 256, " OpenPIC ");
69 } else {
70 mpic = mpic_alloc(np, r.start,
Poonam Aggrwalfb8e3e12009-08-07 21:05:16 +053071 MPIC_PRIMARY | MPIC_WANTS_RESET |
72 MPIC_BIG_ENDIAN | MPIC_BROKEN_FRR_NIRQS |
73 MPIC_SINGLE_DEST_CPU,
74 0, 256, " OpenPIC ");
Poonam Aggrwaldc2e6732009-09-19 22:43:56 +053075 }
Poonam Aggrwalfb8e3e12009-08-07 21:05:16 +053076
77 BUG_ON(mpic == NULL);
78 of_node_put(np);
79
80 mpic_init(mpic);
81
82}
83
84/*
85 * Setup the architecture
86 */
87#ifdef CONFIG_SMP
88extern void __init mpc85xx_smp_init(void);
89#endif
90static void __init mpc85xx_rdb_setup_arch(void)
91{
92#ifdef CONFIG_PCI
93 struct device_node *np;
94#endif
95
96 if (ppc_md.progress)
97 ppc_md.progress("mpc85xx_rdb_setup_arch()", 0);
98
99#ifdef CONFIG_PCI
100 for_each_node_by_type(np, "pci") {
101 if (of_device_is_compatible(np, "fsl,mpc8548-pcie"))
102 fsl_add_bridge(np, 0);
103 }
104
105#endif
106
107#ifdef CONFIG_SMP
108 mpc85xx_smp_init();
109#endif
110
111 printk(KERN_INFO "MPC85xx RDB board from Freescale Semiconductor\n");
112}
113
Dmitry Eremin-Solenikov46d026a2011-11-17 21:56:17 +0400114machine_device_initcall(p2020_rdb, mpc85xx_common_publish_devices);
115machine_device_initcall(p1020_rdb, mpc85xx_common_publish_devices);
Poonam Aggrwalfb8e3e12009-08-07 21:05:16 +0530116
117/*
118 * Called very early, device-tree isn't unflattened
119 */
120static int __init p2020_rdb_probe(void)
121{
122 unsigned long root = of_get_flat_dt_root();
123
124 if (of_flat_dt_is_compatible(root, "fsl,P2020RDB"))
125 return 1;
126 return 0;
127}
128
Poonam Aggrwal52dffd72009-09-25 09:50:28 +0530129static int __init p1020_rdb_probe(void)
130{
131 unsigned long root = of_get_flat_dt_root();
132
133 if (of_flat_dt_is_compatible(root, "fsl,P1020RDB"))
134 return 1;
135 return 0;
136}
137
Poonam Aggrwalfb8e3e12009-08-07 21:05:16 +0530138define_machine(p2020_rdb) {
139 .name = "P2020 RDB",
140 .probe = p2020_rdb_probe,
141 .setup_arch = mpc85xx_rdb_setup_arch,
142 .init_IRQ = mpc85xx_rdb_pic_init,
143#ifdef CONFIG_PCI
144 .pcibios_fixup_bus = fsl_pcibios_fixup_bus,
145#endif
146 .get_irq = mpic_get_irq,
147 .restart = fsl_rstcr_restart,
148 .calibrate_decr = generic_calibrate_decr,
149 .progress = udbg_progress,
150};
Poonam Aggrwal52dffd72009-09-25 09:50:28 +0530151
152define_machine(p1020_rdb) {
153 .name = "P1020 RDB",
154 .probe = p1020_rdb_probe,
155 .setup_arch = mpc85xx_rdb_setup_arch,
156 .init_IRQ = mpc85xx_rdb_pic_init,
157#ifdef CONFIG_PCI
158 .pcibios_fixup_bus = fsl_pcibios_fixup_bus,
159#endif
160 .get_irq = mpic_get_irq,
161 .restart = fsl_rstcr_restart,
162 .calibrate_decr = generic_calibrate_decr,
163 .progress = udbg_progress,
164};