diff options
-rw-r--r-- | drivers/spi/spi-atmel.c | 3 | ||||
-rw-r--r-- | drivers/spi/spi-imx.c | 7 | ||||
-rw-r--r-- | drivers/spi/spi-omap2-mcspi.c | 28 | ||||
-rw-r--r-- | drivers/spi/spi-ti-qspi.c | 3 | ||||
-rw-r--r-- | drivers/spi/spi-xilinx.c | 38 |
5 files changed, 62 insertions, 17 deletions
diff --git a/drivers/spi/spi-atmel.c b/drivers/spi/spi-atmel.c index 63318e2afba1..3fff59ce065f 100644 --- a/drivers/spi/spi-atmel.c +++ b/drivers/spi/spi-atmel.c | |||
@@ -773,7 +773,8 @@ static int atmel_spi_next_xfer_dma_submit(struct spi_master *master, | |||
773 | 773 | ||
774 | *plen = len; | 774 | *plen = len; |
775 | 775 | ||
776 | if (atmel_spi_dma_slave_config(as, &slave_config, 8)) | 776 | if (atmel_spi_dma_slave_config(as, &slave_config, |
777 | xfer->bits_per_word)) | ||
777 | goto err_exit; | 778 | goto err_exit; |
778 | 779 | ||
779 | /* Send both scatterlists */ | 780 | /* Send both scatterlists */ |
diff --git a/drivers/spi/spi-imx.c b/drivers/spi/spi-imx.c index f9deb84e4e55..0e5723ab47f0 100644 --- a/drivers/spi/spi-imx.c +++ b/drivers/spi/spi-imx.c | |||
@@ -336,13 +336,20 @@ static int __maybe_unused mx51_ecspi_config(struct spi_imx_data *spi_imx, | |||
336 | 336 | ||
337 | if (config->mode & SPI_CPHA) | 337 | if (config->mode & SPI_CPHA) |
338 | cfg |= MX51_ECSPI_CONFIG_SCLKPHA(config->cs); | 338 | cfg |= MX51_ECSPI_CONFIG_SCLKPHA(config->cs); |
339 | else | ||
340 | cfg &= ~MX51_ECSPI_CONFIG_SCLKPHA(config->cs); | ||
339 | 341 | ||
340 | if (config->mode & SPI_CPOL) { | 342 | if (config->mode & SPI_CPOL) { |
341 | cfg |= MX51_ECSPI_CONFIG_SCLKPOL(config->cs); | 343 | cfg |= MX51_ECSPI_CONFIG_SCLKPOL(config->cs); |
342 | cfg |= MX51_ECSPI_CONFIG_SCLKCTL(config->cs); | 344 | cfg |= MX51_ECSPI_CONFIG_SCLKCTL(config->cs); |
345 | } else { | ||
346 | cfg &= ~MX51_ECSPI_CONFIG_SCLKPOL(config->cs); | ||
347 | cfg &= ~MX51_ECSPI_CONFIG_SCLKCTL(config->cs); | ||
343 | } | 348 | } |
344 | if (config->mode & SPI_CS_HIGH) | 349 | if (config->mode & SPI_CS_HIGH) |
345 | cfg |= MX51_ECSPI_CONFIG_SSBPOL(config->cs); | 350 | cfg |= MX51_ECSPI_CONFIG_SSBPOL(config->cs); |
351 | else | ||
352 | cfg &= ~MX51_ECSPI_CONFIG_SSBPOL(config->cs); | ||
346 | 353 | ||
347 | writel(ctrl, spi_imx->base + MX51_ECSPI_CTRL); | 354 | writel(ctrl, spi_imx->base + MX51_ECSPI_CTRL); |
348 | writel(cfg, spi_imx->base + MX51_ECSPI_CONFIG); | 355 | writel(cfg, spi_imx->base + MX51_ECSPI_CONFIG); |
diff --git a/drivers/spi/spi-omap2-mcspi.c b/drivers/spi/spi-omap2-mcspi.c index 3d09e0b69b73..1f8903d356e5 100644 --- a/drivers/spi/spi-omap2-mcspi.c +++ b/drivers/spi/spi-omap2-mcspi.c | |||
@@ -1217,6 +1217,33 @@ out: | |||
1217 | return status; | 1217 | return status; |
1218 | } | 1218 | } |
1219 | 1219 | ||
1220 | static int omap2_mcspi_prepare_message(struct spi_master *master, | ||
1221 | struct spi_message *msg) | ||
1222 | { | ||
1223 | struct omap2_mcspi *mcspi = spi_master_get_devdata(master); | ||
1224 | struct omap2_mcspi_regs *ctx = &mcspi->ctx; | ||
1225 | struct omap2_mcspi_cs *cs; | ||
1226 | |||
1227 | /* Only a single channel can have the FORCE bit enabled | ||
1228 | * in its chconf0 register. | ||
1229 | * Scan all channels and disable them except the current one. | ||
1230 | * A FORCE can remain from a last transfer having cs_change enabled | ||
1231 | */ | ||
1232 | list_for_each_entry(cs, &ctx->cs, node) { | ||
1233 | if (msg->spi->controller_state == cs) | ||
1234 | continue; | ||
1235 | |||
1236 | if ((cs->chconf0 & OMAP2_MCSPI_CHCONF_FORCE)) { | ||
1237 | cs->chconf0 &= ~OMAP2_MCSPI_CHCONF_FORCE; | ||
1238 | writel_relaxed(cs->chconf0, | ||
1239 | cs->base + OMAP2_MCSPI_CHCONF0); | ||
1240 | readl_relaxed(cs->base + OMAP2_MCSPI_CHCONF0); | ||
1241 | } | ||
1242 | } | ||
1243 | |||
1244 | return 0; | ||
1245 | } | ||
1246 | |||
1220 | static int omap2_mcspi_transfer_one(struct spi_master *master, | 1247 | static int omap2_mcspi_transfer_one(struct spi_master *master, |
1221 | struct spi_device *spi, struct spi_transfer *t) | 1248 | struct spi_device *spi, struct spi_transfer *t) |
1222 | { | 1249 | { |
@@ -1344,6 +1371,7 @@ static int omap2_mcspi_probe(struct platform_device *pdev) | |||
1344 | master->bits_per_word_mask = SPI_BPW_RANGE_MASK(4, 32); | 1371 | master->bits_per_word_mask = SPI_BPW_RANGE_MASK(4, 32); |
1345 | master->setup = omap2_mcspi_setup; | 1372 | master->setup = omap2_mcspi_setup; |
1346 | master->auto_runtime_pm = true; | 1373 | master->auto_runtime_pm = true; |
1374 | master->prepare_message = omap2_mcspi_prepare_message; | ||
1347 | master->transfer_one = omap2_mcspi_transfer_one; | 1375 | master->transfer_one = omap2_mcspi_transfer_one; |
1348 | master->set_cs = omap2_mcspi_set_cs; | 1376 | master->set_cs = omap2_mcspi_set_cs; |
1349 | master->cleanup = omap2_mcspi_cleanup; | 1377 | master->cleanup = omap2_mcspi_cleanup; |
diff --git a/drivers/spi/spi-ti-qspi.c b/drivers/spi/spi-ti-qspi.c index aa6d284131e0..81b84858cfee 100644 --- a/drivers/spi/spi-ti-qspi.c +++ b/drivers/spi/spi-ti-qspi.c | |||
@@ -410,11 +410,10 @@ static int ti_qspi_start_transfer_one(struct spi_master *master, | |||
410 | 410 | ||
411 | mutex_unlock(&qspi->list_lock); | 411 | mutex_unlock(&qspi->list_lock); |
412 | 412 | ||
413 | ti_qspi_write(qspi, qspi->cmd | QSPI_INVAL, QSPI_SPI_CMD_REG); | ||
413 | m->status = status; | 414 | m->status = status; |
414 | spi_finalize_current_message(master); | 415 | spi_finalize_current_message(master); |
415 | 416 | ||
416 | ti_qspi_write(qspi, qspi->cmd | QSPI_INVAL, QSPI_SPI_CMD_REG); | ||
417 | |||
418 | return status; | 417 | return status; |
419 | } | 418 | } |
420 | 419 | ||
diff --git a/drivers/spi/spi-xilinx.c b/drivers/spi/spi-xilinx.c index a339c1e9997a..3009121173cd 100644 --- a/drivers/spi/spi-xilinx.c +++ b/drivers/spi/spi-xilinx.c | |||
@@ -270,6 +270,7 @@ static int xilinx_spi_txrx_bufs(struct spi_device *spi, struct spi_transfer *t) | |||
270 | 270 | ||
271 | while (remaining_words) { | 271 | while (remaining_words) { |
272 | int n_words, tx_words, rx_words; | 272 | int n_words, tx_words, rx_words; |
273 | u32 sr; | ||
273 | 274 | ||
274 | n_words = min(remaining_words, xspi->buffer_size); | 275 | n_words = min(remaining_words, xspi->buffer_size); |
275 | 276 | ||
@@ -284,24 +285,33 @@ static int xilinx_spi_txrx_bufs(struct spi_device *spi, struct spi_transfer *t) | |||
284 | if (use_irq) { | 285 | if (use_irq) { |
285 | xspi->write_fn(cr, xspi->regs + XSPI_CR_OFFSET); | 286 | xspi->write_fn(cr, xspi->regs + XSPI_CR_OFFSET); |
286 | wait_for_completion(&xspi->done); | 287 | wait_for_completion(&xspi->done); |
287 | } else | 288 | /* A transmit has just completed. Process received data |
288 | while (!(xspi->read_fn(xspi->regs + XSPI_SR_OFFSET) & | 289 | * and check for more data to transmit. Always inhibit |
289 | XSPI_SR_TX_EMPTY_MASK)) | 290 | * the transmitter while the Isr refills the transmit |
290 | ; | 291 | * register/FIFO, or make sure it is stopped if we're |
291 | 292 | * done. | |
292 | /* A transmit has just completed. Process received data and | 293 | */ |
293 | * check for more data to transmit. Always inhibit the | ||
294 | * transmitter while the Isr refills the transmit register/FIFO, | ||
295 | * or make sure it is stopped if we're done. | ||
296 | */ | ||
297 | if (use_irq) | ||
298 | xspi->write_fn(cr | XSPI_CR_TRANS_INHIBIT, | 294 | xspi->write_fn(cr | XSPI_CR_TRANS_INHIBIT, |
299 | xspi->regs + XSPI_CR_OFFSET); | 295 | xspi->regs + XSPI_CR_OFFSET); |
296 | sr = XSPI_SR_TX_EMPTY_MASK; | ||
297 | } else | ||
298 | sr = xspi->read_fn(xspi->regs + XSPI_SR_OFFSET); | ||
300 | 299 | ||
301 | /* Read out all the data from the Rx FIFO */ | 300 | /* Read out all the data from the Rx FIFO */ |
302 | rx_words = n_words; | 301 | rx_words = n_words; |
303 | while (rx_words--) | 302 | while (rx_words) { |
304 | xilinx_spi_rx(xspi); | 303 | if ((sr & XSPI_SR_TX_EMPTY_MASK) && (rx_words > 1)) { |
304 | xilinx_spi_rx(xspi); | ||
305 | rx_words--; | ||
306 | continue; | ||
307 | } | ||
308 | |||
309 | sr = xspi->read_fn(xspi->regs + XSPI_SR_OFFSET); | ||
310 | if (!(sr & XSPI_SR_RX_EMPTY_MASK)) { | ||
311 | xilinx_spi_rx(xspi); | ||
312 | rx_words--; | ||
313 | } | ||
314 | } | ||
305 | 315 | ||
306 | remaining_words -= n_words; | 316 | remaining_words -= n_words; |
307 | } | 317 | } |