aboutsummaryrefslogtreecommitdiffstats
path: root/sound
diff options
context:
space:
mode:
authorjassi brar <jassisinghbrar@gmail.com>2009-09-18 20:46:06 -0400
committerMark Brown <broonie@opensource.wolfsonmicro.com>2009-09-19 11:28:54 -0400
commitd0f5fa17aa63262685e43b798ca0830d89786235 (patch)
treebda5cadcdd2c5c1ba6c88192228b4c64444b41fa /sound
parent9f072b7b2260a588bfb5fb43418c3358104e7c13 (diff)
ASoC: Support WM8580 based audio subsystem on SMDK64xx machines
New machine driver for WM8580 I2S i/f on SMDK64XX. By default SoC-Slave is set and WM8580 is configured to use it's PLLA to generate clocks from a 12MHz crystal attached to WM8580. [Added dependency on BROKEN since the IISv4 interface hasn't been merged yet, fixed the PLL API usage and removed the disabling of the PLL in the hw_free function since that'll break simultaneous playback and record -- broonie.] Signed-off-by: Jassi <jassi.brar@samsung.com> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Diffstat (limited to 'sound')
-rw-r--r--sound/soc/s3c24xx/Kconfig9
-rw-r--r--sound/soc/s3c24xx/Makefile2
-rw-r--r--sound/soc/s3c24xx/smdk64xx_wm8580.c273
3 files changed, 284 insertions, 0 deletions
diff --git a/sound/soc/s3c24xx/Kconfig b/sound/soc/s3c24xx/Kconfig
index 923428fc1adb..d7912f1e4627 100644
--- a/sound/soc/s3c24xx/Kconfig
+++ b/sound/soc/s3c24xx/Kconfig
@@ -56,6 +56,15 @@ config SND_S3C24XX_SOC_JIVE_WM8750
56 help 56 help
57 Sat Y if you want to add support for SoC audio on the Jive. 57 Sat Y if you want to add support for SoC audio on the Jive.
58 58
59config SND_S3C64XX_SOC_WM8580
60 tristate "SoC I2S Audio support for WM8580 on SMDK64XX"
61 depends on SND_S3C24XX_SOC && (MACH_SMDK6400 || MACH_SMDK6410)
62 depends on BROKEN
63 select SND_SOC_WM8580
64 select SND_S3C64XX_SOC_I2S
65 help
66 Sat Y if you want to add support for SoC audio on the SMDK64XX.
67
59config SND_S3C24XX_SOC_SMDK2443_WM9710 68config SND_S3C24XX_SOC_SMDK2443_WM9710
60 tristate "SoC AC97 Audio support for SMDK2443 - WM9710" 69 tristate "SoC AC97 Audio support for SMDK2443 - WM9710"
61 depends on SND_S3C24XX_SOC && MACH_SMDK2443 70 depends on SND_S3C24XX_SOC && MACH_SMDK2443
diff --git a/sound/soc/s3c24xx/Makefile b/sound/soc/s3c24xx/Makefile
index 99f5a7dd3fc6..7790406f90b7 100644
--- a/sound/soc/s3c24xx/Makefile
+++ b/sound/soc/s3c24xx/Makefile
@@ -23,6 +23,7 @@ snd-soc-s3c24xx-uda134x-objs := s3c24xx_uda134x.o
23snd-soc-s3c24xx-simtec-objs := s3c24xx_simtec.o 23snd-soc-s3c24xx-simtec-objs := s3c24xx_simtec.o
24snd-soc-s3c24xx-simtec-hermes-objs := s3c24xx_simtec_hermes.o 24snd-soc-s3c24xx-simtec-hermes-objs := s3c24xx_simtec_hermes.o
25snd-soc-s3c24xx-simtec-tlv320aic23-objs := s3c24xx_simtec_tlv320aic23.o 25snd-soc-s3c24xx-simtec-tlv320aic23-objs := s3c24xx_simtec_tlv320aic23.o
26snd-soc-smdk64xx-wm8580-objs := smdk64xx_wm8580.o
26 27
27obj-$(CONFIG_SND_S3C24XX_SOC_JIVE_WM8750) += snd-soc-jive-wm8750.o 28obj-$(CONFIG_SND_S3C24XX_SOC_JIVE_WM8750) += snd-soc-jive-wm8750.o
28obj-$(CONFIG_SND_S3C24XX_SOC_NEO1973_WM8753) += snd-soc-neo1973-wm8753.o 29obj-$(CONFIG_SND_S3C24XX_SOC_NEO1973_WM8753) += snd-soc-neo1973-wm8753.o
@@ -33,4 +34,5 @@ obj-$(CONFIG_SND_S3C24XX_SOC_S3C24XX_UDA134X) += snd-soc-s3c24xx-uda134x.o
33obj-$(CONFIG_SND_S3C24XX_SOC_SIMTEC) += snd-soc-s3c24xx-simtec.o 34obj-$(CONFIG_SND_S3C24XX_SOC_SIMTEC) += snd-soc-s3c24xx-simtec.o
34obj-$(CONFIG_SND_S3C24XX_SOC_SIMTEC_HERMES) += snd-soc-s3c24xx-simtec-hermes.o 35obj-$(CONFIG_SND_S3C24XX_SOC_SIMTEC_HERMES) += snd-soc-s3c24xx-simtec-hermes.o
35obj-$(CONFIG_SND_S3C24XX_SOC_SIMTEC_TLV320AIC23) += snd-soc-s3c24xx-simtec-tlv320aic23.o 36obj-$(CONFIG_SND_S3C24XX_SOC_SIMTEC_TLV320AIC23) += snd-soc-s3c24xx-simtec-tlv320aic23.o
37obj-$(CONFIG_SND_S3C64XX_SOC_WM8580) += snd-soc-smdk64xx-wm8580.o
36 38
diff --git a/sound/soc/s3c24xx/smdk64xx_wm8580.c b/sound/soc/s3c24xx/smdk64xx_wm8580.c
new file mode 100644
index 000000000000..482aaf10eff6
--- /dev/null
+++ b/sound/soc/s3c24xx/smdk64xx_wm8580.c
@@ -0,0 +1,273 @@
1/*
2 * smdk64xx_wm8580.c
3 *
4 * Copyright (c) 2009 Samsung Electronics Co. Ltd
5 * Author: Jaswinder Singh <jassi.brar@samsung.com>
6 *
7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License as published by the
9 * Free Software Foundation; either version 2 of the License, or (at your
10 * option) any later version.
11 */
12
13#include <linux/platform_device.h>
14#include <linux/clk.h>
15#include <sound/core.h>
16#include <sound/pcm.h>
17#include <sound/pcm_params.h>
18#include <sound/soc.h>
19#include <sound/soc-dapm.h>
20
21#include "../codecs/wm8580.h"
22#include "s3c24xx-pcm.h"
23#include "s3c64xx-i2s.h"
24
25#define S3C64XX_I2S_V4 2
26
27/* SMDK64XX has a 12MHZ crystal attached to WM8580 */
28#define SMDK64XX_WM8580_FREQ 12000000
29
30static int smdk64xx_hw_params(struct snd_pcm_substream *substream,
31 struct snd_pcm_hw_params *params)
32{
33 struct snd_soc_pcm_runtime *rtd = substream->private_data;
34 struct snd_soc_dai *cpu_dai = rtd->dai->cpu_dai;
35 struct snd_soc_dai *codec_dai = rtd->dai->codec_dai;
36 unsigned int pll_out;
37 int bfs, rfs, ret;
38
39 switch (params_format(params)) {
40 case SNDRV_PCM_FORMAT_U8:
41 case SNDRV_PCM_FORMAT_S8:
42 bfs = 16;
43 break;
44 case SNDRV_PCM_FORMAT_U16_LE:
45 case SNDRV_PCM_FORMAT_S16_LE:
46 bfs = 32;
47 break;
48 default:
49 return -EINVAL;
50 }
51
52 /* The Fvco for WM8580 PLLs must fall within [90,100]MHz.
53 * This criterion can't be met if we request PLL output
54 * as {8000x256, 64000x256, 11025x256}Hz.
55 * As a wayout, we rather change rfs to a minimum value that
56 * results in (params_rate(params) * rfs), and itself, acceptable
57 * to both - the CODEC and the CPU.
58 */
59 switch (params_rate(params)) {
60 case 16000:
61 case 22050:
62 case 32000:
63 case 44100:
64 case 48000:
65 case 88200:
66 case 96000:
67 rfs = 256;
68 break;
69 case 64000:
70 rfs = 384;
71 break;
72 case 8000:
73 case 11025:
74 rfs = 512;
75 break;
76 default:
77 return -EINVAL;
78 }
79 pll_out = params_rate(params) * rfs;
80
81 /* Set the Codec DAI configuration */
82 ret = snd_soc_dai_set_fmt(codec_dai, SND_SOC_DAIFMT_I2S
83 | SND_SOC_DAIFMT_NB_NF
84 | SND_SOC_DAIFMT_CBM_CFM);
85 if (ret < 0)
86 return ret;
87
88 /* Set the AP DAI configuration */
89 ret = snd_soc_dai_set_fmt(cpu_dai, SND_SOC_DAIFMT_I2S
90 | SND_SOC_DAIFMT_NB_NF
91 | SND_SOC_DAIFMT_CBM_CFM);
92 if (ret < 0)
93 return ret;
94
95 ret = snd_soc_dai_set_sysclk(cpu_dai, S3C64XX_CLKSRC_CDCLK,
96 0, SND_SOC_CLOCK_IN);
97 if (ret < 0)
98 return ret;
99
100 /* We use PCLK for basic ops in SoC-Slave mode */
101 ret = snd_soc_dai_set_sysclk(cpu_dai, S3C64XX_CLKSRC_PCLK,
102 0, SND_SOC_CLOCK_IN);
103 if (ret < 0)
104 return ret;
105
106 /* Set WM8580 to drive MCLK from it's PLLA */
107 ret = snd_soc_dai_set_clkdiv(codec_dai, WM8580_MCLK,
108 WM8580_CLKSRC_PLLA);
109 if (ret < 0)
110 return ret;
111
112 /* Explicitly set WM8580-DAC to source from MCLK */
113 ret = snd_soc_dai_set_clkdiv(codec_dai, WM8580_DAC_CLKSEL,
114 WM8580_CLKSRC_MCLK);
115 if (ret < 0)
116 return ret;
117
118 /* Assuming the CODEC driver evaluates it's rfs too from this call */
119 ret = snd_soc_dai_set_pll(codec_dai, 0, WM8580_PLLA,
120 SMDK64XX_WM8580_FREQ, pll_out);
121 if (ret < 0)
122 return ret;
123
124 ret = snd_soc_dai_set_clkdiv(cpu_dai, S3C_I2SV2_DIV_BCLK, bfs);
125 if (ret < 0)
126 return ret;
127
128 ret = snd_soc_dai_set_clkdiv(cpu_dai, S3C_I2SV2_DIV_RCLK, rfs);
129 if (ret < 0)
130 return ret;
131
132 return 0;
133}
134
135/*
136 * SMDK64XX WM8580 DAI operations.
137 */
138static struct snd_soc_ops smdk64xx_ops = {
139 .hw_params = smdk64xx_hw_params,
140};
141
142/* SMDK64xx Playback widgets */
143static const struct snd_soc_dapm_widget wm8580_dapm_widgets_pbk[] = {
144 SND_SOC_DAPM_HP("Front-L/R", NULL),
145 SND_SOC_DAPM_HP("Center/Sub", NULL),
146 SND_SOC_DAPM_HP("Rear-L/R", NULL),
147};
148
149/* SMDK64xx Capture widgets */
150static const struct snd_soc_dapm_widget wm8580_dapm_widgets_cpt[] = {
151 SND_SOC_DAPM_MIC("MicIn", NULL),
152 SND_SOC_DAPM_LINE("LineIn", NULL),
153};
154
155/* SMDK-PAIFTX connections */
156static const struct snd_soc_dapm_route audio_map_tx[] = {
157 /* MicIn feeds AINL */
158 {"AINL", NULL, "MicIn"},
159
160 /* LineIn feeds AINL/R */
161 {"AINL", NULL, "LineIn"},
162 {"AINR", NULL, "LineIn"},
163};
164
165/* SMDK-PAIFRX connections */
166static const struct snd_soc_dapm_route audio_map_rx[] = {
167 /* Front Left/Right are fed VOUT1L/R */
168 {"Front-L/R", NULL, "VOUT1L"},
169 {"Front-L/R", NULL, "VOUT1R"},
170
171 /* Center/Sub are fed VOUT2L/R */
172 {"Center/Sub", NULL, "VOUT2L"},
173 {"Center/Sub", NULL, "VOUT2R"},
174
175 /* Rear Left/Right are fed VOUT3L/R */
176 {"Rear-L/R", NULL, "VOUT3L"},
177 {"Rear-L/R", NULL, "VOUT3R"},
178};
179
180static int smdk64xx_wm8580_init_paiftx(struct snd_soc_codec *codec)
181{
182 /* Add smdk64xx specific Capture widgets */
183 snd_soc_dapm_new_controls(codec, wm8580_dapm_widgets_cpt,
184 ARRAY_SIZE(wm8580_dapm_widgets_cpt));
185
186 /* Set up PAIFTX audio path */
187 snd_soc_dapm_add_routes(codec, audio_map_tx, ARRAY_SIZE(audio_map_tx));
188
189 /* All enabled by default */
190 snd_soc_dapm_enable_pin(codec, "MicIn");
191 snd_soc_dapm_enable_pin(codec, "LineIn");
192
193 /* signal a DAPM event */
194 snd_soc_dapm_sync(codec);
195
196 return 0;
197}
198
199static int smdk64xx_wm8580_init_paifrx(struct snd_soc_codec *codec)
200{
201 /* Add smdk64xx specific Playback widgets */
202 snd_soc_dapm_new_controls(codec, wm8580_dapm_widgets_pbk,
203 ARRAY_SIZE(wm8580_dapm_widgets_pbk));
204
205 /* Set up PAIFRX audio path */
206 snd_soc_dapm_add_routes(codec, audio_map_rx, ARRAY_SIZE(audio_map_rx));
207
208 /* All enabled by default */
209 snd_soc_dapm_enable_pin(codec, "Front-L/R");
210 snd_soc_dapm_enable_pin(codec, "Center/Sub");
211 snd_soc_dapm_enable_pin(codec, "Rear-L/R");
212
213 /* signal a DAPM event */
214 snd_soc_dapm_sync(codec);
215
216 return 0;
217}
218
219static struct snd_soc_dai_link smdk64xx_dai[] = {
220{ /* Primary Playback i/f */
221 .name = "WM8580 PAIF RX",
222 .stream_name = "Playback",
223 .cpu_dai = &s3c64xx_i2s_dai[S3C64XX_I2S_V4],
224 .codec_dai = &wm8580_dai[WM8580_DAI_PAIFRX],
225 .init = smdk64xx_wm8580_init_paifrx,
226 .ops = &smdk64xx_ops,
227},
228{ /* Primary Capture i/f */
229 .name = "WM8580 PAIF TX",
230 .stream_name = "Capture",
231 .cpu_dai = &s3c64xx_i2s_dai[S3C64XX_I2S_V4],
232 .codec_dai = &wm8580_dai[WM8580_DAI_PAIFTX],
233 .init = smdk64xx_wm8580_init_paiftx,
234 .ops = &smdk64xx_ops,
235},
236};
237
238static struct snd_soc_card smdk64xx = {
239 .name = "smdk64xx",
240 .platform = &s3c24xx_soc_platform,
241 .dai_link = smdk64xx_dai,
242 .num_links = ARRAY_SIZE(smdk64xx_dai),
243};
244
245static struct snd_soc_device smdk64xx_snd_devdata = {
246 .card = &smdk64xx,
247 .codec_dev = &soc_codec_dev_wm8580,
248};
249
250static struct platform_device *smdk64xx_snd_device;
251
252static int __init smdk64xx_audio_init(void)
253{
254 int ret;
255
256 smdk64xx_snd_device = platform_device_alloc("soc-audio", -1);
257 if (!smdk64xx_snd_device)
258 return -ENOMEM;
259
260 platform_set_drvdata(smdk64xx_snd_device, &smdk64xx_snd_devdata);
261 smdk64xx_snd_devdata.dev = &smdk64xx_snd_device->dev;
262 ret = platform_device_add(smdk64xx_snd_device);
263
264 if (ret)
265 platform_device_put(smdk64xx_snd_device);
266
267 return ret;
268}
269module_init(smdk64xx_audio_init);
270
271MODULE_AUTHOR("Jaswinder Singh, jassi.brar@samsung.com");
272MODULE_DESCRIPTION("ALSA SoC SMDK64XX WM8580");
273MODULE_LICENSE("GPL");