2 * SHDMA Device Tree glue
4 * Copyright (C) 2013 Renesas Electronics Inc.
5 * Author: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
7 * This is free software; you can redistribute it and/or modify
8 * it under the terms of version 2 of the GNU General Public License as
9 * published by the Free Software Foundation.
12 #include <linux/dmaengine.h>
13 #include <linux/module.h>
15 #include <linux/of_dma.h>
16 #include <linux/of_platform.h>
17 #include <linux/platform_device.h>
18 #include <linux/shdma-base.h>
20 #define to_shdma_chan(c) container_of(c, struct shdma_chan, dma_chan)
22 static struct dma_chan *shdma_of_xlate(struct of_phandle_args *dma_spec,
25 u32 id = dma_spec->args[0];
27 struct dma_chan *chan;
29 if (dma_spec->args_count != 1)
33 /* Only slave DMA channels can be allocated via DT */
34 dma_cap_set(DMA_SLAVE, mask);
36 chan = dma_request_channel(mask, shdma_chan_filter, (void *)id);
38 to_shdma_chan(chan)->hw_req = id;
43 static int shdma_of_probe(struct platform_device *pdev)
45 const struct of_dev_auxdata *lookup = dev_get_platdata(&pdev->dev);
48 ret = of_dma_controller_register(pdev->dev.of_node,
49 shdma_of_xlate, pdev);
53 ret = of_platform_populate(pdev->dev.of_node, NULL, lookup, &pdev->dev);
55 of_dma_controller_free(pdev->dev.of_node);
60 static const struct of_device_id shdma_of_match[] = {
61 { .compatible = "renesas,shdma-mux", },
64 MODULE_DEVICE_TABLE(of, sh_dmae_of_match);
66 static struct platform_driver shdma_of = {
70 .of_match_table = shdma_of_match,
72 .probe = shdma_of_probe,
75 module_platform_driver(shdma_of);
77 MODULE_LICENSE("GPL v2");
78 MODULE_DESCRIPTION("SH-DMA driver DT glue");
79 MODULE_AUTHOR("Guennadi Liakhovetski <g.liakhovetski@gmx.de>");