diff options
author | Mark Brown <broonie@opensource.wolfsonmicro.com> | 2012-11-06 04:03:29 -0500 |
---|---|---|
committer | Mark Brown <broonie@opensource.wolfsonmicro.com> | 2012-11-06 04:03:29 -0500 |
commit | 70324494b6f283311c5339fb1795fdec2d8850d9 (patch) | |
tree | 5a318c2b60ba6e7861d630310d1930f62b8893ce /drivers/spi/spi-omap2-mcspi.c | |
parent | 73b5301b02c8d3456a5ea64c9ed9802a4a376af6 (diff) | |
parent | e47a682ace0cd56eb8e09b806c2b0f034b491520 (diff) |
Merge branch 'spi-linus' into spi-next
Diffstat (limited to 'drivers/spi/spi-omap2-mcspi.c')
-rw-r--r-- | drivers/spi/spi-omap2-mcspi.c | 39 |
1 files changed, 19 insertions, 20 deletions
diff --git a/drivers/spi/spi-omap2-mcspi.c b/drivers/spi/spi-omap2-mcspi.c index 51046332677c..643e7e27aa47 100644 --- a/drivers/spi/spi-omap2-mcspi.c +++ b/drivers/spi/spi-omap2-mcspi.c | |||
@@ -324,18 +324,13 @@ static void omap2_mcspi_tx_dma(struct spi_device *spi, | |||
324 | struct omap2_mcspi *mcspi; | 324 | struct omap2_mcspi *mcspi; |
325 | struct omap2_mcspi_dma *mcspi_dma; | 325 | struct omap2_mcspi_dma *mcspi_dma; |
326 | unsigned int count; | 326 | unsigned int count; |
327 | u8 * rx; | ||
328 | const u8 * tx; | 327 | const u8 * tx; |
329 | void __iomem *chstat_reg; | ||
330 | struct omap2_mcspi_cs *cs = spi->controller_state; | ||
331 | 328 | ||
332 | mcspi = spi_master_get_devdata(spi->master); | 329 | mcspi = spi_master_get_devdata(spi->master); |
333 | mcspi_dma = &mcspi->dma_channels[spi->chip_select]; | 330 | mcspi_dma = &mcspi->dma_channels[spi->chip_select]; |
334 | count = xfer->len; | 331 | count = xfer->len; |
335 | 332 | ||
336 | rx = xfer->rx_buf; | ||
337 | tx = xfer->tx_buf; | 333 | tx = xfer->tx_buf; |
338 | chstat_reg = cs->base + OMAP2_MCSPI_CHSTAT0; | ||
339 | 334 | ||
340 | if (mcspi_dma->dma_tx) { | 335 | if (mcspi_dma->dma_tx) { |
341 | struct dma_async_tx_descriptor *tx; | 336 | struct dma_async_tx_descriptor *tx; |
@@ -360,19 +355,6 @@ static void omap2_mcspi_tx_dma(struct spi_device *spi, | |||
360 | dma_async_issue_pending(mcspi_dma->dma_tx); | 355 | dma_async_issue_pending(mcspi_dma->dma_tx); |
361 | omap2_mcspi_set_dma_req(spi, 0, 1); | 356 | omap2_mcspi_set_dma_req(spi, 0, 1); |
362 | 357 | ||
363 | wait_for_completion(&mcspi_dma->dma_tx_completion); | ||
364 | dma_unmap_single(mcspi->dev, xfer->tx_dma, count, | ||
365 | DMA_TO_DEVICE); | ||
366 | |||
367 | /* for TX_ONLY mode, be sure all words have shifted out */ | ||
368 | if (rx == NULL) { | ||
369 | if (mcspi_wait_for_reg_bit(chstat_reg, | ||
370 | OMAP2_MCSPI_CHSTAT_TXS) < 0) | ||
371 | dev_err(&spi->dev, "TXS timed out\n"); | ||
372 | else if (mcspi_wait_for_reg_bit(chstat_reg, | ||
373 | OMAP2_MCSPI_CHSTAT_EOT) < 0) | ||
374 | dev_err(&spi->dev, "EOT timed out\n"); | ||
375 | } | ||
376 | } | 358 | } |
377 | 359 | ||
378 | static unsigned | 360 | static unsigned |
@@ -493,6 +475,7 @@ omap2_mcspi_txrx_dma(struct spi_device *spi, struct spi_transfer *xfer) | |||
493 | struct dma_slave_config cfg; | 475 | struct dma_slave_config cfg; |
494 | enum dma_slave_buswidth width; | 476 | enum dma_slave_buswidth width; |
495 | unsigned es; | 477 | unsigned es; |
478 | void __iomem *chstat_reg; | ||
496 | 479 | ||
497 | mcspi = spi_master_get_devdata(spi->master); | 480 | mcspi = spi_master_get_devdata(spi->master); |
498 | mcspi_dma = &mcspi->dma_channels[spi->chip_select]; | 481 | mcspi_dma = &mcspi->dma_channels[spi->chip_select]; |
@@ -527,8 +510,24 @@ omap2_mcspi_txrx_dma(struct spi_device *spi, struct spi_transfer *xfer) | |||
527 | omap2_mcspi_tx_dma(spi, xfer, cfg); | 510 | omap2_mcspi_tx_dma(spi, xfer, cfg); |
528 | 511 | ||
529 | if (rx != NULL) | 512 | if (rx != NULL) |
530 | return omap2_mcspi_rx_dma(spi, xfer, cfg, es); | 513 | count = omap2_mcspi_rx_dma(spi, xfer, cfg, es); |
531 | 514 | ||
515 | if (tx != NULL) { | ||
516 | chstat_reg = cs->base + OMAP2_MCSPI_CHSTAT0; | ||
517 | wait_for_completion(&mcspi_dma->dma_tx_completion); | ||
518 | dma_unmap_single(mcspi->dev, xfer->tx_dma, xfer->len, | ||
519 | DMA_TO_DEVICE); | ||
520 | |||
521 | /* for TX_ONLY mode, be sure all words have shifted out */ | ||
522 | if (rx == NULL) { | ||
523 | if (mcspi_wait_for_reg_bit(chstat_reg, | ||
524 | OMAP2_MCSPI_CHSTAT_TXS) < 0) | ||
525 | dev_err(&spi->dev, "TXS timed out\n"); | ||
526 | else if (mcspi_wait_for_reg_bit(chstat_reg, | ||
527 | OMAP2_MCSPI_CHSTAT_EOT) < 0) | ||
528 | dev_err(&spi->dev, "EOT timed out\n"); | ||
529 | } | ||
530 | } | ||
532 | return count; | 531 | return count; |
533 | } | 532 | } |
534 | 533 | ||