diff options
author | Oleksij Rempel <o.rempel@pengutronix.de> | 2017-07-25 03:57:08 -0400 |
---|---|---|
committer | Mark Brown <broonie@kernel.org> | 2017-07-26 08:08:56 -0400 |
commit | 8bc85a871436525cc38f819bbc122d216730e905 (patch) | |
tree | c066f3bb9a5840110bd0d1fc6b36d6482d81b865 | |
parent | 59a8831da31ebdabf82cac82bf01270d215bf149 (diff) |
spi: loopback-test: implement testing with no CS
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 <o.rempel@pengutronix.de>
Signed-off-by: Mark Brown <broonie@kernel.org>
-rw-r--r-- | drivers/spi/spi-loopback-test.c | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/drivers/spi/spi-loopback-test.c b/drivers/spi/spi-loopback-test.c index 64a1e6f212c1..bed7403bb6b3 100644 --- a/drivers/spi/spi-loopback-test.c +++ b/drivers/spi/spi-loopback-test.c | |||
@@ -57,6 +57,11 @@ MODULE_PARM_DESC(loop_req, | |||
57 | "if set controller will be asked to enable test loop mode. " \ | 57 | "if set controller will be asked to enable test loop mode. " \ |
58 | "If controller supported it, MISO and MOSI will be connected"); | 58 | "If controller supported it, MISO and MOSI will be connected"); |
59 | 59 | ||
60 | static int no_cs; | ||
61 | module_param(no_cs, int, 0); | ||
62 | MODULE_PARM_DESC(no_cs, | ||
63 | "if set Chip Select (CS) will not be used"); | ||
64 | |||
60 | /* run only a specific test */ | 65 | /* run only a specific test */ |
61 | static int run_only_test = -1; | 66 | static int run_only_test = -1; |
62 | module_param(run_only_test, int, 0); | 67 | module_param(run_only_test, int, 0); |
@@ -319,11 +324,12 @@ static int spi_loopback_test_probe(struct spi_device *spi) | |||
319 | { | 324 | { |
320 | int ret; | 325 | int ret; |
321 | 326 | ||
322 | if (loop_req) { | 327 | if (loop_req || no_cs) { |
323 | spi->mode = SPI_LOOP | spi->mode; | 328 | spi->mode |= loop_req ? SPI_LOOP : 0; |
329 | spi->mode |= no_cs ? SPI_NO_CS : 0; | ||
324 | ret = spi_setup(spi); | 330 | ret = spi_setup(spi); |
325 | if (ret) { | 331 | if (ret) { |
326 | dev_err(&spi->dev, "SPI setup with SPI_LOOP failed (%d)\n", | 332 | dev_err(&spi->dev, "SPI setup with SPI_LOOP or SPI_NO_CS failed (%d)\n", |
327 | ret); | 333 | ret); |
328 | return ret; | 334 | return ret; |
329 | } | 335 | } |