]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commitdiff
ASoC: cs42l51: fix mclk support
authorOlivier Moysan <olivier.moysan@st.com>
Fri, 19 Oct 2018 15:56:35 +0000 (17:56 +0200)
committerMark Brown <broonie@kernel.org>
Fri, 19 Oct 2018 16:06:07 +0000 (17:06 +0100)
The MCLK clock is made optional for cs42l51 codec.
However, ASoC DAPM clock supply widget, expects the clock to be defined
unconditionally.
Register MCLK DAPM conditionally in codec driver,
depending on clock presence in DT.

Fixes: 5e8d63a726f8 ("ASoC: cs42l51: add mclk support")
Signed-off-by: Olivier Moysan <olivier.moysan@st.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
sound/soc/codecs/cs42l51.c

index eb40bff54cec98a35f2b96f57e465d9701c7385a..fd2bd74024c1d5af5e0555bbdc91aadd2c016078 100644 (file)
@@ -21,6 +21,7 @@
  *  - master mode *NOT* supported
  */
 
+#include <linux/clk.h>
 #include <linux/module.h>
 #include <linux/slab.h>
 #include <sound/core.h>
@@ -41,6 +42,7 @@ enum master_slave_mode {
 
 struct cs42l51_private {
        unsigned int mclk;
+       struct clk *mclk_handle;
        unsigned int audio_mode;        /* The mode (I2S or left-justified) */
        enum master_slave_mode func;
 };
@@ -492,9 +494,13 @@ static int cs42l51_component_probe(struct snd_soc_component *component)
 {
        int ret, reg;
        struct snd_soc_dapm_context *dapm;
+       struct cs42l51_private *cs42l51;
 
+       cs42l51 = snd_soc_component_get_drvdata(component);
        dapm = snd_soc_component_get_dapm(component);
-       snd_soc_dapm_new_controls(dapm, cs42l51_dapm_mclk_widgets, 1);
+
+       if (cs42l51->mclk_handle)
+               snd_soc_dapm_new_controls(dapm, cs42l51_dapm_mclk_widgets, 1);
 
        /*
         * DAC configuration
@@ -548,6 +554,13 @@ int cs42l51_probe(struct device *dev, struct regmap *regmap)
 
        dev_set_drvdata(dev, cs42l51);
 
+       cs42l51->mclk_handle = devm_clk_get(dev, "MCLK");
+       if (IS_ERR(cs42l51->mclk_handle)) {
+               if (PTR_ERR(cs42l51->mclk_handle) != -ENOENT)
+                       return PTR_ERR(cs42l51->mclk_handle);
+               cs42l51->mclk_handle = NULL;
+       }
+
        /* Verify that we have a CS42L51 */
        ret = regmap_read(regmap, CS42L51_CHIP_REV_ID, &val);
        if (ret < 0) {