]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/blame - arch/powerpc/platforms/85xx/mpc8544_ds.c
[POWERPC] 8{5,6}xx: Fix build issue with !CONFIG_PCI
[mirror_ubuntu-artful-kernel.git] / arch / powerpc / platforms / 85xx / mpc8544_ds.c
CommitLineData
d93daf84
JL
1/*
2 * MPC8544 DS Board Setup
3 *
4 * Author Xianghua Xiao (x.xiao@freescale.com)
f16dab98
RZ
5 * Roy Zang <tie-fei.zang@freescale.com>
6 * - Add PCI/PCI Exprees support
d93daf84
JL
7 * Copyright 2007 Freescale Semiconductor Inc.
8 *
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.
13 */
14
15#include <linux/stddef.h>
16#include <linux/kernel.h>
f16dab98 17#include <linux/pci.h>
d93daf84
JL
18#include <linux/kdev_t.h>
19#include <linux/delay.h>
20#include <linux/seq_file.h>
f16dab98 21#include <linux/interrupt.h>
d93daf84
JL
22
23#include <asm/system.h>
24#include <asm/time.h>
25#include <asm/machdep.h>
f16dab98 26#include <asm/pci-bridge.h>
d93daf84
JL
27#include <asm/mpc85xx.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
34#include <sysdev/fsl_soc.h>
f16dab98 35#include <sysdev/fsl_pci.h>
d93daf84
JL
36#include "mpc85xx.h"
37
38#undef DEBUG
39
40#ifdef DEBUG
41#define DBG(fmt, args...) printk(KERN_ERR "%s: " fmt, __FUNCTION__, ## args)
42#else
43#define DBG(fmt, args...)
44#endif
45
f16dab98
RZ
46#ifdef CONFIG_PPC_I8259
47static void mpc8544_8259_cascade(unsigned int irq, struct irq_desc *desc)
48{
49 unsigned int cascade_irq = i8259_irq();
50
51 if (cascade_irq != NO_IRQ) {
52 generic_handle_irq(cascade_irq);
53 }
54 desc->chip->eoi(irq);
55}
56#endif /* CONFIG_PPC_I8259 */
d93daf84
JL
57
58void __init mpc8544_ds_pic_init(void)
59{
60 struct mpic *mpic;
61 struct resource r;
62 struct device_node *np = NULL;
63#ifdef CONFIG_PPC_I8259
64 struct device_node *cascade_node = NULL;
65 int cascade_irq;
66#endif
67
68 np = of_find_node_by_type(np, "open-pic");
69
70 if (np == NULL) {
71 printk(KERN_ERR "Could not find open-pic node\n");
72 return;
73 }
74
75 if (of_address_to_resource(np, 0, &r)) {
76 printk(KERN_ERR "Failed to map mpic register space\n");
77 of_node_put(np);
78 return;
79 }
80
d93daf84
JL
81 mpic = mpic_alloc(np, r.start,
82 MPIC_PRIMARY | MPIC_WANTS_RESET | MPIC_BIG_ENDIAN,
b533f8ae 83 0, 256, " OpenPIC ");
d93daf84
JL
84 BUG_ON(mpic == NULL);
85
d93daf84
JL
86 mpic_init(mpic);
87
88#ifdef CONFIG_PPC_I8259
89 /* Initialize the i8259 controller */
90 for_each_node_by_type(np, "interrupt-controller")
55b61fec 91 if (of_device_is_compatible(np, "chrp,iic")) {
d93daf84
JL
92 cascade_node = np;
93 break;
94 }
95
96 if (cascade_node == NULL) {
97 printk(KERN_DEBUG "Could not find i8259 PIC\n");
98 return;
99 }
100
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;
105 }
106
107 DBG("mpc8544ds: cascade mapped to irq %d\n", cascade_irq);
108
109 i8259_init(cascade_node, 0);
110 of_node_put(cascade_node);
111
112 set_irq_chained_handler(cascade_irq, mpc8544_8259_cascade);
113#endif /* CONFIG_PPC_I8259 */
114}
115
f16dab98 116#ifdef CONFIG_PCI
b66510cb
KG
117extern int uses_fsl_uli_m1575;
118extern int uli_exclude_device(struct pci_controller *hose,
119 u_char bus, u_char devfn);
f16dab98 120
b66510cb
KG
121static int mpc85xx_exclude_device(struct pci_controller *hose,
122 u_char bus, u_char devfn)
f16dab98 123{
b66510cb
KG
124 struct device_node* node;
125 struct resource rsrc;
f16dab98 126
b66510cb
KG
127 node = (struct device_node *)hose->arch_data;
128 of_address_to_resource(node, 0, &rsrc);
f16dab98 129
b66510cb
KG
130 if ((rsrc.start & 0xfffff) == 0xb000) {
131 return uli_exclude_device(hose, bus, devfn);
132 }
f16dab98 133
b66510cb 134 return PCIBIOS_SUCCESSFUL;
f16dab98 135}
f16dab98 136#endif /* CONFIG_PCI */
d93daf84
JL
137
138/*
139 * Setup the architecture
140 */
141static void __init mpc8544_ds_setup_arch(void)
142{
f16dab98
RZ
143#ifdef CONFIG_PCI
144 struct device_node *np;
145#endif
146
d93daf84
JL
147 if (ppc_md.progress)
148 ppc_md.progress("mpc8544_ds_setup_arch()", 0);
149
f16dab98
RZ
150#ifdef CONFIG_PCI
151 for (np = NULL; (np = of_find_node_by_type(np, "pci")) != NULL;) {
152 struct resource rsrc;
153 of_address_to_resource(np, 0, &rsrc);
154 if ((rsrc.start & 0xfffff) == 0xb000)
155 fsl_add_bridge(np, 1);
156 else
157 fsl_add_bridge(np, 0);
158 }
b66510cb
KG
159 uses_fsl_uli_m1575 = 1;
160 ppc_md.pci_exclude_device = mpc85xx_exclude_device;
f16dab98
RZ
161#endif
162
d93daf84
JL
163 printk("MPC8544 DS board from Freescale Semiconductor\n");
164}
165
d93daf84
JL
166/*
167 * Called very early, device-tree isn't unflattened
168 */
169static int __init mpc8544_ds_probe(void)
170{
171 unsigned long root = of_get_flat_dt_root();
172
173 return of_flat_dt_is_compatible(root, "MPC8544DS");
174}
175
176define_machine(mpc8544_ds) {
177 .name = "MPC8544 DS",
178 .probe = mpc8544_ds_probe,
179 .setup_arch = mpc8544_ds_setup_arch,
180 .init_IRQ = mpc8544_ds_pic_init,
2af8569d 181#ifdef CONFIG_PCI
f16dab98 182 .pcibios_fixup_bus = fsl_pcibios_fixup_bus,
2af8569d 183#endif
d93daf84
JL
184 .get_irq = mpic_get_irq,
185 .restart = mpc85xx_restart,
186 .calibrate_decr = generic_calibrate_decr,
187 .progress = udbg_progress,
188};