Skip to content

Commit f0fd22d

Browse files
authored
Merge pull request #159 from zhigang-wu/topic/capture-noise
byt:ssp:porting the patch dcc6149 to clear fifo.
2 parents 0a1587b + 3d3313d commit f0fd22d

2 files changed

Lines changed: 33 additions & 0 deletions

File tree

src/drivers/byt-ssp.c

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,32 @@ static int hweight_32(uint32_t mask)
5454
return count;
5555
}
5656

57+
/* empty SSP receive FIFO */
58+
static void ssp_empty_rx_fifo(struct dai *dai)
59+
{
60+
struct ssp_pdata *ssp = dai_get_drvdata(dai);
61+
uint32_t sssr;
62+
uint32_t entries;
63+
uint32_t i;
64+
65+
spin_lock(&ssp->lock);
66+
67+
sssr = ssp_read(dai, SSSR);
68+
69+
/* clear interrupt */
70+
if (sssr & SSSR_ROR)
71+
ssp_write(dai, SSSR, sssr);
72+
73+
/* empty fifo */
74+
if (sssr & SSSR_RNE) {
75+
entries = SFIFOL_RFL(ssp_read(dai, SFIFOL));
76+
for (i = 0; i < entries + 1; i++)
77+
ssp_read(dai, SSDR);
78+
}
79+
80+
spin_unlock(&ssp->lock);
81+
}
82+
5783
/* save SSP context prior to entering D3 */
5884
static int ssp_context_store(struct dai *dai)
5985
{
@@ -500,6 +526,7 @@ static void ssp_stop(struct dai *dai, int direction)
500526
if (direction == DAI_DIR_CAPTURE &&
501527
ssp->state[SOF_IPC_STREAM_CAPTURE] == COMP_STATE_ACTIVE) {
502528
ssp_update_bits(dai, SSCR1, SSCR1_RSRE, 0);
529+
ssp_empty_rx_fifo(dai);
503530
ssp->state[SOF_IPC_STREAM_CAPTURE] = COMP_STATE_PAUSED;
504531
trace_ssp("Ss0");
505532
}
@@ -598,6 +625,7 @@ static int ssp_probe(struct dai *dai)
598625
platform_interrupt_unmask(ssp_irq(dai), 1);
599626
interrupt_enable(ssp_irq(dai));
600627

628+
ssp_empty_rx_fifo(dai);
601629
return 0;
602630
}
603631

src/include/sof/ssp.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@
6161
defined CONFIG_CHERRYTRAIL ||\
6262
defined CONFIG_BROADWELL ||\
6363
defined CONFIG_HASWELL
64+
#define SFIFOL 0x68
6465
#define SFIFOTT 0x6C
6566
#define SSCR3 0x70
6667
#define SSCR4 0x74
@@ -198,6 +199,10 @@ extern const struct dai_ops ssp_ops;
198199
#define SFIFOTT_TX(x) ((x) - 1)
199200
#define SFIFOTT_RX(x) (((x) - 1) << 16)
200201

202+
/* SFIFOL bits */
203+
#define SFIFOL_TFL(x) ((x) & 0xFFFF)
204+
#define SFIFOL_RFL(x) ((x) >> 16)
205+
201206
#if defined CONFIG_APOLLOLAKE || defined CONFIG_CANNONLAKE ||\
202207
defined CONFIG_HASWELL || defined CONFIG_BROADWELL
203208
#define SSTSA_TSEN BIT(8)

0 commit comments

Comments
 (0)