aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/cpuidle
diff options
context:
space:
mode:
authorMichal Simek <michal.simek@xilinx.com>2013-06-04 03:17:39 -0400
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>2013-06-05 08:04:26 -0400
commitbd2a337a25dd22bcd6b3fb1f99461f6991773e68 (patch)
tree26f7eb072bbf7ebe07b72646c9d8993456a23fde /drivers/cpuidle
parentd6f346f2d2bf511c2c59176121a6e42ce60173a0 (diff)
ARM: zynq: Add cpuidle support
Add cpuidle support for Xilinx Zynq. Signed-off-by: Michal Simek <michal.simek@xilinx.com> Acked-by: Daniel Lezcano <daniel.lezcano@linaro.org> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Diffstat (limited to 'drivers/cpuidle')
-rw-r--r--drivers/cpuidle/Kconfig7
-rw-r--r--drivers/cpuidle/Makefile1
-rw-r--r--drivers/cpuidle/cpuidle-zynq.c83
3 files changed, 91 insertions, 0 deletions
diff --git a/drivers/cpuidle/Kconfig b/drivers/cpuidle/Kconfig
index e997f15d4d0d..a7d2e833f70c 100644
--- a/drivers/cpuidle/Kconfig
+++ b/drivers/cpuidle/Kconfig
@@ -37,4 +37,11 @@ config CPU_IDLE_CALXEDA
37 depends on ARCH_HIGHBANK 37 depends on ARCH_HIGHBANK
38 help 38 help
39 Select this to enable cpuidle on Calxeda processors. 39 Select this to enable cpuidle on Calxeda processors.
40
41config CPU_IDLE_ZYNQ
42 bool "CPU Idle Driver for Xilinx Zynq processors"
43 depends on ARCH_ZYNQ
44 help
45 Select this to enable cpuidle on Xilinx Zynq processors.
46
40endif 47endif
diff --git a/drivers/cpuidle/Makefile b/drivers/cpuidle/Makefile
index 0d8bd55e776f..8767a7b3eb91 100644
--- a/drivers/cpuidle/Makefile
+++ b/drivers/cpuidle/Makefile
@@ -7,3 +7,4 @@ obj-$(CONFIG_ARCH_NEEDS_CPU_IDLE_COUPLED) += coupled.o
7 7
8obj-$(CONFIG_CPU_IDLE_CALXEDA) += cpuidle-calxeda.o 8obj-$(CONFIG_CPU_IDLE_CALXEDA) += cpuidle-calxeda.o
9obj-$(CONFIG_ARCH_KIRKWOOD) += cpuidle-kirkwood.o 9obj-$(CONFIG_ARCH_KIRKWOOD) += cpuidle-kirkwood.o
10obj-$(CONFIG_CPU_IDLE_ZYNQ) += cpuidle-zynq.o
diff --git a/drivers/cpuidle/cpuidle-zynq.c b/drivers/cpuidle/cpuidle-zynq.c
new file mode 100644
index 000000000000..38e03a183591
--- /dev/null
+++ b/drivers/cpuidle/cpuidle-zynq.c
@@ -0,0 +1,83 @@
1/*
2 * Copyright (C) 2012-2013 Xilinx
3 *
4 * CPU idle support for Xilinx Zynq
5 *
6 * based on arch/arm/mach-at91/cpuidle.c
7 *
8 * This program is free software; you can redistribute it and/or modify it
9 * under the terms and conditions of the GNU General Public License,
10 * version 2, as published by the Free Software Foundation.
11 *
12 * This program is distributed in the hope it will be useful, but WITHOUT
13 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
15 * more details.
16 *
17 * You should have received a copy of the GNU General Public License along with
18 * this program. If not, see <http://www.gnu.org/licenses/>.
19 *
20 * The cpu idle uses wait-for-interrupt and RAM self refresh in order
21 * to implement two idle states -
22 * #1 wait-for-interrupt
23 * #2 wait-for-interrupt and RAM self refresh
24 *
25 * Maintainer: Michal Simek <michal.simek@xilinx.com>
26 */
27
28#include <linux/init.h>
29#include <linux/cpu_pm.h>
30#include <linux/cpuidle.h>
31#include <linux/of.h>
32#include <asm/proc-fns.h>
33#include <asm/cpuidle.h>
34
35#define ZYNQ_MAX_STATES 2
36
37/* Actual code that puts the SoC in different idle states */
38static int zynq_enter_idle(struct cpuidle_device *dev,
39 struct cpuidle_driver *drv, int index)
40{
41 /* Devices must be stopped here */
42 cpu_pm_enter();
43
44 /* Add code for DDR self refresh start */
45 cpu_do_idle();
46
47 /* Add code for DDR self refresh stop */
48 cpu_pm_exit();
49
50 return index;
51}
52
53static struct cpuidle_driver zynq_idle_driver = {
54 .name = "zynq_idle",
55 .owner = THIS_MODULE,
56 .states = {
57 ARM_CPUIDLE_WFI_STATE,
58 {
59 .enter = zynq_enter_idle,
60 .exit_latency = 10,
61 .target_residency = 10000,
62 .flags = CPUIDLE_FLAG_TIME_VALID |
63 CPUIDLE_FLAG_TIMER_STOP,
64 .name = "RAM_SR",
65 .desc = "WFI and RAM Self Refresh",
66 },
67 },
68 .safe_state_index = 0,
69 .state_count = ZYNQ_MAX_STATES,
70};
71
72/* Initialize CPU idle by registering the idle states */
73static int __init zynq_cpuidle_init(void)
74{
75 if (!of_machine_is_compatible("xlnx,zynq-7000"))
76 return -ENODEV;
77
78 pr_info("Xilinx Zynq CpuIdle Driver started\n");
79
80 return cpuidle_register(&zynq_idle_driver, NULL);
81}
82
83device_initcall(zynq_cpuidle_init);