Commit | Line | Data |
---|---|---|
1c51ed4f MD |
1 | /* |
2 | * SMP support for R-Mobile / SH-Mobile | |
3 | * | |
4 | * Copyright (C) 2010 Magnus Damm | |
c413521e | 5 | * Copyright (C) 2011 Paul Mundt |
1c51ed4f MD |
6 | * |
7 | * Based on vexpress, Copyright (C) 2002 ARM Ltd, All Rights Reserved | |
8 | * | |
9 | * This program is free software; you can redistribute it and/or modify | |
10 | * it under the terms of the GNU General Public License version 2 as | |
11 | * published by the Free Software Foundation. | |
12 | */ | |
13 | #include <linux/init.h> | |
14 | #include <linux/errno.h> | |
15 | #include <linux/delay.h> | |
16 | #include <linux/device.h> | |
17 | #include <linux/smp.h> | |
18 | #include <linux/io.h> | |
450cca47 | 19 | #include <linux/of.h> |
0f7b332f | 20 | #include <asm/hardware/gic.h> |
72f4d579 MD |
21 | #include <asm/mach-types.h> |
22 | #include <mach/common.h> | |
bd5a875d | 23 | #include <mach/emev2.h> |
1c51ed4f | 24 | |
873e9f7a | 25 | #ifdef CONFIG_ARCH_SH73A0 |
9601e873 AB |
26 | #define is_sh73a0() (machine_is_ag5evm() || machine_is_kota2() || \ |
27 | of_machine_is_compatible("renesas,sh73a0")) | |
873e9f7a MD |
28 | #else |
29 | #define is_sh73a0() (0) | |
30 | #endif | |
31 | ||
f40aaf6d | 32 | #define is_r8a7779() machine_is_marzen() |
6ae42bb2 NI |
33 | |
34 | #ifdef CONFIG_ARCH_EMEV2 | |
450cca47 | 35 | #define is_emev2() of_machine_is_compatible("renesas,emev2") |
6ae42bb2 NI |
36 | #else |
37 | #define is_emev2() (0) | |
38 | #endif | |
28626632 | 39 | |
1c51ed4f MD |
40 | static unsigned int __init shmobile_smp_get_core_count(void) |
41 | { | |
28626632 | 42 | if (is_sh73a0()) |
72f4d579 MD |
43 | return sh73a0_get_core_count(); |
44 | ||
f40aaf6d MD |
45 | if (is_r8a7779()) |
46 | return r8a7779_get_core_count(); | |
47 | ||
bd5a875d MD |
48 | if (is_emev2()) |
49 | return emev2_get_core_count(); | |
50 | ||
1c51ed4f MD |
51 | return 1; |
52 | } | |
53 | ||
54 | static void __init shmobile_smp_prepare_cpus(void) | |
55 | { | |
28626632 | 56 | if (is_sh73a0()) |
72f4d579 | 57 | sh73a0_smp_prepare_cpus(); |
f40aaf6d MD |
58 | |
59 | if (is_r8a7779()) | |
60 | r8a7779_smp_prepare_cpus(); | |
bd5a875d MD |
61 | |
62 | if (is_emev2()) | |
63 | emev2_smp_prepare_cpus(); | |
1c51ed4f MD |
64 | } |
65 | ||
8b306796 MD |
66 | int shmobile_platform_cpu_kill(unsigned int cpu) |
67 | { | |
f40aaf6d MD |
68 | if (is_r8a7779()) |
69 | return r8a7779_platform_cpu_kill(cpu); | |
70 | ||
bd5a875d MD |
71 | if (is_emev2()) |
72 | return emev2_platform_cpu_kill(cpu); | |
73 | ||
8b306796 MD |
74 | return 1; |
75 | } | |
76 | ||
1c51ed4f MD |
77 | void __cpuinit platform_secondary_init(unsigned int cpu) |
78 | { | |
79 | trace_hardirqs_off(); | |
72f4d579 | 80 | |
28626632 | 81 | if (is_sh73a0()) |
72f4d579 | 82 | sh73a0_secondary_init(cpu); |
f40aaf6d MD |
83 | |
84 | if (is_r8a7779()) | |
85 | r8a7779_secondary_init(cpu); | |
bd5a875d MD |
86 | |
87 | if (is_emev2()) | |
88 | emev2_secondary_init(cpu); | |
1c51ed4f MD |
89 | } |
90 | ||
91 | int __cpuinit boot_secondary(unsigned int cpu, struct task_struct *idle) | |
92 | { | |
28626632 | 93 | if (is_sh73a0()) |
72f4d579 MD |
94 | return sh73a0_boot_secondary(cpu); |
95 | ||
f40aaf6d MD |
96 | if (is_r8a7779()) |
97 | return r8a7779_boot_secondary(cpu); | |
98 | ||
bd5a875d MD |
99 | if (is_emev2()) |
100 | return emev2_boot_secondary(cpu); | |
101 | ||
1c51ed4f MD |
102 | return -ENOSYS; |
103 | } | |
104 | ||
105 | void __init smp_init_cpus(void) | |
106 | { | |
107 | unsigned int ncores = shmobile_smp_get_core_count(); | |
108 | unsigned int i; | |
109 | ||
a06f916b RK |
110 | if (ncores > nr_cpu_ids) { |
111 | pr_warn("SMP: %u cores greater than maximum (%u), clipping\n", | |
112 | ncores, nr_cpu_ids); | |
113 | ncores = nr_cpu_ids; | |
114 | } | |
115 | ||
1c51ed4f MD |
116 | for (i = 0; i < ncores; i++) |
117 | set_cpu_possible(i, true); | |
0f7b332f RK |
118 | |
119 | set_smp_cross_call(gic_raise_softirq); | |
1c51ed4f MD |
120 | } |
121 | ||
c413521e | 122 | void __init platform_smp_prepare_cpus(unsigned int max_cpus) |
1c51ed4f | 123 | { |
c413521e | 124 | shmobile_smp_prepare_cpus(); |
1c51ed4f | 125 | } |