diff options
author | Jyri Sarha <jsarha@ti.com> | 2015-01-13 14:16:34 -0500 |
---|---|---|
committer | Mark Brown <broonie@kernel.org> | 2015-01-15 06:45:52 -0500 |
commit | f9911803e82a32c126c40dd6246ade2faf472cbc (patch) | |
tree | 41eeb7ff84c9627d8104b2c2dc2831aa01c09c12 /sound/soc/generic | |
parent | 97bf6af1f928216fd6c5a66e8a57bfa95a659672 (diff) |
ASoC: simple-card: Enable and disable DAI clocks as needed
Call clk_prepare_enable() and clk_disable_unprepare() for cpu dai
clock and codec dai clock in dai statup and shutdown callbacks. This
to make sure the related clock are enabled when the audio device is
used.
Signed-off-by: Jyri Sarha <jsarha@ti.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
Diffstat (limited to 'sound/soc/generic')
-rw-r--r-- | sound/soc/generic/simple-card.c | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/sound/soc/generic/simple-card.c b/sound/soc/generic/simple-card.c index fb9240fdc9b7..cb3998d96cca 100644 --- a/sound/soc/generic/simple-card.c +++ b/sound/soc/generic/simple-card.c | |||
@@ -39,6 +39,37 @@ struct simple_card_data { | |||
39 | #define simple_priv_to_link(priv, i) ((priv)->snd_card.dai_link + i) | 39 | #define simple_priv_to_link(priv, i) ((priv)->snd_card.dai_link + i) |
40 | #define simple_priv_to_props(priv, i) ((priv)->dai_props + i) | 40 | #define simple_priv_to_props(priv, i) ((priv)->dai_props + i) |
41 | 41 | ||
42 | static int asoc_simple_card_startup(struct snd_pcm_substream *substream) | ||
43 | { | ||
44 | struct snd_soc_pcm_runtime *rtd = substream->private_data; | ||
45 | struct simple_card_data *priv = snd_soc_card_get_drvdata(rtd->card); | ||
46 | struct simple_dai_props *dai_props = | ||
47 | &priv->dai_props[rtd - rtd->card->rtd]; | ||
48 | int ret; | ||
49 | |||
50 | ret = clk_prepare_enable(dai_props->cpu_dai.clk); | ||
51 | if (ret) | ||
52 | return ret; | ||
53 | |||
54 | ret = clk_prepare_enable(dai_props->codec_dai.clk); | ||
55 | if (ret) | ||
56 | clk_disable_unprepare(dai_props->cpu_dai.clk); | ||
57 | |||
58 | return ret; | ||
59 | } | ||
60 | |||
61 | static void asoc_simple_card_shutdown(struct snd_pcm_substream *substream) | ||
62 | { | ||
63 | struct snd_soc_pcm_runtime *rtd = substream->private_data; | ||
64 | struct simple_card_data *priv = snd_soc_card_get_drvdata(rtd->card); | ||
65 | struct simple_dai_props *dai_props = | ||
66 | &priv->dai_props[rtd - rtd->card->rtd]; | ||
67 | |||
68 | clk_disable_unprepare(dai_props->cpu_dai.clk); | ||
69 | |||
70 | clk_disable_unprepare(dai_props->codec_dai.clk); | ||
71 | } | ||
72 | |||
42 | static int asoc_simple_card_hw_params(struct snd_pcm_substream *substream, | 73 | static int asoc_simple_card_hw_params(struct snd_pcm_substream *substream, |
43 | struct snd_pcm_hw_params *params) | 74 | struct snd_pcm_hw_params *params) |
44 | { | 75 | { |
@@ -58,6 +89,8 @@ static int asoc_simple_card_hw_params(struct snd_pcm_substream *substream, | |||
58 | } | 89 | } |
59 | 90 | ||
60 | static struct snd_soc_ops asoc_simple_card_ops = { | 91 | static struct snd_soc_ops asoc_simple_card_ops = { |
92 | .startup = asoc_simple_card_startup, | ||
93 | .shutdown = asoc_simple_card_shutdown, | ||
61 | .hw_params = asoc_simple_card_hw_params, | 94 | .hw_params = asoc_simple_card_hw_params, |
62 | }; | 95 | }; |
63 | 96 | ||
@@ -219,6 +252,7 @@ asoc_simple_card_sub_parse_of(struct device_node *np, | |||
219 | } | 252 | } |
220 | 253 | ||
221 | dai->sysclk = clk_get_rate(clk); | 254 | dai->sysclk = clk_get_rate(clk); |
255 | dai->clk = clk; | ||
222 | } else if (!of_property_read_u32(np, "system-clock-frequency", &val)) { | 256 | } else if (!of_property_read_u32(np, "system-clock-frequency", &val)) { |
223 | dai->sysclk = val; | 257 | dai->sysclk = val; |
224 | } else { | 258 | } else { |