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
11001100 #ifdef CONFIG_S3C64XX_DEV_SPI0
11011101 static struct resource s3c64xx_spi0_resource[] = {
11021102 [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),
11061104 };
11071105
11081106 struct 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
11301128 pd.num_cs = num_cs;
11311129 pd.src_clk_nr = src_clk_nr;
11321130 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;
11331133 #if defined(CONFIG_PL330_DMA)
11341134 pd.filter = pl330_filter;
11351135 #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
11451145 #ifdef CONFIG_S3C64XX_DEV_SPI1
11461146 static struct resource s3c64xx_spi1_resource[] = {
11471147 [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),
11511149 };
11521150
11531151 struct 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
11751173 pd.num_cs = num_cs;
11761174 pd.src_clk_nr = src_clk_nr;
11771175 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;
11781178 #if defined(CONFIG_PL330_DMA)
11791179 pd.filter = pl330_filter;
11801180 #elif defined(CONFIG_S3C64XX_PL080)
11811181 pd.filter = pl08x_filter_id;
11821182 #endif
11831183
1184+
11841185 s3c_set_platdata(&pd, sizeof(pd), &s3c64xx_device_spi1);
11851186 }
11861187 #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
11881189 #ifdef CONFIG_S3C64XX_DEV_SPI2
11891190 static struct resource s3c64xx_spi2_resource[] = {
11901191 [0] = DEFINE_RES_MEM(S3C_PA_SPI2, SZ_256),
1191− [1] = DEFINE_RES_DMA(DMACH_SPI2_TX),
1192− [2] = DEFINE_RES_DMA(DMACH_SPI2_RX),
1193− [3] = DEFINE_RES_IRQ(IRQ_SPI2),
1192+ [1] = DEFINE_RES_IRQ(IRQ_SPI2),
11941193 };
11951194
11961195 struct 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
12181217 pd.num_cs = num_cs;
12191218 pd.src_clk_nr = src_clk_nr;
12201219 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;
12211222 #if defined(CONFIG_PL330_DMA)
12221223 pd.filter = pl330_filter;
12231224 #elif defined(CONFIG_S3C64XX_PL080)
drivers/spi/spi-s3c64xx.c+7−20
@@ -133,7 +133,6 @@ · 132 unmodified lines
133133 struct s3c64xx_spi_dma_data {
134134 struct dma_chan *ch;
135135 enum dma_transfer_direction direction;
136− unsigned int dmach;
137136 };
138137
139138 /**
@@ -325,7 +324,7 @@ static int s3c64xx_spi_prepare_transfer(struct spi_master *spi) · 185 unmodified lines
325324
326325 /* Acquire DMA channels */
327326 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");
329328 if (!sdd->rx_dma.ch) {
330329 dev_err(dev, "Failed to get RX DMA channel\n");
331330 ret = -EBUSY;
@@ -334,7 +333,7 @@ static int s3c64xx_spi_prepare_transfer(struct spi_master *spi) · 2 unmodified lines
334333 spi->dma_rx = sdd->rx_dma.ch;
335334
336335 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");
338337 if (!sdd->tx_dma.ch) {
339338 dev_err(dev, "Failed to get TX DMA channel\n");
340339 ret = -EBUSY;
@@ -1028,7 +1027,6 @@ static inline struct s3c64xx_spi_port_config *s3c64xx_spi_get_port_config( · 687 unmodified lines
10281027 static int s3c64xx_spi_probe(struct platform_device *pdev)
10291028 {
10301029 struct resource *mem_res;
1031− struct resource *res;
10321030 struct s3c64xx_spi_driver_data *sdd;
10331031 struct s3c64xx_spi_info *sci = dev_get_platdata(&pdev->dev);
10341032 struct spi_master *master;
@@ -1087,20 +1085,9 @@ static int s3c64xx_spi_probe(struct platform_device *pdev) · 52 unmodified lines
10871085
10881086 sdd->cur_bpw = 8;
10891087
1090− if (!sdd->pdev->dev.of_node) {
1091− res = platform_get_resource(pdev, IORESOURCE_DMA, 0);
1092− if (!res) {
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;
1088+ if (!sdd->pdev->dev.of_node && (!sci->dma_tx || !sci->dma_rx)) {
1089+ dev_warn(&pdev->dev, "Unable to get SPI tx/rx DMA data. Switching to poll mode\n");
1090+ sdd->port_conf->quirks = S3C64XX_SPI_QUIRK_POLL;
11041091 }
11051092
11061093 sdd->tx_dma.direction = DMA_MEM_TO_DEV;
@@ -1197,9 +1184,9 @@ static int s3c64xx_spi_probe(struct platform_device *pdev) · 90 unmodified lines
11971184
11981185 dev_dbg(&pdev->dev, "Samsung SoC SPI Driver loaded for Bus SPI-%d with %d Slaves attached\n",
11991186 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",
12011188 mem_res, (FIFO_LVL_MASK(sdd) >> 1) + 1,
1202− sdd->rx_dma.dmach, sdd->tx_dma.dmach);
1189+ sci->dma_rx, sci->dma_tx);
12031190
12041191 pm_runtime_mark_last_busy(&pdev->dev);
12051192 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
4040 int num_cs;
4141 int (*cfg_gpio)(void);
4242 dma_filter_fn filter;
43+ void *dma_tx;
44+ void *dma_rx;
4345 };
4446
4547 /**

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