1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * GE PPC9A board support
5 * Author: Martyn Welch <martyn.welch@ge.com>
7 * Copyright 2008 GE Intelligent Platforms Embedded Systems, Inc.
9 * Based on: mpc86xx_hpcn.c (MPC86xx HPCN board specific routines)
10 * Copyright 2006 Freescale Semiconductor Inc.
12 * NEC fixup adapted from arch/mips/pci/fixup-lm2e.c
15 #include <linux/stddef.h>
16 #include <linux/kernel.h>
17 #include <linux/pci.h>
18 #include <linux/kdev_t.h>
19 #include <linux/delay.h>
20 #include <linux/seq_file.h>
21 #include <linux/of_platform.h>
24 #include <asm/machdep.h>
25 #include <asm/pci-bridge.h>
27 #include <mm/mmu_decl.h>
31 #include <asm/nvram.h>
33 #include <sysdev/fsl_pci.h>
34 #include <sysdev/fsl_soc.h>
35 #include <sysdev/ge/ge_pic.h>
42 #define DBG (fmt...) do { printk(KERN_ERR "PPC9A: " fmt); } while (0)
44 #define DBG (fmt...) do { } while (0)
47 void __iomem
*ppc9a_regs
;
49 static void __init
gef_ppc9a_init_irq(void)
51 struct device_node
*cascade_node
= NULL
;
56 * There is a simple interrupt handler in the main FPGA, this needs
57 * to be cascaded into the MPIC
59 cascade_node
= of_find_compatible_node(NULL
, NULL
, "gef,fpga-pic-1.00");
61 printk(KERN_WARNING
"PPC9A: No FPGA PIC\n");
65 gef_pic_init(cascade_node
);
66 of_node_put(cascade_node
);
69 static void __init
gef_ppc9a_setup_arch(void)
71 struct device_node
*regs
;
73 printk(KERN_INFO
"GE Intelligent Platforms PPC9A 6U VME SBC\n");
79 fsl_pci_assign_primary();
81 /* Remap basic board registers */
82 regs
= of_find_compatible_node(NULL
, NULL
, "gef,ppc9a-fpga-regs");
84 ppc9a_regs
= of_iomap(regs
, 0);
85 if (ppc9a_regs
== NULL
)
86 printk(KERN_WARNING
"Unable to map board registers\n");
90 #if defined(CONFIG_MMIO_NVRAM)
95 /* Return the PCB revision */
96 static unsigned int gef_ppc9a_get_pcb_rev(void)
100 reg
= ioread32be(ppc9a_regs
);
101 return (reg
>> 16) & 0xff;
104 /* Return the board (software) revision */
105 static unsigned int gef_ppc9a_get_board_rev(void)
109 reg
= ioread32be(ppc9a_regs
);
110 return (reg
>> 8) & 0xff;
113 /* Return the FPGA revision */
114 static unsigned int gef_ppc9a_get_fpga_rev(void)
118 reg
= ioread32be(ppc9a_regs
);
122 /* Return VME Geographical Address */
123 static unsigned int gef_ppc9a_get_vme_geo_addr(void)
127 reg
= ioread32be(ppc9a_regs
+ 0x4);
131 /* Return VME System Controller Status */
132 static unsigned int gef_ppc9a_get_vme_is_syscon(void)
136 reg
= ioread32be(ppc9a_regs
+ 0x4);
137 return (reg
>> 9) & 0x1;
140 static void gef_ppc9a_show_cpuinfo(struct seq_file
*m
)
142 uint svid
= mfspr(SPRN_SVR
);
144 seq_printf(m
, "Vendor\t\t: GE Intelligent Platforms\n");
146 seq_printf(m
, "Revision\t: %u%c\n", gef_ppc9a_get_pcb_rev(),
147 ('A' + gef_ppc9a_get_board_rev()));
148 seq_printf(m
, "FPGA Revision\t: %u\n", gef_ppc9a_get_fpga_rev());
150 seq_printf(m
, "SVR\t\t: 0x%x\n", svid
);
152 seq_printf(m
, "VME geo. addr\t: %u\n", gef_ppc9a_get_vme_geo_addr());
154 seq_printf(m
, "VME syscon\t: %s\n",
155 gef_ppc9a_get_vme_is_syscon() ? "yes" : "no");
158 static void gef_ppc9a_nec_fixup(struct pci_dev
*pdev
)
162 /* Do not do the fixup on other platforms! */
163 if (!machine_is(gef_ppc9a
))
166 printk(KERN_INFO
"Running NEC uPD720101 Fixup\n");
168 /* Ensure ports 1, 2, 3, 4 & 5 are enabled */
169 pci_read_config_dword(pdev
, 0xe0, &val
);
170 pci_write_config_dword(pdev
, 0xe0, (val
& ~7) | 0x5);
172 /* System clock is 48-MHz Oscillator and EHCI Enabled. */
173 pci_write_config_dword(pdev
, 0xe4, 1 << 5);
175 DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_NEC
, PCI_DEVICE_ID_NEC_USB
,
176 gef_ppc9a_nec_fixup
);
179 * Called very early, device-tree isn't unflattened
181 * This function is called to determine whether the BSP is compatible with the
182 * supplied device-tree, which is assumed to be the correct one for the actual
183 * board. It is expected thati, in the future, a kernel may support multiple
186 static int __init
gef_ppc9a_probe(void)
188 if (of_machine_is_compatible("gef,ppc9a"))
194 machine_arch_initcall(gef_ppc9a
, mpc86xx_common_publish_devices
);
196 define_machine(gef_ppc9a
) {
198 .probe
= gef_ppc9a_probe
,
199 .setup_arch
= gef_ppc9a_setup_arch
,
200 .init_IRQ
= gef_ppc9a_init_irq
,
201 .show_cpuinfo
= gef_ppc9a_show_cpuinfo
,
202 .get_irq
= mpic_get_irq
,
203 .time_init
= mpc86xx_time_init
,
204 .calibrate_decr
= generic_calibrate_decr
,
205 .progress
= udbg_progress
,
207 .pcibios_fixup_bus
= fsl_pcibios_fixup_bus
,