blob: f858306dba6aa517f3078f26cbd6b62861b3886c [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>
Jon Loeligerd93daf82007-03-20 11:19:10 -050023
Jon Loeligerd93daf82007-03-20 11:19:10 -050024#include <asm/time.h>
25#include <asm/machdep.h>
Roy Zangf16dab92007-07-13 18:05:08 +080026#include <asm/pci-bridge.h>
Jon Loeligerd93daf82007-03-20 11:19:10 -050027#include <mm/mmu_decl.h>
28#include <asm/prom.h>
29#include <asm/udbg.h>
30#include <asm/mpic.h>
31#include <asm/i8259.h>
Kumar Gala152d0182009-05-15 00:37:35 -050032#include <asm/swiotlb.h>
Jon Loeligerd93daf82007-03-20 11:19:10 -050033
34#include <sysdev/fsl_soc.h>
Roy Zangf16dab92007-07-13 18:05:08 +080035#include <sysdev/fsl_pci.h>
Kyle Moffett582d3e02011-12-02 06:27:58 +000036#include "smp.h"
Jon Loeligerd93daf82007-03-20 11:19:10 -050037
Dmitry Eremin-Solenikov543a07b2011-11-17 21:56:16 +040038#include "mpc85xx.h"
39
Jon Loeligerd93daf82007-03-20 11:19:10 -050040#undef DEBUG
41
42#ifdef DEBUG
Harvey Harrisone48b1b42008-03-29 08:21:07 +110043#define DBG(fmt, args...) printk(KERN_ERR "%s: " fmt, __func__, ## args)
Jon Loeligerd93daf82007-03-20 11:19:10 -050044#else
45#define DBG(fmt, args...)
46#endif
47
Roy Zangf16dab92007-07-13 18:05:08 +080048#ifdef CONFIG_PPC_I8259
Thomas Gleixnerbd0b9ac2015-09-14 10:42:37 +020049static void mpc85xx_8259_cascade(struct irq_desc *desc)
Roy Zangf16dab92007-07-13 18:05:08 +080050{
Thomas Gleixnerec775d02011-03-25 16:45:20 +010051 struct irq_chip *chip = irq_desc_get_chip(desc);
Roy Zangf16dab92007-07-13 18:05:08 +080052 unsigned int cascade_irq = i8259_irq();
53
54 if (cascade_irq != NO_IRQ) {
55 generic_handle_irq(cascade_irq);
56 }
Lennert Buytenhek712d5d72011-03-07 13:59:19 +000057 chip->irq_eoi(&desc->irq_data);
Roy Zangf16dab92007-07-13 18:05:08 +080058}
59#endif /* CONFIG_PPC_I8259 */
Jon Loeligerd93daf82007-03-20 11:19:10 -050060
Kumar Gala7f503822007-08-17 09:26:40 -050061void __init mpc85xx_ds_pic_init(void)
Jon Loeligerd93daf82007-03-20 11:19:10 -050062{
63 struct mpic *mpic;
Jon Loeligerd93daf82007-03-20 11:19:10 -050064#ifdef CONFIG_PPC_I8259
Kyle Moffett996983b2011-12-02 06:28:02 +000065 struct device_node *np;
Jon Loeligerd93daf82007-03-20 11:19:10 -050066 struct device_node *cascade_node = NULL;
67 int cascade_irq;
68#endif
Haiying Wang06be64a2008-11-13 07:46:12 -060069 unsigned long root = of_get_flat_dt_root();
Jon Loeligerd93daf82007-03-20 11:19:10 -050070
Haiying Wang06be64a2008-11-13 07:46:12 -060071 if (of_flat_dt_is_compatible(root, "fsl,MPC8572DS-CAMP")) {
Kyle Moffett996983b2011-12-02 06:28:02 +000072 mpic = mpic_alloc(NULL, 0,
Kyle Moffette55d7f72011-12-22 10:19:14 +000073 MPIC_NO_RESET |
Kyle Moffett50196092011-12-22 10:19:12 +000074 MPIC_BIG_ENDIAN |
Fabio Baltieria63e23b2011-07-12 09:49:43 +020075 MPIC_SINGLE_DEST_CPU,
Haiying Wang06be64a2008-11-13 07:46:12 -060076 0, 256, " OpenPIC ");
77 } else {
Kyle Moffett996983b2011-12-02 06:28:02 +000078 mpic = mpic_alloc(NULL, 0,
Kyle Moffett50196092011-12-22 10:19:12 +000079 MPIC_BIG_ENDIAN |
Kumar Gala3c10c9c2008-10-28 18:01:39 +000080 MPIC_SINGLE_DEST_CPU,
Kumar Galab533f8a2007-07-03 02:35:35 -050081 0, 256, " OpenPIC ");
Haiying Wang06be64a2008-11-13 07:46:12 -060082 }
83
Jon Loeligerd93daf82007-03-20 11:19:10 -050084 BUG_ON(mpic == NULL);
Jon Loeligerd93daf82007-03-20 11:19:10 -050085 mpic_init(mpic);
86
87#ifdef CONFIG_PPC_I8259
88 /* Initialize the i8259 controller */
89 for_each_node_by_type(np, "interrupt-controller")
Stephen Rothwell55b61fe2007-05-03 17:26:52 +100090 if (of_device_is_compatible(np, "chrp,iic")) {
Jon Loeligerd93daf82007-03-20 11:19:10 -050091 cascade_node = np;
92 break;
93 }
94
95 if (cascade_node == NULL) {
96 printk(KERN_DEBUG "Could not find i8259 PIC\n");
97 return;
98 }
99
100 cascade_irq = irq_of_parse_and_map(cascade_node, 0);
101 if (cascade_irq == NO_IRQ) {
102 printk(KERN_ERR "Failed to map cascade interrupt\n");
103 return;
104 }
105
Kumar Gala7f503822007-08-17 09:26:40 -0500106 DBG("mpc85xxds: cascade mapped to irq %d\n", cascade_irq);
Jon Loeligerd93daf82007-03-20 11:19:10 -0500107
108 i8259_init(cascade_node, 0);
109 of_node_put(cascade_node);
110
Thomas Gleixnerec775d02011-03-25 16:45:20 +0100111 irq_set_chained_handler(cascade_irq, mpc85xx_8259_cascade);
Jon Loeligerd93daf82007-03-20 11:19:10 -0500112#endif /* CONFIG_PPC_I8259 */
113}
114
Roy Zangf16dab92007-07-13 18:05:08 +0800115#ifdef CONFIG_PCI
Kumar Galab66510c2007-08-16 23:55:55 -0500116extern int uli_exclude_device(struct pci_controller *hose,
117 u_char bus, u_char devfn);
Roy Zangf16dab92007-07-13 18:05:08 +0800118
Scott Wood91a6f342012-07-10 19:26:49 -0500119static struct device_node *pci_with_uli;
120
Kumar Galab66510c2007-08-16 23:55:55 -0500121static int mpc85xx_exclude_device(struct pci_controller *hose,
122 u_char bus, u_char devfn)
Roy Zangf16dab92007-07-13 18:05:08 +0800123{
Scott Wood91a6f342012-07-10 19:26:49 -0500124 if (hose->dn == pci_with_uli)
Kumar Galab66510c2007-08-16 23:55:55 -0500125 return uli_exclude_device(hose, bus, devfn);
Kumar Galab66510c2007-08-16 23:55:55 -0500126
127 return PCIBIOS_SUCCESSFUL;
Roy Zangf16dab92007-07-13 18:05:08 +0800128}
Roy Zangf16dab92007-07-13 18:05:08 +0800129#endif /* CONFIG_PCI */
Jon Loeligerd93daf82007-03-20 11:19:10 -0500130
Jia Hongtao905e75c2012-08-28 15:44:08 +0800131static void __init mpc85xx_ds_uli_init(void)
Scott Wood91a6f342012-07-10 19:26:49 -0500132{
133#ifdef CONFIG_PCI
134 struct device_node *node;
135
Scott Wood91a6f342012-07-10 19:26:49 -0500136 /* See if we have a ULI under the primary */
137
138 node = of_find_node_by_name(NULL, "uli1575");
139 while ((pci_with_uli = of_get_parent(node))) {
140 of_node_put(node);
141 node = pci_with_uli;
142
143 if (pci_with_uli == fsl_pci_primary) {
144 ppc_md.pci_exclude_device = mpc85xx_exclude_device;
145 break;
146 }
147 }
148#endif
149}
150
Jon Loeligerd93daf82007-03-20 11:19:10 -0500151/*
152 * Setup the architecture
153 */
Kumar Gala7f503822007-08-17 09:26:40 -0500154static void __init mpc85xx_ds_setup_arch(void)
Jon Loeligerd93daf82007-03-20 11:19:10 -0500155{
156 if (ppc_md.progress)
Kumar Gala7f503822007-08-17 09:26:40 -0500157 ppc_md.progress("mpc85xx_ds_setup_arch()", 0);
Jon Loeligerd93daf82007-03-20 11:19:10 -0500158
Jia Hongtao688ba1d2012-08-03 18:14:10 +0800159 swiotlb_detect_4g();
Jia Hongtao905e75c2012-08-28 15:44:08 +0800160 fsl_pci_assign_primary();
161 mpc85xx_ds_uli_init();
Kumar Gala8bd39472008-11-19 09:25:29 -0600162 mpc85xx_smp_init();
Kumar Gala8bd39472008-11-19 09:25:29 -0600163
Kumar Gala7f503822007-08-17 09:26:40 -0500164 printk("MPC85xx DS board from Freescale Semiconductor\n");
Jon Loeligerd93daf82007-03-20 11:19:10 -0500165}
166
Jon Loeligerd93daf82007-03-20 11:19:10 -0500167/*
168 * Called very early, device-tree isn't unflattened
169 */
170static int __init mpc8544_ds_probe(void)
171{
172 unsigned long root = of_get_flat_dt_root();
173
Scott Wood91a6f342012-07-10 19:26:49 -0500174 return !!of_flat_dt_is_compatible(root, "MPC8544DS");
Jon Loeligerd93daf82007-03-20 11:19:10 -0500175}
176
Jia Hongtao905e75c2012-08-28 15:44:08 +0800177machine_arch_initcall(mpc8544_ds, mpc85xx_common_publish_devices);
178machine_arch_initcall(mpc8572_ds, mpc85xx_common_publish_devices);
179machine_arch_initcall(p2020_ds, mpc85xx_common_publish_devices);
Sebastian Siewior1028d4f2008-03-15 00:01:30 +0100180
Kumar Gala152d0182009-05-15 00:37:35 -0500181machine_arch_initcall(mpc8544_ds, swiotlb_setup_bus_notifier);
182machine_arch_initcall(mpc8572_ds, swiotlb_setup_bus_notifier);
183machine_arch_initcall(p2020_ds, swiotlb_setup_bus_notifier);
184
Kumar Gala5d54ddc2007-09-11 01:25:43 -0500185/*
186 * Called very early, device-tree isn't unflattened
187 */
188static int __init mpc8572_ds_probe(void)
189{
190 unsigned long root = of_get_flat_dt_root();
191
Scott Wood91a6f342012-07-10 19:26:49 -0500192 return !!of_flat_dt_is_compatible(root, "fsl,MPC8572DS");
Kumar Gala01af9502009-04-15 14:38:40 -0500193}
194
195/*
196 * Called very early, device-tree isn't unflattened
197 */
198static int __init p2020_ds_probe(void)
199{
200 unsigned long root = of_get_flat_dt_root();
201
Scott Wood91a6f342012-07-10 19:26:49 -0500202 return !!of_flat_dt_is_compatible(root, "fsl,P2020DS");
Kumar Gala5d54ddc2007-09-11 01:25:43 -0500203}
204
Jon Loeligerd93daf82007-03-20 11:19:10 -0500205define_machine(mpc8544_ds) {
206 .name = "MPC8544 DS",
207 .probe = mpc8544_ds_probe,
Kumar Gala7f503822007-08-17 09:26:40 -0500208 .setup_arch = mpc85xx_ds_setup_arch,
209 .init_IRQ = mpc85xx_ds_pic_init,
Kumar Gala2af85692007-09-10 14:30:33 -0500210#ifdef CONFIG_PCI
Roy Zangf16dab92007-07-13 18:05:08 +0800211 .pcibios_fixup_bus = fsl_pcibios_fixup_bus,
Wang Dongsheng48b16182014-03-20 11:19:37 +0800212 .pcibios_fixup_phb = fsl_pcibios_fixup_phb,
Kumar Gala2af85692007-09-10 14:30:33 -0500213#endif
Jon Loeligerd93daf82007-03-20 11:19:10 -0500214 .get_irq = mpic_get_irq,
Kumar Galae1c15752007-10-04 01:04:57 -0500215 .restart = fsl_rstcr_restart,
Jon Loeligerd93daf82007-03-20 11:19:10 -0500216 .calibrate_decr = generic_calibrate_decr,
217 .progress = udbg_progress,
218};
Kumar Gala5d54ddc2007-09-11 01:25:43 -0500219
220define_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,
Wang Dongsheng48b16182014-03-20 11:19:37 +0800227 .pcibios_fixup_phb = fsl_pcibios_fixup_phb,
Kumar Gala5d54ddc2007-09-11 01:25:43 -0500228#endif
229 .get_irq = mpic_get_irq,
Kumar Galae1c15752007-10-04 01:04:57 -0500230 .restart = fsl_rstcr_restart,
Kumar Gala5d54ddc2007-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,
Wang Dongsheng48b16182014-03-20 11:19:37 +0800242 .pcibios_fixup_phb = fsl_pcibios_fixup_phb,
Kumar Gala01af9502009-04-15 14:38:40 -0500243#endif
244 .get_irq = mpic_get_irq,
245 .restart = fsl_rstcr_restart,
246 .calibrate_decr = generic_calibrate_decr,
247 .progress = udbg_progress,
248};