pm.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609
  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 "clock.h"
  54. #include "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 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 = OMAP_IRQ_BIT(INT_IH2_IRQ);
  110. u32 level2_wake = OMAP_IRQ_BIT(INT_UART2) | OMAP_IRQ_BIT(INT_KEYBOARD);
  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_omap1510() || cpu_is_omap16xx())
  118. level1_wake |= OMAP_IRQ_BIT(INT_GPIO_BANK1);
  119. else if (cpu_is_omap730())
  120. level1_wake |= OMAP_IRQ_BIT(INT_730_GPIO_BANK1);
  121. omap_writel(~level1_wake, OMAP_IH1_MIR);
  122. if (cpu_is_omap1510())
  123. omap_writel(~level2_wake, OMAP_IH2_MIR);
  124. /* INT_1610_WAKE_UP_REQ is needed for GPIO wakeup... */
  125. if (cpu_is_omap16xx()) {
  126. omap_writel(~level2_wake, OMAP_IH2_0_MIR);
  127. omap_writel(~OMAP_IRQ_BIT(INT_1610_WAKE_UP_REQ), OMAP_IH2_1_MIR);
  128. omap_writel(~0x0, OMAP_IH2_2_MIR);
  129. omap_writel(~0x0, OMAP_IH2_3_MIR);
  130. }
  131. /* New IRQ agreement, recalculate in cascade order */
  132. omap_writel(1, OMAP_IH2_CONTROL);
  133. omap_writel(1, OMAP_IH1_CONTROL);
  134. }
  135. void omap_pm_suspend(void)
  136. {
  137. unsigned long arg0 = 0, arg1 = 0;
  138. printk("PM: OMAP%x is trying to enter deep sleep...\n", system_rev);
  139. omap_serial_wake_trigger(1);
  140. if (machine_is_omap_osk()) {
  141. /* Stop LED1 (D9) blink */
  142. tps65010_set_led(LED1, OFF);
  143. }
  144. omap_writew(0xffff, ULPD_SOFT_DISABLE_REQ_REG);
  145. /*
  146. * Step 1: turn off interrupts (FIXME: NOTE: already disabled)
  147. */
  148. local_irq_disable();
  149. local_fiq_disable();
  150. /*
  151. * Step 2: save registers
  152. *
  153. * The omap is a strange/beautiful device. The caches, memory
  154. * and register state are preserved across power saves.
  155. * We have to save and restore very little register state to
  156. * idle the omap.
  157. *
  158. * Save interrupt, MPUI, ARM and UPLD control registers.
  159. */
  160. if (cpu_is_omap1510()) {
  161. MPUI1510_SAVE(OMAP_IH1_MIR);
  162. MPUI1510_SAVE(OMAP_IH2_MIR);
  163. MPUI1510_SAVE(MPUI_CTRL);
  164. MPUI1510_SAVE(MPUI_DSP_BOOT_CONFIG);
  165. MPUI1510_SAVE(MPUI_DSP_API_CONFIG);
  166. MPUI1510_SAVE(EMIFS_CONFIG);
  167. MPUI1510_SAVE(EMIFF_SDRAM_CONFIG);
  168. } else if (cpu_is_omap16xx()) {
  169. MPUI1610_SAVE(OMAP_IH1_MIR);
  170. MPUI1610_SAVE(OMAP_IH2_0_MIR);
  171. MPUI1610_SAVE(OMAP_IH2_1_MIR);
  172. MPUI1610_SAVE(OMAP_IH2_2_MIR);
  173. MPUI1610_SAVE(OMAP_IH2_3_MIR);
  174. MPUI1610_SAVE(MPUI_CTRL);
  175. MPUI1610_SAVE(MPUI_DSP_BOOT_CONFIG);
  176. MPUI1610_SAVE(MPUI_DSP_API_CONFIG);
  177. MPUI1610_SAVE(EMIFS_CONFIG);
  178. MPUI1610_SAVE(EMIFF_SDRAM_CONFIG);
  179. }
  180. ARM_SAVE(ARM_CKCTL);
  181. ARM_SAVE(ARM_IDLECT1);
  182. ARM_SAVE(ARM_IDLECT2);
  183. if (!(cpu_is_omap1510()))
  184. ARM_SAVE(ARM_IDLECT3);
  185. ARM_SAVE(ARM_EWUPCT);
  186. ARM_SAVE(ARM_RSTCT1);
  187. ARM_SAVE(ARM_RSTCT2);
  188. ARM_SAVE(ARM_SYSST);
  189. ULPD_SAVE(ULPD_CLOCK_CTRL);
  190. ULPD_SAVE(ULPD_STATUS_REQ);
  191. /* (Step 3 removed - we now allow deep sleep by default) */
  192. /*
  193. * Step 4: OMAP DSP Shutdown
  194. */
  195. /*
  196. * Step 5: Wakeup Event Setup
  197. */
  198. omap_pm_wakeup_setup();
  199. /*
  200. * Step 6: ARM and Traffic controller shutdown
  201. */
  202. /* disable ARM watchdog */
  203. omap_writel(0x00F5, OMAP_WDT_TIMER_MODE);
  204. omap_writel(0x00A0, OMAP_WDT_TIMER_MODE);
  205. /*
  206. * Step 6b: ARM and Traffic controller shutdown
  207. *
  208. * Step 6 continues here. Prepare jump to power management
  209. * assembly code in internal SRAM.
  210. *
  211. * Since the omap_cpu_suspend routine has been copied to
  212. * SRAM, we'll do an indirect procedure call to it and pass the
  213. * contents of arm_idlect1 and arm_idlect2 so it can restore
  214. * them when it wakes up and it will return.
  215. */
  216. arg0 = arm_sleep_save[ARM_SLEEP_SAVE_ARM_IDLECT1];
  217. arg1 = arm_sleep_save[ARM_SLEEP_SAVE_ARM_IDLECT2];
  218. /*
  219. * Step 6c: ARM and Traffic controller shutdown
  220. *
  221. * Jump to assembly code. The processor will stay there
  222. * until wake up.
  223. */
  224. omap_sram_suspend(arg0, arg1);
  225. /*
  226. * If we are here, processor is woken up!
  227. */
  228. /*
  229. * Restore ARM state, except ARM_IDLECT1/2 which omap_cpu_suspend did
  230. */
  231. if (!(cpu_is_omap1510()))
  232. ARM_RESTORE(ARM_IDLECT3);
  233. ARM_RESTORE(ARM_CKCTL);
  234. ARM_RESTORE(ARM_EWUPCT);
  235. ARM_RESTORE(ARM_RSTCT1);
  236. ARM_RESTORE(ARM_RSTCT2);
  237. ARM_RESTORE(ARM_SYSST);
  238. ULPD_RESTORE(ULPD_CLOCK_CTRL);
  239. ULPD_RESTORE(ULPD_STATUS_REQ);
  240. if (cpu_is_omap1510()) {
  241. MPUI1510_RESTORE(MPUI_CTRL);
  242. MPUI1510_RESTORE(MPUI_DSP_BOOT_CONFIG);
  243. MPUI1510_RESTORE(MPUI_DSP_API_CONFIG);
  244. MPUI1510_RESTORE(EMIFS_CONFIG);
  245. MPUI1510_RESTORE(EMIFF_SDRAM_CONFIG);
  246. MPUI1510_RESTORE(OMAP_IH1_MIR);
  247. MPUI1510_RESTORE(OMAP_IH2_MIR);
  248. } else if (cpu_is_omap16xx()) {
  249. MPUI1610_RESTORE(MPUI_CTRL);
  250. MPUI1610_RESTORE(MPUI_DSP_BOOT_CONFIG);
  251. MPUI1610_RESTORE(MPUI_DSP_API_CONFIG);
  252. MPUI1610_RESTORE(EMIFS_CONFIG);
  253. MPUI1610_RESTORE(EMIFF_SDRAM_CONFIG);
  254. MPUI1610_RESTORE(OMAP_IH1_MIR);
  255. MPUI1610_RESTORE(OMAP_IH2_0_MIR);
  256. MPUI1610_RESTORE(OMAP_IH2_1_MIR);
  257. MPUI1610_RESTORE(OMAP_IH2_2_MIR);
  258. MPUI1610_RESTORE(OMAP_IH2_3_MIR);
  259. }
  260. omap_writew(0, ULPD_SOFT_DISABLE_REQ_REG);
  261. /*
  262. * Reenable interrupts
  263. */
  264. local_irq_enable();
  265. local_fiq_enable();
  266. omap_serial_wake_trigger(0);
  267. printk("PM: OMAP%x is re-starting from deep sleep...\n", system_rev);
  268. if (machine_is_omap_osk()) {
  269. /* Let LED1 (D9) blink again */
  270. tps65010_set_led(LED1, BLINK);
  271. }
  272. }
  273. #if defined(DEBUG) && defined(CONFIG_PROC_FS)
  274. static int g_read_completed;
  275. /*
  276. * Read system PM registers for debugging
  277. */
  278. static int omap_pm_read_proc(
  279. char *page_buffer,
  280. char **my_first_byte,
  281. off_t virtual_start,
  282. int length,
  283. int *eof,
  284. void *data)
  285. {
  286. int my_buffer_offset = 0;
  287. char * const my_base = page_buffer;
  288. ARM_SAVE(ARM_CKCTL);
  289. ARM_SAVE(ARM_IDLECT1);
  290. ARM_SAVE(ARM_IDLECT2);
  291. if (!(cpu_is_omap1510()))
  292. ARM_SAVE(ARM_IDLECT3);
  293. ARM_SAVE(ARM_EWUPCT);
  294. ARM_SAVE(ARM_RSTCT1);
  295. ARM_SAVE(ARM_RSTCT2);
  296. ARM_SAVE(ARM_SYSST);
  297. ULPD_SAVE(ULPD_IT_STATUS);
  298. ULPD_SAVE(ULPD_CLOCK_CTRL);
  299. ULPD_SAVE(ULPD_SOFT_REQ);
  300. ULPD_SAVE(ULPD_STATUS_REQ);
  301. ULPD_SAVE(ULPD_DPLL_CTRL);
  302. ULPD_SAVE(ULPD_POWER_CTRL);
  303. if (cpu_is_omap1510()) {
  304. MPUI1510_SAVE(MPUI_CTRL);
  305. MPUI1510_SAVE(MPUI_DSP_STATUS);
  306. MPUI1510_SAVE(MPUI_DSP_BOOT_CONFIG);
  307. MPUI1510_SAVE(MPUI_DSP_API_CONFIG);
  308. MPUI1510_SAVE(EMIFF_SDRAM_CONFIG);
  309. MPUI1510_SAVE(EMIFS_CONFIG);
  310. } else if (cpu_is_omap16xx()) {
  311. MPUI1610_SAVE(MPUI_CTRL);
  312. MPUI1610_SAVE(MPUI_DSP_STATUS);
  313. MPUI1610_SAVE(MPUI_DSP_BOOT_CONFIG);
  314. MPUI1610_SAVE(MPUI_DSP_API_CONFIG);
  315. MPUI1610_SAVE(EMIFF_SDRAM_CONFIG);
  316. MPUI1610_SAVE(EMIFS_CONFIG);
  317. }
  318. if (virtual_start == 0) {
  319. g_read_completed = 0;
  320. my_buffer_offset += sprintf(my_base + my_buffer_offset,
  321. "ARM_CKCTL_REG: 0x%-8x \n"
  322. "ARM_IDLECT1_REG: 0x%-8x \n"
  323. "ARM_IDLECT2_REG: 0x%-8x \n"
  324. "ARM_IDLECT3_REG: 0x%-8x \n"
  325. "ARM_EWUPCT_REG: 0x%-8x \n"
  326. "ARM_RSTCT1_REG: 0x%-8x \n"
  327. "ARM_RSTCT2_REG: 0x%-8x \n"
  328. "ARM_SYSST_REG: 0x%-8x \n"
  329. "ULPD_IT_STATUS_REG: 0x%-4x \n"
  330. "ULPD_CLOCK_CTRL_REG: 0x%-4x \n"
  331. "ULPD_SOFT_REQ_REG: 0x%-4x \n"
  332. "ULPD_DPLL_CTRL_REG: 0x%-4x \n"
  333. "ULPD_STATUS_REQ_REG: 0x%-4x \n"
  334. "ULPD_POWER_CTRL_REG: 0x%-4x \n",
  335. ARM_SHOW(ARM_CKCTL),
  336. ARM_SHOW(ARM_IDLECT1),
  337. ARM_SHOW(ARM_IDLECT2),
  338. ARM_SHOW(ARM_IDLECT3),
  339. ARM_SHOW(ARM_EWUPCT),
  340. ARM_SHOW(ARM_RSTCT1),
  341. ARM_SHOW(ARM_RSTCT2),
  342. ARM_SHOW(ARM_SYSST),
  343. ULPD_SHOW(ULPD_IT_STATUS),
  344. ULPD_SHOW(ULPD_CLOCK_CTRL),
  345. ULPD_SHOW(ULPD_SOFT_REQ),
  346. ULPD_SHOW(ULPD_DPLL_CTRL),
  347. ULPD_SHOW(ULPD_STATUS_REQ),
  348. ULPD_SHOW(ULPD_POWER_CTRL));
  349. if (cpu_is_omap1510()) {
  350. my_buffer_offset += sprintf(my_base + my_buffer_offset,
  351. "MPUI1510_CTRL_REG 0x%-8x \n"
  352. "MPUI1510_DSP_STATUS_REG: 0x%-8x \n"
  353. "MPUI1510_DSP_BOOT_CONFIG_REG: 0x%-8x \n"
  354. "MPUI1510_DSP_API_CONFIG_REG: 0x%-8x \n"
  355. "MPUI1510_SDRAM_CONFIG_REG: 0x%-8x \n"
  356. "MPUI1510_EMIFS_CONFIG_REG: 0x%-8x \n",
  357. MPUI1510_SHOW(MPUI_CTRL),
  358. MPUI1510_SHOW(MPUI_DSP_STATUS),
  359. MPUI1510_SHOW(MPUI_DSP_BOOT_CONFIG),
  360. MPUI1510_SHOW(MPUI_DSP_API_CONFIG),
  361. MPUI1510_SHOW(EMIFF_SDRAM_CONFIG),
  362. MPUI1510_SHOW(EMIFS_CONFIG));
  363. } else if (cpu_is_omap16xx()) {
  364. my_buffer_offset += sprintf(my_base + my_buffer_offset,
  365. "MPUI1610_CTRL_REG 0x%-8x \n"
  366. "MPUI1610_DSP_STATUS_REG: 0x%-8x \n"
  367. "MPUI1610_DSP_BOOT_CONFIG_REG: 0x%-8x \n"
  368. "MPUI1610_DSP_API_CONFIG_REG: 0x%-8x \n"
  369. "MPUI1610_SDRAM_CONFIG_REG: 0x%-8x \n"
  370. "MPUI1610_EMIFS_CONFIG_REG: 0x%-8x \n",
  371. MPUI1610_SHOW(MPUI_CTRL),
  372. MPUI1610_SHOW(MPUI_DSP_STATUS),
  373. MPUI1610_SHOW(MPUI_DSP_BOOT_CONFIG),
  374. MPUI1610_SHOW(MPUI_DSP_API_CONFIG),
  375. MPUI1610_SHOW(EMIFF_SDRAM_CONFIG),
  376. MPUI1610_SHOW(EMIFS_CONFIG));
  377. }
  378. g_read_completed++;
  379. } else if (g_read_completed >= 1) {
  380. *eof = 1;
  381. return 0;
  382. }
  383. g_read_completed++;
  384. *my_first_byte = page_buffer;
  385. return my_buffer_offset;
  386. }
  387. static void omap_pm_init_proc(void)
  388. {
  389. struct proc_dir_entry *entry;
  390. entry = create_proc_read_entry("driver/omap_pm",
  391. S_IWUSR | S_IRUGO, NULL,
  392. omap_pm_read_proc, NULL);
  393. }
  394. #endif /* DEBUG && CONFIG_PROC_FS */
  395. /*
  396. * omap_pm_prepare - Do preliminary suspend work.
  397. * @state: suspend state we're entering.
  398. *
  399. */
  400. //#include <asm/arch/hardware.h>
  401. static int omap_pm_prepare(suspend_state_t state)
  402. {
  403. int error = 0;
  404. switch (state)
  405. {
  406. case PM_SUSPEND_STANDBY:
  407. case PM_SUSPEND_MEM:
  408. break;
  409. case PM_SUSPEND_DISK:
  410. return -ENOTSUPP;
  411. default:
  412. return -EINVAL;
  413. }
  414. return error;
  415. }
  416. /*
  417. * omap_pm_enter - Actually enter a sleep state.
  418. * @state: State we're entering.
  419. *
  420. */
  421. static int omap_pm_enter(suspend_state_t state)
  422. {
  423. switch (state)
  424. {
  425. case PM_SUSPEND_STANDBY:
  426. case PM_SUSPEND_MEM:
  427. omap_pm_suspend();
  428. break;
  429. case PM_SUSPEND_DISK:
  430. return -ENOTSUPP;
  431. default:
  432. return -EINVAL;
  433. }
  434. return 0;
  435. }
  436. /**
  437. * omap_pm_finish - Finish up suspend sequence.
  438. * @state: State we're coming out of.
  439. *
  440. * This is called after we wake back up (or if entering the sleep state
  441. * failed).
  442. */
  443. static int omap_pm_finish(suspend_state_t state)
  444. {
  445. return 0;
  446. }
  447. static irqreturn_t omap_wakeup_interrupt(int irq, void * dev,
  448. struct pt_regs * regs)
  449. {
  450. return IRQ_HANDLED;
  451. }
  452. static struct irqaction omap_wakeup_irq = {
  453. .name = "peripheral wakeup",
  454. .flags = SA_INTERRUPT,
  455. .handler = omap_wakeup_interrupt
  456. };
  457. static struct pm_ops omap_pm_ops ={
  458. .pm_disk_mode = 0,
  459. .prepare = omap_pm_prepare,
  460. .enter = omap_pm_enter,
  461. .finish = omap_pm_finish,
  462. };
  463. static int __init omap_pm_init(void)
  464. {
  465. printk("Power Management for TI OMAP.\n");
  466. /*
  467. * We copy the assembler sleep/wakeup routines to SRAM.
  468. * These routines need to be in SRAM as that's the only
  469. * memory the MPU can see when it wakes up.
  470. */
  471. if (cpu_is_omap1510()) {
  472. omap_sram_idle = omap_sram_push(omap1510_idle_loop_suspend,
  473. omap1510_idle_loop_suspend_sz);
  474. omap_sram_suspend = omap_sram_push(omap1510_cpu_suspend,
  475. omap1510_cpu_suspend_sz);
  476. } else if (cpu_is_omap16xx()) {
  477. omap_sram_idle = omap_sram_push(omap1610_idle_loop_suspend,
  478. omap1610_idle_loop_suspend_sz);
  479. omap_sram_suspend = omap_sram_push(omap1610_cpu_suspend,
  480. omap1610_cpu_suspend_sz);
  481. }
  482. if (omap_sram_idle == NULL || omap_sram_suspend == NULL) {
  483. printk(KERN_ERR "PM not initialized: Missing SRAM support\n");
  484. return -ENODEV;
  485. }
  486. pm_idle = omap_pm_idle;
  487. setup_irq(INT_1610_WAKE_UP_REQ, &omap_wakeup_irq);
  488. #if 0
  489. /* --- BEGIN BOARD-DEPENDENT CODE --- */
  490. /* Sleepx mask direction */
  491. omap_writew((omap_readw(0xfffb5008) & ~2), 0xfffb5008);
  492. /* Unmask sleepx signal */
  493. omap_writew((omap_readw(0xfffb5004) & ~2), 0xfffb5004);
  494. /* --- END BOARD-DEPENDENT CODE --- */
  495. #endif
  496. /* Program new power ramp-up time
  497. * (0 for most boards since we don't lower voltage when in deep sleep)
  498. */
  499. omap_writew(ULPD_SETUP_ANALOG_CELL_3_VAL, ULPD_SETUP_ANALOG_CELL_3);
  500. /* Setup ULPD POWER_CTRL_REG - enter deep sleep whenever possible */
  501. omap_writew(ULPD_POWER_CTRL_REG_VAL, ULPD_POWER_CTRL);
  502. /* Configure IDLECT3 */
  503. if (cpu_is_omap16xx())
  504. omap_writel(OMAP1610_IDLECT3_VAL, OMAP1610_IDLECT3);
  505. pm_set_ops(&omap_pm_ops);
  506. #if defined(DEBUG) && defined(CONFIG_PROC_FS)
  507. omap_pm_init_proc();
  508. #endif
  509. /* configure LOW_PWR pin */
  510. omap_cfg_reg(T20_1610_LOW_PWR);
  511. return 0;
  512. }
  513. __initcall(omap_pm_init);