aboutsummaryrefslogtreecommitdiffstats
path: root/sound/soc
diff options
context:
space:
mode:
authorBen Dooks <ben@simtec.co.uk>2009-03-03 19:49:27 -0500
committerMark Brown <broonie@opensource.wolfsonmicro.com>2009-03-06 08:37:07 -0500
commit3093e48c48b69ccc06a1f78ffe7ece7ee2ee09ef (patch)
tree653bcbbb6781b7727752cb374e8ea1298294acad /sound/soc
parent979c036e090332cd3a090ce8b4eb50c3aa28dea0 (diff)
ASoC: Add JIVE audio support
Add support for the Jive's WM8750 codec attached via the S3C2412 IIS. Signed-off-by: Ben Dooks <ben@simtec.co.uk> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Diffstat (limited to 'sound/soc')
-rw-r--r--sound/soc/s3c24xx/Kconfig9
-rw-r--r--sound/soc/s3c24xx/Makefile2
-rw-r--r--sound/soc/s3c24xx/jive_wm8750.c216
3 files changed, 227 insertions, 0 deletions
diff --git a/sound/soc/s3c24xx/Kconfig b/sound/soc/s3c24xx/Kconfig
index e05a71084c32..7803218d1903 100644
--- a/sound/soc/s3c24xx/Kconfig
+++ b/sound/soc/s3c24xx/Kconfig
@@ -26,6 +26,15 @@ config SND_S3C24XX_SOC_NEO1973_WM8753
26 Say Y if you want to add support for SoC audio on smdk2440 26 Say Y if you want to add support for SoC audio on smdk2440
27 with the WM8753. 27 with the WM8753.
28 28
29config SND_S3C24XX_SOC_JIVE_WM8750
30 tristate "SoC I2S Audio support for Jive"
31 depends on SND_S3C24XX_SOC && MACH_JIVE
32 select SND_SOC_WM8750
33 select SND_SOC_WM8750_SPI
34 select SND_S3C2412_SOC_I2S
35 help
36 Sat Y if you want to add support for SoC audio on the Jive.
37
29config SND_S3C24XX_SOC_SMDK2443_WM9710 38config SND_S3C24XX_SOC_SMDK2443_WM9710
30 tristate "SoC AC97 Audio support for SMDK2443 - WM9710" 39 tristate "SoC AC97 Audio support for SMDK2443 - WM9710"
31 depends on SND_S3C24XX_SOC && MACH_SMDK2443 40 depends on SND_S3C24XX_SOC && MACH_SMDK2443
diff --git a/sound/soc/s3c24xx/Makefile b/sound/soc/s3c24xx/Makefile
index 96b3f3f617d4..bc11976e269c 100644
--- a/sound/soc/s3c24xx/Makefile
+++ b/sound/soc/s3c24xx/Makefile
@@ -10,11 +10,13 @@ obj-$(CONFIG_SND_S3C2443_SOC_AC97) += snd-soc-s3c2443-ac97.o
10obj-$(CONFIG_SND_S3C2412_SOC_I2S) += snd-soc-s3c2412-i2s.o 10obj-$(CONFIG_SND_S3C2412_SOC_I2S) += snd-soc-s3c2412-i2s.o
11 11
12# S3C24XX Machine Support 12# S3C24XX Machine Support
13snd-soc-jive-wm8750-objs := jive_wm8750.o
13snd-soc-neo1973-wm8753-objs := neo1973_wm8753.o 14snd-soc-neo1973-wm8753-objs := neo1973_wm8753.o
14snd-soc-smdk2443-wm9710-objs := smdk2443_wm9710.o 15snd-soc-smdk2443-wm9710-objs := smdk2443_wm9710.o
15snd-soc-ln2440sbc-alc650-objs := ln2440sbc_alc650.o 16snd-soc-ln2440sbc-alc650-objs := ln2440sbc_alc650.o
16snd-soc-s3c24xx-uda134x-objs := s3c24xx_uda134x.o 17snd-soc-s3c24xx-uda134x-objs := s3c24xx_uda134x.o
17 18
19obj-$(CONFIG_SND_S3C24XX_SOC_JIVE_WM8750) += snd-soc-jive-wm8750.o
18obj-$(CONFIG_SND_S3C24XX_SOC_NEO1973_WM8753) += snd-soc-neo1973-wm8753.o 20obj-$(CONFIG_SND_S3C24XX_SOC_NEO1973_WM8753) += snd-soc-neo1973-wm8753.o
19obj-$(CONFIG_SND_S3C24XX_SOC_SMDK2443_WM9710) += snd-soc-smdk2443-wm9710.o 21obj-$(CONFIG_SND_S3C24XX_SOC_SMDK2443_WM9710) += snd-soc-smdk2443-wm9710.o
20obj-$(CONFIG_SND_S3C24XX_SOC_LN2440SBC_ALC650) += snd-soc-ln2440sbc-alc650.o 22obj-$(CONFIG_SND_S3C24XX_SOC_LN2440SBC_ALC650) += snd-soc-ln2440sbc-alc650.o
diff --git a/sound/soc/s3c24xx/jive_wm8750.c b/sound/soc/s3c24xx/jive_wm8750.c
new file mode 100644
index 000000000000..fe466c1f71ec
--- /dev/null
+++ b/sound/soc/s3c24xx/jive_wm8750.c
@@ -0,0 +1,216 @@
1/* sound/soc/s3c24xx/jive_wm8750.c
2 *
3 * Copyright 2007,2008 Simtec Electronics
4 *
5 * Based on sound/soc/pxa/spitz.c
6 * Copyright 2005 Wolfson Microelectronics PLC.
7 * Copyright 2005 Openedhand Ltd.
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License version 2 as
11 * published by the Free Software Foundation.
12*/
13
14#include <linux/module.h>
15#include <linux/moduleparam.h>
16#include <linux/timer.h>
17#include <linux/interrupt.h>
18#include <linux/platform_device.h>
19#include <linux/clk.h>
20
21#include <sound/core.h>
22#include <sound/pcm.h>
23#include <sound/soc.h>
24#include <sound/soc-dapm.h>
25
26#include <asm/mach-types.h>
27
28#include "s3c24xx-pcm.h"
29#include "s3c2412-i2s.h"
30
31#include "../codecs/wm8750.h"
32
33static const struct snd_soc_dapm_route audio_map[] = {
34 { "Headphone Jack", NULL, "LOUT1" },
35 { "Headphone Jack", NULL, "ROUT1" },
36 { "Internal Speaker", NULL, "LOUT2" },
37 { "Internal Speaker", NULL, "ROUT2" },
38 { "LINPUT1", NULL, "Line Input" },
39 { "RINPUT1", NULL, "Line Input" },
40};
41
42static const struct snd_soc_dapm_widget wm8750_dapm_widgets[] = {
43 SND_SOC_DAPM_HP("Headphone Jack", NULL),
44 SND_SOC_DAPM_SPK("Internal Speaker", NULL),
45 SND_SOC_DAPM_LINE("Line In", NULL),
46};
47
48static int jive_startup(struct snd_pcm_substream *substream)
49{
50 struct snd_soc_pcm_runtime *rtd = substream->private_data;
51 struct snd_soc_codec *codec = rtd->socdev->codec;
52
53 snd_soc_dapm_enable_pin(codec, "Headphone Jack");
54 snd_soc_dapm_enable_pin(codec, "Internal Speaker");
55 snd_soc_dapm_enable_pin(codec, "Line In");
56
57 snd_soc_dapm_sync(codec);
58
59 return 0;
60}
61
62static int jive_hw_params(struct snd_pcm_substream *substream,
63 struct snd_pcm_hw_params *params)
64{
65 struct snd_soc_pcm_runtime *rtd = substream->private_data;
66 struct snd_soc_dai *codec_dai = rtd->dai->codec_dai;
67 struct snd_soc_dai *cpu_dai = rtd->dai->cpu_dai;
68 struct s3c2412_rate_calc div;
69 unsigned int clk = 0;
70 int ret = 0;
71
72 switch (params_rate(params)) {
73 case 8000:
74 case 16000:
75 case 48000:
76 case 96000:
77 clk = 12288000;
78 break;
79 case 11025:
80 case 22050:
81 case 44100:
82 clk = 11289600;
83 break;
84 }
85
86 s3c2412_iis_calc_rate(&div, NULL, params_rate(params),
87 s3c2412_get_iisclk());
88
89 /* set codec DAI configuration */
90 ret = snd_soc_dai_set_fmt(codec_dai, SND_SOC_DAIFMT_I2S |
91 SND_SOC_DAIFMT_NB_NF |
92 SND_SOC_DAIFMT_CBS_CFS);
93 if (ret < 0)
94 return ret;
95
96 /* set cpu DAI configuration */
97 ret = snd_soc_dai_set_fmt(cpu_dai, SND_SOC_DAIFMT_I2S |
98 SND_SOC_DAIFMT_NB_NF |
99 SND_SOC_DAIFMT_CBS_CFS);
100 if (ret < 0)
101 return ret;
102
103 /* set the codec system clock for DAC and ADC */
104 ret = snd_soc_dai_set_sysclk(codec_dai, WM8750_SYSCLK, clk,
105 SND_SOC_CLOCK_IN);
106 if (ret < 0)
107 return ret;
108
109 ret = snd_soc_dai_set_clkdiv(cpu_dai, S3C2412_DIV_RCLK, div.fs_div);
110 if (ret < 0)
111 return ret;
112
113 ret = snd_soc_dai_set_clkdiv(cpu_dai, S3C2412_DIV_PRESCALER,
114 div.clk_div - 1);
115 if (ret < 0)
116 return ret;
117
118 return 0;
119}
120
121static struct snd_soc_ops jive_ops = {
122 .startup = jive_startup,
123 .hw_params = jive_hw_params,
124};
125
126static int jive_wm8750_init(struct snd_soc_codec *codec)
127{
128 int err;
129
130 /* These endpoints are not being used. */
131 snd_soc_dapm_disable_pin(codec, "LINPUT2");
132 snd_soc_dapm_disable_pin(codec, "RINPUT2");
133 snd_soc_dapm_disable_pin(codec, "LINPUT3");
134 snd_soc_dapm_disable_pin(codec, "RINPUT3");
135 snd_soc_dapm_disable_pin(codec, "OUT3");
136 snd_soc_dapm_disable_pin(codec, "MONO");
137
138 /* Add jive specific widgets */
139 err = snd_soc_dapm_new_controls(codec, wm8750_dapm_widgets,
140 ARRAY_SIZE(wm8750_dapm_widgets));
141 if (err) {
142 printk(KERN_ERR "%s: failed to add widgets (%d)\n",
143 __func__, err);
144 return err;
145 }
146
147 snd_soc_dapm_add_routes(codec, audio_map, ARRAY_SIZE(audio_map));
148 snd_soc_dapm_sync(codec);
149
150 return 0;
151}
152
153static struct snd_soc_dai_link jive_dai = {
154 .name = "wm8750",
155 .stream_name = "WM8750",
156 .cpu_dai = &s3c2412_i2s_dai,
157 .codec_dai = &wm8750_dai,
158 .init = jive_wm8750_init,
159 .ops = &jive_ops,
160};
161
162/* jive audio machine driver */
163static struct snd_soc_machine snd_soc_machine_jive = {
164 .name = "Jive",
165 .dai_link = &jive_dai,
166 .num_links = 1,
167};
168
169/* jive audio private data */
170static struct wm8750_setup_data jive_wm8750_setup = {
171};
172
173/* jive audio subsystem */
174static struct snd_soc_device jive_snd_devdata = {
175 .machine = &snd_soc_machine_jive,
176 .platform = &s3c24xx_soc_platform,
177 .codec_dev = &soc_codec_dev_wm8750_spi,
178 .codec_data = &jive_wm8750_setup,
179};
180
181static struct platform_device *jive_snd_device;
182
183static int __init jive_init(void)
184{
185 int ret;
186
187 if (!machine_is_jive())
188 return 0;
189
190 printk("JIVE WM8750 Audio support\n");
191
192 jive_snd_device = platform_device_alloc("soc-audio", -1);
193 if (!jive_snd_device)
194 return -ENOMEM;
195
196 platform_set_drvdata(jive_snd_device, &jive_snd_devdata);
197 jive_snd_devdata.dev = &jive_snd_device->dev;
198 ret = platform_device_add(jive_snd_device);
199
200 if (ret)
201 platform_device_put(jive_snd_device);
202
203 return ret;
204}
205
206static void __exit jive_exit(void)
207{
208 platform_device_unregister(jive_snd_device);
209}
210
211module_init(jive_init);
212module_exit(jive_exit);
213
214MODULE_AUTHOR("Ben Dooks <ben@simtec.co.uk>");
215MODULE_DESCRIPTION("ALSA SoC Jive Audio support");
216MODULE_LICENSE("GPL");