diff options
Diffstat (limited to 'drivers/dma/sh/shdma-of.c')
-rw-r--r-- | drivers/dma/sh/shdma-of.c | 82 |
1 files changed, 82 insertions, 0 deletions
diff --git a/drivers/dma/sh/shdma-of.c b/drivers/dma/sh/shdma-of.c new file mode 100644 index 000000000000..11bcb05cd79c --- /dev/null +++ b/drivers/dma/sh/shdma-of.c | |||
@@ -0,0 +1,82 @@ | |||
1 | /* | ||
2 | * SHDMA Device Tree glue | ||
3 | * | ||
4 | * Copyright (C) 2013 Renesas Electronics Inc. | ||
5 | * Author: Guennadi Liakhovetski <g.liakhovetski@gmx.de> | ||
6 | * | ||
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. | ||
10 | */ | ||
11 | |||
12 | #include <linux/dmaengine.h> | ||
13 | #include <linux/module.h> | ||
14 | #include <linux/of.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> | ||
19 | |||
20 | #define to_shdma_chan(c) container_of(c, struct shdma_chan, dma_chan) | ||
21 | |||
22 | static struct dma_chan *shdma_of_xlate(struct of_phandle_args *dma_spec, | ||
23 | struct of_dma *ofdma) | ||
24 | { | ||
25 | u32 id = dma_spec->args[0]; | ||
26 | dma_cap_mask_t mask; | ||
27 | struct dma_chan *chan; | ||
28 | |||
29 | if (dma_spec->args_count != 1) | ||
30 | return NULL; | ||
31 | |||
32 | dma_cap_zero(mask); | ||
33 | /* Only slave DMA channels can be allocated via DT */ | ||
34 | dma_cap_set(DMA_SLAVE, mask); | ||
35 | |||
36 | chan = dma_request_channel(mask, shdma_chan_filter, (void *)id); | ||
37 | if (chan) | ||
38 | to_shdma_chan(chan)->hw_req = id; | ||
39 | |||
40 | return chan; | ||
41 | } | ||
42 | |||
43 | static int shdma_of_probe(struct platform_device *pdev) | ||
44 | { | ||
45 | const struct of_dev_auxdata *lookup = pdev->dev.platform_data; | ||
46 | int ret; | ||
47 | |||
48 | if (!lookup) | ||
49 | return -EINVAL; | ||
50 | |||
51 | ret = of_dma_controller_register(pdev->dev.of_node, | ||
52 | shdma_of_xlate, pdev); | ||
53 | if (ret < 0) | ||
54 | return ret; | ||
55 | |||
56 | ret = of_platform_populate(pdev->dev.of_node, NULL, lookup, &pdev->dev); | ||
57 | if (ret < 0) | ||
58 | of_dma_controller_free(pdev->dev.of_node); | ||
59 | |||
60 | return ret; | ||
61 | } | ||
62 | |||
63 | static const struct of_device_id shdma_of_match[] = { | ||
64 | { .compatible = "renesas,shdma-mux", }, | ||
65 | { } | ||
66 | }; | ||
67 | MODULE_DEVICE_TABLE(of, sh_dmae_of_match); | ||
68 | |||
69 | static struct platform_driver shdma_of = { | ||
70 | .driver = { | ||
71 | .owner = THIS_MODULE, | ||
72 | .name = "shdma-of", | ||
73 | .of_match_table = shdma_of_match, | ||
74 | }, | ||
75 | .probe = shdma_of_probe, | ||
76 | }; | ||
77 | |||
78 | module_platform_driver(shdma_of); | ||
79 | |||
80 | MODULE_LICENSE("GPL v2"); | ||
81 | MODULE_DESCRIPTION("SH-DMA driver DT glue"); | ||
82 | MODULE_AUTHOR("Guennadi Liakhovetski <g.liakhovetski@gmx.de>"); | ||