Commit d5864e5b authored by Martin Sperl's avatar Martin Sperl Committed by Mark Brown

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: default avatarMartin Sperl <kernel@martin.sperl.org>
Signed-off-by: default avatarMark Brown <broonie@kernel.org>
parent 0ff2de8b
......@@ -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",
......
......@@ -831,6 +831,7 @@ struct spi_transfer {
u8 cs_change_delay_unit;
#define SPI_DELAY_UNIT_USECS 0
#define SPI_DELAY_UNIT_NSECS 1
#define SPI_DELAY_UNIT_SCK 2
u32 speed_hz;
u16 word_delay;
......
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