Path: blob/master/arch/powerpc/platforms/86xx/gef_ppc9a.c
26481 views
// SPDX-License-Identifier: GPL-2.0-or-later1/*2* GE PPC9A board support3*4* Author: Martyn Welch <[email protected]>5*6* Copyright 2008 GE Intelligent Platforms Embedded Systems, Inc.7*8* Based on: mpc86xx_hpcn.c (MPC86xx HPCN board specific routines)9* Copyright 2006 Freescale Semiconductor Inc.10*11* NEC fixup adapted from arch/mips/pci/fixup-lm2e.c12*/1314#include <linux/stddef.h>15#include <linux/kernel.h>16#include <linux/pci.h>17#include <linux/kdev_t.h>18#include <linux/delay.h>19#include <linux/seq_file.h>20#include <linux/of.h>21#include <linux/of_address.h>2223#include <asm/time.h>24#include <asm/machdep.h>25#include <asm/pci-bridge.h>26#include <mm/mmu_decl.h>27#include <asm/udbg.h>2829#include <asm/mpic.h>30#include <asm/nvram.h>3132#include <sysdev/fsl_pci.h>33#include <sysdev/fsl_soc.h>34#include <sysdev/ge/ge_pic.h>3536#include "mpc86xx.h"3738#undef DEBUG3940#ifdef DEBUG41#define DBG (fmt...) do { printk(KERN_ERR "PPC9A: " fmt); } while (0)42#else43#define DBG (fmt...) do { } while (0)44#endif4546void __iomem *ppc9a_regs;4748static void __init gef_ppc9a_init_irq(void)49{50struct device_node *cascade_node = NULL;5152mpc86xx_init_irq();5354/*55* There is a simple interrupt handler in the main FPGA, this needs56* to be cascaded into the MPIC57*/58cascade_node = of_find_compatible_node(NULL, NULL, "gef,fpga-pic-1.00");59if (!cascade_node) {60printk(KERN_WARNING "PPC9A: No FPGA PIC\n");61return;62}6364gef_pic_init(cascade_node);65of_node_put(cascade_node);66}6768static void __init gef_ppc9a_setup_arch(void)69{70struct device_node *regs;7172printk(KERN_INFO "GE Intelligent Platforms PPC9A 6U VME SBC\n");7374#ifdef CONFIG_SMP75mpc86xx_smp_init();76#endif7778fsl_pci_assign_primary();7980/* Remap basic board registers */81regs = of_find_compatible_node(NULL, NULL, "gef,ppc9a-fpga-regs");82if (regs) {83ppc9a_regs = of_iomap(regs, 0);84if (ppc9a_regs == NULL)85printk(KERN_WARNING "Unable to map board registers\n");86of_node_put(regs);87}8889#if defined(CONFIG_MMIO_NVRAM)90mmio_nvram_init();91#endif92}9394/* Return the PCB revision */95static unsigned int gef_ppc9a_get_pcb_rev(void)96{97unsigned int reg;9899reg = ioread32be(ppc9a_regs);100return (reg >> 16) & 0xff;101}102103/* Return the board (software) revision */104static unsigned int gef_ppc9a_get_board_rev(void)105{106unsigned int reg;107108reg = ioread32be(ppc9a_regs);109return (reg >> 8) & 0xff;110}111112/* Return the FPGA revision */113static unsigned int gef_ppc9a_get_fpga_rev(void)114{115unsigned int reg;116117reg = ioread32be(ppc9a_regs);118return reg & 0xf;119}120121/* Return VME Geographical Address */122static unsigned int gef_ppc9a_get_vme_geo_addr(void)123{124unsigned int reg;125126reg = ioread32be(ppc9a_regs + 0x4);127return reg & 0x1f;128}129130/* Return VME System Controller Status */131static unsigned int gef_ppc9a_get_vme_is_syscon(void)132{133unsigned int reg;134135reg = ioread32be(ppc9a_regs + 0x4);136return (reg >> 9) & 0x1;137}138139static void gef_ppc9a_show_cpuinfo(struct seq_file *m)140{141uint svid = mfspr(SPRN_SVR);142143seq_printf(m, "Vendor\t\t: GE Intelligent Platforms\n");144145seq_printf(m, "Revision\t: %u%c\n", gef_ppc9a_get_pcb_rev(),146('A' + gef_ppc9a_get_board_rev()));147seq_printf(m, "FPGA Revision\t: %u\n", gef_ppc9a_get_fpga_rev());148149seq_printf(m, "SVR\t\t: 0x%x\n", svid);150151seq_printf(m, "VME geo. addr\t: %u\n", gef_ppc9a_get_vme_geo_addr());152153seq_printf(m, "VME syscon\t: %s\n",154gef_ppc9a_get_vme_is_syscon() ? "yes" : "no");155}156157static void gef_ppc9a_nec_fixup(struct pci_dev *pdev)158{159unsigned int val;160161/* Do not do the fixup on other platforms! */162if (!machine_is(gef_ppc9a))163return;164165printk(KERN_INFO "Running NEC uPD720101 Fixup\n");166167/* Ensure ports 1, 2, 3, 4 & 5 are enabled */168pci_read_config_dword(pdev, 0xe0, &val);169pci_write_config_dword(pdev, 0xe0, (val & ~7) | 0x5);170171/* System clock is 48-MHz Oscillator and EHCI Enabled. */172pci_write_config_dword(pdev, 0xe4, 1 << 5);173}174DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_NEC, PCI_DEVICE_ID_NEC_USB,175gef_ppc9a_nec_fixup);176177machine_arch_initcall(gef_ppc9a, mpc86xx_common_publish_devices);178179define_machine(gef_ppc9a) {180.name = "GE PPC9A",181.compatible = "gef,ppc9a",182.setup_arch = gef_ppc9a_setup_arch,183.init_IRQ = gef_ppc9a_init_irq,184.show_cpuinfo = gef_ppc9a_show_cpuinfo,185.get_irq = mpic_get_irq,186.time_init = mpc86xx_time_init,187.progress = udbg_progress,188#ifdef CONFIG_PCI189.pcibios_fixup_bus = fsl_pcibios_fixup_bus,190#endif191};192193194