pm34xx.c 30 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096
  1. /*
  2. * OMAP3 Power Management Routines
  3. *
  4. * Copyright (C) 2006-2008 Nokia Corporation
  5. * Tony Lindgren <tony@atomide.com>
  6. * Jouni Hogander
  7. *
  8. * Copyright (C) 2007 Texas Instruments, Inc.
  9. * Rajendra Nayak <rnayak@ti.com>
  10. *
  11. * Copyright (C) 2005 Texas Instruments, Inc.
  12. * Richard Woodruff <r-woodruff2@ti.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/pm.h>
  21. #include <linux/suspend.h>
  22. #include <linux/interrupt.h>
  23. #include <linux/module.h>
  24. #include <linux/list.h>
  25. #include <linux/err.h>
  26. #include <linux/gpio.h>
  27. #include <linux/clk.h>
  28. #include <linux/delay.h>
  29. #include <linux/slab.h>
  30. #include <linux/console.h>
  31. #include <plat/sram.h>
  32. #include "clockdomain.h"
  33. #include "powerdomain.h"
  34. #include <plat/serial.h>
  35. #include <plat/sdrc.h>
  36. #include <plat/prcm.h>
  37. #include <plat/gpmc.h>
  38. #include <plat/dma.h>
  39. #include <asm/tlbflush.h>
  40. #include "cm2xxx_3xxx.h"
  41. #include "cm-regbits-34xx.h"
  42. #include "prm-regbits-34xx.h"
  43. #include "prm2xxx_3xxx.h"
  44. #include "pm.h"
  45. #include "sdrc.h"
  46. #include "control.h"
  47. #ifdef CONFIG_SUSPEND
  48. static suspend_state_t suspend_state = PM_SUSPEND_ON;
  49. static inline bool is_suspending(void)
  50. {
  51. return (suspend_state != PM_SUSPEND_ON);
  52. }
  53. #else
  54. static inline bool is_suspending(void)
  55. {
  56. return false;
  57. }
  58. #endif
  59. /* Scratchpad offsets */
  60. #define OMAP343X_TABLE_ADDRESS_OFFSET 0xc4
  61. #define OMAP343X_TABLE_VALUE_OFFSET 0xc0
  62. #define OMAP343X_CONTROL_REG_VALUE_OFFSET 0xc8
  63. /* pm34xx errata defined in pm.h */
  64. u16 pm34xx_errata;
  65. struct power_state {
  66. struct powerdomain *pwrdm;
  67. u32 next_state;
  68. #ifdef CONFIG_SUSPEND
  69. u32 saved_state;
  70. #endif
  71. struct list_head node;
  72. };
  73. static LIST_HEAD(pwrst_list);
  74. static void (*_omap_sram_idle)(u32 *addr, int save_state);
  75. static int (*_omap_save_secure_sram)(u32 *addr);
  76. static struct powerdomain *mpu_pwrdm, *neon_pwrdm;
  77. static struct powerdomain *core_pwrdm, *per_pwrdm;
  78. static struct powerdomain *cam_pwrdm;
  79. static inline void omap3_per_save_context(void)
  80. {
  81. omap_gpio_save_context();
  82. }
  83. static inline void omap3_per_restore_context(void)
  84. {
  85. omap_gpio_restore_context();
  86. }
  87. static void omap3_enable_io_chain(void)
  88. {
  89. int timeout = 0;
  90. if (omap_rev() >= OMAP3430_REV_ES3_1) {
  91. omap2_prm_set_mod_reg_bits(OMAP3430_EN_IO_CHAIN_MASK, WKUP_MOD,
  92. PM_WKEN);
  93. /* Do a readback to assure write has been done */
  94. omap2_prm_read_mod_reg(WKUP_MOD, PM_WKEN);
  95. while (!(omap2_prm_read_mod_reg(WKUP_MOD, PM_WKEN) &
  96. OMAP3430_ST_IO_CHAIN_MASK)) {
  97. timeout++;
  98. if (timeout > 1000) {
  99. printk(KERN_ERR "Wake up daisy chain "
  100. "activation failed.\n");
  101. return;
  102. }
  103. omap2_prm_set_mod_reg_bits(OMAP3430_ST_IO_CHAIN_MASK,
  104. WKUP_MOD, PM_WKEN);
  105. }
  106. }
  107. }
  108. static void omap3_disable_io_chain(void)
  109. {
  110. if (omap_rev() >= OMAP3430_REV_ES3_1)
  111. omap2_prm_clear_mod_reg_bits(OMAP3430_EN_IO_CHAIN_MASK, WKUP_MOD,
  112. PM_WKEN);
  113. }
  114. static void omap3_core_save_context(void)
  115. {
  116. omap3_ctrl_save_padconf();
  117. /*
  118. * Force write last pad into memory, as this can fail in some
  119. * cases according to errata 1.157, 1.185
  120. */
  121. omap_ctrl_writel(omap_ctrl_readl(OMAP343X_PADCONF_ETK_D14),
  122. OMAP343X_CONTROL_MEM_WKUP + 0x2a0);
  123. /* Save the Interrupt controller context */
  124. omap_intc_save_context();
  125. /* Save the GPMC context */
  126. omap3_gpmc_save_context();
  127. /* Save the system control module context, padconf already save above*/
  128. omap3_control_save_context();
  129. omap_dma_global_context_save();
  130. }
  131. static void omap3_core_restore_context(void)
  132. {
  133. /* Restore the control module context, padconf restored by h/w */
  134. omap3_control_restore_context();
  135. /* Restore the GPMC context */
  136. omap3_gpmc_restore_context();
  137. /* Restore the interrupt controller context */
  138. omap_intc_restore_context();
  139. omap_dma_global_context_restore();
  140. }
  141. /*
  142. * FIXME: This function should be called before entering off-mode after
  143. * OMAP3 secure services have been accessed. Currently it is only called
  144. * once during boot sequence, but this works as we are not using secure
  145. * services.
  146. */
  147. static void omap3_save_secure_ram_context(void)
  148. {
  149. u32 ret;
  150. int mpu_next_state = pwrdm_read_next_pwrst(mpu_pwrdm);
  151. if (omap_type() != OMAP2_DEVICE_TYPE_GP) {
  152. /*
  153. * MPU next state must be set to POWER_ON temporarily,
  154. * otherwise the WFI executed inside the ROM code
  155. * will hang the system.
  156. */
  157. pwrdm_set_next_pwrst(mpu_pwrdm, PWRDM_POWER_ON);
  158. ret = _omap_save_secure_sram((u32 *)
  159. __pa(omap3_secure_ram_storage));
  160. pwrdm_set_next_pwrst(mpu_pwrdm, mpu_next_state);
  161. /* Following is for error tracking, it should not happen */
  162. if (ret) {
  163. printk(KERN_ERR "save_secure_sram() returns %08x\n",
  164. ret);
  165. while (1)
  166. ;
  167. }
  168. }
  169. }
  170. /*
  171. * PRCM Interrupt Handler Helper Function
  172. *
  173. * The purpose of this function is to clear any wake-up events latched
  174. * in the PRCM PM_WKST_x registers. It is possible that a wake-up event
  175. * may occur whilst attempting to clear a PM_WKST_x register and thus
  176. * set another bit in this register. A while loop is used to ensure
  177. * that any peripheral wake-up events occurring while attempting to
  178. * clear the PM_WKST_x are detected and cleared.
  179. */
  180. static int prcm_clear_mod_irqs(s16 module, u8 regs)
  181. {
  182. u32 wkst, fclk, iclk, clken;
  183. u16 wkst_off = (regs == 3) ? OMAP3430ES2_PM_WKST3 : PM_WKST1;
  184. u16 fclk_off = (regs == 3) ? OMAP3430ES2_CM_FCLKEN3 : CM_FCLKEN1;
  185. u16 iclk_off = (regs == 3) ? CM_ICLKEN3 : CM_ICLKEN1;
  186. u16 grpsel_off = (regs == 3) ?
  187. OMAP3430ES2_PM_MPUGRPSEL3 : OMAP3430_PM_MPUGRPSEL;
  188. int c = 0;
  189. wkst = omap2_prm_read_mod_reg(module, wkst_off);
  190. wkst &= omap2_prm_read_mod_reg(module, grpsel_off);
  191. if (wkst) {
  192. iclk = omap2_cm_read_mod_reg(module, iclk_off);
  193. fclk = omap2_cm_read_mod_reg(module, fclk_off);
  194. while (wkst) {
  195. clken = wkst;
  196. omap2_cm_set_mod_reg_bits(clken, module, iclk_off);
  197. /*
  198. * For USBHOST, we don't know whether HOST1 or
  199. * HOST2 woke us up, so enable both f-clocks
  200. */
  201. if (module == OMAP3430ES2_USBHOST_MOD)
  202. clken |= 1 << OMAP3430ES2_EN_USBHOST2_SHIFT;
  203. omap2_cm_set_mod_reg_bits(clken, module, fclk_off);
  204. omap2_prm_write_mod_reg(wkst, module, wkst_off);
  205. wkst = omap2_prm_read_mod_reg(module, wkst_off);
  206. c++;
  207. }
  208. omap2_cm_write_mod_reg(iclk, module, iclk_off);
  209. omap2_cm_write_mod_reg(fclk, module, fclk_off);
  210. }
  211. return c;
  212. }
  213. static int _prcm_int_handle_wakeup(void)
  214. {
  215. int c;
  216. c = prcm_clear_mod_irqs(WKUP_MOD, 1);
  217. c += prcm_clear_mod_irqs(CORE_MOD, 1);
  218. c += prcm_clear_mod_irqs(OMAP3430_PER_MOD, 1);
  219. if (omap_rev() > OMAP3430_REV_ES1_0) {
  220. c += prcm_clear_mod_irqs(CORE_MOD, 3);
  221. c += prcm_clear_mod_irqs(OMAP3430ES2_USBHOST_MOD, 1);
  222. }
  223. return c;
  224. }
  225. /*
  226. * PRCM Interrupt Handler
  227. *
  228. * The PRM_IRQSTATUS_MPU register indicates if there are any pending
  229. * interrupts from the PRCM for the MPU. These bits must be cleared in
  230. * order to clear the PRCM interrupt. The PRCM interrupt handler is
  231. * implemented to simply clear the PRM_IRQSTATUS_MPU in order to clear
  232. * the PRCM interrupt. Please note that bit 0 of the PRM_IRQSTATUS_MPU
  233. * register indicates that a wake-up event is pending for the MPU and
  234. * this bit can only be cleared if the all the wake-up events latched
  235. * in the various PM_WKST_x registers have been cleared. The interrupt
  236. * handler is implemented using a do-while loop so that if a wake-up
  237. * event occurred during the processing of the prcm interrupt handler
  238. * (setting a bit in the corresponding PM_WKST_x register and thus
  239. * preventing us from clearing bit 0 of the PRM_IRQSTATUS_MPU register)
  240. * this would be handled.
  241. */
  242. static irqreturn_t prcm_interrupt_handler (int irq, void *dev_id)
  243. {
  244. u32 irqenable_mpu, irqstatus_mpu;
  245. int c = 0;
  246. irqenable_mpu = omap2_prm_read_mod_reg(OCP_MOD,
  247. OMAP3_PRM_IRQENABLE_MPU_OFFSET);
  248. irqstatus_mpu = omap2_prm_read_mod_reg(OCP_MOD,
  249. OMAP3_PRM_IRQSTATUS_MPU_OFFSET);
  250. irqstatus_mpu &= irqenable_mpu;
  251. do {
  252. if (irqstatus_mpu & (OMAP3430_WKUP_ST_MASK |
  253. OMAP3430_IO_ST_MASK)) {
  254. c = _prcm_int_handle_wakeup();
  255. /*
  256. * Is the MPU PRCM interrupt handler racing with the
  257. * IVA2 PRCM interrupt handler ?
  258. */
  259. WARN(c == 0, "prcm: WARNING: PRCM indicated MPU wakeup "
  260. "but no wakeup sources are marked\n");
  261. } else {
  262. /* XXX we need to expand our PRCM interrupt handler */
  263. WARN(1, "prcm: WARNING: PRCM interrupt received, but "
  264. "no code to handle it (%08x)\n", irqstatus_mpu);
  265. }
  266. omap2_prm_write_mod_reg(irqstatus_mpu, OCP_MOD,
  267. OMAP3_PRM_IRQSTATUS_MPU_OFFSET);
  268. irqstatus_mpu = omap2_prm_read_mod_reg(OCP_MOD,
  269. OMAP3_PRM_IRQSTATUS_MPU_OFFSET);
  270. irqstatus_mpu &= irqenable_mpu;
  271. } while (irqstatus_mpu);
  272. return IRQ_HANDLED;
  273. }
  274. /* Function to restore the table entry that was modified for enabling MMU */
  275. static void restore_table_entry(void)
  276. {
  277. void __iomem *scratchpad_address;
  278. u32 previous_value, control_reg_value;
  279. u32 *address;
  280. scratchpad_address = OMAP2_L4_IO_ADDRESS(OMAP343X_SCRATCHPAD);
  281. /* Get address of entry that was modified */
  282. address = (u32 *)__raw_readl(scratchpad_address +
  283. OMAP343X_TABLE_ADDRESS_OFFSET);
  284. /* Get the previous value which needs to be restored */
  285. previous_value = __raw_readl(scratchpad_address +
  286. OMAP343X_TABLE_VALUE_OFFSET);
  287. address = __va(address);
  288. *address = previous_value;
  289. flush_tlb_all();
  290. control_reg_value = __raw_readl(scratchpad_address
  291. + OMAP343X_CONTROL_REG_VALUE_OFFSET);
  292. /* This will enable caches and prediction */
  293. set_cr(control_reg_value);
  294. }
  295. void omap_sram_idle(void)
  296. {
  297. /* Variable to tell what needs to be saved and restored
  298. * in omap_sram_idle*/
  299. /* save_state = 0 => Nothing to save and restored */
  300. /* save_state = 1 => Only L1 and logic lost */
  301. /* save_state = 2 => Only L2 lost */
  302. /* save_state = 3 => L1, L2 and logic lost */
  303. int save_state = 0;
  304. int mpu_next_state = PWRDM_POWER_ON;
  305. int per_next_state = PWRDM_POWER_ON;
  306. int core_next_state = PWRDM_POWER_ON;
  307. int per_going_off;
  308. int core_prev_state, per_prev_state;
  309. u32 sdrc_pwr = 0;
  310. if (!_omap_sram_idle)
  311. return;
  312. pwrdm_clear_all_prev_pwrst(mpu_pwrdm);
  313. pwrdm_clear_all_prev_pwrst(neon_pwrdm);
  314. pwrdm_clear_all_prev_pwrst(core_pwrdm);
  315. pwrdm_clear_all_prev_pwrst(per_pwrdm);
  316. mpu_next_state = pwrdm_read_next_pwrst(mpu_pwrdm);
  317. switch (mpu_next_state) {
  318. case PWRDM_POWER_ON:
  319. case PWRDM_POWER_RET:
  320. /* No need to save context */
  321. save_state = 0;
  322. break;
  323. case PWRDM_POWER_OFF:
  324. save_state = 3;
  325. break;
  326. default:
  327. /* Invalid state */
  328. printk(KERN_ERR "Invalid mpu state in sram_idle\n");
  329. return;
  330. }
  331. pwrdm_pre_transition();
  332. /* NEON control */
  333. if (pwrdm_read_pwrst(neon_pwrdm) == PWRDM_POWER_ON)
  334. pwrdm_set_next_pwrst(neon_pwrdm, mpu_next_state);
  335. /* Enable IO-PAD and IO-CHAIN wakeups */
  336. per_next_state = pwrdm_read_next_pwrst(per_pwrdm);
  337. core_next_state = pwrdm_read_next_pwrst(core_pwrdm);
  338. if (omap3_has_io_wakeup() &&
  339. (per_next_state < PWRDM_POWER_ON ||
  340. core_next_state < PWRDM_POWER_ON)) {
  341. omap2_prm_set_mod_reg_bits(OMAP3430_EN_IO_MASK, WKUP_MOD, PM_WKEN);
  342. omap3_enable_io_chain();
  343. }
  344. /* Block console output in case it is on one of the OMAP UARTs */
  345. if (!is_suspending())
  346. if (per_next_state < PWRDM_POWER_ON ||
  347. core_next_state < PWRDM_POWER_ON)
  348. if (!console_trylock())
  349. goto console_still_active;
  350. /* PER */
  351. if (per_next_state < PWRDM_POWER_ON) {
  352. per_going_off = (per_next_state == PWRDM_POWER_OFF) ? 1 : 0;
  353. omap_uart_prepare_idle(2);
  354. omap_uart_prepare_idle(3);
  355. omap2_gpio_prepare_for_idle(per_going_off);
  356. if (per_next_state == PWRDM_POWER_OFF)
  357. omap3_per_save_context();
  358. }
  359. /* CORE */
  360. if (core_next_state < PWRDM_POWER_ON) {
  361. omap_uart_prepare_idle(0);
  362. omap_uart_prepare_idle(1);
  363. if (core_next_state == PWRDM_POWER_OFF) {
  364. omap3_core_save_context();
  365. omap3_cm_save_context();
  366. }
  367. }
  368. omap3_intc_prepare_idle();
  369. /*
  370. * On EMU/HS devices ROM code restores a SRDC value
  371. * from scratchpad which has automatic self refresh on timeout
  372. * of AUTO_CNT = 1 enabled. This takes care of erratum ID i443.
  373. * Hence store/restore the SDRC_POWER register here.
  374. */
  375. if (omap_rev() >= OMAP3430_REV_ES3_0 &&
  376. omap_type() != OMAP2_DEVICE_TYPE_GP &&
  377. core_next_state == PWRDM_POWER_OFF)
  378. sdrc_pwr = sdrc_read_reg(SDRC_POWER);
  379. /*
  380. * omap3_arm_context is the location where ARM registers
  381. * get saved. The restore path then reads from this
  382. * location and restores them back.
  383. */
  384. _omap_sram_idle(omap3_arm_context, save_state);
  385. cpu_init();
  386. /* Restore normal SDRC POWER settings */
  387. if (omap_rev() >= OMAP3430_REV_ES3_0 &&
  388. omap_type() != OMAP2_DEVICE_TYPE_GP &&
  389. core_next_state == PWRDM_POWER_OFF)
  390. sdrc_write_reg(sdrc_pwr, SDRC_POWER);
  391. /* Restore table entry modified during MMU restoration */
  392. if (pwrdm_read_prev_pwrst(mpu_pwrdm) == PWRDM_POWER_OFF)
  393. restore_table_entry();
  394. /* CORE */
  395. if (core_next_state < PWRDM_POWER_ON) {
  396. core_prev_state = pwrdm_read_prev_pwrst(core_pwrdm);
  397. if (core_prev_state == PWRDM_POWER_OFF) {
  398. omap3_core_restore_context();
  399. omap3_cm_restore_context();
  400. omap3_sram_restore_context();
  401. omap2_sms_restore_context();
  402. }
  403. omap_uart_resume_idle(0);
  404. omap_uart_resume_idle(1);
  405. if (core_next_state == PWRDM_POWER_OFF)
  406. omap2_prm_clear_mod_reg_bits(OMAP3430_AUTO_OFF_MASK,
  407. OMAP3430_GR_MOD,
  408. OMAP3_PRM_VOLTCTRL_OFFSET);
  409. }
  410. omap3_intc_resume_idle();
  411. /* PER */
  412. if (per_next_state < PWRDM_POWER_ON) {
  413. per_prev_state = pwrdm_read_prev_pwrst(per_pwrdm);
  414. omap2_gpio_resume_after_idle();
  415. if (per_prev_state == PWRDM_POWER_OFF)
  416. omap3_per_restore_context();
  417. omap_uart_resume_idle(2);
  418. omap_uart_resume_idle(3);
  419. }
  420. if (!is_suspending())
  421. console_unlock();
  422. console_still_active:
  423. /* Disable IO-PAD and IO-CHAIN wakeup */
  424. if (omap3_has_io_wakeup() &&
  425. (per_next_state < PWRDM_POWER_ON ||
  426. core_next_state < PWRDM_POWER_ON)) {
  427. omap2_prm_clear_mod_reg_bits(OMAP3430_EN_IO_MASK, WKUP_MOD,
  428. PM_WKEN);
  429. omap3_disable_io_chain();
  430. }
  431. pwrdm_post_transition();
  432. omap2_clkdm_allow_idle(mpu_pwrdm->pwrdm_clkdms[0]);
  433. }
  434. int omap3_can_sleep(void)
  435. {
  436. if (!sleep_while_idle)
  437. return 0;
  438. if (!omap_uart_can_sleep())
  439. return 0;
  440. return 1;
  441. }
  442. static void omap3_pm_idle(void)
  443. {
  444. local_irq_disable();
  445. local_fiq_disable();
  446. if (!omap3_can_sleep())
  447. goto out;
  448. if (omap_irq_pending() || need_resched())
  449. goto out;
  450. omap_sram_idle();
  451. out:
  452. local_fiq_enable();
  453. local_irq_enable();
  454. }
  455. #ifdef CONFIG_SUSPEND
  456. static int omap3_pm_suspend(void)
  457. {
  458. struct power_state *pwrst;
  459. int state, ret = 0;
  460. if (wakeup_timer_seconds || wakeup_timer_milliseconds)
  461. omap2_pm_wakeup_on_timer(wakeup_timer_seconds,
  462. wakeup_timer_milliseconds);
  463. /* Read current next_pwrsts */
  464. list_for_each_entry(pwrst, &pwrst_list, node)
  465. pwrst->saved_state = pwrdm_read_next_pwrst(pwrst->pwrdm);
  466. /* Set ones wanted by suspend */
  467. list_for_each_entry(pwrst, &pwrst_list, node) {
  468. if (omap_set_pwrdm_state(pwrst->pwrdm, pwrst->next_state))
  469. goto restore;
  470. if (pwrdm_clear_all_prev_pwrst(pwrst->pwrdm))
  471. goto restore;
  472. }
  473. omap_uart_prepare_suspend();
  474. omap3_intc_suspend();
  475. omap_sram_idle();
  476. restore:
  477. /* Restore next_pwrsts */
  478. list_for_each_entry(pwrst, &pwrst_list, node) {
  479. state = pwrdm_read_prev_pwrst(pwrst->pwrdm);
  480. if (state > pwrst->next_state) {
  481. printk(KERN_INFO "Powerdomain (%s) didn't enter "
  482. "target state %d\n",
  483. pwrst->pwrdm->name, pwrst->next_state);
  484. ret = -1;
  485. }
  486. omap_set_pwrdm_state(pwrst->pwrdm, pwrst->saved_state);
  487. }
  488. if (ret)
  489. printk(KERN_ERR "Could not enter target state in pm_suspend\n");
  490. else
  491. printk(KERN_INFO "Successfully put all powerdomains "
  492. "to target state\n");
  493. return ret;
  494. }
  495. static int omap3_pm_enter(suspend_state_t unused)
  496. {
  497. int ret = 0;
  498. switch (suspend_state) {
  499. case PM_SUSPEND_STANDBY:
  500. case PM_SUSPEND_MEM:
  501. ret = omap3_pm_suspend();
  502. break;
  503. default:
  504. ret = -EINVAL;
  505. }
  506. return ret;
  507. }
  508. /* Hooks to enable / disable UART interrupts during suspend */
  509. static int omap3_pm_begin(suspend_state_t state)
  510. {
  511. disable_hlt();
  512. suspend_state = state;
  513. omap_uart_enable_irqs(0);
  514. return 0;
  515. }
  516. static void omap3_pm_end(void)
  517. {
  518. suspend_state = PM_SUSPEND_ON;
  519. omap_uart_enable_irqs(1);
  520. enable_hlt();
  521. return;
  522. }
  523. static const struct platform_suspend_ops omap_pm_ops = {
  524. .begin = omap3_pm_begin,
  525. .end = omap3_pm_end,
  526. .enter = omap3_pm_enter,
  527. .valid = suspend_valid_only_mem,
  528. };
  529. #endif /* CONFIG_SUSPEND */
  530. /**
  531. * omap3_iva_idle(): ensure IVA is in idle so it can be put into
  532. * retention
  533. *
  534. * In cases where IVA2 is activated by bootcode, it may prevent
  535. * full-chip retention or off-mode because it is not idle. This
  536. * function forces the IVA2 into idle state so it can go
  537. * into retention/off and thus allow full-chip retention/off.
  538. *
  539. **/
  540. static void __init omap3_iva_idle(void)
  541. {
  542. /* ensure IVA2 clock is disabled */
  543. omap2_cm_write_mod_reg(0, OMAP3430_IVA2_MOD, CM_FCLKEN);
  544. /* if no clock activity, nothing else to do */
  545. if (!(omap2_cm_read_mod_reg(OMAP3430_IVA2_MOD, OMAP3430_CM_CLKSTST) &
  546. OMAP3430_CLKACTIVITY_IVA2_MASK))
  547. return;
  548. /* Reset IVA2 */
  549. omap2_prm_write_mod_reg(OMAP3430_RST1_IVA2_MASK |
  550. OMAP3430_RST2_IVA2_MASK |
  551. OMAP3430_RST3_IVA2_MASK,
  552. OMAP3430_IVA2_MOD, OMAP2_RM_RSTCTRL);
  553. /* Enable IVA2 clock */
  554. omap2_cm_write_mod_reg(OMAP3430_CM_FCLKEN_IVA2_EN_IVA2_MASK,
  555. OMAP3430_IVA2_MOD, CM_FCLKEN);
  556. /* Set IVA2 boot mode to 'idle' */
  557. omap_ctrl_writel(OMAP3_IVA2_BOOTMOD_IDLE,
  558. OMAP343X_CONTROL_IVA2_BOOTMOD);
  559. /* Un-reset IVA2 */
  560. omap2_prm_write_mod_reg(0, OMAP3430_IVA2_MOD, OMAP2_RM_RSTCTRL);
  561. /* Disable IVA2 clock */
  562. omap2_cm_write_mod_reg(0, OMAP3430_IVA2_MOD, CM_FCLKEN);
  563. /* Reset IVA2 */
  564. omap2_prm_write_mod_reg(OMAP3430_RST1_IVA2_MASK |
  565. OMAP3430_RST2_IVA2_MASK |
  566. OMAP3430_RST3_IVA2_MASK,
  567. OMAP3430_IVA2_MOD, OMAP2_RM_RSTCTRL);
  568. }
  569. static void __init omap3_d2d_idle(void)
  570. {
  571. u16 mask, padconf;
  572. /* In a stand alone OMAP3430 where there is not a stacked
  573. * modem for the D2D Idle Ack and D2D MStandby must be pulled
  574. * high. S CONTROL_PADCONF_SAD2D_IDLEACK and
  575. * CONTROL_PADCONF_SAD2D_MSTDBY to have a pull up. */
  576. mask = (1 << 4) | (1 << 3); /* pull-up, enabled */
  577. padconf = omap_ctrl_readw(OMAP3_PADCONF_SAD2D_MSTANDBY);
  578. padconf |= mask;
  579. omap_ctrl_writew(padconf, OMAP3_PADCONF_SAD2D_MSTANDBY);
  580. padconf = omap_ctrl_readw(OMAP3_PADCONF_SAD2D_IDLEACK);
  581. padconf |= mask;
  582. omap_ctrl_writew(padconf, OMAP3_PADCONF_SAD2D_IDLEACK);
  583. /* reset modem */
  584. omap2_prm_write_mod_reg(OMAP3430_RM_RSTCTRL_CORE_MODEM_SW_RSTPWRON_MASK |
  585. OMAP3430_RM_RSTCTRL_CORE_MODEM_SW_RST_MASK,
  586. CORE_MOD, OMAP2_RM_RSTCTRL);
  587. omap2_prm_write_mod_reg(0, CORE_MOD, OMAP2_RM_RSTCTRL);
  588. }
  589. static void __init prcm_setup_regs(void)
  590. {
  591. u32 omap3630_auto_uart4_mask = cpu_is_omap3630() ?
  592. OMAP3630_AUTO_UART4_MASK : 0;
  593. u32 omap3630_en_uart4_mask = cpu_is_omap3630() ?
  594. OMAP3630_EN_UART4_MASK : 0;
  595. u32 omap3630_grpsel_uart4_mask = cpu_is_omap3630() ?
  596. OMAP3630_GRPSEL_UART4_MASK : 0;
  597. /*
  598. * Enable interface clock autoidle for all modules.
  599. * Note that in the long run this should be done by clockfw
  600. */
  601. omap2_cm_write_mod_reg(
  602. OMAP3430_AUTO_MODEM_MASK |
  603. OMAP3430ES2_AUTO_MMC3_MASK |
  604. OMAP3430ES2_AUTO_ICR_MASK |
  605. OMAP3430_AUTO_AES2_MASK |
  606. OMAP3430_AUTO_SHA12_MASK |
  607. OMAP3430_AUTO_DES2_MASK |
  608. OMAP3430_AUTO_MMC2_MASK |
  609. OMAP3430_AUTO_MMC1_MASK |
  610. OMAP3430_AUTO_MSPRO_MASK |
  611. OMAP3430_AUTO_HDQ_MASK |
  612. OMAP3430_AUTO_MCSPI4_MASK |
  613. OMAP3430_AUTO_MCSPI3_MASK |
  614. OMAP3430_AUTO_MCSPI2_MASK |
  615. OMAP3430_AUTO_MCSPI1_MASK |
  616. OMAP3430_AUTO_I2C3_MASK |
  617. OMAP3430_AUTO_I2C2_MASK |
  618. OMAP3430_AUTO_I2C1_MASK |
  619. OMAP3430_AUTO_UART2_MASK |
  620. OMAP3430_AUTO_UART1_MASK |
  621. OMAP3430_AUTO_GPT11_MASK |
  622. OMAP3430_AUTO_GPT10_MASK |
  623. OMAP3430_AUTO_MCBSP5_MASK |
  624. OMAP3430_AUTO_MCBSP1_MASK |
  625. OMAP3430ES1_AUTO_FAC_MASK | /* This is es1 only */
  626. OMAP3430_AUTO_MAILBOXES_MASK |
  627. OMAP3430_AUTO_OMAPCTRL_MASK |
  628. OMAP3430ES1_AUTO_FSHOSTUSB_MASK |
  629. OMAP3430_AUTO_HSOTGUSB_MASK |
  630. OMAP3430_AUTO_SAD2D_MASK |
  631. OMAP3430_AUTO_SSI_MASK,
  632. CORE_MOD, CM_AUTOIDLE1);
  633. omap2_cm_write_mod_reg(
  634. OMAP3430_AUTO_PKA_MASK |
  635. OMAP3430_AUTO_AES1_MASK |
  636. OMAP3430_AUTO_RNG_MASK |
  637. OMAP3430_AUTO_SHA11_MASK |
  638. OMAP3430_AUTO_DES1_MASK,
  639. CORE_MOD, CM_AUTOIDLE2);
  640. if (omap_rev() > OMAP3430_REV_ES1_0) {
  641. omap2_cm_write_mod_reg(
  642. OMAP3430_AUTO_MAD2D_MASK |
  643. OMAP3430ES2_AUTO_USBTLL_MASK,
  644. CORE_MOD, CM_AUTOIDLE3);
  645. }
  646. omap2_cm_write_mod_reg(
  647. OMAP3430_AUTO_WDT2_MASK |
  648. OMAP3430_AUTO_WDT1_MASK |
  649. OMAP3430_AUTO_GPIO1_MASK |
  650. OMAP3430_AUTO_32KSYNC_MASK |
  651. OMAP3430_AUTO_GPT12_MASK |
  652. OMAP3430_AUTO_GPT1_MASK,
  653. WKUP_MOD, CM_AUTOIDLE);
  654. omap2_cm_write_mod_reg(
  655. OMAP3430_AUTO_DSS_MASK,
  656. OMAP3430_DSS_MOD,
  657. CM_AUTOIDLE);
  658. omap2_cm_write_mod_reg(
  659. OMAP3430_AUTO_CAM_MASK,
  660. OMAP3430_CAM_MOD,
  661. CM_AUTOIDLE);
  662. omap2_cm_write_mod_reg(
  663. omap3630_auto_uart4_mask |
  664. OMAP3430_AUTO_GPIO6_MASK |
  665. OMAP3430_AUTO_GPIO5_MASK |
  666. OMAP3430_AUTO_GPIO4_MASK |
  667. OMAP3430_AUTO_GPIO3_MASK |
  668. OMAP3430_AUTO_GPIO2_MASK |
  669. OMAP3430_AUTO_WDT3_MASK |
  670. OMAP3430_AUTO_UART3_MASK |
  671. OMAP3430_AUTO_GPT9_MASK |
  672. OMAP3430_AUTO_GPT8_MASK |
  673. OMAP3430_AUTO_GPT7_MASK |
  674. OMAP3430_AUTO_GPT6_MASK |
  675. OMAP3430_AUTO_GPT5_MASK |
  676. OMAP3430_AUTO_GPT4_MASK |
  677. OMAP3430_AUTO_GPT3_MASK |
  678. OMAP3430_AUTO_GPT2_MASK |
  679. OMAP3430_AUTO_MCBSP4_MASK |
  680. OMAP3430_AUTO_MCBSP3_MASK |
  681. OMAP3430_AUTO_MCBSP2_MASK,
  682. OMAP3430_PER_MOD,
  683. CM_AUTOIDLE);
  684. if (omap_rev() > OMAP3430_REV_ES1_0) {
  685. omap2_cm_write_mod_reg(
  686. OMAP3430ES2_AUTO_USBHOST_MASK,
  687. OMAP3430ES2_USBHOST_MOD,
  688. CM_AUTOIDLE);
  689. }
  690. omap_ctrl_writel(OMAP3430_AUTOIDLE_MASK, OMAP2_CONTROL_SYSCONFIG);
  691. /*
  692. * Set all plls to autoidle. This is needed until autoidle is
  693. * enabled by clockfw
  694. */
  695. omap2_cm_write_mod_reg(1 << OMAP3430_AUTO_IVA2_DPLL_SHIFT,
  696. OMAP3430_IVA2_MOD, CM_AUTOIDLE2);
  697. omap2_cm_write_mod_reg(1 << OMAP3430_AUTO_MPU_DPLL_SHIFT,
  698. MPU_MOD,
  699. CM_AUTOIDLE2);
  700. omap2_cm_write_mod_reg((1 << OMAP3430_AUTO_PERIPH_DPLL_SHIFT) |
  701. (1 << OMAP3430_AUTO_CORE_DPLL_SHIFT),
  702. PLL_MOD,
  703. CM_AUTOIDLE);
  704. omap2_cm_write_mod_reg(1 << OMAP3430ES2_AUTO_PERIPH2_DPLL_SHIFT,
  705. PLL_MOD,
  706. CM_AUTOIDLE2);
  707. /*
  708. * Enable control of expternal oscillator through
  709. * sys_clkreq. In the long run clock framework should
  710. * take care of this.
  711. */
  712. omap2_prm_rmw_mod_reg_bits(OMAP_AUTOEXTCLKMODE_MASK,
  713. 1 << OMAP_AUTOEXTCLKMODE_SHIFT,
  714. OMAP3430_GR_MOD,
  715. OMAP3_PRM_CLKSRC_CTRL_OFFSET);
  716. /* setup wakup source */
  717. omap2_prm_write_mod_reg(OMAP3430_EN_IO_MASK | OMAP3430_EN_GPIO1_MASK |
  718. OMAP3430_EN_GPT1_MASK | OMAP3430_EN_GPT12_MASK,
  719. WKUP_MOD, PM_WKEN);
  720. /* No need to write EN_IO, that is always enabled */
  721. omap2_prm_write_mod_reg(OMAP3430_GRPSEL_GPIO1_MASK |
  722. OMAP3430_GRPSEL_GPT1_MASK |
  723. OMAP3430_GRPSEL_GPT12_MASK,
  724. WKUP_MOD, OMAP3430_PM_MPUGRPSEL);
  725. /* For some reason IO doesn't generate wakeup event even if
  726. * it is selected to mpu wakeup goup */
  727. omap2_prm_write_mod_reg(OMAP3430_IO_EN_MASK | OMAP3430_WKUP_EN_MASK,
  728. OCP_MOD, OMAP3_PRM_IRQENABLE_MPU_OFFSET);
  729. /* Enable PM_WKEN to support DSS LPR */
  730. omap2_prm_write_mod_reg(OMAP3430_PM_WKEN_DSS_EN_DSS_MASK,
  731. OMAP3430_DSS_MOD, PM_WKEN);
  732. /* Enable wakeups in PER */
  733. omap2_prm_write_mod_reg(omap3630_en_uart4_mask |
  734. OMAP3430_EN_GPIO2_MASK | OMAP3430_EN_GPIO3_MASK |
  735. OMAP3430_EN_GPIO4_MASK | OMAP3430_EN_GPIO5_MASK |
  736. OMAP3430_EN_GPIO6_MASK | OMAP3430_EN_UART3_MASK |
  737. OMAP3430_EN_MCBSP2_MASK | OMAP3430_EN_MCBSP3_MASK |
  738. OMAP3430_EN_MCBSP4_MASK,
  739. OMAP3430_PER_MOD, PM_WKEN);
  740. /* and allow them to wake up MPU */
  741. omap2_prm_write_mod_reg(omap3630_grpsel_uart4_mask |
  742. OMAP3430_GRPSEL_GPIO2_MASK |
  743. OMAP3430_GRPSEL_GPIO3_MASK |
  744. OMAP3430_GRPSEL_GPIO4_MASK |
  745. OMAP3430_GRPSEL_GPIO5_MASK |
  746. OMAP3430_GRPSEL_GPIO6_MASK |
  747. OMAP3430_GRPSEL_UART3_MASK |
  748. OMAP3430_GRPSEL_MCBSP2_MASK |
  749. OMAP3430_GRPSEL_MCBSP3_MASK |
  750. OMAP3430_GRPSEL_MCBSP4_MASK,
  751. OMAP3430_PER_MOD, OMAP3430_PM_MPUGRPSEL);
  752. /* Don't attach IVA interrupts */
  753. omap2_prm_write_mod_reg(0, WKUP_MOD, OMAP3430_PM_IVAGRPSEL);
  754. omap2_prm_write_mod_reg(0, CORE_MOD, OMAP3430_PM_IVAGRPSEL1);
  755. omap2_prm_write_mod_reg(0, CORE_MOD, OMAP3430ES2_PM_IVAGRPSEL3);
  756. omap2_prm_write_mod_reg(0, OMAP3430_PER_MOD, OMAP3430_PM_IVAGRPSEL);
  757. /* Clear any pending 'reset' flags */
  758. omap2_prm_write_mod_reg(0xffffffff, MPU_MOD, OMAP2_RM_RSTST);
  759. omap2_prm_write_mod_reg(0xffffffff, CORE_MOD, OMAP2_RM_RSTST);
  760. omap2_prm_write_mod_reg(0xffffffff, OMAP3430_PER_MOD, OMAP2_RM_RSTST);
  761. omap2_prm_write_mod_reg(0xffffffff, OMAP3430_EMU_MOD, OMAP2_RM_RSTST);
  762. omap2_prm_write_mod_reg(0xffffffff, OMAP3430_NEON_MOD, OMAP2_RM_RSTST);
  763. omap2_prm_write_mod_reg(0xffffffff, OMAP3430_DSS_MOD, OMAP2_RM_RSTST);
  764. omap2_prm_write_mod_reg(0xffffffff, OMAP3430ES2_USBHOST_MOD, OMAP2_RM_RSTST);
  765. /* Clear any pending PRCM interrupts */
  766. omap2_prm_write_mod_reg(0, OCP_MOD, OMAP3_PRM_IRQSTATUS_MPU_OFFSET);
  767. omap3_iva_idle();
  768. omap3_d2d_idle();
  769. }
  770. void omap3_pm_off_mode_enable(int enable)
  771. {
  772. struct power_state *pwrst;
  773. u32 state;
  774. if (enable)
  775. state = PWRDM_POWER_OFF;
  776. else
  777. state = PWRDM_POWER_RET;
  778. #ifdef CONFIG_CPU_IDLE
  779. /*
  780. * Erratum i583: implementation for ES rev < Es1.2 on 3630. We cannot
  781. * enable OFF mode in a stable form for previous revisions, restrict
  782. * instead to RET
  783. */
  784. if (IS_PM34XX_ERRATUM(PM_SDRC_WAKEUP_ERRATUM_i583))
  785. omap3_cpuidle_update_states(state, PWRDM_POWER_RET);
  786. else
  787. omap3_cpuidle_update_states(state, state);
  788. #endif
  789. list_for_each_entry(pwrst, &pwrst_list, node) {
  790. if (IS_PM34XX_ERRATUM(PM_SDRC_WAKEUP_ERRATUM_i583) &&
  791. pwrst->pwrdm == core_pwrdm &&
  792. state == PWRDM_POWER_OFF) {
  793. pwrst->next_state = PWRDM_POWER_RET;
  794. pr_warn("%s: Core OFF disabled due to errata i583\n",
  795. __func__);
  796. } else {
  797. pwrst->next_state = state;
  798. }
  799. omap_set_pwrdm_state(pwrst->pwrdm, pwrst->next_state);
  800. }
  801. }
  802. int omap3_pm_get_suspend_state(struct powerdomain *pwrdm)
  803. {
  804. struct power_state *pwrst;
  805. list_for_each_entry(pwrst, &pwrst_list, node) {
  806. if (pwrst->pwrdm == pwrdm)
  807. return pwrst->next_state;
  808. }
  809. return -EINVAL;
  810. }
  811. int omap3_pm_set_suspend_state(struct powerdomain *pwrdm, int state)
  812. {
  813. struct power_state *pwrst;
  814. list_for_each_entry(pwrst, &pwrst_list, node) {
  815. if (pwrst->pwrdm == pwrdm) {
  816. pwrst->next_state = state;
  817. return 0;
  818. }
  819. }
  820. return -EINVAL;
  821. }
  822. static int __init pwrdms_setup(struct powerdomain *pwrdm, void *unused)
  823. {
  824. struct power_state *pwrst;
  825. if (!pwrdm->pwrsts)
  826. return 0;
  827. pwrst = kmalloc(sizeof(struct power_state), GFP_ATOMIC);
  828. if (!pwrst)
  829. return -ENOMEM;
  830. pwrst->pwrdm = pwrdm;
  831. pwrst->next_state = PWRDM_POWER_RET;
  832. list_add(&pwrst->node, &pwrst_list);
  833. if (pwrdm_has_hdwr_sar(pwrdm))
  834. pwrdm_enable_hdwr_sar(pwrdm);
  835. return omap_set_pwrdm_state(pwrst->pwrdm, pwrst->next_state);
  836. }
  837. /*
  838. * Enable hw supervised mode for all clockdomains if it's
  839. * supported. Initiate sleep transition for other clockdomains, if
  840. * they are not used
  841. */
  842. static int __init clkdms_setup(struct clockdomain *clkdm, void *unused)
  843. {
  844. if (clkdm->flags & CLKDM_CAN_ENABLE_AUTO)
  845. omap2_clkdm_allow_idle(clkdm);
  846. else if (clkdm->flags & CLKDM_CAN_FORCE_SLEEP &&
  847. atomic_read(&clkdm->usecount) == 0)
  848. omap2_clkdm_sleep(clkdm);
  849. return 0;
  850. }
  851. void omap_push_sram_idle(void)
  852. {
  853. _omap_sram_idle = omap_sram_push(omap34xx_cpu_suspend,
  854. omap34xx_cpu_suspend_sz);
  855. if (omap_type() != OMAP2_DEVICE_TYPE_GP)
  856. _omap_save_secure_sram = omap_sram_push(save_secure_ram_context,
  857. save_secure_ram_context_sz);
  858. }
  859. static void __init pm_errata_configure(void)
  860. {
  861. if (cpu_is_omap3630()) {
  862. pm34xx_errata |= PM_RTA_ERRATUM_i608;
  863. /* Enable the l2 cache toggling in sleep logic */
  864. enable_omap3630_toggle_l2_on_restore();
  865. if (omap_rev() < OMAP3630_REV_ES1_2)
  866. pm34xx_errata |= PM_SDRC_WAKEUP_ERRATUM_i583;
  867. }
  868. }
  869. static int __init omap3_pm_init(void)
  870. {
  871. struct power_state *pwrst, *tmp;
  872. struct clockdomain *neon_clkdm, *per_clkdm, *mpu_clkdm, *core_clkdm;
  873. int ret;
  874. if (!cpu_is_omap34xx())
  875. return -ENODEV;
  876. pm_errata_configure();
  877. printk(KERN_ERR "Power Management for TI OMAP3.\n");
  878. /* XXX prcm_setup_regs needs to be before enabling hw
  879. * supervised mode for powerdomains */
  880. prcm_setup_regs();
  881. ret = request_irq(INT_34XX_PRCM_MPU_IRQ,
  882. (irq_handler_t)prcm_interrupt_handler,
  883. IRQF_DISABLED, "prcm", NULL);
  884. if (ret) {
  885. printk(KERN_ERR "request_irq failed to register for 0x%x\n",
  886. INT_34XX_PRCM_MPU_IRQ);
  887. goto err1;
  888. }
  889. ret = pwrdm_for_each(pwrdms_setup, NULL);
  890. if (ret) {
  891. printk(KERN_ERR "Failed to setup powerdomains\n");
  892. goto err2;
  893. }
  894. (void) clkdm_for_each(clkdms_setup, NULL);
  895. mpu_pwrdm = pwrdm_lookup("mpu_pwrdm");
  896. if (mpu_pwrdm == NULL) {
  897. printk(KERN_ERR "Failed to get mpu_pwrdm\n");
  898. goto err2;
  899. }
  900. neon_pwrdm = pwrdm_lookup("neon_pwrdm");
  901. per_pwrdm = pwrdm_lookup("per_pwrdm");
  902. core_pwrdm = pwrdm_lookup("core_pwrdm");
  903. cam_pwrdm = pwrdm_lookup("cam_pwrdm");
  904. neon_clkdm = clkdm_lookup("neon_clkdm");
  905. mpu_clkdm = clkdm_lookup("mpu_clkdm");
  906. per_clkdm = clkdm_lookup("per_clkdm");
  907. core_clkdm = clkdm_lookup("core_clkdm");
  908. omap_push_sram_idle();
  909. #ifdef CONFIG_SUSPEND
  910. suspend_set_ops(&omap_pm_ops);
  911. #endif /* CONFIG_SUSPEND */
  912. pm_idle = omap3_pm_idle;
  913. omap3_idle_init();
  914. /*
  915. * RTA is disabled during initialization as per erratum i608
  916. * it is safer to disable RTA by the bootloader, but we would like
  917. * to be doubly sure here and prevent any mishaps.
  918. */
  919. if (IS_PM34XX_ERRATUM(PM_RTA_ERRATUM_i608))
  920. omap3630_ctrl_disable_rta();
  921. clkdm_add_wkdep(neon_clkdm, mpu_clkdm);
  922. if (omap_type() != OMAP2_DEVICE_TYPE_GP) {
  923. omap3_secure_ram_storage =
  924. kmalloc(0x803F, GFP_KERNEL);
  925. if (!omap3_secure_ram_storage)
  926. printk(KERN_ERR "Memory allocation failed when"
  927. "allocating for secure sram context\n");
  928. local_irq_disable();
  929. local_fiq_disable();
  930. omap_dma_global_context_save();
  931. omap3_save_secure_ram_context();
  932. omap_dma_global_context_restore();
  933. local_irq_enable();
  934. local_fiq_enable();
  935. }
  936. omap3_save_scratchpad_contents();
  937. err1:
  938. return ret;
  939. err2:
  940. free_irq(INT_34XX_PRCM_MPU_IRQ, NULL);
  941. list_for_each_entry_safe(pwrst, tmp, &pwrst_list, node) {
  942. list_del(&pwrst->node);
  943. kfree(pwrst);
  944. }
  945. return ret;
  946. }
  947. late_initcall(omap3_pm_init);