Skip to content

Commit ff949d9

Browse files
lategoodbyebroonie
authored andcommitted
spi: spi-fsl-lpspi: Fix off-by-one in prescale max
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 <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Mark Brown <[email protected]>
1 parent 5478a4f commit ff949d9

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

drivers/spi/spi-fsl-lpspi.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ static struct fsl_lpspi_devtype_data imx93_lpspi_devtype_data = {
136136
};
137137

138138
static struct fsl_lpspi_devtype_data imx7ulp_lpspi_devtype_data = {
139-
.prescale_max = 8,
139+
.prescale_max = 7,
140140
};
141141

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

337337
div = DIV_ROUND_UP(perclk_rate, config.speed_hz);
338338

339-
for (prescale = 0; prescale < prescale_max; prescale++) {
339+
for (prescale = 0; prescale <= prescale_max; prescale++) {
340340
scldiv = div / (1 << prescale) - 2;
341341
if (scldiv < 256) {
342342
fsl_lpspi->config.prescale = prescale;

0 commit comments

Comments
 (0)