spi: spi-imx: fix mixing of native and gpio chipselects for imx51/imx53/imx6 variants
authorRasmus Villemoes <linux@rasmusvillemoes.dk>
Fri, 2 Jun 2023 11:57:30 +0000 (13:57 +0200)
committerMark Brown <broonie@kernel.org>
Fri, 2 Jun 2023 12:15:14 +0000 (13:15 +0100)
commita34e0353a681bbdd0402825e25410c3236109f31
treeb71b11e8f75dd73fb6d76e2da32f3396186b8db5
parent20c475d21ed9326f7b1396c9bb8991b375cb6c50
spi: spi-imx: fix mixing of native and gpio chipselects for imx51/imx53/imx6 variants

Commit 87c614175bbf (spi: spi-imx: fix MX51_ECSPI_* macros when cs >
3) ensured that the argument passed to the macros was masked with &3,
so that we no longer write outside the intended fields in the various
control registers. When all chip selects are gpios, this works just
fine.

However, when a mix of native and gpio chip selects are in use, that
masking is too naive. Say, for example, that SS0 is muxed as native
chip select, and there is also a chip at 4 (obviously with a gpio
cs). In that case, when accessing the latter chip, both the SS0 pin
and the gpio pin will be asserted low.

The fix for this is to use the ->unused_native_cs value as channel
number for any spi device which uses a gpio as chip select.

Signed-off-by: Rasmus Villemoes <linux@rasmusvillemoes.dk>
Link: https://lore.kernel.org/r/20230602115731.708883-1-linux@rasmusvillemoes.dk
Signed-off-by: Mark Brown <broonie@kernel.org>
drivers/spi/spi-imx.c