Kevin Hilman | 8bd2294 | 2009-05-28 10:56:16 -0700 | [diff] [blame] | 1 | /* |
| 2 | * OMAP3 Power Management Routines |
| 3 | * |
| 4 | * Copyright (C) 2006-2008 Nokia Corporation |
| 5 | * Tony Lindgren <tony@atomide.com> |
| 6 | * Jouni Hogander |
| 7 | * |
Rajendra Nayak | 2f5939c | 2008-09-26 17:50:07 +0530 | [diff] [blame] | 8 | * Copyright (C) 2007 Texas Instruments, Inc. |
| 9 | * Rajendra Nayak <rnayak@ti.com> |
| 10 | * |
Kevin Hilman | 8bd2294 | 2009-05-28 10:56:16 -0700 | [diff] [blame] | 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 | |
| 21 | #include <linux/pm.h> |
| 22 | #include <linux/suspend.h> |
| 23 | #include <linux/interrupt.h> |
| 24 | #include <linux/module.h> |
| 25 | #include <linux/list.h> |
| 26 | #include <linux/err.h> |
| 27 | #include <linux/gpio.h> |
Kevin Hilman | c40552b | 2009-10-06 14:25:09 -0700 | [diff] [blame] | 28 | #include <linux/clk.h> |
Kevin Hilman | 8bd2294 | 2009-05-28 10:56:16 -0700 | [diff] [blame] | 29 | |
Tony Lindgren | ce491cf | 2009-10-20 09:40:47 -0700 | [diff] [blame] | 30 | #include <plat/sram.h> |
| 31 | #include <plat/clockdomain.h> |
| 32 | #include <plat/powerdomain.h> |
| 33 | #include <plat/control.h> |
| 34 | #include <plat/serial.h> |
Rajendra Nayak | 61255ab | 2008-09-26 17:49:56 +0530 | [diff] [blame] | 35 | #include <plat/sdrc.h> |
Rajendra Nayak | 2f5939c | 2008-09-26 17:50:07 +0530 | [diff] [blame] | 36 | #include <plat/prcm.h> |
| 37 | #include <plat/gpmc.h> |
Tero Kristo | f2d1185 | 2008-08-28 13:13:31 +0000 | [diff] [blame] | 38 | #include <plat/dma.h> |
Kevin Hilman | d7814e4 | 2009-10-06 14:30:23 -0700 | [diff] [blame] | 39 | #include <plat/dmtimer.h> |
Kevin Hilman | 8bd2294 | 2009-05-28 10:56:16 -0700 | [diff] [blame] | 40 | |
Rajendra Nayak | 57f277b | 2008-09-26 17:49:34 +0530 | [diff] [blame] | 41 | #include <asm/tlbflush.h> |
| 42 | |
Kevin Hilman | 8bd2294 | 2009-05-28 10:56:16 -0700 | [diff] [blame] | 43 | #include "cm.h" |
| 44 | #include "cm-regbits-34xx.h" |
| 45 | #include "prm-regbits-34xx.h" |
| 46 | |
| 47 | #include "prm.h" |
| 48 | #include "pm.h" |
Tero Kristo | 13a6fe0f | 2008-10-13 13:17:06 +0300 | [diff] [blame] | 49 | #include "sdrc.h" |
| 50 | |
| 51 | #define SDRC_POWER_AUTOCOUNT_SHIFT 8 |
| 52 | #define SDRC_POWER_AUTOCOUNT_MASK (0xffff << SDRC_POWER_AUTOCOUNT_SHIFT) |
| 53 | #define SDRC_POWER_CLKCTRL_SHIFT 4 |
| 54 | #define SDRC_POWER_CLKCTRL_MASK (0x3 << SDRC_POWER_CLKCTRL_SHIFT) |
| 55 | #define SDRC_SELF_REFRESH_ON_AUTOCOUNT (0x2 << SDRC_POWER_CLKCTRL_SHIFT) |
Kevin Hilman | 8bd2294 | 2009-05-28 10:56:16 -0700 | [diff] [blame] | 56 | |
Rajendra Nayak | 2f5939c | 2008-09-26 17:50:07 +0530 | [diff] [blame] | 57 | /* Scratchpad offsets */ |
| 58 | #define OMAP343X_TABLE_ADDRESS_OFFSET 0x31 |
| 59 | #define OMAP343X_TABLE_VALUE_OFFSET 0x30 |
| 60 | #define OMAP343X_CONTROL_REG_VALUE_OFFSET 0x32 |
| 61 | |
Kevin Hilman | c40552b | 2009-10-06 14:25:09 -0700 | [diff] [blame] | 62 | u32 enable_off_mode; |
| 63 | u32 sleep_while_idle; |
Kevin Hilman | d7814e4 | 2009-10-06 14:30:23 -0700 | [diff] [blame] | 64 | u32 wakeup_timer_seconds; |
Kevin Hilman | c40552b | 2009-10-06 14:25:09 -0700 | [diff] [blame] | 65 | |
Kevin Hilman | 8bd2294 | 2009-05-28 10:56:16 -0700 | [diff] [blame] | 66 | struct power_state { |
| 67 | struct powerdomain *pwrdm; |
| 68 | u32 next_state; |
Kevin Hilman | 10f90ed | 2009-06-24 11:39:18 -0700 | [diff] [blame] | 69 | #ifdef CONFIG_SUSPEND |
Kevin Hilman | 8bd2294 | 2009-05-28 10:56:16 -0700 | [diff] [blame] | 70 | u32 saved_state; |
Kevin Hilman | 10f90ed | 2009-06-24 11:39:18 -0700 | [diff] [blame] | 71 | #endif |
Kevin Hilman | 8bd2294 | 2009-05-28 10:56:16 -0700 | [diff] [blame] | 72 | struct list_head node; |
| 73 | }; |
| 74 | |
| 75 | static LIST_HEAD(pwrst_list); |
| 76 | |
| 77 | static void (*_omap_sram_idle)(u32 *addr, int save_state); |
| 78 | |
Tero Kristo | 27d59a4 | 2008-10-13 13:15:00 +0300 | [diff] [blame] | 79 | static int (*_omap_save_secure_sram)(u32 *addr); |
| 80 | |
Rajendra Nayak | fa3c2a4 | 2008-09-26 17:49:22 +0530 | [diff] [blame] | 81 | static struct powerdomain *mpu_pwrdm, *neon_pwrdm; |
| 82 | static struct powerdomain *core_pwrdm, *per_pwrdm; |
| 83 | |
| 84 | static int set_pwrdm_state(struct powerdomain *pwrdm, u32 state); |
Kevin Hilman | 8bd2294 | 2009-05-28 10:56:16 -0700 | [diff] [blame] | 85 | |
Rajendra Nayak | 2f5939c | 2008-09-26 17:50:07 +0530 | [diff] [blame] | 86 | static inline void omap3_per_save_context(void) |
| 87 | { |
| 88 | omap_gpio_save_context(); |
| 89 | } |
| 90 | |
| 91 | static inline void omap3_per_restore_context(void) |
| 92 | { |
| 93 | omap_gpio_restore_context(); |
| 94 | } |
| 95 | |
| 96 | static void omap3_core_save_context(void) |
| 97 | { |
| 98 | u32 control_padconf_off; |
| 99 | |
| 100 | /* Save the padconf registers */ |
| 101 | control_padconf_off = omap_ctrl_readl(OMAP343X_CONTROL_PADCONF_OFF); |
| 102 | control_padconf_off |= START_PADCONF_SAVE; |
| 103 | omap_ctrl_writel(control_padconf_off, OMAP343X_CONTROL_PADCONF_OFF); |
| 104 | /* wait for the save to complete */ |
| 105 | while (!omap_ctrl_readl(OMAP343X_CONTROL_GENERAL_PURPOSE_STATUS) |
| 106 | & PADCONF_SAVE_DONE) |
| 107 | ; |
| 108 | /* Save the Interrupt controller context */ |
| 109 | omap_intc_save_context(); |
| 110 | /* Save the GPMC context */ |
| 111 | omap3_gpmc_save_context(); |
| 112 | /* Save the system control module context, padconf already save above*/ |
| 113 | omap3_control_save_context(); |
Tero Kristo | f2d1185 | 2008-08-28 13:13:31 +0000 | [diff] [blame] | 114 | omap_dma_global_context_save(); |
Rajendra Nayak | 2f5939c | 2008-09-26 17:50:07 +0530 | [diff] [blame] | 115 | } |
| 116 | |
| 117 | static void omap3_core_restore_context(void) |
| 118 | { |
| 119 | /* Restore the control module context, padconf restored by h/w */ |
| 120 | omap3_control_restore_context(); |
| 121 | /* Restore the GPMC context */ |
| 122 | omap3_gpmc_restore_context(); |
| 123 | /* Restore the interrupt controller context */ |
| 124 | omap_intc_restore_context(); |
Tero Kristo | f2d1185 | 2008-08-28 13:13:31 +0000 | [diff] [blame] | 125 | omap_dma_global_context_restore(); |
Rajendra Nayak | 2f5939c | 2008-09-26 17:50:07 +0530 | [diff] [blame] | 126 | } |
| 127 | |
Tero Kristo | 9d97140 | 2008-12-12 11:20:05 +0200 | [diff] [blame] | 128 | /* |
| 129 | * FIXME: This function should be called before entering off-mode after |
| 130 | * OMAP3 secure services have been accessed. Currently it is only called |
| 131 | * once during boot sequence, but this works as we are not using secure |
| 132 | * services. |
| 133 | */ |
Tero Kristo | 27d59a4 | 2008-10-13 13:15:00 +0300 | [diff] [blame] | 134 | static void omap3_save_secure_ram_context(u32 target_mpu_state) |
| 135 | { |
| 136 | u32 ret; |
| 137 | |
| 138 | if (omap_type() != OMAP2_DEVICE_TYPE_GP) { |
Tero Kristo | 27d59a4 | 2008-10-13 13:15:00 +0300 | [diff] [blame] | 139 | /* |
| 140 | * MPU next state must be set to POWER_ON temporarily, |
| 141 | * otherwise the WFI executed inside the ROM code |
| 142 | * will hang the system. |
| 143 | */ |
| 144 | pwrdm_set_next_pwrst(mpu_pwrdm, PWRDM_POWER_ON); |
| 145 | ret = _omap_save_secure_sram((u32 *) |
| 146 | __pa(omap3_secure_ram_storage)); |
| 147 | pwrdm_set_next_pwrst(mpu_pwrdm, target_mpu_state); |
| 148 | /* Following is for error tracking, it should not happen */ |
| 149 | if (ret) { |
| 150 | printk(KERN_ERR "save_secure_sram() returns %08x\n", |
| 151 | ret); |
| 152 | while (1) |
| 153 | ; |
| 154 | } |
| 155 | } |
| 156 | } |
| 157 | |
Jon Hunter | 77da2d9 | 2009-06-27 00:07:25 -0500 | [diff] [blame] | 158 | /* |
| 159 | * PRCM Interrupt Handler Helper Function |
| 160 | * |
| 161 | * The purpose of this function is to clear any wake-up events latched |
| 162 | * in the PRCM PM_WKST_x registers. It is possible that a wake-up event |
| 163 | * may occur whilst attempting to clear a PM_WKST_x register and thus |
| 164 | * set another bit in this register. A while loop is used to ensure |
| 165 | * that any peripheral wake-up events occurring while attempting to |
| 166 | * clear the PM_WKST_x are detected and cleared. |
| 167 | */ |
Paul Walmsley | 8cb0ac9 | 2009-07-22 10:29:02 -0700 | [diff] [blame] | 168 | static int prcm_clear_mod_irqs(s16 module, u8 regs) |
Jon Hunter | 77da2d9 | 2009-06-27 00:07:25 -0500 | [diff] [blame] | 169 | { |
Vikram Pandita | 71a8077 | 2009-07-17 19:33:09 -0500 | [diff] [blame] | 170 | u32 wkst, fclk, iclk, clken; |
Jon Hunter | 77da2d9 | 2009-06-27 00:07:25 -0500 | [diff] [blame] | 171 | u16 wkst_off = (regs == 3) ? OMAP3430ES2_PM_WKST3 : PM_WKST1; |
| 172 | u16 fclk_off = (regs == 3) ? OMAP3430ES2_CM_FCLKEN3 : CM_FCLKEN1; |
| 173 | u16 iclk_off = (regs == 3) ? CM_ICLKEN3 : CM_ICLKEN1; |
Paul Walmsley | 5d80597 | 2009-07-22 10:18:07 -0700 | [diff] [blame] | 174 | u16 grpsel_off = (regs == 3) ? |
| 175 | OMAP3430ES2_PM_MPUGRPSEL3 : OMAP3430_PM_MPUGRPSEL; |
Paul Walmsley | 8cb0ac9 | 2009-07-22 10:29:02 -0700 | [diff] [blame] | 176 | int c = 0; |
Jon Hunter | 77da2d9 | 2009-06-27 00:07:25 -0500 | [diff] [blame] | 177 | |
| 178 | wkst = prm_read_mod_reg(module, wkst_off); |
Paul Walmsley | 5d80597 | 2009-07-22 10:18:07 -0700 | [diff] [blame] | 179 | wkst &= prm_read_mod_reg(module, grpsel_off); |
Jon Hunter | 77da2d9 | 2009-06-27 00:07:25 -0500 | [diff] [blame] | 180 | if (wkst) { |
| 181 | iclk = cm_read_mod_reg(module, iclk_off); |
| 182 | fclk = cm_read_mod_reg(module, fclk_off); |
| 183 | while (wkst) { |
Vikram Pandita | 71a8077 | 2009-07-17 19:33:09 -0500 | [diff] [blame] | 184 | clken = wkst; |
| 185 | cm_set_mod_reg_bits(clken, module, iclk_off); |
| 186 | /* |
| 187 | * For USBHOST, we don't know whether HOST1 or |
| 188 | * HOST2 woke us up, so enable both f-clocks |
| 189 | */ |
| 190 | if (module == OMAP3430ES2_USBHOST_MOD) |
| 191 | clken |= 1 << OMAP3430ES2_EN_USBHOST2_SHIFT; |
| 192 | cm_set_mod_reg_bits(clken, module, fclk_off); |
Jon Hunter | 77da2d9 | 2009-06-27 00:07:25 -0500 | [diff] [blame] | 193 | prm_write_mod_reg(wkst, module, wkst_off); |
| 194 | wkst = prm_read_mod_reg(module, wkst_off); |
Paul Walmsley | 8cb0ac9 | 2009-07-22 10:29:02 -0700 | [diff] [blame] | 195 | c++; |
Jon Hunter | 77da2d9 | 2009-06-27 00:07:25 -0500 | [diff] [blame] | 196 | } |
| 197 | cm_write_mod_reg(iclk, module, iclk_off); |
| 198 | cm_write_mod_reg(fclk, module, fclk_off); |
| 199 | } |
Paul Walmsley | 8cb0ac9 | 2009-07-22 10:29:02 -0700 | [diff] [blame] | 200 | |
| 201 | return c; |
| 202 | } |
| 203 | |
| 204 | static int _prcm_int_handle_wakeup(void) |
| 205 | { |
| 206 | int c; |
| 207 | |
| 208 | c = prcm_clear_mod_irqs(WKUP_MOD, 1); |
| 209 | c += prcm_clear_mod_irqs(CORE_MOD, 1); |
| 210 | c += prcm_clear_mod_irqs(OMAP3430_PER_MOD, 1); |
| 211 | if (omap_rev() > OMAP3430_REV_ES1_0) { |
| 212 | c += prcm_clear_mod_irqs(CORE_MOD, 3); |
| 213 | c += prcm_clear_mod_irqs(OMAP3430ES2_USBHOST_MOD, 1); |
| 214 | } |
| 215 | |
| 216 | return c; |
Jon Hunter | 77da2d9 | 2009-06-27 00:07:25 -0500 | [diff] [blame] | 217 | } |
| 218 | |
| 219 | /* |
| 220 | * PRCM Interrupt Handler |
| 221 | * |
| 222 | * The PRM_IRQSTATUS_MPU register indicates if there are any pending |
| 223 | * interrupts from the PRCM for the MPU. These bits must be cleared in |
| 224 | * order to clear the PRCM interrupt. The PRCM interrupt handler is |
| 225 | * implemented to simply clear the PRM_IRQSTATUS_MPU in order to clear |
| 226 | * the PRCM interrupt. Please note that bit 0 of the PRM_IRQSTATUS_MPU |
| 227 | * register indicates that a wake-up event is pending for the MPU and |
| 228 | * this bit can only be cleared if the all the wake-up events latched |
| 229 | * in the various PM_WKST_x registers have been cleared. The interrupt |
| 230 | * handler is implemented using a do-while loop so that if a wake-up |
| 231 | * event occurred during the processing of the prcm interrupt handler |
| 232 | * (setting a bit in the corresponding PM_WKST_x register and thus |
| 233 | * preventing us from clearing bit 0 of the PRM_IRQSTATUS_MPU register) |
| 234 | * this would be handled. |
| 235 | */ |
Kevin Hilman | 8bd2294 | 2009-05-28 10:56:16 -0700 | [diff] [blame] | 236 | static irqreturn_t prcm_interrupt_handler (int irq, void *dev_id) |
| 237 | { |
Jon Hunter | 77da2d9 | 2009-06-27 00:07:25 -0500 | [diff] [blame] | 238 | u32 irqstatus_mpu; |
Paul Walmsley | 8cb0ac9 | 2009-07-22 10:29:02 -0700 | [diff] [blame] | 239 | int c = 0; |
Kevin Hilman | 8bd2294 | 2009-05-28 10:56:16 -0700 | [diff] [blame] | 240 | |
Jon Hunter | 77da2d9 | 2009-06-27 00:07:25 -0500 | [diff] [blame] | 241 | do { |
Jon Hunter | 77da2d9 | 2009-06-27 00:07:25 -0500 | [diff] [blame] | 242 | irqstatus_mpu = prm_read_mod_reg(OCP_MOD, |
| 243 | OMAP3_PRM_IRQSTATUS_MPU_OFFSET); |
Paul Walmsley | 8cb0ac9 | 2009-07-22 10:29:02 -0700 | [diff] [blame] | 244 | |
| 245 | if (irqstatus_mpu & (OMAP3430_WKUP_ST | OMAP3430_IO_ST)) { |
| 246 | c = _prcm_int_handle_wakeup(); |
| 247 | |
| 248 | /* |
| 249 | * Is the MPU PRCM interrupt handler racing with the |
| 250 | * IVA2 PRCM interrupt handler ? |
| 251 | */ |
| 252 | WARN(c == 0, "prcm: WARNING: PRCM indicated MPU wakeup " |
| 253 | "but no wakeup sources are marked\n"); |
| 254 | } else { |
| 255 | /* XXX we need to expand our PRCM interrupt handler */ |
| 256 | WARN(1, "prcm: WARNING: PRCM interrupt received, but " |
| 257 | "no code to handle it (%08x)\n", irqstatus_mpu); |
| 258 | } |
| 259 | |
Jon Hunter | 77da2d9 | 2009-06-27 00:07:25 -0500 | [diff] [blame] | 260 | prm_write_mod_reg(irqstatus_mpu, OCP_MOD, |
| 261 | OMAP3_PRM_IRQSTATUS_MPU_OFFSET); |
Kevin Hilman | 8bd2294 | 2009-05-28 10:56:16 -0700 | [diff] [blame] | 262 | |
Jon Hunter | 77da2d9 | 2009-06-27 00:07:25 -0500 | [diff] [blame] | 263 | } while (prm_read_mod_reg(OCP_MOD, OMAP3_PRM_IRQSTATUS_MPU_OFFSET)); |
Kevin Hilman | 8bd2294 | 2009-05-28 10:56:16 -0700 | [diff] [blame] | 264 | |
| 265 | return IRQ_HANDLED; |
| 266 | } |
| 267 | |
Rajendra Nayak | 57f277b | 2008-09-26 17:49:34 +0530 | [diff] [blame] | 268 | static void restore_control_register(u32 val) |
| 269 | { |
| 270 | __asm__ __volatile__ ("mcr p15, 0, %0, c1, c0, 0" : : "r" (val)); |
| 271 | } |
| 272 | |
| 273 | /* Function to restore the table entry that was modified for enabling MMU */ |
| 274 | static void restore_table_entry(void) |
| 275 | { |
| 276 | u32 *scratchpad_address; |
| 277 | u32 previous_value, control_reg_value; |
| 278 | u32 *address; |
| 279 | |
| 280 | scratchpad_address = OMAP2_L4_IO_ADDRESS(OMAP343X_SCRATCHPAD); |
| 281 | |
| 282 | /* Get address of entry that was modified */ |
| 283 | address = (u32 *)__raw_readl(scratchpad_address + |
| 284 | OMAP343X_TABLE_ADDRESS_OFFSET); |
| 285 | /* Get the previous value which needs to be restored */ |
| 286 | previous_value = __raw_readl(scratchpad_address + |
| 287 | OMAP343X_TABLE_VALUE_OFFSET); |
| 288 | address = __va(address); |
| 289 | *address = previous_value; |
| 290 | flush_tlb_all(); |
| 291 | control_reg_value = __raw_readl(scratchpad_address |
| 292 | + OMAP343X_CONTROL_REG_VALUE_OFFSET); |
| 293 | /* This will enable caches and prediction */ |
| 294 | restore_control_register(control_reg_value); |
| 295 | } |
| 296 | |
Kevin Hilman | 8bd2294 | 2009-05-28 10:56:16 -0700 | [diff] [blame] | 297 | static void omap_sram_idle(void) |
| 298 | { |
| 299 | /* Variable to tell what needs to be saved and restored |
| 300 | * in omap_sram_idle*/ |
| 301 | /* save_state = 0 => Nothing to save and restored */ |
| 302 | /* save_state = 1 => Only L1 and logic lost */ |
| 303 | /* save_state = 2 => Only L2 lost */ |
| 304 | /* save_state = 3 => L1, L2 and logic lost */ |
Rajendra Nayak | fa3c2a4 | 2008-09-26 17:49:22 +0530 | [diff] [blame] | 305 | int save_state = 0; |
| 306 | int mpu_next_state = PWRDM_POWER_ON; |
| 307 | int per_next_state = PWRDM_POWER_ON; |
| 308 | int core_next_state = PWRDM_POWER_ON; |
Rajendra Nayak | 2f5939c | 2008-09-26 17:50:07 +0530 | [diff] [blame] | 309 | int core_prev_state, per_prev_state; |
Tero Kristo | 13a6fe0f | 2008-10-13 13:17:06 +0300 | [diff] [blame] | 310 | u32 sdrc_pwr = 0; |
Kevin Hilman | 8bd2294 | 2009-05-28 10:56:16 -0700 | [diff] [blame] | 311 | |
| 312 | if (!_omap_sram_idle) |
| 313 | return; |
| 314 | |
Rajendra Nayak | fa3c2a4 | 2008-09-26 17:49:22 +0530 | [diff] [blame] | 315 | pwrdm_clear_all_prev_pwrst(mpu_pwrdm); |
| 316 | pwrdm_clear_all_prev_pwrst(neon_pwrdm); |
| 317 | pwrdm_clear_all_prev_pwrst(core_pwrdm); |
| 318 | pwrdm_clear_all_prev_pwrst(per_pwrdm); |
| 319 | |
Kevin Hilman | 8bd2294 | 2009-05-28 10:56:16 -0700 | [diff] [blame] | 320 | mpu_next_state = pwrdm_read_next_pwrst(mpu_pwrdm); |
| 321 | switch (mpu_next_state) { |
Rajendra Nayak | fa3c2a4 | 2008-09-26 17:49:22 +0530 | [diff] [blame] | 322 | case PWRDM_POWER_ON: |
Kevin Hilman | 8bd2294 | 2009-05-28 10:56:16 -0700 | [diff] [blame] | 323 | case PWRDM_POWER_RET: |
| 324 | /* No need to save context */ |
| 325 | save_state = 0; |
| 326 | break; |
Rajendra Nayak | 61255ab | 2008-09-26 17:49:56 +0530 | [diff] [blame] | 327 | case PWRDM_POWER_OFF: |
| 328 | save_state = 3; |
| 329 | break; |
Kevin Hilman | 8bd2294 | 2009-05-28 10:56:16 -0700 | [diff] [blame] | 330 | default: |
| 331 | /* Invalid state */ |
| 332 | printk(KERN_ERR "Invalid mpu state in sram_idle\n"); |
| 333 | return; |
| 334 | } |
Peter 'p2' De Schrijver | fe617af | 2008-10-15 17:48:44 +0300 | [diff] [blame] | 335 | pwrdm_pre_transition(); |
| 336 | |
Rajendra Nayak | fa3c2a4 | 2008-09-26 17:49:22 +0530 | [diff] [blame] | 337 | /* NEON control */ |
| 338 | if (pwrdm_read_pwrst(neon_pwrdm) == PWRDM_POWER_ON) |
| 339 | set_pwrdm_state(neon_pwrdm, mpu_next_state); |
| 340 | |
Kevin Hilman | 658ce97 | 2008-11-04 20:50:52 -0800 | [diff] [blame^] | 341 | /* PER */ |
| 342 | per_next_state = pwrdm_read_next_pwrst(per_pwrdm); |
| 343 | if (per_next_state < PWRDM_POWER_ON) { |
| 344 | omap2_gpio_prepare_for_retention(); |
| 345 | omap_uart_prepare_idle(2); |
| 346 | if (per_next_state == PWRDM_POWER_OFF) |
| 347 | omap3_per_save_context(); |
| 348 | } |
| 349 | |
| 350 | /* CORE */ |
Rajendra Nayak | fa3c2a4 | 2008-09-26 17:49:22 +0530 | [diff] [blame] | 351 | core_next_state = pwrdm_read_next_pwrst(core_pwrdm); |
| 352 | if (core_next_state < PWRDM_POWER_ON) { |
Rajendra Nayak | fa3c2a4 | 2008-09-26 17:49:22 +0530 | [diff] [blame] | 353 | omap_uart_prepare_idle(0); |
| 354 | omap_uart_prepare_idle(1); |
Rajendra Nayak | 2f5939c | 2008-09-26 17:50:07 +0530 | [diff] [blame] | 355 | if (core_next_state == PWRDM_POWER_OFF) { |
| 356 | omap3_core_save_context(); |
| 357 | omap3_prcm_save_context(); |
| 358 | } |
Rajendra Nayak | fa3c2a4 | 2008-09-26 17:49:22 +0530 | [diff] [blame] | 359 | /* Enable IO-PAD wakeup */ |
| 360 | prm_set_mod_reg_bits(OMAP3430_EN_IO, WKUP_MOD, PM_WKEN); |
| 361 | } |
Kevin Hilman | 8bd2294 | 2009-05-28 10:56:16 -0700 | [diff] [blame] | 362 | |
Rajendra Nayak | 61255ab | 2008-09-26 17:49:56 +0530 | [diff] [blame] | 363 | /* |
Tero Kristo | 13a6fe0f | 2008-10-13 13:17:06 +0300 | [diff] [blame] | 364 | * Force SDRAM controller to self-refresh mode after timeout on |
| 365 | * autocount. This is needed on ES3.0 to avoid SDRAM controller |
| 366 | * hang-ups. |
| 367 | */ |
| 368 | if (omap_rev() >= OMAP3430_REV_ES3_0 && |
| 369 | omap_type() != OMAP2_DEVICE_TYPE_GP && |
| 370 | core_next_state == PWRDM_POWER_OFF) { |
| 371 | sdrc_pwr = sdrc_read_reg(SDRC_POWER); |
| 372 | sdrc_write_reg((sdrc_pwr & |
| 373 | ~(SDRC_POWER_AUTOCOUNT_MASK|SDRC_POWER_CLKCTRL_MASK)) | |
| 374 | (1 << SDRC_POWER_AUTOCOUNT_SHIFT) | |
| 375 | SDRC_SELF_REFRESH_ON_AUTOCOUNT, SDRC_POWER); |
| 376 | } |
| 377 | |
| 378 | /* |
Rajendra Nayak | 61255ab | 2008-09-26 17:49:56 +0530 | [diff] [blame] | 379 | * omap3_arm_context is the location where ARM registers |
| 380 | * get saved. The restore path then reads from this |
| 381 | * location and restores them back. |
| 382 | */ |
| 383 | _omap_sram_idle(omap3_arm_context, save_state); |
Kevin Hilman | 8bd2294 | 2009-05-28 10:56:16 -0700 | [diff] [blame] | 384 | cpu_init(); |
| 385 | |
Tero Kristo | 13a6fe0f | 2008-10-13 13:17:06 +0300 | [diff] [blame] | 386 | /* Restore normal SDRAM 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 | |
Rajendra Nayak | 57f277b | 2008-09-26 17:49:34 +0530 | [diff] [blame] | 392 | /* Restore table entry modified during MMU restoration */ |
| 393 | if (pwrdm_read_prev_pwrst(mpu_pwrdm) == PWRDM_POWER_OFF) |
| 394 | restore_table_entry(); |
| 395 | |
Kevin Hilman | 658ce97 | 2008-11-04 20:50:52 -0800 | [diff] [blame^] | 396 | /* CORE */ |
Rajendra Nayak | fa3c2a4 | 2008-09-26 17:49:22 +0530 | [diff] [blame] | 397 | if (core_next_state < PWRDM_POWER_ON) { |
Rajendra Nayak | 2f5939c | 2008-09-26 17:50:07 +0530 | [diff] [blame] | 398 | core_prev_state = pwrdm_read_prev_pwrst(core_pwrdm); |
| 399 | if (core_prev_state == PWRDM_POWER_OFF) { |
| 400 | omap3_core_restore_context(); |
| 401 | omap3_prcm_restore_context(); |
| 402 | omap3_sram_restore_context(); |
Kalle Jokiniemi | 8a917d2 | 2009-05-13 13:32:11 +0300 | [diff] [blame] | 403 | omap2_sms_restore_context(); |
Rajendra Nayak | 2f5939c | 2008-09-26 17:50:07 +0530 | [diff] [blame] | 404 | } |
Kevin Hilman | 658ce97 | 2008-11-04 20:50:52 -0800 | [diff] [blame^] | 405 | omap_uart_resume_idle(0); |
| 406 | omap_uart_resume_idle(1); |
| 407 | if (core_next_state == PWRDM_POWER_OFF) |
| 408 | prm_clear_mod_reg_bits(OMAP3430_AUTO_OFF, |
| 409 | OMAP3430_GR_MOD, |
| 410 | OMAP3_PRM_VOLTCTRL_OFFSET); |
| 411 | } |
| 412 | |
| 413 | /* PER */ |
| 414 | if (per_next_state < PWRDM_POWER_ON) { |
| 415 | per_prev_state = pwrdm_read_prev_pwrst(per_pwrdm); |
| 416 | omap_uart_resume_idle(2); |
| 417 | if (per_prev_state == PWRDM_POWER_OFF) |
| 418 | omap3_per_restore_context(); |
Rajendra Nayak | fa3c2a4 | 2008-09-26 17:49:22 +0530 | [diff] [blame] | 419 | omap2_gpio_resume_after_retention(); |
| 420 | } |
Peter 'p2' De Schrijver | fe617af | 2008-10-15 17:48:44 +0300 | [diff] [blame] | 421 | |
Kevin Hilman | 658ce97 | 2008-11-04 20:50:52 -0800 | [diff] [blame^] | 422 | /* Disable IO-PAD wakeup */ |
| 423 | if (core_next_state < PWRDM_POWER_ON) |
| 424 | prm_clear_mod_reg_bits(OMAP3430_EN_IO, WKUP_MOD, PM_WKEN); |
| 425 | |
Peter 'p2' De Schrijver | fe617af | 2008-10-15 17:48:44 +0300 | [diff] [blame] | 426 | pwrdm_post_transition(); |
| 427 | |
Kevin Hilman | 8bd2294 | 2009-05-28 10:56:16 -0700 | [diff] [blame] | 428 | } |
| 429 | |
| 430 | /* |
| 431 | * Check if functional clocks are enabled before entering |
| 432 | * sleep. This function could be behind CONFIG_PM_DEBUG |
| 433 | * when all drivers are configuring their sysconfig registers |
| 434 | * properly and using their clocks properly. |
| 435 | */ |
| 436 | static int omap3_fclks_active(void) |
| 437 | { |
| 438 | u32 fck_core1 = 0, fck_core3 = 0, fck_sgx = 0, fck_dss = 0, |
| 439 | fck_cam = 0, fck_per = 0, fck_usbhost = 0; |
| 440 | |
| 441 | fck_core1 = cm_read_mod_reg(CORE_MOD, |
| 442 | CM_FCLKEN1); |
| 443 | if (omap_rev() > OMAP3430_REV_ES1_0) { |
| 444 | fck_core3 = cm_read_mod_reg(CORE_MOD, |
| 445 | OMAP3430ES2_CM_FCLKEN3); |
| 446 | fck_sgx = cm_read_mod_reg(OMAP3430ES2_SGX_MOD, |
| 447 | CM_FCLKEN); |
| 448 | fck_usbhost = cm_read_mod_reg(OMAP3430ES2_USBHOST_MOD, |
| 449 | CM_FCLKEN); |
| 450 | } else |
| 451 | fck_sgx = cm_read_mod_reg(GFX_MOD, |
| 452 | OMAP3430ES2_CM_FCLKEN3); |
| 453 | fck_dss = cm_read_mod_reg(OMAP3430_DSS_MOD, |
| 454 | CM_FCLKEN); |
| 455 | fck_cam = cm_read_mod_reg(OMAP3430_CAM_MOD, |
| 456 | CM_FCLKEN); |
| 457 | fck_per = cm_read_mod_reg(OMAP3430_PER_MOD, |
| 458 | CM_FCLKEN); |
Kevin Hilman | 4af4016 | 2009-02-04 10:51:40 -0800 | [diff] [blame] | 459 | |
| 460 | /* Ignore UART clocks. These are handled by UART core (serial.c) */ |
| 461 | fck_core1 &= ~(OMAP3430_EN_UART1 | OMAP3430_EN_UART2); |
| 462 | fck_per &= ~OMAP3430_EN_UART3; |
| 463 | |
Kevin Hilman | 8bd2294 | 2009-05-28 10:56:16 -0700 | [diff] [blame] | 464 | if (fck_core1 | fck_core3 | fck_sgx | fck_dss | |
| 465 | fck_cam | fck_per | fck_usbhost) |
| 466 | return 1; |
| 467 | return 0; |
| 468 | } |
| 469 | |
| 470 | static int omap3_can_sleep(void) |
| 471 | { |
Kevin Hilman | c40552b | 2009-10-06 14:25:09 -0700 | [diff] [blame] | 472 | if (!sleep_while_idle) |
| 473 | return 0; |
Kevin Hilman | 4af4016 | 2009-02-04 10:51:40 -0800 | [diff] [blame] | 474 | if (!omap_uart_can_sleep()) |
| 475 | return 0; |
Kevin Hilman | 8bd2294 | 2009-05-28 10:56:16 -0700 | [diff] [blame] | 476 | if (omap3_fclks_active()) |
| 477 | return 0; |
| 478 | return 1; |
| 479 | } |
| 480 | |
| 481 | /* This sets pwrdm state (other than mpu & core. Currently only ON & |
| 482 | * RET are supported. Function is assuming that clkdm doesn't have |
| 483 | * hw_sup mode enabled. */ |
| 484 | static int set_pwrdm_state(struct powerdomain *pwrdm, u32 state) |
| 485 | { |
| 486 | u32 cur_state; |
| 487 | int sleep_switch = 0; |
| 488 | int ret = 0; |
| 489 | |
| 490 | if (pwrdm == NULL || IS_ERR(pwrdm)) |
| 491 | return -EINVAL; |
| 492 | |
| 493 | while (!(pwrdm->pwrsts & (1 << state))) { |
| 494 | if (state == PWRDM_POWER_OFF) |
| 495 | return ret; |
| 496 | state--; |
| 497 | } |
| 498 | |
| 499 | cur_state = pwrdm_read_next_pwrst(pwrdm); |
| 500 | if (cur_state == state) |
| 501 | return ret; |
| 502 | |
| 503 | if (pwrdm_read_pwrst(pwrdm) < PWRDM_POWER_ON) { |
| 504 | omap2_clkdm_wakeup(pwrdm->pwrdm_clkdms[0]); |
| 505 | sleep_switch = 1; |
| 506 | pwrdm_wait_transition(pwrdm); |
| 507 | } |
| 508 | |
| 509 | ret = pwrdm_set_next_pwrst(pwrdm, state); |
| 510 | if (ret) { |
| 511 | printk(KERN_ERR "Unable to set state of powerdomain: %s\n", |
| 512 | pwrdm->name); |
| 513 | goto err; |
| 514 | } |
| 515 | |
| 516 | if (sleep_switch) { |
| 517 | omap2_clkdm_allow_idle(pwrdm->pwrdm_clkdms[0]); |
| 518 | pwrdm_wait_transition(pwrdm); |
Peter 'p2' De Schrijver | fe617af | 2008-10-15 17:48:44 +0300 | [diff] [blame] | 519 | pwrdm_state_switch(pwrdm); |
Kevin Hilman | 8bd2294 | 2009-05-28 10:56:16 -0700 | [diff] [blame] | 520 | } |
| 521 | |
| 522 | err: |
| 523 | return ret; |
| 524 | } |
| 525 | |
| 526 | static void omap3_pm_idle(void) |
| 527 | { |
| 528 | local_irq_disable(); |
| 529 | local_fiq_disable(); |
| 530 | |
| 531 | if (!omap3_can_sleep()) |
| 532 | goto out; |
| 533 | |
| 534 | if (omap_irq_pending()) |
| 535 | goto out; |
| 536 | |
| 537 | omap_sram_idle(); |
| 538 | |
| 539 | out: |
| 540 | local_fiq_enable(); |
| 541 | local_irq_enable(); |
| 542 | } |
| 543 | |
Kevin Hilman | 10f90ed | 2009-06-24 11:39:18 -0700 | [diff] [blame] | 544 | #ifdef CONFIG_SUSPEND |
Tero Kristo | 2466211 | 2009-03-05 16:32:23 +0200 | [diff] [blame] | 545 | static suspend_state_t suspend_state; |
| 546 | |
Kevin Hilman | d7814e4 | 2009-10-06 14:30:23 -0700 | [diff] [blame] | 547 | static void omap2_pm_wakeup_on_timer(u32 seconds) |
| 548 | { |
| 549 | u32 tick_rate, cycles; |
| 550 | |
| 551 | if (!seconds) |
| 552 | return; |
| 553 | |
| 554 | tick_rate = clk_get_rate(omap_dm_timer_get_fclk(gptimer_wakeup)); |
| 555 | cycles = tick_rate * seconds; |
| 556 | omap_dm_timer_stop(gptimer_wakeup); |
| 557 | omap_dm_timer_set_load_start(gptimer_wakeup, 0, 0xffffffff - cycles); |
| 558 | |
| 559 | pr_info("PM: Resume timer in %d secs (%d ticks at %d ticks/sec.)\n", |
| 560 | seconds, cycles, tick_rate); |
| 561 | } |
| 562 | |
Kevin Hilman | 8bd2294 | 2009-05-28 10:56:16 -0700 | [diff] [blame] | 563 | static int omap3_pm_prepare(void) |
| 564 | { |
| 565 | disable_hlt(); |
| 566 | return 0; |
| 567 | } |
| 568 | |
| 569 | static int omap3_pm_suspend(void) |
| 570 | { |
| 571 | struct power_state *pwrst; |
| 572 | int state, ret = 0; |
| 573 | |
Kevin Hilman | d7814e4 | 2009-10-06 14:30:23 -0700 | [diff] [blame] | 574 | if (wakeup_timer_seconds) |
| 575 | omap2_pm_wakeup_on_timer(wakeup_timer_seconds); |
| 576 | |
Kevin Hilman | 8bd2294 | 2009-05-28 10:56:16 -0700 | [diff] [blame] | 577 | /* Read current next_pwrsts */ |
| 578 | list_for_each_entry(pwrst, &pwrst_list, node) |
| 579 | pwrst->saved_state = pwrdm_read_next_pwrst(pwrst->pwrdm); |
| 580 | /* Set ones wanted by suspend */ |
| 581 | list_for_each_entry(pwrst, &pwrst_list, node) { |
| 582 | if (set_pwrdm_state(pwrst->pwrdm, pwrst->next_state)) |
| 583 | goto restore; |
| 584 | if (pwrdm_clear_all_prev_pwrst(pwrst->pwrdm)) |
| 585 | goto restore; |
| 586 | } |
| 587 | |
Kevin Hilman | 4af4016 | 2009-02-04 10:51:40 -0800 | [diff] [blame] | 588 | omap_uart_prepare_suspend(); |
Kevin Hilman | 8bd2294 | 2009-05-28 10:56:16 -0700 | [diff] [blame] | 589 | omap_sram_idle(); |
| 590 | |
| 591 | restore: |
| 592 | /* Restore next_pwrsts */ |
| 593 | list_for_each_entry(pwrst, &pwrst_list, node) { |
Kevin Hilman | 8bd2294 | 2009-05-28 10:56:16 -0700 | [diff] [blame] | 594 | state = pwrdm_read_prev_pwrst(pwrst->pwrdm); |
| 595 | if (state > pwrst->next_state) { |
| 596 | printk(KERN_INFO "Powerdomain (%s) didn't enter " |
| 597 | "target state %d\n", |
| 598 | pwrst->pwrdm->name, pwrst->next_state); |
| 599 | ret = -1; |
| 600 | } |
Jouni Hogander | 6c5f803 | 2008-10-29 12:06:04 +0200 | [diff] [blame] | 601 | set_pwrdm_state(pwrst->pwrdm, pwrst->saved_state); |
Kevin Hilman | 8bd2294 | 2009-05-28 10:56:16 -0700 | [diff] [blame] | 602 | } |
| 603 | if (ret) |
| 604 | printk(KERN_ERR "Could not enter target state in pm_suspend\n"); |
| 605 | else |
| 606 | printk(KERN_INFO "Successfully put all powerdomains " |
| 607 | "to target state\n"); |
| 608 | |
| 609 | return ret; |
| 610 | } |
| 611 | |
Tero Kristo | 2466211 | 2009-03-05 16:32:23 +0200 | [diff] [blame] | 612 | static int omap3_pm_enter(suspend_state_t unused) |
Kevin Hilman | 8bd2294 | 2009-05-28 10:56:16 -0700 | [diff] [blame] | 613 | { |
| 614 | int ret = 0; |
| 615 | |
Tero Kristo | 2466211 | 2009-03-05 16:32:23 +0200 | [diff] [blame] | 616 | switch (suspend_state) { |
Kevin Hilman | 8bd2294 | 2009-05-28 10:56:16 -0700 | [diff] [blame] | 617 | case PM_SUSPEND_STANDBY: |
| 618 | case PM_SUSPEND_MEM: |
| 619 | ret = omap3_pm_suspend(); |
| 620 | break; |
| 621 | default: |
| 622 | ret = -EINVAL; |
| 623 | } |
| 624 | |
| 625 | return ret; |
| 626 | } |
| 627 | |
| 628 | static void omap3_pm_finish(void) |
| 629 | { |
| 630 | enable_hlt(); |
| 631 | } |
| 632 | |
Tero Kristo | 2466211 | 2009-03-05 16:32:23 +0200 | [diff] [blame] | 633 | /* Hooks to enable / disable UART interrupts during suspend */ |
| 634 | static int omap3_pm_begin(suspend_state_t state) |
| 635 | { |
| 636 | suspend_state = state; |
| 637 | omap_uart_enable_irqs(0); |
| 638 | return 0; |
| 639 | } |
| 640 | |
| 641 | static void omap3_pm_end(void) |
| 642 | { |
| 643 | suspend_state = PM_SUSPEND_ON; |
| 644 | omap_uart_enable_irqs(1); |
| 645 | return; |
| 646 | } |
| 647 | |
Kevin Hilman | 8bd2294 | 2009-05-28 10:56:16 -0700 | [diff] [blame] | 648 | static struct platform_suspend_ops omap_pm_ops = { |
Tero Kristo | 2466211 | 2009-03-05 16:32:23 +0200 | [diff] [blame] | 649 | .begin = omap3_pm_begin, |
| 650 | .end = omap3_pm_end, |
Kevin Hilman | 8bd2294 | 2009-05-28 10:56:16 -0700 | [diff] [blame] | 651 | .prepare = omap3_pm_prepare, |
| 652 | .enter = omap3_pm_enter, |
| 653 | .finish = omap3_pm_finish, |
| 654 | .valid = suspend_valid_only_mem, |
| 655 | }; |
Kevin Hilman | 10f90ed | 2009-06-24 11:39:18 -0700 | [diff] [blame] | 656 | #endif /* CONFIG_SUSPEND */ |
Kevin Hilman | 8bd2294 | 2009-05-28 10:56:16 -0700 | [diff] [blame] | 657 | |
Kevin Hilman | 1155e42 | 2008-11-25 11:48:24 -0800 | [diff] [blame] | 658 | |
| 659 | /** |
| 660 | * omap3_iva_idle(): ensure IVA is in idle so it can be put into |
| 661 | * retention |
| 662 | * |
| 663 | * In cases where IVA2 is activated by bootcode, it may prevent |
| 664 | * full-chip retention or off-mode because it is not idle. This |
| 665 | * function forces the IVA2 into idle state so it can go |
| 666 | * into retention/off and thus allow full-chip retention/off. |
| 667 | * |
| 668 | **/ |
| 669 | static void __init omap3_iva_idle(void) |
| 670 | { |
| 671 | /* ensure IVA2 clock is disabled */ |
| 672 | cm_write_mod_reg(0, OMAP3430_IVA2_MOD, CM_FCLKEN); |
| 673 | |
| 674 | /* if no clock activity, nothing else to do */ |
| 675 | if (!(cm_read_mod_reg(OMAP3430_IVA2_MOD, OMAP3430_CM_CLKSTST) & |
| 676 | OMAP3430_CLKACTIVITY_IVA2_MASK)) |
| 677 | return; |
| 678 | |
| 679 | /* Reset IVA2 */ |
| 680 | prm_write_mod_reg(OMAP3430_RST1_IVA2 | |
| 681 | OMAP3430_RST2_IVA2 | |
| 682 | OMAP3430_RST3_IVA2, |
| 683 | OMAP3430_IVA2_MOD, RM_RSTCTRL); |
| 684 | |
| 685 | /* Enable IVA2 clock */ |
| 686 | cm_write_mod_reg(OMAP3430_CM_FCLKEN_IVA2_EN_IVA2, |
| 687 | OMAP3430_IVA2_MOD, CM_FCLKEN); |
| 688 | |
| 689 | /* Set IVA2 boot mode to 'idle' */ |
| 690 | omap_ctrl_writel(OMAP3_IVA2_BOOTMOD_IDLE, |
| 691 | OMAP343X_CONTROL_IVA2_BOOTMOD); |
| 692 | |
| 693 | /* Un-reset IVA2 */ |
| 694 | prm_write_mod_reg(0, OMAP3430_IVA2_MOD, RM_RSTCTRL); |
| 695 | |
| 696 | /* Disable IVA2 clock */ |
| 697 | cm_write_mod_reg(0, OMAP3430_IVA2_MOD, CM_FCLKEN); |
| 698 | |
| 699 | /* Reset IVA2 */ |
| 700 | prm_write_mod_reg(OMAP3430_RST1_IVA2 | |
| 701 | OMAP3430_RST2_IVA2 | |
| 702 | OMAP3430_RST3_IVA2, |
| 703 | OMAP3430_IVA2_MOD, RM_RSTCTRL); |
| 704 | } |
| 705 | |
Kevin Hilman | 8111b22 | 2009-04-28 15:27:44 -0700 | [diff] [blame] | 706 | static void __init omap3_d2d_idle(void) |
Kevin Hilman | 8bd2294 | 2009-05-28 10:56:16 -0700 | [diff] [blame] | 707 | { |
Kevin Hilman | 8111b22 | 2009-04-28 15:27:44 -0700 | [diff] [blame] | 708 | u16 mask, padconf; |
| 709 | |
| 710 | /* In a stand alone OMAP3430 where there is not a stacked |
| 711 | * modem for the D2D Idle Ack and D2D MStandby must be pulled |
| 712 | * high. S CONTROL_PADCONF_SAD2D_IDLEACK and |
| 713 | * CONTROL_PADCONF_SAD2D_MSTDBY to have a pull up. */ |
| 714 | mask = (1 << 4) | (1 << 3); /* pull-up, enabled */ |
| 715 | padconf = omap_ctrl_readw(OMAP3_PADCONF_SAD2D_MSTANDBY); |
| 716 | padconf |= mask; |
| 717 | omap_ctrl_writew(padconf, OMAP3_PADCONF_SAD2D_MSTANDBY); |
| 718 | |
| 719 | padconf = omap_ctrl_readw(OMAP3_PADCONF_SAD2D_IDLEACK); |
| 720 | padconf |= mask; |
| 721 | omap_ctrl_writew(padconf, OMAP3_PADCONF_SAD2D_IDLEACK); |
| 722 | |
Kevin Hilman | 8bd2294 | 2009-05-28 10:56:16 -0700 | [diff] [blame] | 723 | /* reset modem */ |
| 724 | prm_write_mod_reg(OMAP3430_RM_RSTCTRL_CORE_MODEM_SW_RSTPWRON | |
| 725 | OMAP3430_RM_RSTCTRL_CORE_MODEM_SW_RST, |
| 726 | CORE_MOD, RM_RSTCTRL); |
| 727 | prm_write_mod_reg(0, CORE_MOD, RM_RSTCTRL); |
Kevin Hilman | 8111b22 | 2009-04-28 15:27:44 -0700 | [diff] [blame] | 728 | } |
Kevin Hilman | 8bd2294 | 2009-05-28 10:56:16 -0700 | [diff] [blame] | 729 | |
Kevin Hilman | 8111b22 | 2009-04-28 15:27:44 -0700 | [diff] [blame] | 730 | static void __init prcm_setup_regs(void) |
| 731 | { |
Kevin Hilman | 8bd2294 | 2009-05-28 10:56:16 -0700 | [diff] [blame] | 732 | /* XXX Reset all wkdeps. This should be done when initializing |
| 733 | * powerdomains */ |
| 734 | prm_write_mod_reg(0, OMAP3430_IVA2_MOD, PM_WKDEP); |
| 735 | prm_write_mod_reg(0, MPU_MOD, PM_WKDEP); |
| 736 | prm_write_mod_reg(0, OMAP3430_DSS_MOD, PM_WKDEP); |
| 737 | prm_write_mod_reg(0, OMAP3430_NEON_MOD, PM_WKDEP); |
| 738 | prm_write_mod_reg(0, OMAP3430_CAM_MOD, PM_WKDEP); |
| 739 | prm_write_mod_reg(0, OMAP3430_PER_MOD, PM_WKDEP); |
| 740 | if (omap_rev() > OMAP3430_REV_ES1_0) { |
| 741 | prm_write_mod_reg(0, OMAP3430ES2_SGX_MOD, PM_WKDEP); |
| 742 | prm_write_mod_reg(0, OMAP3430ES2_USBHOST_MOD, PM_WKDEP); |
| 743 | } else |
| 744 | prm_write_mod_reg(0, GFX_MOD, PM_WKDEP); |
| 745 | |
| 746 | /* |
| 747 | * Enable interface clock autoidle for all modules. |
| 748 | * Note that in the long run this should be done by clockfw |
| 749 | */ |
| 750 | cm_write_mod_reg( |
Kevin Hilman | 8111b22 | 2009-04-28 15:27:44 -0700 | [diff] [blame] | 751 | OMAP3430_AUTO_MODEM | |
Kevin Hilman | 8bd2294 | 2009-05-28 10:56:16 -0700 | [diff] [blame] | 752 | OMAP3430ES2_AUTO_MMC3 | |
| 753 | OMAP3430ES2_AUTO_ICR | |
| 754 | OMAP3430_AUTO_AES2 | |
| 755 | OMAP3430_AUTO_SHA12 | |
| 756 | OMAP3430_AUTO_DES2 | |
| 757 | OMAP3430_AUTO_MMC2 | |
| 758 | OMAP3430_AUTO_MMC1 | |
| 759 | OMAP3430_AUTO_MSPRO | |
| 760 | OMAP3430_AUTO_HDQ | |
| 761 | OMAP3430_AUTO_MCSPI4 | |
| 762 | OMAP3430_AUTO_MCSPI3 | |
| 763 | OMAP3430_AUTO_MCSPI2 | |
| 764 | OMAP3430_AUTO_MCSPI1 | |
| 765 | OMAP3430_AUTO_I2C3 | |
| 766 | OMAP3430_AUTO_I2C2 | |
| 767 | OMAP3430_AUTO_I2C1 | |
| 768 | OMAP3430_AUTO_UART2 | |
| 769 | OMAP3430_AUTO_UART1 | |
| 770 | OMAP3430_AUTO_GPT11 | |
| 771 | OMAP3430_AUTO_GPT10 | |
| 772 | OMAP3430_AUTO_MCBSP5 | |
| 773 | OMAP3430_AUTO_MCBSP1 | |
| 774 | OMAP3430ES1_AUTO_FAC | /* This is es1 only */ |
| 775 | OMAP3430_AUTO_MAILBOXES | |
| 776 | OMAP3430_AUTO_OMAPCTRL | |
| 777 | OMAP3430ES1_AUTO_FSHOSTUSB | |
| 778 | OMAP3430_AUTO_HSOTGUSB | |
Kevin Hilman | 8111b22 | 2009-04-28 15:27:44 -0700 | [diff] [blame] | 779 | OMAP3430_AUTO_SAD2D | |
Kevin Hilman | 8bd2294 | 2009-05-28 10:56:16 -0700 | [diff] [blame] | 780 | OMAP3430_AUTO_SSI, |
| 781 | CORE_MOD, CM_AUTOIDLE1); |
| 782 | |
| 783 | cm_write_mod_reg( |
| 784 | OMAP3430_AUTO_PKA | |
| 785 | OMAP3430_AUTO_AES1 | |
| 786 | OMAP3430_AUTO_RNG | |
| 787 | OMAP3430_AUTO_SHA11 | |
| 788 | OMAP3430_AUTO_DES1, |
| 789 | CORE_MOD, CM_AUTOIDLE2); |
| 790 | |
| 791 | if (omap_rev() > OMAP3430_REV_ES1_0) { |
| 792 | cm_write_mod_reg( |
Kevin Hilman | 8111b22 | 2009-04-28 15:27:44 -0700 | [diff] [blame] | 793 | OMAP3430_AUTO_MAD2D | |
Kevin Hilman | 8bd2294 | 2009-05-28 10:56:16 -0700 | [diff] [blame] | 794 | OMAP3430ES2_AUTO_USBTLL, |
| 795 | CORE_MOD, CM_AUTOIDLE3); |
| 796 | } |
| 797 | |
| 798 | cm_write_mod_reg( |
| 799 | OMAP3430_AUTO_WDT2 | |
| 800 | OMAP3430_AUTO_WDT1 | |
| 801 | OMAP3430_AUTO_GPIO1 | |
| 802 | OMAP3430_AUTO_32KSYNC | |
| 803 | OMAP3430_AUTO_GPT12 | |
| 804 | OMAP3430_AUTO_GPT1 , |
| 805 | WKUP_MOD, CM_AUTOIDLE); |
| 806 | |
| 807 | cm_write_mod_reg( |
| 808 | OMAP3430_AUTO_DSS, |
| 809 | OMAP3430_DSS_MOD, |
| 810 | CM_AUTOIDLE); |
| 811 | |
| 812 | cm_write_mod_reg( |
| 813 | OMAP3430_AUTO_CAM, |
| 814 | OMAP3430_CAM_MOD, |
| 815 | CM_AUTOIDLE); |
| 816 | |
| 817 | cm_write_mod_reg( |
| 818 | OMAP3430_AUTO_GPIO6 | |
| 819 | OMAP3430_AUTO_GPIO5 | |
| 820 | OMAP3430_AUTO_GPIO4 | |
| 821 | OMAP3430_AUTO_GPIO3 | |
| 822 | OMAP3430_AUTO_GPIO2 | |
| 823 | OMAP3430_AUTO_WDT3 | |
| 824 | OMAP3430_AUTO_UART3 | |
| 825 | OMAP3430_AUTO_GPT9 | |
| 826 | OMAP3430_AUTO_GPT8 | |
| 827 | OMAP3430_AUTO_GPT7 | |
| 828 | OMAP3430_AUTO_GPT6 | |
| 829 | OMAP3430_AUTO_GPT5 | |
| 830 | OMAP3430_AUTO_GPT4 | |
| 831 | OMAP3430_AUTO_GPT3 | |
| 832 | OMAP3430_AUTO_GPT2 | |
| 833 | OMAP3430_AUTO_MCBSP4 | |
| 834 | OMAP3430_AUTO_MCBSP3 | |
| 835 | OMAP3430_AUTO_MCBSP2, |
| 836 | OMAP3430_PER_MOD, |
| 837 | CM_AUTOIDLE); |
| 838 | |
| 839 | if (omap_rev() > OMAP3430_REV_ES1_0) { |
| 840 | cm_write_mod_reg( |
| 841 | OMAP3430ES2_AUTO_USBHOST, |
| 842 | OMAP3430ES2_USBHOST_MOD, |
| 843 | CM_AUTOIDLE); |
| 844 | } |
| 845 | |
| 846 | /* |
| 847 | * Set all plls to autoidle. This is needed until autoidle is |
| 848 | * enabled by clockfw |
| 849 | */ |
| 850 | cm_write_mod_reg(1 << OMAP3430_AUTO_IVA2_DPLL_SHIFT, |
| 851 | OMAP3430_IVA2_MOD, CM_AUTOIDLE2); |
| 852 | cm_write_mod_reg(1 << OMAP3430_AUTO_MPU_DPLL_SHIFT, |
| 853 | MPU_MOD, |
| 854 | CM_AUTOIDLE2); |
| 855 | cm_write_mod_reg((1 << OMAP3430_AUTO_PERIPH_DPLL_SHIFT) | |
| 856 | (1 << OMAP3430_AUTO_CORE_DPLL_SHIFT), |
| 857 | PLL_MOD, |
| 858 | CM_AUTOIDLE); |
| 859 | cm_write_mod_reg(1 << OMAP3430ES2_AUTO_PERIPH2_DPLL_SHIFT, |
| 860 | PLL_MOD, |
| 861 | CM_AUTOIDLE2); |
| 862 | |
| 863 | /* |
| 864 | * Enable control of expternal oscillator through |
| 865 | * sys_clkreq. In the long run clock framework should |
| 866 | * take care of this. |
| 867 | */ |
| 868 | prm_rmw_mod_reg_bits(OMAP_AUTOEXTCLKMODE_MASK, |
| 869 | 1 << OMAP_AUTOEXTCLKMODE_SHIFT, |
| 870 | OMAP3430_GR_MOD, |
| 871 | OMAP3_PRM_CLKSRC_CTRL_OFFSET); |
| 872 | |
| 873 | /* setup wakup source */ |
| 874 | prm_write_mod_reg(OMAP3430_EN_IO | OMAP3430_EN_GPIO1 | |
| 875 | OMAP3430_EN_GPT1 | OMAP3430_EN_GPT12, |
| 876 | WKUP_MOD, PM_WKEN); |
| 877 | /* No need to write EN_IO, that is always enabled */ |
| 878 | prm_write_mod_reg(OMAP3430_EN_GPIO1 | OMAP3430_EN_GPT1 | |
| 879 | OMAP3430_EN_GPT12, |
| 880 | WKUP_MOD, OMAP3430_PM_MPUGRPSEL); |
| 881 | /* For some reason IO doesn't generate wakeup event even if |
| 882 | * it is selected to mpu wakeup goup */ |
| 883 | prm_write_mod_reg(OMAP3430_IO_EN | OMAP3430_WKUP_EN, |
| 884 | OCP_MOD, OMAP3_PRM_IRQENABLE_MPU_OFFSET); |
Kevin Hilman | 1155e42 | 2008-11-25 11:48:24 -0800 | [diff] [blame] | 885 | |
Kevin Hilman | b427f92 | 2009-10-22 14:48:13 -0700 | [diff] [blame] | 886 | /* Enable wakeups in PER */ |
Kevin Hilman | eb350f7 | 2009-09-10 15:53:08 +0000 | [diff] [blame] | 887 | prm_write_mod_reg(OMAP3430_EN_GPIO2 | OMAP3430_EN_GPIO3 | |
| 888 | OMAP3430_EN_GPIO4 | OMAP3430_EN_GPIO5 | |
Kevin Hilman | b427f92 | 2009-10-22 14:48:13 -0700 | [diff] [blame] | 889 | OMAP3430_EN_GPIO6 | OMAP3430_EN_UART3, |
| 890 | OMAP3430_PER_MOD, PM_WKEN); |
Kevin Hilman | eb350f7 | 2009-09-10 15:53:08 +0000 | [diff] [blame] | 891 | /* and allow them to wake up MPU */ |
| 892 | prm_write_mod_reg(OMAP3430_GRPSEL_GPIO2 | OMAP3430_EN_GPIO3 | |
| 893 | OMAP3430_GRPSEL_GPIO4 | OMAP3430_EN_GPIO5 | |
Kevin Hilman | b427f92 | 2009-10-22 14:48:13 -0700 | [diff] [blame] | 894 | OMAP3430_GRPSEL_GPIO6 | OMAP3430_EN_UART3, |
Kevin Hilman | eb350f7 | 2009-09-10 15:53:08 +0000 | [diff] [blame] | 895 | OMAP3430_PER_MOD, OMAP3430_PM_MPUGRPSEL); |
| 896 | |
Kevin Hilman | d3fd329 | 2009-05-05 16:34:25 -0700 | [diff] [blame] | 897 | /* Don't attach IVA interrupts */ |
| 898 | prm_write_mod_reg(0, WKUP_MOD, OMAP3430_PM_IVAGRPSEL); |
| 899 | prm_write_mod_reg(0, CORE_MOD, OMAP3430_PM_IVAGRPSEL1); |
| 900 | prm_write_mod_reg(0, CORE_MOD, OMAP3430ES2_PM_IVAGRPSEL3); |
| 901 | prm_write_mod_reg(0, OMAP3430_PER_MOD, OMAP3430_PM_IVAGRPSEL); |
| 902 | |
Kevin Hilman | b1340d1 | 2009-04-27 16:14:54 -0700 | [diff] [blame] | 903 | /* Clear any pending 'reset' flags */ |
| 904 | prm_write_mod_reg(0xffffffff, MPU_MOD, RM_RSTST); |
| 905 | prm_write_mod_reg(0xffffffff, CORE_MOD, RM_RSTST); |
| 906 | prm_write_mod_reg(0xffffffff, OMAP3430_PER_MOD, RM_RSTST); |
| 907 | prm_write_mod_reg(0xffffffff, OMAP3430_EMU_MOD, RM_RSTST); |
| 908 | prm_write_mod_reg(0xffffffff, OMAP3430_NEON_MOD, RM_RSTST); |
| 909 | prm_write_mod_reg(0xffffffff, OMAP3430_DSS_MOD, RM_RSTST); |
| 910 | prm_write_mod_reg(0xffffffff, OMAP3430ES2_USBHOST_MOD, RM_RSTST); |
| 911 | |
Kevin Hilman | 014c46d | 2009-04-27 07:50:23 -0700 | [diff] [blame] | 912 | /* Clear any pending PRCM interrupts */ |
| 913 | prm_write_mod_reg(0, OCP_MOD, OMAP3_PRM_IRQSTATUS_MPU_OFFSET); |
| 914 | |
Kevin Hilman | 040fed0 | 2009-05-05 16:34:25 -0700 | [diff] [blame] | 915 | /* Don't attach IVA interrupts */ |
| 916 | prm_write_mod_reg(0, WKUP_MOD, OMAP3430_PM_IVAGRPSEL); |
| 917 | prm_write_mod_reg(0, CORE_MOD, OMAP3430_PM_IVAGRPSEL1); |
| 918 | prm_write_mod_reg(0, CORE_MOD, OMAP3430ES2_PM_IVAGRPSEL3); |
| 919 | prm_write_mod_reg(0, OMAP3430_PER_MOD, OMAP3430_PM_IVAGRPSEL); |
| 920 | |
Kevin Hilman | 3a07ae3 | 2009-04-27 16:14:54 -0700 | [diff] [blame] | 921 | /* Clear any pending 'reset' flags */ |
| 922 | prm_write_mod_reg(0xffffffff, MPU_MOD, RM_RSTST); |
| 923 | prm_write_mod_reg(0xffffffff, CORE_MOD, RM_RSTST); |
| 924 | prm_write_mod_reg(0xffffffff, OMAP3430_PER_MOD, RM_RSTST); |
| 925 | prm_write_mod_reg(0xffffffff, OMAP3430_EMU_MOD, RM_RSTST); |
| 926 | prm_write_mod_reg(0xffffffff, OMAP3430_NEON_MOD, RM_RSTST); |
| 927 | prm_write_mod_reg(0xffffffff, OMAP3430_DSS_MOD, RM_RSTST); |
| 928 | prm_write_mod_reg(0xffffffff, OMAP3430ES2_USBHOST_MOD, RM_RSTST); |
| 929 | |
Kevin Hilman | 3a6667a | 2009-04-27 07:50:23 -0700 | [diff] [blame] | 930 | /* Clear any pending PRCM interrupts */ |
| 931 | prm_write_mod_reg(0, OCP_MOD, OMAP3_PRM_IRQSTATUS_MPU_OFFSET); |
| 932 | |
Kevin Hilman | 1155e42 | 2008-11-25 11:48:24 -0800 | [diff] [blame] | 933 | omap3_iva_idle(); |
Kevin Hilman | 8111b22 | 2009-04-28 15:27:44 -0700 | [diff] [blame] | 934 | omap3_d2d_idle(); |
Kevin Hilman | 8bd2294 | 2009-05-28 10:56:16 -0700 | [diff] [blame] | 935 | } |
| 936 | |
Kevin Hilman | c40552b | 2009-10-06 14:25:09 -0700 | [diff] [blame] | 937 | void omap3_pm_off_mode_enable(int enable) |
| 938 | { |
| 939 | struct power_state *pwrst; |
| 940 | u32 state; |
| 941 | |
| 942 | if (enable) |
| 943 | state = PWRDM_POWER_OFF; |
| 944 | else |
| 945 | state = PWRDM_POWER_RET; |
| 946 | |
| 947 | list_for_each_entry(pwrst, &pwrst_list, node) { |
| 948 | pwrst->next_state = state; |
| 949 | set_pwrdm_state(pwrst->pwrdm, state); |
| 950 | } |
| 951 | } |
| 952 | |
Tero Kristo | 68d4778 | 2008-11-26 12:26:24 +0200 | [diff] [blame] | 953 | int omap3_pm_get_suspend_state(struct powerdomain *pwrdm) |
| 954 | { |
| 955 | struct power_state *pwrst; |
| 956 | |
| 957 | list_for_each_entry(pwrst, &pwrst_list, node) { |
| 958 | if (pwrst->pwrdm == pwrdm) |
| 959 | return pwrst->next_state; |
| 960 | } |
| 961 | return -EINVAL; |
| 962 | } |
| 963 | |
| 964 | int omap3_pm_set_suspend_state(struct powerdomain *pwrdm, int state) |
| 965 | { |
| 966 | struct power_state *pwrst; |
| 967 | |
| 968 | list_for_each_entry(pwrst, &pwrst_list, node) { |
| 969 | if (pwrst->pwrdm == pwrdm) { |
| 970 | pwrst->next_state = state; |
| 971 | return 0; |
| 972 | } |
| 973 | } |
| 974 | return -EINVAL; |
| 975 | } |
| 976 | |
Peter 'p2' De Schrijver | a23456e | 2008-10-15 18:13:47 +0300 | [diff] [blame] | 977 | static int __init pwrdms_setup(struct powerdomain *pwrdm, void *unused) |
Kevin Hilman | 8bd2294 | 2009-05-28 10:56:16 -0700 | [diff] [blame] | 978 | { |
| 979 | struct power_state *pwrst; |
| 980 | |
| 981 | if (!pwrdm->pwrsts) |
| 982 | return 0; |
| 983 | |
Ming Lei | d3d381c | 2009-08-22 21:20:26 +0800 | [diff] [blame] | 984 | pwrst = kmalloc(sizeof(struct power_state), GFP_ATOMIC); |
Kevin Hilman | 8bd2294 | 2009-05-28 10:56:16 -0700 | [diff] [blame] | 985 | if (!pwrst) |
| 986 | return -ENOMEM; |
| 987 | pwrst->pwrdm = pwrdm; |
| 988 | pwrst->next_state = PWRDM_POWER_RET; |
| 989 | list_add(&pwrst->node, &pwrst_list); |
| 990 | |
| 991 | if (pwrdm_has_hdwr_sar(pwrdm)) |
| 992 | pwrdm_enable_hdwr_sar(pwrdm); |
| 993 | |
| 994 | return set_pwrdm_state(pwrst->pwrdm, pwrst->next_state); |
| 995 | } |
| 996 | |
| 997 | /* |
| 998 | * Enable hw supervised mode for all clockdomains if it's |
| 999 | * supported. Initiate sleep transition for other clockdomains, if |
| 1000 | * they are not used |
| 1001 | */ |
Peter 'p2' De Schrijver | a23456e | 2008-10-15 18:13:47 +0300 | [diff] [blame] | 1002 | static int __init clkdms_setup(struct clockdomain *clkdm, void *unused) |
Kevin Hilman | 8bd2294 | 2009-05-28 10:56:16 -0700 | [diff] [blame] | 1003 | { |
| 1004 | if (clkdm->flags & CLKDM_CAN_ENABLE_AUTO) |
| 1005 | omap2_clkdm_allow_idle(clkdm); |
| 1006 | else if (clkdm->flags & CLKDM_CAN_FORCE_SLEEP && |
| 1007 | atomic_read(&clkdm->usecount) == 0) |
| 1008 | omap2_clkdm_sleep(clkdm); |
| 1009 | return 0; |
| 1010 | } |
| 1011 | |
Rajendra Nayak | 3231fc8 | 2008-09-26 17:49:14 +0530 | [diff] [blame] | 1012 | void omap_push_sram_idle(void) |
| 1013 | { |
| 1014 | _omap_sram_idle = omap_sram_push(omap34xx_cpu_suspend, |
| 1015 | omap34xx_cpu_suspend_sz); |
Tero Kristo | 27d59a4 | 2008-10-13 13:15:00 +0300 | [diff] [blame] | 1016 | if (omap_type() != OMAP2_DEVICE_TYPE_GP) |
| 1017 | _omap_save_secure_sram = omap_sram_push(save_secure_ram_context, |
| 1018 | save_secure_ram_context_sz); |
Rajendra Nayak | 3231fc8 | 2008-09-26 17:49:14 +0530 | [diff] [blame] | 1019 | } |
| 1020 | |
Kevin Hilman | 7cc515f | 2009-06-10 09:02:25 -0700 | [diff] [blame] | 1021 | static int __init omap3_pm_init(void) |
Kevin Hilman | 8bd2294 | 2009-05-28 10:56:16 -0700 | [diff] [blame] | 1022 | { |
| 1023 | struct power_state *pwrst, *tmp; |
| 1024 | int ret; |
| 1025 | |
| 1026 | if (!cpu_is_omap34xx()) |
| 1027 | return -ENODEV; |
| 1028 | |
| 1029 | printk(KERN_ERR "Power Management for TI OMAP3.\n"); |
| 1030 | |
| 1031 | /* XXX prcm_setup_regs needs to be before enabling hw |
| 1032 | * supervised mode for powerdomains */ |
| 1033 | prcm_setup_regs(); |
| 1034 | |
| 1035 | ret = request_irq(INT_34XX_PRCM_MPU_IRQ, |
| 1036 | (irq_handler_t)prcm_interrupt_handler, |
| 1037 | IRQF_DISABLED, "prcm", NULL); |
| 1038 | if (ret) { |
| 1039 | printk(KERN_ERR "request_irq failed to register for 0x%x\n", |
| 1040 | INT_34XX_PRCM_MPU_IRQ); |
| 1041 | goto err1; |
| 1042 | } |
| 1043 | |
Peter 'p2' De Schrijver | a23456e | 2008-10-15 18:13:47 +0300 | [diff] [blame] | 1044 | ret = pwrdm_for_each(pwrdms_setup, NULL); |
Kevin Hilman | 8bd2294 | 2009-05-28 10:56:16 -0700 | [diff] [blame] | 1045 | if (ret) { |
| 1046 | printk(KERN_ERR "Failed to setup powerdomains\n"); |
| 1047 | goto err2; |
| 1048 | } |
| 1049 | |
Peter 'p2' De Schrijver | a23456e | 2008-10-15 18:13:47 +0300 | [diff] [blame] | 1050 | (void) clkdm_for_each(clkdms_setup, NULL); |
Kevin Hilman | 8bd2294 | 2009-05-28 10:56:16 -0700 | [diff] [blame] | 1051 | |
| 1052 | mpu_pwrdm = pwrdm_lookup("mpu_pwrdm"); |
| 1053 | if (mpu_pwrdm == NULL) { |
| 1054 | printk(KERN_ERR "Failed to get mpu_pwrdm\n"); |
| 1055 | goto err2; |
| 1056 | } |
| 1057 | |
Rajendra Nayak | fa3c2a4 | 2008-09-26 17:49:22 +0530 | [diff] [blame] | 1058 | neon_pwrdm = pwrdm_lookup("neon_pwrdm"); |
| 1059 | per_pwrdm = pwrdm_lookup("per_pwrdm"); |
| 1060 | core_pwrdm = pwrdm_lookup("core_pwrdm"); |
| 1061 | |
Rajendra Nayak | 3231fc8 | 2008-09-26 17:49:14 +0530 | [diff] [blame] | 1062 | omap_push_sram_idle(); |
Kevin Hilman | 10f90ed | 2009-06-24 11:39:18 -0700 | [diff] [blame] | 1063 | #ifdef CONFIG_SUSPEND |
Kevin Hilman | 8bd2294 | 2009-05-28 10:56:16 -0700 | [diff] [blame] | 1064 | suspend_set_ops(&omap_pm_ops); |
Kevin Hilman | 10f90ed | 2009-06-24 11:39:18 -0700 | [diff] [blame] | 1065 | #endif /* CONFIG_SUSPEND */ |
Kevin Hilman | 8bd2294 | 2009-05-28 10:56:16 -0700 | [diff] [blame] | 1066 | |
| 1067 | pm_idle = omap3_pm_idle; |
| 1068 | |
Rajendra Nayak | fa3c2a4 | 2008-09-26 17:49:22 +0530 | [diff] [blame] | 1069 | pwrdm_add_wkdep(neon_pwrdm, mpu_pwrdm); |
| 1070 | /* |
| 1071 | * REVISIT: This wkdep is only necessary when GPIO2-6 are enabled for |
| 1072 | * IO-pad wakeup. Otherwise it will unnecessarily waste power |
| 1073 | * waking up PER with every CORE wakeup - see |
| 1074 | * http://marc.info/?l=linux-omap&m=121852150710062&w=2 |
| 1075 | */ |
| 1076 | pwrdm_add_wkdep(per_pwrdm, core_pwrdm); |
| 1077 | |
Tero Kristo | 27d59a4 | 2008-10-13 13:15:00 +0300 | [diff] [blame] | 1078 | if (omap_type() != OMAP2_DEVICE_TYPE_GP) { |
| 1079 | omap3_secure_ram_storage = |
| 1080 | kmalloc(0x803F, GFP_KERNEL); |
| 1081 | if (!omap3_secure_ram_storage) |
| 1082 | printk(KERN_ERR "Memory allocation failed when" |
| 1083 | "allocating for secure sram context\n"); |
Tero Kristo | 27d59a4 | 2008-10-13 13:15:00 +0300 | [diff] [blame] | 1084 | |
Tero Kristo | 9d97140 | 2008-12-12 11:20:05 +0200 | [diff] [blame] | 1085 | local_irq_disable(); |
| 1086 | local_fiq_disable(); |
| 1087 | |
| 1088 | omap_dma_global_context_save(); |
| 1089 | omap3_save_secure_ram_context(PWRDM_POWER_ON); |
| 1090 | omap_dma_global_context_restore(); |
| 1091 | |
| 1092 | local_irq_enable(); |
| 1093 | local_fiq_enable(); |
| 1094 | } |
| 1095 | |
| 1096 | omap3_save_scratchpad_contents(); |
Kevin Hilman | 8bd2294 | 2009-05-28 10:56:16 -0700 | [diff] [blame] | 1097 | err1: |
| 1098 | return ret; |
| 1099 | err2: |
| 1100 | free_irq(INT_34XX_PRCM_MPU_IRQ, NULL); |
| 1101 | list_for_each_entry_safe(pwrst, tmp, &pwrst_list, node) { |
| 1102 | list_del(&pwrst->node); |
| 1103 | kfree(pwrst); |
| 1104 | } |
| 1105 | return ret; |
| 1106 | } |
| 1107 | |
| 1108 | late_initcall(omap3_pm_init); |