linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] spi: fsl: fix use of spisel_boot signal on MPC8309
@ 2020-11-27 15:29 Rasmus Villemoes
  2020-11-30 16:56 ` Mark Brown
  0 siblings, 1 reply; 2+ messages in thread
From: Rasmus Villemoes @ 2020-11-27 15:29 UTC (permalink / raw)
  To: Mark Brown, linux-spi
  Cc: linux-kernel, Rasmus Villemoes, stable, Christophe Leroy, Linus Walleij

Commit 0f0581b24bd0 ("spi: fsl: Convert to use CS GPIO descriptors")
broke the use of the SPISEL_BOOT signal as a chip select on the
MPC8309.

pdata->max_chipselect, which becomes master->num_chipselect, must be
initialized to take into account the possibility that there's one more
chip select in use than the number of GPIO chip selects.

Cc: stable@vger.kernel.org # v5.4+
Cc: Christophe Leroy <christophe.leroy@c-s.fr>
Cc: Linus Walleij <linus.walleij@linaro.org>
Fixes: 0f0581b24bd0 ("spi: fsl: Convert to use CS GPIO descriptors")
Signed-off-by: Rasmus Villemoes <rasmus.villemoes@prevas.dk>
---
Longer-term, it might be nicer to introduce a very trivial "gpiochip"
with nr_gpios=1, which doesn't really implement neither the
"general-purpose" nor the "input" part of the gpio acronym. That's how
this ended up being handled in U-Boot, for example:

https://github.com/u-boot/u-boot/commit/3fb22bc2f825ea1b3326edc5b32d711a759a265f

But for -stable, this is much simpler.

 drivers/spi/spi-fsl-spi.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/drivers/spi/spi-fsl-spi.c b/drivers/spi/spi-fsl-spi.c
index 299e9870cf58..9494257e1c33 100644
--- a/drivers/spi/spi-fsl-spi.c
+++ b/drivers/spi/spi-fsl-spi.c
@@ -716,10 +716,11 @@ static int of_fsl_spi_probe(struct platform_device *ofdev)
 	type = fsl_spi_get_type(&ofdev->dev);
 	if (type == TYPE_FSL) {
 		struct fsl_spi_platform_data *pdata = dev_get_platdata(dev);
+		bool spisel_boot = false;
 #if IS_ENABLED(CONFIG_FSL_SOC)
 		struct mpc8xxx_spi_probe_info *pinfo = to_of_pinfo(pdata);
-		bool spisel_boot = of_property_read_bool(np, "fsl,spisel_boot");
 
+		spisel_boot = of_property_read_bool(np, "fsl,spisel_boot");
 		if (spisel_boot) {
 			pinfo->immr_spi_cs = ioremap(get_immrbase() + IMMR_SPI_CS_OFFSET, 4);
 			if (!pinfo->immr_spi_cs)
@@ -734,10 +735,14 @@ static int of_fsl_spi_probe(struct platform_device *ofdev)
 		 * supported on the GRLIB variant.
 		 */
 		ret = gpiod_count(dev, "cs");
-		if (ret <= 0)
+		if (ret < 0)
+			ret = 0;
+		if (ret == 0 && !spisel_boot) {
 			pdata->max_chipselect = 1;
-		else
+		} else {
+			pdata->max_chipselect = ret + spisel_boot;
 			pdata->cs_control = fsl_spi_cs_control;
+		}
 	}
 
 	ret = of_address_to_resource(np, 0, &mem);
-- 
2.23.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] spi: fsl: fix use of spisel_boot signal on MPC8309
  2020-11-27 15:29 [PATCH] spi: fsl: fix use of spisel_boot signal on MPC8309 Rasmus Villemoes
@ 2020-11-30 16:56 ` Mark Brown
  0 siblings, 0 replies; 2+ messages in thread
From: Mark Brown @ 2020-11-30 16:56 UTC (permalink / raw)
  To: Rasmus Villemoes, linux-spi
  Cc: Christophe Leroy, stable, Linus Walleij, linux-kernel

On Fri, 27 Nov 2020 16:29:47 +0100, Rasmus Villemoes wrote:
> Commit 0f0581b24bd0 ("spi: fsl: Convert to use CS GPIO descriptors")
> broke the use of the SPISEL_BOOT signal as a chip select on the
> MPC8309.
> 
> pdata->max_chipselect, which becomes master->num_chipselect, must be
> initialized to take into account the possibility that there's one more
> chip select in use than the number of GPIO chip selects.

Applied to

   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi.git for-next

Thanks!

[1/1] spi: fsl: fix use of spisel_boot signal on MPC8309
      commit: 122541f2b10897b08f7f7e6db5f1eb693e51f0a1

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] 2+ messages in thread

end of thread, other threads:[~2020-11-30 16:57 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-27 15:29 [PATCH] spi: fsl: fix use of spisel_boot signal on MPC8309 Rasmus Villemoes
2020-11-30 16:56 ` 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).