diff options
author | Tushar Behera <tushar.behera@linaro.org> | 2014-05-26 04:28:21 -0400 |
---|---|---|
committer | Mark Brown <broonie@linaro.org> | 2014-05-26 11:16:54 -0400 |
commit | b10ab7b838bdd86031aececcb386dc253ef3466f (patch) | |
tree | 08a43428c8c631d06ae9e18def44f654397d4db1 /sound/soc/codecs/max98090.c | |
parent | 2c81a10ae6c6aaef68f8b92b4fc8037d1dfe0d9e (diff) |
ASoC: max98090: Add master clock handling
If master clock is provided through device tree, then update
the master clock frequency during set_sysclk.
Documentation has been updated to reflect the change.
Signed-off-by: Tushar Behera <tushar.behera@linaro.org>
Signed-off-by: Mark Brown <broonie@linaro.org>
Diffstat (limited to 'sound/soc/codecs/max98090.c')
-rw-r--r-- | sound/soc/codecs/max98090.c | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/sound/soc/codecs/max98090.c b/sound/soc/codecs/max98090.c index 4ee1f88760c4..8857be798f3b 100644 --- a/sound/soc/codecs/max98090.c +++ b/sound/soc/codecs/max98090.c | |||
@@ -16,6 +16,7 @@ | |||
16 | #include <linux/regmap.h> | 16 | #include <linux/regmap.h> |
17 | #include <linux/slab.h> | 17 | #include <linux/slab.h> |
18 | #include <linux/acpi.h> | 18 | #include <linux/acpi.h> |
19 | #include <linux/clk.h> | ||
19 | #include <sound/jack.h> | 20 | #include <sound/jack.h> |
20 | #include <sound/pcm.h> | 21 | #include <sound/pcm.h> |
21 | #include <sound/pcm_params.h> | 22 | #include <sound/pcm_params.h> |
@@ -1798,6 +1799,19 @@ static int max98090_set_bias_level(struct snd_soc_codec *codec, | |||
1798 | break; | 1799 | break; |
1799 | 1800 | ||
1800 | case SND_SOC_BIAS_PREPARE: | 1801 | case SND_SOC_BIAS_PREPARE: |
1802 | /* | ||
1803 | * SND_SOC_BIAS_PREPARE is called while preparing for a | ||
1804 | * transition to ON or away from ON. If current bias_level | ||
1805 | * is SND_SOC_BIAS_ON, then it is preparing for a transition | ||
1806 | * away from ON. Disable the clock in that case, otherwise | ||
1807 | * enable it. | ||
1808 | */ | ||
1809 | if (!IS_ERR(max98090->mclk)) { | ||
1810 | if (codec->dapm.bias_level == SND_SOC_BIAS_ON) | ||
1811 | clk_disable_unprepare(max98090->mclk); | ||
1812 | else | ||
1813 | clk_prepare_enable(max98090->mclk); | ||
1814 | } | ||
1801 | break; | 1815 | break; |
1802 | 1816 | ||
1803 | case SND_SOC_BIAS_STANDBY: | 1817 | case SND_SOC_BIAS_STANDBY: |
@@ -1927,6 +1941,11 @@ static int max98090_dai_set_sysclk(struct snd_soc_dai *dai, | |||
1927 | if (freq == max98090->sysclk) | 1941 | if (freq == max98090->sysclk) |
1928 | return 0; | 1942 | return 0; |
1929 | 1943 | ||
1944 | if (!IS_ERR(max98090->mclk)) { | ||
1945 | freq = clk_round_rate(max98090->mclk, freq); | ||
1946 | clk_set_rate(max98090->mclk, freq); | ||
1947 | } | ||
1948 | |||
1930 | /* Setup clocks for slave mode, and using the PLL | 1949 | /* Setup clocks for slave mode, and using the PLL |
1931 | * PSCLK = 0x01 (when master clk is 10MHz to 20MHz) | 1950 | * PSCLK = 0x01 (when master clk is 10MHz to 20MHz) |
1932 | * 0x02 (when master clk is 20MHz to 40MHz).. | 1951 | * 0x02 (when master clk is 20MHz to 40MHz).. |
@@ -2211,6 +2230,10 @@ static int max98090_probe(struct snd_soc_codec *codec) | |||
2211 | 2230 | ||
2212 | dev_dbg(codec->dev, "max98090_probe\n"); | 2231 | dev_dbg(codec->dev, "max98090_probe\n"); |
2213 | 2232 | ||
2233 | max98090->mclk = devm_clk_get(codec->dev, "mclk"); | ||
2234 | if (PTR_ERR(max98090->mclk) == -EPROBE_DEFER) | ||
2235 | return -EPROBE_DEFER; | ||
2236 | |||
2214 | max98090->codec = codec; | 2237 | max98090->codec = codec; |
2215 | 2238 | ||
2216 | /* Reset the codec, the DSP core, and disable all interrupts */ | 2239 | /* Reset the codec, the DSP core, and disable all interrupts */ |