Path: blob/master/arch/powerpc/platforms/embedded6xx/holly.c
10819 views
/*1* Board setup routines for the IBM 750GX/CL platform w/ TSI10x bridge2*3* Copyright 2007 IBM Corporation4*5* Stephen Winiecki <[email protected]>6* Josh Boyer <[email protected]>7*8* Based on code from mpc7448_hpc2.c9*10* This program is free software; you can redistribute it and/or11* modify it under the terms of the GNU General Public License12* version 2 as published by the Free Software Foundation.13*/1415#include <linux/stddef.h>16#include <linux/kernel.h>17#include <linux/pci.h>18#include <linux/kdev_t.h>19#include <linux/console.h>20#include <linux/delay.h>21#include <linux/irq.h>22#include <linux/seq_file.h>23#include <linux/root_dev.h>24#include <linux/serial.h>25#include <linux/tty.h>26#include <linux/serial_core.h>27#include <linux/of_platform.h>2829#include <asm/system.h>30#include <asm/time.h>31#include <asm/machdep.h>32#include <asm/prom.h>33#include <asm/udbg.h>34#include <asm/tsi108.h>35#include <asm/pci-bridge.h>36#include <asm/reg.h>37#include <mm/mmu_decl.h>38#include <asm/tsi108_irq.h>39#include <asm/tsi108_pci.h>40#include <asm/mpic.h>4142#undef DEBUG4344#define HOLLY_PCI_CFG_PHYS 0x7c0000004546int holly_exclude_device(struct pci_controller *hose, u_char bus, u_char devfn)47{48if (bus == 0 && PCI_SLOT(devfn) == 0)49return PCIBIOS_DEVICE_NOT_FOUND;50else51return PCIBIOS_SUCCESSFUL;52}5354static void holly_remap_bridge(void)55{56u32 lut_val, lut_addr;57int i;5859printk(KERN_INFO "Remapping PCI bridge\n");6061/* Re-init the PCI bridge and LUT registers to have mappings that don't62* rely on PIBS63*/64lut_addr = 0x900;65for (i = 0; i < 31; i++) {66tsi108_write_reg(TSI108_PB_OFFSET + lut_addr, 0x00000201);67lut_addr += 4;68tsi108_write_reg(TSI108_PB_OFFSET + lut_addr, 0x0);69lut_addr += 4;70}7172/* Reserve the last LUT entry for PCI I/O space */73tsi108_write_reg(TSI108_PB_OFFSET + lut_addr, 0x00000241);74lut_addr += 4;75tsi108_write_reg(TSI108_PB_OFFSET + lut_addr, 0x0);7677/* Map PCI I/O space */78tsi108_write_reg(TSI108_PCI_PFAB_IO_UPPER, 0x0);79tsi108_write_reg(TSI108_PCI_PFAB_IO, 0x1);8081/* Map PCI CFG space */82tsi108_write_reg(TSI108_PCI_PFAB_BAR0_UPPER, 0x0);83tsi108_write_reg(TSI108_PCI_PFAB_BAR0, 0x7c000000 | 0x01);8485/* We don't need MEM32 and PRM remapping so disable them */86tsi108_write_reg(TSI108_PCI_PFAB_MEM32, 0x0);87tsi108_write_reg(TSI108_PCI_PFAB_PFM3, 0x0);88tsi108_write_reg(TSI108_PCI_PFAB_PFM4, 0x0);8990/* Set P2O_BAR0 */91tsi108_write_reg(TSI108_PCI_P2O_BAR0_UPPER, 0x0);92tsi108_write_reg(TSI108_PCI_P2O_BAR0, 0xc0000000);9394/* Init the PCI LUTs to do no remapping */95lut_addr = 0x500;96lut_val = 0x00000002;9798for (i = 0; i < 32; i++) {99tsi108_write_reg(TSI108_PCI_OFFSET + lut_addr, lut_val);100lut_addr += 4;101tsi108_write_reg(TSI108_PCI_OFFSET + lut_addr, 0x40000000);102lut_addr += 4;103lut_val += 0x02000000;104}105tsi108_write_reg(TSI108_PCI_P2O_PAGE_SIZES, 0x00007900);106107/* Set 64-bit PCI bus address for system memory */108tsi108_write_reg(TSI108_PCI_P2O_BAR2_UPPER, 0x0);109tsi108_write_reg(TSI108_PCI_P2O_BAR2, 0x0);110}111112static void __init holly_setup_arch(void)113{114struct device_node *np;115116if (ppc_md.progress)117ppc_md.progress("holly_setup_arch():set_bridge", 0);118119tsi108_csr_vir_base = get_vir_csrbase();120121/* setup PCI host bridge */122holly_remap_bridge();123124np = of_find_node_by_type(NULL, "pci");125if (np)126tsi108_setup_pci(np, HOLLY_PCI_CFG_PHYS, 1);127128ppc_md.pci_exclude_device = holly_exclude_device;129if (ppc_md.progress)130ppc_md.progress("tsi108: resources set", 0x100);131132printk(KERN_INFO "PPC750GX/CL Platform\n");133}134135/*136* Interrupt setup and service. Interrupts on the holly come137* from the four external INT pins, PCI interrupts are routed via138* PCI interrupt control registers, it generates internal IRQ23139*140* Interrupt routing on the Holly Board:141* TSI108:PB_INT[0] -> CPU0:INT#142* TSI108:PB_INT[1] -> CPU0:MCP#143* TSI108:PB_INT[2] -> N/C144* TSI108:PB_INT[3] -> N/C145*/146static void __init holly_init_IRQ(void)147{148struct mpic *mpic;149phys_addr_t mpic_paddr = 0;150struct device_node *tsi_pic;151#ifdef CONFIG_PCI152unsigned int cascade_pci_irq;153struct device_node *tsi_pci;154struct device_node *cascade_node = NULL;155#endif156157tsi_pic = of_find_node_by_type(NULL, "open-pic");158if (tsi_pic) {159unsigned int size;160const void *prop = of_get_property(tsi_pic, "reg", &size);161mpic_paddr = of_translate_address(tsi_pic, prop);162}163164if (mpic_paddr == 0) {165printk(KERN_ERR "%s: No tsi108 PIC found !\n", __func__);166return;167}168169pr_debug("%s: tsi108 pic phys_addr = 0x%x\n", __func__, (u32) mpic_paddr);170171mpic = mpic_alloc(tsi_pic, mpic_paddr,172MPIC_PRIMARY | MPIC_BIG_ENDIAN | MPIC_WANTS_RESET |173MPIC_SPV_EOI | MPIC_NO_PTHROU_DIS | MPIC_REGSET_TSI108,17424,175NR_IRQS-4, /* num_sources used */176"Tsi108_PIC");177178BUG_ON(mpic == NULL);179180mpic_assign_isu(mpic, 0, mpic_paddr + 0x100);181182mpic_init(mpic);183184#ifdef CONFIG_PCI185tsi_pci = of_find_node_by_type(NULL, "pci");186if (tsi_pci == NULL) {187printk(KERN_ERR "%s: No tsi108 pci node found !\n", __func__);188return;189}190191cascade_node = of_find_node_by_type(NULL, "pic-router");192if (cascade_node == NULL) {193printk(KERN_ERR "%s: No tsi108 pci cascade node found !\n", __func__);194return;195}196197cascade_pci_irq = irq_of_parse_and_map(tsi_pci, 0);198pr_debug("%s: tsi108 cascade_pci_irq = 0x%x\n", __func__, (u32) cascade_pci_irq);199tsi108_pci_int_init(cascade_node);200irq_set_handler_data(cascade_pci_irq, mpic);201irq_set_chained_handler(cascade_pci_irq, tsi108_irq_cascade);202#endif203/* Configure MPIC outputs to CPU0 */204tsi108_write_reg(TSI108_MPIC_OFFSET + 0x30c, 0);205of_node_put(tsi_pic);206}207208void holly_show_cpuinfo(struct seq_file *m)209{210seq_printf(m, "vendor\t\t: IBM\n");211seq_printf(m, "machine\t\t: PPC750 GX/CL\n");212}213214void holly_restart(char *cmd)215{216__be32 __iomem *ocn_bar1 = NULL;217unsigned long bar;218struct device_node *bridge = NULL;219const void *prop;220int size;221phys_addr_t addr = 0xc0000000;222223local_irq_disable();224225bridge = of_find_node_by_type(NULL, "tsi-bridge");226if (bridge) {227prop = of_get_property(bridge, "reg", &size);228addr = of_translate_address(bridge, prop);229}230addr += (TSI108_PB_OFFSET + 0x414);231232ocn_bar1 = ioremap(addr, 0x4);233234/* Turn on the BOOT bit so the addresses are correctly235* routed to the HLP interface */236bar = ioread32be(ocn_bar1);237bar |= 2;238iowrite32be(bar, ocn_bar1);239iosync();240241/* Set SRR0 to the reset vector and turn on MSR_IP */242mtspr(SPRN_SRR0, 0xfff00100);243mtspr(SPRN_SRR1, MSR_IP);244245/* Do an rfi to jump back to firmware. Somewhat evil,246* but it works247*/248__asm__ __volatile__("rfi" : : : "memory");249250/* Spin until reset happens. Shouldn't really get here */251for (;;) ;252}253254void holly_power_off(void)255{256local_irq_disable();257/* No way to shut power off with software */258for (;;) ;259}260261void holly_halt(void)262{263holly_power_off();264}265266/*267* Called very early, device-tree isn't unflattened268*/269static int __init holly_probe(void)270{271unsigned long root = of_get_flat_dt_root();272273if (!of_flat_dt_is_compatible(root, "ibm,holly"))274return 0;275return 1;276}277278static int ppc750_machine_check_exception(struct pt_regs *regs)279{280const struct exception_table_entry *entry;281282/* Are we prepared to handle this fault */283if ((entry = search_exception_tables(regs->nip)) != NULL) {284tsi108_clear_pci_cfg_error();285regs->msr |= MSR_RI;286regs->nip = entry->fixup;287return 1;288}289return 0;290}291292define_machine(holly){293.name = "PPC750 GX/CL TSI",294.probe = holly_probe,295.setup_arch = holly_setup_arch,296.init_IRQ = holly_init_IRQ,297.show_cpuinfo = holly_show_cpuinfo,298.get_irq = mpic_get_irq,299.restart = holly_restart,300.calibrate_decr = generic_calibrate_decr,301.machine_check_exception = ppc750_machine_check_exception,302.progress = udbg_progress,303};304305306