Skip to content

Commit 4d9ca63

Browse files
Jon Linbroonie
authored andcommitted
spi: rockchip: Config spi rx dma burst size depend on xfer length
The burst length can be adjusted according to the transmission length to improve the transmission rate Signed-off-by: Jon Lin <[email protected]> Tested-by: Emil Renner Berthing <[email protected]> Reviewed-by: Emil Renner Berthing <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Mark Brown <[email protected]>
1 parent 15b413d commit 4d9ca63

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

drivers/spi/spi-rockchip.c

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -384,6 +384,19 @@ static void rockchip_spi_dma_txcb(void *data)
384384
spi_finalize_current_transfer(ctlr);
385385
}
386386

387+
static u32 rockchip_spi_calc_burst_size(u32 data_len)
388+
{
389+
u32 i;
390+
391+
/* burst size: 1, 2, 4, 8 */
392+
for (i = 1; i < 8; i <<= 1) {
393+
if (data_len & i)
394+
break;
395+
}
396+
397+
return i;
398+
}
399+
387400
static int rockchip_spi_prepare_dma(struct rockchip_spi *rs,
388401
struct spi_controller *ctlr, struct spi_transfer *xfer)
389402
{
@@ -397,7 +410,8 @@ static int rockchip_spi_prepare_dma(struct rockchip_spi *rs,
397410
.direction = DMA_DEV_TO_MEM,
398411
.src_addr = rs->dma_addr_rx,
399412
.src_addr_width = rs->n_bytes,
400-
.src_maxburst = 1,
413+
.src_maxburst = rockchip_spi_calc_burst_size(xfer->len /
414+
rs->n_bytes),
401415
};
402416

403417
dmaengine_slave_config(ctlr->dma_rx, &rxconf);
@@ -525,7 +539,8 @@ static void rockchip_spi_config(struct rockchip_spi *rs,
525539
writel_relaxed(rs->fifo_len / 2 - 1, rs->regs + ROCKCHIP_SPI_RXFTLR);
526540

527541
writel_relaxed(rs->fifo_len / 2, rs->regs + ROCKCHIP_SPI_DMATDLR);
528-
writel_relaxed(0, rs->regs + ROCKCHIP_SPI_DMARDLR);
542+
writel_relaxed(rockchip_spi_calc_burst_size(xfer->len / rs->n_bytes) - 1,
543+
rs->regs + ROCKCHIP_SPI_DMARDLR);
529544
writel_relaxed(dmacr, rs->regs + ROCKCHIP_SPI_DMACR);
530545

531546
/* the hardware only supports an even clock divisor, so

0 commit comments

Comments
 (0)