]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
Merge remote-tracking branches 'asoc/topic/max98090' and 'asoc/topic/max98095' into...
authorMark Brown <broonie@linaro.org>
Tue, 3 Jun 2014 09:39:52 +0000 (10:39 +0100)
committerMark Brown <broonie@linaro.org>
Tue, 3 Jun 2014 09:39:52 +0000 (10:39 +0100)
Documentation/devicetree/bindings/sound/max98090.txt
Documentation/devicetree/bindings/sound/max98095.txt
sound/soc/codecs/max98090.c
sound/soc/codecs/max98090.h
sound/soc/codecs/max98095.c

index e4c8b36dcf89222571216da76e8fd502c7c85546..a5e63fa47dc5d0e6fcb5adc2bbc010158f86b904 100644 (file)
@@ -10,6 +10,12 @@ Required properties:
 
 - interrupts : The CODEC's interrupt output.
 
+Optional properties:
+
+- clocks: The phandle of the master clock to the CODEC
+
+- clock-names: Should be "mclk"
+
 Pins on the device (for linking into audio routes):
 
   * MIC1
index bacbeaac72b5dcc479c50b2f5f161f11cc1244bc..318a4c82f17f8781d3e18a4cc110ade66cd8386b 100644 (file)
@@ -8,6 +8,12 @@ Required properties:
 
 - reg : The I2C address of the device.
 
+Optional properties:
+
+- clocks: The phandle of the master clock to the CODEC
+
+- clock-names: Should be "mclk"
+
 Example:
 
 max98095: codec@11 {
index 9b76f5a4511511125121b493632b85e109f7715b..f5fccc7a8e89b59b42911fb5684d8ab31b775b52 100644 (file)
@@ -17,6 +17,7 @@
 #include <linux/regmap.h>
 #include <linux/slab.h>
 #include <linux/acpi.h>
+#include <linux/clk.h>
 #include <sound/jack.h>
 #include <sound/pcm.h>
 #include <sound/pcm_params.h>
@@ -1547,19 +1548,19 @@ static const int lrclk_rates[] = {
 };
 
 static const int user_pclk_rates[] = {
-       13000000, 13000000
+       13000000, 13000000, 19200000, 19200000,
 };
 
 static const int user_lrclk_rates[] = {
-       44100, 48000
+       44100, 48000, 44100, 48000,
 };
 
 static const unsigned long long ni_value[] = {
-       3528, 768
+       3528, 768, 441, 8
 };
 
 static const unsigned long long mi_value[] = {
-       8125, 1625
+       8125, 1625, 1500, 25
 };
 
 static void max98090_configure_bclk(struct snd_soc_codec *codec)
@@ -1800,6 +1801,19 @@ static int max98090_set_bias_level(struct snd_soc_codec *codec,
                break;
 
        case SND_SOC_BIAS_PREPARE:
+               /*
+                * SND_SOC_BIAS_PREPARE is called while preparing for a
+                * transition to ON or away from ON. If current bias_level
+                * is SND_SOC_BIAS_ON, then it is preparing for a transition
+                * away from ON. Disable the clock in that case, otherwise
+                * enable it.
+                */
+               if (!IS_ERR(max98090->mclk)) {
+                       if (codec->dapm.bias_level == SND_SOC_BIAS_ON)
+                               clk_disable_unprepare(max98090->mclk);
+                       else
+                               clk_prepare_enable(max98090->mclk);
+               }
                break;
 
        case SND_SOC_BIAS_STANDBY:
@@ -1929,6 +1943,11 @@ static int max98090_dai_set_sysclk(struct snd_soc_dai *dai,
        if (freq == max98090->sysclk)
                return 0;
 
+       if (!IS_ERR(max98090->mclk)) {
+               freq = clk_round_rate(max98090->mclk, freq);
+               clk_set_rate(max98090->mclk, freq);
+       }
+
        /* Setup clocks for slave mode, and using the PLL
         * PSCLK = 0x01 (when master clk is 10MHz to 20MHz)
         *               0x02 (when master clk is 20MHz to 40MHz)..
@@ -2213,6 +2232,10 @@ static int max98090_probe(struct snd_soc_codec *codec)
 
        dev_dbg(codec->dev, "max98090_probe\n");
 
+       max98090->mclk = devm_clk_get(codec->dev, "mclk");
+       if (PTR_ERR(max98090->mclk) == -EPROBE_DEFER)
+               return -EPROBE_DEFER;
+
        max98090->codec = codec;
 
        /* Reset the codec, the DSP core, and disable all interrupts */
index 5a3c8d0613cb4e6156f952f99d10e80ffb1d57ae..cf1b6062ba8c6de043fa2ffb46834119e858f936 100644 (file)
@@ -1524,6 +1524,7 @@ struct max98090_priv {
        struct snd_soc_codec *codec;
        enum max98090_type devtype;
        struct max98090_pdata *pdata;
+       struct clk *mclk;
        unsigned int sysclk;
        unsigned int bclk;
        unsigned int lrclk;
index d6c1e4c19a5ab7e17b5d56fb249689023c33e4e2..89ec00424880fb31d2ee2c878164d9e1b755b319 100644 (file)
@@ -15,6 +15,7 @@
 #include <linux/delay.h>
 #include <linux/pm.h>
 #include <linux/i2c.h>
+#include <linux/clk.h>
 #include <sound/core.h>
 #include <sound/pcm.h>
 #include <sound/pcm_params.h>
@@ -42,6 +43,7 @@ struct max98095_priv {
        struct regmap *regmap;
        enum max98095_type devtype;
        struct max98095_pdata *pdata;
+       struct clk *mclk;
        unsigned int sysclk;
        struct max98095_cdata dai[3];
        const char **eq_texts;
@@ -1395,6 +1397,11 @@ static int max98095_dai_set_sysclk(struct snd_soc_dai *dai,
        if (freq == max98095->sysclk)
                return 0;
 
+       if (!IS_ERR(max98095->mclk)) {
+               freq = clk_round_rate(max98095->mclk, freq);
+               clk_set_rate(max98095->mclk, freq);
+       }
+
        /* Setup clocks for slave mode, and using the PLL
         * PSCLK = 0x01 (when master clk is 10MHz to 20MHz)
         *         0x02 (when master clk is 20MHz to 40MHz)..
@@ -1634,6 +1641,19 @@ static int max98095_set_bias_level(struct snd_soc_codec *codec,
                break;
 
        case SND_SOC_BIAS_PREPARE:
+               /*
+                * SND_SOC_BIAS_PREPARE is called while preparing for a
+                * transition to ON or away from ON. If current bias_level
+                * is SND_SOC_BIAS_ON, then it is preparing for a transition
+                * away from ON. Disable the clock in that case, otherwise
+                * enable it.
+                */
+               if (!IS_ERR(max98095->mclk)) {
+                       if (codec->dapm.bias_level == SND_SOC_BIAS_ON)
+                               clk_disable_unprepare(max98095->mclk);
+                       else
+                               clk_prepare_enable(max98095->mclk);
+               }
                break;
 
        case SND_SOC_BIAS_STANDBY:
@@ -2238,6 +2258,10 @@ static int max98095_probe(struct snd_soc_codec *codec)
        struct i2c_client *client;
        int ret = 0;
 
+       max98095->mclk = devm_clk_get(codec->dev, "mclk");
+       if (PTR_ERR(max98095->mclk) == -EPROBE_DEFER)
+               return -EPROBE_DEFER;
+
        /* reset the codec, the DSP core, and disable all interrupts */
        max98095_reset(codec);