diff options
author | Jan Kundrát <jan.kundrat@cesnet.cz> | 2019-03-07 09:29:42 -0500 |
---|---|---|
committer | Mark Brown <broonie@kernel.org> | 2019-03-18 08:18:28 -0400 |
commit | 2ed6692e8ce924346c3aab5585b07005adb30625 (patch) | |
tree | 9c77ba50e365714bc1d4e5cfd5dfee6382cc416b | |
parent | 4e3891a55f671a4e641d2ef4e5ec0e27e56b20d9 (diff) |
spi: spidev: Enable control of inter-word delays
Commit b7bb367afa4b added support for inserting delays in between
individual words within a single SPI transaction. This makes it
accessible from userspace.
WARNING: This delay is silently ignored unless the SPI controller
implements extra support for it. This is similar to how the in-kernel
users handle the other existing property, spi_transfer->word_delay.
Signed-off-by: Jan Kundrát <jan.kundrat@cesnet.cz>
Signed-off-by: Mark Brown <broonie@kernel.org>
-rw-r--r-- | drivers/spi/spidev.c | 4 | ||||
-rw-r--r-- | include/uapi/linux/spi/spidev.h | 6 |
2 files changed, 8 insertions, 2 deletions
diff --git a/drivers/spi/spidev.c b/drivers/spi/spidev.c index b0c76e2626ce..70966e10be7e 100644 --- a/drivers/spi/spidev.c +++ b/drivers/spi/spidev.c | |||
@@ -276,17 +276,19 @@ static int spidev_message(struct spidev_data *spidev, | |||
276 | k_tmp->bits_per_word = u_tmp->bits_per_word; | 276 | k_tmp->bits_per_word = u_tmp->bits_per_word; |
277 | k_tmp->delay_usecs = u_tmp->delay_usecs; | 277 | k_tmp->delay_usecs = u_tmp->delay_usecs; |
278 | k_tmp->speed_hz = u_tmp->speed_hz; | 278 | k_tmp->speed_hz = u_tmp->speed_hz; |
279 | k_tmp->word_delay_usecs = u_tmp->word_delay_usecs; | ||
279 | if (!k_tmp->speed_hz) | 280 | if (!k_tmp->speed_hz) |
280 | k_tmp->speed_hz = spidev->speed_hz; | 281 | k_tmp->speed_hz = spidev->speed_hz; |
281 | #ifdef VERBOSE | 282 | #ifdef VERBOSE |
282 | dev_dbg(&spidev->spi->dev, | 283 | dev_dbg(&spidev->spi->dev, |
283 | " xfer len %u %s%s%s%dbits %u usec %uHz\n", | 284 | " xfer len %u %s%s%s%dbits %u usec %u usec %uHz\n", |
284 | u_tmp->len, | 285 | u_tmp->len, |
285 | u_tmp->rx_buf ? "rx " : "", | 286 | u_tmp->rx_buf ? "rx " : "", |
286 | u_tmp->tx_buf ? "tx " : "", | 287 | u_tmp->tx_buf ? "tx " : "", |
287 | u_tmp->cs_change ? "cs " : "", | 288 | u_tmp->cs_change ? "cs " : "", |
288 | u_tmp->bits_per_word ? : spidev->spi->bits_per_word, | 289 | u_tmp->bits_per_word ? : spidev->spi->bits_per_word, |
289 | u_tmp->delay_usecs, | 290 | u_tmp->delay_usecs, |
291 | u_tmp->word_delay_usecs, | ||
290 | u_tmp->speed_hz ? : spidev->spi->max_speed_hz); | 292 | u_tmp->speed_hz ? : spidev->spi->max_speed_hz); |
291 | #endif | 293 | #endif |
292 | spi_message_add_tail(k_tmp, &msg); | 294 | spi_message_add_tail(k_tmp, &msg); |
diff --git a/include/uapi/linux/spi/spidev.h b/include/uapi/linux/spi/spidev.h index c4253f0090d8..ee0f2460bff6 100644 --- a/include/uapi/linux/spi/spidev.h +++ b/include/uapi/linux/spi/spidev.h | |||
@@ -66,6 +66,9 @@ | |||
66 | * @delay_usecs: If nonzero, how long to delay after the last bit transfer | 66 | * @delay_usecs: If nonzero, how long to delay after the last bit transfer |
67 | * before optionally deselecting the device before the next transfer. | 67 | * before optionally deselecting the device before the next transfer. |
68 | * @cs_change: True to deselect device before starting the next transfer. | 68 | * @cs_change: True to deselect device before starting the next transfer. |
69 | * @word_delay_usecs: If nonzero, how long to wait between words within one | ||
70 | * transfer. This property needs explicit support in the SPI controller, | ||
71 | * otherwise it is silently ignored. | ||
69 | * | 72 | * |
70 | * This structure is mapped directly to the kernel spi_transfer structure; | 73 | * This structure is mapped directly to the kernel spi_transfer structure; |
71 | * the fields have the same meanings, except of course that the pointers | 74 | * the fields have the same meanings, except of course that the pointers |
@@ -100,7 +103,8 @@ struct spi_ioc_transfer { | |||
100 | __u8 cs_change; | 103 | __u8 cs_change; |
101 | __u8 tx_nbits; | 104 | __u8 tx_nbits; |
102 | __u8 rx_nbits; | 105 | __u8 rx_nbits; |
103 | __u16 pad; | 106 | __u8 word_delay_usecs; |
107 | __u8 pad; | ||
104 | 108 | ||
105 | /* If the contents of 'struct spi_ioc_transfer' ever change | 109 | /* If the contents of 'struct spi_ioc_transfer' ever change |
106 | * incompatibly, then the ioctl number (currently 0) must change; | 110 | * incompatibly, then the ioctl number (currently 0) must change; |