blob: eacea0e3fcc88b5d42f13bed9e75ca4b589f2db0 [file] [log] [blame]
Jon Loeliger4ca4b622006-06-17 17:52:45 -05001/*
2 * Author: Xianghua Xiao <x.xiao@freescale.com>
3 * Zhang Wei <wei.zhang@freescale.com>
4 *
5 * Copyright 2006 Freescale Semiconductor Inc.
6 *
7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License as published by the
9 * Free Software Foundation; either version 2 of the License, or (at your
10 * option) any later version.
11 */
12
Jon Loeliger4ca4b622006-06-17 17:52:45 -050013#include <linux/stddef.h>
14#include <linux/kernel.h>
15#include <linux/init.h>
16#include <linux/delay.h>
17
Michael Ellermanaaddd3e2008-06-24 11:32:21 +100018#include <asm/code-patching.h>
Jon Loeliger4ca4b622006-06-17 17:52:45 -050019#include <asm/page.h>
David Gibsonf1a1eb22007-05-09 15:20:37 +100020#include <asm/pgtable.h>
Jon Loeliger4ca4b622006-06-17 17:52:45 -050021#include <asm/pci-bridge.h>
Stephen Rothwellb8b572e2008-08-01 15:20:30 +100022#include <asm/mpic.h>
Jon Loeliger4ca4b622006-06-17 17:52:45 -050023#include <asm/cacheflush.h>
24
25#include <sysdev/fsl_soc.h>
26
27#include "mpc86xx.h"
28
29extern void __secondary_start_mpc86xx(void);
Jon Loeliger4ca4b622006-06-17 17:52:45 -050030
Kumar Gala1e76dff2009-04-22 12:32:09 -050031#define MCM_PORT_CONFIG_OFFSET 0x10
32
33/* Offset from CCSRBAR */
34#define MPC86xx_MCM_OFFSET (0x1000)
35#define MPC86xx_MCM_SIZE (0x1000)
Jon Loeliger4ca4b622006-06-17 17:52:45 -050036
37static void __init
38smp_86xx_release_core(int nr)
39{
Kumar Gala9ad494f2006-06-28 00:37:45 -050040 __be32 __iomem *mcm_vaddr;
41 unsigned long pcr;
Jon Loeliger4ca4b622006-06-17 17:52:45 -050042
43 if (nr < 0 || nr >= NR_CPUS)
44 return;
45
46 /*
47 * Startup Core #nr.
48 */
49 mcm_vaddr = ioremap(get_immrbase() + MPC86xx_MCM_OFFSET,
50 MPC86xx_MCM_SIZE);
Kumar Gala9ad494f2006-06-28 00:37:45 -050051 pcr = in_be32(mcm_vaddr + (MCM_PORT_CONFIG_OFFSET >> 2));
Jon Loeliger4ca4b622006-06-17 17:52:45 -050052 pcr |= 1 << (nr + 24);
Kumar Gala9ad494f2006-06-28 00:37:45 -050053 out_be32(mcm_vaddr + (MCM_PORT_CONFIG_OFFSET >> 2), pcr);
Kumar Gala1e76dff2009-04-22 12:32:09 -050054
55 iounmap(mcm_vaddr);
Jon Loeliger4ca4b622006-06-17 17:52:45 -050056}
57
58
59static void __init
60smp_86xx_kick_cpu(int nr)
61{
62 unsigned int save_vector;
63 unsigned long target, flags;
64 int n = 0;
Michael Ellermane7a57272008-06-24 11:32:22 +100065 unsigned int *vector = (unsigned int *)(KERNELBASE + 0x100);
Jon Loeliger4ca4b622006-06-17 17:52:45 -050066
67 if (nr < 0 || nr >= NR_CPUS)
68 return;
69
70 pr_debug("smp_86xx_kick_cpu: kick CPU #%d\n", nr);
71
72 local_irq_save(flags);
Jon Loeliger4ca4b622006-06-17 17:52:45 -050073
74 /* Save reset vector */
75 save_vector = *vector;
76
77 /* Setup fake reset vector to call __secondary_start_mpc86xx. */
78 target = (unsigned long) __secondary_start_mpc86xx;
Michael Ellermane7a57272008-06-24 11:32:22 +100079 patch_branch(vector, target, BRANCH_SET_LINK);
Jon Loeliger4ca4b622006-06-17 17:52:45 -050080
81 /* Kick that CPU */
82 smp_86xx_release_core(nr);
83
84 /* Wait a bit for the CPU to take the exception. */
85 while ((__secondary_hold_acknowledge != nr) && (n++, n < 1000))
86 mdelay(1);
87
88 /* Restore the exception vector */
89 *vector = save_vector;
90 flush_icache_range((unsigned long) vector, (unsigned long) vector + 4);
91
92 local_irq_restore(flags);
93
94 pr_debug("wait CPU #%d for %d msecs.\n", nr, n);
95}
96
97
98static void __init
99smp_86xx_setup_cpu(int cpu_nr)
100{
101 mpic_setup_this_cpu();
102}
103
104
105struct smp_ops_t smp_86xx_ops = {
106 .message_pass = smp_mpic_message_pass,
107 .probe = smp_mpic_probe,
108 .kick_cpu = smp_86xx_kick_cpu,
109 .setup_cpu = smp_86xx_setup_cpu,
110 .take_timebase = smp_generic_take_timebase,
111 .give_timebase = smp_generic_give_timebase,
112};
113
114
115void __init
116mpc86xx_smp_init(void)
117{
118 smp_ops = &smp_86xx_ops;
119}