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
;
51 if (of_machine_is_compatible("fsl,MPC8572DS-CAMP")) {
52 mpic
= mpic_alloc(NULL
, 0,
58 mpic
= mpic_alloc(NULL
, 0,
67 * There is a simple interrupt handler in the main FPGA, this needs
68 * to be cascaded into the MPIC
70 for_each_node_by_type(np
, "interrupt-controller")
71 if (of_device_is_compatible(np
, "gef,fpga-pic-1.00")) {
76 if (cascade_node
== NULL
) {
77 printk(KERN_WARNING
"IMP3A: No FPGA PIC\n");
81 gef_pic_init(cascade_node
);
82 of_node_put(cascade_node
);
85 static void ge_imp3a_pci_assign_primary(void)
88 struct device_node
*np
;
91 for_each_node_by_type(np
, "pci") {
92 if (of_device_is_compatible(np
, "fsl,mpc8540-pci") ||
93 of_device_is_compatible(np
, "fsl,mpc8548-pcie") ||
94 of_device_is_compatible(np
, "fsl,p2020-pcie")) {
95 of_address_to_resource(np
, 0, &rsrc
);
96 if ((rsrc
.start
& 0xfffff) == 0x9000)
104 * Setup the architecture
106 static void __init
ge_imp3a_setup_arch(void)
108 struct device_node
*regs
;
111 ppc_md
.progress("ge_imp3a_setup_arch()", 0);
115 ge_imp3a_pci_assign_primary();
119 /* Remap basic board registers */
120 regs
= of_find_compatible_node(NULL
, NULL
, "ge,imp3a-fpga-regs");
122 imp3a_regs
= of_iomap(regs
, 0);
123 if (imp3a_regs
== NULL
)
124 printk(KERN_WARNING
"Unable to map board registers\n");
128 #if defined(CONFIG_MMIO_NVRAM)
132 printk(KERN_INFO
"GE Intelligent Platforms IMP3A 3U cPCI SBC\n");
135 /* Return the PCB revision */
136 static unsigned int ge_imp3a_get_pcb_rev(void)
140 reg
= ioread16(imp3a_regs
);
141 return (reg
>> 8) & 0xff;
144 /* Return the board (software) revision */
145 static unsigned int ge_imp3a_get_board_rev(void)
149 reg
= ioread16(imp3a_regs
+ 0x2);
153 /* Return the FPGA revision */
154 static unsigned int ge_imp3a_get_fpga_rev(void)
158 reg
= ioread16(imp3a_regs
+ 0x2);
159 return (reg
>> 8) & 0xff;
162 /* Return compactPCI Geographical Address */
163 static unsigned int ge_imp3a_get_cpci_geo_addr(void)
167 reg
= ioread16(imp3a_regs
+ 0x6);
168 return (reg
& 0x0f00) >> 8;
171 /* Return compactPCI System Controller Status */
172 static unsigned int ge_imp3a_get_cpci_is_syscon(void)
176 reg
= ioread16(imp3a_regs
+ 0x6);
177 return reg
& (1 << 12);
180 static void ge_imp3a_show_cpuinfo(struct seq_file
*m
)
182 seq_printf(m
, "Vendor\t\t: GE Intelligent Platforms\n");
184 seq_printf(m
, "Revision\t: %u%c\n", ge_imp3a_get_pcb_rev(),
185 ('A' + ge_imp3a_get_board_rev() - 1));
187 seq_printf(m
, "FPGA Revision\t: %u\n", ge_imp3a_get_fpga_rev());
189 seq_printf(m
, "cPCI geo. addr\t: %u\n", ge_imp3a_get_cpci_geo_addr());
191 seq_printf(m
, "cPCI syscon\t: %s\n",
192 ge_imp3a_get_cpci_is_syscon() ? "yes" : "no");
196 * Called very early, device-tree isn't unflattened
198 static int __init
ge_imp3a_probe(void)
200 return of_machine_is_compatible("ge,IMP3A");
203 machine_arch_initcall(ge_imp3a
, mpc85xx_common_publish_devices
);
205 machine_arch_initcall(ge_imp3a
, swiotlb_setup_bus_notifier
);
207 define_machine(ge_imp3a
) {
209 .probe
= ge_imp3a_probe
,
210 .setup_arch
= ge_imp3a_setup_arch
,
211 .init_IRQ
= ge_imp3a_pic_init
,
212 .show_cpuinfo
= ge_imp3a_show_cpuinfo
,
214 .pcibios_fixup_bus
= fsl_pcibios_fixup_bus
,
215 .pcibios_fixup_phb
= fsl_pcibios_fixup_phb
,
217 .get_irq
= mpic_get_irq
,
218 .calibrate_decr
= generic_calibrate_decr
,
219 .progress
= udbg_progress
,