Skip to content

Commit 765c243

Browse files
Larisa Grigoregregkh
authored andcommitted
spi: spi-fsl-lpspi: Clear status register after disabling the module
[ Upstream commit dedf9c9 ] Clear the error flags after disabling the module to avoid the case when a flag is set again between flag clear and module disable. And use SR_CLEAR_MASK to replace hardcoded value for improved readability. Although fsl_lpspi_reset() was only introduced in commit a15dc3d ("spi: lpspi: Fix CLK pin becomes low before one transfer"), the original driver only reset SR in the interrupt handler, making it vulnerable to the same issue. Therefore the fixes commit is set at the introduction of the driver. Fixes: 5314987 ("spi: imx: add lpspi bus driver") Signed-off-by: Larisa Grigore <larisa.grigore@nxp.com> Signed-off-by: Ciprian Marian Costea <ciprianmarian.costea@nxp.com> Reviewed-by: Frank Li <Frank.Li@nxp.com> Signed-off-by: James Clark <james.clark@linaro.org> Link: https://patch.msgid.link/20250828-james-nxp-lpspi-v2-4-6262b9aa9be4@linaro.org Signed-off-by: Mark Brown <broonie@kernel.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent 754f617 commit 765c243

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

drivers/spi/spi-fsl-lpspi.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,8 @@
8383
#define TCR_RXMSK BIT(19)
8484
#define TCR_TXMSK BIT(18)
8585

86+
#define SR_CLEAR_MASK GENMASK(13, 8)
87+
8688
struct fsl_lpspi_devtype_data {
8789
u8 prescale_max;
8890
};
@@ -536,14 +538,13 @@ static int fsl_lpspi_reset(struct fsl_lpspi_data *fsl_lpspi)
536538
fsl_lpspi_intctrl(fsl_lpspi, 0);
537539
}
538540

539-
/* W1C for all flags in SR */
540-
temp = 0x3F << 8;
541-
writel(temp, fsl_lpspi->base + IMX7ULP_SR);
542-
543541
/* Clear FIFO and disable module */
544542
temp = CR_RRF | CR_RTF;
545543
writel(temp, fsl_lpspi->base + IMX7ULP_CR);
546544

545+
/* W1C for all flags in SR */
546+
writel(SR_CLEAR_MASK, fsl_lpspi->base + IMX7ULP_SR);
547+
547548
return 0;
548549
}
549550

0 commit comments

Comments
 (0)