[PATCH 5/5] spi: bcm-qspi: Improve interrupt handling

From: Mark Tomlinson
Date: Mon Jun 15 2020 - 00:06:26 EST


Acknowledge interrupts correctly and add support for fifo-full
interrupt, distinguishing it from the done interrupt.

Reviewed-by: Callum Sinclair <callum.sinclair@xxxxxxxxxxxxxxxxxxx>
Reviewed-by: Chris Packham <chris.packham@xxxxxxxxxxxxxxxxxxx>
Signed-off-by: Mark Tomlinson <mark.tomlinson@xxxxxxxxxxxxxxxxxxx>
---
drivers/spi/spi-bcm-qspi.c | 11 ++++++-----
drivers/spi/spi-bcm-qspi.h | 5 ++++-
2 files changed, 10 insertions(+), 6 deletions(-)

diff --git a/drivers/spi/spi-bcm-qspi.c b/drivers/spi/spi-bcm-qspi.c
index 0cc51bcda300..3753eff8a154 100644
--- a/drivers/spi/spi-bcm-qspi.c
+++ b/drivers/spi/spi-bcm-qspi.c
@@ -1123,6 +1123,8 @@ static irqreturn_t bcm_qspi_bspi_lr_l2_isr(int irq, void *dev_id)
if (qspi->bspi_rf_op_len == 0) {
qspi->bspi_rf_op = NULL;
if (qspi->soc_intc) {
+ /* Ack BSPI done interrupt */
+ soc_intc->bcm_qspi_int_ack(soc_intc, BSPI_DONE);
/* disable soc BSPI interrupt */
soc_intc->bcm_qspi_int_set(soc_intc, BSPI_DONE,
false);
@@ -1134,11 +1136,10 @@ static irqreturn_t bcm_qspi_bspi_lr_l2_isr(int irq, void *dev_id)
bcm_qspi_bspi_lr_clear(qspi);
else
bcm_qspi_bspi_flush_prefetch_buffers(qspi);
- }
-
- if (qspi->soc_intc)
- /* clear soc BSPI interrupt */
- soc_intc->bcm_qspi_int_ack(soc_intc, BSPI_DONE);
+ } else if (qspi->soc_intc)
+ /* Ack FIFO full interrupt */
+ soc_intc->bcm_qspi_int_ack(soc_intc,
+ BSPI_FIFO_FULL);
}

status &= INTR_BSPI_LR_SESSION_DONE_MASK;
diff --git a/drivers/spi/spi-bcm-qspi.h b/drivers/spi/spi-bcm-qspi.h
index 01aec6460108..b68e275bc721 100644
--- a/drivers/spi/spi-bcm-qspi.h
+++ b/drivers/spi/spi-bcm-qspi.h
@@ -48,7 +48,8 @@ enum {
MSPI_DONE = 0x1,
BSPI_DONE = 0x2,
BSPI_ERR = 0x4,
- MSPI_BSPI_DONE = 0x7
+ MSPI_BSPI_DONE = 0x7,
+ BSPI_FIFO_FULL = 0x8
};

struct bcm_qspi_soc_intc {
@@ -84,6 +85,8 @@ static inline u32 get_qspi_mask(int type)
return INTR_MSPI_DONE_MASK;
case BSPI_DONE:
return BSPI_LR_INTERRUPTS_ALL;
+ case BSPI_FIFO_FULL:
+ return INTR_BSPI_LR_FULLNESS_REACHED_MASK;
case MSPI_BSPI_DONE:
return QSPI_INTERRUPTS_ALL;
case BSPI_ERR:
--
2.27.0