blob: 13ba36a6831fb2374ff62dcfc967cf426b98ae3c [file] [log] [blame]
Magnus Damm72f4d572010-12-14 16:57:11 +09001/*
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>
Magnus Damm72f4d572010-12-14 16:57:11 +090023#include <linux/io.h>
Marc Zyngiera62580e2011-09-08 13:15:22 +010024#include <linux/delay.h>
Magnus Damm72f4d572010-12-14 16:57:11 +090025#include <mach/common.h>
Marc Zyngiera62580e2011-09-08 13:15:22 +010026#include <mach/sh73a0.h>
Magnus Damm352e57a2013-07-31 16:07:59 +090027#include <asm/smp_plat.h>
Magnus Damm72f4d572010-12-14 16:57:11 +090028#include <asm/smp_twd.h>
Magnus Damm72f4d572010-12-14 16:57:11 +090029
Rob Herringa2a47ca2012-03-09 17:16:40 -060030#define WUPCR IOMEM(0xe6151010)
31#define SRESCR IOMEM(0xe6151018)
32#define PSTR IOMEM(0xe6151040)
33#define SBAR IOMEM(0xe6180020)
34#define APARMBAREA IOMEM(0xe6f10020)
Magnus Damm72f4d572010-12-14 16:57:11 +090035
Magnus Damm76853502013-02-18 22:47:07 +090036#define SH73A0_SCU_BASE 0xf0000000
Magnus Dammaa8d3bb2013-02-13 22:46:38 +090037
Kuninori Morimotod6720002012-05-10 00:26:58 -070038#ifdef CONFIG_HAVE_ARM_TWD
Magnus Dammaa8d3bb2013-02-13 22:46:38 +090039static DEFINE_TWD_LOCAL_TIMER(twd_local_timer, SH73A0_SCU_BASE + 0x600, 29);
Kuninori Morimotod6720002012-05-10 00:26:58 -070040void __init sh73a0_register_twd(void)
41{
42 twd_local_timer_register(&twd_local_timer);
43}
44#endif
Marc Zyngier4200b162012-01-10 19:44:19 +000045
Paul Gortmaker8bd26e32013-06-17 15:43:14 -040046static int sh73a0_boot_secondary(unsigned int cpu, struct task_struct *idle)
Magnus Damm72f4d572010-12-14 16:57:11 +090047{
Magnus Damm12eb8472013-07-31 16:07:21 +090048 unsigned int lcpu = cpu_logical_map(cpu);
Magnus Damm12eb8472013-07-31 16:07:21 +090049
50 if (((__raw_readl(PSTR) >> (4 * lcpu)) & 3) == 3)
51 __raw_writel(1 << lcpu, WUPCR); /* wake up */
Magnus Damm72f4d572010-12-14 16:57:11 +090052 else
Magnus Damm12eb8472013-07-31 16:07:21 +090053 __raw_writel(1 << lcpu, SRESCR); /* reset */
Magnus Damm72f4d572010-12-14 16:57:11 +090054
55 return 0;
56}
57
Marc Zyngiera62580e2011-09-08 13:15:22 +010058static void __init sh73a0_smp_prepare_cpus(unsigned int max_cpus)
Magnus Damm72f4d572010-12-14 16:57:11 +090059{
Magnus Damm12eb8472013-07-31 16:07:21 +090060 /* Map the reset vector (in headsmp.S) */
Rob Herringa2a47ca2012-03-09 17:16:40 -060061 __raw_writel(0, APARMBAREA); /* 4k */
Magnus Dammabfa04e2013-06-10 18:20:06 +090062 __raw_writel(__pa(shmobile_boot_vector), SBAR);
Magnus Damm72f4d572010-12-14 16:57:11 +090063
Magnus Damm12eb8472013-07-31 16:07:21 +090064 /* setup sh73a0 specific SCU bits */
65 shmobile_scu_base = IOMEM(SH73A0_SCU_BASE);
66 shmobile_smp_scu_prepare_cpus(max_cpus);
Magnus Damm72f4d572010-12-14 16:57:11 +090067}
Marc Zyngiera62580e2011-09-08 13:15:22 +010068
Marc Zyngiera62580e2011-09-08 13:15:22 +010069struct smp_operations sh73a0_smp_ops __initdata = {
Marc Zyngiera62580e2011-09-08 13:15:22 +010070 .smp_prepare_cpus = sh73a0_smp_prepare_cpus,
Marc Zyngiera62580e2011-09-08 13:15:22 +010071 .smp_boot_secondary = sh73a0_boot_secondary,
72#ifdef CONFIG_HOTPLUG_CPU
Magnus Damma3b142a2013-08-08 07:13:39 +090073 .cpu_disable = shmobile_smp_cpu_disable,
Magnus Damm352e57a2013-07-31 16:07:59 +090074 .cpu_die = shmobile_smp_scu_cpu_die,
75 .cpu_kill = shmobile_smp_scu_cpu_kill,
Marc Zyngiera62580e2011-09-08 13:15:22 +010076#endif
77};