aboutsummaryrefslogtreecommitdiffstats
path: root/sound/soc/blackfin/bfin-eval-adau1373.c
diff options
context:
space:
mode:
authorLars-Peter Clausen <lars@metafoo.de>2011-08-15 14:15:23 -0400
committerMark Brown <broonie@opensource.wolfsonmicro.com>2011-08-16 11:53:54 -0400
commitf049ffb3f8cf682df405f029914938f95d667695 (patch)
treee7832406ceefdf544186772ad1f1eb76927e42f0 /sound/soc/blackfin/bfin-eval-adau1373.c
parentddd7a26094c93a950f4b2e6b4d5865c93976372e (diff)
ASoC: Blackfin: ADAU1373 eval board support
Add a machine driver to support the EVAL-ADAU1373 board connected to a Analog Devices BF5XX evaluation board. Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Diffstat (limited to 'sound/soc/blackfin/bfin-eval-adau1373.c')
-rw-r--r--sound/soc/blackfin/bfin-eval-adau1373.c202
1 files changed, 202 insertions, 0 deletions
diff --git a/sound/soc/blackfin/bfin-eval-adau1373.c b/sound/soc/blackfin/bfin-eval-adau1373.c
new file mode 100644
index 000000000000..8df2a3b0cb36
--- /dev/null
+++ b/sound/soc/blackfin/bfin-eval-adau1373.c
@@ -0,0 +1,202 @@
1/*
2 * Machine driver for EVAL-ADAU1373 on Analog Devices bfin
3 * evaluation boards.
4 *
5 * Copyright 2011 Analog Devices Inc.
6 * Author: Lars-Peter Clausen <lars@metafoo.de>
7 *
8 * Licensed under the GPL-2 or later.
9 */
10
11#include <linux/module.h>
12#include <linux/device.h>
13#include <sound/core.h>
14#include <sound/pcm.h>
15#include <sound/soc.h>
16#include <sound/pcm_params.h>
17
18#include "../codecs/adau1373.h"
19
20static const struct snd_soc_dapm_widget bfin_eval_adau1373_dapm_widgets[] = {
21 SND_SOC_DAPM_LINE("Line In1", NULL),
22 SND_SOC_DAPM_LINE("Line In2", NULL),
23 SND_SOC_DAPM_LINE("Line In3", NULL),
24 SND_SOC_DAPM_LINE("Line In4", NULL),
25
26 SND_SOC_DAPM_LINE("Line Out1", NULL),
27 SND_SOC_DAPM_LINE("Line Out2", NULL),
28 SND_SOC_DAPM_LINE("Stereo Out", NULL),
29 SND_SOC_DAPM_HP("Headphone", NULL),
30 SND_SOC_DAPM_HP("Earpiece", NULL),
31 SND_SOC_DAPM_SPK("Speaker", NULL),
32};
33
34static const struct snd_soc_dapm_route bfin_eval_adau1373_dapm_routes[] = {
35 { "AIN1L", NULL, "Line In1" },
36 { "AIN1R", NULL, "Line In1" },
37 { "AIN2L", NULL, "Line In2" },
38 { "AIN2R", NULL, "Line In2" },
39 { "AIN3L", NULL, "Line In3" },
40 { "AIN3R", NULL, "Line In3" },
41 { "AIN4L", NULL, "Line In4" },
42 { "AIN4R", NULL, "Line In4" },
43
44 /* MICBIAS can be connected via a jumper to the line-in jack, since w
45 don't know which one is going to be used, just power both. */
46 { "Line In1", NULL, "MICBIAS1" },
47 { "Line In2", NULL, "MICBIAS1" },
48 { "Line In3", NULL, "MICBIAS1" },
49 { "Line In4", NULL, "MICBIAS1" },
50 { "Line In1", NULL, "MICBIAS2" },
51 { "Line In2", NULL, "MICBIAS2" },
52 { "Line In3", NULL, "MICBIAS2" },
53 { "Line In4", NULL, "MICBIAS2" },
54
55 { "Line Out1", NULL, "LOUT1L" },
56 { "Line Out1", NULL, "LOUT1R" },
57 { "Line Out2", NULL, "LOUT2L" },
58 { "Line Out2", NULL, "LOUT2R" },
59 { "Headphone", NULL, "HPL" },
60 { "Headphone", NULL, "HPR" },
61 { "Earpiece", NULL, "EP" },
62 { "Speaker", NULL, "SPKL" },
63 { "Stereo Out", NULL, "SPKR" },
64};
65
66static int bfin_eval_adau1373_hw_params(struct snd_pcm_substream *substream,
67 struct snd_pcm_hw_params *params)
68{
69 struct snd_soc_pcm_runtime *rtd = substream->private_data;
70 struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
71 struct snd_soc_dai *codec_dai = rtd->codec_dai;
72 int ret;
73 int pll_rate;
74
75 ret = snd_soc_dai_set_fmt(cpu_dai, SND_SOC_DAIFMT_I2S |
76 SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBM_CFM);
77 if (ret)
78 return ret;
79
80 ret = snd_soc_dai_set_fmt(codec_dai, SND_SOC_DAIFMT_I2S |
81 SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBM_CFM);
82 if (ret)
83 return ret;
84
85 switch (params_rate(params)) {
86 case 48000:
87 case 8000:
88 case 12000:
89 case 16000:
90 case 24000:
91 case 32000:
92 pll_rate = 48000 * 1024;
93 break;
94 case 44100:
95 case 7350:
96 case 11025:
97 case 14700:
98 case 22050:
99 case 29400:
100 pll_rate = 44100 * 1024;
101 break;
102 default:
103 return -EINVAL;
104 }
105
106 ret = snd_soc_dai_set_pll(codec_dai, ADAU1373_PLL1,
107 ADAU1373_PLL_SRC_MCLK1, 12288000, pll_rate);
108 if (ret)
109 return ret;
110
111 ret = snd_soc_dai_set_sysclk(codec_dai, ADAU1373_CLK_SRC_PLL1, pll_rate,
112 SND_SOC_CLOCK_IN);
113
114 return ret;
115}
116
117static int bfin_eval_adau1373_codec_init(struct snd_soc_pcm_runtime *rtd)
118{
119 struct snd_soc_dai *codec_dai = rtd->codec_dai;
120 unsigned int pll_rate = 48000 * 1024;
121 int ret;
122
123 ret = snd_soc_dai_set_pll(codec_dai, ADAU1373_PLL1,
124 ADAU1373_PLL_SRC_MCLK1, 12288000, pll_rate);
125 if (ret)
126 return ret;
127
128 ret = snd_soc_dai_set_sysclk(codec_dai, ADAU1373_CLK_SRC_PLL1, pll_rate,
129 SND_SOC_CLOCK_IN);
130
131 return ret;
132}
133static struct snd_soc_ops bfin_eval_adau1373_ops = {
134 .hw_params = bfin_eval_adau1373_hw_params,
135};
136
137static struct snd_soc_dai_link bfin_eval_adau1373_dai = {
138 .name = "adau1373",
139 .stream_name = "adau1373",
140 .cpu_dai_name = "bfin-i2s.0",
141 .codec_dai_name = "adau1373-aif1",
142 .platform_name = "bfin-i2s-pcm-audio",
143 .codec_name = "adau1373.0-001a",
144 .ops = &bfin_eval_adau1373_ops,
145 .init = bfin_eval_adau1373_codec_init,
146};
147
148static struct snd_soc_card bfin_eval_adau1373 = {
149 .name = "bfin-eval-adau1373",
150 .dai_link = &bfin_eval_adau1373_dai,
151 .num_links = 1,
152
153 .dapm_widgets = bfin_eval_adau1373_dapm_widgets,
154 .num_dapm_widgets = ARRAY_SIZE(bfin_eval_adau1373_dapm_widgets),
155 .dapm_routes = bfin_eval_adau1373_dapm_routes,
156 .num_dapm_routes = ARRAY_SIZE(bfin_eval_adau1373_dapm_routes),
157};
158
159static int bfin_eval_adau1373_probe(struct platform_device *pdev)
160{
161 struct snd_soc_card *card = &bfin_eval_adau1373;
162
163 card->dev = &pdev->dev;
164
165 return snd_soc_register_card(&bfin_eval_adau1373);
166}
167
168static int __devexit bfin_eval_adau1373_remove(struct platform_device *pdev)
169{
170 struct snd_soc_card *card = platform_get_drvdata(pdev);
171
172 snd_soc_unregister_card(card);
173
174 return 0;
175}
176
177static struct platform_driver bfin_eval_adau1373_driver = {
178 .driver = {
179 .name = "bfin-eval-adau1373",
180 .owner = THIS_MODULE,
181 .pm = &snd_soc_pm_ops,
182 },
183 .probe = bfin_eval_adau1373_probe,
184 .remove = __devexit_p(bfin_eval_adau1373_remove),
185};
186
187static int __init bfin_eval_adau1373_init(void)
188{
189 return platform_driver_register(&bfin_eval_adau1373_driver);
190}
191module_init(bfin_eval_adau1373_init);
192
193static void __exit bfin_eval_adau1373_exit(void)
194{
195 platform_driver_unregister(&bfin_eval_adau1373_driver);
196}
197module_exit(bfin_eval_adau1373_exit);
198
199MODULE_AUTHOR("Lars-Peter Clausen <lars@metafoo.de>");
200MODULE_DESCRIPTION("ALSA SoC bfin adau1373 driver");
201MODULE_LICENSE("GPL");
202MODULE_ALIAS("platform:bfin-eval-adau1373");