Merge git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6
[wrt350n-kernel.git] / arch / powerpc / platforms / 85xx / mpc85xx_ds.c
blobbdb3d0b38cd2789b1cde4d63f7ffcad2a9af6336
1 /*
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>
24 #include <asm/time.h>
25 #include <asm/machdep.h>
26 #include <asm/pci-bridge.h>
27 #include <mm/mmu_decl.h>
28 #include <asm/prom.h>
29 #include <asm/udbg.h>
30 #include <asm/mpic.h>
31 #include <asm/i8259.h>
33 #include <sysdev/fsl_soc.h>
34 #include <sysdev/fsl_pci.h>
36 #undef DEBUG
38 #ifdef DEBUG
39 #define DBG(fmt, args...) printk(KERN_ERR "%s: " fmt, __FUNCTION__, ## args)
40 #else
41 #define DBG(fmt, args...)
42 #endif
44 #ifdef CONFIG_PPC_I8259
45 static void mpc85xx_8259_cascade(unsigned int irq, struct irq_desc *desc)
47 unsigned int cascade_irq = i8259_irq();
49 if (cascade_irq != NO_IRQ) {
50 generic_handle_irq(cascade_irq);
52 desc->chip->eoi(irq);
54 #endif /* CONFIG_PPC_I8259 */
56 void __init mpc85xx_ds_pic_init(void)
58 struct mpic *mpic;
59 struct resource r;
60 struct device_node *np = NULL;
61 #ifdef CONFIG_PPC_I8259
62 struct device_node *cascade_node = NULL;
63 int cascade_irq;
64 #endif
66 np = of_find_node_by_type(np, "open-pic");
68 if (np == NULL) {
69 printk(KERN_ERR "Could not find open-pic node\n");
70 return;
73 if (of_address_to_resource(np, 0, &r)) {
74 printk(KERN_ERR "Failed to map mpic register space\n");
75 of_node_put(np);
76 return;
79 mpic = mpic_alloc(np, r.start,
80 MPIC_PRIMARY | MPIC_WANTS_RESET | MPIC_BIG_ENDIAN,
81 0, 256, " OpenPIC ");
82 BUG_ON(mpic == NULL);
84 mpic_init(mpic);
86 #ifdef CONFIG_PPC_I8259
87 /* Initialize the i8259 controller */
88 for_each_node_by_type(np, "interrupt-controller")
89 if (of_device_is_compatible(np, "chrp,iic")) {
90 cascade_node = np;
91 break;
94 if (cascade_node == NULL) {
95 printk(KERN_DEBUG "Could not find i8259 PIC\n");
96 return;
99 cascade_irq = irq_of_parse_and_map(cascade_node, 0);
100 if (cascade_irq == NO_IRQ) {
101 printk(KERN_ERR "Failed to map cascade interrupt\n");
102 return;
105 DBG("mpc85xxds: cascade mapped to irq %d\n", cascade_irq);
107 i8259_init(cascade_node, 0);
108 of_node_put(cascade_node);
110 set_irq_chained_handler(cascade_irq, mpc85xx_8259_cascade);
111 #endif /* CONFIG_PPC_I8259 */
114 #ifdef CONFIG_PCI
115 static int primary_phb_addr;
116 extern int uses_fsl_uli_m1575;
117 extern int uli_exclude_device(struct pci_controller *hose,
118 u_char bus, u_char devfn);
120 static int mpc85xx_exclude_device(struct pci_controller *hose,
121 u_char bus, u_char devfn)
123 struct device_node* node;
124 struct resource rsrc;
126 node = hose->dn;
127 of_address_to_resource(node, 0, &rsrc);
129 if ((rsrc.start & 0xfffff) == primary_phb_addr) {
130 return uli_exclude_device(hose, bus, devfn);
133 return PCIBIOS_SUCCESSFUL;
135 #endif /* CONFIG_PCI */
138 * Setup the architecture
140 static void __init mpc85xx_ds_setup_arch(void)
142 #ifdef CONFIG_PCI
143 struct device_node *np;
144 #endif
146 if (ppc_md.progress)
147 ppc_md.progress("mpc85xx_ds_setup_arch()", 0);
149 #ifdef CONFIG_PCI
150 for_each_node_by_type(np, "pci") {
151 if (of_device_is_compatible(np, "fsl,mpc8540-pci") ||
152 of_device_is_compatible(np, "fsl,mpc8548-pcie")) {
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);
157 else
158 fsl_add_bridge(np, 0);
162 uses_fsl_uli_m1575 = 1;
163 ppc_md.pci_exclude_device = mpc85xx_exclude_device;
164 #endif
166 printk("MPC85xx DS board from Freescale Semiconductor\n");
170 * Called very early, device-tree isn't unflattened
172 static int __init mpc8544_ds_probe(void)
174 unsigned long root = of_get_flat_dt_root();
176 if (of_flat_dt_is_compatible(root, "MPC8544DS")) {
177 #ifdef CONFIG_PCI
178 primary_phb_addr = 0xb000;
179 #endif
180 return 1;
181 } else {
182 return 0;
187 * Called very early, device-tree isn't unflattened
189 static int __init mpc8572_ds_probe(void)
191 unsigned long root = of_get_flat_dt_root();
193 if (of_flat_dt_is_compatible(root, "fsl,MPC8572DS")) {
194 #ifdef CONFIG_PCI
195 primary_phb_addr = 0x8000;
196 #endif
197 return 1;
198 } else {
199 return 0;
203 define_machine(mpc8544_ds) {
204 .name = "MPC8544 DS",
205 .probe = mpc8544_ds_probe,
206 .setup_arch = mpc85xx_ds_setup_arch,
207 .init_IRQ = mpc85xx_ds_pic_init,
208 #ifdef CONFIG_PCI
209 .pcibios_fixup_bus = fsl_pcibios_fixup_bus,
210 #endif
211 .get_irq = mpic_get_irq,
212 .restart = fsl_rstcr_restart,
213 .calibrate_decr = generic_calibrate_decr,
214 .progress = udbg_progress,
217 define_machine(mpc8572_ds) {
218 .name = "MPC8572 DS",
219 .probe = mpc8572_ds_probe,
220 .setup_arch = mpc85xx_ds_setup_arch,
221 .init_IRQ = mpc85xx_ds_pic_init,
222 #ifdef CONFIG_PCI
223 .pcibios_fixup_bus = fsl_pcibios_fixup_bus,
224 #endif
225 .get_irq = mpic_get_irq,
226 .restart = fsl_rstcr_restart,
227 .calibrate_decr = generic_calibrate_decr,
228 .progress = udbg_progress,