2 * OMAP3 Power Management Routines
4 * Copyright (C) 2006-2008 Nokia Corporation
5 * Tony Lindgren <tony@atomide.com>
8 * Copyright (C) 2005 Texas Instruments, Inc.
9 * Richard Woodruff <r-woodruff2@ti.com>
11 * Based on pm.c for omap1
13 * This program is free software; you can redistribute it and/or modify
14 * it under the terms of the GNU General Public License version 2 as
15 * published by the Free Software Foundation.
19 #include <linux/suspend.h>
20 #include <linux/interrupt.h>
21 #include <linux/module.h>
22 #include <linux/list.h>
23 #include <linux/err.h>
24 #include <linux/gpio.h>
26 #include <mach/sram.h>
27 #include <mach/clockdomain.h>
28 #include <mach/powerdomain.h>
29 #include <mach/control.h>
30 #include <mach/serial.h>
33 #include "cm-regbits-34xx.h"
34 #include "prm-regbits-34xx.h"
40 struct powerdomain
*pwrdm
;
45 struct list_head node
;
48 static LIST_HEAD(pwrst_list
);
50 static void (*_omap_sram_idle
)(u32
*addr
, int save_state
);
52 static struct powerdomain
*mpu_pwrdm
;
55 * PRCM Interrupt Handler Helper Function
57 * The purpose of this function is to clear any wake-up events latched
58 * in the PRCM PM_WKST_x registers. It is possible that a wake-up event
59 * may occur whilst attempting to clear a PM_WKST_x register and thus
60 * set another bit in this register. A while loop is used to ensure
61 * that any peripheral wake-up events occurring while attempting to
62 * clear the PM_WKST_x are detected and cleared.
64 static int prcm_clear_mod_irqs(s16 module
, u8 regs
)
66 u32 wkst
, fclk
, iclk
, clken
;
67 u16 wkst_off
= (regs
== 3) ? OMAP3430ES2_PM_WKST3
: PM_WKST1
;
68 u16 fclk_off
= (regs
== 3) ? OMAP3430ES2_CM_FCLKEN3
: CM_FCLKEN1
;
69 u16 iclk_off
= (regs
== 3) ? CM_ICLKEN3
: CM_ICLKEN1
;
70 u16 grpsel_off
= (regs
== 3) ?
71 OMAP3430ES2_PM_MPUGRPSEL3
: OMAP3430_PM_MPUGRPSEL
;
74 wkst
= prm_read_mod_reg(module
, wkst_off
);
75 wkst
&= prm_read_mod_reg(module
, grpsel_off
);
77 iclk
= cm_read_mod_reg(module
, iclk_off
);
78 fclk
= cm_read_mod_reg(module
, fclk_off
);
81 cm_set_mod_reg_bits(clken
, module
, iclk_off
);
83 * For USBHOST, we don't know whether HOST1 or
84 * HOST2 woke us up, so enable both f-clocks
86 if (module
== OMAP3430ES2_USBHOST_MOD
)
87 clken
|= 1 << OMAP3430ES2_EN_USBHOST2_SHIFT
;
88 cm_set_mod_reg_bits(clken
, module
, fclk_off
);
89 prm_write_mod_reg(wkst
, module
, wkst_off
);
90 wkst
= prm_read_mod_reg(module
, wkst_off
);
93 cm_write_mod_reg(iclk
, module
, iclk_off
);
94 cm_write_mod_reg(fclk
, module
, fclk_off
);
100 static int _prcm_int_handle_wakeup(void)
104 c
= prcm_clear_mod_irqs(WKUP_MOD
, 1);
105 c
+= prcm_clear_mod_irqs(CORE_MOD
, 1);
106 c
+= prcm_clear_mod_irqs(OMAP3430_PER_MOD
, 1);
107 if (omap_rev() > OMAP3430_REV_ES1_0
) {
108 c
+= prcm_clear_mod_irqs(CORE_MOD
, 3);
109 c
+= prcm_clear_mod_irqs(OMAP3430ES2_USBHOST_MOD
, 1);
116 * PRCM Interrupt Handler
118 * The PRM_IRQSTATUS_MPU register indicates if there are any pending
119 * interrupts from the PRCM for the MPU. These bits must be cleared in
120 * order to clear the PRCM interrupt. The PRCM interrupt handler is
121 * implemented to simply clear the PRM_IRQSTATUS_MPU in order to clear
122 * the PRCM interrupt. Please note that bit 0 of the PRM_IRQSTATUS_MPU
123 * register indicates that a wake-up event is pending for the MPU and
124 * this bit can only be cleared if the all the wake-up events latched
125 * in the various PM_WKST_x registers have been cleared. The interrupt
126 * handler is implemented using a do-while loop so that if a wake-up
127 * event occurred during the processing of the prcm interrupt handler
128 * (setting a bit in the corresponding PM_WKST_x register and thus
129 * preventing us from clearing bit 0 of the PRM_IRQSTATUS_MPU register)
130 * this would be handled.
132 static irqreturn_t
prcm_interrupt_handler (int irq
, void *dev_id
)
138 irqstatus_mpu
= prm_read_mod_reg(OCP_MOD
,
139 OMAP3_PRM_IRQSTATUS_MPU_OFFSET
);
141 if (irqstatus_mpu
& (OMAP3430_WKUP_ST
| OMAP3430_IO_ST
)) {
142 c
= _prcm_int_handle_wakeup();
145 * Is the MPU PRCM interrupt handler racing with the
146 * IVA2 PRCM interrupt handler ?
148 WARN(c
== 0, "prcm: WARNING: PRCM indicated MPU wakeup "
149 "but no wakeup sources are marked\n");
151 /* XXX we need to expand our PRCM interrupt handler */
152 WARN(1, "prcm: WARNING: PRCM interrupt received, but "
153 "no code to handle it (%08x)\n", irqstatus_mpu
);
156 prm_write_mod_reg(irqstatus_mpu
, OCP_MOD
,
157 OMAP3_PRM_IRQSTATUS_MPU_OFFSET
);
159 } while (prm_read_mod_reg(OCP_MOD
, OMAP3_PRM_IRQSTATUS_MPU_OFFSET
));
164 static void omap_sram_idle(void)
166 /* Variable to tell what needs to be saved and restored
167 * in omap_sram_idle*/
168 /* save_state = 0 => Nothing to save and restored */
169 /* save_state = 1 => Only L1 and logic lost */
170 /* save_state = 2 => Only L2 lost */
171 /* save_state = 3 => L1, L2 and logic lost */
172 int save_state
= 0, mpu_next_state
;
174 if (!_omap_sram_idle
)
177 mpu_next_state
= pwrdm_read_next_pwrst(mpu_pwrdm
);
178 switch (mpu_next_state
) {
179 case PWRDM_POWER_RET
:
180 /* No need to save context */
185 printk(KERN_ERR
"Invalid mpu state in sram_idle\n");
188 pwrdm_pre_transition();
190 omap2_gpio_prepare_for_retention();
191 omap_uart_prepare_idle(0);
192 omap_uart_prepare_idle(1);
193 omap_uart_prepare_idle(2);
195 _omap_sram_idle(NULL
, save_state
);
198 omap_uart_resume_idle(2);
199 omap_uart_resume_idle(1);
200 omap_uart_resume_idle(0);
201 omap2_gpio_resume_after_retention();
203 pwrdm_post_transition();
208 * Check if functional clocks are enabled before entering
209 * sleep. This function could be behind CONFIG_PM_DEBUG
210 * when all drivers are configuring their sysconfig registers
211 * properly and using their clocks properly.
213 static int omap3_fclks_active(void)
215 u32 fck_core1
= 0, fck_core3
= 0, fck_sgx
= 0, fck_dss
= 0,
216 fck_cam
= 0, fck_per
= 0, fck_usbhost
= 0;
218 fck_core1
= cm_read_mod_reg(CORE_MOD
,
220 if (omap_rev() > OMAP3430_REV_ES1_0
) {
221 fck_core3
= cm_read_mod_reg(CORE_MOD
,
222 OMAP3430ES2_CM_FCLKEN3
);
223 fck_sgx
= cm_read_mod_reg(OMAP3430ES2_SGX_MOD
,
225 fck_usbhost
= cm_read_mod_reg(OMAP3430ES2_USBHOST_MOD
,
228 fck_sgx
= cm_read_mod_reg(GFX_MOD
,
229 OMAP3430ES2_CM_FCLKEN3
);
230 fck_dss
= cm_read_mod_reg(OMAP3430_DSS_MOD
,
232 fck_cam
= cm_read_mod_reg(OMAP3430_CAM_MOD
,
234 fck_per
= cm_read_mod_reg(OMAP3430_PER_MOD
,
237 /* Ignore UART clocks. These are handled by UART core (serial.c) */
238 fck_core1
&= ~(OMAP3430_EN_UART1
| OMAP3430_EN_UART2
);
239 fck_per
&= ~OMAP3430_EN_UART3
;
241 if (fck_core1
| fck_core3
| fck_sgx
| fck_dss
|
242 fck_cam
| fck_per
| fck_usbhost
)
247 static int omap3_can_sleep(void)
249 if (!omap_uart_can_sleep())
251 if (omap3_fclks_active())
256 /* This sets pwrdm state (other than mpu & core. Currently only ON &
257 * RET are supported. Function is assuming that clkdm doesn't have
258 * hw_sup mode enabled. */
259 static int set_pwrdm_state(struct powerdomain
*pwrdm
, u32 state
)
262 int sleep_switch
= 0;
265 if (pwrdm
== NULL
|| IS_ERR(pwrdm
))
268 while (!(pwrdm
->pwrsts
& (1 << state
))) {
269 if (state
== PWRDM_POWER_OFF
)
274 cur_state
= pwrdm_read_next_pwrst(pwrdm
);
275 if (cur_state
== state
)
278 if (pwrdm_read_pwrst(pwrdm
) < PWRDM_POWER_ON
) {
279 omap2_clkdm_wakeup(pwrdm
->pwrdm_clkdms
[0]);
281 pwrdm_wait_transition(pwrdm
);
284 ret
= pwrdm_set_next_pwrst(pwrdm
, state
);
286 printk(KERN_ERR
"Unable to set state of powerdomain: %s\n",
292 omap2_clkdm_allow_idle(pwrdm
->pwrdm_clkdms
[0]);
293 pwrdm_wait_transition(pwrdm
);
294 pwrdm_state_switch(pwrdm
);
301 static void omap3_pm_idle(void)
306 if (!omap3_can_sleep())
309 if (omap_irq_pending())
319 #ifdef CONFIG_SUSPEND
320 static suspend_state_t suspend_state
;
322 static int omap3_pm_prepare(void)
328 static int omap3_pm_suspend(void)
330 struct power_state
*pwrst
;
333 /* Read current next_pwrsts */
334 list_for_each_entry(pwrst
, &pwrst_list
, node
)
335 pwrst
->saved_state
= pwrdm_read_next_pwrst(pwrst
->pwrdm
);
336 /* Set ones wanted by suspend */
337 list_for_each_entry(pwrst
, &pwrst_list
, node
) {
338 if (set_pwrdm_state(pwrst
->pwrdm
, pwrst
->next_state
))
340 if (pwrdm_clear_all_prev_pwrst(pwrst
->pwrdm
))
344 omap_uart_prepare_suspend();
348 /* Restore next_pwrsts */
349 list_for_each_entry(pwrst
, &pwrst_list
, node
) {
350 state
= pwrdm_read_prev_pwrst(pwrst
->pwrdm
);
351 if (state
> pwrst
->next_state
) {
352 printk(KERN_INFO
"Powerdomain (%s) didn't enter "
354 pwrst
->pwrdm
->name
, pwrst
->next_state
);
357 set_pwrdm_state(pwrst
->pwrdm
, pwrst
->saved_state
);
360 printk(KERN_ERR
"Could not enter target state in pm_suspend\n");
362 printk(KERN_INFO
"Successfully put all powerdomains "
363 "to target state\n");
368 static int omap3_pm_enter(suspend_state_t unused
)
372 switch (suspend_state
) {
373 case PM_SUSPEND_STANDBY
:
375 ret
= omap3_pm_suspend();
384 static void omap3_pm_finish(void)
389 /* Hooks to enable / disable UART interrupts during suspend */
390 static int omap3_pm_begin(suspend_state_t state
)
392 suspend_state
= state
;
393 omap_uart_enable_irqs(0);
397 static void omap3_pm_end(void)
399 suspend_state
= PM_SUSPEND_ON
;
400 omap_uart_enable_irqs(1);
404 static struct platform_suspend_ops omap_pm_ops
= {
405 .begin
= omap3_pm_begin
,
407 .prepare
= omap3_pm_prepare
,
408 .enter
= omap3_pm_enter
,
409 .finish
= omap3_pm_finish
,
410 .valid
= suspend_valid_only_mem
,
412 #endif /* CONFIG_SUSPEND */
416 * omap3_iva_idle(): ensure IVA is in idle so it can be put into
419 * In cases where IVA2 is activated by bootcode, it may prevent
420 * full-chip retention or off-mode because it is not idle. This
421 * function forces the IVA2 into idle state so it can go
422 * into retention/off and thus allow full-chip retention/off.
425 static void __init
omap3_iva_idle(void)
427 /* ensure IVA2 clock is disabled */
428 cm_write_mod_reg(0, OMAP3430_IVA2_MOD
, CM_FCLKEN
);
430 /* if no clock activity, nothing else to do */
431 if (!(cm_read_mod_reg(OMAP3430_IVA2_MOD
, OMAP3430_CM_CLKSTST
) &
432 OMAP3430_CLKACTIVITY_IVA2_MASK
))
436 prm_write_mod_reg(OMAP3430_RST1_IVA2
|
439 OMAP3430_IVA2_MOD
, RM_RSTCTRL
);
441 /* Enable IVA2 clock */
442 cm_write_mod_reg(OMAP3430_CM_FCLKEN_IVA2_EN_IVA2
,
443 OMAP3430_IVA2_MOD
, CM_FCLKEN
);
445 /* Set IVA2 boot mode to 'idle' */
446 omap_ctrl_writel(OMAP3_IVA2_BOOTMOD_IDLE
,
447 OMAP343X_CONTROL_IVA2_BOOTMOD
);
450 prm_write_mod_reg(0, OMAP3430_IVA2_MOD
, RM_RSTCTRL
);
452 /* Disable IVA2 clock */
453 cm_write_mod_reg(0, OMAP3430_IVA2_MOD
, CM_FCLKEN
);
456 prm_write_mod_reg(OMAP3430_RST1_IVA2
|
459 OMAP3430_IVA2_MOD
, RM_RSTCTRL
);
462 static void __init
omap3_d2d_idle(void)
466 /* In a stand alone OMAP3430 where there is not a stacked
467 * modem for the D2D Idle Ack and D2D MStandby must be pulled
468 * high. S CONTROL_PADCONF_SAD2D_IDLEACK and
469 * CONTROL_PADCONF_SAD2D_MSTDBY to have a pull up. */
470 mask
= (1 << 4) | (1 << 3); /* pull-up, enabled */
471 padconf
= omap_ctrl_readw(OMAP3_PADCONF_SAD2D_MSTANDBY
);
473 omap_ctrl_writew(padconf
, OMAP3_PADCONF_SAD2D_MSTANDBY
);
475 padconf
= omap_ctrl_readw(OMAP3_PADCONF_SAD2D_IDLEACK
);
477 omap_ctrl_writew(padconf
, OMAP3_PADCONF_SAD2D_IDLEACK
);
480 prm_write_mod_reg(OMAP3430_RM_RSTCTRL_CORE_MODEM_SW_RSTPWRON
|
481 OMAP3430_RM_RSTCTRL_CORE_MODEM_SW_RST
,
482 CORE_MOD
, RM_RSTCTRL
);
483 prm_write_mod_reg(0, CORE_MOD
, RM_RSTCTRL
);
486 static void __init
prcm_setup_regs(void)
488 /* XXX Reset all wkdeps. This should be done when initializing
490 prm_write_mod_reg(0, OMAP3430_IVA2_MOD
, PM_WKDEP
);
491 prm_write_mod_reg(0, MPU_MOD
, PM_WKDEP
);
492 prm_write_mod_reg(0, OMAP3430_DSS_MOD
, PM_WKDEP
);
493 prm_write_mod_reg(0, OMAP3430_NEON_MOD
, PM_WKDEP
);
494 prm_write_mod_reg(0, OMAP3430_CAM_MOD
, PM_WKDEP
);
495 prm_write_mod_reg(0, OMAP3430_PER_MOD
, PM_WKDEP
);
496 if (omap_rev() > OMAP3430_REV_ES1_0
) {
497 prm_write_mod_reg(0, OMAP3430ES2_SGX_MOD
, PM_WKDEP
);
498 prm_write_mod_reg(0, OMAP3430ES2_USBHOST_MOD
, PM_WKDEP
);
500 prm_write_mod_reg(0, GFX_MOD
, PM_WKDEP
);
503 * Enable interface clock autoidle for all modules.
504 * Note that in the long run this should be done by clockfw
507 OMAP3430_AUTO_MODEM
|
508 OMAP3430ES2_AUTO_MMC3
|
509 OMAP3430ES2_AUTO_ICR
|
511 OMAP3430_AUTO_SHA12
|
515 OMAP3430_AUTO_MSPRO
|
517 OMAP3430_AUTO_MCSPI4
|
518 OMAP3430_AUTO_MCSPI3
|
519 OMAP3430_AUTO_MCSPI2
|
520 OMAP3430_AUTO_MCSPI1
|
524 OMAP3430_AUTO_UART2
|
525 OMAP3430_AUTO_UART1
|
526 OMAP3430_AUTO_GPT11
|
527 OMAP3430_AUTO_GPT10
|
528 OMAP3430_AUTO_MCBSP5
|
529 OMAP3430_AUTO_MCBSP1
|
530 OMAP3430ES1_AUTO_FAC
| /* This is es1 only */
531 OMAP3430_AUTO_MAILBOXES
|
532 OMAP3430_AUTO_OMAPCTRL
|
533 OMAP3430ES1_AUTO_FSHOSTUSB
|
534 OMAP3430_AUTO_HSOTGUSB
|
535 OMAP3430_AUTO_SAD2D
|
537 CORE_MOD
, CM_AUTOIDLE1
);
543 OMAP3430_AUTO_SHA11
|
545 CORE_MOD
, CM_AUTOIDLE2
);
547 if (omap_rev() > OMAP3430_REV_ES1_0
) {
549 OMAP3430_AUTO_MAD2D
|
550 OMAP3430ES2_AUTO_USBTLL
,
551 CORE_MOD
, CM_AUTOIDLE3
);
557 OMAP3430_AUTO_GPIO1
|
558 OMAP3430_AUTO_32KSYNC
|
559 OMAP3430_AUTO_GPT12
|
561 WKUP_MOD
, CM_AUTOIDLE
);
574 OMAP3430_AUTO_GPIO6
|
575 OMAP3430_AUTO_GPIO5
|
576 OMAP3430_AUTO_GPIO4
|
577 OMAP3430_AUTO_GPIO3
|
578 OMAP3430_AUTO_GPIO2
|
580 OMAP3430_AUTO_UART3
|
589 OMAP3430_AUTO_MCBSP4
|
590 OMAP3430_AUTO_MCBSP3
|
591 OMAP3430_AUTO_MCBSP2
,
595 if (omap_rev() > OMAP3430_REV_ES1_0
) {
597 OMAP3430ES2_AUTO_USBHOST
,
598 OMAP3430ES2_USBHOST_MOD
,
603 * Set all plls to autoidle. This is needed until autoidle is
606 cm_write_mod_reg(1 << OMAP3430_AUTO_IVA2_DPLL_SHIFT
,
607 OMAP3430_IVA2_MOD
, CM_AUTOIDLE2
);
608 cm_write_mod_reg(1 << OMAP3430_AUTO_MPU_DPLL_SHIFT
,
611 cm_write_mod_reg((1 << OMAP3430_AUTO_PERIPH_DPLL_SHIFT
) |
612 (1 << OMAP3430_AUTO_CORE_DPLL_SHIFT
),
615 cm_write_mod_reg(1 << OMAP3430ES2_AUTO_PERIPH2_DPLL_SHIFT
,
620 * Enable control of expternal oscillator through
621 * sys_clkreq. In the long run clock framework should
624 prm_rmw_mod_reg_bits(OMAP_AUTOEXTCLKMODE_MASK
,
625 1 << OMAP_AUTOEXTCLKMODE_SHIFT
,
627 OMAP3_PRM_CLKSRC_CTRL_OFFSET
);
629 /* setup wakup source */
630 prm_write_mod_reg(OMAP3430_EN_IO
| OMAP3430_EN_GPIO1
|
631 OMAP3430_EN_GPT1
| OMAP3430_EN_GPT12
,
633 /* No need to write EN_IO, that is always enabled */
634 prm_write_mod_reg(OMAP3430_EN_GPIO1
| OMAP3430_EN_GPT1
|
636 WKUP_MOD
, OMAP3430_PM_MPUGRPSEL
);
637 /* For some reason IO doesn't generate wakeup event even if
638 * it is selected to mpu wakeup goup */
639 prm_write_mod_reg(OMAP3430_IO_EN
| OMAP3430_WKUP_EN
,
640 OCP_MOD
, OMAP3_PRM_IRQENABLE_MPU_OFFSET
);
642 /* Enable wakeups in PER */
643 prm_write_mod_reg(OMAP3430_EN_GPIO2
| OMAP3430_EN_GPIO3
|
644 OMAP3430_EN_GPIO4
| OMAP3430_EN_GPIO5
|
645 OMAP3430_EN_GPIO6
| OMAP3430_EN_UART3
,
646 OMAP3430_PER_MOD
, PM_WKEN
);
647 /* and allow them to wake up MPU */
648 prm_write_mod_reg(OMAP3430_GRPSEL_GPIO2
| OMAP3430_EN_GPIO3
|
649 OMAP3430_GRPSEL_GPIO4
| OMAP3430_EN_GPIO5
|
650 OMAP3430_GRPSEL_GPIO6
| OMAP3430_EN_UART3
,
651 OMAP3430_PER_MOD
, OMAP3430_PM_MPUGRPSEL
);
653 /* Don't attach IVA interrupts */
654 prm_write_mod_reg(0, WKUP_MOD
, OMAP3430_PM_IVAGRPSEL
);
655 prm_write_mod_reg(0, CORE_MOD
, OMAP3430_PM_IVAGRPSEL1
);
656 prm_write_mod_reg(0, CORE_MOD
, OMAP3430ES2_PM_IVAGRPSEL3
);
657 prm_write_mod_reg(0, OMAP3430_PER_MOD
, OMAP3430_PM_IVAGRPSEL
);
659 /* Clear any pending 'reset' flags */
660 prm_write_mod_reg(0xffffffff, MPU_MOD
, RM_RSTST
);
661 prm_write_mod_reg(0xffffffff, CORE_MOD
, RM_RSTST
);
662 prm_write_mod_reg(0xffffffff, OMAP3430_PER_MOD
, RM_RSTST
);
663 prm_write_mod_reg(0xffffffff, OMAP3430_EMU_MOD
, RM_RSTST
);
664 prm_write_mod_reg(0xffffffff, OMAP3430_NEON_MOD
, RM_RSTST
);
665 prm_write_mod_reg(0xffffffff, OMAP3430_DSS_MOD
, RM_RSTST
);
666 prm_write_mod_reg(0xffffffff, OMAP3430ES2_USBHOST_MOD
, RM_RSTST
);
668 /* Clear any pending PRCM interrupts */
669 prm_write_mod_reg(0, OCP_MOD
, OMAP3_PRM_IRQSTATUS_MPU_OFFSET
);
671 /* Don't attach IVA interrupts */
672 prm_write_mod_reg(0, WKUP_MOD
, OMAP3430_PM_IVAGRPSEL
);
673 prm_write_mod_reg(0, CORE_MOD
, OMAP3430_PM_IVAGRPSEL1
);
674 prm_write_mod_reg(0, CORE_MOD
, OMAP3430ES2_PM_IVAGRPSEL3
);
675 prm_write_mod_reg(0, OMAP3430_PER_MOD
, OMAP3430_PM_IVAGRPSEL
);
677 /* Clear any pending 'reset' flags */
678 prm_write_mod_reg(0xffffffff, MPU_MOD
, RM_RSTST
);
679 prm_write_mod_reg(0xffffffff, CORE_MOD
, RM_RSTST
);
680 prm_write_mod_reg(0xffffffff, OMAP3430_PER_MOD
, RM_RSTST
);
681 prm_write_mod_reg(0xffffffff, OMAP3430_EMU_MOD
, RM_RSTST
);
682 prm_write_mod_reg(0xffffffff, OMAP3430_NEON_MOD
, RM_RSTST
);
683 prm_write_mod_reg(0xffffffff, OMAP3430_DSS_MOD
, RM_RSTST
);
684 prm_write_mod_reg(0xffffffff, OMAP3430ES2_USBHOST_MOD
, RM_RSTST
);
686 /* Clear any pending PRCM interrupts */
687 prm_write_mod_reg(0, OCP_MOD
, OMAP3_PRM_IRQSTATUS_MPU_OFFSET
);
693 int omap3_pm_get_suspend_state(struct powerdomain
*pwrdm
)
695 struct power_state
*pwrst
;
697 list_for_each_entry(pwrst
, &pwrst_list
, node
) {
698 if (pwrst
->pwrdm
== pwrdm
)
699 return pwrst
->next_state
;
704 int omap3_pm_set_suspend_state(struct powerdomain
*pwrdm
, int state
)
706 struct power_state
*pwrst
;
708 list_for_each_entry(pwrst
, &pwrst_list
, node
) {
709 if (pwrst
->pwrdm
== pwrdm
) {
710 pwrst
->next_state
= state
;
717 static int __init
pwrdms_setup(struct powerdomain
*pwrdm
, void *unused
)
719 struct power_state
*pwrst
;
724 pwrst
= kmalloc(sizeof(struct power_state
), GFP_ATOMIC
);
727 pwrst
->pwrdm
= pwrdm
;
728 pwrst
->next_state
= PWRDM_POWER_RET
;
729 list_add(&pwrst
->node
, &pwrst_list
);
731 if (pwrdm_has_hdwr_sar(pwrdm
))
732 pwrdm_enable_hdwr_sar(pwrdm
);
734 return set_pwrdm_state(pwrst
->pwrdm
, pwrst
->next_state
);
738 * Enable hw supervised mode for all clockdomains if it's
739 * supported. Initiate sleep transition for other clockdomains, if
742 static int __init
clkdms_setup(struct clockdomain
*clkdm
, void *unused
)
744 if (clkdm
->flags
& CLKDM_CAN_ENABLE_AUTO
)
745 omap2_clkdm_allow_idle(clkdm
);
746 else if (clkdm
->flags
& CLKDM_CAN_FORCE_SLEEP
&&
747 atomic_read(&clkdm
->usecount
) == 0)
748 omap2_clkdm_sleep(clkdm
);
752 static int __init
omap3_pm_init(void)
754 struct power_state
*pwrst
, *tmp
;
757 if (!cpu_is_omap34xx())
760 printk(KERN_ERR
"Power Management for TI OMAP3.\n");
762 /* XXX prcm_setup_regs needs to be before enabling hw
763 * supervised mode for powerdomains */
766 ret
= request_irq(INT_34XX_PRCM_MPU_IRQ
,
767 (irq_handler_t
)prcm_interrupt_handler
,
768 IRQF_DISABLED
, "prcm", NULL
);
770 printk(KERN_ERR
"request_irq failed to register for 0x%x\n",
771 INT_34XX_PRCM_MPU_IRQ
);
775 ret
= pwrdm_for_each(pwrdms_setup
, NULL
);
777 printk(KERN_ERR
"Failed to setup powerdomains\n");
781 (void) clkdm_for_each(clkdms_setup
, NULL
);
783 mpu_pwrdm
= pwrdm_lookup("mpu_pwrdm");
784 if (mpu_pwrdm
== NULL
) {
785 printk(KERN_ERR
"Failed to get mpu_pwrdm\n");
789 _omap_sram_idle
= omap_sram_push(omap34xx_cpu_suspend
,
790 omap34xx_cpu_suspend_sz
);
792 #ifdef CONFIG_SUSPEND
793 suspend_set_ops(&omap_pm_ops
);
794 #endif /* CONFIG_SUSPEND */
796 pm_idle
= omap3_pm_idle
;
801 free_irq(INT_34XX_PRCM_MPU_IRQ
, NULL
);
802 list_for_each_entry_safe(pwrst
, tmp
, &pwrst_list
, node
) {
803 list_del(&pwrst
->node
);
809 late_initcall(omap3_pm_init
);