Message ID | 20240930093056.93418-4-wahrenst@gmx.net (mailing list archive) |
---|---|
State | In Next, archived |
Headers | show |
Series | spi: spi-fsl-lpspi: Some calculation improvements | expand |
On Mon, Sep 30, 2024 at 11:30:56AM +0200, Stefan Wahren wrote: > Setting spi_transfer->effective_speed_hz in transfer_one so that > SPI client driver can use it. > > Signed-off-by: Stefan Wahren <wahrenst@gmx.net> Reviewed-by: Frank Li <Frank.Li@nxp.com> > --- > drivers/spi/spi-fsl-lpspi.c | 6 ++++++ > 1 file changed, 6 insertions(+) > > diff --git a/drivers/spi/spi-fsl-lpspi.c b/drivers/spi/spi-fsl-lpspi.c > index 3b5aa91079ae..5d55ef4d4ba6 100644 > --- a/drivers/spi/spi-fsl-lpspi.c > +++ b/drivers/spi/spi-fsl-lpspi.c > @@ -92,6 +92,7 @@ struct lpspi_config { > u8 prescale; > u16 mode; > u32 speed_hz; > + u32 effective_speed_hz; > }; > > struct fsl_lpspi_data { > @@ -351,6 +352,9 @@ static int fsl_lpspi_set_bitrate(struct fsl_lpspi_data *fsl_lpspi) > writel(scldiv | (scldiv << 8) | ((scldiv >> 1) << 16), > fsl_lpspi->base + IMX7ULP_CCR); > > + fsl_lpspi->config.effective_speed_hz = perclk_rate / (scldiv + 2) * > + (1 << prescale); > + > dev_dbg(fsl_lpspi->dev, "perclk=%u, speed=%u, prescale=%u, scldiv=%d\n", > perclk_rate, config.speed_hz, prescale, scldiv); > > @@ -750,6 +754,8 @@ static int fsl_lpspi_transfer_one(struct spi_controller *controller, > if (ret < 0) > return ret; > > + t->effective_speed_hz = fsl_lpspi->config.effective_speed_hz; > + > fsl_lpspi_set_cmd(fsl_lpspi); > fsl_lpspi->is_first_byte = false; > > -- > 2.34.1 >
diff --git a/drivers/spi/spi-fsl-lpspi.c b/drivers/spi/spi-fsl-lpspi.c index 3b5aa91079ae..5d55ef4d4ba6 100644 --- a/drivers/spi/spi-fsl-lpspi.c +++ b/drivers/spi/spi-fsl-lpspi.c @@ -92,6 +92,7 @@ struct lpspi_config { u8 prescale; u16 mode; u32 speed_hz; + u32 effective_speed_hz; }; struct fsl_lpspi_data { @@ -351,6 +352,9 @@ static int fsl_lpspi_set_bitrate(struct fsl_lpspi_data *fsl_lpspi) writel(scldiv | (scldiv << 8) | ((scldiv >> 1) << 16), fsl_lpspi->base + IMX7ULP_CCR); + fsl_lpspi->config.effective_speed_hz = perclk_rate / (scldiv + 2) * + (1 << prescale); + dev_dbg(fsl_lpspi->dev, "perclk=%u, speed=%u, prescale=%u, scldiv=%d\n", perclk_rate, config.speed_hz, prescale, scldiv); @@ -750,6 +754,8 @@ static int fsl_lpspi_transfer_one(struct spi_controller *controller, if (ret < 0) return ret; + t->effective_speed_hz = fsl_lpspi->config.effective_speed_hz; + fsl_lpspi_set_cmd(fsl_lpspi); fsl_lpspi->is_first_byte = false;
Setting spi_transfer->effective_speed_hz in transfer_one so that SPI client driver can use it. Signed-off-by: Stefan Wahren <wahrenst@gmx.net> --- drivers/spi/spi-fsl-lpspi.c | 6 ++++++ 1 file changed, 6 insertions(+) -- 2.34.1