mirror of
https://github.com/Ysurac/openmptcprouter.git
synced 2025-03-09 15:40:20 +00:00
66 lines
2 KiB
Diff
66 lines
2 KiB
Diff
From 52b6d4c87bc1afc2ef70595532b55788a0309843 Mon Sep 17 00:00:00 2001
|
|
From: Phil Elwell <phil@raspberrypi.com>
|
|
Date: Mon, 1 Jul 2024 15:49:14 +0100
|
|
Subject: [PATCH 494/697] 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>
|
|
---
|
|
drivers/spi/spi-dw-core.c | 27 +++++++++++++++++----------
|
|
1 file changed, 17 insertions(+), 10 deletions(-)
|
|
|
|
--- a/drivers/spi/spi-dw-core.c
|
|
+++ b/drivers/spi/spi-dw-core.c
|
|
@@ -227,12 +227,17 @@ static irqreturn_t dw_spi_transfer_handl
|
|
* final stage of the transfer. By doing so we'll get the next IRQ
|
|
* right when the leftover incoming data is received.
|
|
*/
|
|
- dw_reader(dws);
|
|
- if (!dws->rx_len) {
|
|
- dw_spi_mask_intr(dws, 0xff);
|
|
+ if (dws->rx_len) {
|
|
+ dw_reader(dws);
|
|
+ if (!dws->rx_len) {
|
|
+ dw_spi_mask_intr(dws, 0xff);
|
|
+ spi_finalize_current_transfer(dws->host);
|
|
+ } else if (dws->rx_len <= dw_readl(dws, DW_SPI_RXFTLR)) {
|
|
+ dw_writel(dws, DW_SPI_RXFTLR, dws->rx_len - 1);
|
|
+ }
|
|
+ } else if (!dws->tx_len) {
|
|
+ dw_spi_mask_intr(dws, DW_SPI_INT_TXEI);
|
|
spi_finalize_current_transfer(dws->host);
|
|
- } else if (dws->rx_len <= dw_readl(dws, DW_SPI_RXFTLR)) {
|
|
- dw_writel(dws, DW_SPI_RXFTLR, dws->rx_len - 1);
|
|
}
|
|
|
|
/*
|
|
@@ -241,12 +246,9 @@ static irqreturn_t dw_spi_transfer_handl
|
|
* have the TXE IRQ flood at the final stage of the transfer.
|
|
*/
|
|
if (irq_status & DW_SPI_INT_TXEI) {
|
|
- dw_writer(dws);
|
|
- if (!dws->tx_len) {
|
|
+ if (!dws->tx_len)
|
|
dw_spi_mask_intr(dws, DW_SPI_INT_TXEI);
|
|
- if (!dws->rx_len)
|
|
- spi_finalize_current_transfer(dws->host);
|
|
- }
|
|
+ dw_writer(dws);
|
|
}
|
|
|
|
return IRQ_HANDLED;
|
|
@@ -436,6 +438,11 @@ static int dw_spi_transfer_one(struct sp
|
|
dws->rx = transfer->rx_buf;
|
|
dws->rx_len = dws->tx_len;
|
|
|
|
+ if (!dws->rx) {
|
|
+ dws->rx_len = 0;
|
|
+ cfg.tmode = DW_SPI_CTRLR0_TMOD_TO;
|
|
+ }
|
|
+
|
|
/* Ensure the data above is visible for all CPUs */
|
|
smp_mb();
|
|
|