Path: blob/master/arch/powerpc/platforms/85xx/xes_mpc85xx.c
26481 views
// SPDX-License-Identifier: GPL-2.0-only1/*2* Copyright (C) 2009 Extreme Engineering Solutions, Inc.3*4* X-ES board-specific functionality5*6* Based on mpc85xx_ds code from Freescale Semiconductor, Inc.7*8* Author: Nate Case <[email protected]>9*/1011#include <linux/stddef.h>12#include <linux/kernel.h>13#include <linux/pci.h>14#include <linux/kdev_t.h>15#include <linux/delay.h>16#include <linux/seq_file.h>17#include <linux/interrupt.h>18#include <linux/of.h>19#include <linux/of_address.h>2021#include <asm/time.h>22#include <asm/machdep.h>23#include <asm/pci-bridge.h>24#include <mm/mmu_decl.h>25#include <asm/udbg.h>26#include <asm/mpic.h>2728#include <sysdev/fsl_soc.h>29#include <sysdev/fsl_pci.h>30#include "smp.h"3132#include "mpc85xx.h"3334/* A few bit definitions needed for fixups on some boards */35#define MPC85xx_L2CTL_L2E 0x80000000 /* L2 enable */36#define MPC85xx_L2CTL_L2I 0x40000000 /* L2 flash invalidate */37#define MPC85xx_L2CTL_L2SIZ_MASK 0x30000000 /* L2 SRAM size (R/O) */3839static void __init xes_mpc85xx_pic_init(void)40{41struct mpic *mpic = mpic_alloc(NULL, 0, MPIC_BIG_ENDIAN,420, 256, " OpenPIC ");43BUG_ON(mpic == NULL);44mpic_init(mpic);45}4647static void __init xes_mpc85xx_configure_l2(void __iomem *l2_base)48{49volatile uint32_t ctl, tmp;5051asm volatile("msync; isync");52tmp = in_be32(l2_base);5354/*55* xMon may have enabled part of L2 as SRAM, so we need to set it56* up for all cache mode just to be safe.57*/58printk(KERN_INFO "xes_mpc85xx: Enabling L2 as cache\n");5960ctl = MPC85xx_L2CTL_L2E | MPC85xx_L2CTL_L2I;61if (of_machine_is_compatible("MPC8540") ||62of_machine_is_compatible("MPC8560"))63/*64* Assume L2 SRAM is used fully for cache, so set65* L2BLKSZ (bits 4:5) to match L2SIZ (bits 2:3).66*/67ctl |= (tmp & MPC85xx_L2CTL_L2SIZ_MASK) >> 2;6869asm volatile("msync; isync");70out_be32(l2_base, ctl);71asm volatile("msync; isync");72}7374static void __init xes_mpc85xx_fixups(void)75{76struct device_node *np;77int err;7879/*80* Legacy xMon firmware on some X-ES boards does not enable L281* as cache. We must ensure that they get enabled here.82*/83for_each_node_by_name(np, "l2-cache-controller") {84struct resource r[2];85void __iomem *l2_base;8687/* Only MPC8548, MPC8540, and MPC8560 boards are affected */88if (!of_device_is_compatible(np,89"fsl,mpc8548-l2-cache-controller") &&90!of_device_is_compatible(np,91"fsl,mpc8540-l2-cache-controller") &&92!of_device_is_compatible(np,93"fsl,mpc8560-l2-cache-controller"))94continue;9596err = of_address_to_resource(np, 0, &r[0]);97if (err) {98printk(KERN_WARNING "xes_mpc85xx: Could not get "99"resource for device tree node '%pOF'",100np);101continue;102}103104l2_base = ioremap(r[0].start, resource_size(&r[0]));105106xes_mpc85xx_configure_l2(l2_base);107}108}109110/*111* Setup the architecture112*/113static void __init xes_mpc85xx_setup_arch(void)114{115struct device_node *root;116const char *model = "Unknown";117118root = of_find_node_by_path("/");119if (root == NULL)120return;121122model = of_get_property(root, "model", NULL);123124printk(KERN_INFO "X-ES MPC85xx-based single-board computer: %s\n",125model + strlen("xes,"));126127xes_mpc85xx_fixups();128129mpc85xx_smp_init();130131fsl_pci_assign_primary();132}133134machine_arch_initcall(xes_mpc8572, mpc85xx_common_publish_devices);135machine_arch_initcall(xes_mpc8548, mpc85xx_common_publish_devices);136machine_arch_initcall(xes_mpc8540, mpc85xx_common_publish_devices);137138define_machine(xes_mpc8572) {139.name = "X-ES MPC8572",140.compatible = "xes,MPC8572",141.setup_arch = xes_mpc85xx_setup_arch,142.init_IRQ = xes_mpc85xx_pic_init,143#ifdef CONFIG_PCI144.pcibios_fixup_bus = fsl_pcibios_fixup_bus,145.pcibios_fixup_phb = fsl_pcibios_fixup_phb,146#endif147.get_irq = mpic_get_irq,148.progress = udbg_progress,149};150151define_machine(xes_mpc8548) {152.name = "X-ES MPC8548",153.compatible = "xes,MPC8548",154.setup_arch = xes_mpc85xx_setup_arch,155.init_IRQ = xes_mpc85xx_pic_init,156#ifdef CONFIG_PCI157.pcibios_fixup_bus = fsl_pcibios_fixup_bus,158.pcibios_fixup_phb = fsl_pcibios_fixup_phb,159#endif160.get_irq = mpic_get_irq,161.progress = udbg_progress,162};163164define_machine(xes_mpc8540) {165.name = "X-ES MPC8540",166.compatible = "xes,MPC8540",167.setup_arch = xes_mpc85xx_setup_arch,168.init_IRQ = xes_mpc85xx_pic_init,169#ifdef CONFIG_PCI170.pcibios_fixup_bus = fsl_pcibios_fixup_bus,171.pcibios_fixup_phb = fsl_pcibios_fixup_phb,172#endif173.get_irq = mpic_get_irq,174.progress = udbg_progress,175};176177178