pm.c 18 KB

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