diff options
Diffstat (limited to 'sound/soc/samsung/speyside.c')
-rw-r--r-- | sound/soc/samsung/speyside.c | 123 |
1 files changed, 123 insertions, 0 deletions
diff --git a/sound/soc/samsung/speyside.c b/sound/soc/samsung/speyside.c new file mode 100644 index 000000000000..f6dcee7b218b --- /dev/null +++ b/sound/soc/samsung/speyside.c | |||
@@ -0,0 +1,123 @@ | |||
1 | /* | ||
2 | * Speyside audio support | ||
3 | * | ||
4 | * Copyright 2011 Wolfson Microelectronics | ||
5 | * | ||
6 | * This program is free software; you can redistribute it and/or modify it | ||
7 | * under the terms of the GNU General Public License as published by the | ||
8 | * Free Software Foundation; either version 2 of the License, or (at your | ||
9 | * option) any later version. | ||
10 | */ | ||
11 | |||
12 | #include <sound/soc.h> | ||
13 | #include <sound/soc-dapm.h> | ||
14 | |||
15 | #include "../codecs/wm8915.h" | ||
16 | |||
17 | static int speyside_hw_params(struct snd_pcm_substream *substream, | ||
18 | struct snd_pcm_hw_params *params) | ||
19 | { | ||
20 | struct snd_soc_pcm_runtime *rtd = substream->private_data; | ||
21 | struct snd_soc_dai *cpu_dai = rtd->cpu_dai; | ||
22 | struct snd_soc_dai *codec_dai = rtd->codec_dai; | ||
23 | int ret; | ||
24 | |||
25 | ret = snd_soc_dai_set_fmt(codec_dai, SND_SOC_DAIFMT_I2S | ||
26 | | SND_SOC_DAIFMT_NB_NF | ||
27 | | SND_SOC_DAIFMT_CBM_CFM); | ||
28 | if (ret < 0) | ||
29 | return ret; | ||
30 | |||
31 | ret = snd_soc_dai_set_fmt(cpu_dai, SND_SOC_DAIFMT_I2S | ||
32 | | SND_SOC_DAIFMT_NB_NF | ||
33 | | SND_SOC_DAIFMT_CBM_CFM); | ||
34 | if (ret < 0) | ||
35 | return ret; | ||
36 | |||
37 | ret = snd_soc_dai_set_pll(codec_dai, 0, WM8915_FLL_MCLK1, | ||
38 | 32768, 256 * 48000); | ||
39 | if (ret < 0) | ||
40 | return ret; | ||
41 | |||
42 | ret = snd_soc_dai_set_sysclk(codec_dai, WM8915_SYSCLK_FLL, | ||
43 | 256 * 48000, SND_SOC_CLOCK_IN); | ||
44 | if (ret < 0) | ||
45 | return ret; | ||
46 | |||
47 | return 0; | ||
48 | } | ||
49 | |||
50 | static struct snd_soc_ops speyside_ops = { | ||
51 | .hw_params = speyside_hw_params, | ||
52 | }; | ||
53 | |||
54 | static struct snd_soc_dai_link speyside_dai[] = { | ||
55 | { | ||
56 | .name = "CPU", | ||
57 | .stream_name = "CPU", | ||
58 | .cpu_dai_name = "samsung-i2s.0", | ||
59 | .codec_dai_name = "wm8915-aif1", | ||
60 | .platform_name = "samsung-audio", | ||
61 | .codec_name = "wm8915.1-001a", | ||
62 | .ops = &speyside_ops, | ||
63 | }, | ||
64 | }; | ||
65 | |||
66 | static struct snd_soc_card speyside = { | ||
67 | .name = "Speyside", | ||
68 | .dai_link = speyside_dai, | ||
69 | .num_links = ARRAY_SIZE(speyside_dai), | ||
70 | }; | ||
71 | |||
72 | static __devinit int speyside_probe(struct platform_device *pdev) | ||
73 | { | ||
74 | struct snd_soc_card *card = &speyside; | ||
75 | int ret; | ||
76 | |||
77 | card->dev = &pdev->dev; | ||
78 | |||
79 | ret = snd_soc_register_card(card); | ||
80 | if (ret) { | ||
81 | dev_err(&pdev->dev, "snd_soc_register_card() failed: %d\n", | ||
82 | ret); | ||
83 | return ret; | ||
84 | } | ||
85 | |||
86 | return 0; | ||
87 | } | ||
88 | |||
89 | static int __devexit speyside_remove(struct platform_device *pdev) | ||
90 | { | ||
91 | struct snd_soc_card *card = platform_get_drvdata(pdev); | ||
92 | |||
93 | snd_soc_unregister_card(card); | ||
94 | |||
95 | return 0; | ||
96 | } | ||
97 | |||
98 | static struct platform_driver speyside_driver = { | ||
99 | .driver = { | ||
100 | .name = "speyside", | ||
101 | .owner = THIS_MODULE, | ||
102 | .pm = &snd_soc_pm_ops, | ||
103 | }, | ||
104 | .probe = speyside_probe, | ||
105 | .remove = __devexit_p(speyside_remove), | ||
106 | }; | ||
107 | |||
108 | static int __init speyside_audio_init(void) | ||
109 | { | ||
110 | return platform_driver_register(&speyside_driver); | ||
111 | } | ||
112 | module_init(speyside_audio_init); | ||
113 | |||
114 | static void __exit speyside_audio_exit(void) | ||
115 | { | ||
116 | platform_driver_unregister(&speyside_driver); | ||
117 | } | ||
118 | module_exit(speyside_audio_exit); | ||
119 | |||
120 | MODULE_DESCRIPTION("Speyside audio support"); | ||
121 | MODULE_AUTHOR("Mark Brown <broonie@opensource.wolfsonmicro.com>"); | ||
122 | MODULE_LICENSE("GPL"); | ||
123 | MODULE_ALIAS("platform:speyside"); | ||