From 9eb26f9e4036cb4c88594235f0704834708e1ad9 Mon Sep 17 00:00:00 2001 From: Varun Wadekar Date: Fri, 30 Dec 2011 10:35:17 +0530 Subject: SPI: tegra: Pass rx data only to req bit length When fifo is read, it can contain valid data bits and random bits in rest of the fifo. Reading only valid bits from fifo and resetting rest to zero before sending to client. Change-Id: I961279048aada6087b323ab6730bf72706730917 Signed-off-by: Krishna Yarlagadda Reviewed-on: http://git-master/r/70534 Reviewed-by: Automatic_Commit_Validation_User Reviewed-by: Laxman Dewangan Signed-off-by: Varun Wadekar --- drivers/spi/spi-tegra.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'drivers/spi') diff --git a/drivers/spi/spi-tegra.c b/drivers/spi/spi-tegra.c index e1741cd20295..38cb8d11562d 100644 --- a/drivers/spi/spi-tegra.c +++ b/drivers/spi/spi-tegra.c @@ -407,8 +407,14 @@ static unsigned int spi_tegra_read_rx_fifo_to_client_rxbuf( tspi->cur_rx_pos += tspi->curr_dma_words * tspi->bytes_per_word; read_words += tspi->curr_dma_words; } else { + unsigned int rx_mask, bits_per_word; + + bits_per_word = t->bits_per_word ? t->bits_per_word : + tspi->cur_spi->bits_per_word; + rx_mask = (1 << bits_per_word) -1; for (count = 0; count < rx_full_count; ++count) { x = spi_tegra_readl(tspi, SLINK_RX_FIFO); + x &= rx_mask; for (i = 0; (i < tspi->bytes_per_word); ++i) *rx_buf++ = (x >> (i*8)) & 0xFF; } @@ -455,8 +461,14 @@ static void spi_tegra_copy_spi_rxbuf_to_client_rxbuf( unsigned int count; unsigned char *rx_buf = t->rx_buf + tspi->cur_rx_pos; unsigned int x; + unsigned int rx_mask, bits_per_word; + + bits_per_word = t->bits_per_word ? t->bits_per_word : + tspi->cur_spi->bits_per_word; + rx_mask = (1 << bits_per_word) -1; for (count = 0; count < tspi->curr_dma_words; ++count) { x = tspi->rx_buf[count]; + x &= rx_mask; for (i = 0; (i < tspi->bytes_per_word); ++i) *rx_buf++ = (x >> (i*8)) & 0xFF; } -- cgit v1.2.3