Release 4.15 arch/arm/kernel/smp_scu.c
/*
* linux/arch/arm/kernel/smp_scu.c
*
* Copyright (C) 2002 ARM Ltd.
* All Rights Reserved
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*/
#include <linux/init.h>
#include <linux/io.h>
#include <asm/smp_plat.h>
#include <asm/smp_scu.h>
#include <asm/cacheflush.h>
#include <asm/cputype.h>
#define SCU_CTRL 0x00
#define SCU_ENABLE (1 << 0)
#define SCU_STANDBY_ENABLE (1 << 5)
#define SCU_CONFIG 0x04
#define SCU_CPU_STATUS 0x08
#define SCU_CPU_STATUS_MASK GENMASK(1, 0)
#define SCU_INVALIDATE 0x0c
#define SCU_FPGA_REVISION 0x10
#ifdef CONFIG_SMP
/*
* Get the number of CPU cores from the SCU configuration
*/
unsigned int __init scu_get_core_count(void __iomem *scu_base)
{
unsigned int ncores = readl_relaxed(scu_base + SCU_CONFIG);
return (ncores & 0x03) + 1;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Russell King | 31 | 96.88% | 1 | 50.00% |
Ben Dooks | 1 | 3.12% | 1 | 50.00% |
Total | 32 | 100.00% | 2 | 100.00% |
/*
* Enable the SCU
*/
void scu_enable(void __iomem *scu_base)
{
u32 scu_ctrl;
#ifdef CONFIG_ARM_ERRATA_764369
/* Cortex-A9 only */
if ((read_cpuid_id() & 0xff0ffff0) == 0x410fc090) {
scu_ctrl = readl_relaxed(scu_base + 0x30);
if (!(scu_ctrl & 1))
writel_relaxed(scu_ctrl | 0x1, scu_base + 0x30);
}
#endif
scu_ctrl = readl_relaxed(scu_base + SCU_CTRL);
/* already enabled? */
if (scu_ctrl & SCU_ENABLE)
return;
scu_ctrl |= SCU_ENABLE;
/* Cortex-A9 earlier than r2p0 has no standby bit in SCU */
if ((read_cpuid_id() & 0xff0ffff0) == 0x410fc090 &&
(read_cpuid_id() & 0x00f0000f) >= 0x00200000)
scu_ctrl |= SCU_STANDBY_ENABLE;
writel_relaxed(scu_ctrl, scu_base + SCU_CTRL);
/*
* Ensure that the data accessed by CPU0 before the SCU was
* initialised is visible to the other CPUs.
*/
flush_cache_all();
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Will Deacon | 44 | 36.67% | 1 | 12.50% |
Russell King | 32 | 26.67% | 1 | 12.50% |
Shawn Guo | 27 | 22.50% | 2 | 25.00% |
Catalin Marinas | 11 | 9.17% | 2 | 25.00% |
Ben Dooks | 4 | 3.33% | 1 | 12.50% |
Uwe Kleine-König | 2 | 1.67% | 1 | 12.50% |
Total | 120 | 100.00% | 8 | 100.00% |
#endif
static int scu_set_power_mode_internal(void __iomem *scu_base,
unsigned int logical_cpu,
unsigned int mode)
{
unsigned int val;
int cpu = MPIDR_AFFINITY_LEVEL(cpu_logical_map(logical_cpu), 0);
if (mode > 3 || mode == 1 || cpu > 3)
return -EINVAL;
val = readb_relaxed(scu_base + SCU_CPU_STATUS + cpu);
val &= ~SCU_CPU_STATUS_MASK;
val |= mode;
writeb_relaxed(val, scu_base + SCU_CPU_STATUS + cpu);
return 0;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Russell King | 67 | 76.14% | 1 | 16.67% |
Martin Blumenstingl | 11 | 12.50% | 2 | 33.33% |
Rob Herring | 5 | 5.68% | 1 | 16.67% |
Will Deacon | 3 | 3.41% | 1 | 16.67% |
Ben Dooks | 2 | 2.27% | 1 | 16.67% |
Total | 88 | 100.00% | 6 | 100.00% |
/*
* Set the executing CPUs power mode as defined. This will be in
* preparation for it executing a WFI instruction.
*
* This function must be called with preemption disabled, and as it
* has the side effect of disabling coherency, caches must have been
* flushed. Interrupts must also have been disabled.
*/
int scu_power_mode(void __iomem *scu_base, unsigned int mode)
{
return scu_set_power_mode_internal(scu_base, smp_processor_id(), mode);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Martin Blumenstingl | 25 | 100.00% | 1 | 100.00% |
Total | 25 | 100.00% | 1 | 100.00% |
/*
* Set the given (logical) CPU's power mode to SCU_PM_NORMAL.
*/
int scu_cpu_power_enable(void __iomem *scu_base, unsigned int cpu)
{
return scu_set_power_mode_internal(scu_base, cpu, SCU_PM_NORMAL);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Martin Blumenstingl | 24 | 100.00% | 1 | 100.00% |
Total | 24 | 100.00% | 1 | 100.00% |
int scu_get_cpu_power_mode(void __iomem *scu_base, unsigned int logical_cpu)
{
unsigned int val;
int cpu = MPIDR_AFFINITY_LEVEL(cpu_logical_map(logical_cpu), 0);
if (cpu > 3)
return -EINVAL;
val = readb_relaxed(scu_base + SCU_CPU_STATUS + cpu);
val &= SCU_CPU_STATUS_MASK;
return val;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Martin Blumenstingl | 59 | 100.00% | 1 | 100.00% |
Total | 59 | 100.00% | 1 | 100.00% |
Overall Contributors
Person | Tokens | Prop | Commits | CommitProp |
Russell King | 162 | 39.71% | 2 | 14.29% |
Martin Blumenstingl | 125 | 30.64% | 2 | 14.29% |
Will Deacon | 53 | 12.99% | 2 | 14.29% |
Shawn Guo | 35 | 8.58% | 2 | 14.29% |
Catalin Marinas | 14 | 3.43% | 2 | 14.29% |
Rob Herring | 10 | 2.45% | 2 | 14.29% |
Ben Dooks | 7 | 1.72% | 1 | 7.14% |
Uwe Kleine-König | 2 | 0.49% | 1 | 7.14% |
Total | 408 | 100.00% | 14 | 100.00% |
Information contained on this website is for historical information purposes only and does not indicate or represent copyright ownership.