Skip to content

Commit

Permalink
spi: spi-fsl-lpspi: Fix off-by-one in prescale max
Browse files Browse the repository at this point in the history
The commit 783bf5d ("spi: spi-fsl-lpspi: limit PRESCALE bit in
TCR register") doesn't implement the prescaler maximum as intended.
The maximum allowed value for i.MX93 should be 1 and for i.MX7ULP
it should be 7. So this needs also a adjustment of the comparison
in the scldiv calculation.

Fixes: 783bf5d ("spi: spi-fsl-lpspi: limit PRESCALE bit in TCR register")
Signed-off-by: Stefan Wahren <wahrenst@gmx.net>
Link: https://patch.msgid.link/20240905111537.90389-1-wahrenst@gmx.net
Signed-off-by: Mark Brown <broonie@kernel.org>
  • Loading branch information
Stefan Wahren authored and Mark Brown committed Sep 5, 2024
1 parent 5478a4f commit ff949d9
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions drivers/spi/spi-fsl-lpspi.c
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ static struct fsl_lpspi_devtype_data imx93_lpspi_devtype_data = {
};

static struct fsl_lpspi_devtype_data imx7ulp_lpspi_devtype_data = {
.prescale_max = 8,
.prescale_max = 7,
};

static const struct of_device_id fsl_lpspi_dt_ids[] = {
Expand Down Expand Up @@ -336,7 +336,7 @@ static int fsl_lpspi_set_bitrate(struct fsl_lpspi_data *fsl_lpspi)

div = DIV_ROUND_UP(perclk_rate, config.speed_hz);

for (prescale = 0; prescale < prescale_max; prescale++) {
for (prescale = 0; prescale <= prescale_max; prescale++) {
scldiv = div / (1 << prescale) - 2;
if (scldiv < 256) {
fsl_lpspi->config.prescale = prescale;
Expand Down

0 comments on commit ff949d9

Please sign in to comment.