2 * MPC85xx DS Board Setup
4 * Author Xianghua Xiao (x.xiao@freescale.com)
5 * Roy Zang <tie-fei.zang@freescale.com>
6 * - Add PCI/PCI Exprees support
7 * Copyright 2007 Freescale Semiconductor Inc.
9 * This program is free software; you can redistribute it and/or modify it
10 * under the terms of the GNU General Public License as published by the
11 * Free Software Foundation; either version 2 of the License, or (at your
12 * option) any later version.
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/interrupt.h>
22 #include <linux/of_platform.h>
24 #include <asm/system.h>
26 #include <asm/machdep.h>
27 #include <asm/pci-bridge.h>
28 #include <mm/mmu_decl.h>
32 #include <asm/i8259.h>
34 #include <sysdev/fsl_soc.h>
35 #include <sysdev/fsl_pci.h>
40 #define DBG(fmt, args...) printk(KERN_ERR "%s: " fmt, __func__, ## args)
42 #define DBG(fmt, args...)
45 #ifdef CONFIG_PPC_I8259
46 static void mpc85xx_8259_cascade(unsigned int irq, struct irq_desc *desc)
48 unsigned int cascade_irq = i8259_irq();
50 if (cascade_irq != NO_IRQ) {
51 generic_handle_irq(cascade_irq);
55 #endif /* CONFIG_PPC_I8259 */
57 void __init mpc85xx_ds_pic_init(void)
61 struct device_node *np;
62 #ifdef CONFIG_PPC_I8259
63 struct device_node *cascade_node = NULL;
66 unsigned long root = of_get_flat_dt_root();
68 np = of_find_node_by_type(NULL, "open-pic");
70 printk(KERN_ERR "Could not find open-pic node\n");
74 if (of_address_to_resource(np, 0, &r)) {
75 printk(KERN_ERR "Failed to map mpic register space\n");
80 if (of_flat_dt_is_compatible(root, "fsl,MPC8572DS-CAMP")) {
81 mpic = mpic_alloc(np, r.start,
83 MPIC_BIG_ENDIAN | MPIC_BROKEN_FRR_NIRQS,
86 mpic = mpic_alloc(np, r.start,
87 MPIC_PRIMARY | MPIC_WANTS_RESET |
88 MPIC_BIG_ENDIAN | MPIC_BROKEN_FRR_NIRQS |
98 #ifdef CONFIG_PPC_I8259
99 /* Initialize the i8259 controller */
100 for_each_node_by_type(np, "interrupt-controller")
101 if (of_device_is_compatible(np, "chrp,iic")) {
106 if (cascade_node == NULL) {
107 printk(KERN_DEBUG "Could not find i8259 PIC\n");
111 cascade_irq = irq_of_parse_and_map(cascade_node, 0);
112 if (cascade_irq == NO_IRQ) {
113 printk(KERN_ERR "Failed to map cascade interrupt\n");
117 DBG("mpc85xxds: cascade mapped to irq %d\n", cascade_irq);
119 i8259_init(cascade_node, 0);
120 of_node_put(cascade_node);
122 set_irq_chained_handler(cascade_irq, mpc85xx_8259_cascade);
123 #endif /* CONFIG_PPC_I8259 */
127 static int primary_phb_addr;
128 extern int uli_exclude_device(struct pci_controller *hose,
129 u_char bus, u_char devfn);
131 static int mpc85xx_exclude_device(struct pci_controller *hose,
132 u_char bus, u_char devfn)
134 struct device_node* node;
135 struct resource rsrc;
138 of_address_to_resource(node, 0, &rsrc);
140 if ((rsrc.start & 0xfffff) == primary_phb_addr) {
141 return uli_exclude_device(hose, bus, devfn);
144 return PCIBIOS_SUCCESSFUL;
146 #endif /* CONFIG_PCI */
149 * Setup the architecture
151 static void __init mpc85xx_ds_setup_arch(void)
154 struct device_node *np;
158 ppc_md.progress("mpc85xx_ds_setup_arch()", 0);
161 for_each_node_by_type(np, "pci") {
162 if (of_device_is_compatible(np, "fsl,mpc8540-pci") ||
163 of_device_is_compatible(np, "fsl,mpc8548-pcie")) {
164 struct resource rsrc;
165 of_address_to_resource(np, 0, &rsrc);
166 if ((rsrc.start & 0xfffff) == primary_phb_addr)
167 fsl_add_bridge(np, 1);
169 fsl_add_bridge(np, 0);
173 ppc_md.pci_exclude_device = mpc85xx_exclude_device;
176 printk("MPC85xx DS board from Freescale Semiconductor\n");
180 * Called very early, device-tree isn't unflattened
182 static int __init mpc8544_ds_probe(void)
184 unsigned long root = of_get_flat_dt_root();
186 if (of_flat_dt_is_compatible(root, "MPC8544DS")) {
188 primary_phb_addr = 0xb000;
196 static struct of_device_id __initdata mpc85xxds_ids[] = {
198 { .compatible = "soc", },
199 { .compatible = "simple-bus", },
203 static int __init mpc85xxds_publish_devices(void)
205 return of_platform_bus_probe(NULL, mpc85xxds_ids, NULL);
207 machine_device_initcall(mpc8544_ds, mpc85xxds_publish_devices);
208 machine_device_initcall(mpc8572_ds, mpc85xxds_publish_devices);
211 * Called very early, device-tree isn't unflattened
213 static int __init mpc8572_ds_probe(void)
215 unsigned long root = of_get_flat_dt_root();
217 if (of_flat_dt_is_compatible(root, "fsl,MPC8572DS")) {
219 primary_phb_addr = 0x8000;
227 define_machine(mpc8544_ds) {
228 .name = "MPC8544 DS",
229 .probe = mpc8544_ds_probe,
230 .setup_arch = mpc85xx_ds_setup_arch,
231 .init_IRQ = mpc85xx_ds_pic_init,
233 .pcibios_fixup_bus = fsl_pcibios_fixup_bus,
235 .get_irq = mpic_get_irq,
236 .restart = fsl_rstcr_restart,
237 .calibrate_decr = generic_calibrate_decr,
238 .progress = udbg_progress,
241 define_machine(mpc8572_ds) {
242 .name = "MPC8572 DS",
243 .probe = mpc8572_ds_probe,
244 .setup_arch = mpc85xx_ds_setup_arch,
245 .init_IRQ = mpc85xx_ds_pic_init,
247 .pcibios_fixup_bus = fsl_pcibios_fixup_bus,
249 .get_irq = mpic_get_irq,
250 .restart = fsl_rstcr_restart,
251 .calibrate_decr = generic_calibrate_decr,
252 .progress = udbg_progress,