]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commitdiff
spi: rockchip: configure CTRLR1 according to size and data frame
authorHuibin Hong <huibin.hong@rock-chips.com>
Wed, 16 Aug 2017 02:12:02 +0000 (10:12 +0800)
committerMark Brown <broonie@kernel.org>
Wed, 16 Aug 2017 10:58:23 +0000 (11:58 +0100)
CTRLR1 is number of data frames, when rx only.
When data frame is 8 bit, CTRLR1 is len-1.
When data frame is 16 bit, CTRLR1 is (len/2)-1.

Signed-off-by: Huibin Hong <huibin.hong@rock-chips.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
drivers/spi/spi-rockchip.c

index 474033e2149e7abf8faa1b5eeae9cbfc7ff67a4e..fdcf3076681b5eeffb1885b428c8d00ff2682d2f 100644 (file)
@@ -568,7 +568,13 @@ static void rockchip_spi_config(struct rockchip_spi *rs)
 
        writel_relaxed(cr0, rs->regs + ROCKCHIP_SPI_CTRLR0);
 
-       writel_relaxed(rs->len - 1, rs->regs + ROCKCHIP_SPI_CTRLR1);
+       if (rs->n_bytes == 1)
+               writel_relaxed(rs->len - 1, rs->regs + ROCKCHIP_SPI_CTRLR1);
+       else if (rs->n_bytes == 2)
+               writel_relaxed((rs->len / 2) - 1, rs->regs + ROCKCHIP_SPI_CTRLR1);
+       else
+               writel_relaxed((rs->len * 2) - 1, rs->regs + ROCKCHIP_SPI_CTRLR1);
+
        writel_relaxed(rs->fifo_len / 2 - 1, rs->regs + ROCKCHIP_SPI_TXFTLR);
        writel_relaxed(rs->fifo_len / 2 - 1, rs->regs + ROCKCHIP_SPI_RXFTLR);