Skip to content

Commit d8b3e39

Browse files
povikbroonie
authored andcommitted
ASoC: apple: mca: Fix SERDES reset sequence
Fix the reset sequence of reads and writes that we invoke from within the early trigger. It looks like there never was a SERDES_CONF_SOME_RST bit that should be involved in the reset sequence, and its presence in the driver code is a mistake from earlier. Instead, the reset sequence should go as follows: We should switch the the SERDES unit's SYNC_SEL mux to the value of 7 (so outside the range of 1...6 representing cluster's SYNCGEN units), then raise the RST bit in SERDES_STATUS and wait for it to clear. Properly resetting the SERDES unit fixes frame desynchronization hazard in case of long frames (longer than 4 used slots). The desynchronization manifests itself by rotating the PCM channels. Fixes: 3df5d0d ("ASoC: apple: mca: Start new platform driver") Signed-off-by: Martin Povišer <povik+lin@cutebit.org> Link: https://lore.kernel.org/r/20230224153302.45365-2-povik+lin@cutebit.org Signed-off-by: Mark Brown <broonie@kernel.org>
1 parent aaf5f0d commit d8b3e39

1 file changed

Lines changed: 13 additions & 5 deletions

File tree

sound/soc/apple/mca.c

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,6 @@
101101
#define SERDES_CONF_UNK3 BIT(14)
102102
#define SERDES_CONF_NO_DATA_FEEDBACK BIT(15)
103103
#define SERDES_CONF_SYNC_SEL GENMASK(18, 16)
104-
#define SERDES_CONF_SOME_RST BIT(19)
105104
#define REG_TX_SERDES_BITSTART 0x08
106105
#define REG_RX_SERDES_BITSTART 0x0c
107106
#define REG_TX_SERDES_SLOTMASK 0x0c
@@ -203,15 +202,24 @@ static void mca_fe_early_trigger(struct snd_pcm_substream *substream, int cmd,
203202
case SNDRV_PCM_TRIGGER_START:
204203
case SNDRV_PCM_TRIGGER_RESUME:
205204
case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
205+
mca_modify(cl, serdes_conf, SERDES_CONF_SYNC_SEL,
206+
FIELD_PREP(SERDES_CONF_SYNC_SEL, 0));
207+
mca_modify(cl, serdes_conf, SERDES_CONF_SYNC_SEL,
208+
FIELD_PREP(SERDES_CONF_SYNC_SEL, 7));
206209
mca_modify(cl, serdes_unit + REG_SERDES_STATUS,
207210
SERDES_STATUS_EN | SERDES_STATUS_RST,
208211
SERDES_STATUS_RST);
209-
mca_modify(cl, serdes_conf, SERDES_CONF_SOME_RST,
210-
SERDES_CONF_SOME_RST);
211-
readl_relaxed(cl->base + serdes_conf);
212-
mca_modify(cl, serdes_conf, SERDES_STATUS_RST, 0);
212+
/*
213+
* Experiments suggest that it takes at most ~1 us
214+
* for the bit to clear, so wait 2 us for good measure.
215+
*/
216+
udelay(2);
213217
WARN_ON(readl_relaxed(cl->base + serdes_unit + REG_SERDES_STATUS) &
214218
SERDES_STATUS_RST);
219+
mca_modify(cl, serdes_conf, SERDES_CONF_SYNC_SEL,
220+
FIELD_PREP(SERDES_CONF_SYNC_SEL, 0));
221+
mca_modify(cl, serdes_conf, SERDES_CONF_SYNC_SEL,
222+
FIELD_PREP(SERDES_CONF_SYNC_SEL, cl->no + 1));
215223
break;
216224
default:
217225
break;

0 commit comments

Comments
 (0)