Skip to content

Commit 629bc0a

Browse files
povikjannau
authored andcommitted
ASoC: apple: mca: Fix SYNCGEN enable on FE clock consumers
Signed-off-by: Martin Povišer <povik+lin@cutebit.org>
1 parent 2ff1981 commit 629bc0a

1 file changed

Lines changed: 19 additions & 4 deletions

File tree

sound/soc/apple/mca.c

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,9 @@ struct mca_cluster {
141141
bool clocks_in_use[SNDRV_PCM_STREAM_LAST + 1];
142142
struct device_link *pd_link;
143143

144+
/* In case of clock consumer FE */
145+
int syncgen_in_use;
146+
144147
unsigned int bclk_ratio;
145148

146149
/* Masks etc. picked up via the set_tdm_slot method */
@@ -387,14 +390,24 @@ static int mca_fe_prepare(struct snd_pcm_substream *substream,
387390
if (cl->clk_provider)
388391
return 0;
389392

390-
if (!mca_fe_clocks_in_use(cl)) {
393+
if (!cl->syncgen_in_use) {
391394
int port = mca_fe_get_port(substream);
395+
396+
cl->pd_link = device_link_add(mca->dev, cl->pd_dev,
397+
DL_FLAG_STATELESS | DL_FLAG_PM_RUNTIME |
398+
DL_FLAG_RPM_ACTIVE);
399+
if (!cl->pd_link) {
400+
dev_err(mca->dev,
401+
"cluster %d: unable to prop-up power domain\n", cl->no);
402+
return -EINVAL;
403+
}
404+
392405
writel_relaxed(port + 6 + 1,
393406
cl->base + REG_SYNCGEN_MCLK_SEL);
394407
mca_modify(cl, REG_SYNCGEN_STATUS, SYNCGEN_STATUS_EN,
395408
SYNCGEN_STATUS_EN);
396409
}
397-
cl->clocks_in_use[substream->stream] = true;
410+
cl->syncgen_in_use |= 1 << substream->stream;
398411

399412
return 0;
400413
}
@@ -407,11 +420,13 @@ static int mca_fe_hw_free(struct snd_pcm_substream *substream,
407420
if (cl->clk_provider)
408421
return 0;
409422

410-
cl->clocks_in_use[substream->stream] = false;
411-
if (mca_fe_clocks_in_use(cl))
423+
cl->syncgen_in_use &= ~(1 << substream->stream);
424+
if (cl->syncgen_in_use)
412425
return 0;
413426

414427
mca_modify(cl, REG_SYNCGEN_STATUS, SYNCGEN_STATUS_EN, 0);
428+
if (cl->pd_link)
429+
device_link_del(cl->pd_link);
415430

416431
return 0;
417432
}

0 commit comments

Comments
 (0)