Path: blob/master/arch/powerpc/platforms/86xx/gef_ppc9a.c
10818 views
/*1* GE PPC9A board support2*3* Author: Martyn Welch <[email protected]>4*5* Copyright 2008 GE Intelligent Platforms Embedded Systems, Inc.6*7* This program is free software; you can redistribute it and/or modify it8* under the terms of the GNU General Public License as published by the9* Free Software Foundation; either version 2 of the License, or (at your10* option) any later version.11*12* Based on: mpc86xx_hpcn.c (MPC86xx HPCN board specific routines)13* Copyright 2006 Freescale Semiconductor Inc.14*15* NEC fixup adapted from arch/mips/pci/fixup-lm2e.c16*/1718#include <linux/stddef.h>19#include <linux/kernel.h>20#include <linux/pci.h>21#include <linux/kdev_t.h>22#include <linux/delay.h>23#include <linux/seq_file.h>24#include <linux/of_platform.h>2526#include <asm/system.h>27#include <asm/time.h>28#include <asm/machdep.h>29#include <asm/pci-bridge.h>30#include <asm/prom.h>31#include <mm/mmu_decl.h>32#include <asm/udbg.h>3334#include <asm/mpic.h>35#include <asm/nvram.h>3637#include <sysdev/fsl_pci.h>38#include <sysdev/fsl_soc.h>3940#include "mpc86xx.h"41#include "gef_pic.h"4243#undef DEBUG4445#ifdef DEBUG46#define DBG (fmt...) do { printk(KERN_ERR "PPC9A: " fmt); } while (0)47#else48#define DBG (fmt...) do { } while (0)49#endif5051void __iomem *ppc9a_regs;5253static void __init gef_ppc9a_init_irq(void)54{55struct device_node *cascade_node = NULL;5657mpc86xx_init_irq();5859/*60* There is a simple interrupt handler in the main FPGA, this needs61* to be cascaded into the MPIC62*/63cascade_node = of_find_compatible_node(NULL, NULL, "gef,fpga-pic-1.00");64if (!cascade_node) {65printk(KERN_WARNING "PPC9A: No FPGA PIC\n");66return;67}6869gef_pic_init(cascade_node);70of_node_put(cascade_node);71}7273static void __init gef_ppc9a_setup_arch(void)74{75struct device_node *regs;76#ifdef CONFIG_PCI77struct device_node *np;7879for_each_compatible_node(np, "pci", "fsl,mpc8641-pcie") {80fsl_add_bridge(np, 1);81}82#endif8384printk(KERN_INFO "GE Intelligent Platforms PPC9A 6U VME SBC\n");8586#ifdef CONFIG_SMP87mpc86xx_smp_init();88#endif8990/* Remap basic board registers */91regs = of_find_compatible_node(NULL, NULL, "gef,ppc9a-fpga-regs");92if (regs) {93ppc9a_regs = of_iomap(regs, 0);94if (ppc9a_regs == NULL)95printk(KERN_WARNING "Unable to map board registers\n");96of_node_put(regs);97}9899#if defined(CONFIG_MMIO_NVRAM)100mmio_nvram_init();101#endif102}103104/* Return the PCB revision */105static unsigned int gef_ppc9a_get_pcb_rev(void)106{107unsigned int reg;108109reg = ioread32be(ppc9a_regs);110return (reg >> 16) & 0xff;111}112113/* Return the board (software) revision */114static unsigned int gef_ppc9a_get_board_rev(void)115{116unsigned int reg;117118reg = ioread32be(ppc9a_regs);119return (reg >> 8) & 0xff;120}121122/* Return the FPGA revision */123static unsigned int gef_ppc9a_get_fpga_rev(void)124{125unsigned int reg;126127reg = ioread32be(ppc9a_regs);128return reg & 0xf;129}130131/* Return VME Geographical Address */132static unsigned int gef_ppc9a_get_vme_geo_addr(void)133{134unsigned int reg;135136reg = ioread32be(ppc9a_regs + 0x4);137return reg & 0x1f;138}139140/* Return VME System Controller Status */141static unsigned int gef_ppc9a_get_vme_is_syscon(void)142{143unsigned int reg;144145reg = ioread32be(ppc9a_regs + 0x4);146return (reg >> 9) & 0x1;147}148149static void gef_ppc9a_show_cpuinfo(struct seq_file *m)150{151uint svid = mfspr(SPRN_SVR);152153seq_printf(m, "Vendor\t\t: GE Intelligent Platforms\n");154155seq_printf(m, "Revision\t: %u%c\n", gef_ppc9a_get_pcb_rev(),156('A' + gef_ppc9a_get_board_rev()));157seq_printf(m, "FPGA Revision\t: %u\n", gef_ppc9a_get_fpga_rev());158159seq_printf(m, "SVR\t\t: 0x%x\n", svid);160161seq_printf(m, "VME geo. addr\t: %u\n", gef_ppc9a_get_vme_geo_addr());162163seq_printf(m, "VME syscon\t: %s\n",164gef_ppc9a_get_vme_is_syscon() ? "yes" : "no");165}166167static void __init gef_ppc9a_nec_fixup(struct pci_dev *pdev)168{169unsigned int val;170171/* Do not do the fixup on other platforms! */172if (!machine_is(gef_ppc9a))173return;174175printk(KERN_INFO "Running NEC uPD720101 Fixup\n");176177/* Ensure ports 1, 2, 3, 4 & 5 are enabled */178pci_read_config_dword(pdev, 0xe0, &val);179pci_write_config_dword(pdev, 0xe0, (val & ~7) | 0x5);180181/* System clock is 48-MHz Oscillator and EHCI Enabled. */182pci_write_config_dword(pdev, 0xe4, 1 << 5);183}184DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_NEC, PCI_DEVICE_ID_NEC_USB,185gef_ppc9a_nec_fixup);186187/*188* Called very early, device-tree isn't unflattened189*190* This function is called to determine whether the BSP is compatible with the191* supplied device-tree, which is assumed to be the correct one for the actual192* board. It is expected thati, in the future, a kernel may support multiple193* boards.194*/195static int __init gef_ppc9a_probe(void)196{197unsigned long root = of_get_flat_dt_root();198199if (of_flat_dt_is_compatible(root, "gef,ppc9a"))200return 1;201202return 0;203}204205static long __init mpc86xx_time_init(void)206{207unsigned int temp;208209/* Set the time base to zero */210mtspr(SPRN_TBWL, 0);211mtspr(SPRN_TBWU, 0);212213temp = mfspr(SPRN_HID0);214temp |= HID0_TBEN;215mtspr(SPRN_HID0, temp);216asm volatile("isync");217218return 0;219}220221static __initdata struct of_device_id of_bus_ids[] = {222{ .compatible = "simple-bus", },223{ .compatible = "gianfar", },224{},225};226227static int __init declare_of_platform_devices(void)228{229printk(KERN_DEBUG "Probe platform devices\n");230of_platform_bus_probe(NULL, of_bus_ids, NULL);231232return 0;233}234machine_device_initcall(gef_ppc9a, declare_of_platform_devices);235236define_machine(gef_ppc9a) {237.name = "GE PPC9A",238.probe = gef_ppc9a_probe,239.setup_arch = gef_ppc9a_setup_arch,240.init_IRQ = gef_ppc9a_init_irq,241.show_cpuinfo = gef_ppc9a_show_cpuinfo,242.get_irq = mpic_get_irq,243.restart = fsl_rstcr_restart,244.time_init = mpc86xx_time_init,245.calibrate_decr = generic_calibrate_decr,246.progress = udbg_progress,247#ifdef CONFIG_PCI248.pcibios_fixup_bus = fsl_pcibios_fixup_bus,249#endif250};251252253