From 184420df42e66db77aaca2b7697c0098fa3695f7 Mon Sep 17 00:00:00 2001 From: Gary Zhang Date: Thu, 1 Mar 2012 16:23:43 +0800 Subject: ENGR00175219-8 wm8958: add clock management 1. add clko_clk clock management 2. use 'Headphone Jack' name Signed-off-by: Gary Zhang --- sound/soc/imx/Makefile | 4 ++-- sound/soc/imx/imx-wm8958.c | 32 +++++++++++++++++++++++++++----- 2 files changed, 29 insertions(+), 7 deletions(-) (limited to 'sound/soc') diff --git a/sound/soc/imx/Makefile b/sound/soc/imx/Makefile index c1abab092adc..54cc5661446d 100644 --- a/sound/soc/imx/Makefile +++ b/sound/soc/imx/Makefile @@ -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 diff --git a/sound/soc/imx/imx-wm8958.c b/sound/soc/imx/imx-wm8958.c index aadc51822dc0..64ff33e5e418 100755 --- a/sound/soc/imx/imx-wm8958.c +++ b/sound/soc/imx/imx-wm8958.c @@ -26,6 +26,7 @@ #include #include #include +#include #include #include #include @@ -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; } -- cgit v1.2.3