Path: blob/master/arch/powerpc/platforms/85xx/xes_mpc85xx.c
10820 views
/*1* Copyright (C) 2009 Extreme Engineering Solutions, Inc.2*3* X-ES board-specific functionality4*5* Based on mpc85xx_ds code from Freescale Semiconductor, Inc.6*7* Author: Nate Case <[email protected]>8*9* This is free software; you can redistribute it and/or modify10* it under the terms of the GNU General Public License version 2 as11* published by the Free Software Foundation.12*/1314#include <linux/stddef.h>15#include <linux/kernel.h>16#include <linux/pci.h>17#include <linux/kdev_t.h>18#include <linux/delay.h>19#include <linux/seq_file.h>20#include <linux/interrupt.h>21#include <linux/of_platform.h>2223#include <asm/system.h>24#include <asm/time.h>25#include <asm/machdep.h>26#include <asm/pci-bridge.h>27#include <mm/mmu_decl.h>28#include <asm/prom.h>29#include <asm/udbg.h>30#include <asm/mpic.h>3132#include <sysdev/fsl_soc.h>33#include <sysdev/fsl_pci.h>3435/* A few bit definitions needed for fixups on some boards */36#define MPC85xx_L2CTL_L2E 0x80000000 /* L2 enable */37#define MPC85xx_L2CTL_L2I 0x40000000 /* L2 flash invalidate */38#define MPC85xx_L2CTL_L2SIZ_MASK 0x30000000 /* L2 SRAM size (R/O) */3940void __init xes_mpc85xx_pic_init(void)41{42struct mpic *mpic;43struct resource r;44struct device_node *np;4546np = of_find_node_by_type(NULL, "open-pic");47if (np == NULL) {48printk(KERN_ERR "Could not find open-pic node\n");49return;50}5152if (of_address_to_resource(np, 0, &r)) {53printk(KERN_ERR "Failed to map mpic register space\n");54of_node_put(np);55return;56}5758mpic = mpic_alloc(np, r.start,59MPIC_PRIMARY | MPIC_WANTS_RESET |60MPIC_BIG_ENDIAN | MPIC_BROKEN_FRR_NIRQS,610, 256, " OpenPIC ");62BUG_ON(mpic == NULL);63of_node_put(np);6465mpic_init(mpic);66}6768static void xes_mpc85xx_configure_l2(void __iomem *l2_base)69{70volatile uint32_t ctl, tmp;7172asm volatile("msync; isync");73tmp = in_be32(l2_base);7475/*76* xMon may have enabled part of L2 as SRAM, so we need to set it77* up for all cache mode just to be safe.78*/79printk(KERN_INFO "xes_mpc85xx: Enabling L2 as cache\n");8081ctl = MPC85xx_L2CTL_L2E | MPC85xx_L2CTL_L2I;82if (of_machine_is_compatible("MPC8540") ||83of_machine_is_compatible("MPC8560"))84/*85* Assume L2 SRAM is used fully for cache, so set86* L2BLKSZ (bits 4:5) to match L2SIZ (bits 2:3).87*/88ctl |= (tmp & MPC85xx_L2CTL_L2SIZ_MASK) >> 2;8990asm volatile("msync; isync");91out_be32(l2_base, ctl);92asm volatile("msync; isync");93}9495static void xes_mpc85xx_fixups(void)96{97struct device_node *np;98int err;99100/*101* Legacy xMon firmware on some X-ES boards does not enable L2102* as cache. We must ensure that they get enabled here.103*/104for_each_node_by_name(np, "l2-cache-controller") {105struct resource r[2];106void __iomem *l2_base;107108/* Only MPC8548, MPC8540, and MPC8560 boards are affected */109if (!of_device_is_compatible(np,110"fsl,mpc8548-l2-cache-controller") &&111!of_device_is_compatible(np,112"fsl,mpc8540-l2-cache-controller") &&113!of_device_is_compatible(np,114"fsl,mpc8560-l2-cache-controller"))115continue;116117err = of_address_to_resource(np, 0, &r[0]);118if (err) {119printk(KERN_WARNING "xes_mpc85xx: Could not get "120"resource for device tree node '%s'",121np->full_name);122continue;123}124125l2_base = ioremap(r[0].start, r[0].end - r[0].start + 1);126127xes_mpc85xx_configure_l2(l2_base);128}129}130131#ifdef CONFIG_PCI132static int primary_phb_addr;133#endif134135/*136* Setup the architecture137*/138#ifdef CONFIG_SMP139extern void __init mpc85xx_smp_init(void);140#endif141static void __init xes_mpc85xx_setup_arch(void)142{143#ifdef CONFIG_PCI144struct device_node *np;145#endif146struct device_node *root;147const char *model = "Unknown";148149root = of_find_node_by_path("/");150if (root == NULL)151return;152153model = of_get_property(root, "model", NULL);154155printk(KERN_INFO "X-ES MPC85xx-based single-board computer: %s\n",156model + strlen("xes,"));157158xes_mpc85xx_fixups();159160#ifdef CONFIG_PCI161for_each_node_by_type(np, "pci") {162if (of_device_is_compatible(np, "fsl,mpc8540-pci") ||163of_device_is_compatible(np, "fsl,mpc8548-pcie")) {164struct resource rsrc;165of_address_to_resource(np, 0, &rsrc);166if ((rsrc.start & 0xfffff) == primary_phb_addr)167fsl_add_bridge(np, 1);168else169fsl_add_bridge(np, 0);170}171}172#endif173174#ifdef CONFIG_SMP175mpc85xx_smp_init();176#endif177}178179static struct of_device_id __initdata xes_mpc85xx_ids[] = {180{ .type = "soc", },181{ .compatible = "soc", },182{ .compatible = "simple-bus", },183{ .compatible = "gianfar", },184{},185};186187static int __init xes_mpc85xx_publish_devices(void)188{189return of_platform_bus_probe(NULL, xes_mpc85xx_ids, NULL);190}191machine_device_initcall(xes_mpc8572, xes_mpc85xx_publish_devices);192machine_device_initcall(xes_mpc8548, xes_mpc85xx_publish_devices);193machine_device_initcall(xes_mpc8540, xes_mpc85xx_publish_devices);194195/*196* Called very early, device-tree isn't unflattened197*/198static int __init xes_mpc8572_probe(void)199{200unsigned long root = of_get_flat_dt_root();201202if (of_flat_dt_is_compatible(root, "xes,MPC8572")) {203#ifdef CONFIG_PCI204primary_phb_addr = 0x8000;205#endif206return 1;207} else {208return 0;209}210}211212static int __init xes_mpc8548_probe(void)213{214unsigned long root = of_get_flat_dt_root();215216if (of_flat_dt_is_compatible(root, "xes,MPC8548")) {217#ifdef CONFIG_PCI218primary_phb_addr = 0xb000;219#endif220return 1;221} else {222return 0;223}224}225226static int __init xes_mpc8540_probe(void)227{228unsigned long root = of_get_flat_dt_root();229230if (of_flat_dt_is_compatible(root, "xes,MPC8540")) {231#ifdef CONFIG_PCI232primary_phb_addr = 0xb000;233#endif234return 1;235} else {236return 0;237}238}239240define_machine(xes_mpc8572) {241.name = "X-ES MPC8572",242.probe = xes_mpc8572_probe,243.setup_arch = xes_mpc85xx_setup_arch,244.init_IRQ = xes_mpc85xx_pic_init,245#ifdef CONFIG_PCI246.pcibios_fixup_bus = fsl_pcibios_fixup_bus,247#endif248.get_irq = mpic_get_irq,249.restart = fsl_rstcr_restart,250.calibrate_decr = generic_calibrate_decr,251.progress = udbg_progress,252};253254define_machine(xes_mpc8548) {255.name = "X-ES MPC8548",256.probe = xes_mpc8548_probe,257.setup_arch = xes_mpc85xx_setup_arch,258.init_IRQ = xes_mpc85xx_pic_init,259#ifdef CONFIG_PCI260.pcibios_fixup_bus = fsl_pcibios_fixup_bus,261#endif262.get_irq = mpic_get_irq,263.restart = fsl_rstcr_restart,264.calibrate_decr = generic_calibrate_decr,265.progress = udbg_progress,266};267268define_machine(xes_mpc8540) {269.name = "X-ES MPC8540",270.probe = xes_mpc8540_probe,271.setup_arch = xes_mpc85xx_setup_arch,272.init_IRQ = xes_mpc85xx_pic_init,273#ifdef CONFIG_PCI274.pcibios_fixup_bus = fsl_pcibios_fixup_bus,275#endif276.get_irq = mpic_get_irq,277.restart = fsl_rstcr_restart,278.calibrate_decr = generic_calibrate_decr,279.progress = udbg_progress,280};281282283