aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/spi/spi-s3c64xx.c
diff options
context:
space:
mode:
authorArnd Bergmann <arnd@arndb.de>2015-11-18 09:21:32 -0500
committerMark Brown <broonie@kernel.org>2015-11-18 12:52:38 -0500
commita0067db36a2f9733a2e956a44ef8145e6a809bdb (patch)
treeb76e540559f2806c327a8aeee731ac96573b4fa7 /drivers/spi/spi-s3c64xx.c
parent8005c49d9aea74d382f474ce11afbbc7d7130bec (diff)
spi: s3c64xx: pass DMA arguments in platform data
The s3c64xx platform data already contains a pointer to the DMA filter function, but not to the associated data. This simplifies the code and makes it more generic by passing the data along with the filter function like we do for other drivers. Signed-off-by: Arnd Bergmann <arnd@arndb.de> Signed-off-by: Mark Brown <broonie@kernel.org>
Diffstat (limited to 'drivers/spi/spi-s3c64xx.c')
-rw-r--r--drivers/spi/spi-s3c64xx.c27
1 files changed, 7 insertions, 20 deletions
diff --git a/drivers/spi/spi-s3c64xx.c b/drivers/spi/spi-s3c64xx.c
index 8e86e7f6663a..b954c5444cca 100644
--- a/drivers/spi/spi-s3c64xx.c
+++ b/drivers/spi/spi-s3c64xx.c
@@ -133,7 +133,6 @@
133struct s3c64xx_spi_dma_data { 133struct s3c64xx_spi_dma_data {
134 struct dma_chan *ch; 134 struct dma_chan *ch;
135 enum dma_transfer_direction direction; 135 enum dma_transfer_direction direction;
136 unsigned int dmach;
137}; 136};
138 137
139/** 138/**
@@ -325,7 +324,7 @@ static int s3c64xx_spi_prepare_transfer(struct spi_master *spi)
325 324
326 /* Acquire DMA channels */ 325 /* Acquire DMA channels */
327 sdd->rx_dma.ch = dma_request_slave_channel_compat(mask, filter, 326 sdd->rx_dma.ch = dma_request_slave_channel_compat(mask, filter,
328 (void *)(long)sdd->rx_dma.dmach, dev, "rx"); 327 sdd->cntrlr_info->dma_rx, dev, "rx");
329 if (!sdd->rx_dma.ch) { 328 if (!sdd->rx_dma.ch) {
330 dev_err(dev, "Failed to get RX DMA channel\n"); 329 dev_err(dev, "Failed to get RX DMA channel\n");
331 ret = -EBUSY; 330 ret = -EBUSY;
@@ -334,7 +333,7 @@ static int s3c64xx_spi_prepare_transfer(struct spi_master *spi)
334 spi->dma_rx = sdd->rx_dma.ch; 333 spi->dma_rx = sdd->rx_dma.ch;
335 334
336 sdd->tx_dma.ch = dma_request_slave_channel_compat(mask, filter, 335 sdd->tx_dma.ch = dma_request_slave_channel_compat(mask, filter,
337 (void *)(long)sdd->tx_dma.dmach, dev, "tx"); 336 sdd->cntrlr_info->dma_tx, dev, "tx");
338 if (!sdd->tx_dma.ch) { 337 if (!sdd->tx_dma.ch) {
339 dev_err(dev, "Failed to get TX DMA channel\n"); 338 dev_err(dev, "Failed to get TX DMA channel\n");
340 ret = -EBUSY; 339 ret = -EBUSY;
@@ -1028,7 +1027,6 @@ static inline struct s3c64xx_spi_port_config *s3c64xx_spi_get_port_config(
1028static int s3c64xx_spi_probe(struct platform_device *pdev) 1027static int s3c64xx_spi_probe(struct platform_device *pdev)
1029{ 1028{
1030 struct resource *mem_res; 1029 struct resource *mem_res;
1031 struct resource *res;
1032 struct s3c64xx_spi_driver_data *sdd; 1030 struct s3c64xx_spi_driver_data *sdd;
1033 struct s3c64xx_spi_info *sci = dev_get_platdata(&pdev->dev); 1031 struct s3c64xx_spi_info *sci = dev_get_platdata(&pdev->dev);
1034 struct spi_master *master; 1032 struct spi_master *master;
@@ -1087,20 +1085,9 @@ static int s3c64xx_spi_probe(struct platform_device *pdev)
1087 1085
1088 sdd->cur_bpw = 8; 1086 sdd->cur_bpw = 8;
1089 1087
1090 if (!sdd->pdev->dev.of_node) { 1088 if (!sdd->pdev->dev.of_node && (!sci->dma_tx || !sci->dma_rx)) {
1091 res = platform_get_resource(pdev, IORESOURCE_DMA, 0); 1089 dev_warn(&pdev->dev, "Unable to get SPI tx/rx DMA data. Switching to poll mode\n");
1092 if (!res) { 1090 sdd->port_conf->quirks = S3C64XX_SPI_QUIRK_POLL;
1093 dev_warn(&pdev->dev, "Unable to get SPI tx dma resource. Switching to poll mode\n");
1094 sdd->port_conf->quirks = S3C64XX_SPI_QUIRK_POLL;
1095 } else
1096 sdd->tx_dma.dmach = res->start;
1097
1098 res = platform_get_resource(pdev, IORESOURCE_DMA, 1);
1099 if (!res) {
1100 dev_warn(&pdev->dev, "Unable to get SPI rx dma resource. Switching to poll mode\n");
1101 sdd->port_conf->quirks = S3C64XX_SPI_QUIRK_POLL;
1102 } else
1103 sdd->rx_dma.dmach = res->start;
1104 } 1091 }
1105 1092
1106 sdd->tx_dma.direction = DMA_MEM_TO_DEV; 1093 sdd->tx_dma.direction = DMA_MEM_TO_DEV;
@@ -1197,9 +1184,9 @@ static int s3c64xx_spi_probe(struct platform_device *pdev)
1197 1184
1198 dev_dbg(&pdev->dev, "Samsung SoC SPI Driver loaded for Bus SPI-%d with %d Slaves attached\n", 1185 dev_dbg(&pdev->dev, "Samsung SoC SPI Driver loaded for Bus SPI-%d with %d Slaves attached\n",
1199 sdd->port_id, master->num_chipselect); 1186 sdd->port_id, master->num_chipselect);
1200 dev_dbg(&pdev->dev, "\tIOmem=[%pR]\tFIFO %dbytes\tDMA=[Rx-%d, Tx-%d]\n", 1187 dev_dbg(&pdev->dev, "\tIOmem=[%pR]\tFIFO %dbytes\tDMA=[Rx-%p, Tx-%p]\n",
1201 mem_res, (FIFO_LVL_MASK(sdd) >> 1) + 1, 1188 mem_res, (FIFO_LVL_MASK(sdd) >> 1) + 1,
1202 sdd->rx_dma.dmach, sdd->tx_dma.dmach); 1189 sci->dma_rx, sci->dma_tx);
1203 1190
1204 pm_runtime_mark_last_busy(&pdev->dev); 1191 pm_runtime_mark_last_busy(&pdev->dev);
1205 pm_runtime_put_autosuspend(&pdev->dev); 1192 pm_runtime_put_autosuspend(&pdev->dev);