• Daniel Kurtz's avatar
    spi: mediatek: Only do dma for 4-byte aligned buffers · 1ce24864
    Daniel Kurtz authored
    Mediatek SPI DMA only works when tx and rx buffer addresses are 4-byte
    aligned.
    
    Unaligned DMA transactions appeared to work previously, since we the
    spi core was incorrectly using the spi_master device for dma, which
    had a 0 dma_mask, and therefore the swiotlb dma map operations were
    falling back to using bounce buffers.  Since each DMA transaction would
    use its own buffer, the mapped starting address of each transaction was
    always aligned.  When doing real DMA, the mapped address will share the
    alignment of the raw tx/rx buffer provided by the SPI user, which may or
    may not be aligned.
    
    If a buffer is not aligned, we cannot use DMA, and must use FIFO based
    transaction instead.
    
    So, this patch implements a scheme that allows using the FIFO for
    arbitrary length transactions (larger than the 32-byte FIFO size) by
    reloading the FIFO in the interrupt handler.
    Signed-off-by: default avatarDaniel Kurtz <djkurtz@chromium.org>
    Cc: Leilk Liu <leilk.liu@mediatek.com>
    Signed-off-by: default avatarMark Brown <broonie@kernel.org>
    1ce24864
spi-mt65xx.c 20.9 KB