aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/mach-omap2/prm2xxx.c
diff options
context:
space:
mode:
authorPaul Walmsley <paul@pwsan.com>2012-10-21 03:01:13 -0400
committerPaul Walmsley <paul@pwsan.com>2012-10-21 03:01:13 -0400
commit2bb2a5d30abb0dc99d074877bfad2056142c730b (patch)
tree6da1f32009cec6777baa0a474f7c2579cc57a6bc /arch/arm/mach-omap2/prm2xxx.c
parentb5c5353d417580f7a6ac21a0954f1c500a5cc4f5 (diff)
ARM: OMAP2+: PRM: create PRM reset source API for the watchdog timer driver
The OMAP watchdog timer driver needs to determine what caused the SoC to reset for its GETBOOTSTATUS ioctl. So, define a set of standard reset sources across OMAP SoCs. For OMAP2xxx, 3xxx, and 4xxx SoCs, define mappings from the SoC-specific reset source register bits to the standardized reset source IDs. Create SoC-specific PRM functions that read the appropriate per-SoC register and use the mapping to return the standardized reset bits. Register the SoC-specific PRM functions with the common PRM code via prm_register(). Create a function in the common PRM code, prm_read_reset_sources(), that calls the SoC-specific function, registered during boot. This patch does not yet handle some SoCs, such as AM33xx. Those SoCs were not handled by the code this will replace. Signed-off-by: Paul Walmsley <paul@pwsan.com>
Diffstat (limited to 'arch/arm/mach-omap2/prm2xxx.c')
-rw-r--r--arch/arm/mach-omap2/prm2xxx.c68
1 files changed, 68 insertions, 0 deletions
diff --git a/arch/arm/mach-omap2/prm2xxx.c b/arch/arm/mach-omap2/prm2xxx.c
index 9cdb4e5e3d80..e2860f9c111d 100644
--- a/arch/arm/mach-omap2/prm2xxx.c
+++ b/arch/arm/mach-omap2/prm2xxx.c
@@ -29,6 +29,46 @@
29#include "cm2xxx_3xxx.h" 29#include "cm2xxx_3xxx.h"
30#include "prm-regbits-24xx.h" 30#include "prm-regbits-24xx.h"
31 31
32/*
33 * omap2xxx_prm_reset_src_map - map from bits in the PRM_RSTST_WKUP
34 * hardware register (which are specific to the OMAP2xxx SoCs) to
35 * reset source ID bit shifts (which is an OMAP SoC-independent
36 * enumeration)
37 */
38static struct prm_reset_src_map omap2xxx_prm_reset_src_map[] = {
39 { OMAP_GLOBALCOLD_RST_SHIFT, OMAP_GLOBAL_COLD_RST_SRC_ID_SHIFT },
40 { OMAP_GLOBALWARM_RST_SHIFT, OMAP_GLOBAL_WARM_RST_SRC_ID_SHIFT },
41 { OMAP24XX_SECU_VIOL_RST_SHIFT, OMAP_SECU_VIOL_RST_SRC_ID_SHIFT },
42 { OMAP24XX_MPU_WD_RST_SHIFT, OMAP_MPU_WD_RST_SRC_ID_SHIFT },
43 { OMAP24XX_SECU_WD_RST_SHIFT, OMAP_SECU_WD_RST_SRC_ID_SHIFT },
44 { OMAP24XX_EXTWMPU_RST_SHIFT, OMAP_EXTWARM_RST_SRC_ID_SHIFT },
45 { -1, -1 },
46};
47
48/**
49 * omap2xxx_prm_read_reset_sources - return the last SoC reset source
50 *
51 * Return a u32 representing the last reset sources of the SoC. The
52 * returned reset source bits are standardized across OMAP SoCs.
53 */
54static u32 omap2xxx_prm_read_reset_sources(void)
55{
56 struct prm_reset_src_map *p;
57 u32 r = 0;
58 u32 v;
59
60 v = omap2_prm_read_mod_reg(WKUP_MOD, OMAP2_RM_RSTST);
61
62 p = omap2xxx_prm_reset_src_map;
63 while (p->reg_shift >= 0 && p->std_shift >= 0) {
64 if (v & (1 << p->reg_shift))
65 r |= 1 << p->std_shift;
66 p++;
67 }
68
69 return r;
70}
71
32int omap2xxx_clkdm_sleep(struct clockdomain *clkdm) 72int omap2xxx_clkdm_sleep(struct clockdomain *clkdm)
33{ 73{
34 omap2_prm_set_mod_reg_bits(OMAP24XX_FORCESTATE_MASK, 74 omap2_prm_set_mod_reg_bits(OMAP24XX_FORCESTATE_MASK,
@@ -56,3 +96,31 @@ struct pwrdm_ops omap2_pwrdm_operations = {
56 .pwrdm_read_mem_retst = omap2_pwrdm_read_mem_retst, 96 .pwrdm_read_mem_retst = omap2_pwrdm_read_mem_retst,
57 .pwrdm_wait_transition = omap2_pwrdm_wait_transition, 97 .pwrdm_wait_transition = omap2_pwrdm_wait_transition,
58}; 98};
99
100/*
101 *
102 */
103
104static struct prm_ll_data omap2xxx_prm_ll_data = {
105 .read_reset_sources = &omap2xxx_prm_read_reset_sources,
106};
107
108static int __init omap2xxx_prm_init(void)
109{
110 if (!cpu_is_omap24xx())
111 return 0;
112
113 return prm_register(&omap2xxx_prm_ll_data);
114}
115subsys_initcall(omap2xxx_prm_init);
116
117static void __exit omap2xxx_prm_exit(void)
118{
119 if (!cpu_is_omap24xx())
120 return;
121
122 /* Should never happen */
123 WARN(prm_unregister(&omap2xxx_prm_ll_data),
124 "%s: prm_ll_data function pointer mismatch\n", __func__);
125}
126__exitcall(omap2xxx_prm_exit);