Linux-SPI Archive mirror
 help / color / mirror / Atom feed
From: Heikki Keranen <heikki.keranen@bittium.com>
To: broonie@kernel.org
Cc: linux-spi@vger.kernel.org,
	Heikki Keranen <heikki.keranen@bittium.com>,
	Petri Tauriainen <petri.tauriainen@bittium.com>
Subject: [PATCH] spi: mux: Fix master controller settings after mux select
Date: Mon, 22 Apr 2024 14:41:50 +0300	[thread overview]
Message-ID: <20240422114150.84426-1-heikki.keranen@bittium.com> (raw)

In some cases SPI child devices behind spi-mux require different
settings like: max_speed_hz, mode and bits_per_word.

Typically the slave device driver puts the settings in place and calls
spi_setup() once during probe and assumes they stay in place for all
following spi transfers.

However spi-mux forwarded spi_setup() -call to SPI master driver only
when slave driver calls spi_setup(). If second slave device was
accessed meanwhile and that driver called spi_setup(), the
settings did not change back to the first spi device.
In case of wrong max_speed_hz this caused spi trasfers to fail.

This commit adds spi_setup() call after mux is changed. This way
the right device specific parameters are set to the master driver.

The fix has been tested by using custom hardware and debugging
spi master driver speed settings.

Co-authored-by: Petri Tauriainen <petri.tauriainen@bittium.com>
Signed-off-by: Heikki Keranen <heikki.keranen@bittium.com>
---
 drivers/spi/spi-mux.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/spi/spi-mux.c b/drivers/spi/spi-mux.c
index bd988f53753e..5d72e3d59df8 100644
--- a/drivers/spi/spi-mux.c
+++ b/drivers/spi/spi-mux.c
@@ -68,6 +68,8 @@ static int spi_mux_select(struct spi_device *spi)
 
 	priv->current_cs = spi_get_chipselect(spi, 0);
 
+	spi_setup(priv->spi);
+
 	return 0;
 }
 
-- 
2.39.2


             reply	other threads:[~2024-04-22 11:57 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-22 11:41 Heikki Keranen [this message]
2024-04-23  5:20 ` [PATCH] spi: mux: Fix master controller settings after mux select Mark Brown
2024-04-23 10:45 ` Andy Shevchenko
2024-04-24 11:16   ` [PATCH v2] " Heikki Keranen
2024-04-24 12:54     ` Andy Shevchenko
2024-04-24 13:52     ` Mark Brown

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240422114150.84426-1-heikki.keranen@bittium.com \
    --to=heikki.keranen@bittium.com \
    --cc=broonie@kernel.org \
    --cc=linux-spi@vger.kernel.org \
    --cc=petri.tauriainen@bittium.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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 read-only IMAP folder(s) and NNTP newsgroup(s).