Skip to content

Commit

Permalink
bcm2835-i2s: setup clock only if CPU is clock master
Browse files Browse the repository at this point in the history
Code ported from bcm2708-i2s driver in Raspberry Pi tree.

RPi commit c14827e ("bcm2708: Allow
option card devices to be configured via DT")

Original work by Zoltan Szenczi, committed to RPi tree by
Phil Elwell.

Signed-off-by: Matthias Reichl <hias@horus.com>
  • Loading branch information
HiassofT authored and popcornmix committed Aug 23, 2016
1 parent 01506b7 commit fb8d849
Showing 1 changed file with 19 additions and 9 deletions.
28 changes: 19 additions & 9 deletions sound/soc/bcm/bcm2835-i2s.c
Expand Up @@ -411,15 +411,25 @@ static int bcm2835_i2s_hw_params(struct snd_pcm_substream *substream,
divf = dividend & BCM2835_CLK_DIVF_MASK;
}

/* Set clock divider */
regmap_write(dev->clk_regmap, BCM2835_CLK_PCMDIV_REG, BCM2835_CLK_PASSWD
| BCM2835_CLK_DIVI(divi)
| BCM2835_CLK_DIVF(divf));

/* Setup clock, but don't start it yet */
regmap_write(dev->clk_regmap, BCM2835_CLK_PCMCTL_REG, BCM2835_CLK_PASSWD
| BCM2835_CLK_MASH(mash)
| BCM2835_CLK_SRC(clk_src));
/* Clock should only be set up here if CPU is clock master */
switch (dev->fmt & SND_SOC_DAIFMT_MASTER_MASK) {
case SND_SOC_DAIFMT_CBS_CFS:
case SND_SOC_DAIFMT_CBS_CFM:
/* Set clock divider */
regmap_write(dev->clk_regmap, BCM2835_CLK_PCMDIV_REG,
BCM2835_CLK_PASSWD
| BCM2835_CLK_DIVI(divi)
| BCM2835_CLK_DIVF(divf));

/* Setup clock, but don't start it yet */
regmap_write(dev->clk_regmap, BCM2835_CLK_PCMCTL_REG,
BCM2835_CLK_PASSWD
| BCM2835_CLK_MASH(mash)
| BCM2835_CLK_SRC(clk_src));
break;
default:
break;
}

/* Setup the frame format */
format = BCM2835_I2S_CHEN;
Expand Down

0 comments on commit fb8d849

Please sign in to comment.