blob: 56f8c8f674df108d46d4f69866475b26ae1f1476 [file] [log] [blame]
Jon Loeligerd93daf82007-03-20 11:19:10 -05001/*
Kumar Gala7f503822007-08-17 09:26:40 -05002 * MPC85xx DS Board Setup
Jon Loeligerd93daf82007-03-20 11:19:10 -05003 *
4 * Author Xianghua Xiao (x.xiao@freescale.com)
Roy Zangf16dab92007-07-13 18:05:08 +08005 * Roy Zang <tie-fei.zang@freescale.com>
6 * - Add PCI/PCI Exprees support
Jon Loeligerd93daf82007-03-20 11:19:10 -05007 * 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>
Roy Zangf16dab92007-07-13 18:05:08 +080017#include <linux/pci.h>
Jon Loeligerd93daf82007-03-20 11:19:10 -050018#include <linux/kdev_t.h>
19#include <linux/delay.h>
20#include <linux/seq_file.h>
Roy Zangf16dab92007-07-13 18:05:08 +080021#include <linux/interrupt.h>
Sebastian Siewior1028d4f2008-03-15 00:01:30 +010022#include <linux/of_platform.h>
Yinghai Lu95f72d12010-07-12 14:36:09 +100023#include <linux/memblock.h>
Jon Loeligerd93daf82007-03-20 11:19:10 -050024
Jon Loeligerd93daf82007-03-20 11:19:10 -050025#include <asm/time.h>
26#include <asm/machdep.h>
Roy Zangf16dab92007-07-13 18:05:08 +080027#include <asm/pci-bridge.h>
Jon Loeligerd93daf82007-03-20 11:19:10 -050028#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>
Kumar Gala152d0182009-05-15 00:37:35 -050033#include <asm/swiotlb.h>
Jon Loeligerd93daf82007-03-20 11:19:10 -050034
35#include <sysdev/fsl_soc.h>
Roy Zangf16dab92007-07-13 18:05:08 +080036#include <sysdev/fsl_pci.h>
Kyle Moffett582d3e02011-12-02 06:27:58 +000037#include "smp.h"
Jon Loeligerd93daf82007-03-20 11:19:10 -050038
Dmitry Eremin-Solenikov543a07b2011-11-17 21:56:16 +040039#include "mpc85xx.h"
40
Jon Loeligerd93daf82007-03-20 11:19:10 -050041#undef DEBUG
42
43#ifdef DEBUG
Harvey Harrisone48b1b42008-03-29 08:21:07 +110044#define DBG(fmt, args...) printk(KERN_ERR "%s: " fmt, __func__, ## args)
Jon Loeligerd93daf82007-03-20 11:19:10 -050045#else
46#define DBG(fmt, args...)
47#endif
48
Roy Zangf16dab92007-07-13 18:05:08 +080049#ifdef CONFIG_PPC_I8259
Kumar Gala7f503822007-08-17 09:26:40 -050050static void mpc85xx_8259_cascade(unsigned int irq, struct irq_desc *desc)
Roy Zangf16dab92007-07-13 18:05:08 +080051{
Thomas Gleixnerec775d02011-03-25 16:45:20 +010052 struct irq_chip *chip = irq_desc_get_chip(desc);
Roy Zangf16dab92007-07-13 18:05:08 +080053 unsigned int cascade_irq = i8259_irq();
54
55 if (cascade_irq != NO_IRQ) {
56 generic_handle_irq(cascade_irq);
57 }
Lennert Buytenhek712d5d72011-03-07 13:59:19 +000058 chip->irq_eoi(&desc->irq_data);
Roy Zangf16dab92007-07-13 18:05:08 +080059}
60#endif /* CONFIG_PPC_I8259 */
Jon Loeligerd93daf82007-03-20 11:19:10 -050061
Kumar Gala7f503822007-08-17 09:26:40 -050062void __init mpc85xx_ds_pic_init(void)
Jon Loeligerd93daf82007-03-20 11:19:10 -050063{
64 struct mpic *mpic;
Jon Loeligerd93daf82007-03-20 11:19:10 -050065#ifdef CONFIG_PPC_I8259
Kyle Moffett996983b2011-12-02 06:28:02 +000066 struct device_node *np;
Jon Loeligerd93daf82007-03-20 11:19:10 -050067 struct device_node *cascade_node = NULL;
68 int cascade_irq;
69#endif
Haiying Wang06be64a2008-11-13 07:46:12 -060070 unsigned long root = of_get_flat_dt_root();
Jon Loeligerd93daf82007-03-20 11:19:10 -050071
Haiying Wang06be64a2008-11-13 07:46:12 -060072 if (of_flat_dt_is_compatible(root, "fsl,MPC8572DS-CAMP")) {
Kyle Moffett996983b2011-12-02 06:28:02 +000073 mpic = mpic_alloc(NULL, 0,
Kyle Moffette55d7f72011-12-22 10:19:14 +000074 MPIC_NO_RESET |
Kyle Moffett50196092011-12-22 10:19:12 +000075 MPIC_BIG_ENDIAN |
Fabio Baltieria63e23b2011-07-12 09:49:43 +020076 MPIC_SINGLE_DEST_CPU,
Haiying Wang06be64a2008-11-13 07:46:12 -060077 0, 256, " OpenPIC ");
78 } else {
Kyle Moffett996983b2011-12-02 06:28:02 +000079 mpic = mpic_alloc(NULL, 0,
Kyle Moffett50196092011-12-22 10:19:12 +000080 MPIC_BIG_ENDIAN |
Kumar Gala3c10c9c2008-10-28 18:01:39 +000081 MPIC_SINGLE_DEST_CPU,
Kumar Galab533f8a2007-07-03 02:35:35 -050082 0, 256, " OpenPIC ");
Haiying Wang06be64a2008-11-13 07:46:12 -060083 }
84
Jon Loeligerd93daf82007-03-20 11:19:10 -050085 BUG_ON(mpic == NULL);
Jon Loeligerd93daf82007-03-20 11:19:10 -050086 mpic_init(mpic);
87
88#ifdef CONFIG_PPC_I8259
89 /* Initialize the i8259 controller */
90 for_each_node_by_type(np, "interrupt-controller")
Stephen Rothwell55b61fe2007-05-03 17:26:52 +100091 if (of_device_is_compatible(np, "chrp,iic")) {
Jon Loeligerd93daf82007-03-20 11:19:10 -050092 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
Kumar Gala7f503822007-08-17 09:26:40 -0500107 DBG("mpc85xxds: cascade mapped to irq %d\n", cascade_irq);
Jon Loeligerd93daf82007-03-20 11:19:10 -0500108
109 i8259_init(cascade_node, 0);
110 of_node_put(cascade_node);
111
Thomas Gleixnerec775d02011-03-25 16:45:20 +0100112 irq_set_chained_handler(cascade_irq, mpc85xx_8259_cascade);
Jon Loeligerd93daf82007-03-20 11:19:10 -0500113#endif /* CONFIG_PPC_I8259 */
114}
115
Roy Zangf16dab92007-07-13 18:05:08 +0800116#ifdef CONFIG_PCI
Kumar Galab66510c2007-08-16 23:55:55 -0500117extern int uli_exclude_device(struct pci_controller *hose,
118 u_char bus, u_char devfn);
Roy Zangf16dab92007-07-13 18:05:08 +0800119
Scott Wood91a6f342012-07-10 19:26:49 -0500120static struct device_node *pci_with_uli;
121
Kumar Galab66510c2007-08-16 23:55:55 -0500122static int mpc85xx_exclude_device(struct pci_controller *hose,
123 u_char bus, u_char devfn)
Roy Zangf16dab92007-07-13 18:05:08 +0800124{
Scott Wood91a6f342012-07-10 19:26:49 -0500125 if (hose->dn == pci_with_uli)
Kumar Galab66510c2007-08-16 23:55:55 -0500126 return uli_exclude_device(hose, bus, devfn);
Kumar Galab66510c2007-08-16 23:55:55 -0500127
128 return PCIBIOS_SUCCESSFUL;
Roy Zangf16dab92007-07-13 18:05:08 +0800129}
Roy Zangf16dab92007-07-13 18:05:08 +0800130#endif /* CONFIG_PCI */
Jon Loeligerd93daf82007-03-20 11:19:10 -0500131
Scott Wood91a6f342012-07-10 19:26:49 -0500132static void __init mpc85xx_ds_pci_init(void)
133{
134#ifdef CONFIG_PCI
135 struct device_node *node;
136
137 fsl_pci_init();
138
139 /* See if we have a ULI under the primary */
140
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;
145
146 if (pci_with_uli == fsl_pci_primary) {
147 ppc_md.pci_exclude_device = mpc85xx_exclude_device;
148 break;
149 }
150 }
151#endif
152}
153
Jon Loeligerd93daf82007-03-20 11:19:10 -0500154/*
155 * Setup the architecture
156 */
Kumar Gala7f503822007-08-17 09:26:40 -0500157static void __init mpc85xx_ds_setup_arch(void)
Jon Loeligerd93daf82007-03-20 11:19:10 -0500158{
159 if (ppc_md.progress)
Kumar Gala7f503822007-08-17 09:26:40 -0500160 ppc_md.progress("mpc85xx_ds_setup_arch()", 0);
Jon Loeligerd93daf82007-03-20 11:19:10 -0500161
Jia Hongtao688ba1d2012-08-03 18:14:10 +0800162 swiotlb_detect_4g();
Scott Wood91a6f342012-07-10 19:26:49 -0500163 mpc85xx_ds_pci_init();
Kumar Gala8bd39472008-11-19 09:25:29 -0600164 mpc85xx_smp_init();
Kumar Gala8bd39472008-11-19 09:25:29 -0600165
Kumar Gala7f503822007-08-17 09:26:40 -0500166 printk("MPC85xx DS board from Freescale Semiconductor\n");
Jon Loeligerd93daf82007-03-20 11:19:10 -0500167}
168
Jon Loeligerd93daf82007-03-20 11:19:10 -0500169/*
170 * Called very early, device-tree isn't unflattened
171 */
172static int __init mpc8544_ds_probe(void)
173{
174 unsigned long root = of_get_flat_dt_root();
175
Scott Wood91a6f342012-07-10 19:26:49 -0500176 return !!of_flat_dt_is_compatible(root, "MPC8544DS");
Jon Loeligerd93daf82007-03-20 11:19:10 -0500177}
178
Dmitry Eremin-Solenikov46d026a2011-11-17 21:56:17 +0400179machine_device_initcall(mpc8544_ds, mpc85xx_common_publish_devices);
180machine_device_initcall(mpc8572_ds, mpc85xx_common_publish_devices);
181machine_device_initcall(p2020_ds, mpc85xx_common_publish_devices);
Sebastian Siewior1028d4f2008-03-15 00:01:30 +0100182
Kumar Gala152d0182009-05-15 00:37:35 -0500183machine_arch_initcall(mpc8544_ds, swiotlb_setup_bus_notifier);
184machine_arch_initcall(mpc8572_ds, swiotlb_setup_bus_notifier);
185machine_arch_initcall(p2020_ds, swiotlb_setup_bus_notifier);
186
Kumar Gala5d54ddcb2007-09-11 01:25:43 -0500187/*
188 * Called very early, device-tree isn't unflattened
189 */
190static int __init mpc8572_ds_probe(void)
191{
192 unsigned long root = of_get_flat_dt_root();
193
Scott Wood91a6f342012-07-10 19:26:49 -0500194 return !!of_flat_dt_is_compatible(root, "fsl,MPC8572DS");
Kumar Gala01af9502009-04-15 14:38:40 -0500195}
196
197/*
198 * Called very early, device-tree isn't unflattened
199 */
200static int __init p2020_ds_probe(void)
201{
202 unsigned long root = of_get_flat_dt_root();
203
Scott Wood91a6f342012-07-10 19:26:49 -0500204 return !!of_flat_dt_is_compatible(root, "fsl,P2020DS");
Kumar Gala5d54ddcb2007-09-11 01:25:43 -0500205}
206
Jon Loeligerd93daf82007-03-20 11:19:10 -0500207define_machine(mpc8544_ds) {
208 .name = "MPC8544 DS",
209 .probe = mpc8544_ds_probe,
Kumar Gala7f503822007-08-17 09:26:40 -0500210 .setup_arch = mpc85xx_ds_setup_arch,
211 .init_IRQ = mpc85xx_ds_pic_init,
Kumar Gala2af85692007-09-10 14:30:33 -0500212#ifdef CONFIG_PCI
Roy Zangf16dab92007-07-13 18:05:08 +0800213 .pcibios_fixup_bus = fsl_pcibios_fixup_bus,
Kumar Gala2af85692007-09-10 14:30:33 -0500214#endif
Jon Loeligerd93daf82007-03-20 11:19:10 -0500215 .get_irq = mpic_get_irq,
Kumar Galae1c15752007-10-04 01:04:57 -0500216 .restart = fsl_rstcr_restart,
Jon Loeligerd93daf82007-03-20 11:19:10 -0500217 .calibrate_decr = generic_calibrate_decr,
218 .progress = udbg_progress,
219};
Kumar Gala5d54ddcb2007-09-11 01:25:43 -0500220
221define_machine(mpc8572_ds) {
222 .name = "MPC8572 DS",
223 .probe = mpc8572_ds_probe,
224 .setup_arch = mpc85xx_ds_setup_arch,
225 .init_IRQ = mpc85xx_ds_pic_init,
226#ifdef CONFIG_PCI
227 .pcibios_fixup_bus = fsl_pcibios_fixup_bus,
228#endif
229 .get_irq = mpic_get_irq,
Kumar Galae1c15752007-10-04 01:04:57 -0500230 .restart = fsl_rstcr_restart,
Kumar Gala5d54ddcb2007-09-11 01:25:43 -0500231 .calibrate_decr = generic_calibrate_decr,
232 .progress = udbg_progress,
233};
Kumar Gala01af9502009-04-15 14:38:40 -0500234
235define_machine(p2020_ds) {
236 .name = "P2020 DS",
237 .probe = p2020_ds_probe,
238 .setup_arch = mpc85xx_ds_setup_arch,
239 .init_IRQ = mpc85xx_ds_pic_init,
240#ifdef CONFIG_PCI
241 .pcibios_fixup_bus = fsl_pcibios_fixup_bus,
242#endif
243 .get_irq = mpic_get_irq,
244 .restart = fsl_rstcr_restart,
245 .calibrate_decr = generic_calibrate_decr,
246 .progress = udbg_progress,
247};