2014-07-08 06:54:13 +08:00
|
|
|
/*
|
2010-08-20 17:17:51 +08:00
|
|
|
* Cloned from linux/arch/arm/mach-realview/hotplug.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/kernel.h>
|
|
|
|
#include <linux/errno.h>
|
|
|
|
#include <linux/smp.h>
|
2011-07-16 12:39:09 +08:00
|
|
|
#include <linux/io.h>
|
2010-08-20 17:17:51 +08:00
|
|
|
|
|
|
|
#include <asm/cacheflush.h>
|
2012-03-29 01:30:01 +08:00
|
|
|
#include <asm/cp15.h>
|
2012-01-20 19:01:12 +08:00
|
|
|
#include <asm/smp_plat.h>
|
2010-08-20 17:17:51 +08:00
|
|
|
|
2011-09-08 20:15:22 +08:00
|
|
|
#include "common.h"
|
2013-12-19 03:06:56 +08:00
|
|
|
#include "regs-pmu.h"
|
2011-09-08 20:15:22 +08:00
|
|
|
|
2010-08-20 17:17:51 +08:00
|
|
|
static inline void cpu_leave_lowpower(void)
|
|
|
|
{
|
|
|
|
unsigned int v;
|
|
|
|
|
|
|
|
asm volatile(
|
|
|
|
"mrc p15, 0, %0, c1, c0, 0\n"
|
2010-12-19 19:36:33 +08:00
|
|
|
" orr %0, %0, %1\n"
|
2010-08-20 17:17:51 +08:00
|
|
|
" mcr p15, 0, %0, c1, c0, 0\n"
|
|
|
|
" mrc p15, 0, %0, c1, c0, 1\n"
|
2011-02-28 19:35:33 +08:00
|
|
|
" orr %0, %0, %2\n"
|
2010-08-20 17:17:51 +08:00
|
|
|
" mcr p15, 0, %0, c1, c0, 1\n"
|
|
|
|
: "=&r" (v)
|
2011-02-28 19:35:33 +08:00
|
|
|
: "Ir" (CR_C), "Ir" (0x40)
|
2010-08-20 17:17:51 +08:00
|
|
|
: "cc");
|
|
|
|
}
|
|
|
|
|
2010-12-19 19:30:43 +08:00
|
|
|
static inline void platform_do_lowpower(unsigned int cpu, int *spurious)
|
2010-08-20 17:17:51 +08:00
|
|
|
{
|
2014-07-16 01:59:18 +08:00
|
|
|
u32 mpidr = cpu_logical_map(cpu);
|
|
|
|
u32 core_id = MPIDR_AFFINITY_LEVEL(mpidr, 0);
|
|
|
|
|
2010-08-20 17:17:51 +08:00
|
|
|
for (;;) {
|
2011-07-16 12:39:09 +08:00
|
|
|
|
2014-07-16 01:59:18 +08:00
|
|
|
/* Turn the CPU off on next WFI instruction. */
|
|
|
|
exynos_cpu_power_down(core_id);
|
2011-07-16 12:39:09 +08:00
|
|
|
|
2014-05-27 23:43:21 +08:00
|
|
|
wfi();
|
2010-08-20 17:17:51 +08:00
|
|
|
|
2014-07-16 01:59:18 +08:00
|
|
|
if (pen_release == core_id) {
|
2010-08-20 17:17:51 +08:00
|
|
|
/*
|
|
|
|
* OK, proper wakeup, we're done
|
|
|
|
*/
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2010-12-19 19:30:43 +08:00
|
|
|
* Getting here, means that we have come out of WFI without
|
2010-08-20 17:17:51 +08:00
|
|
|
* having been woken up - this shouldn't happen
|
|
|
|
*
|
2010-12-19 19:30:43 +08:00
|
|
|
* Just note it happening - when we're woken, we can report
|
|
|
|
* its occurrence.
|
2010-08-20 17:17:51 +08:00
|
|
|
*/
|
2010-12-19 19:30:43 +08:00
|
|
|
(*spurious)++;
|
2010-08-20 17:17:51 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* platform-specific code to shutdown a CPU
|
|
|
|
*
|
|
|
|
* Called with IRQs disabled
|
|
|
|
*/
|
2011-09-08 20:15:22 +08:00
|
|
|
void __ref exynos_cpu_die(unsigned int cpu)
|
2010-08-20 17:17:51 +08:00
|
|
|
{
|
2010-12-19 19:30:43 +08:00
|
|
|
int spurious = 0;
|
|
|
|
|
2014-05-09 21:51:04 +08:00
|
|
|
v7_exit_coherency_flush(louis);
|
2012-11-22 13:46:17 +08:00
|
|
|
|
2010-12-19 19:30:43 +08:00
|
|
|
platform_do_lowpower(cpu, &spurious);
|
2010-08-20 17:17:51 +08:00
|
|
|
|
|
|
|
/*
|
|
|
|
* bring this CPU back into the world of cache
|
|
|
|
* coherency, and then restore interrupts
|
|
|
|
*/
|
|
|
|
cpu_leave_lowpower();
|
2010-12-19 19:30:43 +08:00
|
|
|
|
|
|
|
if (spurious)
|
|
|
|
pr_warn("CPU%u: %u spurious wakeup calls\n", cpu, spurious);
|
2010-08-20 17:17:51 +08:00
|
|
|
}
|