From 8f23e308ab4676319ee5d3f054e500448dfe17db Mon Sep 17 00:00:00 2001 From: Hemanth Puranik Date: Tue, 13 Dec 2011 10:07:05 +0530 Subject: ASoC: Ux500: Audio driver not requesting for clocks it uses Driver was modified to request for sysclk. sysclk is requested using the clock framework. ST-Ericsson ID: 343921 ST-Ericsson Linux next: NA ST-Ericsson FOSS-OUT ID: Trivial Change-Id: Id4f7d8a7af57211ba07801110758ab6c58acadf2 Signed-off-by: Hemanth Puranik Reviewed-on: http://gerrit.lud.stericsson.com/gerrit/42271 Reviewed-by: Amaresh MULAGE Reviewed-by: Rabin VINCENT --- sound/soc/ux500/u5500.c | 4 +-- sound/soc/ux500/ux500_ab5500.c | 74 ++++++++++++++++++++++++++++++++++++++++-- sound/soc/ux500/ux500_ab5500.h | 4 +++ 3 files changed, 78 insertions(+), 4 deletions(-) mode change 100644 => 100755 sound/soc/ux500/u5500.c mode change 100644 => 100755 sound/soc/ux500/ux500_ab5500.c mode change 100644 => 100755 sound/soc/ux500/ux500_ab5500.h (limited to 'sound') diff --git a/sound/soc/ux500/u5500.c b/sound/soc/ux500/u5500.c old mode 100644 new mode 100755 index 75f5a3ca1e1..1d17830c1c7 --- a/sound/soc/ux500/u5500.c +++ b/sound/soc/ux500/u5500.c @@ -70,7 +70,7 @@ struct snd_soc_dai_link u5500_dai_links[] = { .codec_dai_name = "ab5500-codec-dai.0", .platform_name = "ux500-pcm.0", .codec_name = "ab5500-codec.0", - .init = NULL, + .init = ux500_ab5500_machine_codec_init, .ops = (struct snd_soc_ops[]) { { .startup = ux500_ab5500_startup, @@ -108,7 +108,7 @@ struct snd_soc_dai_link u5500_dai_links[] = { .codec_dai_name = "ab5500-codec-dai.1", .platform_name = "ux500-pcm.0", .codec_name = "ab5500-codec.0", - .init = NULL, + .init = ux500_ab5500_machine_codec_init, .ops = (struct snd_soc_ops[]) { { .startup = ux500_ab5500_startup, diff --git a/sound/soc/ux500/ux500_ab5500.c b/sound/soc/ux500/ux500_ab5500.c old mode 100644 new mode 100755 index 6dbf72e9153..3a1dab0a990 --- a/sound/soc/ux500/ux500_ab5500.c +++ b/sound/soc/ux500/ux500_ab5500.c @@ -13,17 +13,69 @@ */ #include +#include #include "../codecs/ab5500.h" #include "ux500_msp_dai.h" -int ux500_ab5500_startup(struct snd_pcm_substream *substream) +/* For a workwround purpose we enable sysclk + by default this will be changed later */ +static unsigned int sysclk_state = 1;/* Enabled */ +static struct clk *ux500_ab5500_sysclk; + +static int sysclk_input_select_control_info(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_info *uinfo) +{ + uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN; + uinfo->count = 1; + uinfo->value.integer.min = 0; + uinfo->value.integer.max = 1; + return 0; +} + +static int sysclk_input_select_control_get(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { + ucontrol->value.integer.value[0] = sysclk_state; return 0; } +static int sysclk_input_select_control_put(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + sysclk_state = ucontrol->value.integer.value[0]; + return 0; +} + +static const struct snd_kcontrol_new sysclk_input_select_control = { + .iface = SNDRV_CTL_ELEM_IFACE_MIXER, + .name = "Sysclk Input Select", + .index = 0, + .access = SNDRV_CTL_ELEM_ACCESS_READWRITE, + .info = sysclk_input_select_control_info, + .get = sysclk_input_select_control_get, + .put = sysclk_input_select_control_put +}; + +int ux500_ab5500_startup(struct snd_pcm_substream *substream) +{ + struct snd_soc_pcm_runtime *rtd = substream->private_data; + struct snd_soc_codec *codec = rtd->codec; + int ret = 0; + + if (sysclk_state == 1) { + ret = clk_enable(ux500_ab5500_sysclk); + if (ret) + dev_err(codec->dev, "failed to enable clock %d\n", ret); + } + + return ret; +} + void ux500_ab5500_shutdown(struct snd_pcm_substream *substream) { - printk(KERN_DEBUG "%s: Enter.\n", __func__); + pr_info("%s: Enter.\n", __func__); + if (sysclk_state == 1) + clk_disable(ux500_ab5500_sysclk); } int ux500_ab5500_hw_params(struct snd_pcm_substream *substream, @@ -60,3 +112,21 @@ int ux500_ab5500_hw_params(struct snd_pcm_substream *substream, return ret; } + +int ux500_ab5500_machine_codec_init(struct snd_soc_pcm_runtime *rtd) +{ + struct snd_soc_codec *codec = rtd->codec; + int ret = 0; + + snd_ctl_add(codec->card->snd_card, + snd_ctl_new1(&sysclk_input_select_control, codec)); + + ux500_ab5500_sysclk = clk_get(codec->dev, "sysclk"); + if (IS_ERR(ux500_ab5500_sysclk)) { + dev_err(codec->dev, "could not get sysclk %ld\n", + PTR_ERR(ux500_ab5500_sysclk)); + ret = PTR_ERR(ux500_ab5500_sysclk); + } + + return ret; +} diff --git a/sound/soc/ux500/ux500_ab5500.h b/sound/soc/ux500/ux500_ab5500.h old mode 100644 new mode 100755 index ea69f1a048c..8a9be4b98d0 --- a/sound/soc/ux500/ux500_ab5500.h +++ b/sound/soc/ux500/ux500_ab5500.h @@ -14,6 +14,8 @@ #ifndef UX500_AB5500_H #define UX500_AB5500_H +struct snd_soc_pcm_runtime; + int ux500_ab5500_startup(struct snd_pcm_substream *substream); void ux500_ab5500_shutdown(struct snd_pcm_substream *substream); @@ -21,4 +23,6 @@ void ux500_ab5500_shutdown(struct snd_pcm_substream *substream); int ux500_ab5500_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params); +int ux500_ab5500_machine_codec_init(struct snd_soc_pcm_runtime *runtime); + #endif -- cgit v1.2.3