aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/spi/spi-tegra114.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/spi/spi-tegra114.c')
-rw-r--r--drivers/spi/spi-tegra114.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/drivers/spi/spi-tegra114.c b/drivers/spi/spi-tegra114.c
index e4a85ada861d..795bcbc0131b 100644
--- a/drivers/spi/spi-tegra114.c
+++ b/drivers/spi/spi-tegra114.c
@@ -302,6 +302,7 @@ static unsigned tegra_spi_fill_tx_fifo_from_client_txbuf(
302 max_n_32bit = DIV_ROUND_UP(nbytes, 4); 302 max_n_32bit = DIV_ROUND_UP(nbytes, 4);
303 for (count = 0; count < max_n_32bit; count++) { 303 for (count = 0; count < max_n_32bit; count++) {
304 u32 x = 0; 304 u32 x = 0;
305
305 for (i = 0; (i < 4) && nbytes; i++, nbytes--) 306 for (i = 0; (i < 4) && nbytes; i++, nbytes--)
306 x |= (u32)(*tx_buf++) << (i * 8); 307 x |= (u32)(*tx_buf++) << (i * 8);
307 tegra_spi_writel(tspi, x, SPI_TX_FIFO); 308 tegra_spi_writel(tspi, x, SPI_TX_FIFO);
@@ -312,6 +313,7 @@ static unsigned tegra_spi_fill_tx_fifo_from_client_txbuf(
312 nbytes = written_words * tspi->bytes_per_word; 313 nbytes = written_words * tspi->bytes_per_word;
313 for (count = 0; count < max_n_32bit; count++) { 314 for (count = 0; count < max_n_32bit; count++) {
314 u32 x = 0; 315 u32 x = 0;
316
315 for (i = 0; nbytes && (i < tspi->bytes_per_word); 317 for (i = 0; nbytes && (i < tspi->bytes_per_word);
316 i++, nbytes--) 318 i++, nbytes--)
317 x |= (u32)(*tx_buf++) << (i * 8); 319 x |= (u32)(*tx_buf++) << (i * 8);
@@ -338,6 +340,7 @@ static unsigned int tegra_spi_read_rx_fifo_to_client_rxbuf(
338 len = tspi->curr_dma_words * tspi->bytes_per_word; 340 len = tspi->curr_dma_words * tspi->bytes_per_word;
339 for (count = 0; count < rx_full_count; count++) { 341 for (count = 0; count < rx_full_count; count++) {
340 u32 x = tegra_spi_readl(tspi, SPI_RX_FIFO); 342 u32 x = tegra_spi_readl(tspi, SPI_RX_FIFO);
343
341 for (i = 0; len && (i < 4); i++, len--) 344 for (i = 0; len && (i < 4); i++, len--)
342 *rx_buf++ = (x >> i*8) & 0xFF; 345 *rx_buf++ = (x >> i*8) & 0xFF;
343 } 346 }
@@ -345,8 +348,10 @@ static unsigned int tegra_spi_read_rx_fifo_to_client_rxbuf(
345 read_words += tspi->curr_dma_words; 348 read_words += tspi->curr_dma_words;
346 } else { 349 } else {
347 u32 rx_mask = ((u32)1 << t->bits_per_word) - 1; 350 u32 rx_mask = ((u32)1 << t->bits_per_word) - 1;
351
348 for (count = 0; count < rx_full_count; count++) { 352 for (count = 0; count < rx_full_count; count++) {
349 u32 x = tegra_spi_readl(tspi, SPI_RX_FIFO) & rx_mask; 353 u32 x = tegra_spi_readl(tspi, SPI_RX_FIFO) & rx_mask;
354
350 for (i = 0; (i < tspi->bytes_per_word); i++) 355 for (i = 0; (i < tspi->bytes_per_word); i++)
351 *rx_buf++ = (x >> (i*8)) & 0xFF; 356 *rx_buf++ = (x >> (i*8)) & 0xFF;
352 } 357 }
@@ -365,6 +370,7 @@ static void tegra_spi_copy_client_txbuf_to_spi_txbuf(
365 370
366 if (tspi->is_packed) { 371 if (tspi->is_packed) {
367 unsigned len = tspi->curr_dma_words * tspi->bytes_per_word; 372 unsigned len = tspi->curr_dma_words * tspi->bytes_per_word;
373
368 memcpy(tspi->tx_dma_buf, t->tx_buf + tspi->cur_pos, len); 374 memcpy(tspi->tx_dma_buf, t->tx_buf + tspi->cur_pos, len);
369 } else { 375 } else {
370 unsigned int i; 376 unsigned int i;
@@ -374,6 +380,7 @@ static void tegra_spi_copy_client_txbuf_to_spi_txbuf(
374 380
375 for (count = 0; count < tspi->curr_dma_words; count++) { 381 for (count = 0; count < tspi->curr_dma_words; count++) {
376 u32 x = 0; 382 u32 x = 0;
383
377 for (i = 0; consume && (i < tspi->bytes_per_word); 384 for (i = 0; consume && (i < tspi->bytes_per_word);
378 i++, consume--) 385 i++, consume--)
379 x |= (u32)(*tx_buf++) << (i * 8); 386 x |= (u32)(*tx_buf++) << (i * 8);
@@ -396,6 +403,7 @@ static void tegra_spi_copy_spi_rxbuf_to_client_rxbuf(
396 403
397 if (tspi->is_packed) { 404 if (tspi->is_packed) {
398 unsigned len = tspi->curr_dma_words * tspi->bytes_per_word; 405 unsigned len = tspi->curr_dma_words * tspi->bytes_per_word;
406
399 memcpy(t->rx_buf + tspi->cur_rx_pos, tspi->rx_dma_buf, len); 407 memcpy(t->rx_buf + tspi->cur_rx_pos, tspi->rx_dma_buf, len);
400 } else { 408 } else {
401 unsigned int i; 409 unsigned int i;
@@ -405,6 +413,7 @@ static void tegra_spi_copy_spi_rxbuf_to_client_rxbuf(
405 413
406 for (count = 0; count < tspi->curr_dma_words; count++) { 414 for (count = 0; count < tspi->curr_dma_words; count++) {
407 u32 x = tspi->rx_dma_buf[count] & rx_mask; 415 u32 x = tspi->rx_dma_buf[count] & rx_mask;
416
408 for (i = 0; (i < tspi->bytes_per_word); i++) 417 for (i = 0; (i < tspi->bytes_per_word); i++)
409 *rx_buf++ = (x >> (i*8)) & 0xFF; 418 *rx_buf++ = (x >> (i*8)) & 0xFF;
410 } 419 }