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>
23 #include <linux/memblock.h>
25 #include <asm/system.h>
27 #include <asm/machdep.h>
28 #include <asm/pci-bridge.h>
29 #include <mm/mmu_decl.h>
33 #include <asm/i8259.h>
34 #include <asm/swiotlb.h>
36 #include <sysdev/fsl_soc.h>
37 #include <sysdev/fsl_pci.h>
45 #define DBG(fmt, args...) printk(KERN_ERR "%s: " fmt, __func__, ## args)
47 #define DBG(fmt, args...)
50 #ifdef CONFIG_PPC_I8259
51 static void mpc85xx_8259_cascade(unsigned int irq
, struct irq_desc
*desc
)
53 struct irq_chip
*chip
= irq_desc_get_chip(desc
);
54 unsigned int cascade_irq
= i8259_irq();
56 if (cascade_irq
!= NO_IRQ
) {
57 generic_handle_irq(cascade_irq
);
59 chip
->irq_eoi(&desc
->irq_data
);
61 #endif /* CONFIG_PPC_I8259 */
63 void __init
mpc85xx_ds_pic_init(void)
66 #ifdef CONFIG_PPC_I8259
67 struct device_node
*np
;
68 struct device_node
*cascade_node
= NULL
;
71 unsigned long root
= of_get_flat_dt_root();
73 if (of_flat_dt_is_compatible(root
, "fsl,MPC8572DS-CAMP")) {
74 mpic
= mpic_alloc(NULL
, 0,
75 MPIC_BIG_ENDIAN
| MPIC_BROKEN_FRR_NIRQS
|
79 mpic
= mpic_alloc(NULL
, 0,
81 MPIC_BIG_ENDIAN
| MPIC_BROKEN_FRR_NIRQS
|
89 #ifdef CONFIG_PPC_I8259
90 /* Initialize the i8259 controller */
91 for_each_node_by_type(np
, "interrupt-controller")
92 if (of_device_is_compatible(np
, "chrp,iic")) {
97 if (cascade_node
== NULL
) {
98 printk(KERN_DEBUG
"Could not find i8259 PIC\n");
102 cascade_irq
= irq_of_parse_and_map(cascade_node
, 0);
103 if (cascade_irq
== NO_IRQ
) {
104 printk(KERN_ERR
"Failed to map cascade interrupt\n");
108 DBG("mpc85xxds: cascade mapped to irq %d\n", cascade_irq
);
110 i8259_init(cascade_node
, 0);
111 of_node_put(cascade_node
);
113 irq_set_chained_handler(cascade_irq
, mpc85xx_8259_cascade
);
114 #endif /* CONFIG_PPC_I8259 */
118 static int primary_phb_addr
;
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
;
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
;
146 struct pci_controller
*hose
;
148 dma_addr_t max
= 0xffffffff;
151 ppc_md
.progress("mpc85xx_ds_setup_arch()", 0);
154 for_each_node_by_type(np
, "pci") {
155 if (of_device_is_compatible(np
, "fsl,mpc8540-pci") ||
156 of_device_is_compatible(np
, "fsl,mpc8548-pcie") ||
157 of_device_is_compatible(np
, "fsl,p2020-pcie")) {
158 struct resource rsrc
;
159 of_address_to_resource(np
, 0, &rsrc
);
160 if ((rsrc
.start
& 0xfffff) == primary_phb_addr
)
161 fsl_add_bridge(np
, 1);
163 fsl_add_bridge(np
, 0);
165 hose
= pci_find_hose_for_OF_device(np
);
166 max
= min(max
, hose
->dma_window_base_cur
+
167 hose
->dma_window_size
);
171 ppc_md
.pci_exclude_device
= mpc85xx_exclude_device
;
176 #ifdef CONFIG_SWIOTLB
177 if (memblock_end_of_DRAM() > max
) {
178 ppc_swiotlb_enable
= 1;
179 set_pci_dma_ops(&swiotlb_dma_ops
);
180 ppc_md
.pci_dma_dev_setup
= pci_dma_dev_setup_swiotlb
;
184 printk("MPC85xx DS board from Freescale Semiconductor\n");
188 * Called very early, device-tree isn't unflattened
190 static int __init
mpc8544_ds_probe(void)
192 unsigned long root
= of_get_flat_dt_root();
194 if (of_flat_dt_is_compatible(root
, "MPC8544DS")) {
196 primary_phb_addr
= 0xb000;
204 machine_device_initcall(mpc8544_ds
, mpc85xx_common_publish_devices
);
205 machine_device_initcall(mpc8572_ds
, mpc85xx_common_publish_devices
);
206 machine_device_initcall(p2020_ds
, mpc85xx_common_publish_devices
);
208 machine_arch_initcall(mpc8544_ds
, swiotlb_setup_bus_notifier
);
209 machine_arch_initcall(mpc8572_ds
, swiotlb_setup_bus_notifier
);
210 machine_arch_initcall(p2020_ds
, swiotlb_setup_bus_notifier
);
213 * Called very early, device-tree isn't unflattened
215 static int __init
mpc8572_ds_probe(void)
217 unsigned long root
= of_get_flat_dt_root();
219 if (of_flat_dt_is_compatible(root
, "fsl,MPC8572DS")) {
221 primary_phb_addr
= 0x8000;
230 * Called very early, device-tree isn't unflattened
232 static int __init
p2020_ds_probe(void)
234 unsigned long root
= of_get_flat_dt_root();
236 if (of_flat_dt_is_compatible(root
, "fsl,P2020DS")) {
238 primary_phb_addr
= 0x9000;
246 define_machine(mpc8544_ds
) {
247 .name
= "MPC8544 DS",
248 .probe
= mpc8544_ds_probe
,
249 .setup_arch
= mpc85xx_ds_setup_arch
,
250 .init_IRQ
= mpc85xx_ds_pic_init
,
252 .pcibios_fixup_bus
= fsl_pcibios_fixup_bus
,
254 .get_irq
= mpic_get_irq
,
255 .restart
= fsl_rstcr_restart
,
256 .calibrate_decr
= generic_calibrate_decr
,
257 .progress
= udbg_progress
,
260 define_machine(mpc8572_ds
) {
261 .name
= "MPC8572 DS",
262 .probe
= mpc8572_ds_probe
,
263 .setup_arch
= mpc85xx_ds_setup_arch
,
264 .init_IRQ
= mpc85xx_ds_pic_init
,
266 .pcibios_fixup_bus
= fsl_pcibios_fixup_bus
,
268 .get_irq
= mpic_get_irq
,
269 .restart
= fsl_rstcr_restart
,
270 .calibrate_decr
= generic_calibrate_decr
,
271 .progress
= udbg_progress
,
274 define_machine(p2020_ds
) {
276 .probe
= p2020_ds_probe
,
277 .setup_arch
= mpc85xx_ds_setup_arch
,
278 .init_IRQ
= mpc85xx_ds_pic_init
,
280 .pcibios_fixup_bus
= fsl_pcibios_fixup_bus
,
282 .get_irq
= mpic_get_irq
,
283 .restart
= fsl_rstcr_restart
,
284 .calibrate_decr
= generic_calibrate_decr
,
285 .progress
= udbg_progress
,