aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/cpuidle
diff options
context:
space:
mode:
authorRafael J. Wysocki <rafael.j.wysocki@intel.com>2013-07-27 08:19:53 -0400
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>2013-07-27 08:19:53 -0400
commit9aadfa8fd9f8d311ba3014bf76e4d8aeee515533 (patch)
treea34c6fb208a5994438efa935466e4e0b1e730551 /drivers/cpuidle
parent9ec7684c976bc528c2f37bbc0045fab28d16d172 (diff)
parentbe100ee83a812804d1f467f45aba9809ba49b732 (diff)
Merge branch 'cpuidle-arm' into pm-cpuidle
* cpuidle-arm: ARM: ux500: cpuidle: Move ux500 cpuidle driver to drivers/cpuidle ARM: ux500: cpuidle: Remove pointless include ARM: ux500: cpuidle: Instantiate the driver from platform device ARM: davinci: cpuidle: Fix target residency cpuidle: Add Kconfig.arm and move calxeda, kirkwood and zynq
Diffstat (limited to 'drivers/cpuidle')
-rw-r--r--drivers/cpuidle/Kconfig20
-rw-r--r--drivers/cpuidle/Kconfig.arm29
-rw-r--r--drivers/cpuidle/Makefile9
-rw-r--r--drivers/cpuidle/cpuidle-ux500.c131
4 files changed, 173 insertions, 16 deletions
diff --git a/drivers/cpuidle/Kconfig b/drivers/cpuidle/Kconfig
index 0e2cd5cab4d0..b3fb81d7cf04 100644
--- a/drivers/cpuidle/Kconfig
+++ b/drivers/cpuidle/Kconfig
@@ -1,5 +1,6 @@
1menu "CPU Idle"
1 2
2menuconfig CPU_IDLE 3config CPU_IDLE
3 bool "CPU idle PM support" 4 bool "CPU idle PM support"
4 default y if ACPI || PPC_PSERIES 5 default y if ACPI || PPC_PSERIES
5 select CPU_IDLE_GOV_LADDER if (!NO_HZ && !NO_HZ_IDLE) 6 select CPU_IDLE_GOV_LADDER if (!NO_HZ && !NO_HZ_IDLE)
@@ -29,20 +30,13 @@ config CPU_IDLE_GOV_MENU
29 bool "Menu governor (for tickless system)" 30 bool "Menu governor (for tickless system)"
30 default y 31 default y
31 32
32config CPU_IDLE_CALXEDA 33menu "ARM CPU Idle Drivers"
33 bool "CPU Idle Driver for Calxeda processors" 34depends on ARM
34 depends on ARCH_HIGHBANK 35source "drivers/cpuidle/Kconfig.arm"
35 select ARM_CPU_SUSPEND 36endmenu
36 help
37 Select this to enable cpuidle on Calxeda processors.
38
39config CPU_IDLE_ZYNQ
40 bool "CPU Idle Driver for Xilinx Zynq processors"
41 depends on ARCH_ZYNQ
42 help
43 Select this to enable cpuidle on Xilinx Zynq processors.
44 37
45endif 38endif
46 39
47config ARCH_NEEDS_CPU_IDLE_COUPLED 40config ARCH_NEEDS_CPU_IDLE_COUPLED
48 def_bool n 41 def_bool n
42endmenu
diff --git a/drivers/cpuidle/Kconfig.arm b/drivers/cpuidle/Kconfig.arm
new file mode 100644
index 000000000000..b3302193c15a
--- /dev/null
+++ b/drivers/cpuidle/Kconfig.arm
@@ -0,0 +1,29 @@
1#
2# ARM CPU Idle drivers
3#
4
5config ARM_HIGHBANK_CPUIDLE
6 bool "CPU Idle Driver for Calxeda processors"
7 depends on ARCH_HIGHBANK
8 select ARM_CPU_SUSPEND
9 help
10 Select this to enable cpuidle on Calxeda processors.
11
12config ARM_KIRKWOOD_CPUIDLE
13 bool "CPU Idle Driver for Marvell Kirkwood SoCs"
14 depends on ARCH_KIRKWOOD
15 help
16 This adds the CPU Idle driver for Marvell Kirkwood SoCs.
17
18config ARM_ZYNQ_CPUIDLE
19 bool "CPU Idle Driver for Xilinx Zynq processors"
20 depends on ARCH_ZYNQ
21 help
22 Select this to enable cpuidle on Xilinx Zynq processors.
23
24config ARM_U8500_CPUIDLE
25 bool "Cpu Idle Driver for the ST-E u8500 processors"
26 depends on ARCH_U8500
27 help
28 Select this to enable cpuidle for ST-E u8500 processors
29
diff --git a/drivers/cpuidle/Makefile b/drivers/cpuidle/Makefile
index 8767a7b3eb91..0b9d200c7e45 100644
--- a/drivers/cpuidle/Makefile
+++ b/drivers/cpuidle/Makefile
@@ -5,6 +5,9 @@
5obj-y += cpuidle.o driver.o governor.o sysfs.o governors/ 5obj-y += cpuidle.o driver.o governor.o sysfs.o governors/
6obj-$(CONFIG_ARCH_NEEDS_CPU_IDLE_COUPLED) += coupled.o 6obj-$(CONFIG_ARCH_NEEDS_CPU_IDLE_COUPLED) += coupled.o
7 7
8obj-$(CONFIG_CPU_IDLE_CALXEDA) += cpuidle-calxeda.o 8##################################################################################
9obj-$(CONFIG_ARCH_KIRKWOOD) += cpuidle-kirkwood.o 9# ARM SoC drivers
10obj-$(CONFIG_CPU_IDLE_ZYNQ) += cpuidle-zynq.o 10obj-$(CONFIG_ARM_HIGHBANK_CPUIDLE) += cpuidle-calxeda.o
11obj-$(CONFIG_ARM_KIRKWOOD_CPUIDLE) += cpuidle-kirkwood.o
12obj-$(CONFIG_ARM_ZYNQ_CPUIDLE) += cpuidle-zynq.o
13obj-$(CONFIG_ARM_U8500_CPUIDLE) += cpuidle-ux500.o
diff --git a/drivers/cpuidle/cpuidle-ux500.c b/drivers/cpuidle/cpuidle-ux500.c
new file mode 100644
index 000000000000..e0564652af35
--- /dev/null
+++ b/drivers/cpuidle/cpuidle-ux500.c
@@ -0,0 +1,131 @@
1/*
2 * Copyright (c) 2012 Linaro : Daniel Lezcano <daniel.lezcano@linaro.org> (IBM)
3 *
4 * Based on the work of Rickard Andersson <rickard.andersson@stericsson.com>
5 * and Jonas Aaberg <jonas.aberg@stericsson.com>.
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
10 */
11
12#include <linux/module.h>
13#include <linux/cpuidle.h>
14#include <linux/spinlock.h>
15#include <linux/atomic.h>
16#include <linux/smp.h>
17#include <linux/mfd/dbx500-prcmu.h>
18#include <linux/platform_data/arm-ux500-pm.h>
19#include <linux/platform_device.h>
20
21#include <asm/cpuidle.h>
22#include <asm/proc-fns.h>
23
24static atomic_t master = ATOMIC_INIT(0);
25static DEFINE_SPINLOCK(master_lock);
26
27static inline int ux500_enter_idle(struct cpuidle_device *dev,
28 struct cpuidle_driver *drv, int index)
29{
30 int this_cpu = smp_processor_id();
31 bool recouple = false;
32
33 if (atomic_inc_return(&master) == num_online_cpus()) {
34
35 /* With this lock, we prevent the other cpu to exit and enter
36 * this function again and become the master */
37 if (!spin_trylock(&master_lock))
38 goto wfi;
39
40 /* decouple the gic from the A9 cores */
41 if (prcmu_gic_decouple()) {
42 spin_unlock(&master_lock);
43 goto out;
44 }
45
46 /* If an error occur, we will have to recouple the gic
47 * manually */
48 recouple = true;
49
50 /* At this state, as the gic is decoupled, if the other
51 * cpu is in WFI, we have the guarantee it won't be wake
52 * up, so we can safely go to retention */
53 if (!prcmu_is_cpu_in_wfi(this_cpu ? 0 : 1))
54 goto out;
55
56 /* The prcmu will be in charge of watching the interrupts
57 * and wake up the cpus */
58 if (prcmu_copy_gic_settings())
59 goto out;
60
61 /* Check in the meantime an interrupt did
62 * not occur on the gic ... */
63 if (prcmu_gic_pending_irq())
64 goto out;
65
66 /* ... and the prcmu */
67 if (prcmu_pending_irq())
68 goto out;
69
70 /* Go to the retention state, the prcmu will wait for the
71 * cpu to go WFI and this is what happens after exiting this
72 * 'master' critical section */
73 if (prcmu_set_power_state(PRCMU_AP_IDLE, true, true))
74 goto out;
75
76 /* When we switch to retention, the prcmu is in charge
77 * of recoupling the gic automatically */
78 recouple = false;
79
80 spin_unlock(&master_lock);
81 }
82wfi:
83 cpu_do_idle();
84out:
85 atomic_dec(&master);
86
87 if (recouple) {
88 prcmu_gic_recouple();
89 spin_unlock(&master_lock);
90 }
91
92 return index;
93}
94
95static struct cpuidle_driver ux500_idle_driver = {
96 .name = "ux500_idle",
97 .owner = THIS_MODULE,
98 .states = {
99 ARM_CPUIDLE_WFI_STATE,
100 {
101 .enter = ux500_enter_idle,
102 .exit_latency = 70,
103 .target_residency = 260,
104 .flags = CPUIDLE_FLAG_TIME_VALID |
105 CPUIDLE_FLAG_TIMER_STOP,
106 .name = "ApIdle",
107 .desc = "ARM Retention",
108 },
109 },
110 .safe_state_index = 0,
111 .state_count = 2,
112};
113
114static int __init dbx500_cpuidle_probe(struct platform_device *pdev)
115{
116 /* Configure wake up reasons */
117 prcmu_enable_wakeups(PRCMU_WAKEUP(ARM) | PRCMU_WAKEUP(RTC) |
118 PRCMU_WAKEUP(ABB));
119
120 return cpuidle_register(&ux500_idle_driver, NULL);
121}
122
123static struct platform_driver dbx500_cpuidle_plat_driver = {
124 .driver = {
125 .name = "cpuidle-dbx500",
126 .owner = THIS_MODULE,
127 },
128 .probe = dbx500_cpuidle_probe,
129};
130
131module_platform_driver(dbx500_cpuidle_plat_driver);