2 * linux/arch/arm/mach-omap2/pm.c
4 * OMAP2 Power Management Routines
6 * Copyright (C) 2005 Texas Instruments, Inc.
7 * Copyright (C) 2006-2008 Nokia Corporation
10 * Richard Woodruff <r-woodruff2@ti.com>
13 * Amit Kucheria <amit.kucheria@nokia.com>
14 * Igor Stoppa <igor.stoppa@nokia.com>
16 * Based on pm.c for omap1
18 * This program is free software; you can redistribute it and/or modify
19 * it under the terms of the GNU General Public License version 2 as
20 * published by the Free Software Foundation.
23 #include <linux/suspend.h>
24 #include <linux/sched.h>
25 #include <linux/proc_fs.h>
26 #include <linux/interrupt.h>
27 #include <linux/sysfs.h>
28 #include <linux/module.h>
29 #include <linux/delay.h>
30 #include <linux/clk.h>
32 #include <linux/irq.h>
34 #include <asm/atomic.h>
35 #include <asm/mach/time.h>
36 #include <asm/mach/irq.h>
37 #include <asm/mach-types.h>
39 #include <asm/arch/irqs.h>
40 #include <asm/arch/clock.h>
41 #include <asm/arch/sram.h>
42 #include <asm/arch/control.h>
43 #include <asm/arch/gpio.h>
44 #include <asm/arch/pm.h>
45 #include <asm/arch/mux.h>
46 #include <asm/arch/dma.h>
47 #include <asm/arch/board.h>
50 #include "prm-regbits-24xx.h"
52 #include "cm-regbits-24xx.h"
55 /* These addrs are in assembly language code to be patched at runtime */
56 extern void *omap2_ocs_sdrc_power;
57 extern void *omap2_ocs_sdrc_dlla_ctrl;
59 static void (*omap2_sram_idle)(void);
60 static void (*omap2_sram_suspend)(void __iomem *dllctrl);
61 static void (*saved_idle)(void);
63 static u32 omap2_read_32k_sync_counter(void)
65 return omap_readl(OMAP2_32KSYNCT_BASE + 0x0010);
68 #ifdef CONFIG_PM_DEBUG
69 int omap2_pm_debug = 0;
71 static int serial_console_clock_disabled;
72 static int serial_console_uart;
73 static unsigned int serial_console_next_disable;
75 static struct clk *console_iclk, *console_fclk;
77 static void serial_console_kick(void)
79 serial_console_next_disable = omap2_read_32k_sync_counter();
80 /* Keep the clocks on for 4 secs */
81 serial_console_next_disable += 4 * 32768;
84 static void serial_wait_tx(void)
86 static const unsigned long uart_bases[3] = {
87 0x4806a000, 0x4806c000, 0x4806e000
89 unsigned long lsr_reg;
92 /* Wait for TX FIFO and THR to get empty */
93 lsr_reg = IO_ADDRESS(uart_bases[serial_console_uart - 1] + (5 << 2));
94 while ((__raw_readb(lsr_reg) & 0x60) != 0x60)
97 serial_console_kick();
100 static void serial_console_fclk_mask(u32 *f1, u32 *f2)
102 switch (serial_console_uart) {
115 static void serial_console_sleep(int enable)
117 if (console_iclk == NULL || console_fclk == NULL)
121 BUG_ON(serial_console_clock_disabled);
122 if (clk_get_usecount(console_fclk) == 0)
124 if ((int) serial_console_next_disable -
125 (int) omap2_read_32k_sync_counter() >= 0)
128 clk_disable(console_iclk);
129 clk_disable(console_fclk);
130 serial_console_clock_disabled = 1;
132 int serial_wakeup = 0;
135 switch (serial_console_uart) {
137 l = prm_read_mod_reg(CORE_MOD, PM_WKST1);
138 if (l & OMAP24XX_ST_UART1)
142 l = prm_read_mod_reg(CORE_MOD, PM_WKST1);
143 if (l & OMAP24XX_ST_UART2)
147 l = prm_read_mod_reg(CORE_MOD, OMAP24XX_PM_WKST2);
148 if (l & OMAP24XX_ST_UART3)
153 serial_console_kick();
154 if (!serial_console_clock_disabled)
156 clk_enable(console_iclk);
157 clk_enable(console_fclk);
158 serial_console_clock_disabled = 0;
162 static void pm_init_serial_console(void)
164 const struct omap_serial_console_config *conf;
167 conf = omap_get_config(OMAP_TAG_SERIAL_CONSOLE,
168 struct omap_serial_console_config);
171 if (conf->console_uart > 3 || conf->console_uart < 1)
173 serial_console_uart = conf->console_uart;
174 sprintf(name, "uart%d_fck", conf->console_uart);
175 console_fclk = clk_get(NULL, name);
176 if (IS_ERR(console_fclk))
179 console_iclk = clk_get(NULL, name);
180 if (IS_ERR(console_fclk))
182 if (console_fclk == NULL || console_iclk == NULL) {
183 serial_console_uart = 0;
186 switch (serial_console_uart) {
188 prm_set_mod_reg_bits(OMAP24XX_ST_UART1, CORE_MOD, PM_WKEN1);
191 prm_set_mod_reg_bits(OMAP24XX_ST_UART2, CORE_MOD, PM_WKEN1);
194 prm_set_mod_reg_bits(OMAP24XX_ST_UART3, CORE_MOD,
200 #define DUMP_PRM_MOD_REG(mod, reg) \
201 regs[reg_count].name = #mod "." #reg; \
202 regs[reg_count++].val = prm_read_mod_reg(mod, reg)
203 #define DUMP_CM_MOD_REG(mod, reg) \
204 regs[reg_count].name = #mod "." #reg; \
205 regs[reg_count++].val = cm_read_mod_reg(mod, reg)
206 #define DUMP_PRM_REG(reg) \
207 regs[reg_count].name = #reg; \
208 regs[reg_count++].val = __raw_readl(reg)
209 #define DUMP_CM_REG(reg) \
210 regs[reg_count].name = #reg; \
211 regs[reg_count++].val = __raw_readl(reg)
212 #define DUMP_INTC_REG(reg, off) \
213 regs[reg_count].name = #reg; \
214 regs[reg_count++].val = __raw_readl(IO_ADDRESS(0x480fe000 + (off)))
216 static void omap2_pm_dump(int mode, int resume, unsigned int us)
222 int reg_count = 0, i;
223 const char *s1 = NULL, *s2 = NULL;
228 DUMP_PRM_REG(OMAP24XX_PRCM_IRQENABLE_MPU);
229 DUMP_CM_MOD_REG(MPU_MOD, CM_CLKSTCTRL);
230 DUMP_PRM_MOD_REG(MPU_MOD, PM_PWSTCTRL);
231 DUMP_PRM_MOD_REG(MPU_MOD, PM_PWSTST);
232 DUMP_PRM_MOD_REG(MPU_MOD, PM_WKDEP);
236 DUMP_INTC_REG(INTC_MIR0, 0x0084);
237 DUMP_INTC_REG(INTC_MIR1, 0x00a4);
238 DUMP_INTC_REG(INTC_MIR2, 0x00c4);
241 DUMP_CM_MOD_REG(CORE_MOD, CM_FCLKEN1);
242 DUMP_CM_MOD_REG(CORE_MOD, OMAP24XX_CM_FCLKEN2);
243 DUMP_CM_MOD_REG(WKUP_MOD, CM_FCLKEN);
244 DUMP_CM_MOD_REG(CORE_MOD, CM_ICLKEN1);
245 DUMP_CM_MOD_REG(CORE_MOD, CM_ICLKEN2);
246 DUMP_CM_MOD_REG(WKUP_MOD, CM_ICLKEN);
247 DUMP_CM_MOD_REG(PLL_MOD, CM_CLKEN);
248 DUMP_PRM_REG(OMAP24XX_PRCM_CLKEMUL_CTRL);
249 DUMP_CM_MOD_REG(PLL_MOD, CM_AUTOIDLE);
250 DUMP_PRM_MOD_REG(CORE_MOD, PM_PWSTST);
251 DUMP_PRM_REG(OMAP24XX_PRCM_CLKSRC_CTRL);
255 DUMP_CM_MOD_REG(OMAP24XX_DSP_MOD, CM_FCLKEN);
256 DUMP_CM_MOD_REG(OMAP24XX_DSP_MOD, CM_ICLKEN);
257 DUMP_CM_MOD_REG(OMAP24XX_DSP_MOD, CM_IDLEST);
258 DUMP_CM_MOD_REG(OMAP24XX_DSP_MOD, CM_AUTOIDLE);
259 DUMP_CM_MOD_REG(OMAP24XX_DSP_MOD, CM_CLKSEL);
260 DUMP_CM_MOD_REG(OMAP24XX_DSP_MOD, CM_CLKSTCTRL);
261 DUMP_PRM_MOD_REG(OMAP24XX_DSP_MOD, RM_RSTCTRL);
262 DUMP_PRM_MOD_REG(OMAP24XX_DSP_MOD, RM_RSTST);
263 DUMP_PRM_MOD_REG(OMAP24XX_DSP_MOD, PM_PWSTCTRL);
264 DUMP_PRM_MOD_REG(OMAP24XX_DSP_MOD, PM_PWSTST);
267 DUMP_PRM_MOD_REG(CORE_MOD, PM_WKST1);
268 DUMP_PRM_MOD_REG(CORE_MOD, OMAP24XX_PM_WKST2);
269 DUMP_PRM_MOD_REG(WKUP_MOD, PM_WKST);
270 DUMP_PRM_REG(OMAP24XX_PRCM_IRQSTATUS_MPU);
272 DUMP_INTC_REG(INTC_PENDING_IRQ0, 0x0098);
273 DUMP_INTC_REG(INTC_PENDING_IRQ1, 0x00b8);
274 DUMP_INTC_REG(INTC_PENDING_IRQ2, 0x00d8);
294 #if defined(CONFIG_NO_IDLE_HZ) || defined(CONFIG_NO_HZ)
295 pr_debug("--- Going to %s %s (next timer after %u ms)\n", s1,
297 jiffies_to_msecs(get_next_timer_interrupt(jiffies) -
300 pr_debug("--- Going to %s %s\n", s1, s2);
303 pr_debug("--- Woke up (slept for %u.%03u ms)\n", us / 1000,
306 for (i = 0; i < reg_count; i++)
307 pr_debug("%-20s: 0x%08x\n", regs[i].name, regs[i].val);
311 static inline void serial_console_sleep(int enable) {}
312 static inline void pm_init_serial_console(void) {}
313 static inline void omap2_pm_dump(int mode, int resume, unsigned int us) {}
314 static inline void serial_console_fclk_mask(u32 *f1, u32 *f2) {}
316 #define omap2_pm_debug 0
320 static unsigned short enable_dyn_sleep = 0; /* disabled till drivers are fixed */
322 static ssize_t idle_show(struct kobject *kobj, struct kobj_attribute *attr,
325 return sprintf(buf, "%hu\n", enable_dyn_sleep);
328 static ssize_t idle_store(struct kobject *kobj, struct kobj_attribute *attr,
329 const char *buf, size_t n)
331 unsigned short value;
332 if (sscanf(buf, "%hu", &value) != 1 ||
333 (value != 0 && value != 1)) {
334 printk(KERN_ERR "idle_sleep_store: Invalid value\n");
337 enable_dyn_sleep = value;
341 static struct kobj_attribute sleep_while_idle_attr =
342 __ATTR(sleep_while_idle, 0644, idle_show, idle_store);
344 static struct clk *osc_ck, *emul_ck;
346 static int omap2_fclks_active(void)
350 f1 = cm_read_mod_reg(CORE_MOD, CM_FCLKEN1);
351 f2 = cm_read_mod_reg(CORE_MOD, OMAP24XX_CM_FCLKEN2);
352 serial_console_fclk_mask(&f1, &f2);
358 static int omap2_irq_pending(void)
360 u32 pending_reg = 0x480fe098;
363 for (i = 0; i < 4; i++) {
364 if (omap_readl(pending_reg))
371 static atomic_t sleep_block = ATOMIC_INIT(0);
373 void omap2_block_sleep(void)
375 atomic_inc(&sleep_block);
378 void omap2_allow_sleep(void)
382 i = atomic_dec_return(&sleep_block);
386 static void omap2_enter_full_retention(void)
388 u32 l, sleep_time = 0;
390 /* There is 1 reference hold for all children of the oscillator
391 * clock, the following will remove it. If no one else uses the
392 * oscillator itself it will be disabled if/when we enter retention
397 /* Clear old wake-up events */
398 /* REVISIT: These write to reserved bits? */
399 prm_write_mod_reg(0xffffffff, CORE_MOD, PM_WKST1);
400 prm_write_mod_reg(0xffffffff, CORE_MOD, OMAP24XX_PM_WKST2);
401 prm_write_mod_reg(0xffffffff, WKUP_MOD, PM_WKST);
403 /* Try to enter retention */
404 prm_write_mod_reg((0x01 << OMAP_POWERSTATE_SHIFT) | OMAP_LOGICRETSTATE,
405 MPU_MOD, PM_PWSTCTRL);
407 /* Workaround to kill USB */
408 l = omap_ctrl_readl(OMAP2_CONTROL_DEVCONF0) | OMAP24XX_USBSTANDBYCTRL;
409 omap_ctrl_writel(l, OMAP2_CONTROL_DEVCONF0);
411 omap2_gpio_prepare_for_retention();
413 if (omap2_pm_debug) {
414 omap2_pm_dump(0, 0, 0);
415 sleep_time = omap2_read_32k_sync_counter();
418 /* One last check for pending IRQs to avoid extra latency due
419 * to sleeping unnecessarily. */
420 if (omap2_irq_pending())
423 serial_console_sleep(1);
424 /* Jump to SRAM suspend code */
425 omap2_sram_suspend(OMAP_SDRC_REGADDR(SDRC_DLLA_CTRL));
427 serial_console_sleep(0);
429 if (omap2_pm_debug) {
430 unsigned long long tmp;
433 resume_time = omap2_read_32k_sync_counter();
434 tmp = resume_time - sleep_time;
436 omap2_pm_dump(0, 1, tmp / 32768);
438 omap2_gpio_resume_after_retention();
442 /* clear CORE wake-up events */
443 prm_write_mod_reg(0xffffffff, CORE_MOD, PM_WKST1);
444 prm_write_mod_reg(0xffffffff, CORE_MOD, OMAP24XX_PM_WKST2);
446 /* wakeup domain events - bit 1: GPT1, bit5 GPIO */
447 prm_clear_mod_reg_bits(0x4 | 0x1, WKUP_MOD, PM_WKST);
449 /* MPU domain wake events */
450 l = __raw_readl(OMAP24XX_PRCM_IRQSTATUS_MPU);
452 __raw_writel(0x01, OMAP24XX_PRCM_IRQSTATUS_MPU);
454 __raw_writel(0x20, OMAP24XX_PRCM_IRQSTATUS_MPU);
456 /* Mask future PRCM-to-MPU interrupts */
457 __raw_writel(0x0, OMAP24XX_PRCM_IRQSTATUS_MPU);
460 static int omap2_i2c_active(void)
464 l = cm_read_mod_reg(CORE_MOD, CM_FCLKEN1);
465 return l & (OMAP2420_EN_I2C2 | OMAP2420_EN_I2C1);
468 static int sti_console_enabled;
470 static int omap2_allow_mpu_retention(void)
474 if (atomic_read(&sleep_block))
477 /* Check for MMC, UART2, UART1, McSPI2, McSPI1 and DSS1. */
478 l = cm_read_mod_reg(CORE_MOD, CM_FCLKEN1);
479 if (l & (OMAP2420_EN_MMC | OMAP24XX_EN_UART2 |
480 OMAP24XX_EN_UART1 | OMAP24XX_EN_MCSPI2 |
481 OMAP24XX_EN_MCSPI1 | OMAP24XX_EN_DSS1))
483 /* Check for UART3. */
484 l = cm_read_mod_reg(CORE_MOD, OMAP24XX_CM_FCLKEN2);
485 if (l & OMAP24XX_EN_UART3)
487 if (sti_console_enabled)
493 static void omap2_enter_mpu_retention(void)
498 /* Putting MPU into the WFI state while a transfer is active
499 * seems to cause the I2C block to timeout. Why? Good question. */
500 if (omap2_i2c_active())
503 /* The peripherals seem not to be able to wake up the MPU when
504 * it is in retention mode. */
505 if (omap2_allow_mpu_retention()) {
506 /* REVISIT: These write to reserved bits? */
507 prm_write_mod_reg(0xffffffff, CORE_MOD, PM_WKST1);
508 prm_write_mod_reg(0xffffffff, CORE_MOD, OMAP24XX_PM_WKST2);
509 prm_write_mod_reg(0xffffffff, WKUP_MOD, PM_WKST);
511 /* Try to enter MPU retention */
512 prm_write_mod_reg((0x01 << OMAP_POWERSTATE_SHIFT) |
514 MPU_MOD, PM_PWSTCTRL);
516 /* Block MPU retention */
518 prm_write_mod_reg(OMAP_LOGICRETSTATE, MPU_MOD, PM_PWSTCTRL);
522 if (omap2_pm_debug) {
523 omap2_pm_dump(only_idle ? 2 : 1, 0, 0);
524 sleep_time = omap2_read_32k_sync_counter();
529 if (omap2_pm_debug) {
530 unsigned long long tmp;
533 resume_time = omap2_read_32k_sync_counter();
534 tmp = resume_time - sleep_time;
536 omap2_pm_dump(only_idle ? 2 : 1, 1, tmp / 32768);
540 static int omap2_can_sleep(void)
542 if (!enable_dyn_sleep)
544 if (omap2_fclks_active())
546 if (atomic_read(&sleep_block) > 0)
548 if (clk_get_usecount(osc_ck) > 1)
550 if (omap_dma_running())
556 static void omap2_pm_idle(void)
561 if (!omap2_can_sleep()) {
562 /* timer_dyn_reprogram() takes about 100-200 us to complete.
563 * In some contexts (e.g. when waiting for a GPMC-SDRAM DMA
564 * transfer to complete), the increased latency is too much.
566 * omap2_block_sleep() and omap2_allow_sleep() can be used
569 if (atomic_read(&sleep_block) == 0) {
570 timer_dyn_reprogram();
571 if (omap2_irq_pending())
574 omap2_enter_mpu_retention();
579 * Since an interrupt may set up a timer, we don't want to
580 * reprogram the hardware timer with interrupts enabled.
581 * Re-enable interrupts only after returning from idle.
583 timer_dyn_reprogram();
585 if (omap2_irq_pending())
588 omap2_enter_full_retention();
595 static int omap2_pm_prepare(void)
597 /* We cannot sleep in idle until we have resumed */
598 saved_idle = pm_idle;
604 static int omap2_pm_suspend(void)
608 wken_wkup = prm_read_mod_reg(WKUP_MOD, PM_WKEN);
609 prm_write_mod_reg(wken_wkup & ~OMAP24XX_EN_GPT1, WKUP_MOD, PM_WKEN);
612 mir1 = omap_readl(0x480fe0a4);
613 omap_writel(1 << 5, 0x480fe0ac);
615 omap2_enter_full_retention();
617 omap_writel(mir1, 0x480fe0a4);
618 prm_write_mod_reg(wken_wkup, WKUP_MOD, PM_WKEN);
623 static int omap2_pm_enter(suspend_state_t state)
628 case PM_SUSPEND_STANDBY:
630 ret = omap2_pm_suspend();
639 static void omap2_pm_finish(void)
641 pm_idle = saved_idle;
644 static struct platform_suspend_ops omap_pm_ops = {
645 .prepare = omap2_pm_prepare,
646 .enter = omap2_pm_enter,
647 .finish = omap2_pm_finish,
648 .valid = suspend_valid_only_mem,
651 static void __init prcm_setup_regs(void)
655 /* Enable autoidle */
656 __raw_writel(OMAP24XX_AUTOIDLE, OMAP24XX_PRCM_SYSCONFIG);
658 /* Set all domain wakeup dependencies */
659 prm_write_mod_reg(OMAP_EN_WKUP_MASK, MPU_MOD, PM_WKDEP);
660 prm_write_mod_reg(0, OMAP24XX_DSP_MOD, PM_WKDEP);
661 prm_write_mod_reg(0, GFX_MOD, PM_WKDEP);
662 prm_write_mod_reg(0, CORE_MOD, PM_WKDEP);
663 if (cpu_is_omap2430())
664 prm_write_mod_reg(0, OMAP2430_MDM_MOD, PM_WKDEP);
666 l = prm_read_mod_reg(CORE_MOD, PM_PWSTCTRL);
667 /* Enable retention for all memory blocks */
668 l |= OMAP24XX_MEM3RETSTATE | OMAP24XX_MEM2RETSTATE |
669 OMAP24XX_MEM1RETSTATE;
671 /* Set power state to RETENTION */
672 l &= ~OMAP_POWERSTATE_MASK;
673 l |= 0x01 << OMAP_POWERSTATE_SHIFT;
674 prm_write_mod_reg(l, CORE_MOD, PM_PWSTCTRL);
676 prm_write_mod_reg((0x01 << OMAP_POWERSTATE_SHIFT) |
678 MPU_MOD, PM_PWSTCTRL);
680 /* Power down DSP and GFX */
681 prm_write_mod_reg(OMAP24XX_FORCESTATE | (0x3 << OMAP_POWERSTATE_SHIFT),
682 OMAP24XX_DSP_MOD, PM_PWSTCTRL);
683 prm_write_mod_reg(OMAP24XX_FORCESTATE | (0x3 << OMAP_POWERSTATE_SHIFT),
684 GFX_MOD, PM_PWSTCTRL);
686 /* Enable clock auto control for all domains */
687 cm_write_mod_reg(OMAP24XX_AUTOSTATE_MPU_MASK, MPU_MOD, CM_CLKSTCTRL);
688 cm_write_mod_reg(OMAP24XX_AUTOSTATE_DSS_MASK |
689 OMAP24XX_AUTOSTATE_L4_MASK |
690 OMAP24XX_AUTOSTATE_L3_MASK,
691 CORE_MOD, CM_CLKSTCTRL);
692 cm_write_mod_reg(OMAP24XX_AUTOSTATE_GFX_MASK, GFX_MOD, CM_CLKSTCTRL);
693 cm_write_mod_reg(OMAP2420_AUTOSTATE_IVA_MASK |
694 OMAP24XX_AUTOSTATE_DSP_MASK,
695 OMAP24XX_DSP_MOD, CM_CLKSTCTRL);
697 /* Enable clock autoidle for all domains */
698 cm_write_mod_reg(OMAP24XX_AUTO_CAM |
699 OMAP24XX_AUTO_MAILBOXES |
702 OMAP24XX_AUTO_MSPRO |
707 OMAP24XX_AUTO_UART2 |
708 OMAP24XX_AUTO_UART1 |
711 OMAP24XX_AUTO_MCSPI2 |
712 OMAP24XX_AUTO_MCSPI1 |
713 OMAP24XX_AUTO_MCBSP2 |
714 OMAP24XX_AUTO_MCBSP1 |
715 OMAP24XX_AUTO_GPT12 |
716 OMAP24XX_AUTO_GPT11 |
717 OMAP24XX_AUTO_GPT10 |
726 OMAP2420_AUTO_VLYNQ |
728 CORE_MOD, CM_AUTOIDLE1);
729 cm_write_mod_reg(OMAP24XX_AUTO_UART3 |
732 CORE_MOD, CM_AUTOIDLE2);
733 cm_write_mod_reg(OMAP24XX_AUTO_SDRC |
736 CORE_MOD, CM_AUTOIDLE3);
737 cm_write_mod_reg(OMAP24XX_AUTO_PKA |
742 CORE_MOD, OMAP24XX_CM_AUTOIDLE4);
744 cm_write_mod_reg(OMAP2420_AUTO_DSP_IPI, OMAP24XX_DSP_MOD, CM_AUTOIDLE);
746 /* Put DPLL and both APLLs into autoidle mode */
747 cm_write_mod_reg((0x03 << OMAP24XX_AUTO_DPLL_SHIFT) |
748 (0x03 << OMAP24XX_AUTO_96M_SHIFT) |
749 (0x03 << OMAP24XX_AUTO_54M_SHIFT),
750 PLL_MOD, CM_AUTOIDLE);
752 cm_write_mod_reg(OMAP24XX_AUTO_OMAPCTRL |
754 OMAP24XX_AUTO_MPU_WDT |
755 OMAP24XX_AUTO_GPIOS |
756 OMAP24XX_AUTO_32KSYNC |
758 WKUP_MOD, CM_AUTOIDLE);
760 /* REVISIT: Configure number of 32 kHz clock cycles for sys_clk
762 __raw_writel(15 << OMAP_SETUP_TIME_SHIFT, OMAP24XX_PRCM_CLKSSETUP);
764 /* Configure automatic voltage transition */
765 __raw_writel(2 << OMAP_SETUP_TIME_SHIFT, OMAP24XX_PRCM_VOLTSETUP);
766 __raw_writel(OMAP24XX_AUTO_EXTVOLT |
767 (0x1 << OMAP24XX_SETOFF_LEVEL_SHIFT) |
768 OMAP24XX_MEMRETCTRL |
769 (0x1 << OMAP24XX_SETRET_LEVEL_SHIFT) |
770 (0x0 << OMAP24XX_VOLT_LEVEL_SHIFT),
771 OMAP24XX_PRCM_VOLTCTRL);
773 /* Enable wake-up events */
774 prm_write_mod_reg(OMAP24XX_EN_GPIOS | OMAP24XX_EN_GPT1,
778 static int __init omap2_pm_init(void)
783 printk(KERN_INFO "Power Management for OMAP2 initializing\n");
784 l = __raw_readl(OMAP24XX_PRCM_REVISION);
785 printk(KERN_INFO "PRCM revision %d.%d\n", (l >> 4) & 0x0f, l & 0x0f);
787 osc_ck = clk_get(NULL, "osc_ck");
788 if (IS_ERR(osc_ck)) {
789 printk(KERN_ERR "could not get osc_ck\n");
793 if (cpu_is_omap242x()) {
794 emul_ck = clk_get(NULL, "emul_ck");
795 if (IS_ERR(emul_ck)) {
796 printk(KERN_ERR "could not get emul_ck\n");
804 pm_init_serial_console();
806 /* Hack to prevent MPU retention when STI console is enabled. */
808 const struct omap_sti_console_config *sti;
810 sti = omap_get_config(OMAP_TAG_STI_CONSOLE,
811 struct omap_sti_console_config);
812 if (sti != NULL && sti->enable)
813 sti_console_enabled = 1;
817 * We copy the assembler sleep/wakeup routines to SRAM.
818 * These routines need to be in SRAM as that's the only
819 * memory the MPU can see when it wakes up.
821 omap2_sram_idle = omap_sram_push(omap24xx_idle_loop_suspend,
822 omap24xx_idle_loop_suspend_sz);
824 omap2_sram_suspend = omap_sram_push(omap24xx_cpu_suspend,
825 omap24xx_cpu_suspend_sz);
827 /* Patch in the correct register addresses for multiboot */
828 omap_sram_patch_va(omap24xx_cpu_suspend, &omap2_ocs_sdrc_power,
830 OMAP_SDRC_REGADDR(SDRC_POWER));
831 omap_sram_patch_va(omap24xx_cpu_suspend, &omap2_ocs_sdrc_dlla_ctrl,
833 OMAP_SDRC_REGADDR(SDRC_DLLA_CTRL));
835 suspend_set_ops(&omap_pm_ops);
836 pm_idle = omap2_pm_idle;
838 error = sysfs_create_file(power_kobj, &sleep_while_idle_attr.attr);
840 printk(KERN_ERR "sysfs_create_file failed: %d\n", error);
845 late_initcall(omap2_pm_init);