aboutsummaryrefslogtreecommitdiffstats
path: root/arch/sh/kernel/cpu/shmobile
diff options
context:
space:
mode:
Diffstat (limited to 'arch/sh/kernel/cpu/shmobile')
-rw-r--r--arch/sh/kernel/cpu/shmobile/cpuidle.c28
1 files changed, 17 insertions, 11 deletions
diff --git a/arch/sh/kernel/cpu/shmobile/cpuidle.c b/arch/sh/kernel/cpu/shmobile/cpuidle.c
index e4469e7233cb..ad1012ad6b42 100644
--- a/arch/sh/kernel/cpu/shmobile/cpuidle.c
+++ b/arch/sh/kernel/cpu/shmobile/cpuidle.c
@@ -25,11 +25,12 @@ static unsigned long cpuidle_mode[] = {
25}; 25};
26 26
27static int cpuidle_sleep_enter(struct cpuidle_device *dev, 27static int cpuidle_sleep_enter(struct cpuidle_device *dev,
28 struct cpuidle_state *state) 28 struct cpuidle_driver *drv,
29 int index)
29{ 30{
30 unsigned long allowed_mode = arch_hwblk_sleep_mode(); 31 unsigned long allowed_mode = arch_hwblk_sleep_mode();
31 ktime_t before, after; 32 ktime_t before, after;
32 int requested_state = state - &dev->states[0]; 33 int requested_state = index;
33 int allowed_state; 34 int allowed_state;
34 int k; 35 int k;
35 36
@@ -46,11 +47,13 @@ static int cpuidle_sleep_enter(struct cpuidle_device *dev,
46 */ 47 */
47 k = min_t(int, allowed_state, requested_state); 48 k = min_t(int, allowed_state, requested_state);
48 49
49 dev->last_state = &dev->states[k];
50 before = ktime_get(); 50 before = ktime_get();
51 sh_mobile_call_standby(cpuidle_mode[k]); 51 sh_mobile_call_standby(cpuidle_mode[k]);
52 after = ktime_get(); 52 after = ktime_get();
53 return ktime_to_ns(ktime_sub(after, before)) >> 10; 53
54 dev->last_residency = (int)ktime_to_ns(ktime_sub(after, before)) >> 10;
55
56 return k;
54} 57}
55 58
56static struct cpuidle_device cpuidle_dev; 59static struct cpuidle_device cpuidle_dev;
@@ -62,19 +65,19 @@ static struct cpuidle_driver cpuidle_driver = {
62void sh_mobile_setup_cpuidle(void) 65void sh_mobile_setup_cpuidle(void)
63{ 66{
64 struct cpuidle_device *dev = &cpuidle_dev; 67 struct cpuidle_device *dev = &cpuidle_dev;
68 struct cpuidle_driver *drv = &cpuidle_driver;
65 struct cpuidle_state *state; 69 struct cpuidle_state *state;
66 int i; 70 int i;
67 71
68 cpuidle_register_driver(&cpuidle_driver);
69 72
70 for (i = 0; i < CPUIDLE_STATE_MAX; i++) { 73 for (i = 0; i < CPUIDLE_STATE_MAX; i++) {
71 dev->states[i].name[0] = '\0'; 74 drv->states[i].name[0] = '\0';
72 dev->states[i].desc[0] = '\0'; 75 drv->states[i].desc[0] = '\0';
73 } 76 }
74 77
75 i = CPUIDLE_DRIVER_STATE_START; 78 i = CPUIDLE_DRIVER_STATE_START;
76 79
77 state = &dev->states[i++]; 80 state = &drv->states[i++];
78 snprintf(state->name, CPUIDLE_NAME_LEN, "C1"); 81 snprintf(state->name, CPUIDLE_NAME_LEN, "C1");
79 strncpy(state->desc, "SuperH Sleep Mode", CPUIDLE_DESC_LEN); 82 strncpy(state->desc, "SuperH Sleep Mode", CPUIDLE_DESC_LEN);
80 state->exit_latency = 1; 83 state->exit_latency = 1;
@@ -84,10 +87,10 @@ void sh_mobile_setup_cpuidle(void)
84 state->flags |= CPUIDLE_FLAG_TIME_VALID; 87 state->flags |= CPUIDLE_FLAG_TIME_VALID;
85 state->enter = cpuidle_sleep_enter; 88 state->enter = cpuidle_sleep_enter;
86 89
87 dev->safe_state = state; 90 drv->safe_state_index = i-1;
88 91
89 if (sh_mobile_sleep_supported & SUSP_SH_SF) { 92 if (sh_mobile_sleep_supported & SUSP_SH_SF) {
90 state = &dev->states[i++]; 93 state = &drv->states[i++];
91 snprintf(state->name, CPUIDLE_NAME_LEN, "C2"); 94 snprintf(state->name, CPUIDLE_NAME_LEN, "C2");
92 strncpy(state->desc, "SuperH Sleep Mode [SF]", 95 strncpy(state->desc, "SuperH Sleep Mode [SF]",
93 CPUIDLE_DESC_LEN); 96 CPUIDLE_DESC_LEN);
@@ -100,7 +103,7 @@ void sh_mobile_setup_cpuidle(void)
100 } 103 }
101 104
102 if (sh_mobile_sleep_supported & SUSP_SH_STANDBY) { 105 if (sh_mobile_sleep_supported & SUSP_SH_STANDBY) {
103 state = &dev->states[i++]; 106 state = &drv->states[i++];
104 snprintf(state->name, CPUIDLE_NAME_LEN, "C3"); 107 snprintf(state->name, CPUIDLE_NAME_LEN, "C3");
105 strncpy(state->desc, "SuperH Mobile Standby Mode [SF]", 108 strncpy(state->desc, "SuperH Mobile Standby Mode [SF]",
106 CPUIDLE_DESC_LEN); 109 CPUIDLE_DESC_LEN);
@@ -112,7 +115,10 @@ void sh_mobile_setup_cpuidle(void)
112 state->enter = cpuidle_sleep_enter; 115 state->enter = cpuidle_sleep_enter;
113 } 116 }
114 117
118 drv->state_count = i;
115 dev->state_count = i; 119 dev->state_count = i;
116 120
121 cpuidle_register_driver(&cpuidle_driver);
122
117 cpuidle_register_device(dev); 123 cpuidle_register_device(dev);
118} 124}