Thomas Gleixner | 2025cf9 | 2019-05-29 07:18:02 -0700 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0-only |
Feng Tang | 7063c0d | 2010-12-24 13:59:11 +0800 | [diff] [blame] | 2 | /* |
Serge Semin | 6c710c0 | 2020-05-29 16:11:59 +0300 | [diff] [blame] | 3 | * Special handling for DW DMA core |
Feng Tang | 7063c0d | 2010-12-24 13:59:11 +0800 | [diff] [blame] | 4 | * |
Andy Shevchenko | 197e96b | 2014-09-12 15:12:01 +0300 | [diff] [blame] | 5 | * Copyright (c) 2009, 2014 Intel Corporation. |
Feng Tang | 7063c0d | 2010-12-24 13:59:11 +0800 | [diff] [blame] | 6 | */ |
| 7 | |
Serge Semin | bdbdf0f | 2020-05-29 16:11:52 +0300 | [diff] [blame] | 8 | #include <linux/completion.h> |
Andy Shevchenko | e794095 | 2020-05-06 18:30:22 +0300 | [diff] [blame] | 9 | #include <linux/dma-mapping.h> |
| 10 | #include <linux/dmaengine.h> |
Andy Shevchenko | e62a15d | 2020-05-06 18:30:21 +0300 | [diff] [blame] | 11 | #include <linux/irqreturn.h> |
Serge Semin | bdbdf0f | 2020-05-29 16:11:52 +0300 | [diff] [blame] | 12 | #include <linux/jiffies.h> |
Feng Tang | 7063c0d | 2010-12-24 13:59:11 +0800 | [diff] [blame] | 13 | #include <linux/pci.h> |
Andy Shevchenko | d744f82 | 2015-03-09 16:48:50 +0200 | [diff] [blame] | 14 | #include <linux/platform_data/dma-dw.h> |
Serge Semin | 6c710c0 | 2020-05-29 16:11:59 +0300 | [diff] [blame] | 15 | #include <linux/spi/spi.h> |
| 16 | #include <linux/types.h> |
| 17 | |
| 18 | #include "spi-dw.h" |
Feng Tang | 7063c0d | 2010-12-24 13:59:11 +0800 | [diff] [blame] | 19 | |
Serge Semin | 1ade2d8 | 2020-05-29 16:11:53 +0300 | [diff] [blame] | 20 | #define WAIT_RETRIES 5 |
Andy Shevchenko | 30c8eb5 | 2014-10-28 18:25:02 +0200 | [diff] [blame] | 21 | #define RX_BUSY 0 |
Serge Semin | c534df9 | 2020-05-29 16:11:55 +0300 | [diff] [blame] | 22 | #define RX_BURST_LEVEL 16 |
Andy Shevchenko | 30c8eb5 | 2014-10-28 18:25:02 +0200 | [diff] [blame] | 23 | #define TX_BUSY 1 |
Serge Semin | c534df9 | 2020-05-29 16:11:55 +0300 | [diff] [blame] | 24 | #define TX_BURST_LEVEL 16 |
Andy Shevchenko | 30c8eb5 | 2014-10-28 18:25:02 +0200 | [diff] [blame] | 25 | |
Serge Semin | 5778441 | 2020-05-29 16:12:02 +0300 | [diff] [blame] | 26 | static bool dw_spi_dma_chan_filter(struct dma_chan *chan, void *param) |
Feng Tang | 7063c0d | 2010-12-24 13:59:11 +0800 | [diff] [blame] | 27 | { |
Andy Shevchenko | d744f82 | 2015-03-09 16:48:50 +0200 | [diff] [blame] | 28 | struct dw_dma_slave *s = param; |
Feng Tang | 7063c0d | 2010-12-24 13:59:11 +0800 | [diff] [blame] | 29 | |
Andy Shevchenko | d744f82 | 2015-03-09 16:48:50 +0200 | [diff] [blame] | 30 | if (s->dma_dev != chan->device->dev) |
| 31 | return false; |
| 32 | |
| 33 | chan->private = s; |
| 34 | return true; |
Feng Tang | 7063c0d | 2010-12-24 13:59:11 +0800 | [diff] [blame] | 35 | } |
| 36 | |
Serge Semin | 5778441 | 2020-05-29 16:12:02 +0300 | [diff] [blame] | 37 | static void dw_spi_dma_maxburst_init(struct dw_spi *dws) |
Serge Semin | 0b2b665 | 2020-05-29 16:11:56 +0300 | [diff] [blame] | 38 | { |
| 39 | struct dma_slave_caps caps; |
| 40 | u32 max_burst, def_burst; |
| 41 | int ret; |
| 42 | |
| 43 | def_burst = dws->fifo_len / 2; |
| 44 | |
| 45 | ret = dma_get_slave_caps(dws->rxchan, &caps); |
| 46 | if (!ret && caps.max_burst) |
| 47 | max_burst = caps.max_burst; |
| 48 | else |
| 49 | max_burst = RX_BURST_LEVEL; |
| 50 | |
| 51 | dws->rxburst = min(max_burst, def_burst); |
Serge Semin | 01ddbbb | 2020-09-20 14:23:12 +0300 | [diff] [blame] | 52 | dw_writel(dws, DW_SPI_DMARDLR, dws->rxburst - 1); |
Serge Semin | 0b2b665 | 2020-05-29 16:11:56 +0300 | [diff] [blame] | 53 | |
| 54 | ret = dma_get_slave_caps(dws->txchan, &caps); |
| 55 | if (!ret && caps.max_burst) |
| 56 | max_burst = caps.max_burst; |
| 57 | else |
| 58 | max_burst = TX_BURST_LEVEL; |
| 59 | |
Serge Semin | 01ddbbb | 2020-09-20 14:23:12 +0300 | [diff] [blame] | 60 | /* |
| 61 | * Having a Rx DMA channel serviced with higher priority than a Tx DMA |
| 62 | * channel might not be enough to provide a well balanced DMA-based |
| 63 | * SPI transfer interface. There might still be moments when the Tx DMA |
| 64 | * channel is occasionally handled faster than the Rx DMA channel. |
| 65 | * That in its turn will eventually cause the SPI Rx FIFO overflow if |
| 66 | * SPI bus speed is high enough to fill the SPI Rx FIFO in before it's |
| 67 | * cleared by the Rx DMA channel. In order to fix the problem the Tx |
| 68 | * DMA activity is intentionally slowed down by limiting the SPI Tx |
| 69 | * FIFO depth with a value twice bigger than the Tx burst length. |
| 70 | */ |
Serge Semin | 0b2b665 | 2020-05-29 16:11:56 +0300 | [diff] [blame] | 71 | dws->txburst = min(max_burst, def_burst); |
Serge Semin | 01ddbbb | 2020-09-20 14:23:12 +0300 | [diff] [blame] | 72 | dw_writel(dws, DW_SPI_DMATDLR, dws->txburst); |
Serge Semin | 0b2b665 | 2020-05-29 16:11:56 +0300 | [diff] [blame] | 73 | } |
| 74 | |
Serge Semin | 5778441 | 2020-05-29 16:12:02 +0300 | [diff] [blame] | 75 | static int dw_spi_dma_init_mfld(struct device *dev, struct dw_spi *dws) |
Feng Tang | 7063c0d | 2010-12-24 13:59:11 +0800 | [diff] [blame] | 76 | { |
Andy Shevchenko | b3f82dc | 2020-05-29 21:31:49 +0300 | [diff] [blame] | 77 | struct dw_dma_slave dma_tx = { .dst_id = 1 }, *tx = &dma_tx; |
| 78 | struct dw_dma_slave dma_rx = { .src_id = 0 }, *rx = &dma_rx; |
Andy Shevchenko | b89e9c8 | 2014-09-12 15:12:00 +0300 | [diff] [blame] | 79 | struct pci_dev *dma_dev; |
Feng Tang | 7063c0d | 2010-12-24 13:59:11 +0800 | [diff] [blame] | 80 | dma_cap_mask_t mask; |
| 81 | |
| 82 | /* |
| 83 | * Get pci device for DMA controller, currently it could only |
Andy Shevchenko | ea09245 | 2014-09-12 15:11:59 +0300 | [diff] [blame] | 84 | * be the DMA controller of Medfield |
Feng Tang | 7063c0d | 2010-12-24 13:59:11 +0800 | [diff] [blame] | 85 | */ |
Andy Shevchenko | b89e9c8 | 2014-09-12 15:12:00 +0300 | [diff] [blame] | 86 | dma_dev = pci_get_device(PCI_VENDOR_ID_INTEL, 0x0827, NULL); |
| 87 | if (!dma_dev) |
| 88 | return -ENODEV; |
| 89 | |
Feng Tang | 7063c0d | 2010-12-24 13:59:11 +0800 | [diff] [blame] | 90 | dma_cap_zero(mask); |
| 91 | dma_cap_set(DMA_SLAVE, mask); |
| 92 | |
| 93 | /* 1. Init rx channel */ |
Andy Shevchenko | b3f82dc | 2020-05-29 21:31:49 +0300 | [diff] [blame] | 94 | rx->dma_dev = &dma_dev->dev; |
| 95 | dws->rxchan = dma_request_channel(mask, dw_spi_dma_chan_filter, rx); |
Feng Tang | 7063c0d | 2010-12-24 13:59:11 +0800 | [diff] [blame] | 96 | if (!dws->rxchan) |
| 97 | goto err_exit; |
Feng Tang | 7063c0d | 2010-12-24 13:59:11 +0800 | [diff] [blame] | 98 | |
| 99 | /* 2. Init tx channel */ |
Andy Shevchenko | b3f82dc | 2020-05-29 21:31:49 +0300 | [diff] [blame] | 100 | tx->dma_dev = &dma_dev->dev; |
| 101 | dws->txchan = dma_request_channel(mask, dw_spi_dma_chan_filter, tx); |
Feng Tang | 7063c0d | 2010-12-24 13:59:11 +0800 | [diff] [blame] | 102 | if (!dws->txchan) |
| 103 | goto free_rxchan; |
Andy Shevchenko | a041e67 | 2020-05-07 14:54:49 +0300 | [diff] [blame] | 104 | |
| 105 | dws->master->dma_rx = dws->rxchan; |
Andy Shevchenko | f89a6d8 | 2015-03-09 16:48:49 +0200 | [diff] [blame] | 106 | dws->master->dma_tx = dws->txchan; |
Feng Tang | 7063c0d | 2010-12-24 13:59:11 +0800 | [diff] [blame] | 107 | |
Serge Semin | bdbdf0f | 2020-05-29 16:11:52 +0300 | [diff] [blame] | 108 | init_completion(&dws->dma_completion); |
| 109 | |
Serge Semin | 5778441 | 2020-05-29 16:12:02 +0300 | [diff] [blame] | 110 | dw_spi_dma_maxburst_init(dws); |
Serge Semin | 0b2b665 | 2020-05-29 16:11:56 +0300 | [diff] [blame] | 111 | |
Feng Tang | 7063c0d | 2010-12-24 13:59:11 +0800 | [diff] [blame] | 112 | return 0; |
| 113 | |
| 114 | free_rxchan: |
| 115 | dma_release_channel(dws->rxchan); |
Andy Shevchenko | a041e67 | 2020-05-07 14:54:49 +0300 | [diff] [blame] | 116 | dws->rxchan = NULL; |
Feng Tang | 7063c0d | 2010-12-24 13:59:11 +0800 | [diff] [blame] | 117 | err_exit: |
Andy Shevchenko | b89e9c8 | 2014-09-12 15:12:00 +0300 | [diff] [blame] | 118 | return -EBUSY; |
Feng Tang | 7063c0d | 2010-12-24 13:59:11 +0800 | [diff] [blame] | 119 | } |
| 120 | |
Serge Semin | 5778441 | 2020-05-29 16:12:02 +0300 | [diff] [blame] | 121 | static int dw_spi_dma_init_generic(struct device *dev, struct dw_spi *dws) |
Jarkko Nikula | 22d48ad | 2020-05-06 18:30:25 +0300 | [diff] [blame] | 122 | { |
| 123 | dws->rxchan = dma_request_slave_channel(dev, "rx"); |
| 124 | if (!dws->rxchan) |
| 125 | return -ENODEV; |
Jarkko Nikula | 22d48ad | 2020-05-06 18:30:25 +0300 | [diff] [blame] | 126 | |
| 127 | dws->txchan = dma_request_slave_channel(dev, "tx"); |
| 128 | if (!dws->txchan) { |
| 129 | dma_release_channel(dws->rxchan); |
Andy Shevchenko | a041e67 | 2020-05-07 14:54:49 +0300 | [diff] [blame] | 130 | dws->rxchan = NULL; |
Jarkko Nikula | 22d48ad | 2020-05-06 18:30:25 +0300 | [diff] [blame] | 131 | return -ENODEV; |
| 132 | } |
Andy Shevchenko | a041e67 | 2020-05-07 14:54:49 +0300 | [diff] [blame] | 133 | |
| 134 | dws->master->dma_rx = dws->rxchan; |
Jarkko Nikula | 22d48ad | 2020-05-06 18:30:25 +0300 | [diff] [blame] | 135 | dws->master->dma_tx = dws->txchan; |
| 136 | |
Serge Semin | bdbdf0f | 2020-05-29 16:11:52 +0300 | [diff] [blame] | 137 | init_completion(&dws->dma_completion); |
| 138 | |
Serge Semin | 5778441 | 2020-05-29 16:12:02 +0300 | [diff] [blame] | 139 | dw_spi_dma_maxburst_init(dws); |
Serge Semin | 0b2b665 | 2020-05-29 16:11:56 +0300 | [diff] [blame] | 140 | |
Jarkko Nikula | 22d48ad | 2020-05-06 18:30:25 +0300 | [diff] [blame] | 141 | return 0; |
| 142 | } |
| 143 | |
Serge Semin | 5778441 | 2020-05-29 16:12:02 +0300 | [diff] [blame] | 144 | static void dw_spi_dma_exit(struct dw_spi *dws) |
Feng Tang | 7063c0d | 2010-12-24 13:59:11 +0800 | [diff] [blame] | 145 | { |
Andy Shevchenko | a041e67 | 2020-05-07 14:54:49 +0300 | [diff] [blame] | 146 | if (dws->txchan) { |
| 147 | dmaengine_terminate_sync(dws->txchan); |
| 148 | dma_release_channel(dws->txchan); |
| 149 | } |
Andy Shevchenko | 8e45ef6 | 2014-09-18 20:08:53 +0300 | [diff] [blame] | 150 | |
Andy Shevchenko | a041e67 | 2020-05-07 14:54:49 +0300 | [diff] [blame] | 151 | if (dws->rxchan) { |
| 152 | dmaengine_terminate_sync(dws->rxchan); |
| 153 | dma_release_channel(dws->rxchan); |
| 154 | } |
Feng Tang | 7063c0d | 2010-12-24 13:59:11 +0800 | [diff] [blame] | 155 | } |
| 156 | |
Serge Semin | 5778441 | 2020-05-29 16:12:02 +0300 | [diff] [blame] | 157 | static irqreturn_t dw_spi_dma_transfer_handler(struct dw_spi *dws) |
Andy Shevchenko | f051fc8 | 2015-03-09 16:48:47 +0200 | [diff] [blame] | 158 | { |
Thor Thayer | dd11444 | 2015-03-12 14:19:31 -0500 | [diff] [blame] | 159 | u16 irq_status = dw_readl(dws, DW_SPI_ISR); |
Andy Shevchenko | f051fc8 | 2015-03-09 16:48:47 +0200 | [diff] [blame] | 160 | |
| 161 | if (!irq_status) |
| 162 | return IRQ_NONE; |
| 163 | |
Thor Thayer | dd11444 | 2015-03-12 14:19:31 -0500 | [diff] [blame] | 164 | dw_readl(dws, DW_SPI_ICR); |
Andy Shevchenko | f051fc8 | 2015-03-09 16:48:47 +0200 | [diff] [blame] | 165 | spi_reset_chip(dws); |
| 166 | |
| 167 | dev_err(&dws->master->dev, "%s: FIFO overrun/underrun\n", __func__); |
| 168 | dws->master->cur_msg->status = -EIO; |
Serge Semin | bdbdf0f | 2020-05-29 16:11:52 +0300 | [diff] [blame] | 169 | complete(&dws->dma_completion); |
Andy Shevchenko | f051fc8 | 2015-03-09 16:48:47 +0200 | [diff] [blame] | 170 | return IRQ_HANDLED; |
| 171 | } |
| 172 | |
Serge Semin | 5778441 | 2020-05-29 16:12:02 +0300 | [diff] [blame] | 173 | static bool dw_spi_can_dma(struct spi_controller *master, |
| 174 | struct spi_device *spi, struct spi_transfer *xfer) |
Andy Shevchenko | f89a6d8 | 2015-03-09 16:48:49 +0200 | [diff] [blame] | 175 | { |
Jarkko Nikula | 721483e | 2018-02-01 17:17:29 +0200 | [diff] [blame] | 176 | struct dw_spi *dws = spi_controller_get_devdata(master); |
Andy Shevchenko | f89a6d8 | 2015-03-09 16:48:49 +0200 | [diff] [blame] | 177 | |
Andy Shevchenko | f89a6d8 | 2015-03-09 16:48:49 +0200 | [diff] [blame] | 178 | return xfer->len > dws->fifo_len; |
| 179 | } |
| 180 | |
Serge Semin | 5778441 | 2020-05-29 16:12:02 +0300 | [diff] [blame] | 181 | static enum dma_slave_buswidth dw_spi_dma_convert_width(u8 n_bytes) |
| 182 | { |
Serge Semin | 4fdc03a | 2020-05-22 03:07:54 +0300 | [diff] [blame] | 183 | if (n_bytes == 1) |
Andy Shevchenko | e31abce | 2015-03-09 16:48:45 +0200 | [diff] [blame] | 184 | return DMA_SLAVE_BUSWIDTH_1_BYTE; |
Serge Semin | 4fdc03a | 2020-05-22 03:07:54 +0300 | [diff] [blame] | 185 | else if (n_bytes == 2) |
Andy Shevchenko | e31abce | 2015-03-09 16:48:45 +0200 | [diff] [blame] | 186 | return DMA_SLAVE_BUSWIDTH_2_BYTES; |
| 187 | |
| 188 | return DMA_SLAVE_BUSWIDTH_UNDEFINED; |
| 189 | } |
| 190 | |
Serge Semin | 917ce29 | 2020-09-20 14:23:21 +0300 | [diff] [blame^] | 191 | static int dw_spi_dma_wait(struct dw_spi *dws, unsigned int len, u32 speed) |
Serge Semin | bdbdf0f | 2020-05-29 16:11:52 +0300 | [diff] [blame] | 192 | { |
| 193 | unsigned long long ms; |
| 194 | |
Serge Semin | 917ce29 | 2020-09-20 14:23:21 +0300 | [diff] [blame^] | 195 | ms = len * MSEC_PER_SEC * BITS_PER_BYTE; |
| 196 | do_div(ms, speed); |
Serge Semin | bdbdf0f | 2020-05-29 16:11:52 +0300 | [diff] [blame] | 197 | ms += ms + 200; |
| 198 | |
| 199 | if (ms > UINT_MAX) |
| 200 | ms = UINT_MAX; |
| 201 | |
| 202 | ms = wait_for_completion_timeout(&dws->dma_completion, |
| 203 | msecs_to_jiffies(ms)); |
| 204 | |
| 205 | if (ms == 0) { |
| 206 | dev_err(&dws->master->cur_msg->spi->dev, |
| 207 | "DMA transaction timed out\n"); |
| 208 | return -ETIMEDOUT; |
| 209 | } |
| 210 | |
| 211 | return 0; |
| 212 | } |
| 213 | |
Serge Semin | 1ade2d8 | 2020-05-29 16:11:53 +0300 | [diff] [blame] | 214 | static inline bool dw_spi_dma_tx_busy(struct dw_spi *dws) |
| 215 | { |
| 216 | return !(dw_readl(dws, DW_SPI_SR) & SR_TF_EMPT); |
| 217 | } |
| 218 | |
| 219 | static int dw_spi_dma_wait_tx_done(struct dw_spi *dws, |
| 220 | struct spi_transfer *xfer) |
| 221 | { |
| 222 | int retry = WAIT_RETRIES; |
| 223 | struct spi_delay delay; |
| 224 | u32 nents; |
| 225 | |
| 226 | nents = dw_readl(dws, DW_SPI_TXFLR); |
| 227 | delay.unit = SPI_DELAY_UNIT_SCK; |
| 228 | delay.value = nents * dws->n_bytes * BITS_PER_BYTE; |
| 229 | |
| 230 | while (dw_spi_dma_tx_busy(dws) && retry--) |
| 231 | spi_delay_exec(&delay, xfer); |
| 232 | |
| 233 | if (retry < 0) { |
| 234 | dev_err(&dws->master->dev, "Tx hanged up\n"); |
| 235 | return -EIO; |
| 236 | } |
| 237 | |
| 238 | return 0; |
| 239 | } |
| 240 | |
Feng Tang | 7063c0d | 2010-12-24 13:59:11 +0800 | [diff] [blame] | 241 | /* |
Andy Shevchenko | 30c8eb5 | 2014-10-28 18:25:02 +0200 | [diff] [blame] | 242 | * dws->dma_chan_busy is set before the dma transfer starts, callback for tx |
| 243 | * channel will clear a corresponding bit. |
Feng Tang | 7063c0d | 2010-12-24 13:59:11 +0800 | [diff] [blame] | 244 | */ |
Andy Shevchenko | 30c8eb5 | 2014-10-28 18:25:02 +0200 | [diff] [blame] | 245 | static void dw_spi_dma_tx_done(void *arg) |
Feng Tang | 7063c0d | 2010-12-24 13:59:11 +0800 | [diff] [blame] | 246 | { |
| 247 | struct dw_spi *dws = arg; |
| 248 | |
Andy Shevchenko | 854d2f2 | 2015-03-06 14:42:01 +0200 | [diff] [blame] | 249 | clear_bit(TX_BUSY, &dws->dma_chan_busy); |
| 250 | if (test_bit(RX_BUSY, &dws->dma_chan_busy)) |
Feng Tang | 7063c0d | 2010-12-24 13:59:11 +0800 | [diff] [blame] | 251 | return; |
Serge Semin | 0327f0b | 2020-05-15 13:47:42 +0300 | [diff] [blame] | 252 | |
Serge Semin | bdbdf0f | 2020-05-29 16:11:52 +0300 | [diff] [blame] | 253 | complete(&dws->dma_completion); |
Feng Tang | 7063c0d | 2010-12-24 13:59:11 +0800 | [diff] [blame] | 254 | } |
| 255 | |
Serge Semin | a874d81 | 2020-09-20 14:23:14 +0300 | [diff] [blame] | 256 | static int dw_spi_dma_config_tx(struct dw_spi *dws) |
Feng Tang | 7063c0d | 2010-12-24 13:59:11 +0800 | [diff] [blame] | 257 | { |
Andy Shevchenko | a5c2db9 | 2014-10-28 18:25:01 +0200 | [diff] [blame] | 258 | struct dma_slave_config txconf; |
Feng Tang | 7063c0d | 2010-12-24 13:59:11 +0800 | [diff] [blame] | 259 | |
Andy Shevchenko | 3cb97e2 | 2020-05-06 18:30:18 +0300 | [diff] [blame] | 260 | memset(&txconf, 0, sizeof(txconf)); |
Vinod Koul | a485df4 | 2011-10-14 10:47:38 +0530 | [diff] [blame] | 261 | txconf.direction = DMA_MEM_TO_DEV; |
Feng Tang | 7063c0d | 2010-12-24 13:59:11 +0800 | [diff] [blame] | 262 | txconf.dst_addr = dws->dma_addr; |
Serge Semin | 0b2b665 | 2020-05-29 16:11:56 +0300 | [diff] [blame] | 263 | txconf.dst_maxburst = dws->txburst; |
Feng Tang | 7063c0d | 2010-12-24 13:59:11 +0800 | [diff] [blame] | 264 | txconf.src_addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES; |
Serge Semin | 5778441 | 2020-05-29 16:12:02 +0300 | [diff] [blame] | 265 | txconf.dst_addr_width = dw_spi_dma_convert_width(dws->n_bytes); |
Viresh Kumar | 258aea7 | 2012-02-01 16:12:19 +0530 | [diff] [blame] | 266 | txconf.device_fc = false; |
Feng Tang | 7063c0d | 2010-12-24 13:59:11 +0800 | [diff] [blame] | 267 | |
Serge Semin | a874d81 | 2020-09-20 14:23:14 +0300 | [diff] [blame] | 268 | return dmaengine_slave_config(dws->txchan, &txconf); |
| 269 | } |
| 270 | |
Serge Semin | 917ce29 | 2020-09-20 14:23:21 +0300 | [diff] [blame^] | 271 | static int dw_spi_dma_submit_tx(struct dw_spi *dws, struct scatterlist *sgl, |
| 272 | unsigned int nents) |
Serge Semin | a874d81 | 2020-09-20 14:23:14 +0300 | [diff] [blame] | 273 | { |
| 274 | struct dma_async_tx_descriptor *txdesc; |
Serge Semin | 9a6471a | 2020-09-20 14:23:17 +0300 | [diff] [blame] | 275 | dma_cookie_t cookie; |
| 276 | int ret; |
Feng Tang | 7063c0d | 2010-12-24 13:59:11 +0800 | [diff] [blame] | 277 | |
Serge Semin | 917ce29 | 2020-09-20 14:23:21 +0300 | [diff] [blame^] | 278 | txdesc = dmaengine_prep_slave_sg(dws->txchan, sgl, nents, |
| 279 | DMA_MEM_TO_DEV, |
| 280 | DMA_PREP_INTERRUPT | DMA_CTRL_ACK); |
Andy Shevchenko | c9dafb2 | 2015-03-02 20:15:58 +0200 | [diff] [blame] | 281 | if (!txdesc) |
Serge Semin | 7a4d61f | 2020-09-20 14:23:18 +0300 | [diff] [blame] | 282 | return -ENOMEM; |
Andy Shevchenko | c9dafb2 | 2015-03-02 20:15:58 +0200 | [diff] [blame] | 283 | |
Andy Shevchenko | 30c8eb5 | 2014-10-28 18:25:02 +0200 | [diff] [blame] | 284 | txdesc->callback = dw_spi_dma_tx_done; |
Feng Tang | 7063c0d | 2010-12-24 13:59:11 +0800 | [diff] [blame] | 285 | txdesc->callback_param = dws; |
| 286 | |
Serge Semin | 9a6471a | 2020-09-20 14:23:17 +0300 | [diff] [blame] | 287 | cookie = dmaengine_submit(txdesc); |
| 288 | ret = dma_submit_error(cookie); |
| 289 | if (ret) { |
| 290 | dmaengine_terminate_sync(dws->txchan); |
Serge Semin | 7a4d61f | 2020-09-20 14:23:18 +0300 | [diff] [blame] | 291 | return ret; |
Serge Semin | 9a6471a | 2020-09-20 14:23:17 +0300 | [diff] [blame] | 292 | } |
| 293 | |
Serge Semin | ab7a4d7 | 2020-09-20 14:23:16 +0300 | [diff] [blame] | 294 | set_bit(TX_BUSY, &dws->dma_chan_busy); |
| 295 | |
Serge Semin | 7a4d61f | 2020-09-20 14:23:18 +0300 | [diff] [blame] | 296 | return 0; |
Andy Shevchenko | a5c2db9 | 2014-10-28 18:25:01 +0200 | [diff] [blame] | 297 | } |
| 298 | |
Serge Semin | 33726ef | 2020-05-29 16:11:54 +0300 | [diff] [blame] | 299 | static inline bool dw_spi_dma_rx_busy(struct dw_spi *dws) |
| 300 | { |
| 301 | return !!(dw_readl(dws, DW_SPI_SR) & SR_RF_NOT_EMPT); |
| 302 | } |
| 303 | |
| 304 | static int dw_spi_dma_wait_rx_done(struct dw_spi *dws) |
| 305 | { |
| 306 | int retry = WAIT_RETRIES; |
| 307 | struct spi_delay delay; |
| 308 | unsigned long ns, us; |
| 309 | u32 nents; |
| 310 | |
| 311 | /* |
| 312 | * It's unlikely that DMA engine is still doing the data fetching, but |
| 313 | * if it's let's give it some reasonable time. The timeout calculation |
| 314 | * is based on the synchronous APB/SSI reference clock rate, on a |
| 315 | * number of data entries left in the Rx FIFO, times a number of clock |
| 316 | * periods normally needed for a single APB read/write transaction |
| 317 | * without PREADY signal utilized (which is true for the DW APB SSI |
| 318 | * controller). |
| 319 | */ |
| 320 | nents = dw_readl(dws, DW_SPI_RXFLR); |
| 321 | ns = 4U * NSEC_PER_SEC / dws->max_freq * nents; |
| 322 | if (ns <= NSEC_PER_USEC) { |
| 323 | delay.unit = SPI_DELAY_UNIT_NSECS; |
| 324 | delay.value = ns; |
| 325 | } else { |
| 326 | us = DIV_ROUND_UP(ns, NSEC_PER_USEC); |
| 327 | delay.unit = SPI_DELAY_UNIT_USECS; |
| 328 | delay.value = clamp_val(us, 0, USHRT_MAX); |
| 329 | } |
| 330 | |
| 331 | while (dw_spi_dma_rx_busy(dws) && retry--) |
| 332 | spi_delay_exec(&delay, NULL); |
| 333 | |
| 334 | if (retry < 0) { |
| 335 | dev_err(&dws->master->dev, "Rx hanged up\n"); |
| 336 | return -EIO; |
| 337 | } |
| 338 | |
| 339 | return 0; |
| 340 | } |
| 341 | |
Andy Shevchenko | 30c8eb5 | 2014-10-28 18:25:02 +0200 | [diff] [blame] | 342 | /* |
| 343 | * dws->dma_chan_busy is set before the dma transfer starts, callback for rx |
| 344 | * channel will clear a corresponding bit. |
| 345 | */ |
| 346 | static void dw_spi_dma_rx_done(void *arg) |
| 347 | { |
| 348 | struct dw_spi *dws = arg; |
| 349 | |
Andy Shevchenko | 854d2f2 | 2015-03-06 14:42:01 +0200 | [diff] [blame] | 350 | clear_bit(RX_BUSY, &dws->dma_chan_busy); |
| 351 | if (test_bit(TX_BUSY, &dws->dma_chan_busy)) |
Andy Shevchenko | 30c8eb5 | 2014-10-28 18:25:02 +0200 | [diff] [blame] | 352 | return; |
Serge Semin | 0327f0b | 2020-05-15 13:47:42 +0300 | [diff] [blame] | 353 | |
Serge Semin | bdbdf0f | 2020-05-29 16:11:52 +0300 | [diff] [blame] | 354 | complete(&dws->dma_completion); |
Andy Shevchenko | 30c8eb5 | 2014-10-28 18:25:02 +0200 | [diff] [blame] | 355 | } |
| 356 | |
Serge Semin | a874d81 | 2020-09-20 14:23:14 +0300 | [diff] [blame] | 357 | static int dw_spi_dma_config_rx(struct dw_spi *dws) |
Andy Shevchenko | a5c2db9 | 2014-10-28 18:25:01 +0200 | [diff] [blame] | 358 | { |
| 359 | struct dma_slave_config rxconf; |
Andy Shevchenko | 30c8eb5 | 2014-10-28 18:25:02 +0200 | [diff] [blame] | 360 | |
Andy Shevchenko | 3cb97e2 | 2020-05-06 18:30:18 +0300 | [diff] [blame] | 361 | memset(&rxconf, 0, sizeof(rxconf)); |
Vinod Koul | a485df4 | 2011-10-14 10:47:38 +0530 | [diff] [blame] | 362 | rxconf.direction = DMA_DEV_TO_MEM; |
Feng Tang | 7063c0d | 2010-12-24 13:59:11 +0800 | [diff] [blame] | 363 | rxconf.src_addr = dws->dma_addr; |
Serge Semin | 0b2b665 | 2020-05-29 16:11:56 +0300 | [diff] [blame] | 364 | rxconf.src_maxburst = dws->rxburst; |
Feng Tang | 7063c0d | 2010-12-24 13:59:11 +0800 | [diff] [blame] | 365 | rxconf.dst_addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES; |
Serge Semin | 5778441 | 2020-05-29 16:12:02 +0300 | [diff] [blame] | 366 | rxconf.src_addr_width = dw_spi_dma_convert_width(dws->n_bytes); |
Viresh Kumar | 258aea7 | 2012-02-01 16:12:19 +0530 | [diff] [blame] | 367 | rxconf.device_fc = false; |
Feng Tang | 7063c0d | 2010-12-24 13:59:11 +0800 | [diff] [blame] | 368 | |
Serge Semin | a874d81 | 2020-09-20 14:23:14 +0300 | [diff] [blame] | 369 | return dmaengine_slave_config(dws->rxchan, &rxconf); |
| 370 | } |
| 371 | |
Serge Semin | 917ce29 | 2020-09-20 14:23:21 +0300 | [diff] [blame^] | 372 | static int dw_spi_dma_submit_rx(struct dw_spi *dws, struct scatterlist *sgl, |
| 373 | unsigned int nents) |
Serge Semin | a874d81 | 2020-09-20 14:23:14 +0300 | [diff] [blame] | 374 | { |
| 375 | struct dma_async_tx_descriptor *rxdesc; |
Serge Semin | 9a6471a | 2020-09-20 14:23:17 +0300 | [diff] [blame] | 376 | dma_cookie_t cookie; |
| 377 | int ret; |
Serge Semin | a874d81 | 2020-09-20 14:23:14 +0300 | [diff] [blame] | 378 | |
Serge Semin | 917ce29 | 2020-09-20 14:23:21 +0300 | [diff] [blame^] | 379 | rxdesc = dmaengine_prep_slave_sg(dws->rxchan, sgl, nents, |
| 380 | DMA_DEV_TO_MEM, |
| 381 | DMA_PREP_INTERRUPT | DMA_CTRL_ACK); |
Andy Shevchenko | c9dafb2 | 2015-03-02 20:15:58 +0200 | [diff] [blame] | 382 | if (!rxdesc) |
Serge Semin | 7a4d61f | 2020-09-20 14:23:18 +0300 | [diff] [blame] | 383 | return -ENOMEM; |
Andy Shevchenko | c9dafb2 | 2015-03-02 20:15:58 +0200 | [diff] [blame] | 384 | |
Andy Shevchenko | 30c8eb5 | 2014-10-28 18:25:02 +0200 | [diff] [blame] | 385 | rxdesc->callback = dw_spi_dma_rx_done; |
Feng Tang | 7063c0d | 2010-12-24 13:59:11 +0800 | [diff] [blame] | 386 | rxdesc->callback_param = dws; |
| 387 | |
Serge Semin | 9a6471a | 2020-09-20 14:23:17 +0300 | [diff] [blame] | 388 | cookie = dmaengine_submit(rxdesc); |
| 389 | ret = dma_submit_error(cookie); |
| 390 | if (ret) { |
| 391 | dmaengine_terminate_sync(dws->rxchan); |
Serge Semin | 7a4d61f | 2020-09-20 14:23:18 +0300 | [diff] [blame] | 392 | return ret; |
Serge Semin | 9a6471a | 2020-09-20 14:23:17 +0300 | [diff] [blame] | 393 | } |
| 394 | |
Serge Semin | ab7a4d7 | 2020-09-20 14:23:16 +0300 | [diff] [blame] | 395 | set_bit(RX_BUSY, &dws->dma_chan_busy); |
| 396 | |
Serge Semin | 7a4d61f | 2020-09-20 14:23:18 +0300 | [diff] [blame] | 397 | return 0; |
Andy Shevchenko | a5c2db9 | 2014-10-28 18:25:01 +0200 | [diff] [blame] | 398 | } |
| 399 | |
Serge Semin | 5778441 | 2020-05-29 16:12:02 +0300 | [diff] [blame] | 400 | static int dw_spi_dma_setup(struct dw_spi *dws, struct spi_transfer *xfer) |
Andy Shevchenko | a5c2db9 | 2014-10-28 18:25:01 +0200 | [diff] [blame] | 401 | { |
Serge Semin | 7ef3038 | 2020-09-20 14:23:13 +0300 | [diff] [blame] | 402 | u16 imr, dma_ctrl; |
Serge Semin | a874d81 | 2020-09-20 14:23:14 +0300 | [diff] [blame] | 403 | int ret; |
Andy Shevchenko | a5c2db9 | 2014-10-28 18:25:01 +0200 | [diff] [blame] | 404 | |
Serge Semin | 7ef3038 | 2020-09-20 14:23:13 +0300 | [diff] [blame] | 405 | if (!xfer->tx_buf) |
| 406 | return -EINVAL; |
| 407 | |
Serge Semin | a874d81 | 2020-09-20 14:23:14 +0300 | [diff] [blame] | 408 | /* Setup DMA channels */ |
| 409 | ret = dw_spi_dma_config_tx(dws); |
| 410 | if (ret) |
| 411 | return ret; |
| 412 | |
| 413 | if (xfer->rx_buf) { |
| 414 | ret = dw_spi_dma_config_rx(dws); |
| 415 | if (ret) |
| 416 | return ret; |
| 417 | } |
| 418 | |
Serge Semin | 7ef3038 | 2020-09-20 14:23:13 +0300 | [diff] [blame] | 419 | /* Set the DMA handshaking interface */ |
| 420 | dma_ctrl = SPI_DMA_TDMAE; |
Andy Shevchenko | 3d7db0f | 2020-05-29 21:31:50 +0300 | [diff] [blame] | 421 | if (xfer->rx_buf) |
Andy Shevchenko | a5c2db9 | 2014-10-28 18:25:01 +0200 | [diff] [blame] | 422 | dma_ctrl |= SPI_DMA_RDMAE; |
Thor Thayer | dd11444 | 2015-03-12 14:19:31 -0500 | [diff] [blame] | 423 | dw_writel(dws, DW_SPI_DMACR, dma_ctrl); |
Andy Shevchenko | a5c2db9 | 2014-10-28 18:25:01 +0200 | [diff] [blame] | 424 | |
Andy Shevchenko | f051fc8 | 2015-03-09 16:48:47 +0200 | [diff] [blame] | 425 | /* Set the interrupt mask */ |
Serge Semin | 7ef3038 | 2020-09-20 14:23:13 +0300 | [diff] [blame] | 426 | imr = SPI_INT_TXOI; |
Andy Shevchenko | 3d7db0f | 2020-05-29 21:31:50 +0300 | [diff] [blame] | 427 | if (xfer->rx_buf) |
| 428 | imr |= SPI_INT_RXUI | SPI_INT_RXOI; |
Serge Semin | 43dba9f | 2020-05-22 03:07:51 +0300 | [diff] [blame] | 429 | spi_umask_intr(dws, imr); |
Andy Shevchenko | f051fc8 | 2015-03-09 16:48:47 +0200 | [diff] [blame] | 430 | |
Serge Semin | bdbdf0f | 2020-05-29 16:11:52 +0300 | [diff] [blame] | 431 | reinit_completion(&dws->dma_completion); |
| 432 | |
Serge Semin | 5778441 | 2020-05-29 16:12:02 +0300 | [diff] [blame] | 433 | dws->transfer_handler = dw_spi_dma_transfer_handler; |
Andy Shevchenko | f051fc8 | 2015-03-09 16:48:47 +0200 | [diff] [blame] | 434 | |
Andy Shevchenko | 9f14538 | 2015-03-09 16:48:46 +0200 | [diff] [blame] | 435 | return 0; |
Andy Shevchenko | a5c2db9 | 2014-10-28 18:25:01 +0200 | [diff] [blame] | 436 | } |
| 437 | |
Serge Semin | b86fed12 | 2020-09-20 14:23:19 +0300 | [diff] [blame] | 438 | static int dw_spi_dma_transfer_all(struct dw_spi *dws, |
| 439 | struct spi_transfer *xfer) |
Andy Shevchenko | a5c2db9 | 2014-10-28 18:25:01 +0200 | [diff] [blame] | 440 | { |
Serge Semin | bdbdf0f | 2020-05-29 16:11:52 +0300 | [diff] [blame] | 441 | int ret; |
Andy Shevchenko | a5c2db9 | 2014-10-28 18:25:01 +0200 | [diff] [blame] | 442 | |
Serge Semin | ab7a4d7 | 2020-09-20 14:23:16 +0300 | [diff] [blame] | 443 | /* Submit the DMA Tx transfer */ |
Serge Semin | 917ce29 | 2020-09-20 14:23:21 +0300 | [diff] [blame^] | 444 | ret = dw_spi_dma_submit_tx(dws, xfer->tx_sg.sgl, xfer->tx_sg.nents); |
Serge Semin | 7a4d61f | 2020-09-20 14:23:18 +0300 | [diff] [blame] | 445 | if (ret) |
Serge Semin | 945b5b6 | 2020-09-20 14:23:20 +0300 | [diff] [blame] | 446 | goto err_clear_dmac; |
Andy Shevchenko | a5c2db9 | 2014-10-28 18:25:01 +0200 | [diff] [blame] | 447 | |
Serge Semin | ab7a4d7 | 2020-09-20 14:23:16 +0300 | [diff] [blame] | 448 | /* Submit the DMA Rx transfer if required */ |
Serge Semin | be3034d | 2020-09-20 14:23:15 +0300 | [diff] [blame] | 449 | if (xfer->rx_buf) { |
Serge Semin | 917ce29 | 2020-09-20 14:23:21 +0300 | [diff] [blame^] | 450 | ret = dw_spi_dma_submit_rx(dws, xfer->rx_sg.sgl, |
| 451 | xfer->rx_sg.nents); |
Serge Semin | 7a4d61f | 2020-09-20 14:23:18 +0300 | [diff] [blame] | 452 | if (ret) |
Serge Semin | 945b5b6 | 2020-09-20 14:23:20 +0300 | [diff] [blame] | 453 | goto err_clear_dmac; |
Andy Shevchenko | a5c2db9 | 2014-10-28 18:25:01 +0200 | [diff] [blame] | 454 | |
Serge Semin | be3034d | 2020-09-20 14:23:15 +0300 | [diff] [blame] | 455 | /* rx must be started before tx due to spi instinct */ |
Andy Shevchenko | 30c8eb5 | 2014-10-28 18:25:02 +0200 | [diff] [blame] | 456 | dma_async_issue_pending(dws->rxchan); |
| 457 | } |
Andy Shevchenko | f7477c2 | 2014-10-02 16:31:09 +0300 | [diff] [blame] | 458 | |
Serge Semin | 7ef3038 | 2020-09-20 14:23:13 +0300 | [diff] [blame] | 459 | dma_async_issue_pending(dws->txchan); |
Andy Shevchenko | f7477c2 | 2014-10-02 16:31:09 +0300 | [diff] [blame] | 460 | |
Serge Semin | 917ce29 | 2020-09-20 14:23:21 +0300 | [diff] [blame^] | 461 | ret = dw_spi_dma_wait(dws, xfer->len, xfer->effective_speed_hz); |
Serge Semin | 945b5b6 | 2020-09-20 14:23:20 +0300 | [diff] [blame] | 462 | |
| 463 | err_clear_dmac: |
| 464 | dw_writel(dws, DW_SPI_DMACR, 0); |
| 465 | |
| 466 | return ret; |
Serge Semin | b86fed12 | 2020-09-20 14:23:19 +0300 | [diff] [blame] | 467 | } |
| 468 | |
| 469 | static int dw_spi_dma_transfer(struct dw_spi *dws, struct spi_transfer *xfer) |
| 470 | { |
| 471 | int ret; |
| 472 | |
| 473 | ret = dw_spi_dma_transfer_all(dws, xfer); |
Serge Semin | bdbdf0f | 2020-05-29 16:11:52 +0300 | [diff] [blame] | 474 | if (ret) |
| 475 | return ret; |
| 476 | |
Serge Semin | 7ef3038 | 2020-09-20 14:23:13 +0300 | [diff] [blame] | 477 | if (dws->master->cur_msg->status == -EINPROGRESS) { |
Serge Semin | 1ade2d8 | 2020-05-29 16:11:53 +0300 | [diff] [blame] | 478 | ret = dw_spi_dma_wait_tx_done(dws, xfer); |
| 479 | if (ret) |
| 480 | return ret; |
| 481 | } |
| 482 | |
Serge Semin | be3034d | 2020-09-20 14:23:15 +0300 | [diff] [blame] | 483 | if (xfer->rx_buf && dws->master->cur_msg->status == -EINPROGRESS) |
Serge Semin | 33726ef | 2020-05-29 16:11:54 +0300 | [diff] [blame] | 484 | ret = dw_spi_dma_wait_rx_done(dws); |
| 485 | |
| 486 | return ret; |
Feng Tang | 7063c0d | 2010-12-24 13:59:11 +0800 | [diff] [blame] | 487 | } |
| 488 | |
Serge Semin | 5778441 | 2020-05-29 16:12:02 +0300 | [diff] [blame] | 489 | static void dw_spi_dma_stop(struct dw_spi *dws) |
Andy Shevchenko | 4d5ac1e | 2015-03-09 16:48:48 +0200 | [diff] [blame] | 490 | { |
| 491 | if (test_bit(TX_BUSY, &dws->dma_chan_busy)) { |
Andy Shevchenko | cf1716e | 2017-01-03 15:48:20 +0200 | [diff] [blame] | 492 | dmaengine_terminate_sync(dws->txchan); |
Andy Shevchenko | 4d5ac1e | 2015-03-09 16:48:48 +0200 | [diff] [blame] | 493 | clear_bit(TX_BUSY, &dws->dma_chan_busy); |
| 494 | } |
| 495 | if (test_bit(RX_BUSY, &dws->dma_chan_busy)) { |
Andy Shevchenko | cf1716e | 2017-01-03 15:48:20 +0200 | [diff] [blame] | 496 | dmaengine_terminate_sync(dws->rxchan); |
Andy Shevchenko | 4d5ac1e | 2015-03-09 16:48:48 +0200 | [diff] [blame] | 497 | clear_bit(RX_BUSY, &dws->dma_chan_busy); |
| 498 | } |
| 499 | } |
| 500 | |
Serge Semin | 5778441 | 2020-05-29 16:12:02 +0300 | [diff] [blame] | 501 | static const struct dw_spi_dma_ops dw_spi_dma_mfld_ops = { |
| 502 | .dma_init = dw_spi_dma_init_mfld, |
| 503 | .dma_exit = dw_spi_dma_exit, |
| 504 | .dma_setup = dw_spi_dma_setup, |
| 505 | .can_dma = dw_spi_can_dma, |
| 506 | .dma_transfer = dw_spi_dma_transfer, |
| 507 | .dma_stop = dw_spi_dma_stop, |
Feng Tang | 7063c0d | 2010-12-24 13:59:11 +0800 | [diff] [blame] | 508 | }; |
Andy Shevchenko | 37aa8aa | 2020-05-06 18:30:23 +0300 | [diff] [blame] | 509 | |
Serge Semin | 5778441 | 2020-05-29 16:12:02 +0300 | [diff] [blame] | 510 | void dw_spi_dma_setup_mfld(struct dw_spi *dws) |
Andy Shevchenko | 37aa8aa | 2020-05-06 18:30:23 +0300 | [diff] [blame] | 511 | { |
Serge Semin | 5778441 | 2020-05-29 16:12:02 +0300 | [diff] [blame] | 512 | dws->dma_ops = &dw_spi_dma_mfld_ops; |
Andy Shevchenko | 37aa8aa | 2020-05-06 18:30:23 +0300 | [diff] [blame] | 513 | } |
Serge Semin | 5778441 | 2020-05-29 16:12:02 +0300 | [diff] [blame] | 514 | EXPORT_SYMBOL_GPL(dw_spi_dma_setup_mfld); |
Jarkko Nikula | 22d48ad | 2020-05-06 18:30:25 +0300 | [diff] [blame] | 515 | |
Serge Semin | 5778441 | 2020-05-29 16:12:02 +0300 | [diff] [blame] | 516 | static const struct dw_spi_dma_ops dw_spi_dma_generic_ops = { |
| 517 | .dma_init = dw_spi_dma_init_generic, |
| 518 | .dma_exit = dw_spi_dma_exit, |
| 519 | .dma_setup = dw_spi_dma_setup, |
| 520 | .can_dma = dw_spi_can_dma, |
| 521 | .dma_transfer = dw_spi_dma_transfer, |
| 522 | .dma_stop = dw_spi_dma_stop, |
Jarkko Nikula | 22d48ad | 2020-05-06 18:30:25 +0300 | [diff] [blame] | 523 | }; |
| 524 | |
Serge Semin | 5778441 | 2020-05-29 16:12:02 +0300 | [diff] [blame] | 525 | void dw_spi_dma_setup_generic(struct dw_spi *dws) |
Jarkko Nikula | 22d48ad | 2020-05-06 18:30:25 +0300 | [diff] [blame] | 526 | { |
Serge Semin | 5778441 | 2020-05-29 16:12:02 +0300 | [diff] [blame] | 527 | dws->dma_ops = &dw_spi_dma_generic_ops; |
Jarkko Nikula | 22d48ad | 2020-05-06 18:30:25 +0300 | [diff] [blame] | 528 | } |
Serge Semin | 5778441 | 2020-05-29 16:12:02 +0300 | [diff] [blame] | 529 | EXPORT_SYMBOL_GPL(dw_spi_dma_setup_generic); |