[POWERPC] spufs: fix support for read/write on cntl
[linux-2.6] / arch / powerpc / platforms / 86xx / mpc86xx_smp.c
1 /*
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
13 #include <linux/stddef.h>
14 #include <linux/kernel.h>
15 #include <linux/init.h>
16 #include <linux/delay.h>
17
18 #include <asm/pgtable.h>
19 #include <asm/page.h>
20 #include <asm/pci-bridge.h>
21 #include <asm-powerpc/mpic.h>
22 #include <asm/mpc86xx.h>
23 #include <asm/cacheflush.h>
24
25 #include <sysdev/fsl_soc.h>
26
27 #include "mpc86xx.h"
28
29 extern void __secondary_start_mpc86xx(void);
30 extern unsigned long __secondary_hold_acknowledge;
31
32
33 static void __init
34 smp_86xx_release_core(int nr)
35 {
36         __be32 __iomem *mcm_vaddr;
37         unsigned long pcr;
38
39         if (nr < 0 || nr >= NR_CPUS)
40                 return;
41
42         /*
43          * Startup Core #nr.
44          */
45         mcm_vaddr = ioremap(get_immrbase() + MPC86xx_MCM_OFFSET,
46                             MPC86xx_MCM_SIZE);
47         pcr = in_be32(mcm_vaddr + (MCM_PORT_CONFIG_OFFSET >> 2));
48         pcr |= 1 << (nr + 24);
49         out_be32(mcm_vaddr + (MCM_PORT_CONFIG_OFFSET >> 2), pcr);
50 }
51
52
53 static void __init
54 smp_86xx_kick_cpu(int nr)
55 {
56         unsigned int save_vector;
57         unsigned long target, flags;
58         int n = 0;
59         volatile unsigned int *vector
60                  = (volatile unsigned int *)(KERNELBASE + 0x100);
61
62         if (nr < 0 || nr >= NR_CPUS)
63                 return;
64
65         pr_debug("smp_86xx_kick_cpu: kick CPU #%d\n", nr);
66
67         local_irq_save(flags);
68         local_irq_disable();
69
70         /* Save reset vector */
71         save_vector = *vector;
72
73         /* Setup fake reset vector to call __secondary_start_mpc86xx. */
74         target = (unsigned long) __secondary_start_mpc86xx;
75         create_branch((unsigned long)vector, target, BRANCH_SET_LINK);
76
77         /* Kick that CPU */
78         smp_86xx_release_core(nr);
79
80         /* Wait a bit for the CPU to take the exception. */
81         while ((__secondary_hold_acknowledge != nr) && (n++, n < 1000))
82                 mdelay(1);
83
84         /* Restore the exception vector */
85         *vector = save_vector;
86         flush_icache_range((unsigned long) vector, (unsigned long) vector + 4);
87
88         local_irq_restore(flags);
89
90         pr_debug("wait CPU #%d for %d msecs.\n", nr, n);
91 }
92
93
94 static void __init
95 smp_86xx_setup_cpu(int cpu_nr)
96 {
97         mpic_setup_this_cpu();
98 }
99
100
101 struct smp_ops_t smp_86xx_ops = {
102         .message_pass = smp_mpic_message_pass,
103         .probe = smp_mpic_probe,
104         .kick_cpu = smp_86xx_kick_cpu,
105         .setup_cpu = smp_86xx_setup_cpu,
106         .take_timebase = smp_generic_take_timebase,
107         .give_timebase = smp_generic_give_timebase,
108 };
109
110
111 void __init
112 mpc86xx_smp_init(void)
113 {
114         smp_ops = &smp_86xx_ops;
115 }