diff options
author | Tony Lindgren <tony@atomide.com> | 2011-03-11 14:32:25 -0500 |
---|---|---|
committer | Tony Lindgren <tony@atomide.com> | 2011-03-11 14:32:25 -0500 |
commit | 029268e4c124a38b11ae965849ea2dfef724a568 (patch) | |
tree | e36914094589e5d8318f535fec1ec658c2305460 /arch/arm | |
parent | 0d9596958d0be59e6bb373b5e6bc0729cbba5110 (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')
-rw-r--r-- | arch/arm/mach-omap2/mux.c | 88 | ||||
-rw-r--r-- | arch/arm/mach-omap2/mux.h | 2 | ||||
-rw-r--r-- | arch/arm/mach-omap2/omap_hwmod.c | 6 | ||||
-rw-r--r-- | arch/arm/plat-omap/include/plat/omap_hwmod.h | 3 |
4 files changed, 83 insertions, 16 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 | |||
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,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 |
diff --git a/arch/arm/mach-omap2/mux.h b/arch/arm/mach-omap2/mux.h index a4ab17a737a6..1d5bf4298c6f 100644 --- a/arch/arm/mach-omap2/mux.h +++ b/arch/arm/mach-omap2/mux.h | |||
@@ -159,7 +159,7 @@ struct omap_board_mux { | |||
159 | u16 value; | 159 | u16 value; |
160 | }; | 160 | }; |
161 | 161 | ||
162 | #define OMAP_DEVICE_PAD_ENABLED BIT(7) /* Not needed for board-*.c */ | 162 | #define OMAP_DEVICE_PAD_IDLE BIT(7) /* Not needed for board-*.c */ |
163 | #define OMAP_DEVICE_PAD_REMUX BIT(1) /* Dynamically remux a pad, | 163 | #define OMAP_DEVICE_PAD_REMUX BIT(1) /* Dynamically remux a pad, |
164 | needs enable, idle and off | 164 | needs enable, idle and off |
165 | values */ | 165 | values */ |
diff --git a/arch/arm/mach-omap2/omap_hwmod.c b/arch/arm/mach-omap2/omap_hwmod.c index 4c8329e4e6e1..e03429453ce7 100644 --- a/arch/arm/mach-omap2/omap_hwmod.c +++ b/arch/arm/mach-omap2/omap_hwmod.c | |||
@@ -1244,7 +1244,9 @@ static int _enable(struct omap_hwmod *oh) | |||
1244 | _deassert_hardreset(oh, oh->rst_lines[0].name); | 1244 | _deassert_hardreset(oh, oh->rst_lines[0].name); |
1245 | 1245 | ||
1246 | /* Mux pins for device runtime if populated */ | 1246 | /* Mux pins for device runtime if populated */ |
1247 | if (oh->mux) | 1247 | if (oh->mux && (!oh->mux->enabled || |
1248 | ((oh->_state == _HWMOD_STATE_IDLE) && | ||
1249 | oh->mux->pads_dynamic))) | ||
1248 | omap_hwmod_mux(oh->mux, _HWMOD_STATE_ENABLED); | 1250 | omap_hwmod_mux(oh->mux, _HWMOD_STATE_ENABLED); |
1249 | 1251 | ||
1250 | _add_initiator_dep(oh, mpu_oh); | 1252 | _add_initiator_dep(oh, mpu_oh); |
@@ -1293,7 +1295,7 @@ static int _idle(struct omap_hwmod *oh) | |||
1293 | _disable_clocks(oh); | 1295 | _disable_clocks(oh); |
1294 | 1296 | ||
1295 | /* Mux pins for device idle if populated */ | 1297 | /* Mux pins for device idle if populated */ |
1296 | if (oh->mux) | 1298 | if (oh->mux && oh->mux->pads_dynamic) |
1297 | omap_hwmod_mux(oh->mux, _HWMOD_STATE_IDLE); | 1299 | omap_hwmod_mux(oh->mux, _HWMOD_STATE_IDLE); |
1298 | 1300 | ||
1299 | oh->_state = _HWMOD_STATE_IDLE; | 1301 | oh->_state = _HWMOD_STATE_IDLE; |
diff --git a/arch/arm/plat-omap/include/plat/omap_hwmod.h b/arch/arm/plat-omap/include/plat/omap_hwmod.h index 23c77cd4abed..1adea9c62984 100644 --- a/arch/arm/plat-omap/include/plat/omap_hwmod.h +++ b/arch/arm/plat-omap/include/plat/omap_hwmod.h | |||
@@ -90,6 +90,9 @@ extern struct omap_hwmod_sysc_fields omap_hwmod_sysc_type2; | |||
90 | struct omap_hwmod_mux_info { | 90 | struct omap_hwmod_mux_info { |
91 | int nr_pads; | 91 | int nr_pads; |
92 | struct omap_device_pad *pads; | 92 | struct omap_device_pad *pads; |
93 | int nr_pads_dynamic; | ||
94 | struct omap_device_pad **pads_dynamic; | ||
95 | bool enabled; | ||
93 | }; | 96 | }; |
94 | 97 | ||
95 | /** | 98 | /** |