forked from torvalds/linux
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This patch adds Device Tree support to the shdma driver. No special DT properties are used, only standard DMA DT bindings are implemented. Since shdma controllers reside on SoCs, their configuration is SoC-specific and shall be passed to the driver from the SoC platform data, using the auxdata procedure. Signed-off-by: Guennadi Liakhovetski <[email protected]> Acked-by: Arnd Bergmann <[email protected]> Signed-off-by: Vinod Koul <[email protected]>
- Loading branch information
Showing
6 changed files
with
205 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
* SHDMA Device Tree bindings | ||
|
||
Sh-/r-mobile and r-car systems often have multiple identical DMA controller | ||
instances, capable of serving any of a common set of DMA slave devices, using | ||
the same configuration. To describe this topology we require all compatible | ||
SHDMA DT nodes to be placed under a DMA multiplexer node. All such compatible | ||
DMAC instances have the same number of channels and use the same DMA | ||
descriptors. Therefore respective DMA DT bindings can also all be placed in the | ||
multiplexer node. Even if there is only one such DMAC instance on a system, it | ||
still has to be placed under such a multiplexer node. | ||
|
||
* DMA multiplexer | ||
|
||
Required properties: | ||
- compatible: should be "renesas,shdma-mux" | ||
- #dma-cells: should be <1>, see "dmas" property below | ||
|
||
Optional properties (currently unused): | ||
- dma-channels: number of DMA channels | ||
- dma-requests: number of DMA request signals | ||
|
||
* DMA controller | ||
|
||
Required properties: | ||
- compatible: should be "renesas,shdma" | ||
|
||
Example: | ||
dmac: dma-mux0 { | ||
compatible = "renesas,shdma-mux"; | ||
#dma-cells = <1>; | ||
dma-channels = <6>; | ||
dma-requests = <256>; | ||
reg = <0 0>; /* Needed for AUXDATA */ | ||
#address-cells = <1>; | ||
#size-cells = <1>; | ||
ranges; | ||
|
||
dma0: shdma@fe008020 { | ||
compatible = "renesas,shdma"; | ||
reg = <0xfe008020 0x270>, | ||
<0xfe009000 0xc>; | ||
interrupt-parent = <&gic>; | ||
interrupts = <0 34 4 | ||
0 28 4 | ||
0 29 4 | ||
0 30 4 | ||
0 31 4 | ||
0 32 4 | ||
0 33 4>; | ||
interrupt-names = "error", | ||
"ch0", "ch1", "ch2", "ch3", | ||
"ch4", "ch5"; | ||
}; | ||
|
||
dma1: shdma@fe018020 { | ||
... | ||
}; | ||
|
||
dma2: shdma@fe028020 { | ||
... | ||
}; | ||
}; | ||
|
||
* DMA client | ||
|
||
Required properties: | ||
- dmas: a list of <[DMA multiplexer phandle] [MID/RID value]> pairs, | ||
where MID/RID values are fixed handles, specified in the SoC | ||
manual | ||
- dma-names: a list of DMA channel names, one per "dmas" entry | ||
|
||
Example: | ||
dmas = <&dmac 0xd1 | ||
&dmac 0xd2>; | ||
dma-names = "tx", "rx"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
obj-$(CONFIG_SH_DMAE_BASE) += shdma-base.o | ||
obj-$(CONFIG_SH_DMAE_BASE) += shdma-base.o shdma-of.o | ||
obj-$(CONFIG_SH_DMAE) += shdma.o | ||
obj-$(CONFIG_SUDMAC) += sudmac.o |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
/* | ||
* SHDMA Device Tree glue | ||
* | ||
* Copyright (C) 2013 Renesas Electronics Inc. | ||
* Author: Guennadi Liakhovetski <[email protected]> | ||
* | ||
* This is free software; you can redistribute it and/or modify | ||
* it under the terms of version 2 of the GNU General Public License as | ||
* published by the Free Software Foundation. | ||
*/ | ||
|
||
#include <linux/dmaengine.h> | ||
#include <linux/module.h> | ||
#include <linux/of.h> | ||
#include <linux/of_dma.h> | ||
#include <linux/of_platform.h> | ||
#include <linux/platform_device.h> | ||
#include <linux/shdma-base.h> | ||
|
||
#define to_shdma_chan(c) container_of(c, struct shdma_chan, dma_chan) | ||
|
||
static struct dma_chan *shdma_of_xlate(struct of_phandle_args *dma_spec, | ||
struct of_dma *ofdma) | ||
{ | ||
u32 id = dma_spec->args[0]; | ||
dma_cap_mask_t mask; | ||
struct dma_chan *chan; | ||
|
||
if (dma_spec->args_count != 1) | ||
return NULL; | ||
|
||
dma_cap_zero(mask); | ||
/* Only slave DMA channels can be allocated via DT */ | ||
dma_cap_set(DMA_SLAVE, mask); | ||
|
||
chan = dma_request_channel(mask, shdma_chan_filter, (void *)id); | ||
if (chan) | ||
to_shdma_chan(chan)->hw_req = id; | ||
|
||
return chan; | ||
} | ||
|
||
static int shdma_of_probe(struct platform_device *pdev) | ||
{ | ||
const struct of_dev_auxdata *lookup = pdev->dev.platform_data; | ||
int ret; | ||
|
||
if (!lookup) | ||
return -EINVAL; | ||
|
||
ret = of_dma_controller_register(pdev->dev.of_node, | ||
shdma_of_xlate, pdev); | ||
if (ret < 0) | ||
return ret; | ||
|
||
ret = of_platform_populate(pdev->dev.of_node, NULL, lookup, &pdev->dev); | ||
if (ret < 0) | ||
of_dma_controller_free(pdev->dev.of_node); | ||
|
||
return ret; | ||
} | ||
|
||
static const struct of_device_id shdma_of_match[] = { | ||
{ .compatible = "renesas,shdma-mux", }, | ||
{ } | ||
}; | ||
MODULE_DEVICE_TABLE(of, sh_dmae_of_match); | ||
|
||
static struct platform_driver shdma_of = { | ||
.driver = { | ||
.owner = THIS_MODULE, | ||
.name = "shdma-of", | ||
.of_match_table = shdma_of_match, | ||
}, | ||
.probe = shdma_of_probe, | ||
}; | ||
|
||
module_platform_driver(shdma_of); | ||
|
||
MODULE_LICENSE("GPL v2"); | ||
MODULE_DESCRIPTION("SH-DMA driver DT glue"); | ||
MODULE_AUTHOR("Guennadi Liakhovetski <[email protected]>"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters