Commit e006c181 authored by David Lechner's avatar David Lechner Committed by Mark Brown

spi: axi-spi-engine: remove xfer arg from spi_engine_gen_sleep()

This replaces the xfer parameter of spi_engine_gen_sleep() in the AXI
SPI Engine driver with parameters for the delay in nanoseconds and the
SPI SCLK rate. This will allow this function to be used by callers in
the future that do not have a spi_transfer struct.
Signed-off-by: default avatarDavid Lechner <dlechner@baylibre.com>
Acked-by: default avatarMichael Hennerich <michael.hennerich@analog.com>
Acked-by: default avatarNuno Sa <nuno.sa@analog.com>
Link: https://lore.kernel.org/r/20231204-axi-spi-engine-series-2-v1-5-063672323fce@baylibre.comSigned-off-by: default avatarMark Brown <broonie@kernel.org>
parent be9070bc
......@@ -168,17 +168,16 @@ static void spi_engine_gen_xfer(struct spi_engine_program *p, bool dry,
}
static void spi_engine_gen_sleep(struct spi_engine_program *p, bool dry,
struct spi_transfer *xfer)
int delay_ns, u32 sclk_hz)
{
unsigned int t;
int delay_ns;
delay_ns = spi_delay_to_ns(&xfer->delay, xfer);
/* negative delay indicates error, e.g. from spi_delay_to_ns() */
if (delay_ns <= 0)
return;
/* rounding down since executing the instruction adds a couple of ticks delay */
t = DIV_ROUND_DOWN_ULL((u64)delay_ns * xfer->effective_speed_hz, NSEC_PER_SEC);
t = DIV_ROUND_DOWN_ULL((u64)delay_ns * sclk_hz, NSEC_PER_SEC);
while (t) {
unsigned int n = min(t, 256U);
......@@ -256,7 +255,8 @@ static void spi_engine_compile_message(struct spi_message *msg, bool dry,
}
spi_engine_gen_xfer(p, dry, xfer);
spi_engine_gen_sleep(p, dry, xfer);
spi_engine_gen_sleep(p, dry, spi_delay_to_ns(&xfer->delay, xfer),
xfer->effective_speed_hz);
if (xfer->cs_change) {
if (list_is_last(&xfer->transfer_list, &msg->transfers)) {
......
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