Skip to content

Commit 79a4ad7

Browse files
alessandro-g89opsiff
authored andcommitted
spi: spi-sun4i: fix early activation
[ Upstream commit fb98bd0 ] 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> Signed-off-by: Sasha Levin <sashal@kernel.org> (cherry picked from commit e99de950330510b0da9cb4a1e326ac3930c30a23)
1 parent 3ac83d3 commit 79a4ad7

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

drivers/spi/spi-sun4i.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,9 @@ static int sun4i_spi_transfer_one(struct spi_master *master,
263263
else
264264
reg |= SUN4I_CTL_DHB;
265265

266+
/* Now that the settings are correct, enable the interface */
267+
reg |= SUN4I_CTL_ENABLE;
268+
266269
sun4i_spi_write(sspi, SUN4I_CTL_REG, reg);
267270

268271
/* Ensure that we have a parent clock fast enough */
@@ -403,7 +406,7 @@ static int sun4i_spi_runtime_resume(struct device *dev)
403406
}
404407

405408
sun4i_spi_write(sspi, SUN4I_CTL_REG,
406-
SUN4I_CTL_ENABLE | SUN4I_CTL_MASTER | SUN4I_CTL_TP);
409+
SUN4I_CTL_MASTER | SUN4I_CTL_TP);
407410

408411
return 0;
409412

0 commit comments

Comments
 (0)