2 * OMAP2xxx PRM module functions
4 * Copyright (C) 2010-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/errno.h>
17 #include <linux/err.h>
19 #include <linux/irq.h>
25 #include "powerdomain.h"
26 #include "clockdomain.h"
28 #include "cm2xxx_3xxx.h"
29 #include "prm-regbits-24xx.h"
32 * omap2xxx_prm_reset_src_map - map from bits in the PRM_RSTST_WKUP
33 * hardware register (which are specific to the OMAP2xxx SoCs) to
34 * reset source ID bit shifts (which is an OMAP SoC-independent
37 static struct prm_reset_src_map omap2xxx_prm_reset_src_map
[] = {
38 { OMAP_GLOBALCOLD_RST_SHIFT
, OMAP_GLOBAL_COLD_RST_SRC_ID_SHIFT
},
39 { OMAP_GLOBALWARM_RST_SHIFT
, OMAP_GLOBAL_WARM_RST_SRC_ID_SHIFT
},
40 { OMAP24XX_SECU_VIOL_RST_SHIFT
, OMAP_SECU_VIOL_RST_SRC_ID_SHIFT
},
41 { OMAP24XX_MPU_WD_RST_SHIFT
, OMAP_MPU_WD_RST_SRC_ID_SHIFT
},
42 { OMAP24XX_SECU_WD_RST_SHIFT
, OMAP_SECU_WD_RST_SRC_ID_SHIFT
},
43 { OMAP24XX_EXTWMPU_RST_SHIFT
, OMAP_EXTWARM_RST_SRC_ID_SHIFT
},
48 * omap2xxx_prm_read_reset_sources - return the last SoC reset source
50 * Return a u32 representing the last reset sources of the SoC. The
51 * returned reset source bits are standardized across OMAP SoCs.
53 static u32
omap2xxx_prm_read_reset_sources(void)
55 struct prm_reset_src_map
*p
;
59 v
= omap2_prm_read_mod_reg(WKUP_MOD
, OMAP2_RM_RSTST
);
61 p
= omap2xxx_prm_reset_src_map
;
62 while (p
->reg_shift
>= 0 && p
->std_shift
>= 0) {
63 if (v
& (1 << p
->reg_shift
))
64 r
|= 1 << p
->std_shift
;
72 * omap2xxx_prm_dpll_reset - use DPLL reset to reboot the OMAP SoC
74 * Set the DPLL reset bit, which should reboot the SoC. This is the
75 * recommended way to restart the SoC. No return value.
77 void omap2xxx_prm_dpll_reset(void)
79 omap2_prm_set_mod_reg_bits(OMAP_RST_DPLL3_MASK
, WKUP_MOD
,
82 omap2_prm_read_mod_reg(WKUP_MOD
, OMAP2_RM_RSTCTRL
);
85 int omap2xxx_clkdm_sleep(struct clockdomain
*clkdm
)
87 omap2_prm_set_mod_reg_bits(OMAP24XX_FORCESTATE_MASK
,
88 clkdm
->pwrdm
.ptr
->prcm_offs
,
93 int omap2xxx_clkdm_wakeup(struct clockdomain
*clkdm
)
95 omap2_prm_clear_mod_reg_bits(OMAP24XX_FORCESTATE_MASK
,
96 clkdm
->pwrdm
.ptr
->prcm_offs
,
101 struct pwrdm_ops omap2_pwrdm_operations
= {
102 .pwrdm_set_next_pwrst
= omap2_pwrdm_set_next_pwrst
,
103 .pwrdm_read_next_pwrst
= omap2_pwrdm_read_next_pwrst
,
104 .pwrdm_read_pwrst
= omap2_pwrdm_read_pwrst
,
105 .pwrdm_set_logic_retst
= omap2_pwrdm_set_logic_retst
,
106 .pwrdm_set_mem_onst
= omap2_pwrdm_set_mem_onst
,
107 .pwrdm_set_mem_retst
= omap2_pwrdm_set_mem_retst
,
108 .pwrdm_read_mem_pwrst
= omap2_pwrdm_read_mem_pwrst
,
109 .pwrdm_read_mem_retst
= omap2_pwrdm_read_mem_retst
,
110 .pwrdm_wait_transition
= omap2_pwrdm_wait_transition
,
117 static struct prm_ll_data omap2xxx_prm_ll_data
= {
118 .read_reset_sources
= &omap2xxx_prm_read_reset_sources
,
121 int __init
omap2xxx_prm_init(void)
123 if (!cpu_is_omap24xx())
126 return prm_register(&omap2xxx_prm_ll_data
);
129 static void __exit
omap2xxx_prm_exit(void)
131 if (!cpu_is_omap24xx())
134 /* Should never happen */
135 WARN(prm_unregister(&omap2xxx_prm_ll_data
),
136 "%s: prm_ll_data function pointer mismatch\n", __func__
);
138 __exitcall(omap2xxx_prm_exit
);