~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/arch/arm/mach-shmobile/platsmp-scu.c

Version: ~ [ linux-6.11-rc3 ] ~ [ linux-6.10.4 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.45 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.104 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.164 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.223 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.281 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.319 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.9 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 // SPDX-License-Identifier: GPL-2.0
  2 /*
  3  * SMP support for SoCs with SCU covered by mach-shmobile
  4  *
  5  * Copyright (C) 2013  Magnus Damm
  6  */
  7 #include <linux/cpu.h>
  8 #include <linux/delay.h>
  9 #include <linux/init.h>
 10 #include <linux/io.h>
 11 #include <linux/smp.h>
 12 #include <asm/cacheflush.h>
 13 #include <asm/smp_plat.h>
 14 #include <asm/smp_scu.h>
 15 #include "common.h"
 16 
 17 
 18 static phys_addr_t shmobile_scu_base_phys;
 19 static void __iomem *shmobile_scu_base;
 20 
 21 static int shmobile_scu_cpu_prepare(unsigned int cpu)
 22 {
 23         /* For this particular CPU register SCU SMP boot vector */
 24         shmobile_smp_hook(cpu, __pa_symbol(shmobile_boot_scu),
 25                           shmobile_scu_base_phys);
 26         return 0;
 27 }
 28 
 29 void __init shmobile_smp_scu_prepare_cpus(phys_addr_t scu_base_phys,
 30                                           unsigned int max_cpus)
 31 {
 32         /* install boot code shared by all CPUs */
 33         shmobile_boot_fn = __pa_symbol(shmobile_smp_boot);
 34 
 35         /* enable SCU and cache coherency on booting CPU */
 36         shmobile_scu_base_phys = scu_base_phys;
 37         shmobile_scu_base = ioremap(scu_base_phys, PAGE_SIZE);
 38         scu_enable(shmobile_scu_base);
 39         scu_power_mode(shmobile_scu_base, SCU_PM_NORMAL);
 40 
 41         /* Use CPU notifier for reset vector control */
 42         cpuhp_setup_state_nocalls(CPUHP_ARM_SHMOBILE_SCU_PREPARE,
 43                                   "arm/shmobile-scu:prepare",
 44                                   shmobile_scu_cpu_prepare, NULL);
 45 }
 46 
 47 #ifdef CONFIG_HOTPLUG_CPU
 48 void shmobile_smp_scu_cpu_die(unsigned int cpu)
 49 {
 50         /* For this particular CPU deregister boot vector */
 51         shmobile_smp_hook(cpu, 0, 0);
 52 
 53         dsb();
 54         flush_cache_all();
 55 
 56         /* disable cache coherency */
 57         scu_power_mode(shmobile_scu_base, SCU_PM_POWEROFF);
 58 
 59         /* jump to shared mach-shmobile sleep / reset code */
 60         shmobile_smp_sleep();
 61 }
 62 
 63 static int shmobile_smp_scu_psr_core_disabled(int cpu)
 64 {
 65         unsigned long mask = SCU_PM_POWEROFF << (cpu * 8);
 66 
 67         if ((readl(shmobile_scu_base + 8) & mask) == mask)
 68                 return 1;
 69 
 70         return 0;
 71 }
 72 
 73 int shmobile_smp_scu_cpu_kill(unsigned int cpu)
 74 {
 75         int k;
 76 
 77         /* this function is running on another CPU than the offline target,
 78          * here we need wait for shutdown code in platform_cpu_die() to
 79          * finish before asking SoC-specific code to power off the CPU core.
 80          */
 81         for (k = 0; k < 1000; k++) {
 82                 if (shmobile_smp_scu_psr_core_disabled(cpu))
 83                         return 1;
 84 
 85                 mdelay(1);
 86         }
 87 
 88         return 0;
 89 }
 90 #endif
 91 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php