Skip to content

Commit ab2f357

Browse files
olerembroonie
authored andcommitted
spi: imx: add SPI_NO_CS support
To run spi-loopback-tests on HW without modifications, we need to disable Chip Select. This should avoid surprising side effects for SPI devices by testing patterns. Signed-off-by: Oleksij Rempel <[email protected]> Signed-off-by: Mark Brown <[email protected]>
1 parent 26e4bb8 commit ab2f357

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

drivers/spi/spi-imx.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -813,6 +813,9 @@ static void spi_imx_chipselect(struct spi_device *spi, int is_active)
813813
int active = is_active != BITBANG_CS_INACTIVE;
814814
int dev_is_lowactive = !(spi->mode & SPI_CS_HIGH);
815815

816+
if (spi->mode & SPI_NO_CS)
817+
return;
818+
816819
if (!gpio_is_valid(spi->cs_gpio))
817820
return;
818821

@@ -1139,6 +1142,9 @@ static int spi_imx_setup(struct spi_device *spi)
11391142
dev_dbg(&spi->dev, "%s: mode %d, %u bpw, %d hz\n", __func__,
11401143
spi->mode, spi->bits_per_word, spi->max_speed_hz);
11411144

1145+
if (spi->mode & SPI_NO_CS)
1146+
return 0;
1147+
11421148
if (gpio_is_valid(spi->cs_gpio))
11431149
gpio_direction_output(spi->cs_gpio,
11441150
spi->mode & SPI_CS_HIGH ? 0 : 1);
@@ -1238,7 +1244,8 @@ static int spi_imx_probe(struct platform_device *pdev)
12381244
spi_imx->bitbang.master->cleanup = spi_imx_cleanup;
12391245
spi_imx->bitbang.master->prepare_message = spi_imx_prepare_message;
12401246
spi_imx->bitbang.master->unprepare_message = spi_imx_unprepare_message;
1241-
spi_imx->bitbang.master->mode_bits = SPI_CPOL | SPI_CPHA | SPI_CS_HIGH;
1247+
spi_imx->bitbang.master->mode_bits = SPI_CPOL | SPI_CPHA | SPI_CS_HIGH \
1248+
| SPI_NO_CS;
12421249
if (is_imx35_cspi(spi_imx) || is_imx51_ecspi(spi_imx) ||
12431250
is_imx53_ecspi(spi_imx))
12441251
spi_imx->bitbang.master->mode_bits |= SPI_LOOP | SPI_READY;

0 commit comments

Comments
 (0)