diff options
Diffstat (limited to 'sound/soc/generic/simple-card.c')
-rw-r--r-- | sound/soc/generic/simple-card.c | 41 |
1 files changed, 37 insertions, 4 deletions
diff --git a/sound/soc/generic/simple-card.c b/sound/soc/generic/simple-card.c index fb9240fdc9b7..f7c6734bd5da 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 { |
@@ -452,9 +486,8 @@ static int asoc_simple_card_parse_of(struct device_node *node, | |||
452 | } | 486 | } |
453 | 487 | ||
454 | /* Decrease the reference count of the device nodes */ | 488 | /* Decrease the reference count of the device nodes */ |
455 | static int asoc_simple_card_unref(struct platform_device *pdev) | 489 | static int asoc_simple_card_unref(struct snd_soc_card *card) |
456 | { | 490 | { |
457 | struct snd_soc_card *card = platform_get_drvdata(pdev); | ||
458 | struct snd_soc_dai_link *dai_link; | 491 | struct snd_soc_dai_link *dai_link; |
459 | int num_links; | 492 | int num_links; |
460 | 493 | ||
@@ -556,7 +589,7 @@ static int asoc_simple_card_probe(struct platform_device *pdev) | |||
556 | return ret; | 589 | return ret; |
557 | 590 | ||
558 | err: | 591 | err: |
559 | asoc_simple_card_unref(pdev); | 592 | asoc_simple_card_unref(&priv->snd_card); |
560 | return ret; | 593 | return ret; |
561 | } | 594 | } |
562 | 595 | ||
@@ -572,7 +605,7 @@ static int asoc_simple_card_remove(struct platform_device *pdev) | |||
572 | snd_soc_jack_free_gpios(&simple_card_mic_jack, 1, | 605 | snd_soc_jack_free_gpios(&simple_card_mic_jack, 1, |
573 | &simple_card_mic_jack_gpio); | 606 | &simple_card_mic_jack_gpio); |
574 | 607 | ||
575 | return asoc_simple_card_unref(pdev); | 608 | return asoc_simple_card_unref(card); |
576 | } | 609 | } |
577 | 610 | ||
578 | static const struct of_device_id asoc_simple_of_match[] = { | 611 | static const struct of_device_id asoc_simple_of_match[] = { |