First Support on Ginger and OMAP TI
[linux-ginger.git] / arch / arm / mach-omap2 / pm34xx.c
blobe052e4dfa779296b43a599c11425aae820d3d957
1 /*
2 * OMAP3 Power Management Routines
4 * Copyright (C) 2006-2008 Nokia Corporation
5 * Tony Lindgren <tony@atomide.com>
6 * Jouni Hogander
8 * Copyright (C) 2007 Texas Instruments, Inc.
9 * Rajendra Nayak <rnayak@ti.com>
11 * Copyright (C) 2005 Texas Instruments, Inc.
12 * Richard Woodruff <r-woodruff2@ti.com>
14 * Based on pm.c for omap1
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.
21 #include <linux/pm.h>
22 #include <linux/suspend.h>
23 #include <linux/interrupt.h>
24 #include <linux/module.h>
25 #include <linux/list.h>
26 #include <linux/err.h>
27 #include <linux/gpio.h>
28 #include <linux/clk.h>
29 #include <linux/delay.h>
30 #include <linux/usb/musb.h>
32 #include <plat/cpu.h>
33 #include <plat/sram.h>
34 #include <plat/clockdomain.h>
35 #include <plat/powerdomain.h>
36 #include <plat/control.h>
37 #include <plat/serial.h>
38 #include <plat/sdrc.h>
39 #include <plat/prcm.h>
40 #include <plat/gpmc.h>
41 #include <plat/dma.h>
42 #include <plat/dmtimer.h>
44 #include <plat/resource.h>
46 #include <asm/tlbflush.h>
48 #include "cm.h"
49 #include "cm-regbits-34xx.h"
50 #include "prm-regbits-34xx.h"
52 #include "smartreflex.h"
53 #include "prm.h"
54 #include "pm.h"
55 #include "sdrc.h"
57 static int regset_save_on_suspend;
59 /* Scratchpad offsets */
60 #define OMAP343X_TABLE_ADDRESS_OFFSET 0x31
61 #define OMAP343X_TABLE_VALUE_OFFSET 0x30
62 #define OMAP343X_CONTROL_REG_VALUE_OFFSET 0x32
64 u32 enable_off_mode;
65 u32 sleep_while_idle;
66 u32 wakeup_timer_seconds;
67 u32 voltage_off_while_idle;
69 struct power_state {
70 struct powerdomain *pwrdm;
71 u32 next_state;
72 #ifdef CONFIG_SUSPEND
73 u32 saved_state;
74 #endif
75 struct list_head node;
78 static LIST_HEAD(pwrst_list);
80 static void (*_omap_sram_idle)(u32 *addr, int save_state);
82 static int (*_omap_save_secure_sram)(u32 *addr);
84 static struct powerdomain *mpu_pwrdm, *neon_pwrdm;
85 static struct powerdomain *core_pwrdm, *per_pwrdm;
86 static struct powerdomain *cam_pwrdm;
88 static struct prm_setup_vc prm_setup = {
89 .clksetup = 0xff,
90 .voltsetup_time1 = 0xfff,
91 .voltsetup_time2 = 0xfff,
92 .voltoffset = 0xff,
93 .voltsetup2 = 0xff,
94 .vdd0_on = 0x30, /* 1.2v */
95 .vdd0_onlp = 0x20, /* 1.0v */
96 .vdd0_ret = 0x1e, /* 0.975v */
97 .vdd0_off = 0x00, /* 0.6v */
98 .vdd1_on = 0x2c, /* 1.15v */
99 .vdd1_onlp = 0x20, /* 1.0v */
100 .vdd1_ret = 0x1e, /* .975v */
101 .vdd1_off = 0x00, /* 0.6v */
104 static inline void omap3_per_save_context(void)
106 omap_gpio_save_context();
109 static inline void omap3_per_restore_context(void)
111 omap_gpio_restore_context();
114 static void omap3_enable_io_chain(void)
116 int timeout = 0;
118 if (omap_rev_ge_3_1()) {
119 prm_set_mod_reg_bits(OMAP3430_EN_IO_CHAIN, WKUP_MOD, PM_WKEN);
120 /* Do a readback to assure write has been done */
121 prm_read_mod_reg(WKUP_MOD, PM_WKEN);
123 while (!(prm_read_mod_reg(WKUP_MOD, PM_WKST) &
124 OMAP3430_ST_IO_CHAIN)) {
125 timeout++;
126 if (timeout > 1000) {
127 printk(KERN_ERR "Wake up daisy chain "
128 "activation failed.\n");
129 return;
131 prm_set_mod_reg_bits(OMAP3430_ST_IO_CHAIN,
132 WKUP_MOD, PM_WKST);
137 static void omap3_disable_io_chain(void)
139 if (omap_rev_ge_3_1())
140 prm_clear_mod_reg_bits(OMAP3430_EN_IO_CHAIN, WKUP_MOD, PM_WKEN);
143 static void omap3_core_save_context(void)
145 u32 control_padconf_off;
147 /* Save the padconf registers */
148 control_padconf_off = omap_ctrl_readl(OMAP343X_CONTROL_PADCONF_OFF);
149 control_padconf_off |= START_PADCONF_SAVE;
150 omap_ctrl_writel(control_padconf_off, OMAP343X_CONTROL_PADCONF_OFF);
151 /* wait for the save to complete */
152 while (!(omap_ctrl_readl(OMAP343X_CONTROL_GENERAL_PURPOSE_STATUS)
153 & PADCONF_SAVE_DONE))
154 udelay(1);
157 * Force write last pad into memory, as this can fail in some
158 * cases according to erratas 1.157, 1.185
160 omap_ctrl_writel(omap_ctrl_readl(OMAP343X_PADCONF_ETK_D14),
161 OMAP343X_CONTROL_MEM_WKUP + 0x2a0);
163 /* Save the Interrupt controller context */
164 omap_intc_save_context();
165 /* Save the GPMC context */
166 omap3_gpmc_save_context();
167 /* Save the system control module context, padconf already save above*/
168 omap3_control_save_context();
169 omap_dma_global_context_save();
172 static void omap3_core_restore_context(void)
174 /* Restore the control module context, padconf restored by h/w */
175 omap3_control_restore_context();
176 /* Restore the GPMC context */
177 omap3_gpmc_restore_context();
178 /* Restore the interrupt controller context */
179 omap_intc_restore_context();
180 omap_dma_global_context_restore();
184 * FIXME: This function should be called before entering off-mode after
185 * OMAP3 secure services have been accessed. Currently it is only called
186 * once during boot sequence, but this works as we are not using secure
187 * services.
189 static void omap3_save_secure_ram_context(u32 target_mpu_state)
191 u32 ret;
193 if (omap_type() != OMAP2_DEVICE_TYPE_GP) {
195 * MPU next state must be set to POWER_ON temporarily,
196 * otherwise the WFI executed inside the ROM code
197 * will hang the system.
199 pwrdm_set_next_pwrst(mpu_pwrdm, PWRDM_POWER_ON);
200 ret = _omap_save_secure_sram((u32 *)
201 __pa(omap3_secure_ram_storage));
202 pwrdm_set_next_pwrst(mpu_pwrdm, target_mpu_state);
203 /* Following is for error tracking, it should not happen */
204 if (ret) {
205 printk(KERN_ERR "save_secure_sram() returns %08x\n",
206 ret);
207 while (1)
214 * PRCM Interrupt Handler Helper Function
216 * The purpose of this function is to clear any wake-up events latched
217 * in the PRCM PM_WKST_x registers. It is possible that a wake-up event
218 * may occur whilst attempting to clear a PM_WKST_x register and thus
219 * set another bit in this register. A while loop is used to ensure
220 * that any peripheral wake-up events occurring while attempting to
221 * clear the PM_WKST_x are detected and cleared.
223 static int prcm_clear_mod_irqs(s16 module, u8 regs)
225 u32 wkst, fclk, iclk, clken;
226 u16 wkst_off = (regs == 3) ? OMAP3430ES2_PM_WKST3 : PM_WKST1;
227 u16 fclk_off = (regs == 3) ? OMAP3430ES2_CM_FCLKEN3 : CM_FCLKEN1;
228 u16 iclk_off = (regs == 3) ? CM_ICLKEN3 : CM_ICLKEN1;
229 u16 grpsel_off = (regs == 3) ?
230 OMAP3430ES2_PM_MPUGRPSEL3 : OMAP3430_PM_MPUGRPSEL;
231 int c = 0;
233 wkst = prm_read_mod_reg(module, wkst_off);
234 wkst &= prm_read_mod_reg(module, grpsel_off);
235 if (wkst) {
236 iclk = cm_read_mod_reg(module, iclk_off);
237 fclk = cm_read_mod_reg(module, fclk_off);
238 while (wkst) {
239 clken = wkst;
240 cm_set_mod_reg_bits(clken, module, iclk_off);
242 * For USBHOST, we don't know whether HOST1 or
243 * HOST2 woke us up, so enable both f-clocks
245 if (module == OMAP3430ES2_USBHOST_MOD)
246 clken |= 1 << OMAP3430ES2_EN_USBHOST2_SHIFT;
247 cm_set_mod_reg_bits(clken, module, fclk_off);
248 prm_write_mod_reg(wkst, module, wkst_off);
249 wkst = prm_read_mod_reg(module, wkst_off);
250 c++;
252 cm_write_mod_reg(iclk, module, iclk_off);
253 cm_write_mod_reg(fclk, module, fclk_off);
256 return c;
259 static int _prcm_int_handle_wakeup(void)
261 int c;
263 c = prcm_clear_mod_irqs(WKUP_MOD, 1);
264 c += prcm_clear_mod_irqs(CORE_MOD, 1);
265 c += prcm_clear_mod_irqs(OMAP3430_PER_MOD, 1);
266 if (omap_rev_gt_1_0() || cpu_is_omap3505() || cpu_is_omap3517()) {
267 c += prcm_clear_mod_irqs(CORE_MOD, 3);
268 c += prcm_clear_mod_irqs(OMAP3430ES2_USBHOST_MOD, 1);
271 return c;
275 * PRCM Interrupt Handler
277 * The PRM_IRQSTATUS_MPU register indicates if there are any pending
278 * interrupts from the PRCM for the MPU. These bits must be cleared in
279 * order to clear the PRCM interrupt. The PRCM interrupt handler is
280 * implemented to simply clear the PRM_IRQSTATUS_MPU in order to clear
281 * the PRCM interrupt. Please note that bit 0 of the PRM_IRQSTATUS_MPU
282 * register indicates that a wake-up event is pending for the MPU and
283 * this bit can only be cleared if the all the wake-up events latched
284 * in the various PM_WKST_x registers have been cleared. The interrupt
285 * handler is implemented using a do-while loop so that if a wake-up
286 * event occurred during the processing of the prcm interrupt handler
287 * (setting a bit in the corresponding PM_WKST_x register and thus
288 * preventing us from clearing bit 0 of the PRM_IRQSTATUS_MPU register)
289 * this would be handled.
291 static irqreturn_t prcm_interrupt_handler (int irq, void *dev_id)
293 u32 irqstatus_mpu;
294 int c = 0;
296 do {
297 irqstatus_mpu = prm_read_mod_reg(OCP_MOD,
298 OMAP3_PRM_IRQSTATUS_MPU_OFFSET);
300 if (irqstatus_mpu & (OMAP3430_WKUP_ST | OMAP3430_IO_ST)) {
301 c = _prcm_int_handle_wakeup();
304 * Is the MPU PRCM interrupt handler racing with the
305 * IVA2 PRCM interrupt handler ?
307 WARN(c == 0, "prcm: WARNING: PRCM indicated MPU wakeup "
308 "but no wakeup sources are marked\n");
309 } else {
310 /* XXX we need to expand our PRCM interrupt handler */
311 WARN(1, "prcm: WARNING: PRCM interrupt received, but "
312 "no code to handle it (%08x)\n", irqstatus_mpu);
315 prm_write_mod_reg(irqstatus_mpu, OCP_MOD,
316 OMAP3_PRM_IRQSTATUS_MPU_OFFSET);
318 } while (prm_read_mod_reg(OCP_MOD, OMAP3_PRM_IRQSTATUS_MPU_OFFSET));
320 return IRQ_HANDLED;
323 static void restore_control_register(u32 val)
325 __asm__ __volatile__ ("mcr p15, 0, %0, c1, c0, 0" : : "r" (val));
328 /* Function to restore the table entry that was modified for enabling MMU */
329 static void restore_table_entry(void)
331 u32 *scratchpad_address;
332 u32 previous_value, control_reg_value;
333 u32 *address;
335 scratchpad_address = OMAP2_L4_IO_ADDRESS(OMAP343X_SCRATCHPAD);
337 /* Get address of entry that was modified */
338 address = (u32 *)__raw_readl(scratchpad_address +
339 OMAP343X_TABLE_ADDRESS_OFFSET);
340 /* Get the previous value which needs to be restored */
341 previous_value = __raw_readl(scratchpad_address +
342 OMAP343X_TABLE_VALUE_OFFSET);
343 address = __va(address);
344 *address = previous_value;
345 flush_tlb_all();
346 control_reg_value = __raw_readl(scratchpad_address
347 + OMAP343X_CONTROL_REG_VALUE_OFFSET);
348 /* This will enable caches and prediction */
349 restore_control_register(control_reg_value);
352 void omap_sram_idle(void)
354 /* Variable to tell what needs to be saved and restored
355 * in omap_sram_idle*/
356 /* save_state = 0 => Nothing to save and restored */
357 /* save_state = 1 => Only L1 and logic lost */
358 /* save_state = 2 => Only L2 lost */
359 /* save_state = 3 => L1, L2 and logic lost */
360 int save_state = 0;
361 int mpu_next_state = PWRDM_POWER_ON;
362 int per_next_state = PWRDM_POWER_ON;
363 int core_next_state = PWRDM_POWER_ON;
364 int core_prev_state, per_prev_state;
365 u32 sdrc_pwr = 0;
366 int per_state_modified = 0;
368 if (!_omap_sram_idle)
369 return;
371 pwrdm_clear_all_prev_pwrst(mpu_pwrdm);
372 pwrdm_clear_all_prev_pwrst(neon_pwrdm);
373 pwrdm_clear_all_prev_pwrst(core_pwrdm);
374 pwrdm_clear_all_prev_pwrst(per_pwrdm);
376 mpu_next_state = pwrdm_read_next_pwrst(mpu_pwrdm);
377 switch (mpu_next_state) {
378 case PWRDM_POWER_ON:
379 case PWRDM_POWER_RET:
380 /* No need to save context */
381 save_state = 0;
382 break;
383 case PWRDM_POWER_OFF:
384 save_state = 3;
385 break;
386 default:
387 /* Invalid state */
388 printk(KERN_ERR "Invalid mpu state in sram_idle\n");
389 return;
392 pwrdm_pre_transition();
394 /* NEON control */
395 if (pwrdm_read_pwrst(neon_pwrdm) == PWRDM_POWER_ON)
396 pwrdm_set_next_pwrst(neon_pwrdm, mpu_next_state);
398 /* PER */
399 per_next_state = pwrdm_read_next_pwrst(per_pwrdm);
400 core_next_state = pwrdm_read_next_pwrst(core_pwrdm);
401 if (per_next_state < PWRDM_POWER_ON) {
402 omap_uart_prepare_idle(2);
403 omap2_gpio_prepare_for_idle(per_next_state);
404 if (per_next_state == PWRDM_POWER_OFF) {
405 if (core_next_state == PWRDM_POWER_ON) {
406 per_next_state = PWRDM_POWER_RET;
407 pwrdm_set_next_pwrst(per_pwrdm, per_next_state);
408 per_state_modified = 1;
409 } else
410 omap3_per_save_context();
414 if (pwrdm_read_pwrst(cam_pwrdm) == PWRDM_POWER_ON)
415 omap2_clkdm_deny_idle(mpu_pwrdm->pwrdm_clkdms[0]);
418 * Disable smartreflex before entering WFI.
419 * Only needed if we are going to enter retention or off.
421 if (mpu_next_state <= PWRDM_POWER_RET)
422 disable_smartreflex(SR1);
423 if (core_next_state <= PWRDM_POWER_RET)
424 disable_smartreflex(SR2);
426 /* CORE */
427 if (core_next_state < PWRDM_POWER_ON) {
428 omap_uart_prepare_idle(0);
429 omap_uart_prepare_idle(1);
430 if (core_next_state == PWRDM_POWER_OFF) {
431 prm_set_mod_reg_bits(OMAP3430_AUTO_OFF,
432 OMAP3430_GR_MOD,
433 OMAP3_PRM_VOLTCTRL_OFFSET);
434 #ifndef CONFIG_USB_MUSB_HDRC_MODULE
435 /* Save the MUSB context */
436 musb_save_context();
437 #endif
438 omap3_core_save_context();
439 omap3_prcm_save_context();
440 } else if (core_next_state == PWRDM_POWER_RET) {
441 prm_set_mod_reg_bits(OMAP3430_AUTO_RET,
442 OMAP3430_GR_MOD,
443 OMAP3_PRM_VOLTCTRL_OFFSET);
445 /* Enable IO-PAD and IO-CHAIN wakeups */
446 prm_set_mod_reg_bits(OMAP3430_EN_IO, WKUP_MOD, PM_WKEN);
447 omap3_enable_io_chain();
449 omap3_intc_prepare_idle();
452 * On EMU/HS devices ROM code restores a SRDC value
453 * from scratchpad which has automatic self refresh on timeout
454 * of AUTO_CNT = 1 enabled. This takes care of errata 1.142.
455 * Hence store/restore the SDRC_POWER register here.
457 if (omap_rev_ge_3_0() &&
458 omap_type() != OMAP2_DEVICE_TYPE_GP &&
459 core_next_state == PWRDM_POWER_OFF)
460 sdrc_pwr = sdrc_read_reg(SDRC_POWER);
462 if (regset_save_on_suspend)
463 pm_dbg_regset_save(1);
466 * omap3_arm_context is the location where ARM registers
467 * get saved. The restore path then reads from this
468 * location and restores them back.
470 _omap_sram_idle(omap3_arm_context, save_state);
471 cpu_init();
473 if (regset_save_on_suspend)
474 pm_dbg_regset_save(2);
476 /* Restore normal SDRC POWER settings */
477 if (omap_rev_ge_3_0() &&
478 omap_type() != OMAP2_DEVICE_TYPE_GP &&
479 core_next_state == PWRDM_POWER_OFF)
480 sdrc_write_reg(sdrc_pwr, SDRC_POWER);
482 /* Restore table entry modified during MMU restoration */
483 if (pwrdm_read_prev_pwrst(mpu_pwrdm) == PWRDM_POWER_OFF)
484 restore_table_entry();
486 /* CORE */
487 if (core_next_state < PWRDM_POWER_ON) {
488 core_prev_state = pwrdm_read_prev_pwrst(core_pwrdm);
489 if (core_prev_state == PWRDM_POWER_OFF) {
490 omap3_core_restore_context();
491 omap3_prcm_restore_context();
492 omap3_sram_restore_context();
493 omap2_sms_restore_context();
494 #ifndef CONFIG_USB_MUSB_HDRC_MODULE
495 /* Restore the MUSB context */
496 musb_restore_context();
497 #endif
499 omap_uart_resume_idle(0);
500 omap_uart_resume_idle(1);
501 if (core_next_state == PWRDM_POWER_OFF)
502 prm_clear_mod_reg_bits(OMAP3430_AUTO_OFF,
503 OMAP3430_GR_MOD,
504 OMAP3_PRM_VOLTCTRL_OFFSET);
505 else if (core_next_state == PWRDM_POWER_RET)
506 prm_clear_mod_reg_bits(OMAP3430_AUTO_RET,
507 OMAP3430_GR_MOD,
508 OMAP3_PRM_VOLTCTRL_OFFSET);
510 omap3_intc_resume_idle();
513 * Enable smartreflex after WFI. Only needed if we entered
514 * retention or off
516 if (mpu_next_state <= PWRDM_POWER_RET)
517 enable_smartreflex(SR1);
518 if (core_next_state <= PWRDM_POWER_RET)
519 enable_smartreflex(SR2);
521 /* PER */
522 if (per_next_state < PWRDM_POWER_ON) {
523 if (per_next_state == PWRDM_POWER_OFF) {
525 * Reading the prev-state takes long time (11us@OPP2),
526 * only do it, if we really tried to put PER in OFF
528 per_prev_state = pwrdm_read_prev_pwrst(per_pwrdm);
529 if (per_prev_state == PWRDM_POWER_OFF) {
530 omap3_per_restore_context();
531 omap3_gpio_restore_pad_context(0);
532 } else if (per_next_state == PWRDM_POWER_OFF) {
533 omap3_gpio_restore_pad_context(1);
536 omap2_gpio_resume_after_idle();
537 omap_uart_resume_idle(2);
538 if (per_state_modified)
539 pwrdm_set_next_pwrst(per_pwrdm, PWRDM_POWER_OFF);
542 /* Disable IO-PAD and IO-CHAIN wakeup */
543 if (core_next_state < PWRDM_POWER_ON) {
544 prm_clear_mod_reg_bits(OMAP3430_EN_IO, WKUP_MOD, PM_WKEN);
545 omap3_disable_io_chain();
549 pwrdm_post_transition();
551 omap2_clkdm_allow_idle(mpu_pwrdm->pwrdm_clkdms[0]);
554 int omap3_can_sleep(void)
556 if (cpu_is_omap3505() || cpu_is_omap3517())
557 return 0;
558 if (!sleep_while_idle)
559 return 0;
560 if (!omap_uart_can_sleep())
561 return 0;
562 return 1;
565 /* This sets pwrdm state (other than mpu & core. Currently only ON &
566 * RET are supported. Function is assuming that clkdm doesn't have
567 * hw_sup mode enabled. */
568 int set_pwrdm_state(struct powerdomain *pwrdm, u32 state)
570 u32 cur_state;
571 int sleep_switch = 0;
572 int ret = 0;
574 if (pwrdm == NULL || IS_ERR(pwrdm))
575 return -EINVAL;
577 while (!(pwrdm->pwrsts & (1 << state))) {
578 if (state == PWRDM_POWER_OFF)
579 return ret;
580 state--;
583 cur_state = pwrdm_read_next_pwrst(pwrdm);
584 if (cur_state == state)
585 return ret;
587 if (pwrdm_read_pwrst(pwrdm) < PWRDM_POWER_ON) {
588 omap2_clkdm_wakeup(pwrdm->pwrdm_clkdms[0]);
589 sleep_switch = 1;
590 pwrdm_wait_transition(pwrdm);
593 ret = pwrdm_set_next_pwrst(pwrdm, state);
594 if (ret) {
595 printk(KERN_ERR "Unable to set state of powerdomain: %s\n",
596 pwrdm->name);
597 goto err;
600 if (sleep_switch) {
601 omap2_clkdm_allow_idle(pwrdm->pwrdm_clkdms[0]);
602 pwrdm_wait_transition(pwrdm);
603 pwrdm_state_switch(pwrdm);
606 err:
607 return ret;
610 static void omap3_pm_idle(void)
612 local_irq_disable();
613 local_fiq_disable();
615 if (!omap3_can_sleep())
616 goto out;
618 if (omap_irq_pending() || need_resched())
619 goto out;
621 omap_sram_idle();
623 out:
624 local_fiq_enable();
625 local_irq_enable();
628 #ifdef CONFIG_SUSPEND
629 static suspend_state_t suspend_state;
631 static void omap2_pm_wakeup_on_timer(u32 seconds)
633 u32 tick_rate, cycles;
635 if (!seconds)
636 return;
638 tick_rate = clk_get_rate(omap_dm_timer_get_fclk(gptimer_wakeup));
639 cycles = tick_rate * seconds;
640 omap_dm_timer_stop(gptimer_wakeup);
641 omap_dm_timer_set_load_start(gptimer_wakeup, 0, 0xffffffff - cycles);
643 pr_info("PM: Resume timer in %d secs (%d ticks at %d ticks/sec.)\n",
644 seconds, cycles, tick_rate);
647 static int omap3_pm_prepare(void)
649 disable_hlt();
650 return 0;
653 static int omap3_pm_suspend(void)
655 struct power_state *pwrst;
656 int state, ret = 0;
658 if (wakeup_timer_seconds)
659 omap2_pm_wakeup_on_timer(wakeup_timer_seconds);
661 /* Read current next_pwrsts */
662 list_for_each_entry(pwrst, &pwrst_list, node)
663 pwrst->saved_state = pwrdm_read_next_pwrst(pwrst->pwrdm);
664 /* Set ones wanted by suspend */
665 list_for_each_entry(pwrst, &pwrst_list, node) {
666 if (set_pwrdm_state(pwrst->pwrdm, pwrst->next_state))
667 goto restore;
668 if (pwrdm_clear_all_prev_pwrst(pwrst->pwrdm))
669 goto restore;
672 omap_uart_prepare_suspend();
673 omap3_intc_suspend();
675 regset_save_on_suspend = 1;
676 omap_sram_idle();
677 regset_save_on_suspend = 0;
679 restore:
680 /* Restore next_pwrsts */
681 list_for_each_entry(pwrst, &pwrst_list, node) {
682 state = pwrdm_read_prev_pwrst(pwrst->pwrdm);
683 if (state > pwrst->next_state) {
684 printk(KERN_INFO "Powerdomain (%s) didn't enter "
685 "target state %d\n",
686 pwrst->pwrdm->name, pwrst->next_state);
687 ret = -1;
689 set_pwrdm_state(pwrst->pwrdm, pwrst->saved_state);
691 if (ret)
692 printk(KERN_ERR "Could not enter target state in pm_suspend\n");
693 else
694 printk(KERN_INFO "Successfully put all powerdomains "
695 "to target state\n");
697 return ret;
700 static int omap3_pm_enter(suspend_state_t unused)
702 int ret = 0;
704 switch (suspend_state) {
705 case PM_SUSPEND_STANDBY:
706 case PM_SUSPEND_MEM:
707 ret = omap3_pm_suspend();
708 break;
709 default:
710 ret = -EINVAL;
713 return ret;
716 static void omap3_pm_finish(void)
718 enable_hlt();
721 /* Hooks to enable / disable UART interrupts during suspend */
722 static int omap3_pm_begin(suspend_state_t state)
724 suspend_state = state;
725 omap_uart_enable_irqs(0);
726 return 0;
729 static void omap3_pm_end(void)
731 suspend_state = PM_SUSPEND_ON;
732 omap_uart_enable_irqs(1);
733 return;
736 static struct platform_suspend_ops omap_pm_ops = {
737 .begin = omap3_pm_begin,
738 .end = omap3_pm_end,
739 .prepare = omap3_pm_prepare,
740 .enter = omap3_pm_enter,
741 .finish = omap3_pm_finish,
742 .valid = suspend_valid_only_mem,
744 #endif /* CONFIG_SUSPEND */
748 * omap3_iva_idle(): ensure IVA is in idle so it can be put into
749 * retention
751 * In cases where IVA2 is activated by bootcode, it may prevent
752 * full-chip retention or off-mode because it is not idle. This
753 * function forces the IVA2 into idle state so it can go
754 * into retention/off and thus allow full-chip retention/off.
757 static void __init omap3_iva_idle(void)
759 /* ensure IVA2 clock is disabled */
760 cm_write_mod_reg(0, OMAP3430_IVA2_MOD, CM_FCLKEN);
762 /* if no clock activity, nothing else to do */
763 if (!(cm_read_mod_reg(OMAP3430_IVA2_MOD, OMAP3430_CM_CLKSTST) &
764 OMAP3430_CLKACTIVITY_IVA2_MASK))
765 return;
767 /* Reset IVA2 */
768 prm_write_mod_reg(OMAP3430_RST1_IVA2 |
769 OMAP3430_RST2_IVA2 |
770 OMAP3430_RST3_IVA2,
771 OMAP3430_IVA2_MOD, RM_RSTCTRL);
773 /* Enable IVA2 clock */
774 cm_write_mod_reg(OMAP3430_CM_FCLKEN_IVA2_EN_IVA2,
775 OMAP3430_IVA2_MOD, CM_FCLKEN);
777 /* Set IVA2 boot mode to 'idle' */
778 omap_ctrl_writel(OMAP3_IVA2_BOOTMOD_IDLE,
779 OMAP343X_CONTROL_IVA2_BOOTMOD);
781 /* Un-reset IVA2 */
782 prm_write_mod_reg(0, OMAP3430_IVA2_MOD, RM_RSTCTRL);
784 /* Disable IVA2 clock */
785 cm_write_mod_reg(0, OMAP3430_IVA2_MOD, CM_FCLKEN);
787 /* Reset IVA2 */
788 prm_write_mod_reg(OMAP3430_RST1_IVA2 |
789 OMAP3430_RST2_IVA2 |
790 OMAP3430_RST3_IVA2,
791 OMAP3430_IVA2_MOD, RM_RSTCTRL);
794 static void __init omap3_d2d_idle(void)
796 u16 mask, padconf;
798 /* In a stand alone OMAP3430 where there is not a stacked
799 * modem for the D2D Idle Ack and D2D MStandby must be pulled
800 * high. S CONTROL_PADCONF_SAD2D_IDLEACK and
801 * CONTROL_PADCONF_SAD2D_MSTDBY to have a pull up. */
802 mask = (1 << 4) | (1 << 3); /* pull-up, enabled */
803 padconf = omap_ctrl_readw(OMAP3_PADCONF_SAD2D_MSTANDBY);
804 padconf |= mask;
805 omap_ctrl_writew(padconf, OMAP3_PADCONF_SAD2D_MSTANDBY);
807 padconf = omap_ctrl_readw(OMAP3_PADCONF_SAD2D_IDLEACK);
808 padconf |= mask;
809 omap_ctrl_writew(padconf, OMAP3_PADCONF_SAD2D_IDLEACK);
811 /* reset modem */
812 prm_write_mod_reg(OMAP3430_RM_RSTCTRL_CORE_MODEM_SW_RSTPWRON |
813 OMAP3430_RM_RSTCTRL_CORE_MODEM_SW_RST,
814 CORE_MOD, RM_RSTCTRL);
815 prm_write_mod_reg(0, CORE_MOD, RM_RSTCTRL);
818 static void __init prcm_setup_regs(void)
820 /* XXX Reset all wkdeps. This should be done when initializing
821 * powerdomains */
822 prm_write_mod_reg(0, OMAP3430_IVA2_MOD, PM_WKDEP);
823 prm_write_mod_reg(0, MPU_MOD, PM_WKDEP);
824 prm_write_mod_reg(0, OMAP3430_DSS_MOD, PM_WKDEP);
825 prm_write_mod_reg(0, OMAP3430_NEON_MOD, PM_WKDEP);
826 prm_write_mod_reg(0, OMAP3430_CAM_MOD, PM_WKDEP);
827 prm_write_mod_reg(0, OMAP3430_PER_MOD, PM_WKDEP);
828 if (omap_rev_gt_1_0() || cpu_is_omap3505() || cpu_is_omap3517()) {
829 prm_write_mod_reg(0, OMAP3430ES2_SGX_MOD, PM_WKDEP);
830 prm_write_mod_reg(0, OMAP3430ES2_USBHOST_MOD, PM_WKDEP);
831 } else
832 prm_write_mod_reg(0, GFX_MOD, PM_WKDEP);
835 * Enable interface clock autoidle for all modules.
836 * Note that in the long run this should be done by clockfw
838 cm_write_mod_reg(
839 OMAP3430_AUTO_MODEM |
840 OMAP3430ES2_AUTO_MMC3 |
841 OMAP3430ES2_AUTO_ICR |
842 OMAP3430_AUTO_AES2 |
843 OMAP3430_AUTO_SHA12 |
844 OMAP3430_AUTO_DES2 |
845 OMAP3430_AUTO_MMC2 |
846 OMAP3430_AUTO_MMC1 |
847 OMAP3430_AUTO_MSPRO |
848 OMAP3430_AUTO_HDQ |
849 OMAP3430_AUTO_MCSPI4 |
850 OMAP3430_AUTO_MCSPI3 |
851 OMAP3430_AUTO_MCSPI2 |
852 OMAP3430_AUTO_MCSPI1 |
853 OMAP3430_AUTO_I2C3 |
854 OMAP3430_AUTO_I2C2 |
855 OMAP3430_AUTO_I2C1 |
856 OMAP3430_AUTO_UART2 |
857 OMAP3430_AUTO_UART1 |
858 OMAP3430_AUTO_GPT11 |
859 OMAP3430_AUTO_GPT10 |
860 OMAP3430_AUTO_MCBSP5 |
861 OMAP3430_AUTO_MCBSP1 |
862 OMAP3430ES1_AUTO_FAC | /* This is es1 only */
863 OMAP3430_AUTO_MAILBOXES |
864 OMAP3430_AUTO_OMAPCTRL |
865 OMAP3430ES1_AUTO_FSHOSTUSB |
866 OMAP3430_AUTO_HSOTGUSB |
867 OMAP3430_AUTO_SAD2D |
868 OMAP3430_AUTO_SSI,
869 CORE_MOD, CM_AUTOIDLE1);
871 cm_write_mod_reg(
872 OMAP3430_AUTO_PKA |
873 OMAP3430_AUTO_AES1 |
874 OMAP3430_AUTO_RNG |
875 OMAP3430_AUTO_SHA11 |
876 OMAP3430_AUTO_DES1,
877 CORE_MOD, CM_AUTOIDLE2);
879 if (omap_rev_gt_1_0() || cpu_is_omap3505() || cpu_is_omap3517()) {
880 cm_write_mod_reg(
881 OMAP3430_AUTO_MAD2D |
882 OMAP3430ES2_AUTO_USBTLL,
883 CORE_MOD, CM_AUTOIDLE3);
886 cm_write_mod_reg(
887 OMAP3430_AUTO_WDT2 |
888 OMAP3430_AUTO_WDT1 |
889 OMAP3430_AUTO_GPIO1 |
890 OMAP3430_AUTO_32KSYNC |
891 OMAP3430_AUTO_GPT12 |
892 OMAP3430_AUTO_GPT1 ,
893 WKUP_MOD, CM_AUTOIDLE);
895 cm_write_mod_reg(
896 OMAP3430_AUTO_DSS,
897 OMAP3430_DSS_MOD,
898 CM_AUTOIDLE);
900 cm_write_mod_reg(
901 OMAP3430_AUTO_CAM,
902 OMAP3430_CAM_MOD,
903 CM_AUTOIDLE);
905 cm_write_mod_reg(
906 OMAP3430_AUTO_GPIO6 |
907 OMAP3430_AUTO_GPIO5 |
908 OMAP3430_AUTO_GPIO4 |
909 OMAP3430_AUTO_GPIO3 |
910 OMAP3430_AUTO_GPIO2 |
911 OMAP3430_AUTO_WDT3 |
912 OMAP3430_AUTO_UART3 |
913 OMAP3430_AUTO_GPT9 |
914 OMAP3430_AUTO_GPT8 |
915 OMAP3430_AUTO_GPT7 |
916 OMAP3430_AUTO_GPT6 |
917 OMAP3430_AUTO_GPT5 |
918 OMAP3430_AUTO_GPT4 |
919 OMAP3430_AUTO_GPT3 |
920 OMAP3430_AUTO_GPT2 |
921 OMAP3430_AUTO_MCBSP4 |
922 OMAP3430_AUTO_MCBSP3 |
923 OMAP3430_AUTO_MCBSP2,
924 OMAP3430_PER_MOD,
925 CM_AUTOIDLE);
927 if (omap_rev_gt_1_0() || cpu_is_omap3505() || cpu_is_omap3517()) {
928 cm_write_mod_reg(
929 OMAP3430ES2_AUTO_USBHOST,
930 OMAP3430ES2_USBHOST_MOD,
931 CM_AUTOIDLE);
934 omap_ctrl_writel(OMAP3430_AUTOIDLE, OMAP2_CONTROL_SYSCONFIG);
937 * Set all plls to autoidle. This is needed until autoidle is
938 * enabled by clockfw
940 cm_write_mod_reg(1 << OMAP3430_AUTO_IVA2_DPLL_SHIFT,
941 OMAP3430_IVA2_MOD, CM_AUTOIDLE2);
942 cm_write_mod_reg(1 << OMAP3430_AUTO_MPU_DPLL_SHIFT,
943 MPU_MOD,
944 CM_AUTOIDLE2);
945 cm_write_mod_reg((1 << OMAP3430_AUTO_PERIPH_DPLL_SHIFT) |
946 (1 << OMAP3430_AUTO_CORE_DPLL_SHIFT),
947 PLL_MOD,
948 CM_AUTOIDLE);
949 cm_write_mod_reg(1 << OMAP3430ES2_AUTO_PERIPH2_DPLL_SHIFT,
950 PLL_MOD,
951 CM_AUTOIDLE2);
954 * Enable control of expternal oscillator through
955 * sys_clkreq. In the long run clock framework should
956 * take care of this.
958 prm_rmw_mod_reg_bits(OMAP_AUTOEXTCLKMODE_MASK,
959 1 << OMAP_AUTOEXTCLKMODE_SHIFT,
960 OMAP3430_GR_MOD,
961 OMAP3_PRM_CLKSRC_CTRL_OFFSET);
963 /* setup wakup source */
964 prm_write_mod_reg(OMAP3430_EN_IO | OMAP3430_EN_GPIO1 |
965 OMAP3430_EN_GPT1 | OMAP3430_EN_GPT12,
966 WKUP_MOD, PM_WKEN);
967 /* No need to write EN_IO, that is always enabled */
968 prm_write_mod_reg(OMAP3430_EN_GPIO1 | OMAP3430_EN_GPT1 |
969 OMAP3430_EN_GPT12,
970 WKUP_MOD, OMAP3430_PM_MPUGRPSEL);
971 /* For some reason IO doesn't generate wakeup event even if
972 * it is selected to mpu wakeup goup */
973 prm_write_mod_reg(OMAP3430_IO_EN | OMAP3430_WKUP_EN,
974 OCP_MOD, OMAP3_PRM_IRQENABLE_MPU_OFFSET);
976 /* Enable wakeups in PER */
977 prm_write_mod_reg(OMAP3430_EN_GPIO2 | OMAP3430_EN_GPIO3 |
978 OMAP3430_EN_GPIO4 | OMAP3430_EN_GPIO5 |
979 OMAP3430_EN_GPIO6 | OMAP3430_EN_UART3,
980 OMAP3430_PER_MOD, PM_WKEN);
981 /* and allow them to wake up MPU */
982 prm_write_mod_reg(OMAP3430_GRPSEL_GPIO2 | OMAP3430_EN_GPIO3 |
983 OMAP3430_GRPSEL_GPIO4 | OMAP3430_EN_GPIO5 |
984 OMAP3430_GRPSEL_GPIO6 | OMAP3430_EN_UART3,
985 OMAP3430_PER_MOD, OMAP3430_PM_MPUGRPSEL);
987 /* Don't attach IVA interrupts */
988 prm_write_mod_reg(0, WKUP_MOD, OMAP3430_PM_IVAGRPSEL);
989 prm_write_mod_reg(0, CORE_MOD, OMAP3430_PM_IVAGRPSEL1);
990 prm_write_mod_reg(0, CORE_MOD, OMAP3430ES2_PM_IVAGRPSEL3);
991 prm_write_mod_reg(0, OMAP3430_PER_MOD, OMAP3430_PM_IVAGRPSEL);
993 /* Clear any pending 'reset' flags */
994 prm_write_mod_reg(0xffffffff, MPU_MOD, RM_RSTST);
995 prm_write_mod_reg(0xffffffff, CORE_MOD, RM_RSTST);
996 prm_write_mod_reg(0xffffffff, OMAP3430_PER_MOD, RM_RSTST);
997 prm_write_mod_reg(0xffffffff, OMAP3430_EMU_MOD, RM_RSTST);
998 prm_write_mod_reg(0xffffffff, OMAP3430_NEON_MOD, RM_RSTST);
999 prm_write_mod_reg(0xffffffff, OMAP3430_DSS_MOD, RM_RSTST);
1000 prm_write_mod_reg(0xffffffff, OMAP3430ES2_USBHOST_MOD, RM_RSTST);
1002 /* Clear any pending PRCM interrupts */
1003 prm_write_mod_reg(0, OCP_MOD, OMAP3_PRM_IRQSTATUS_MPU_OFFSET);
1005 omap3_iva_idle();
1006 omap3_d2d_idle();
1009 void omap3_pm_off_mode_enable(int enable)
1011 struct power_state *pwrst;
1012 u32 state;
1014 if (enable)
1015 state = PWRDM_POWER_OFF;
1016 else
1017 state = PWRDM_POWER_RET;
1019 #ifdef CONFIG_CPU_IDLE
1020 omap3_cpuidle_update_states();
1021 #endif
1023 #ifdef CONFIG_OMAP_PM_SRF
1024 resource_lock_opp(VDD1_OPP);
1025 resource_lock_opp(VDD2_OPP);
1026 if (resource_refresh())
1027 printk(KERN_ERR "Error: could not refresh resources\n");
1028 resource_unlock_opp(VDD1_OPP);
1029 resource_unlock_opp(VDD2_OPP);
1030 #endif
1031 list_for_each_entry(pwrst, &pwrst_list, node) {
1032 pwrst->next_state = state;
1033 set_pwrdm_state(pwrst->pwrdm, state);
1037 int omap3_pm_get_suspend_state(struct powerdomain *pwrdm)
1039 struct power_state *pwrst;
1041 list_for_each_entry(pwrst, &pwrst_list, node) {
1042 if (pwrst->pwrdm == pwrdm)
1043 return pwrst->next_state;
1045 return -EINVAL;
1048 int omap3_pm_set_suspend_state(struct powerdomain *pwrdm, int state)
1050 struct power_state *pwrst;
1052 list_for_each_entry(pwrst, &pwrst_list, node) {
1053 if (pwrst->pwrdm == pwrdm) {
1054 pwrst->next_state = state;
1055 return 0;
1058 return -EINVAL;
1061 void omap3_pm_init_vc(struct prm_setup_vc *setup_vc)
1063 if (!setup_vc)
1064 return;
1066 prm_setup.clksetup = setup_vc->clksetup;
1067 prm_setup.voltsetup_time1 = setup_vc->voltsetup_time1;
1068 prm_setup.voltsetup_time2 = setup_vc->voltsetup_time2;
1069 prm_setup.voltoffset = setup_vc->voltoffset;
1070 prm_setup.voltsetup2 = setup_vc->voltsetup2;
1071 prm_setup.vdd0_on = setup_vc->vdd0_on;
1072 prm_setup.vdd0_onlp = setup_vc->vdd0_onlp;
1073 prm_setup.vdd0_ret = setup_vc->vdd0_ret;
1074 prm_setup.vdd0_off = setup_vc->vdd0_off;
1075 prm_setup.vdd1_on = setup_vc->vdd1_on;
1076 prm_setup.vdd1_onlp = setup_vc->vdd1_onlp;
1077 prm_setup.vdd1_ret = setup_vc->vdd1_ret;
1078 prm_setup.vdd1_off = setup_vc->vdd1_off;
1081 static int __init pwrdms_setup(struct powerdomain *pwrdm, void *unused)
1083 struct power_state *pwrst;
1085 if (!pwrdm->pwrsts)
1086 return 0;
1088 pwrst = kmalloc(sizeof(struct power_state), GFP_ATOMIC);
1089 if (!pwrst)
1090 return -ENOMEM;
1091 pwrst->pwrdm = pwrdm;
1092 pwrst->next_state = PWRDM_POWER_RET;
1093 list_add(&pwrst->node, &pwrst_list);
1095 if (pwrdm_has_hdwr_sar(pwrdm))
1096 pwrdm_enable_hdwr_sar(pwrdm);
1098 return set_pwrdm_state(pwrst->pwrdm, pwrst->next_state);
1102 * Enable hw supervised mode for all clockdomains if it's
1103 * supported. Initiate sleep transition for other clockdomains, if
1104 * they are not used
1106 static int __init clkdms_setup(struct clockdomain *clkdm, void *unused)
1108 if (clkdm->flags & CLKDM_CAN_ENABLE_AUTO)
1109 omap2_clkdm_allow_idle(clkdm);
1110 else if (clkdm->flags & CLKDM_CAN_FORCE_SLEEP &&
1111 atomic_read(&clkdm->usecount) == 0)
1112 omap2_clkdm_sleep(clkdm);
1113 return 0;
1116 void omap_push_sram_idle(void)
1118 _omap_sram_idle = omap_sram_push(omap34xx_cpu_suspend,
1119 omap34xx_cpu_suspend_sz);
1120 if (omap_type() != OMAP2_DEVICE_TYPE_GP)
1121 _omap_save_secure_sram = omap_sram_push(save_secure_ram_context,
1122 save_secure_ram_context_sz);
1125 static int __init omap3_pm_init(void)
1127 struct power_state *pwrst, *tmp;
1128 int ret;
1130 if (!cpu_is_omap34xx())
1131 return -ENODEV;
1133 printk(KERN_ERR "Power Management for TI OMAP3.\n");
1135 /* XXX prcm_setup_regs needs to be before enabling hw
1136 * supervised mode for powerdomains */
1137 prcm_setup_regs();
1139 ret = request_irq(INT_34XX_PRCM_MPU_IRQ,
1140 (irq_handler_t)prcm_interrupt_handler,
1141 IRQF_DISABLED, "prcm", NULL);
1142 if (ret) {
1143 printk(KERN_ERR "request_irq failed to register for 0x%x\n",
1144 INT_34XX_PRCM_MPU_IRQ);
1145 goto err1;
1148 ret = pwrdm_for_each(pwrdms_setup, NULL);
1149 if (ret) {
1150 printk(KERN_ERR "Failed to setup powerdomains\n");
1151 goto err2;
1154 (void) clkdm_for_each(clkdms_setup, NULL);
1156 mpu_pwrdm = pwrdm_lookup("mpu_pwrdm");
1157 if (mpu_pwrdm == NULL) {
1158 printk(KERN_ERR "Failed to get mpu_pwrdm\n");
1159 goto err2;
1162 neon_pwrdm = pwrdm_lookup("neon_pwrdm");
1163 per_pwrdm = pwrdm_lookup("per_pwrdm");
1164 core_pwrdm = pwrdm_lookup("core_pwrdm");
1165 cam_pwrdm = pwrdm_lookup("cam_pwrdm");
1167 omap_push_sram_idle();
1168 #ifdef CONFIG_SUSPEND
1169 suspend_set_ops(&omap_pm_ops);
1170 #endif /* CONFIG_SUSPEND */
1172 pm_idle = omap3_pm_idle;
1173 omap3_idle_init();
1175 pwrdm_add_wkdep(neon_pwrdm, mpu_pwrdm);
1177 * REVISIT: This wkdep is only necessary when GPIO2-6 are enabled for
1178 * IO-pad wakeup. Otherwise it will unnecessarily waste power
1179 * waking up PER with every CORE wakeup - see
1180 * http://marc.info/?l=linux-omap&m=121852150710062&w=2
1182 pwrdm_add_wkdep(per_pwrdm, core_pwrdm);
1184 if (omap_type() != OMAP2_DEVICE_TYPE_GP) {
1185 omap3_secure_ram_storage =
1186 kmalloc(0x803F, GFP_KERNEL);
1187 if (!omap3_secure_ram_storage)
1188 printk(KERN_ERR "Memory allocation failed when"
1189 "allocating for secure sram context\n");
1191 local_irq_disable();
1192 local_fiq_disable();
1194 omap_dma_global_context_save();
1195 omap3_save_secure_ram_context(PWRDM_POWER_ON);
1196 omap_dma_global_context_restore();
1198 local_irq_enable();
1199 local_fiq_enable();
1202 omap3_save_scratchpad_contents();
1203 err1:
1204 return ret;
1205 err2:
1206 free_irq(INT_34XX_PRCM_MPU_IRQ, NULL);
1207 list_for_each_entry_safe(pwrst, tmp, &pwrst_list, node) {
1208 list_del(&pwrst->node);
1209 kfree(pwrst);
1211 return ret;
1214 static void __init configure_vc(void)
1217 prm_write_mod_reg((R_SRI2C_SLAVE_ADDR << OMAP3430_SMPS_SA1_SHIFT) |
1218 (R_SRI2C_SLAVE_ADDR << OMAP3430_SMPS_SA0_SHIFT),
1219 OMAP3430_GR_MOD, OMAP3_PRM_VC_SMPS_SA_OFFSET);
1220 prm_write_mod_reg((R_VDD2_SR_CONTROL << OMAP3430_VOLRA1_SHIFT) |
1221 (R_VDD1_SR_CONTROL << OMAP3430_VOLRA0_SHIFT),
1222 OMAP3430_GR_MOD, OMAP3_PRM_VC_SMPS_VOL_RA_OFFSET);
1224 prm_write_mod_reg((prm_setup.vdd0_on << OMAP3430_VC_CMD_ON_SHIFT) |
1225 (prm_setup.vdd0_onlp << OMAP3430_VC_CMD_ONLP_SHIFT) |
1226 (prm_setup.vdd0_ret << OMAP3430_VC_CMD_RET_SHIFT) |
1227 (prm_setup.vdd0_off << OMAP3430_VC_CMD_OFF_SHIFT),
1228 OMAP3430_GR_MOD, OMAP3_PRM_VC_CMD_VAL_0_OFFSET);
1230 prm_write_mod_reg((prm_setup.vdd1_on << OMAP3430_VC_CMD_ON_SHIFT) |
1231 (prm_setup.vdd1_onlp << OMAP3430_VC_CMD_ONLP_SHIFT) |
1232 (prm_setup.vdd1_ret << OMAP3430_VC_CMD_RET_SHIFT) |
1233 (prm_setup.vdd1_off << OMAP3430_VC_CMD_OFF_SHIFT),
1234 OMAP3430_GR_MOD, OMAP3_PRM_VC_CMD_VAL_1_OFFSET);
1236 prm_write_mod_reg(OMAP3430_CMD1 | OMAP3430_RAV1, OMAP3430_GR_MOD,
1237 OMAP3_PRM_VC_CH_CONF_OFFSET);
1239 prm_write_mod_reg(OMAP3430_MCODE_SHIFT | OMAP3430_HSEN,
1240 OMAP3430_GR_MOD,
1241 OMAP3_PRM_VC_I2C_CFG_OFFSET);
1243 /* Write setup times */
1244 prm_write_mod_reg(prm_setup.clksetup, OMAP3430_GR_MOD,
1245 OMAP3_PRM_CLKSETUP_OFFSET);
1246 prm_write_mod_reg((prm_setup.voltsetup_time2 <<
1247 OMAP3430_SETUP_TIME2_SHIFT) |
1248 (prm_setup.voltsetup_time1 <<
1249 OMAP3430_SETUP_TIME1_SHIFT),
1250 OMAP3430_GR_MOD, OMAP3_PRM_VOLTSETUP1_OFFSET);
1252 prm_write_mod_reg(prm_setup.voltoffset, OMAP3430_GR_MOD,
1253 OMAP3_PRM_VOLTOFFSET_OFFSET);
1254 prm_write_mod_reg(prm_setup.voltsetup2, OMAP3430_GR_MOD,
1255 OMAP3_PRM_VOLTSETUP2_OFFSET);
1257 pm_dbg_regset_init(1);
1258 pm_dbg_regset_init(2);
1261 static int __init omap3_pm_early_init(void)
1263 prm_clear_mod_reg_bits(OMAP3430_OFFMODE_POL, OMAP3430_GR_MOD,
1264 OMAP3_PRM_POLCTRL_OFFSET);
1266 configure_vc();
1268 return 0;
1271 arch_initcall(omap3_pm_early_init);
1272 late_initcall(omap3_pm_init);