Skip to content

Commit 1ca895d

Browse files
decsnyfabiobaltieri
authored andcommitted
spi_nxp_lpspi: Reintroduce fast path no configure
Reintroduce the fast path that skips reconfiguring if we use the same configuration, this fixes regression that causes a lot of latency at the start of repeated transfers. Unfortuantely need to find alternative workaround for S32K3 in order to do this instead of module reset, so disable skipping for that platform. Signed-off-by: Declan Snyder <[email protected]>
1 parent 09e31d6 commit 1ca895d

File tree

3 files changed

+12
-4
lines changed

3 files changed

+12
-4
lines changed

drivers/spi/spi_nxp_lpspi/spi_nxp_lpspi.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ static void lpspi_isr(const struct device *dev)
210210
}
211211

212212
if (spi_context_rx_len_left(ctx) == 1) {
213-
base->TCR = 0;
213+
base->TCR &= ~LPSPI_TCR_CONT_MASK;
214214
} else if (spi_context_rx_on(ctx)) {
215215
size_t rx_fifo_len = rx_fifo_cur_len(base);
216216
size_t expected_rx_left = rx_fifo_len < ctx->rx_len ? ctx->rx_len - rx_fifo_len : 0;
@@ -224,7 +224,7 @@ static void lpspi_isr(const struct device *dev)
224224
} else {
225225
spi_context_complete(ctx, dev, 0);
226226
NVIC_ClearPendingIRQ(config->irqn);
227-
base->TCR = 0;
227+
base->TCR &= ~LPSPI_TCR_CONT_MASK;
228228
lpspi_wait_tx_fifo_empty(dev);
229229
spi_context_cs_control(ctx, false);
230230
spi_context_release(&data->ctx, 0);
@@ -267,7 +267,7 @@ static int transceive(const struct device *dev, const struct spi_config *spi_cfg
267267
LPSPI_Enable(base, true);
268268

269269
/* keep the chip select asserted until the end of the zephyr xfer */
270-
base->TCR |= LPSPI_TCR_CONT_MASK | LPSPI_TCR_CONTC_MASK;
270+
base->TCR |= LPSPI_TCR_CONT_MASK;
271271
/* tcr is written to tx fifo */
272272
lpspi_wait_tx_fifo_empty(dev);
273273

drivers/spi/spi_nxp_lpspi/spi_nxp_lpspi_common.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,14 @@ int spi_mcux_configure(const struct device *dev, const struct spi_config *spi_cf
3030
uint32_t clock_freq;
3131
int ret;
3232

33+
/* fast path to avoid reconfigure */
34+
/* TODO: S32K3 errata ERR050456 requiring module reset before every transfer,
35+
* investigate alternative workaround so we don't have this latency for S32.
36+
*/
37+
if (spi_context_configured(ctx, spi_cfg) && !IS_ENABLED(CONFIG_SOC_FAMILY_NXP_S32)) {
38+
return 0;
39+
}
40+
3341
if (spi_cfg->operation & SPI_HALF_DUPLEX) {
3442
/* the IP DOES support half duplex, need to implement driver support */
3543
LOG_ERR("Half-duplex not supported");

drivers/spi/spi_nxp_lpspi/spi_nxp_lpspi_dma.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ static int transceive_dma_sync(const struct device *dev)
285285

286286
spi_context_cs_control(ctx, false);
287287

288-
base->TCR = 0;
288+
base->TCR &= ~LPSPI_TCR_CONT_MASK;
289289

290290
return 0;
291291
}

0 commit comments

Comments
 (0)