cpuidle34xx.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549
  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. #include <linux/sched.h>
  25. #include <linux/cpuidle.h>
  26. #include <plat/prcm.h>
  27. #include <plat/irqs.h>
  28. #include "powerdomain.h"
  29. #include "clockdomain.h"
  30. #include <plat/serial.h>
  31. #include "pm.h"
  32. #include "control.h"
  33. #ifdef CONFIG_CPU_IDLE
  34. #define OMAP3_MAX_STATES 7
  35. #define OMAP3_STATE_C1 0 /* C1 - MPU WFI + Core active */
  36. #define OMAP3_STATE_C2 1 /* C2 - MPU WFI + Core inactive */
  37. #define OMAP3_STATE_C3 2 /* C3 - MPU CSWR + Core inactive */
  38. #define OMAP3_STATE_C4 3 /* C4 - MPU OFF + Core iactive */
  39. #define OMAP3_STATE_C5 4 /* C5 - MPU RET + Core RET */
  40. #define OMAP3_STATE_C6 5 /* C6 - MPU OFF + Core RET */
  41. #define OMAP3_STATE_C7 6 /* C7 - MPU OFF + Core OFF */
  42. #define OMAP3_STATE_MAX OMAP3_STATE_C7
  43. #define CPUIDLE_FLAG_CHECK_BM 0x10000 /* use omap3_enter_idle_bm() */
  44. struct omap3_processor_cx {
  45. u8 valid;
  46. u8 type;
  47. u32 sleep_latency;
  48. u32 wakeup_latency;
  49. u32 mpu_state;
  50. u32 core_state;
  51. u32 threshold;
  52. u32 flags;
  53. const char *desc;
  54. };
  55. struct omap3_processor_cx omap3_power_states[OMAP3_MAX_STATES];
  56. struct omap3_processor_cx current_cx_state;
  57. struct powerdomain *mpu_pd, *core_pd, *per_pd;
  58. struct powerdomain *cam_pd;
  59. /*
  60. * The latencies/thresholds for various C states have
  61. * to be configured from the respective board files.
  62. * These are some default values (which might not provide
  63. * the best power savings) used on boards which do not
  64. * pass these details from the board file.
  65. */
  66. static struct cpuidle_params cpuidle_params_table[] = {
  67. /* C1 */
  68. {1, 2, 2, 5},
  69. /* C2 */
  70. {1, 10, 10, 30},
  71. /* C3 */
  72. {1, 50, 50, 300},
  73. /* C4 */
  74. {1, 1500, 1800, 4000},
  75. /* C5 */
  76. {1, 2500, 7500, 12000},
  77. /* C6 */
  78. {1, 3000, 8500, 15000},
  79. /* C7 */
  80. {1, 10000, 30000, 300000},
  81. };
  82. static int omap3_idle_bm_check(void)
  83. {
  84. if (!omap3_can_sleep())
  85. return 1;
  86. return 0;
  87. }
  88. static int _cpuidle_allow_idle(struct powerdomain *pwrdm,
  89. struct clockdomain *clkdm)
  90. {
  91. clkdm_allow_idle(clkdm);
  92. return 0;
  93. }
  94. static int _cpuidle_deny_idle(struct powerdomain *pwrdm,
  95. struct clockdomain *clkdm)
  96. {
  97. clkdm_deny_idle(clkdm);
  98. return 0;
  99. }
  100. /**
  101. * omap3_enter_idle - Programs OMAP3 to enter the specified state
  102. * @dev: cpuidle device
  103. * @state: The target state to be programmed
  104. *
  105. * Called from the CPUidle framework to program the device to the
  106. * specified target state selected by the governor.
  107. */
  108. static int omap3_enter_idle(struct cpuidle_device *dev,
  109. struct cpuidle_state *state)
  110. {
  111. struct omap3_processor_cx *cx = cpuidle_get_statedata(state);
  112. struct timespec ts_preidle, ts_postidle, ts_idle;
  113. u32 mpu_state = cx->mpu_state, core_state = cx->core_state;
  114. current_cx_state = *cx;
  115. /* Used to keep track of the total time in idle */
  116. getnstimeofday(&ts_preidle);
  117. local_irq_disable();
  118. local_fiq_disable();
  119. pwrdm_set_next_pwrst(mpu_pd, mpu_state);
  120. pwrdm_set_next_pwrst(core_pd, core_state);
  121. if (omap_irq_pending() || need_resched())
  122. goto return_sleep_time;
  123. if (cx->type == OMAP3_STATE_C1) {
  124. pwrdm_for_each_clkdm(mpu_pd, _cpuidle_deny_idle);
  125. pwrdm_for_each_clkdm(core_pd, _cpuidle_deny_idle);
  126. }
  127. /* Execute ARM wfi */
  128. omap_sram_idle();
  129. if (cx->type == OMAP3_STATE_C1) {
  130. pwrdm_for_each_clkdm(mpu_pd, _cpuidle_allow_idle);
  131. pwrdm_for_each_clkdm(core_pd, _cpuidle_allow_idle);
  132. }
  133. return_sleep_time:
  134. getnstimeofday(&ts_postidle);
  135. ts_idle = timespec_sub(ts_postidle, ts_preidle);
  136. local_irq_enable();
  137. local_fiq_enable();
  138. return ts_idle.tv_nsec / NSEC_PER_USEC + ts_idle.tv_sec * USEC_PER_SEC;
  139. }
  140. /**
  141. * next_valid_state - Find next valid c-state
  142. * @dev: cpuidle device
  143. * @state: Currently selected c-state
  144. *
  145. * If the current state is valid, it is returned back to the caller.
  146. * Else, this function searches for a lower c-state which is still
  147. * valid (as defined in omap3_power_states[]).
  148. */
  149. static struct cpuidle_state *next_valid_state(struct cpuidle_device *dev,
  150. struct cpuidle_state *curr)
  151. {
  152. struct cpuidle_state *next = NULL;
  153. struct omap3_processor_cx *cx;
  154. cx = (struct omap3_processor_cx *)cpuidle_get_statedata(curr);
  155. /* Check if current state is valid */
  156. if (cx->valid) {
  157. return curr;
  158. } else {
  159. u8 idx = OMAP3_STATE_MAX;
  160. /*
  161. * Reach the current state starting at highest C-state
  162. */
  163. for (; idx >= OMAP3_STATE_C1; idx--) {
  164. if (&dev->states[idx] == curr) {
  165. next = &dev->states[idx];
  166. break;
  167. }
  168. }
  169. /*
  170. * Should never hit this condition.
  171. */
  172. WARN_ON(next == NULL);
  173. /*
  174. * Drop to next valid state.
  175. * Start search from the next (lower) state.
  176. */
  177. idx--;
  178. for (; idx >= OMAP3_STATE_C1; idx--) {
  179. struct omap3_processor_cx *cx;
  180. cx = cpuidle_get_statedata(&dev->states[idx]);
  181. if (cx->valid) {
  182. next = &dev->states[idx];
  183. break;
  184. }
  185. }
  186. /*
  187. * C1 and C2 are always valid.
  188. * So, no need to check for 'next==NULL' outside this loop.
  189. */
  190. }
  191. return next;
  192. }
  193. /**
  194. * omap3_enter_idle_bm - Checks for any bus activity
  195. * @dev: cpuidle device
  196. * @state: The target state to be programmed
  197. *
  198. * Used for C states with CPUIDLE_FLAG_CHECK_BM flag set. This
  199. * function checks for any pending activity and then programs the
  200. * device to the specified or a safer state.
  201. */
  202. static int omap3_enter_idle_bm(struct cpuidle_device *dev,
  203. struct cpuidle_state *state)
  204. {
  205. struct cpuidle_state *new_state = next_valid_state(dev, state);
  206. u32 core_next_state, per_next_state = 0, per_saved_state = 0;
  207. u32 cam_state;
  208. struct omap3_processor_cx *cx;
  209. int ret;
  210. if ((state->flags & CPUIDLE_FLAG_CHECK_BM) && omap3_idle_bm_check()) {
  211. BUG_ON(!dev->safe_state);
  212. new_state = dev->safe_state;
  213. goto select_state;
  214. }
  215. cx = cpuidle_get_statedata(state);
  216. core_next_state = cx->core_state;
  217. /*
  218. * FIXME: we currently manage device-specific idle states
  219. * for PER and CORE in combination with CPU-specific
  220. * idle states. This is wrong, and device-specific
  221. * idle management needs to be separated out into
  222. * its own code.
  223. */
  224. /*
  225. * Prevent idle completely if CAM is active.
  226. * CAM does not have wakeup capability in OMAP3.
  227. */
  228. cam_state = pwrdm_read_pwrst(cam_pd);
  229. if (cam_state == PWRDM_POWER_ON) {
  230. new_state = dev->safe_state;
  231. goto select_state;
  232. }
  233. /*
  234. * Prevent PER off if CORE is not in retention or off as this
  235. * would disable PER wakeups completely.
  236. */
  237. per_next_state = per_saved_state = pwrdm_read_next_pwrst(per_pd);
  238. if ((per_next_state == PWRDM_POWER_OFF) &&
  239. (core_next_state > PWRDM_POWER_RET))
  240. per_next_state = PWRDM_POWER_RET;
  241. /* Are we changing PER target state? */
  242. if (per_next_state != per_saved_state)
  243. pwrdm_set_next_pwrst(per_pd, per_next_state);
  244. select_state:
  245. dev->last_state = new_state;
  246. ret = omap3_enter_idle(dev, new_state);
  247. /* Restore original PER state if it was modified */
  248. if (per_next_state != per_saved_state)
  249. pwrdm_set_next_pwrst(per_pd, per_saved_state);
  250. return ret;
  251. }
  252. DEFINE_PER_CPU(struct cpuidle_device, omap3_idle_dev);
  253. /**
  254. * omap3_cpuidle_update_states() - Update the cpuidle states
  255. * @mpu_deepest_state: Enable states up to and including this for mpu domain
  256. * @core_deepest_state: Enable states up to and including this for core domain
  257. *
  258. * This goes through the list of states available and enables and disables the
  259. * validity of C states based on deepest state that can be achieved for the
  260. * variable domain
  261. */
  262. void omap3_cpuidle_update_states(u32 mpu_deepest_state, u32 core_deepest_state)
  263. {
  264. int i;
  265. for (i = OMAP3_STATE_C1; i < OMAP3_MAX_STATES; i++) {
  266. struct omap3_processor_cx *cx = &omap3_power_states[i];
  267. if ((cx->mpu_state >= mpu_deepest_state) &&
  268. (cx->core_state >= core_deepest_state)) {
  269. cx->valid = 1;
  270. } else {
  271. cx->valid = 0;
  272. }
  273. }
  274. }
  275. void omap3_pm_init_cpuidle(struct cpuidle_params *cpuidle_board_params)
  276. {
  277. int i;
  278. if (!cpuidle_board_params)
  279. return;
  280. for (i = OMAP3_STATE_C1; i < OMAP3_MAX_STATES; i++) {
  281. cpuidle_params_table[i].valid =
  282. cpuidle_board_params[i].valid;
  283. cpuidle_params_table[i].sleep_latency =
  284. cpuidle_board_params[i].sleep_latency;
  285. cpuidle_params_table[i].wake_latency =
  286. cpuidle_board_params[i].wake_latency;
  287. cpuidle_params_table[i].threshold =
  288. cpuidle_board_params[i].threshold;
  289. }
  290. return;
  291. }
  292. /* omap3_init_power_states - Initialises the OMAP3 specific C states.
  293. *
  294. * Below is the desciption of each C state.
  295. * C1 . MPU WFI + Core active
  296. * C2 . MPU WFI + Core inactive
  297. * C3 . MPU CSWR + Core inactive
  298. * C4 . MPU OFF + Core inactive
  299. * C5 . MPU CSWR + Core CSWR
  300. * C6 . MPU OFF + Core CSWR
  301. * C7 . MPU OFF + Core OFF
  302. */
  303. void omap_init_power_states(void)
  304. {
  305. /* C1 . MPU WFI + Core active */
  306. omap3_power_states[OMAP3_STATE_C1].valid =
  307. cpuidle_params_table[OMAP3_STATE_C1].valid;
  308. omap3_power_states[OMAP3_STATE_C1].type = OMAP3_STATE_C1;
  309. omap3_power_states[OMAP3_STATE_C1].sleep_latency =
  310. cpuidle_params_table[OMAP3_STATE_C1].sleep_latency;
  311. omap3_power_states[OMAP3_STATE_C1].wakeup_latency =
  312. cpuidle_params_table[OMAP3_STATE_C1].wake_latency;
  313. omap3_power_states[OMAP3_STATE_C1].threshold =
  314. cpuidle_params_table[OMAP3_STATE_C1].threshold;
  315. omap3_power_states[OMAP3_STATE_C1].mpu_state = PWRDM_POWER_ON;
  316. omap3_power_states[OMAP3_STATE_C1].core_state = PWRDM_POWER_ON;
  317. omap3_power_states[OMAP3_STATE_C1].flags = CPUIDLE_FLAG_TIME_VALID;
  318. omap3_power_states[OMAP3_STATE_C1].desc = "MPU ON + CORE ON";
  319. /* C2 . MPU WFI + Core inactive */
  320. omap3_power_states[OMAP3_STATE_C2].valid =
  321. cpuidle_params_table[OMAP3_STATE_C2].valid;
  322. omap3_power_states[OMAP3_STATE_C2].type = OMAP3_STATE_C2;
  323. omap3_power_states[OMAP3_STATE_C2].sleep_latency =
  324. cpuidle_params_table[OMAP3_STATE_C2].sleep_latency;
  325. omap3_power_states[OMAP3_STATE_C2].wakeup_latency =
  326. cpuidle_params_table[OMAP3_STATE_C2].wake_latency;
  327. omap3_power_states[OMAP3_STATE_C2].threshold =
  328. cpuidle_params_table[OMAP3_STATE_C2].threshold;
  329. omap3_power_states[OMAP3_STATE_C2].mpu_state = PWRDM_POWER_ON;
  330. omap3_power_states[OMAP3_STATE_C2].core_state = PWRDM_POWER_ON;
  331. omap3_power_states[OMAP3_STATE_C2].flags = CPUIDLE_FLAG_TIME_VALID |
  332. CPUIDLE_FLAG_CHECK_BM;
  333. omap3_power_states[OMAP3_STATE_C2].desc = "MPU ON + CORE ON";
  334. /* C3 . MPU CSWR + Core inactive */
  335. omap3_power_states[OMAP3_STATE_C3].valid =
  336. cpuidle_params_table[OMAP3_STATE_C3].valid;
  337. omap3_power_states[OMAP3_STATE_C3].type = OMAP3_STATE_C3;
  338. omap3_power_states[OMAP3_STATE_C3].sleep_latency =
  339. cpuidle_params_table[OMAP3_STATE_C3].sleep_latency;
  340. omap3_power_states[OMAP3_STATE_C3].wakeup_latency =
  341. cpuidle_params_table[OMAP3_STATE_C3].wake_latency;
  342. omap3_power_states[OMAP3_STATE_C3].threshold =
  343. cpuidle_params_table[OMAP3_STATE_C3].threshold;
  344. omap3_power_states[OMAP3_STATE_C3].mpu_state = PWRDM_POWER_RET;
  345. omap3_power_states[OMAP3_STATE_C3].core_state = PWRDM_POWER_ON;
  346. omap3_power_states[OMAP3_STATE_C3].flags = CPUIDLE_FLAG_TIME_VALID |
  347. CPUIDLE_FLAG_CHECK_BM;
  348. omap3_power_states[OMAP3_STATE_C3].desc = "MPU RET + CORE ON";
  349. /* C4 . MPU OFF + Core inactive */
  350. omap3_power_states[OMAP3_STATE_C4].valid =
  351. cpuidle_params_table[OMAP3_STATE_C4].valid;
  352. omap3_power_states[OMAP3_STATE_C4].type = OMAP3_STATE_C4;
  353. omap3_power_states[OMAP3_STATE_C4].sleep_latency =
  354. cpuidle_params_table[OMAP3_STATE_C4].sleep_latency;
  355. omap3_power_states[OMAP3_STATE_C4].wakeup_latency =
  356. cpuidle_params_table[OMAP3_STATE_C4].wake_latency;
  357. omap3_power_states[OMAP3_STATE_C4].threshold =
  358. cpuidle_params_table[OMAP3_STATE_C4].threshold;
  359. omap3_power_states[OMAP3_STATE_C4].mpu_state = PWRDM_POWER_OFF;
  360. omap3_power_states[OMAP3_STATE_C4].core_state = PWRDM_POWER_ON;
  361. omap3_power_states[OMAP3_STATE_C4].flags = CPUIDLE_FLAG_TIME_VALID |
  362. CPUIDLE_FLAG_CHECK_BM;
  363. omap3_power_states[OMAP3_STATE_C4].desc = "MPU OFF + CORE ON";
  364. /* C5 . MPU CSWR + Core CSWR*/
  365. omap3_power_states[OMAP3_STATE_C5].valid =
  366. cpuidle_params_table[OMAP3_STATE_C5].valid;
  367. omap3_power_states[OMAP3_STATE_C5].type = OMAP3_STATE_C5;
  368. omap3_power_states[OMAP3_STATE_C5].sleep_latency =
  369. cpuidle_params_table[OMAP3_STATE_C5].sleep_latency;
  370. omap3_power_states[OMAP3_STATE_C5].wakeup_latency =
  371. cpuidle_params_table[OMAP3_STATE_C5].wake_latency;
  372. omap3_power_states[OMAP3_STATE_C5].threshold =
  373. cpuidle_params_table[OMAP3_STATE_C5].threshold;
  374. omap3_power_states[OMAP3_STATE_C5].mpu_state = PWRDM_POWER_RET;
  375. omap3_power_states[OMAP3_STATE_C5].core_state = PWRDM_POWER_RET;
  376. omap3_power_states[OMAP3_STATE_C5].flags = CPUIDLE_FLAG_TIME_VALID |
  377. CPUIDLE_FLAG_CHECK_BM;
  378. omap3_power_states[OMAP3_STATE_C5].desc = "MPU RET + CORE RET";
  379. /* C6 . MPU OFF + Core CSWR */
  380. omap3_power_states[OMAP3_STATE_C6].valid =
  381. cpuidle_params_table[OMAP3_STATE_C6].valid;
  382. omap3_power_states[OMAP3_STATE_C6].type = OMAP3_STATE_C6;
  383. omap3_power_states[OMAP3_STATE_C6].sleep_latency =
  384. cpuidle_params_table[OMAP3_STATE_C6].sleep_latency;
  385. omap3_power_states[OMAP3_STATE_C6].wakeup_latency =
  386. cpuidle_params_table[OMAP3_STATE_C6].wake_latency;
  387. omap3_power_states[OMAP3_STATE_C6].threshold =
  388. cpuidle_params_table[OMAP3_STATE_C6].threshold;
  389. omap3_power_states[OMAP3_STATE_C6].mpu_state = PWRDM_POWER_OFF;
  390. omap3_power_states[OMAP3_STATE_C6].core_state = PWRDM_POWER_RET;
  391. omap3_power_states[OMAP3_STATE_C6].flags = CPUIDLE_FLAG_TIME_VALID |
  392. CPUIDLE_FLAG_CHECK_BM;
  393. omap3_power_states[OMAP3_STATE_C6].desc = "MPU OFF + CORE RET";
  394. /* C7 . MPU OFF + Core OFF */
  395. omap3_power_states[OMAP3_STATE_C7].valid =
  396. cpuidle_params_table[OMAP3_STATE_C7].valid;
  397. omap3_power_states[OMAP3_STATE_C7].type = OMAP3_STATE_C7;
  398. omap3_power_states[OMAP3_STATE_C7].sleep_latency =
  399. cpuidle_params_table[OMAP3_STATE_C7].sleep_latency;
  400. omap3_power_states[OMAP3_STATE_C7].wakeup_latency =
  401. cpuidle_params_table[OMAP3_STATE_C7].wake_latency;
  402. omap3_power_states[OMAP3_STATE_C7].threshold =
  403. cpuidle_params_table[OMAP3_STATE_C7].threshold;
  404. omap3_power_states[OMAP3_STATE_C7].mpu_state = PWRDM_POWER_OFF;
  405. omap3_power_states[OMAP3_STATE_C7].core_state = PWRDM_POWER_OFF;
  406. omap3_power_states[OMAP3_STATE_C7].flags = CPUIDLE_FLAG_TIME_VALID |
  407. CPUIDLE_FLAG_CHECK_BM;
  408. omap3_power_states[OMAP3_STATE_C7].desc = "MPU OFF + CORE OFF";
  409. /*
  410. * Erratum i583: implementation for ES rev < Es1.2 on 3630. We cannot
  411. * enable OFF mode in a stable form for previous revisions.
  412. * we disable C7 state as a result.
  413. */
  414. if (IS_PM34XX_ERRATUM(PM_SDRC_WAKEUP_ERRATUM_i583)) {
  415. omap3_power_states[OMAP3_STATE_C7].valid = 0;
  416. cpuidle_params_table[OMAP3_STATE_C7].valid = 0;
  417. pr_warn("%s: core off state C7 disabled due to i583\n",
  418. __func__);
  419. }
  420. }
  421. struct cpuidle_driver omap3_idle_driver = {
  422. .name = "omap3_idle",
  423. .owner = THIS_MODULE,
  424. };
  425. /**
  426. * omap3_idle_init - Init routine for OMAP3 idle
  427. *
  428. * Registers the OMAP3 specific cpuidle driver with the cpuidle
  429. * framework with the valid set of states.
  430. */
  431. int __init omap3_idle_init(void)
  432. {
  433. int i, count = 0;
  434. struct omap3_processor_cx *cx;
  435. struct cpuidle_state *state;
  436. struct cpuidle_device *dev;
  437. mpu_pd = pwrdm_lookup("mpu_pwrdm");
  438. core_pd = pwrdm_lookup("core_pwrdm");
  439. per_pd = pwrdm_lookup("per_pwrdm");
  440. cam_pd = pwrdm_lookup("cam_pwrdm");
  441. omap_init_power_states();
  442. cpuidle_register_driver(&omap3_idle_driver);
  443. dev = &per_cpu(omap3_idle_dev, smp_processor_id());
  444. for (i = OMAP3_STATE_C1; i < OMAP3_MAX_STATES; i++) {
  445. cx = &omap3_power_states[i];
  446. state = &dev->states[count];
  447. if (!cx->valid)
  448. continue;
  449. cpuidle_set_statedata(state, cx);
  450. state->exit_latency = cx->sleep_latency + cx->wakeup_latency;
  451. state->target_residency = cx->threshold;
  452. state->flags = cx->flags;
  453. state->enter = (state->flags & CPUIDLE_FLAG_CHECK_BM) ?
  454. omap3_enter_idle_bm : omap3_enter_idle;
  455. if (cx->type == OMAP3_STATE_C1)
  456. dev->safe_state = state;
  457. sprintf(state->name, "C%d", count+1);
  458. strncpy(state->desc, cx->desc, CPUIDLE_DESC_LEN);
  459. count++;
  460. }
  461. if (!count)
  462. return -EINVAL;
  463. dev->state_count = count;
  464. if (enable_off_mode)
  465. omap3_cpuidle_update_states(PWRDM_POWER_OFF, PWRDM_POWER_OFF);
  466. else
  467. omap3_cpuidle_update_states(PWRDM_POWER_RET, PWRDM_POWER_RET);
  468. if (cpuidle_register_device(dev)) {
  469. printk(KERN_ERR "%s: CPUidle register device failed\n",
  470. __func__);
  471. return -EIO;
  472. }
  473. return 0;
  474. }
  475. #else
  476. int __init omap3_idle_init(void)
  477. {
  478. return 0;
  479. }
  480. #endif /* CONFIG_CPU_IDLE */