Skip to content

Commit 28dafe3

Browse files
ananglkartben
authored andcommitted
drivers: mspi_dw: Add error reporting on RX FIFO overflow
Immediately finish an RX transfer when the RX FIFO overflow is encountered and return the -EIO error code, which better indicates the problem than -ETIMEDOUT that was returned previously in such case. Signed-off-by: Andrzej Głąbek <[email protected]>
1 parent e4dc744 commit 28dafe3

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

drivers/mspi/mspi_dw.c

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ DEFINE_MM_REG_RD(rxflr, 0x24)
101101
DEFINE_MM_REG_RD(sr, 0x28)
102102
DEFINE_MM_REG_WR(imr, 0x2c)
103103
DEFINE_MM_REG_RD(isr, 0x30)
104+
DEFINE_MM_REG_RD(risr, 0x34)
104105
DEFINE_MM_REG_RD_WR(dr, 0x60)
105106
DEFINE_MM_REG_WR(spi_ctrlr0, 0xf4)
106107

@@ -279,6 +280,11 @@ static void mspi_dw_isr(const struct device *dev)
279280
break;
280281
}
281282

283+
if (read_risr(dev) & RISR_RXOIR_BIT) {
284+
finished = true;
285+
break;
286+
}
287+
282288
int_status = read_isr(dev);
283289
}
284290

@@ -977,7 +983,11 @@ static int start_next_packet(const struct device *dev, k_timeout_t timeout)
977983
write_imr(dev, imr);
978984

979985
rc = k_sem_take(&dev_data->finished, timeout);
980-
if (rc < 0) {
986+
if (read_risr(dev) & RISR_RXOIR_BIT) {
987+
LOG_ERR("RX FIFO overflow occurred");
988+
rc = -EIO;
989+
} else if (rc < 0) {
990+
LOG_ERR("Transfer timed out");
981991
rc = -ETIMEDOUT;
982992
}
983993

drivers/mspi/mspi_dw.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,19 @@
6666
#define ISR_RXFIS_BIT BIT(4)
6767
#define ISR_MSTIS_BIT BIT(5)
6868

69+
/* RISR - Raw Interrupt Status Register */
70+
#define RISR_TXEIR_BIT BIT(0)
71+
#define RISR_TXOIR_BIT BIT(1)
72+
#define RISR_RXUIR_BIT BIT(2)
73+
#define RISR_RXOIR_BIT BIT(3)
74+
#define RISR_RXFIR_BIT BIT(4)
75+
#define RISR_MSTIR_BIT BIT(5)
76+
#define RISR_XRXOIR_BIT BIT(6)
77+
#define RISR_TXUIR_BIT BIT(7)
78+
#define RISR_AXIER_BIT BIT(8)
79+
#define RISR_SPITER_BIT BIT(10)
80+
#define RISR_DONER_BIT BIT(11)
81+
6982
/* SPI_CTRLR0 - SPI Control Register */
7083
#define SPI_CTRLR0_CLK_STRETCH_EN_BIT BIT(30)
7184
#define SPI_CTRLR0_XIP_PREFETCH_EN_BIT BIT(29)

0 commit comments

Comments
 (0)