Skip to content

Commit 96cbfed

Browse files
pelwellpopcornmix
authored andcommitted
spi: dw: Save bandwidth with the TMOD_TO feature
TMOD_TO is the transmit-only mode that doesn't put data into the receive FIFO. Using TMOD_TO when the user doesn't want the received data saves CPU time and memory bandwidth. Signed-off-by: Phil Elwell <phil@raspberrypi.com>
1 parent 50ddd63 commit 96cbfed

File tree

1 file changed

+17
-10
lines changed

1 file changed

+17
-10
lines changed

drivers/spi/spi-dw-core.c

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -227,12 +227,17 @@ static irqreturn_t dw_spi_transfer_handler(struct dw_spi *dws)
227227
* final stage of the transfer. By doing so we'll get the next IRQ
228228
* right when the leftover incoming data is received.
229229
*/
230-
dw_reader(dws);
231-
if (!dws->rx_len) {
232-
dw_spi_mask_intr(dws, 0xff);
230+
if (dws->rx_len) {
231+
dw_reader(dws);
232+
if (!dws->rx_len) {
233+
dw_spi_mask_intr(dws, 0xff);
234+
spi_finalize_current_transfer(dws->host);
235+
} else if (dws->rx_len <= dw_readl(dws, DW_SPI_RXFTLR)) {
236+
dw_writel(dws, DW_SPI_RXFTLR, dws->rx_len - 1);
237+
}
238+
} else if (!dws->tx_len) {
239+
dw_spi_mask_intr(dws, DW_SPI_INT_TXEI);
233240
spi_finalize_current_transfer(dws->host);
234-
} else if (dws->rx_len <= dw_readl(dws, DW_SPI_RXFTLR)) {
235-
dw_writel(dws, DW_SPI_RXFTLR, dws->rx_len - 1);
236241
}
237242

238243
/*
@@ -241,12 +246,9 @@ static irqreturn_t dw_spi_transfer_handler(struct dw_spi *dws)
241246
* have the TXE IRQ flood at the final stage of the transfer.
242247
*/
243248
if (irq_status & DW_SPI_INT_TXEI) {
244-
dw_writer(dws);
245-
if (!dws->tx_len) {
249+
if (!dws->tx_len)
246250
dw_spi_mask_intr(dws, DW_SPI_INT_TXEI);
247-
if (!dws->rx_len)
248-
spi_finalize_current_transfer(dws->host);
249-
}
251+
dw_writer(dws);
250252
}
251253

252254
return IRQ_HANDLED;
@@ -436,6 +438,11 @@ static int dw_spi_transfer_one(struct spi_controller *host,
436438
dws->rx = transfer->rx_buf;
437439
dws->rx_len = dws->tx_len;
438440

441+
if (!dws->rx) {
442+
dws->rx_len = 0;
443+
cfg.tmode = DW_SPI_CTRLR0_TMOD_TO;
444+
}
445+
439446
/* Ensure the data above is visible for all CPUs */
440447
smp_mb();
441448

0 commit comments

Comments
 (0)