Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 556e7c13 authored by Vipin Deep Kaur's avatar Vipin Deep Kaur
Browse files

spi: spi-qcom-geni: Clear the RX fifo if FIFO has data after timeout



Dummy read the rx fifo in case RX fifo has data after a timeout. This
is to clear the spurious rx watermark interrupt that keeps firing due
to stale data in the rx fifo.

Change-Id: I4094261e00d61b07cd53a7ae508efdad73c3f022
Signed-off-by: default avatarVipin Deep Kaur <vkaur@codeaurora.org>
parent f24a5982
Loading
Loading
Loading
Loading
+12 −0
Original line number Diff line number Diff line
@@ -1162,9 +1162,21 @@ static void handle_fifo_timeout(struct spi_geni_master *mas,
					struct spi_transfer *xfer)
{
	unsigned long timeout;
	u32 rx_fifo_status;
	int rx_wc, i;

	geni_se_dump_dbg_regs(&mas->spi_rsc, mas->base, mas->ipc);
	reinit_completion(&mas->xfer_done);

	/* Dummy read the rx fifo for any spurious data*/
	if (xfer->rx_buf) {
		rx_fifo_status = geni_read_reg(mas->base,
					SE_GENI_RX_FIFO_STATUS);
		rx_wc = (rx_fifo_status & RX_FIFO_WC_MSK);
		for (i = 0; i < rx_wc; i++)
			geni_read_reg(mas->base, SE_GENI_RX_FIFOn);
	}

	geni_cancel_m_cmd(mas->base);
	if (mas->cur_xfer_mode == FIFO_MODE)
		geni_write_reg(0, mas->base, SE_GENI_TX_WATERMARK_REG);