msm: pm-8x60: Move hotplug related code out of pm code.
Move hotplug related code into hotplug.c and compile hotplug.c only when
CONFIG_HOTPLUG_CPU is defined.
Signed-off-by: Mahesh Sivasubramanian <msivasub@codeaurora.org>
Change-Id: Ia9aa7a64e9831f52431c77c22f30fb64892efaea
diff --git a/arch/arm/mach-msm/hotplug.c b/arch/arm/mach-msm/hotplug.c
index e8aa38e..86a2374 100644
--- a/arch/arm/mach-msm/hotplug.c
+++ b/arch/arm/mach-msm/hotplug.c
@@ -11,10 +11,22 @@
#include <linux/smp.h>
#include <asm/cacheflush.h>
+#include <asm/vfp.h>
-#ifdef CONFIG_SMP
+#include "qdss.h"
+#include "spm.h"
+#include "pm.h"
+
extern volatile int pen_release;
+struct msm_hotplug_device {
+ struct completion cpu_killed;
+ unsigned int warm_boot;
+};
+
+static DEFINE_PER_CPU_SHARED_ALIGNED(struct msm_hotplug_device,
+ msm_hotplug_devices);
+
static inline void cpu_enter_lowpower(void)
{
/* Just flush the cache. Changing the coherency is not yet
@@ -30,14 +42,8 @@
{
/* Just enter wfi for now. TODO: Properly shut off the cpu. */
for (;;) {
- /*
- * here's the WFI
- */
- asm("wfi"
- :
- :
- : "memory", "cc");
+ msm_pm_cpu_enter_lowpower(cpu);
if (pen_release == cpu) {
/*
* OK, proper wakeup, we're done
@@ -56,11 +62,13 @@
pr_debug("CPU%u: spurious wakeup call\n", cpu);
}
}
-#endif
int platform_cpu_kill(unsigned int cpu)
{
- return 1;
+ struct completion *killed =
+ &per_cpu(msm_hotplug_devices, cpu).cpu_killed;
+
+ return wait_for_completion_timeout(killed, HZ * 5);
}
/*
@@ -70,19 +78,20 @@
*/
void platform_cpu_die(unsigned int cpu)
{
-#ifdef CONFIG_SMP
+ if (unlikely(cpu != smp_processor_id())) {
+ pr_crit("%s: running on %u, should be %u\n",
+ __func__, smp_processor_id(), cpu);
+ BUG();
+ }
+ complete(&__get_cpu_var(msm_hotplug_devices).cpu_killed);
/*
* we're ready for shutdown now, so do it
*/
cpu_enter_lowpower();
platform_do_lowpower(cpu);
- /*
- * bring this CPU back into the world of cache
- * coherency, and then restore interrupts
- */
+ pr_notice("CPU%u: %s: normal wakeup\n", cpu, __func__);
cpu_leave_lowpower();
-#endif
}
int platform_cpu_disable(unsigned int cpu)
@@ -93,3 +102,23 @@
*/
return cpu == 0 ? -EPERM : 0;
}
+
+int msm_platform_secondary_init(unsigned int cpu)
+{
+ int ret;
+ struct msm_hotplug_device *dev = &__get_cpu_var(msm_hotplug_devices);
+
+ if (!dev->warm_boot) {
+ dev->warm_boot = 1;
+ init_completion(&dev->cpu_killed);
+ return 0;
+ }
+ etm_restore_reg_check();
+ msm_restore_jtag_debug();
+#ifdef CONFIG_VFP
+ vfp_reinit();
+#endif
+ ret = msm_spm_set_low_power_mode(MSM_SPM_MODE_CLOCK_GATING, false);
+
+ return ret;
+}