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>
23 #include <asm/system.h>
25 #include <asm/machdep.h>
26 #include <asm/pci-bridge.h>
27 #include <asm/mpc85xx.h>
28 #include <mm/mmu_decl.h>
32 #include <asm/i8259.h>
34 #include <sysdev/fsl_soc.h>
35 #include <sysdev/fsl_pci.h>
41 #define DBG(fmt, args...) printk(KERN_ERR "%s: " fmt, __FUNCTION__, ## args)
43 #define DBG(fmt, args...)
46 #ifdef CONFIG_PPC_I8259
47 static void mpc85xx_8259_cascade(unsigned int irq, struct irq_desc *desc)
49 unsigned int cascade_irq = i8259_irq();
51 if (cascade_irq != NO_IRQ) {
52 generic_handle_irq(cascade_irq);
56 #endif /* CONFIG_PPC_I8259 */
58 void __init mpc85xx_ds_pic_init(void)
62 struct device_node *np = NULL;
63 #ifdef CONFIG_PPC_I8259
64 struct device_node *cascade_node = NULL;
68 np = of_find_node_by_type(np, "open-pic");
71 printk(KERN_ERR "Could not find open-pic node\n");
75 if (of_address_to_resource(np, 0, &r)) {
76 printk(KERN_ERR "Failed to map mpic register space\n");
81 mpic = mpic_alloc(np, r.start,
82 MPIC_PRIMARY | MPIC_WANTS_RESET | MPIC_BIG_ENDIAN,
88 #ifdef CONFIG_PPC_I8259
89 /* Initialize the i8259 controller */
90 for_each_node_by_type(np, "interrupt-controller")
91 if (of_device_is_compatible(np, "chrp,iic")) {
96 if (cascade_node == NULL) {
97 printk(KERN_DEBUG "Could not find i8259 PIC\n");
101 cascade_irq = irq_of_parse_and_map(cascade_node, 0);
102 if (cascade_irq == NO_IRQ) {
103 printk(KERN_ERR "Failed to map cascade interrupt\n");
107 DBG("mpc85xxds: cascade mapped to irq %d\n", cascade_irq);
109 i8259_init(cascade_node, 0);
110 of_node_put(cascade_node);
112 set_irq_chained_handler(cascade_irq, mpc85xx_8259_cascade);
113 #endif /* CONFIG_PPC_I8259 */
117 static int primary_phb_addr;
118 extern int uses_fsl_uli_m1575;
119 extern int uli_exclude_device(struct pci_controller *hose,
120 u_char bus, u_char devfn);
122 static int mpc85xx_exclude_device(struct pci_controller *hose,
123 u_char bus, u_char devfn)
125 struct device_node* node;
126 struct resource rsrc;
128 node = (struct device_node *)hose->arch_data;
129 of_address_to_resource(node, 0, &rsrc);
131 if ((rsrc.start & 0xfffff) == primary_phb_addr) {
132 return uli_exclude_device(hose, bus, devfn);
135 return PCIBIOS_SUCCESSFUL;
137 #endif /* CONFIG_PCI */
140 * Setup the architecture
142 static void __init mpc85xx_ds_setup_arch(void)
145 struct device_node *np;
149 ppc_md.progress("mpc85xx_ds_setup_arch()", 0);
152 for (np = NULL; (np = of_find_node_by_type(np, "pci")) != NULL;) {
153 struct resource rsrc;
154 of_address_to_resource(np, 0, &rsrc);
155 if ((rsrc.start & 0xfffff) == primary_phb_addr)
156 fsl_add_bridge(np, 1);
158 fsl_add_bridge(np, 0);
160 uses_fsl_uli_m1575 = 1;
161 ppc_md.pci_exclude_device = mpc85xx_exclude_device;
164 printk("MPC85xx DS board from Freescale Semiconductor\n");
168 * Called very early, device-tree isn't unflattened
170 static int __init mpc8544_ds_probe(void)
172 unsigned long root = of_get_flat_dt_root();
174 if (of_flat_dt_is_compatible(root, "MPC8544DS")) {
176 primary_phb_addr = 0xb000;
185 * Called very early, device-tree isn't unflattened
187 static int __init mpc8572_ds_probe(void)
189 unsigned long root = of_get_flat_dt_root();
191 if (of_flat_dt_is_compatible(root, "fsl,MPC8572DS")) {
193 primary_phb_addr = 0x8000;
201 define_machine(mpc8544_ds) {
202 .name = "MPC8544 DS",
203 .probe = mpc8544_ds_probe,
204 .setup_arch = mpc85xx_ds_setup_arch,
205 .init_IRQ = mpc85xx_ds_pic_init,
207 .pcibios_fixup_bus = fsl_pcibios_fixup_bus,
209 .get_irq = mpic_get_irq,
210 .restart = mpc85xx_restart,
211 .calibrate_decr = generic_calibrate_decr,
212 .progress = udbg_progress,
215 define_machine(mpc8572_ds) {
216 .name = "MPC8572 DS",
217 .probe = mpc8572_ds_probe,
218 .setup_arch = mpc85xx_ds_setup_arch,
219 .init_IRQ = mpc85xx_ds_pic_init,
221 .pcibios_fixup_bus = fsl_pcibios_fixup_bus,
223 .get_irq = mpic_get_irq,
224 .restart = mpc85xx_restart,
225 .calibrate_decr = generic_calibrate_decr,
226 .progress = udbg_progress,