Skip to content

Commit e6702c4

Browse files
dlechbroonie
authored andcommitted
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: David Lechner <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Mark Brown <[email protected]>
1 parent 087591c commit e6702c4

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

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

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,7 @@ struct spi_engine {
162162
unsigned int offload_sdo_mem_size;
163163
struct spi_offload *offload;
164164
u32 offload_caps;
165+
bool offload_requires_sync;
165166
};
166167

167168
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)
702703

703704
static int spi_engine_optimize_message(struct spi_message *msg)
704705
{
706+
struct spi_controller *host = msg->spi->controller;
707+
struct spi_engine *spi_engine = spi_controller_get_devdata(host);
705708
struct spi_engine_program p_dry, *p;
706709
int ret;
707710

@@ -718,8 +721,13 @@ static int spi_engine_optimize_message(struct spi_message *msg)
718721

719722
spi_engine_compile_message(msg, false, p);
720723

721-
spi_engine_program_add_cmd(p, false, SPI_ENGINE_CMD_SYNC(
722-
msg->offload ? 0 : AXI_SPI_ENGINE_CUR_MSG_SYNC_ID));
724+
/*
725+
* Non-offload needs SYNC for completion interrupt. Older versions of
726+
* the IP core also need SYNC for offload to work properly.
727+
*/
728+
if (!msg->offload || spi_engine->offload_requires_sync)
729+
spi_engine_program_add_cmd(p, false, SPI_ENGINE_CMD_SYNC(
730+
msg->offload ? 0 : AXI_SPI_ENGINE_CUR_MSG_SYNC_ID));
723731

724732
msg->opt_state = p;
725733

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

1066+
/* IP v1.5 dropped the requirement for SYNC in offload messages. */
1067+
spi_engine->offload_requires_sync = ADI_AXI_PCORE_VER_MINOR(version) < 5;
1068+
10581069
writel_relaxed(0x00, spi_engine->base + SPI_ENGINE_REG_RESET);
10591070
writel_relaxed(0xff, spi_engine->base + SPI_ENGINE_REG_INT_PENDING);
10601071
writel_relaxed(0x00, spi_engine->base + SPI_ENGINE_REG_INT_ENABLE);

0 commit comments

Comments
 (0)