OMAP3: PM: Add voltage levels to prm_setup_vc (previously prm_setup_time)
[linux-ginger.git] / arch / arm / mach-omap2 / pm34xx.c
blobdc87bca4cb9704327f25e03f2617b7a27c89428e
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>
30 #include <plat/sram.h>
31 #include <plat/clockdomain.h>
32 #include <plat/powerdomain.h>
33 #include <plat/control.h>
34 #include <plat/serial.h>
35 #include <plat/sdrc.h>
36 #include <plat/prcm.h>
37 #include <plat/gpmc.h>
38 #include <plat/dma.h>
39 #include <plat/dmtimer.h>
41 #include <plat/resource.h>
43 #include <asm/tlbflush.h>
45 #include "cm.h"
46 #include "cm-regbits-34xx.h"
47 #include "prm-regbits-34xx.h"
49 #include "smartreflex.h"
50 #include "prm.h"
51 #include "pm.h"
52 #include "sdrc.h"
54 static int regset_save_on_suspend;
56 /* Scratchpad offsets */
57 #define OMAP343X_TABLE_ADDRESS_OFFSET 0x31
58 #define OMAP343X_TABLE_VALUE_OFFSET 0x30
59 #define OMAP343X_CONTROL_REG_VALUE_OFFSET 0x32
61 u32 enable_off_mode;
62 u32 sleep_while_idle;
63 u32 wakeup_timer_seconds;
64 u32 voltage_off_while_idle;
66 struct power_state {
67 struct powerdomain *pwrdm;
68 u32 next_state;
69 #ifdef CONFIG_SUSPEND
70 u32 saved_state;
71 #endif
72 struct list_head node;
75 static LIST_HEAD(pwrst_list);
77 static void (*_omap_sram_idle)(u32 *addr, int save_state);
79 static int (*_omap_save_secure_sram)(u32 *addr);
81 static struct powerdomain *mpu_pwrdm, *neon_pwrdm;
82 static struct powerdomain *core_pwrdm, *per_pwrdm;
83 static struct powerdomain *cam_pwrdm;
85 static struct prm_setup_vc prm_setup = {
86 .clksetup = 0xff,
87 .voltsetup_time1 = 0xfff,
88 .voltsetup_time2 = 0xfff,
89 .voltoffset = 0xff,
90 .voltsetup2 = 0xff,
91 .vdd0_on = 0x30,
92 .vdd0_onlp = 0x1e,
93 .vdd0_ret = 0x1e,
94 .vdd0_off = 0x30,
95 .vdd1_on = 0x2c,
96 .vdd1_onlp = 0x1e,
97 .vdd1_ret = 0x1e,
98 .vdd1_off = 0x2c,
101 static inline void omap3_per_save_context(void)
103 omap_gpio_save_context();
106 static inline void omap3_per_restore_context(void)
108 omap_gpio_restore_context();
111 static void omap3_enable_io_chain(void)
113 int timeout = 0;
115 if (omap_rev() >= OMAP3430_REV_ES3_1) {
116 prm_set_mod_reg_bits(OMAP3430_EN_IO_CHAIN, WKUP_MOD, PM_WKEN);
117 /* Do a readback to assure write has been done */
118 prm_read_mod_reg(WKUP_MOD, PM_WKEN);
120 while (!(prm_read_mod_reg(WKUP_MOD, PM_WKST) &
121 OMAP3430_ST_IO_CHAIN)) {
122 timeout++;
123 if (timeout > 1000) {
124 printk(KERN_ERR "Wake up daisy chain "
125 "activation failed.\n");
126 return;
128 prm_set_mod_reg_bits(OMAP3430_ST_IO_CHAIN,
129 WKUP_MOD, PM_WKST);
134 static void omap3_disable_io_chain(void)
136 if (omap_rev() >= OMAP3430_REV_ES3_1)
137 prm_clear_mod_reg_bits(OMAP3430_EN_IO_CHAIN, WKUP_MOD, PM_WKEN);
140 static void omap3_core_save_context(void)
142 u32 control_padconf_off;
144 /* Save the padconf registers */
145 control_padconf_off = omap_ctrl_readl(OMAP343X_CONTROL_PADCONF_OFF);
146 control_padconf_off |= START_PADCONF_SAVE;
147 omap_ctrl_writel(control_padconf_off, OMAP343X_CONTROL_PADCONF_OFF);
148 /* wait for the save to complete */
149 while (!omap_ctrl_readl(OMAP343X_CONTROL_GENERAL_PURPOSE_STATUS)
150 & PADCONF_SAVE_DONE)
152 /* Save the Interrupt controller context */
153 omap_intc_save_context();
154 /* Save the GPMC context */
155 omap3_gpmc_save_context();
156 /* Save the system control module context, padconf already save above*/
157 omap3_control_save_context();
158 omap_dma_global_context_save();
161 static void omap3_core_restore_context(void)
163 /* Restore the control module context, padconf restored by h/w */
164 omap3_control_restore_context();
165 /* Restore the GPMC context */
166 omap3_gpmc_restore_context();
167 /* Restore the interrupt controller context */
168 omap_intc_restore_context();
169 omap_dma_global_context_restore();
173 * FIXME: This function should be called before entering off-mode after
174 * OMAP3 secure services have been accessed. Currently it is only called
175 * once during boot sequence, but this works as we are not using secure
176 * services.
178 static void omap3_save_secure_ram_context(u32 target_mpu_state)
180 u32 ret;
182 if (omap_type() != OMAP2_DEVICE_TYPE_GP) {
184 * MPU next state must be set to POWER_ON temporarily,
185 * otherwise the WFI executed inside the ROM code
186 * will hang the system.
188 pwrdm_set_next_pwrst(mpu_pwrdm, PWRDM_POWER_ON);
189 ret = _omap_save_secure_sram((u32 *)
190 __pa(omap3_secure_ram_storage));
191 pwrdm_set_next_pwrst(mpu_pwrdm, target_mpu_state);
192 /* Following is for error tracking, it should not happen */
193 if (ret) {
194 printk(KERN_ERR "save_secure_sram() returns %08x\n",
195 ret);
196 while (1)
203 * PRCM Interrupt Handler Helper Function
205 * The purpose of this function is to clear any wake-up events latched
206 * in the PRCM PM_WKST_x registers. It is possible that a wake-up event
207 * may occur whilst attempting to clear a PM_WKST_x register and thus
208 * set another bit in this register. A while loop is used to ensure
209 * that any peripheral wake-up events occurring while attempting to
210 * clear the PM_WKST_x are detected and cleared.
212 static int prcm_clear_mod_irqs(s16 module, u8 regs)
214 u32 wkst, fclk, iclk, clken;
215 u16 wkst_off = (regs == 3) ? OMAP3430ES2_PM_WKST3 : PM_WKST1;
216 u16 fclk_off = (regs == 3) ? OMAP3430ES2_CM_FCLKEN3 : CM_FCLKEN1;
217 u16 iclk_off = (regs == 3) ? CM_ICLKEN3 : CM_ICLKEN1;
218 u16 grpsel_off = (regs == 3) ?
219 OMAP3430ES2_PM_MPUGRPSEL3 : OMAP3430_PM_MPUGRPSEL;
220 int c = 0;
222 wkst = prm_read_mod_reg(module, wkst_off);
223 wkst &= prm_read_mod_reg(module, grpsel_off);
224 if (wkst) {
225 iclk = cm_read_mod_reg(module, iclk_off);
226 fclk = cm_read_mod_reg(module, fclk_off);
227 while (wkst) {
228 clken = wkst;
229 cm_set_mod_reg_bits(clken, module, iclk_off);
231 * For USBHOST, we don't know whether HOST1 or
232 * HOST2 woke us up, so enable both f-clocks
234 if (module == OMAP3430ES2_USBHOST_MOD)
235 clken |= 1 << OMAP3430ES2_EN_USBHOST2_SHIFT;
236 cm_set_mod_reg_bits(clken, module, fclk_off);
237 prm_write_mod_reg(wkst, module, wkst_off);
238 wkst = prm_read_mod_reg(module, wkst_off);
239 c++;
241 cm_write_mod_reg(iclk, module, iclk_off);
242 cm_write_mod_reg(fclk, module, fclk_off);
245 return c;
248 static int _prcm_int_handle_wakeup(void)
250 int c;
252 c = prcm_clear_mod_irqs(WKUP_MOD, 1);
253 c += prcm_clear_mod_irqs(CORE_MOD, 1);
254 c += prcm_clear_mod_irqs(OMAP3430_PER_MOD, 1);
255 if (omap_rev() > OMAP3430_REV_ES1_0) {
256 c += prcm_clear_mod_irqs(CORE_MOD, 3);
257 c += prcm_clear_mod_irqs(OMAP3430ES2_USBHOST_MOD, 1);
260 return c;
264 * PRCM Interrupt Handler
266 * The PRM_IRQSTATUS_MPU register indicates if there are any pending
267 * interrupts from the PRCM for the MPU. These bits must be cleared in
268 * order to clear the PRCM interrupt. The PRCM interrupt handler is
269 * implemented to simply clear the PRM_IRQSTATUS_MPU in order to clear
270 * the PRCM interrupt. Please note that bit 0 of the PRM_IRQSTATUS_MPU
271 * register indicates that a wake-up event is pending for the MPU and
272 * this bit can only be cleared if the all the wake-up events latched
273 * in the various PM_WKST_x registers have been cleared. The interrupt
274 * handler is implemented using a do-while loop so that if a wake-up
275 * event occurred during the processing of the prcm interrupt handler
276 * (setting a bit in the corresponding PM_WKST_x register and thus
277 * preventing us from clearing bit 0 of the PRM_IRQSTATUS_MPU register)
278 * this would be handled.
280 static irqreturn_t prcm_interrupt_handler (int irq, void *dev_id)
282 u32 irqstatus_mpu;
283 int c = 0;
285 do {
286 irqstatus_mpu = prm_read_mod_reg(OCP_MOD,
287 OMAP3_PRM_IRQSTATUS_MPU_OFFSET);
289 if (irqstatus_mpu & (OMAP3430_WKUP_ST | OMAP3430_IO_ST)) {
290 c = _prcm_int_handle_wakeup();
293 * Is the MPU PRCM interrupt handler racing with the
294 * IVA2 PRCM interrupt handler ?
296 WARN(c == 0, "prcm: WARNING: PRCM indicated MPU wakeup "
297 "but no wakeup sources are marked\n");
298 } else {
299 /* XXX we need to expand our PRCM interrupt handler */
300 WARN(1, "prcm: WARNING: PRCM interrupt received, but "
301 "no code to handle it (%08x)\n", irqstatus_mpu);
304 prm_write_mod_reg(irqstatus_mpu, OCP_MOD,
305 OMAP3_PRM_IRQSTATUS_MPU_OFFSET);
307 } while (prm_read_mod_reg(OCP_MOD, OMAP3_PRM_IRQSTATUS_MPU_OFFSET));
309 return IRQ_HANDLED;
312 static void restore_control_register(u32 val)
314 __asm__ __volatile__ ("mcr p15, 0, %0, c1, c0, 0" : : "r" (val));
317 /* Function to restore the table entry that was modified for enabling MMU */
318 static void restore_table_entry(void)
320 u32 *scratchpad_address;
321 u32 previous_value, control_reg_value;
322 u32 *address;
324 scratchpad_address = OMAP2_L4_IO_ADDRESS(OMAP343X_SCRATCHPAD);
326 /* Get address of entry that was modified */
327 address = (u32 *)__raw_readl(scratchpad_address +
328 OMAP343X_TABLE_ADDRESS_OFFSET);
329 /* Get the previous value which needs to be restored */
330 previous_value = __raw_readl(scratchpad_address +
331 OMAP343X_TABLE_VALUE_OFFSET);
332 address = __va(address);
333 *address = previous_value;
334 flush_tlb_all();
335 control_reg_value = __raw_readl(scratchpad_address
336 + OMAP343X_CONTROL_REG_VALUE_OFFSET);
337 /* This will enable caches and prediction */
338 restore_control_register(control_reg_value);
341 void omap_sram_idle(void)
343 /* Variable to tell what needs to be saved and restored
344 * in omap_sram_idle*/
345 /* save_state = 0 => Nothing to save and restored */
346 /* save_state = 1 => Only L1 and logic lost */
347 /* save_state = 2 => Only L2 lost */
348 /* save_state = 3 => L1, L2 and logic lost */
349 int save_state = 0;
350 int mpu_next_state = PWRDM_POWER_ON;
351 int per_next_state = PWRDM_POWER_ON;
352 int core_next_state = PWRDM_POWER_ON;
353 int core_prev_state, per_prev_state;
354 u32 sdrc_pwr = 0;
355 int per_state_modified = 0;
357 if (!_omap_sram_idle)
358 return;
360 pwrdm_clear_all_prev_pwrst(mpu_pwrdm);
361 pwrdm_clear_all_prev_pwrst(neon_pwrdm);
362 pwrdm_clear_all_prev_pwrst(core_pwrdm);
363 pwrdm_clear_all_prev_pwrst(per_pwrdm);
365 mpu_next_state = pwrdm_read_next_pwrst(mpu_pwrdm);
366 switch (mpu_next_state) {
367 case PWRDM_POWER_ON:
368 case PWRDM_POWER_RET:
369 /* No need to save context */
370 save_state = 0;
371 break;
372 case PWRDM_POWER_OFF:
373 save_state = 3;
374 break;
375 default:
376 /* Invalid state */
377 printk(KERN_ERR "Invalid mpu state in sram_idle\n");
378 return;
381 pwrdm_pre_transition();
383 /* NEON control */
384 if (pwrdm_read_pwrst(neon_pwrdm) == PWRDM_POWER_ON)
385 pwrdm_set_next_pwrst(neon_pwrdm, mpu_next_state);
387 /* PER */
388 per_next_state = pwrdm_read_next_pwrst(per_pwrdm);
389 core_next_state = pwrdm_read_next_pwrst(core_pwrdm);
390 if (per_next_state < PWRDM_POWER_ON) {
391 omap_uart_prepare_idle(2);
392 omap2_gpio_prepare_for_idle(per_next_state);
393 if (per_next_state == PWRDM_POWER_OFF) {
394 if (core_next_state == PWRDM_POWER_ON) {
395 per_next_state = PWRDM_POWER_RET;
396 pwrdm_set_next_pwrst(per_pwrdm, per_next_state);
397 per_state_modified = 1;
398 } else
399 omap3_per_save_context();
403 if (pwrdm_read_pwrst(cam_pwrdm) == PWRDM_POWER_ON)
404 omap2_clkdm_deny_idle(mpu_pwrdm->pwrdm_clkdms[0]);
406 /* CORE */
407 if (core_next_state < PWRDM_POWER_ON) {
408 /* Disable smartreflex before entering WFI */
409 disable_smartreflex(SR1);
410 disable_smartreflex(SR2);
411 omap_uart_prepare_idle(0);
412 omap_uart_prepare_idle(1);
413 if (core_next_state == PWRDM_POWER_OFF) {
414 prm_set_mod_reg_bits(OMAP3430_AUTO_OFF,
415 OMAP3430_GR_MOD,
416 OMAP3_PRM_VOLTCTRL_OFFSET);
417 omap3_core_save_context();
418 omap3_prcm_save_context();
420 /* Enable IO-PAD and IO-CHAIN wakeups */
421 prm_set_mod_reg_bits(OMAP3430_EN_IO, WKUP_MOD, PM_WKEN);
422 omap3_enable_io_chain();
426 * On EMU/HS devices ROM code restores a SRDC value
427 * from scratchpad which has automatic self refresh on timeout
428 * of AUTO_CNT = 1 enabled. This takes care of errata 1.142.
429 * Hence store/restore the SDRC_POWER register here.
431 if (omap_rev() >= OMAP3430_REV_ES3_0 &&
432 omap_type() != OMAP2_DEVICE_TYPE_GP &&
433 core_next_state == PWRDM_POWER_OFF)
434 sdrc_pwr = sdrc_read_reg(SDRC_POWER);
436 if (regset_save_on_suspend)
437 pm_dbg_regset_save(1);
440 * omap3_arm_context is the location where ARM registers
441 * get saved. The restore path then reads from this
442 * location and restores them back.
444 _omap_sram_idle(omap3_arm_context, save_state);
445 cpu_init();
447 /* Restore normal SDRC POWER settings */
448 if (omap_rev() >= OMAP3430_REV_ES3_0 &&
449 omap_type() != OMAP2_DEVICE_TYPE_GP &&
450 core_next_state == PWRDM_POWER_OFF)
451 sdrc_write_reg(sdrc_pwr, SDRC_POWER);
453 /* Restore table entry modified during MMU restoration */
454 if (pwrdm_read_prev_pwrst(mpu_pwrdm) == PWRDM_POWER_OFF)
455 restore_table_entry();
457 /* CORE */
458 if (core_next_state < PWRDM_POWER_ON) {
459 core_prev_state = pwrdm_read_prev_pwrst(core_pwrdm);
460 if (core_prev_state == PWRDM_POWER_OFF) {
461 omap3_core_restore_context();
462 omap3_prcm_restore_context();
463 omap3_sram_restore_context();
464 omap2_sms_restore_context();
466 omap_uart_resume_idle(0);
467 omap_uart_resume_idle(1);
468 if (core_next_state == PWRDM_POWER_OFF)
469 prm_clear_mod_reg_bits(OMAP3430_AUTO_OFF,
470 OMAP3430_GR_MOD,
471 OMAP3_PRM_VOLTCTRL_OFFSET);
472 /* Enable smartreflex after WFI */
473 enable_smartreflex(SR1);
474 enable_smartreflex(SR2);
477 /* PER */
478 if (per_next_state < PWRDM_POWER_ON) {
479 per_prev_state = pwrdm_read_prev_pwrst(per_pwrdm);
480 if (per_prev_state == PWRDM_POWER_OFF) {
481 omap3_per_restore_context();
482 omap3_gpio_restore_pad_context(0);
483 } else if (per_next_state == PWRDM_POWER_OFF)
484 omap3_gpio_restore_pad_context(1);
485 omap2_gpio_resume_after_idle();
486 omap_uart_resume_idle(2);
487 if (per_state_modified)
488 pwrdm_set_next_pwrst(per_pwrdm, PWRDM_POWER_OFF);
491 /* Disable IO-PAD and IO-CHAIN wakeup */
492 if (core_next_state < PWRDM_POWER_ON) {
493 prm_clear_mod_reg_bits(OMAP3430_EN_IO, WKUP_MOD, PM_WKEN);
494 omap3_disable_io_chain();
498 pwrdm_post_transition();
500 omap2_clkdm_allow_idle(mpu_pwrdm->pwrdm_clkdms[0]);
503 int omap3_can_sleep(void)
505 if (!sleep_while_idle)
506 return 0;
507 if (!omap_uart_can_sleep())
508 return 0;
509 return 1;
512 /* This sets pwrdm state (other than mpu & core. Currently only ON &
513 * RET are supported. Function is assuming that clkdm doesn't have
514 * hw_sup mode enabled. */
515 int set_pwrdm_state(struct powerdomain *pwrdm, u32 state)
517 u32 cur_state;
518 int sleep_switch = 0;
519 int ret = 0;
521 if (pwrdm == NULL || IS_ERR(pwrdm))
522 return -EINVAL;
524 while (!(pwrdm->pwrsts & (1 << state))) {
525 if (state == PWRDM_POWER_OFF)
526 return ret;
527 state--;
530 cur_state = pwrdm_read_next_pwrst(pwrdm);
531 if (cur_state == state)
532 return ret;
534 if (pwrdm_read_pwrst(pwrdm) < PWRDM_POWER_ON) {
535 omap2_clkdm_wakeup(pwrdm->pwrdm_clkdms[0]);
536 sleep_switch = 1;
537 pwrdm_wait_transition(pwrdm);
540 ret = pwrdm_set_next_pwrst(pwrdm, state);
541 if (ret) {
542 printk(KERN_ERR "Unable to set state of powerdomain: %s\n",
543 pwrdm->name);
544 goto err;
547 if (sleep_switch) {
548 omap2_clkdm_allow_idle(pwrdm->pwrdm_clkdms[0]);
549 pwrdm_wait_transition(pwrdm);
550 pwrdm_state_switch(pwrdm);
553 err:
554 return ret;
557 static void omap3_pm_idle(void)
559 local_irq_disable();
560 local_fiq_disable();
562 if (!omap3_can_sleep())
563 goto out;
565 if (omap_irq_pending() || need_resched())
566 goto out;
568 omap_sram_idle();
570 out:
571 local_fiq_enable();
572 local_irq_enable();
575 #ifdef CONFIG_SUSPEND
576 static suspend_state_t suspend_state;
578 static void omap2_pm_wakeup_on_timer(u32 seconds)
580 u32 tick_rate, cycles;
582 if (!seconds)
583 return;
585 tick_rate = clk_get_rate(omap_dm_timer_get_fclk(gptimer_wakeup));
586 cycles = tick_rate * seconds;
587 omap_dm_timer_stop(gptimer_wakeup);
588 omap_dm_timer_set_load_start(gptimer_wakeup, 0, 0xffffffff - cycles);
590 pr_info("PM: Resume timer in %d secs (%d ticks at %d ticks/sec.)\n",
591 seconds, cycles, tick_rate);
594 static int omap3_pm_prepare(void)
596 disable_hlt();
597 return 0;
600 static int omap3_pm_suspend(void)
602 struct power_state *pwrst;
603 int state, ret = 0;
605 if (wakeup_timer_seconds)
606 omap2_pm_wakeup_on_timer(wakeup_timer_seconds);
608 /* Read current next_pwrsts */
609 list_for_each_entry(pwrst, &pwrst_list, node)
610 pwrst->saved_state = pwrdm_read_next_pwrst(pwrst->pwrdm);
611 /* Set ones wanted by suspend */
612 list_for_each_entry(pwrst, &pwrst_list, node) {
613 if (set_pwrdm_state(pwrst->pwrdm, pwrst->next_state))
614 goto restore;
615 if (pwrdm_clear_all_prev_pwrst(pwrst->pwrdm))
616 goto restore;
619 omap_uart_prepare_suspend();
621 regset_save_on_suspend = 1;
622 omap_sram_idle();
623 regset_save_on_suspend = 0;
625 restore:
626 /* Restore next_pwrsts */
627 list_for_each_entry(pwrst, &pwrst_list, node) {
628 state = pwrdm_read_prev_pwrst(pwrst->pwrdm);
629 if (state > pwrst->next_state) {
630 printk(KERN_INFO "Powerdomain (%s) didn't enter "
631 "target state %d\n",
632 pwrst->pwrdm->name, pwrst->next_state);
633 ret = -1;
635 set_pwrdm_state(pwrst->pwrdm, pwrst->saved_state);
637 if (ret)
638 printk(KERN_ERR "Could not enter target state in pm_suspend\n");
639 else
640 printk(KERN_INFO "Successfully put all powerdomains "
641 "to target state\n");
643 return ret;
646 static int omap3_pm_enter(suspend_state_t unused)
648 int ret = 0;
650 switch (suspend_state) {
651 case PM_SUSPEND_STANDBY:
652 case PM_SUSPEND_MEM:
653 ret = omap3_pm_suspend();
654 break;
655 default:
656 ret = -EINVAL;
659 return ret;
662 static void omap3_pm_finish(void)
664 enable_hlt();
667 /* Hooks to enable / disable UART interrupts during suspend */
668 static int omap3_pm_begin(suspend_state_t state)
670 suspend_state = state;
671 omap_uart_enable_irqs(0);
672 return 0;
675 static void omap3_pm_end(void)
677 suspend_state = PM_SUSPEND_ON;
678 omap_uart_enable_irqs(1);
679 return;
682 static struct platform_suspend_ops omap_pm_ops = {
683 .begin = omap3_pm_begin,
684 .end = omap3_pm_end,
685 .prepare = omap3_pm_prepare,
686 .enter = omap3_pm_enter,
687 .finish = omap3_pm_finish,
688 .valid = suspend_valid_only_mem,
690 #endif /* CONFIG_SUSPEND */
694 * omap3_iva_idle(): ensure IVA is in idle so it can be put into
695 * retention
697 * In cases where IVA2 is activated by bootcode, it may prevent
698 * full-chip retention or off-mode because it is not idle. This
699 * function forces the IVA2 into idle state so it can go
700 * into retention/off and thus allow full-chip retention/off.
703 static void __init omap3_iva_idle(void)
705 /* ensure IVA2 clock is disabled */
706 cm_write_mod_reg(0, OMAP3430_IVA2_MOD, CM_FCLKEN);
708 /* if no clock activity, nothing else to do */
709 if (!(cm_read_mod_reg(OMAP3430_IVA2_MOD, OMAP3430_CM_CLKSTST) &
710 OMAP3430_CLKACTIVITY_IVA2_MASK))
711 return;
713 /* Reset IVA2 */
714 prm_write_mod_reg(OMAP3430_RST1_IVA2 |
715 OMAP3430_RST2_IVA2 |
716 OMAP3430_RST3_IVA2,
717 OMAP3430_IVA2_MOD, RM_RSTCTRL);
719 /* Enable IVA2 clock */
720 cm_write_mod_reg(OMAP3430_CM_FCLKEN_IVA2_EN_IVA2,
721 OMAP3430_IVA2_MOD, CM_FCLKEN);
723 /* Set IVA2 boot mode to 'idle' */
724 omap_ctrl_writel(OMAP3_IVA2_BOOTMOD_IDLE,
725 OMAP343X_CONTROL_IVA2_BOOTMOD);
727 /* Un-reset IVA2 */
728 prm_write_mod_reg(0, OMAP3430_IVA2_MOD, RM_RSTCTRL);
730 /* Disable IVA2 clock */
731 cm_write_mod_reg(0, OMAP3430_IVA2_MOD, CM_FCLKEN);
733 /* Reset IVA2 */
734 prm_write_mod_reg(OMAP3430_RST1_IVA2 |
735 OMAP3430_RST2_IVA2 |
736 OMAP3430_RST3_IVA2,
737 OMAP3430_IVA2_MOD, RM_RSTCTRL);
740 static void __init omap3_d2d_idle(void)
742 u16 mask, padconf;
744 /* In a stand alone OMAP3430 where there is not a stacked
745 * modem for the D2D Idle Ack and D2D MStandby must be pulled
746 * high. S CONTROL_PADCONF_SAD2D_IDLEACK and
747 * CONTROL_PADCONF_SAD2D_MSTDBY to have a pull up. */
748 mask = (1 << 4) | (1 << 3); /* pull-up, enabled */
749 padconf = omap_ctrl_readw(OMAP3_PADCONF_SAD2D_MSTANDBY);
750 padconf |= mask;
751 omap_ctrl_writew(padconf, OMAP3_PADCONF_SAD2D_MSTANDBY);
753 padconf = omap_ctrl_readw(OMAP3_PADCONF_SAD2D_IDLEACK);
754 padconf |= mask;
755 omap_ctrl_writew(padconf, OMAP3_PADCONF_SAD2D_IDLEACK);
757 /* reset modem */
758 prm_write_mod_reg(OMAP3430_RM_RSTCTRL_CORE_MODEM_SW_RSTPWRON |
759 OMAP3430_RM_RSTCTRL_CORE_MODEM_SW_RST,
760 CORE_MOD, RM_RSTCTRL);
761 prm_write_mod_reg(0, CORE_MOD, RM_RSTCTRL);
764 static void __init prcm_setup_regs(void)
766 /* XXX Reset all wkdeps. This should be done when initializing
767 * powerdomains */
768 prm_write_mod_reg(0, OMAP3430_IVA2_MOD, PM_WKDEP);
769 prm_write_mod_reg(0, MPU_MOD, PM_WKDEP);
770 prm_write_mod_reg(0, OMAP3430_DSS_MOD, PM_WKDEP);
771 prm_write_mod_reg(0, OMAP3430_NEON_MOD, PM_WKDEP);
772 prm_write_mod_reg(0, OMAP3430_CAM_MOD, PM_WKDEP);
773 prm_write_mod_reg(0, OMAP3430_PER_MOD, PM_WKDEP);
774 if (omap_rev() > OMAP3430_REV_ES1_0) {
775 prm_write_mod_reg(0, OMAP3430ES2_SGX_MOD, PM_WKDEP);
776 prm_write_mod_reg(0, OMAP3430ES2_USBHOST_MOD, PM_WKDEP);
777 } else
778 prm_write_mod_reg(0, GFX_MOD, PM_WKDEP);
781 * Enable interface clock autoidle for all modules.
782 * Note that in the long run this should be done by clockfw
784 cm_write_mod_reg(
785 OMAP3430_AUTO_MODEM |
786 OMAP3430ES2_AUTO_MMC3 |
787 OMAP3430ES2_AUTO_ICR |
788 OMAP3430_AUTO_AES2 |
789 OMAP3430_AUTO_SHA12 |
790 OMAP3430_AUTO_DES2 |
791 OMAP3430_AUTO_MMC2 |
792 OMAP3430_AUTO_MMC1 |
793 OMAP3430_AUTO_MSPRO |
794 OMAP3430_AUTO_HDQ |
795 OMAP3430_AUTO_MCSPI4 |
796 OMAP3430_AUTO_MCSPI3 |
797 OMAP3430_AUTO_MCSPI2 |
798 OMAP3430_AUTO_MCSPI1 |
799 OMAP3430_AUTO_I2C3 |
800 OMAP3430_AUTO_I2C2 |
801 OMAP3430_AUTO_I2C1 |
802 OMAP3430_AUTO_UART2 |
803 OMAP3430_AUTO_UART1 |
804 OMAP3430_AUTO_GPT11 |
805 OMAP3430_AUTO_GPT10 |
806 OMAP3430_AUTO_MCBSP5 |
807 OMAP3430_AUTO_MCBSP1 |
808 OMAP3430ES1_AUTO_FAC | /* This is es1 only */
809 OMAP3430_AUTO_MAILBOXES |
810 OMAP3430_AUTO_OMAPCTRL |
811 OMAP3430ES1_AUTO_FSHOSTUSB |
812 OMAP3430_AUTO_HSOTGUSB |
813 OMAP3430_AUTO_SAD2D |
814 OMAP3430_AUTO_SSI,
815 CORE_MOD, CM_AUTOIDLE1);
817 cm_write_mod_reg(
818 OMAP3430_AUTO_PKA |
819 OMAP3430_AUTO_AES1 |
820 OMAP3430_AUTO_RNG |
821 OMAP3430_AUTO_SHA11 |
822 OMAP3430_AUTO_DES1,
823 CORE_MOD, CM_AUTOIDLE2);
825 if (omap_rev() > OMAP3430_REV_ES1_0) {
826 cm_write_mod_reg(
827 OMAP3430_AUTO_MAD2D |
828 OMAP3430ES2_AUTO_USBTLL,
829 CORE_MOD, CM_AUTOIDLE3);
832 cm_write_mod_reg(
833 OMAP3430_AUTO_WDT2 |
834 OMAP3430_AUTO_WDT1 |
835 OMAP3430_AUTO_GPIO1 |
836 OMAP3430_AUTO_32KSYNC |
837 OMAP3430_AUTO_GPT12 |
838 OMAP3430_AUTO_GPT1 ,
839 WKUP_MOD, CM_AUTOIDLE);
841 cm_write_mod_reg(
842 OMAP3430_AUTO_DSS,
843 OMAP3430_DSS_MOD,
844 CM_AUTOIDLE);
846 cm_write_mod_reg(
847 OMAP3430_AUTO_CAM,
848 OMAP3430_CAM_MOD,
849 CM_AUTOIDLE);
851 cm_write_mod_reg(
852 OMAP3430_AUTO_GPIO6 |
853 OMAP3430_AUTO_GPIO5 |
854 OMAP3430_AUTO_GPIO4 |
855 OMAP3430_AUTO_GPIO3 |
856 OMAP3430_AUTO_GPIO2 |
857 OMAP3430_AUTO_WDT3 |
858 OMAP3430_AUTO_UART3 |
859 OMAP3430_AUTO_GPT9 |
860 OMAP3430_AUTO_GPT8 |
861 OMAP3430_AUTO_GPT7 |
862 OMAP3430_AUTO_GPT6 |
863 OMAP3430_AUTO_GPT5 |
864 OMAP3430_AUTO_GPT4 |
865 OMAP3430_AUTO_GPT3 |
866 OMAP3430_AUTO_GPT2 |
867 OMAP3430_AUTO_MCBSP4 |
868 OMAP3430_AUTO_MCBSP3 |
869 OMAP3430_AUTO_MCBSP2,
870 OMAP3430_PER_MOD,
871 CM_AUTOIDLE);
873 if (omap_rev() > OMAP3430_REV_ES1_0) {
874 cm_write_mod_reg(
875 OMAP3430ES2_AUTO_USBHOST,
876 OMAP3430ES2_USBHOST_MOD,
877 CM_AUTOIDLE);
881 * Set all plls to autoidle. This is needed until autoidle is
882 * enabled by clockfw
884 cm_write_mod_reg(1 << OMAP3430_AUTO_IVA2_DPLL_SHIFT,
885 OMAP3430_IVA2_MOD, CM_AUTOIDLE2);
886 cm_write_mod_reg(1 << OMAP3430_AUTO_MPU_DPLL_SHIFT,
887 MPU_MOD,
888 CM_AUTOIDLE2);
889 cm_write_mod_reg((1 << OMAP3430_AUTO_PERIPH_DPLL_SHIFT) |
890 (1 << OMAP3430_AUTO_CORE_DPLL_SHIFT),
891 PLL_MOD,
892 CM_AUTOIDLE);
893 cm_write_mod_reg(1 << OMAP3430ES2_AUTO_PERIPH2_DPLL_SHIFT,
894 PLL_MOD,
895 CM_AUTOIDLE2);
898 * Enable control of expternal oscillator through
899 * sys_clkreq. In the long run clock framework should
900 * take care of this.
902 prm_rmw_mod_reg_bits(OMAP_AUTOEXTCLKMODE_MASK,
903 1 << OMAP_AUTOEXTCLKMODE_SHIFT,
904 OMAP3430_GR_MOD,
905 OMAP3_PRM_CLKSRC_CTRL_OFFSET);
907 /* setup wakup source */
908 prm_write_mod_reg(OMAP3430_EN_IO | OMAP3430_EN_GPIO1 |
909 OMAP3430_EN_GPT1 | OMAP3430_EN_GPT12,
910 WKUP_MOD, PM_WKEN);
911 /* No need to write EN_IO, that is always enabled */
912 prm_write_mod_reg(OMAP3430_EN_GPIO1 | OMAP3430_EN_GPT1 |
913 OMAP3430_EN_GPT12,
914 WKUP_MOD, OMAP3430_PM_MPUGRPSEL);
915 /* For some reason IO doesn't generate wakeup event even if
916 * it is selected to mpu wakeup goup */
917 prm_write_mod_reg(OMAP3430_IO_EN | OMAP3430_WKUP_EN,
918 OCP_MOD, OMAP3_PRM_IRQENABLE_MPU_OFFSET);
920 /* Enable wakeups in PER */
921 prm_write_mod_reg(OMAP3430_EN_GPIO2 | OMAP3430_EN_GPIO3 |
922 OMAP3430_EN_GPIO4 | OMAP3430_EN_GPIO5 |
923 OMAP3430_EN_GPIO6 | OMAP3430_EN_UART3,
924 OMAP3430_PER_MOD, PM_WKEN);
925 /* and allow them to wake up MPU */
926 prm_write_mod_reg(OMAP3430_GRPSEL_GPIO2 | OMAP3430_EN_GPIO3 |
927 OMAP3430_GRPSEL_GPIO4 | OMAP3430_EN_GPIO5 |
928 OMAP3430_GRPSEL_GPIO6 | OMAP3430_EN_UART3,
929 OMAP3430_PER_MOD, OMAP3430_PM_MPUGRPSEL);
931 /* Don't attach IVA interrupts */
932 prm_write_mod_reg(0, WKUP_MOD, OMAP3430_PM_IVAGRPSEL);
933 prm_write_mod_reg(0, CORE_MOD, OMAP3430_PM_IVAGRPSEL1);
934 prm_write_mod_reg(0, CORE_MOD, OMAP3430ES2_PM_IVAGRPSEL3);
935 prm_write_mod_reg(0, OMAP3430_PER_MOD, OMAP3430_PM_IVAGRPSEL);
937 /* Clear any pending 'reset' flags */
938 prm_write_mod_reg(0xffffffff, MPU_MOD, RM_RSTST);
939 prm_write_mod_reg(0xffffffff, CORE_MOD, RM_RSTST);
940 prm_write_mod_reg(0xffffffff, OMAP3430_PER_MOD, RM_RSTST);
941 prm_write_mod_reg(0xffffffff, OMAP3430_EMU_MOD, RM_RSTST);
942 prm_write_mod_reg(0xffffffff, OMAP3430_NEON_MOD, RM_RSTST);
943 prm_write_mod_reg(0xffffffff, OMAP3430_DSS_MOD, RM_RSTST);
944 prm_write_mod_reg(0xffffffff, OMAP3430ES2_USBHOST_MOD, RM_RSTST);
946 /* Clear any pending PRCM interrupts */
947 prm_write_mod_reg(0, OCP_MOD, OMAP3_PRM_IRQSTATUS_MPU_OFFSET);
949 /* Don't attach IVA interrupts */
950 prm_write_mod_reg(0, WKUP_MOD, OMAP3430_PM_IVAGRPSEL);
951 prm_write_mod_reg(0, CORE_MOD, OMAP3430_PM_IVAGRPSEL1);
952 prm_write_mod_reg(0, CORE_MOD, OMAP3430ES2_PM_IVAGRPSEL3);
953 prm_write_mod_reg(0, OMAP3430_PER_MOD, OMAP3430_PM_IVAGRPSEL);
955 /* Clear any pending 'reset' flags */
956 prm_write_mod_reg(0xffffffff, MPU_MOD, RM_RSTST);
957 prm_write_mod_reg(0xffffffff, CORE_MOD, RM_RSTST);
958 prm_write_mod_reg(0xffffffff, OMAP3430_PER_MOD, RM_RSTST);
959 prm_write_mod_reg(0xffffffff, OMAP3430_EMU_MOD, RM_RSTST);
960 prm_write_mod_reg(0xffffffff, OMAP3430_NEON_MOD, RM_RSTST);
961 prm_write_mod_reg(0xffffffff, OMAP3430_DSS_MOD, RM_RSTST);
962 prm_write_mod_reg(0xffffffff, OMAP3430ES2_USBHOST_MOD, RM_RSTST);
964 /* Clear any pending PRCM interrupts */
965 prm_write_mod_reg(0, OCP_MOD, OMAP3_PRM_IRQSTATUS_MPU_OFFSET);
967 omap3_iva_idle();
968 omap3_d2d_idle();
971 void omap3_pm_off_mode_enable(int enable)
973 struct power_state *pwrst;
974 u32 state;
976 if (enable)
977 state = PWRDM_POWER_OFF;
978 else
979 state = PWRDM_POWER_RET;
981 #ifdef CONFIG_OMAP_PM_SRF
982 resource_lock_opp(VDD1_OPP);
983 resource_lock_opp(VDD2_OPP);
984 if (resource_refresh())
985 printk(KERN_ERR "Error: could not refresh resources\n");
986 resource_unlock_opp(VDD1_OPP);
987 resource_unlock_opp(VDD2_OPP);
988 #endif
989 list_for_each_entry(pwrst, &pwrst_list, node) {
990 pwrst->next_state = state;
991 set_pwrdm_state(pwrst->pwrdm, state);
995 int omap3_pm_get_suspend_state(struct powerdomain *pwrdm)
997 struct power_state *pwrst;
999 list_for_each_entry(pwrst, &pwrst_list, node) {
1000 if (pwrst->pwrdm == pwrdm)
1001 return pwrst->next_state;
1003 return -EINVAL;
1006 int omap3_pm_set_suspend_state(struct powerdomain *pwrdm, int state)
1008 struct power_state *pwrst;
1010 list_for_each_entry(pwrst, &pwrst_list, node) {
1011 if (pwrst->pwrdm == pwrdm) {
1012 pwrst->next_state = state;
1013 return 0;
1016 return -EINVAL;
1019 void omap3_set_prm_setup_vc(struct prm_setup_vc *setup_vc)
1021 prm_setup.clksetup = setup_vc->clksetup;
1022 prm_setup.voltsetup_time1 = setup_vc->voltsetup_time1;
1023 prm_setup.voltsetup_time2 = setup_vc->voltsetup_time2;
1024 prm_setup.voltoffset = setup_vc->voltoffset;
1025 prm_setup.voltsetup2 = setup_vc->voltsetup2;
1026 prm_setup.vdd0_on = setup_vc->vdd0_on;
1027 prm_setup.vdd0_onlp = setup_vc->vdd0_onlp;
1028 prm_setup.vdd0_ret = setup_vc->vdd0_ret;
1029 prm_setup.vdd0_off = setup_vc->vdd0_off;
1030 prm_setup.vdd1_on = setup_vc->vdd1_on;
1031 prm_setup.vdd1_onlp = setup_vc->vdd1_onlp;
1032 prm_setup.vdd1_ret = setup_vc->vdd1_ret;
1033 prm_setup.vdd1_off = setup_vc->vdd1_off;
1036 static int __init pwrdms_setup(struct powerdomain *pwrdm, void *unused)
1038 struct power_state *pwrst;
1040 if (!pwrdm->pwrsts)
1041 return 0;
1043 pwrst = kmalloc(sizeof(struct power_state), GFP_ATOMIC);
1044 if (!pwrst)
1045 return -ENOMEM;
1046 pwrst->pwrdm = pwrdm;
1047 pwrst->next_state = PWRDM_POWER_RET;
1048 list_add(&pwrst->node, &pwrst_list);
1050 if (pwrdm_has_hdwr_sar(pwrdm))
1051 pwrdm_enable_hdwr_sar(pwrdm);
1053 return set_pwrdm_state(pwrst->pwrdm, pwrst->next_state);
1057 * Enable hw supervised mode for all clockdomains if it's
1058 * supported. Initiate sleep transition for other clockdomains, if
1059 * they are not used
1061 static int __init clkdms_setup(struct clockdomain *clkdm, void *unused)
1063 if (clkdm->flags & CLKDM_CAN_ENABLE_AUTO)
1064 omap2_clkdm_allow_idle(clkdm);
1065 else if (clkdm->flags & CLKDM_CAN_FORCE_SLEEP &&
1066 atomic_read(&clkdm->usecount) == 0)
1067 omap2_clkdm_sleep(clkdm);
1068 return 0;
1071 void omap_push_sram_idle(void)
1073 _omap_sram_idle = omap_sram_push(omap34xx_cpu_suspend,
1074 omap34xx_cpu_suspend_sz);
1075 if (omap_type() != OMAP2_DEVICE_TYPE_GP)
1076 _omap_save_secure_sram = omap_sram_push(save_secure_ram_context,
1077 save_secure_ram_context_sz);
1080 static int __init omap3_pm_init(void)
1082 struct power_state *pwrst, *tmp;
1083 int ret;
1085 if (!cpu_is_omap34xx())
1086 return -ENODEV;
1088 printk(KERN_ERR "Power Management for TI OMAP3.\n");
1090 /* XXX prcm_setup_regs needs to be before enabling hw
1091 * supervised mode for powerdomains */
1092 prcm_setup_regs();
1094 ret = request_irq(INT_34XX_PRCM_MPU_IRQ,
1095 (irq_handler_t)prcm_interrupt_handler,
1096 IRQF_DISABLED, "prcm", NULL);
1097 if (ret) {
1098 printk(KERN_ERR "request_irq failed to register for 0x%x\n",
1099 INT_34XX_PRCM_MPU_IRQ);
1100 goto err1;
1103 ret = pwrdm_for_each(pwrdms_setup, NULL);
1104 if (ret) {
1105 printk(KERN_ERR "Failed to setup powerdomains\n");
1106 goto err2;
1109 (void) clkdm_for_each(clkdms_setup, NULL);
1111 mpu_pwrdm = pwrdm_lookup("mpu_pwrdm");
1112 if (mpu_pwrdm == NULL) {
1113 printk(KERN_ERR "Failed to get mpu_pwrdm\n");
1114 goto err2;
1117 neon_pwrdm = pwrdm_lookup("neon_pwrdm");
1118 per_pwrdm = pwrdm_lookup("per_pwrdm");
1119 core_pwrdm = pwrdm_lookup("core_pwrdm");
1120 cam_pwrdm = pwrdm_lookup("cam_pwrdm");
1122 omap_push_sram_idle();
1123 #ifdef CONFIG_SUSPEND
1124 suspend_set_ops(&omap_pm_ops);
1125 #endif /* CONFIG_SUSPEND */
1127 pm_idle = omap3_pm_idle;
1128 omap3_idle_init();
1130 pwrdm_add_wkdep(neon_pwrdm, mpu_pwrdm);
1132 * REVISIT: This wkdep is only necessary when GPIO2-6 are enabled for
1133 * IO-pad wakeup. Otherwise it will unnecessarily waste power
1134 * waking up PER with every CORE wakeup - see
1135 * http://marc.info/?l=linux-omap&m=121852150710062&w=2
1137 pwrdm_add_wkdep(per_pwrdm, core_pwrdm);
1139 if (omap_type() != OMAP2_DEVICE_TYPE_GP) {
1140 omap3_secure_ram_storage =
1141 kmalloc(0x803F, GFP_KERNEL);
1142 if (!omap3_secure_ram_storage)
1143 printk(KERN_ERR "Memory allocation failed when"
1144 "allocating for secure sram context\n");
1146 local_irq_disable();
1147 local_fiq_disable();
1149 omap_dma_global_context_save();
1150 omap3_save_secure_ram_context(PWRDM_POWER_ON);
1151 omap_dma_global_context_restore();
1153 local_irq_enable();
1154 local_fiq_enable();
1157 omap3_save_scratchpad_contents();
1158 err1:
1159 return ret;
1160 err2:
1161 free_irq(INT_34XX_PRCM_MPU_IRQ, NULL);
1162 list_for_each_entry_safe(pwrst, tmp, &pwrst_list, node) {
1163 list_del(&pwrst->node);
1164 kfree(pwrst);
1166 return ret;
1169 static void __init configure_vc(void)
1172 prm_write_mod_reg((R_SRI2C_SLAVE_ADDR << OMAP3430_SMPS_SA1_SHIFT) |
1173 (R_SRI2C_SLAVE_ADDR << OMAP3430_SMPS_SA0_SHIFT),
1174 OMAP3430_GR_MOD, OMAP3_PRM_VC_SMPS_SA_OFFSET);
1175 prm_write_mod_reg((R_VDD2_SR_CONTROL << OMAP3430_VOLRA1_SHIFT) |
1176 (R_VDD1_SR_CONTROL << OMAP3430_VOLRA0_SHIFT),
1177 OMAP3430_GR_MOD, OMAP3_PRM_VC_SMPS_VOL_RA_OFFSET);
1179 prm_write_mod_reg((prm_setup.vdd0_on << OMAP3430_VC_CMD_ON_SHIFT) |
1180 (prm_setup.vdd0_onlp << OMAP3430_VC_CMD_ONLP_SHIFT) |
1181 (prm_setup.vdd0_ret << OMAP3430_VC_CMD_RET_SHIFT) |
1182 (prm_setup.vdd0_off << OMAP3430_VC_CMD_OFF_SHIFT),
1183 OMAP3430_GR_MOD, OMAP3_PRM_VC_CMD_VAL_0_OFFSET);
1185 prm_write_mod_reg((prm_setup.vdd1_on << OMAP3430_VC_CMD_ON_SHIFT) |
1186 (prm_setup.vdd1_onlp << OMAP3430_VC_CMD_ONLP_SHIFT) |
1187 (prm_setup.vdd1_ret << OMAP3430_VC_CMD_RET_SHIFT) |
1188 (prm_setup.vdd1_off << OMAP3430_VC_CMD_OFF_SHIFT),
1189 OMAP3430_GR_MOD, OMAP3_PRM_VC_CMD_VAL_1_OFFSET);
1191 prm_write_mod_reg(OMAP3430_CMD1 | OMAP3430_RAV1, OMAP3430_GR_MOD,
1192 OMAP3_PRM_VC_CH_CONF_OFFSET);
1194 prm_write_mod_reg(OMAP3430_MCODE_SHIFT | OMAP3430_HSEN | OMAP3430_SREN,
1195 OMAP3430_GR_MOD,
1196 OMAP3_PRM_VC_I2C_CFG_OFFSET);
1198 /* Setup value for voltctrl */
1199 prm_write_mod_reg(OMAP3430_AUTO_RET,
1200 OMAP3430_GR_MOD, OMAP3_PRM_VOLTCTRL_OFFSET);
1202 /* Write setup times */
1203 prm_write_mod_reg(prm_setup.clksetup, OMAP3430_GR_MOD,
1204 OMAP3_PRM_CLKSETUP_OFFSET);
1205 prm_write_mod_reg((prm_setup.voltsetup_time2 <<
1206 OMAP3430_SETUP_TIME2_SHIFT) |
1207 (prm_setup.voltsetup_time1 <<
1208 OMAP3430_SETUP_TIME1_SHIFT),
1209 OMAP3430_GR_MOD, OMAP3_PRM_VOLTSETUP1_OFFSET);
1211 prm_write_mod_reg(prm_setup.voltoffset, OMAP3430_GR_MOD,
1212 OMAP3_PRM_VOLTOFFSET_OFFSET);
1213 prm_write_mod_reg(prm_setup.voltsetup2, OMAP3430_GR_MOD,
1214 OMAP3_PRM_VOLTSETUP2_OFFSET);
1216 pm_dbg_regset_init(1);
1219 static int __init omap3_pm_early_init(void)
1221 prm_clear_mod_reg_bits(OMAP3430_OFFMODE_POL, OMAP3430_GR_MOD,
1222 OMAP3_PRM_POLCTRL_OFFSET);
1224 configure_vc();
1226 return 0;
1229 arch_initcall(omap3_pm_early_init);
1230 late_initcall(omap3_pm_init);