blob: 0403aa8629ddc10adf2727668a37f7d1c72ca6c0 [file] [log] [blame]
Kuninori Morimotoe2f25942018-09-07 01:43:23 +00001// SPDX-License-Identifier: GPL-2.0
Magnus Damm72f4d572010-12-14 16:57:11 +09002/*
3 * SMP support for R-Mobile / SH-Mobile - sh73a0 portion
4 *
5 * Copyright (C) 2010 Magnus Damm
6 * Copyright (C) 2010 Takashi Yoshii
Magnus Damm72f4d572010-12-14 16:57:11 +09007 */
8#include <linux/kernel.h>
9#include <linux/init.h>
10#include <linux/smp.h>
Magnus Damm72f4d572010-12-14 16:57:11 +090011#include <linux/io.h>
Marc Zyngiera62580e2011-09-08 13:15:22 +010012#include <linux/delay.h>
Geert Uytterhoevended59d62014-06-20 18:53:09 +020013
Magnus Damm352e57a2013-07-31 16:07:59 +090014#include <asm/smp_plat.h>
Geert Uytterhoevended59d62014-06-20 18:53:09 +020015
Magnus Dammfd44aa52014-06-17 16:47:37 +090016#include "common.h"
Geert Uytterhoevended59d62014-06-20 18:53:09 +020017#include "sh73a0.h"
Magnus Damm72f4d572010-12-14 16:57:11 +090018
Rob Herringa2a47ca2012-03-09 17:16:40 -060019#define WUPCR IOMEM(0xe6151010)
20#define SRESCR IOMEM(0xe6151018)
21#define PSTR IOMEM(0xe6151040)
22#define SBAR IOMEM(0xe6180020)
23#define APARMBAREA IOMEM(0xe6f10020)
Magnus Damm72f4d572010-12-14 16:57:11 +090024
Magnus Damm76853502013-02-18 22:47:07 +090025#define SH73A0_SCU_BASE 0xf0000000
Magnus Dammaa8d3bb2013-02-13 22:46:38 +090026
Paul Gortmaker8bd26e32013-06-17 15:43:14 -040027static int sh73a0_boot_secondary(unsigned int cpu, struct task_struct *idle)
Magnus Damm72f4d572010-12-14 16:57:11 +090028{
Magnus Damm12eb8472013-07-31 16:07:21 +090029 unsigned int lcpu = cpu_logical_map(cpu);
Magnus Damm12eb8472013-07-31 16:07:21 +090030
31 if (((__raw_readl(PSTR) >> (4 * lcpu)) & 3) == 3)
32 __raw_writel(1 << lcpu, WUPCR); /* wake up */
Magnus Damm72f4d572010-12-14 16:57:11 +090033 else
Magnus Damm12eb8472013-07-31 16:07:21 +090034 __raw_writel(1 << lcpu, SRESCR); /* reset */
Magnus Damm72f4d572010-12-14 16:57:11 +090035
36 return 0;
37}
38
Marc Zyngiera62580e2011-09-08 13:15:22 +010039static void __init sh73a0_smp_prepare_cpus(unsigned int max_cpus)
Magnus Damm72f4d572010-12-14 16:57:11 +090040{
Magnus Damm12eb8472013-07-31 16:07:21 +090041 /* Map the reset vector (in headsmp.S) */
Rob Herringa2a47ca2012-03-09 17:16:40 -060042 __raw_writel(0, APARMBAREA); /* 4k */
Magnus Dammabfa04e2013-06-10 18:20:06 +090043 __raw_writel(__pa(shmobile_boot_vector), SBAR);
Magnus Damm72f4d572010-12-14 16:57:11 +090044
Magnus Damm12eb8472013-07-31 16:07:21 +090045 /* setup sh73a0 specific SCU bits */
Geert Uytterhoeven8701d802016-01-28 16:13:32 +010046 shmobile_smp_scu_prepare_cpus(SH73A0_SCU_BASE, max_cpus);
Magnus Damm72f4d572010-12-14 16:57:11 +090047}
Marc Zyngiera62580e2011-09-08 13:15:22 +010048
Masahiro Yamada75305272015-11-15 10:39:53 +090049const struct smp_operations sh73a0_smp_ops __initconst = {
Marc Zyngiera62580e2011-09-08 13:15:22 +010050 .smp_prepare_cpus = sh73a0_smp_prepare_cpus,
Marc Zyngiera62580e2011-09-08 13:15:22 +010051 .smp_boot_secondary = sh73a0_boot_secondary,
52#ifdef CONFIG_HOTPLUG_CPU
Stephen Boyd787047e2015-07-29 00:34:48 +010053 .cpu_can_disable = shmobile_smp_cpu_can_disable,
Magnus Damm352e57a2013-07-31 16:07:59 +090054 .cpu_die = shmobile_smp_scu_cpu_die,
55 .cpu_kill = shmobile_smp_scu_cpu_kill,
Marc Zyngiera62580e2011-09-08 13:15:22 +010056#endif
57};