Commit | Line | Data |
---|---|---|
72f4d579 MD |
1 | /* |
2 | * SMP support for R-Mobile / SH-Mobile - sh73a0 portion | |
3 | * | |
4 | * Copyright (C) 2010 Magnus Damm | |
5 | * Copyright (C) 2010 Takashi Yoshii | |
6 | * | |
7 | * This program is free software; you can redistribute it and/or modify | |
8 | * it under the terms of the GNU General Public License as published by | |
9 | * the Free Software Foundation; version 2 of the License. | |
10 | * | |
11 | * This program is distributed in the hope that it will be useful, | |
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 | * GNU General Public License for more details. | |
15 | * | |
16 | * You should have received a copy of the GNU General Public License | |
17 | * along with this program; if not, write to the Free Software | |
18 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | |
19 | */ | |
20 | #include <linux/kernel.h> | |
21 | #include <linux/init.h> | |
22 | #include <linux/smp.h> | |
72f4d579 | 23 | #include <linux/io.h> |
a62580e5 | 24 | #include <linux/delay.h> |
ded59d6d | 25 | |
352e57a3 | 26 | #include <asm/smp_plat.h> |
72f4d579 | 27 | #include <asm/smp_twd.h> |
ded59d6d | 28 | |
fd44aa5e | 29 | #include "common.h" |
ded59d6d | 30 | #include "sh73a0.h" |
72f4d579 | 31 | |
a2a47ca3 RH |
32 | #define WUPCR IOMEM(0xe6151010) |
33 | #define SRESCR IOMEM(0xe6151018) | |
34 | #define PSTR IOMEM(0xe6151040) | |
35 | #define SBAR IOMEM(0xe6180020) | |
36 | #define APARMBAREA IOMEM(0xe6f10020) | |
72f4d579 | 37 | |
76853504 | 38 | #define SH73A0_SCU_BASE 0xf0000000 |
aa8d3bb1 | 39 | |
d6720003 | 40 | #ifdef CONFIG_HAVE_ARM_TWD |
aa8d3bb1 | 41 | static DEFINE_TWD_LOCAL_TIMER(twd_local_timer, SH73A0_SCU_BASE + 0x600, 29); |
d6720003 KM |
42 | void __init sh73a0_register_twd(void) |
43 | { | |
44 | twd_local_timer_register(&twd_local_timer); | |
45 | } | |
46 | #endif | |
4200b16d | 47 | |
8bd26e3a | 48 | static int sh73a0_boot_secondary(unsigned int cpu, struct task_struct *idle) |
72f4d579 | 49 | { |
12eb8474 | 50 | unsigned int lcpu = cpu_logical_map(cpu); |
12eb8474 MD |
51 | |
52 | if (((__raw_readl(PSTR) >> (4 * lcpu)) & 3) == 3) | |
53 | __raw_writel(1 << lcpu, WUPCR); /* wake up */ | |
72f4d579 | 54 | else |
12eb8474 | 55 | __raw_writel(1 << lcpu, SRESCR); /* reset */ |
72f4d579 MD |
56 | |
57 | return 0; | |
58 | } | |
59 | ||
a62580e5 | 60 | static void __init sh73a0_smp_prepare_cpus(unsigned int max_cpus) |
72f4d579 | 61 | { |
12eb8474 | 62 | /* Map the reset vector (in headsmp.S) */ |
a2a47ca3 | 63 | __raw_writel(0, APARMBAREA); /* 4k */ |
abfa04eb | 64 | __raw_writel(__pa(shmobile_boot_vector), SBAR); |
72f4d579 | 65 | |
12eb8474 MD |
66 | /* setup sh73a0 specific SCU bits */ |
67 | shmobile_scu_base = IOMEM(SH73A0_SCU_BASE); | |
68 | shmobile_smp_scu_prepare_cpus(max_cpus); | |
72f4d579 | 69 | } |
a62580e5 | 70 | |
a62580e5 | 71 | struct smp_operations sh73a0_smp_ops __initdata = { |
a62580e5 | 72 | .smp_prepare_cpus = sh73a0_smp_prepare_cpus, |
a62580e5 MZ |
73 | .smp_boot_secondary = sh73a0_boot_secondary, |
74 | #ifdef CONFIG_HOTPLUG_CPU | |
a3b142a1 | 75 | .cpu_disable = shmobile_smp_cpu_disable, |
352e57a3 MD |
76 | .cpu_die = shmobile_smp_scu_cpu_die, |
77 | .cpu_kill = shmobile_smp_scu_cpu_kill, | |
a62580e5 MZ |
78 | #endif |
79 | }; |