aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMika Westerberg <mika.westerberg@linux.intel.com>2014-08-19 13:29:19 -0400
committerVinod Koul <vinod.koul@intel.com>2014-09-18 02:24:07 -0400
commitb729bf34535ed413667b397a2f59cfa81266facf (patch)
tree9e8020289c02e2894afabb6ef57fabaf20d77d56
parenta0a53a43ef51374c144a5f19f3f90c43aed76857 (diff)
spi/pxa2xx: Don't use slave_id of dma_slave_config
That field has been deprecated in favour of getting the necessary information from ACPI/DT. However, we still need to deal systems that are PCI only (no ACPI to back up). In order to support such systems, we allow the DMA filter function and its corresponding parameter via pxa2xx_spi_master platform data. Then when the pxa2xx_spi_dma_setup() doesn't find the channel via ACPI, it falls back to use the given filter function. Suggested-by: Arnd Bergmann <arnd@arndb.de> Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Acked-by: Mark Brown <broonie@linaro.org> Signed-off-by: Vinod Koul <vinod.koul@intel.com>
-rw-r--r--drivers/spi/spi-pxa2xx-dma.c15
-rw-r--r--drivers/spi/spi-pxa2xx-pci.c64
-rw-r--r--drivers/spi/spi-pxa2xx.c2
-rw-r--r--include/linux/spi/pxa2xx_spi.h9
4 files changed, 54 insertions, 36 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 20ebbc764693..0424b67c983e 100644
--- a/drivers/spi/spi-pxa2xx-pci.c
+++ b/drivers/spi/spi-pxa2xx-pci.c
@@ -10,6 +10,9 @@
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,33 +22,41 @@ struct pxa_spi_info {
19 enum pxa_ssp_type type; 22 enum pxa_ssp_type type;
20 int port_id; 23 int port_id;
21 int num_chipselect; 24 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; 25 unsigned long max_clk_rate;
26
27 /* DMA channel request parameters */
28 void *tx_param;
29 void *rx_param;
27}; 30};
28 31
32static struct dw_dma_slave byt_tx_param = { .dst_id = 0 };
33static struct dw_dma_slave byt_rx_param = { .src_id = 1 };
34
35static bool lpss_dma_filter(struct dma_chan *chan, void *param)
36{
37 struct dw_dma_slave *dws = param;
38
39 if (dws->dma_dev != chan->device->dev)
40 return false;
41
42 chan->private = dws;
43 return true;
44}
45
29static struct pxa_spi_info spi_info_configs[] = { 46static struct pxa_spi_info spi_info_configs[] = {
30 [PORT_CE4100] = { 47 [PORT_CE4100] = {
31 .type = PXA25x_SSP, 48 .type = PXA25x_SSP,
32 .port_id = -1, 49 .port_id = -1,
33 .num_chipselect = -1, 50 .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, 51 .max_clk_rate = 3686400,
39 }, 52 },
40 [PORT_BYT] = { 53 [PORT_BYT] = {
41 .type = LPSS_SSP, 54 .type = LPSS_SSP,
42 .port_id = 0, 55 .port_id = 0,
43 .num_chipselect = 1, 56 .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, 57 .max_clk_rate = 50000000,
58 .tx_param = &byt_tx_param,
59 .rx_param = &byt_rx_param,
49 }, 60 },
50}; 61};
51 62
@@ -59,6 +70,7 @@ static int pxa2xx_spi_pci_probe(struct pci_dev *dev,
59 struct ssp_device *ssp; 70 struct ssp_device *ssp;
60 struct pxa_spi_info *c; 71 struct pxa_spi_info *c;
61 char buf[40]; 72 char buf[40];
73 struct pci_dev *dma_dev;
62 74
63 ret = pcim_enable_device(dev); 75 ret = pcim_enable_device(dev);
64 if (ret) 76 if (ret)
@@ -73,11 +85,29 @@ static int pxa2xx_spi_pci_probe(struct pci_dev *dev,
73 memset(&spi_pdata, 0, sizeof(spi_pdata)); 85 memset(&spi_pdata, 0, sizeof(spi_pdata));
74 spi_pdata.num_chipselect = (c->num_chipselect > 0) ? 86 spi_pdata.num_chipselect = (c->num_chipselect > 0) ?
75 c->num_chipselect : dev->devfn; 87 c->num_chipselect : dev->devfn;
76 spi_pdata.tx_slave_id = c->tx_slave_id; 88
77 spi_pdata.tx_chan_id = c->tx_chan_id; 89 dma_dev = pci_get_slot(dev->bus, PCI_DEVFN(PCI_SLOT(dev->devfn), 0));
78 spi_pdata.rx_slave_id = c->rx_slave_id; 90
79 spi_pdata.rx_chan_id = c->rx_chan_id; 91 if (c->tx_param) {
80 spi_pdata.enable_dma = c->rx_slave_id >= 0 && c->tx_slave_id >= 0; 92 struct dw_dma_slave *slave = c->tx_param;
93
94 slave->dma_dev = &dma_dev->dev;
95 slave->src_master = 1;
96 slave->dst_master = 0;
97 }
98
99 if (c->rx_param) {
100 struct dw_dma_slave *slave = c->rx_param;
101
102 slave->dma_dev = &dma_dev->dev;
103 slave->src_master = 1;
104 slave->dst_master = 0;
105 }
106
107 spi_pdata.dma_filter = lpss_dma_filter;
108 spi_pdata.tx_param = c->tx_param;
109 spi_pdata.rx_param = c->rx_param;
110 spi_pdata.enable_dma = c->rx_param && c->tx_param;
81 111
82 ssp = &spi_pdata.ssp; 112 ssp = &spi_pdata.ssp;
83 ssp->phys_base = pci_resource_start(dev, 0); 113 ssp->phys_base = pci_resource_start(dev, 0);
diff --git a/drivers/spi/spi-pxa2xx.c b/drivers/spi/spi-pxa2xx.c
index fe792106bdc5..256c0abbddd2 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}
diff --git a/include/linux/spi/pxa2xx_spi.h b/include/linux/spi/pxa2xx_spi.h
index 82d5111cd0c2..d5a316550177 100644
--- a/include/linux/spi/pxa2xx_spi.h
+++ b/include/linux/spi/pxa2xx_spi.h
@@ -23,6 +23,8 @@
23#define PXA2XX_CS_ASSERT (0x01) 23#define PXA2XX_CS_ASSERT (0x01)
24#define PXA2XX_CS_DEASSERT (0x02) 24#define PXA2XX_CS_DEASSERT (0x02)
25 25
26struct dma_chan;
27
26/* device.platform_data for SSP controller devices */ 28/* device.platform_data for SSP controller devices */
27struct pxa2xx_spi_master { 29struct pxa2xx_spi_master {
28 u32 clock_enable; 30 u32 clock_enable;
@@ -30,10 +32,9 @@ struct pxa2xx_spi_master {
30 u8 enable_dma; 32 u8 enable_dma;
31 33
32 /* DMA engine specific config */ 34 /* DMA engine specific config */
33 int rx_chan_id; 35 bool (*dma_filter)(struct dma_chan *chan, void *param);
34 int tx_chan_id; 36 void *tx_param;
35 int rx_slave_id; 37 void *rx_param;
36 int tx_slave_id;
37 38
38 /* For non-PXA arches */ 39 /* For non-PXA arches */
39 struct ssp_device ssp; 40 struct ssp_device ssp;