Skip to content

Commit 2d117b1

Browse files
kv2019iabonislawski
authored andcommitted
intel: ssp: do not read data directly if DMA is active
If DMA is active, do not read data directly from the SSP RX fifo. Signed-off-by: Kai Vehmanen <kai.vehmanen@linux.intel.com> (cherry picked from commit e94071f) (cherry picked from commit 736af01)
1 parent 6dc3504 commit 2d117b1

1 file changed

Lines changed: 15 additions & 3 deletions

File tree

  • src/drivers/intel/ssp

src/drivers/intel/ssp/ssp.c

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,18 @@ static void ssp_empty_rx_fifo(struct dai *dai)
7171
uint64_t sample_ticks = clock_ticks_per_sample(PLATFORM_DEFAULT_CLOCK,
7272
ssp->params.fsync_rate);
7373
uint32_t retry = SSP_RX_FLUSH_RETRY_MAX;
74+
bool direct_reads = ssp->state[DAI_DIR_CAPTURE] <= COMP_STATE_PREPARE;
7475
uint32_t entries;
7576
uint32_t i;
7677

78+
#if CONFIG_DMA_SUSPEND_DRAIN
79+
/*
80+
* In drain mode, DMA is stopped before DAI, so flush must be
81+
* always done with direct register read.
82+
*/
83+
direct_reads = true;
84+
#endif
85+
7786
/*
7887
* To make sure all the RX FIFO entries are read out for the flushing,
7988
* we need to wait a minimal SSP port delay after entries are all read,
@@ -84,9 +93,12 @@ static void ssp_empty_rx_fifo(struct dai *dai)
8493
while ((ssp_read(dai, SSSR) & SSSR_RNE) && retry--) {
8594
entries = SSCR3_RFL_VAL(ssp_read(dai, SSCR3));
8695
dai_dbg(dai, "ssp_empty_rx_fifo(), before flushing, entries %d", entries);
87-
for (i = 0; i < entries + 1; i++)
88-
/* read to try empty fifo */
89-
ssp_read(dai, SSDR);
96+
97+
/* let DMA consume data or read RX FIFO directly */
98+
if (direct_reads) {
99+
for (i = 0; i < entries + 1; i++)
100+
ssp_read(dai, SSDR);
101+
}
90102

91103
/* wait to get valid fifo status and re-check */
92104
wait_delay(sample_ticks);

0 commit comments

Comments
 (0)