diff options
author | Nicolò Veronese | 2023-10-04 00:14:26 +0200 |
---|---|---|
committer | Tom Rini | 2023-10-11 13:21:33 -0400 |
commit | 538b97dd5d6be8206b532664cf616c567434368d (patch) | |
tree | 96bd39b7be08994cc1ee7f2f49fd8936498ece16 | |
parent | 20535a3369d9ca3e3d6dd880c5fa23115a8b3fbd (diff) |
spi: mtk_spim: prevent global pll clock override
With commit 793e62301180 ("spi: mtk_spim: get spi clk rate only once") a
new system to calculate the SPI clocks has been added.
Unfortunately, the do_div macro overrides the global priv->pll_clk_rate
field. This will cause to have a reduced clock rate on each subsequent
SPI call.
Signed-off-by: Valerio 'ftp21' Mancini <ftp21@ftp21.eu>
Signed-off-by: Nicolò Veronese <nicveronese@gmail.com>
-rw-r--r-- | drivers/spi/mtk_spim.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/drivers/spi/mtk_spim.c b/drivers/spi/mtk_spim.c index 418e586b91d..90f4c3cecb9 100644 --- a/drivers/spi/mtk_spim.c +++ b/drivers/spi/mtk_spim.c @@ -409,7 +409,7 @@ static int mtk_spim_transfer_wait(struct spi_slave *slave, { struct udevice *bus = dev_get_parent(slave->dev); struct mtk_spim_priv *priv = dev_get_priv(bus); - u32 sck_l, sck_h, clk_count, reg; + u32 pll_clk, sck_l, sck_h, clk_count, reg; ulong us = 1; int ret = 0; @@ -418,11 +418,12 @@ static int mtk_spim_transfer_wait(struct spi_slave *slave, else clk_count = op->data.nbytes; + pll_clk = priv->pll_clk_rate; sck_l = readl(priv->base + SPI_CFG2_REG) >> SPI_CFG2_SCK_LOW_OFFSET; sck_h = readl(priv->base + SPI_CFG2_REG) & SPI_CFG2_SCK_HIGH_MASK; - do_div(priv->pll_clk_rate, sck_l + sck_h + 2); + do_div(pll_clk, sck_l + sck_h + 2); - us = CLK_TO_US(priv->pll_clk_rate, clk_count * 8); + us = CLK_TO_US(pll_clk, clk_count * 8); us += 1000 * 1000; /* 1s tolerance */ if (us > UINT_MAX) |