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
;
54 /* PRCM Interrupt Handler for wakeups */
55 static irqreturn_t
prcm_interrupt_handler (int irq
, void *dev_id
)
57 u32 wkst
, irqstatus_mpu
;
61 wkst
= prm_read_mod_reg(WKUP_MOD
, PM_WKST
);
63 iclk
= cm_read_mod_reg(WKUP_MOD
, CM_ICLKEN
);
64 fclk
= cm_read_mod_reg(WKUP_MOD
, CM_FCLKEN
);
65 cm_set_mod_reg_bits(wkst
, WKUP_MOD
, CM_ICLKEN
);
66 cm_set_mod_reg_bits(wkst
, WKUP_MOD
, CM_FCLKEN
);
67 prm_write_mod_reg(wkst
, WKUP_MOD
, PM_WKST
);
68 while (prm_read_mod_reg(WKUP_MOD
, PM_WKST
))
70 cm_write_mod_reg(iclk
, WKUP_MOD
, CM_ICLKEN
);
71 cm_write_mod_reg(fclk
, WKUP_MOD
, CM_FCLKEN
);
75 wkst
= prm_read_mod_reg(CORE_MOD
, PM_WKST1
);
77 iclk
= cm_read_mod_reg(CORE_MOD
, CM_ICLKEN1
);
78 fclk
= cm_read_mod_reg(CORE_MOD
, CM_FCLKEN1
);
79 cm_set_mod_reg_bits(wkst
, CORE_MOD
, CM_ICLKEN1
);
80 cm_set_mod_reg_bits(wkst
, CORE_MOD
, CM_FCLKEN1
);
81 prm_write_mod_reg(wkst
, CORE_MOD
, PM_WKST1
);
82 while (prm_read_mod_reg(CORE_MOD
, PM_WKST1
))
84 cm_write_mod_reg(iclk
, CORE_MOD
, CM_ICLKEN1
);
85 cm_write_mod_reg(fclk
, CORE_MOD
, CM_FCLKEN1
);
87 wkst
= prm_read_mod_reg(CORE_MOD
, OMAP3430ES2_PM_WKST3
);
89 iclk
= cm_read_mod_reg(CORE_MOD
, CM_ICLKEN3
);
90 fclk
= cm_read_mod_reg(CORE_MOD
, OMAP3430ES2_CM_FCLKEN3
);
91 cm_set_mod_reg_bits(wkst
, CORE_MOD
, CM_ICLKEN3
);
92 cm_set_mod_reg_bits(wkst
, CORE_MOD
, OMAP3430ES2_CM_FCLKEN3
);
93 prm_write_mod_reg(wkst
, CORE_MOD
, OMAP3430ES2_PM_WKST3
);
94 while (prm_read_mod_reg(CORE_MOD
, OMAP3430ES2_PM_WKST3
))
96 cm_write_mod_reg(iclk
, CORE_MOD
, CM_ICLKEN3
);
97 cm_write_mod_reg(fclk
, CORE_MOD
, OMAP3430ES2_CM_FCLKEN3
);
101 wkst
= prm_read_mod_reg(OMAP3430_PER_MOD
, PM_WKST
);
103 iclk
= cm_read_mod_reg(OMAP3430_PER_MOD
, CM_ICLKEN
);
104 fclk
= cm_read_mod_reg(OMAP3430_PER_MOD
, CM_FCLKEN
);
105 cm_set_mod_reg_bits(wkst
, OMAP3430_PER_MOD
, CM_ICLKEN
);
106 cm_set_mod_reg_bits(wkst
, OMAP3430_PER_MOD
, CM_FCLKEN
);
107 prm_write_mod_reg(wkst
, OMAP3430_PER_MOD
, PM_WKST
);
108 while (prm_read_mod_reg(OMAP3430_PER_MOD
, PM_WKST
))
110 cm_write_mod_reg(iclk
, OMAP3430_PER_MOD
, CM_ICLKEN
);
111 cm_write_mod_reg(fclk
, OMAP3430_PER_MOD
, CM_FCLKEN
);
114 if (omap_rev() > OMAP3430_REV_ES1_0
) {
116 wkst
= prm_read_mod_reg(OMAP3430ES2_USBHOST_MOD
, PM_WKST
);
118 iclk
= cm_read_mod_reg(OMAP3430ES2_USBHOST_MOD
,
120 fclk
= cm_read_mod_reg(OMAP3430ES2_USBHOST_MOD
,
122 cm_set_mod_reg_bits(wkst
, OMAP3430ES2_USBHOST_MOD
,
124 cm_set_mod_reg_bits(wkst
, OMAP3430ES2_USBHOST_MOD
,
126 prm_write_mod_reg(wkst
, OMAP3430ES2_USBHOST_MOD
,
128 while (prm_read_mod_reg(OMAP3430ES2_USBHOST_MOD
,
131 cm_write_mod_reg(iclk
, OMAP3430ES2_USBHOST_MOD
,
133 cm_write_mod_reg(fclk
, OMAP3430ES2_USBHOST_MOD
,
138 irqstatus_mpu
= prm_read_mod_reg(OCP_MOD
,
139 OMAP3_PRM_IRQSTATUS_MPU_OFFSET
);
140 prm_write_mod_reg(irqstatus_mpu
, OCP_MOD
,
141 OMAP3_PRM_IRQSTATUS_MPU_OFFSET
);
143 while (prm_read_mod_reg(OCP_MOD
, OMAP3_PRM_IRQSTATUS_MPU_OFFSET
))
149 static void omap_sram_idle(void)
151 /* Variable to tell what needs to be saved and restored
152 * in omap_sram_idle*/
153 /* save_state = 0 => Nothing to save and restored */
154 /* save_state = 1 => Only L1 and logic lost */
155 /* save_state = 2 => Only L2 lost */
156 /* save_state = 3 => L1, L2 and logic lost */
157 int save_state
= 0, mpu_next_state
;
159 if (!_omap_sram_idle
)
162 mpu_next_state
= pwrdm_read_next_pwrst(mpu_pwrdm
);
163 switch (mpu_next_state
) {
164 case PWRDM_POWER_RET
:
165 /* No need to save context */
170 printk(KERN_ERR
"Invalid mpu state in sram_idle\n");
173 omap2_gpio_prepare_for_retention();
174 omap_uart_prepare_idle(0);
175 omap_uart_prepare_idle(1);
176 omap_uart_prepare_idle(2);
178 _omap_sram_idle(NULL
, save_state
);
181 omap_uart_resume_idle(2);
182 omap_uart_resume_idle(1);
183 omap_uart_resume_idle(0);
184 omap2_gpio_resume_after_retention();
188 * Check if functional clocks are enabled before entering
189 * sleep. This function could be behind CONFIG_PM_DEBUG
190 * when all drivers are configuring their sysconfig registers
191 * properly and using their clocks properly.
193 static int omap3_fclks_active(void)
195 u32 fck_core1
= 0, fck_core3
= 0, fck_sgx
= 0, fck_dss
= 0,
196 fck_cam
= 0, fck_per
= 0, fck_usbhost
= 0;
198 fck_core1
= cm_read_mod_reg(CORE_MOD
,
200 if (omap_rev() > OMAP3430_REV_ES1_0
) {
201 fck_core3
= cm_read_mod_reg(CORE_MOD
,
202 OMAP3430ES2_CM_FCLKEN3
);
203 fck_sgx
= cm_read_mod_reg(OMAP3430ES2_SGX_MOD
,
205 fck_usbhost
= cm_read_mod_reg(OMAP3430ES2_USBHOST_MOD
,
208 fck_sgx
= cm_read_mod_reg(GFX_MOD
,
209 OMAP3430ES2_CM_FCLKEN3
);
210 fck_dss
= cm_read_mod_reg(OMAP3430_DSS_MOD
,
212 fck_cam
= cm_read_mod_reg(OMAP3430_CAM_MOD
,
214 fck_per
= cm_read_mod_reg(OMAP3430_PER_MOD
,
217 /* Ignore UART clocks. These are handled by UART core (serial.c) */
218 fck_core1
&= ~(OMAP3430_EN_UART1
| OMAP3430_EN_UART2
);
219 fck_per
&= ~OMAP3430_EN_UART3
;
221 if (fck_core1
| fck_core3
| fck_sgx
| fck_dss
|
222 fck_cam
| fck_per
| fck_usbhost
)
227 static int omap3_can_sleep(void)
229 if (!omap_uart_can_sleep())
231 if (omap3_fclks_active())
236 /* This sets pwrdm state (other than mpu & core. Currently only ON &
237 * RET are supported. Function is assuming that clkdm doesn't have
238 * hw_sup mode enabled. */
239 static int set_pwrdm_state(struct powerdomain
*pwrdm
, u32 state
)
242 int sleep_switch
= 0;
245 if (pwrdm
== NULL
|| IS_ERR(pwrdm
))
248 while (!(pwrdm
->pwrsts
& (1 << state
))) {
249 if (state
== PWRDM_POWER_OFF
)
254 cur_state
= pwrdm_read_next_pwrst(pwrdm
);
255 if (cur_state
== state
)
258 if (pwrdm_read_pwrst(pwrdm
) < PWRDM_POWER_ON
) {
259 omap2_clkdm_wakeup(pwrdm
->pwrdm_clkdms
[0]);
261 pwrdm_wait_transition(pwrdm
);
264 ret
= pwrdm_set_next_pwrst(pwrdm
, state
);
266 printk(KERN_ERR
"Unable to set state of powerdomain: %s\n",
272 omap2_clkdm_allow_idle(pwrdm
->pwrdm_clkdms
[0]);
273 pwrdm_wait_transition(pwrdm
);
280 static void omap3_pm_idle(void)
285 if (!omap3_can_sleep())
288 if (omap_irq_pending())
298 #ifdef CONFIG_SUSPEND
299 static suspend_state_t suspend_state
;
301 static int omap3_pm_prepare(void)
307 static int omap3_pm_suspend(void)
309 struct power_state
*pwrst
;
312 /* Read current next_pwrsts */
313 list_for_each_entry(pwrst
, &pwrst_list
, node
)
314 pwrst
->saved_state
= pwrdm_read_next_pwrst(pwrst
->pwrdm
);
315 /* Set ones wanted by suspend */
316 list_for_each_entry(pwrst
, &pwrst_list
, node
) {
317 if (set_pwrdm_state(pwrst
->pwrdm
, pwrst
->next_state
))
319 if (pwrdm_clear_all_prev_pwrst(pwrst
->pwrdm
))
323 omap_uart_prepare_suspend();
327 /* Restore next_pwrsts */
328 list_for_each_entry(pwrst
, &pwrst_list
, node
) {
329 state
= pwrdm_read_prev_pwrst(pwrst
->pwrdm
);
330 if (state
> pwrst
->next_state
) {
331 printk(KERN_INFO
"Powerdomain (%s) didn't enter "
333 pwrst
->pwrdm
->name
, pwrst
->next_state
);
336 set_pwrdm_state(pwrst
->pwrdm
, pwrst
->saved_state
);
339 printk(KERN_ERR
"Could not enter target state in pm_suspend\n");
341 printk(KERN_INFO
"Successfully put all powerdomains "
342 "to target state\n");
347 static int omap3_pm_enter(suspend_state_t unused
)
351 switch (suspend_state
) {
352 case PM_SUSPEND_STANDBY
:
354 ret
= omap3_pm_suspend();
363 static void omap3_pm_finish(void)
368 /* Hooks to enable / disable UART interrupts during suspend */
369 static int omap3_pm_begin(suspend_state_t state
)
371 suspend_state
= state
;
372 omap_uart_enable_irqs(0);
376 static void omap3_pm_end(void)
378 suspend_state
= PM_SUSPEND_ON
;
379 omap_uart_enable_irqs(1);
383 static struct platform_suspend_ops omap_pm_ops
= {
384 .begin
= omap3_pm_begin
,
386 .prepare
= omap3_pm_prepare
,
387 .enter
= omap3_pm_enter
,
388 .finish
= omap3_pm_finish
,
389 .valid
= suspend_valid_only_mem
,
391 #endif /* CONFIG_SUSPEND */
395 * omap3_iva_idle(): ensure IVA is in idle so it can be put into
398 * In cases where IVA2 is activated by bootcode, it may prevent
399 * full-chip retention or off-mode because it is not idle. This
400 * function forces the IVA2 into idle state so it can go
401 * into retention/off and thus allow full-chip retention/off.
404 static void __init
omap3_iva_idle(void)
406 /* ensure IVA2 clock is disabled */
407 cm_write_mod_reg(0, OMAP3430_IVA2_MOD
, CM_FCLKEN
);
409 /* if no clock activity, nothing else to do */
410 if (!(cm_read_mod_reg(OMAP3430_IVA2_MOD
, OMAP3430_CM_CLKSTST
) &
411 OMAP3430_CLKACTIVITY_IVA2_MASK
))
415 prm_write_mod_reg(OMAP3430_RST1_IVA2
|
418 OMAP3430_IVA2_MOD
, RM_RSTCTRL
);
420 /* Enable IVA2 clock */
421 cm_write_mod_reg(OMAP3430_CM_FCLKEN_IVA2_EN_IVA2
,
422 OMAP3430_IVA2_MOD
, CM_FCLKEN
);
424 /* Set IVA2 boot mode to 'idle' */
425 omap_ctrl_writel(OMAP3_IVA2_BOOTMOD_IDLE
,
426 OMAP343X_CONTROL_IVA2_BOOTMOD
);
429 prm_write_mod_reg(0, OMAP3430_IVA2_MOD
, RM_RSTCTRL
);
431 /* Disable IVA2 clock */
432 cm_write_mod_reg(0, OMAP3430_IVA2_MOD
, CM_FCLKEN
);
435 prm_write_mod_reg(OMAP3430_RST1_IVA2
|
438 OMAP3430_IVA2_MOD
, RM_RSTCTRL
);
441 static void __init
omap3_d2d_idle(void)
445 /* In a stand alone OMAP3430 where there is not a stacked
446 * modem for the D2D Idle Ack and D2D MStandby must be pulled
447 * high. S CONTROL_PADCONF_SAD2D_IDLEACK and
448 * CONTROL_PADCONF_SAD2D_MSTDBY to have a pull up. */
449 mask
= (1 << 4) | (1 << 3); /* pull-up, enabled */
450 padconf
= omap_ctrl_readw(OMAP3_PADCONF_SAD2D_MSTANDBY
);
452 omap_ctrl_writew(padconf
, OMAP3_PADCONF_SAD2D_MSTANDBY
);
454 padconf
= omap_ctrl_readw(OMAP3_PADCONF_SAD2D_IDLEACK
);
456 omap_ctrl_writew(padconf
, OMAP3_PADCONF_SAD2D_IDLEACK
);
459 prm_write_mod_reg(OMAP3430_RM_RSTCTRL_CORE_MODEM_SW_RSTPWRON
|
460 OMAP3430_RM_RSTCTRL_CORE_MODEM_SW_RST
,
461 CORE_MOD
, RM_RSTCTRL
);
462 prm_write_mod_reg(0, CORE_MOD
, RM_RSTCTRL
);
465 static void __init
prcm_setup_regs(void)
467 /* XXX Reset all wkdeps. This should be done when initializing
469 prm_write_mod_reg(0, OMAP3430_IVA2_MOD
, PM_WKDEP
);
470 prm_write_mod_reg(0, MPU_MOD
, PM_WKDEP
);
471 prm_write_mod_reg(0, OMAP3430_DSS_MOD
, PM_WKDEP
);
472 prm_write_mod_reg(0, OMAP3430_NEON_MOD
, PM_WKDEP
);
473 prm_write_mod_reg(0, OMAP3430_CAM_MOD
, PM_WKDEP
);
474 prm_write_mod_reg(0, OMAP3430_PER_MOD
, PM_WKDEP
);
475 if (omap_rev() > OMAP3430_REV_ES1_0
) {
476 prm_write_mod_reg(0, OMAP3430ES2_SGX_MOD
, PM_WKDEP
);
477 prm_write_mod_reg(0, OMAP3430ES2_USBHOST_MOD
, PM_WKDEP
);
479 prm_write_mod_reg(0, GFX_MOD
, PM_WKDEP
);
482 * Enable interface clock autoidle for all modules.
483 * Note that in the long run this should be done by clockfw
486 OMAP3430_AUTO_MODEM
|
487 OMAP3430ES2_AUTO_MMC3
|
488 OMAP3430ES2_AUTO_ICR
|
490 OMAP3430_AUTO_SHA12
|
494 OMAP3430_AUTO_MSPRO
|
496 OMAP3430_AUTO_MCSPI4
|
497 OMAP3430_AUTO_MCSPI3
|
498 OMAP3430_AUTO_MCSPI2
|
499 OMAP3430_AUTO_MCSPI1
|
503 OMAP3430_AUTO_UART2
|
504 OMAP3430_AUTO_UART1
|
505 OMAP3430_AUTO_GPT11
|
506 OMAP3430_AUTO_GPT10
|
507 OMAP3430_AUTO_MCBSP5
|
508 OMAP3430_AUTO_MCBSP1
|
509 OMAP3430ES1_AUTO_FAC
| /* This is es1 only */
510 OMAP3430_AUTO_MAILBOXES
|
511 OMAP3430_AUTO_OMAPCTRL
|
512 OMAP3430ES1_AUTO_FSHOSTUSB
|
513 OMAP3430_AUTO_HSOTGUSB
|
514 OMAP3430_AUTO_SAD2D
|
516 CORE_MOD
, CM_AUTOIDLE1
);
522 OMAP3430_AUTO_SHA11
|
524 CORE_MOD
, CM_AUTOIDLE2
);
526 if (omap_rev() > OMAP3430_REV_ES1_0
) {
528 OMAP3430_AUTO_MAD2D
|
529 OMAP3430ES2_AUTO_USBTLL
,
530 CORE_MOD
, CM_AUTOIDLE3
);
536 OMAP3430_AUTO_GPIO1
|
537 OMAP3430_AUTO_32KSYNC
|
538 OMAP3430_AUTO_GPT12
|
540 WKUP_MOD
, CM_AUTOIDLE
);
553 OMAP3430_AUTO_GPIO6
|
554 OMAP3430_AUTO_GPIO5
|
555 OMAP3430_AUTO_GPIO4
|
556 OMAP3430_AUTO_GPIO3
|
557 OMAP3430_AUTO_GPIO2
|
559 OMAP3430_AUTO_UART3
|
568 OMAP3430_AUTO_MCBSP4
|
569 OMAP3430_AUTO_MCBSP3
|
570 OMAP3430_AUTO_MCBSP2
,
574 if (omap_rev() > OMAP3430_REV_ES1_0
) {
576 OMAP3430ES2_AUTO_USBHOST
,
577 OMAP3430ES2_USBHOST_MOD
,
582 * Set all plls to autoidle. This is needed until autoidle is
585 cm_write_mod_reg(1 << OMAP3430_AUTO_IVA2_DPLL_SHIFT
,
586 OMAP3430_IVA2_MOD
, CM_AUTOIDLE2
);
587 cm_write_mod_reg(1 << OMAP3430_AUTO_MPU_DPLL_SHIFT
,
590 cm_write_mod_reg((1 << OMAP3430_AUTO_PERIPH_DPLL_SHIFT
) |
591 (1 << OMAP3430_AUTO_CORE_DPLL_SHIFT
),
594 cm_write_mod_reg(1 << OMAP3430ES2_AUTO_PERIPH2_DPLL_SHIFT
,
599 * Enable control of expternal oscillator through
600 * sys_clkreq. In the long run clock framework should
603 prm_rmw_mod_reg_bits(OMAP_AUTOEXTCLKMODE_MASK
,
604 1 << OMAP_AUTOEXTCLKMODE_SHIFT
,
606 OMAP3_PRM_CLKSRC_CTRL_OFFSET
);
608 /* setup wakup source */
609 prm_write_mod_reg(OMAP3430_EN_IO
| OMAP3430_EN_GPIO1
|
610 OMAP3430_EN_GPT1
| OMAP3430_EN_GPT12
,
612 /* No need to write EN_IO, that is always enabled */
613 prm_write_mod_reg(OMAP3430_EN_GPIO1
| OMAP3430_EN_GPT1
|
615 WKUP_MOD
, OMAP3430_PM_MPUGRPSEL
);
616 /* For some reason IO doesn't generate wakeup event even if
617 * it is selected to mpu wakeup goup */
618 prm_write_mod_reg(OMAP3430_IO_EN
| OMAP3430_WKUP_EN
,
619 OCP_MOD
, OMAP3_PRM_IRQENABLE_MPU_OFFSET
);
621 /* Don't attach IVA interrupts */
622 prm_write_mod_reg(0, WKUP_MOD
, OMAP3430_PM_IVAGRPSEL
);
623 prm_write_mod_reg(0, CORE_MOD
, OMAP3430_PM_IVAGRPSEL1
);
624 prm_write_mod_reg(0, CORE_MOD
, OMAP3430ES2_PM_IVAGRPSEL3
);
625 prm_write_mod_reg(0, OMAP3430_PER_MOD
, OMAP3430_PM_IVAGRPSEL
);
627 /* Clear any pending 'reset' flags */
628 prm_write_mod_reg(0xffffffff, MPU_MOD
, RM_RSTST
);
629 prm_write_mod_reg(0xffffffff, CORE_MOD
, RM_RSTST
);
630 prm_write_mod_reg(0xffffffff, OMAP3430_PER_MOD
, RM_RSTST
);
631 prm_write_mod_reg(0xffffffff, OMAP3430_EMU_MOD
, RM_RSTST
);
632 prm_write_mod_reg(0xffffffff, OMAP3430_NEON_MOD
, RM_RSTST
);
633 prm_write_mod_reg(0xffffffff, OMAP3430_DSS_MOD
, RM_RSTST
);
634 prm_write_mod_reg(0xffffffff, OMAP3430ES2_USBHOST_MOD
, RM_RSTST
);
636 /* Clear any pending PRCM interrupts */
637 prm_write_mod_reg(0, OCP_MOD
, OMAP3_PRM_IRQSTATUS_MPU_OFFSET
);
639 /* Don't attach IVA interrupts */
640 prm_write_mod_reg(0, WKUP_MOD
, OMAP3430_PM_IVAGRPSEL
);
641 prm_write_mod_reg(0, CORE_MOD
, OMAP3430_PM_IVAGRPSEL1
);
642 prm_write_mod_reg(0, CORE_MOD
, OMAP3430ES2_PM_IVAGRPSEL3
);
643 prm_write_mod_reg(0, OMAP3430_PER_MOD
, OMAP3430_PM_IVAGRPSEL
);
645 /* Clear any pending 'reset' flags */
646 prm_write_mod_reg(0xffffffff, MPU_MOD
, RM_RSTST
);
647 prm_write_mod_reg(0xffffffff, CORE_MOD
, RM_RSTST
);
648 prm_write_mod_reg(0xffffffff, OMAP3430_PER_MOD
, RM_RSTST
);
649 prm_write_mod_reg(0xffffffff, OMAP3430_EMU_MOD
, RM_RSTST
);
650 prm_write_mod_reg(0xffffffff, OMAP3430_NEON_MOD
, RM_RSTST
);
651 prm_write_mod_reg(0xffffffff, OMAP3430_DSS_MOD
, RM_RSTST
);
652 prm_write_mod_reg(0xffffffff, OMAP3430ES2_USBHOST_MOD
, RM_RSTST
);
654 /* Clear any pending PRCM interrupts */
655 prm_write_mod_reg(0, OCP_MOD
, OMAP3_PRM_IRQSTATUS_MPU_OFFSET
);
661 static int __init
pwrdms_setup(struct powerdomain
*pwrdm
)
663 struct power_state
*pwrst
;
668 pwrst
= kmalloc(sizeof(struct power_state
), GFP_KERNEL
);
671 pwrst
->pwrdm
= pwrdm
;
672 pwrst
->next_state
= PWRDM_POWER_RET
;
673 list_add(&pwrst
->node
, &pwrst_list
);
675 if (pwrdm_has_hdwr_sar(pwrdm
))
676 pwrdm_enable_hdwr_sar(pwrdm
);
678 return set_pwrdm_state(pwrst
->pwrdm
, pwrst
->next_state
);
682 * Enable hw supervised mode for all clockdomains if it's
683 * supported. Initiate sleep transition for other clockdomains, if
686 static int __init
clkdms_setup(struct clockdomain
*clkdm
)
688 if (clkdm
->flags
& CLKDM_CAN_ENABLE_AUTO
)
689 omap2_clkdm_allow_idle(clkdm
);
690 else if (clkdm
->flags
& CLKDM_CAN_FORCE_SLEEP
&&
691 atomic_read(&clkdm
->usecount
) == 0)
692 omap2_clkdm_sleep(clkdm
);
696 static int __init
omap3_pm_init(void)
698 struct power_state
*pwrst
, *tmp
;
701 if (!cpu_is_omap34xx())
704 printk(KERN_ERR
"Power Management for TI OMAP3.\n");
706 /* XXX prcm_setup_regs needs to be before enabling hw
707 * supervised mode for powerdomains */
710 ret
= request_irq(INT_34XX_PRCM_MPU_IRQ
,
711 (irq_handler_t
)prcm_interrupt_handler
,
712 IRQF_DISABLED
, "prcm", NULL
);
714 printk(KERN_ERR
"request_irq failed to register for 0x%x\n",
715 INT_34XX_PRCM_MPU_IRQ
);
719 ret
= pwrdm_for_each(pwrdms_setup
);
721 printk(KERN_ERR
"Failed to setup powerdomains\n");
725 (void) clkdm_for_each(clkdms_setup
);
727 mpu_pwrdm
= pwrdm_lookup("mpu_pwrdm");
728 if (mpu_pwrdm
== NULL
) {
729 printk(KERN_ERR
"Failed to get mpu_pwrdm\n");
733 _omap_sram_idle
= omap_sram_push(omap34xx_cpu_suspend
,
734 omap34xx_cpu_suspend_sz
);
736 #ifdef CONFIG_SUSPEND
737 suspend_set_ops(&omap_pm_ops
);
738 #endif /* CONFIG_SUSPEND */
740 pm_idle
= omap3_pm_idle
;
745 free_irq(INT_34XX_PRCM_MPU_IRQ
, NULL
);
746 list_for_each_entry_safe(pwrst
, tmp
, &pwrst_list
, node
) {
747 list_del(&pwrst
->node
);
753 late_initcall(omap3_pm_init
);