Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Arnd Bergmann and committed by
Mark Brown
a0067db3 8005c49d

+19 -29
+10 -9
arch/arm/plat-samsung/devs.c
··· 1100 1100 #ifdef CONFIG_S3C64XX_DEV_SPI0 1101 1101 static struct resource s3c64xx_spi0_resource[] = { 1102 1102 [0] = DEFINE_RES_MEM(S3C_PA_SPI0, SZ_256), 1103 - [1] = DEFINE_RES_DMA(DMACH_SPI0_TX), 1104 - [2] = DEFINE_RES_DMA(DMACH_SPI0_RX), 1105 - [3] = DEFINE_RES_IRQ(IRQ_SPI0), 1103 + [1] = DEFINE_RES_IRQ(IRQ_SPI0), 1106 1104 }; 1107 1105 1108 1106 struct platform_device s3c64xx_device_spi0 = { ··· 1128 1130 pd.num_cs = num_cs; 1129 1131 pd.src_clk_nr = src_clk_nr; 1130 1132 pd.cfg_gpio = (cfg_gpio) ? cfg_gpio : s3c64xx_spi0_cfg_gpio; 1133 + pd.dma_tx = (void *)DMACH_SPI0_TX; 1134 + pd.dma_rx = (void *)DMACH_SPI0_RX; 1131 1135 #if defined(CONFIG_PL330_DMA) 1132 1136 pd.filter = pl330_filter; 1133 1137 #elif defined(CONFIG_S3C64XX_PL080) ··· 1145 1145 #ifdef CONFIG_S3C64XX_DEV_SPI1 1146 1146 static struct resource s3c64xx_spi1_resource[] = { 1147 1147 [0] = DEFINE_RES_MEM(S3C_PA_SPI1, SZ_256), 1148 - [1] = DEFINE_RES_DMA(DMACH_SPI1_TX), 1149 - [2] = DEFINE_RES_DMA(DMACH_SPI1_RX), 1150 - [3] = DEFINE_RES_IRQ(IRQ_SPI1), 1148 + [1] = DEFINE_RES_IRQ(IRQ_SPI1), 1151 1149 }; 1152 1150 1153 1151 struct platform_device s3c64xx_device_spi1 = { ··· 1173 1175 pd.num_cs = num_cs; 1174 1176 pd.src_clk_nr = src_clk_nr; 1175 1177 pd.cfg_gpio = (cfg_gpio) ? cfg_gpio : s3c64xx_spi1_cfg_gpio; 1178 + pd.dma_tx = (void *)DMACH_SPI1_TX; 1179 + pd.dma_rx = (void *)DMACH_SPI1_RX; 1176 1180 #if defined(CONFIG_PL330_DMA) 1177 1181 pd.filter = pl330_filter; 1178 1182 #elif defined(CONFIG_S3C64XX_PL080) 1179 1183 pd.filter = pl08x_filter_id; 1180 1184 #endif 1185 + 1181 1186 1182 1187 s3c_set_platdata(&pd, sizeof(pd), &s3c64xx_device_spi1); 1183 1188 } ··· 1189 1188 #ifdef CONFIG_S3C64XX_DEV_SPI2 1190 1189 static struct resource s3c64xx_spi2_resource[] = { 1191 1190 [0] = DEFINE_RES_MEM(S3C_PA_SPI2, SZ_256), 1192 - [1] = DEFINE_RES_DMA(DMACH_SPI2_TX), 1193 - [2] = DEFINE_RES_DMA(DMACH_SPI2_RX), 1194 - [3] = DEFINE_RES_IRQ(IRQ_SPI2), 1191 + [1] = DEFINE_RES_IRQ(IRQ_SPI2), 1195 1192 }; 1196 1193 1197 1194 struct platform_device s3c64xx_device_spi2 = { ··· 1217 1218 pd.num_cs = num_cs; 1218 1219 pd.src_clk_nr = src_clk_nr; 1219 1220 pd.cfg_gpio = (cfg_gpio) ? cfg_gpio : s3c64xx_spi2_cfg_gpio; 1221 + pd.dma_tx = (void *)DMACH_SPI2_TX; 1222 + pd.dma_rx = (void *)DMACH_SPI2_RX; 1220 1223 #if defined(CONFIG_PL330_DMA) 1221 1224 pd.filter = pl330_filter; 1222 1225 #elif defined(CONFIG_S3C64XX_PL080)
+7 -20
drivers/spi/spi-s3c64xx.c
··· 133 133 struct s3c64xx_spi_dma_data { 134 134 struct dma_chan *ch; 135 135 enum dma_transfer_direction direction; 136 - unsigned int dmach; 137 136 }; 138 137 139 138 /** ··· 324 325 325 326 /* Acquire DMA channels */ 326 327 sdd->rx_dma.ch = dma_request_slave_channel_compat(mask, filter, 327 - (void *)(long)sdd->rx_dma.dmach, dev, "rx"); 328 + sdd->cntrlr_info->dma_rx, dev, "rx"); 328 329 if (!sdd->rx_dma.ch) { 329 330 dev_err(dev, "Failed to get RX DMA channel\n"); 330 331 ret = -EBUSY; ··· 333 334 spi->dma_rx = sdd->rx_dma.ch; 334 335 335 336 sdd->tx_dma.ch = dma_request_slave_channel_compat(mask, filter, 336 - (void *)(long)sdd->tx_dma.dmach, dev, "tx"); 337 + sdd->cntrlr_info->dma_tx, dev, "tx"); 337 338 if (!sdd->tx_dma.ch) { 338 339 dev_err(dev, "Failed to get TX DMA channel\n"); 339 340 ret = -EBUSY; ··· 1027 1028 static int s3c64xx_spi_probe(struct platform_device *pdev) 1028 1029 { 1029 1030 struct resource *mem_res; 1030 - struct resource *res; 1031 1031 struct s3c64xx_spi_driver_data *sdd; 1032 1032 struct s3c64xx_spi_info *sci = dev_get_platdata(&pdev->dev); 1033 1033 struct spi_master *master; ··· 1085 1087 1086 1088 sdd->cur_bpw = 8; 1087 1089 1088 - if (!sdd->pdev->dev.of_node) { 1089 - res = platform_get_resource(pdev, IORESOURCE_DMA, 0); 1090 - if (!res) { 1091 - dev_warn(&pdev->dev, "Unable to get SPI tx dma resource. Switching to poll mode\n"); 1092 - sdd->port_conf->quirks = S3C64XX_SPI_QUIRK_POLL; 1093 - } else 1094 - sdd->tx_dma.dmach = res->start; 1095 - 1096 - res = platform_get_resource(pdev, IORESOURCE_DMA, 1); 1097 - if (!res) { 1098 - dev_warn(&pdev->dev, "Unable to get SPI rx dma resource. Switching to poll mode\n"); 1099 - sdd->port_conf->quirks = S3C64XX_SPI_QUIRK_POLL; 1100 - } else 1101 - sdd->rx_dma.dmach = res->start; 1090 + if (!sdd->pdev->dev.of_node && (!sci->dma_tx || !sci->dma_rx)) { 1091 + dev_warn(&pdev->dev, "Unable to get SPI tx/rx DMA data. Switching to poll mode\n"); 1092 + sdd->port_conf->quirks = S3C64XX_SPI_QUIRK_POLL; 1102 1093 } 1103 1094 1104 1095 sdd->tx_dma.direction = DMA_MEM_TO_DEV; ··· 1184 1197 1185 1198 dev_dbg(&pdev->dev, "Samsung SoC SPI Driver loaded for Bus SPI-%d with %d Slaves attached\n", 1186 1199 sdd->port_id, master->num_chipselect); 1187 - dev_dbg(&pdev->dev, "\tIOmem=[%pR]\tFIFO %dbytes\tDMA=[Rx-%d, Tx-%d]\n", 1200 + dev_dbg(&pdev->dev, "\tIOmem=[%pR]\tFIFO %dbytes\tDMA=[Rx-%p, Tx-%p]\n", 1188 1201 mem_res, (FIFO_LVL_MASK(sdd) >> 1) + 1, 1189 - sdd->rx_dma.dmach, sdd->tx_dma.dmach); 1202 + sci->dma_rx, sci->dma_tx); 1190 1203 1191 1204 pm_runtime_mark_last_busy(&pdev->dev); 1192 1205 pm_runtime_put_autosuspend(&pdev->dev);
+2
include/linux/platform_data/spi-s3c64xx.h
··· 40 40 int num_cs; 41 41 int (*cfg_gpio)(void); 42 42 dma_filter_fn filter; 43 + void *dma_tx; 44 + void *dma_rx; 43 45 }; 44 46 45 47 /**