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_address.h>
21 #include <linux/of_platform.h>
24 #include <asm/machdep.h>
25 #include <asm/pci-bridge.h>
26 #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 __init 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) {
93 of_node_put(fsl_pci_primary);
94 fsl_pci_primary = of_node_get(np);
102 * Setup the architecture
104 static void __init ge_imp3a_setup_arch(void)
106 struct device_node *regs;
109 ppc_md.progress("ge_imp3a_setup_arch()", 0);
113 ge_imp3a_pci_assign_primary();
117 /* Remap basic board registers */
118 regs = of_find_compatible_node(NULL, NULL, "ge,imp3a-fpga-regs");
120 imp3a_regs = of_iomap(regs, 0);
121 if (imp3a_regs == NULL)
122 printk(KERN_WARNING "Unable to map board registers\n");
126 #if defined(CONFIG_MMIO_NVRAM)
130 printk(KERN_INFO "GE Intelligent Platforms IMP3A 3U cPCI SBC\n");
133 /* Return the PCB revision */
134 static unsigned int ge_imp3a_get_pcb_rev(void)
138 reg = ioread16(imp3a_regs);
139 return (reg >> 8) & 0xff;
142 /* Return the board (software) revision */
143 static unsigned int ge_imp3a_get_board_rev(void)
147 reg = ioread16(imp3a_regs + 0x2);
151 /* Return the FPGA revision */
152 static unsigned int ge_imp3a_get_fpga_rev(void)
156 reg = ioread16(imp3a_regs + 0x2);
157 return (reg >> 8) & 0xff;
160 /* Return compactPCI Geographical Address */
161 static unsigned int ge_imp3a_get_cpci_geo_addr(void)
165 reg = ioread16(imp3a_regs + 0x6);
166 return (reg & 0x0f00) >> 8;
169 /* Return compactPCI System Controller Status */
170 static unsigned int ge_imp3a_get_cpci_is_syscon(void)
174 reg = ioread16(imp3a_regs + 0x6);
175 return reg & (1 << 12);
178 static void ge_imp3a_show_cpuinfo(struct seq_file *m)
180 seq_printf(m, "Vendor\t\t: GE Intelligent Platforms\n");
182 seq_printf(m, "Revision\t: %u%c\n", ge_imp3a_get_pcb_rev(),
183 ('A' + ge_imp3a_get_board_rev() - 1));
185 seq_printf(m, "FPGA Revision\t: %u\n", ge_imp3a_get_fpga_rev());
187 seq_printf(m, "cPCI geo. addr\t: %u\n", ge_imp3a_get_cpci_geo_addr());
189 seq_printf(m, "cPCI syscon\t: %s\n",
190 ge_imp3a_get_cpci_is_syscon() ? "yes" : "no");
193 machine_arch_initcall(ge_imp3a, mpc85xx_common_publish_devices);
195 define_machine(ge_imp3a) {
197 .compatible = "ge,IMP3A",
198 .setup_arch = ge_imp3a_setup_arch,
199 .init_IRQ = ge_imp3a_pic_init,
200 .show_cpuinfo = ge_imp3a_show_cpuinfo,
202 .pcibios_fixup_bus = fsl_pcibios_fixup_bus,
203 .pcibios_fixup_phb = fsl_pcibios_fixup_phb,
205 .get_irq = mpic_get_irq,
206 .progress = udbg_progress,