aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/spi/spi-omap2-mcspi.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/spi/spi-omap2-mcspi.c')
-rw-r--r--drivers/spi/spi-omap2-mcspi.c19
1 files changed, 12 insertions, 7 deletions
diff --git a/drivers/spi/spi-omap2-mcspi.c b/drivers/spi/spi-omap2-mcspi.c
index ed4af4708d9a..443df39840bc 100644
--- a/drivers/spi/spi-omap2-mcspi.c
+++ b/drivers/spi/spi-omap2-mcspi.c
@@ -276,7 +276,7 @@ static void omap2_mcspi_set_fifo(const struct spi_device *spi,
276 struct omap2_mcspi_cs *cs = spi->controller_state; 276 struct omap2_mcspi_cs *cs = spi->controller_state;
277 struct omap2_mcspi *mcspi; 277 struct omap2_mcspi *mcspi;
278 unsigned int wcnt; 278 unsigned int wcnt;
279 int fifo_depth, bytes_per_word; 279 int max_fifo_depth, fifo_depth, bytes_per_word;
280 u32 chconf, xferlevel; 280 u32 chconf, xferlevel;
281 281
282 mcspi = spi_master_get_devdata(master); 282 mcspi = spi_master_get_devdata(master);
@@ -287,7 +287,12 @@ static void omap2_mcspi_set_fifo(const struct spi_device *spi,
287 if (t->len % bytes_per_word != 0) 287 if (t->len % bytes_per_word != 0)
288 goto disable_fifo; 288 goto disable_fifo;
289 289
290 fifo_depth = gcd(t->len, OMAP2_MCSPI_MAX_FIFODEPTH); 290 if (t->rx_buf != NULL && t->tx_buf != NULL)
291 max_fifo_depth = OMAP2_MCSPI_MAX_FIFODEPTH / 2;
292 else
293 max_fifo_depth = OMAP2_MCSPI_MAX_FIFODEPTH;
294
295 fifo_depth = gcd(t->len, max_fifo_depth);
291 if (fifo_depth < 2 || fifo_depth % bytes_per_word != 0) 296 if (fifo_depth < 2 || fifo_depth % bytes_per_word != 0)
292 goto disable_fifo; 297 goto disable_fifo;
293 298
@@ -299,7 +304,8 @@ static void omap2_mcspi_set_fifo(const struct spi_device *spi,
299 if (t->rx_buf != NULL) { 304 if (t->rx_buf != NULL) {
300 chconf |= OMAP2_MCSPI_CHCONF_FFER; 305 chconf |= OMAP2_MCSPI_CHCONF_FFER;
301 xferlevel |= (fifo_depth - 1) << 8; 306 xferlevel |= (fifo_depth - 1) << 8;
302 } else { 307 }
308 if (t->tx_buf != NULL) {
303 chconf |= OMAP2_MCSPI_CHCONF_FFET; 309 chconf |= OMAP2_MCSPI_CHCONF_FFET;
304 xferlevel |= fifo_depth - 1; 310 xferlevel |= fifo_depth - 1;
305 } 311 }
@@ -498,7 +504,7 @@ omap2_mcspi_rx_dma(struct spi_device *spi, struct spi_transfer *xfer,
498 ((u32 *)xfer->rx_buf)[elements++] = w; 504 ((u32 *)xfer->rx_buf)[elements++] = w;
499 } else { 505 } else {
500 int bytes_per_word = mcspi_bytes_per_word(word_len); 506 int bytes_per_word = mcspi_bytes_per_word(word_len);
501 dev_err(&spi->dev, "DMA RX penultimate word empty"); 507 dev_err(&spi->dev, "DMA RX penultimate word empty\n");
502 count -= (bytes_per_word << 1); 508 count -= (bytes_per_word << 1);
503 omap2_mcspi_set_enable(spi, 1); 509 omap2_mcspi_set_enable(spi, 1);
504 return count; 510 return count;
@@ -516,7 +522,7 @@ omap2_mcspi_rx_dma(struct spi_device *spi, struct spi_transfer *xfer,
516 else /* word_len <= 32 */ 522 else /* word_len <= 32 */
517 ((u32 *)xfer->rx_buf)[elements] = w; 523 ((u32 *)xfer->rx_buf)[elements] = w;
518 } else { 524 } else {
519 dev_err(&spi->dev, "DMA RX last word empty"); 525 dev_err(&spi->dev, "DMA RX last word empty\n");
520 count -= mcspi_bytes_per_word(word_len); 526 count -= mcspi_bytes_per_word(word_len);
521 } 527 }
522 omap2_mcspi_set_enable(spi, 1); 528 omap2_mcspi_set_enable(spi, 1);
@@ -1407,7 +1413,7 @@ static int omap2_mcspi_probe(struct platform_device *pdev)
1407 if (status < 0) 1413 if (status < 0)
1408 goto disable_pm; 1414 goto disable_pm;
1409 1415
1410 status = spi_register_master(master); 1416 status = devm_spi_register_master(&pdev->dev, master);
1411 if (status < 0) 1417 if (status < 0)
1412 goto disable_pm; 1418 goto disable_pm;
1413 1419
@@ -1435,7 +1441,6 @@ static int omap2_mcspi_remove(struct platform_device *pdev)
1435 pm_runtime_put_sync(mcspi->dev); 1441 pm_runtime_put_sync(mcspi->dev);
1436 pm_runtime_disable(&pdev->dev); 1442 pm_runtime_disable(&pdev->dev);
1437 1443
1438 spi_unregister_master(master);
1439 kfree(dma_channels); 1444 kfree(dma_channels);
1440 1445
1441 return 0; 1446 return 0;