diff options
author | Peter Ujfalusi <peter.ujfalusi@ti.com> | 2012-11-21 18:15:17 -0500 |
---|---|---|
committer | Paul Walmsley <paul@pwsan.com> | 2012-11-21 18:15:17 -0500 |
commit | dad4191d79bded6674529084bcf842c00e4d874a (patch) | |
tree | 72d072bf30441da7e745ba28c10af91ce570b40e /arch/arm/mach-omap2 | |
parent | e6d3a8b0bdcd8f323488a52927682190aee5488e (diff) |
ARM: OMAP2+: hwmod: Add possibility to count hwmod resources based on type
Add flags parameter for omap_hwmod_count_resources() so users can tell which
type of resources they are interested when counting them in hwmod database.
Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com>
Acked-by: BenoƮt Cousson <b-cousson@ti.com>
[paul@pwsan.com: updated to apply]
Signed-off-by: Paul Walmsley <paul@pwsan.com>
Diffstat (limited to 'arch/arm/mach-omap2')
-rw-r--r-- | arch/arm/mach-omap2/omap_device.c | 11 | ||||
-rw-r--r-- | arch/arm/mach-omap2/omap_hwmod.c | 27 | ||||
-rw-r--r-- | arch/arm/mach-omap2/omap_hwmod.h | 2 |
3 files changed, 25 insertions, 15 deletions
diff --git a/arch/arm/mach-omap2/omap_device.c b/arch/arm/mach-omap2/omap_device.c index 0ef934fec364..8917a0881206 100644 --- a/arch/arm/mach-omap2/omap_device.c +++ b/arch/arm/mach-omap2/omap_device.c | |||
@@ -441,19 +441,21 @@ int omap_device_get_context_loss_count(struct platform_device *pdev) | |||
441 | /** | 441 | /** |
442 | * omap_device_count_resources - count number of struct resource entries needed | 442 | * omap_device_count_resources - count number of struct resource entries needed |
443 | * @od: struct omap_device * | 443 | * @od: struct omap_device * |
444 | * @flags: Type of resources to include when counting (IRQ/DMA/MEM) | ||
444 | * | 445 | * |
445 | * Count the number of struct resource entries needed for this | 446 | * Count the number of struct resource entries needed for this |
446 | * omap_device @od. Used by omap_device_build_ss() to determine how | 447 | * omap_device @od. Used by omap_device_build_ss() to determine how |
447 | * much memory to allocate before calling | 448 | * much memory to allocate before calling |
448 | * omap_device_fill_resources(). Returns the count. | 449 | * omap_device_fill_resources(). Returns the count. |
449 | */ | 450 | */ |
450 | static int omap_device_count_resources(struct omap_device *od) | 451 | static int omap_device_count_resources(struct omap_device *od, |
452 | unsigned long flags) | ||
451 | { | 453 | { |
452 | int c = 0; | 454 | int c = 0; |
453 | int i; | 455 | int i; |
454 | 456 | ||
455 | for (i = 0; i < od->hwmods_cnt; i++) | 457 | for (i = 0; i < od->hwmods_cnt; i++) |
456 | c += omap_hwmod_count_resources(od->hwmods[i]); | 458 | c += omap_hwmod_count_resources(od->hwmods[i], flags); |
457 | 459 | ||
458 | pr_debug("omap_device: %s: counted %d total resources across %d hwmods\n", | 460 | pr_debug("omap_device: %s: counted %d total resources across %d hwmods\n", |
459 | od->pdev->name, c, od->hwmods_cnt); | 461 | od->pdev->name, c, od->hwmods_cnt); |
@@ -557,7 +559,10 @@ struct omap_device *omap_device_alloc(struct platform_device *pdev, | |||
557 | od->hwmods = hwmods; | 559 | od->hwmods = hwmods; |
558 | od->pdev = pdev; | 560 | od->pdev = pdev; |
559 | 561 | ||
560 | res_count = omap_device_count_resources(od); | 562 | /* Count all resources for the device */ |
563 | res_count = omap_device_count_resources(od, IORESOURCE_IRQ | | ||
564 | IORESOURCE_DMA | | ||
565 | IORESOURCE_MEM); | ||
561 | /* | 566 | /* |
562 | * DT Boot: | 567 | * DT Boot: |
563 | * OF framework will construct the resource structure (currently | 568 | * OF framework will construct the resource structure (currently |
diff --git a/arch/arm/mach-omap2/omap_hwmod.c b/arch/arm/mach-omap2/omap_hwmod.c index 083adbed0bfd..a8090907fe35 100644 --- a/arch/arm/mach-omap2/omap_hwmod.c +++ b/arch/arm/mach-omap2/omap_hwmod.c | |||
@@ -3427,7 +3427,7 @@ int omap_hwmod_reset(struct omap_hwmod *oh) | |||
3427 | /** | 3427 | /** |
3428 | * omap_hwmod_count_resources - count number of struct resources needed by hwmod | 3428 | * omap_hwmod_count_resources - count number of struct resources needed by hwmod |
3429 | * @oh: struct omap_hwmod * | 3429 | * @oh: struct omap_hwmod * |
3430 | * @res: pointer to the first element of an array of struct resource to fill | 3430 | * @flags: Type of resources to include when counting (IRQ/DMA/MEM) |
3431 | * | 3431 | * |
3432 | * Count the number of struct resource array elements necessary to | 3432 | * Count the number of struct resource array elements necessary to |
3433 | * contain omap_hwmod @oh resources. Intended to be called by code | 3433 | * contain omap_hwmod @oh resources. Intended to be called by code |
@@ -3440,20 +3440,25 @@ int omap_hwmod_reset(struct omap_hwmod *oh) | |||
3440 | * resource IDs. | 3440 | * resource IDs. |
3441 | * | 3441 | * |
3442 | */ | 3442 | */ |
3443 | int omap_hwmod_count_resources(struct omap_hwmod *oh) | 3443 | int omap_hwmod_count_resources(struct omap_hwmod *oh, unsigned long flags) |
3444 | { | 3444 | { |
3445 | struct omap_hwmod_ocp_if *os; | 3445 | int ret = 0; |
3446 | struct list_head *p; | ||
3447 | int ret; | ||
3448 | int i = 0; | ||
3449 | 3446 | ||
3450 | ret = _count_mpu_irqs(oh) + _count_sdma_reqs(oh); | 3447 | if (flags & IORESOURCE_IRQ) |
3448 | ret += _count_mpu_irqs(oh); | ||
3451 | 3449 | ||
3452 | p = oh->slave_ports.next; | 3450 | if (flags & IORESOURCE_DMA) |
3451 | ret += _count_sdma_reqs(oh); | ||
3453 | 3452 | ||
3454 | while (i < oh->slaves_cnt) { | 3453 | if (flags & IORESOURCE_MEM) { |
3455 | os = _fetch_next_ocp_if(&p, &i); | 3454 | int i = 0; |
3456 | ret += _count_ocp_if_addr_spaces(os); | 3455 | struct omap_hwmod_ocp_if *os; |
3456 | struct list_head *p = oh->slave_ports.next; | ||
3457 | |||
3458 | while (i < oh->slaves_cnt) { | ||
3459 | os = _fetch_next_ocp_if(&p, &i); | ||
3460 | ret += _count_ocp_if_addr_spaces(os); | ||
3461 | } | ||
3457 | } | 3462 | } |
3458 | 3463 | ||
3459 | return ret; | 3464 | return ret; |
diff --git a/arch/arm/mach-omap2/omap_hwmod.h b/arch/arm/mach-omap2/omap_hwmod.h index 421ff65562b0..86b7414b5835 100644 --- a/arch/arm/mach-omap2/omap_hwmod.h +++ b/arch/arm/mach-omap2/omap_hwmod.h | |||
@@ -631,7 +631,7 @@ void omap_hwmod_write(u32 v, struct omap_hwmod *oh, u16 reg_offs); | |||
631 | u32 omap_hwmod_read(struct omap_hwmod *oh, u16 reg_offs); | 631 | u32 omap_hwmod_read(struct omap_hwmod *oh, u16 reg_offs); |
632 | int omap_hwmod_softreset(struct omap_hwmod *oh); | 632 | int omap_hwmod_softreset(struct omap_hwmod *oh); |
633 | 633 | ||
634 | int omap_hwmod_count_resources(struct omap_hwmod *oh); | 634 | int omap_hwmod_count_resources(struct omap_hwmod *oh, unsigned long flags); |
635 | int omap_hwmod_fill_resources(struct omap_hwmod *oh, struct resource *res); | 635 | int omap_hwmod_fill_resources(struct omap_hwmod *oh, struct resource *res); |
636 | int omap_hwmod_fill_dma_resources(struct omap_hwmod *oh, struct resource *res); | 636 | int omap_hwmod_fill_dma_resources(struct omap_hwmod *oh, struct resource *res); |
637 | int omap_hwmod_get_resource_byname(struct omap_hwmod *oh, unsigned int type, | 637 | int omap_hwmod_get_resource_byname(struct omap_hwmod *oh, unsigned int type, |