Skip to content

Commit 3106eda

Browse files
dlechbroonie
authored andcommitted
spi: axi-spi-engine: restore clkdiv at end of message
This modifies the ADI AXI SPI Engine driver to restore the clkdiv configuration register at the end of a SPI message. Having the clkdiv in a known state is needed to be able to add a new command in the future that only performs a delay without any SPI transfers. Furthermore having that state be the smallest possible divider will allow these delays to have the highest possible precision. Changing the initial value of clk_div from -1 to 1 is now possible because we know the function will always be called with a known clkdiv config register state. Making this change will also have the effect of not emitting a clkdiv configuration register instruction in cases where the maximum sclk rate is used. Having one less instruction to process reduces delays on the bus which will be beneficial when we implement offload support to enable reading data from devices at very high rates. Signed-off-by: David Lechner <dlechner@baylibre.com> Acked-by: Michael Hennerich <michael.hennerich@analog.com> Acked-by: Nuno Sa <nuno.sa@analog.com> Link: https://lore.kernel.org/r/20231204-axi-spi-engine-series-2-v1-7-063672323fce@baylibre.com Signed-off-by: Mark Brown <broonie@kernel.org>
1 parent 125a839 commit 3106eda

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

drivers/spi/spi-axi-spi-engine.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ static void spi_engine_compile_message(struct spi_message *msg, bool dry,
228228
bool keep_cs = false;
229229
u8 bits_per_word = 0;
230230

231-
clk_div = -1;
231+
clk_div = 1;
232232

233233
spi_engine_program_add_cmd(p, dry,
234234
SPI_ENGINE_CMD_WRITE(SPI_ENGINE_CMD_REG_CONFIG,
@@ -280,6 +280,14 @@ static void spi_engine_compile_message(struct spi_message *msg, bool dry,
280280

281281
if (!keep_cs)
282282
spi_engine_gen_cs(p, dry, spi, false);
283+
284+
/*
285+
* Restore clockdiv to default so that future gen_sleep commands don't
286+
* have to be aware of the current register state.
287+
*/
288+
if (clk_div != 1)
289+
spi_engine_program_add_cmd(p, dry,
290+
SPI_ENGINE_CMD_WRITE(SPI_ENGINE_CMD_REG_CLK_DIV, 0));
283291
}
284292

285293
static void spi_engine_xfer_next(struct spi_message *msg,

0 commit comments

Comments
 (0)