diff options
Diffstat (limited to 'arch/arm/mach-omap2/mux.c')
-rw-r--r-- | arch/arm/mach-omap2/mux.c | 85 |
1 files changed, 71 insertions, 14 deletions
diff --git a/arch/arm/mach-omap2/mux.c b/arch/arm/mach-omap2/mux.c index 6c84659cf846..bb043cbb3886 100644 --- a/arch/arm/mach-omap2/mux.c +++ b/arch/arm/mach-omap2/mux.c | |||
@@ -258,7 +258,7 @@ struct omap_hwmod_mux_info * __init | |||
258 | omap_hwmod_mux_init(struct omap_device_pad *bpads, int nr_pads) | 258 | omap_hwmod_mux_init(struct omap_device_pad *bpads, int nr_pads) |
259 | { | 259 | { |
260 | struct omap_hwmod_mux_info *hmux; | 260 | struct omap_hwmod_mux_info *hmux; |
261 | int i; | 261 | int i, nr_pads_dynamic = 0; |
262 | 262 | ||
263 | if (!bpads || nr_pads < 1) | 263 | if (!bpads || nr_pads < 1) |
264 | return NULL; | 264 | return NULL; |
@@ -302,9 +302,40 @@ omap_hwmod_mux_init(struct omap_device_pad *bpads, int nr_pads) | |||
302 | pad->enable = bpad->enable; | 302 | pad->enable = bpad->enable; |
303 | pad->idle = bpad->idle; | 303 | pad->idle = bpad->idle; |
304 | pad->off = bpad->off; | 304 | pad->off = bpad->off; |
305 | |||
306 | if (pad->flags & OMAP_DEVICE_PAD_REMUX) | ||
307 | nr_pads_dynamic++; | ||
308 | |||
305 | pr_debug("%s: Initialized %s\n", __func__, pad->name); | 309 | pr_debug("%s: Initialized %s\n", __func__, pad->name); |
306 | } | 310 | } |
307 | 311 | ||
312 | if (!nr_pads_dynamic) | ||
313 | return hmux; | ||
314 | |||
315 | /* | ||
316 | * Add pads that need dynamic muxing into a separate list | ||
317 | */ | ||
318 | |||
319 | hmux->nr_pads_dynamic = nr_pads_dynamic; | ||
320 | hmux->pads_dynamic = kzalloc(sizeof(struct omap_device_pad *) * | ||
321 | nr_pads_dynamic, GFP_KERNEL); | ||
322 | if (!hmux->pads_dynamic) { | ||
323 | pr_err("%s: Could not allocate dynamic pads\n", __func__); | ||
324 | return hmux; | ||
325 | } | ||
326 | |||
327 | nr_pads_dynamic = 0; | ||
328 | for (i = 0; i < hmux->nr_pads; i++) { | ||
329 | struct omap_device_pad *pad = &hmux->pads[i]; | ||
330 | |||
331 | if (pad->flags & OMAP_DEVICE_PAD_REMUX) { | ||
332 | pr_debug("%s: pad %s tagged dynamic\n", | ||
333 | __func__, pad->name); | ||
334 | hmux->pads_dynamic[nr_pads_dynamic] = pad; | ||
335 | nr_pads_dynamic++; | ||
336 | } | ||
337 | } | ||
338 | |||
308 | return hmux; | 339 | return hmux; |
309 | 340 | ||
310 | err3: | 341 | err3: |
@@ -322,6 +353,36 @@ void omap_hwmod_mux(struct omap_hwmod_mux_info *hmux, u8 state) | |||
322 | { | 353 | { |
323 | int i; | 354 | int i; |
324 | 355 | ||
356 | /* Runtime idling of dynamic pads */ | ||
357 | if (state == _HWMOD_STATE_IDLE && hmux->enabled) { | ||
358 | for (i = 0; i < hmux->nr_pads_dynamic; i++) { | ||
359 | struct omap_device_pad *pad = hmux->pads_dynamic[i]; | ||
360 | int val = -EINVAL; | ||
361 | |||
362 | val = pad->idle; | ||
363 | omap_mux_write(pad->partition, val, | ||
364 | pad->mux->reg_offset); | ||
365 | } | ||
366 | |||
367 | return; | ||
368 | } | ||
369 | |||
370 | /* Runtime enabling of dynamic pads */ | ||
371 | if ((state == _HWMOD_STATE_ENABLED) && hmux->pads_dynamic | ||
372 | && hmux->enabled) { | ||
373 | for (i = 0; i < hmux->nr_pads_dynamic; i++) { | ||
374 | struct omap_device_pad *pad = hmux->pads_dynamic[i]; | ||
375 | int val = -EINVAL; | ||
376 | |||
377 | val = pad->enable; | ||
378 | omap_mux_write(pad->partition, val, | ||
379 | pad->mux->reg_offset); | ||
380 | } | ||
381 | |||
382 | return; | ||
383 | } | ||
384 | |||
385 | /* Enabling or disabling of all pads */ | ||
325 | for (i = 0; i < hmux->nr_pads; i++) { | 386 | for (i = 0; i < hmux->nr_pads; i++) { |
326 | struct omap_device_pad *pad = &hmux->pads[i]; | 387 | struct omap_device_pad *pad = &hmux->pads[i]; |
327 | int flags, val = -EINVAL; | 388 | int flags, val = -EINVAL; |
@@ -330,31 +391,22 @@ void omap_hwmod_mux(struct omap_hwmod_mux_info *hmux, u8 state) | |||
330 | 391 | ||
331 | switch (state) { | 392 | switch (state) { |
332 | case _HWMOD_STATE_ENABLED: | 393 | case _HWMOD_STATE_ENABLED: |
333 | if (flags & OMAP_DEVICE_PAD_ENABLED) | ||
334 | break; | ||
335 | flags |= OMAP_DEVICE_PAD_ENABLED; | ||
336 | val = pad->enable; | 394 | val = pad->enable; |
337 | pr_debug("%s: Enabling %s %x\n", __func__, | 395 | pr_debug("%s: Enabling %s %x\n", __func__, |
338 | pad->name, val); | 396 | pad->name, val); |
339 | break; | 397 | break; |
340 | case _HWMOD_STATE_IDLE: | ||
341 | if (!(flags & OMAP_DEVICE_PAD_REMUX)) | ||
342 | break; | ||
343 | flags &= ~OMAP_DEVICE_PAD_ENABLED; | ||
344 | val = pad->idle; | ||
345 | pr_debug("%s: Idling %s %x\n", __func__, | ||
346 | pad->name, val); | ||
347 | break; | ||
348 | case _HWMOD_STATE_DISABLED: | 398 | case _HWMOD_STATE_DISABLED: |
349 | default: | ||
350 | /* Use safe mode unless OMAP_DEVICE_PAD_REMUX */ | 399 | /* Use safe mode unless OMAP_DEVICE_PAD_REMUX */ |
351 | if (flags & OMAP_DEVICE_PAD_REMUX) | 400 | if (flags & OMAP_DEVICE_PAD_REMUX) |
352 | val = pad->off; | 401 | val = pad->off; |
353 | else | 402 | else |
354 | val = OMAP_MUX_MODE7; | 403 | val = OMAP_MUX_MODE7; |
355 | flags &= ~OMAP_DEVICE_PAD_ENABLED; | ||
356 | pr_debug("%s: Disabling %s %x\n", __func__, | 404 | pr_debug("%s: Disabling %s %x\n", __func__, |
357 | pad->name, val); | 405 | pad->name, val); |
406 | break; | ||
407 | default: | ||
408 | /* Nothing to be done */ | ||
409 | break; | ||
358 | }; | 410 | }; |
359 | 411 | ||
360 | if (val >= 0) { | 412 | if (val >= 0) { |
@@ -363,6 +415,11 @@ void omap_hwmod_mux(struct omap_hwmod_mux_info *hmux, u8 state) | |||
363 | pad->flags = flags; | 415 | pad->flags = flags; |
364 | } | 416 | } |
365 | } | 417 | } |
418 | |||
419 | if (state == _HWMOD_STATE_ENABLED) | ||
420 | hmux->enabled = true; | ||
421 | else | ||
422 | hmux->enabled = false; | ||
366 | } | 423 | } |
367 | 424 | ||
368 | #ifdef CONFIG_DEBUG_FS | 425 | #ifdef CONFIG_DEBUG_FS |