aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNenghua Cao <nhcao@marvell.com>2013-12-13 03:14:31 -0500
committerVinod Koul <vinod.koul@intel.com>2014-01-09 07:16:20 -0500
commit3b0f4a54f247b2b5f2523fab0e6243f76ac80d9f (patch)
tree7de4b00c3408056149b80c4b64e25610b920429f
parent96286b57669073e81870e33a3e5ce476433d115f (diff)
dma:mmp_tdma: get sram pool through device tree
Support to get sram pool from generic device tree binding. The existing way of get sram poll, directly call sram_get_gpool(), still work here. Signed-off-by: Nenghua Cao <nhcao@marvell.com> Acked-by: Zhangfei Gao <zhangfei.gao@gmail.com> Signed-off-by: Vinod Koul <vinod.koul@intel.com>
-rw-r--r--drivers/dma/mmp_tdma.c22
1 files changed, 18 insertions, 4 deletions
diff --git a/drivers/dma/mmp_tdma.c b/drivers/dma/mmp_tdma.c
index d4b730ce0369..33f96aaa80c7 100644
--- a/drivers/dma/mmp_tdma.c
+++ b/drivers/dma/mmp_tdma.c
@@ -126,6 +126,8 @@ struct mmp_tdma_chan {
126 size_t buf_len; 126 size_t buf_len;
127 size_t period_len; 127 size_t period_len;
128 size_t pos; 128 size_t pos;
129
130 struct gen_pool *pool;
129}; 131};
130 132
131#define TDMA_CHANNEL_NUM 2 133#define TDMA_CHANNEL_NUM 2
@@ -324,7 +326,7 @@ static void mmp_tdma_free_descriptor(struct mmp_tdma_chan *tdmac)
324 struct gen_pool *gpool; 326 struct gen_pool *gpool;
325 int size = tdmac->desc_num * sizeof(struct mmp_tdma_desc); 327 int size = tdmac->desc_num * sizeof(struct mmp_tdma_desc);
326 328
327 gpool = sram_get_gpool("asram"); 329 gpool = tdmac->pool;
328 if (tdmac->desc_arr) 330 if (tdmac->desc_arr)
329 gen_pool_free(gpool, (unsigned long)tdmac->desc_arr, 331 gen_pool_free(gpool, (unsigned long)tdmac->desc_arr,
330 size); 332 size);
@@ -374,7 +376,7 @@ struct mmp_tdma_desc *mmp_tdma_alloc_descriptor(struct mmp_tdma_chan *tdmac)
374 struct gen_pool *gpool; 376 struct gen_pool *gpool;
375 int size = tdmac->desc_num * sizeof(struct mmp_tdma_desc); 377 int size = tdmac->desc_num * sizeof(struct mmp_tdma_desc);
376 378
377 gpool = sram_get_gpool("asram"); 379 gpool = tdmac->pool;
378 if (!gpool) 380 if (!gpool)
379 return NULL; 381 return NULL;
380 382
@@ -505,7 +507,8 @@ static int mmp_tdma_remove(struct platform_device *pdev)
505} 507}
506 508
507static int mmp_tdma_chan_init(struct mmp_tdma_device *tdev, 509static int mmp_tdma_chan_init(struct mmp_tdma_device *tdev,
508 int idx, int irq, int type) 510 int idx, int irq,
511 int type, struct gen_pool *pool)
509{ 512{
510 struct mmp_tdma_chan *tdmac; 513 struct mmp_tdma_chan *tdmac;
511 514
@@ -527,6 +530,7 @@ static int mmp_tdma_chan_init(struct mmp_tdma_device *tdev,
527 tdmac->idx = idx; 530 tdmac->idx = idx;
528 tdmac->type = type; 531 tdmac->type = type;
529 tdmac->reg_base = tdev->base + idx * 4; 532 tdmac->reg_base = tdev->base + idx * 4;
533 tdmac->pool = pool;
530 tdmac->status = DMA_COMPLETE; 534 tdmac->status = DMA_COMPLETE;
531 tdev->tdmac[tdmac->idx] = tdmac; 535 tdev->tdmac[tdmac->idx] = tdmac;
532 tasklet_init(&tdmac->tasklet, dma_do_tasklet, (unsigned long)tdmac); 536 tasklet_init(&tdmac->tasklet, dma_do_tasklet, (unsigned long)tdmac);
@@ -553,6 +557,7 @@ static int mmp_tdma_probe(struct platform_device *pdev)
553 int i, ret; 557 int i, ret;
554 int irq = 0, irq_num = 0; 558 int irq = 0, irq_num = 0;
555 int chan_num = TDMA_CHANNEL_NUM; 559 int chan_num = TDMA_CHANNEL_NUM;
560 struct gen_pool *pool;
556 561
557 of_id = of_match_device(mmp_tdma_dt_ids, &pdev->dev); 562 of_id = of_match_device(mmp_tdma_dt_ids, &pdev->dev);
558 if (of_id) 563 if (of_id)
@@ -579,6 +584,15 @@ static int mmp_tdma_probe(struct platform_device *pdev)
579 584
580 INIT_LIST_HEAD(&tdev->device.channels); 585 INIT_LIST_HEAD(&tdev->device.channels);
581 586
587 if (pdev->dev.of_node)
588 pool = of_get_named_gen_pool(pdev->dev.of_node, "asram", 0);
589 else
590 pool = sram_get_gpool("asram");
591 if (!pool) {
592 dev_err(&pdev->dev, "asram pool not available\n");
593 return -ENOMEM;
594 }
595
582 if (irq_num != chan_num) { 596 if (irq_num != chan_num) {
583 irq = platform_get_irq(pdev, 0); 597 irq = platform_get_irq(pdev, 0);
584 ret = devm_request_irq(&pdev->dev, irq, 598 ret = devm_request_irq(&pdev->dev, irq,
@@ -590,7 +604,7 @@ static int mmp_tdma_probe(struct platform_device *pdev)
590 /* initialize channel parameters */ 604 /* initialize channel parameters */
591 for (i = 0; i < chan_num; i++) { 605 for (i = 0; i < chan_num; i++) {
592 irq = (irq_num != chan_num) ? 0 : platform_get_irq(pdev, i); 606 irq = (irq_num != chan_num) ? 0 : platform_get_irq(pdev, i);
593 ret = mmp_tdma_chan_init(tdev, i, irq, type); 607 ret = mmp_tdma_chan_init(tdev, i, irq, type, pool);
594 if (ret) 608 if (ret)
595 return ret; 609 return ret;
596 } 610 }