Path: blob/master/arch/powerpc/platforms/embedded6xx/mpc7448_hpc2.c
10819 views
/*1* mpc7448_hpc2.c2*3* Board setup routines for the Freescale mpc7448hpc2(taiga) platform4*5* Author: Jacob Pan6* [email protected]7* Author: Xianghua Xiao8* [email protected]9* Maintainer: Roy Zang <[email protected]>10* Add Flat Device Tree support fot mpc7448hpc2 board11*12* Copyright 2004-2006 Freescale Semiconductor, Inc.13*14* This program is free software; you can redistribute it and/or15* modify it under the terms of the GNU General Public License16* as published by the Free Software Foundation; either version17* 2 of the License, or (at your option) any later version.18*/1920#include <linux/stddef.h>21#include <linux/kernel.h>22#include <linux/pci.h>23#include <linux/kdev_t.h>24#include <linux/console.h>25#include <linux/delay.h>26#include <linux/irq.h>27#include <linux/seq_file.h>28#include <linux/root_dev.h>29#include <linux/serial.h>30#include <linux/tty.h>31#include <linux/serial_core.h>3233#include <asm/system.h>34#include <asm/time.h>35#include <asm/machdep.h>36#include <asm/prom.h>37#include <asm/udbg.h>38#include <asm/tsi108.h>39#include <asm/pci-bridge.h>40#include <asm/reg.h>41#include <mm/mmu_decl.h>42#include <asm/tsi108_pci.h>43#include <asm/tsi108_irq.h>44#include <asm/mpic.h>4546#undef DEBUG47#ifdef DEBUG48#define DBG(fmt...) do { printk(fmt); } while(0)49#else50#define DBG(fmt...) do { } while(0)51#endif5253#define MPC7448HPC2_PCI_CFG_PHYS 0xfb0000005455int mpc7448_hpc2_exclude_device(struct pci_controller *hose,56u_char bus, u_char devfn)57{58if (bus == 0 && PCI_SLOT(devfn) == 0)59return PCIBIOS_DEVICE_NOT_FOUND;60else61return PCIBIOS_SUCCESSFUL;62}6364static void __init mpc7448_hpc2_setup_arch(void)65{66struct device_node *np;67if (ppc_md.progress)68ppc_md.progress("mpc7448_hpc2_setup_arch():set_bridge", 0);6970tsi108_csr_vir_base = get_vir_csrbase();7172/* setup PCI host bridge */73#ifdef CONFIG_PCI74for_each_compatible_node(np, "pci", "tsi108-pci")75tsi108_setup_pci(np, MPC7448HPC2_PCI_CFG_PHYS, 0);7677ppc_md.pci_exclude_device = mpc7448_hpc2_exclude_device;78if (ppc_md.progress)79ppc_md.progress("tsi108: resources set", 0x100);80#endif8182printk(KERN_INFO "MPC7448HPC2 (TAIGA) Platform\n");83printk(KERN_INFO84"Jointly ported by Freescale and Tundra Semiconductor\n");85printk(KERN_INFO86"Enabling L2 cache then enabling the HID0 prefetch engine.\n");87}8889/*90* Interrupt setup and service. Interrupts on the mpc7448_hpc2 come91* from the four external INT pins, PCI interrupts are routed via92* PCI interrupt control registers, it generates internal IRQ2393*94* Interrupt routing on the Taiga Board:95* TSI108:PB_INT[0] -> CPU0:INT#96* TSI108:PB_INT[1] -> CPU0:MCP#97* TSI108:PB_INT[2] -> N/C98* TSI108:PB_INT[3] -> N/C99*/100static void __init mpc7448_hpc2_init_IRQ(void)101{102struct mpic *mpic;103phys_addr_t mpic_paddr = 0;104struct device_node *tsi_pic;105#ifdef CONFIG_PCI106unsigned int cascade_pci_irq;107struct device_node *tsi_pci;108struct device_node *cascade_node = NULL;109#endif110111tsi_pic = of_find_node_by_type(NULL, "open-pic");112if (tsi_pic) {113unsigned int size;114const void *prop = of_get_property(tsi_pic, "reg", &size);115mpic_paddr = of_translate_address(tsi_pic, prop);116}117118if (mpic_paddr == 0) {119printk("%s: No tsi108 PIC found !\n", __func__);120return;121}122123DBG("%s: tsi108 pic phys_addr = 0x%x\n", __func__,124(u32) mpic_paddr);125126mpic = mpic_alloc(tsi_pic, mpic_paddr,127MPIC_PRIMARY | MPIC_BIG_ENDIAN | MPIC_WANTS_RESET |128MPIC_SPV_EOI | MPIC_NO_PTHROU_DIS | MPIC_REGSET_TSI108,12924,130NR_IRQS-4, /* num_sources used */131"Tsi108_PIC");132133BUG_ON(mpic == NULL);134135mpic_assign_isu(mpic, 0, mpic_paddr + 0x100);136137mpic_init(mpic);138139#ifdef CONFIG_PCI140tsi_pci = of_find_node_by_type(NULL, "pci");141if (tsi_pci == NULL) {142printk("%s: No tsi108 pci node found !\n", __func__);143return;144}145cascade_node = of_find_node_by_type(NULL, "pic-router");146if (cascade_node == NULL) {147printk("%s: No tsi108 pci cascade node found !\n", __func__);148return;149}150151cascade_pci_irq = irq_of_parse_and_map(tsi_pci, 0);152DBG("%s: tsi108 cascade_pci_irq = 0x%x\n", __func__,153(u32) cascade_pci_irq);154tsi108_pci_int_init(cascade_node);155irq_set_handler_data(cascade_pci_irq, mpic);156irq_set_chained_handler(cascade_pci_irq, tsi108_irq_cascade);157#endif158/* Configure MPIC outputs to CPU0 */159tsi108_write_reg(TSI108_MPIC_OFFSET + 0x30c, 0);160of_node_put(tsi_pic);161}162163void mpc7448_hpc2_show_cpuinfo(struct seq_file *m)164{165seq_printf(m, "vendor\t\t: Freescale Semiconductor\n");166}167168void mpc7448_hpc2_restart(char *cmd)169{170local_irq_disable();171172/* Set exception prefix high - to the firmware */173_nmask_and_or_msr(0, MSR_IP);174175for (;;) ; /* Spin until reset happens */176}177178void mpc7448_hpc2_power_off(void)179{180local_irq_disable();181for (;;) ; /* No way to shut power off with software */182}183184void mpc7448_hpc2_halt(void)185{186mpc7448_hpc2_power_off();187}188189/*190* Called very early, device-tree isn't unflattened191*/192static int __init mpc7448_hpc2_probe(void)193{194unsigned long root = of_get_flat_dt_root();195196if (!of_flat_dt_is_compatible(root, "mpc74xx"))197return 0;198return 1;199}200201static int mpc7448_machine_check_exception(struct pt_regs *regs)202{203const struct exception_table_entry *entry;204205/* Are we prepared to handle this fault */206if ((entry = search_exception_tables(regs->nip)) != NULL) {207tsi108_clear_pci_cfg_error();208regs->msr |= MSR_RI;209regs->nip = entry->fixup;210return 1;211}212return 0;213}214215define_machine(mpc7448_hpc2){216.name = "MPC7448 HPC2",217.probe = mpc7448_hpc2_probe,218.setup_arch = mpc7448_hpc2_setup_arch,219.init_IRQ = mpc7448_hpc2_init_IRQ,220.show_cpuinfo = mpc7448_hpc2_show_cpuinfo,221.get_irq = mpic_get_irq,222.restart = mpc7448_hpc2_restart,223.calibrate_decr = generic_calibrate_decr,224.machine_check_exception= mpc7448_machine_check_exception,225.progress = udbg_progress,226};227228229