1*4882a593Smuzhiyun // SPDX-License-Identifier: GPL-2.0 2*4882a593Smuzhiyun /* 3*4882a593Smuzhiyun * SMP support for R-Mobile / SH-Mobile - r8a7779 portion 4*4882a593Smuzhiyun * 5*4882a593Smuzhiyun * Copyright (C) 2011 Renesas Solutions Corp. 6*4882a593Smuzhiyun * Copyright (C) 2011 Magnus Damm 7*4882a593Smuzhiyun */ 8*4882a593Smuzhiyun #include <linux/kernel.h> 9*4882a593Smuzhiyun #include <linux/init.h> 10*4882a593Smuzhiyun #include <linux/smp.h> 11*4882a593Smuzhiyun #include <linux/spinlock.h> 12*4882a593Smuzhiyun #include <linux/io.h> 13*4882a593Smuzhiyun #include <linux/delay.h> 14*4882a593Smuzhiyun #include <linux/soc/renesas/rcar-sysc.h> 15*4882a593Smuzhiyun 16*4882a593Smuzhiyun #include <asm/cacheflush.h> 17*4882a593Smuzhiyun #include <asm/smp_plat.h> 18*4882a593Smuzhiyun #include <asm/smp_scu.h> 19*4882a593Smuzhiyun 20*4882a593Smuzhiyun #include "common.h" 21*4882a593Smuzhiyun #include "r8a7779.h" 22*4882a593Smuzhiyun 23*4882a593Smuzhiyun #define AVECR IOMEM(0xfe700040) 24*4882a593Smuzhiyun #define R8A7779_SCU_BASE 0xf0000000 25*4882a593Smuzhiyun r8a7779_boot_secondary(unsigned int cpu,struct task_struct * idle)26*4882a593Smuzhiyunstatic int r8a7779_boot_secondary(unsigned int cpu, struct task_struct *idle) 27*4882a593Smuzhiyun { 28*4882a593Smuzhiyun int ret = -EIO; 29*4882a593Smuzhiyun 30*4882a593Smuzhiyun cpu = cpu_logical_map(cpu); 31*4882a593Smuzhiyun if (cpu) 32*4882a593Smuzhiyun ret = rcar_sysc_power_up_cpu(cpu); 33*4882a593Smuzhiyun 34*4882a593Smuzhiyun return ret; 35*4882a593Smuzhiyun } 36*4882a593Smuzhiyun r8a7779_smp_prepare_cpus(unsigned int max_cpus)37*4882a593Smuzhiyunstatic void __init r8a7779_smp_prepare_cpus(unsigned int max_cpus) 38*4882a593Smuzhiyun { 39*4882a593Smuzhiyun /* Map the reset vector (in headsmp-scu.S, headsmp.S) */ 40*4882a593Smuzhiyun __raw_writel(__pa(shmobile_boot_vector), AVECR); 41*4882a593Smuzhiyun 42*4882a593Smuzhiyun /* setup r8a7779 specific SCU bits */ 43*4882a593Smuzhiyun shmobile_smp_scu_prepare_cpus(R8A7779_SCU_BASE, max_cpus); 44*4882a593Smuzhiyun } 45*4882a593Smuzhiyun 46*4882a593Smuzhiyun #ifdef CONFIG_HOTPLUG_CPU r8a7779_platform_cpu_kill(unsigned int cpu)47*4882a593Smuzhiyunstatic int r8a7779_platform_cpu_kill(unsigned int cpu) 48*4882a593Smuzhiyun { 49*4882a593Smuzhiyun int ret = -EIO; 50*4882a593Smuzhiyun 51*4882a593Smuzhiyun cpu = cpu_logical_map(cpu); 52*4882a593Smuzhiyun if (cpu) 53*4882a593Smuzhiyun ret = rcar_sysc_power_down_cpu(cpu); 54*4882a593Smuzhiyun 55*4882a593Smuzhiyun return ret ? ret : 1; 56*4882a593Smuzhiyun } 57*4882a593Smuzhiyun r8a7779_cpu_kill(unsigned int cpu)58*4882a593Smuzhiyunstatic int r8a7779_cpu_kill(unsigned int cpu) 59*4882a593Smuzhiyun { 60*4882a593Smuzhiyun if (shmobile_smp_scu_cpu_kill(cpu)) 61*4882a593Smuzhiyun return r8a7779_platform_cpu_kill(cpu); 62*4882a593Smuzhiyun 63*4882a593Smuzhiyun return 0; 64*4882a593Smuzhiyun } 65*4882a593Smuzhiyun #endif /* CONFIG_HOTPLUG_CPU */ 66*4882a593Smuzhiyun 67*4882a593Smuzhiyun const struct smp_operations r8a7779_smp_ops __initconst = { 68*4882a593Smuzhiyun .smp_prepare_cpus = r8a7779_smp_prepare_cpus, 69*4882a593Smuzhiyun .smp_boot_secondary = r8a7779_boot_secondary, 70*4882a593Smuzhiyun #ifdef CONFIG_HOTPLUG_CPU 71*4882a593Smuzhiyun .cpu_die = shmobile_smp_scu_cpu_die, 72*4882a593Smuzhiyun .cpu_kill = r8a7779_cpu_kill, 73*4882a593Smuzhiyun #endif 74*4882a593Smuzhiyun }; 75