aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/mach-omap2/pm34xx.c
diff options
context:
space:
mode:
Diffstat (limited to 'arch/arm/mach-omap2/pm34xx.c')
-rw-r--r--arch/arm/mach-omap2/pm34xx.c236
1 files changed, 130 insertions, 106 deletions
diff --git a/arch/arm/mach-omap2/pm34xx.c b/arch/arm/mach-omap2/pm34xx.c
index 0cb20d29f70c..8cbbeade4b8a 100644
--- a/arch/arm/mach-omap2/pm34xx.c
+++ b/arch/arm/mach-omap2/pm34xx.c
@@ -31,8 +31,8 @@
31#include <linux/console.h> 31#include <linux/console.h>
32 32
33#include <plat/sram.h> 33#include <plat/sram.h>
34#include <plat/clockdomain.h> 34#include "clockdomain.h"
35#include <plat/powerdomain.h> 35#include "powerdomain.h"
36#include <plat/serial.h> 36#include <plat/serial.h>
37#include <plat/sdrc.h> 37#include <plat/sdrc.h>
38#include <plat/prcm.h> 38#include <plat/prcm.h>
@@ -41,11 +41,11 @@
41 41
42#include <asm/tlbflush.h> 42#include <asm/tlbflush.h>
43 43
44#include "cm.h" 44#include "cm2xxx_3xxx.h"
45#include "cm-regbits-34xx.h" 45#include "cm-regbits-34xx.h"
46#include "prm-regbits-34xx.h" 46#include "prm-regbits-34xx.h"
47 47
48#include "prm.h" 48#include "prm2xxx_3xxx.h"
49#include "pm.h" 49#include "pm.h"
50#include "sdrc.h" 50#include "sdrc.h"
51#include "control.h" 51#include "control.h"
@@ -68,6 +68,9 @@ static inline bool is_suspending(void)
68#define OMAP343X_TABLE_VALUE_OFFSET 0xc0 68#define OMAP343X_TABLE_VALUE_OFFSET 0xc0
69#define OMAP343X_CONTROL_REG_VALUE_OFFSET 0xc8 69#define OMAP343X_CONTROL_REG_VALUE_OFFSET 0xc8
70 70
71/* pm34xx errata defined in pm.h */
72u16 pm34xx_errata;
73
71struct power_state { 74struct power_state {
72 struct powerdomain *pwrdm; 75 struct powerdomain *pwrdm;
73 u32 next_state; 76 u32 next_state;
@@ -102,12 +105,12 @@ static void omap3_enable_io_chain(void)
102 int timeout = 0; 105 int timeout = 0;
103 106
104 if (omap_rev() >= OMAP3430_REV_ES3_1) { 107 if (omap_rev() >= OMAP3430_REV_ES3_1) {
105 prm_set_mod_reg_bits(OMAP3430_EN_IO_CHAIN_MASK, WKUP_MOD, 108 omap2_prm_set_mod_reg_bits(OMAP3430_EN_IO_CHAIN_MASK, WKUP_MOD,
106 PM_WKEN); 109 PM_WKEN);
107 /* Do a readback to assure write has been done */ 110 /* Do a readback to assure write has been done */
108 prm_read_mod_reg(WKUP_MOD, PM_WKEN); 111 omap2_prm_read_mod_reg(WKUP_MOD, PM_WKEN);
109 112
110 while (!(prm_read_mod_reg(WKUP_MOD, PM_WKEN) & 113 while (!(omap2_prm_read_mod_reg(WKUP_MOD, PM_WKEN) &
111 OMAP3430_ST_IO_CHAIN_MASK)) { 114 OMAP3430_ST_IO_CHAIN_MASK)) {
112 timeout++; 115 timeout++;
113 if (timeout > 1000) { 116 if (timeout > 1000) {
@@ -115,7 +118,7 @@ static void omap3_enable_io_chain(void)
115 "activation failed.\n"); 118 "activation failed.\n");
116 return; 119 return;
117 } 120 }
118 prm_set_mod_reg_bits(OMAP3430_ST_IO_CHAIN_MASK, 121 omap2_prm_set_mod_reg_bits(OMAP3430_ST_IO_CHAIN_MASK,
119 WKUP_MOD, PM_WKEN); 122 WKUP_MOD, PM_WKEN);
120 } 123 }
121 } 124 }
@@ -124,26 +127,17 @@ static void omap3_enable_io_chain(void)
124static void omap3_disable_io_chain(void) 127static void omap3_disable_io_chain(void)
125{ 128{
126 if (omap_rev() >= OMAP3430_REV_ES3_1) 129 if (omap_rev() >= OMAP3430_REV_ES3_1)
127 prm_clear_mod_reg_bits(OMAP3430_EN_IO_CHAIN_MASK, WKUP_MOD, 130 omap2_prm_clear_mod_reg_bits(OMAP3430_EN_IO_CHAIN_MASK, WKUP_MOD,
128 PM_WKEN); 131 PM_WKEN);
129} 132}
130 133
131static void omap3_core_save_context(void) 134static void omap3_core_save_context(void)
132{ 135{
133 u32 control_padconf_off; 136 omap3_ctrl_save_padconf();
134
135 /* Save the padconf registers */
136 control_padconf_off = omap_ctrl_readl(OMAP343X_CONTROL_PADCONF_OFF);
137 control_padconf_off |= START_PADCONF_SAVE;
138 omap_ctrl_writel(control_padconf_off, OMAP343X_CONTROL_PADCONF_OFF);
139 /* wait for the save to complete */
140 while (!(omap_ctrl_readl(OMAP343X_CONTROL_GENERAL_PURPOSE_STATUS)
141 & PADCONF_SAVE_DONE))
142 udelay(1);
143 137
144 /* 138 /*
145 * Force write last pad into memory, as this can fail in some 139 * Force write last pad into memory, as this can fail in some
146 * cases according to erratas 1.157, 1.185 140 * cases according to errata 1.157, 1.185
147 */ 141 */
148 omap_ctrl_writel(omap_ctrl_readl(OMAP343X_PADCONF_ETK_D14), 142 omap_ctrl_writel(omap_ctrl_readl(OMAP343X_PADCONF_ETK_D14),
149 OMAP343X_CONTROL_MEM_WKUP + 0x2a0); 143 OMAP343X_CONTROL_MEM_WKUP + 0x2a0);
@@ -218,27 +212,27 @@ static int prcm_clear_mod_irqs(s16 module, u8 regs)
218 OMAP3430ES2_PM_MPUGRPSEL3 : OMAP3430_PM_MPUGRPSEL; 212 OMAP3430ES2_PM_MPUGRPSEL3 : OMAP3430_PM_MPUGRPSEL;
219 int c = 0; 213 int c = 0;
220 214
221 wkst = prm_read_mod_reg(module, wkst_off); 215 wkst = omap2_prm_read_mod_reg(module, wkst_off);
222 wkst &= prm_read_mod_reg(module, grpsel_off); 216 wkst &= omap2_prm_read_mod_reg(module, grpsel_off);
223 if (wkst) { 217 if (wkst) {
224 iclk = cm_read_mod_reg(module, iclk_off); 218 iclk = omap2_cm_read_mod_reg(module, iclk_off);
225 fclk = cm_read_mod_reg(module, fclk_off); 219 fclk = omap2_cm_read_mod_reg(module, fclk_off);
226 while (wkst) { 220 while (wkst) {
227 clken = wkst; 221 clken = wkst;
228 cm_set_mod_reg_bits(clken, module, iclk_off); 222 omap2_cm_set_mod_reg_bits(clken, module, iclk_off);
229 /* 223 /*
230 * For USBHOST, we don't know whether HOST1 or 224 * For USBHOST, we don't know whether HOST1 or
231 * HOST2 woke us up, so enable both f-clocks 225 * HOST2 woke us up, so enable both f-clocks
232 */ 226 */
233 if (module == OMAP3430ES2_USBHOST_MOD) 227 if (module == OMAP3430ES2_USBHOST_MOD)
234 clken |= 1 << OMAP3430ES2_EN_USBHOST2_SHIFT; 228 clken |= 1 << OMAP3430ES2_EN_USBHOST2_SHIFT;
235 cm_set_mod_reg_bits(clken, module, fclk_off); 229 omap2_cm_set_mod_reg_bits(clken, module, fclk_off);
236 prm_write_mod_reg(wkst, module, wkst_off); 230 omap2_prm_write_mod_reg(wkst, module, wkst_off);
237 wkst = prm_read_mod_reg(module, wkst_off); 231 wkst = omap2_prm_read_mod_reg(module, wkst_off);
238 c++; 232 c++;
239 } 233 }
240 cm_write_mod_reg(iclk, module, iclk_off); 234 omap2_cm_write_mod_reg(iclk, module, iclk_off);
241 cm_write_mod_reg(fclk, module, fclk_off); 235 omap2_cm_write_mod_reg(fclk, module, fclk_off);
242 } 236 }
243 237
244 return c; 238 return c;
@@ -281,9 +275,9 @@ static irqreturn_t prcm_interrupt_handler (int irq, void *dev_id)
281 u32 irqenable_mpu, irqstatus_mpu; 275 u32 irqenable_mpu, irqstatus_mpu;
282 int c = 0; 276 int c = 0;
283 277
284 irqenable_mpu = prm_read_mod_reg(OCP_MOD, 278 irqenable_mpu = omap2_prm_read_mod_reg(OCP_MOD,
285 OMAP3_PRM_IRQENABLE_MPU_OFFSET); 279 OMAP3_PRM_IRQENABLE_MPU_OFFSET);
286 irqstatus_mpu = prm_read_mod_reg(OCP_MOD, 280 irqstatus_mpu = omap2_prm_read_mod_reg(OCP_MOD,
287 OMAP3_PRM_IRQSTATUS_MPU_OFFSET); 281 OMAP3_PRM_IRQSTATUS_MPU_OFFSET);
288 irqstatus_mpu &= irqenable_mpu; 282 irqstatus_mpu &= irqenable_mpu;
289 283
@@ -304,10 +298,10 @@ static irqreturn_t prcm_interrupt_handler (int irq, void *dev_id)
304 "no code to handle it (%08x)\n", irqstatus_mpu); 298 "no code to handle it (%08x)\n", irqstatus_mpu);
305 } 299 }
306 300
307 prm_write_mod_reg(irqstatus_mpu, OCP_MOD, 301 omap2_prm_write_mod_reg(irqstatus_mpu, OCP_MOD,
308 OMAP3_PRM_IRQSTATUS_MPU_OFFSET); 302 OMAP3_PRM_IRQSTATUS_MPU_OFFSET);
309 303
310 irqstatus_mpu = prm_read_mod_reg(OCP_MOD, 304 irqstatus_mpu = omap2_prm_read_mod_reg(OCP_MOD,
311 OMAP3_PRM_IRQSTATUS_MPU_OFFSET); 305 OMAP3_PRM_IRQSTATUS_MPU_OFFSET);
312 irqstatus_mpu &= irqenable_mpu; 306 irqstatus_mpu &= irqenable_mpu;
313 307
@@ -357,6 +351,7 @@ void omap_sram_idle(void)
357 int mpu_next_state = PWRDM_POWER_ON; 351 int mpu_next_state = PWRDM_POWER_ON;
358 int per_next_state = PWRDM_POWER_ON; 352 int per_next_state = PWRDM_POWER_ON;
359 int core_next_state = PWRDM_POWER_ON; 353 int core_next_state = PWRDM_POWER_ON;
354 int per_going_off;
360 int core_prev_state, per_prev_state; 355 int core_prev_state, per_prev_state;
361 u32 sdrc_pwr = 0; 356 u32 sdrc_pwr = 0;
362 357
@@ -395,7 +390,7 @@ void omap_sram_idle(void)
395 if (omap3_has_io_wakeup() && 390 if (omap3_has_io_wakeup() &&
396 (per_next_state < PWRDM_POWER_ON || 391 (per_next_state < PWRDM_POWER_ON ||
397 core_next_state < PWRDM_POWER_ON)) { 392 core_next_state < PWRDM_POWER_ON)) {
398 prm_set_mod_reg_bits(OMAP3430_EN_IO_MASK, WKUP_MOD, PM_WKEN); 393 omap2_prm_set_mod_reg_bits(OMAP3430_EN_IO_MASK, WKUP_MOD, PM_WKEN);
399 omap3_enable_io_chain(); 394 omap3_enable_io_chain();
400 } 395 }
401 396
@@ -408,9 +403,10 @@ void omap_sram_idle(void)
408 403
409 /* PER */ 404 /* PER */
410 if (per_next_state < PWRDM_POWER_ON) { 405 if (per_next_state < PWRDM_POWER_ON) {
406 per_going_off = (per_next_state == PWRDM_POWER_OFF) ? 1 : 0;
411 omap_uart_prepare_idle(2); 407 omap_uart_prepare_idle(2);
412 omap_uart_prepare_idle(3); 408 omap_uart_prepare_idle(3);
413 omap2_gpio_prepare_for_idle(per_next_state); 409 omap2_gpio_prepare_for_idle(per_going_off);
414 if (per_next_state == PWRDM_POWER_OFF) 410 if (per_next_state == PWRDM_POWER_OFF)
415 omap3_per_save_context(); 411 omap3_per_save_context();
416 } 412 }
@@ -421,7 +417,7 @@ void omap_sram_idle(void)
421 omap_uart_prepare_idle(1); 417 omap_uart_prepare_idle(1);
422 if (core_next_state == PWRDM_POWER_OFF) { 418 if (core_next_state == PWRDM_POWER_OFF) {
423 omap3_core_save_context(); 419 omap3_core_save_context();
424 omap3_prcm_save_context(); 420 omap3_cm_save_context();
425 } 421 }
426 } 422 }
427 423
@@ -430,7 +426,7 @@ void omap_sram_idle(void)
430 /* 426 /*
431 * On EMU/HS devices ROM code restores a SRDC value 427 * On EMU/HS devices ROM code restores a SRDC value
432 * from scratchpad which has automatic self refresh on timeout 428 * from scratchpad which has automatic self refresh on timeout
433 * of AUTO_CNT = 1 enabled. This takes care of errata 1.142. 429 * of AUTO_CNT = 1 enabled. This takes care of erratum ID i443.
434 * Hence store/restore the SDRC_POWER register here. 430 * Hence store/restore the SDRC_POWER register here.
435 */ 431 */
436 if (omap_rev() >= OMAP3430_REV_ES3_0 && 432 if (omap_rev() >= OMAP3430_REV_ES3_0 &&
@@ -461,14 +457,14 @@ void omap_sram_idle(void)
461 core_prev_state = pwrdm_read_prev_pwrst(core_pwrdm); 457 core_prev_state = pwrdm_read_prev_pwrst(core_pwrdm);
462 if (core_prev_state == PWRDM_POWER_OFF) { 458 if (core_prev_state == PWRDM_POWER_OFF) {
463 omap3_core_restore_context(); 459 omap3_core_restore_context();
464 omap3_prcm_restore_context(); 460 omap3_cm_restore_context();
465 omap3_sram_restore_context(); 461 omap3_sram_restore_context();
466 omap2_sms_restore_context(); 462 omap2_sms_restore_context();
467 } 463 }
468 omap_uart_resume_idle(0); 464 omap_uart_resume_idle(0);
469 omap_uart_resume_idle(1); 465 omap_uart_resume_idle(1);
470 if (core_next_state == PWRDM_POWER_OFF) 466 if (core_next_state == PWRDM_POWER_OFF)
471 prm_clear_mod_reg_bits(OMAP3430_AUTO_OFF_MASK, 467 omap2_prm_clear_mod_reg_bits(OMAP3430_AUTO_OFF_MASK,
472 OMAP3430_GR_MOD, 468 OMAP3430_GR_MOD,
473 OMAP3_PRM_VOLTCTRL_OFFSET); 469 OMAP3_PRM_VOLTCTRL_OFFSET);
474 } 470 }
@@ -492,7 +488,8 @@ console_still_active:
492 if (omap3_has_io_wakeup() && 488 if (omap3_has_io_wakeup() &&
493 (per_next_state < PWRDM_POWER_ON || 489 (per_next_state < PWRDM_POWER_ON ||
494 core_next_state < PWRDM_POWER_ON)) { 490 core_next_state < PWRDM_POWER_ON)) {
495 prm_clear_mod_reg_bits(OMAP3430_EN_IO_MASK, WKUP_MOD, PM_WKEN); 491 omap2_prm_clear_mod_reg_bits(OMAP3430_EN_IO_MASK, WKUP_MOD,
492 PM_WKEN);
496 omap3_disable_io_chain(); 493 omap3_disable_io_chain();
497 } 494 }
498 495
@@ -529,12 +526,6 @@ out:
529} 526}
530 527
531#ifdef CONFIG_SUSPEND 528#ifdef CONFIG_SUSPEND
532static int omap3_pm_prepare(void)
533{
534 disable_hlt();
535 return 0;
536}
537
538static int omap3_pm_suspend(void) 529static int omap3_pm_suspend(void)
539{ 530{
540 struct power_state *pwrst; 531 struct power_state *pwrst;
@@ -597,14 +588,10 @@ static int omap3_pm_enter(suspend_state_t unused)
597 return ret; 588 return ret;
598} 589}
599 590
600static void omap3_pm_finish(void)
601{
602 enable_hlt();
603}
604
605/* Hooks to enable / disable UART interrupts during suspend */ 591/* Hooks to enable / disable UART interrupts during suspend */
606static int omap3_pm_begin(suspend_state_t state) 592static int omap3_pm_begin(suspend_state_t state)
607{ 593{
594 disable_hlt();
608 suspend_state = state; 595 suspend_state = state;
609 omap_uart_enable_irqs(0); 596 omap_uart_enable_irqs(0);
610 return 0; 597 return 0;
@@ -614,15 +601,14 @@ static void omap3_pm_end(void)
614{ 601{
615 suspend_state = PM_SUSPEND_ON; 602 suspend_state = PM_SUSPEND_ON;
616 omap_uart_enable_irqs(1); 603 omap_uart_enable_irqs(1);
604 enable_hlt();
617 return; 605 return;
618} 606}
619 607
620static const struct platform_suspend_ops omap_pm_ops = { 608static const struct platform_suspend_ops omap_pm_ops = {
621 .begin = omap3_pm_begin, 609 .begin = omap3_pm_begin,
622 .end = omap3_pm_end, 610 .end = omap3_pm_end,
623 .prepare = omap3_pm_prepare,
624 .enter = omap3_pm_enter, 611 .enter = omap3_pm_enter,
625 .finish = omap3_pm_finish,
626 .valid = suspend_valid_only_mem, 612 .valid = suspend_valid_only_mem,
627}; 613};
628#endif /* CONFIG_SUSPEND */ 614#endif /* CONFIG_SUSPEND */
@@ -641,21 +627,21 @@ static const struct platform_suspend_ops omap_pm_ops = {
641static void __init omap3_iva_idle(void) 627static void __init omap3_iva_idle(void)
642{ 628{
643 /* ensure IVA2 clock is disabled */ 629 /* ensure IVA2 clock is disabled */
644 cm_write_mod_reg(0, OMAP3430_IVA2_MOD, CM_FCLKEN); 630 omap2_cm_write_mod_reg(0, OMAP3430_IVA2_MOD, CM_FCLKEN);
645 631
646 /* if no clock activity, nothing else to do */ 632 /* if no clock activity, nothing else to do */
647 if (!(cm_read_mod_reg(OMAP3430_IVA2_MOD, OMAP3430_CM_CLKSTST) & 633 if (!(omap2_cm_read_mod_reg(OMAP3430_IVA2_MOD, OMAP3430_CM_CLKSTST) &
648 OMAP3430_CLKACTIVITY_IVA2_MASK)) 634 OMAP3430_CLKACTIVITY_IVA2_MASK))
649 return; 635 return;
650 636
651 /* Reset IVA2 */ 637 /* Reset IVA2 */
652 prm_write_mod_reg(OMAP3430_RST1_IVA2_MASK | 638 omap2_prm_write_mod_reg(OMAP3430_RST1_IVA2_MASK |
653 OMAP3430_RST2_IVA2_MASK | 639 OMAP3430_RST2_IVA2_MASK |
654 OMAP3430_RST3_IVA2_MASK, 640 OMAP3430_RST3_IVA2_MASK,
655 OMAP3430_IVA2_MOD, OMAP2_RM_RSTCTRL); 641 OMAP3430_IVA2_MOD, OMAP2_RM_RSTCTRL);
656 642
657 /* Enable IVA2 clock */ 643 /* Enable IVA2 clock */
658 cm_write_mod_reg(OMAP3430_CM_FCLKEN_IVA2_EN_IVA2_MASK, 644 omap2_cm_write_mod_reg(OMAP3430_CM_FCLKEN_IVA2_EN_IVA2_MASK,
659 OMAP3430_IVA2_MOD, CM_FCLKEN); 645 OMAP3430_IVA2_MOD, CM_FCLKEN);
660 646
661 /* Set IVA2 boot mode to 'idle' */ 647 /* Set IVA2 boot mode to 'idle' */
@@ -663,13 +649,13 @@ static void __init omap3_iva_idle(void)
663 OMAP343X_CONTROL_IVA2_BOOTMOD); 649 OMAP343X_CONTROL_IVA2_BOOTMOD);
664 650
665 /* Un-reset IVA2 */ 651 /* Un-reset IVA2 */
666 prm_write_mod_reg(0, OMAP3430_IVA2_MOD, OMAP2_RM_RSTCTRL); 652 omap2_prm_write_mod_reg(0, OMAP3430_IVA2_MOD, OMAP2_RM_RSTCTRL);
667 653
668 /* Disable IVA2 clock */ 654 /* Disable IVA2 clock */
669 cm_write_mod_reg(0, OMAP3430_IVA2_MOD, CM_FCLKEN); 655 omap2_cm_write_mod_reg(0, OMAP3430_IVA2_MOD, CM_FCLKEN);
670 656
671 /* Reset IVA2 */ 657 /* Reset IVA2 */
672 prm_write_mod_reg(OMAP3430_RST1_IVA2_MASK | 658 omap2_prm_write_mod_reg(OMAP3430_RST1_IVA2_MASK |
673 OMAP3430_RST2_IVA2_MASK | 659 OMAP3430_RST2_IVA2_MASK |
674 OMAP3430_RST3_IVA2_MASK, 660 OMAP3430_RST3_IVA2_MASK,
675 OMAP3430_IVA2_MOD, OMAP2_RM_RSTCTRL); 661 OMAP3430_IVA2_MOD, OMAP2_RM_RSTCTRL);
@@ -693,10 +679,10 @@ static void __init omap3_d2d_idle(void)
693 omap_ctrl_writew(padconf, OMAP3_PADCONF_SAD2D_IDLEACK); 679 omap_ctrl_writew(padconf, OMAP3_PADCONF_SAD2D_IDLEACK);
694 680
695 /* reset modem */ 681 /* reset modem */
696 prm_write_mod_reg(OMAP3430_RM_RSTCTRL_CORE_MODEM_SW_RSTPWRON_MASK | 682 omap2_prm_write_mod_reg(OMAP3430_RM_RSTCTRL_CORE_MODEM_SW_RSTPWRON_MASK |
697 OMAP3430_RM_RSTCTRL_CORE_MODEM_SW_RST_MASK, 683 OMAP3430_RM_RSTCTRL_CORE_MODEM_SW_RST_MASK,
698 CORE_MOD, OMAP2_RM_RSTCTRL); 684 CORE_MOD, OMAP2_RM_RSTCTRL);
699 prm_write_mod_reg(0, CORE_MOD, OMAP2_RM_RSTCTRL); 685 omap2_prm_write_mod_reg(0, CORE_MOD, OMAP2_RM_RSTCTRL);
700} 686}
701 687
702static void __init prcm_setup_regs(void) 688static void __init prcm_setup_regs(void)
@@ -711,23 +697,23 @@ static void __init prcm_setup_regs(void)
711 697
712 /* XXX Reset all wkdeps. This should be done when initializing 698 /* XXX Reset all wkdeps. This should be done when initializing
713 * powerdomains */ 699 * powerdomains */
714 prm_write_mod_reg(0, OMAP3430_IVA2_MOD, PM_WKDEP); 700 omap2_prm_write_mod_reg(0, OMAP3430_IVA2_MOD, PM_WKDEP);
715 prm_write_mod_reg(0, MPU_MOD, PM_WKDEP); 701 omap2_prm_write_mod_reg(0, MPU_MOD, PM_WKDEP);
716 prm_write_mod_reg(0, OMAP3430_DSS_MOD, PM_WKDEP); 702 omap2_prm_write_mod_reg(0, OMAP3430_DSS_MOD, PM_WKDEP);
717 prm_write_mod_reg(0, OMAP3430_NEON_MOD, PM_WKDEP); 703 omap2_prm_write_mod_reg(0, OMAP3430_NEON_MOD, PM_WKDEP);
718 prm_write_mod_reg(0, OMAP3430_CAM_MOD, PM_WKDEP); 704 omap2_prm_write_mod_reg(0, OMAP3430_CAM_MOD, PM_WKDEP);
719 prm_write_mod_reg(0, OMAP3430_PER_MOD, PM_WKDEP); 705 omap2_prm_write_mod_reg(0, OMAP3430_PER_MOD, PM_WKDEP);
720 if (omap_rev() > OMAP3430_REV_ES1_0) { 706 if (omap_rev() > OMAP3430_REV_ES1_0) {
721 prm_write_mod_reg(0, OMAP3430ES2_SGX_MOD, PM_WKDEP); 707 omap2_prm_write_mod_reg(0, OMAP3430ES2_SGX_MOD, PM_WKDEP);
722 prm_write_mod_reg(0, OMAP3430ES2_USBHOST_MOD, PM_WKDEP); 708 omap2_prm_write_mod_reg(0, OMAP3430ES2_USBHOST_MOD, PM_WKDEP);
723 } else 709 } else
724 prm_write_mod_reg(0, GFX_MOD, PM_WKDEP); 710 omap2_prm_write_mod_reg(0, GFX_MOD, PM_WKDEP);
725 711
726 /* 712 /*
727 * Enable interface clock autoidle for all modules. 713 * Enable interface clock autoidle for all modules.
728 * Note that in the long run this should be done by clockfw 714 * Note that in the long run this should be done by clockfw
729 */ 715 */
730 cm_write_mod_reg( 716 omap2_cm_write_mod_reg(
731 OMAP3430_AUTO_MODEM_MASK | 717 OMAP3430_AUTO_MODEM_MASK |
732 OMAP3430ES2_AUTO_MMC3_MASK | 718 OMAP3430ES2_AUTO_MMC3_MASK |
733 OMAP3430ES2_AUTO_ICR_MASK | 719 OMAP3430ES2_AUTO_ICR_MASK |
@@ -760,7 +746,7 @@ static void __init prcm_setup_regs(void)
760 OMAP3430_AUTO_SSI_MASK, 746 OMAP3430_AUTO_SSI_MASK,
761 CORE_MOD, CM_AUTOIDLE1); 747 CORE_MOD, CM_AUTOIDLE1);
762 748
763 cm_write_mod_reg( 749 omap2_cm_write_mod_reg(
764 OMAP3430_AUTO_PKA_MASK | 750 OMAP3430_AUTO_PKA_MASK |
765 OMAP3430_AUTO_AES1_MASK | 751 OMAP3430_AUTO_AES1_MASK |
766 OMAP3430_AUTO_RNG_MASK | 752 OMAP3430_AUTO_RNG_MASK |
@@ -769,13 +755,13 @@ static void __init prcm_setup_regs(void)
769 CORE_MOD, CM_AUTOIDLE2); 755 CORE_MOD, CM_AUTOIDLE2);
770 756
771 if (omap_rev() > OMAP3430_REV_ES1_0) { 757 if (omap_rev() > OMAP3430_REV_ES1_0) {
772 cm_write_mod_reg( 758 omap2_cm_write_mod_reg(
773 OMAP3430_AUTO_MAD2D_MASK | 759 OMAP3430_AUTO_MAD2D_MASK |
774 OMAP3430ES2_AUTO_USBTLL_MASK, 760 OMAP3430ES2_AUTO_USBTLL_MASK,
775 CORE_MOD, CM_AUTOIDLE3); 761 CORE_MOD, CM_AUTOIDLE3);
776 } 762 }
777 763
778 cm_write_mod_reg( 764 omap2_cm_write_mod_reg(
779 OMAP3430_AUTO_WDT2_MASK | 765 OMAP3430_AUTO_WDT2_MASK |
780 OMAP3430_AUTO_WDT1_MASK | 766 OMAP3430_AUTO_WDT1_MASK |
781 OMAP3430_AUTO_GPIO1_MASK | 767 OMAP3430_AUTO_GPIO1_MASK |
@@ -784,17 +770,17 @@ static void __init prcm_setup_regs(void)
784 OMAP3430_AUTO_GPT1_MASK, 770 OMAP3430_AUTO_GPT1_MASK,
785 WKUP_MOD, CM_AUTOIDLE); 771 WKUP_MOD, CM_AUTOIDLE);
786 772
787 cm_write_mod_reg( 773 omap2_cm_write_mod_reg(
788 OMAP3430_AUTO_DSS_MASK, 774 OMAP3430_AUTO_DSS_MASK,
789 OMAP3430_DSS_MOD, 775 OMAP3430_DSS_MOD,
790 CM_AUTOIDLE); 776 CM_AUTOIDLE);
791 777
792 cm_write_mod_reg( 778 omap2_cm_write_mod_reg(
793 OMAP3430_AUTO_CAM_MASK, 779 OMAP3430_AUTO_CAM_MASK,
794 OMAP3430_CAM_MOD, 780 OMAP3430_CAM_MOD,
795 CM_AUTOIDLE); 781 CM_AUTOIDLE);
796 782
797 cm_write_mod_reg( 783 omap2_cm_write_mod_reg(
798 omap3630_auto_uart4_mask | 784 omap3630_auto_uart4_mask |
799 OMAP3430_AUTO_GPIO6_MASK | 785 OMAP3430_AUTO_GPIO6_MASK |
800 OMAP3430_AUTO_GPIO5_MASK | 786 OMAP3430_AUTO_GPIO5_MASK |
@@ -818,7 +804,7 @@ static void __init prcm_setup_regs(void)
818 CM_AUTOIDLE); 804 CM_AUTOIDLE);
819 805
820 if (omap_rev() > OMAP3430_REV_ES1_0) { 806 if (omap_rev() > OMAP3430_REV_ES1_0) {
821 cm_write_mod_reg( 807 omap2_cm_write_mod_reg(
822 OMAP3430ES2_AUTO_USBHOST_MASK, 808 OMAP3430ES2_AUTO_USBHOST_MASK,
823 OMAP3430ES2_USBHOST_MOD, 809 OMAP3430ES2_USBHOST_MOD,
824 CM_AUTOIDLE); 810 CM_AUTOIDLE);
@@ -830,16 +816,16 @@ static void __init prcm_setup_regs(void)
830 * Set all plls to autoidle. This is needed until autoidle is 816 * Set all plls to autoidle. This is needed until autoidle is
831 * enabled by clockfw 817 * enabled by clockfw
832 */ 818 */
833 cm_write_mod_reg(1 << OMAP3430_AUTO_IVA2_DPLL_SHIFT, 819 omap2_cm_write_mod_reg(1 << OMAP3430_AUTO_IVA2_DPLL_SHIFT,
834 OMAP3430_IVA2_MOD, CM_AUTOIDLE2); 820 OMAP3430_IVA2_MOD, CM_AUTOIDLE2);
835 cm_write_mod_reg(1 << OMAP3430_AUTO_MPU_DPLL_SHIFT, 821 omap2_cm_write_mod_reg(1 << OMAP3430_AUTO_MPU_DPLL_SHIFT,
836 MPU_MOD, 822 MPU_MOD,
837 CM_AUTOIDLE2); 823 CM_AUTOIDLE2);
838 cm_write_mod_reg((1 << OMAP3430_AUTO_PERIPH_DPLL_SHIFT) | 824 omap2_cm_write_mod_reg((1 << OMAP3430_AUTO_PERIPH_DPLL_SHIFT) |
839 (1 << OMAP3430_AUTO_CORE_DPLL_SHIFT), 825 (1 << OMAP3430_AUTO_CORE_DPLL_SHIFT),
840 PLL_MOD, 826 PLL_MOD,
841 CM_AUTOIDLE); 827 CM_AUTOIDLE);
842 cm_write_mod_reg(1 << OMAP3430ES2_AUTO_PERIPH2_DPLL_SHIFT, 828 omap2_cm_write_mod_reg(1 << OMAP3430ES2_AUTO_PERIPH2_DPLL_SHIFT,
843 PLL_MOD, 829 PLL_MOD,
844 CM_AUTOIDLE2); 830 CM_AUTOIDLE2);
845 831
@@ -848,31 +834,31 @@ static void __init prcm_setup_regs(void)
848 * sys_clkreq. In the long run clock framework should 834 * sys_clkreq. In the long run clock framework should
849 * take care of this. 835 * take care of this.
850 */ 836 */
851 prm_rmw_mod_reg_bits(OMAP_AUTOEXTCLKMODE_MASK, 837 omap2_prm_rmw_mod_reg_bits(OMAP_AUTOEXTCLKMODE_MASK,
852 1 << OMAP_AUTOEXTCLKMODE_SHIFT, 838 1 << OMAP_AUTOEXTCLKMODE_SHIFT,
853 OMAP3430_GR_MOD, 839 OMAP3430_GR_MOD,
854 OMAP3_PRM_CLKSRC_CTRL_OFFSET); 840 OMAP3_PRM_CLKSRC_CTRL_OFFSET);
855 841
856 /* setup wakup source */ 842 /* setup wakup source */
857 prm_write_mod_reg(OMAP3430_EN_IO_MASK | OMAP3430_EN_GPIO1_MASK | 843 omap2_prm_write_mod_reg(OMAP3430_EN_IO_MASK | OMAP3430_EN_GPIO1_MASK |
858 OMAP3430_EN_GPT1_MASK | OMAP3430_EN_GPT12_MASK, 844 OMAP3430_EN_GPT1_MASK | OMAP3430_EN_GPT12_MASK,
859 WKUP_MOD, PM_WKEN); 845 WKUP_MOD, PM_WKEN);
860 /* No need to write EN_IO, that is always enabled */ 846 /* No need to write EN_IO, that is always enabled */
861 prm_write_mod_reg(OMAP3430_GRPSEL_GPIO1_MASK | 847 omap2_prm_write_mod_reg(OMAP3430_GRPSEL_GPIO1_MASK |
862 OMAP3430_GRPSEL_GPT1_MASK | 848 OMAP3430_GRPSEL_GPT1_MASK |
863 OMAP3430_GRPSEL_GPT12_MASK, 849 OMAP3430_GRPSEL_GPT12_MASK,
864 WKUP_MOD, OMAP3430_PM_MPUGRPSEL); 850 WKUP_MOD, OMAP3430_PM_MPUGRPSEL);
865 /* For some reason IO doesn't generate wakeup event even if 851 /* For some reason IO doesn't generate wakeup event even if
866 * it is selected to mpu wakeup goup */ 852 * it is selected to mpu wakeup goup */
867 prm_write_mod_reg(OMAP3430_IO_EN_MASK | OMAP3430_WKUP_EN_MASK, 853 omap2_prm_write_mod_reg(OMAP3430_IO_EN_MASK | OMAP3430_WKUP_EN_MASK,
868 OCP_MOD, OMAP3_PRM_IRQENABLE_MPU_OFFSET); 854 OCP_MOD, OMAP3_PRM_IRQENABLE_MPU_OFFSET);
869 855
870 /* Enable PM_WKEN to support DSS LPR */ 856 /* Enable PM_WKEN to support DSS LPR */
871 prm_write_mod_reg(OMAP3430_PM_WKEN_DSS_EN_DSS_MASK, 857 omap2_prm_write_mod_reg(OMAP3430_PM_WKEN_DSS_EN_DSS_MASK,
872 OMAP3430_DSS_MOD, PM_WKEN); 858 OMAP3430_DSS_MOD, PM_WKEN);
873 859
874 /* Enable wakeups in PER */ 860 /* Enable wakeups in PER */
875 prm_write_mod_reg(omap3630_en_uart4_mask | 861 omap2_prm_write_mod_reg(omap3630_en_uart4_mask |
876 OMAP3430_EN_GPIO2_MASK | OMAP3430_EN_GPIO3_MASK | 862 OMAP3430_EN_GPIO2_MASK | OMAP3430_EN_GPIO3_MASK |
877 OMAP3430_EN_GPIO4_MASK | OMAP3430_EN_GPIO5_MASK | 863 OMAP3430_EN_GPIO4_MASK | OMAP3430_EN_GPIO5_MASK |
878 OMAP3430_EN_GPIO6_MASK | OMAP3430_EN_UART3_MASK | 864 OMAP3430_EN_GPIO6_MASK | OMAP3430_EN_UART3_MASK |
@@ -880,7 +866,7 @@ static void __init prcm_setup_regs(void)
880 OMAP3430_EN_MCBSP4_MASK, 866 OMAP3430_EN_MCBSP4_MASK,
881 OMAP3430_PER_MOD, PM_WKEN); 867 OMAP3430_PER_MOD, PM_WKEN);
882 /* and allow them to wake up MPU */ 868 /* and allow them to wake up MPU */
883 prm_write_mod_reg(omap3630_grpsel_uart4_mask | 869 omap2_prm_write_mod_reg(omap3630_grpsel_uart4_mask |
884 OMAP3430_GRPSEL_GPIO2_MASK | 870 OMAP3430_GRPSEL_GPIO2_MASK |
885 OMAP3430_GRPSEL_GPIO3_MASK | 871 OMAP3430_GRPSEL_GPIO3_MASK |
886 OMAP3430_GRPSEL_GPIO4_MASK | 872 OMAP3430_GRPSEL_GPIO4_MASK |
@@ -893,22 +879,22 @@ static void __init prcm_setup_regs(void)
893 OMAP3430_PER_MOD, OMAP3430_PM_MPUGRPSEL); 879 OMAP3430_PER_MOD, OMAP3430_PM_MPUGRPSEL);
894 880
895 /* Don't attach IVA interrupts */ 881 /* Don't attach IVA interrupts */
896 prm_write_mod_reg(0, WKUP_MOD, OMAP3430_PM_IVAGRPSEL); 882 omap2_prm_write_mod_reg(0, WKUP_MOD, OMAP3430_PM_IVAGRPSEL);
897 prm_write_mod_reg(0, CORE_MOD, OMAP3430_PM_IVAGRPSEL1); 883 omap2_prm_write_mod_reg(0, CORE_MOD, OMAP3430_PM_IVAGRPSEL1);
898 prm_write_mod_reg(0, CORE_MOD, OMAP3430ES2_PM_IVAGRPSEL3); 884 omap2_prm_write_mod_reg(0, CORE_MOD, OMAP3430ES2_PM_IVAGRPSEL3);
899 prm_write_mod_reg(0, OMAP3430_PER_MOD, OMAP3430_PM_IVAGRPSEL); 885 omap2_prm_write_mod_reg(0, OMAP3430_PER_MOD, OMAP3430_PM_IVAGRPSEL);
900 886
901 /* Clear any pending 'reset' flags */ 887 /* Clear any pending 'reset' flags */
902 prm_write_mod_reg(0xffffffff, MPU_MOD, OMAP2_RM_RSTST); 888 omap2_prm_write_mod_reg(0xffffffff, MPU_MOD, OMAP2_RM_RSTST);
903 prm_write_mod_reg(0xffffffff, CORE_MOD, OMAP2_RM_RSTST); 889 omap2_prm_write_mod_reg(0xffffffff, CORE_MOD, OMAP2_RM_RSTST);
904 prm_write_mod_reg(0xffffffff, OMAP3430_PER_MOD, OMAP2_RM_RSTST); 890 omap2_prm_write_mod_reg(0xffffffff, OMAP3430_PER_MOD, OMAP2_RM_RSTST);
905 prm_write_mod_reg(0xffffffff, OMAP3430_EMU_MOD, OMAP2_RM_RSTST); 891 omap2_prm_write_mod_reg(0xffffffff, OMAP3430_EMU_MOD, OMAP2_RM_RSTST);
906 prm_write_mod_reg(0xffffffff, OMAP3430_NEON_MOD, OMAP2_RM_RSTST); 892 omap2_prm_write_mod_reg(0xffffffff, OMAP3430_NEON_MOD, OMAP2_RM_RSTST);
907 prm_write_mod_reg(0xffffffff, OMAP3430_DSS_MOD, OMAP2_RM_RSTST); 893 omap2_prm_write_mod_reg(0xffffffff, OMAP3430_DSS_MOD, OMAP2_RM_RSTST);
908 prm_write_mod_reg(0xffffffff, OMAP3430ES2_USBHOST_MOD, OMAP2_RM_RSTST); 894 omap2_prm_write_mod_reg(0xffffffff, OMAP3430ES2_USBHOST_MOD, OMAP2_RM_RSTST);
909 895
910 /* Clear any pending PRCM interrupts */ 896 /* Clear any pending PRCM interrupts */
911 prm_write_mod_reg(0, OCP_MOD, OMAP3_PRM_IRQSTATUS_MPU_OFFSET); 897 omap2_prm_write_mod_reg(0, OCP_MOD, OMAP3_PRM_IRQSTATUS_MPU_OFFSET);
912 898
913 omap3_iva_idle(); 899 omap3_iva_idle();
914 omap3_d2d_idle(); 900 omap3_d2d_idle();
@@ -925,12 +911,29 @@ void omap3_pm_off_mode_enable(int enable)
925 state = PWRDM_POWER_RET; 911 state = PWRDM_POWER_RET;
926 912
927#ifdef CONFIG_CPU_IDLE 913#ifdef CONFIG_CPU_IDLE
928 omap3_cpuidle_update_states(); 914 /*
915 * Erratum i583: implementation for ES rev < Es1.2 on 3630. We cannot
916 * enable OFF mode in a stable form for previous revisions, restrict
917 * instead to RET
918 */
919 if (IS_PM34XX_ERRATUM(PM_SDRC_WAKEUP_ERRATUM_i583))
920 omap3_cpuidle_update_states(state, PWRDM_POWER_RET);
921 else
922 omap3_cpuidle_update_states(state, state);
929#endif 923#endif
930 924
931 list_for_each_entry(pwrst, &pwrst_list, node) { 925 list_for_each_entry(pwrst, &pwrst_list, node) {
932 pwrst->next_state = state; 926 if (IS_PM34XX_ERRATUM(PM_SDRC_WAKEUP_ERRATUM_i583) &&
933 omap_set_pwrdm_state(pwrst->pwrdm, state); 927 pwrst->pwrdm == core_pwrdm &&
928 state == PWRDM_POWER_OFF) {
929 pwrst->next_state = PWRDM_POWER_RET;
930 WARN_ONCE(1,
931 "%s: Core OFF disabled due to errata i583\n",
932 __func__);
933 } else {
934 pwrst->next_state = state;
935 }
936 omap_set_pwrdm_state(pwrst->pwrdm, pwrst->next_state);
934 } 937 }
935} 938}
936 939
@@ -1002,6 +1005,17 @@ void omap_push_sram_idle(void)
1002 save_secure_ram_context_sz); 1005 save_secure_ram_context_sz);
1003} 1006}
1004 1007
1008static void __init pm_errata_configure(void)
1009{
1010 if (cpu_is_omap3630()) {
1011 pm34xx_errata |= PM_RTA_ERRATUM_i608;
1012 /* Enable the l2 cache toggling in sleep logic */
1013 enable_omap3630_toggle_l2_on_restore();
1014 if (omap_rev() < OMAP3630_REV_ES1_2)
1015 pm34xx_errata |= PM_SDRC_WAKEUP_ERRATUM_i583;
1016 }
1017}
1018
1005static int __init omap3_pm_init(void) 1019static int __init omap3_pm_init(void)
1006{ 1020{
1007 struct power_state *pwrst, *tmp; 1021 struct power_state *pwrst, *tmp;
@@ -1011,6 +1025,8 @@ static int __init omap3_pm_init(void)
1011 if (!cpu_is_omap34xx()) 1025 if (!cpu_is_omap34xx())
1012 return -ENODEV; 1026 return -ENODEV;
1013 1027
1028 pm_errata_configure();
1029
1014 printk(KERN_ERR "Power Management for TI OMAP3.\n"); 1030 printk(KERN_ERR "Power Management for TI OMAP3.\n");
1015 1031
1016 /* XXX prcm_setup_regs needs to be before enabling hw 1032 /* XXX prcm_setup_regs needs to be before enabling hw
@@ -1058,6 +1074,14 @@ static int __init omap3_pm_init(void)
1058 pm_idle = omap3_pm_idle; 1074 pm_idle = omap3_pm_idle;
1059 omap3_idle_init(); 1075 omap3_idle_init();
1060 1076
1077 /*
1078 * RTA is disabled during initialization as per erratum i608
1079 * it is safer to disable RTA by the bootloader, but we would like
1080 * to be doubly sure here and prevent any mishaps.
1081 */
1082 if (IS_PM34XX_ERRATUM(PM_RTA_ERRATUM_i608))
1083 omap3630_ctrl_disable_rta();
1084
1061 clkdm_add_wkdep(neon_clkdm, mpu_clkdm); 1085 clkdm_add_wkdep(neon_clkdm, mpu_clkdm);
1062 if (omap_type() != OMAP2_DEVICE_TYPE_GP) { 1086 if (omap_type() != OMAP2_DEVICE_TYPE_GP) {
1063 omap3_secure_ram_storage = 1087 omap3_secure_ram_storage =