Skip to contentSkip to conversation

ARM: mach-shmobile: sh73a0 Coupled CPUIdle Prototype

PATCH New Magnus Damm 1 participant 1 message Sep 13, 2012

Subsystems (4)
lore
Share & tools
lore

Magnus Damm

author maintainer
#0 lore raw

PATCH 1/1 ARM: mach-shmobile: sh73a0 Coupled CPUIdle Prototype

From: Magnus Damm <[email protected]>

Prototype patch to enable the coupled CPUIdle
helper code on sh73a0. Not for upstream merge.

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

---

 arch/arm/mach-shmobile/Kconfig               |    1 
 arch/arm/mach-shmobile/Makefile              |    1 
 arch/arm/mach-shmobile/board-ag5evm.c        |    2 
 arch/arm/mach-shmobile/board-kota2.c         |    2 
 arch/arm/mach-shmobile/board-kzm9g.c         |    2 
 arch/arm/mach-shmobile/cpuidle.c             |   20 ++++++---
 arch/arm/mach-shmobile/include/mach/common.h |    1 
 arch/arm/mach-shmobile/pm-sh73a0.c           |   57 ++++++++++++++++++++++++++
 8 files changed, 81 insertions(+), 5 deletions(-)
arch/arm/mach-shmobile/Kconfig +1 -0
@@ -28,6 +28,7 @@ config ARCH_SH73A0
 	select ARCH_WANT_OPTIONAL_GPIOLIB
 	select ARM_GIC
 	select I2C
+	select ARCH_NEEDS_CPU_IDLE_COUPLED if SMP
 
 config ARCH_R8A7740
 	bool "R-Mobile A1 (R8A77400)"
arch/arm/mach-shmobile/Makefile +1 -0
@@ -41,6 +41,7 @@ obj-$(CONFIG_SUSPEND)		+= suspend.o
 obj-$(CONFIG_CPU_IDLE)		+= cpuidle.o
 obj-$(CONFIG_ARCH_SHMOBILE)	+= pm-rmobile.o
 obj-$(CONFIG_ARCH_SH7372)	+= pm-sh7372.o sleep-sh7372.o
+obj-$(CONFIG_ARCH_SH73A0)	+= pm-sh73a0.o
 obj-$(CONFIG_ARCH_R8A7740)	+= pm-r8a7740.o
 obj-$(CONFIG_ARCH_R8A7779)	+= pm-r8a7779.o
 
arch/arm/mach-shmobile/board-ag5evm.c +2 -0
@@ -647,6 +647,8 @@ static void __init ag5evm_init(void)
 #endif
 	sh73a0_add_standard_devices();
 	platform_add_devices(ag5evm_devices, ARRAY_SIZE(ag5evm_devices));
+
+	sh73a0_pm_init();
 }
 
 MACHINE_START(AG5EVM, "ag5evm")
arch/arm/mach-shmobile/board-kota2.c +2 -0
@@ -542,6 +542,8 @@ static void __init kota2_init(void)
 #endif
 	sh73a0_add_standard_devices();
 	platform_add_devices(kota2_devices, ARRAY_SIZE(kota2_devices));
+
+	sh73a0_pm_init();
 }
 
 MACHINE_START(KOTA2, "kota2")
arch/arm/mach-shmobile/board-kzm9g.c +2 -0
@@ -761,6 +761,8 @@ static void __init kzm_init(void)
 
 	sh73a0_add_standard_devices();
 	platform_add_devices(kzm_devices, ARRAY_SIZE(kzm_devices));
+
+	sh73a0_pm_init();
 }
 
 static const char *kzm9g_boards_compat_dt[] __initdata = {
arch/arm/mach-shmobile/cpuidle.c +15 -5
@@ -34,7 +34,7 @@ static int shmobile_cpuidle_enter(struct
 	return index;
 }
 
-static struct cpuidle_device shmobile_cpuidle_dev;
+static DEFINE_PER_CPU(struct cpuidle_device, shmobile_cpuidle_dev);
 static struct cpuidle_driver shmobile_cpuidle_driver = {
 	.name			= "shmobile_cpuidle",
 	.owner			= THIS_MODULE,
@@ -48,8 +48,9 @@ void (*shmobile_cpuidle_setup)(struct cp
 
 int shmobile_cpuidle_init(void)
 {
-	struct cpuidle_device *dev = &shmobile_cpuidle_dev;
 	struct cpuidle_driver *drv = &shmobile_cpuidle_driver;
+	struct cpuidle_device *dev;
+	unsigned int cpu_id = 0;
 	int i;
 
 	for (i = 0; i < CPUIDLE_STATE_MAX; i++)
@@ -60,8 +61,17 @@ int shmobile_cpuidle_init(void)
 
 	cpuidle_register_driver(drv);
 
-	dev->state_count = drv->state_count;
-	cpuidle_register_device(dev);
-
+	for_each_cpu(cpu_id, cpu_online_mask) {
+		dev = &per_cpu(shmobile_cpuidle_dev, cpu_id);
+		dev->cpu = cpu_id;
+		dev->state_count = drv->state_count;
+#ifdef CONFIG_ARCH_NEEDS_CPU_IDLE_COUPLED
+		dev->coupled_cpus = *cpu_online_mask;
+#endif
+		if (cpuidle_register_device(dev)) {
+			pr_err("Unable to register CPUIdle device\n");
+			return -EIO;
+		}
+	}
 	return 0;
 }
arch/arm/mach-shmobile/include/mach/common.h +1 -0
@@ -53,6 +53,7 @@ extern void sh73a0_add_early_devices(voi
 extern void sh73a0_add_standard_devices(void);
 extern void sh73a0_clock_init(void);
 extern void sh73a0_pinmux_init(void);
+void __init sh73a0_pm_init(void);
 extern struct clk sh73a0_extal1_clk;
 extern struct clk sh73a0_extal2_clk;
 extern struct clk sh73a0_extcki_clk;
arch/arm/mach-shmobile/pm-sh73a0.c new file +57 -0

57 lines not on this page · raw message