2018-09-07 09:43:23 +08:00
|
|
|
// SPDX-License-Identifier: GPL-2.0
|
2013-07-31 15:07:12 +08:00
|
|
|
/*
|
|
|
|
* SMP support for SoCs with SCU covered by mach-shmobile
|
|
|
|
*
|
|
|
|
* Copyright (C) 2013 Magnus Damm
|
|
|
|
*/
|
2013-09-14 21:46:25 +08:00
|
|
|
#include <linux/cpu.h>
|
2013-07-31 15:07:49 +08:00
|
|
|
#include <linux/delay.h>
|
2013-07-31 15:07:12 +08:00
|
|
|
#include <linux/init.h>
|
|
|
|
#include <linux/io.h>
|
|
|
|
#include <linux/smp.h>
|
2013-07-31 15:07:49 +08:00
|
|
|
#include <asm/cacheflush.h>
|
2013-07-31 15:07:12 +08:00
|
|
|
#include <asm/smp_plat.h>
|
|
|
|
#include <asm/smp_scu.h>
|
2014-06-17 15:47:37 +08:00
|
|
|
#include "common.h"
|
2013-07-31 15:07:12 +08:00
|
|
|
|
2016-01-28 23:04:21 +08:00
|
|
|
|
ARM: shmobile: Consolidate SCU mapping code
Currently the SCU registers are mapped in SoC-specific code, using
different methods, all involving the static mapping set up from
machine_desc.map_io():
- On emev2, a static (non-identity) mapping is used, with ioremap().
As the static mapping uses the MT_DEVICE type, ioremap() reuses it,
and the returned virtual address is suitable for passing to
shmobile_smp_hook(),
- On sh73a0 and r8a7779, a static identity mapping is used, with the
legacy IOMEM() macro.
As the static mapping uses the MT_DEVICE_NONSHARED type, replacing
IOMEM() by ioremap() would create a new mapping, whose virtual
address cannot be passed to shmobile_smp_hook().
Move the mapping of the SCU registers from SoC-specific code to common
code, always using ioremap(). To work in the absence of a static
mapping, this requires passing the physical SCU base address to
shmobile_smp_hook().
Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Signed-off-by: Simon Horman <horms+renesas@verge.net.au>
2016-01-28 23:13:32 +08:00
|
|
|
static phys_addr_t shmobile_scu_base_phys;
|
|
|
|
static void __iomem *shmobile_scu_base;
|
2016-01-28 23:04:21 +08:00
|
|
|
|
2016-09-07 01:04:38 +08:00
|
|
|
static int shmobile_scu_cpu_prepare(unsigned int cpu)
|
2013-09-14 21:46:25 +08:00
|
|
|
{
|
2016-09-07 01:04:38 +08:00
|
|
|
/* For this particular CPU register SCU SMP boot vector */
|
2017-01-15 10:59:29 +08:00
|
|
|
shmobile_smp_hook(cpu, __pa_symbol(shmobile_boot_scu),
|
2016-09-07 01:04:38 +08:00
|
|
|
shmobile_scu_base_phys);
|
|
|
|
return 0;
|
2013-09-14 21:46:25 +08:00
|
|
|
}
|
|
|
|
|
ARM: shmobile: Consolidate SCU mapping code
Currently the SCU registers are mapped in SoC-specific code, using
different methods, all involving the static mapping set up from
machine_desc.map_io():
- On emev2, a static (non-identity) mapping is used, with ioremap().
As the static mapping uses the MT_DEVICE type, ioremap() reuses it,
and the returned virtual address is suitable for passing to
shmobile_smp_hook(),
- On sh73a0 and r8a7779, a static identity mapping is used, with the
legacy IOMEM() macro.
As the static mapping uses the MT_DEVICE_NONSHARED type, replacing
IOMEM() by ioremap() would create a new mapping, whose virtual
address cannot be passed to shmobile_smp_hook().
Move the mapping of the SCU registers from SoC-specific code to common
code, always using ioremap(). To work in the absence of a static
mapping, this requires passing the physical SCU base address to
shmobile_smp_hook().
Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Signed-off-by: Simon Horman <horms+renesas@verge.net.au>
2016-01-28 23:13:32 +08:00
|
|
|
void __init shmobile_smp_scu_prepare_cpus(phys_addr_t scu_base_phys,
|
|
|
|
unsigned int max_cpus)
|
2013-07-31 15:07:12 +08:00
|
|
|
{
|
2013-08-01 02:38:27 +08:00
|
|
|
/* install boot code shared by all CPUs */
|
2017-01-15 10:59:29 +08:00
|
|
|
shmobile_boot_fn = __pa_symbol(shmobile_smp_boot);
|
2013-07-31 15:07:12 +08:00
|
|
|
|
|
|
|
/* enable SCU and cache coherency on booting CPU */
|
ARM: shmobile: Consolidate SCU mapping code
Currently the SCU registers are mapped in SoC-specific code, using
different methods, all involving the static mapping set up from
machine_desc.map_io():
- On emev2, a static (non-identity) mapping is used, with ioremap().
As the static mapping uses the MT_DEVICE type, ioremap() reuses it,
and the returned virtual address is suitable for passing to
shmobile_smp_hook(),
- On sh73a0 and r8a7779, a static identity mapping is used, with the
legacy IOMEM() macro.
As the static mapping uses the MT_DEVICE_NONSHARED type, replacing
IOMEM() by ioremap() would create a new mapping, whose virtual
address cannot be passed to shmobile_smp_hook().
Move the mapping of the SCU registers from SoC-specific code to common
code, always using ioremap(). To work in the absence of a static
mapping, this requires passing the physical SCU base address to
shmobile_smp_hook().
Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Signed-off-by: Simon Horman <horms+renesas@verge.net.au>
2016-01-28 23:13:32 +08:00
|
|
|
shmobile_scu_base_phys = scu_base_phys;
|
|
|
|
shmobile_scu_base = ioremap(scu_base_phys, PAGE_SIZE);
|
2013-07-31 15:07:12 +08:00
|
|
|
scu_enable(shmobile_scu_base);
|
|
|
|
scu_power_mode(shmobile_scu_base, SCU_PM_NORMAL);
|
2013-09-14 21:46:25 +08:00
|
|
|
|
|
|
|
/* Use CPU notifier for reset vector control */
|
2016-09-07 01:04:38 +08:00
|
|
|
cpuhp_setup_state_nocalls(CPUHP_ARM_SHMOBILE_SCU_PREPARE,
|
|
|
|
"arm/shmobile-scu:prepare",
|
|
|
|
shmobile_scu_cpu_prepare, NULL);
|
2013-07-31 15:07:12 +08:00
|
|
|
}
|
|
|
|
|
2013-07-31 15:07:49 +08:00
|
|
|
#ifdef CONFIG_HOTPLUG_CPU
|
|
|
|
void shmobile_smp_scu_cpu_die(unsigned int cpu)
|
|
|
|
{
|
2013-08-01 02:38:27 +08:00
|
|
|
/* For this particular CPU deregister boot vector */
|
|
|
|
shmobile_smp_hook(cpu, 0, 0);
|
|
|
|
|
2013-07-31 15:07:49 +08:00
|
|
|
dsb();
|
|
|
|
flush_cache_all();
|
|
|
|
|
|
|
|
/* disable cache coherency */
|
|
|
|
scu_power_mode(shmobile_scu_base, SCU_PM_POWEROFF);
|
|
|
|
|
2013-08-01 02:38:27 +08:00
|
|
|
/* jump to shared mach-shmobile sleep / reset code */
|
|
|
|
shmobile_smp_sleep();
|
2013-07-31 15:07:49 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static int shmobile_smp_scu_psr_core_disabled(int cpu)
|
|
|
|
{
|
|
|
|
unsigned long mask = SCU_PM_POWEROFF << (cpu * 8);
|
|
|
|
|
2020-11-17 22:24:47 +08:00
|
|
|
if ((readl(shmobile_scu_base + 8) & mask) == mask)
|
2013-07-31 15:07:49 +08:00
|
|
|
return 1;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int shmobile_smp_scu_cpu_kill(unsigned int cpu)
|
|
|
|
{
|
|
|
|
int k;
|
|
|
|
|
|
|
|
/* this function is running on another CPU than the offline target,
|
|
|
|
* here we need wait for shutdown code in platform_cpu_die() to
|
|
|
|
* finish before asking SoC-specific code to power off the CPU core.
|
|
|
|
*/
|
|
|
|
for (k = 0; k < 1000; k++) {
|
|
|
|
if (shmobile_smp_scu_psr_core_disabled(cpu))
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
mdelay(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
#endif
|