aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Documentation/devicetree/bindings/sound/max98095.txt6
-rw-r--r--sound/soc/codecs/max98095.c24
2 files changed, 30 insertions, 0 deletions
diff --git a/Documentation/devicetree/bindings/sound/max98095.txt b/Documentation/devicetree/bindings/sound/max98095.txt
index bacbeaac72b5..318a4c82f17f 100644
--- a/Documentation/devicetree/bindings/sound/max98095.txt
+++ b/Documentation/devicetree/bindings/sound/max98095.txt
@@ -8,6 +8,12 @@ Required properties:
8 8
9- reg : The I2C address of the device. 9- reg : The I2C address of the device.
10 10
11Optional properties:
12
13- clocks: The phandle of the master clock to the CODEC
14
15- clock-names: Should be "mclk"
16
11Example: 17Example:
12 18
13max98095: codec@11 { 19max98095: codec@11 {
diff --git a/sound/soc/codecs/max98095.c b/sound/soc/codecs/max98095.c
index 8e548af9eac8..7dbca28875fe 100644
--- a/sound/soc/codecs/max98095.c
+++ b/sound/soc/codecs/max98095.c
@@ -15,6 +15,7 @@
15#include <linux/delay.h> 15#include <linux/delay.h>
16#include <linux/pm.h> 16#include <linux/pm.h>
17#include <linux/i2c.h> 17#include <linux/i2c.h>
18#include <linux/clk.h>
18#include <sound/core.h> 19#include <sound/core.h>
19#include <sound/pcm.h> 20#include <sound/pcm.h>
20#include <sound/pcm_params.h> 21#include <sound/pcm_params.h>
@@ -42,6 +43,7 @@ struct max98095_priv {
42 struct regmap *regmap; 43 struct regmap *regmap;
43 enum max98095_type devtype; 44 enum max98095_type devtype;
44 struct max98095_pdata *pdata; 45 struct max98095_pdata *pdata;
46 struct clk *mclk;
45 unsigned int sysclk; 47 unsigned int sysclk;
46 struct max98095_cdata dai[3]; 48 struct max98095_cdata dai[3];
47 const char **eq_texts; 49 const char **eq_texts;
@@ -1395,6 +1397,11 @@ static int max98095_dai_set_sysclk(struct snd_soc_dai *dai,
1395 if (freq == max98095->sysclk) 1397 if (freq == max98095->sysclk)
1396 return 0; 1398 return 0;
1397 1399
1400 if (!IS_ERR(max98095->mclk)) {
1401 freq = clk_round_rate(max98095->mclk, freq);
1402 clk_set_rate(max98095->mclk, freq);
1403 }
1404
1398 /* Setup clocks for slave mode, and using the PLL 1405 /* Setup clocks for slave mode, and using the PLL
1399 * PSCLK = 0x01 (when master clk is 10MHz to 20MHz) 1406 * PSCLK = 0x01 (when master clk is 10MHz to 20MHz)
1400 * 0x02 (when master clk is 20MHz to 40MHz).. 1407 * 0x02 (when master clk is 20MHz to 40MHz)..
@@ -1634,6 +1641,19 @@ static int max98095_set_bias_level(struct snd_soc_codec *codec,
1634 break; 1641 break;
1635 1642
1636 case SND_SOC_BIAS_PREPARE: 1643 case SND_SOC_BIAS_PREPARE:
1644 /*
1645 * SND_SOC_BIAS_PREPARE is called while preparing for a
1646 * transition to ON or away from ON. If current bias_level
1647 * is SND_SOC_BIAS_ON, then it is preparing for a transition
1648 * away from ON. Disable the clock in that case, otherwise
1649 * enable it.
1650 */
1651 if (!IS_ERR(max98095->mclk)) {
1652 if (codec->dapm.bias_level == SND_SOC_BIAS_ON)
1653 clk_disable_unprepare(max98095->mclk);
1654 else
1655 clk_prepare_enable(max98095->mclk);
1656 }
1637 break; 1657 break;
1638 1658
1639 case SND_SOC_BIAS_STANDBY: 1659 case SND_SOC_BIAS_STANDBY:
@@ -2238,6 +2258,10 @@ static int max98095_probe(struct snd_soc_codec *codec)
2238 struct i2c_client *client; 2258 struct i2c_client *client;
2239 int ret = 0; 2259 int ret = 0;
2240 2260
2261 max98095->mclk = devm_clk_get(codec->dev, "mclk");
2262 if (PTR_ERR(max98095->mclk) == -EPROBE_DEFER)
2263 return -EPROBE_DEFER;
2264
2241 /* reset the codec, the DSP core, and disable all interrupts */ 2265 /* reset the codec, the DSP core, and disable all interrupts */
2242 max98095_reset(codec); 2266 max98095_reset(codec);
2243 2267