Path: blob/master/arch/powerpc/platforms/86xx/mpc86xx_smp.c
10818 views
/*1* Author: Xianghua Xiao <[email protected]>2* Zhang Wei <[email protected]>3*4* Copyright 2006 Freescale Semiconductor Inc.5*6* This program is free software; you can redistribute it and/or modify it7* under the terms of the GNU General Public License as published by the8* Free Software Foundation; either version 2 of the License, or (at your9* option) any later version.10*/1112#include <linux/stddef.h>13#include <linux/kernel.h>14#include <linux/init.h>15#include <linux/delay.h>1617#include <asm/code-patching.h>18#include <asm/page.h>19#include <asm/pgtable.h>20#include <asm/pci-bridge.h>21#include <asm/mpic.h>22#include <asm/cacheflush.h>2324#include <sysdev/fsl_soc.h>2526#include "mpc86xx.h"2728extern void __secondary_start_mpc86xx(void);2930#define MCM_PORT_CONFIG_OFFSET 0x103132/* Offset from CCSRBAR */33#define MPC86xx_MCM_OFFSET (0x1000)34#define MPC86xx_MCM_SIZE (0x1000)3536static void __init37smp_86xx_release_core(int nr)38{39__be32 __iomem *mcm_vaddr;40unsigned long pcr;4142if (nr < 0 || nr >= NR_CPUS)43return;4445/*46* Startup Core #nr.47*/48mcm_vaddr = ioremap(get_immrbase() + MPC86xx_MCM_OFFSET,49MPC86xx_MCM_SIZE);50pcr = in_be32(mcm_vaddr + (MCM_PORT_CONFIG_OFFSET >> 2));51pcr |= 1 << (nr + 24);52out_be32(mcm_vaddr + (MCM_PORT_CONFIG_OFFSET >> 2), pcr);5354iounmap(mcm_vaddr);55}565758static int __init59smp_86xx_kick_cpu(int nr)60{61unsigned int save_vector;62unsigned long target, flags;63int n = 0;64unsigned int *vector = (unsigned int *)(KERNELBASE + 0x100);6566if (nr < 0 || nr >= NR_CPUS)67return -ENOENT;6869pr_debug("smp_86xx_kick_cpu: kick CPU #%d\n", nr);7071local_irq_save(flags);7273/* Save reset vector */74save_vector = *vector;7576/* Setup fake reset vector to call __secondary_start_mpc86xx. */77target = (unsigned long) __secondary_start_mpc86xx;78patch_branch(vector, target, BRANCH_SET_LINK);7980/* Kick that CPU */81smp_86xx_release_core(nr);8283/* Wait a bit for the CPU to take the exception. */84while ((__secondary_hold_acknowledge != nr) && (n++, n < 1000))85mdelay(1);8687/* Restore the exception vector */88*vector = save_vector;89flush_icache_range((unsigned long) vector, (unsigned long) vector + 4);9091local_irq_restore(flags);9293pr_debug("wait CPU #%d for %d msecs.\n", nr, n);9495return 0;96}979899static void __init100smp_86xx_setup_cpu(int cpu_nr)101{102mpic_setup_this_cpu();103}104105106struct smp_ops_t smp_86xx_ops = {107.message_pass = smp_mpic_message_pass,108.probe = smp_mpic_probe,109.kick_cpu = smp_86xx_kick_cpu,110.setup_cpu = smp_86xx_setup_cpu,111.take_timebase = smp_generic_take_timebase,112.give_timebase = smp_generic_give_timebase,113};114115116void __init117mpc86xx_smp_init(void)118{119smp_ops = &smp_86xx_ops;120}121122123