diff options
author | Martin Sperl <kernel@martin.sperl.org> | 2019-02-23 08:49:50 +0000 |
---|---|---|
committer | Mark Brown <broonie@kernel.org> | 2019-05-08 18:30:01 +0900 |
commit | d5864e5bed96db7230da45463d6ae7af5b3b4399 (patch) | |
tree | 5f88ca741879905a3740c8c8ffdc19cbec25f369 /drivers/spi | |
parent | 0ff2de8bb163551ec4230a5a6f3c40c1f6adec4f (diff) | |
download | linux-d5864e5bed96db7230da45463d6ae7af5b3b4399.tar.gz linux-d5864e5bed96db7230da45463d6ae7af5b3b4399.tar.bz2 linux-d5864e5bed96db7230da45463d6ae7af5b3b4399.zip |
spi: core: allow defining time that cs is deasserted as a multiple of SCK
Support setting a delay between cs assert and deassert as
a multiple of spi clock length.
Signed-off-by: Martin Sperl <kernel@martin.sperl.org>
Signed-off-by: Mark Brown <broonie@kernel.org>
Diffstat (limited to 'drivers/spi')
-rw-r--r-- | drivers/spi/spi.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c index 7e8ffe3fdc00..cfa3c3decb8a 100644 --- a/drivers/spi/spi.c +++ b/drivers/spi/spi.c @@ -1111,6 +1111,7 @@ static void _spi_transfer_cs_change_delay(struct spi_message *msg, { u32 delay = xfer->cs_change_delay; u32 unit = xfer->cs_change_delay_unit; + u32 hz; /* return early on "fast" mode - for everything but USECS */ if (!delay && unit != SPI_DELAY_UNIT_USECS) @@ -1126,6 +1127,13 @@ static void _spi_transfer_cs_change_delay(struct spi_message *msg, break; case SPI_DELAY_UNIT_NSECS: /* nothing to do here */ break; + case SPI_DELAY_UNIT_SCK: + /* if there is no effective speed know, then approximate + * by underestimating with half the requested hz + */ + hz = xfer->effective_speed_hz ?: xfer->speed_hz / 2; + delay *= DIV_ROUND_UP(1000000000, hz); + break; default: dev_err_once(&msg->spi->dev, "Use of unsupported delay unit %i, using default of 10us\n", |