hc
2024-02-20 102a0743326a03cd1a1202ceda21e175b7d3575c
kernel/drivers/spi/spi-pxa2xx-pci.c
....@@ -1,3 +1,4 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * CE4100's SPI device is more or less the same one as found on PXA
34 *
....@@ -5,7 +6,6 @@
56 */
67 #include <linux/clk-provider.h>
78 #include <linux/module.h>
8
-#include <linux/of_device.h>
99 #include <linux/pci.h>
1010 #include <linux/platform_device.h>
1111 #include <linux/spi/pxa2xx_spi.h>
....@@ -35,6 +35,8 @@
3535 bool (*dma_filter)(struct dma_chan *chan, void *param);
3636 void *tx_param;
3737 void *rx_param;
38
+
39
+ int dma_burst_size;
3840
3941 int (*setup)(struct pci_dev *pdev, struct pxa_spi_info *c);
4042 };
....@@ -72,14 +74,23 @@
7274 return true;
7375 }
7476
77
+static void lpss_dma_put_device(void *dma_dev)
78
+{
79
+ pci_dev_put(dma_dev);
80
+}
81
+
7582 static int lpss_spi_setup(struct pci_dev *dev, struct pxa_spi_info *c)
7683 {
7784 struct pci_dev *dma_dev;
85
+ int ret;
7886
7987 c->num_chipselect = 1;
8088 c->max_clk_rate = 50000000;
8189
8290 dma_dev = pci_get_slot(dev->bus, PCI_DEVFN(PCI_SLOT(dev->devfn), 0));
91
+ ret = devm_add_action_or_reset(&dev->dev, lpss_dma_put_device, dma_dev);
92
+ if (ret)
93
+ return ret;
8394
8495 if (c->tx_param) {
8596 struct dw_dma_slave *slave = c->tx_param;
....@@ -103,8 +114,9 @@
103114
104115 static int mrfld_spi_setup(struct pci_dev *dev, struct pxa_spi_info *c)
105116 {
106
- struct pci_dev *dma_dev = pci_get_slot(dev->bus, PCI_DEVFN(21, 0));
107117 struct dw_dma_slave *tx, *rx;
118
+ struct pci_dev *dma_dev;
119
+ int ret;
108120
109121 switch (PCI_FUNC(dev->devfn)) {
110122 case 0:
....@@ -129,6 +141,11 @@
129141 return -ENODEV;
130142 }
131143
144
+ dma_dev = pci_get_slot(dev->bus, PCI_DEVFN(21, 0));
145
+ ret = devm_add_action_or_reset(&dev->dev, lpss_dma_put_device, dma_dev);
146
+ if (ret)
147
+ return ret;
148
+
132149 tx = c->tx_param;
133150 tx->dma_dev = &dma_dev->dev;
134151
....@@ -136,6 +153,7 @@
136153 rx->dma_dev = &dma_dev->dev;
137154
138155 c->dma_filter = lpss_dma_filter;
156
+ c->dma_burst_size = 8;
139157 return 0;
140158 }
141159
....@@ -207,7 +225,7 @@
207225 struct platform_device_info pi;
208226 int ret;
209227 struct platform_device *pdev;
210
- struct pxa2xx_spi_master spi_pdata;
228
+ struct pxa2xx_spi_controller spi_pdata;
211229 struct ssp_device *ssp;
212230 struct pxa_spi_info *c;
213231 char buf[40];
....@@ -233,6 +251,7 @@
233251 spi_pdata.tx_param = c->tx_param;
234252 spi_pdata.rx_param = c->rx_param;
235253 spi_pdata.enable_dma = c->rx_param && c->tx_param;
254
+ spi_pdata.dma_burst_size = c->dma_burst_size ? c->dma_burst_size : 1;
236255
237256 ssp = &spi_pdata.ssp;
238257 ssp->phys_base = pci_resource_start(dev, 0);
....@@ -275,7 +294,7 @@
275294 static void pxa2xx_spi_pci_remove(struct pci_dev *dev)
276295 {
277296 struct platform_device *pdev = pci_get_drvdata(dev);
278
- struct pxa2xx_spi_master *spi_pdata;
297
+ struct pxa2xx_spi_controller *spi_pdata;
279298
280299 spi_pdata = dev_get_platdata(&pdev->dev);
281300