mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-10 04:48:04 +09:00
Merge branch 'tracking-armlt-tc2-psci' into lsk-3.10-vexpress
This commit is contained in:
@@ -286,6 +286,15 @@
|
||||
clock-output-names = "oscclk6a";
|
||||
};
|
||||
|
||||
psci {
|
||||
compatible = "arm,psci";
|
||||
method = "smc";
|
||||
cpu_suspend = <0x80100001>;
|
||||
cpu_off = <0x80100002>;
|
||||
cpu_on = <0x80100003>;
|
||||
migrate = <0x80100004>;
|
||||
};
|
||||
|
||||
dcc {
|
||||
compatible = "arm,vexpress,config-bus";
|
||||
arm,vexpress,config-bridge = <&v2m_sysreg>;
|
||||
|
||||
@@ -10,5 +10,9 @@ obj-$(CONFIG_ARCH_VEXPRESS_DCSCB) += dcscb.o dcscb_setup.o
|
||||
CFLAGS_REMOVE_dcscb.o = -pg
|
||||
obj-$(CONFIG_ARCH_VEXPRESS_TC2) += tc2_pm.o tc2_pm_setup.o
|
||||
CFLAGS_REMOVE_tc2_pm.o = -pg
|
||||
ifeq ($(CONFIG_ARCH_VEXPRESS_TC2),y)
|
||||
obj-$(CONFIG_ARM_PSCI) += tc2_pm_psci.o
|
||||
CFLAGS_REMOVE_tc2_pm_psci.o = -pg
|
||||
endif
|
||||
obj-$(CONFIG_SMP) += platsmp.o
|
||||
obj-$(CONFIG_HOTPLUG_CPU) += hotplug.o
|
||||
|
||||
10
arch/arm/mach-vexpress/include/mach/tc2.h
Normal file
10
arch/arm/mach-vexpress/include/mach/tc2.h
Normal file
@@ -0,0 +1,10 @@
|
||||
#ifndef __MACH_TC2_H
|
||||
#define __MACH_TC2_H
|
||||
|
||||
/*
|
||||
* cpu and cluster limits
|
||||
*/
|
||||
#define TC2_MAX_CPUS 3
|
||||
#define TC2_MAX_CLUSTERS 2
|
||||
|
||||
#endif
|
||||
@@ -23,8 +23,10 @@
|
||||
#include <asm/cacheflush.h>
|
||||
#include <asm/cputype.h>
|
||||
#include <asm/cp15.h>
|
||||
#include <asm/psci.h>
|
||||
|
||||
#include <mach/motherboard.h>
|
||||
#include <mach/tc2.h>
|
||||
|
||||
#include <linux/vexpress.h>
|
||||
#include <linux/arm-cci.h>
|
||||
@@ -37,12 +39,13 @@
|
||||
*/
|
||||
static arch_spinlock_t tc2_pm_lock = __ARCH_SPIN_LOCK_UNLOCKED;
|
||||
|
||||
static int tc2_pm_use_count[3][2];
|
||||
static int tc2_pm_use_count[TC2_MAX_CPUS][TC2_MAX_CLUSTERS];
|
||||
|
||||
static int tc2_pm_power_up(unsigned int cpu, unsigned int cluster)
|
||||
{
|
||||
pr_debug("%s: cpu %u cluster %u\n", __func__, cpu, cluster);
|
||||
if (cluster >= 2 || cpu >= vexpress_spc_get_nb_cpus(cluster))
|
||||
if (cluster >= TC2_MAX_CLUSTERS ||
|
||||
cpu >= vexpress_spc_get_nb_cpus(cluster))
|
||||
return -EINVAL;
|
||||
|
||||
/*
|
||||
@@ -90,7 +93,8 @@ static void tc2_pm_down(u64 residency)
|
||||
cluster = MPIDR_AFFINITY_LEVEL(mpidr, 1);
|
||||
|
||||
pr_debug("%s: cpu %u cluster %u\n", __func__, cpu, cluster);
|
||||
BUG_ON(cluster >= 2 || cpu >= vexpress_spc_get_nb_cpus(cluster));
|
||||
BUG_ON(cluster >= TC2_MAX_CLUSTERS ||
|
||||
cpu >= vexpress_spc_get_nb_cpus(cluster));
|
||||
|
||||
__mcpm_cpu_going_down(cpu, cluster);
|
||||
|
||||
@@ -194,7 +198,8 @@ static void tc2_pm_powered_up(void)
|
||||
cluster = MPIDR_AFFINITY_LEVEL(mpidr, 1);
|
||||
|
||||
pr_debug("%s: cpu %u cluster %u\n", __func__, cpu, cluster);
|
||||
BUG_ON(cluster >= 2 || cpu >= vexpress_spc_get_nb_cpus(cluster));
|
||||
BUG_ON(cluster >= TC2_MAX_CLUSTERS ||
|
||||
cpu >= vexpress_spc_get_nb_cpus(cluster));
|
||||
|
||||
local_irq_save(flags);
|
||||
arch_spin_lock(&tc2_pm_lock);
|
||||
@@ -232,7 +237,9 @@ static void __init tc2_pm_usage_count_init(void)
|
||||
cluster = MPIDR_AFFINITY_LEVEL(mpidr, 1);
|
||||
|
||||
pr_debug("%s: cpu %u cluster %u\n", __func__, cpu, cluster);
|
||||
BUG_ON(cpu >= 3 || cluster >= 2);
|
||||
BUG_ON(cluster >= TC2_MAX_CLUSTERS ||
|
||||
cpu >= vexpress_spc_get_nb_cpus(cluster));
|
||||
|
||||
tc2_pm_use_count[cpu][cluster] = 1;
|
||||
}
|
||||
|
||||
@@ -242,6 +249,12 @@ static int __init tc2_pm_init(void)
|
||||
{
|
||||
int ret;
|
||||
|
||||
ret = psci_probe();
|
||||
if (!ret) {
|
||||
pr_debug("psci found. Aborting native init\n");
|
||||
return -ENODEV;
|
||||
}
|
||||
|
||||
if (!vexpress_spc_check_loaded())
|
||||
return -ENODEV;
|
||||
|
||||
|
||||
173
arch/arm/mach-vexpress/tc2_pm_psci.c
Normal file
173
arch/arm/mach-vexpress/tc2_pm_psci.c
Normal file
@@ -0,0 +1,173 @@
|
||||
/*
|
||||
* arch/arm/mach-vexpress/tc2_pm_psci.c - TC2 PSCI support
|
||||
*
|
||||
* Created by: Achin Gupta, December 2012
|
||||
* Copyright: (C) 2012 ARM Limited
|
||||
*
|
||||
* Some portions of this file were originally written by Nicolas Pitre
|
||||
* Copyright: (C) 2012 Linaro Limited
|
||||
*
|
||||
* 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/kernel.h>
|
||||
#include <linux/spinlock.h>
|
||||
#include <linux/errno.h>
|
||||
|
||||
#include <asm/mcpm.h>
|
||||
#include <asm/proc-fns.h>
|
||||
#include <asm/cacheflush.h>
|
||||
#include <asm/psci.h>
|
||||
#include <asm/atomic.h>
|
||||
#include <asm/cputype.h>
|
||||
#include <asm/cp15.h>
|
||||
|
||||
#include <mach/motherboard.h>
|
||||
#include <mach/tc2.h>
|
||||
|
||||
#include <linux/vexpress.h>
|
||||
|
||||
/*
|
||||
* Platform specific state id understood by the firmware and used to
|
||||
* program the power controller
|
||||
*/
|
||||
#define PSCI_POWER_STATE_ID 0
|
||||
|
||||
static atomic_t tc2_pm_use_count[TC2_MAX_CPUS][TC2_MAX_CLUSTERS];
|
||||
|
||||
static int tc2_pm_psci_power_up(unsigned int cpu, unsigned int cluster)
|
||||
{
|
||||
unsigned int mpidr = (cluster << 8) | cpu;
|
||||
int ret = 0;
|
||||
|
||||
BUG_ON(!psci_ops.cpu_on);
|
||||
|
||||
switch (atomic_inc_return(&tc2_pm_use_count[cpu][cluster])) {
|
||||
case 1:
|
||||
/*
|
||||
* This is a request to power up a cpu that linux thinks has
|
||||
* been powered down. Retries are needed if the firmware has
|
||||
* seen the power down request as yet.
|
||||
*/
|
||||
do
|
||||
ret = psci_ops.cpu_on(mpidr,
|
||||
virt_to_phys(mcpm_entry_point));
|
||||
while (ret == -EAGAIN);
|
||||
|
||||
return ret;
|
||||
case 2:
|
||||
/* This power up request has overtaken a power down request */
|
||||
return ret;
|
||||
default:
|
||||
/* Any other value is a bug */
|
||||
BUG();
|
||||
}
|
||||
}
|
||||
|
||||
static void tc2_pm_psci_power_down(void)
|
||||
{
|
||||
struct psci_power_state power_state;
|
||||
unsigned int mpidr, cpu, cluster;
|
||||
|
||||
mpidr = read_cpuid_mpidr();
|
||||
cpu = MPIDR_AFFINITY_LEVEL(mpidr, 0);
|
||||
cluster = MPIDR_AFFINITY_LEVEL(mpidr, 1);
|
||||
|
||||
BUG_ON(!psci_ops.cpu_off);
|
||||
|
||||
switch (atomic_dec_return(&tc2_pm_use_count[cpu][cluster])) {
|
||||
case 1:
|
||||
/*
|
||||
* Overtaken by a power up. Flush caches, exit coherency,
|
||||
* return & fake a reset
|
||||
*/
|
||||
set_cr(get_cr() & ~CR_C);
|
||||
|
||||
flush_cache_louis();
|
||||
|
||||
asm volatile ("clrex");
|
||||
set_auxcr(get_auxcr() & ~(1 << 6));
|
||||
|
||||
return;
|
||||
case 0:
|
||||
/* A normal request to possibly power down the cluster */
|
||||
power_state.id = PSCI_POWER_STATE_ID;
|
||||
power_state.type = PSCI_POWER_STATE_TYPE_POWER_DOWN;
|
||||
power_state.affinity_level = PSCI_POWER_STATE_AFFINITY_LEVEL1;
|
||||
|
||||
psci_ops.cpu_off(power_state);
|
||||
|
||||
/* On success this function never returns */
|
||||
default:
|
||||
/* Any other value is a bug */
|
||||
BUG();
|
||||
}
|
||||
}
|
||||
|
||||
static void tc2_pm_psci_suspend(u64 unused)
|
||||
{
|
||||
struct psci_power_state power_state;
|
||||
|
||||
BUG_ON(!psci_ops.cpu_suspend);
|
||||
|
||||
/* On TC2 always attempt to power down the cluster */
|
||||
power_state.id = PSCI_POWER_STATE_ID;
|
||||
power_state.type = PSCI_POWER_STATE_TYPE_POWER_DOWN;
|
||||
power_state.affinity_level = PSCI_POWER_STATE_AFFINITY_LEVEL1;
|
||||
|
||||
psci_ops.cpu_suspend(power_state, virt_to_phys(mcpm_entry_point));
|
||||
|
||||
/* On success this function never returns */
|
||||
BUG();
|
||||
}
|
||||
|
||||
static const struct mcpm_platform_ops tc2_pm_power_ops = {
|
||||
.power_up = tc2_pm_psci_power_up,
|
||||
.power_down = tc2_pm_psci_power_down,
|
||||
.suspend = tc2_pm_psci_suspend,
|
||||
};
|
||||
|
||||
static void __init tc2_pm_usage_count_init(void)
|
||||
{
|
||||
unsigned int mpidr, cpu, cluster;
|
||||
|
||||
mpidr = read_cpuid_mpidr();
|
||||
cpu = MPIDR_AFFINITY_LEVEL(mpidr, 0);
|
||||
cluster = MPIDR_AFFINITY_LEVEL(mpidr, 1);
|
||||
|
||||
pr_debug("%s: cpu %u cluster %u\n", __func__, cpu, cluster);
|
||||
BUG_ON(cluster >= TC2_MAX_CLUSTERS ||
|
||||
cpu >= vexpress_spc_get_nb_cpus(cluster));
|
||||
|
||||
atomic_set(&tc2_pm_use_count[cpu][cluster], 1);
|
||||
}
|
||||
|
||||
static int __init tc2_pm_psci_init(void)
|
||||
{
|
||||
int ret;
|
||||
|
||||
ret = psci_probe();
|
||||
if (ret) {
|
||||
pr_debug("psci not found. Aborting psci init\n");
|
||||
return -ENODEV;
|
||||
}
|
||||
|
||||
if (!vexpress_spc_check_loaded()) {
|
||||
pr_debug("spc not found. Aborting psci init\n");
|
||||
return -ENODEV;
|
||||
}
|
||||
|
||||
tc2_pm_usage_count_init();
|
||||
|
||||
ret = mcpm_platform_register(&tc2_pm_power_ops);
|
||||
if (!ret)
|
||||
ret = mcpm_sync_init(NULL);
|
||||
if (!ret)
|
||||
pr_info("TC2 power management initialized\n");
|
||||
return ret;
|
||||
}
|
||||
|
||||
early_initcall(tc2_pm_psci_init);
|
||||
Reference in New Issue
Block a user