* [PATCH] spi: spi-sun4i: fix early activation
@ 2024-11-01 18:40 Alessandro Grassi
0 siblings, 0 replies; 3+ messages in thread
From: Alessandro Grassi @ 2024-11-01 18:40 UTC (permalink / raw)
To: linux-spi; +Cc: Alessandro Grassi
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>
---
drivers/spi/spi-sun4i.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/drivers/spi/spi-sun4i.c b/drivers/spi/spi-sun4i.c
index fcbe864c9b7d..4b070377e3d1 100644
--- a/drivers/spi/spi-sun4i.c
+++ b/drivers/spi/spi-sun4i.c
@@ -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;
--
2.45.2
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCH] spi: spi-sun4i: fix early activation
@ 2025-05-02 9:55 Alessandro Grassi
2025-05-15 7:35 ` Mark Brown
0 siblings, 1 reply; 3+ messages in thread
From: Alessandro Grassi @ 2025-05-02 9:55 UTC (permalink / raw)
To: broonie; +Cc: linux-spi, Alessandro Grassi
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>
---
drivers/spi/spi-sun4i.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/drivers/spi/spi-sun4i.c b/drivers/spi/spi-sun4i.c
index f89826d7dc49..aa92fd5a35a9 100644
--- a/drivers/spi/spi-sun4i.c
+++ b/drivers/spi/spi-sun4i.c
@@ -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;
--
2.47.2
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] spi: spi-sun4i: fix early activation
2025-05-02 9:55 Alessandro Grassi
@ 2025-05-15 7:35 ` Mark Brown
0 siblings, 0 replies; 3+ messages in thread
From: Mark Brown @ 2025-05-15 7:35 UTC (permalink / raw)
To: Alessandro Grassi; +Cc: linux-spi
On Fri, 02 May 2025 11:55:20 +0200, Alessandro Grassi wrote:
> 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.
>
> [...]
Applied to
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi.git for-next
Thanks!
[1/1] spi: spi-sun4i: fix early activation
commit: fb98bd0a13de2c9d96cb5c00c81b5ca118ac9d71
All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.
You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.
If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.
Please add any relevant lists and maintainers to the CCs when replying
to this mail.
Thanks,
Mark
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2025-05-15 7:35 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-11-01 18:40 [PATCH] spi: spi-sun4i: fix early activation Alessandro Grassi
-- strict thread matches above, loose matches on Subject: below --
2025-05-02 9:55 Alessandro Grassi
2025-05-15 7:35 ` Mark Brown
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).