diff options
Diffstat (limited to 'arch/arm/mach-omap2/omap_hwmod.c')
-rw-r--r-- | arch/arm/mach-omap2/omap_hwmod.c | 100 |
1 files changed, 87 insertions, 13 deletions
diff --git a/arch/arm/mach-omap2/omap_hwmod.c b/arch/arm/mach-omap2/omap_hwmod.c index 70912d1c71e0..fb11ec176d55 100644 --- a/arch/arm/mach-omap2/omap_hwmod.c +++ b/arch/arm/mach-omap2/omap_hwmod.c | |||
@@ -137,12 +137,24 @@ static void _write_sysconfig(u32 v, struct omap_hwmod *oh) | |||
137 | static int _set_master_standbymode(struct omap_hwmod *oh, u8 standbymode, | 137 | static int _set_master_standbymode(struct omap_hwmod *oh, u8 standbymode, |
138 | u32 *v) | 138 | u32 *v) |
139 | { | 139 | { |
140 | u32 mstandby_mask; | ||
141 | u8 mstandby_shift; | ||
142 | |||
140 | if (!oh->sysconfig || | 143 | if (!oh->sysconfig || |
141 | !(oh->sysconfig->sysc_flags & SYSC_HAS_MIDLEMODE)) | 144 | !(oh->sysconfig->sysc_flags & SYSC_HAS_MIDLEMODE)) |
142 | return -EINVAL; | 145 | return -EINVAL; |
143 | 146 | ||
144 | *v &= ~SYSC_MIDLEMODE_MASK; | 147 | if (!oh->sysconfig->sysc_fields) { |
145 | *v |= __ffs(standbymode) << SYSC_MIDLEMODE_SHIFT; | 148 | WARN(!oh->sysconfig->sysc_fields, "offset struct for " |
149 | "sysconfig not provided!\n"); | ||
150 | return -EINVAL; | ||
151 | } | ||
152 | |||
153 | mstandby_shift = oh->sysconfig->sysc_fields->midle_shift; | ||
154 | mstandby_mask = (0x3 << mstandby_shift); | ||
155 | |||
156 | *v &= ~mstandby_mask; | ||
157 | *v |= __ffs(standbymode) << mstandby_shift; | ||
146 | 158 | ||
147 | return 0; | 159 | return 0; |
148 | } | 160 | } |
@@ -159,12 +171,24 @@ static int _set_master_standbymode(struct omap_hwmod *oh, u8 standbymode, | |||
159 | */ | 171 | */ |
160 | static int _set_slave_idlemode(struct omap_hwmod *oh, u8 idlemode, u32 *v) | 172 | static int _set_slave_idlemode(struct omap_hwmod *oh, u8 idlemode, u32 *v) |
161 | { | 173 | { |
174 | u32 sidle_mask; | ||
175 | u8 sidle_shift; | ||
176 | |||
162 | if (!oh->sysconfig || | 177 | if (!oh->sysconfig || |
163 | !(oh->sysconfig->sysc_flags & SYSC_HAS_SIDLEMODE)) | 178 | !(oh->sysconfig->sysc_flags & SYSC_HAS_SIDLEMODE)) |
164 | return -EINVAL; | 179 | return -EINVAL; |
165 | 180 | ||
166 | *v &= ~SYSC_SIDLEMODE_MASK; | 181 | if (!oh->sysconfig->sysc_fields) { |
167 | *v |= __ffs(idlemode) << SYSC_SIDLEMODE_SHIFT; | 182 | WARN(!oh->sysconfig->sysc_fields, "offset struct for " |
183 | "sysconfig not provided!\n"); | ||
184 | return -EINVAL; | ||
185 | } | ||
186 | |||
187 | sidle_shift = oh->sysconfig->sysc_fields->sidle_shift; | ||
188 | sidle_mask = (0x3 << sidle_shift); | ||
189 | |||
190 | *v &= ~sidle_mask; | ||
191 | *v |= __ffs(idlemode) << sidle_shift; | ||
168 | 192 | ||
169 | return 0; | 193 | return 0; |
170 | } | 194 | } |
@@ -182,12 +206,24 @@ static int _set_slave_idlemode(struct omap_hwmod *oh, u8 idlemode, u32 *v) | |||
182 | */ | 206 | */ |
183 | static int _set_clockactivity(struct omap_hwmod *oh, u8 clockact, u32 *v) | 207 | static int _set_clockactivity(struct omap_hwmod *oh, u8 clockact, u32 *v) |
184 | { | 208 | { |
209 | u32 clkact_mask; | ||
210 | u8 clkact_shift; | ||
211 | |||
185 | if (!oh->sysconfig || | 212 | if (!oh->sysconfig || |
186 | !(oh->sysconfig->sysc_flags & SYSC_HAS_CLOCKACTIVITY)) | 213 | !(oh->sysconfig->sysc_flags & SYSC_HAS_CLOCKACTIVITY)) |
187 | return -EINVAL; | 214 | return -EINVAL; |
188 | 215 | ||
189 | *v &= ~SYSC_CLOCKACTIVITY_MASK; | 216 | if (!oh->sysconfig->sysc_fields) { |
190 | *v |= clockact << SYSC_CLOCKACTIVITY_SHIFT; | 217 | WARN(!oh->sysconfig->sysc_fields, "offset struct for " |
218 | "sysconfig not provided!\n"); | ||
219 | return -EINVAL; | ||
220 | } | ||
221 | |||
222 | clkact_shift = oh->sysconfig->sysc_fields->clkact_shift; | ||
223 | clkact_mask = (0x3 << clkact_shift); | ||
224 | |||
225 | *v &= ~clkact_mask; | ||
226 | *v |= clockact << clkact_shift; | ||
191 | 227 | ||
192 | return 0; | 228 | return 0; |
193 | } | 229 | } |
@@ -202,11 +238,21 @@ static int _set_clockactivity(struct omap_hwmod *oh, u8 clockact, u32 *v) | |||
202 | */ | 238 | */ |
203 | static int _set_softreset(struct omap_hwmod *oh, u32 *v) | 239 | static int _set_softreset(struct omap_hwmod *oh, u32 *v) |
204 | { | 240 | { |
241 | u32 softrst_mask; | ||
242 | |||
205 | if (!oh->sysconfig || | 243 | if (!oh->sysconfig || |
206 | !(oh->sysconfig->sysc_flags & SYSC_HAS_SOFTRESET)) | 244 | !(oh->sysconfig->sysc_flags & SYSC_HAS_SOFTRESET)) |
207 | return -EINVAL; | 245 | return -EINVAL; |
208 | 246 | ||
209 | *v |= SYSC_SOFTRESET_MASK; | 247 | if (!oh->sysconfig->sysc_fields) { |
248 | WARN(!oh->sysconfig->sysc_fields, "offset struct for " | ||
249 | "sysconfig not provided!\n"); | ||
250 | return -EINVAL; | ||
251 | } | ||
252 | |||
253 | softrst_mask = (0x1 << oh->sysconfig->sysc_fields->srst_shift); | ||
254 | |||
255 | *v |= softrst_mask; | ||
210 | 256 | ||
211 | return 0; | 257 | return 0; |
212 | } | 258 | } |
@@ -227,12 +273,24 @@ static int _set_softreset(struct omap_hwmod *oh, u32 *v) | |||
227 | static int _set_module_autoidle(struct omap_hwmod *oh, u8 autoidle, | 273 | static int _set_module_autoidle(struct omap_hwmod *oh, u8 autoidle, |
228 | u32 *v) | 274 | u32 *v) |
229 | { | 275 | { |
276 | u32 autoidle_mask; | ||
277 | u8 autoidle_shift; | ||
278 | |||
230 | if (!oh->sysconfig || | 279 | if (!oh->sysconfig || |
231 | !(oh->sysconfig->sysc_flags & SYSC_HAS_AUTOIDLE)) | 280 | !(oh->sysconfig->sysc_flags & SYSC_HAS_AUTOIDLE)) |
232 | return -EINVAL; | 281 | return -EINVAL; |
233 | 282 | ||
234 | *v &= ~SYSC_AUTOIDLE_MASK; | 283 | if (!oh->sysconfig->sysc_fields) { |
235 | *v |= autoidle << SYSC_AUTOIDLE_SHIFT; | 284 | WARN(oh->sysconfig->sysc_fields, "offset struct for " |
285 | "sysconfig not provided!\n"); | ||
286 | return -EINVAL; | ||
287 | } | ||
288 | |||
289 | autoidle_shift = oh->sysconfig->sysc_fields->autoidle_shift; | ||
290 | autoidle_mask = (0x3 << autoidle_shift); | ||
291 | |||
292 | *v &= ~autoidle_mask; | ||
293 | *v |= autoidle << autoidle_shift; | ||
236 | 294 | ||
237 | return 0; | 295 | return 0; |
238 | } | 296 | } |
@@ -246,14 +304,22 @@ static int _set_module_autoidle(struct omap_hwmod *oh, u8 autoidle, | |||
246 | */ | 304 | */ |
247 | static int _enable_wakeup(struct omap_hwmod *oh) | 305 | static int _enable_wakeup(struct omap_hwmod *oh) |
248 | { | 306 | { |
249 | u32 v; | 307 | u32 v, wakeup_mask; |
250 | 308 | ||
251 | if (!oh->sysconfig || | 309 | if (!oh->sysconfig || |
252 | !(oh->sysconfig->sysc_flags & SYSC_HAS_ENAWAKEUP)) | 310 | !(oh->sysconfig->sysc_flags & SYSC_HAS_ENAWAKEUP)) |
253 | return -EINVAL; | 311 | return -EINVAL; |
254 | 312 | ||
313 | if (!oh->sysconfig->sysc_fields) { | ||
314 | WARN(!oh->sysconfig->sysc_fields, "offset struct for " | ||
315 | "sysconfig not provided!\n"); | ||
316 | return -EINVAL; | ||
317 | } | ||
318 | |||
319 | wakeup_mask = (0x1 << oh->sysconfig->sysc_fields->enwkup_shift); | ||
320 | |||
255 | v = oh->_sysc_cache; | 321 | v = oh->_sysc_cache; |
256 | v |= SYSC_ENAWAKEUP_MASK; | 322 | v |= wakeup_mask; |
257 | _write_sysconfig(v, oh); | 323 | _write_sysconfig(v, oh); |
258 | 324 | ||
259 | /* XXX test pwrdm_get_wken for this hwmod's subsystem */ | 325 | /* XXX test pwrdm_get_wken for this hwmod's subsystem */ |
@@ -272,14 +338,22 @@ static int _enable_wakeup(struct omap_hwmod *oh) | |||
272 | */ | 338 | */ |
273 | static int _disable_wakeup(struct omap_hwmod *oh) | 339 | static int _disable_wakeup(struct omap_hwmod *oh) |
274 | { | 340 | { |
275 | u32 v; | 341 | u32 v, wakeup_mask; |
276 | 342 | ||
277 | if (!oh->sysconfig || | 343 | if (!oh->sysconfig || |
278 | !(oh->sysconfig->sysc_flags & SYSC_HAS_ENAWAKEUP)) | 344 | !(oh->sysconfig->sysc_flags & SYSC_HAS_ENAWAKEUP)) |
279 | return -EINVAL; | 345 | return -EINVAL; |
280 | 346 | ||
347 | if (!oh->sysconfig->sysc_fields) { | ||
348 | WARN(!oh->sysconfig->sysc_fields, "offset struct for " | ||
349 | "sysconfig not provided!\n"); | ||
350 | return -EINVAL; | ||
351 | } | ||
352 | |||
353 | wakeup_mask = (0x1 << oh->sysconfig->sysc_fields->enwkup_shift); | ||
354 | |||
281 | v = oh->_sysc_cache; | 355 | v = oh->_sysc_cache; |
282 | v &= ~SYSC_ENAWAKEUP_MASK; | 356 | v &= ~wakeup_mask; |
283 | _write_sysconfig(v, oh); | 357 | _write_sysconfig(v, oh); |
284 | 358 | ||
285 | /* XXX test pwrdm_get_wken for this hwmod's subsystem */ | 359 | /* XXX test pwrdm_get_wken for this hwmod's subsystem */ |