Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

spi: spi-sun4i: fix early activation

The SPI interface is activated before the CPOL setting is applied. In
that moment, the clock idles high and CS goes low. After a short delay,
CPOL and other settings are applied, which may cause the clock to change
state and idle low. This transition is not part of a clock cycle, and it
can confuse the receiving device.

To prevent this unexpected transition, activate the interface while CPOL
and the other settings are being applied.

Signed-off-by: Alessandro Grassi <alessandro.grassi@mailbox.org>
Link: https://patch.msgid.link/20250502095520.13825-1-alessandro.grassi@mailbox.org
Signed-off-by: Mark Brown <broonie@kernel.org>

authored by

Alessandro Grassi and committed by
Mark Brown
fb98bd0a e979a7c7

+4 -1
+4 -1
drivers/spi/spi-sun4i.c
··· 264 264 else 265 265 reg |= SUN4I_CTL_DHB; 266 266 267 + /* Now that the settings are correct, enable the interface */ 268 + reg |= SUN4I_CTL_ENABLE; 269 + 267 270 sun4i_spi_write(sspi, SUN4I_CTL_REG, reg); 268 271 269 272 /* Ensure that we have a parent clock fast enough */ ··· 407 404 } 408 405 409 406 sun4i_spi_write(sspi, SUN4I_CTL_REG, 410 - SUN4I_CTL_ENABLE | SUN4I_CTL_MASTER | SUN4I_CTL_TP); 407 + SUN4I_CTL_MASTER | SUN4I_CTL_TP); 411 408 412 409 return 0; 413 410