aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/spi
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2014-10-18 21:11:04 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2014-10-18 21:11:04 -0400
commit52d589a01d4545ce1dc5c3892bb8c7b55edfe714 (patch)
tree864858dae5d01aae411497e926679cf92392b4f6 /drivers/spi
parent0a582821d4f8edf41d9b56ae057ee2002fc275f0 (diff)
parent6b997bab20448cfe85456e4789d5d9222ab6b830 (diff)
Merge branch 'for-linus' of git://git.infradead.org/users/vkoul/slave-dma
Pull slave-dmaengine updates from Vinod Koul: "For dmaengine contributions we have: - designware cleanup by Andy - my series moving device_control users to dmanegine_xxx APIs for later removal of device_control API - minor fixes spread over drivers mainly mv_xor, pl330, mmp, imx-sdma etc" * 'for-linus' of git://git.infradead.org/users/vkoul/slave-dma: (60 commits) serial: atmel: add missing dmaengine header dmaengine: remove FSLDMA_EXTERNAL_START dmaengine: freescale: remove FSLDMA_EXTERNAL_START control method carma-fpga: move to fsl_dma_external_start() carma-fpga: use dmaengine_xxx() API dmaengine: freescale: add and export fsl_dma_external_start() dmaengine: add dmaengine_prep_dma_sg() helper video: mx3fb: use dmaengine_terminate_all() API serial: sh-sci: use dmaengine_terminate_all() API net: ks8842: use dmaengine_terminate_all() API mtd: sh_flctl: use dmaengine_terminate_all() API mtd: fsmc_nand: use dmaengine_terminate_all() API V4L2: mx3_camer: use dmaengine_pause() API dmaengine: coh901318: use dmaengine_terminate_all() API pata_arasan_cf: use dmaengine_terminate_all() API dmaengine: edma: check for echan->edesc => NULL in edma_dma_pause() dmaengine: dw: export probe()/remove() and Co to users dmaengine: dw: enable and disable controller when needed dmaengine: dw: always export dw_dma_{en,dis}able dmaengine: dw: introduce dw_dma_on() helper ...
Diffstat (limited to 'drivers/spi')
-rw-r--r--drivers/spi/spi-pxa2xx-dma.c15
-rw-r--r--drivers/spi/spi-pxa2xx-pci.c101
-rw-r--r--drivers/spi/spi-pxa2xx.c2
3 files changed, 86 insertions, 32 deletions
diff --git a/drivers/spi/spi-pxa2xx-dma.c b/drivers/spi/spi-pxa2xx-dma.c
index c41ff148a2b4..62a9297e96ac 100644
--- a/drivers/spi/spi-pxa2xx-dma.c
+++ b/drivers/spi/spi-pxa2xx-dma.c
@@ -157,7 +157,6 @@ static struct dma_async_tx_descriptor *
157pxa2xx_spi_dma_prepare_one(struct driver_data *drv_data, 157pxa2xx_spi_dma_prepare_one(struct driver_data *drv_data,
158 enum dma_transfer_direction dir) 158 enum dma_transfer_direction dir)
159{ 159{
160 struct pxa2xx_spi_master *pdata = drv_data->master_info;
161 struct chip_data *chip = drv_data->cur_chip; 160 struct chip_data *chip = drv_data->cur_chip;
162 enum dma_slave_buswidth width; 161 enum dma_slave_buswidth width;
163 struct dma_slave_config cfg; 162 struct dma_slave_config cfg;
@@ -184,7 +183,6 @@ pxa2xx_spi_dma_prepare_one(struct driver_data *drv_data,
184 cfg.dst_addr = drv_data->ssdr_physical; 183 cfg.dst_addr = drv_data->ssdr_physical;
185 cfg.dst_addr_width = width; 184 cfg.dst_addr_width = width;
186 cfg.dst_maxburst = chip->dma_burst_size; 185 cfg.dst_maxburst = chip->dma_burst_size;
187 cfg.slave_id = pdata->tx_slave_id;
188 186
189 sgt = &drv_data->tx_sgt; 187 sgt = &drv_data->tx_sgt;
190 nents = drv_data->tx_nents; 188 nents = drv_data->tx_nents;
@@ -193,7 +191,6 @@ pxa2xx_spi_dma_prepare_one(struct driver_data *drv_data,
193 cfg.src_addr = drv_data->ssdr_physical; 191 cfg.src_addr = drv_data->ssdr_physical;
194 cfg.src_addr_width = width; 192 cfg.src_addr_width = width;
195 cfg.src_maxburst = chip->dma_burst_size; 193 cfg.src_maxburst = chip->dma_burst_size;
196 cfg.slave_id = pdata->rx_slave_id;
197 194
198 sgt = &drv_data->rx_sgt; 195 sgt = &drv_data->rx_sgt;
199 nents = drv_data->rx_nents; 196 nents = drv_data->rx_nents;
@@ -210,14 +207,6 @@ pxa2xx_spi_dma_prepare_one(struct driver_data *drv_data,
210 DMA_PREP_INTERRUPT | DMA_CTRL_ACK); 207 DMA_PREP_INTERRUPT | DMA_CTRL_ACK);
211} 208}
212 209
213static bool pxa2xx_spi_dma_filter(struct dma_chan *chan, void *param)
214{
215 const struct pxa2xx_spi_master *pdata = param;
216
217 return chan->chan_id == pdata->tx_chan_id ||
218 chan->chan_id == pdata->rx_chan_id;
219}
220
221bool pxa2xx_spi_dma_is_possible(size_t len) 210bool pxa2xx_spi_dma_is_possible(size_t len)
222{ 211{
223 return len <= MAX_DMA_LEN; 212 return len <= MAX_DMA_LEN;
@@ -321,12 +310,12 @@ int pxa2xx_spi_dma_setup(struct driver_data *drv_data)
321 return -ENOMEM; 310 return -ENOMEM;
322 311
323 drv_data->tx_chan = dma_request_slave_channel_compat(mask, 312 drv_data->tx_chan = dma_request_slave_channel_compat(mask,
324 pxa2xx_spi_dma_filter, pdata, dev, "tx"); 313 pdata->dma_filter, pdata->tx_param, dev, "tx");
325 if (!drv_data->tx_chan) 314 if (!drv_data->tx_chan)
326 return -ENODEV; 315 return -ENODEV;
327 316
328 drv_data->rx_chan = dma_request_slave_channel_compat(mask, 317 drv_data->rx_chan = dma_request_slave_channel_compat(mask,
329 pxa2xx_spi_dma_filter, pdata, dev, "rx"); 318 pdata->dma_filter, pdata->rx_param, dev, "rx");
330 if (!drv_data->rx_chan) { 319 if (!drv_data->rx_chan) {
331 dma_release_channel(drv_data->tx_chan); 320 dma_release_channel(drv_data->tx_chan);
332 drv_data->tx_chan = NULL; 321 drv_data->tx_chan = NULL;
diff --git a/drivers/spi/spi-pxa2xx-pci.c b/drivers/spi/spi-pxa2xx-pci.c
index 536c863bebf1..6beee8ce2d68 100644
--- a/drivers/spi/spi-pxa2xx-pci.c
+++ b/drivers/spi/spi-pxa2xx-pci.c
@@ -10,42 +10,87 @@
10#include <linux/clk.h> 10#include <linux/clk.h>
11#include <linux/clk-provider.h> 11#include <linux/clk-provider.h>
12 12
13#include <linux/dmaengine.h>
14#include <linux/platform_data/dma-dw.h>
15
13enum { 16enum {
14 PORT_CE4100, 17 PORT_CE4100,
15 PORT_BYT, 18 PORT_BYT,
19 PORT_BSW0,
20 PORT_BSW1,
21 PORT_BSW2,
16}; 22};
17 23
18struct pxa_spi_info { 24struct pxa_spi_info {
19 enum pxa_ssp_type type; 25 enum pxa_ssp_type type;
20 int port_id; 26 int port_id;
21 int num_chipselect; 27 int num_chipselect;
22 int tx_slave_id;
23 int tx_chan_id;
24 int rx_slave_id;
25 int rx_chan_id;
26 unsigned long max_clk_rate; 28 unsigned long max_clk_rate;
29
30 /* DMA channel request parameters */
31 void *tx_param;
32 void *rx_param;
27}; 33};
28 34
35static struct dw_dma_slave byt_tx_param = { .dst_id = 0 };
36static struct dw_dma_slave byt_rx_param = { .src_id = 1 };
37
38static struct dw_dma_slave bsw0_tx_param = { .dst_id = 0 };
39static struct dw_dma_slave bsw0_rx_param = { .src_id = 1 };
40static struct dw_dma_slave bsw1_tx_param = { .dst_id = 6 };
41static struct dw_dma_slave bsw1_rx_param = { .src_id = 7 };
42static struct dw_dma_slave bsw2_tx_param = { .dst_id = 8 };
43static struct dw_dma_slave bsw2_rx_param = { .src_id = 9 };
44
45static bool lpss_dma_filter(struct dma_chan *chan, void *param)
46{
47 struct dw_dma_slave *dws = param;
48
49 if (dws->dma_dev != chan->device->dev)
50 return false;
51
52 chan->private = dws;
53 return true;
54}
55
29static struct pxa_spi_info spi_info_configs[] = { 56static struct pxa_spi_info spi_info_configs[] = {
30 [PORT_CE4100] = { 57 [PORT_CE4100] = {
31 .type = PXA25x_SSP, 58 .type = PXA25x_SSP,
32 .port_id = -1, 59 .port_id = -1,
33 .num_chipselect = -1, 60 .num_chipselect = -1,
34 .tx_slave_id = -1,
35 .tx_chan_id = -1,
36 .rx_slave_id = -1,
37 .rx_chan_id = -1,
38 .max_clk_rate = 3686400, 61 .max_clk_rate = 3686400,
39 }, 62 },
40 [PORT_BYT] = { 63 [PORT_BYT] = {
41 .type = LPSS_SSP, 64 .type = LPSS_SSP,
42 .port_id = 0, 65 .port_id = 0,
43 .num_chipselect = 1, 66 .num_chipselect = 1,
44 .tx_slave_id = 0,
45 .tx_chan_id = 0,
46 .rx_slave_id = 1,
47 .rx_chan_id = 1,
48 .max_clk_rate = 50000000, 67 .max_clk_rate = 50000000,
68 .tx_param = &byt_tx_param,
69 .rx_param = &byt_rx_param,
70 },
71 [PORT_BSW0] = {
72 .type = LPSS_SSP,
73 .port_id = 0,
74 .num_chipselect = 1,
75 .max_clk_rate = 50000000,
76 .tx_param = &bsw0_tx_param,
77 .rx_param = &bsw0_rx_param,
78 },
79 [PORT_BSW1] = {
80 .type = LPSS_SSP,
81 .port_id = 1,
82 .num_chipselect = 1,
83 .max_clk_rate = 50000000,
84 .tx_param = &bsw1_tx_param,
85 .rx_param = &bsw1_rx_param,
86 },
87 [PORT_BSW2] = {
88 .type = LPSS_SSP,
89 .port_id = 2,
90 .num_chipselect = 1,
91 .max_clk_rate = 50000000,
92 .tx_param = &bsw2_tx_param,
93 .rx_param = &bsw2_rx_param,
49 }, 94 },
50}; 95};
51 96
@@ -59,6 +104,7 @@ static int pxa2xx_spi_pci_probe(struct pci_dev *dev,
59 struct ssp_device *ssp; 104 struct ssp_device *ssp;
60 struct pxa_spi_info *c; 105 struct pxa_spi_info *c;
61 char buf[40]; 106 char buf[40];
107 struct pci_dev *dma_dev;
62 108
63 ret = pcim_enable_device(dev); 109 ret = pcim_enable_device(dev);
64 if (ret) 110 if (ret)
@@ -73,11 +119,29 @@ static int pxa2xx_spi_pci_probe(struct pci_dev *dev,
73 memset(&spi_pdata, 0, sizeof(spi_pdata)); 119 memset(&spi_pdata, 0, sizeof(spi_pdata));
74 spi_pdata.num_chipselect = (c->num_chipselect > 0) ? 120 spi_pdata.num_chipselect = (c->num_chipselect > 0) ?
75 c->num_chipselect : dev->devfn; 121 c->num_chipselect : dev->devfn;
76 spi_pdata.tx_slave_id = c->tx_slave_id; 122
77 spi_pdata.tx_chan_id = c->tx_chan_id; 123 dma_dev = pci_get_slot(dev->bus, PCI_DEVFN(PCI_SLOT(dev->devfn), 0));
78 spi_pdata.rx_slave_id = c->rx_slave_id; 124
79 spi_pdata.rx_chan_id = c->rx_chan_id; 125 if (c->tx_param) {
80 spi_pdata.enable_dma = c->rx_slave_id >= 0 && c->tx_slave_id >= 0; 126 struct dw_dma_slave *slave = c->tx_param;
127
128 slave->dma_dev = &dma_dev->dev;
129 slave->src_master = 1;
130 slave->dst_master = 0;
131 }
132
133 if (c->rx_param) {
134 struct dw_dma_slave *slave = c->rx_param;
135
136 slave->dma_dev = &dma_dev->dev;
137 slave->src_master = 1;
138 slave->dst_master = 0;
139 }
140
141 spi_pdata.dma_filter = lpss_dma_filter;
142 spi_pdata.tx_param = c->tx_param;
143 spi_pdata.rx_param = c->rx_param;
144 spi_pdata.enable_dma = c->rx_param && c->tx_param;
81 145
82 ssp = &spi_pdata.ssp; 146 ssp = &spi_pdata.ssp;
83 ssp->phys_base = pci_resource_start(dev, 0); 147 ssp->phys_base = pci_resource_start(dev, 0);
@@ -128,6 +192,9 @@ static void pxa2xx_spi_pci_remove(struct pci_dev *dev)
128static const struct pci_device_id pxa2xx_spi_pci_devices[] = { 192static const struct pci_device_id pxa2xx_spi_pci_devices[] = {
129 { PCI_VDEVICE(INTEL, 0x2e6a), PORT_CE4100 }, 193 { PCI_VDEVICE(INTEL, 0x2e6a), PORT_CE4100 },
130 { PCI_VDEVICE(INTEL, 0x0f0e), PORT_BYT }, 194 { PCI_VDEVICE(INTEL, 0x0f0e), PORT_BYT },
195 { PCI_VDEVICE(INTEL, 0x228e), PORT_BSW0 },
196 { PCI_VDEVICE(INTEL, 0x2290), PORT_BSW1 },
197 { PCI_VDEVICE(INTEL, 0x22ac), PORT_BSW2 },
131 { }, 198 { },
132}; 199};
133MODULE_DEVICE_TABLE(pci, pxa2xx_spi_pci_devices); 200MODULE_DEVICE_TABLE(pci, pxa2xx_spi_pci_devices);
diff --git a/drivers/spi/spi-pxa2xx.c b/drivers/spi/spi-pxa2xx.c
index 46f45ca2c694..d8a105f76837 100644
--- a/drivers/spi/spi-pxa2xx.c
+++ b/drivers/spi/spi-pxa2xx.c
@@ -1062,8 +1062,6 @@ pxa2xx_spi_acpi_get_pdata(struct platform_device *pdev)
1062 1062
1063 pdata->num_chipselect = 1; 1063 pdata->num_chipselect = 1;
1064 pdata->enable_dma = true; 1064 pdata->enable_dma = true;
1065 pdata->tx_chan_id = -1;
1066 pdata->rx_chan_id = -1;
1067 1065
1068 return pdata; 1066 return pdata;
1069} 1067}