Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0
0002 /*
0003  * SMP support for R-Mobile / SH-Mobile - r8a7779 portion
0004  *
0005  * Copyright (C) 2011  Renesas Solutions Corp.
0006  * Copyright (C) 2011  Magnus Damm
0007  */
0008 #include <linux/kernel.h>
0009 #include <linux/init.h>
0010 #include <linux/smp.h>
0011 #include <linux/spinlock.h>
0012 #include <linux/io.h>
0013 #include <linux/delay.h>
0014 #include <linux/soc/renesas/rcar-sysc.h>
0015 
0016 #include <asm/cacheflush.h>
0017 #include <asm/smp_plat.h>
0018 #include <asm/smp_scu.h>
0019 
0020 #include "common.h"
0021 #include "r8a7779.h"
0022 
0023 #define HPBREG_BASE     0xfe700000
0024 #define AVECR           0x0040  /* ARM Reset Vector Address Register */
0025 
0026 #define R8A7779_SCU_BASE    0xf0000000
0027 
0028 static int r8a7779_boot_secondary(unsigned int cpu, struct task_struct *idle)
0029 {
0030     int ret = -EIO;
0031 
0032     cpu = cpu_logical_map(cpu);
0033     if (cpu)
0034         ret = rcar_sysc_power_up_cpu(cpu);
0035 
0036     return ret;
0037 }
0038 
0039 static void __init r8a7779_smp_prepare_cpus(unsigned int max_cpus)
0040 {
0041     void __iomem *base = ioremap(HPBREG_BASE, 0x1000);
0042 
0043     /* Map the reset vector (in headsmp-scu.S, headsmp.S) */
0044     writel(__pa(shmobile_boot_vector), base + AVECR);
0045 
0046     /* setup r8a7779 specific SCU bits */
0047     shmobile_smp_scu_prepare_cpus(R8A7779_SCU_BASE, max_cpus);
0048 
0049     iounmap(base);
0050 }
0051 
0052 #ifdef CONFIG_HOTPLUG_CPU
0053 static int r8a7779_platform_cpu_kill(unsigned int cpu)
0054 {
0055     int ret = -EIO;
0056 
0057     cpu = cpu_logical_map(cpu);
0058     if (cpu)
0059         ret = rcar_sysc_power_down_cpu(cpu);
0060 
0061     return ret ? ret : 1;
0062 }
0063 
0064 static int r8a7779_cpu_kill(unsigned int cpu)
0065 {
0066     if (shmobile_smp_scu_cpu_kill(cpu))
0067         return r8a7779_platform_cpu_kill(cpu);
0068 
0069     return 0;
0070 }
0071 #endif /* CONFIG_HOTPLUG_CPU */
0072 
0073 const struct smp_operations r8a7779_smp_ops  __initconst = {
0074     .smp_prepare_cpus   = r8a7779_smp_prepare_cpus,
0075     .smp_boot_secondary = r8a7779_boot_secondary,
0076 #ifdef CONFIG_HOTPLUG_CPU
0077     .cpu_die        = shmobile_smp_scu_cpu_die,
0078     .cpu_kill       = r8a7779_cpu_kill,
0079 #endif
0080 };