aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMark Brown <broonie@opensource.wolfsonmicro.com>2008-11-21 09:01:41 -0500
committerMark Brown <broonie@opensource.wolfsonmicro.com>2008-11-21 09:35:02 -0500
commit2dac9217b26fd0a0a1712386ce2ea1411835ffb7 (patch)
treec6365053f95a393c6f2e8d6f669e23256eafe88a
parentdee89c4d94433520e4e3977ae203d4cfbfe385fb (diff)
ASoC: Add Marvell Zylonite machine support
Implement support for the Marvell Zylonite PXA3xx reference platform, supporting standard AC97 stereo and AUX interfaces together with the auxiliary I2S interface of the WM9713. The board has two options for the MCLK of the WM9713: either the standard AC97 system clock can be used or the 13MHz CLK_POUT output of the PXA3xx can be used, selected via SW15 on the board. Currently only the AC97 system clock is supported by this driver. Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
-rw-r--r--sound/soc/pxa/Makefile2
-rw-r--r--sound/soc/pxa/zylonite.c219
2 files changed, 221 insertions, 0 deletions
diff --git a/sound/soc/pxa/Makefile b/sound/soc/pxa/Makefile
index 1a3a36e75bf0..08a9f2797729 100644
--- a/sound/soc/pxa/Makefile
+++ b/sound/soc/pxa/Makefile
@@ -17,6 +17,7 @@ snd-soc-e800-objs := e800_wm9712.o
17snd-soc-spitz-objs := spitz.o 17snd-soc-spitz-objs := spitz.o
18snd-soc-em-x270-objs := em-x270.o 18snd-soc-em-x270-objs := em-x270.o
19snd-soc-palm27x-objs := palm27x.o 19snd-soc-palm27x-objs := palm27x.o
20snd-soc-zylonite-objs := zylonite.o
20 21
21obj-$(CONFIG_SND_PXA2XX_SOC_CORGI) += snd-soc-corgi.o 22obj-$(CONFIG_SND_PXA2XX_SOC_CORGI) += snd-soc-corgi.o
22obj-$(CONFIG_SND_PXA2XX_SOC_POODLE) += snd-soc-poodle.o 23obj-$(CONFIG_SND_PXA2XX_SOC_POODLE) += snd-soc-poodle.o
@@ -25,3 +26,4 @@ obj-$(CONFIG_SND_PXA2XX_SOC_E800) += snd-soc-e800.o
25obj-$(CONFIG_SND_PXA2XX_SOC_SPITZ) += snd-soc-spitz.o 26obj-$(CONFIG_SND_PXA2XX_SOC_SPITZ) += snd-soc-spitz.o
26obj-$(CONFIG_SND_PXA2XX_SOC_EM_X270) += snd-soc-em-x270.o 27obj-$(CONFIG_SND_PXA2XX_SOC_EM_X270) += snd-soc-em-x270.o
27obj-$(CONFIG_SND_PXA2XX_SOC_PALM27X) += snd-soc-palm27x.o 28obj-$(CONFIG_SND_PXA2XX_SOC_PALM27X) += snd-soc-palm27x.o
29obj-$(CONFIG_SND_SOC_ZYLONITE) += snd-soc-zylonite.o
diff --git a/sound/soc/pxa/zylonite.c b/sound/soc/pxa/zylonite.c
new file mode 100644
index 000000000000..842d6500d61f
--- /dev/null
+++ b/sound/soc/pxa/zylonite.c
@@ -0,0 +1,219 @@
1/*
2 * zylonite.c -- SoC audio for Zylonite
3 *
4 * Copyright 2008 Wolfson Microelectronics PLC.
5 * Author: Mark Brown <broonie@opensource.wolfsonmicro.com>
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License as
9 * published by the Free Software Foundation; either version 2 of the
10 * License, or (at your option) any later version.
11 *
12 */
13
14#include <linux/module.h>
15#include <linux/moduleparam.h>
16#include <linux/device.h>
17#include <linux/i2c.h>
18#include <sound/core.h>
19#include <sound/pcm.h>
20#include <sound/pcm_params.h>
21#include <sound/soc.h>
22#include <sound/soc-dapm.h>
23
24#include "../codecs/wm9713.h"
25#include "pxa2xx-pcm.h"
26#include "pxa2xx-ac97.h"
27#include "pxa-ssp.h"
28
29static struct snd_soc_card zylonite;
30
31static const struct snd_soc_dapm_widget zylonite_dapm_widgets[] = {
32 SND_SOC_DAPM_HP("Headphone", NULL),
33 SND_SOC_DAPM_MIC("Headset Microphone", NULL),
34 SND_SOC_DAPM_MIC("Handset Microphone", NULL),
35 SND_SOC_DAPM_SPK("Multiactor", NULL),
36 SND_SOC_DAPM_SPK("Headset Earpiece", NULL),
37};
38
39/* Currently supported audio map */
40static const struct snd_soc_dapm_route audio_map[] = {
41
42 /* Headphone output connected to HPL/HPR */
43 { "Headphone", NULL, "HPL" },
44 { "Headphone", NULL, "HPR" },
45
46 /* On-board earpiece */
47 { "Headset Earpiece", NULL, "OUT3" },
48
49 /* Headphone mic */
50 { "MIC2A", NULL, "Mic Bias" },
51 { "Mic Bias", NULL, "Headset Microphone" },
52
53 /* On-board mic */
54 { "MIC1", NULL, "Mic Bias" },
55 { "Mic Bias", NULL, "Handset Microphone" },
56
57 /* Multiactor differentially connected over SPKL/SPKR */
58 { "Multiactor", NULL, "SPKL" },
59 { "Multiactor", NULL, "SPKR" },
60};
61
62static int zylonite_wm9713_init(struct snd_soc_codec *codec)
63{
64 /* Currently we only support use of the AC97 clock here. If
65 * CLK_POUT is selected by SW15 then the clock API will need
66 * to be used to request and enable it here.
67 */
68
69 snd_soc_dapm_new_controls(codec, zylonite_dapm_widgets,
70 ARRAY_SIZE(zylonite_dapm_widgets));
71
72 snd_soc_dapm_add_routes(codec, audio_map, ARRAY_SIZE(audio_map));
73
74 /* Static setup for now */
75 snd_soc_dapm_enable_pin(codec, "Headphone");
76 snd_soc_dapm_enable_pin(codec, "Headset Earpiece");
77
78 snd_soc_dapm_sync(codec);
79 return 0;
80}
81
82static int zylonite_voice_hw_params(struct snd_pcm_substream *substream,
83 struct snd_pcm_hw_params *params)
84{
85 struct snd_soc_pcm_runtime *rtd = substream->private_data;
86 struct snd_soc_dai *codec_dai = rtd->dai->codec_dai;
87 struct snd_soc_dai *cpu_dai = rtd->dai->cpu_dai;
88 unsigned int pll_out = 0;
89 unsigned int acds = 0;
90 unsigned int wm9713_div = 0;
91 int ret = 0;
92
93 switch (params_rate(params)) {
94 case 8000:
95 wm9713_div = 12;
96 pll_out = 2048000;
97 break;
98 case 16000:
99 wm9713_div = 6;
100 pll_out = 4096000;
101 break;
102 case 48000:
103 default:
104 wm9713_div = 2;
105 pll_out = 12288000;
106 acds = 1;
107 break;
108 }
109
110 ret = snd_soc_dai_set_fmt(codec_dai, SND_SOC_DAIFMT_I2S |
111 SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBS_CFS);
112 if (ret < 0)
113 return ret;
114
115 ret = snd_soc_dai_set_fmt(cpu_dai, SND_SOC_DAIFMT_I2S |
116 SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBS_CFS);
117 if (ret < 0)
118 return ret;
119
120 ret = snd_soc_dai_set_tdm_slot(cpu_dai,
121 params_channels(params),
122 params_channels(params));
123 if (ret < 0)
124 return ret;
125
126 ret = snd_soc_dai_set_pll(cpu_dai, 0, 0, pll_out);
127 if (ret < 0)
128 return ret;
129
130 ret = snd_soc_dai_set_clkdiv(cpu_dai, PXA_SSP_AUDIO_DIV_ACDS, acds);
131 if (ret < 0)
132 return ret;
133
134 ret = snd_soc_dai_set_sysclk(cpu_dai, PXA_SSP_CLK_AUDIO, 0, 1);
135 if (ret < 0)
136 return ret;
137
138 /* Note that if the PLL is in use the WM9713_PCMCLK_PLL_DIV needs
139 * to be set instead.
140 */
141 ret = snd_soc_dai_set_clkdiv(codec_dai, WM9713_PCMCLK_DIV,
142 WM9713_PCMDIV(wm9713_div));
143 if (ret < 0)
144 return ret;
145
146 return 0;
147}
148
149static struct snd_soc_ops zylonite_voice_ops = {
150 .hw_params = zylonite_voice_hw_params,
151};
152
153static struct snd_soc_dai_link zylonite_dai[] = {
154{
155 .name = "AC97",
156 .stream_name = "AC97 HiFi",
157 .cpu_dai = &pxa_ac97_dai[PXA2XX_DAI_AC97_HIFI],
158 .codec_dai = &wm9713_dai[WM9713_DAI_AC97_HIFI],
159 .init = zylonite_wm9713_init,
160},
161{
162 .name = "AC97 Aux",
163 .stream_name = "AC97 Aux",
164 .cpu_dai = &pxa_ac97_dai[PXA2XX_DAI_AC97_AUX],
165 .codec_dai = &wm9713_dai[WM9713_DAI_AC97_AUX],
166},
167{
168 .name = "WM9713 Voice",
169 .stream_name = "WM9713 Voice",
170 .cpu_dai = &pxa_ssp_dai[PXA_DAI_SSP3],
171 .codec_dai = &wm9713_dai[WM9713_DAI_PCM_VOICE],
172 .ops = &zylonite_voice_ops,
173},
174};
175
176static struct snd_soc_card zylonite = {
177 .name = "Zylonite",
178 .dai_link = zylonite_dai,
179 .num_links = ARRAY_SIZE(zylonite_dai),
180};
181
182static struct snd_soc_device zylonite_snd_ac97_devdata = {
183 .card = &zylonite,
184 .platform = &pxa2xx_soc_platform,
185 .codec_dev = &soc_codec_dev_wm9713,
186};
187
188static struct platform_device *zylonite_snd_ac97_device;
189
190static int __init zylonite_init(void)
191{
192 int ret;
193
194 zylonite_snd_ac97_device = platform_device_alloc("soc-audio", -1);
195 if (!zylonite_snd_ac97_device)
196 return -ENOMEM;
197
198 platform_set_drvdata(zylonite_snd_ac97_device,
199 &zylonite_snd_ac97_devdata);
200 zylonite_snd_ac97_devdata.dev = &zylonite_snd_ac97_device->dev;
201
202 ret = platform_device_add(zylonite_snd_ac97_device);
203 if (ret != 0)
204 platform_device_put(zylonite_snd_ac97_device);
205
206 return ret;
207}
208
209static void __exit zylonite_exit(void)
210{
211 platform_device_unregister(zylonite_snd_ac97_device);
212}
213
214module_init(zylonite_init);
215module_exit(zylonite_exit);
216
217MODULE_AUTHOR("Mark Brown <broonie@opensource.wolfsonmicro.com>");
218MODULE_DESCRIPTION("ALSA SoC WM9713 Zylonite");
219MODULE_LICENSE("GPL");