aboutsummaryrefslogtreecommitdiffstats
path: root/sound/soc/pxa
diff options
context:
space:
mode:
Diffstat (limited to 'sound/soc/pxa')
-rw-r--r--sound/soc/pxa/Kconfig12
-rw-r--r--sound/soc/pxa/Makefile2
-rw-r--r--sound/soc/pxa/magician.c2
-rw-r--r--sound/soc/pxa/pxa-ssp.c20
-rw-r--r--sound/soc/pxa/raumfeld.c335
-rw-r--r--sound/soc/pxa/zylonite.c5
6 files changed, 362 insertions, 14 deletions
diff --git a/sound/soc/pxa/Kconfig b/sound/soc/pxa/Kconfig
index dcb3181bb340..376e14a9c273 100644
--- a/sound/soc/pxa/Kconfig
+++ b/sound/soc/pxa/Kconfig
@@ -90,7 +90,8 @@ config SND_PXA2XX_SOC_E800
90 90
91config SND_PXA2XX_SOC_EM_X270 91config SND_PXA2XX_SOC_EM_X270
92 tristate "SoC Audio support for CompuLab EM-x270, eXeda and CM-X300" 92 tristate "SoC Audio support for CompuLab EM-x270, eXeda and CM-X300"
93 depends on SND_PXA2XX_SOC && MACH_EM_X270 93 depends on SND_PXA2XX_SOC && (MACH_EM_X270 || MACH_EXEDA || \
94 MACH_CM_X300)
94 select SND_PXA2XX_SOC_AC97 95 select SND_PXA2XX_SOC_AC97
95 select SND_SOC_WM9712 96 select SND_SOC_WM9712
96 help 97 help
@@ -117,6 +118,15 @@ config SND_SOC_ZYLONITE
117 Say Y if you want to add support for SoC audio on the 118 Say Y if you want to add support for SoC audio on the
118 Marvell Zylonite reference platform. 119 Marvell Zylonite reference platform.
119 120
121config SND_SOC_RAUMFELD
122 tristate "SoC Audio support Raumfeld audio adapter"
123 depends on SND_PXA2XX_SOC && (MACH_RAUMFELD_SPEAKER || MACH_RAUMFELD_CONNECTOR)
124 select SND_PXA_SOC_SSP
125 select SND_SOC_CS4270
126 select SND_SOC_AK4104
127 help
128 Say Y if you want to add support for SoC audio on Raumfeld devices
129
120config SND_PXA2XX_SOC_MAGICIAN 130config SND_PXA2XX_SOC_MAGICIAN
121 tristate "SoC Audio support for HTC Magician" 131 tristate "SoC Audio support for HTC Magician"
122 depends on SND_PXA2XX_SOC && MACH_MAGICIAN 132 depends on SND_PXA2XX_SOC && MACH_MAGICIAN
diff --git a/sound/soc/pxa/Makefile b/sound/soc/pxa/Makefile
index 6e096b480335..f3e08fd40ca2 100644
--- a/sound/soc/pxa/Makefile
+++ b/sound/soc/pxa/Makefile
@@ -23,6 +23,7 @@ snd-soc-zylonite-objs := zylonite.o
23snd-soc-magician-objs := magician.o 23snd-soc-magician-objs := magician.o
24snd-soc-mioa701-objs := mioa701_wm9713.o 24snd-soc-mioa701-objs := mioa701_wm9713.o
25snd-soc-imote2-objs := imote2.o 25snd-soc-imote2-objs := imote2.o
26snd-soc-raumfeld-objs := raumfeld.o
26 27
27obj-$(CONFIG_SND_PXA2XX_SOC_CORGI) += snd-soc-corgi.o 28obj-$(CONFIG_SND_PXA2XX_SOC_CORGI) += snd-soc-corgi.o
28obj-$(CONFIG_SND_PXA2XX_SOC_POODLE) += snd-soc-poodle.o 29obj-$(CONFIG_SND_PXA2XX_SOC_POODLE) += snd-soc-poodle.o
@@ -37,3 +38,4 @@ obj-$(CONFIG_SND_PXA2XX_SOC_MAGICIAN) += snd-soc-magician.o
37obj-$(CONFIG_SND_PXA2XX_SOC_MIOA701) += snd-soc-mioa701.o 38obj-$(CONFIG_SND_PXA2XX_SOC_MIOA701) += snd-soc-mioa701.o
38obj-$(CONFIG_SND_SOC_ZYLONITE) += snd-soc-zylonite.o 39obj-$(CONFIG_SND_SOC_ZYLONITE) += snd-soc-zylonite.o
39obj-$(CONFIG_SND_PXA2XX_SOC_IMOTE2) += snd-soc-imote2.o 40obj-$(CONFIG_SND_PXA2XX_SOC_IMOTE2) += snd-soc-imote2.o
41obj-$(CONFIG_SND_SOC_RAUMFELD) += snd-soc-raumfeld.o
diff --git a/sound/soc/pxa/magician.c b/sound/soc/pxa/magician.c
index 9f7c61e23daf..4c8d99a8d386 100644
--- a/sound/soc/pxa/magician.c
+++ b/sound/soc/pxa/magician.c
@@ -213,7 +213,7 @@ static int magician_playback_hw_params(struct snd_pcm_substream *substream,
213 return ret; 213 return ret;
214 214
215 /* set SSP audio pll clock */ 215 /* set SSP audio pll clock */
216 ret = snd_soc_dai_set_pll(cpu_dai, 0, 0, acps); 216 ret = snd_soc_dai_set_pll(cpu_dai, 0, 0, 0, acps);
217 if (ret < 0) 217 if (ret < 0)
218 return ret; 218 return ret;
219 219
diff --git a/sound/soc/pxa/pxa-ssp.c b/sound/soc/pxa/pxa-ssp.c
index d11a6d7e384a..3bd7712f029b 100644
--- a/sound/soc/pxa/pxa-ssp.c
+++ b/sound/soc/pxa/pxa-ssp.c
@@ -305,8 +305,8 @@ static int pxa_ssp_set_dai_clkdiv(struct snd_soc_dai *cpu_dai,
305/* 305/*
306 * Configure the PLL frequency pxa27x and (afaik - pxa320 only) 306 * Configure the PLL frequency pxa27x and (afaik - pxa320 only)
307 */ 307 */
308static int pxa_ssp_set_dai_pll(struct snd_soc_dai *cpu_dai, 308static int pxa_ssp_set_dai_pll(struct snd_soc_dai *cpu_dai, int pll_id,
309 int pll_id, unsigned int freq_in, unsigned int freq_out) 309 int source, unsigned int freq_in, unsigned int freq_out)
310{ 310{
311 struct ssp_priv *priv = cpu_dai->private_data; 311 struct ssp_priv *priv = cpu_dai->private_data;
312 struct ssp_device *ssp = priv->dev.ssp; 312 struct ssp_device *ssp = priv->dev.ssp;
@@ -760,13 +760,13 @@ struct snd_soc_dai pxa_ssp_dai[] = {
760 .resume = pxa_ssp_resume, 760 .resume = pxa_ssp_resume,
761 .playback = { 761 .playback = {
762 .channels_min = 1, 762 .channels_min = 1,
763 .channels_max = 2, 763 .channels_max = 8,
764 .rates = PXA_SSP_RATES, 764 .rates = PXA_SSP_RATES,
765 .formats = PXA_SSP_FORMATS, 765 .formats = PXA_SSP_FORMATS,
766 }, 766 },
767 .capture = { 767 .capture = {
768 .channels_min = 1, 768 .channels_min = 1,
769 .channels_max = 2, 769 .channels_max = 8,
770 .rates = PXA_SSP_RATES, 770 .rates = PXA_SSP_RATES,
771 .formats = PXA_SSP_FORMATS, 771 .formats = PXA_SSP_FORMATS,
772 }, 772 },
@@ -780,13 +780,13 @@ struct snd_soc_dai pxa_ssp_dai[] = {
780 .resume = pxa_ssp_resume, 780 .resume = pxa_ssp_resume,
781 .playback = { 781 .playback = {
782 .channels_min = 1, 782 .channels_min = 1,
783 .channels_max = 2, 783 .channels_max = 8,
784 .rates = PXA_SSP_RATES, 784 .rates = PXA_SSP_RATES,
785 .formats = PXA_SSP_FORMATS, 785 .formats = PXA_SSP_FORMATS,
786 }, 786 },
787 .capture = { 787 .capture = {
788 .channels_min = 1, 788 .channels_min = 1,
789 .channels_max = 2, 789 .channels_max = 8,
790 .rates = PXA_SSP_RATES, 790 .rates = PXA_SSP_RATES,
791 .formats = PXA_SSP_FORMATS, 791 .formats = PXA_SSP_FORMATS,
792 }, 792 },
@@ -801,13 +801,13 @@ struct snd_soc_dai pxa_ssp_dai[] = {
801 .resume = pxa_ssp_resume, 801 .resume = pxa_ssp_resume,
802 .playback = { 802 .playback = {
803 .channels_min = 1, 803 .channels_min = 1,
804 .channels_max = 2, 804 .channels_max = 8,
805 .rates = PXA_SSP_RATES, 805 .rates = PXA_SSP_RATES,
806 .formats = PXA_SSP_FORMATS, 806 .formats = PXA_SSP_FORMATS,
807 }, 807 },
808 .capture = { 808 .capture = {
809 .channels_min = 1, 809 .channels_min = 1,
810 .channels_max = 2, 810 .channels_max = 8,
811 .rates = PXA_SSP_RATES, 811 .rates = PXA_SSP_RATES,
812 .formats = PXA_SSP_FORMATS, 812 .formats = PXA_SSP_FORMATS,
813 }, 813 },
@@ -822,13 +822,13 @@ struct snd_soc_dai pxa_ssp_dai[] = {
822 .resume = pxa_ssp_resume, 822 .resume = pxa_ssp_resume,
823 .playback = { 823 .playback = {
824 .channels_min = 1, 824 .channels_min = 1,
825 .channels_max = 2, 825 .channels_max = 8,
826 .rates = PXA_SSP_RATES, 826 .rates = PXA_SSP_RATES,
827 .formats = PXA_SSP_FORMATS, 827 .formats = PXA_SSP_FORMATS,
828 }, 828 },
829 .capture = { 829 .capture = {
830 .channels_min = 1, 830 .channels_min = 1,
831 .channels_max = 2, 831 .channels_max = 8,
832 .rates = PXA_SSP_RATES, 832 .rates = PXA_SSP_RATES,
833 .formats = PXA_SSP_FORMATS, 833 .formats = PXA_SSP_FORMATS,
834 }, 834 },
diff --git a/sound/soc/pxa/raumfeld.c b/sound/soc/pxa/raumfeld.c
new file mode 100644
index 000000000000..acfce1c0f1c9
--- /dev/null
+++ b/sound/soc/pxa/raumfeld.c
@@ -0,0 +1,335 @@
1/*
2 * raumfeld_audio.c -- SoC audio for Raumfeld audio devices
3 *
4 * Copyright (c) 2009 Daniel Mack <daniel@caiaq.de>
5 *
6 * based on code from:
7 *
8 * Wolfson Microelectronics PLC.
9 * Openedhand Ltd.
10 * Liam Girdwood <lrg@slimlogic.co.uk>
11 * Richard Purdie <richard@openedhand.com>
12 *
13 * This program is free software; you can redistribute it and/or modify it
14 * under the terms of the GNU General Public License as published by the
15 * Free Software Foundation; either version 2 of the License, or (at your
16 * option) any later version.
17 */
18
19#include <linux/module.h>
20#include <linux/i2c.h>
21#include <linux/delay.h>
22#include <linux/gpio.h>
23#include <sound/pcm.h>
24#include <sound/soc.h>
25#include <sound/soc-dapm.h>
26
27#include <asm/mach-types.h>
28
29#include "../codecs/cs4270.h"
30#include "../codecs/ak4104.h"
31#include "pxa2xx-pcm.h"
32#include "pxa-ssp.h"
33
34#define GPIO_SPDIF_RESET (38)
35#define GPIO_MCLK_RESET (111)
36#define GPIO_CODEC_RESET (120)
37
38static struct i2c_client *max9486_client;
39static struct i2c_board_info max9486_hwmon_info = {
40 I2C_BOARD_INFO("max9485", 0x63),
41};
42
43#define MAX9485_MCLK_FREQ_112896 0x22
44#define MAX9485_MCLK_FREQ_122880 0x23
45
46static void set_max9485_clk(char clk)
47{
48 i2c_master_send(max9486_client, &clk, 1);
49}
50
51static void raumfeld_enable_audio(bool en)
52{
53 if (en) {
54 gpio_set_value(GPIO_MCLK_RESET, 1);
55
56 /* wait some time to let the clocks become stable */
57 msleep(100);
58
59 gpio_set_value(GPIO_SPDIF_RESET, 1);
60 gpio_set_value(GPIO_CODEC_RESET, 1);
61 } else {
62 gpio_set_value(GPIO_MCLK_RESET, 0);
63 gpio_set_value(GPIO_SPDIF_RESET, 0);
64 gpio_set_value(GPIO_CODEC_RESET, 0);
65 }
66}
67
68/* CS4270 */
69static int raumfeld_cs4270_startup(struct snd_pcm_substream *substream)
70{
71 struct snd_soc_pcm_runtime *rtd = substream->private_data;
72 struct snd_soc_dai *codec_dai = rtd->dai->codec_dai;
73
74 set_max9485_clk(MAX9485_MCLK_FREQ_112896);
75
76 return snd_soc_dai_set_sysclk(codec_dai, 0, 11289600, 0);
77}
78
79static int raumfeld_cs4270_hw_params(struct snd_pcm_substream *substream,
80 struct snd_pcm_hw_params *params)
81{
82 struct snd_soc_pcm_runtime *rtd = substream->private_data;
83 struct snd_soc_dai *codec_dai = rtd->dai->codec_dai;
84 struct snd_soc_dai *cpu_dai = rtd->dai->cpu_dai;
85 unsigned int fmt, clk = 0;
86 int ret = 0;
87
88 switch (params_rate(params)) {
89 case 8000:
90 case 16000:
91 case 48000:
92 case 96000:
93 set_max9485_clk(MAX9485_MCLK_FREQ_122880);
94 clk = 12288000;
95 break;
96 case 11025:
97 case 22050:
98 case 44100:
99 case 88200:
100 set_max9485_clk(MAX9485_MCLK_FREQ_112896);
101 clk = 11289600;
102 break;
103 }
104
105 fmt = SND_SOC_DAIFMT_I2S |
106 SND_SOC_DAIFMT_NB_NF |
107 SND_SOC_DAIFMT_CBS_CFS;
108
109 /* setup the CODEC DAI */
110 ret = snd_soc_dai_set_fmt(codec_dai, fmt);
111 if (ret < 0)
112 return ret;
113
114 ret = snd_soc_dai_set_sysclk(codec_dai, 0, clk, 0);
115 if (ret < 0)
116 return ret;
117
118 /* setup the CPU DAI */
119 ret = snd_soc_dai_set_pll(cpu_dai, 0, 0, 0, clk);
120 if (ret < 0)
121 return ret;
122
123 ret = snd_soc_dai_set_fmt(cpu_dai, fmt);
124 if (ret < 0)
125 return ret;
126
127 ret = snd_soc_dai_set_clkdiv(cpu_dai, PXA_SSP_DIV_SCR, 4);
128 if (ret < 0)
129 return ret;
130
131 ret = snd_soc_dai_set_sysclk(cpu_dai, PXA_SSP_CLK_EXT, 0, 1);
132 if (ret < 0)
133 return ret;
134
135 return 0;
136}
137
138static struct snd_soc_ops raumfeld_cs4270_ops = {
139 .startup = raumfeld_cs4270_startup,
140 .hw_params = raumfeld_cs4270_hw_params,
141};
142
143static int raumfeld_line_suspend(struct platform_device *pdev, pm_message_t state)
144{
145 raumfeld_enable_audio(false);
146 return 0;
147}
148
149static int raumfeld_line_resume(struct platform_device *pdev)
150{
151 raumfeld_enable_audio(true);
152 return 0;
153}
154
155static struct snd_soc_dai_link raumfeld_line_dai = {
156 .name = "CS4270",
157 .stream_name = "CS4270",
158 .cpu_dai = &pxa_ssp_dai[PXA_DAI_SSP1],
159 .codec_dai = &cs4270_dai,
160 .ops = &raumfeld_cs4270_ops,
161};
162
163static struct snd_soc_card snd_soc_line_raumfeld = {
164 .name = "Raumfeld analog",
165 .platform = &pxa2xx_soc_platform,
166 .dai_link = &raumfeld_line_dai,
167 .suspend_post = raumfeld_line_suspend,
168 .resume_pre = raumfeld_line_resume,
169 .num_links = 1,
170};
171
172
173/* AK4104 */
174
175static int raumfeld_ak4104_hw_params(struct snd_pcm_substream *substream,
176 struct snd_pcm_hw_params *params)
177{
178 struct snd_soc_pcm_runtime *rtd = substream->private_data;
179 struct snd_soc_dai *codec_dai = rtd->dai->codec_dai;
180 struct snd_soc_dai *cpu_dai = rtd->dai->cpu_dai;
181 int fmt, ret = 0, clk = 0;
182
183 switch (params_rate(params)) {
184 case 8000:
185 case 16000:
186 case 48000:
187 case 96000:
188 set_max9485_clk(MAX9485_MCLK_FREQ_122880);
189 clk = 12288000;
190 break;
191 case 11025:
192 case 22050:
193 case 44100:
194 case 88200:
195 set_max9485_clk(MAX9485_MCLK_FREQ_112896);
196 clk = 11289600;
197 break;
198 }
199
200 fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF;
201
202 /* setup the CODEC DAI */
203 ret = snd_soc_dai_set_fmt(codec_dai, fmt | SND_SOC_DAIFMT_CBS_CFS);
204 if (ret < 0)
205 return ret;
206
207 /* setup the CPU DAI */
208 ret = snd_soc_dai_set_pll(cpu_dai, 0, 0, 0, clk);
209 if (ret < 0)
210 return ret;
211
212 ret = snd_soc_dai_set_fmt(cpu_dai, fmt | SND_SOC_DAIFMT_CBS_CFS);
213 if (ret < 0)
214 return ret;
215
216 ret = snd_soc_dai_set_clkdiv(cpu_dai, PXA_SSP_DIV_SCR, 4);
217 if (ret < 0)
218 return ret;
219
220 ret = snd_soc_dai_set_sysclk(cpu_dai, PXA_SSP_CLK_EXT, 0, 1);
221 if (ret < 0)
222 return ret;
223
224 return 0;
225}
226
227static struct snd_soc_ops raumfeld_ak4104_ops = {
228 .hw_params = raumfeld_ak4104_hw_params,
229};
230
231static struct snd_soc_dai_link raumfeld_spdif_dai = {
232 .name = "ak4104",
233 .stream_name = "Playback",
234 .cpu_dai = &pxa_ssp_dai[PXA_DAI_SSP2],
235 .codec_dai = &ak4104_dai,
236 .ops = &raumfeld_ak4104_ops,
237};
238
239static struct snd_soc_card snd_soc_spdif_raumfeld = {
240 .name = "Raumfeld S/PDIF",
241 .platform = &pxa2xx_soc_platform,
242 .dai_link = &raumfeld_spdif_dai,
243 .num_links = 1
244};
245
246/* raumfeld_audio audio subsystem */
247static struct snd_soc_device raumfeld_line_devdata = {
248 .card = &snd_soc_line_raumfeld,
249 .codec_dev = &soc_codec_device_cs4270,
250};
251
252static struct snd_soc_device raumfeld_spdif_devdata = {
253 .card = &snd_soc_spdif_raumfeld,
254 .codec_dev = &soc_codec_device_ak4104,
255};
256
257static struct platform_device *raumfeld_audio_line_device;
258static struct platform_device *raumfeld_audio_spdif_device;
259
260static int __init raumfeld_audio_init(void)
261{
262 int ret;
263
264 if (!machine_is_raumfeld_speaker() &&
265 !machine_is_raumfeld_connector())
266 return 0;
267
268 max9486_client = i2c_new_device(i2c_get_adapter(0),
269 &max9486_hwmon_info);
270
271 if (!max9486_client)
272 return -ENOMEM;
273
274 set_max9485_clk(MAX9485_MCLK_FREQ_122880);
275
276 /* LINE */
277 raumfeld_audio_line_device = platform_device_alloc("soc-audio", 0);
278 if (!raumfeld_audio_line_device)
279 return -ENOMEM;
280
281 platform_set_drvdata(raumfeld_audio_line_device,
282 &raumfeld_line_devdata);
283 raumfeld_line_devdata.dev = &raumfeld_audio_line_device->dev;
284 ret = platform_device_add(raumfeld_audio_line_device);
285 if (ret)
286 platform_device_put(raumfeld_audio_line_device);
287
288 /* no S/PDIF on Speakers */
289 if (machine_is_raumfeld_speaker())
290 return ret;
291
292 /* S/PDIF */
293 raumfeld_audio_spdif_device = platform_device_alloc("soc-audio", 1);
294 if (!raumfeld_audio_spdif_device) {
295 platform_device_put(raumfeld_audio_line_device);
296 return -ENOMEM;
297 }
298
299 platform_set_drvdata(raumfeld_audio_spdif_device,
300 &raumfeld_spdif_devdata);
301 raumfeld_spdif_devdata.dev = &raumfeld_audio_spdif_device->dev;
302 ret = platform_device_add(raumfeld_audio_spdif_device);
303 if (ret) {
304 platform_device_put(raumfeld_audio_line_device);
305 platform_device_put(raumfeld_audio_spdif_device);
306 }
307
308 raumfeld_enable_audio(true);
309
310 return ret;
311}
312
313static void __exit raumfeld_audio_exit(void)
314{
315 raumfeld_enable_audio(false);
316
317 platform_device_unregister(raumfeld_audio_line_device);
318
319 if (machine_is_raumfeld_connector())
320 platform_device_unregister(raumfeld_audio_spdif_device);
321
322 i2c_unregister_device(max9486_client);
323
324 gpio_free(GPIO_MCLK_RESET);
325 gpio_free(GPIO_CODEC_RESET);
326 gpio_free(GPIO_SPDIF_RESET);
327}
328
329module_init(raumfeld_audio_init);
330module_exit(raumfeld_audio_exit);
331
332/* Module information */
333MODULE_AUTHOR("Daniel Mack <daniel@caiaq.de>");
334MODULE_DESCRIPTION("Raumfeld audio SoC");
335MODULE_LICENSE("GPL");
diff --git a/sound/soc/pxa/zylonite.c b/sound/soc/pxa/zylonite.c
index 9a386b4c4ed1..dd678ae24398 100644
--- a/sound/soc/pxa/zylonite.c
+++ b/sound/soc/pxa/zylonite.c
@@ -74,7 +74,8 @@ static const struct snd_soc_dapm_route audio_map[] = {
74static int zylonite_wm9713_init(struct snd_soc_codec *codec) 74static int zylonite_wm9713_init(struct snd_soc_codec *codec)
75{ 75{
76 if (clk_pout) 76 if (clk_pout)
77 snd_soc_dai_set_pll(&codec->dai[0], 0, clk_get_rate(pout), 0); 77 snd_soc_dai_set_pll(&codec->dai[0], 0, 0,
78 clk_get_rate(pout), 0);
78 79
79 snd_soc_dapm_new_controls(codec, zylonite_dapm_widgets, 80 snd_soc_dapm_new_controls(codec, zylonite_dapm_widgets,
80 ARRAY_SIZE(zylonite_dapm_widgets)); 81 ARRAY_SIZE(zylonite_dapm_widgets));
@@ -128,7 +129,7 @@ static int zylonite_voice_hw_params(struct snd_pcm_substream *substream,
128 if (ret < 0) 129 if (ret < 0)
129 return ret; 130 return ret;
130 131
131 ret = snd_soc_dai_set_pll(cpu_dai, 0, 0, pll_out); 132 ret = snd_soc_dai_set_pll(cpu_dai, 0, 0, 0, pll_out);
132 if (ret < 0) 133 if (ret < 0)
133 return ret; 134 return ret;
134 135