]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
spi: spi-sun4i: fix early activation
authorAlessandro Grassi <alessandro.grassi@mailbox.org>
Fri, 2 May 2025 09:55:20 +0000 (11:55 +0200)
committerMark Brown <broonie@kernel.org>
Wed, 14 May 2025 08:56:43 +0000 (10:56 +0200)
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>
drivers/spi/spi-sun4i.c

index f89826d7dc4964f9ca0568cd265b46d0e62bc829..aa92fd5a35a98f440936b7322c409ca53df9de5f 100644 (file)
@@ -264,6 +264,9 @@ static int sun4i_spi_transfer_one(struct spi_controller *host,
        else
                reg |= SUN4I_CTL_DHB;
 
+       /* Now that the settings are correct, enable the interface */
+       reg |= SUN4I_CTL_ENABLE;
+
        sun4i_spi_write(sspi, SUN4I_CTL_REG, reg);
 
        /* Ensure that we have a parent clock fast enough */
@@ -404,7 +407,7 @@ static int sun4i_spi_runtime_resume(struct device *dev)
        }
 
        sun4i_spi_write(sspi, SUN4I_CTL_REG,
-                       SUN4I_CTL_ENABLE | SUN4I_CTL_MASTER | SUN4I_CTL_TP);
+                       SUN4I_CTL_MASTER | SUN4I_CTL_TP);
 
        return 0;