diff options
author | Varun Wadekar <vwadekar@nvidia.com> | 2011-12-30 10:35:17 +0530 |
---|---|---|
committer | Varun Wadekar <vwadekar@nvidia.com> | 2011-12-30 10:35:17 +0530 |
commit | 9eb26f9e4036cb4c88594235f0704834708e1ad9 (patch) | |
tree | b46bae6ff3f8cd961f7e162b766a8e0980294aa0 /drivers/spi | |
parent | 16663701396134081324bbaf64d611d2e7682dd7 (diff) |
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 <kyarlagadda@nvidia.com>
Reviewed-on: http://git-master/r/70534
Reviewed-by: Automatic_Commit_Validation_User
Reviewed-by: Laxman Dewangan <ldewangan@nvidia.com>
Signed-off-by: Varun Wadekar <vwadekar@nvidia.com>
Diffstat (limited to 'drivers/spi')
-rw-r--r-- | drivers/spi/spi-tegra.c | 12 |
1 files changed, 12 insertions, 0 deletions
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; } |