cpuidle-powernv.c (92a578b064d0227a3a7fbbdb9e29dbab7f8d400e) cpuidle-powernv.c (8eb8ac89a364305d05ad16be983b7890eb462cc3)
1/*
2 * cpuidle-powernv - idle state cpuidle driver.
3 * Adapted from drivers/cpuidle/cpuidle-pseries
4 *
5 */
6
7#include <linux/kernel.h>
8#include <linux/module.h>
9#include <linux/init.h>
10#include <linux/moduleparam.h>
11#include <linux/cpuidle.h>
12#include <linux/cpu.h>
13#include <linux/notifier.h>
14#include <linux/clockchips.h>
15#include <linux/of.h>
16
17#include <asm/machdep.h>
18#include <asm/firmware.h>
1/*
2 * cpuidle-powernv - idle state cpuidle driver.
3 * Adapted from drivers/cpuidle/cpuidle-pseries
4 *
5 */
6
7#include <linux/kernel.h>
8#include <linux/module.h>
9#include <linux/init.h>
10#include <linux/moduleparam.h>
11#include <linux/cpuidle.h>
12#include <linux/cpu.h>
13#include <linux/notifier.h>
14#include <linux/clockchips.h>
15#include <linux/of.h>
16
17#include <asm/machdep.h>
18#include <asm/firmware.h>
19#include <asm/opal.h>
19#include <asm/runlatch.h>
20
20#include <asm/runlatch.h>
21
21/* Flags and constants used in PowerNV platform */
22
23#define MAX_POWERNV_IDLE_STATES 8
22#define MAX_POWERNV_IDLE_STATES 8
24#define IDLE_USE_INST_NAP 0x00010000 /* Use nap instruction */
25#define IDLE_USE_INST_SLEEP 0x00020000 /* Use sleep instruction */
26
27struct cpuidle_driver powernv_idle_driver = {
28 .name = "powernv_idle",
29 .owner = THIS_MODULE,
30};
31
32static int max_idle_state;
33static struct cpuidle_state *cpuidle_state_table;

--- 54 unchanged lines hidden (view full) ---

88
89/*
90 * States for dedicated partition case.
91 */
92static struct cpuidle_state powernv_states[MAX_POWERNV_IDLE_STATES] = {
93 { /* Snooze */
94 .name = "snooze",
95 .desc = "snooze",
23
24struct cpuidle_driver powernv_idle_driver = {
25 .name = "powernv_idle",
26 .owner = THIS_MODULE,
27};
28
29static int max_idle_state;
30static struct cpuidle_state *cpuidle_state_table;

--- 54 unchanged lines hidden (view full) ---

85
86/*
87 * States for dedicated partition case.
88 */
89static struct cpuidle_state powernv_states[MAX_POWERNV_IDLE_STATES] = {
90 { /* Snooze */
91 .name = "snooze",
92 .desc = "snooze",
93 .flags = CPUIDLE_FLAG_TIME_VALID,
96 .exit_latency = 0,
97 .target_residency = 0,
98 .enter = &snooze_loop },
99};
100
101static int powernv_cpuidle_add_cpu_notifier(struct notifier_block *n,
102 unsigned long action, void *hcpu)
103{

--- 88 unchanged lines hidden (view full) ---

192 for (i = 0; i < dt_idle_states; i++) {
193
194 flags = be32_to_cpu(idle_state_flags[i]);
195
196 /* Cpuidle accepts exit_latency in us and we estimate
197 * target residency to be 10x exit_latency
198 */
199 latency_ns = be32_to_cpu(idle_state_latency[i]);
94 .exit_latency = 0,
95 .target_residency = 0,
96 .enter = &snooze_loop },
97};
98
99static int powernv_cpuidle_add_cpu_notifier(struct notifier_block *n,
100 unsigned long action, void *hcpu)
101{

--- 88 unchanged lines hidden (view full) ---

190 for (i = 0; i < dt_idle_states; i++) {
191
192 flags = be32_to_cpu(idle_state_flags[i]);
193
194 /* Cpuidle accepts exit_latency in us and we estimate
195 * target residency to be 10x exit_latency
196 */
197 latency_ns = be32_to_cpu(idle_state_latency[i]);
200 if (flags & IDLE_USE_INST_NAP) {
198 if (flags & OPAL_PM_NAP_ENABLED) {
201 /* Add NAP state */
202 strcpy(powernv_states[nr_idle_states].name, "Nap");
203 strcpy(powernv_states[nr_idle_states].desc, "Nap");
199 /* Add NAP state */
200 strcpy(powernv_states[nr_idle_states].name, "Nap");
201 strcpy(powernv_states[nr_idle_states].desc, "Nap");
204 powernv_states[nr_idle_states].flags = 0;
202 powernv_states[nr_idle_states].flags = CPUIDLE_FLAG_TIME_VALID;
205 powernv_states[nr_idle_states].exit_latency =
206 ((unsigned int)latency_ns) / 1000;
207 powernv_states[nr_idle_states].target_residency =
208 ((unsigned int)latency_ns / 100);
209 powernv_states[nr_idle_states].enter = &nap_loop;
210 nr_idle_states++;
211 }
212
203 powernv_states[nr_idle_states].exit_latency =
204 ((unsigned int)latency_ns) / 1000;
205 powernv_states[nr_idle_states].target_residency =
206 ((unsigned int)latency_ns / 100);
207 powernv_states[nr_idle_states].enter = &nap_loop;
208 nr_idle_states++;
209 }
210
213 if (flags & IDLE_USE_INST_SLEEP) {
211 if (flags & OPAL_PM_SLEEP_ENABLED) {
214 /* Add FASTSLEEP state */
215 strcpy(powernv_states[nr_idle_states].name, "FastSleep");
216 strcpy(powernv_states[nr_idle_states].desc, "FastSleep");
212 /* Add FASTSLEEP state */
213 strcpy(powernv_states[nr_idle_states].name, "FastSleep");
214 strcpy(powernv_states[nr_idle_states].desc, "FastSleep");
217 powernv_states[nr_idle_states].flags = CPUIDLE_FLAG_TIMER_STOP;
215 powernv_states[nr_idle_states].flags =
216 CPUIDLE_FLAG_TIME_VALID | CPUIDLE_FLAG_TIMER_STOP;
218 powernv_states[nr_idle_states].exit_latency =
219 ((unsigned int)latency_ns) / 1000;
220 powernv_states[nr_idle_states].target_residency =
221 ((unsigned int)latency_ns / 100);
222 powernv_states[nr_idle_states].enter = &fastsleep_loop;
223 nr_idle_states++;
224 }
225 }

--- 44 unchanged lines hidden ---
217 powernv_states[nr_idle_states].exit_latency =
218 ((unsigned int)latency_ns) / 1000;
219 powernv_states[nr_idle_states].target_residency =
220 ((unsigned int)latency_ns / 100);
221 powernv_states[nr_idle_states].enter = &fastsleep_loop;
222 nr_idle_states++;
223 }
224 }

--- 44 unchanged lines hidden ---