powerpc: Fix personality handling in ppc64_personality()
[linux/fpc-iii.git] / arch / powerpc / platforms / 85xx / mpc85xx_ds.c
blob6d3265fe7718c7ff71785329133013ec1382c979
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>
22 #include <linux/of_platform.h>
23 #include <linux/memblock.h>
25 #include <asm/time.h>
26 #include <asm/machdep.h>
27 #include <asm/pci-bridge.h>
28 #include <mm/mmu_decl.h>
29 #include <asm/prom.h>
30 #include <asm/udbg.h>
31 #include <asm/mpic.h>
32 #include <asm/i8259.h>
33 #include <asm/swiotlb.h>
35 #include <sysdev/fsl_soc.h>
36 #include <sysdev/fsl_pci.h>
37 #include "smp.h"
39 #include "mpc85xx.h"
41 #undef DEBUG
43 #ifdef DEBUG
44 #define DBG(fmt, args...) printk(KERN_ERR "%s: " fmt, __func__, ## args)
45 #else
46 #define DBG(fmt, args...)
47 #endif
49 #ifdef CONFIG_PPC_I8259
50 static void mpc85xx_8259_cascade(unsigned int irq, struct irq_desc *desc)
52 struct irq_chip *chip = irq_desc_get_chip(desc);
53 unsigned int cascade_irq = i8259_irq();
55 if (cascade_irq != NO_IRQ) {
56 generic_handle_irq(cascade_irq);
58 chip->irq_eoi(&desc->irq_data);
60 #endif /* CONFIG_PPC_I8259 */
62 void __init mpc85xx_ds_pic_init(void)
64 struct mpic *mpic;
65 #ifdef CONFIG_PPC_I8259
66 struct device_node *np;
67 struct device_node *cascade_node = NULL;
68 int cascade_irq;
69 #endif
70 unsigned long root = of_get_flat_dt_root();
72 if (of_flat_dt_is_compatible(root, "fsl,MPC8572DS-CAMP")) {
73 mpic = mpic_alloc(NULL, 0,
74 MPIC_NO_RESET |
75 MPIC_BIG_ENDIAN |
76 MPIC_SINGLE_DEST_CPU,
77 0, 256, " OpenPIC ");
78 } else {
79 mpic = mpic_alloc(NULL, 0,
80 MPIC_BIG_ENDIAN |
81 MPIC_SINGLE_DEST_CPU,
82 0, 256, " OpenPIC ");
85 BUG_ON(mpic == NULL);
86 mpic_init(mpic);
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")) {
92 cascade_node = np;
93 break;
96 if (cascade_node == NULL) {
97 printk(KERN_DEBUG "Could not find i8259 PIC\n");
98 return;
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");
104 return;
107 DBG("mpc85xxds: cascade mapped to irq %d\n", cascade_irq);
109 i8259_init(cascade_node, 0);
110 of_node_put(cascade_node);
112 irq_set_chained_handler(cascade_irq, mpc85xx_8259_cascade);
113 #endif /* CONFIG_PPC_I8259 */
116 #ifdef CONFIG_PCI
117 extern int uli_exclude_device(struct pci_controller *hose,
118 u_char bus, u_char devfn);
120 static struct device_node *pci_with_uli;
122 static int mpc85xx_exclude_device(struct pci_controller *hose,
123 u_char bus, u_char devfn)
125 if (hose->dn == pci_with_uli)
126 return uli_exclude_device(hose, bus, devfn);
128 return PCIBIOS_SUCCESSFUL;
130 #endif /* CONFIG_PCI */
132 static void __init mpc85xx_ds_pci_init(void)
134 #ifdef CONFIG_PCI
135 struct device_node *node;
137 fsl_pci_init();
139 /* See if we have a ULI under the primary */
141 node = of_find_node_by_name(NULL, "uli1575");
142 while ((pci_with_uli = of_get_parent(node))) {
143 of_node_put(node);
144 node = pci_with_uli;
146 if (pci_with_uli == fsl_pci_primary) {
147 ppc_md.pci_exclude_device = mpc85xx_exclude_device;
148 break;
151 #endif
155 * Setup the architecture
157 static void __init mpc85xx_ds_setup_arch(void)
159 if (ppc_md.progress)
160 ppc_md.progress("mpc85xx_ds_setup_arch()", 0);
162 mpc85xx_ds_pci_init();
163 mpc85xx_smp_init();
165 printk("MPC85xx DS board from Freescale Semiconductor\n");
169 * Called very early, device-tree isn't unflattened
171 static int __init mpc8544_ds_probe(void)
173 unsigned long root = of_get_flat_dt_root();
175 return !!of_flat_dt_is_compatible(root, "MPC8544DS");
178 machine_device_initcall(mpc8544_ds, mpc85xx_common_publish_devices);
179 machine_device_initcall(mpc8572_ds, mpc85xx_common_publish_devices);
180 machine_device_initcall(p2020_ds, mpc85xx_common_publish_devices);
182 machine_arch_initcall(mpc8544_ds, swiotlb_setup_bus_notifier);
183 machine_arch_initcall(mpc8572_ds, swiotlb_setup_bus_notifier);
184 machine_arch_initcall(p2020_ds, swiotlb_setup_bus_notifier);
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 return !!of_flat_dt_is_compatible(root, "fsl,MPC8572DS");
197 * Called very early, device-tree isn't unflattened
199 static int __init p2020_ds_probe(void)
201 unsigned long root = of_get_flat_dt_root();
203 return !!of_flat_dt_is_compatible(root, "fsl,P2020DS");
206 define_machine(mpc8544_ds) {
207 .name = "MPC8544 DS",
208 .probe = mpc8544_ds_probe,
209 .setup_arch = mpc85xx_ds_setup_arch,
210 .init_IRQ = mpc85xx_ds_pic_init,
211 #ifdef CONFIG_PCI
212 .pcibios_fixup_bus = fsl_pcibios_fixup_bus,
213 #endif
214 .get_irq = mpic_get_irq,
215 .restart = fsl_rstcr_restart,
216 .calibrate_decr = generic_calibrate_decr,
217 .progress = udbg_progress,
220 define_machine(mpc8572_ds) {
221 .name = "MPC8572 DS",
222 .probe = mpc8572_ds_probe,
223 .setup_arch = mpc85xx_ds_setup_arch,
224 .init_IRQ = mpc85xx_ds_pic_init,
225 #ifdef CONFIG_PCI
226 .pcibios_fixup_bus = fsl_pcibios_fixup_bus,
227 #endif
228 .get_irq = mpic_get_irq,
229 .restart = fsl_rstcr_restart,
230 .calibrate_decr = generic_calibrate_decr,
231 .progress = udbg_progress,
234 define_machine(p2020_ds) {
235 .name = "P2020 DS",
236 .probe = p2020_ds_probe,
237 .setup_arch = mpc85xx_ds_setup_arch,
238 .init_IRQ = mpc85xx_ds_pic_init,
239 #ifdef CONFIG_PCI
240 .pcibios_fixup_bus = fsl_pcibios_fixup_bus,
241 #endif
242 .get_irq = mpic_get_irq,
243 .restart = fsl_rstcr_restart,
244 .calibrate_decr = generic_calibrate_decr,
245 .progress = udbg_progress,