Skip to contentSkip to conversation

ARM: shmobile: r8a7790 Core Standby CPUIdle prototype

PATCH New Magnus Damm 1 participant 1 message Mar 16, 2014

Subsystems (4)
lore
Share & tools
lore

Magnus Damm

author maintainer
#0 lore raw

PATCH 5/6 ARM: shmobile: r8a7790 Core Standby CPUIdle prototype

From: Magnus Damm <[email protected]>

Prototype code to enable per-cpu power domain control via the r8a7790 Core Standby sleep mode. Needs more work.

Not-Yet-Signed-off-by Magnus Damm <[email protected]>

---

 arch/arm/mach-shmobile/include/mach/common.h |    2 
 arch/arm/mach-shmobile/platsmp-apmu.c        |   38 ++++++++++++++++--
 arch/arm/mach-shmobile/pm-r8a7790.c          |   53 +++++++++++++++++++++++++-
 3 files changed, 87 insertions(+), 6 deletions(-)
arch/arm/mach-shmobile/include/mach/common.h +2 -0
@@ -24,6 +24,8 @@ extern int shmobile_smp_scu_cpu_kill(uns
 extern void shmobile_smp_apmu_prepare_cpus(unsigned int max_cpus);
 extern int shmobile_smp_apmu_boot_secondary(unsigned int cpu,
 					    struct task_struct *idle);
+extern void shmobile_smp_apmu_cpu_shutdown(unsigned int cpu);
+extern void shmobile_smp_apmu_cpu_resume(void);
 extern void shmobile_smp_apmu_cpu_die(unsigned int cpu);
 extern int shmobile_smp_apmu_cpu_kill(unsigned int cpu);
 struct clk;
arch/arm/mach-shmobile/platsmp-apmu.c +33 -5
@@ -143,7 +143,7 @@ int shmobile_smp_apmu_boot_secondary(uns
 }
 #endif
 
-#ifdef CONFIG_HOTPLUG_CPU
+#if defined(CONFIG_HOTPLUG_CPU) || defined(CONFIG_CPU_IDLE)
 /* nicked from arch/arm/mach-exynos/hotplug.c */
 static inline void cpu_enter_lowpower_a15(void)
 {
@@ -174,16 +174,44 @@ static inline void cpu_enter_lowpower_a1
 	dsb();
 }
 
-void shmobile_smp_apmu_cpu_die(unsigned int cpu)
+void shmobile_smp_apmu_cpu_shutdown(unsigned int cpu)
 {
-	/* For this particular CPU deregister boot vector */
-	shmobile_smp_hook(cpu, 0, 0);
-
 	/* Select next sleep mode using the APMU */
 	apmu_wrap(cpu, apmu_power_off);
 
 	/* Do ARM specific CPU shutdown */
 	cpu_enter_lowpower_a15();
+}
+
+static inline void cpu_leave_lowpower(void)
+{
+	unsigned int v;
+
+	asm volatile("mrc    p15, 0, %0, c1, c0, 0\n"
+		     "       orr     %0, %0, %1\n"
+		     "       mcr     p15, 0, %0, c1, c0, 0\n"
+		     "       mrc     p15, 0, %0, c1, c0, 1\n"
+		     "       orr     %0, %0, %2\n"
+		     "       mcr     p15, 0, %0, c1, c0, 1\n"
+		     : "=&r" (v)
+		     : "Ir" (CR_C), "Ir" (0x40)
+		     : "cc");
+}
+
+void shmobile_smp_apmu_cpu_resume(void)
+{
+	cpu_leave_lowpower();
+}
+#endif
+
+#if defined(CONFIG_HOTPLUG_CPU)
+void shmobile_smp_apmu_cpu_die(unsigned int cpu)
+{
+	/* For this particular CPU deregister boot vector */
+	shmobile_smp_hook(cpu, 0, 0);
+
+	/* Shutdown CPU core */
+	shmobile_smp_apmu_cpu_shutdown(cpu);
 
 	/* jump to shared mach-shmobile sleep / reset code */
 	shmobile_smp_sleep();
arch/arm/mach-shmobile/pm-r8a7790.c +52 -1

73 lines not on this page · raw message