This source file includes following definitions.
- omap2_prm_is_hardreset_asserted
- omap2_prm_assert_hardreset
- omap2_prm_deassert_hardreset
- omap2_pwrdm_set_mem_onst
- omap2_pwrdm_set_mem_retst
- omap2_pwrdm_read_mem_pwrst
- omap2_pwrdm_read_mem_retst
- omap2_pwrdm_set_logic_retst
- omap2_pwrdm_wait_transition
- omap2_clkdm_add_wkdep
- omap2_clkdm_del_wkdep
- omap2_clkdm_read_wkdep
- omap2_clkdm_clear_all_wkdeps
1
2
3
4
5
6
7
8
9
10
11 #include <linux/kernel.h>
12 #include <linux/errno.h>
13 #include <linux/err.h>
14 #include <linux/io.h>
15
16 #include "powerdomain.h"
17 #include "prm2xxx_3xxx.h"
18 #include "prm-regbits-24xx.h"
19 #include "clockdomain.h"
20
21
22
23
24
25
26
27
28
29
30
31
32
33 int omap2_prm_is_hardreset_asserted(u8 shift, u8 part, s16 prm_mod, u16 offset)
34 {
35 return omap2_prm_read_mod_bits_shift(prm_mod, OMAP2_RM_RSTCTRL,
36 (1 << shift));
37 }
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53 int omap2_prm_assert_hardreset(u8 shift, u8 part, s16 prm_mod, u16 offset)
54 {
55 u32 mask;
56
57 mask = 1 << shift;
58 omap2_prm_rmw_mod_reg_bits(mask, mask, prm_mod, OMAP2_RM_RSTCTRL);
59
60 return 0;
61 }
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82 int omap2_prm_deassert_hardreset(u8 rst_shift, u8 st_shift, u8 part,
83 s16 prm_mod, u16 rst_offset, u16 st_offset)
84 {
85 u32 rst, st;
86 int c;
87
88 rst = 1 << rst_shift;
89 st = 1 << st_shift;
90
91
92 if (omap2_prm_read_mod_bits_shift(prm_mod, OMAP2_RM_RSTCTRL, rst) == 0)
93 return -EEXIST;
94
95
96 omap2_prm_rmw_mod_reg_bits(0xffffffff, st, prm_mod, OMAP2_RM_RSTST);
97
98 omap2_prm_rmw_mod_reg_bits(rst, 0, prm_mod, OMAP2_RM_RSTCTRL);
99
100 omap_test_timeout(omap2_prm_read_mod_bits_shift(prm_mod, OMAP2_RM_RSTST,
101 st),
102 MAX_MODULE_HARDRESET_WAIT, c);
103
104 return (c == MAX_MODULE_HARDRESET_WAIT) ? -EBUSY : 0;
105 }
106
107
108
109
110
111 int omap2_pwrdm_set_mem_onst(struct powerdomain *pwrdm, u8 bank,
112 u8 pwrst)
113 {
114 u32 m;
115
116 m = omap2_pwrdm_get_mem_bank_onstate_mask(bank);
117
118 omap2_prm_rmw_mod_reg_bits(m, (pwrst << __ffs(m)), pwrdm->prcm_offs,
119 OMAP2_PM_PWSTCTRL);
120
121 return 0;
122 }
123
124 int omap2_pwrdm_set_mem_retst(struct powerdomain *pwrdm, u8 bank,
125 u8 pwrst)
126 {
127 u32 m;
128
129 m = omap2_pwrdm_get_mem_bank_retst_mask(bank);
130
131 omap2_prm_rmw_mod_reg_bits(m, (pwrst << __ffs(m)), pwrdm->prcm_offs,
132 OMAP2_PM_PWSTCTRL);
133
134 return 0;
135 }
136
137 int omap2_pwrdm_read_mem_pwrst(struct powerdomain *pwrdm, u8 bank)
138 {
139 u32 m;
140
141 m = omap2_pwrdm_get_mem_bank_stst_mask(bank);
142
143 return omap2_prm_read_mod_bits_shift(pwrdm->prcm_offs, OMAP2_PM_PWSTST,
144 m);
145 }
146
147 int omap2_pwrdm_read_mem_retst(struct powerdomain *pwrdm, u8 bank)
148 {
149 u32 m;
150
151 m = omap2_pwrdm_get_mem_bank_retst_mask(bank);
152
153 return omap2_prm_read_mod_bits_shift(pwrdm->prcm_offs,
154 OMAP2_PM_PWSTCTRL, m);
155 }
156
157 int omap2_pwrdm_set_logic_retst(struct powerdomain *pwrdm, u8 pwrst)
158 {
159 u32 v;
160
161 v = pwrst << __ffs(OMAP_LOGICRETSTATE_MASK);
162 omap2_prm_rmw_mod_reg_bits(OMAP_LOGICRETSTATE_MASK, v, pwrdm->prcm_offs,
163 OMAP2_PM_PWSTCTRL);
164
165 return 0;
166 }
167
168 int omap2_pwrdm_wait_transition(struct powerdomain *pwrdm)
169 {
170 u32 c = 0;
171
172
173
174
175
176
177
178
179 while ((omap2_prm_read_mod_reg(pwrdm->prcm_offs, OMAP2_PM_PWSTST) &
180 OMAP_INTRANSITION_MASK) &&
181 (c++ < PWRDM_TRANSITION_BAILOUT))
182 udelay(1);
183
184 if (c > PWRDM_TRANSITION_BAILOUT) {
185 pr_err("powerdomain: %s: waited too long to complete transition\n",
186 pwrdm->name);
187 return -EAGAIN;
188 }
189
190 pr_debug("powerdomain: completed transition in %d loops\n", c);
191
192 return 0;
193 }
194
195 int omap2_clkdm_add_wkdep(struct clockdomain *clkdm1,
196 struct clockdomain *clkdm2)
197 {
198 omap2_prm_set_mod_reg_bits((1 << clkdm2->dep_bit),
199 clkdm1->pwrdm.ptr->prcm_offs, PM_WKDEP);
200 return 0;
201 }
202
203 int omap2_clkdm_del_wkdep(struct clockdomain *clkdm1,
204 struct clockdomain *clkdm2)
205 {
206 omap2_prm_clear_mod_reg_bits((1 << clkdm2->dep_bit),
207 clkdm1->pwrdm.ptr->prcm_offs, PM_WKDEP);
208 return 0;
209 }
210
211 int omap2_clkdm_read_wkdep(struct clockdomain *clkdm1,
212 struct clockdomain *clkdm2)
213 {
214 return omap2_prm_read_mod_bits_shift(clkdm1->pwrdm.ptr->prcm_offs,
215 PM_WKDEP, (1 << clkdm2->dep_bit));
216 }
217
218
219 int omap2_clkdm_clear_all_wkdeps(struct clockdomain *clkdm)
220 {
221 struct clkdm_dep *cd;
222 u32 mask = 0;
223
224 for (cd = clkdm->wkdep_srcs; cd && cd->clkdm_name; cd++) {
225 if (!cd->clkdm)
226 continue;
227
228
229 mask |= 1 << cd->clkdm->dep_bit;
230 cd->wkdep_usecount = 0;
231 }
232
233 omap2_prm_clear_mod_reg_bits(mask, clkdm->pwrdm.ptr->prcm_offs,
234 PM_WKDEP);
235 return 0;
236 }
237