pm24xx.c 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591
  1. /*
  2. * OMAP2 Power Management Routines
  3. *
  4. * Copyright (C) 2005 Texas Instruments, Inc.
  5. * Copyright (C) 2006-2008 Nokia Corporation
  6. *
  7. * Written by:
  8. * Richard Woodruff <r-woodruff2@ti.com>
  9. * Tony Lindgren
  10. * Juha Yrjola
  11. * Amit Kucheria <amit.kucheria@nokia.com>
  12. * Igor Stoppa <igor.stoppa@nokia.com>
  13. *
  14. * Based on pm.c for omap1
  15. *
  16. * This program is free software; you can redistribute it and/or modify
  17. * it under the terms of the GNU General Public License version 2 as
  18. * published by the Free Software Foundation.
  19. */
  20. #include <linux/suspend.h>
  21. #include <linux/sched.h>
  22. #include <linux/proc_fs.h>
  23. #include <linux/interrupt.h>
  24. #include <linux/sysfs.h>
  25. #include <linux/module.h>
  26. #include <linux/delay.h>
  27. #include <linux/clk.h>
  28. #include <linux/io.h>
  29. #include <linux/irq.h>
  30. #include <linux/time.h>
  31. #include <linux/gpio.h>
  32. #include <linux/console.h>
  33. #include <asm/mach/time.h>
  34. #include <asm/mach/irq.h>
  35. #include <asm/mach-types.h>
  36. #include <mach/irqs.h>
  37. #include <plat/clock.h>
  38. #include <plat/sram.h>
  39. #include <plat/dma.h>
  40. #include <plat/board.h>
  41. #include "prm2xxx_3xxx.h"
  42. #include "prm-regbits-24xx.h"
  43. #include "cm2xxx_3xxx.h"
  44. #include "cm-regbits-24xx.h"
  45. #include "sdrc.h"
  46. #include "pm.h"
  47. #include "control.h"
  48. #include "powerdomain.h"
  49. #include "clockdomain.h"
  50. #ifdef CONFIG_SUSPEND
  51. static suspend_state_t suspend_state = PM_SUSPEND_ON;
  52. static inline bool is_suspending(void)
  53. {
  54. return (suspend_state != PM_SUSPEND_ON);
  55. }
  56. #else
  57. static inline bool is_suspending(void)
  58. {
  59. return false;
  60. }
  61. #endif
  62. static void (*omap2_sram_idle)(void);
  63. static void (*omap2_sram_suspend)(u32 dllctrl, void __iomem *sdrc_dlla_ctrl,
  64. void __iomem *sdrc_power);
  65. static struct powerdomain *mpu_pwrdm, *core_pwrdm;
  66. static struct clockdomain *dsp_clkdm, *mpu_clkdm, *wkup_clkdm, *gfx_clkdm;
  67. static struct clk *osc_ck, *emul_ck;
  68. static int omap2_fclks_active(void)
  69. {
  70. u32 f1, f2;
  71. f1 = omap2_cm_read_mod_reg(CORE_MOD, CM_FCLKEN1);
  72. f2 = omap2_cm_read_mod_reg(CORE_MOD, OMAP24XX_CM_FCLKEN2);
  73. /* Ignore UART clocks. These are handled by UART core (serial.c) */
  74. f1 &= ~(OMAP24XX_EN_UART1_MASK | OMAP24XX_EN_UART2_MASK);
  75. f2 &= ~OMAP24XX_EN_UART3_MASK;
  76. if (f1 | f2)
  77. return 1;
  78. return 0;
  79. }
  80. static void omap2_enter_full_retention(void)
  81. {
  82. u32 l;
  83. struct timespec ts_preidle, ts_postidle, ts_idle;
  84. /* There is 1 reference hold for all children of the oscillator
  85. * clock, the following will remove it. If no one else uses the
  86. * oscillator itself it will be disabled if/when we enter retention
  87. * mode.
  88. */
  89. clk_disable(osc_ck);
  90. /* Clear old wake-up events */
  91. /* REVISIT: These write to reserved bits? */
  92. omap2_prm_write_mod_reg(0xffffffff, CORE_MOD, PM_WKST1);
  93. omap2_prm_write_mod_reg(0xffffffff, CORE_MOD, OMAP24XX_PM_WKST2);
  94. omap2_prm_write_mod_reg(0xffffffff, WKUP_MOD, PM_WKST);
  95. /*
  96. * Set MPU powerdomain's next power state to RETENTION;
  97. * preserve logic state during retention
  98. */
  99. pwrdm_set_logic_retst(mpu_pwrdm, PWRDM_POWER_RET);
  100. pwrdm_set_next_pwrst(mpu_pwrdm, PWRDM_POWER_RET);
  101. /* Workaround to kill USB */
  102. l = omap_ctrl_readl(OMAP2_CONTROL_DEVCONF0) | OMAP24XX_USBSTANDBYCTRL;
  103. omap_ctrl_writel(l, OMAP2_CONTROL_DEVCONF0);
  104. omap2_gpio_prepare_for_idle(0);
  105. if (omap2_pm_debug) {
  106. omap2_pm_dump(0, 0, 0);
  107. getnstimeofday(&ts_preidle);
  108. }
  109. /* One last check for pending IRQs to avoid extra latency due
  110. * to sleeping unnecessarily. */
  111. if (omap_irq_pending())
  112. goto no_sleep;
  113. /* Block console output in case it is on one of the OMAP UARTs */
  114. if (!is_suspending())
  115. if (try_acquire_console_sem())
  116. goto no_sleep;
  117. omap_uart_prepare_idle(0);
  118. omap_uart_prepare_idle(1);
  119. omap_uart_prepare_idle(2);
  120. /* Jump to SRAM suspend code */
  121. omap2_sram_suspend(sdrc_read_reg(SDRC_DLLA_CTRL),
  122. OMAP_SDRC_REGADDR(SDRC_DLLA_CTRL),
  123. OMAP_SDRC_REGADDR(SDRC_POWER));
  124. omap_uart_resume_idle(2);
  125. omap_uart_resume_idle(1);
  126. omap_uart_resume_idle(0);
  127. if (!is_suspending())
  128. release_console_sem();
  129. no_sleep:
  130. if (omap2_pm_debug) {
  131. unsigned long long tmp;
  132. getnstimeofday(&ts_postidle);
  133. ts_idle = timespec_sub(ts_postidle, ts_preidle);
  134. tmp = timespec_to_ns(&ts_idle) * NSEC_PER_USEC;
  135. omap2_pm_dump(0, 1, tmp);
  136. }
  137. omap2_gpio_resume_after_idle();
  138. clk_enable(osc_ck);
  139. /* clear CORE wake-up events */
  140. omap2_prm_write_mod_reg(0xffffffff, CORE_MOD, PM_WKST1);
  141. omap2_prm_write_mod_reg(0xffffffff, CORE_MOD, OMAP24XX_PM_WKST2);
  142. /* wakeup domain events - bit 1: GPT1, bit5 GPIO */
  143. omap2_prm_clear_mod_reg_bits(0x4 | 0x1, WKUP_MOD, PM_WKST);
  144. /* MPU domain wake events */
  145. l = omap2_prm_read_mod_reg(OCP_MOD, OMAP2_PRCM_IRQSTATUS_MPU_OFFSET);
  146. if (l & 0x01)
  147. omap2_prm_write_mod_reg(0x01, OCP_MOD,
  148. OMAP2_PRCM_IRQSTATUS_MPU_OFFSET);
  149. if (l & 0x20)
  150. omap2_prm_write_mod_reg(0x20, OCP_MOD,
  151. OMAP2_PRCM_IRQSTATUS_MPU_OFFSET);
  152. /* Mask future PRCM-to-MPU interrupts */
  153. omap2_prm_write_mod_reg(0x0, OCP_MOD, OMAP2_PRCM_IRQSTATUS_MPU_OFFSET);
  154. }
  155. static int omap2_i2c_active(void)
  156. {
  157. u32 l;
  158. l = omap2_cm_read_mod_reg(CORE_MOD, CM_FCLKEN1);
  159. return l & (OMAP2420_EN_I2C2_MASK | OMAP2420_EN_I2C1_MASK);
  160. }
  161. static int sti_console_enabled;
  162. static int omap2_allow_mpu_retention(void)
  163. {
  164. u32 l;
  165. /* Check for MMC, UART2, UART1, McSPI2, McSPI1 and DSS1. */
  166. l = omap2_cm_read_mod_reg(CORE_MOD, CM_FCLKEN1);
  167. if (l & (OMAP2420_EN_MMC_MASK | OMAP24XX_EN_UART2_MASK |
  168. OMAP24XX_EN_UART1_MASK | OMAP24XX_EN_MCSPI2_MASK |
  169. OMAP24XX_EN_MCSPI1_MASK | OMAP24XX_EN_DSS1_MASK))
  170. return 0;
  171. /* Check for UART3. */
  172. l = omap2_cm_read_mod_reg(CORE_MOD, OMAP24XX_CM_FCLKEN2);
  173. if (l & OMAP24XX_EN_UART3_MASK)
  174. return 0;
  175. if (sti_console_enabled)
  176. return 0;
  177. return 1;
  178. }
  179. static void omap2_enter_mpu_retention(void)
  180. {
  181. int only_idle = 0;
  182. struct timespec ts_preidle, ts_postidle, ts_idle;
  183. /* Putting MPU into the WFI state while a transfer is active
  184. * seems to cause the I2C block to timeout. Why? Good question. */
  185. if (omap2_i2c_active())
  186. return;
  187. /* The peripherals seem not to be able to wake up the MPU when
  188. * it is in retention mode. */
  189. if (omap2_allow_mpu_retention()) {
  190. /* REVISIT: These write to reserved bits? */
  191. omap2_prm_write_mod_reg(0xffffffff, CORE_MOD, PM_WKST1);
  192. omap2_prm_write_mod_reg(0xffffffff, CORE_MOD, OMAP24XX_PM_WKST2);
  193. omap2_prm_write_mod_reg(0xffffffff, WKUP_MOD, PM_WKST);
  194. /* Try to enter MPU retention */
  195. omap2_prm_write_mod_reg((0x01 << OMAP_POWERSTATE_SHIFT) |
  196. OMAP_LOGICRETSTATE_MASK,
  197. MPU_MOD, OMAP2_PM_PWSTCTRL);
  198. } else {
  199. /* Block MPU retention */
  200. omap2_prm_write_mod_reg(OMAP_LOGICRETSTATE_MASK, MPU_MOD,
  201. OMAP2_PM_PWSTCTRL);
  202. only_idle = 1;
  203. }
  204. if (omap2_pm_debug) {
  205. omap2_pm_dump(only_idle ? 2 : 1, 0, 0);
  206. getnstimeofday(&ts_preidle);
  207. }
  208. omap2_sram_idle();
  209. if (omap2_pm_debug) {
  210. unsigned long long tmp;
  211. getnstimeofday(&ts_postidle);
  212. ts_idle = timespec_sub(ts_postidle, ts_preidle);
  213. tmp = timespec_to_ns(&ts_idle) * NSEC_PER_USEC;
  214. omap2_pm_dump(only_idle ? 2 : 1, 1, tmp);
  215. }
  216. }
  217. static int omap2_can_sleep(void)
  218. {
  219. if (omap2_fclks_active())
  220. return 0;
  221. if (!omap_uart_can_sleep())
  222. return 0;
  223. if (osc_ck->usecount > 1)
  224. return 0;
  225. if (omap_dma_running())
  226. return 0;
  227. return 1;
  228. }
  229. static void omap2_pm_idle(void)
  230. {
  231. local_irq_disable();
  232. local_fiq_disable();
  233. if (!omap2_can_sleep()) {
  234. if (omap_irq_pending())
  235. goto out;
  236. omap2_enter_mpu_retention();
  237. goto out;
  238. }
  239. if (omap_irq_pending())
  240. goto out;
  241. omap2_enter_full_retention();
  242. out:
  243. local_fiq_enable();
  244. local_irq_enable();
  245. }
  246. #ifdef CONFIG_SUSPEND
  247. static int omap2_pm_begin(suspend_state_t state)
  248. {
  249. disable_hlt();
  250. suspend_state = state;
  251. return 0;
  252. }
  253. static int omap2_pm_suspend(void)
  254. {
  255. u32 wken_wkup, mir1;
  256. wken_wkup = omap2_prm_read_mod_reg(WKUP_MOD, PM_WKEN);
  257. wken_wkup &= ~OMAP24XX_EN_GPT1_MASK;
  258. omap2_prm_write_mod_reg(wken_wkup, WKUP_MOD, PM_WKEN);
  259. /* Mask GPT1 */
  260. mir1 = omap_readl(0x480fe0a4);
  261. omap_writel(1 << 5, 0x480fe0ac);
  262. omap_uart_prepare_suspend();
  263. omap2_enter_full_retention();
  264. omap_writel(mir1, 0x480fe0a4);
  265. omap2_prm_write_mod_reg(wken_wkup, WKUP_MOD, PM_WKEN);
  266. return 0;
  267. }
  268. static int omap2_pm_enter(suspend_state_t state)
  269. {
  270. int ret = 0;
  271. switch (state) {
  272. case PM_SUSPEND_STANDBY:
  273. case PM_SUSPEND_MEM:
  274. ret = omap2_pm_suspend();
  275. break;
  276. default:
  277. ret = -EINVAL;
  278. }
  279. return ret;
  280. }
  281. static void omap2_pm_end(void)
  282. {
  283. suspend_state = PM_SUSPEND_ON;
  284. enable_hlt();
  285. }
  286. static const struct platform_suspend_ops omap_pm_ops = {
  287. .begin = omap2_pm_begin,
  288. .enter = omap2_pm_enter,
  289. .end = omap2_pm_end,
  290. .valid = suspend_valid_only_mem,
  291. };
  292. #else
  293. static const struct platform_suspend_ops __initdata omap_pm_ops;
  294. #endif /* CONFIG_SUSPEND */
  295. /* XXX This function should be shareable between OMAP2xxx and OMAP3 */
  296. static int __init clkdms_setup(struct clockdomain *clkdm, void *unused)
  297. {
  298. clkdm_clear_all_wkdeps(clkdm);
  299. clkdm_clear_all_sleepdeps(clkdm);
  300. if (clkdm->flags & CLKDM_CAN_ENABLE_AUTO)
  301. omap2_clkdm_allow_idle(clkdm);
  302. else if (clkdm->flags & CLKDM_CAN_FORCE_SLEEP &&
  303. atomic_read(&clkdm->usecount) == 0)
  304. omap2_clkdm_sleep(clkdm);
  305. return 0;
  306. }
  307. static void __init prcm_setup_regs(void)
  308. {
  309. int i, num_mem_banks;
  310. struct powerdomain *pwrdm;
  311. /* Enable autoidle */
  312. omap2_prm_write_mod_reg(OMAP24XX_AUTOIDLE_MASK, OCP_MOD,
  313. OMAP2_PRCM_SYSCONFIG_OFFSET);
  314. /*
  315. * Set CORE powerdomain memory banks to retain their contents
  316. * during RETENTION
  317. */
  318. num_mem_banks = pwrdm_get_mem_bank_count(core_pwrdm);
  319. for (i = 0; i < num_mem_banks; i++)
  320. pwrdm_set_mem_retst(core_pwrdm, i, PWRDM_POWER_RET);
  321. /* Set CORE powerdomain's next power state to RETENTION */
  322. pwrdm_set_next_pwrst(core_pwrdm, PWRDM_POWER_RET);
  323. /*
  324. * Set MPU powerdomain's next power state to RETENTION;
  325. * preserve logic state during retention
  326. */
  327. pwrdm_set_logic_retst(mpu_pwrdm, PWRDM_POWER_RET);
  328. pwrdm_set_next_pwrst(mpu_pwrdm, PWRDM_POWER_RET);
  329. /* Force-power down DSP, GFX powerdomains */
  330. pwrdm = clkdm_get_pwrdm(dsp_clkdm);
  331. pwrdm_set_next_pwrst(pwrdm, PWRDM_POWER_OFF);
  332. omap2_clkdm_sleep(dsp_clkdm);
  333. pwrdm = clkdm_get_pwrdm(gfx_clkdm);
  334. pwrdm_set_next_pwrst(pwrdm, PWRDM_POWER_OFF);
  335. omap2_clkdm_sleep(gfx_clkdm);
  336. /*
  337. * Clear clockdomain wakeup dependencies and enable
  338. * hardware-supervised idle for all clkdms
  339. */
  340. clkdm_for_each(clkdms_setup, NULL);
  341. clkdm_add_wkdep(mpu_clkdm, wkup_clkdm);
  342. /* Enable clock autoidle for all domains */
  343. omap2_cm_write_mod_reg(OMAP24XX_AUTO_CAM_MASK |
  344. OMAP24XX_AUTO_MAILBOXES_MASK |
  345. OMAP24XX_AUTO_WDT4_MASK |
  346. OMAP2420_AUTO_WDT3_MASK |
  347. OMAP24XX_AUTO_MSPRO_MASK |
  348. OMAP2420_AUTO_MMC_MASK |
  349. OMAP24XX_AUTO_FAC_MASK |
  350. OMAP2420_AUTO_EAC_MASK |
  351. OMAP24XX_AUTO_HDQ_MASK |
  352. OMAP24XX_AUTO_UART2_MASK |
  353. OMAP24XX_AUTO_UART1_MASK |
  354. OMAP24XX_AUTO_I2C2_MASK |
  355. OMAP24XX_AUTO_I2C1_MASK |
  356. OMAP24XX_AUTO_MCSPI2_MASK |
  357. OMAP24XX_AUTO_MCSPI1_MASK |
  358. OMAP24XX_AUTO_MCBSP2_MASK |
  359. OMAP24XX_AUTO_MCBSP1_MASK |
  360. OMAP24XX_AUTO_GPT12_MASK |
  361. OMAP24XX_AUTO_GPT11_MASK |
  362. OMAP24XX_AUTO_GPT10_MASK |
  363. OMAP24XX_AUTO_GPT9_MASK |
  364. OMAP24XX_AUTO_GPT8_MASK |
  365. OMAP24XX_AUTO_GPT7_MASK |
  366. OMAP24XX_AUTO_GPT6_MASK |
  367. OMAP24XX_AUTO_GPT5_MASK |
  368. OMAP24XX_AUTO_GPT4_MASK |
  369. OMAP24XX_AUTO_GPT3_MASK |
  370. OMAP24XX_AUTO_GPT2_MASK |
  371. OMAP2420_AUTO_VLYNQ_MASK |
  372. OMAP24XX_AUTO_DSS_MASK,
  373. CORE_MOD, CM_AUTOIDLE1);
  374. omap2_cm_write_mod_reg(OMAP24XX_AUTO_UART3_MASK |
  375. OMAP24XX_AUTO_SSI_MASK |
  376. OMAP24XX_AUTO_USB_MASK,
  377. CORE_MOD, CM_AUTOIDLE2);
  378. omap2_cm_write_mod_reg(OMAP24XX_AUTO_SDRC_MASK |
  379. OMAP24XX_AUTO_GPMC_MASK |
  380. OMAP24XX_AUTO_SDMA_MASK,
  381. CORE_MOD, CM_AUTOIDLE3);
  382. omap2_cm_write_mod_reg(OMAP24XX_AUTO_PKA_MASK |
  383. OMAP24XX_AUTO_AES_MASK |
  384. OMAP24XX_AUTO_RNG_MASK |
  385. OMAP24XX_AUTO_SHA_MASK |
  386. OMAP24XX_AUTO_DES_MASK,
  387. CORE_MOD, OMAP24XX_CM_AUTOIDLE4);
  388. omap2_cm_write_mod_reg(OMAP2420_AUTO_DSP_IPI_MASK, OMAP24XX_DSP_MOD,
  389. CM_AUTOIDLE);
  390. /* Put DPLL and both APLLs into autoidle mode */
  391. omap2_cm_write_mod_reg((0x03 << OMAP24XX_AUTO_DPLL_SHIFT) |
  392. (0x03 << OMAP24XX_AUTO_96M_SHIFT) |
  393. (0x03 << OMAP24XX_AUTO_54M_SHIFT),
  394. PLL_MOD, CM_AUTOIDLE);
  395. omap2_cm_write_mod_reg(OMAP24XX_AUTO_OMAPCTRL_MASK |
  396. OMAP24XX_AUTO_WDT1_MASK |
  397. OMAP24XX_AUTO_MPU_WDT_MASK |
  398. OMAP24XX_AUTO_GPIOS_MASK |
  399. OMAP24XX_AUTO_32KSYNC_MASK |
  400. OMAP24XX_AUTO_GPT1_MASK,
  401. WKUP_MOD, CM_AUTOIDLE);
  402. /* REVISIT: Configure number of 32 kHz clock cycles for sys_clk
  403. * stabilisation */
  404. omap2_prm_write_mod_reg(15 << OMAP_SETUP_TIME_SHIFT, OMAP24XX_GR_MOD,
  405. OMAP2_PRCM_CLKSSETUP_OFFSET);
  406. /* Configure automatic voltage transition */
  407. omap2_prm_write_mod_reg(2 << OMAP_SETUP_TIME_SHIFT, OMAP24XX_GR_MOD,
  408. OMAP2_PRCM_VOLTSETUP_OFFSET);
  409. omap2_prm_write_mod_reg(OMAP24XX_AUTO_EXTVOLT_MASK |
  410. (0x1 << OMAP24XX_SETOFF_LEVEL_SHIFT) |
  411. OMAP24XX_MEMRETCTRL_MASK |
  412. (0x1 << OMAP24XX_SETRET_LEVEL_SHIFT) |
  413. (0x0 << OMAP24XX_VOLT_LEVEL_SHIFT),
  414. OMAP24XX_GR_MOD, OMAP2_PRCM_VOLTCTRL_OFFSET);
  415. /* Enable wake-up events */
  416. omap2_prm_write_mod_reg(OMAP24XX_EN_GPIOS_MASK | OMAP24XX_EN_GPT1_MASK,
  417. WKUP_MOD, PM_WKEN);
  418. }
  419. static int __init omap2_pm_init(void)
  420. {
  421. u32 l;
  422. if (!cpu_is_omap24xx())
  423. return -ENODEV;
  424. printk(KERN_INFO "Power Management for OMAP2 initializing\n");
  425. l = omap2_prm_read_mod_reg(OCP_MOD, OMAP2_PRCM_REVISION_OFFSET);
  426. printk(KERN_INFO "PRCM revision %d.%d\n", (l >> 4) & 0x0f, l & 0x0f);
  427. /* Look up important powerdomains */
  428. mpu_pwrdm = pwrdm_lookup("mpu_pwrdm");
  429. if (!mpu_pwrdm)
  430. pr_err("PM: mpu_pwrdm not found\n");
  431. core_pwrdm = pwrdm_lookup("core_pwrdm");
  432. if (!core_pwrdm)
  433. pr_err("PM: core_pwrdm not found\n");
  434. /* Look up important clockdomains */
  435. mpu_clkdm = clkdm_lookup("mpu_clkdm");
  436. if (!mpu_clkdm)
  437. pr_err("PM: mpu_clkdm not found\n");
  438. wkup_clkdm = clkdm_lookup("wkup_clkdm");
  439. if (!wkup_clkdm)
  440. pr_err("PM: wkup_clkdm not found\n");
  441. dsp_clkdm = clkdm_lookup("dsp_clkdm");
  442. if (!dsp_clkdm)
  443. pr_err("PM: dsp_clkdm not found\n");
  444. gfx_clkdm = clkdm_lookup("gfx_clkdm");
  445. if (!gfx_clkdm)
  446. pr_err("PM: gfx_clkdm not found\n");
  447. osc_ck = clk_get(NULL, "osc_ck");
  448. if (IS_ERR(osc_ck)) {
  449. printk(KERN_ERR "could not get osc_ck\n");
  450. return -ENODEV;
  451. }
  452. if (cpu_is_omap242x()) {
  453. emul_ck = clk_get(NULL, "emul_ck");
  454. if (IS_ERR(emul_ck)) {
  455. printk(KERN_ERR "could not get emul_ck\n");
  456. clk_put(osc_ck);
  457. return -ENODEV;
  458. }
  459. }
  460. prcm_setup_regs();
  461. /* Hack to prevent MPU retention when STI console is enabled. */
  462. {
  463. const struct omap_sti_console_config *sti;
  464. sti = omap_get_config(OMAP_TAG_STI_CONSOLE,
  465. struct omap_sti_console_config);
  466. if (sti != NULL && sti->enable)
  467. sti_console_enabled = 1;
  468. }
  469. /*
  470. * We copy the assembler sleep/wakeup routines to SRAM.
  471. * These routines need to be in SRAM as that's the only
  472. * memory the MPU can see when it wakes up.
  473. */
  474. if (cpu_is_omap24xx()) {
  475. omap2_sram_idle = omap_sram_push(omap24xx_idle_loop_suspend,
  476. omap24xx_idle_loop_suspend_sz);
  477. omap2_sram_suspend = omap_sram_push(omap24xx_cpu_suspend,
  478. omap24xx_cpu_suspend_sz);
  479. }
  480. suspend_set_ops(&omap_pm_ops);
  481. pm_idle = omap2_pm_idle;
  482. return 0;
  483. }
  484. late_initcall(omap2_pm_init);