aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNenghua Cao <nhcao@marvell.com>2014-01-20 07:39:01 -0500
committerVinod Koul <vinod.koul@intel.com>2014-03-06 04:19:54 -0500
commit7dedc002c0ec676590bf78ae8d76f2ffd51564f6 (patch)
tree728cd0881737a0e7032a7e585803190af4c68253
parentf0b507774449ec35fbfd7173e5fc7dd4df71a81c (diff)
dma: mmp_tdma: move to generic device tree binding
This patch makes the mmp_tdma controller able to provide DMA resources in DT environments by providing an dma xlate function to get the generic DMA device tree helper support. Then DMA clients only need to call dma_request_slave_channel() for requesting a DMA channel from dmaengine. Signed-off-by: Nenghua Cao <nhcao@marvell.com> Signed-off-by: Vinod Koul <vinod.koul@intel.com>
-rw-r--r--drivers/dma/mmp_tdma.c50
1 files changed, 50 insertions, 0 deletions
diff --git a/drivers/dma/mmp_tdma.c b/drivers/dma/mmp_tdma.c
index 33f96aaa80c7..724f7f4c9720 100644
--- a/drivers/dma/mmp_tdma.c
+++ b/drivers/dma/mmp_tdma.c
@@ -22,6 +22,7 @@
22#include <mach/regs-icu.h> 22#include <mach/regs-icu.h>
23#include <linux/platform_data/dma-mmp_tdma.h> 23#include <linux/platform_data/dma-mmp_tdma.h>
24#include <linux/of_device.h> 24#include <linux/of_device.h>
25#include <linux/of_dma.h>
25 26
26#include "dmaengine.h" 27#include "dmaengine.h"
27 28
@@ -541,6 +542,45 @@ static int mmp_tdma_chan_init(struct mmp_tdma_device *tdev,
541 return 0; 542 return 0;
542} 543}
543 544
545struct mmp_tdma_filter_param {
546 struct device_node *of_node;
547 unsigned int chan_id;
548};
549
550static bool mmp_tdma_filter_fn(struct dma_chan *chan, void *fn_param)
551{
552 struct mmp_tdma_filter_param *param = fn_param;
553 struct mmp_tdma_chan *tdmac = to_mmp_tdma_chan(chan);
554 struct dma_device *pdma_device = tdmac->chan.device;
555
556 if (pdma_device->dev->of_node != param->of_node)
557 return false;
558
559 if (chan->chan_id != param->chan_id)
560 return false;
561
562 return true;
563}
564
565struct dma_chan *mmp_tdma_xlate(struct of_phandle_args *dma_spec,
566 struct of_dma *ofdma)
567{
568 struct mmp_tdma_device *tdev = ofdma->of_dma_data;
569 dma_cap_mask_t mask = tdev->device.cap_mask;
570 struct mmp_tdma_filter_param param;
571
572 if (dma_spec->args_count != 1)
573 return NULL;
574
575 param.of_node = ofdma->of_node;
576 param.chan_id = dma_spec->args[0];
577
578 if (param.chan_id >= TDMA_CHANNEL_NUM)
579 return NULL;
580
581 return dma_request_channel(mask, mmp_tdma_filter_fn, &param);
582}
583
544static struct of_device_id mmp_tdma_dt_ids[] = { 584static struct of_device_id mmp_tdma_dt_ids[] = {
545 { .compatible = "marvell,adma-1.0", .data = (void *)MMP_AUD_TDMA}, 585 { .compatible = "marvell,adma-1.0", .data = (void *)MMP_AUD_TDMA},
546 { .compatible = "marvell,pxa910-squ", .data = (void *)PXA910_SQU}, 586 { .compatible = "marvell,pxa910-squ", .data = (void *)PXA910_SQU},
@@ -631,6 +671,16 @@ static int mmp_tdma_probe(struct platform_device *pdev)
631 return ret; 671 return ret;
632 } 672 }
633 673
674 if (pdev->dev.of_node) {
675 ret = of_dma_controller_register(pdev->dev.of_node,
676 mmp_tdma_xlate, tdev);
677 if (ret) {
678 dev_err(tdev->device.dev,
679 "failed to register controller\n");
680 dma_async_device_unregister(&tdev->device);
681 }
682 }
683
634 dev_info(tdev->device.dev, "initialized\n"); 684 dev_info(tdev->device.dev, "initialized\n");
635 return 0; 685 return 0;
636} 686}