aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/mach-omap2/omap_device.c
diff options
context:
space:
mode:
authorTony Lindgren <tony@atomide.com>2017-10-10 17:27:26 -0400
committerTony Lindgren <tony@atomide.com>2017-10-10 17:27:26 -0400
commitc2b84a9bb3414cabaa039b8860a694464a0bad06 (patch)
tree947bf0d74636dc0532d254c527c918271f8b6e68 /arch/arm/mach-omap2/omap_device.c
parentfe97874a41bf911350bae6bda7fc044d12c76a4a (diff)
ARM: OMAP2+: Drop omap_hwmod_dma_info
We have all of mach-omap2 booting in device tree only mode now, and this data is populated from device tree. Note that once we have removed support for the omap legacy DMA, we can also drop struct omap_dma_dev_attr. Cc: Lokesh Vutla <lokeshvutla@ti.com> Cc: Paul Walmsley <paul@pwsan.com> Cc: Tero Kristo <t-kristo@ti.com> Signed-off-by: Tony Lindgren <tony@atomide.com>
Diffstat (limited to 'arch/arm/mach-omap2/omap_device.c')
-rw-r--r--arch/arm/mach-omap2/omap_device.c155
1 files changed, 1 insertions, 154 deletions
diff --git a/arch/arm/mach-omap2/omap_device.c b/arch/arm/mach-omap2/omap_device.c
index 50f81b2d22b7..713fc6b4b894 100644
--- a/arch/arm/mach-omap2/omap_device.c
+++ b/arch/arm/mach-omap2/omap_device.c
@@ -311,88 +311,6 @@ int omap_device_get_context_loss_count(struct platform_device *pdev)
311} 311}
312 312
313/** 313/**
314 * omap_device_count_resources - count number of struct resource entries needed
315 * @od: struct omap_device *
316 * @flags: Type of resources to include when counting (IRQ/DMA/MEM)
317 *
318 * Count the number of struct resource entries needed for this
319 * omap_device @od. Used by omap_device_build_ss() to determine how
320 * much memory to allocate before calling
321 * omap_device_fill_resources(). Returns the count.
322 */
323static int omap_device_count_resources(struct omap_device *od,
324 unsigned long flags)
325{
326 int c = 0;
327 int i;
328
329 for (i = 0; i < od->hwmods_cnt; i++)
330 c += omap_hwmod_count_resources(od->hwmods[i], flags);
331
332 pr_debug("omap_device: %s: counted %d total resources across %d hwmods\n",
333 od->pdev->name, c, od->hwmods_cnt);
334
335 return c;
336}
337
338/**
339 * omap_device_fill_resources - fill in array of struct resource
340 * @od: struct omap_device *
341 * @res: pointer to an array of struct resource to be filled in
342 *
343 * Populate one or more empty struct resource pointed to by @res with
344 * the resource data for this omap_device @od. Used by
345 * omap_device_build_ss() after calling omap_device_count_resources().
346 * Ideally this function would not be needed at all. If omap_device
347 * replaces platform_device, then we can specify our own
348 * get_resource()/ get_irq()/etc functions that use the underlying
349 * omap_hwmod information. Or if platform_device is extended to use
350 * subarchitecture-specific function pointers, the various
351 * platform_device functions can simply call omap_device internal
352 * functions to get device resources. Hacking around the existing
353 * platform_device code wastes memory. Returns 0.
354 */
355static int omap_device_fill_resources(struct omap_device *od,
356 struct resource *res)
357{
358 int i, r;
359
360 for (i = 0; i < od->hwmods_cnt; i++) {
361 r = omap_hwmod_fill_resources(od->hwmods[i], res);
362 res += r;
363 }
364
365 return 0;
366}
367
368/**
369 * _od_fill_dma_resources - fill in array of struct resource with dma resources
370 * @od: struct omap_device *
371 * @res: pointer to an array of struct resource to be filled in
372 *
373 * Populate one or more empty struct resource pointed to by @res with
374 * the dma resource data for this omap_device @od. Used by
375 * omap_device_alloc() after calling omap_device_count_resources().
376 *
377 * Ideally this function would not be needed at all. If we have
378 * mechanism to get dma resources from DT.
379 *
380 * Returns 0.
381 */
382static int _od_fill_dma_resources(struct omap_device *od,
383 struct resource *res)
384{
385 int i, r;
386
387 for (i = 0; i < od->hwmods_cnt; i++) {
388 r = omap_hwmod_fill_dma_resources(od->hwmods[i], res);
389 res += r;
390 }
391
392 return 0;
393}
394
395/**
396 * omap_device_alloc - allocate an omap_device 314 * omap_device_alloc - allocate an omap_device
397 * @pdev: platform_device that will be included in this omap_device 315 * @pdev: platform_device that will be included in this omap_device
398 * @oh: ptr to the single omap_hwmod that backs this omap_device 316 * @oh: ptr to the single omap_hwmod that backs this omap_device
@@ -409,8 +327,7 @@ struct omap_device *omap_device_alloc(struct platform_device *pdev,
409{ 327{
410 int ret = -ENOMEM; 328 int ret = -ENOMEM;
411 struct omap_device *od; 329 struct omap_device *od;
412 struct resource *res = NULL; 330 int i;
413 int i, res_count;
414 struct omap_hwmod **hwmods; 331 struct omap_hwmod **hwmods;
415 332
416 od = kzalloc(sizeof(struct omap_device), GFP_KERNEL); 333 od = kzalloc(sizeof(struct omap_device), GFP_KERNEL);
@@ -426,74 +343,6 @@ struct omap_device *omap_device_alloc(struct platform_device *pdev,
426 343
427 od->hwmods = hwmods; 344 od->hwmods = hwmods;
428 od->pdev = pdev; 345 od->pdev = pdev;
429
430 /*
431 * Non-DT Boot:
432 * Here, pdev->num_resources = 0, and we should get all the
433 * resources from hwmod.
434 *
435 * DT Boot:
436 * OF framework will construct the resource structure (currently
437 * does for MEM & IRQ resource) and we should respect/use these
438 * resources, killing hwmod dependency.
439 * If pdev->num_resources > 0, we assume that MEM & IRQ resources
440 * have been allocated by OF layer already (through DTB).
441 * As preparation for the future we examine the OF provided resources
442 * to see if we have DMA resources provided already. In this case
443 * there is no need to update the resources for the device, we use the
444 * OF provided ones.
445 *
446 * TODO: Once DMA resource is available from OF layer, we should
447 * kill filling any resources from hwmod.
448 */
449 if (!pdev->num_resources) {
450 /* Count all resources for the device */
451 res_count = omap_device_count_resources(od, IORESOURCE_IRQ |
452 IORESOURCE_DMA |
453 IORESOURCE_MEM);
454 } else {
455 /* Take a look if we already have DMA resource via DT */
456 for (i = 0; i < pdev->num_resources; i++) {
457 struct resource *r = &pdev->resource[i];
458
459 /* We have it, no need to touch the resources */
460 if (r->flags == IORESOURCE_DMA)
461 goto have_everything;
462 }
463 /* Count only DMA resources for the device */
464 res_count = omap_device_count_resources(od, IORESOURCE_DMA);
465 /* The device has no DMA resource, no need for update */
466 if (!res_count)
467 goto have_everything;
468
469 res_count += pdev->num_resources;
470 }
471
472 /* Allocate resources memory to account for new resources */
473 res = kzalloc(sizeof(struct resource) * res_count, GFP_KERNEL);
474 if (!res)
475 goto oda_exit3;
476
477 if (!pdev->num_resources) {
478 dev_dbg(&pdev->dev, "%s: using %d resources from hwmod\n",
479 __func__, res_count);
480 omap_device_fill_resources(od, res);
481 } else {
482 dev_dbg(&pdev->dev,
483 "%s: appending %d DMA resources from hwmod\n",
484 __func__, res_count - pdev->num_resources);
485 memcpy(res, pdev->resource,
486 sizeof(struct resource) * pdev->num_resources);
487 _od_fill_dma_resources(od, &res[pdev->num_resources]);
488 }
489
490 ret = platform_device_add_resources(pdev, res, res_count);
491 kfree(res);
492
493 if (ret)
494 goto oda_exit3;
495
496have_everything:
497 pdev->archdata.od = od; 346 pdev->archdata.od = od;
498 347
499 for (i = 0; i < oh_cnt; i++) { 348 for (i = 0; i < oh_cnt; i++) {
@@ -503,8 +352,6 @@ have_everything:
503 352
504 return od; 353 return od;
505 354
506oda_exit3:
507 kfree(hwmods);
508oda_exit2: 355oda_exit2:
509 kfree(od); 356 kfree(od);
510oda_exit1: 357oda_exit1: