diff mbox

spi: rockchip: configure CTRLR1 according to size and data frame

Message ID 1502849522-10073-1-git-send-email-huibin.hong@rock-chips.com (mailing list archive)
State Accepted
Commit 04b37d2d02c0a5ae2f4e59326ef6deaff18e0456
Headers show

Commit Message

Huibin Hong Aug. 16, 2017, 2:12 a.m. UTC
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>
---

 drivers/spi/spi-rockchip.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

Comments

Geert Uytterhoeven Aug. 16, 2017, 12:16 p.m. UTC | #1
Hi Huibin,

On Wed, Aug 16, 2017 at 4:12 AM, Huibin Hong <huibin.hong@rock-chips.com> wrote:
> 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.

What does the last "else" case correspond to?

> Signed-off-by: Huibin Hong <huibin.hong@rock-chips.com>
> ---
>
>  drivers/spi/spi-rockchip.c | 8 +++++++-
>  1 file changed, 7 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/spi/spi-rockchip.c b/drivers/spi/spi-rockchip.c
> index 0b4a52b..6b1bac8 100644
> --- a/drivers/spi/spi-rockchip.c
> +++ b/drivers/spi/spi-rockchip.c
> @@ -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);

Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds
--
To unsubscribe from this list: send the line "unsubscribe linux-spi" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/drivers/spi/spi-rockchip.c b/drivers/spi/spi-rockchip.c
index 0b4a52b..6b1bac8 100644
--- a/drivers/spi/spi-rockchip.c
+++ b/drivers/spi/spi-rockchip.c
@@ -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);