Path: blob/master/arch/powerpc/platforms/embedded6xx/holly.c
26489 views
// SPDX-License-Identifier: GPL-2.0-only1/*2* Board setup routines for the IBM 750GX/CL platform w/ TSI10x bridge3*4* Copyright 2007 IBM Corporation5*6* Stephen Winiecki <[email protected]>7* Josh Boyer <[email protected]>8*9* Based on code from mpc7448_hpc2.c10*/1112#include <linux/stddef.h>13#include <linux/kernel.h>14#include <linux/pci.h>15#include <linux/kdev_t.h>16#include <linux/console.h>17#include <linux/delay.h>18#include <linux/irq.h>19#include <linux/seq_file.h>20#include <linux/root_dev.h>21#include <linux/serial.h>22#include <linux/tty.h>23#include <linux/serial_core.h>24#include <linux/of.h>25#include <linux/of_address.h>26#include <linux/of_irq.h>27#include <linux/extable.h>2829#include <asm/time.h>30#include <asm/machdep.h>31#include <asm/udbg.h>32#include <asm/tsi108.h>33#include <asm/pci-bridge.h>34#include <asm/reg.h>35#include <mm/mmu_decl.h>36#include <asm/tsi108_irq.h>37#include <asm/tsi108_pci.h>38#include <asm/mpic.h>3940#undef DEBUG4142#define HOLLY_PCI_CFG_PHYS 0x7c0000004344static int holly_exclude_device(struct pci_controller *hose, u_char bus,45u_char devfn)46{47if (bus == 0 && PCI_SLOT(devfn) == 0)48return PCIBIOS_DEVICE_NOT_FOUND;49else50return PCIBIOS_SUCCESSFUL;51}5253static void __init holly_remap_bridge(void)54{55u32 lut_val, lut_addr;56int i;5758printk(KERN_INFO "Remapping PCI bridge\n");5960/* Re-init the PCI bridge and LUT registers to have mappings that don't61* rely on PIBS62*/63lut_addr = 0x900;64for (i = 0; i < 31; i++) {65tsi108_write_reg(TSI108_PB_OFFSET + lut_addr, 0x00000201);66lut_addr += 4;67tsi108_write_reg(TSI108_PB_OFFSET + lut_addr, 0x0);68lut_addr += 4;69}7071/* Reserve the last LUT entry for PCI I/O space */72tsi108_write_reg(TSI108_PB_OFFSET + lut_addr, 0x00000241);73lut_addr += 4;74tsi108_write_reg(TSI108_PB_OFFSET + lut_addr, 0x0);7576/* Map PCI I/O space */77tsi108_write_reg(TSI108_PCI_PFAB_IO_UPPER, 0x0);78tsi108_write_reg(TSI108_PCI_PFAB_IO, 0x1);7980/* Map PCI CFG space */81tsi108_write_reg(TSI108_PCI_PFAB_BAR0_UPPER, 0x0);82tsi108_write_reg(TSI108_PCI_PFAB_BAR0, 0x7c000000 | 0x01);8384/* We don't need MEM32 and PRM remapping so disable them */85tsi108_write_reg(TSI108_PCI_PFAB_MEM32, 0x0);86tsi108_write_reg(TSI108_PCI_PFAB_PFM3, 0x0);87tsi108_write_reg(TSI108_PCI_PFAB_PFM4, 0x0);8889/* Set P2O_BAR0 */90tsi108_write_reg(TSI108_PCI_P2O_BAR0_UPPER, 0x0);91tsi108_write_reg(TSI108_PCI_P2O_BAR0, 0xc0000000);9293/* Init the PCI LUTs to do no remapping */94lut_addr = 0x500;95lut_val = 0x00000002;9697for (i = 0; i < 32; i++) {98tsi108_write_reg(TSI108_PCI_OFFSET + lut_addr, lut_val);99lut_addr += 4;100tsi108_write_reg(TSI108_PCI_OFFSET + lut_addr, 0x40000000);101lut_addr += 4;102lut_val += 0x02000000;103}104tsi108_write_reg(TSI108_PCI_P2O_PAGE_SIZES, 0x00007900);105106/* Set 64-bit PCI bus address for system memory */107tsi108_write_reg(TSI108_PCI_P2O_BAR2_UPPER, 0x0);108tsi108_write_reg(TSI108_PCI_P2O_BAR2, 0x0);109}110111static void __init holly_init_pci(void)112{113struct device_node *np;114115if (ppc_md.progress)116ppc_md.progress("holly_setup_arch():set_bridge", 0);117118/* setup PCI host bridge */119holly_remap_bridge();120121np = of_find_node_by_type(NULL, "pci");122if (np)123tsi108_setup_pci(np, HOLLY_PCI_CFG_PHYS, 1);124125of_node_put(np);126127ppc_md.pci_exclude_device = holly_exclude_device;128if (ppc_md.progress)129ppc_md.progress("tsi108: resources set", 0x100);130}131132static void __init holly_setup_arch(void)133{134tsi108_csr_vir_base = get_vir_csrbase();135136printk(KERN_INFO "PPC750GX/CL Platform\n");137}138139/*140* Interrupt setup and service. Interrupts on the holly come141* from the four external INT pins, PCI interrupts are routed via142* PCI interrupt control registers, it generates internal IRQ23143*144* Interrupt routing on the Holly Board:145* TSI108:PB_INT[0] -> CPU0:INT#146* TSI108:PB_INT[1] -> CPU0:MCP#147* TSI108:PB_INT[2] -> N/C148* TSI108:PB_INT[3] -> N/C149*/150static void __init holly_init_IRQ(void)151{152struct mpic *mpic;153#ifdef CONFIG_PCI154unsigned int cascade_pci_irq;155struct device_node *tsi_pci;156struct device_node *cascade_node = NULL;157#endif158159mpic = mpic_alloc(NULL, 0, MPIC_BIG_ENDIAN |160MPIC_SPV_EOI | MPIC_NO_PTHROU_DIS | MPIC_REGSET_TSI108,16124, 0,162"Tsi108_PIC");163164BUG_ON(mpic == NULL);165166mpic_assign_isu(mpic, 0, mpic->paddr + 0x100);167168mpic_init(mpic);169170#ifdef CONFIG_PCI171tsi_pci = of_find_node_by_type(NULL, "pci");172if (tsi_pci == NULL) {173printk(KERN_ERR "%s: No tsi108 pci node found !\n", __func__);174return;175}176177cascade_node = of_find_node_by_type(NULL, "pic-router");178if (cascade_node == NULL) {179printk(KERN_ERR "%s: No tsi108 pci cascade node found !\n", __func__);180return;181}182183cascade_pci_irq = irq_of_parse_and_map(tsi_pci, 0);184pr_debug("%s: tsi108 cascade_pci_irq = 0x%x\n", __func__, (u32) cascade_pci_irq);185tsi108_pci_int_init(cascade_node);186irq_set_handler_data(cascade_pci_irq, mpic);187irq_set_chained_handler(cascade_pci_irq, tsi108_irq_cascade);188189of_node_put(tsi_pci);190of_node_put(cascade_node);191#endif192/* Configure MPIC outputs to CPU0 */193tsi108_write_reg(TSI108_MPIC_OFFSET + 0x30c, 0);194}195196static void holly_show_cpuinfo(struct seq_file *m)197{198seq_printf(m, "vendor\t\t: IBM\n");199seq_printf(m, "machine\t\t: PPC750 GX/CL\n");200}201202static void __noreturn holly_restart(char *cmd)203{204__be32 __iomem *ocn_bar1 = NULL;205unsigned long bar;206struct device_node *bridge = NULL;207struct resource res;208phys_addr_t addr = 0xc0000000;209210local_irq_disable();211212bridge = of_find_node_by_type(NULL, "tsi-bridge");213if (bridge) {214of_address_to_resource(bridge, 0, &res);215addr = res.start;216of_node_put(bridge);217}218addr += (TSI108_PB_OFFSET + 0x414);219220ocn_bar1 = ioremap(addr, 0x4);221222/* Turn on the BOOT bit so the addresses are correctly223* routed to the HLP interface */224bar = ioread32be(ocn_bar1);225bar |= 2;226iowrite32be(bar, ocn_bar1);227iosync();228229/* Set SRR0 to the reset vector and turn on MSR_IP */230mtspr(SPRN_SRR0, 0xfff00100);231mtspr(SPRN_SRR1, MSR_IP);232233/* Do an rfi to jump back to firmware. Somewhat evil,234* but it works235*/236__asm__ __volatile__("rfi" : : : "memory");237238/* Spin until reset happens. Shouldn't really get here */239for (;;) ;240}241242static int ppc750_machine_check_exception(struct pt_regs *regs)243{244const struct exception_table_entry *entry;245246/* Are we prepared to handle this fault */247if ((entry = search_exception_tables(regs->nip)) != NULL) {248tsi108_clear_pci_cfg_error();249regs_set_recoverable(regs);250regs_set_return_ip(regs, extable_fixup(entry));251return 1;252}253return 0;254}255256define_machine(holly){257.name = "PPC750 GX/CL TSI",258.compatible = "ibm,holly",259.setup_arch = holly_setup_arch,260.discover_phbs = holly_init_pci,261.init_IRQ = holly_init_IRQ,262.show_cpuinfo = holly_show_cpuinfo,263.get_irq = mpic_get_irq,264.restart = holly_restart,265.machine_check_exception = ppc750_machine_check_exception,266.progress = udbg_progress,267};268269270