* [PATCH v2] spi: omap2-mcspi: Ensure that CS is correctly asserted when switching from MULTI mode to SINGLE mode
@ 2024-05-06 14:27 Louis Chauvet
2024-05-06 14:53 ` Miquel Raynal
0 siblings, 1 reply; 2+ messages in thread
From: Louis Chauvet @ 2024-05-06 14:27 UTC (permalink / raw)
To: Mark Brown
Cc: linux-spi, linux-kernel, miquel.raynal, thomas.petazzoni,
yen-mei.goh, jeremie.dautheribes, Louis Chauvet
The OMAP2 support features a "multi" mode, where the controller
automatically sets the Chip Select (CS) when necessary. This mode allows
for shorter delays between CS selection and word content, but the CS is
always deasserted at the end.
The default transfer_one_message function expects the last transfer of a
message to keep the CS enabled. However, when two consecutive messages
use "multi" mode followed by "single" mode, the chipselect is not enabled
during the second message. This discrepancy causes the driver to time
out.
To address this issue, the CS is now reasserted for each new message that
follows a "multi"-mode message. This change ensures proper CS handling
and prevents driver timeouts.
Fixes: d153ff4056cb ("spi: omap2-mcspi: Add support for MULTI-mode")
Signed-off-by: Louis Chauvet <louis.chauvet@bootlin.com>
---
Changes in v2:
- Fix build error, I used the old API (master instead of controller)
- Link to v1: https://lore.kernel.org/r/20240409-fix-omap2-mcspi-v1-1-f2b881ae196d@bootlin.com
---
drivers/spi/spi-omap2-mcspi.c | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/drivers/spi/spi-omap2-mcspi.c b/drivers/spi/spi-omap2-mcspi.c
index 7e3083b83534..dd514a7504ec 100644
--- a/drivers/spi/spi-omap2-mcspi.c
+++ b/drivers/spi/spi-omap2-mcspi.c
@@ -1264,6 +1264,15 @@ static int omap2_mcspi_prepare_message(struct spi_controller *ctlr,
struct spi_transfer *tr;
u8 bits_per_word;
+ /*
+ * When the last transfer used multi-mode, the CS is not keep down by the controller.
+ * The default transfer_one_message expect that the last transfer of a message keep the CS
+ * active.
+ * Ensure that the next call to spi_set_cs will work as expected if single-mode is used.
+ */
+ if (mcspi->use_multi_mode)
+ ctlr->last_cs[0] = -1;
+
/*
* The conditions are strict, it is mandatory to check each transfer of the list to see if
* multi-mode is applicable.
---
base-commit: dfca7eb7615116b696ecdc85417c9e2df0b546dc
change-id: 20240408-fix-omap2-mcspi-a6b41142ad9a
Best regards,
--
Louis Chauvet <louis.chauvet@bootlin.com>
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH v2] spi: omap2-mcspi: Ensure that CS is correctly asserted when switching from MULTI mode to SINGLE mode
2024-05-06 14:27 [PATCH v2] spi: omap2-mcspi: Ensure that CS is correctly asserted when switching from MULTI mode to SINGLE mode Louis Chauvet
@ 2024-05-06 14:53 ` Miquel Raynal
0 siblings, 0 replies; 2+ messages in thread
From: Miquel Raynal @ 2024-05-06 14:53 UTC (permalink / raw)
To: Louis Chauvet
Cc: Mark Brown, linux-spi, linux-kernel, thomas.petazzoni,
yen-mei.goh, jeremie.dautheribes
Hi Louis,
Minor nits below.
louis.chauvet@bootlin.com wrote on Mon, 06 May 2024 16:27:59 +0200:
> The OMAP2 support features a "multi" mode, where the controller
s/The //
> automatically sets the Chip Select (CS) when necessary. This mode allows
> for shorter delays between CS selection and word content, but the CS is
> always deasserted at the end.
>
> The default transfer_one_message function expects the last transfer of a
> message to keep the CS enabled. However, when two consecutive messages
> use "multi" mode followed by "single" mode, the chipselect is not enabled
Above you wrote Chip Select and CS, maybe you want to reuse one of them
to be more consistent?
> during the second message. This discrepancy causes the driver to time
> out.
>
> To address this issue, the CS is now reasserted for each new message that
needs to be
> follows a "multi"-mode message. This change ensures proper CS handling
> and prevents driver timeouts.
>
> Fixes: d153ff4056cb ("spi: omap2-mcspi: Add support for MULTI-mode")
>
No new line needed here, but more importantly, I see no valid Git object
with this hash, can you double check?
> Signed-off-by: Louis Chauvet <louis.chauvet@bootlin.com>
> ---
> Changes in v2:
> - Fix build error, I used the old API (master instead of controller)
> - Link to v1: https://lore.kernel.org/r/20240409-fix-omap2-mcspi-v1-1-f2b881ae196d@bootlin.com
> ---
> drivers/spi/spi-omap2-mcspi.c | 9 +++++++++
> 1 file changed, 9 insertions(+)
>
> diff --git a/drivers/spi/spi-omap2-mcspi.c b/drivers/spi/spi-omap2-mcspi.c
> index 7e3083b83534..dd514a7504ec 100644
> --- a/drivers/spi/spi-omap2-mcspi.c
> +++ b/drivers/spi/spi-omap2-mcspi.c
> @@ -1264,6 +1264,15 @@ static int omap2_mcspi_prepare_message(struct spi_controller *ctlr,
> struct spi_transfer *tr;
> u8 bits_per_word;
>
> + /*
> + * When the last transfer used multi-mode, the CS is not keep down by the controller.
If the kept
> + * The default transfer_one_message expect that the last transfer of a message keep the CS
expects keeps
> + * active.
> + * Ensure that the next call to spi_set_cs will work as expected if single-mode is used.
> + */
> + if (mcspi->use_multi_mode)
> + ctlr->last_cs[0] = -1;
Maybe you should use SPI_INVALID_CS?
> +
> /*
> * The conditions are strict, it is mandatory to check each transfer of the list to see if
> * multi-mode is applicable.
>
> ---
> base-commit: dfca7eb7615116b696ecdc85417c9e2df0b546dc
> change-id: 20240408-fix-omap2-mcspi-a6b41142ad9a
>
> Best regards,
Thanks,
Miquèl
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2024-05-06 14:53 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-05-06 14:27 [PATCH v2] spi: omap2-mcspi: Ensure that CS is correctly asserted when switching from MULTI mode to SINGLE mode Louis Chauvet
2024-05-06 14:53 ` Miquel Raynal
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).