]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
ARM: shmobile: r8a7740: Add CPUIdle
authorBastian Hecht <hechtb@gmail.com>
Wed, 17 Apr 2013 10:56:30 +0000 (10:56 +0000)
committerSimon Horman <horms+renesas@verge.net.au>
Thu, 25 Apr 2013 00:19:06 +0000 (09:19 +0900)
We make use of the r8a7740 Suspend To Ram code to plug together a
CPUIdle driver.

Signed-off-by: Bastian Hecht <hechtb+renesas@gmail.com>
Acked-by: Daniel Lezcano <daniel.lezcano@linaro.org>
arch/arm/mach-shmobile/Makefile
arch/arm/mach-shmobile/cpuidle-r8a7740.c [new file with mode: 0644]
arch/arm/mach-shmobile/include/mach/r8a7740.h
arch/arm/mach-shmobile/pm-r8a7740.c

index 90bb8c37d034a18df21f05024cc24ec9bb90d99e..ee7ba7b36494d6da176f281e5b10b1e676023c58 100644 (file)
@@ -30,7 +30,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_R8A7740)     += pm-r8a7740.o sleep-r8a7740.o
+obj-$(CONFIG_ARCH_R8A7740)     += pm-r8a7740.o sleep-r8a7740.o cpuidle-r8a7740.o
 obj-$(CONFIG_ARCH_R8A7779)     += pm-r8a7779.o
 obj-$(CONFIG_ARCH_SH73A0)      += pm-sh73a0.o
 
diff --git a/arch/arm/mach-shmobile/cpuidle-r8a7740.c b/arch/arm/mach-shmobile/cpuidle-r8a7740.c
new file mode 100644 (file)
index 0000000..48c7a6c
--- /dev/null
@@ -0,0 +1,62 @@
+/*
+ * CPUIdle code for SoC r8a7740
+ *
+ * Copyright (C) 2013 Bastian Hecht
+ *
+ * This file is subject to the terms and conditions of the GNU General Public
+ * License.  See the file "COPYING" in the main directory of this archive
+ * for more details.
+ */
+#include <linux/cpuidle.h>
+#include <linux/module.h>
+#include <asm/cpuidle.h>
+#include <mach/common.h>
+#include <mach/r8a7740.h>
+
+#if defined(CONFIG_SUSPEND) && defined(CONFIG_CPU_IDLE)
+static int r8a7740_enter_a3sm_pll_on(struct cpuidle_device *dev,
+                                       struct cpuidle_driver *drv, int index)
+{
+       r8a7740_enter_a3sm_common(1);
+       return 1;
+}
+
+static int r8a7740_enter_a3sm_pll_off(struct cpuidle_device *dev,
+                                       struct cpuidle_driver *drv, int index)
+{
+       r8a7740_enter_a3sm_common(0);
+       return 2;
+}
+
+static struct cpuidle_driver r8a7740_cpuidle_driver = {
+       .name                   = "r8a7740_cpuidle",
+       .owner                  = THIS_MODULE,
+       .en_core_tk_irqen       = 1,
+       .state_count            = 3,
+       .safe_state_index       = 0, /* C1 */
+       .states[0] = ARM_CPUIDLE_WFI_STATE,
+       .states[1] = {
+               .name = "C2",
+               .desc = "A3SM PLL ON",
+               .exit_latency = 40,
+               .target_residency = 30 + 40,
+               .flags = CPUIDLE_FLAG_TIME_VALID,
+               .enter = r8a7740_enter_a3sm_pll_on,
+       },
+       .states[2] = {
+               .name = "C3",
+               .desc = "A3SM PLL OFF",
+               .exit_latency = 120,
+               .target_residency = 30 + 120,
+               .flags = CPUIDLE_FLAG_TIME_VALID,
+               .enter = r8a7740_enter_a3sm_pll_off,
+       },
+};
+
+void r8a7740_cpuidle_init(void)
+{
+       shmobile_cpuidle_set_driver(&r8a7740_cpuidle_driver);
+}
+#else
+void r8a7740_cpuidle_init(void) {}
+#endif
index 9d814f45d84077e971196225ad5ea30aeab40015..86e6ac5e82662e5b75dce278c61789e43a5c3491 100644 (file)
@@ -619,6 +619,7 @@ extern void r8a7740_pinmux_init(void);
 extern void r8a7740_pm_init(void);
 extern void r8a7740_resume(void);
 extern void r8a7740_shutdown(void);
+extern void r8a7740_cpuidle_init(void);
 extern void r8a7740_enter_a3sm_common(int);
 
 #ifdef CONFIG_PM
index fe3c867ea0a4bdf5ed862b80c421b6a226df7754..2f196bde4a719367a059769ea4fbc243bb15f791 100644 (file)
@@ -237,4 +237,5 @@ static void r8a7740_suspend_init(void) {}
 void __init r8a7740_pm_init(void)
 {
        r8a7740_suspend_init();
+       r8a7740_cpuidle_init();
 }