Blackfin SPI driver: fix bug SPI DMA incomplete transmission

SPI writes intermittently drop bytes at end of DMA transfer
http://blackfin.uclinux.org/gf/project/uclinux-dist/tracker/?action=TrackerItemEdit&tracker_item_id=3205
http://blackfin.uclinux.org/gf/project/uclinux-dist/tracker/?action=TrackerItemEdit&tracker_item_id=2892

Signed-off-by: Mike Frysinger <michael.frysinger@analog.com>
Signed-off-by: Bryan Wu <bryan.wu@analog.com>

Bryan Wu d6fe89b0 27bb9e79

+10 -5
+10 -5
drivers/spi/spi_bfin5xx.c
··· 582 582 dev_dbg(&drv_data->pdev->dev, "in dma_irq_handler\n"); 583 583 clear_dma_irqstat(CH_SPI); 584 584 585 + /* Wait for DMA to complete */ 586 + while (get_dma_curr_irqstat(CH_SPI) & DMA_RUN) 587 + continue; 588 + 585 589 /* 586 - * wait for the last transaction shifted out. yes, these two 587 - * while loops are supposed to be the same (see the HRM). 590 + * wait for the last transaction shifted out. HRM states: 591 + * at this point there may still be data in the SPI DMA FIFO waiting 592 + * to be transmitted ... software needs to poll TXS in the SPI_STAT 593 + * register until it goes low for 2 successive reads 588 594 */ 589 595 if (drv_data->tx != NULL) { 590 - while (bfin_read_SPI_STAT() & TXS) 591 - continue; 592 - while (bfin_read_SPI_STAT() & TXS) 596 + while ((bfin_read_SPI_STAT() & TXS) || 597 + (bfin_read_SPI_STAT() & TXS)) 593 598 continue; 594 599 } 595 600