Skip to content

Commit 7e3e234

Browse files
authored
Merge pull request #150 from bkokoszx/ssp_master_slave_hwd
apl-ssp: setting additional bits in ssp registers
2 parents 0375c21 + effa56f commit 7e3e234

3 files changed

Lines changed: 91 additions & 3 deletions

File tree

src/drivers/apl-ssp.c

Lines changed: 67 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,7 @@ static inline int ssp_set_config(struct dai *dai,
149149
uint32_t sample_width = 2;
150150

151151
bool inverted_frame = false;
152+
bool cfs = false;
152153
int ret = 0;
153154

154155
spin_lock(&ssp->lock);
@@ -215,10 +216,13 @@ static inline int ssp_set_config(struct dai *dai,
215216
break;
216217
case SOF_DAI_FMT_CBS_CFS:
217218
sscr1 |= SSCR1_SCFR;
219+
cfs = true;
218220
break;
219221
case SOF_DAI_FMT_CBM_CFS:
220222
sscr1 |= SSCR1_SCLKDIR;
221223
/* FIXME: this mode has not been tested */
224+
225+
cfs = true;
222226
break;
223227
case SOF_DAI_FMT_CBS_CFM:
224228
sscr1 |= SSCR1_SCFR | SSCR1_SFRMDIR;
@@ -255,6 +259,40 @@ static inline int ssp_set_config(struct dai *dai,
255259
mdivc = mn_reg_read(0x0);
256260
mdivc |= 0x1;
257261

262+
/* Additional hardware settings */
263+
264+
/* Receiver Time-out Interrupt Disabled/Enabled */
265+
sscr1 |= (ssp->params.quirks & SOF_DAI_INTEL_SSP_QUIRK_TINTE) ?
266+
SSCR1_TINTE : 0;
267+
268+
/* Peripheral Trailing Byte Interrupts Disable/Enable */
269+
sscr1 |= (ssp->params.quirks & SOF_DAI_INTEL_SSP_QUIRK_PINTE) ?
270+
SSCR1_PINTE : 0;
271+
272+
/* Transmit data are driven at the same/opposite clock edge specified
273+
* in SSPSP.SCMODE[1:0]
274+
*/
275+
sscr2 |= (ssp->params.quirks & SOF_DAI_INTEL_SSP_QUIRK_SMTATF) ?
276+
SSCR2_SMTATF : 0;
277+
278+
/* Receive data are sampled at the same/opposite clock edge specified
279+
* in SSPSP.SCMODE[1:0]
280+
*/
281+
sscr2 |= (ssp->params.quirks & SOF_DAI_INTEL_SSP_QUIRK_MMRATF) ?
282+
SSCR2_MMRATF : 0;
283+
284+
/* Enable/disable the fix for PSP slave mode TXD wait for frame
285+
* de-assertion before starting the second channel
286+
*/
287+
sscr2 |= (ssp->params.quirks & SOF_DAI_INTEL_SSP_QUIRK_PSPSTWFDFD) ?
288+
SSCR2_PSPSTWFDFD : 0;
289+
290+
/* Enable/disable the fix for PSP master mode FSRT with dummy stop &
291+
* frame end padding capability
292+
*/
293+
sscr2 |= (ssp->params.quirks & SOF_DAI_INTEL_SSP_QUIRK_PSPSRWFDFD) ?
294+
SSCR2_PSPSRWFDFD : 0;
295+
258296
#ifdef CONFIG_CANNONLAKE
259297
if (!config->ssp.mclk_rate || config->ssp.mclk_rate > F_24000_kHz) {
260298
trace_ssp_error("eci");
@@ -503,7 +541,21 @@ static inline int ssp_set_config(struct dai *dai,
503541
sscr0 |= SSCR0_MOD | SSCR0_FRDC(config->ssp.tdm_slots);
504542

505543
/* set asserted frame length */
506-
frame_len = 1;
544+
frame_len = 1; /* default */
545+
546+
if (cfs && ssp->params.frame_pulse_width > 0 &&
547+
ssp->params.frame_pulse_width <=
548+
SOF_DAI_INTEL_SSP_FRAME_PULSE_WIDTH_MAX) {
549+
frame_len = ssp->params.frame_pulse_width;
550+
}
551+
552+
/* frame_pulse_width must less or equal 38 */
553+
if (ssp->params.frame_pulse_width >
554+
SOF_DAI_INTEL_SSP_FRAME_PULSE_WIDTH_MAX) {
555+
trace_ssp_error("efa");
556+
ret = -EINVAL;
557+
goto out;
558+
}
507559

508560
/*
509561
* handle frame polarity, DSP_A default is rising/active high,
@@ -527,8 +579,21 @@ static inline int ssp_set_config(struct dai *dai,
527579
sscr0 |= SSCR0_MOD | SSCR0_FRDC(config->ssp.tdm_slots);
528580

529581
/* set asserted frame length */
530-
frame_len = 1;
582+
frame_len = 1; /* default */
531583

584+
if (cfs && ssp->params.frame_pulse_width > 0 &&
585+
ssp->params.frame_pulse_width <=
586+
SOF_DAI_INTEL_SSP_FRAME_PULSE_WIDTH_MAX) {
587+
frame_len = ssp->params.frame_pulse_width;
588+
}
589+
590+
/* frame_pulse_width must less or equal 38 */
591+
if (ssp->params.frame_pulse_width >
592+
SOF_DAI_INTEL_SSP_FRAME_PULSE_WIDTH_MAX) {
593+
trace_ssp_error("efb");
594+
ret = -EINVAL;
595+
goto out;
596+
}
532597
/*
533598
* handle frame polarity, DSP_B default is rising/active high,
534599
* non-inverted(inverted_frame=0) -- active high(SFRMP=1),

src/include/sof/ssp.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,9 +134,13 @@ extern const struct dai_ops ssp_ops;
134134
#elif defined CONFIG_APOLLOLAKE || defined CONFIG_CANNONLAKE \
135135
|| defined CONFIG_HASWELL || defined CONFIG_BROADWELL
136136
#define SSCR2_TURM1 BIT(1)
137+
#define SSCR2_PSPSRWFDFD BIT(3)
138+
#define SSCR2_PSPSTWFDFD BIT(4)
137139
#define SSCR2_SDFD BIT(14)
138140
#define SSCR2_SDPM BIT(16)
139141
#define SSCR2_LJDFD BIT(17)
142+
#define SSCR2_MMRATF BIT(18)
143+
#define SSCR2_SMTATF BIT(19)
140144
#endif
141145

142146

src/include/uapi/ipc.h

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,23 @@ struct sof_ipc_compound_hdr {
226226
#define SOF_DAI_FMT_INV_MASK 0x0f00
227227
#define SOF_DAI_FMT_MASTER_MASK 0xf000
228228

229+
/* ssc1: TINTE */
230+
#define SOF_DAI_INTEL_SSP_QUIRK_TINTE (1 << 0)
231+
/* ssc1: PINTE */
232+
#define SOF_DAI_INTEL_SSP_QUIRK_PINTE (1 << 1)
233+
/* ssc2: SMTATF */
234+
#define SOF_DAI_INTEL_SSP_QUIRK_SMTATF (1 << 2)
235+
/* ssc2: MMRATF */
236+
#define SOF_DAI_INTEL_SSP_QUIRK_MMRATF (1 << 3)
237+
/* ssc2: PSPSTWFDFD */
238+
#define SOF_DAI_INTEL_SSP_QUIRK_PSPSTWFDFD (1 << 4)
239+
/* ssc2: PSPSRWFDFD */
240+
#define SOF_DAI_INTEL_SSP_QUIRK_PSPSRWFDFD (1 << 5)
241+
/* here is the possibility to define others aux macros */
242+
243+
244+
#define SOF_DAI_INTEL_SSP_FRAME_PULSE_WIDTH_MAX 38
245+
229246
/** \brief Types of DAI */
230247
enum sof_ipc_dai_type {
231248
SOF_DAI_INTEL_NONE = 0, /**< None */
@@ -259,8 +276,10 @@ struct sof_ipc_dai_ssp_params {
259276
uint32_t bclk_keep_active;
260277
uint32_t fs_keep_active;
261278

262-
//uint32_t quirks; // FIXME: is 32 bits enough ?
279+
uint16_t frame_pulse_width;
280+
uint32_t quirks; // FIXME: is 32 bits enough ?
263281

282+
uint16_t padding;
264283
/* private data, e.g. for quirks */
265284
//uint32_t pdata[10]; // FIXME: would really need ~16 u32
266285
} __attribute__((packed));

0 commit comments

Comments
 (0)