| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * CE4100's SPI device is more or less the same one as found on PXA |
|---|
| 3 | 4 | * |
|---|
| .. | .. |
|---|
| 5 | 6 | */ |
|---|
| 6 | 7 | #include <linux/clk-provider.h> |
|---|
| 7 | 8 | #include <linux/module.h> |
|---|
| 8 | | -#include <linux/of_device.h> |
|---|
| 9 | 9 | #include <linux/pci.h> |
|---|
| 10 | 10 | #include <linux/platform_device.h> |
|---|
| 11 | 11 | #include <linux/spi/pxa2xx_spi.h> |
|---|
| .. | .. |
|---|
| 35 | 35 | bool (*dma_filter)(struct dma_chan *chan, void *param); |
|---|
| 36 | 36 | void *tx_param; |
|---|
| 37 | 37 | void *rx_param; |
|---|
| 38 | + |
|---|
| 39 | + int dma_burst_size; |
|---|
| 38 | 40 | |
|---|
| 39 | 41 | int (*setup)(struct pci_dev *pdev, struct pxa_spi_info *c); |
|---|
| 40 | 42 | }; |
|---|
| .. | .. |
|---|
| 72 | 74 | return true; |
|---|
| 73 | 75 | } |
|---|
| 74 | 76 | |
|---|
| 77 | +static void lpss_dma_put_device(void *dma_dev) |
|---|
| 78 | +{ |
|---|
| 79 | + pci_dev_put(dma_dev); |
|---|
| 80 | +} |
|---|
| 81 | + |
|---|
| 75 | 82 | static int lpss_spi_setup(struct pci_dev *dev, struct pxa_spi_info *c) |
|---|
| 76 | 83 | { |
|---|
| 77 | 84 | struct pci_dev *dma_dev; |
|---|
| 85 | + int ret; |
|---|
| 78 | 86 | |
|---|
| 79 | 87 | c->num_chipselect = 1; |
|---|
| 80 | 88 | c->max_clk_rate = 50000000; |
|---|
| 81 | 89 | |
|---|
| 82 | 90 | 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; |
|---|
| 83 | 94 | |
|---|
| 84 | 95 | if (c->tx_param) { |
|---|
| 85 | 96 | struct dw_dma_slave *slave = c->tx_param; |
|---|
| .. | .. |
|---|
| 103 | 114 | |
|---|
| 104 | 115 | static int mrfld_spi_setup(struct pci_dev *dev, struct pxa_spi_info *c) |
|---|
| 105 | 116 | { |
|---|
| 106 | | - struct pci_dev *dma_dev = pci_get_slot(dev->bus, PCI_DEVFN(21, 0)); |
|---|
| 107 | 117 | struct dw_dma_slave *tx, *rx; |
|---|
| 118 | + struct pci_dev *dma_dev; |
|---|
| 119 | + int ret; |
|---|
| 108 | 120 | |
|---|
| 109 | 121 | switch (PCI_FUNC(dev->devfn)) { |
|---|
| 110 | 122 | case 0: |
|---|
| .. | .. |
|---|
| 129 | 141 | return -ENODEV; |
|---|
| 130 | 142 | } |
|---|
| 131 | 143 | |
|---|
| 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 | + |
|---|
| 132 | 149 | tx = c->tx_param; |
|---|
| 133 | 150 | tx->dma_dev = &dma_dev->dev; |
|---|
| 134 | 151 | |
|---|
| .. | .. |
|---|
| 136 | 153 | rx->dma_dev = &dma_dev->dev; |
|---|
| 137 | 154 | |
|---|
| 138 | 155 | c->dma_filter = lpss_dma_filter; |
|---|
| 156 | + c->dma_burst_size = 8; |
|---|
| 139 | 157 | return 0; |
|---|
| 140 | 158 | } |
|---|
| 141 | 159 | |
|---|
| .. | .. |
|---|
| 207 | 225 | struct platform_device_info pi; |
|---|
| 208 | 226 | int ret; |
|---|
| 209 | 227 | struct platform_device *pdev; |
|---|
| 210 | | - struct pxa2xx_spi_master spi_pdata; |
|---|
| 228 | + struct pxa2xx_spi_controller spi_pdata; |
|---|
| 211 | 229 | struct ssp_device *ssp; |
|---|
| 212 | 230 | struct pxa_spi_info *c; |
|---|
| 213 | 231 | char buf[40]; |
|---|
| .. | .. |
|---|
| 233 | 251 | spi_pdata.tx_param = c->tx_param; |
|---|
| 234 | 252 | spi_pdata.rx_param = c->rx_param; |
|---|
| 235 | 253 | 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; |
|---|
| 236 | 255 | |
|---|
| 237 | 256 | ssp = &spi_pdata.ssp; |
|---|
| 238 | 257 | ssp->phys_base = pci_resource_start(dev, 0); |
|---|
| .. | .. |
|---|
| 275 | 294 | static void pxa2xx_spi_pci_remove(struct pci_dev *dev) |
|---|
| 276 | 295 | { |
|---|
| 277 | 296 | struct platform_device *pdev = pci_get_drvdata(dev); |
|---|
| 278 | | - struct pxa2xx_spi_master *spi_pdata; |
|---|
| 297 | + struct pxa2xx_spi_controller *spi_pdata; |
|---|
| 279 | 298 | |
|---|
| 280 | 299 | spi_pdata = dev_get_platdata(&pdev->dev); |
|---|
| 281 | 300 | |
|---|