pm.c 17 KB

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