Path: blob/master/arch/powerpc/platforms/85xx/mpc85xx_ads.c
10820 views
/*1* MPC85xx setup and early boot code plus other random bits.2*3* Maintained by Kumar Gala (see MAINTAINERS for contact information)4*5* Copyright 2005 Freescale Semiconductor 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*/1213#include <linux/stddef.h>14#include <linux/kernel.h>15#include <linux/pci.h>16#include <linux/kdev_t.h>17#include <linux/delay.h>18#include <linux/seq_file.h>19#include <linux/of_platform.h>2021#include <asm/system.h>22#include <asm/time.h>23#include <asm/machdep.h>24#include <asm/pci-bridge.h>25#include <asm/mpic.h>26#include <mm/mmu_decl.h>27#include <asm/udbg.h>2829#include <sysdev/fsl_soc.h>30#include <sysdev/fsl_pci.h>3132#ifdef CONFIG_CPM233#include <asm/cpm2.h>34#include <sysdev/cpm2_pic.h>35#endif3637#ifdef CONFIG_PCI38static int mpc85xx_exclude_device(struct pci_controller *hose,39u_char bus, u_char devfn)40{41if (bus == 0 && PCI_SLOT(devfn) == 0)42return PCIBIOS_DEVICE_NOT_FOUND;43else44return PCIBIOS_SUCCESSFUL;45}46#endif /* CONFIG_PCI */4748#ifdef CONFIG_CPM24950static void cpm2_cascade(unsigned int irq, struct irq_desc *desc)51{52struct irq_chip *chip = irq_desc_get_chip(desc);53int cascade_irq;5455while ((cascade_irq = cpm2_get_irq()) >= 0)56generic_handle_irq(cascade_irq);5758chip->irq_eoi(&desc->irq_data);59}6061#endif /* CONFIG_CPM2 */6263static void __init mpc85xx_ads_pic_init(void)64{65struct mpic *mpic;66struct resource r;67struct device_node *np = NULL;68#ifdef CONFIG_CPM269int irq;70#endif7172np = of_find_node_by_type(np, "open-pic");73if (!np) {74printk(KERN_ERR "Could not find open-pic node\n");75return;76}7778if (of_address_to_resource(np, 0, &r)) {79printk(KERN_ERR "Could not map mpic register space\n");80of_node_put(np);81return;82}8384mpic = mpic_alloc(np, r.start,85MPIC_PRIMARY | MPIC_WANTS_RESET | MPIC_BIG_ENDIAN,860, 256, " OpenPIC ");87BUG_ON(mpic == NULL);88of_node_put(np);8990mpic_init(mpic);9192#ifdef CONFIG_CPM293/* Setup CPM2 PIC */94np = of_find_compatible_node(NULL, NULL, "fsl,cpm2-pic");95if (np == NULL) {96printk(KERN_ERR "PIC init: can not find fsl,cpm2-pic node\n");97return;98}99irq = irq_of_parse_and_map(np, 0);100101cpm2_pic_init(np);102of_node_put(np);103irq_set_chained_handler(irq, cpm2_cascade);104#endif105}106107/*108* Setup the architecture109*/110#ifdef CONFIG_CPM2111struct cpm_pin {112int port, pin, flags;113};114115static const struct cpm_pin mpc8560_ads_pins[] = {116/* SCC1 */117{3, 29, CPM_PIN_OUTPUT | CPM_PIN_PRIMARY},118{3, 30, CPM_PIN_OUTPUT | CPM_PIN_SECONDARY},119{3, 31, CPM_PIN_INPUT | CPM_PIN_PRIMARY},120121/* SCC2 */122{2, 12, CPM_PIN_INPUT | CPM_PIN_PRIMARY},123{2, 13, CPM_PIN_INPUT | CPM_PIN_PRIMARY},124{3, 26, CPM_PIN_OUTPUT | CPM_PIN_PRIMARY},125{3, 27, CPM_PIN_OUTPUT | CPM_PIN_PRIMARY},126{3, 28, CPM_PIN_INPUT | CPM_PIN_PRIMARY},127128/* FCC2 */129{1, 18, CPM_PIN_INPUT | CPM_PIN_PRIMARY},130{1, 19, CPM_PIN_INPUT | CPM_PIN_PRIMARY},131{1, 20, CPM_PIN_INPUT | CPM_PIN_PRIMARY},132{1, 21, CPM_PIN_INPUT | CPM_PIN_PRIMARY},133{1, 22, CPM_PIN_OUTPUT | CPM_PIN_PRIMARY},134{1, 23, CPM_PIN_OUTPUT | CPM_PIN_PRIMARY},135{1, 24, CPM_PIN_OUTPUT | CPM_PIN_PRIMARY},136{1, 25, CPM_PIN_OUTPUT | CPM_PIN_PRIMARY},137{1, 26, CPM_PIN_INPUT | CPM_PIN_PRIMARY},138{1, 27, CPM_PIN_INPUT | CPM_PIN_PRIMARY},139{1, 28, CPM_PIN_INPUT | CPM_PIN_PRIMARY},140{1, 29, CPM_PIN_OUTPUT | CPM_PIN_SECONDARY},141{1, 30, CPM_PIN_INPUT | CPM_PIN_PRIMARY},142{1, 31, CPM_PIN_OUTPUT | CPM_PIN_PRIMARY},143{2, 18, CPM_PIN_INPUT | CPM_PIN_PRIMARY}, /* CLK14 */144{2, 19, CPM_PIN_INPUT | CPM_PIN_PRIMARY}, /* CLK13 */145146/* FCC3 */147{1, 4, CPM_PIN_OUTPUT | CPM_PIN_PRIMARY},148{1, 5, CPM_PIN_OUTPUT | CPM_PIN_PRIMARY},149{1, 6, CPM_PIN_OUTPUT | CPM_PIN_PRIMARY},150{1, 8, CPM_PIN_INPUT | CPM_PIN_PRIMARY},151{1, 9, CPM_PIN_INPUT | CPM_PIN_PRIMARY},152{1, 10, CPM_PIN_INPUT | CPM_PIN_PRIMARY},153{1, 11, CPM_PIN_INPUT | CPM_PIN_PRIMARY},154{1, 12, CPM_PIN_INPUT | CPM_PIN_PRIMARY},155{1, 13, CPM_PIN_INPUT | CPM_PIN_PRIMARY},156{1, 14, CPM_PIN_OUTPUT | CPM_PIN_PRIMARY},157{1, 15, CPM_PIN_OUTPUT | CPM_PIN_PRIMARY},158{1, 16, CPM_PIN_INPUT | CPM_PIN_PRIMARY},159{1, 17, CPM_PIN_INPUT | CPM_PIN_PRIMARY},160{2, 16, CPM_PIN_INPUT | CPM_PIN_PRIMARY}, /* CLK16 */161{2, 17, CPM_PIN_INPUT | CPM_PIN_PRIMARY}, /* CLK15 */162{2, 27, CPM_PIN_OUTPUT | CPM_PIN_PRIMARY},163};164165static void __init init_ioports(void)166{167int i;168169for (i = 0; i < ARRAY_SIZE(mpc8560_ads_pins); i++) {170const struct cpm_pin *pin = &mpc8560_ads_pins[i];171cpm2_set_pin(pin->port, pin->pin, pin->flags);172}173174cpm2_clk_setup(CPM_CLK_SCC1, CPM_BRG1, CPM_CLK_RX);175cpm2_clk_setup(CPM_CLK_SCC1, CPM_BRG1, CPM_CLK_TX);176cpm2_clk_setup(CPM_CLK_SCC2, CPM_BRG2, CPM_CLK_RX);177cpm2_clk_setup(CPM_CLK_SCC2, CPM_BRG2, CPM_CLK_TX);178cpm2_clk_setup(CPM_CLK_FCC2, CPM_CLK13, CPM_CLK_RX);179cpm2_clk_setup(CPM_CLK_FCC2, CPM_CLK14, CPM_CLK_TX);180cpm2_clk_setup(CPM_CLK_FCC3, CPM_CLK15, CPM_CLK_RX);181cpm2_clk_setup(CPM_CLK_FCC3, CPM_CLK16, CPM_CLK_TX);182}183#endif184185static void __init mpc85xx_ads_setup_arch(void)186{187#ifdef CONFIG_PCI188struct device_node *np;189#endif190191if (ppc_md.progress)192ppc_md.progress("mpc85xx_ads_setup_arch()", 0);193194#ifdef CONFIG_CPM2195cpm2_reset();196init_ioports();197#endif198199#ifdef CONFIG_PCI200for_each_compatible_node(np, "pci", "fsl,mpc8540-pci")201fsl_add_bridge(np, 1);202203ppc_md.pci_exclude_device = mpc85xx_exclude_device;204#endif205}206207static void mpc85xx_ads_show_cpuinfo(struct seq_file *m)208{209uint pvid, svid, phid1;210211pvid = mfspr(SPRN_PVR);212svid = mfspr(SPRN_SVR);213214seq_printf(m, "Vendor\t\t: Freescale Semiconductor\n");215seq_printf(m, "PVR\t\t: 0x%x\n", pvid);216seq_printf(m, "SVR\t\t: 0x%x\n", svid);217218/* Display cpu Pll setting */219phid1 = mfspr(SPRN_HID1);220seq_printf(m, "PLL setting\t: 0x%x\n", ((phid1 >> 24) & 0x3f));221}222223static struct of_device_id __initdata of_bus_ids[] = {224{ .name = "soc", },225{ .type = "soc", },226{ .name = "cpm", },227{ .name = "localbus", },228{ .compatible = "simple-bus", },229{ .compatible = "gianfar", },230{},231};232233static int __init declare_of_platform_devices(void)234{235of_platform_bus_probe(NULL, of_bus_ids, NULL);236237return 0;238}239machine_device_initcall(mpc85xx_ads, declare_of_platform_devices);240241/*242* Called very early, device-tree isn't unflattened243*/244static int __init mpc85xx_ads_probe(void)245{246unsigned long root = of_get_flat_dt_root();247248return of_flat_dt_is_compatible(root, "MPC85xxADS");249}250251define_machine(mpc85xx_ads) {252.name = "MPC85xx ADS",253.probe = mpc85xx_ads_probe,254.setup_arch = mpc85xx_ads_setup_arch,255.init_IRQ = mpc85xx_ads_pic_init,256.show_cpuinfo = mpc85xx_ads_show_cpuinfo,257.get_irq = mpic_get_irq,258.restart = fsl_rstcr_restart,259.calibrate_decr = generic_calibrate_decr,260.progress = udbg_progress,261};262263264