1 // SPDX-License-Identifier: GPL-2.0
3 * SHDMA Device Tree glue
5 * Copyright (C) 2013 Renesas Electronics Inc.
6 * Author: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
9 #include <linux/dmaengine.h>
10 #include <linux/module.h>
12 #include <linux/of_dma.h>
13 #include <linux/of_platform.h>
14 #include <linux/platform_device.h>
15 #include <linux/shdma-base.h>
17 #define to_shdma_chan(c) container_of(c, struct shdma_chan, dma_chan)
19 static struct dma_chan
*shdma_of_xlate(struct of_phandle_args
*dma_spec
,
22 u32 id
= dma_spec
->args
[0];
24 struct dma_chan
*chan
;
26 if (dma_spec
->args_count
!= 1)
30 /* Only slave DMA channels can be allocated via DT */
31 dma_cap_set(DMA_SLAVE
, mask
);
33 chan
= dma_request_channel(mask
, shdma_chan_filter
,
34 (void *)(uintptr_t)id
);
36 to_shdma_chan(chan
)->hw_req
= id
;
41 static int shdma_of_probe(struct platform_device
*pdev
)
43 const struct of_dev_auxdata
*lookup
= dev_get_platdata(&pdev
->dev
);
46 ret
= of_dma_controller_register(pdev
->dev
.of_node
,
47 shdma_of_xlate
, pdev
);
51 ret
= of_platform_populate(pdev
->dev
.of_node
, NULL
, lookup
, &pdev
->dev
);
53 of_dma_controller_free(pdev
->dev
.of_node
);
58 static const struct of_device_id shdma_of_match
[] = {
59 { .compatible
= "renesas,shdma-mux", },
62 MODULE_DEVICE_TABLE(of
, sh_dmae_of_match
);
64 static struct platform_driver shdma_of
= {
67 .of_match_table
= shdma_of_match
,
69 .probe
= shdma_of_probe
,
72 module_platform_driver(shdma_of
);
74 MODULE_LICENSE("GPL v2");
75 MODULE_DESCRIPTION("SH-DMA driver DT glue");
76 MODULE_AUTHOR("Guennadi Liakhovetski <g.liakhovetski@gmx.de>");