diff --git a/src/drivers/intel/ssp/ssp.c b/src/drivers/intel/ssp/ssp.c index 16e9e1727768..daf8f05464cd 100644 --- a/src/drivers/intel/ssp/ssp.c +++ b/src/drivers/intel/ssp/ssp.c @@ -74,9 +74,18 @@ static void ssp_empty_rx_fifo(struct dai *dai) uint64_t sample_ticks = clock_ticks_per_sample(PLATFORM_DEFAULT_CLOCK, ssp->params.fsync_rate); uint32_t retry = SSP_RX_FLUSH_RETRY_MAX; + bool read_ssdr = ssp->state[DAI_DIR_CAPTURE] <= COMP_STATE_PREPARE; uint32_t entries; uint32_t i; +#if CONFIG_DMA_SUSPEND_DRAIN + /* + * in drain mode, DMA is stopped before DAI, + * so flush must be done with direct register read + */ + read_ssdr = true; +#endif + /* * To make sure all the RX FIFO entries are read out for the flushing, * we need to wait a minimal SSP port delay after entries are all read, @@ -87,7 +96,8 @@ static void ssp_empty_rx_fifo(struct dai *dai) while ((ssp_read(dai, SSSR) & SSSR_RNE) && retry--) { entries = SSCR3_RFL_VAL(ssp_read(dai, SSCR3)); dai_dbg(dai, "ssp_empty_rx_fifo(), before flushing, entries %d", entries); - for (i = 0; i < entries + 1; i++) + + for (i = 0; read_ssdr && i < entries + 1; i++) /* read to try empty fifo */ ssp_read(dai, SSDR); @@ -963,6 +973,11 @@ static void ssp_early_start(struct dai *dai, int direction) key = k_spin_lock(&dai->lock); + if (direction == DAI_DIR_CAPTURE) { + /* RX fifo must be cleared before start */ + ssp_empty_rx_fifo(dai); + } + /* request mclk/bclk */ ssp_pre_start(dai);