ENGR00175219-8 wm8958: add clock management
authorGary Zhang <b13634@freescale.com>
Thu, 1 Mar 2012 08:23:43 +0000 (16:23 +0800)
committerGary Zhang <b13634@freescale.com>
Fri, 2 Mar 2012 07:44:08 +0000 (15:44 +0800)
1. add clko_clk clock management
2. use 'Headphone Jack' name

Signed-off-by: Gary Zhang <b13634@freescale.com>
sound/soc/imx/Makefile
sound/soc/imx/imx-wm8958.c

index c1abab092adc6765b65486a614b79a47333fa4c3..54cc5661446d48312240696fef3b1020b75c4cd4 100644 (file)
@@ -24,8 +24,8 @@ obj-$(CONFIG_SND_SOC_EUKREA_TLV320) += snd-soc-eukrea-tlv320.o
 obj-$(CONFIG_SND_SOC_PHYCORE_AC97) += snd-soc-phycore-ac97.o
 obj-$(CONFIG_SND_SOC_MX27VIS_AIC32X4) += snd-soc-mx27vis-aic32x4.o
 obj-$(CONFIG_SND_MXC_SOC_WM1133_EV1) += snd-soc-wm1133-ev1.o
+obj-$(CONFIG_SND_SOC_IMX_WM8958) += snd-soc-imx-wm8958.o
 obj-$(CONFIG_SND_SOC_IMX_SGTL5000) += snd-soc-imx-sgtl5000.o
 obj-$(CONFIG_SND_SOC_IMX_CS42888) += snd-soc-imx-cs42888.o
 obj-$(CONFIG_SND_SOC_IMX_SPDIF) += snd-soc-imx-spdif.o
-obj-$(CONFIG_SND_SOC_IMX_HDMI) += snd-soc-imx-hdmi.o
-obj-$(CONFIG_SND_SOC_IMX_WM8958) += snd-soc-imx-wm8958.o
\ No newline at end of file
+obj-$(CONFIG_SND_SOC_IMX_HDMI) += snd-soc-imx-hdmi.o
\ No newline at end of file
index aadc51822dc09de41ffd578943c39874aca9fcd6..64ff33e5e418b9cbcb8689d3fc8ed4b2a5d8c069 100755 (executable)
@@ -26,6 +26,7 @@
 #include <linux/io.h>
 #include <linux/fsl_devices.h>
 #include <linux/slab.h>
+#include <linux/clk.h>
 #include <sound/core.h>
 #include <sound/pcm.h>
 #include <sound/pcm_params.h>
@@ -50,7 +51,7 @@ struct imx_priv {
 };
 static struct imx_priv card_priv;
 static struct snd_soc_card snd_soc_card_imx;
-
+struct clk *codec_mclk;
 static struct snd_soc_jack hs_jack;
 
 /* Headphones jack detection DAPM pins */
@@ -73,11 +74,23 @@ static struct snd_soc_jack_gpio hs_jack_gpios[] = {
 
 static int imx_hifi_startup(struct snd_pcm_substream *substream)
 {
+       struct snd_soc_pcm_runtime *rtd = substream->private_data;
+       struct snd_soc_dai *codec_dai = rtd->codec_dai;
+
+       if (!codec_dai->active)
+               clk_enable(codec_mclk);
+
        return 0;
 }
 
 static void imx_hifi_shutdown(struct snd_pcm_substream *substream)
 {
+       struct snd_soc_pcm_runtime *rtd = substream->private_data;
+       struct snd_soc_dai *codec_dai = rtd->codec_dai;
+
+       if (!codec_dai->active)
+               clk_disable(codec_mclk);
+
        return;
 }
 
@@ -141,7 +154,7 @@ static int imx_hifi_hw_params(struct snd_pcm_substream *substream,
 static const struct snd_soc_dapm_widget imx_dapm_widgets[] = {
        SND_SOC_DAPM_MIC("Headset Mic", NULL),
        SND_SOC_DAPM_MIC("Main Mic", NULL),
-       SND_SOC_DAPM_HP("Headset Phone", NULL),
+       SND_SOC_DAPM_HP("Headphone Jack", NULL),
        SND_SOC_DAPM_SPK("Ext Spk", NULL),
 };
 
@@ -159,8 +172,8 @@ static const struct snd_soc_dapm_route audio_map[] = {
 
        /* ----output------------------- */
        /* HP_OUT --> Headphone Jack */
-       {"Headset Phone", NULL, "HPOUT1L"},
-       {"Headset Phone", NULL, "HPOUT1R"},
+       {"Headphone Jack", NULL, "HPOUT1L"},
+       {"Headphone Jack", NULL, "HPOUT1R"},
 
        /* LINE_OUT --> Ext Speaker */
        {"Ext Spk", NULL, "SPKOUTLP"},
@@ -182,7 +195,7 @@ static int imx_wm8958_init(struct snd_soc_pcm_runtime *rtd)
        /* Set up imx specific audio path audio_map */
        snd_soc_dapm_add_routes(&codec->dapm, audio_map, ARRAY_SIZE(audio_map));
 
-       snd_soc_dapm_enable_pin(&codec->dapm, "Headset Phone");
+       snd_soc_dapm_enable_pin(&codec->dapm, "Headphone Jack");
 
        snd_soc_dapm_sync(&codec->dapm);
 
@@ -266,6 +279,12 @@ static int __devinit imx_wm8958_probe(struct platform_device *pdev)
        struct wm8994 *wm8958 = plat->priv;
        int ret = 0;
 
+       codec_mclk = clk_get(NULL, "clko_clk");
+       if (IS_ERR(codec_mclk)) {
+               printk(KERN_ERR "can't get CLKO clock.\n");
+               return PTR_ERR(codec_mclk);
+       }
+
        priv->pdev = pdev;
        priv->wm8958 = wm8958;
 
@@ -290,6 +309,9 @@ static int __devexit imx_wm8958_remove(struct platform_device *pdev)
        if (plat->finit)
                plat->finit();
 
+       clk_disable(codec_mclk);
+       clk_put(codec_mclk);
+
        return 0;
 }