Rajendra Nayak | 99e6a4d | 2008-10-08 17:30:58 +0530 | [diff] [blame] | 1 | /* |
| 2 | * linux/arch/arm/mach-omap2/cpuidle34xx.c |
| 3 | * |
| 4 | * OMAP3 CPU IDLE Routines |
| 5 | * |
| 6 | * Copyright (C) 2008 Texas Instruments, Inc. |
| 7 | * Rajendra Nayak <rnayak@ti.com> |
| 8 | * |
| 9 | * Copyright (C) 2007 Texas Instruments, Inc. |
| 10 | * Karthik Dasu <karthik-dp@ti.com> |
| 11 | * |
| 12 | * Copyright (C) 2006 Nokia Corporation |
| 13 | * Tony Lindgren <tony@atomide.com> |
| 14 | * |
| 15 | * Copyright (C) 2005 Texas Instruments, Inc. |
| 16 | * Richard Woodruff <r-woodruff2@ti.com> |
| 17 | * |
| 18 | * Based on pm.c for omap2 |
| 19 | * |
| 20 | * This program is free software; you can redistribute it and/or modify |
| 21 | * it under the terms of the GNU General Public License version 2 as |
| 22 | * published by the Free Software Foundation. |
| 23 | */ |
| 24 | |
Tero Kristo | cf22854 | 2009-03-20 15:21:02 +0200 | [diff] [blame^] | 25 | #include <linux/sched.h> |
Rajendra Nayak | 99e6a4d | 2008-10-08 17:30:58 +0530 | [diff] [blame] | 26 | #include <linux/cpuidle.h> |
| 27 | |
| 28 | #include <plat/prcm.h> |
Rajendra Nayak | 20b0166 | 2008-10-08 17:31:22 +0530 | [diff] [blame] | 29 | #include <plat/irqs.h> |
Peter 'p2' De Schrijver | 06d8f06 | 2009-03-13 18:19:16 +0200 | [diff] [blame] | 30 | #include <plat/powerdomain.h> |
| 31 | #include <plat/clockdomain.h> |
Rajendra Nayak | 20b0166 | 2008-10-08 17:31:22 +0530 | [diff] [blame] | 32 | #include <plat/control.h> |
Kevin Hilman | 0f724ed | 2008-10-28 17:32:11 -0700 | [diff] [blame] | 33 | #include <plat/serial.h> |
Rajendra Nayak | 99e6a4d | 2008-10-08 17:30:58 +0530 | [diff] [blame] | 34 | |
Kevin Hilman | c98e223 | 2008-10-28 17:30:07 -0700 | [diff] [blame] | 35 | #include "pm.h" |
| 36 | |
Rajendra Nayak | 99e6a4d | 2008-10-08 17:30:58 +0530 | [diff] [blame] | 37 | #ifdef CONFIG_CPU_IDLE |
| 38 | |
Sanjeev Premi | 8e431ed | 2009-03-13 21:34:25 +0530 | [diff] [blame] | 39 | #define OMAP3_MAX_STATES 7 |
| 40 | #define OMAP3_STATE_C1 0 /* C1 - MPU WFI + Core active */ |
| 41 | #define OMAP3_STATE_C2 1 /* C2 - MPU WFI + Core inactive */ |
| 42 | #define OMAP3_STATE_C3 2 /* C3 - MPU CSWR + Core inactive */ |
| 43 | #define OMAP3_STATE_C4 3 /* C4 - MPU OFF + Core iactive */ |
| 44 | #define OMAP3_STATE_C5 4 /* C5 - MPU RET + Core RET */ |
| 45 | #define OMAP3_STATE_C6 5 /* C6 - MPU OFF + Core RET */ |
| 46 | #define OMAP3_STATE_C7 6 /* C7 - MPU OFF + Core OFF */ |
Rajendra Nayak | 99e6a4d | 2008-10-08 17:30:58 +0530 | [diff] [blame] | 47 | |
| 48 | struct omap3_processor_cx { |
| 49 | u8 valid; |
| 50 | u8 type; |
| 51 | u32 sleep_latency; |
| 52 | u32 wakeup_latency; |
| 53 | u32 mpu_state; |
| 54 | u32 core_state; |
| 55 | u32 threshold; |
| 56 | u32 flags; |
| 57 | }; |
| 58 | |
| 59 | struct omap3_processor_cx omap3_power_states[OMAP3_MAX_STATES]; |
| 60 | struct omap3_processor_cx current_cx_state; |
Rajendra Nayak | 20b0166 | 2008-10-08 17:31:22 +0530 | [diff] [blame] | 61 | struct powerdomain *mpu_pd, *core_pd; |
Rajendra Nayak | 99e6a4d | 2008-10-08 17:30:58 +0530 | [diff] [blame] | 62 | |
| 63 | static int omap3_idle_bm_check(void) |
| 64 | { |
Rajendra Nayak | 20b0166 | 2008-10-08 17:31:22 +0530 | [diff] [blame] | 65 | if (!omap3_can_sleep()) |
| 66 | return 1; |
Rajendra Nayak | 99e6a4d | 2008-10-08 17:30:58 +0530 | [diff] [blame] | 67 | return 0; |
| 68 | } |
| 69 | |
Peter 'p2' De Schrijver | 06d8f06 | 2009-03-13 18:19:16 +0200 | [diff] [blame] | 70 | static int _cpuidle_allow_idle(struct powerdomain *pwrdm, |
| 71 | struct clockdomain *clkdm) |
| 72 | { |
| 73 | omap2_clkdm_allow_idle(clkdm); |
| 74 | return 0; |
| 75 | } |
| 76 | |
| 77 | static int _cpuidle_deny_idle(struct powerdomain *pwrdm, |
| 78 | struct clockdomain *clkdm) |
| 79 | { |
| 80 | omap2_clkdm_deny_idle(clkdm); |
| 81 | return 0; |
| 82 | } |
| 83 | |
Rajendra Nayak | 99e6a4d | 2008-10-08 17:30:58 +0530 | [diff] [blame] | 84 | /** |
| 85 | * omap3_enter_idle - Programs OMAP3 to enter the specified state |
| 86 | * @dev: cpuidle device |
| 87 | * @state: The target state to be programmed |
| 88 | * |
| 89 | * Called from the CPUidle framework to program the device to the |
| 90 | * specified target state selected by the governor. |
| 91 | */ |
| 92 | static int omap3_enter_idle(struct cpuidle_device *dev, |
| 93 | struct cpuidle_state *state) |
| 94 | { |
| 95 | struct omap3_processor_cx *cx = cpuidle_get_statedata(state); |
| 96 | struct timespec ts_preidle, ts_postidle, ts_idle; |
Kevin Hilman | c98e223 | 2008-10-28 17:30:07 -0700 | [diff] [blame] | 97 | u32 mpu_state = cx->mpu_state, core_state = cx->core_state; |
Rajendra Nayak | 99e6a4d | 2008-10-08 17:30:58 +0530 | [diff] [blame] | 98 | |
| 99 | current_cx_state = *cx; |
| 100 | |
| 101 | /* Used to keep track of the total time in idle */ |
| 102 | getnstimeofday(&ts_preidle); |
| 103 | |
| 104 | local_irq_disable(); |
| 105 | local_fiq_disable(); |
| 106 | |
Kevin Hilman | c98e223 | 2008-10-28 17:30:07 -0700 | [diff] [blame] | 107 | if (!enable_off_mode) { |
| 108 | if (mpu_state < PWRDM_POWER_RET) |
| 109 | mpu_state = PWRDM_POWER_RET; |
| 110 | if (core_state < PWRDM_POWER_RET) |
| 111 | core_state = PWRDM_POWER_RET; |
| 112 | } |
| 113 | |
Jouni Hogander | 7139178 | 2008-10-28 10:59:05 +0200 | [diff] [blame] | 114 | pwrdm_set_next_pwrst(mpu_pd, mpu_state); |
| 115 | pwrdm_set_next_pwrst(core_pd, core_state); |
Rajendra Nayak | 20b0166 | 2008-10-08 17:31:22 +0530 | [diff] [blame] | 116 | |
Tero Kristo | cf22854 | 2009-03-20 15:21:02 +0200 | [diff] [blame^] | 117 | if (omap_irq_pending() || need_resched()) |
Rajendra Nayak | 20b0166 | 2008-10-08 17:31:22 +0530 | [diff] [blame] | 118 | goto return_sleep_time; |
Rajendra Nayak | 99e6a4d | 2008-10-08 17:30:58 +0530 | [diff] [blame] | 119 | |
Peter 'p2' De Schrijver | 06d8f06 | 2009-03-13 18:19:16 +0200 | [diff] [blame] | 120 | if (cx->type == OMAP3_STATE_C1) { |
| 121 | pwrdm_for_each_clkdm(mpu_pd, _cpuidle_deny_idle); |
| 122 | pwrdm_for_each_clkdm(core_pd, _cpuidle_deny_idle); |
| 123 | } |
| 124 | |
Rajendra Nayak | 99e6a4d | 2008-10-08 17:30:58 +0530 | [diff] [blame] | 125 | /* Execute ARM wfi */ |
| 126 | omap_sram_idle(); |
| 127 | |
Peter 'p2' De Schrijver | 06d8f06 | 2009-03-13 18:19:16 +0200 | [diff] [blame] | 128 | if (cx->type == OMAP3_STATE_C1) { |
| 129 | pwrdm_for_each_clkdm(mpu_pd, _cpuidle_allow_idle); |
| 130 | pwrdm_for_each_clkdm(core_pd, _cpuidle_allow_idle); |
| 131 | } |
| 132 | |
Rajendra Nayak | 20b0166 | 2008-10-08 17:31:22 +0530 | [diff] [blame] | 133 | return_sleep_time: |
Rajendra Nayak | 99e6a4d | 2008-10-08 17:30:58 +0530 | [diff] [blame] | 134 | getnstimeofday(&ts_postidle); |
| 135 | ts_idle = timespec_sub(ts_postidle, ts_preidle); |
| 136 | |
| 137 | local_irq_enable(); |
| 138 | local_fiq_enable(); |
| 139 | |
Rajendra Nayak | 20b0166 | 2008-10-08 17:31:22 +0530 | [diff] [blame] | 140 | return (u32)timespec_to_ns(&ts_idle)/1000; |
Rajendra Nayak | 99e6a4d | 2008-10-08 17:30:58 +0530 | [diff] [blame] | 141 | } |
| 142 | |
| 143 | /** |
| 144 | * omap3_enter_idle_bm - Checks for any bus activity |
| 145 | * @dev: cpuidle device |
| 146 | * @state: The target state to be programmed |
| 147 | * |
| 148 | * Used for C states with CPUIDLE_FLAG_CHECK_BM flag set. This |
| 149 | * function checks for any pending activity and then programs the |
| 150 | * device to the specified or a safer state. |
| 151 | */ |
| 152 | static int omap3_enter_idle_bm(struct cpuidle_device *dev, |
| 153 | struct cpuidle_state *state) |
| 154 | { |
Kevin Hilman | 0f724ed | 2008-10-28 17:32:11 -0700 | [diff] [blame] | 155 | struct cpuidle_state *new_state = state; |
| 156 | |
Rajendra Nayak | 99e6a4d | 2008-10-08 17:30:58 +0530 | [diff] [blame] | 157 | if ((state->flags & CPUIDLE_FLAG_CHECK_BM) && omap3_idle_bm_check()) { |
Kevin Hilman | 0f724ed | 2008-10-28 17:32:11 -0700 | [diff] [blame] | 158 | BUG_ON(!dev->safe_state); |
| 159 | new_state = dev->safe_state; |
Rajendra Nayak | 99e6a4d | 2008-10-08 17:30:58 +0530 | [diff] [blame] | 160 | } |
Kevin Hilman | 0f724ed | 2008-10-28 17:32:11 -0700 | [diff] [blame] | 161 | |
| 162 | dev->last_state = new_state; |
| 163 | return omap3_enter_idle(dev, new_state); |
Rajendra Nayak | 99e6a4d | 2008-10-08 17:30:58 +0530 | [diff] [blame] | 164 | } |
| 165 | |
| 166 | DEFINE_PER_CPU(struct cpuidle_device, omap3_idle_dev); |
| 167 | |
| 168 | /* omap3_init_power_states - Initialises the OMAP3 specific C states. |
| 169 | * |
| 170 | * Below is the desciption of each C state. |
Peter 'p2' De Schrijver | 06d8f06 | 2009-03-13 18:19:16 +0200 | [diff] [blame] | 171 | * C1 . MPU WFI + Core active |
| 172 | * C2 . MPU WFI + Core inactive |
| 173 | * C3 . MPU CSWR + Core inactive |
| 174 | * C4 . MPU OFF + Core inactive |
| 175 | * C5 . MPU CSWR + Core CSWR |
| 176 | * C6 . MPU OFF + Core CSWR |
| 177 | * C7 . MPU OFF + Core OFF |
Rajendra Nayak | 99e6a4d | 2008-10-08 17:30:58 +0530 | [diff] [blame] | 178 | */ |
| 179 | void omap_init_power_states(void) |
| 180 | { |
| 181 | /* C1 . MPU WFI + Core active */ |
| 182 | omap3_power_states[OMAP3_STATE_C1].valid = 1; |
| 183 | omap3_power_states[OMAP3_STATE_C1].type = OMAP3_STATE_C1; |
Peter 'p2' De Schrijver | 06d8f06 | 2009-03-13 18:19:16 +0200 | [diff] [blame] | 184 | omap3_power_states[OMAP3_STATE_C1].sleep_latency = 2; |
| 185 | omap3_power_states[OMAP3_STATE_C1].wakeup_latency = 2; |
| 186 | omap3_power_states[OMAP3_STATE_C1].threshold = 5; |
Rajendra Nayak | 99e6a4d | 2008-10-08 17:30:58 +0530 | [diff] [blame] | 187 | omap3_power_states[OMAP3_STATE_C1].mpu_state = PWRDM_POWER_ON; |
| 188 | omap3_power_states[OMAP3_STATE_C1].core_state = PWRDM_POWER_ON; |
| 189 | omap3_power_states[OMAP3_STATE_C1].flags = CPUIDLE_FLAG_TIME_VALID; |
| 190 | |
Peter 'p2' De Schrijver | 06d8f06 | 2009-03-13 18:19:16 +0200 | [diff] [blame] | 191 | /* C2 . MPU WFI + Core inactive */ |
Rajendra Nayak | 99e6a4d | 2008-10-08 17:30:58 +0530 | [diff] [blame] | 192 | omap3_power_states[OMAP3_STATE_C2].valid = 1; |
| 193 | omap3_power_states[OMAP3_STATE_C2].type = OMAP3_STATE_C2; |
Peter 'p2' De Schrijver | 06d8f06 | 2009-03-13 18:19:16 +0200 | [diff] [blame] | 194 | omap3_power_states[OMAP3_STATE_C2].sleep_latency = 10; |
| 195 | omap3_power_states[OMAP3_STATE_C2].wakeup_latency = 10; |
| 196 | omap3_power_states[OMAP3_STATE_C2].threshold = 30; |
| 197 | omap3_power_states[OMAP3_STATE_C2].mpu_state = PWRDM_POWER_ON; |
Rajendra Nayak | 99e6a4d | 2008-10-08 17:30:58 +0530 | [diff] [blame] | 198 | omap3_power_states[OMAP3_STATE_C2].core_state = PWRDM_POWER_ON; |
Peter 'p2' De Schrijver | 06d8f06 | 2009-03-13 18:19:16 +0200 | [diff] [blame] | 199 | omap3_power_states[OMAP3_STATE_C2].flags = CPUIDLE_FLAG_TIME_VALID; |
Rajendra Nayak | 99e6a4d | 2008-10-08 17:30:58 +0530 | [diff] [blame] | 200 | |
Peter 'p2' De Schrijver | 06d8f06 | 2009-03-13 18:19:16 +0200 | [diff] [blame] | 201 | /* C3 . MPU CSWR + Core inactive */ |
Rajendra Nayak | 20b0166 | 2008-10-08 17:31:22 +0530 | [diff] [blame] | 202 | omap3_power_states[OMAP3_STATE_C3].valid = 1; |
Rajendra Nayak | 99e6a4d | 2008-10-08 17:30:58 +0530 | [diff] [blame] | 203 | omap3_power_states[OMAP3_STATE_C3].type = OMAP3_STATE_C3; |
Peter 'p2' De Schrijver | 06d8f06 | 2009-03-13 18:19:16 +0200 | [diff] [blame] | 204 | omap3_power_states[OMAP3_STATE_C3].sleep_latency = 50; |
| 205 | omap3_power_states[OMAP3_STATE_C3].wakeup_latency = 50; |
| 206 | omap3_power_states[OMAP3_STATE_C3].threshold = 300; |
| 207 | omap3_power_states[OMAP3_STATE_C3].mpu_state = PWRDM_POWER_RET; |
Rajendra Nayak | 99e6a4d | 2008-10-08 17:30:58 +0530 | [diff] [blame] | 208 | omap3_power_states[OMAP3_STATE_C3].core_state = PWRDM_POWER_ON; |
Kevin Hilman | 0f724ed | 2008-10-28 17:32:11 -0700 | [diff] [blame] | 209 | omap3_power_states[OMAP3_STATE_C3].flags = CPUIDLE_FLAG_TIME_VALID | |
| 210 | CPUIDLE_FLAG_CHECK_BM; |
Rajendra Nayak | 99e6a4d | 2008-10-08 17:30:58 +0530 | [diff] [blame] | 211 | |
Peter 'p2' De Schrijver | 06d8f06 | 2009-03-13 18:19:16 +0200 | [diff] [blame] | 212 | /* C4 . MPU OFF + Core inactive */ |
Rajendra Nayak | 20b0166 | 2008-10-08 17:31:22 +0530 | [diff] [blame] | 213 | omap3_power_states[OMAP3_STATE_C4].valid = 1; |
Rajendra Nayak | 99e6a4d | 2008-10-08 17:30:58 +0530 | [diff] [blame] | 214 | omap3_power_states[OMAP3_STATE_C4].type = OMAP3_STATE_C4; |
Peter 'p2' De Schrijver | 06d8f06 | 2009-03-13 18:19:16 +0200 | [diff] [blame] | 215 | omap3_power_states[OMAP3_STATE_C4].sleep_latency = 1500; |
| 216 | omap3_power_states[OMAP3_STATE_C4].wakeup_latency = 1800; |
| 217 | omap3_power_states[OMAP3_STATE_C4].threshold = 4000; |
| 218 | omap3_power_states[OMAP3_STATE_C4].mpu_state = PWRDM_POWER_OFF; |
| 219 | omap3_power_states[OMAP3_STATE_C4].core_state = PWRDM_POWER_ON; |
Rajendra Nayak | 99e6a4d | 2008-10-08 17:30:58 +0530 | [diff] [blame] | 220 | omap3_power_states[OMAP3_STATE_C4].flags = CPUIDLE_FLAG_TIME_VALID | |
| 221 | CPUIDLE_FLAG_CHECK_BM; |
| 222 | |
Peter 'p2' De Schrijver | 06d8f06 | 2009-03-13 18:19:16 +0200 | [diff] [blame] | 223 | /* C5 . MPU CSWR + Core CSWR*/ |
Rajendra Nayak | 20b0166 | 2008-10-08 17:31:22 +0530 | [diff] [blame] | 224 | omap3_power_states[OMAP3_STATE_C5].valid = 1; |
Rajendra Nayak | 99e6a4d | 2008-10-08 17:30:58 +0530 | [diff] [blame] | 225 | omap3_power_states[OMAP3_STATE_C5].type = OMAP3_STATE_C5; |
Peter 'p2' De Schrijver | 06d8f06 | 2009-03-13 18:19:16 +0200 | [diff] [blame] | 226 | omap3_power_states[OMAP3_STATE_C5].sleep_latency = 2500; |
| 227 | omap3_power_states[OMAP3_STATE_C5].wakeup_latency = 7500; |
| 228 | omap3_power_states[OMAP3_STATE_C5].threshold = 12000; |
| 229 | omap3_power_states[OMAP3_STATE_C5].mpu_state = PWRDM_POWER_RET; |
Rajendra Nayak | 99e6a4d | 2008-10-08 17:30:58 +0530 | [diff] [blame] | 230 | omap3_power_states[OMAP3_STATE_C5].core_state = PWRDM_POWER_RET; |
| 231 | omap3_power_states[OMAP3_STATE_C5].flags = CPUIDLE_FLAG_TIME_VALID | |
| 232 | CPUIDLE_FLAG_CHECK_BM; |
| 233 | |
Peter 'p2' De Schrijver | 06d8f06 | 2009-03-13 18:19:16 +0200 | [diff] [blame] | 234 | /* C6 . MPU OFF + Core CSWR */ |
Kevin Hilman | 0f724ed | 2008-10-28 17:32:11 -0700 | [diff] [blame] | 235 | omap3_power_states[OMAP3_STATE_C6].valid = 1; |
Rajendra Nayak | 99e6a4d | 2008-10-08 17:30:58 +0530 | [diff] [blame] | 236 | omap3_power_states[OMAP3_STATE_C6].type = OMAP3_STATE_C6; |
Peter 'p2' De Schrijver | 06d8f06 | 2009-03-13 18:19:16 +0200 | [diff] [blame] | 237 | omap3_power_states[OMAP3_STATE_C6].sleep_latency = 3000; |
| 238 | omap3_power_states[OMAP3_STATE_C6].wakeup_latency = 8500; |
| 239 | omap3_power_states[OMAP3_STATE_C6].threshold = 15000; |
Rajendra Nayak | 99e6a4d | 2008-10-08 17:30:58 +0530 | [diff] [blame] | 240 | omap3_power_states[OMAP3_STATE_C6].mpu_state = PWRDM_POWER_OFF; |
Peter 'p2' De Schrijver | 06d8f06 | 2009-03-13 18:19:16 +0200 | [diff] [blame] | 241 | omap3_power_states[OMAP3_STATE_C6].core_state = PWRDM_POWER_RET; |
Rajendra Nayak | 99e6a4d | 2008-10-08 17:30:58 +0530 | [diff] [blame] | 242 | omap3_power_states[OMAP3_STATE_C6].flags = CPUIDLE_FLAG_TIME_VALID | |
| 243 | CPUIDLE_FLAG_CHECK_BM; |
Peter 'p2' De Schrijver | 06d8f06 | 2009-03-13 18:19:16 +0200 | [diff] [blame] | 244 | |
| 245 | /* C7 . MPU OFF + Core OFF */ |
| 246 | omap3_power_states[OMAP3_STATE_C7].valid = 1; |
| 247 | omap3_power_states[OMAP3_STATE_C7].type = OMAP3_STATE_C7; |
| 248 | omap3_power_states[OMAP3_STATE_C7].sleep_latency = 10000; |
| 249 | omap3_power_states[OMAP3_STATE_C7].wakeup_latency = 30000; |
| 250 | omap3_power_states[OMAP3_STATE_C7].threshold = 300000; |
| 251 | omap3_power_states[OMAP3_STATE_C7].mpu_state = PWRDM_POWER_OFF; |
| 252 | omap3_power_states[OMAP3_STATE_C7].core_state = PWRDM_POWER_OFF; |
| 253 | omap3_power_states[OMAP3_STATE_C7].flags = CPUIDLE_FLAG_TIME_VALID | |
| 254 | CPUIDLE_FLAG_CHECK_BM; |
Rajendra Nayak | 99e6a4d | 2008-10-08 17:30:58 +0530 | [diff] [blame] | 255 | } |
| 256 | |
| 257 | struct cpuidle_driver omap3_idle_driver = { |
| 258 | .name = "omap3_idle", |
| 259 | .owner = THIS_MODULE, |
| 260 | }; |
| 261 | |
| 262 | /** |
| 263 | * omap3_idle_init - Init routine for OMAP3 idle |
| 264 | * |
| 265 | * Registers the OMAP3 specific cpuidle driver with the cpuidle |
| 266 | * framework with the valid set of states. |
| 267 | */ |
Kalle Jokiniemi | 0343371 | 2008-09-26 11:04:20 +0300 | [diff] [blame] | 268 | int __init omap3_idle_init(void) |
Rajendra Nayak | 99e6a4d | 2008-10-08 17:30:58 +0530 | [diff] [blame] | 269 | { |
| 270 | int i, count = 0; |
| 271 | struct omap3_processor_cx *cx; |
| 272 | struct cpuidle_state *state; |
| 273 | struct cpuidle_device *dev; |
| 274 | |
| 275 | mpu_pd = pwrdm_lookup("mpu_pwrdm"); |
Rajendra Nayak | 20b0166 | 2008-10-08 17:31:22 +0530 | [diff] [blame] | 276 | core_pd = pwrdm_lookup("core_pwrdm"); |
Rajendra Nayak | 99e6a4d | 2008-10-08 17:30:58 +0530 | [diff] [blame] | 277 | |
| 278 | omap_init_power_states(); |
| 279 | cpuidle_register_driver(&omap3_idle_driver); |
| 280 | |
| 281 | dev = &per_cpu(omap3_idle_dev, smp_processor_id()); |
| 282 | |
Sanjeev Premi | 8e431ed | 2009-03-13 21:34:25 +0530 | [diff] [blame] | 283 | for (i = OMAP3_STATE_C1; i < OMAP3_MAX_STATES; i++) { |
Rajendra Nayak | 99e6a4d | 2008-10-08 17:30:58 +0530 | [diff] [blame] | 284 | cx = &omap3_power_states[i]; |
| 285 | state = &dev->states[count]; |
| 286 | |
| 287 | if (!cx->valid) |
| 288 | continue; |
| 289 | cpuidle_set_statedata(state, cx); |
| 290 | state->exit_latency = cx->sleep_latency + cx->wakeup_latency; |
| 291 | state->target_residency = cx->threshold; |
| 292 | state->flags = cx->flags; |
| 293 | state->enter = (state->flags & CPUIDLE_FLAG_CHECK_BM) ? |
| 294 | omap3_enter_idle_bm : omap3_enter_idle; |
| 295 | if (cx->type == OMAP3_STATE_C1) |
| 296 | dev->safe_state = state; |
| 297 | sprintf(state->name, "C%d", count+1); |
| 298 | count++; |
| 299 | } |
| 300 | |
| 301 | if (!count) |
| 302 | return -EINVAL; |
| 303 | dev->state_count = count; |
| 304 | |
| 305 | if (cpuidle_register_device(dev)) { |
| 306 | printk(KERN_ERR "%s: CPUidle register device failed\n", |
| 307 | __func__); |
| 308 | return -EIO; |
| 309 | } |
| 310 | |
| 311 | return 0; |
| 312 | } |
Kalle Jokiniemi | 0343371 | 2008-09-26 11:04:20 +0300 | [diff] [blame] | 313 | #else |
| 314 | int __init omap3_idle_init(void) |
| 315 | { |
| 316 | return 0; |
| 317 | } |
Rajendra Nayak | 99e6a4d | 2008-10-08 17:30:58 +0530 | [diff] [blame] | 318 | #endif /* CONFIG_CPU_IDLE */ |