pm34xx.c 29 KB

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