]> git.baikalelectronics.ru Git - kernel.git/commit
spi: core: allow defining time that cs is deasserted
authorMartin Sperl <kernel@martin.sperl.org>
Sat, 23 Feb 2019 08:49:48 +0000 (08:49 +0000)
committerMark Brown <broonie@kernel.org>
Wed, 8 May 2019 09:28:51 +0000 (18:28 +0900)
commit0ff2de8bb163551ec4230a5a6f3c40c1f6adec4f
treee144d1f35586e40c4048cf982a63eeff126186ba
parent154f7da56f1ecba42021d550c9e8432ac8d32c26
spi: core: allow defining time that cs is deasserted

For some SPI devices that support speed_hz > 1MHz the default 10 us delay
when cs_change = 1 is typically way to long and may result in poor spi bus
utilization.

This patch makes it possible to control the delay at micro or nano second
resolution on a per spi_transfer basis. It even allows an "as fast as
possible" mode with:
    xfer.cs_change_delay_unit = SPI_DELAY_UNIT_NSECS;
    xfer.cs_change_delay = 0;

The delay code is shared between delay_usecs and cs_change_delay for
consistency and reuse, so in the future this change_delay_unit could also
apply to delay_usec as well.

Note that on slower SOCs/CPU actually reaching ns deasserts on cs is not
realistic as the gpio overhead alone (without any delays added ) may
already leave cs deasserted for more than 1us - at least on a raspberry pi.
But at the very least this way we can keep it as short as possible.

Signed-off-by: Martin Sperl <kernel@martin.sperl.org>
Signed-off-by: Mark Brown <broonie@kernel.org>
drivers/spi/spi.c
include/linux/spi/spi.h