Kevin Hilman | 8bd2294 | 2009-05-28 10:56:16 -0700 | [diff] [blame] | 1 | /* |
| 2 | * OMAP2 Power Management Routines |
| 3 | * |
| 4 | * Copyright (C) 2005 Texas Instruments, Inc. |
| 5 | * Copyright (C) 2006-2008 Nokia Corporation |
| 6 | * |
| 7 | * Written by: |
| 8 | * Richard Woodruff <r-woodruff2@ti.com> |
| 9 | * Tony Lindgren |
| 10 | * Juha Yrjola |
| 11 | * Amit Kucheria <amit.kucheria@nokia.com> |
| 12 | * Igor Stoppa <igor.stoppa@nokia.com> |
| 13 | * |
| 14 | * Based on pm.c for omap1 |
| 15 | * |
| 16 | * This program is free software; you can redistribute it and/or modify |
| 17 | * it under the terms of the GNU General Public License version 2 as |
| 18 | * published by the Free Software Foundation. |
| 19 | */ |
| 20 | |
| 21 | #include <linux/suspend.h> |
| 22 | #include <linux/sched.h> |
| 23 | #include <linux/proc_fs.h> |
| 24 | #include <linux/interrupt.h> |
| 25 | #include <linux/sysfs.h> |
| 26 | #include <linux/module.h> |
| 27 | #include <linux/delay.h> |
Stephen Boyd | f5b00f6 | 2015-06-22 17:05:21 -0700 | [diff] [blame] | 28 | #include <linux/clk.h> |
Rajendra Nayak | ed1ebc4 | 2012-04-27 15:59:32 +0530 | [diff] [blame] | 29 | #include <linux/clk-provider.h> |
Kevin Hilman | 8bd2294 | 2009-05-28 10:56:16 -0700 | [diff] [blame] | 30 | #include <linux/irq.h> |
| 31 | #include <linux/time.h> |
| 32 | #include <linux/gpio.h> |
Tony Lindgren | 4b25408 | 2012-08-30 15:37:24 -0700 | [diff] [blame] | 33 | #include <linux/platform_data/gpio-omap.h> |
Kevin Hilman | 8bd2294 | 2009-05-28 10:56:16 -0700 | [diff] [blame] | 34 | |
Tony Lindgren | bf027ca | 2012-10-29 13:54:06 -0700 | [diff] [blame] | 35 | #include <asm/fncpy.h> |
| 36 | |
Kevin Hilman | 8bd2294 | 2009-05-28 10:56:16 -0700 | [diff] [blame] | 37 | #include <asm/mach/time.h> |
| 38 | #include <asm/mach/irq.h> |
| 39 | #include <asm/mach-types.h> |
David Howells | 9f97da7 | 2012-03-28 18:30:01 +0100 | [diff] [blame] | 40 | #include <asm/system_misc.h> |
Kevin Hilman | 8bd2294 | 2009-05-28 10:56:16 -0700 | [diff] [blame] | 41 | |
Tony Lindgren | 45c3eb7 | 2012-11-30 08:41:50 -0800 | [diff] [blame] | 42 | #include <linux/omap-dma.h> |
Kevin Hilman | 8bd2294 | 2009-05-28 10:56:16 -0700 | [diff] [blame] | 43 | |
Tony Lindgren | e4c060d | 2012-10-05 13:25:59 -0700 | [diff] [blame] | 44 | #include "soc.h" |
Tony Lindgren | 4e65331 | 2011-11-10 22:45:17 +0100 | [diff] [blame] | 45 | #include "common.h" |
Paul Walmsley | a135eaa | 2012-09-27 10:33:34 -0600 | [diff] [blame] | 46 | #include "clock.h" |
Paul Walmsley | 139563a | 2012-10-21 01:01:10 -0600 | [diff] [blame] | 47 | #include "prm2xxx.h" |
Kevin Hilman | 8bd2294 | 2009-05-28 10:56:16 -0700 | [diff] [blame] | 48 | #include "prm-regbits-24xx.h" |
Paul Walmsley | ff4ae5d | 2012-10-21 01:01:11 -0600 | [diff] [blame] | 49 | #include "cm2xxx.h" |
Kevin Hilman | 8bd2294 | 2009-05-28 10:56:16 -0700 | [diff] [blame] | 50 | #include "cm-regbits-24xx.h" |
| 51 | #include "sdrc.h" |
Tony Lindgren | bf027ca | 2012-10-29 13:54:06 -0700 | [diff] [blame] | 52 | #include "sram.h" |
Kevin Hilman | 8bd2294 | 2009-05-28 10:56:16 -0700 | [diff] [blame] | 53 | #include "pm.h" |
Paul Walmsley | 4814ced | 2010-10-08 11:40:20 -0600 | [diff] [blame] | 54 | #include "control.h" |
Paul Walmsley | 72e06d0 | 2010-12-21 21:05:16 -0700 | [diff] [blame] | 55 | #include "powerdomain.h" |
Paul Walmsley | 1540f214 | 2010-12-21 21:05:15 -0700 | [diff] [blame] | 56 | #include "clockdomain.h" |
Kevin Hilman | 8bd2294 | 2009-05-28 10:56:16 -0700 | [diff] [blame] | 57 | |
Kevin Hilman | 8bd2294 | 2009-05-28 10:56:16 -0700 | [diff] [blame] | 58 | static void (*omap2_sram_suspend)(u32 dllctrl, void __iomem *sdrc_dlla_ctrl, |
| 59 | void __iomem *sdrc_power); |
| 60 | |
Paul Walmsley | 369d561 | 2010-01-26 20:13:01 -0700 | [diff] [blame] | 61 | static struct powerdomain *mpu_pwrdm, *core_pwrdm; |
| 62 | static struct clockdomain *dsp_clkdm, *mpu_clkdm, *wkup_clkdm, *gfx_clkdm; |
Kevin Hilman | 8bd2294 | 2009-05-28 10:56:16 -0700 | [diff] [blame] | 63 | |
| 64 | static struct clk *osc_ck, *emul_ck; |
| 65 | |
Paul Walmsley | 1416408 | 2012-02-02 02:30:50 -0700 | [diff] [blame] | 66 | static int omap2_enter_full_retention(void) |
Kevin Hilman | 8bd2294 | 2009-05-28 10:56:16 -0700 | [diff] [blame] | 67 | { |
| 68 | u32 l; |
Kevin Hilman | 8bd2294 | 2009-05-28 10:56:16 -0700 | [diff] [blame] | 69 | |
| 70 | /* There is 1 reference hold for all children of the oscillator |
| 71 | * clock, the following will remove it. If no one else uses the |
| 72 | * oscillator itself it will be disabled if/when we enter retention |
| 73 | * mode. |
| 74 | */ |
| 75 | clk_disable(osc_ck); |
| 76 | |
| 77 | /* Clear old wake-up events */ |
| 78 | /* REVISIT: These write to reserved bits? */ |
Tero Kristo | 9cb6d36 | 2014-04-04 12:31:51 +0300 | [diff] [blame] | 79 | omap_prm_clear_mod_irqs(CORE_MOD, PM_WKST1, ~0); |
| 80 | omap_prm_clear_mod_irqs(CORE_MOD, OMAP24XX_PM_WKST2, ~0); |
| 81 | omap_prm_clear_mod_irqs(WKUP_MOD, PM_WKST, ~0); |
Kevin Hilman | 8bd2294 | 2009-05-28 10:56:16 -0700 | [diff] [blame] | 82 | |
Paul Walmsley | f653b29 | 2013-01-26 00:58:14 -0700 | [diff] [blame] | 83 | pwrdm_set_next_pwrst(core_pwrdm, PWRDM_POWER_RET); |
Kevin Hilman | 8bd2294 | 2009-05-28 10:56:16 -0700 | [diff] [blame] | 84 | pwrdm_set_next_pwrst(mpu_pwrdm, PWRDM_POWER_RET); |
| 85 | |
| 86 | /* Workaround to kill USB */ |
| 87 | l = omap_ctrl_readl(OMAP2_CONTROL_DEVCONF0) | OMAP24XX_USBSTANDBYCTRL; |
| 88 | omap_ctrl_writel(l, OMAP2_CONTROL_DEVCONF0); |
| 89 | |
Paul Walmsley | 72e06d0 | 2010-12-21 21:05:16 -0700 | [diff] [blame] | 90 | omap2_gpio_prepare_for_idle(0); |
Kevin Hilman | 8bd2294 | 2009-05-28 10:56:16 -0700 | [diff] [blame] | 91 | |
Kevin Hilman | 8bd2294 | 2009-05-28 10:56:16 -0700 | [diff] [blame] | 92 | /* One last check for pending IRQs to avoid extra latency due |
| 93 | * to sleeping unnecessarily. */ |
Jouni Hogander | 9443453 | 2009-02-03 15:49:04 -0800 | [diff] [blame] | 94 | if (omap_irq_pending()) |
Kevin Hilman | 8bd2294 | 2009-05-28 10:56:16 -0700 | [diff] [blame] | 95 | goto no_sleep; |
| 96 | |
| 97 | /* Jump to SRAM suspend code */ |
| 98 | omap2_sram_suspend(sdrc_read_reg(SDRC_DLLA_CTRL), |
| 99 | OMAP_SDRC_REGADDR(SDRC_DLLA_CTRL), |
| 100 | OMAP_SDRC_REGADDR(SDRC_POWER)); |
Kevin Hilman | 8bd2294 | 2009-05-28 10:56:16 -0700 | [diff] [blame] | 101 | |
Kevin Hilman | 4af4016 | 2009-02-04 10:51:40 -0800 | [diff] [blame] | 102 | no_sleep: |
Kevin Hilman | 43ffcd9 | 2009-01-27 11:09:24 -0800 | [diff] [blame] | 103 | omap2_gpio_resume_after_idle(); |
Kevin Hilman | 8bd2294 | 2009-05-28 10:56:16 -0700 | [diff] [blame] | 104 | |
| 105 | clk_enable(osc_ck); |
| 106 | |
| 107 | /* clear CORE wake-up events */ |
Tero Kristo | 9cb6d36 | 2014-04-04 12:31:51 +0300 | [diff] [blame] | 108 | omap_prm_clear_mod_irqs(CORE_MOD, PM_WKST1, ~0); |
| 109 | omap_prm_clear_mod_irqs(CORE_MOD, OMAP24XX_PM_WKST2, ~0); |
Kevin Hilman | 8bd2294 | 2009-05-28 10:56:16 -0700 | [diff] [blame] | 110 | |
| 111 | /* wakeup domain events - bit 1: GPT1, bit5 GPIO */ |
Tero Kristo | 9cb6d36 | 2014-04-04 12:31:51 +0300 | [diff] [blame] | 112 | omap_prm_clear_mod_irqs(WKUP_MOD, PM_WKST, 0x4 | 0x1); |
Kevin Hilman | 8bd2294 | 2009-05-28 10:56:16 -0700 | [diff] [blame] | 113 | |
| 114 | /* MPU domain wake events */ |
Tero Kristo | 9cb6d36 | 2014-04-04 12:31:51 +0300 | [diff] [blame] | 115 | omap_prm_clear_mod_irqs(OCP_MOD, OMAP2_PRCM_IRQSTATUS_MPU_OFFSET, 0x1); |
Kevin Hilman | 8bd2294 | 2009-05-28 10:56:16 -0700 | [diff] [blame] | 116 | |
Tero Kristo | 9cb6d36 | 2014-04-04 12:31:51 +0300 | [diff] [blame] | 117 | omap_prm_clear_mod_irqs(OCP_MOD, OMAP2_PRCM_IRQSTATUS_MPU_OFFSET, 0x20); |
Paul Walmsley | 1416408 | 2012-02-02 02:30:50 -0700 | [diff] [blame] | 118 | |
Paul Walmsley | f653b29 | 2013-01-26 00:58:14 -0700 | [diff] [blame] | 119 | pwrdm_set_next_pwrst(mpu_pwrdm, PWRDM_POWER_ON); |
| 120 | pwrdm_set_next_pwrst(core_pwrdm, PWRDM_POWER_ON); |
| 121 | |
Paul Walmsley | 1416408 | 2012-02-02 02:30:50 -0700 | [diff] [blame] | 122 | return 0; |
Kevin Hilman | 8bd2294 | 2009-05-28 10:56:16 -0700 | [diff] [blame] | 123 | } |
| 124 | |
Kevin Hilman | 8bd2294 | 2009-05-28 10:56:16 -0700 | [diff] [blame] | 125 | static int sti_console_enabled; |
| 126 | |
| 127 | static int omap2_allow_mpu_retention(void) |
| 128 | { |
Tero Kristo | cd6e9db | 2013-10-11 19:15:31 +0300 | [diff] [blame] | 129 | if (!omap2xxx_cm_mpu_retention_allowed()) |
Kevin Hilman | 8bd2294 | 2009-05-28 10:56:16 -0700 | [diff] [blame] | 130 | return 0; |
| 131 | if (sti_console_enabled) |
| 132 | return 0; |
| 133 | |
| 134 | return 1; |
| 135 | } |
| 136 | |
| 137 | static void omap2_enter_mpu_retention(void) |
| 138 | { |
Paul Walmsley | 088e880 | 2012-12-30 10:15:48 -0700 | [diff] [blame] | 139 | const int zero = 0; |
| 140 | |
Kevin Hilman | 8bd2294 | 2009-05-28 10:56:16 -0700 | [diff] [blame] | 141 | /* The peripherals seem not to be able to wake up the MPU when |
| 142 | * it is in retention mode. */ |
| 143 | if (omap2_allow_mpu_retention()) { |
| 144 | /* REVISIT: These write to reserved bits? */ |
Tero Kristo | 9cb6d36 | 2014-04-04 12:31:51 +0300 | [diff] [blame] | 145 | omap_prm_clear_mod_irqs(CORE_MOD, PM_WKST1, ~0); |
| 146 | omap_prm_clear_mod_irqs(CORE_MOD, OMAP24XX_PM_WKST2, ~0); |
| 147 | omap_prm_clear_mod_irqs(WKUP_MOD, PM_WKST, ~0); |
Kevin Hilman | 8bd2294 | 2009-05-28 10:56:16 -0700 | [diff] [blame] | 148 | |
| 149 | /* Try to enter MPU retention */ |
Paul Walmsley | f653b29 | 2013-01-26 00:58:14 -0700 | [diff] [blame] | 150 | pwrdm_set_next_pwrst(mpu_pwrdm, PWRDM_POWER_RET); |
| 151 | |
Kevin Hilman | 8bd2294 | 2009-05-28 10:56:16 -0700 | [diff] [blame] | 152 | } else { |
| 153 | /* Block MPU retention */ |
Paul Walmsley | f653b29 | 2013-01-26 00:58:14 -0700 | [diff] [blame] | 154 | pwrdm_set_next_pwrst(mpu_pwrdm, PWRDM_POWER_ON); |
Kevin Hilman | 8bd2294 | 2009-05-28 10:56:16 -0700 | [diff] [blame] | 155 | } |
| 156 | |
Paul Walmsley | 088e880 | 2012-12-30 10:15:48 -0700 | [diff] [blame] | 157 | /* WFI */ |
| 158 | asm("mcr p15, 0, %0, c7, c0, 4" : : "r" (zero) : "memory", "cc"); |
Paul Walmsley | f653b29 | 2013-01-26 00:58:14 -0700 | [diff] [blame] | 159 | |
| 160 | pwrdm_set_next_pwrst(mpu_pwrdm, PWRDM_POWER_ON); |
Kevin Hilman | 8bd2294 | 2009-05-28 10:56:16 -0700 | [diff] [blame] | 161 | } |
| 162 | |
| 163 | static int omap2_can_sleep(void) |
| 164 | { |
Tero Kristo | cd6e9db | 2013-10-11 19:15:31 +0300 | [diff] [blame] | 165 | if (omap2xxx_cm_fclks_active()) |
Kevin Hilman | 8bd2294 | 2009-05-28 10:56:16 -0700 | [diff] [blame] | 166 | return 0; |
Rajendra Nayak | ed1ebc4 | 2012-04-27 15:59:32 +0530 | [diff] [blame] | 167 | if (__clk_is_enabled(osc_ck)) |
Kevin Hilman | 8bd2294 | 2009-05-28 10:56:16 -0700 | [diff] [blame] | 168 | return 0; |
| 169 | if (omap_dma_running()) |
| 170 | return 0; |
| 171 | |
| 172 | return 1; |
| 173 | } |
| 174 | |
| 175 | static void omap2_pm_idle(void) |
| 176 | { |
Kevin Hilman | 8bd2294 | 2009-05-28 10:56:16 -0700 | [diff] [blame] | 177 | if (!omap2_can_sleep()) { |
Jouni Hogander | 9443453 | 2009-02-03 15:49:04 -0800 | [diff] [blame] | 178 | if (omap_irq_pending()) |
Santosh Shilimkar | 6b85638 | 2013-02-11 19:29:45 +0530 | [diff] [blame] | 179 | return; |
Kevin Hilman | 8bd2294 | 2009-05-28 10:56:16 -0700 | [diff] [blame] | 180 | omap2_enter_mpu_retention(); |
Santosh Shilimkar | 6b85638 | 2013-02-11 19:29:45 +0530 | [diff] [blame] | 181 | return; |
Kevin Hilman | 8bd2294 | 2009-05-28 10:56:16 -0700 | [diff] [blame] | 182 | } |
| 183 | |
Jouni Hogander | 9443453 | 2009-02-03 15:49:04 -0800 | [diff] [blame] | 184 | if (omap_irq_pending()) |
Santosh Shilimkar | 6b85638 | 2013-02-11 19:29:45 +0530 | [diff] [blame] | 185 | return; |
Kevin Hilman | 8bd2294 | 2009-05-28 10:56:16 -0700 | [diff] [blame] | 186 | |
| 187 | omap2_enter_full_retention(); |
Kevin Hilman | 8bd2294 | 2009-05-28 10:56:16 -0700 | [diff] [blame] | 188 | } |
| 189 | |
Kevin Hilman | 8bd2294 | 2009-05-28 10:56:16 -0700 | [diff] [blame] | 190 | static void __init prcm_setup_regs(void) |
| 191 | { |
| 192 | int i, num_mem_banks; |
| 193 | struct powerdomain *pwrdm; |
| 194 | |
Paul Walmsley | 4ef70c0 | 2011-02-25 15:39:30 -0700 | [diff] [blame] | 195 | /* |
| 196 | * Enable autoidle |
| 197 | * XXX This should be handled by hwmod code or PRCM init code |
| 198 | */ |
Paul Walmsley | c4d7e58 | 2010-12-21 21:05:14 -0700 | [diff] [blame] | 199 | omap2_prm_write_mod_reg(OMAP24XX_AUTOIDLE_MASK, OCP_MOD, |
Kevin Hilman | 8bd2294 | 2009-05-28 10:56:16 -0700 | [diff] [blame] | 200 | OMAP2_PRCM_SYSCONFIG_OFFSET); |
| 201 | |
Kevin Hilman | 8bd2294 | 2009-05-28 10:56:16 -0700 | [diff] [blame] | 202 | /* |
| 203 | * Set CORE powerdomain memory banks to retain their contents |
| 204 | * during RETENTION |
| 205 | */ |
| 206 | num_mem_banks = pwrdm_get_mem_bank_count(core_pwrdm); |
| 207 | for (i = 0; i < num_mem_banks; i++) |
| 208 | pwrdm_set_mem_retst(core_pwrdm, i, PWRDM_POWER_RET); |
| 209 | |
Paul Walmsley | f653b29 | 2013-01-26 00:58:14 -0700 | [diff] [blame] | 210 | pwrdm_set_logic_retst(core_pwrdm, PWRDM_POWER_RET); |
Kevin Hilman | 8bd2294 | 2009-05-28 10:56:16 -0700 | [diff] [blame] | 211 | |
Kevin Hilman | 8bd2294 | 2009-05-28 10:56:16 -0700 | [diff] [blame] | 212 | pwrdm_set_logic_retst(mpu_pwrdm, PWRDM_POWER_RET); |
Kevin Hilman | 8bd2294 | 2009-05-28 10:56:16 -0700 | [diff] [blame] | 213 | |
| 214 | /* Force-power down DSP, GFX powerdomains */ |
| 215 | |
| 216 | pwrdm = clkdm_get_pwrdm(dsp_clkdm); |
| 217 | pwrdm_set_next_pwrst(pwrdm, PWRDM_POWER_OFF); |
Kevin Hilman | 8bd2294 | 2009-05-28 10:56:16 -0700 | [diff] [blame] | 218 | |
| 219 | pwrdm = clkdm_get_pwrdm(gfx_clkdm); |
| 220 | pwrdm_set_next_pwrst(pwrdm, PWRDM_POWER_OFF); |
Kevin Hilman | 8bd2294 | 2009-05-28 10:56:16 -0700 | [diff] [blame] | 221 | |
Paul Walmsley | 51d070a | 2011-01-27 02:52:55 -0700 | [diff] [blame] | 222 | /* Enable hardware-supervised idle for all clkdms */ |
Paul Walmsley | 92206fd | 2012-02-02 02:38:50 -0700 | [diff] [blame] | 223 | clkdm_for_each(omap_pm_clkdms_setup, NULL); |
Paul Walmsley | 369d561 | 2010-01-26 20:13:01 -0700 | [diff] [blame] | 224 | clkdm_add_wkdep(mpu_clkdm, wkup_clkdm); |
Kevin Hilman | 8bd2294 | 2009-05-28 10:56:16 -0700 | [diff] [blame] | 225 | |
Dave Gerlach | 2e4b62d | 2014-05-12 13:33:21 -0500 | [diff] [blame] | 226 | omap_common_suspend_init(omap2_enter_full_retention); |
Paul Walmsley | 1416408 | 2012-02-02 02:30:50 -0700 | [diff] [blame] | 227 | |
Kevin Hilman | 8bd2294 | 2009-05-28 10:56:16 -0700 | [diff] [blame] | 228 | /* REVISIT: Configure number of 32 kHz clock cycles for sys_clk |
| 229 | * stabilisation */ |
Paul Walmsley | c4d7e58 | 2010-12-21 21:05:14 -0700 | [diff] [blame] | 230 | omap2_prm_write_mod_reg(15 << OMAP_SETUP_TIME_SHIFT, OMAP24XX_GR_MOD, |
| 231 | OMAP2_PRCM_CLKSSETUP_OFFSET); |
Kevin Hilman | 8bd2294 | 2009-05-28 10:56:16 -0700 | [diff] [blame] | 232 | |
| 233 | /* Configure automatic voltage transition */ |
Paul Walmsley | c4d7e58 | 2010-12-21 21:05:14 -0700 | [diff] [blame] | 234 | omap2_prm_write_mod_reg(2 << OMAP_SETUP_TIME_SHIFT, OMAP24XX_GR_MOD, |
| 235 | OMAP2_PRCM_VOLTSETUP_OFFSET); |
| 236 | omap2_prm_write_mod_reg(OMAP24XX_AUTO_EXTVOLT_MASK | |
| 237 | (0x1 << OMAP24XX_SETOFF_LEVEL_SHIFT) | |
| 238 | OMAP24XX_MEMRETCTRL_MASK | |
| 239 | (0x1 << OMAP24XX_SETRET_LEVEL_SHIFT) | |
| 240 | (0x0 << OMAP24XX_VOLT_LEVEL_SHIFT), |
| 241 | OMAP24XX_GR_MOD, OMAP2_PRCM_VOLTCTRL_OFFSET); |
Kevin Hilman | 8bd2294 | 2009-05-28 10:56:16 -0700 | [diff] [blame] | 242 | |
| 243 | /* Enable wake-up events */ |
Paul Walmsley | c4d7e58 | 2010-12-21 21:05:14 -0700 | [diff] [blame] | 244 | omap2_prm_write_mod_reg(OMAP24XX_EN_GPIOS_MASK | OMAP24XX_EN_GPT1_MASK, |
| 245 | WKUP_MOD, PM_WKEN); |
Tero Kristo | 944ee5d | 2014-02-20 19:09:18 +0200 | [diff] [blame] | 246 | |
| 247 | /* Enable SYS_CLKEN control when all domains idle */ |
| 248 | omap2_prm_set_mod_reg_bits(OMAP_AUTOEXTCLKMODE_MASK, OMAP24XX_GR_MOD, |
| 249 | OMAP2_PRCM_CLKSRC_CTRL_OFFSET); |
Kevin Hilman | 8bd2294 | 2009-05-28 10:56:16 -0700 | [diff] [blame] | 250 | } |
| 251 | |
Shawn Guo | bbd707a | 2012-04-26 16:06:50 +0800 | [diff] [blame] | 252 | int __init omap2_pm_init(void) |
Kevin Hilman | 8bd2294 | 2009-05-28 10:56:16 -0700 | [diff] [blame] | 253 | { |
| 254 | u32 l; |
| 255 | |
Kevin Hilman | 8bd2294 | 2009-05-28 10:56:16 -0700 | [diff] [blame] | 256 | printk(KERN_INFO "Power Management for OMAP2 initializing\n"); |
Paul Walmsley | c4d7e58 | 2010-12-21 21:05:14 -0700 | [diff] [blame] | 257 | l = omap2_prm_read_mod_reg(OCP_MOD, OMAP2_PRCM_REVISION_OFFSET); |
Kevin Hilman | 8bd2294 | 2009-05-28 10:56:16 -0700 | [diff] [blame] | 258 | printk(KERN_INFO "PRCM revision %d.%d\n", (l >> 4) & 0x0f, l & 0x0f); |
| 259 | |
Paul Walmsley | 369d561 | 2010-01-26 20:13:01 -0700 | [diff] [blame] | 260 | /* Look up important powerdomains */ |
Kevin Hilman | 8bd2294 | 2009-05-28 10:56:16 -0700 | [diff] [blame] | 261 | |
| 262 | mpu_pwrdm = pwrdm_lookup("mpu_pwrdm"); |
| 263 | if (!mpu_pwrdm) |
| 264 | pr_err("PM: mpu_pwrdm not found\n"); |
| 265 | |
| 266 | core_pwrdm = pwrdm_lookup("core_pwrdm"); |
| 267 | if (!core_pwrdm) |
| 268 | pr_err("PM: core_pwrdm not found\n"); |
| 269 | |
Paul Walmsley | 369d561 | 2010-01-26 20:13:01 -0700 | [diff] [blame] | 270 | /* Look up important clockdomains */ |
| 271 | |
| 272 | mpu_clkdm = clkdm_lookup("mpu_clkdm"); |
| 273 | if (!mpu_clkdm) |
| 274 | pr_err("PM: mpu_clkdm not found\n"); |
| 275 | |
| 276 | wkup_clkdm = clkdm_lookup("wkup_clkdm"); |
| 277 | if (!wkup_clkdm) |
| 278 | pr_err("PM: wkup_clkdm not found\n"); |
| 279 | |
Kevin Hilman | 8bd2294 | 2009-05-28 10:56:16 -0700 | [diff] [blame] | 280 | dsp_clkdm = clkdm_lookup("dsp_clkdm"); |
| 281 | if (!dsp_clkdm) |
Paul Walmsley | 369d561 | 2010-01-26 20:13:01 -0700 | [diff] [blame] | 282 | pr_err("PM: dsp_clkdm not found\n"); |
Kevin Hilman | 8bd2294 | 2009-05-28 10:56:16 -0700 | [diff] [blame] | 283 | |
| 284 | gfx_clkdm = clkdm_lookup("gfx_clkdm"); |
| 285 | if (!gfx_clkdm) |
| 286 | pr_err("PM: gfx_clkdm not found\n"); |
| 287 | |
| 288 | |
| 289 | osc_ck = clk_get(NULL, "osc_ck"); |
| 290 | if (IS_ERR(osc_ck)) { |
| 291 | printk(KERN_ERR "could not get osc_ck\n"); |
| 292 | return -ENODEV; |
| 293 | } |
| 294 | |
| 295 | if (cpu_is_omap242x()) { |
| 296 | emul_ck = clk_get(NULL, "emul_ck"); |
| 297 | if (IS_ERR(emul_ck)) { |
| 298 | printk(KERN_ERR "could not get emul_ck\n"); |
| 299 | clk_put(osc_ck); |
| 300 | return -ENODEV; |
| 301 | } |
| 302 | } |
| 303 | |
| 304 | prcm_setup_regs(); |
| 305 | |
Kevin Hilman | 8bd2294 | 2009-05-28 10:56:16 -0700 | [diff] [blame] | 306 | /* |
| 307 | * We copy the assembler sleep/wakeup routines to SRAM. |
| 308 | * These routines need to be in SRAM as that's the only |
Paul Walmsley | 088e880 | 2012-12-30 10:15:48 -0700 | [diff] [blame] | 309 | * memory the MPU can see when it wakes up after the entire |
| 310 | * chip enters idle. |
Kevin Hilman | 8bd2294 | 2009-05-28 10:56:16 -0700 | [diff] [blame] | 311 | */ |
Shawn Guo | bbd707a | 2012-04-26 16:06:50 +0800 | [diff] [blame] | 312 | omap2_sram_suspend = omap_sram_push(omap24xx_cpu_suspend, |
| 313 | omap24xx_cpu_suspend_sz); |
Kevin Hilman | 8bd2294 | 2009-05-28 10:56:16 -0700 | [diff] [blame] | 314 | |
Nicolas Pitre | 0bcd24b | 2012-01-04 16:27:48 -0500 | [diff] [blame] | 315 | arm_pm_idle = omap2_pm_idle; |
Kevin Hilman | 8bd2294 | 2009-05-28 10:56:16 -0700 | [diff] [blame] | 316 | |
| 317 | return 0; |
| 318 | } |