blob: 2d6417af73b5b722fe85da8b0f19c98d53a09b56 [file] [log] [blame]
Magnus Damm687c27b2013-10-01 17:13:16 +09001/*
2 * SMP support for r8a7791
3 *
4 * Copyright (C) 2013 Renesas Solutions Corp.
5 * Copyright (C) 2013 Magnus Damm
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#include <linux/kernel.h>
17#include <linux/init.h>
18#include <linux/smp.h>
19#include <linux/io.h>
Geert Uytterhoeven5201b5a2014-06-20 18:53:07 +020020
Magnus Damm687c27b2013-10-01 17:13:16 +090021#include <asm/smp_plat.h>
Geert Uytterhoeven5201b5a2014-06-20 18:53:07 +020022
Magnus Dammfd44aa52014-06-17 16:47:37 +090023#include "common.h"
Hisashi Nakamuraa8d2ff32014-10-24 17:33:08 +090024#include "platsmp-apmu.h"
Geert Uytterhoeven5201b5a2014-06-20 18:53:07 +020025#include "r8a7791.h"
Magnus Damm62872982014-06-17 16:48:01 +090026#include "rcar-gen2.h"
Magnus Damm687c27b2013-10-01 17:13:16 +090027
Hisashi Nakamuraa8d2ff32014-10-24 17:33:08 +090028static struct rcar_apmu_config r8a7791_apmu_config[] = {
29 {
Wolfram Sang98f60f82015-02-03 15:57:42 +010030 .iomem = DEFINE_RES_MEM(0xe6152000, 0x188),
Hisashi Nakamura7466c52e2014-10-24 17:33:09 +090031 .cpus = { 0, 1 },
Hisashi Nakamuraa8d2ff32014-10-24 17:33:08 +090032 }
33};
34
Magnus Damm687c27b2013-10-01 17:13:16 +090035static void __init r8a7791_smp_prepare_cpus(unsigned int max_cpus)
36{
Magnus Damm687c27b2013-10-01 17:13:16 +090037 /* let APMU code install data related to shmobile_boot_vector */
Hisashi Nakamuraa8d2ff32014-10-24 17:33:08 +090038 shmobile_smp_apmu_prepare_cpus(max_cpus,
39 r8a7791_apmu_config,
40 ARRAY_SIZE(r8a7791_apmu_config));
Magnus Damm687c27b2013-10-01 17:13:16 +090041
Gaku Inamia8caad62015-03-16 14:48:43 +090042 rcar_gen2_pm_init();
Magnus Damm687c27b2013-10-01 17:13:16 +090043}
44
Magnus Damm277efd32014-02-26 18:59:16 +090045static int r8a7791_smp_boot_secondary(unsigned int cpu,
46 struct task_struct *idle)
47{
48 /* Error out when hardware debug mode is enabled */
49 if (rcar_gen2_read_mode_pins() & BIT(21)) {
50 pr_warn("Unable to boot CPU%u when MD21 is set\n", cpu);
51 return -ENOTSUPP;
52 }
53
54 return shmobile_smp_apmu_boot_secondary(cpu, idle);
55}
56
Masahiro Yamada75305272015-11-15 10:39:53 +090057const struct smp_operations r8a7791_smp_ops __initconst = {
Magnus Damm687c27b2013-10-01 17:13:16 +090058 .smp_prepare_cpus = r8a7791_smp_prepare_cpus,
Magnus Damm277efd32014-02-26 18:59:16 +090059 .smp_boot_secondary = r8a7791_smp_boot_secondary,
Magnus Damm687c27b2013-10-01 17:13:16 +090060#ifdef CONFIG_HOTPLUG_CPU
Stephen Boyd787047e2015-07-29 00:34:48 +010061 .cpu_can_disable = shmobile_smp_cpu_can_disable,
Magnus Damm687c27b2013-10-01 17:13:16 +090062 .cpu_die = shmobile_smp_apmu_cpu_die,
63 .cpu_kill = shmobile_smp_apmu_cpu_kill,
64#endif
65};