aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/mach-omap2/mux.c
diff options
context:
space:
mode:
authorTony Lindgren <tony@atomide.com>2011-03-11 14:32:25 -0500
committerTony Lindgren <tony@atomide.com>2011-03-11 14:32:25 -0500
commit029268e4c124a38b11ae965849ea2dfef724a568 (patch)
treee36914094589e5d8318f535fec1ec658c2305460 /arch/arm/mach-omap2/mux.c
parent0d9596958d0be59e6bb373b5e6bc0729cbba5110 (diff)
omap2+: Add separate list for dynamic pads to mux
This avoids going through the list unnecessarily when idling devices for runtime PM. Based on an earlier patch by sricharan <r.sricharan@ti.com>. Signed-off-by: sricharan <r.sricharan@ti.com> Signed-off-by: Tony Lindgren <tony@atomide.com>
Diffstat (limited to 'arch/arm/mach-omap2/mux.c')
-rw-r--r--arch/arm/mach-omap2/mux.c88
1 files changed, 75 insertions, 13 deletions
diff --git a/arch/arm/mach-omap2/mux.c b/arch/arm/mach-omap2/mux.c
index 6c84659cf846..8717370c91b1 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
258omap_hwmod_mux_init(struct omap_device_pad *bpads, int nr_pads) 258omap_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
310err3: 341err3:
@@ -322,6 +353,44 @@ 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 pad->flags |= OMAP_DEVICE_PAD_IDLE;
363 val = pad->idle;
364 omap_mux_write(pad->partition, val,
365 pad->mux->reg_offset);
366 }
367
368 return;
369 }
370
371 /* Runtime enabling of dynamic pads */
372 if ((state == _HWMOD_STATE_ENABLED) && hmux->pads_dynamic) {
373 int idled = 0;
374
375 for (i = 0; i < hmux->nr_pads_dynamic; i++) {
376 struct omap_device_pad *pad = hmux->pads_dynamic[i];
377 int val = -EINVAL;
378
379 if (!(pad->flags & OMAP_DEVICE_PAD_IDLE))
380 continue;
381
382 pad->flags &= ~OMAP_DEVICE_PAD_IDLE;
383 val = pad->enable;
384 omap_mux_write(pad->partition, val,
385 pad->mux->reg_offset);
386 idled++;
387 }
388
389 if (idled)
390 return;
391 }
392
393 /* Enabling or disabling of all pads */
325 for (i = 0; i < hmux->nr_pads; i++) { 394 for (i = 0; i < hmux->nr_pads; i++) {
326 struct omap_device_pad *pad = &hmux->pads[i]; 395 struct omap_device_pad *pad = &hmux->pads[i];
327 int flags, val = -EINVAL; 396 int flags, val = -EINVAL;
@@ -330,21 +399,10 @@ void omap_hwmod_mux(struct omap_hwmod_mux_info *hmux, u8 state)
330 399
331 switch (state) { 400 switch (state) {
332 case _HWMOD_STATE_ENABLED: 401 case _HWMOD_STATE_ENABLED:
333 if (flags & OMAP_DEVICE_PAD_ENABLED)
334 break;
335 flags |= OMAP_DEVICE_PAD_ENABLED;
336 val = pad->enable; 402 val = pad->enable;
337 pr_debug("%s: Enabling %s %x\n", __func__, 403 pr_debug("%s: Enabling %s %x\n", __func__,
338 pad->name, val); 404 pad->name, val);
339 break; 405 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: 406 case _HWMOD_STATE_DISABLED:
349 default: 407 default:
350 /* Use safe mode unless OMAP_DEVICE_PAD_REMUX */ 408 /* Use safe mode unless OMAP_DEVICE_PAD_REMUX */
@@ -352,7 +410,6 @@ void omap_hwmod_mux(struct omap_hwmod_mux_info *hmux, u8 state)
352 val = pad->off; 410 val = pad->off;
353 else 411 else
354 val = OMAP_MUX_MODE7; 412 val = OMAP_MUX_MODE7;
355 flags &= ~OMAP_DEVICE_PAD_ENABLED;
356 pr_debug("%s: Disabling %s %x\n", __func__, 413 pr_debug("%s: Disabling %s %x\n", __func__,
357 pad->name, val); 414 pad->name, val);
358 }; 415 };
@@ -363,6 +420,11 @@ void omap_hwmod_mux(struct omap_hwmod_mux_info *hmux, u8 state)
363 pad->flags = flags; 420 pad->flags = flags;
364 } 421 }
365 } 422 }
423
424 if (state == _HWMOD_STATE_ENABLED)
425 hmux->enabled = true;
426 else
427 hmux->enabled = false;
366} 428}
367 429
368#ifdef CONFIG_DEBUG_FS 430#ifdef CONFIG_DEBUG_FS