Unverified Commit 7251953d authored by Linus Walleij's avatar Linus Walleij Committed by Mark Brown
Browse files

spi: fsl: Handle the single hardwired chipselect case



The Freescale MPC8xxx had a special quirk for handling a
single hardwired chipselect, the case when we're using neither
GPIO nor native chip select: when inspecting the device tree
and finding zero "cs-gpios" on the device node the code would
assume we have a single hardwired chipselect that leaves the
device always selected.

This quirk is not handled by the new core code, so we need
to check the "cs-gpios" explicitly in the driver and set
pdata->max_chipselect = 1 which will later fall through to
the SPI master ->num_chipselect.

Make sure not to assign the chip select handler in this
case: there is no handling needed since the chip is always
selected, and this is what the old code did as well.

Cc: Christophe Leroy <christophe.leroy@c-s.fr>
Reported-by: default avatarChristophe Leroy <christophe.leroy@c-s.fr>
Fixes: 0f0581b2 ("spi: fsl: Convert to use CS GPIO descriptors")
Signed-off-by: default avatarLinus Walleij <linus.walleij@linaro.org>
Tested-by: Christophe Leroy <christophe.leroy@c-s.fr> (No tested the
Link: https://lore.kernel.org/r/20191128083718.39177-3-linus.walleij@linaro.org


Signed-off-by: default avatarMark Brown <broonie@kernel.org>
parent 71b8f600
Loading
Loading
Loading
Loading
+12 −2
Original line number Diff line number Diff line
@@ -728,7 +728,17 @@ static int of_fsl_spi_probe(struct platform_device *ofdev)
			}
		}
#endif

		/*
		 * Handle the case where we have one hardwired (always selected)
		 * device on the first "chipselect". Else we let the core code
		 * handle any GPIOs or native chip selects and assign the
		 * appropriate callback for dealing with the CS lines. This isn't
		 * supported on the GRLIB variant.
		 */
		ret = gpiod_count(dev, "cs");
		if (ret <= 0)
			pdata->max_chipselect = 1;
		else
			pdata->cs_control = fsl_spi_cs_control;
	}