Skip to content

Commit 6014649

Browse files
committed
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 31b9871 commit 6014649

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
@@ -225,12 +225,17 @@ static irqreturn_t dw_spi_transfer_handler(struct dw_spi *dws)
225225
* final stage of the transfer. By doing so we'll get the next IRQ
226226
* right when the leftover incoming data is received.
227227
*/
228-
dw_reader(dws);
229-
if (!dws->rx_len) {
230-
dw_spi_mask_intr(dws, 0xff);
228+
if (dws->rx_len) {
229+
dw_reader(dws);
230+
if (!dws->rx_len) {
231+
dw_spi_mask_intr(dws, 0xff);
232+
spi_finalize_current_transfer(dws->host);
233+
} else if (dws->rx_len <= dw_readl(dws, DW_SPI_RXFTLR)) {
234+
dw_writel(dws, DW_SPI_RXFTLR, dws->rx_len - 1);
235+
}
236+
} else if (!dws->tx_len) {
237+
dw_spi_mask_intr(dws, DW_SPI_INT_TXEI);
231238
spi_finalize_current_transfer(dws->host);
232-
} else if (dws->rx_len <= dw_readl(dws, DW_SPI_RXFTLR)) {
233-
dw_writel(dws, DW_SPI_RXFTLR, dws->rx_len - 1);
234239
}
235240

236241
/*
@@ -239,12 +244,9 @@ static irqreturn_t dw_spi_transfer_handler(struct dw_spi *dws)
239244
* have the TXE IRQ flood at the final stage of the transfer.
240245
*/
241246
if (irq_status & DW_SPI_INT_TXEI) {
242-
dw_writer(dws);
243-
if (!dws->tx_len) {
247+
if (!dws->tx_len)
244248
dw_spi_mask_intr(dws, DW_SPI_INT_TXEI);
245-
if (!dws->rx_len)
246-
spi_finalize_current_transfer(dws->host);
247-
}
249+
dw_writer(dws);
248250
}
249251

250252
return IRQ_HANDLED;
@@ -437,6 +439,11 @@ static int dw_spi_transfer_one(struct spi_controller *host,
437439
dws->rx = transfer->rx_buf;
438440
dws->rx_len = dws->tx_len;
439441

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

0 commit comments

Comments
 (0)