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> |
Tero Kristo | dccaad8 | 2009-11-17 18:34:53 +0200 | [diff] [blame] | 29 | #include <linux/delay.h> |
Tejun Heo | 5a0e3ad | 2010-03-24 17:04:11 +0900 | [diff] [blame] | 30 | #include <linux/slab.h> |
Tony Lindgren | 45c3eb7 | 2012-11-30 08:41:50 -0800 | [diff] [blame] | 31 | #include <linux/omap-dma.h> |
Tony Lindgren | e639cd5 | 2014-11-20 12:11:25 -0800 | [diff] [blame] | 32 | #include <linux/omap-gpmc.h> |
Tony Lindgren | 4b25408 | 2012-08-30 15:37:24 -0700 | [diff] [blame] | 33 | #include <linux/platform_data/gpio-omap.h> |
| 34 | |
Jean Pihet | 5e7c58d | 2011-03-03 11:25:43 +0100 | [diff] [blame] | 35 | #include <trace/events/power.h> |
Kevin Hilman | 8bd2294 | 2009-05-28 10:56:16 -0700 | [diff] [blame] | 36 | |
Tony Lindgren | bf027ca | 2012-10-29 13:54:06 -0700 | [diff] [blame] | 37 | #include <asm/fncpy.h> |
Russell King | 2c74a0c | 2011-06-22 17:41:48 +0100 | [diff] [blame] | 38 | #include <asm/suspend.h> |
David Howells | 9f97da7 | 2012-03-28 18:30:01 +0100 | [diff] [blame] | 39 | #include <asm/system_misc.h> |
Russell King | 2c74a0c | 2011-06-22 17:41:48 +0100 | [diff] [blame] | 40 | |
Paul Walmsley | 1540f214 | 2010-12-21 21:05:15 -0700 | [diff] [blame] | 41 | #include "clockdomain.h" |
Paul Walmsley | 72e06d0 | 2010-12-21 21:05:16 -0700 | [diff] [blame] | 42 | #include "powerdomain.h" |
Tony Lindgren | e4c060d | 2012-10-05 13:25:59 -0700 | [diff] [blame] | 43 | #include "soc.h" |
Tony Lindgren | 4e65331 | 2011-11-10 22:45:17 +0100 | [diff] [blame] | 44 | #include "common.h" |
Paul Walmsley | ff4ae5d | 2012-10-21 01:01:11 -0600 | [diff] [blame] | 45 | #include "cm3xxx.h" |
Kevin Hilman | 8bd2294 | 2009-05-28 10:56:16 -0700 | [diff] [blame] | 46 | #include "cm-regbits-34xx.h" |
| 47 | #include "prm-regbits-34xx.h" |
Paul Walmsley | 139563a | 2012-10-21 01:01:10 -0600 | [diff] [blame] | 48 | #include "prm3xxx.h" |
Kevin Hilman | 8bd2294 | 2009-05-28 10:56:16 -0700 | [diff] [blame] | 49 | #include "pm.h" |
Tero Kristo | 13a6fe0f | 2008-10-13 13:17:06 +0300 | [diff] [blame] | 50 | #include "sdrc.h" |
Tony Lindgren | bf027ca | 2012-10-29 13:54:06 -0700 | [diff] [blame] | 51 | #include "sram.h" |
Paul Walmsley | 4814ced | 2010-10-08 11:40:20 -0600 | [diff] [blame] | 52 | #include "control.h" |
Tony Lindgren | 3b8c4eb | 2014-05-05 17:27:35 -0700 | [diff] [blame] | 53 | #include "vc.h" |
Tero Kristo | 13a6fe0f | 2008-10-13 13:17:06 +0300 | [diff] [blame] | 54 | |
Nishanth Menon | 8cdfd83 | 2010-12-20 14:05:05 -0600 | [diff] [blame] | 55 | /* pm34xx errata defined in pm.h */ |
| 56 | u16 pm34xx_errata; |
| 57 | |
Kevin Hilman | 8bd2294 | 2009-05-28 10:56:16 -0700 | [diff] [blame] | 58 | struct power_state { |
| 59 | struct powerdomain *pwrdm; |
| 60 | u32 next_state; |
Kevin Hilman | 10f90ed | 2009-06-24 11:39:18 -0700 | [diff] [blame] | 61 | #ifdef CONFIG_SUSPEND |
Kevin Hilman | 8bd2294 | 2009-05-28 10:56:16 -0700 | [diff] [blame] | 62 | u32 saved_state; |
Kevin Hilman | 10f90ed | 2009-06-24 11:39:18 -0700 | [diff] [blame] | 63 | #endif |
Kevin Hilman | 8bd2294 | 2009-05-28 10:56:16 -0700 | [diff] [blame] | 64 | struct list_head node; |
| 65 | }; |
| 66 | |
| 67 | static LIST_HEAD(pwrst_list); |
| 68 | |
Tero Kristo | 27d59a4 | 2008-10-13 13:15:00 +0300 | [diff] [blame] | 69 | static int (*_omap_save_secure_sram)(u32 *addr); |
Jean Pihet | 46e130d | 2011-06-29 18:40:23 +0200 | [diff] [blame] | 70 | void (*omap3_do_wfi_sram)(void); |
Tero Kristo | 27d59a4 | 2008-10-13 13:15:00 +0300 | [diff] [blame] | 71 | |
Rajendra Nayak | fa3c2a4 | 2008-09-26 17:49:22 +0530 | [diff] [blame] | 72 | static struct powerdomain *mpu_pwrdm, *neon_pwrdm; |
| 73 | static struct powerdomain *core_pwrdm, *per_pwrdm; |
Kalle Jokiniemi | 3a7ec26 | 2009-03-26 15:59:01 +0200 | [diff] [blame] | 74 | |
Rajendra Nayak | 2f5939c | 2008-09-26 17:50:07 +0530 | [diff] [blame] | 75 | static void omap3_core_save_context(void) |
| 76 | { |
Paul Walmsley | 596efe4 | 2010-12-21 21:05:16 -0700 | [diff] [blame] | 77 | omap3_ctrl_save_padconf(); |
Tero Kristo | dccaad8 | 2009-11-17 18:34:53 +0200 | [diff] [blame] | 78 | |
| 79 | /* |
| 80 | * Force write last pad into memory, as this can fail in some |
Jean Pihet | 8352129 | 2010-12-18 16:44:46 +0100 | [diff] [blame] | 81 | * cases according to errata 1.157, 1.185 |
Tero Kristo | dccaad8 | 2009-11-17 18:34:53 +0200 | [diff] [blame] | 82 | */ |
| 83 | omap_ctrl_writel(omap_ctrl_readl(OMAP343X_PADCONF_ETK_D14), |
| 84 | OMAP343X_CONTROL_MEM_WKUP + 0x2a0); |
| 85 | |
Rajendra Nayak | 2f5939c | 2008-09-26 17:50:07 +0530 | [diff] [blame] | 86 | /* Save the Interrupt controller context */ |
| 87 | omap_intc_save_context(); |
| 88 | /* Save the GPMC context */ |
| 89 | omap3_gpmc_save_context(); |
| 90 | /* Save the system control module context, padconf already save above*/ |
| 91 | omap3_control_save_context(); |
Tero Kristo | f2d1185 | 2008-08-28 13:13:31 +0000 | [diff] [blame] | 92 | omap_dma_global_context_save(); |
Rajendra Nayak | 2f5939c | 2008-09-26 17:50:07 +0530 | [diff] [blame] | 93 | } |
| 94 | |
| 95 | static void omap3_core_restore_context(void) |
| 96 | { |
| 97 | /* Restore the control module context, padconf restored by h/w */ |
| 98 | omap3_control_restore_context(); |
| 99 | /* Restore the GPMC context */ |
| 100 | omap3_gpmc_restore_context(); |
| 101 | /* Restore the interrupt controller context */ |
| 102 | omap_intc_restore_context(); |
Tero Kristo | f2d1185 | 2008-08-28 13:13:31 +0000 | [diff] [blame] | 103 | omap_dma_global_context_restore(); |
Rajendra Nayak | 2f5939c | 2008-09-26 17:50:07 +0530 | [diff] [blame] | 104 | } |
| 105 | |
Tero Kristo | 9d97140 | 2008-12-12 11:20:05 +0200 | [diff] [blame] | 106 | /* |
| 107 | * FIXME: This function should be called before entering off-mode after |
| 108 | * OMAP3 secure services have been accessed. Currently it is only called |
| 109 | * once during boot sequence, but this works as we are not using secure |
| 110 | * services. |
| 111 | */ |
Kevin Hilman | 617fcc9 | 2011-01-25 16:40:01 -0800 | [diff] [blame] | 112 | static void omap3_save_secure_ram_context(void) |
Tero Kristo | 27d59a4 | 2008-10-13 13:15:00 +0300 | [diff] [blame] | 113 | { |
| 114 | u32 ret; |
Kevin Hilman | 617fcc9 | 2011-01-25 16:40:01 -0800 | [diff] [blame] | 115 | int mpu_next_state = pwrdm_read_next_pwrst(mpu_pwrdm); |
Tero Kristo | 27d59a4 | 2008-10-13 13:15:00 +0300 | [diff] [blame] | 116 | |
| 117 | if (omap_type() != OMAP2_DEVICE_TYPE_GP) { |
Tero Kristo | 27d59a4 | 2008-10-13 13:15:00 +0300 | [diff] [blame] | 118 | /* |
| 119 | * MPU next state must be set to POWER_ON temporarily, |
| 120 | * otherwise the WFI executed inside the ROM code |
| 121 | * will hang the system. |
| 122 | */ |
| 123 | pwrdm_set_next_pwrst(mpu_pwrdm, PWRDM_POWER_ON); |
Olof Johansson | 6dd1e35 | 2013-11-12 22:51:28 -0800 | [diff] [blame] | 124 | ret = _omap_save_secure_sram((u32 *)(unsigned long) |
Tero Kristo | 27d59a4 | 2008-10-13 13:15:00 +0300 | [diff] [blame] | 125 | __pa(omap3_secure_ram_storage)); |
Kevin Hilman | 617fcc9 | 2011-01-25 16:40:01 -0800 | [diff] [blame] | 126 | pwrdm_set_next_pwrst(mpu_pwrdm, mpu_next_state); |
Tero Kristo | 27d59a4 | 2008-10-13 13:15:00 +0300 | [diff] [blame] | 127 | /* Following is for error tracking, it should not happen */ |
| 128 | if (ret) { |
Mark A. Greer | 9817985 | 2012-03-17 18:22:48 -0700 | [diff] [blame] | 129 | pr_err("save_secure_sram() returns %08x\n", ret); |
Tero Kristo | 27d59a4 | 2008-10-13 13:15:00 +0300 | [diff] [blame] | 130 | while (1) |
| 131 | ; |
| 132 | } |
| 133 | } |
| 134 | } |
| 135 | |
Tero Kristo | 22f5137 | 2011-12-16 14:36:59 -0700 | [diff] [blame] | 136 | static irqreturn_t _prcm_int_handle_io(int irq, void *unused) |
Paul Walmsley | 8cb0ac9 | 2009-07-22 10:29:02 -0700 | [diff] [blame] | 137 | { |
| 138 | int c; |
| 139 | |
Tero Kristo | 9cb6d36 | 2014-04-04 12:31:51 +0300 | [diff] [blame] | 140 | c = omap_prm_clear_mod_irqs(WKUP_MOD, 1, OMAP3430_ST_IO_MASK | |
| 141 | OMAP3430_ST_IO_CHAIN_MASK); |
Paul Walmsley | 8cb0ac9 | 2009-07-22 10:29:02 -0700 | [diff] [blame] | 142 | |
Tero Kristo | 22f5137 | 2011-12-16 14:36:59 -0700 | [diff] [blame] | 143 | return c ? IRQ_HANDLED : IRQ_NONE; |
Jon Hunter | 77da2d9 | 2009-06-27 00:07:25 -0500 | [diff] [blame] | 144 | } |
| 145 | |
Tero Kristo | 22f5137 | 2011-12-16 14:36:59 -0700 | [diff] [blame] | 146 | static irqreturn_t _prcm_int_handle_wakeup(int irq, void *unused) |
Kevin Hilman | 8bd2294 | 2009-05-28 10:56:16 -0700 | [diff] [blame] | 147 | { |
Tero Kristo | 22f5137 | 2011-12-16 14:36:59 -0700 | [diff] [blame] | 148 | int c; |
Kevin Hilman | 8bd2294 | 2009-05-28 10:56:16 -0700 | [diff] [blame] | 149 | |
Tero Kristo | 22f5137 | 2011-12-16 14:36:59 -0700 | [diff] [blame] | 150 | /* |
| 151 | * Clear all except ST_IO and ST_IO_CHAIN for wkup module, |
| 152 | * these are handled in a separate handler to avoid acking |
| 153 | * IO events before parsing in mux code |
| 154 | */ |
Tero Kristo | 9cb6d36 | 2014-04-04 12:31:51 +0300 | [diff] [blame] | 155 | c = omap_prm_clear_mod_irqs(WKUP_MOD, 1, ~(OMAP3430_ST_IO_MASK | |
| 156 | OMAP3430_ST_IO_CHAIN_MASK)); |
| 157 | c += omap_prm_clear_mod_irqs(CORE_MOD, 1, ~0); |
| 158 | c += omap_prm_clear_mod_irqs(OMAP3430_PER_MOD, 1, ~0); |
Tero Kristo | 22f5137 | 2011-12-16 14:36:59 -0700 | [diff] [blame] | 159 | if (omap_rev() > OMAP3430_REV_ES1_0) { |
Tero Kristo | 9cb6d36 | 2014-04-04 12:31:51 +0300 | [diff] [blame] | 160 | c += omap_prm_clear_mod_irqs(CORE_MOD, 3, ~0); |
| 161 | c += omap_prm_clear_mod_irqs(OMAP3430ES2_USBHOST_MOD, 1, ~0); |
Tero Kristo | 22f5137 | 2011-12-16 14:36:59 -0700 | [diff] [blame] | 162 | } |
Paul Walmsley | 8cb0ac9 | 2009-07-22 10:29:02 -0700 | [diff] [blame] | 163 | |
Tero Kristo | 22f5137 | 2011-12-16 14:36:59 -0700 | [diff] [blame] | 164 | return c ? IRQ_HANDLED : IRQ_NONE; |
Kevin Hilman | 8bd2294 | 2009-05-28 10:56:16 -0700 | [diff] [blame] | 165 | } |
| 166 | |
Russell King | cbe2634 | 2011-06-30 08:45:49 +0100 | [diff] [blame] | 167 | static void omap34xx_save_context(u32 *save) |
| 168 | { |
| 169 | u32 val; |
| 170 | |
| 171 | /* Read Auxiliary Control Register */ |
| 172 | asm("mrc p15, 0, %0, c1, c0, 1" : "=r" (val)); |
| 173 | *save++ = 1; |
| 174 | *save++ = val; |
| 175 | |
| 176 | /* Read L2 AUX ctrl register */ |
| 177 | asm("mrc p15, 1, %0, c9, c0, 2" : "=r" (val)); |
| 178 | *save++ = 1; |
| 179 | *save++ = val; |
| 180 | } |
| 181 | |
Russell King | 29cb3cd | 2011-07-02 09:54:01 +0100 | [diff] [blame] | 182 | static int omap34xx_do_sram_idle(unsigned long save_state) |
Rajendra Nayak | 57f277b | 2008-09-26 17:49:34 +0530 | [diff] [blame] | 183 | { |
Russell King | cbe2634 | 2011-06-30 08:45:49 +0100 | [diff] [blame] | 184 | omap34xx_cpu_suspend(save_state); |
Russell King | 29cb3cd | 2011-07-02 09:54:01 +0100 | [diff] [blame] | 185 | return 0; |
Rajendra Nayak | 57f277b | 2008-09-26 17:49:34 +0530 | [diff] [blame] | 186 | } |
| 187 | |
Rajendra Nayak | 99e6a4d | 2008-10-08 17:30:58 +0530 | [diff] [blame] | 188 | void omap_sram_idle(void) |
Kevin Hilman | 8bd2294 | 2009-05-28 10:56:16 -0700 | [diff] [blame] | 189 | { |
| 190 | /* Variable to tell what needs to be saved and restored |
| 191 | * in omap_sram_idle*/ |
| 192 | /* save_state = 0 => Nothing to save and restored */ |
| 193 | /* save_state = 1 => Only L1 and logic lost */ |
| 194 | /* save_state = 2 => Only L2 lost */ |
| 195 | /* save_state = 3 => L1, L2 and logic lost */ |
Rajendra Nayak | fa3c2a4 | 2008-09-26 17:49:22 +0530 | [diff] [blame] | 196 | int save_state = 0; |
| 197 | int mpu_next_state = PWRDM_POWER_ON; |
| 198 | int per_next_state = PWRDM_POWER_ON; |
| 199 | int core_next_state = PWRDM_POWER_ON; |
Paul Walmsley | 72e06d0 | 2010-12-21 21:05:16 -0700 | [diff] [blame] | 200 | int per_going_off; |
Paul Walmsley | eeb3711 | 2012-04-13 06:34:32 -0600 | [diff] [blame] | 201 | int core_prev_state; |
Tero Kristo | 13a6fe0f | 2008-10-13 13:17:06 +0300 | [diff] [blame] | 202 | u32 sdrc_pwr = 0; |
Kevin Hilman | 8bd2294 | 2009-05-28 10:56:16 -0700 | [diff] [blame] | 203 | |
Kevin Hilman | 8bd2294 | 2009-05-28 10:56:16 -0700 | [diff] [blame] | 204 | mpu_next_state = pwrdm_read_next_pwrst(mpu_pwrdm); |
| 205 | switch (mpu_next_state) { |
Rajendra Nayak | fa3c2a4 | 2008-09-26 17:49:22 +0530 | [diff] [blame] | 206 | case PWRDM_POWER_ON: |
Kevin Hilman | 8bd2294 | 2009-05-28 10:56:16 -0700 | [diff] [blame] | 207 | case PWRDM_POWER_RET: |
| 208 | /* No need to save context */ |
| 209 | save_state = 0; |
| 210 | break; |
Rajendra Nayak | 61255ab | 2008-09-26 17:49:56 +0530 | [diff] [blame] | 211 | case PWRDM_POWER_OFF: |
| 212 | save_state = 3; |
| 213 | break; |
Kevin Hilman | 8bd2294 | 2009-05-28 10:56:16 -0700 | [diff] [blame] | 214 | default: |
| 215 | /* Invalid state */ |
Mark A. Greer | 9817985 | 2012-03-17 18:22:48 -0700 | [diff] [blame] | 216 | pr_err("Invalid mpu state in sram_idle\n"); |
Kevin Hilman | 8bd2294 | 2009-05-28 10:56:16 -0700 | [diff] [blame] | 217 | return; |
| 218 | } |
Peter 'p2' De Schrijver | fe617af | 2008-10-15 17:48:44 +0300 | [diff] [blame] | 219 | |
Rajendra Nayak | fa3c2a4 | 2008-09-26 17:49:22 +0530 | [diff] [blame] | 220 | /* NEON control */ |
| 221 | if (pwrdm_read_pwrst(neon_pwrdm) == PWRDM_POWER_ON) |
Jouni Hogander | 7139178 | 2008-10-28 10:59:05 +0200 | [diff] [blame] | 222 | pwrdm_set_next_pwrst(neon_pwrdm, mpu_next_state); |
Rajendra Nayak | fa3c2a4 | 2008-09-26 17:49:22 +0530 | [diff] [blame] | 223 | |
Mike Chan | 40742fa | 2010-05-03 16:04:06 -0700 | [diff] [blame] | 224 | /* Enable IO-PAD and IO-CHAIN wakeups */ |
Kevin Hilman | 658ce97 | 2008-11-04 20:50:52 -0800 | [diff] [blame] | 225 | per_next_state = pwrdm_read_next_pwrst(per_pwrdm); |
Tero Kristo | ecf157d | 2008-12-01 13:17:29 +0200 | [diff] [blame] | 226 | core_next_state = pwrdm_read_next_pwrst(core_pwrdm); |
Mike Chan | 40742fa | 2010-05-03 16:04:06 -0700 | [diff] [blame] | 227 | |
Kevin Hilman | e0e29fd | 2012-08-07 11:28:06 -0700 | [diff] [blame] | 228 | pwrdm_pre_transition(NULL); |
Charulatha V | ff2f8e5 | 2011-09-13 18:32:37 +0530 | [diff] [blame] | 229 | |
Mike Chan | 40742fa | 2010-05-03 16:04:06 -0700 | [diff] [blame] | 230 | /* PER */ |
Kevin Hilman | 658ce97 | 2008-11-04 20:50:52 -0800 | [diff] [blame] | 231 | if (per_next_state < PWRDM_POWER_ON) { |
Paul Walmsley | 72e06d0 | 2010-12-21 21:05:16 -0700 | [diff] [blame] | 232 | per_going_off = (per_next_state == PWRDM_POWER_OFF) ? 1 : 0; |
Paul Walmsley | 72e06d0 | 2010-12-21 21:05:16 -0700 | [diff] [blame] | 233 | omap2_gpio_prepare_for_idle(per_going_off); |
Kevin Hilman | 658ce97 | 2008-11-04 20:50:52 -0800 | [diff] [blame] | 234 | } |
| 235 | |
| 236 | /* CORE */ |
Rajendra Nayak | fa3c2a4 | 2008-09-26 17:49:22 +0530 | [diff] [blame] | 237 | if (core_next_state < PWRDM_POWER_ON) { |
Rajendra Nayak | 2f5939c | 2008-09-26 17:50:07 +0530 | [diff] [blame] | 238 | if (core_next_state == PWRDM_POWER_OFF) { |
| 239 | omap3_core_save_context(); |
Paul Walmsley | f0611a5 | 2010-12-21 15:30:56 -0700 | [diff] [blame] | 240 | omap3_cm_save_context(); |
Rajendra Nayak | 2f5939c | 2008-09-26 17:50:07 +0530 | [diff] [blame] | 241 | } |
Rajendra Nayak | fa3c2a4 | 2008-09-26 17:49:22 +0530 | [diff] [blame] | 242 | } |
Mike Chan | 40742fa | 2010-05-03 16:04:06 -0700 | [diff] [blame] | 243 | |
Tony Lindgren | 3b8c4eb | 2014-05-05 17:27:35 -0700 | [diff] [blame] | 244 | /* Configure PMIC signaling for I2C4 or sys_off_mode */ |
| 245 | omap3_vc_set_pmic_signaling(core_next_state); |
| 246 | |
Tero Kristo | f18cc2f | 2009-10-23 19:03:50 +0300 | [diff] [blame] | 247 | omap3_intc_prepare_idle(); |
Kevin Hilman | 8bd2294 | 2009-05-28 10:56:16 -0700 | [diff] [blame] | 248 | |
Rajendra Nayak | 61255ab | 2008-09-26 17:49:56 +0530 | [diff] [blame] | 249 | /* |
Paul Walmsley | 3047454 | 2011-10-06 13:43:23 -0600 | [diff] [blame] | 250 | * On EMU/HS devices ROM code restores a SRDC value |
| 251 | * from scratchpad which has automatic self refresh on timeout |
| 252 | * of AUTO_CNT = 1 enabled. This takes care of erratum ID i443. |
| 253 | * Hence store/restore the SDRC_POWER register here. |
| 254 | */ |
| 255 | if (cpu_is_omap3430() && omap_rev() >= OMAP3430_REV_ES3_0 && |
| 256 | (omap_type() == OMAP2_DEVICE_TYPE_EMU || |
| 257 | omap_type() == OMAP2_DEVICE_TYPE_SEC) && |
Rajendra Nayak | f265dc4 | 2009-06-09 22:30:41 +0530 | [diff] [blame] | 258 | core_next_state == PWRDM_POWER_OFF) |
Tero Kristo | 13a6fe0f | 2008-10-13 13:17:06 +0300 | [diff] [blame] | 259 | sdrc_pwr = sdrc_read_reg(SDRC_POWER); |
Tero Kristo | 13a6fe0f | 2008-10-13 13:17:06 +0300 | [diff] [blame] | 260 | |
| 261 | /* |
Russell King | 076f2cc | 2011-06-22 15:42:54 +0100 | [diff] [blame] | 262 | * omap3_arm_context is the location where some ARM context |
| 263 | * get saved. The rest is placed on the stack, and restored |
| 264 | * from there before resuming. |
Rajendra Nayak | 61255ab | 2008-09-26 17:49:56 +0530 | [diff] [blame] | 265 | */ |
Russell King | cbe2634 | 2011-06-30 08:45:49 +0100 | [diff] [blame] | 266 | if (save_state) |
| 267 | omap34xx_save_context(omap3_arm_context); |
Russell King | 076f2cc | 2011-06-22 15:42:54 +0100 | [diff] [blame] | 268 | if (save_state == 1 || save_state == 3) |
Russell King | 2c74a0c | 2011-06-22 17:41:48 +0100 | [diff] [blame] | 269 | cpu_suspend(save_state, omap34xx_do_sram_idle); |
Russell King | 076f2cc | 2011-06-22 15:42:54 +0100 | [diff] [blame] | 270 | else |
| 271 | omap34xx_do_sram_idle(save_state); |
Kevin Hilman | 8bd2294 | 2009-05-28 10:56:16 -0700 | [diff] [blame] | 272 | |
Rajendra Nayak | f265dc4 | 2009-06-09 22:30:41 +0530 | [diff] [blame] | 273 | /* Restore normal SDRC POWER settings */ |
Paul Walmsley | 3047454 | 2011-10-06 13:43:23 -0600 | [diff] [blame] | 274 | if (cpu_is_omap3430() && omap_rev() >= OMAP3430_REV_ES3_0 && |
| 275 | (omap_type() == OMAP2_DEVICE_TYPE_EMU || |
| 276 | omap_type() == OMAP2_DEVICE_TYPE_SEC) && |
Tero Kristo | 13a6fe0f | 2008-10-13 13:17:06 +0300 | [diff] [blame] | 277 | core_next_state == PWRDM_POWER_OFF) |
| 278 | sdrc_write_reg(sdrc_pwr, SDRC_POWER); |
| 279 | |
Kevin Hilman | 658ce97 | 2008-11-04 20:50:52 -0800 | [diff] [blame] | 280 | /* CORE */ |
Rajendra Nayak | fa3c2a4 | 2008-09-26 17:49:22 +0530 | [diff] [blame] | 281 | if (core_next_state < PWRDM_POWER_ON) { |
Rajendra Nayak | 2f5939c | 2008-09-26 17:50:07 +0530 | [diff] [blame] | 282 | core_prev_state = pwrdm_read_prev_pwrst(core_pwrdm); |
| 283 | if (core_prev_state == PWRDM_POWER_OFF) { |
| 284 | omap3_core_restore_context(); |
Paul Walmsley | f0611a5 | 2010-12-21 15:30:56 -0700 | [diff] [blame] | 285 | omap3_cm_restore_context(); |
Rajendra Nayak | 2f5939c | 2008-09-26 17:50:07 +0530 | [diff] [blame] | 286 | omap3_sram_restore_context(); |
Kalle Jokiniemi | 8a917d2 | 2009-05-13 13:32:11 +0300 | [diff] [blame] | 287 | omap2_sms_restore_context(); |
Rajendra Nayak | 2f5939c | 2008-09-26 17:50:07 +0530 | [diff] [blame] | 288 | } |
Kevin Hilman | 658ce97 | 2008-11-04 20:50:52 -0800 | [diff] [blame] | 289 | } |
Tero Kristo | f18cc2f | 2009-10-23 19:03:50 +0300 | [diff] [blame] | 290 | omap3_intc_resume_idle(); |
Kevin Hilman | 658ce97 | 2008-11-04 20:50:52 -0800 | [diff] [blame] | 291 | |
Kevin Hilman | e0e29fd | 2012-08-07 11:28:06 -0700 | [diff] [blame] | 292 | pwrdm_post_transition(NULL); |
Kevin Hilman | 658ce97 | 2008-11-04 20:50:52 -0800 | [diff] [blame] | 293 | |
Kevin Hilman | e0e29fd | 2012-08-07 11:28:06 -0700 | [diff] [blame] | 294 | /* PER */ |
| 295 | if (per_next_state < PWRDM_POWER_ON) |
| 296 | omap2_gpio_resume_after_idle(); |
Kevin Hilman | 8bd2294 | 2009-05-28 10:56:16 -0700 | [diff] [blame] | 297 | } |
| 298 | |
Kevin Hilman | 8bd2294 | 2009-05-28 10:56:16 -0700 | [diff] [blame] | 299 | static void omap3_pm_idle(void) |
| 300 | { |
Nicolas Pitre | 0bcd24b | 2012-01-04 16:27:48 -0500 | [diff] [blame] | 301 | if (omap_irq_pending()) |
Santosh Shilimkar | 6b85638 | 2013-02-11 19:29:45 +0530 | [diff] [blame] | 302 | return; |
Kevin Hilman | 8bd2294 | 2009-05-28 10:56:16 -0700 | [diff] [blame] | 303 | |
Jisheng Zhang | 6ca2270 | 2015-09-18 13:41:21 +0800 | [diff] [blame] | 304 | trace_cpu_idle_rcuidle(1, smp_processor_id()); |
Jean Pihet | 5e7c58d | 2011-03-03 11:25:43 +0100 | [diff] [blame] | 305 | |
Kevin Hilman | 8bd2294 | 2009-05-28 10:56:16 -0700 | [diff] [blame] | 306 | omap_sram_idle(); |
| 307 | |
Jisheng Zhang | 6ca2270 | 2015-09-18 13:41:21 +0800 | [diff] [blame] | 308 | trace_cpu_idle_rcuidle(PWR_EVENT_EXIT, smp_processor_id()); |
Kevin Hilman | 8bd2294 | 2009-05-28 10:56:16 -0700 | [diff] [blame] | 309 | } |
| 310 | |
Kevin Hilman | 10f90ed | 2009-06-24 11:39:18 -0700 | [diff] [blame] | 311 | #ifdef CONFIG_SUSPEND |
Kevin Hilman | 8bd2294 | 2009-05-28 10:56:16 -0700 | [diff] [blame] | 312 | static int omap3_pm_suspend(void) |
| 313 | { |
| 314 | struct power_state *pwrst; |
| 315 | int state, ret = 0; |
| 316 | |
| 317 | /* Read current next_pwrsts */ |
| 318 | list_for_each_entry(pwrst, &pwrst_list, node) |
| 319 | pwrst->saved_state = pwrdm_read_next_pwrst(pwrst->pwrdm); |
| 320 | /* Set ones wanted by suspend */ |
| 321 | list_for_each_entry(pwrst, &pwrst_list, node) { |
Santosh Shilimkar | eb6a2c7 | 2010-09-15 01:04:01 +0530 | [diff] [blame] | 322 | if (omap_set_pwrdm_state(pwrst->pwrdm, pwrst->next_state)) |
Kevin Hilman | 8bd2294 | 2009-05-28 10:56:16 -0700 | [diff] [blame] | 323 | goto restore; |
| 324 | if (pwrdm_clear_all_prev_pwrst(pwrst->pwrdm)) |
| 325 | goto restore; |
| 326 | } |
| 327 | |
Tero Kristo | 2bbe3af | 2009-10-23 19:03:48 +0300 | [diff] [blame] | 328 | omap3_intc_suspend(); |
| 329 | |
Kevin Hilman | 8bd2294 | 2009-05-28 10:56:16 -0700 | [diff] [blame] | 330 | omap_sram_idle(); |
| 331 | |
| 332 | restore: |
| 333 | /* Restore next_pwrsts */ |
| 334 | list_for_each_entry(pwrst, &pwrst_list, node) { |
Kevin Hilman | 8bd2294 | 2009-05-28 10:56:16 -0700 | [diff] [blame] | 335 | state = pwrdm_read_prev_pwrst(pwrst->pwrdm); |
| 336 | if (state > pwrst->next_state) { |
Paul Walmsley | 7852ec0 | 2012-07-26 00:54:26 -0600 | [diff] [blame] | 337 | pr_info("Powerdomain (%s) didn't enter target state %d\n", |
| 338 | pwrst->pwrdm->name, pwrst->next_state); |
Kevin Hilman | 8bd2294 | 2009-05-28 10:56:16 -0700 | [diff] [blame] | 339 | ret = -1; |
| 340 | } |
Santosh Shilimkar | eb6a2c7 | 2010-09-15 01:04:01 +0530 | [diff] [blame] | 341 | omap_set_pwrdm_state(pwrst->pwrdm, pwrst->saved_state); |
Kevin Hilman | 8bd2294 | 2009-05-28 10:56:16 -0700 | [diff] [blame] | 342 | } |
| 343 | if (ret) |
Mark A. Greer | 9817985 | 2012-03-17 18:22:48 -0700 | [diff] [blame] | 344 | pr_err("Could not enter target state in pm_suspend\n"); |
Kevin Hilman | 8bd2294 | 2009-05-28 10:56:16 -0700 | [diff] [blame] | 345 | else |
Mark A. Greer | 9817985 | 2012-03-17 18:22:48 -0700 | [diff] [blame] | 346 | pr_info("Successfully put all powerdomains to target state\n"); |
Kevin Hilman | 8bd2294 | 2009-05-28 10:56:16 -0700 | [diff] [blame] | 347 | |
| 348 | return ret; |
| 349 | } |
Dave Gerlach | 2e4b62d | 2014-05-12 13:33:21 -0500 | [diff] [blame] | 350 | #else |
| 351 | #define omap3_pm_suspend NULL |
Kevin Hilman | 10f90ed | 2009-06-24 11:39:18 -0700 | [diff] [blame] | 352 | #endif /* CONFIG_SUSPEND */ |
Kevin Hilman | 8bd2294 | 2009-05-28 10:56:16 -0700 | [diff] [blame] | 353 | |
Kevin Hilman | 8111b22 | 2009-04-28 15:27:44 -0700 | [diff] [blame] | 354 | static void __init prcm_setup_regs(void) |
| 355 | { |
Tero Kristo | ba12c24 | 2014-03-04 17:43:04 +0200 | [diff] [blame] | 356 | omap3_ctrl_init(); |
Tero Kristo | b296c81 | 2009-10-23 19:03:49 +0300 | [diff] [blame] | 357 | |
Tero Kristo | c5180a2 | 2014-02-26 17:30:43 +0200 | [diff] [blame] | 358 | omap3_prm_init_pm(cpu_is_omap3630(), omap3_has_iva()); |
Kevin Hilman | 8bd2294 | 2009-05-28 10:56:16 -0700 | [diff] [blame] | 359 | } |
| 360 | |
Kevin Hilman | c40552b | 2009-10-06 14:25:09 -0700 | [diff] [blame] | 361 | void omap3_pm_off_mode_enable(int enable) |
| 362 | { |
| 363 | struct power_state *pwrst; |
| 364 | u32 state; |
| 365 | |
| 366 | if (enable) |
| 367 | state = PWRDM_POWER_OFF; |
| 368 | else |
| 369 | state = PWRDM_POWER_RET; |
| 370 | |
| 371 | list_for_each_entry(pwrst, &pwrst_list, node) { |
Eduardo Valentin | cc1b602 | 2010-12-20 14:05:09 -0600 | [diff] [blame] | 372 | if (IS_PM34XX_ERRATUM(PM_SDRC_WAKEUP_ERRATUM_i583) && |
| 373 | pwrst->pwrdm == core_pwrdm && |
| 374 | state == PWRDM_POWER_OFF) { |
| 375 | pwrst->next_state = PWRDM_POWER_RET; |
Ricardo Salveti de Araujo | e16b41b | 2011-01-31 11:35:25 -0200 | [diff] [blame] | 376 | pr_warn("%s: Core OFF disabled due to errata i583\n", |
Eduardo Valentin | cc1b602 | 2010-12-20 14:05:09 -0600 | [diff] [blame] | 377 | __func__); |
| 378 | } else { |
| 379 | pwrst->next_state = state; |
| 380 | } |
| 381 | omap_set_pwrdm_state(pwrst->pwrdm, pwrst->next_state); |
Kevin Hilman | c40552b | 2009-10-06 14:25:09 -0700 | [diff] [blame] | 382 | } |
| 383 | } |
| 384 | |
Tero Kristo | 68d4778 | 2008-11-26 12:26:24 +0200 | [diff] [blame] | 385 | int omap3_pm_get_suspend_state(struct powerdomain *pwrdm) |
| 386 | { |
| 387 | struct power_state *pwrst; |
| 388 | |
| 389 | list_for_each_entry(pwrst, &pwrst_list, node) { |
| 390 | if (pwrst->pwrdm == pwrdm) |
| 391 | return pwrst->next_state; |
| 392 | } |
| 393 | return -EINVAL; |
| 394 | } |
| 395 | |
| 396 | int omap3_pm_set_suspend_state(struct powerdomain *pwrdm, int state) |
| 397 | { |
| 398 | struct power_state *pwrst; |
| 399 | |
| 400 | list_for_each_entry(pwrst, &pwrst_list, node) { |
| 401 | if (pwrst->pwrdm == pwrdm) { |
| 402 | pwrst->next_state = state; |
| 403 | return 0; |
| 404 | } |
| 405 | } |
| 406 | return -EINVAL; |
| 407 | } |
| 408 | |
Peter 'p2' De Schrijver | a23456e | 2008-10-15 18:13:47 +0300 | [diff] [blame] | 409 | static int __init pwrdms_setup(struct powerdomain *pwrdm, void *unused) |
Kevin Hilman | 8bd2294 | 2009-05-28 10:56:16 -0700 | [diff] [blame] | 410 | { |
| 411 | struct power_state *pwrst; |
| 412 | |
| 413 | if (!pwrdm->pwrsts) |
| 414 | return 0; |
| 415 | |
Ming Lei | d3d381c | 2009-08-22 21:20:26 +0800 | [diff] [blame] | 416 | pwrst = kmalloc(sizeof(struct power_state), GFP_ATOMIC); |
Kevin Hilman | 8bd2294 | 2009-05-28 10:56:16 -0700 | [diff] [blame] | 417 | if (!pwrst) |
| 418 | return -ENOMEM; |
| 419 | pwrst->pwrdm = pwrdm; |
| 420 | pwrst->next_state = PWRDM_POWER_RET; |
| 421 | list_add(&pwrst->node, &pwrst_list); |
| 422 | |
| 423 | if (pwrdm_has_hdwr_sar(pwrdm)) |
| 424 | pwrdm_enable_hdwr_sar(pwrdm); |
| 425 | |
Santosh Shilimkar | eb6a2c7 | 2010-09-15 01:04:01 +0530 | [diff] [blame] | 426 | return omap_set_pwrdm_state(pwrst->pwrdm, pwrst->next_state); |
Kevin Hilman | 8bd2294 | 2009-05-28 10:56:16 -0700 | [diff] [blame] | 427 | } |
| 428 | |
| 429 | /* |
Jean Pihet | 46e130d | 2011-06-29 18:40:23 +0200 | [diff] [blame] | 430 | * Push functions to SRAM |
| 431 | * |
| 432 | * The minimum set of functions is pushed to SRAM for execution: |
| 433 | * - omap3_do_wfi for erratum i581 WA, |
| 434 | * - save_secure_ram_context for security extensions. |
| 435 | */ |
Rajendra Nayak | 3231fc8 | 2008-09-26 17:49:14 +0530 | [diff] [blame] | 436 | void omap_push_sram_idle(void) |
| 437 | { |
Jean Pihet | 46e130d | 2011-06-29 18:40:23 +0200 | [diff] [blame] | 438 | omap3_do_wfi_sram = omap_sram_push(omap3_do_wfi, omap3_do_wfi_sz); |
| 439 | |
Tero Kristo | 27d59a4 | 2008-10-13 13:15:00 +0300 | [diff] [blame] | 440 | if (omap_type() != OMAP2_DEVICE_TYPE_GP) |
| 441 | _omap_save_secure_sram = omap_sram_push(save_secure_ram_context, |
| 442 | save_secure_ram_context_sz); |
Rajendra Nayak | 3231fc8 | 2008-09-26 17:49:14 +0530 | [diff] [blame] | 443 | } |
| 444 | |
Nishanth Menon | 8cdfd83 | 2010-12-20 14:05:05 -0600 | [diff] [blame] | 445 | static void __init pm_errata_configure(void) |
| 446 | { |
Peter 'p2' De Schrijver | c4236d2 | 2010-12-20 14:05:07 -0600 | [diff] [blame] | 447 | if (cpu_is_omap3630()) { |
Nishanth Menon | 458e999 | 2010-12-20 14:05:06 -0600 | [diff] [blame] | 448 | pm34xx_errata |= PM_RTA_ERRATUM_i608; |
Peter 'p2' De Schrijver | c4236d2 | 2010-12-20 14:05:07 -0600 | [diff] [blame] | 449 | /* Enable the l2 cache toggling in sleep logic */ |
| 450 | enable_omap3630_toggle_l2_on_restore(); |
Eduardo Valentin | cc1b602 | 2010-12-20 14:05:09 -0600 | [diff] [blame] | 451 | if (omap_rev() < OMAP3630_REV_ES1_2) |
Paul Walmsley | 856c3c5 | 2012-10-16 00:08:53 -0600 | [diff] [blame] | 452 | pm34xx_errata |= (PM_SDRC_WAKEUP_ERRATUM_i583 | |
| 453 | PM_PER_MEMORIES_ERRATUM_i582); |
| 454 | } else if (cpu_is_omap34xx()) { |
| 455 | pm34xx_errata |= PM_PER_MEMORIES_ERRATUM_i582; |
Peter 'p2' De Schrijver | c4236d2 | 2010-12-20 14:05:07 -0600 | [diff] [blame] | 456 | } |
Nishanth Menon | 8cdfd83 | 2010-12-20 14:05:05 -0600 | [diff] [blame] | 457 | } |
| 458 | |
Shawn Guo | bbd707a | 2012-04-26 16:06:50 +0800 | [diff] [blame] | 459 | int __init omap3_pm_init(void) |
Kevin Hilman | 8bd2294 | 2009-05-28 10:56:16 -0700 | [diff] [blame] | 460 | { |
| 461 | struct power_state *pwrst, *tmp; |
Paul Walmsley | 856c3c5 | 2012-10-16 00:08:53 -0600 | [diff] [blame] | 462 | struct clockdomain *neon_clkdm, *mpu_clkdm, *per_clkdm, *wkup_clkdm; |
Kevin Hilman | 8bd2294 | 2009-05-28 10:56:16 -0700 | [diff] [blame] | 463 | int ret; |
| 464 | |
Paul Walmsley | b02b917 | 2011-10-06 17:18:45 -0600 | [diff] [blame] | 465 | if (!omap3_has_io_chain_ctrl()) |
Joe Perches | 3d0cb73 | 2014-09-13 11:31:16 -0700 | [diff] [blame] | 466 | pr_warn("PM: no software I/O chain control; some wakeups may be lost\n"); |
Paul Walmsley | b02b917 | 2011-10-06 17:18:45 -0600 | [diff] [blame] | 467 | |
Nishanth Menon | 8cdfd83 | 2010-12-20 14:05:05 -0600 | [diff] [blame] | 468 | pm_errata_configure(); |
| 469 | |
Kevin Hilman | 8bd2294 | 2009-05-28 10:56:16 -0700 | [diff] [blame] | 470 | /* XXX prcm_setup_regs needs to be before enabling hw |
| 471 | * supervised mode for powerdomains */ |
| 472 | prcm_setup_regs(); |
| 473 | |
Tero Kristo | 22f5137 | 2011-12-16 14:36:59 -0700 | [diff] [blame] | 474 | ret = request_irq(omap_prcm_event_to_irq("wkup"), |
| 475 | _prcm_int_handle_wakeup, IRQF_NO_SUSPEND, "pm_wkup", NULL); |
| 476 | |
Kevin Hilman | 8bd2294 | 2009-05-28 10:56:16 -0700 | [diff] [blame] | 477 | if (ret) { |
Tero Kristo | 22f5137 | 2011-12-16 14:36:59 -0700 | [diff] [blame] | 478 | pr_err("pm: Failed to request pm_wkup irq\n"); |
| 479 | goto err1; |
| 480 | } |
| 481 | |
| 482 | /* IO interrupt is shared with mux code */ |
| 483 | ret = request_irq(omap_prcm_event_to_irq("io"), |
| 484 | _prcm_int_handle_io, IRQF_SHARED | IRQF_NO_SUSPEND, "pm_io", |
| 485 | omap3_pm_init); |
Kevin Hilman | 99b59df | 2012-04-27 16:05:51 -0700 | [diff] [blame] | 486 | enable_irq(omap_prcm_event_to_irq("io")); |
Tero Kristo | 22f5137 | 2011-12-16 14:36:59 -0700 | [diff] [blame] | 487 | |
| 488 | if (ret) { |
| 489 | pr_err("pm: Failed to request pm_io irq\n"); |
Mark A. Greer | ce229c5 | 2012-03-17 18:22:47 -0700 | [diff] [blame] | 490 | goto err2; |
Kevin Hilman | 8bd2294 | 2009-05-28 10:56:16 -0700 | [diff] [blame] | 491 | } |
| 492 | |
Peter 'p2' De Schrijver | a23456e | 2008-10-15 18:13:47 +0300 | [diff] [blame] | 493 | ret = pwrdm_for_each(pwrdms_setup, NULL); |
Kevin Hilman | 8bd2294 | 2009-05-28 10:56:16 -0700 | [diff] [blame] | 494 | if (ret) { |
Mark A. Greer | 9817985 | 2012-03-17 18:22:48 -0700 | [diff] [blame] | 495 | pr_err("Failed to setup powerdomains\n"); |
Mark A. Greer | ce229c5 | 2012-03-17 18:22:47 -0700 | [diff] [blame] | 496 | goto err3; |
Kevin Hilman | 8bd2294 | 2009-05-28 10:56:16 -0700 | [diff] [blame] | 497 | } |
| 498 | |
Paul Walmsley | 92206fd | 2012-02-02 02:38:50 -0700 | [diff] [blame] | 499 | (void) clkdm_for_each(omap_pm_clkdms_setup, NULL); |
Kevin Hilman | 8bd2294 | 2009-05-28 10:56:16 -0700 | [diff] [blame] | 500 | |
| 501 | mpu_pwrdm = pwrdm_lookup("mpu_pwrdm"); |
| 502 | if (mpu_pwrdm == NULL) { |
Mark A. Greer | 9817985 | 2012-03-17 18:22:48 -0700 | [diff] [blame] | 503 | pr_err("Failed to get mpu_pwrdm\n"); |
Mark A. Greer | ce229c5 | 2012-03-17 18:22:47 -0700 | [diff] [blame] | 504 | ret = -EINVAL; |
| 505 | goto err3; |
Kevin Hilman | 8bd2294 | 2009-05-28 10:56:16 -0700 | [diff] [blame] | 506 | } |
| 507 | |
Rajendra Nayak | fa3c2a4 | 2008-09-26 17:49:22 +0530 | [diff] [blame] | 508 | neon_pwrdm = pwrdm_lookup("neon_pwrdm"); |
| 509 | per_pwrdm = pwrdm_lookup("per_pwrdm"); |
| 510 | core_pwrdm = pwrdm_lookup("core_pwrdm"); |
| 511 | |
Paul Walmsley | 55ed969 | 2010-01-26 20:12:59 -0700 | [diff] [blame] | 512 | neon_clkdm = clkdm_lookup("neon_clkdm"); |
| 513 | mpu_clkdm = clkdm_lookup("mpu_clkdm"); |
Paul Walmsley | 856c3c5 | 2012-10-16 00:08:53 -0600 | [diff] [blame] | 514 | per_clkdm = clkdm_lookup("per_clkdm"); |
| 515 | wkup_clkdm = clkdm_lookup("wkup_clkdm"); |
Paul Walmsley | 55ed969 | 2010-01-26 20:12:59 -0700 | [diff] [blame] | 516 | |
Dave Gerlach | 2e4b62d | 2014-05-12 13:33:21 -0500 | [diff] [blame] | 517 | omap_common_suspend_init(omap3_pm_suspend); |
Kevin Hilman | 8bd2294 | 2009-05-28 10:56:16 -0700 | [diff] [blame] | 518 | |
Nicolas Pitre | 0bcd24b | 2012-01-04 16:27:48 -0500 | [diff] [blame] | 519 | arm_pm_idle = omap3_pm_idle; |
Kalle Jokiniemi | 0343371 | 2008-09-26 11:04:20 +0300 | [diff] [blame] | 520 | omap3_idle_init(); |
Kevin Hilman | 8bd2294 | 2009-05-28 10:56:16 -0700 | [diff] [blame] | 521 | |
Nishanth Menon | 458e999 | 2010-12-20 14:05:06 -0600 | [diff] [blame] | 522 | /* |
| 523 | * RTA is disabled during initialization as per erratum i608 |
| 524 | * it is safer to disable RTA by the bootloader, but we would like |
| 525 | * to be doubly sure here and prevent any mishaps. |
| 526 | */ |
| 527 | if (IS_PM34XX_ERRATUM(PM_RTA_ERRATUM_i608)) |
| 528 | omap3630_ctrl_disable_rta(); |
| 529 | |
Paul Walmsley | 856c3c5 | 2012-10-16 00:08:53 -0600 | [diff] [blame] | 530 | /* |
| 531 | * The UART3/4 FIFO and the sidetone memory in McBSP2/3 are |
| 532 | * not correctly reset when the PER powerdomain comes back |
| 533 | * from OFF or OSWR when the CORE powerdomain is kept active. |
| 534 | * See OMAP36xx Erratum i582 "PER Domain reset issue after |
| 535 | * Domain-OFF/OSWR Wakeup". This wakeup dependency is not a |
| 536 | * complete workaround. The kernel must also prevent the PER |
| 537 | * powerdomain from going to OSWR/OFF while the CORE |
| 538 | * powerdomain is not going to OSWR/OFF. And if PER last |
| 539 | * power state was off while CORE last power state was ON, the |
| 540 | * UART3/4 and McBSP2/3 SIDETONE devices need to run a |
| 541 | * self-test using their loopback tests; if that fails, those |
| 542 | * devices are unusable until the PER/CORE can complete a transition |
| 543 | * from ON to OSWR/OFF and then back to ON. |
| 544 | * |
| 545 | * XXX Technically this workaround is only needed if off-mode |
| 546 | * or OSWR is enabled. |
| 547 | */ |
| 548 | if (IS_PM34XX_ERRATUM(PM_PER_MEMORIES_ERRATUM_i582)) |
| 549 | clkdm_add_wkdep(per_clkdm, wkup_clkdm); |
| 550 | |
Paul Walmsley | 55ed969 | 2010-01-26 20:12:59 -0700 | [diff] [blame] | 551 | clkdm_add_wkdep(neon_clkdm, mpu_clkdm); |
Tero Kristo | 27d59a4 | 2008-10-13 13:15:00 +0300 | [diff] [blame] | 552 | if (omap_type() != OMAP2_DEVICE_TYPE_GP) { |
| 553 | omap3_secure_ram_storage = |
| 554 | kmalloc(0x803F, GFP_KERNEL); |
| 555 | if (!omap3_secure_ram_storage) |
Paul Walmsley | 7852ec0 | 2012-07-26 00:54:26 -0600 | [diff] [blame] | 556 | pr_err("Memory allocation failed when allocating for secure sram context\n"); |
Tero Kristo | 27d59a4 | 2008-10-13 13:15:00 +0300 | [diff] [blame] | 557 | |
Tero Kristo | 9d97140 | 2008-12-12 11:20:05 +0200 | [diff] [blame] | 558 | local_irq_disable(); |
Tero Kristo | 9d97140 | 2008-12-12 11:20:05 +0200 | [diff] [blame] | 559 | |
| 560 | omap_dma_global_context_save(); |
Kevin Hilman | 617fcc9 | 2011-01-25 16:40:01 -0800 | [diff] [blame] | 561 | omap3_save_secure_ram_context(); |
Tero Kristo | 9d97140 | 2008-12-12 11:20:05 +0200 | [diff] [blame] | 562 | omap_dma_global_context_restore(); |
| 563 | |
| 564 | local_irq_enable(); |
Tero Kristo | 9d97140 | 2008-12-12 11:20:05 +0200 | [diff] [blame] | 565 | } |
| 566 | |
| 567 | omap3_save_scratchpad_contents(); |
Kevin Hilman | 8bd2294 | 2009-05-28 10:56:16 -0700 | [diff] [blame] | 568 | return ret; |
Mark A. Greer | ce229c5 | 2012-03-17 18:22:47 -0700 | [diff] [blame] | 569 | |
| 570 | err3: |
Kevin Hilman | 8bd2294 | 2009-05-28 10:56:16 -0700 | [diff] [blame] | 571 | list_for_each_entry_safe(pwrst, tmp, &pwrst_list, node) { |
| 572 | list_del(&pwrst->node); |
| 573 | kfree(pwrst); |
| 574 | } |
Mark A. Greer | ce229c5 | 2012-03-17 18:22:47 -0700 | [diff] [blame] | 575 | free_irq(omap_prcm_event_to_irq("io"), omap3_pm_init); |
| 576 | err2: |
| 577 | free_irq(omap_prcm_event_to_irq("wkup"), NULL); |
| 578 | err1: |
Kevin Hilman | 8bd2294 | 2009-05-28 10:56:16 -0700 | [diff] [blame] | 579 | return ret; |
| 580 | } |