pm.c 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669
  1. /*
  2. * linux/arch/arm/plat-omap/pm.c
  3. *
  4. * OMAP Power Management Routines
  5. *
  6. * Original code for the SA11x0:
  7. * Copyright (c) 2001 Cliff Brake <cbrake@accelent.com>
  8. *
  9. * Modified for the PXA250 by Nicolas Pitre:
  10. * Copyright (c) 2002 Monta Vista Software, Inc.
  11. *
  12. * Modified for the OMAP1510 by David Singleton:
  13. * Copyright (c) 2002 Monta Vista Software, Inc.
  14. *
  15. * Cleanup 2004 for OMAP1510/1610 by Dirk Behme <dirk.behme@de.bosch.com>
  16. *
  17. * This program is free software; you can redistribute it and/or modify it
  18. * under the terms of the GNU General Public License as published by the
  19. * Free Software Foundation; either version 2 of the License, or (at your
  20. * option) any later version.
  21. *
  22. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
  23. * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
  24. * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
  25. * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
  26. * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
  27. * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
  28. * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
  29. * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  30. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  31. * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  32. *
  33. * You should have received a copy of the GNU General Public License along
  34. * with this program; if not, write to the Free Software Foundation, Inc.,
  35. * 675 Mass Ave, Cambridge, MA 02139, USA.
  36. */
  37. #include <linux/pm.h>
  38. #include <linux/sched.h>
  39. #include <linux/proc_fs.h>
  40. #include <linux/interrupt.h>
  41. #include <asm/io.h>
  42. #include <asm/irq.h>
  43. #include <asm/mach/time.h>
  44. #include <asm/mach/irq.h>
  45. #include <asm/mach-types.h>
  46. #include <asm/arch/irqs.h>
  47. #include <asm/arch/tc.h>
  48. #include <asm/arch/pm.h>
  49. #include <asm/arch/mux.h>
  50. #include <asm/arch/tps65010.h>
  51. #include <asm/arch/dsp_common.h>
  52. #include <asm/arch/clock.h>
  53. #include <asm/arch/sram.h>
  54. static unsigned int arm_sleep_save[ARM_SLEEP_SAVE_SIZE];
  55. static unsigned short ulpd_sleep_save[ULPD_SLEEP_SAVE_SIZE];
  56. static unsigned int mpui730_sleep_save[MPUI730_SLEEP_SAVE_SIZE];
  57. static unsigned int mpui1510_sleep_save[MPUI1510_SLEEP_SAVE_SIZE];
  58. static unsigned int mpui1610_sleep_save[MPUI1610_SLEEP_SAVE_SIZE];
  59. static void (*omap_sram_idle)(void) = NULL;
  60. static void (*omap_sram_suspend)(unsigned long r0, unsigned long r1) = NULL;
  61. /*
  62. * Let's power down on idle, but only if we are really
  63. * idle, because once we start down the path of
  64. * going idle we continue to do idle even if we get
  65. * a clock tick interrupt . .
  66. */
  67. void omap_pm_idle(void)
  68. {
  69. unsigned int mask32 = 0;
  70. /*
  71. * If the DSP is being used let's just idle the CPU, the overhead
  72. * to wake up from Big Sleep is big, milliseconds versus micro
  73. * seconds for wait for interrupt.
  74. */
  75. local_irq_disable();
  76. local_fiq_disable();
  77. if (need_resched()) {
  78. local_fiq_enable();
  79. local_irq_enable();
  80. return;
  81. }
  82. mask32 = omap_readl(ARM_SYSST);
  83. /*
  84. * Prevent the ULPD from entering low power state by setting
  85. * POWER_CTRL_REG:4 = 0
  86. */
  87. omap_writew(omap_readw(ULPD_POWER_CTRL) &
  88. ~ULPD_DEEP_SLEEP_TRANSITION_EN, ULPD_POWER_CTRL);
  89. /*
  90. * Since an interrupt may set up a timer, we don't want to
  91. * reprogram the hardware timer with interrupts enabled.
  92. * Re-enable interrupts only after returning from idle.
  93. */
  94. timer_dyn_reprogram();
  95. if ((mask32 & DSP_IDLE) == 0) {
  96. __asm__ volatile ("mcr p15, 0, r0, c7, c0, 4");
  97. } else
  98. omap_sram_idle();
  99. local_fiq_enable();
  100. local_irq_enable();
  101. }
  102. /*
  103. * Configuration of the wakeup event is board specific. For the
  104. * moment we put it into this helper function. Later it may move
  105. * to board specific files.
  106. */
  107. static void omap_pm_wakeup_setup(void)
  108. {
  109. u32 level1_wake = 0;
  110. u32 level2_wake = OMAP_IRQ_BIT(INT_UART2);
  111. /*
  112. * Turn off all interrupts except GPIO bank 1, L1-2nd level cascade,
  113. * and the L2 wakeup interrupts: keypad and UART2. Note that the
  114. * drivers must still separately call omap_set_gpio_wakeup() to
  115. * wake up to a GPIO interrupt.
  116. */
  117. if (cpu_is_omap730())
  118. level1_wake = OMAP_IRQ_BIT(INT_730_GPIO_BANK1) |
  119. OMAP_IRQ_BIT(INT_730_IH2_IRQ);
  120. else if (cpu_is_omap1510())
  121. level1_wake = OMAP_IRQ_BIT(INT_GPIO_BANK1) |
  122. OMAP_IRQ_BIT(INT_1510_IH2_IRQ);
  123. else if (cpu_is_omap16xx())
  124. level1_wake = OMAP_IRQ_BIT(INT_GPIO_BANK1) |
  125. OMAP_IRQ_BIT(INT_1610_IH2_IRQ);
  126. omap_writel(~level1_wake, OMAP_IH1_MIR);
  127. if (cpu_is_omap730()) {
  128. omap_writel(~level2_wake, OMAP_IH2_0_MIR);
  129. omap_writel(~(OMAP_IRQ_BIT(INT_730_WAKE_UP_REQ) | OMAP_IRQ_BIT(INT_730_MPUIO_KEYPAD)), OMAP_IH2_1_MIR);
  130. } else if (cpu_is_omap1510()) {
  131. level2_wake |= OMAP_IRQ_BIT(INT_KEYBOARD);
  132. omap_writel(~level2_wake, OMAP_IH2_MIR);
  133. } else if (cpu_is_omap16xx()) {
  134. level2_wake |= OMAP_IRQ_BIT(INT_KEYBOARD);
  135. omap_writel(~level2_wake, OMAP_IH2_0_MIR);
  136. /* INT_1610_WAKE_UP_REQ is needed for GPIO wakeup... */
  137. omap_writel(~OMAP_IRQ_BIT(INT_1610_WAKE_UP_REQ), OMAP_IH2_1_MIR);
  138. omap_writel(~0x0, OMAP_IH2_2_MIR);
  139. omap_writel(~0x0, OMAP_IH2_3_MIR);
  140. }
  141. /* New IRQ agreement, recalculate in cascade order */
  142. omap_writel(1, OMAP_IH2_CONTROL);
  143. omap_writel(1, OMAP_IH1_CONTROL);
  144. }
  145. void omap_pm_suspend(void)
  146. {
  147. unsigned long arg0 = 0, arg1 = 0;
  148. printk("PM: OMAP%x is trying to enter deep sleep...\n", system_rev);
  149. omap_serial_wake_trigger(1);
  150. if (machine_is_omap_osk()) {
  151. /* Stop LED1 (D9) blink */
  152. tps65010_set_led(LED1, OFF);
  153. }
  154. omap_writew(0xffff, ULPD_SOFT_DISABLE_REQ_REG);
  155. /*
  156. * Step 1: turn off interrupts (FIXME: NOTE: already disabled)
  157. */
  158. local_irq_disable();
  159. local_fiq_disable();
  160. /*
  161. * Step 2: save registers
  162. *
  163. * The omap is a strange/beautiful device. The caches, memory
  164. * and register state are preserved across power saves.
  165. * We have to save and restore very little register state to
  166. * idle the omap.
  167. *
  168. * Save interrupt, MPUI, ARM and UPLD control registers.
  169. */
  170. if (cpu_is_omap730()) {
  171. MPUI730_SAVE(OMAP_IH1_MIR);
  172. MPUI730_SAVE(OMAP_IH2_0_MIR);
  173. MPUI730_SAVE(OMAP_IH2_1_MIR);
  174. MPUI730_SAVE(MPUI_CTRL);
  175. MPUI730_SAVE(MPUI_DSP_BOOT_CONFIG);
  176. MPUI730_SAVE(MPUI_DSP_API_CONFIG);
  177. MPUI730_SAVE(EMIFS_CONFIG);
  178. MPUI730_SAVE(EMIFF_SDRAM_CONFIG);
  179. } else if (cpu_is_omap1510()) {
  180. MPUI1510_SAVE(OMAP_IH1_MIR);
  181. MPUI1510_SAVE(OMAP_IH2_MIR);
  182. MPUI1510_SAVE(MPUI_CTRL);
  183. MPUI1510_SAVE(MPUI_DSP_BOOT_CONFIG);
  184. MPUI1510_SAVE(MPUI_DSP_API_CONFIG);
  185. MPUI1510_SAVE(EMIFS_CONFIG);
  186. MPUI1510_SAVE(EMIFF_SDRAM_CONFIG);
  187. } else if (cpu_is_omap16xx()) {
  188. MPUI1610_SAVE(OMAP_IH1_MIR);
  189. MPUI1610_SAVE(OMAP_IH2_0_MIR);
  190. MPUI1610_SAVE(OMAP_IH2_1_MIR);
  191. MPUI1610_SAVE(OMAP_IH2_2_MIR);
  192. MPUI1610_SAVE(OMAP_IH2_3_MIR);
  193. MPUI1610_SAVE(MPUI_CTRL);
  194. MPUI1610_SAVE(MPUI_DSP_BOOT_CONFIG);
  195. MPUI1610_SAVE(MPUI_DSP_API_CONFIG);
  196. MPUI1610_SAVE(EMIFS_CONFIG);
  197. MPUI1610_SAVE(EMIFF_SDRAM_CONFIG);
  198. }
  199. ARM_SAVE(ARM_CKCTL);
  200. ARM_SAVE(ARM_IDLECT1);
  201. ARM_SAVE(ARM_IDLECT2);
  202. if (!(cpu_is_omap1510()))
  203. ARM_SAVE(ARM_IDLECT3);
  204. ARM_SAVE(ARM_EWUPCT);
  205. ARM_SAVE(ARM_RSTCT1);
  206. ARM_SAVE(ARM_RSTCT2);
  207. ARM_SAVE(ARM_SYSST);
  208. ULPD_SAVE(ULPD_CLOCK_CTRL);
  209. ULPD_SAVE(ULPD_STATUS_REQ);
  210. /* (Step 3 removed - we now allow deep sleep by default) */
  211. /*
  212. * Step 4: OMAP DSP Shutdown
  213. */
  214. /*
  215. * Step 5: Wakeup Event Setup
  216. */
  217. omap_pm_wakeup_setup();
  218. /*
  219. * Step 6: ARM and Traffic controller shutdown
  220. */
  221. /* disable ARM watchdog */
  222. omap_writel(0x00F5, OMAP_WDT_TIMER_MODE);
  223. omap_writel(0x00A0, OMAP_WDT_TIMER_MODE);
  224. /*
  225. * Step 6b: ARM and Traffic controller shutdown
  226. *
  227. * Step 6 continues here. Prepare jump to power management
  228. * assembly code in internal SRAM.
  229. *
  230. * Since the omap_cpu_suspend routine has been copied to
  231. * SRAM, we'll do an indirect procedure call to it and pass the
  232. * contents of arm_idlect1 and arm_idlect2 so it can restore
  233. * them when it wakes up and it will return.
  234. */
  235. arg0 = arm_sleep_save[ARM_SLEEP_SAVE_ARM_IDLECT1];
  236. arg1 = arm_sleep_save[ARM_SLEEP_SAVE_ARM_IDLECT2];
  237. /*
  238. * Step 6c: ARM and Traffic controller shutdown
  239. *
  240. * Jump to assembly code. The processor will stay there
  241. * until wake up.
  242. */
  243. omap_sram_suspend(arg0, arg1);
  244. /*
  245. * If we are here, processor is woken up!
  246. */
  247. /*
  248. * Restore ARM state, except ARM_IDLECT1/2 which omap_cpu_suspend did
  249. */
  250. if (!(cpu_is_omap1510()))
  251. ARM_RESTORE(ARM_IDLECT3);
  252. ARM_RESTORE(ARM_CKCTL);
  253. ARM_RESTORE(ARM_EWUPCT);
  254. ARM_RESTORE(ARM_RSTCT1);
  255. ARM_RESTORE(ARM_RSTCT2);
  256. ARM_RESTORE(ARM_SYSST);
  257. ULPD_RESTORE(ULPD_CLOCK_CTRL);
  258. ULPD_RESTORE(ULPD_STATUS_REQ);
  259. if (cpu_is_omap730()) {
  260. MPUI730_RESTORE(EMIFS_CONFIG);
  261. MPUI730_RESTORE(EMIFF_SDRAM_CONFIG);
  262. MPUI730_RESTORE(OMAP_IH1_MIR);
  263. MPUI730_RESTORE(OMAP_IH2_0_MIR);
  264. MPUI730_RESTORE(OMAP_IH2_1_MIR);
  265. } else if (cpu_is_omap1510()) {
  266. MPUI1510_RESTORE(MPUI_CTRL);
  267. MPUI1510_RESTORE(MPUI_DSP_BOOT_CONFIG);
  268. MPUI1510_RESTORE(MPUI_DSP_API_CONFIG);
  269. MPUI1510_RESTORE(EMIFS_CONFIG);
  270. MPUI1510_RESTORE(EMIFF_SDRAM_CONFIG);
  271. MPUI1510_RESTORE(OMAP_IH1_MIR);
  272. MPUI1510_RESTORE(OMAP_IH2_MIR);
  273. } else if (cpu_is_omap16xx()) {
  274. MPUI1610_RESTORE(MPUI_CTRL);
  275. MPUI1610_RESTORE(MPUI_DSP_BOOT_CONFIG);
  276. MPUI1610_RESTORE(MPUI_DSP_API_CONFIG);
  277. MPUI1610_RESTORE(EMIFS_CONFIG);
  278. MPUI1610_RESTORE(EMIFF_SDRAM_CONFIG);
  279. MPUI1610_RESTORE(OMAP_IH1_MIR);
  280. MPUI1610_RESTORE(OMAP_IH2_0_MIR);
  281. MPUI1610_RESTORE(OMAP_IH2_1_MIR);
  282. MPUI1610_RESTORE(OMAP_IH2_2_MIR);
  283. MPUI1610_RESTORE(OMAP_IH2_3_MIR);
  284. }
  285. omap_writew(0, ULPD_SOFT_DISABLE_REQ_REG);
  286. /*
  287. * Reenable interrupts
  288. */
  289. local_irq_enable();
  290. local_fiq_enable();
  291. omap_serial_wake_trigger(0);
  292. printk("PM: OMAP%x is re-starting from deep sleep...\n", system_rev);
  293. if (machine_is_omap_osk()) {
  294. /* Let LED1 (D9) blink again */
  295. tps65010_set_led(LED1, BLINK);
  296. }
  297. }
  298. #if defined(DEBUG) && defined(CONFIG_PROC_FS)
  299. static int g_read_completed;
  300. /*
  301. * Read system PM registers for debugging
  302. */
  303. static int omap_pm_read_proc(
  304. char *page_buffer,
  305. char **my_first_byte,
  306. off_t virtual_start,
  307. int length,
  308. int *eof,
  309. void *data)
  310. {
  311. int my_buffer_offset = 0;
  312. char * const my_base = page_buffer;
  313. ARM_SAVE(ARM_CKCTL);
  314. ARM_SAVE(ARM_IDLECT1);
  315. ARM_SAVE(ARM_IDLECT2);
  316. if (!(cpu_is_omap1510()))
  317. ARM_SAVE(ARM_IDLECT3);
  318. ARM_SAVE(ARM_EWUPCT);
  319. ARM_SAVE(ARM_RSTCT1);
  320. ARM_SAVE(ARM_RSTCT2);
  321. ARM_SAVE(ARM_SYSST);
  322. ULPD_SAVE(ULPD_IT_STATUS);
  323. ULPD_SAVE(ULPD_CLOCK_CTRL);
  324. ULPD_SAVE(ULPD_SOFT_REQ);
  325. ULPD_SAVE(ULPD_STATUS_REQ);
  326. ULPD_SAVE(ULPD_DPLL_CTRL);
  327. ULPD_SAVE(ULPD_POWER_CTRL);
  328. if (cpu_is_omap730()) {
  329. MPUI730_SAVE(MPUI_CTRL);
  330. MPUI730_SAVE(MPUI_DSP_STATUS);
  331. MPUI730_SAVE(MPUI_DSP_BOOT_CONFIG);
  332. MPUI730_SAVE(MPUI_DSP_API_CONFIG);
  333. MPUI730_SAVE(EMIFF_SDRAM_CONFIG);
  334. MPUI730_SAVE(EMIFS_CONFIG);
  335. } else if (cpu_is_omap1510()) {
  336. MPUI1510_SAVE(MPUI_CTRL);
  337. MPUI1510_SAVE(MPUI_DSP_STATUS);
  338. MPUI1510_SAVE(MPUI_DSP_BOOT_CONFIG);
  339. MPUI1510_SAVE(MPUI_DSP_API_CONFIG);
  340. MPUI1510_SAVE(EMIFF_SDRAM_CONFIG);
  341. MPUI1510_SAVE(EMIFS_CONFIG);
  342. } else if (cpu_is_omap16xx()) {
  343. MPUI1610_SAVE(MPUI_CTRL);
  344. MPUI1610_SAVE(MPUI_DSP_STATUS);
  345. MPUI1610_SAVE(MPUI_DSP_BOOT_CONFIG);
  346. MPUI1610_SAVE(MPUI_DSP_API_CONFIG);
  347. MPUI1610_SAVE(EMIFF_SDRAM_CONFIG);
  348. MPUI1610_SAVE(EMIFS_CONFIG);
  349. }
  350. if (virtual_start == 0) {
  351. g_read_completed = 0;
  352. my_buffer_offset += sprintf(my_base + my_buffer_offset,
  353. "ARM_CKCTL_REG: 0x%-8x \n"
  354. "ARM_IDLECT1_REG: 0x%-8x \n"
  355. "ARM_IDLECT2_REG: 0x%-8x \n"
  356. "ARM_IDLECT3_REG: 0x%-8x \n"
  357. "ARM_EWUPCT_REG: 0x%-8x \n"
  358. "ARM_RSTCT1_REG: 0x%-8x \n"
  359. "ARM_RSTCT2_REG: 0x%-8x \n"
  360. "ARM_SYSST_REG: 0x%-8x \n"
  361. "ULPD_IT_STATUS_REG: 0x%-4x \n"
  362. "ULPD_CLOCK_CTRL_REG: 0x%-4x \n"
  363. "ULPD_SOFT_REQ_REG: 0x%-4x \n"
  364. "ULPD_DPLL_CTRL_REG: 0x%-4x \n"
  365. "ULPD_STATUS_REQ_REG: 0x%-4x \n"
  366. "ULPD_POWER_CTRL_REG: 0x%-4x \n",
  367. ARM_SHOW(ARM_CKCTL),
  368. ARM_SHOW(ARM_IDLECT1),
  369. ARM_SHOW(ARM_IDLECT2),
  370. ARM_SHOW(ARM_IDLECT3),
  371. ARM_SHOW(ARM_EWUPCT),
  372. ARM_SHOW(ARM_RSTCT1),
  373. ARM_SHOW(ARM_RSTCT2),
  374. ARM_SHOW(ARM_SYSST),
  375. ULPD_SHOW(ULPD_IT_STATUS),
  376. ULPD_SHOW(ULPD_CLOCK_CTRL),
  377. ULPD_SHOW(ULPD_SOFT_REQ),
  378. ULPD_SHOW(ULPD_DPLL_CTRL),
  379. ULPD_SHOW(ULPD_STATUS_REQ),
  380. ULPD_SHOW(ULPD_POWER_CTRL));
  381. if (cpu_is_omap730()) {
  382. my_buffer_offset += sprintf(my_base + my_buffer_offset,
  383. "MPUI730_CTRL_REG 0x%-8x \n"
  384. "MPUI730_DSP_STATUS_REG: 0x%-8x \n"
  385. "MPUI730_DSP_BOOT_CONFIG_REG: 0x%-8x \n"
  386. "MPUI730_DSP_API_CONFIG_REG: 0x%-8x \n"
  387. "MPUI730_SDRAM_CONFIG_REG: 0x%-8x \n"
  388. "MPUI730_EMIFS_CONFIG_REG: 0x%-8x \n",
  389. MPUI730_SHOW(MPUI_CTRL),
  390. MPUI730_SHOW(MPUI_DSP_STATUS),
  391. MPUI730_SHOW(MPUI_DSP_BOOT_CONFIG),
  392. MPUI730_SHOW(MPUI_DSP_API_CONFIG),
  393. MPUI730_SHOW(EMIFF_SDRAM_CONFIG),
  394. MPUI730_SHOW(EMIFS_CONFIG));
  395. } else if (cpu_is_omap1510()) {
  396. my_buffer_offset += sprintf(my_base + my_buffer_offset,
  397. "MPUI1510_CTRL_REG 0x%-8x \n"
  398. "MPUI1510_DSP_STATUS_REG: 0x%-8x \n"
  399. "MPUI1510_DSP_BOOT_CONFIG_REG: 0x%-8x \n"
  400. "MPUI1510_DSP_API_CONFIG_REG: 0x%-8x \n"
  401. "MPUI1510_SDRAM_CONFIG_REG: 0x%-8x \n"
  402. "MPUI1510_EMIFS_CONFIG_REG: 0x%-8x \n",
  403. MPUI1510_SHOW(MPUI_CTRL),
  404. MPUI1510_SHOW(MPUI_DSP_STATUS),
  405. MPUI1510_SHOW(MPUI_DSP_BOOT_CONFIG),
  406. MPUI1510_SHOW(MPUI_DSP_API_CONFIG),
  407. MPUI1510_SHOW(EMIFF_SDRAM_CONFIG),
  408. MPUI1510_SHOW(EMIFS_CONFIG));
  409. } else if (cpu_is_omap16xx()) {
  410. my_buffer_offset += sprintf(my_base + my_buffer_offset,
  411. "MPUI1610_CTRL_REG 0x%-8x \n"
  412. "MPUI1610_DSP_STATUS_REG: 0x%-8x \n"
  413. "MPUI1610_DSP_BOOT_CONFIG_REG: 0x%-8x \n"
  414. "MPUI1610_DSP_API_CONFIG_REG: 0x%-8x \n"
  415. "MPUI1610_SDRAM_CONFIG_REG: 0x%-8x \n"
  416. "MPUI1610_EMIFS_CONFIG_REG: 0x%-8x \n",
  417. MPUI1610_SHOW(MPUI_CTRL),
  418. MPUI1610_SHOW(MPUI_DSP_STATUS),
  419. MPUI1610_SHOW(MPUI_DSP_BOOT_CONFIG),
  420. MPUI1610_SHOW(MPUI_DSP_API_CONFIG),
  421. MPUI1610_SHOW(EMIFF_SDRAM_CONFIG),
  422. MPUI1610_SHOW(EMIFS_CONFIG));
  423. }
  424. g_read_completed++;
  425. } else if (g_read_completed >= 1) {
  426. *eof = 1;
  427. return 0;
  428. }
  429. g_read_completed++;
  430. *my_first_byte = page_buffer;
  431. return my_buffer_offset;
  432. }
  433. static void omap_pm_init_proc(void)
  434. {
  435. struct proc_dir_entry *entry;
  436. entry = create_proc_read_entry("driver/omap_pm",
  437. S_IWUSR | S_IRUGO, NULL,
  438. omap_pm_read_proc, NULL);
  439. }
  440. #endif /* DEBUG && CONFIG_PROC_FS */
  441. /*
  442. * omap_pm_prepare - Do preliminary suspend work.
  443. * @state: suspend state we're entering.
  444. *
  445. */
  446. //#include <asm/hardware.h>
  447. static int omap_pm_prepare(suspend_state_t state)
  448. {
  449. int error = 0;
  450. switch (state)
  451. {
  452. case PM_SUSPEND_STANDBY:
  453. case PM_SUSPEND_MEM:
  454. break;
  455. case PM_SUSPEND_DISK:
  456. return -ENOTSUPP;
  457. default:
  458. return -EINVAL;
  459. }
  460. return error;
  461. }
  462. /*
  463. * omap_pm_enter - Actually enter a sleep state.
  464. * @state: State we're entering.
  465. *
  466. */
  467. static int omap_pm_enter(suspend_state_t state)
  468. {
  469. switch (state)
  470. {
  471. case PM_SUSPEND_STANDBY:
  472. case PM_SUSPEND_MEM:
  473. omap_pm_suspend();
  474. break;
  475. case PM_SUSPEND_DISK:
  476. return -ENOTSUPP;
  477. default:
  478. return -EINVAL;
  479. }
  480. return 0;
  481. }
  482. /**
  483. * omap_pm_finish - Finish up suspend sequence.
  484. * @state: State we're coming out of.
  485. *
  486. * This is called after we wake back up (or if entering the sleep state
  487. * failed).
  488. */
  489. static int omap_pm_finish(suspend_state_t state)
  490. {
  491. return 0;
  492. }
  493. static irqreturn_t omap_wakeup_interrupt(int irq, void * dev,
  494. struct pt_regs * regs)
  495. {
  496. return IRQ_HANDLED;
  497. }
  498. static struct irqaction omap_wakeup_irq = {
  499. .name = "peripheral wakeup",
  500. .flags = SA_INTERRUPT,
  501. .handler = omap_wakeup_interrupt
  502. };
  503. static struct pm_ops omap_pm_ops ={
  504. .pm_disk_mode = 0,
  505. .prepare = omap_pm_prepare,
  506. .enter = omap_pm_enter,
  507. .finish = omap_pm_finish,
  508. };
  509. static int __init omap_pm_init(void)
  510. {
  511. printk("Power Management for TI OMAP.\n");
  512. /*
  513. * We copy the assembler sleep/wakeup routines to SRAM.
  514. * These routines need to be in SRAM as that's the only
  515. * memory the MPU can see when it wakes up.
  516. */
  517. if (cpu_is_omap730()) {
  518. omap_sram_idle = omap_sram_push(omap730_idle_loop_suspend,
  519. omap730_idle_loop_suspend_sz);
  520. omap_sram_suspend = omap_sram_push(omap730_cpu_suspend,
  521. omap730_cpu_suspend_sz);
  522. } else if (cpu_is_omap1510()) {
  523. omap_sram_idle = omap_sram_push(omap1510_idle_loop_suspend,
  524. omap1510_idle_loop_suspend_sz);
  525. omap_sram_suspend = omap_sram_push(omap1510_cpu_suspend,
  526. omap1510_cpu_suspend_sz);
  527. } else if (cpu_is_omap16xx()) {
  528. omap_sram_idle = omap_sram_push(omap1610_idle_loop_suspend,
  529. omap1610_idle_loop_suspend_sz);
  530. omap_sram_suspend = omap_sram_push(omap1610_cpu_suspend,
  531. omap1610_cpu_suspend_sz);
  532. }
  533. if (omap_sram_idle == NULL || omap_sram_suspend == NULL) {
  534. printk(KERN_ERR "PM not initialized: Missing SRAM support\n");
  535. return -ENODEV;
  536. }
  537. pm_idle = omap_pm_idle;
  538. if (cpu_is_omap730())
  539. setup_irq(INT_730_WAKE_UP_REQ, &omap_wakeup_irq);
  540. else if (cpu_is_omap16xx())
  541. setup_irq(INT_1610_WAKE_UP_REQ, &omap_wakeup_irq);
  542. #if 0
  543. /* --- BEGIN BOARD-DEPENDENT CODE --- */
  544. /* Sleepx mask direction */
  545. omap_writew((omap_readw(0xfffb5008) & ~2), 0xfffb5008);
  546. /* Unmask sleepx signal */
  547. omap_writew((omap_readw(0xfffb5004) & ~2), 0xfffb5004);
  548. /* --- END BOARD-DEPENDENT CODE --- */
  549. #endif
  550. /* Program new power ramp-up time
  551. * (0 for most boards since we don't lower voltage when in deep sleep)
  552. */
  553. omap_writew(ULPD_SETUP_ANALOG_CELL_3_VAL, ULPD_SETUP_ANALOG_CELL_3);
  554. /* Setup ULPD POWER_CTRL_REG - enter deep sleep whenever possible */
  555. omap_writew(ULPD_POWER_CTRL_REG_VAL, ULPD_POWER_CTRL);
  556. /* Configure IDLECT3 */
  557. if (cpu_is_omap730())
  558. omap_writel(OMAP730_IDLECT3_VAL, OMAP730_IDLECT3);
  559. else if (cpu_is_omap16xx())
  560. omap_writel(OMAP1610_IDLECT3_VAL, OMAP1610_IDLECT3);
  561. pm_set_ops(&omap_pm_ops);
  562. #if defined(DEBUG) && defined(CONFIG_PROC_FS)
  563. omap_pm_init_proc();
  564. #endif
  565. if (cpu_is_omap16xx()) {
  566. /* configure LOW_PWR pin */
  567. omap_cfg_reg(T20_1610_LOW_PWR);
  568. }
  569. return 0;
  570. }
  571. __initcall(omap_pm_init);