Unverified Commit e6702c44 authored by David Lechner's avatar David Lechner Committed by Mark Brown
Browse files

spi: axi-spi-engine: omit SYNC from offload instructions



Add optimization to omit SYNC instructions from offload messages.
Starting with IP core v1.5.0, the SYNC instruction is no longer required
for proper operation when using the offload feature. Omitting the SYNC
instruction saves a few clock cycles needed to executed which can e.g.
allow achieving higher sample rates on ADCs.

Signed-off-by: default avatarDavid Lechner <dlechner@baylibre.com>
Link: https://patch.msgid.link/20250428-adi-main-v1-4-4b8a1b88a212@baylibre.com


Signed-off-by: default avatarMark Brown <broonie@kernel.org>
parent 087591c9
Loading
Loading
Loading
Loading
+13 −2
Original line number Diff line number Diff line
@@ -162,6 +162,7 @@ struct spi_engine {
	unsigned int offload_sdo_mem_size;
	struct spi_offload *offload;
	u32 offload_caps;
	bool offload_requires_sync;
};

static void spi_engine_program_add_cmd(struct spi_engine_program *p,
@@ -702,6 +703,8 @@ static void spi_engine_offload_unprepare(struct spi_offload *offload)

static int spi_engine_optimize_message(struct spi_message *msg)
{
	struct spi_controller *host = msg->spi->controller;
	struct spi_engine *spi_engine = spi_controller_get_devdata(host);
	struct spi_engine_program p_dry, *p;
	int ret;

@@ -718,6 +721,11 @@ static int spi_engine_optimize_message(struct spi_message *msg)

	spi_engine_compile_message(msg, false, p);

	/*
	 * Non-offload needs SYNC for completion interrupt. Older versions of
	 * the IP core also need SYNC for offload to work properly.
	 */
	if (!msg->offload || spi_engine->offload_requires_sync)
		spi_engine_program_add_cmd(p, false, SPI_ENGINE_CMD_SYNC(
			msg->offload ? 0 : AXI_SPI_ENGINE_CUR_MSG_SYNC_ID));

@@ -1055,6 +1063,9 @@ static int spi_engine_probe(struct platform_device *pdev)
		spi_engine->offload_sdo_mem_size = SPI_ENGINE_OFFLOAD_SDO_FIFO_SIZE;
	}

	/* IP v1.5 dropped the requirement for SYNC in offload messages. */
	spi_engine->offload_requires_sync = ADI_AXI_PCORE_VER_MINOR(version) < 5;

	writel_relaxed(0x00, spi_engine->base + SPI_ENGINE_REG_RESET);
	writel_relaxed(0xff, spi_engine->base + SPI_ENGINE_REG_INT_PENDING);
	writel_relaxed(0x00, spi_engine->base + SPI_ENGINE_REG_INT_ENABLE);