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> | |
0f7b332f | 19 | #include <asm/hardware/gic.h> |
72f4d579 MD |
20 | #include <asm/mach-types.h> |
21 | #include <mach/common.h> | |
1c51ed4f | 22 | |
28626632 | 23 | #define is_sh73a0() (machine_is_ag5evm() || machine_is_kota2()) |
f40aaf6d | 24 | #define is_r8a7779() machine_is_marzen() |
28626632 | 25 | |
1c51ed4f MD |
26 | static unsigned int __init shmobile_smp_get_core_count(void) |
27 | { | |
28626632 | 28 | if (is_sh73a0()) |
72f4d579 MD |
29 | return sh73a0_get_core_count(); |
30 | ||
f40aaf6d MD |
31 | if (is_r8a7779()) |
32 | return r8a7779_get_core_count(); | |
33 | ||
1c51ed4f MD |
34 | return 1; |
35 | } | |
36 | ||
37 | static void __init shmobile_smp_prepare_cpus(void) | |
38 | { | |
28626632 | 39 | if (is_sh73a0()) |
72f4d579 | 40 | sh73a0_smp_prepare_cpus(); |
f40aaf6d MD |
41 | |
42 | if (is_r8a7779()) | |
43 | r8a7779_smp_prepare_cpus(); | |
1c51ed4f MD |
44 | } |
45 | ||
8b306796 MD |
46 | int shmobile_platform_cpu_kill(unsigned int cpu) |
47 | { | |
f40aaf6d MD |
48 | if (is_r8a7779()) |
49 | return r8a7779_platform_cpu_kill(cpu); | |
50 | ||
8b306796 MD |
51 | return 1; |
52 | } | |
53 | ||
1c51ed4f MD |
54 | void __cpuinit platform_secondary_init(unsigned int cpu) |
55 | { | |
56 | trace_hardirqs_off(); | |
72f4d579 | 57 | |
28626632 | 58 | if (is_sh73a0()) |
72f4d579 | 59 | sh73a0_secondary_init(cpu); |
f40aaf6d MD |
60 | |
61 | if (is_r8a7779()) | |
62 | r8a7779_secondary_init(cpu); | |
1c51ed4f MD |
63 | } |
64 | ||
65 | int __cpuinit boot_secondary(unsigned int cpu, struct task_struct *idle) | |
66 | { | |
28626632 | 67 | if (is_sh73a0()) |
72f4d579 MD |
68 | return sh73a0_boot_secondary(cpu); |
69 | ||
f40aaf6d MD |
70 | if (is_r8a7779()) |
71 | return r8a7779_boot_secondary(cpu); | |
72 | ||
1c51ed4f MD |
73 | return -ENOSYS; |
74 | } | |
75 | ||
76 | void __init smp_init_cpus(void) | |
77 | { | |
78 | unsigned int ncores = shmobile_smp_get_core_count(); | |
79 | unsigned int i; | |
80 | ||
a06f916b RK |
81 | if (ncores > nr_cpu_ids) { |
82 | pr_warn("SMP: %u cores greater than maximum (%u), clipping\n", | |
83 | ncores, nr_cpu_ids); | |
84 | ncores = nr_cpu_ids; | |
85 | } | |
86 | ||
1c51ed4f MD |
87 | for (i = 0; i < ncores; i++) |
88 | set_cpu_possible(i, true); | |
0f7b332f RK |
89 | |
90 | set_smp_cross_call(gic_raise_softirq); | |
1c51ed4f MD |
91 | } |
92 | ||
c413521e | 93 | void __init platform_smp_prepare_cpus(unsigned int max_cpus) |
1c51ed4f | 94 | { |
c413521e | 95 | shmobile_smp_prepare_cpus(); |
1c51ed4f | 96 | } |