blob: ceb0dac32ade5dc2696d7810df7749b5785b1b5c [file] [log] [blame]
Kumar Galaab2f4892009-10-22 16:35:07 -05001/*
2 * Corenet based SoC DS Setup
3 *
4 * Maintained by Kumar Gala (see MAINTAINERS for contact information)
5 *
Kumar Galab9a43342011-05-09 15:08:57 -05006 * Copyright 2009-2011 Freescale Semiconductor Inc.
Kumar Galaab2f4892009-10-22 16:35:07 -05007 *
8 * This program is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License as published by the
10 * Free Software Foundation; either version 2 of the License, or (at your
11 * option) any later version.
12 */
13
14#include <linux/kernel.h>
15#include <linux/pci.h>
16#include <linux/kdev_t.h>
17#include <linux/delay.h>
18#include <linux/interrupt.h>
Kumar Galaab2f4892009-10-22 16:35:07 -050019
Kumar Galaab2f4892009-10-22 16:35:07 -050020#include <asm/time.h>
21#include <asm/machdep.h>
22#include <asm/pci-bridge.h>
Kumar Gala6d251dd2011-05-19 21:59:23 -050023#include <asm/ppc-pci.h>
Kumar Galaab2f4892009-10-22 16:35:07 -050024#include <mm/mmu_decl.h>
25#include <asm/prom.h>
26#include <asm/udbg.h>
27#include <asm/mpic.h>
Kevin Hao512e2672013-09-26 09:42:26 +080028#include <asm/ehv_pic.h>
Zhao Qiang0f5a8692014-03-06 09:39:24 +080029#include <asm/qe_ic.h>
Kumar Galaab2f4892009-10-22 16:35:07 -050030
31#include <linux/of_platform.h>
32#include <sysdev/fsl_soc.h>
33#include <sysdev/fsl_pci.h>
Kyle Moffett582d3e02011-12-02 06:27:58 +000034#include "smp.h"
Zhao Qiang0f5a8692014-03-06 09:39:24 +080035#include "mpc85xx.h"
Kumar Galaab2f4892009-10-22 16:35:07 -050036
Kevin Haobefe7c12013-09-26 09:42:27 +080037void __init corenet_gen_pic_init(void)
Kumar Galaab2f4892009-10-22 16:35:07 -050038{
39 struct mpic *mpic;
Kyle Moffette55d7f72011-12-22 10:19:14 +000040 unsigned int flags = MPIC_BIG_ENDIAN | MPIC_SINGLE_DEST_CPU |
41 MPIC_NO_RESET;
Kumar Galaab2f4892009-10-22 16:35:07 -050042
Zhao Qiang0f5a8692014-03-06 09:39:24 +080043 struct device_node *np;
44
Kumar Galaab2f4892009-10-22 16:35:07 -050045 if (ppc_md.get_irq == mpic_get_coreint_irq)
46 flags |= MPIC_ENABLE_COREINT;
47
Kumar Galab9faa362012-01-05 11:09:04 -060048 mpic = mpic_alloc(NULL, 0, flags, 0, 512, " OpenPIC ");
Kumar Galaab2f4892009-10-22 16:35:07 -050049 BUG_ON(mpic == NULL);
50
51 mpic_init(mpic);
Zhao Qiang0f5a8692014-03-06 09:39:24 +080052
53 np = of_find_compatible_node(NULL, NULL, "fsl,qe-ic");
54 if (np) {
55 qe_ic_init(np, 0, qe_ic_cascade_low_mpic,
56 qe_ic_cascade_high_mpic);
57 of_node_put(np);
58 }
Kumar Galaab2f4892009-10-22 16:35:07 -050059}
60
Kumar Galaab2f4892009-10-22 16:35:07 -050061/*
62 * Setup the architecture
63 */
Kevin Haobefe7c12013-09-26 09:42:27 +080064void __init corenet_gen_setup_arch(void)
Kumar Galaab2f4892009-10-22 16:35:07 -050065{
Kumar Galaab2f4892009-10-22 16:35:07 -050066 mpc85xx_smp_init();
Kumar Galaab2f4892009-10-22 16:35:07 -050067
Jia Hongtao905e75c2012-08-28 15:44:08 +080068 swiotlb_detect_4g();
69
Valentin Longchamp497c8b602014-04-22 11:30:31 +020070 pr_info("%s board\n", ppc_md.name);
Zhao Qiang0f5a8692014-03-06 09:39:24 +080071
72 mpc85xx_qe_init();
Kumar Galaab2f4892009-10-22 16:35:07 -050073}
74
Greg Kroah-Hartmancad5cef2012-12-21 14:04:10 -080075static const struct of_device_id of_device_ids[] = {
Kumar Galaab2f4892009-10-22 16:35:07 -050076 {
77 .compatible = "simple-bus"
78 },
79 {
Kai Jiang077200c2011-11-12 20:02:31 +080080 .compatible = "fsl,srio",
Kumar Galaab2f4892009-10-22 16:35:07 -050081 },
Kumar Galab9a43342011-05-09 15:08:57 -050082 {
83 .compatible = "fsl,p4080-pcie",
84 },
85 {
86 .compatible = "fsl,qoriq-pcie-v2.2",
87 },
Timur Tabi4c30c142012-07-26 10:08:54 -050088 {
89 .compatible = "fsl,qoriq-pcie-v2.3",
90 },
91 {
92 .compatible = "fsl,qoriq-pcie-v2.4",
93 },
Kumar Galab9faa362012-01-05 11:09:04 -060094 {
95 .compatible = "fsl,qoriq-pcie-v3.0",
96 },
Zhao Qiang0f5a8692014-03-06 09:39:24 +080097 {
98 .compatible = "fsl,qe",
99 },
Timur Tabi3907ab22011-05-19 08:54:30 -0500100 /* The following two are for the Freescale hypervisor */
101 {
102 .name = "hypervisor",
103 },
104 {
105 .name = "handles",
106 },
Kumar Galaab2f4892009-10-22 16:35:07 -0500107 {}
108};
109
Kevin Haobefe7c12013-09-26 09:42:27 +0800110int __init corenet_gen_publish_devices(void)
Kumar Galaab2f4892009-10-22 16:35:07 -0500111{
112 return of_platform_bus_probe(NULL, of_device_ids, NULL);
113}
Kevin Hao512e2672013-09-26 09:42:26 +0800114
115static const char * const boards[] __initconst = {
116 "fsl,P2041RDB",
117 "fsl,P3041DS",
118 "fsl,P4080DS",
119 "fsl,P5020DS",
120 "fsl,P5040DS",
121 "fsl,T4240QDS",
122 "fsl,B4860QDS",
123 "fsl,B4420QDS",
124 "fsl,B4220QDS",
Valentin Longchamp497c8b602014-04-22 11:30:31 +0200125 "keymile,kmcoge4",
Kevin Hao512e2672013-09-26 09:42:26 +0800126 NULL
127};
128
129static const char * const hv_boards[] __initconst = {
130 "fsl,P2041RDB-hv",
131 "fsl,P3041DS-hv",
132 "fsl,P4080DS-hv",
133 "fsl,P5020DS-hv",
134 "fsl,P5040DS-hv",
135 "fsl,T4240QDS-hv",
136 "fsl,B4860QDS-hv",
137 "fsl,B4420QDS-hv",
138 "fsl,B4220QDS-hv",
139 NULL
140};
141
142/*
143 * Called very early, device-tree isn't unflattened
144 */
145static int __init corenet_generic_probe(void)
146{
147 unsigned long root = of_get_flat_dt_root();
148#ifdef CONFIG_SMP
149 extern struct smp_ops_t smp_85xx_ops;
150#endif
151
152 if (of_flat_dt_match(root, boards))
153 return 1;
154
155 /* Check if we're running under the Freescale hypervisor */
156 if (of_flat_dt_match(root, hv_boards)) {
157 ppc_md.init_IRQ = ehv_pic_init;
158 ppc_md.get_irq = ehv_pic_get_irq;
159 ppc_md.restart = fsl_hv_restart;
160 ppc_md.power_off = fsl_hv_halt;
161 ppc_md.halt = fsl_hv_halt;
162#ifdef CONFIG_SMP
163 /*
164 * Disable the timebase sync operations because we can't write
165 * to the timebase registers under the hypervisor.
166 */
167 smp_85xx_ops.give_timebase = NULL;
168 smp_85xx_ops.take_timebase = NULL;
169#endif
170 return 1;
171 }
172
173 return 0;
174}
175
176define_machine(corenet_generic) {
177 .name = "CoreNet Generic",
178 .probe = corenet_generic_probe,
Kevin Haobefe7c12013-09-26 09:42:27 +0800179 .setup_arch = corenet_gen_setup_arch,
180 .init_IRQ = corenet_gen_pic_init,
Kevin Hao512e2672013-09-26 09:42:26 +0800181#ifdef CONFIG_PCI
182 .pcibios_fixup_bus = fsl_pcibios_fixup_bus,
Wang Dongsheng48b16182014-03-20 11:19:37 +0800183 .pcibios_fixup_phb = fsl_pcibios_fixup_phb,
Kevin Hao512e2672013-09-26 09:42:26 +0800184#endif
185 .get_irq = mpic_get_coreint_irq,
186 .restart = fsl_rstcr_restart,
187 .calibrate_decr = generic_calibrate_decr,
188 .progress = udbg_progress,
189#ifdef CONFIG_PPC64
190 .power_save = book3e_idle,
191#else
192 .power_save = e500_idle,
193#endif
194};
195
Kevin Haobefe7c12013-09-26 09:42:27 +0800196machine_arch_initcall(corenet_generic, corenet_gen_publish_devices);
Kevin Hao512e2672013-09-26 09:42:26 +0800197
198#ifdef CONFIG_SWIOTLB
199machine_arch_initcall(corenet_generic, swiotlb_setup_bus_notifier);
200#endif