Commit | Line | Data |
---|---|---|
49815399 PW |
1 | /* |
2 | * OMAP2xxx PRM module functions | |
3 | * | |
4 | * Copyright (C) 2010-2012 Texas Instruments, Inc. | |
5 | * Copyright (C) 2010 Nokia Corporation | |
6 | * BenoƮt Cousson | |
7 | * Paul Walmsley | |
8 | * Rajendra Nayak <rnayak@ti.com> | |
9 | * | |
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. | |
13 | */ | |
14 | ||
15 | #include <linux/kernel.h> | |
16 | #include <linux/errno.h> | |
17 | #include <linux/err.h> | |
18 | #include <linux/io.h> | |
19 | #include <linux/irq.h> | |
20 | ||
21 | #include "common.h" | |
22 | #include <plat/cpu.h> | |
23 | #include <plat/prcm.h> | |
24 | ||
25 | #include "vp.h" | |
26 | #include "powerdomain.h" | |
4bd5259e | 27 | #include "clockdomain.h" |
49815399 PW |
28 | #include "prm2xxx.h" |
29 | #include "cm2xxx_3xxx.h" | |
30 | #include "prm-regbits-24xx.h" | |
31 | ||
2bb2a5d3 PW |
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 | */ | |
38 | static 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 | */ | |
54 | static 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 | ||
4bd5259e PW |
72 | int omap2xxx_clkdm_sleep(struct clockdomain *clkdm) |
73 | { | |
74 | omap2_prm_set_mod_reg_bits(OMAP24XX_FORCESTATE_MASK, | |
75 | clkdm->pwrdm.ptr->prcm_offs, | |
76 | OMAP2_PM_PWSTCTRL); | |
77 | return 0; | |
78 | } | |
79 | ||
80 | int omap2xxx_clkdm_wakeup(struct clockdomain *clkdm) | |
81 | { | |
82 | omap2_prm_clear_mod_reg_bits(OMAP24XX_FORCESTATE_MASK, | |
83 | clkdm->pwrdm.ptr->prcm_offs, | |
84 | OMAP2_PM_PWSTCTRL); | |
85 | return 0; | |
86 | } | |
87 | ||
49815399 PW |
88 | struct pwrdm_ops omap2_pwrdm_operations = { |
89 | .pwrdm_set_next_pwrst = omap2_pwrdm_set_next_pwrst, | |
90 | .pwrdm_read_next_pwrst = omap2_pwrdm_read_next_pwrst, | |
91 | .pwrdm_read_pwrst = omap2_pwrdm_read_pwrst, | |
92 | .pwrdm_set_logic_retst = omap2_pwrdm_set_logic_retst, | |
93 | .pwrdm_set_mem_onst = omap2_pwrdm_set_mem_onst, | |
94 | .pwrdm_set_mem_retst = omap2_pwrdm_set_mem_retst, | |
95 | .pwrdm_read_mem_pwrst = omap2_pwrdm_read_mem_pwrst, | |
96 | .pwrdm_read_mem_retst = omap2_pwrdm_read_mem_retst, | |
97 | .pwrdm_wait_transition = omap2_pwrdm_wait_transition, | |
98 | }; | |
2bb2a5d3 PW |
99 | |
100 | /* | |
101 | * | |
102 | */ | |
103 | ||
104 | static struct prm_ll_data omap2xxx_prm_ll_data = { | |
105 | .read_reset_sources = &omap2xxx_prm_read_reset_sources, | |
106 | }; | |
107 | ||
108 | static 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 | } | |
115 | subsys_initcall(omap2xxx_prm_init); | |
116 | ||
117 | static 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); |