aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/plat-omap
diff options
context:
space:
mode:
Diffstat (limited to 'arch/arm/plat-omap')
-rw-r--r--arch/arm/plat-omap/include/plat/omap_hwmod.h1
-rw-r--r--arch/arm/plat-omap/omap_device.c79
2 files changed, 68 insertions, 12 deletions
diff --git a/arch/arm/plat-omap/include/plat/omap_hwmod.h b/arch/arm/plat-omap/include/plat/omap_hwmod.h
index 9b9646c3673d..05330735f23f 100644
--- a/arch/arm/plat-omap/include/plat/omap_hwmod.h
+++ b/arch/arm/plat-omap/include/plat/omap_hwmod.h
@@ -615,6 +615,7 @@ int omap_hwmod_softreset(struct omap_hwmod *oh);
615 615
616int omap_hwmod_count_resources(struct omap_hwmod *oh); 616int omap_hwmod_count_resources(struct omap_hwmod *oh);
617int omap_hwmod_fill_resources(struct omap_hwmod *oh, struct resource *res); 617int omap_hwmod_fill_resources(struct omap_hwmod *oh, struct resource *res);
618int omap_hwmod_fill_dma_resources(struct omap_hwmod *oh, struct resource *res);
618int omap_hwmod_get_resource_byname(struct omap_hwmod *oh, unsigned int type, 619int omap_hwmod_get_resource_byname(struct omap_hwmod *oh, unsigned int type,
619 const char *name, struct resource *res); 620 const char *name, struct resource *res);
620 621
diff --git a/arch/arm/plat-omap/omap_device.c b/arch/arm/plat-omap/omap_device.c
index 5c93c09a80c2..d5f617c542d3 100644
--- a/arch/arm/plat-omap/omap_device.c
+++ b/arch/arm/plat-omap/omap_device.c
@@ -365,6 +365,14 @@ static int omap_device_build_from_dt(struct platform_device *pdev)
365 goto odbfd_exit1; 365 goto odbfd_exit1;
366 } 366 }
367 367
368 /* Fix up missing resource names */
369 for (i = 0; i < pdev->num_resources; i++) {
370 struct resource *r = &pdev->resource[i];
371
372 if (r->name == NULL)
373 r->name = dev_name(&pdev->dev);
374 }
375
368 if (of_get_property(node, "ti,no_idle_on_suspend", NULL)) 376 if (of_get_property(node, "ti,no_idle_on_suspend", NULL))
369 omap_device_disable_idle_on_suspend(pdev); 377 omap_device_disable_idle_on_suspend(pdev);
370 378
@@ -485,6 +493,33 @@ static int omap_device_fill_resources(struct omap_device *od,
485} 493}
486 494
487/** 495/**
496 * _od_fill_dma_resources - fill in array of struct resource with dma resources
497 * @od: struct omap_device *
498 * @res: pointer to an array of struct resource to be filled in
499 *
500 * Populate one or more empty struct resource pointed to by @res with
501 * the dma resource data for this omap_device @od. Used by
502 * omap_device_alloc() after calling omap_device_count_resources().
503 *
504 * Ideally this function would not be needed at all. If we have
505 * mechanism to get dma resources from DT.
506 *
507 * Returns 0.
508 */
509static int _od_fill_dma_resources(struct omap_device *od,
510 struct resource *res)
511{
512 int i, r;
513
514 for (i = 0; i < od->hwmods_cnt; i++) {
515 r = omap_hwmod_fill_dma_resources(od->hwmods[i], res);
516 res += r;
517 }
518
519 return 0;
520}
521
522/**
488 * omap_device_alloc - allocate an omap_device 523 * omap_device_alloc - allocate an omap_device
489 * @pdev: platform_device that will be included in this omap_device 524 * @pdev: platform_device that will be included in this omap_device
490 * @oh: ptr to the single omap_hwmod that backs this omap_device 525 * @oh: ptr to the single omap_hwmod that backs this omap_device
@@ -523,24 +558,44 @@ struct omap_device *omap_device_alloc(struct platform_device *pdev,
523 od->hwmods = hwmods; 558 od->hwmods = hwmods;
524 od->pdev = pdev; 559 od->pdev = pdev;
525 560
561 res_count = omap_device_count_resources(od);
526 /* 562 /*
527 * HACK: Ideally the resources from DT should match, and hwmod 563 * DT Boot:
528 * should just add the missing ones. Since the name is not 564 * OF framework will construct the resource structure (currently
529 * properly populated by DT, stick to hwmod resources only. 565 * does for MEM & IRQ resource) and we should respect/use these
566 * resources, killing hwmod dependency.
567 * If pdev->num_resources > 0, we assume that MEM & IRQ resources
568 * have been allocated by OF layer already (through DTB).
569 *
570 * Non-DT Boot:
571 * Here, pdev->num_resources = 0, and we should get all the
572 * resources from hwmod.
573 *
574 * TODO: Once DMA resource is available from OF layer, we should
575 * kill filling any resources from hwmod.
530 */ 576 */
531 if (pdev->num_resources && pdev->resource) 577 if (res_count > pdev->num_resources) {
532 dev_warn(&pdev->dev, "%s(): resources already allocated %d\n", 578 /* Allocate resources memory to account for new resources */
533 __func__, pdev->num_resources);
534
535 res_count = omap_device_count_resources(od);
536 if (res_count > 0) {
537 dev_dbg(&pdev->dev, "%s(): resources allocated from hwmod %d\n",
538 __func__, res_count);
539 res = kzalloc(sizeof(struct resource) * res_count, GFP_KERNEL); 579 res = kzalloc(sizeof(struct resource) * res_count, GFP_KERNEL);
540 if (!res) 580 if (!res)
541 goto oda_exit3; 581 goto oda_exit3;
542 582
543 omap_device_fill_resources(od, res); 583 /*
584 * If pdev->num_resources > 0, then assume that,
585 * MEM and IRQ resources will only come from DT and only
586 * fill DMA resource from hwmod layer.
587 */
588 if (pdev->num_resources && pdev->resource) {
589 dev_dbg(&pdev->dev, "%s(): resources already allocated %d\n",
590 __func__, res_count);
591 memcpy(res, pdev->resource,
592 sizeof(struct resource) * pdev->num_resources);
593 _od_fill_dma_resources(od, &res[pdev->num_resources]);
594 } else {
595 dev_dbg(&pdev->dev, "%s(): using resources from hwmod %d\n",
596 __func__, res_count);
597 omap_device_fill_resources(od, res);
598 }
544 599
545 ret = platform_device_add_resources(pdev, res, res_count); 600 ret = platform_device_add_resources(pdev, res, res_count);
546 kfree(res); 601 kfree(res);