Path: blob/master/arch/powerpc/platforms/85xx/tqm85xx.c
10820 views
/*1* Based on MPC8560 ADS and arch/ppc tqm85xx ports2*3* Maintained by Kumar Gala (see MAINTAINERS for contact information)4*5* Copyright 2008 Freescale Semiconductor Inc.6*7* Copyright (c) 2005-2006 DENX Software Engineering8* Stefan Roese <[email protected]>9*10* Based on original work by11* Kumar Gala <[email protected]>12* Copyright 2004 Freescale Semiconductor Inc.13*14* This program is free software; you can redistribute it and/or modify it15* under the terms of the GNU General Public License as published by the16* Free Software Foundation; either version 2 of the License, or (at your17* 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/delay.h>25#include <linux/seq_file.h>26#include <linux/of_platform.h>2728#include <asm/system.h>29#include <asm/time.h>30#include <asm/machdep.h>31#include <asm/pci-bridge.h>32#include <asm/mpic.h>33#include <asm/prom.h>34#include <mm/mmu_decl.h>35#include <asm/udbg.h>3637#include <sysdev/fsl_soc.h>38#include <sysdev/fsl_pci.h>3940#ifdef CONFIG_CPM241#include <asm/cpm2.h>42#include <sysdev/cpm2_pic.h>4344static void cpm2_cascade(unsigned int irq, struct irq_desc *desc)45{46struct irq_chip *chip = irq_desc_get_chip(desc);47int cascade_irq;4849while ((cascade_irq = cpm2_get_irq()) >= 0)50generic_handle_irq(cascade_irq);5152chip->irq_eoi(&desc->irq_data);53}54#endif /* CONFIG_CPM2 */5556static void __init tqm85xx_pic_init(void)57{58struct mpic *mpic;59struct resource r;60struct device_node *np;61#ifdef CONFIG_CPM262int irq;63#endif6465np = of_find_node_by_type(NULL, "open-pic");66if (!np) {67printk(KERN_ERR "Could not find open-pic node\n");68return;69}7071if (of_address_to_resource(np, 0, &r)) {72printk(KERN_ERR "Could not map mpic register space\n");73of_node_put(np);74return;75}7677mpic = mpic_alloc(np, r.start,78MPIC_PRIMARY | MPIC_WANTS_RESET | MPIC_BIG_ENDIAN,790, 256, " OpenPIC ");80BUG_ON(mpic == NULL);81of_node_put(np);8283mpic_init(mpic);8485#ifdef CONFIG_CPM286/* Setup CPM2 PIC */87np = of_find_compatible_node(NULL, NULL, "fsl,cpm2-pic");88if (np == NULL) {89printk(KERN_ERR "PIC init: can not find fsl,cpm2-pic node\n");90return;91}92irq = irq_of_parse_and_map(np, 0);9394if (irq == NO_IRQ) {95of_node_put(np);96printk(KERN_ERR "PIC init: got no IRQ for cpm cascade\n");97return;98}99100cpm2_pic_init(np);101of_node_put(np);102irq_set_chained_handler(irq, cpm2_cascade);103#endif104}105106/*107* Setup the architecture108*/109static void __init tqm85xx_setup_arch(void)110{111#ifdef CONFIG_PCI112struct device_node *np;113#endif114115if (ppc_md.progress)116ppc_md.progress("tqm85xx_setup_arch()", 0);117118#ifdef CONFIG_CPM2119cpm2_reset();120#endif121122#ifdef CONFIG_PCI123for_each_node_by_type(np, "pci") {124if (of_device_is_compatible(np, "fsl,mpc8540-pci") ||125of_device_is_compatible(np, "fsl,mpc8548-pcie")) {126struct resource rsrc;127if (!of_address_to_resource(np, 0, &rsrc)) {128if ((rsrc.start & 0xfffff) == 0x8000)129fsl_add_bridge(np, 1);130else131fsl_add_bridge(np, 0);132}133}134}135#endif136}137138static void tqm85xx_show_cpuinfo(struct seq_file *m)139{140uint pvid, svid, phid1;141142pvid = mfspr(SPRN_PVR);143svid = mfspr(SPRN_SVR);144145seq_printf(m, "Vendor\t\t: TQ Components\n");146seq_printf(m, "PVR\t\t: 0x%x\n", pvid);147seq_printf(m, "SVR\t\t: 0x%x\n", svid);148149/* Display cpu Pll setting */150phid1 = mfspr(SPRN_HID1);151seq_printf(m, "PLL setting\t: 0x%x\n", ((phid1 >> 24) & 0x3f));152}153154static void __init tqm85xx_ti1520_fixup(struct pci_dev *pdev)155{156unsigned int val;157158/* Do not do the fixup on other platforms! */159if (!machine_is(tqm85xx))160return;161162dev_info(&pdev->dev, "Using TI 1520 fixup on TQM85xx\n");163164/*165* Enable P2CCLK bit in system control register166* to enable CLOCK output to power chip167*/168pci_read_config_dword(pdev, 0x80, &val);169pci_write_config_dword(pdev, 0x80, val | (1 << 27));170171}172DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_TI, PCI_DEVICE_ID_TI_1520,173tqm85xx_ti1520_fixup);174175static struct of_device_id __initdata of_bus_ids[] = {176{ .compatible = "simple-bus", },177{ .compatible = "gianfar", },178{},179};180181static int __init declare_of_platform_devices(void)182{183of_platform_bus_probe(NULL, of_bus_ids, NULL);184185return 0;186}187machine_device_initcall(tqm85xx, declare_of_platform_devices);188189static const char *board[] __initdata = {190"tqc,tqm8540",191"tqc,tqm8541",192"tqc,tqm8548",193"tqc,tqm8555",194"tqc,tqm8560",195NULL196};197198/*199* Called very early, device-tree isn't unflattened200*/201static int __init tqm85xx_probe(void)202{203return of_flat_dt_match(of_get_flat_dt_root(), board);204}205206define_machine(tqm85xx) {207.name = "TQM85xx",208.probe = tqm85xx_probe,209.setup_arch = tqm85xx_setup_arch,210.init_IRQ = tqm85xx_pic_init,211.show_cpuinfo = tqm85xx_show_cpuinfo,212.get_irq = mpic_get_irq,213.restart = fsl_rstcr_restart,214.calibrate_decr = generic_calibrate_decr,215.progress = udbg_progress,216};217218219