aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGeert Uytterhoeven <geert+renesas@glider.be>2014-08-06 08:59:05 -0400
committerMark Brown <broonie@linaro.org>2014-08-16 18:14:30 -0400
commita6be4de6a24cbef6209e3a0fcddaee9e312a1f63 (patch)
tree84a7f2926e1cf827996d986e61689e3cf6da1c0c
parent52fba2b85d30075490db023642632032371505c2 (diff)
spi: sh-msiof: Add DT support to DMA setup
Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be> Signed-off-by: Mark Brown <broonie@linaro.org>
-rw-r--r--Documentation/devicetree/bindings/spi/sh-msiof.txt17
-rw-r--r--drivers/spi/spi-sh-msiof.c25
2 files changed, 32 insertions, 10 deletions
diff --git a/Documentation/devicetree/bindings/spi/sh-msiof.txt b/Documentation/devicetree/bindings/spi/sh-msiof.txt
index f24baf3b6cc1..98e07f1c3dab 100644
--- a/Documentation/devicetree/bindings/spi/sh-msiof.txt
+++ b/Documentation/devicetree/bindings/spi/sh-msiof.txt
@@ -6,8 +6,13 @@ Required properties:
6 "renesas,sh-mobile-msiof" for SH Mobile series. 6 "renesas,sh-mobile-msiof" for SH Mobile series.
7 Examples with soctypes are: 7 Examples with soctypes are:
8 "renesas,msiof-r8a7790" (R-Car H2) 8 "renesas,msiof-r8a7790" (R-Car H2)
9 "renesas,msiof-r8a7791" (R-Car M2) 9- reg : A list of offsets and lengths of the register sets for
10- reg : Offset and length of the register set for the device 10 the device.
11 If only one register set is present, it is to be used
12 by both the CPU and the DMA engine.
13 If two register sets are present, the first is to be
14 used by the CPU, and the second is to be used by the
15 DMA engine.
11- interrupt-parent : The phandle for the interrupt controller that 16- interrupt-parent : The phandle for the interrupt controller that
12 services interrupts for this device 17 services interrupts for this device
13- interrupts : Interrupt specifier 18- interrupts : Interrupt specifier
@@ -17,6 +22,10 @@ Required properties:
17Optional properties: 22Optional properties:
18- clocks : Must contain a reference to the functional clock. 23- clocks : Must contain a reference to the functional clock.
19- num-cs : Total number of chip-selects (default is 1) 24- num-cs : Total number of chip-selects (default is 1)
25- dmas : Must contain a list of two references to DMA
26 specifiers, one for transmission, and one for
27 reception.
28- dma-names : Must contain a list of two DMA names, "tx" and "rx".
20 29
21Optional properties, deprecated for soctype-specific bindings: 30Optional properties, deprecated for soctype-specific bindings:
22- renesas,tx-fifo-size : Overrides the default tx fifo size given in words 31- renesas,tx-fifo-size : Overrides the default tx fifo size given in words
@@ -31,9 +40,11 @@ Example:
31 40
32 msiof0: spi@e6e20000 { 41 msiof0: spi@e6e20000 {
33 compatible = "renesas,msiof-r8a7791"; 42 compatible = "renesas,msiof-r8a7791";
34 reg = <0 0xe6e20000 0 0x0064>; 43 reg = <0 0xe6e20000 0 0x0064>, <0 0xe7e20000 0 0x0064>;
35 interrupts = <0 156 IRQ_TYPE_LEVEL_HIGH>; 44 interrupts = <0 156 IRQ_TYPE_LEVEL_HIGH>;
36 clocks = <&mstp0_clks R8A7791_CLK_MSIOF0>; 45 clocks = <&mstp0_clks R8A7791_CLK_MSIOF0>;
46 dmas = <&dmac0 0x51>, <&dmac0 0x52>;
47 dma-names = "tx", "rx";
37 #address-cells = <1>; 48 #address-cells = <1>;
38 #size-cells = <0>; 49 #size-cells = <0>;
39 status = "disabled"; 50 status = "disabled";
diff --git a/drivers/spi/spi-sh-msiof.c b/drivers/spi/spi-sh-msiof.c
index b19cbb4cb4a0..811a42dba92a 100644
--- a/drivers/spi/spi-sh-msiof.c
+++ b/drivers/spi/spi-sh-msiof.c
@@ -977,10 +977,11 @@ static struct dma_chan *sh_msiof_request_dma_chan(struct device *dev,
977 dma_cap_zero(mask); 977 dma_cap_zero(mask);
978 dma_cap_set(DMA_SLAVE, mask); 978 dma_cap_set(DMA_SLAVE, mask);
979 979
980 chan = dma_request_channel(mask, shdma_chan_filter, 980 chan = dma_request_slave_channel_compat(mask, shdma_chan_filter,
981 (void *)(unsigned long)id); 981 (void *)(unsigned long)id, dev,
982 dir == DMA_MEM_TO_DEV ? "tx" : "rx");
982 if (!chan) { 983 if (!chan) {
983 dev_warn(dev, "dma_request_channel failed\n"); 984 dev_warn(dev, "dma_request_slave_channel_compat failed\n");
984 return NULL; 985 return NULL;
985 } 986 }
986 987
@@ -1010,12 +1011,22 @@ static int sh_msiof_request_dma(struct sh_msiof_spi_priv *p)
1010 struct platform_device *pdev = p->pdev; 1011 struct platform_device *pdev = p->pdev;
1011 struct device *dev = &pdev->dev; 1012 struct device *dev = &pdev->dev;
1012 const struct sh_msiof_spi_info *info = dev_get_platdata(dev); 1013 const struct sh_msiof_spi_info *info = dev_get_platdata(dev);
1014 unsigned int dma_tx_id, dma_rx_id;
1013 const struct resource *res; 1015 const struct resource *res;
1014 struct spi_master *master; 1016 struct spi_master *master;
1015 struct device *tx_dev, *rx_dev; 1017 struct device *tx_dev, *rx_dev;
1016 1018
1017 if (!info || !info->dma_tx_id || !info->dma_rx_id) 1019 if (dev->of_node) {
1018 return 0; /* The driver assumes no error */ 1020 /* In the OF case we will get the slave IDs from the DT */
1021 dma_tx_id = 0;
1022 dma_rx_id = 0;
1023 } else if (info && info->dma_tx_id && info->dma_rx_id) {
1024 dma_tx_id = info->dma_tx_id;
1025 dma_rx_id = info->dma_rx_id;
1026 } else {
1027 /* The driver assumes no error */
1028 return 0;
1029 }
1019 1030
1020 /* The DMA engine uses the second register set, if present */ 1031 /* The DMA engine uses the second register set, if present */
1021 res = platform_get_resource(pdev, IORESOURCE_MEM, 1); 1032 res = platform_get_resource(pdev, IORESOURCE_MEM, 1);
@@ -1024,13 +1035,13 @@ static int sh_msiof_request_dma(struct sh_msiof_spi_priv *p)
1024 1035
1025 master = p->master; 1036 master = p->master;
1026 master->dma_tx = sh_msiof_request_dma_chan(dev, DMA_MEM_TO_DEV, 1037 master->dma_tx = sh_msiof_request_dma_chan(dev, DMA_MEM_TO_DEV,
1027 info->dma_tx_id, 1038 dma_tx_id,
1028 res->start + TFDR); 1039 res->start + TFDR);
1029 if (!master->dma_tx) 1040 if (!master->dma_tx)
1030 return -ENODEV; 1041 return -ENODEV;
1031 1042
1032 master->dma_rx = sh_msiof_request_dma_chan(dev, DMA_DEV_TO_MEM, 1043 master->dma_rx = sh_msiof_request_dma_chan(dev, DMA_DEV_TO_MEM,
1033 info->dma_rx_id, 1044 dma_rx_id,
1034 res->start + RFDR); 1045 res->start + RFDR);
1035 if (!master->dma_rx) 1046 if (!master->dma_rx)
1036 goto free_tx_chan; 1047 goto free_tx_chan;