History

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.

Arnd Bergmann committed 11 years ago

Commit a0067db1 parent 8005c493 files · +19 −29Browse files

Unified · Split

3 files
  1. arch/arm/plat-samsung/devs.c +10 −9
  2. drivers/spi/spi-s3c64xx.c +7 −20
  3. include/linux/platform_data/spi-s3c64xx.h +2 −0
arch/arm/plat-samsung/devs.c+10−9
@@ -1100,9 +1100,7 @@ struct platform_device s3c_device_wdt = { · 1099 unmodified lines
1100#ifdef CONFIG_S3C64XX_DEV_SPI01100#ifdef CONFIG_S3C64XX_DEV_SPI0
1101static struct resource s3c64xx_spi0_resource[] = {1101static struct resource s3c64xx_spi0_resource[] = {
1102 [0] = DEFINE_RES_MEM(S3C_PA_SPI0, SZ_256),1102 [0] = DEFINE_RES_MEM(S3C_PA_SPI0, SZ_256),
1103 [1] = DEFINE_RES_DMA(DMACH_SPI0_TX),1103 [1] = DEFINE_RES_IRQ(IRQ_SPI0),
1104 [2] = DEFINE_RES_DMA(DMACH_SPI0_RX),
1105 [3] = DEFINE_RES_IRQ(IRQ_SPI0),
1106};1104};
1107 1105
1108struct platform_device s3c64xx_device_spi0 = {1106struct platform_device s3c64xx_device_spi0 = {
@@ -1130,6 +1128,8 @@ void __init s3c64xx_spi0_set_platdata(int (*cfg_gpio)(void), int src_clk_nr, · 21 unmodified lines
1130 pd.num_cs = num_cs;1128 pd.num_cs = num_cs;
1131 pd.src_clk_nr = src_clk_nr;1129 pd.src_clk_nr = src_clk_nr;
1132 pd.cfg_gpio = (cfg_gpio) ? cfg_gpio : s3c64xx_spi0_cfg_gpio;1130 pd.cfg_gpio = (cfg_gpio) ? cfg_gpio : s3c64xx_spi0_cfg_gpio;
1131 pd.dma_tx = (void *)DMACH_SPI0_TX;
1132 pd.dma_rx = (void *)DMACH_SPI0_RX;
1133#if defined(CONFIG_PL330_DMA)1133#if defined(CONFIG_PL330_DMA)
1134 pd.filter = pl330_filter;1134 pd.filter = pl330_filter;
1135#elif defined(CONFIG_S3C64XX_PL080)1135#elif defined(CONFIG_S3C64XX_PL080)
@@ -1145,9 +1145,7 @@ void __init s3c64xx_spi0_set_platdata(int (*cfg_gpio)(void), int src_clk_nr, · 9 unmodified lines
1145#ifdef CONFIG_S3C64XX_DEV_SPI11145#ifdef CONFIG_S3C64XX_DEV_SPI1
1146static struct resource s3c64xx_spi1_resource[] = {1146static struct resource s3c64xx_spi1_resource[] = {
1147 [0] = DEFINE_RES_MEM(S3C_PA_SPI1, SZ_256),1147 [0] = DEFINE_RES_MEM(S3C_PA_SPI1, SZ_256),
1148 [1] = DEFINE_RES_DMA(DMACH_SPI1_TX),1148 [1] = DEFINE_RES_IRQ(IRQ_SPI1),
1149 [2] = DEFINE_RES_DMA(DMACH_SPI1_RX),
1150 [3] = DEFINE_RES_IRQ(IRQ_SPI1),
1151};1149};
1152 1150
1153struct platform_device s3c64xx_device_spi1 = {1151struct platform_device s3c64xx_device_spi1 = {
@@ -1175,12 +1173,15 @@ void __init s3c64xx_spi1_set_platdata(int (*cfg_gpio)(void), int src_clk_nr, · 21 unmodified lines
1175 pd.num_cs = num_cs;1173 pd.num_cs = num_cs;
1176 pd.src_clk_nr = src_clk_nr;1174 pd.src_clk_nr = src_clk_nr;
1177 pd.cfg_gpio = (cfg_gpio) ? cfg_gpio : s3c64xx_spi1_cfg_gpio;1175 pd.cfg_gpio = (cfg_gpio) ? cfg_gpio : s3c64xx_spi1_cfg_gpio;
1176 pd.dma_tx = (void *)DMACH_SPI1_TX;
1177 pd.dma_rx = (void *)DMACH_SPI1_RX;
1178#if defined(CONFIG_PL330_DMA)1178#if defined(CONFIG_PL330_DMA)
1179 pd.filter = pl330_filter;1179 pd.filter = pl330_filter;
1180#elif defined(CONFIG_S3C64XX_PL080)1180#elif defined(CONFIG_S3C64XX_PL080)
1181 pd.filter = pl08x_filter_id;1181 pd.filter = pl08x_filter_id;
1182#endif1182#endif
1183 1183
1184
1184 s3c_set_platdata(&pd, sizeof(pd), &s3c64xx_device_spi1);1185 s3c_set_platdata(&pd, sizeof(pd), &s3c64xx_device_spi1);
1185}1186}
1186#endif /* CONFIG_S3C64XX_DEV_SPI1 */1187#endif /* CONFIG_S3C64XX_DEV_SPI1 */
@@ -1188,9 +1189,7 @@ void __init s3c64xx_spi1_set_platdata(int (*cfg_gpio)(void), int src_clk_nr, · 1 unmodified line
1188#ifdef CONFIG_S3C64XX_DEV_SPI21189#ifdef CONFIG_S3C64XX_DEV_SPI2
1189static struct resource s3c64xx_spi2_resource[] = {1190static struct resource s3c64xx_spi2_resource[] = {
1190 [0] = DEFINE_RES_MEM(S3C_PA_SPI2, SZ_256),1191 [0] = DEFINE_RES_MEM(S3C_PA_SPI2, SZ_256),
1191 [1] = DEFINE_RES_DMA(DMACH_SPI2_TX),1192 [1] = DEFINE_RES_IRQ(IRQ_SPI2),
1192 [2] = DEFINE_RES_DMA(DMACH_SPI2_RX),
1193 [3] = DEFINE_RES_IRQ(IRQ_SPI2),
1194};1193};
1195 1194
1196struct platform_device s3c64xx_device_spi2 = {1195struct platform_device s3c64xx_device_spi2 = {
@@ -1218,6 +1217,8 @@ void __init s3c64xx_spi2_set_platdata(int (*cfg_gpio)(void), int src_clk_nr, · 21 unmodified lines
1218 pd.num_cs = num_cs;1217 pd.num_cs = num_cs;
1219 pd.src_clk_nr = src_clk_nr;1218 pd.src_clk_nr = src_clk_nr;
1220 pd.cfg_gpio = (cfg_gpio) ? cfg_gpio : s3c64xx_spi2_cfg_gpio;1219 pd.cfg_gpio = (cfg_gpio) ? cfg_gpio : s3c64xx_spi2_cfg_gpio;
1220 pd.dma_tx = (void *)DMACH_SPI2_TX;
1221 pd.dma_rx = (void *)DMACH_SPI2_RX;
1221#if defined(CONFIG_PL330_DMA)1222#if defined(CONFIG_PL330_DMA)
1222 pd.filter = pl330_filter;1223 pd.filter = pl330_filter;
1223#elif defined(CONFIG_S3C64XX_PL080)1224#elif defined(CONFIG_S3C64XX_PL080)
drivers/spi/spi-s3c64xx.c+7−20
@@ -133,7 +133,6 @@ · 132 unmodified lines
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) · 185 unmodified lines
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) · 2 unmodified lines
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( · 687 unmodified lines
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) · 52 unmodified lines
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) · 90 unmodified lines
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);
include/linux/platform_data/spi-s3c64xx.h+2−0
@@ -40,6 +40,8 @@ struct s3c64xx_spi_info { · 39 unmodified lines
40 int num_cs;40 int num_cs;
41 int (*cfg_gpio)(void);41 int (*cfg_gpio)(void);
42 dma_filter_fn filter;42 dma_filter_fn filter;
43 void *dma_tx;
44 void *dma_rx;
43};45};
44 46
45/**47/**

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t