Commit 2ed6692e authored by Jan Kundrát's avatar Jan Kundrát Committed by Mark Brown

spi: spidev: Enable control of inter-word delays

Commit b7bb367a 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: default avatarJan Kundrát <jan.kundrat@cesnet.cz>
Signed-off-by: default avatarMark Brown <broonie@kernel.org>
parent 4e3891a5
...@@ -276,17 +276,19 @@ static int spidev_message(struct spidev_data *spidev, ...@@ -276,17 +276,19 @@ static int spidev_message(struct spidev_data *spidev,
k_tmp->bits_per_word = u_tmp->bits_per_word; k_tmp->bits_per_word = u_tmp->bits_per_word;
k_tmp->delay_usecs = u_tmp->delay_usecs; k_tmp->delay_usecs = u_tmp->delay_usecs;
k_tmp->speed_hz = u_tmp->speed_hz; k_tmp->speed_hz = u_tmp->speed_hz;
k_tmp->word_delay_usecs = u_tmp->word_delay_usecs;
if (!k_tmp->speed_hz) if (!k_tmp->speed_hz)
k_tmp->speed_hz = spidev->speed_hz; k_tmp->speed_hz = spidev->speed_hz;
#ifdef VERBOSE #ifdef VERBOSE
dev_dbg(&spidev->spi->dev, dev_dbg(&spidev->spi->dev,
" xfer len %u %s%s%s%dbits %u usec %uHz\n", " xfer len %u %s%s%s%dbits %u usec %u usec %uHz\n",
u_tmp->len, u_tmp->len,
u_tmp->rx_buf ? "rx " : "", u_tmp->rx_buf ? "rx " : "",
u_tmp->tx_buf ? "tx " : "", u_tmp->tx_buf ? "tx " : "",
u_tmp->cs_change ? "cs " : "", u_tmp->cs_change ? "cs " : "",
u_tmp->bits_per_word ? : spidev->spi->bits_per_word, u_tmp->bits_per_word ? : spidev->spi->bits_per_word,
u_tmp->delay_usecs, u_tmp->delay_usecs,
u_tmp->word_delay_usecs,
u_tmp->speed_hz ? : spidev->spi->max_speed_hz); u_tmp->speed_hz ? : spidev->spi->max_speed_hz);
#endif #endif
spi_message_add_tail(k_tmp, &msg); spi_message_add_tail(k_tmp, &msg);
......
...@@ -66,6 +66,9 @@ ...@@ -66,6 +66,9 @@
* @delay_usecs: If nonzero, how long to delay after the last bit transfer * @delay_usecs: If nonzero, how long to delay after the last bit transfer
* before optionally deselecting the device before the next transfer. * before optionally deselecting the device before the next transfer.
* @cs_change: True to deselect device before starting the next transfer. * @cs_change: True to deselect device before starting the next transfer.
* @word_delay_usecs: If nonzero, how long to wait between words within one
* transfer. This property needs explicit support in the SPI controller,
* otherwise it is silently ignored.
* *
* This structure is mapped directly to the kernel spi_transfer structure; * This structure is mapped directly to the kernel spi_transfer structure;
* the fields have the same meanings, except of course that the pointers * the fields have the same meanings, except of course that the pointers
...@@ -100,7 +103,8 @@ struct spi_ioc_transfer { ...@@ -100,7 +103,8 @@ struct spi_ioc_transfer {
__u8 cs_change; __u8 cs_change;
__u8 tx_nbits; __u8 tx_nbits;
__u8 rx_nbits; __u8 rx_nbits;
__u16 pad; __u8 word_delay_usecs;
__u8 pad;
/* If the contents of 'struct spi_ioc_transfer' ever change /* If the contents of 'struct spi_ioc_transfer' ever change
* incompatibly, then the ioctl number (currently 0) must change; * incompatibly, then the ioctl number (currently 0) must change;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment