aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/spi
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 /drivers/spi
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>
Diffstat (limited to 'drivers/spi')
-rw-r--r--drivers/spi/spi-sh-msiof.c25
1 files changed, 18 insertions, 7 deletions
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;