1 // SPDX-License-Identifier: GPL-2.0-or-later
5 * Author Martyn Welch <martyn.welch@ge.com>
7 * Copyright 2010 GE Intelligent Platforms Embedded Systems, Inc.
9 * Based on: mpc85xx_ds.c (MPC85xx DS Board Setup)
10 * Copyright 2007 Freescale Semiconductor Inc.
13 #include <linux/stddef.h>
14 #include <linux/kernel.h>
15 #include <linux/pci.h>
16 #include <linux/kdev_t.h>
17 #include <linux/delay.h>
18 #include <linux/seq_file.h>
19 #include <linux/interrupt.h>
20 #include <linux/of_platform.h>
23 #include <asm/machdep.h>
24 #include <asm/pci-bridge.h>
25 #include <mm/mmu_decl.h>
29 #include <asm/swiotlb.h>
30 #include <asm/nvram.h>
32 #include <sysdev/fsl_soc.h>
33 #include <sysdev/fsl_pci.h>
37 #include <sysdev/ge/ge_pic.h>
39 void __iomem
*imp3a_regs
;
41 void __init
ge_imp3a_pic_init(void)
44 struct device_node
*np
;
45 struct device_node
*cascade_node
= NULL
;
47 if (of_machine_is_compatible("fsl,MPC8572DS-CAMP")) {
48 mpic
= mpic_alloc(NULL
, 0,
54 mpic
= mpic_alloc(NULL
, 0,
63 * There is a simple interrupt handler in the main FPGA, this needs
64 * to be cascaded into the MPIC
66 for_each_node_by_type(np
, "interrupt-controller")
67 if (of_device_is_compatible(np
, "gef,fpga-pic-1.00")) {
72 if (cascade_node
== NULL
) {
73 printk(KERN_WARNING
"IMP3A: No FPGA PIC\n");
77 gef_pic_init(cascade_node
);
78 of_node_put(cascade_node
);
81 static void ge_imp3a_pci_assign_primary(void)
84 struct device_node
*np
;
87 for_each_node_by_type(np
, "pci") {
88 if (of_device_is_compatible(np
, "fsl,mpc8540-pci") ||
89 of_device_is_compatible(np
, "fsl,mpc8548-pcie") ||
90 of_device_is_compatible(np
, "fsl,p2020-pcie")) {
91 of_address_to_resource(np
, 0, &rsrc
);
92 if ((rsrc
.start
& 0xfffff) == 0x9000)
100 * Setup the architecture
102 static void __init
ge_imp3a_setup_arch(void)
104 struct device_node
*regs
;
107 ppc_md
.progress("ge_imp3a_setup_arch()", 0);
111 ge_imp3a_pci_assign_primary();
115 /* Remap basic board registers */
116 regs
= of_find_compatible_node(NULL
, NULL
, "ge,imp3a-fpga-regs");
118 imp3a_regs
= of_iomap(regs
, 0);
119 if (imp3a_regs
== NULL
)
120 printk(KERN_WARNING
"Unable to map board registers\n");
124 #if defined(CONFIG_MMIO_NVRAM)
128 printk(KERN_INFO
"GE Intelligent Platforms IMP3A 3U cPCI SBC\n");
131 /* Return the PCB revision */
132 static unsigned int ge_imp3a_get_pcb_rev(void)
136 reg
= ioread16(imp3a_regs
);
137 return (reg
>> 8) & 0xff;
140 /* Return the board (software) revision */
141 static unsigned int ge_imp3a_get_board_rev(void)
145 reg
= ioread16(imp3a_regs
+ 0x2);
149 /* Return the FPGA revision */
150 static unsigned int ge_imp3a_get_fpga_rev(void)
154 reg
= ioread16(imp3a_regs
+ 0x2);
155 return (reg
>> 8) & 0xff;
158 /* Return compactPCI Geographical Address */
159 static unsigned int ge_imp3a_get_cpci_geo_addr(void)
163 reg
= ioread16(imp3a_regs
+ 0x6);
164 return (reg
& 0x0f00) >> 8;
167 /* Return compactPCI System Controller Status */
168 static unsigned int ge_imp3a_get_cpci_is_syscon(void)
172 reg
= ioread16(imp3a_regs
+ 0x6);
173 return reg
& (1 << 12);
176 static void ge_imp3a_show_cpuinfo(struct seq_file
*m
)
178 seq_printf(m
, "Vendor\t\t: GE Intelligent Platforms\n");
180 seq_printf(m
, "Revision\t: %u%c\n", ge_imp3a_get_pcb_rev(),
181 ('A' + ge_imp3a_get_board_rev() - 1));
183 seq_printf(m
, "FPGA Revision\t: %u\n", ge_imp3a_get_fpga_rev());
185 seq_printf(m
, "cPCI geo. addr\t: %u\n", ge_imp3a_get_cpci_geo_addr());
187 seq_printf(m
, "cPCI syscon\t: %s\n",
188 ge_imp3a_get_cpci_is_syscon() ? "yes" : "no");
192 * Called very early, device-tree isn't unflattened
194 static int __init
ge_imp3a_probe(void)
196 return of_machine_is_compatible("ge,IMP3A");
199 machine_arch_initcall(ge_imp3a
, mpc85xx_common_publish_devices
);
201 define_machine(ge_imp3a
) {
203 .probe
= ge_imp3a_probe
,
204 .setup_arch
= ge_imp3a_setup_arch
,
205 .init_IRQ
= ge_imp3a_pic_init
,
206 .show_cpuinfo
= ge_imp3a_show_cpuinfo
,
208 .pcibios_fixup_bus
= fsl_pcibios_fixup_bus
,
209 .pcibios_fixup_phb
= fsl_pcibios_fixup_phb
,
211 .get_irq
= mpic_get_irq
,
212 .calibrate_decr
= generic_calibrate_decr
,
213 .progress
= udbg_progress
,