4 * Author Martyn Welch <martyn.welch@ge.com>
6 * Copyright 2010 GE Intelligent Platforms Embedded Systems, Inc.
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.
13 * Based on: mpc85xx_ds.c (MPC85xx DS Board Setup)
14 * Copyright 2007 Freescale Semiconductor Inc.
17 #include <linux/stddef.h>
18 #include <linux/kernel.h>
19 #include <linux/pci.h>
20 #include <linux/kdev_t.h>
21 #include <linux/delay.h>
22 #include <linux/seq_file.h>
23 #include <linux/interrupt.h>
24 #include <linux/of_platform.h>
27 #include <asm/machdep.h>
28 #include <asm/pci-bridge.h>
29 #include <mm/mmu_decl.h>
33 #include <asm/swiotlb.h>
34 #include <asm/nvram.h>
36 #include <sysdev/fsl_soc.h>
37 #include <sysdev/fsl_pci.h>
41 #include <sysdev/ge/ge_pic.h>
43 void __iomem
*imp3a_regs
;
45 void __init
ge_imp3a_pic_init(void)
48 struct device_node
*np
;
49 struct device_node
*cascade_node
= NULL
;
50 unsigned long root
= of_get_flat_dt_root();
52 if (of_flat_dt_is_compatible(root
, "fsl,MPC8572DS-CAMP")) {
53 mpic
= mpic_alloc(NULL
, 0,
59 mpic
= mpic_alloc(NULL
, 0,
68 * There is a simple interrupt handler in the main FPGA, this needs
69 * to be cascaded into the MPIC
71 for_each_node_by_type(np
, "interrupt-controller")
72 if (of_device_is_compatible(np
, "gef,fpga-pic-1.00")) {
77 if (cascade_node
== NULL
) {
78 printk(KERN_WARNING
"IMP3A: No FPGA PIC\n");
82 gef_pic_init(cascade_node
);
83 of_node_put(cascade_node
);
86 static void ge_imp3a_pci_assign_primary(void)
89 struct device_node
*np
;
92 for_each_node_by_type(np
, "pci") {
93 if (of_device_is_compatible(np
, "fsl,mpc8540-pci") ||
94 of_device_is_compatible(np
, "fsl,mpc8548-pcie") ||
95 of_device_is_compatible(np
, "fsl,p2020-pcie")) {
96 of_address_to_resource(np
, 0, &rsrc
);
97 if ((rsrc
.start
& 0xfffff) == 0x9000)
105 * Setup the architecture
107 static void __init
ge_imp3a_setup_arch(void)
109 struct device_node
*regs
;
112 ppc_md
.progress("ge_imp3a_setup_arch()", 0);
116 ge_imp3a_pci_assign_primary();
120 /* Remap basic board registers */
121 regs
= of_find_compatible_node(NULL
, NULL
, "ge,imp3a-fpga-regs");
123 imp3a_regs
= of_iomap(regs
, 0);
124 if (imp3a_regs
== NULL
)
125 printk(KERN_WARNING
"Unable to map board registers\n");
129 #if defined(CONFIG_MMIO_NVRAM)
133 printk(KERN_INFO
"GE Intelligent Platforms IMP3A 3U cPCI SBC\n");
136 /* Return the PCB revision */
137 static unsigned int ge_imp3a_get_pcb_rev(void)
141 reg
= ioread16(imp3a_regs
);
142 return (reg
>> 8) & 0xff;
145 /* Return the board (software) revision */
146 static unsigned int ge_imp3a_get_board_rev(void)
150 reg
= ioread16(imp3a_regs
+ 0x2);
154 /* Return the FPGA revision */
155 static unsigned int ge_imp3a_get_fpga_rev(void)
159 reg
= ioread16(imp3a_regs
+ 0x2);
160 return (reg
>> 8) & 0xff;
163 /* Return compactPCI Geographical Address */
164 static unsigned int ge_imp3a_get_cpci_geo_addr(void)
168 reg
= ioread16(imp3a_regs
+ 0x6);
169 return (reg
& 0x0f00) >> 8;
172 /* Return compactPCI System Controller Status */
173 static unsigned int ge_imp3a_get_cpci_is_syscon(void)
177 reg
= ioread16(imp3a_regs
+ 0x6);
178 return reg
& (1 << 12);
181 static void ge_imp3a_show_cpuinfo(struct seq_file
*m
)
183 seq_printf(m
, "Vendor\t\t: GE Intelligent Platforms\n");
185 seq_printf(m
, "Revision\t: %u%c\n", ge_imp3a_get_pcb_rev(),
186 ('A' + ge_imp3a_get_board_rev() - 1));
188 seq_printf(m
, "FPGA Revision\t: %u\n", ge_imp3a_get_fpga_rev());
190 seq_printf(m
, "cPCI geo. addr\t: %u\n", ge_imp3a_get_cpci_geo_addr());
192 seq_printf(m
, "cPCI syscon\t: %s\n",
193 ge_imp3a_get_cpci_is_syscon() ? "yes" : "no");
197 * Called very early, device-tree isn't unflattened
199 static int __init
ge_imp3a_probe(void)
201 unsigned long root
= of_get_flat_dt_root();
203 return of_flat_dt_is_compatible(root
, "ge,IMP3A");
206 machine_arch_initcall(ge_imp3a
, mpc85xx_common_publish_devices
);
208 machine_arch_initcall(ge_imp3a
, swiotlb_setup_bus_notifier
);
210 define_machine(ge_imp3a
) {
212 .probe
= ge_imp3a_probe
,
213 .setup_arch
= ge_imp3a_setup_arch
,
214 .init_IRQ
= ge_imp3a_pic_init
,
215 .show_cpuinfo
= ge_imp3a_show_cpuinfo
,
217 .pcibios_fixup_bus
= fsl_pcibios_fixup_bus
,
218 .pcibios_fixup_phb
= fsl_pcibios_fixup_phb
,
220 .get_irq
= mpic_get_irq
,
221 .restart
= fsl_rstcr_restart
,
222 .calibrate_decr
= generic_calibrate_decr
,
223 .progress
= udbg_progress
,