2 * OMAP4 PRM module functions
4 * Copyright (C) 2011-2012 Texas Instruments, Inc.
5 * Copyright (C) 2010 Nokia Corporation
8 * Rajendra Nayak <rnayak@ti.com>
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License version 2 as
12 * published by the Free Software Foundation.
15 #include <linux/kernel.h>
16 #include <linux/delay.h>
17 #include <linux/errno.h>
18 #include <linux/err.h>
20 #include <linux/of_irq.h>
29 #include "prm-regbits-44xx.h"
31 #include "prminst44xx.h"
32 #include "powerdomain.h"
36 static void omap44xx_prm_read_pending_irqs(unsigned long *events
);
37 static void omap44xx_prm_ocp_barrier(void);
38 static void omap44xx_prm_save_and_clear_irqen(u32
*saved_mask
);
39 static void omap44xx_prm_restore_irqen(u32
*saved_mask
);
40 static void omap44xx_prm_reconfigure_io_chain(void);
42 static const struct omap_prcm_irq omap4_prcm_irqs
[] = {
43 OMAP_PRCM_IRQ("io", 9, 1),
46 static struct omap_prcm_irq_setup omap4_prcm_irq_setup
= {
47 .ack
= OMAP4_PRM_IRQSTATUS_MPU_OFFSET
,
48 .mask
= OMAP4_PRM_IRQENABLE_MPU_OFFSET
,
49 .pm_ctrl
= OMAP4_PRM_IO_PMCTRL_OFFSET
,
51 .irqs
= omap4_prcm_irqs
,
52 .nr_irqs
= ARRAY_SIZE(omap4_prcm_irqs
),
53 .read_pending_irqs
= &omap44xx_prm_read_pending_irqs
,
54 .ocp_barrier
= &omap44xx_prm_ocp_barrier
,
55 .save_and_clear_irqen
= &omap44xx_prm_save_and_clear_irqen
,
56 .restore_irqen
= &omap44xx_prm_restore_irqen
,
57 .reconfigure_io_chain
= &omap44xx_prm_reconfigure_io_chain
,
61 * omap44xx_prm_reset_src_map - map from bits in the PRM_RSTST
62 * hardware register (which are specific to OMAP44xx SoCs) to reset
63 * source ID bit shifts (which is an OMAP SoC-independent
66 static struct prm_reset_src_map omap44xx_prm_reset_src_map
[] = {
67 { OMAP4430_GLOBAL_WARM_SW_RST_SHIFT
,
68 OMAP_GLOBAL_WARM_RST_SRC_ID_SHIFT
},
69 { OMAP4430_GLOBAL_COLD_RST_SHIFT
,
70 OMAP_GLOBAL_COLD_RST_SRC_ID_SHIFT
},
71 { OMAP4430_MPU_SECURITY_VIOL_RST_SHIFT
,
72 OMAP_SECU_VIOL_RST_SRC_ID_SHIFT
},
73 { OMAP4430_MPU_WDT_RST_SHIFT
, OMAP_MPU_WD_RST_SRC_ID_SHIFT
},
74 { OMAP4430_SECURE_WDT_RST_SHIFT
, OMAP_SECU_WD_RST_SRC_ID_SHIFT
},
75 { OMAP4430_EXTERNAL_WARM_RST_SHIFT
, OMAP_EXTWARM_RST_SRC_ID_SHIFT
},
76 { OMAP4430_VDD_MPU_VOLT_MGR_RST_SHIFT
,
77 OMAP_VDD_MPU_VM_RST_SRC_ID_SHIFT
},
78 { OMAP4430_VDD_IVA_VOLT_MGR_RST_SHIFT
,
79 OMAP_VDD_IVA_VM_RST_SRC_ID_SHIFT
},
80 { OMAP4430_VDD_CORE_VOLT_MGR_RST_SHIFT
,
81 OMAP_VDD_CORE_VM_RST_SRC_ID_SHIFT
},
82 { OMAP4430_ICEPICK_RST_SHIFT
, OMAP_ICEPICK_RST_SRC_ID_SHIFT
},
83 { OMAP4430_C2C_RST_SHIFT
, OMAP_C2C_RST_SRC_ID_SHIFT
},
87 /* PRM low-level functions */
89 /* Read a register in a CM/PRM instance in the PRM module */
90 static u32
omap4_prm_read_inst_reg(s16 inst
, u16 reg
)
92 return readl_relaxed(prm_base
.va
+ inst
+ reg
);
95 /* Write into a register in a CM/PRM instance in the PRM module */
96 static void omap4_prm_write_inst_reg(u32 val
, s16 inst
, u16 reg
)
98 writel_relaxed(val
, prm_base
.va
+ inst
+ reg
);
101 /* Read-modify-write a register in a PRM module. Caller must lock */
102 static u32
omap4_prm_rmw_inst_reg_bits(u32 mask
, u32 bits
, s16 inst
, s16 reg
)
106 v
= omap4_prm_read_inst_reg(inst
, reg
);
109 omap4_prm_write_inst_reg(v
, inst
, reg
);
117 * struct omap4_vp - OMAP4 VP register access description.
118 * @irqstatus_mpu: offset to IRQSTATUS_MPU register for VP
119 * @tranxdone_status: VP_TRANXDONE_ST bitmask in PRM_IRQSTATUS_MPU reg
123 u32 tranxdone_status
;
126 static struct omap4_vp omap4_vp
[] = {
127 [OMAP4_VP_VDD_MPU_ID
] = {
128 .irqstatus_mpu
= OMAP4_PRM_IRQSTATUS_MPU_2_OFFSET
,
129 .tranxdone_status
= OMAP4430_VP_MPU_TRANXDONE_ST_MASK
,
131 [OMAP4_VP_VDD_IVA_ID
] = {
132 .irqstatus_mpu
= OMAP4_PRM_IRQSTATUS_MPU_OFFSET
,
133 .tranxdone_status
= OMAP4430_VP_IVA_TRANXDONE_ST_MASK
,
135 [OMAP4_VP_VDD_CORE_ID
] = {
136 .irqstatus_mpu
= OMAP4_PRM_IRQSTATUS_MPU_OFFSET
,
137 .tranxdone_status
= OMAP4430_VP_CORE_TRANXDONE_ST_MASK
,
141 static u32
omap4_prm_vp_check_txdone(u8 vp_id
)
143 struct omap4_vp
*vp
= &omap4_vp
[vp_id
];
146 irqstatus
= omap4_prminst_read_inst_reg(OMAP4430_PRM_PARTITION
,
147 OMAP4430_PRM_OCP_SOCKET_INST
,
149 return irqstatus
& vp
->tranxdone_status
;
152 static void omap4_prm_vp_clear_txdone(u8 vp_id
)
154 struct omap4_vp
*vp
= &omap4_vp
[vp_id
];
156 omap4_prminst_write_inst_reg(vp
->tranxdone_status
,
157 OMAP4430_PRM_PARTITION
,
158 OMAP4430_PRM_OCP_SOCKET_INST
,
162 u32
omap4_prm_vcvp_read(u8 offset
)
164 s32 inst
= omap4_prmst_get_prm_dev_inst();
166 if (inst
== PRM_INSTANCE_UNKNOWN
)
169 return omap4_prminst_read_inst_reg(OMAP4430_PRM_PARTITION
,
173 void omap4_prm_vcvp_write(u32 val
, u8 offset
)
175 s32 inst
= omap4_prmst_get_prm_dev_inst();
177 if (inst
== PRM_INSTANCE_UNKNOWN
)
180 omap4_prminst_write_inst_reg(val
, OMAP4430_PRM_PARTITION
,
184 u32
omap4_prm_vcvp_rmw(u32 mask
, u32 bits
, u8 offset
)
186 s32 inst
= omap4_prmst_get_prm_dev_inst();
188 if (inst
== PRM_INSTANCE_UNKNOWN
)
191 return omap4_prminst_rmw_inst_reg_bits(mask
, bits
,
192 OMAP4430_PRM_PARTITION
,
197 static inline u32
_read_pending_irq_reg(u16 irqen_offs
, u16 irqst_offs
)
201 /* XXX read mask from RAM? */
202 mask
= omap4_prm_read_inst_reg(OMAP4430_PRM_OCP_SOCKET_INST
,
204 st
= omap4_prm_read_inst_reg(OMAP4430_PRM_OCP_SOCKET_INST
, irqst_offs
);
210 * omap44xx_prm_read_pending_irqs - read pending PRM MPU IRQs into @events
211 * @events: ptr to two consecutive u32s, preallocated by caller
213 * Read PRM_IRQSTATUS_MPU* bits, AND'ed with the currently-enabled PRM
214 * MPU IRQs, and store the result into the two u32s pointed to by @events.
217 static void omap44xx_prm_read_pending_irqs(unsigned long *events
)
221 for (i
= 0; i
< omap4_prcm_irq_setup
.nr_regs
; i
++)
222 events
[i
] = _read_pending_irq_reg(omap4_prcm_irq_setup
.mask
+
223 i
* 4, omap4_prcm_irq_setup
.ack
+ i
* 4);
227 * omap44xx_prm_ocp_barrier - force buffered MPU writes to the PRM to complete
229 * Force any buffered writes to the PRM IP block to complete. Needed
230 * by the PRM IRQ handler, which reads and writes directly to the IP
231 * block, to avoid race conditions after acknowledging or clearing IRQ
232 * bits. No return value.
234 static void omap44xx_prm_ocp_barrier(void)
236 omap4_prm_read_inst_reg(OMAP4430_PRM_OCP_SOCKET_INST
,
237 OMAP4_REVISION_PRM_OFFSET
);
241 * omap44xx_prm_save_and_clear_irqen - save/clear PRM_IRQENABLE_MPU* regs
242 * @saved_mask: ptr to a u32 array to save IRQENABLE bits
244 * Save the PRM_IRQENABLE_MPU and PRM_IRQENABLE_MPU_2 registers to
245 * @saved_mask. @saved_mask must be allocated by the caller.
246 * Intended to be used in the PRM interrupt handler suspend callback.
247 * The OCP barrier is needed to ensure the write to disable PRM
248 * interrupts reaches the PRM before returning; otherwise, spurious
249 * interrupts might occur. No return value.
251 static void omap44xx_prm_save_and_clear_irqen(u32
*saved_mask
)
256 for (i
= 0; i
< omap4_prcm_irq_setup
.nr_regs
; i
++) {
257 reg
= omap4_prcm_irq_setup
.mask
+ i
* 4;
260 omap4_prm_read_inst_reg(OMAP4430_PRM_OCP_SOCKET_INST
,
262 omap4_prm_write_inst_reg(0, OMAP4430_PRM_OCP_SOCKET_INST
, reg
);
266 omap4_prm_read_inst_reg(OMAP4430_PRM_OCP_SOCKET_INST
,
267 OMAP4_REVISION_PRM_OFFSET
);
271 * omap44xx_prm_restore_irqen - set PRM_IRQENABLE_MPU* registers from args
272 * @saved_mask: ptr to a u32 array of IRQENABLE bits saved previously
274 * Restore the PRM_IRQENABLE_MPU and PRM_IRQENABLE_MPU_2 registers from
275 * @saved_mask. Intended to be used in the PRM interrupt handler resume
276 * callback to restore values saved by omap44xx_prm_save_and_clear_irqen().
277 * No OCP barrier should be needed here; any pending PRM interrupts will fire
278 * once the writes reach the PRM. No return value.
280 static void omap44xx_prm_restore_irqen(u32
*saved_mask
)
284 for (i
= 0; i
< omap4_prcm_irq_setup
.nr_regs
; i
++)
285 omap4_prm_write_inst_reg(saved_mask
[i
],
286 OMAP4430_PRM_OCP_SOCKET_INST
,
287 omap4_prcm_irq_setup
.mask
+ i
* 4);
291 * omap44xx_prm_reconfigure_io_chain - clear latches and reconfigure I/O chain
293 * Clear any previously-latched I/O wakeup events and ensure that the
294 * I/O wakeup gates are aligned with the current mux settings. Works
295 * by asserting WUCLKIN, waiting for WUCLKOUT to be asserted, and then
296 * deasserting WUCLKIN and waiting for WUCLKOUT to be deasserted.
297 * No return value. XXX Are the final two steps necessary?
299 static void omap44xx_prm_reconfigure_io_chain(void)
302 s32 inst
= omap4_prmst_get_prm_dev_inst();
304 if (inst
== PRM_INSTANCE_UNKNOWN
)
307 /* Trigger WUCLKIN enable */
308 omap4_prm_rmw_inst_reg_bits(OMAP4430_WUCLK_CTRL_MASK
,
309 OMAP4430_WUCLK_CTRL_MASK
,
311 omap4_prcm_irq_setup
.pm_ctrl
);
313 (((omap4_prm_read_inst_reg(inst
,
314 omap4_prcm_irq_setup
.pm_ctrl
) &
315 OMAP4430_WUCLK_STATUS_MASK
) >>
316 OMAP4430_WUCLK_STATUS_SHIFT
) == 1),
317 MAX_IOPAD_LATCH_TIME
, i
);
318 if (i
== MAX_IOPAD_LATCH_TIME
)
319 pr_warn("PRM: I/O chain clock line assertion timed out\n");
321 /* Trigger WUCLKIN disable */
322 omap4_prm_rmw_inst_reg_bits(OMAP4430_WUCLK_CTRL_MASK
, 0x0,
324 omap4_prcm_irq_setup
.pm_ctrl
);
326 (((omap4_prm_read_inst_reg(inst
,
327 omap4_prcm_irq_setup
.pm_ctrl
) &
328 OMAP4430_WUCLK_STATUS_MASK
) >>
329 OMAP4430_WUCLK_STATUS_SHIFT
) == 0),
330 MAX_IOPAD_LATCH_TIME
, i
);
331 if (i
== MAX_IOPAD_LATCH_TIME
)
332 pr_warn("PRM: I/O chain clock line deassertion timed out\n");
338 * omap44xx_prm_enable_io_wakeup - enable wakeup events from I/O wakeup latches
340 * Activates the I/O wakeup event latches and allows events logged by
341 * those latches to signal a wakeup event to the PRCM. For I/O wakeups
342 * to occur, WAKEUPENABLE bits must be set in the pad mux registers, and
343 * omap44xx_prm_reconfigure_io_chain() must be called. No return value.
345 static void __init
omap44xx_prm_enable_io_wakeup(void)
347 s32 inst
= omap4_prmst_get_prm_dev_inst();
349 if (inst
== PRM_INSTANCE_UNKNOWN
)
352 omap4_prm_rmw_inst_reg_bits(OMAP4430_GLOBAL_WUEN_MASK
,
353 OMAP4430_GLOBAL_WUEN_MASK
,
355 omap4_prcm_irq_setup
.pm_ctrl
);
359 * omap44xx_prm_read_reset_sources - return the last SoC reset source
361 * Return a u32 representing the last reset sources of the SoC. The
362 * returned reset source bits are standardized across OMAP SoCs.
364 static u32
omap44xx_prm_read_reset_sources(void)
366 struct prm_reset_src_map
*p
;
369 s32 inst
= omap4_prmst_get_prm_dev_inst();
371 if (inst
== PRM_INSTANCE_UNKNOWN
)
375 v
= omap4_prm_read_inst_reg(inst
,
378 p
= omap44xx_prm_reset_src_map
;
379 while (p
->reg_shift
>= 0 && p
->std_shift
>= 0) {
380 if (v
& (1 << p
->reg_shift
))
381 r
|= 1 << p
->std_shift
;
389 * omap44xx_prm_was_any_context_lost_old - was module hardware context lost?
390 * @part: PRM partition ID (e.g., OMAP4430_PRM_PARTITION)
391 * @inst: PRM instance offset (e.g., OMAP4430_PRM_MPU_INST)
392 * @idx: CONTEXT register offset
394 * Return 1 if any bits were set in the *_CONTEXT_* register
395 * identified by (@part, @inst, @idx), which means that some context
396 * was lost for that module; otherwise, return 0.
398 static bool omap44xx_prm_was_any_context_lost_old(u8 part
, s16 inst
, u16 idx
)
400 return (omap4_prminst_read_inst_reg(part
, inst
, idx
)) ? 1 : 0;
404 * omap44xx_prm_clear_context_lost_flags_old - clear context loss flags
405 * @part: PRM partition ID (e.g., OMAP4430_PRM_PARTITION)
406 * @inst: PRM instance offset (e.g., OMAP4430_PRM_MPU_INST)
407 * @idx: CONTEXT register offset
409 * Clear hardware context loss bits for the module identified by
410 * (@part, @inst, @idx). No return value. XXX Writes to reserved bits;
411 * is there a way to avoid this?
413 static void omap44xx_prm_clear_context_loss_flags_old(u8 part
, s16 inst
,
416 omap4_prminst_write_inst_reg(0xffffffff, part
, inst
, idx
);
419 /* Powerdomain low-level functions */
421 static int omap4_pwrdm_set_next_pwrst(struct powerdomain
*pwrdm
, u8 pwrst
)
423 omap4_prminst_rmw_inst_reg_bits(OMAP_POWERSTATE_MASK
,
424 (pwrst
<< OMAP_POWERSTATE_SHIFT
),
425 pwrdm
->prcm_partition
,
426 pwrdm
->prcm_offs
, OMAP4_PM_PWSTCTRL
);
430 static int omap4_pwrdm_read_next_pwrst(struct powerdomain
*pwrdm
)
434 v
= omap4_prminst_read_inst_reg(pwrdm
->prcm_partition
, pwrdm
->prcm_offs
,
436 v
&= OMAP_POWERSTATE_MASK
;
437 v
>>= OMAP_POWERSTATE_SHIFT
;
442 static int omap4_pwrdm_read_pwrst(struct powerdomain
*pwrdm
)
446 v
= omap4_prminst_read_inst_reg(pwrdm
->prcm_partition
, pwrdm
->prcm_offs
,
448 v
&= OMAP_POWERSTATEST_MASK
;
449 v
>>= OMAP_POWERSTATEST_SHIFT
;
454 static int omap4_pwrdm_read_prev_pwrst(struct powerdomain
*pwrdm
)
458 v
= omap4_prminst_read_inst_reg(pwrdm
->prcm_partition
, pwrdm
->prcm_offs
,
460 v
&= OMAP4430_LASTPOWERSTATEENTERED_MASK
;
461 v
>>= OMAP4430_LASTPOWERSTATEENTERED_SHIFT
;
466 static int omap4_pwrdm_set_lowpwrstchange(struct powerdomain
*pwrdm
)
468 omap4_prminst_rmw_inst_reg_bits(OMAP4430_LOWPOWERSTATECHANGE_MASK
,
469 (1 << OMAP4430_LOWPOWERSTATECHANGE_SHIFT
),
470 pwrdm
->prcm_partition
,
471 pwrdm
->prcm_offs
, OMAP4_PM_PWSTCTRL
);
475 static int omap4_pwrdm_clear_all_prev_pwrst(struct powerdomain
*pwrdm
)
477 omap4_prminst_rmw_inst_reg_bits(OMAP4430_LASTPOWERSTATEENTERED_MASK
,
478 OMAP4430_LASTPOWERSTATEENTERED_MASK
,
479 pwrdm
->prcm_partition
,
480 pwrdm
->prcm_offs
, OMAP4_PM_PWSTST
);
484 static int omap4_pwrdm_set_logic_retst(struct powerdomain
*pwrdm
, u8 pwrst
)
488 v
= pwrst
<< __ffs(OMAP4430_LOGICRETSTATE_MASK
);
489 omap4_prminst_rmw_inst_reg_bits(OMAP4430_LOGICRETSTATE_MASK
, v
,
490 pwrdm
->prcm_partition
, pwrdm
->prcm_offs
,
496 static int omap4_pwrdm_set_mem_onst(struct powerdomain
*pwrdm
, u8 bank
,
501 m
= omap2_pwrdm_get_mem_bank_onstate_mask(bank
);
503 omap4_prminst_rmw_inst_reg_bits(m
, (pwrst
<< __ffs(m
)),
504 pwrdm
->prcm_partition
, pwrdm
->prcm_offs
,
510 static int omap4_pwrdm_set_mem_retst(struct powerdomain
*pwrdm
, u8 bank
,
515 m
= omap2_pwrdm_get_mem_bank_retst_mask(bank
);
517 omap4_prminst_rmw_inst_reg_bits(m
, (pwrst
<< __ffs(m
)),
518 pwrdm
->prcm_partition
, pwrdm
->prcm_offs
,
524 static int omap4_pwrdm_read_logic_pwrst(struct powerdomain
*pwrdm
)
528 v
= omap4_prminst_read_inst_reg(pwrdm
->prcm_partition
, pwrdm
->prcm_offs
,
530 v
&= OMAP4430_LOGICSTATEST_MASK
;
531 v
>>= OMAP4430_LOGICSTATEST_SHIFT
;
536 static int omap4_pwrdm_read_logic_retst(struct powerdomain
*pwrdm
)
540 v
= omap4_prminst_read_inst_reg(pwrdm
->prcm_partition
, pwrdm
->prcm_offs
,
542 v
&= OMAP4430_LOGICRETSTATE_MASK
;
543 v
>>= OMAP4430_LOGICRETSTATE_SHIFT
;
549 * omap4_pwrdm_read_prev_logic_pwrst - read the previous logic powerstate
550 * @pwrdm: struct powerdomain * to read the state for
552 * Reads the previous logic powerstate for a powerdomain. This
553 * function must determine the previous logic powerstate by first
554 * checking the previous powerstate for the domain. If that was OFF,
555 * then logic has been lost. If previous state was RETENTION, the
556 * function reads the setting for the next retention logic state to
557 * see the actual value. In every other case, the logic is
558 * retained. Returns either PWRDM_POWER_OFF or PWRDM_POWER_RET
559 * depending whether the logic was retained or not.
561 static int omap4_pwrdm_read_prev_logic_pwrst(struct powerdomain
*pwrdm
)
565 state
= omap4_pwrdm_read_prev_pwrst(pwrdm
);
567 if (state
== PWRDM_POWER_OFF
)
568 return PWRDM_POWER_OFF
;
570 if (state
!= PWRDM_POWER_RET
)
571 return PWRDM_POWER_RET
;
573 return omap4_pwrdm_read_logic_retst(pwrdm
);
576 static int omap4_pwrdm_read_mem_pwrst(struct powerdomain
*pwrdm
, u8 bank
)
580 m
= omap2_pwrdm_get_mem_bank_stst_mask(bank
);
582 v
= omap4_prminst_read_inst_reg(pwrdm
->prcm_partition
, pwrdm
->prcm_offs
,
590 static int omap4_pwrdm_read_mem_retst(struct powerdomain
*pwrdm
, u8 bank
)
594 m
= omap2_pwrdm_get_mem_bank_retst_mask(bank
);
596 v
= omap4_prminst_read_inst_reg(pwrdm
->prcm_partition
, pwrdm
->prcm_offs
,
605 * omap4_pwrdm_read_prev_mem_pwrst - reads the previous memory powerstate
606 * @pwrdm: struct powerdomain * to read mem powerstate for
607 * @bank: memory bank index
609 * Reads the previous memory powerstate for a powerdomain. This
610 * function must determine the previous memory powerstate by first
611 * checking the previous powerstate for the domain. If that was OFF,
612 * then logic has been lost. If previous state was RETENTION, the
613 * function reads the setting for the next memory retention state to
614 * see the actual value. In every other case, the logic is
615 * retained. Returns either PWRDM_POWER_OFF or PWRDM_POWER_RET
616 * depending whether logic was retained or not.
618 static int omap4_pwrdm_read_prev_mem_pwrst(struct powerdomain
*pwrdm
, u8 bank
)
622 state
= omap4_pwrdm_read_prev_pwrst(pwrdm
);
624 if (state
== PWRDM_POWER_OFF
)
625 return PWRDM_POWER_OFF
;
627 if (state
!= PWRDM_POWER_RET
)
628 return PWRDM_POWER_RET
;
630 return omap4_pwrdm_read_mem_retst(pwrdm
, bank
);
633 static int omap4_pwrdm_wait_transition(struct powerdomain
*pwrdm
)
638 * REVISIT: pwrdm_wait_transition() may be better implemented
639 * via a callback and a periodic timer check -- how long do we expect
640 * powerdomain transitions to take?
643 /* XXX Is this udelay() value meaningful? */
644 while ((omap4_prminst_read_inst_reg(pwrdm
->prcm_partition
,
647 OMAP_INTRANSITION_MASK
) &&
648 (c
++ < PWRDM_TRANSITION_BAILOUT
))
651 if (c
> PWRDM_TRANSITION_BAILOUT
) {
652 pr_err("powerdomain: %s: waited too long to complete transition\n",
657 pr_debug("powerdomain: completed transition in %d loops\n", c
);
662 static int omap4_check_vcvp(void)
664 if (prm_features
& PRM_HAS_VOLTAGE
)
670 struct pwrdm_ops omap4_pwrdm_operations
= {
671 .pwrdm_set_next_pwrst
= omap4_pwrdm_set_next_pwrst
,
672 .pwrdm_read_next_pwrst
= omap4_pwrdm_read_next_pwrst
,
673 .pwrdm_read_pwrst
= omap4_pwrdm_read_pwrst
,
674 .pwrdm_read_prev_pwrst
= omap4_pwrdm_read_prev_pwrst
,
675 .pwrdm_set_lowpwrstchange
= omap4_pwrdm_set_lowpwrstchange
,
676 .pwrdm_clear_all_prev_pwrst
= omap4_pwrdm_clear_all_prev_pwrst
,
677 .pwrdm_set_logic_retst
= omap4_pwrdm_set_logic_retst
,
678 .pwrdm_read_logic_pwrst
= omap4_pwrdm_read_logic_pwrst
,
679 .pwrdm_read_prev_logic_pwrst
= omap4_pwrdm_read_prev_logic_pwrst
,
680 .pwrdm_read_logic_retst
= omap4_pwrdm_read_logic_retst
,
681 .pwrdm_read_mem_pwrst
= omap4_pwrdm_read_mem_pwrst
,
682 .pwrdm_read_mem_retst
= omap4_pwrdm_read_mem_retst
,
683 .pwrdm_read_prev_mem_pwrst
= omap4_pwrdm_read_prev_mem_pwrst
,
684 .pwrdm_set_mem_onst
= omap4_pwrdm_set_mem_onst
,
685 .pwrdm_set_mem_retst
= omap4_pwrdm_set_mem_retst
,
686 .pwrdm_wait_transition
= omap4_pwrdm_wait_transition
,
687 .pwrdm_has_voltdm
= omap4_check_vcvp
,
690 static int omap44xx_prm_late_init(void);
695 static struct prm_ll_data omap44xx_prm_ll_data
= {
696 .read_reset_sources
= &omap44xx_prm_read_reset_sources
,
697 .was_any_context_lost_old
= &omap44xx_prm_was_any_context_lost_old
,
698 .clear_context_loss_flags_old
= &omap44xx_prm_clear_context_loss_flags_old
,
699 .late_init
= &omap44xx_prm_late_init
,
700 .assert_hardreset
= omap4_prminst_assert_hardreset
,
701 .deassert_hardreset
= omap4_prminst_deassert_hardreset
,
702 .is_hardreset_asserted
= omap4_prminst_is_hardreset_asserted
,
703 .reset_system
= omap4_prminst_global_warm_sw_reset
,
704 .vp_check_txdone
= omap4_prm_vp_check_txdone
,
705 .vp_clear_txdone
= omap4_prm_vp_clear_txdone
,
708 static const struct omap_prcm_init_data
*prm_init_data
;
710 int __init
omap44xx_prm_init(const struct omap_prcm_init_data
*data
)
712 omap_prm_base_init();
714 prm_init_data
= data
;
716 if (data
->flags
& PRM_HAS_IO_WAKEUP
)
717 prm_features
|= PRM_HAS_IO_WAKEUP
;
719 if (data
->flags
& PRM_HAS_VOLTAGE
)
720 prm_features
|= PRM_HAS_VOLTAGE
;
722 omap4_prminst_set_prm_dev_inst(data
->device_inst_offset
);
724 /* Add AM437X specific differences */
725 if (of_device_is_compatible(data
->np
, "ti,am4-prcm")) {
726 omap4_prcm_irq_setup
.nr_irqs
= 1;
727 omap4_prcm_irq_setup
.nr_regs
= 1;
728 omap4_prcm_irq_setup
.pm_ctrl
= AM43XX_PRM_IO_PMCTRL_OFFSET
;
729 omap4_prcm_irq_setup
.ack
= AM43XX_PRM_IRQSTATUS_MPU_OFFSET
;
730 omap4_prcm_irq_setup
.mask
= AM43XX_PRM_IRQENABLE_MPU_OFFSET
;
733 return prm_register(&omap44xx_prm_ll_data
);
736 static int omap44xx_prm_late_init(void)
740 if (!(prm_features
& PRM_HAS_IO_WAKEUP
))
743 irq_num
= of_irq_get(prm_init_data
->np
, 0);
744 if (irq_num
== -EPROBE_DEFER
)
747 omap4_prcm_irq_setup
.irq
= irq_num
;
749 omap44xx_prm_enable_io_wakeup();
751 return omap_prcm_register_chain_handler(&omap4_prcm_irq_setup
);
754 static void __exit
omap44xx_prm_exit(void)
756 prm_unregister(&omap44xx_prm_ll_data
);
758 __exitcall(omap44xx_prm_exit
);