aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/spi/spi_fsl_espi.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/spi/spi_fsl_espi.c')
-rw-r--r--drivers/spi/spi_fsl_espi.c19
1 files changed, 16 insertions, 3 deletions
diff --git a/drivers/spi/spi_fsl_espi.c b/drivers/spi/spi_fsl_espi.c
index e3b4f6451966..ae789262c981 100644
--- a/drivers/spi/spi_fsl_espi.c
+++ b/drivers/spi/spi_fsl_espi.c
@@ -507,16 +507,29 @@ void fsl_espi_cpu_irq(struct mpc8xxx_spi *mspi, u32 events)
507 507
508 /* We need handle RX first */ 508 /* We need handle RX first */
509 if (events & SPIE_NE) { 509 if (events & SPIE_NE) {
510 u32 rx_data; 510 u32 rx_data, tmp;
511 u8 rx_data_8;
511 512
512 /* Spin until RX is done */ 513 /* Spin until RX is done */
513 while (SPIE_RXCNT(events) < min(4, mspi->len)) { 514 while (SPIE_RXCNT(events) < min(4, mspi->len)) {
514 cpu_relax(); 515 cpu_relax();
515 events = mpc8xxx_spi_read_reg(&reg_base->event); 516 events = mpc8xxx_spi_read_reg(&reg_base->event);
516 } 517 }
517 mspi->len -= 4;
518 518
519 rx_data = mpc8xxx_spi_read_reg(&reg_base->receive); 519 if (mspi->len >= 4) {
520 rx_data = mpc8xxx_spi_read_reg(&reg_base->receive);
521 } else {
522 tmp = mspi->len;
523 rx_data = 0;
524 while (tmp--) {
525 rx_data_8 = in_8((u8 *)&reg_base->receive);
526 rx_data |= (rx_data_8 << (tmp * 8));
527 }
528
529 rx_data <<= (4 - mspi->len) * 8;
530 }
531
532 mspi->len -= 4;
520 533
521 if (mspi->rx) 534 if (mspi->rx)
522 mspi->get_rx(rx_data, mspi); 535 mspi->get_rx(rx_data, mspi);