Skip to content

Commit

Permalink
mpfs_corespi: Fix firing of stale interrupt after warm reset
Browse files Browse the repository at this point in the history
After warm reset the interrupt source in the HW block is not explicitly
cleared, thus once the interrupt source is enabled the old / stale interrupt
fires immediately.

This causes a DEBUGASSERT() failure on line 808 mpfs_spi_unload_rx_fifo:
  DEBUGASSERT(nwords > 0);
  • Loading branch information
pussuw committed Jan 18, 2024
1 parent 53e0cf5 commit a007668
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions arch/risc-v/src/mpfs/mpfs_corespi.c
Original file line number Diff line number Diff line change
Expand Up @@ -1434,6 +1434,22 @@ static void mpfs_spi_init(struct spi_dev_s *dev)
mpfs_spi_set_master_mode(priv, 1);
mpfs_spi_enable(priv, 1);

/* Disable all interrupt sources */

modifyreg32(MPFS_SPI_CONTROL, MPFS_SPI_INTTXTURUN |
MPFS_SPI_INTRXOVRFLOW |
MPFS_SPI_INTTXDONE,
0);

/* Clear all interrupt sources */

putreg32(MPFS_SPI_TXCHUNDRUN |
MPFS_SPI_RXCHOVRFLW |
MPFS_SPI_DATA_RX |
MPFS_SPI_TXDONE, MPFS_SPI_INT_CLEAR);

/* Then enable the interrupt */

up_enable_irq(priv->plic_irq);
}

Expand Down

0 comments on commit a007668

Please sign in to comment.