1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * MPC85xx DS Board Setup
5 * Author Xianghua Xiao (x.xiao@freescale.com)
6 * Roy Zang <tie-fei.zang@freescale.com>
7 * - Add PCI/PCI Exprees support
8 * Copyright 2007 Freescale Semiconductor Inc.
11 #include <linux/stddef.h>
12 #include <linux/kernel.h>
13 #include <linux/pci.h>
14 #include <linux/kdev_t.h>
15 #include <linux/delay.h>
16 #include <linux/seq_file.h>
17 #include <linux/interrupt.h>
18 #include <linux/of_platform.h>
21 #include <asm/machdep.h>
22 #include <asm/pci-bridge.h>
23 #include <mm/mmu_decl.h>
27 #include <asm/i8259.h>
28 #include <asm/swiotlb.h>
30 #include <sysdev/fsl_soc.h>
31 #include <sysdev/fsl_pci.h>
39 #define DBG(fmt, args...) printk(KERN_ERR "%s: " fmt, __func__, ## args)
41 #define DBG(fmt, args...)
44 #ifdef CONFIG_PPC_I8259
45 static void mpc85xx_8259_cascade(struct irq_desc
*desc
)
47 struct irq_chip
*chip
= irq_desc_get_chip(desc
);
48 unsigned int cascade_irq
= i8259_irq();
51 generic_handle_irq(cascade_irq
);
53 chip
->irq_eoi(&desc
->irq_data
);
55 #endif /* CONFIG_PPC_I8259 */
57 void __init
mpc85xx_ds_pic_init(void)
60 #ifdef CONFIG_PPC_I8259
61 struct device_node
*np
;
62 struct device_node
*cascade_node
= NULL
;
65 if (of_machine_is_compatible("fsl,MPC8572DS-CAMP")) {
66 mpic
= mpic_alloc(NULL
, 0,
72 mpic
= mpic_alloc(NULL
, 0,
81 #ifdef CONFIG_PPC_I8259
82 /* Initialize the i8259 controller */
83 for_each_node_by_type(np
, "interrupt-controller")
84 if (of_device_is_compatible(np
, "chrp,iic")) {
89 if (cascade_node
== NULL
) {
90 printk(KERN_DEBUG
"Could not find i8259 PIC\n");
94 cascade_irq
= irq_of_parse_and_map(cascade_node
, 0);
96 printk(KERN_ERR
"Failed to map cascade interrupt\n");
100 DBG("mpc85xxds: cascade mapped to irq %d\n", cascade_irq
);
102 i8259_init(cascade_node
, 0);
103 of_node_put(cascade_node
);
105 irq_set_chained_handler(cascade_irq
, mpc85xx_8259_cascade
);
106 #endif /* CONFIG_PPC_I8259 */
110 extern int uli_exclude_device(struct pci_controller
*hose
,
111 u_char bus
, u_char devfn
);
113 static struct device_node
*pci_with_uli
;
115 static int mpc85xx_exclude_device(struct pci_controller
*hose
,
116 u_char bus
, u_char devfn
)
118 if (hose
->dn
== pci_with_uli
)
119 return uli_exclude_device(hose
, bus
, devfn
);
121 return PCIBIOS_SUCCESSFUL
;
123 #endif /* CONFIG_PCI */
125 static void __init
mpc85xx_ds_uli_init(void)
128 struct device_node
*node
;
130 /* See if we have a ULI under the primary */
132 node
= of_find_node_by_name(NULL
, "uli1575");
133 while ((pci_with_uli
= of_get_parent(node
))) {
137 if (pci_with_uli
== fsl_pci_primary
) {
138 ppc_md
.pci_exclude_device
= mpc85xx_exclude_device
;
146 * Setup the architecture
148 static void __init
mpc85xx_ds_setup_arch(void)
151 ppc_md
.progress("mpc85xx_ds_setup_arch()", 0);
154 fsl_pci_assign_primary();
155 mpc85xx_ds_uli_init();
158 printk("MPC85xx DS board from Freescale Semiconductor\n");
162 * Called very early, device-tree isn't unflattened
164 static int __init
mpc8544_ds_probe(void)
166 return !!of_machine_is_compatible("MPC8544DS");
169 machine_arch_initcall(mpc8544_ds
, mpc85xx_common_publish_devices
);
170 machine_arch_initcall(mpc8572_ds
, mpc85xx_common_publish_devices
);
171 machine_arch_initcall(p2020_ds
, mpc85xx_common_publish_devices
);
174 * Called very early, device-tree isn't unflattened
176 static int __init
mpc8572_ds_probe(void)
178 return !!of_machine_is_compatible("fsl,MPC8572DS");
182 * Called very early, device-tree isn't unflattened
184 static int __init
p2020_ds_probe(void)
186 return !!of_machine_is_compatible("fsl,P2020DS");
189 define_machine(mpc8544_ds
) {
190 .name
= "MPC8544 DS",
191 .probe
= mpc8544_ds_probe
,
192 .setup_arch
= mpc85xx_ds_setup_arch
,
193 .init_IRQ
= mpc85xx_ds_pic_init
,
195 .pcibios_fixup_bus
= fsl_pcibios_fixup_bus
,
196 .pcibios_fixup_phb
= fsl_pcibios_fixup_phb
,
198 .get_irq
= mpic_get_irq
,
199 .calibrate_decr
= generic_calibrate_decr
,
200 .progress
= udbg_progress
,
203 define_machine(mpc8572_ds
) {
204 .name
= "MPC8572 DS",
205 .probe
= mpc8572_ds_probe
,
206 .setup_arch
= mpc85xx_ds_setup_arch
,
207 .init_IRQ
= mpc85xx_ds_pic_init
,
209 .pcibios_fixup_bus
= fsl_pcibios_fixup_bus
,
210 .pcibios_fixup_phb
= fsl_pcibios_fixup_phb
,
212 .get_irq
= mpic_get_irq
,
213 .calibrate_decr
= generic_calibrate_decr
,
214 .progress
= udbg_progress
,
217 define_machine(p2020_ds
) {
219 .probe
= p2020_ds_probe
,
220 .setup_arch
= mpc85xx_ds_setup_arch
,
221 .init_IRQ
= mpc85xx_ds_pic_init
,
223 .pcibios_fixup_bus
= fsl_pcibios_fixup_bus
,
224 .pcibios_fixup_phb
= fsl_pcibios_fixup_phb
,
226 .get_irq
= mpic_get_irq
,
227 .calibrate_decr
= generic_calibrate_decr
,
228 .progress
= udbg_progress
,