aboutsummaryrefslogtreecommitdiffstats
path: root/sound/soc/omap
diff options
context:
space:
mode:
authorGlenn Elliott <gelliott@cs.unc.edu>2012-03-04 19:47:13 -0500
committerGlenn Elliott <gelliott@cs.unc.edu>2012-03-04 19:47:13 -0500
commitc71c03bda1e86c9d5198c5d83f712e695c4f2a1e (patch)
treeecb166cb3e2b7e2adb3b5e292245fefd23381ac8 /sound/soc/omap
parentea53c912f8a86a8567697115b6a0d8152beee5c8 (diff)
parent6a00f206debf8a5c8899055726ad127dbeeed098 (diff)
Merge branch 'mpi-master' into wip-k-fmlpwip-k-fmlp
Conflicts: litmus/sched_cedf.c
Diffstat (limited to 'sound/soc/omap')
-rw-r--r--sound/soc/omap/Kconfig11
-rw-r--r--sound/soc/omap/Makefile1
-rw-r--r--sound/soc/omap/am3517evm.c43
-rw-r--r--sound/soc/omap/ams-delta.c184
-rw-r--r--sound/soc/omap/igep0020.c27
-rw-r--r--sound/soc/omap/mcpdm.c19
-rw-r--r--sound/soc/omap/mcpdm.h2
-rw-r--r--sound/soc/omap/n810.c86
-rw-r--r--sound/soc/omap/omap-mcbsp.c359
-rw-r--r--sound/soc/omap/omap-mcbsp.h12
-rw-r--r--sound/soc/omap/omap-mcpdm.c72
-rw-r--r--sound/soc/omap/omap-mcpdm.h29
-rw-r--r--sound/soc/omap/omap-pcm.c54
-rw-r--r--sound/soc/omap/omap-pcm.h4
-rw-r--r--sound/soc/omap/omap2evm.c151
-rw-r--r--sound/soc/omap/omap3beagle.c28
-rw-r--r--sound/soc/omap/omap3evm.c35
-rw-r--r--sound/soc/omap/omap3pandora.c82
-rw-r--r--sound/soc/omap/osk5912.c49
-rw-r--r--sound/soc/omap/overo.c23
-rw-r--r--sound/soc/omap/rx51.c197
-rw-r--r--sound/soc/omap/sdp3430.c104
-rw-r--r--sound/soc/omap/sdp4430.c84
-rw-r--r--sound/soc/omap/zoom2.c102
24 files changed, 744 insertions, 1014 deletions
diff --git a/sound/soc/omap/Kconfig b/sound/soc/omap/Kconfig
index d542ea2ff6be..99054cf1f68f 100644
--- a/sound/soc/omap/Kconfig
+++ b/sound/soc/omap/Kconfig
@@ -12,8 +12,8 @@ config SND_OMAP_SOC_MCPDM
12config SND_OMAP_SOC_N810 12config SND_OMAP_SOC_N810
13 tristate "SoC Audio support for Nokia N810" 13 tristate "SoC Audio support for Nokia N810"
14 depends on SND_OMAP_SOC && MACH_NOKIA_N810 && I2C 14 depends on SND_OMAP_SOC && MACH_NOKIA_N810 && I2C
15 depends on OMAP_MUX
15 select SND_OMAP_SOC_MCBSP 16 select SND_OMAP_SOC_MCBSP
16 select OMAP_MUX
17 select SND_SOC_TLV320AIC3X 17 select SND_SOC_TLV320AIC3X
18 help 18 help
19 Say Y if you want to add support for SoC audio on Nokia N810. 19 Say Y if you want to add support for SoC audio on Nokia N810.
@@ -24,6 +24,7 @@ config SND_OMAP_SOC_RX51
24 select OMAP_MCBSP 24 select OMAP_MCBSP
25 select SND_OMAP_SOC_MCBSP 25 select SND_OMAP_SOC_MCBSP
26 select SND_SOC_TLV320AIC3X 26 select SND_SOC_TLV320AIC3X
27 select SND_SOC_TPA6130A2
27 help 28 help
28 Say Y if you want to add support for SoC audio on Nokia RX-51 29 Say Y if you want to add support for SoC audio on Nokia RX-51
29 hardware. This is also known as Nokia N900 product. 30 hardware. This is also known as Nokia N900 product.
@@ -64,14 +65,6 @@ config SND_OMAP_SOC_OVERO
64 Say Y if you want to add support for SoC audio on the 65 Say Y if you want to add support for SoC audio on the
65 Gumstix Overo or CompuLab CM-T35 66 Gumstix Overo or CompuLab CM-T35
66 67
67config SND_OMAP_SOC_OMAP2EVM
68 tristate "SoC Audio support for OMAP2EVM board"
69 depends on TWL4030_CORE && SND_OMAP_SOC && MACH_OMAP2EVM
70 select SND_OMAP_SOC_MCBSP
71 select SND_SOC_TWL4030
72 help
73 Say Y if you want to add support for SoC audio on the omap2evm board.
74
75config SND_OMAP_SOC_OMAP3EVM 68config SND_OMAP_SOC_OMAP3EVM
76 tristate "SoC Audio support for OMAP3EVM board" 69 tristate "SoC Audio support for OMAP3EVM board"
77 depends on TWL4030_CORE && SND_OMAP_SOC && MACH_OMAP3EVM 70 depends on TWL4030_CORE && SND_OMAP_SOC && MACH_OMAP3EVM
diff --git a/sound/soc/omap/Makefile b/sound/soc/omap/Makefile
index ba9fc650db28..6c2c87eed5bb 100644
--- a/sound/soc/omap/Makefile
+++ b/sound/soc/omap/Makefile
@@ -13,7 +13,6 @@ snd-soc-rx51-objs := rx51.o
13snd-soc-ams-delta-objs := ams-delta.o 13snd-soc-ams-delta-objs := ams-delta.o
14snd-soc-osk5912-objs := osk5912.o 14snd-soc-osk5912-objs := osk5912.o
15snd-soc-overo-objs := overo.o 15snd-soc-overo-objs := overo.o
16snd-soc-omap2evm-objs := omap2evm.o
17snd-soc-omap3evm-objs := omap3evm.o 16snd-soc-omap3evm-objs := omap3evm.o
18snd-soc-am3517evm-objs := am3517evm.o 17snd-soc-am3517evm-objs := am3517evm.o
19snd-soc-sdp3430-objs := sdp3430.o 18snd-soc-sdp3430-objs := sdp3430.o
diff --git a/sound/soc/omap/am3517evm.c b/sound/soc/omap/am3517evm.c
index 135901b2ea11..73dde4a1adc3 100644
--- a/sound/soc/omap/am3517evm.c
+++ b/sound/soc/omap/am3517evm.c
@@ -22,7 +22,6 @@
22#include <sound/core.h> 22#include <sound/core.h>
23#include <sound/pcm.h> 23#include <sound/pcm.h>
24#include <sound/soc.h> 24#include <sound/soc.h>
25#include <sound/soc-dapm.h>
26 25
27#include <asm/mach-types.h> 26#include <asm/mach-types.h>
28#include <mach/hardware.h> 27#include <mach/hardware.h>
@@ -40,8 +39,8 @@ static int am3517evm_hw_params(struct snd_pcm_substream *substream,
40 struct snd_pcm_hw_params *params) 39 struct snd_pcm_hw_params *params)
41{ 40{
42 struct snd_soc_pcm_runtime *rtd = substream->private_data; 41 struct snd_soc_pcm_runtime *rtd = substream->private_data;
43 struct snd_soc_dai *codec_dai = rtd->dai->codec_dai; 42 struct snd_soc_dai *codec_dai = rtd->codec_dai;
44 struct snd_soc_dai *cpu_dai = rtd->dai->cpu_dai; 43 struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
45 int ret; 44 int ret;
46 45
47 /* Set codec DAI configuration */ 46 /* Set codec DAI configuration */
@@ -111,21 +110,24 @@ static const struct snd_soc_dapm_route audio_map[] = {
111 {"MICIN", NULL, "Mic In"}, 110 {"MICIN", NULL, "Mic In"},
112}; 111};
113 112
114static int am3517evm_aic23_init(struct snd_soc_codec *codec) 113static int am3517evm_aic23_init(struct snd_soc_pcm_runtime *rtd)
115{ 114{
115 struct snd_soc_codec *codec = rtd->codec;
116 struct snd_soc_dapm_context *dapm = &codec->dapm;
117
116 /* Add am3517-evm specific widgets */ 118 /* Add am3517-evm specific widgets */
117 snd_soc_dapm_new_controls(codec, tlv320aic23_dapm_widgets, 119 snd_soc_dapm_new_controls(dapm, tlv320aic23_dapm_widgets,
118 ARRAY_SIZE(tlv320aic23_dapm_widgets)); 120 ARRAY_SIZE(tlv320aic23_dapm_widgets));
119 121
120 /* Set up davinci-evm specific audio path audio_map */ 122 /* Set up davinci-evm specific audio path audio_map */
121 snd_soc_dapm_add_routes(codec, audio_map, ARRAY_SIZE(audio_map)); 123 snd_soc_dapm_add_routes(dapm, audio_map, ARRAY_SIZE(audio_map));
122 124
123 /* always connected */ 125 /* always connected */
124 snd_soc_dapm_enable_pin(codec, "Line Out"); 126 snd_soc_dapm_enable_pin(dapm, "Line Out");
125 snd_soc_dapm_enable_pin(codec, "Line In"); 127 snd_soc_dapm_enable_pin(dapm, "Line In");
126 snd_soc_dapm_enable_pin(codec, "Mic In"); 128 snd_soc_dapm_enable_pin(dapm, "Mic In");
127 129
128 snd_soc_dapm_sync(codec); 130 snd_soc_dapm_sync(dapm);
129 131
130 return 0; 132 return 0;
131} 133}
@@ -134,8 +136,10 @@ static int am3517evm_aic23_init(struct snd_soc_codec *codec)
134static struct snd_soc_dai_link am3517evm_dai = { 136static struct snd_soc_dai_link am3517evm_dai = {
135 .name = "TLV320AIC23", 137 .name = "TLV320AIC23",
136 .stream_name = "AIC23", 138 .stream_name = "AIC23",
137 .cpu_dai = &omap_mcbsp_dai[0], 139 .cpu_dai_name ="omap-mcbsp-dai.0",
138 .codec_dai = &tlv320aic23_dai, 140 .codec_dai_name = "tlv320aic23-hifi",
141 .platform_name = "omap-pcm-audio",
142 .codec_name = "tlv320aic23-codec.2-001a",
139 .init = am3517evm_aic23_init, 143 .init = am3517evm_aic23_init,
140 .ops = &am3517evm_ops, 144 .ops = &am3517evm_ops,
141}; 145};
@@ -143,27 +147,18 @@ static struct snd_soc_dai_link am3517evm_dai = {
143/* Audio machine driver */ 147/* Audio machine driver */
144static struct snd_soc_card snd_soc_am3517evm = { 148static struct snd_soc_card snd_soc_am3517evm = {
145 .name = "am3517evm", 149 .name = "am3517evm",
146 .platform = &omap_soc_platform,
147 .dai_link = &am3517evm_dai, 150 .dai_link = &am3517evm_dai,
148 .num_links = 1, 151 .num_links = 1,
149}; 152};
150 153
151/* Audio subsystem */
152static struct snd_soc_device am3517evm_snd_devdata = {
153 .card = &snd_soc_am3517evm,
154 .codec_dev = &soc_codec_dev_tlv320aic23,
155};
156
157static struct platform_device *am3517evm_snd_device; 154static struct platform_device *am3517evm_snd_device;
158 155
159static int __init am3517evm_soc_init(void) 156static int __init am3517evm_soc_init(void)
160{ 157{
161 int ret; 158 int ret;
162 159
163 if (!machine_is_omap3517evm()) { 160 if (!machine_is_omap3517evm())
164 pr_err("Not OMAP3517 / AM3517 EVM!\n");
165 return -ENODEV; 161 return -ENODEV;
166 }
167 pr_info("OMAP3517 / AM3517 EVM SoC init\n"); 162 pr_info("OMAP3517 / AM3517 EVM SoC init\n");
168 163
169 am3517evm_snd_device = platform_device_alloc("soc-audio", -1); 164 am3517evm_snd_device = platform_device_alloc("soc-audio", -1);
@@ -172,9 +167,7 @@ static int __init am3517evm_soc_init(void)
172 return -ENOMEM; 167 return -ENOMEM;
173 } 168 }
174 169
175 platform_set_drvdata(am3517evm_snd_device, &am3517evm_snd_devdata); 170 platform_set_drvdata(am3517evm_snd_device, &snd_soc_am3517evm);
176 am3517evm_snd_devdata.dev = &am3517evm_snd_device->dev;
177 *(unsigned int *)am3517evm_dai.cpu_dai->private_data = 0; /* McBSP1 */
178 171
179 ret = platform_device_add(am3517evm_snd_device); 172 ret = platform_device_add(am3517evm_snd_device);
180 if (ret) 173 if (ret)
diff --git a/sound/soc/omap/ams-delta.c b/sound/soc/omap/ams-delta.c
index b0f618e44840..462cbcbea74a 100644
--- a/sound/soc/omap/ams-delta.c
+++ b/sound/soc/omap/ams-delta.c
@@ -26,7 +26,7 @@
26#include <linux/spinlock.h> 26#include <linux/spinlock.h>
27#include <linux/tty.h> 27#include <linux/tty.h>
28 28
29#include <sound/soc-dapm.h> 29#include <sound/soc.h>
30#include <sound/jack.h> 30#include <sound/jack.h>
31 31
32#include <asm/mach-types.h> 32#include <asm/mach-types.h>
@@ -94,12 +94,13 @@ static int ams_delta_set_audio_mode(struct snd_kcontrol *kcontrol,
94 struct snd_ctl_elem_value *ucontrol) 94 struct snd_ctl_elem_value *ucontrol)
95{ 95{
96 struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); 96 struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
97 struct snd_soc_dapm_context *dapm = &codec->dapm;
97 struct soc_enum *control = (struct soc_enum *)kcontrol->private_value; 98 struct soc_enum *control = (struct soc_enum *)kcontrol->private_value;
98 unsigned short pins; 99 unsigned short pins;
99 int pin, changed = 0; 100 int pin, changed = 0;
100 101
101 /* Refuse any mode changes if we are not able to control the codec. */ 102 /* Refuse any mode changes if we are not able to control the codec. */
102 if (!codec->control_data) 103 if (!codec->hw_write)
103 return -EUNATCH; 104 return -EUNATCH;
104 105
105 if (ucontrol->value.enumerated.item[0] >= control->max) 106 if (ucontrol->value.enumerated.item[0] >= control->max)
@@ -112,48 +113,48 @@ static int ams_delta_set_audio_mode(struct snd_kcontrol *kcontrol,
112 113
113 /* Setup pins after corresponding bits if changed */ 114 /* Setup pins after corresponding bits if changed */
114 pin = !!(pins & (1 << AMS_DELTA_MOUTHPIECE)); 115 pin = !!(pins & (1 << AMS_DELTA_MOUTHPIECE));
115 if (pin != snd_soc_dapm_get_pin_status(codec, "Mouthpiece")) { 116 if (pin != snd_soc_dapm_get_pin_status(dapm, "Mouthpiece")) {
116 changed = 1; 117 changed = 1;
117 if (pin) 118 if (pin)
118 snd_soc_dapm_enable_pin(codec, "Mouthpiece"); 119 snd_soc_dapm_enable_pin(dapm, "Mouthpiece");
119 else 120 else
120 snd_soc_dapm_disable_pin(codec, "Mouthpiece"); 121 snd_soc_dapm_disable_pin(dapm, "Mouthpiece");
121 } 122 }
122 pin = !!(pins & (1 << AMS_DELTA_EARPIECE)); 123 pin = !!(pins & (1 << AMS_DELTA_EARPIECE));
123 if (pin != snd_soc_dapm_get_pin_status(codec, "Earpiece")) { 124 if (pin != snd_soc_dapm_get_pin_status(dapm, "Earpiece")) {
124 changed = 1; 125 changed = 1;
125 if (pin) 126 if (pin)
126 snd_soc_dapm_enable_pin(codec, "Earpiece"); 127 snd_soc_dapm_enable_pin(dapm, "Earpiece");
127 else 128 else
128 snd_soc_dapm_disable_pin(codec, "Earpiece"); 129 snd_soc_dapm_disable_pin(dapm, "Earpiece");
129 } 130 }
130 pin = !!(pins & (1 << AMS_DELTA_MICROPHONE)); 131 pin = !!(pins & (1 << AMS_DELTA_MICROPHONE));
131 if (pin != snd_soc_dapm_get_pin_status(codec, "Microphone")) { 132 if (pin != snd_soc_dapm_get_pin_status(dapm, "Microphone")) {
132 changed = 1; 133 changed = 1;
133 if (pin) 134 if (pin)
134 snd_soc_dapm_enable_pin(codec, "Microphone"); 135 snd_soc_dapm_enable_pin(dapm, "Microphone");
135 else 136 else
136 snd_soc_dapm_disable_pin(codec, "Microphone"); 137 snd_soc_dapm_disable_pin(dapm, "Microphone");
137 } 138 }
138 pin = !!(pins & (1 << AMS_DELTA_SPEAKER)); 139 pin = !!(pins & (1 << AMS_DELTA_SPEAKER));
139 if (pin != snd_soc_dapm_get_pin_status(codec, "Speaker")) { 140 if (pin != snd_soc_dapm_get_pin_status(dapm, "Speaker")) {
140 changed = 1; 141 changed = 1;
141 if (pin) 142 if (pin)
142 snd_soc_dapm_enable_pin(codec, "Speaker"); 143 snd_soc_dapm_enable_pin(dapm, "Speaker");
143 else 144 else
144 snd_soc_dapm_disable_pin(codec, "Speaker"); 145 snd_soc_dapm_disable_pin(dapm, "Speaker");
145 } 146 }
146 pin = !!(pins & (1 << AMS_DELTA_AGC)); 147 pin = !!(pins & (1 << AMS_DELTA_AGC));
147 if (pin != ams_delta_audio_agc) { 148 if (pin != ams_delta_audio_agc) {
148 ams_delta_audio_agc = pin; 149 ams_delta_audio_agc = pin;
149 changed = 1; 150 changed = 1;
150 if (pin) 151 if (pin)
151 snd_soc_dapm_enable_pin(codec, "AGCIN"); 152 snd_soc_dapm_enable_pin(dapm, "AGCIN");
152 else 153 else
153 snd_soc_dapm_disable_pin(codec, "AGCIN"); 154 snd_soc_dapm_disable_pin(dapm, "AGCIN");
154 } 155 }
155 if (changed) 156 if (changed)
156 snd_soc_dapm_sync(codec); 157 snd_soc_dapm_sync(dapm);
157 158
158 mutex_unlock(&codec->mutex); 159 mutex_unlock(&codec->mutex);
159 160
@@ -164,19 +165,20 @@ static int ams_delta_get_audio_mode(struct snd_kcontrol *kcontrol,
164 struct snd_ctl_elem_value *ucontrol) 165 struct snd_ctl_elem_value *ucontrol)
165{ 166{
166 struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); 167 struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
168 struct snd_soc_dapm_context *dapm = &codec->dapm;
167 unsigned short pins, mode; 169 unsigned short pins, mode;
168 170
169 pins = ((snd_soc_dapm_get_pin_status(codec, "Mouthpiece") << 171 pins = ((snd_soc_dapm_get_pin_status(dapm, "Mouthpiece") <<
170 AMS_DELTA_MOUTHPIECE) | 172 AMS_DELTA_MOUTHPIECE) |
171 (snd_soc_dapm_get_pin_status(codec, "Earpiece") << 173 (snd_soc_dapm_get_pin_status(dapm, "Earpiece") <<
172 AMS_DELTA_EARPIECE)); 174 AMS_DELTA_EARPIECE));
173 if (pins) 175 if (pins)
174 pins |= (snd_soc_dapm_get_pin_status(codec, "Microphone") << 176 pins |= (snd_soc_dapm_get_pin_status(dapm, "Microphone") <<
175 AMS_DELTA_MICROPHONE); 177 AMS_DELTA_MICROPHONE);
176 else 178 else
177 pins = ((snd_soc_dapm_get_pin_status(codec, "Microphone") << 179 pins = ((snd_soc_dapm_get_pin_status(dapm, "Microphone") <<
178 AMS_DELTA_MICROPHONE) | 180 AMS_DELTA_MICROPHONE) |
179 (snd_soc_dapm_get_pin_status(codec, "Speaker") << 181 (snd_soc_dapm_get_pin_status(dapm, "Speaker") <<
180 AMS_DELTA_SPEAKER) | 182 AMS_DELTA_SPEAKER) |
181 (ams_delta_audio_agc << AMS_DELTA_AGC)); 183 (ams_delta_audio_agc << AMS_DELTA_AGC));
182 184
@@ -246,7 +248,7 @@ static struct snd_soc_jack_pin ams_delta_hook_switch_pins[] = {
246 */ 248 */
247 249
248/* To actually apply any modem controlled configuration changes to the codec, 250/* To actually apply any modem controlled configuration changes to the codec,
249 * we must connect codec DAI pins to the modem for a moment. Be carefull not 251 * we must connect codec DAI pins to the modem for a moment. Be careful not
250 * to interfere with our digital mute function that shares the same hardware. */ 252 * to interfere with our digital mute function that shares the same hardware. */
251static struct timer_list cx81801_timer; 253static struct timer_list cx81801_timer;
252static bool cx81801_cmd_pending; 254static bool cx81801_cmd_pending;
@@ -268,31 +270,57 @@ static void cx81801_timeout(unsigned long data)
268 ams_delta_latch2_write(AMS_DELTA_LATCH2_MODEM_CODEC, 0); 270 ams_delta_latch2_write(AMS_DELTA_LATCH2_MODEM_CODEC, 0);
269} 271}
270 272
273/*
274 * Used for passing a codec structure pointer
275 * from the board initialization code to the tty line discipline.
276 */
277static struct snd_soc_codec *cx20442_codec;
278
271/* Line discipline .open() */ 279/* Line discipline .open() */
272static int cx81801_open(struct tty_struct *tty) 280static int cx81801_open(struct tty_struct *tty)
273{ 281{
274 return v253_ops.open(tty); 282 int ret;
283
284 if (!cx20442_codec)
285 return -ENODEV;
286
287 /*
288 * Pass the codec structure pointer for use by other ldisc callbacks,
289 * both the card and the codec specific parts.
290 */
291 tty->disc_data = cx20442_codec;
292
293 ret = v253_ops.open(tty);
294
295 if (ret < 0)
296 tty->disc_data = NULL;
297
298 return ret;
275} 299}
276 300
277/* Line discipline .close() */ 301/* Line discipline .close() */
278static void cx81801_close(struct tty_struct *tty) 302static void cx81801_close(struct tty_struct *tty)
279{ 303{
280 struct snd_soc_codec *codec = tty->disc_data; 304 struct snd_soc_codec *codec = tty->disc_data;
305 struct snd_soc_dapm_context *dapm = &codec->dapm;
281 306
282 del_timer_sync(&cx81801_timer); 307 del_timer_sync(&cx81801_timer);
283 308
284 v253_ops.close(tty);
285
286 /* Prevent the hook switch from further changing the DAPM pins */ 309 /* Prevent the hook switch from further changing the DAPM pins */
287 INIT_LIST_HEAD(&ams_delta_hook_switch.pins); 310 INIT_LIST_HEAD(&ams_delta_hook_switch.pins);
288 311
312 if (!codec)
313 return;
314
315 v253_ops.close(tty);
316
289 /* Revert back to default audio input/output constellation */ 317 /* Revert back to default audio input/output constellation */
290 snd_soc_dapm_disable_pin(codec, "Mouthpiece"); 318 snd_soc_dapm_disable_pin(dapm, "Mouthpiece");
291 snd_soc_dapm_enable_pin(codec, "Earpiece"); 319 snd_soc_dapm_enable_pin(dapm, "Earpiece");
292 snd_soc_dapm_enable_pin(codec, "Microphone"); 320 snd_soc_dapm_enable_pin(dapm, "Microphone");
293 snd_soc_dapm_disable_pin(codec, "Speaker"); 321 snd_soc_dapm_disable_pin(dapm, "Speaker");
294 snd_soc_dapm_disable_pin(codec, "AGCIN"); 322 snd_soc_dapm_disable_pin(dapm, "AGCIN");
295 snd_soc_dapm_sync(codec); 323 snd_soc_dapm_sync(dapm);
296} 324}
297 325
298/* Line discipline .hangup() */ 326/* Line discipline .hangup() */
@@ -310,7 +338,10 @@ static void cx81801_receive(struct tty_struct *tty,
310 const unsigned char *c; 338 const unsigned char *c;
311 int apply, ret; 339 int apply, ret;
312 340
313 if (!codec->control_data) { 341 if (!codec)
342 return;
343
344 if (!codec->hw_write) {
314 /* First modem response, complete setup procedure */ 345 /* First modem response, complete setup procedure */
315 346
316 /* Initialize timer used for config pulse generation */ 347 /* Initialize timer used for config pulse generation */
@@ -323,7 +354,7 @@ static void cx81801_receive(struct tty_struct *tty,
323 ARRAY_SIZE(ams_delta_hook_switch_pins), 354 ARRAY_SIZE(ams_delta_hook_switch_pins),
324 ams_delta_hook_switch_pins); 355 ams_delta_hook_switch_pins);
325 if (ret) 356 if (ret)
326 dev_warn(codec->socdev->card->dev, 357 dev_warn(codec->dev,
327 "Failed to link hook switch to DAPM pins, " 358 "Failed to link hook switch to DAPM pins, "
328 "will continue with hook switch unlinked.\n"); 359 "will continue with hook switch unlinked.\n");
329 360
@@ -371,9 +402,9 @@ static struct tty_ldisc_ops cx81801_ops = {
371 402
372 403
373/* 404/*
374 * Even if not very usefull, the sound card can still work without any of the 405 * Even if not very useful, the sound card can still work without any of the
375 * above functonality activated. You can still control its audio input/output 406 * above functonality activated. You can still control its audio input/output
376 * constellation and speakerphone gain from userspace by issueing AT commands 407 * constellation and speakerphone gain from userspace by issuing AT commands
377 * over the modem port. 408 * over the modem port.
378 */ 409 */
379 410
@@ -383,7 +414,7 @@ static int ams_delta_hw_params(struct snd_pcm_substream *substream,
383 struct snd_soc_pcm_runtime *rtd = substream->private_data; 414 struct snd_soc_pcm_runtime *rtd = substream->private_data;
384 415
385 /* Set cpu DAI configuration */ 416 /* Set cpu DAI configuration */
386 return snd_soc_dai_set_fmt(rtd->dai->cpu_dai, 417 return snd_soc_dai_set_fmt(rtd->cpu_dai,
387 SND_SOC_DAIFMT_DSP_A | 418 SND_SOC_DAIFMT_DSP_A |
388 SND_SOC_DAIFMT_NB_NF | 419 SND_SOC_DAIFMT_NB_NF |
389 SND_SOC_DAIFMT_CBM_CFM); 420 SND_SOC_DAIFMT_CBM_CFM);
@@ -398,22 +429,22 @@ static struct snd_soc_ops ams_delta_ops = {
398static int ams_delta_set_bias_level(struct snd_soc_card *card, 429static int ams_delta_set_bias_level(struct snd_soc_card *card,
399 enum snd_soc_bias_level level) 430 enum snd_soc_bias_level level)
400{ 431{
401 struct snd_soc_codec *codec = card->codec; 432 struct snd_soc_codec *codec = card->rtd->codec;
402 433
403 switch (level) { 434 switch (level) {
404 case SND_SOC_BIAS_ON: 435 case SND_SOC_BIAS_ON:
405 case SND_SOC_BIAS_PREPARE: 436 case SND_SOC_BIAS_PREPARE:
406 case SND_SOC_BIAS_STANDBY: 437 case SND_SOC_BIAS_STANDBY:
407 if (codec->bias_level == SND_SOC_BIAS_OFF) 438 if (codec->dapm.bias_level == SND_SOC_BIAS_OFF)
408 ams_delta_latch2_write(AMS_DELTA_LATCH2_MODEM_NRESET, 439 ams_delta_latch2_write(AMS_DELTA_LATCH2_MODEM_NRESET,
409 AMS_DELTA_LATCH2_MODEM_NRESET); 440 AMS_DELTA_LATCH2_MODEM_NRESET);
410 break; 441 break;
411 case SND_SOC_BIAS_OFF: 442 case SND_SOC_BIAS_OFF:
412 if (codec->bias_level != SND_SOC_BIAS_OFF) 443 if (codec->dapm.bias_level != SND_SOC_BIAS_OFF)
413 ams_delta_latch2_write(AMS_DELTA_LATCH2_MODEM_NRESET, 444 ams_delta_latch2_write(AMS_DELTA_LATCH2_MODEM_NRESET,
414 0); 445 0);
415 } 446 }
416 codec->bias_level = level; 447 codec->dapm.bias_level = level;
417 448
418 return 0; 449 return 0;
419} 450}
@@ -461,18 +492,21 @@ static void ams_delta_shutdown(struct snd_pcm_substream *substream)
461 * Card initialization 492 * Card initialization
462 */ 493 */
463 494
464static int ams_delta_cx20442_init(struct snd_soc_codec *codec) 495static int ams_delta_cx20442_init(struct snd_soc_pcm_runtime *rtd)
465{ 496{
466 struct snd_soc_dai *codec_dai = codec->dai; 497 struct snd_soc_codec *codec = rtd->codec;
467 struct snd_soc_card *card = codec->socdev->card; 498 struct snd_soc_dapm_context *dapm = &codec->dapm;
499 struct snd_soc_dai *codec_dai = rtd->codec_dai;
500 struct snd_soc_card *card = rtd->card;
468 int ret; 501 int ret;
469 /* Codec is ready, now add/activate board specific controls */ 502 /* Codec is ready, now add/activate board specific controls */
470 503
504 /* Store a pointer to the codec structure for tty ldisc use */
505 cx20442_codec = codec;
506
471 /* Set up digital mute if not provided by the codec */ 507 /* Set up digital mute if not provided by the codec */
472 if (!codec_dai->ops) { 508 if (!codec_dai->driver->ops) {
473 codec_dai->ops = &ams_delta_dai_ops; 509 codec_dai->driver->ops = &ams_delta_dai_ops;
474 } else if (!codec_dai->ops->digital_mute) {
475 codec_dai->ops->digital_mute = ams_delta_digital_mute;
476 } else { 510 } else {
477 ams_delta_ops.startup = ams_delta_startup; 511 ams_delta_ops.startup = ams_delta_startup;
478 ams_delta_ops.shutdown = ams_delta_shutdown; 512 ams_delta_ops.shutdown = ams_delta_shutdown;
@@ -483,7 +517,7 @@ static int ams_delta_cx20442_init(struct snd_soc_codec *codec)
483 517
484 /* Add hook switch - can be used to control the codec from userspace 518 /* Add hook switch - can be used to control the codec from userspace
485 * even if line discipline fails */ 519 * even if line discipline fails */
486 ret = snd_soc_jack_new(card, "hook_switch", 520 ret = snd_soc_jack_new(rtd->codec, "hook_switch",
487 SND_JACK_HEADSET, &ams_delta_hook_switch); 521 SND_JACK_HEADSET, &ams_delta_hook_switch);
488 if (ret) 522 if (ret)
489 dev_warn(card->dev, 523 dev_warn(card->dev,
@@ -509,7 +543,7 @@ static int ams_delta_cx20442_init(struct snd_soc_codec *codec)
509 } 543 }
510 544
511 /* Add board specific DAPM widgets and routes */ 545 /* Add board specific DAPM widgets and routes */
512 ret = snd_soc_dapm_new_controls(codec, ams_delta_dapm_widgets, 546 ret = snd_soc_dapm_new_controls(dapm, ams_delta_dapm_widgets,
513 ARRAY_SIZE(ams_delta_dapm_widgets)); 547 ARRAY_SIZE(ams_delta_dapm_widgets));
514 if (ret) { 548 if (ret) {
515 dev_warn(card->dev, 549 dev_warn(card->dev,
@@ -518,7 +552,7 @@ static int ams_delta_cx20442_init(struct snd_soc_codec *codec)
518 return 0; 552 return 0;
519 } 553 }
520 554
521 ret = snd_soc_dapm_add_routes(codec, ams_delta_audio_map, 555 ret = snd_soc_dapm_add_routes(dapm, ams_delta_audio_map,
522 ARRAY_SIZE(ams_delta_audio_map)); 556 ARRAY_SIZE(ams_delta_audio_map));
523 if (ret) { 557 if (ret) {
524 dev_warn(card->dev, 558 dev_warn(card->dev,
@@ -528,13 +562,13 @@ static int ams_delta_cx20442_init(struct snd_soc_codec *codec)
528 } 562 }
529 563
530 /* Set up initial pin constellation */ 564 /* Set up initial pin constellation */
531 snd_soc_dapm_disable_pin(codec, "Mouthpiece"); 565 snd_soc_dapm_disable_pin(dapm, "Mouthpiece");
532 snd_soc_dapm_enable_pin(codec, "Earpiece"); 566 snd_soc_dapm_enable_pin(dapm, "Earpiece");
533 snd_soc_dapm_enable_pin(codec, "Microphone"); 567 snd_soc_dapm_enable_pin(dapm, "Microphone");
534 snd_soc_dapm_disable_pin(codec, "Speaker"); 568 snd_soc_dapm_disable_pin(dapm, "Speaker");
535 snd_soc_dapm_disable_pin(codec, "AGCIN"); 569 snd_soc_dapm_disable_pin(dapm, "AGCIN");
536 snd_soc_dapm_disable_pin(codec, "AGCOUT"); 570 snd_soc_dapm_disable_pin(dapm, "AGCOUT");
537 snd_soc_dapm_sync(codec); 571 snd_soc_dapm_sync(dapm);
538 572
539 /* Add virtual switch */ 573 /* Add virtual switch */
540 ret = snd_soc_add_controls(codec, ams_delta_audio_controls, 574 ret = snd_soc_add_controls(codec, ams_delta_audio_controls,
@@ -551,27 +585,22 @@ static int ams_delta_cx20442_init(struct snd_soc_codec *codec)
551static struct snd_soc_dai_link ams_delta_dai_link = { 585static struct snd_soc_dai_link ams_delta_dai_link = {
552 .name = "CX20442", 586 .name = "CX20442",
553 .stream_name = "CX20442", 587 .stream_name = "CX20442",
554 .cpu_dai = &omap_mcbsp_dai[0], 588 .cpu_dai_name ="omap-mcbsp-dai.0",
555 .codec_dai = &cx20442_dai, 589 .codec_dai_name = "cx20442-voice",
556 .init = ams_delta_cx20442_init, 590 .init = ams_delta_cx20442_init,
591 .platform_name = "omap-pcm-audio",
592 .codec_name = "cx20442-codec",
557 .ops = &ams_delta_ops, 593 .ops = &ams_delta_ops,
558}; 594};
559 595
560/* Audio card driver */ 596/* Audio card driver */
561static struct snd_soc_card ams_delta_audio_card = { 597static struct snd_soc_card ams_delta_audio_card = {
562 .name = "AMS_DELTA", 598 .name = "AMS_DELTA",
563 .platform = &omap_soc_platform,
564 .dai_link = &ams_delta_dai_link, 599 .dai_link = &ams_delta_dai_link,
565 .num_links = 1, 600 .num_links = 1,
566 .set_bias_level = ams_delta_set_bias_level, 601 .set_bias_level = ams_delta_set_bias_level,
567}; 602};
568 603
569/* Audio subsystem */
570static struct snd_soc_device ams_delta_snd_soc_device = {
571 .card = &ams_delta_audio_card,
572 .codec_dev = &cx20442_codec_dev,
573};
574
575/* Module init/exit */ 604/* Module init/exit */
576static struct platform_device *ams_delta_audio_platform_device; 605static struct platform_device *ams_delta_audio_platform_device;
577static struct platform_device *cx20442_platform_device; 606static struct platform_device *cx20442_platform_device;
@@ -589,9 +618,7 @@ static int __init ams_delta_module_init(void)
589 return -ENOMEM; 618 return -ENOMEM;
590 619
591 platform_set_drvdata(ams_delta_audio_platform_device, 620 platform_set_drvdata(ams_delta_audio_platform_device,
592 &ams_delta_snd_soc_device); 621 &ams_delta_audio_card);
593 ams_delta_snd_soc_device.dev = &ams_delta_audio_platform_device->dev;
594 *(unsigned int *)ams_delta_dai_link.cpu_dai->private_data = OMAP_MCBSP1;
595 622
596 ret = platform_device_add(ams_delta_audio_platform_device); 623 ret = platform_device_add(ams_delta_audio_platform_device);
597 if (ret) 624 if (ret)
@@ -601,8 +628,8 @@ static int __init ams_delta_module_init(void)
601 * Codec platform device could be registered from elsewhere (board?), 628 * Codec platform device could be registered from elsewhere (board?),
602 * but I do it here as it makes sense only if used with the card. 629 * but I do it here as it makes sense only if used with the card.
603 */ 630 */
604 cx20442_platform_device = platform_device_register_simple("cx20442", 631 cx20442_platform_device =
605 -1, NULL, 0); 632 platform_device_register_simple("cx20442-codec", -1, NULL, 0);
606 return 0; 633 return 0;
607err: 634err:
608 platform_device_put(ams_delta_audio_platform_device); 635 platform_device_put(ams_delta_audio_platform_device);
@@ -612,19 +639,6 @@ module_init(ams_delta_module_init);
612 639
613static void __exit ams_delta_module_exit(void) 640static void __exit ams_delta_module_exit(void)
614{ 641{
615 struct snd_soc_codec *codec;
616 struct tty_struct *tty;
617
618 if (ams_delta_audio_card.codec) {
619 codec = ams_delta_audio_card.codec;
620
621 if (codec->control_data) {
622 tty = codec->control_data;
623
624 tty_hangup(tty);
625 }
626 }
627
628 if (tty_unregister_ldisc(N_V253) != 0) 642 if (tty_unregister_ldisc(N_V253) != 0)
629 dev_warn(&ams_delta_audio_platform_device->dev, 643 dev_warn(&ams_delta_audio_platform_device->dev,
630 "failed to unregister V253 line discipline\n"); 644 "failed to unregister V253 line discipline\n");
diff --git a/sound/soc/omap/igep0020.c b/sound/soc/omap/igep0020.c
index 3583c429f9be..0ae34702995b 100644
--- a/sound/soc/omap/igep0020.c
+++ b/sound/soc/omap/igep0020.c
@@ -24,7 +24,6 @@
24#include <sound/core.h> 24#include <sound/core.h>
25#include <sound/pcm.h> 25#include <sound/pcm.h>
26#include <sound/soc.h> 26#include <sound/soc.h>
27#include <sound/soc-dapm.h>
28 27
29#include <asm/mach-types.h> 28#include <asm/mach-types.h>
30#include <mach/hardware.h> 29#include <mach/hardware.h>
@@ -33,14 +32,13 @@
33 32
34#include "omap-mcbsp.h" 33#include "omap-mcbsp.h"
35#include "omap-pcm.h" 34#include "omap-pcm.h"
36#include "../codecs/twl4030.h"
37 35
38static int igep2_hw_params(struct snd_pcm_substream *substream, 36static int igep2_hw_params(struct snd_pcm_substream *substream,
39 struct snd_pcm_hw_params *params) 37 struct snd_pcm_hw_params *params)
40{ 38{
41 struct snd_soc_pcm_runtime *rtd = substream->private_data; 39 struct snd_soc_pcm_runtime *rtd = substream->private_data;
42 struct snd_soc_dai *codec_dai = rtd->dai->codec_dai; 40 struct snd_soc_dai *codec_dai = rtd->codec_dai;
43 struct snd_soc_dai *cpu_dai = rtd->dai->cpu_dai; 41 struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
44 int ret; 42 int ret;
45 43
46 /* Set codec DAI configuration */ 44 /* Set codec DAI configuration */
@@ -82,35 +80,28 @@ static struct snd_soc_ops igep2_ops = {
82static struct snd_soc_dai_link igep2_dai = { 80static struct snd_soc_dai_link igep2_dai = {
83 .name = "TWL4030", 81 .name = "TWL4030",
84 .stream_name = "TWL4030", 82 .stream_name = "TWL4030",
85 .cpu_dai = &omap_mcbsp_dai[0], 83 .cpu_dai_name = "omap-mcbsp-dai.1",
86 .codec_dai = &twl4030_dai[TWL4030_DAI_HIFI], 84 .codec_dai_name = "twl4030-hifi",
85 .platform_name = "omap-pcm-audio",
86 .codec_name = "twl4030-codec",
87 .ops = &igep2_ops, 87 .ops = &igep2_ops,
88}; 88};
89 89
90/* Audio machine driver */ 90/* Audio machine driver */
91static struct snd_soc_card snd_soc_card_igep2 = { 91static struct snd_soc_card snd_soc_card_igep2 = {
92 .name = "igep2", 92 .name = "igep2",
93 .platform = &omap_soc_platform,
94 .dai_link = &igep2_dai, 93 .dai_link = &igep2_dai,
95 .num_links = 1, 94 .num_links = 1,
96}; 95};
97 96
98/* Audio subsystem */
99static struct snd_soc_device igep2_snd_devdata = {
100 .card = &snd_soc_card_igep2,
101 .codec_dev = &soc_codec_dev_twl4030,
102};
103
104static struct platform_device *igep2_snd_device; 97static struct platform_device *igep2_snd_device;
105 98
106static int __init igep2_soc_init(void) 99static int __init igep2_soc_init(void)
107{ 100{
108 int ret; 101 int ret;
109 102
110 if (!machine_is_igep0020()) { 103 if (!machine_is_igep0020())
111 pr_debug("Not IGEP v2!\n");
112 return -ENODEV; 104 return -ENODEV;
113 }
114 printk(KERN_INFO "IGEP v2 SoC init\n"); 105 printk(KERN_INFO "IGEP v2 SoC init\n");
115 106
116 igep2_snd_device = platform_device_alloc("soc-audio", -1); 107 igep2_snd_device = platform_device_alloc("soc-audio", -1);
@@ -119,9 +110,7 @@ static int __init igep2_soc_init(void)
119 return -ENOMEM; 110 return -ENOMEM;
120 } 111 }
121 112
122 platform_set_drvdata(igep2_snd_device, &igep2_snd_devdata); 113 platform_set_drvdata(igep2_snd_device, &snd_soc_card_igep2);
123 igep2_snd_devdata.dev = &igep2_snd_device->dev;
124 *(unsigned int *)igep2_dai.cpu_dai->private_data = 1; /* McBSP2 */
125 114
126 ret = platform_device_add(igep2_snd_device); 115 ret = platform_device_add(igep2_snd_device);
127 if (ret) 116 if (ret)
diff --git a/sound/soc/omap/mcpdm.c b/sound/soc/omap/mcpdm.c
index 90b8bf71c893..928f03707451 100644
--- a/sound/soc/omap/mcpdm.c
+++ b/sound/soc/omap/mcpdm.c
@@ -402,7 +402,7 @@ int omap_mcpdm_set_offset(int offset1, int offset2)
402 return 0; 402 return 0;
403} 403}
404 404
405static int __devinit omap_mcpdm_probe(struct platform_device *pdev) 405int __devinit omap_mcpdm_probe(struct platform_device *pdev)
406{ 406{
407 struct resource *res; 407 struct resource *res;
408 int ret = 0; 408 int ret = 0;
@@ -449,7 +449,7 @@ exit:
449 return ret; 449 return ret;
450} 450}
451 451
452static int __devexit omap_mcpdm_remove(struct platform_device *pdev) 452int __devexit omap_mcpdm_remove(struct platform_device *pdev)
453{ 453{
454 struct omap_mcpdm *mcpdm_ptr = platform_get_drvdata(pdev); 454 struct omap_mcpdm *mcpdm_ptr = platform_get_drvdata(pdev);
455 455
@@ -468,18 +468,3 @@ static int __devexit omap_mcpdm_remove(struct platform_device *pdev)
468 return 0; 468 return 0;
469} 469}
470 470
471static struct platform_driver omap_mcpdm_driver = {
472 .probe = omap_mcpdm_probe,
473 .remove = __devexit_p(omap_mcpdm_remove),
474 .driver = {
475 .name = "omap-mcpdm",
476 },
477};
478
479static struct platform_device *omap_mcpdm_device;
480
481static int __init omap_mcpdm_init(void)
482{
483 return platform_driver_register(&omap_mcpdm_driver);
484}
485arch_initcall(omap_mcpdm_init);
diff --git a/sound/soc/omap/mcpdm.h b/sound/soc/omap/mcpdm.h
index 7bb326ef0886..df3e16fb51f3 100644
--- a/sound/soc/omap/mcpdm.h
+++ b/sound/soc/omap/mcpdm.h
@@ -149,3 +149,5 @@ extern int omap_mcpdm_playback_close(struct omap_mcpdm_link *downlink);
149extern int omap_mcpdm_request(void); 149extern int omap_mcpdm_request(void);
150extern void omap_mcpdm_free(void); 150extern void omap_mcpdm_free(void);
151extern int omap_mcpdm_set_offset(int offset1, int offset2); 151extern int omap_mcpdm_set_offset(int offset1, int offset2);
152int __devinit omap_mcpdm_probe(struct platform_device *pdev);
153int __devexit omap_mcpdm_remove(struct platform_device *pdev);
diff --git a/sound/soc/omap/n810.c b/sound/soc/omap/n810.c
index 08e09d72790f..83d213bfd3d1 100644
--- a/sound/soc/omap/n810.c
+++ b/sound/soc/omap/n810.c
@@ -27,7 +27,6 @@
27#include <sound/core.h> 27#include <sound/core.h>
28#include <sound/pcm.h> 28#include <sound/pcm.h>
29#include <sound/soc.h> 29#include <sound/soc.h>
30#include <sound/soc-dapm.h>
31 30
32#include <asm/mach-types.h> 31#include <asm/mach-types.h>
33#include <mach/hardware.h> 32#include <mach/hardware.h>
@@ -36,7 +35,6 @@
36 35
37#include "omap-mcbsp.h" 36#include "omap-mcbsp.h"
38#include "omap-pcm.h" 37#include "omap-pcm.h"
39#include "../codecs/tlv320aic3x.h"
40 38
41#define N810_HEADSET_AMP_GPIO 10 39#define N810_HEADSET_AMP_GPIO 10
42#define N810_SPEAKER_AMP_GPIO 101 40#define N810_SPEAKER_AMP_GPIO 101
@@ -58,6 +56,7 @@ static int n810_dmic_func;
58 56
59static void n810_ext_control(struct snd_soc_codec *codec) 57static void n810_ext_control(struct snd_soc_codec *codec)
60{ 58{
59 struct snd_soc_dapm_context *dapm = &codec->dapm;
61 int hp = 0, line1l = 0; 60 int hp = 0, line1l = 0;
62 61
63 switch (n810_jack_func) { 62 switch (n810_jack_func) {
@@ -72,32 +71,32 @@ static void n810_ext_control(struct snd_soc_codec *codec)
72 } 71 }
73 72
74 if (n810_spk_func) 73 if (n810_spk_func)
75 snd_soc_dapm_enable_pin(codec, "Ext Spk"); 74 snd_soc_dapm_enable_pin(dapm, "Ext Spk");
76 else 75 else
77 snd_soc_dapm_disable_pin(codec, "Ext Spk"); 76 snd_soc_dapm_disable_pin(dapm, "Ext Spk");
78 77
79 if (hp) 78 if (hp)
80 snd_soc_dapm_enable_pin(codec, "Headphone Jack"); 79 snd_soc_dapm_enable_pin(dapm, "Headphone Jack");
81 else 80 else
82 snd_soc_dapm_disable_pin(codec, "Headphone Jack"); 81 snd_soc_dapm_disable_pin(dapm, "Headphone Jack");
83 if (line1l) 82 if (line1l)
84 snd_soc_dapm_enable_pin(codec, "LINE1L"); 83 snd_soc_dapm_enable_pin(dapm, "LINE1L");
85 else 84 else
86 snd_soc_dapm_disable_pin(codec, "LINE1L"); 85 snd_soc_dapm_disable_pin(dapm, "LINE1L");
87 86
88 if (n810_dmic_func) 87 if (n810_dmic_func)
89 snd_soc_dapm_enable_pin(codec, "DMic"); 88 snd_soc_dapm_enable_pin(dapm, "DMic");
90 else 89 else
91 snd_soc_dapm_disable_pin(codec, "DMic"); 90 snd_soc_dapm_disable_pin(dapm, "DMic");
92 91
93 snd_soc_dapm_sync(codec); 92 snd_soc_dapm_sync(dapm);
94} 93}
95 94
96static int n810_startup(struct snd_pcm_substream *substream) 95static int n810_startup(struct snd_pcm_substream *substream)
97{ 96{
98 struct snd_pcm_runtime *runtime = substream->runtime; 97 struct snd_pcm_runtime *runtime = substream->runtime;
99 struct snd_soc_pcm_runtime *rtd = substream->private_data; 98 struct snd_soc_pcm_runtime *rtd = substream->private_data;
100 struct snd_soc_codec *codec = rtd->socdev->card->codec; 99 struct snd_soc_codec *codec = rtd->codec;
101 100
102 snd_pcm_hw_constraint_minmax(runtime, 101 snd_pcm_hw_constraint_minmax(runtime,
103 SNDRV_PCM_HW_PARAM_CHANNELS, 2, 2); 102 SNDRV_PCM_HW_PARAM_CHANNELS, 2, 2);
@@ -115,8 +114,8 @@ static int n810_hw_params(struct snd_pcm_substream *substream,
115 struct snd_pcm_hw_params *params) 114 struct snd_pcm_hw_params *params)
116{ 115{
117 struct snd_soc_pcm_runtime *rtd = substream->private_data; 116 struct snd_soc_pcm_runtime *rtd = substream->private_data;
118 struct snd_soc_dai *codec_dai = rtd->dai->codec_dai; 117 struct snd_soc_dai *codec_dai = rtd->codec_dai;
119 struct snd_soc_dai *cpu_dai = rtd->dai->cpu_dai; 118 struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
120 int err; 119 int err;
121 120
122 /* Set codec DAI configuration */ 121 /* Set codec DAI configuration */
@@ -271,19 +270,21 @@ static const struct snd_kcontrol_new aic33_n810_controls[] = {
271 n810_get_input, n810_set_input), 270 n810_get_input, n810_set_input),
272}; 271};
273 272
274static int n810_aic33_init(struct snd_soc_codec *codec) 273static int n810_aic33_init(struct snd_soc_pcm_runtime *rtd)
275{ 274{
275 struct snd_soc_codec *codec = rtd->codec;
276 struct snd_soc_dapm_context *dapm = &codec->dapm;
276 int err; 277 int err;
277 278
278 /* Not connected */ 279 /* Not connected */
279 snd_soc_dapm_nc_pin(codec, "MONO_LOUT"); 280 snd_soc_dapm_nc_pin(dapm, "MONO_LOUT");
280 snd_soc_dapm_nc_pin(codec, "HPLCOM"); 281 snd_soc_dapm_nc_pin(dapm, "HPLCOM");
281 snd_soc_dapm_nc_pin(codec, "HPRCOM"); 282 snd_soc_dapm_nc_pin(dapm, "HPRCOM");
282 snd_soc_dapm_nc_pin(codec, "MIC3L"); 283 snd_soc_dapm_nc_pin(dapm, "MIC3L");
283 snd_soc_dapm_nc_pin(codec, "MIC3R"); 284 snd_soc_dapm_nc_pin(dapm, "MIC3R");
284 snd_soc_dapm_nc_pin(codec, "LINE1R"); 285 snd_soc_dapm_nc_pin(dapm, "LINE1R");
285 snd_soc_dapm_nc_pin(codec, "LINE2L"); 286 snd_soc_dapm_nc_pin(dapm, "LINE2L");
286 snd_soc_dapm_nc_pin(codec, "LINE2R"); 287 snd_soc_dapm_nc_pin(dapm, "LINE2R");
287 288
288 /* Add N810 specific controls */ 289 /* Add N810 specific controls */
289 err = snd_soc_add_controls(codec, aic33_n810_controls, 290 err = snd_soc_add_controls(codec, aic33_n810_controls,
@@ -292,13 +293,13 @@ static int n810_aic33_init(struct snd_soc_codec *codec)
292 return err; 293 return err;
293 294
294 /* Add N810 specific widgets */ 295 /* Add N810 specific widgets */
295 snd_soc_dapm_new_controls(codec, aic33_dapm_widgets, 296 snd_soc_dapm_new_controls(dapm, aic33_dapm_widgets,
296 ARRAY_SIZE(aic33_dapm_widgets)); 297 ARRAY_SIZE(aic33_dapm_widgets));
297 298
298 /* Set up N810 specific audio path audio_map */ 299 /* Set up N810 specific audio path audio_map */
299 snd_soc_dapm_add_routes(codec, audio_map, ARRAY_SIZE(audio_map)); 300 snd_soc_dapm_add_routes(dapm, audio_map, ARRAY_SIZE(audio_map));
300 301
301 snd_soc_dapm_sync(codec); 302 snd_soc_dapm_sync(dapm);
302 303
303 return 0; 304 return 0;
304} 305}
@@ -307,8 +308,10 @@ static int n810_aic33_init(struct snd_soc_codec *codec)
307static struct snd_soc_dai_link n810_dai = { 308static struct snd_soc_dai_link n810_dai = {
308 .name = "TLV320AIC33", 309 .name = "TLV320AIC33",
309 .stream_name = "AIC33", 310 .stream_name = "AIC33",
310 .cpu_dai = &omap_mcbsp_dai[0], 311 .cpu_dai_name = "omap-mcbsp-dai.1",
311 .codec_dai = &aic3x_dai, 312 .platform_name = "omap-pcm-audio",
313 .codec_name = "tlv320aic3x-codec.2-0018",
314 .codec_dai_name = "tlv320aic3x-hifi",
312 .init = n810_aic33_init, 315 .init = n810_aic33_init,
313 .ops = &n810_ops, 316 .ops = &n810_ops,
314}; 317};
@@ -316,33 +319,12 @@ static struct snd_soc_dai_link n810_dai = {
316/* Audio machine driver */ 319/* Audio machine driver */
317static struct snd_soc_card snd_soc_n810 = { 320static struct snd_soc_card snd_soc_n810 = {
318 .name = "N810", 321 .name = "N810",
319 .platform = &omap_soc_platform,
320 .dai_link = &n810_dai, 322 .dai_link = &n810_dai,
321 .num_links = 1, 323 .num_links = 1,
322}; 324};
323 325
324/* Audio private data */
325static struct aic3x_setup_data n810_aic33_setup = {
326 .gpio_func[0] = AIC3X_GPIO1_FUNC_DISABLED,
327 .gpio_func[1] = AIC3X_GPIO2_FUNC_DIGITAL_MIC_INPUT,
328};
329
330/* Audio subsystem */
331static struct snd_soc_device n810_snd_devdata = {
332 .card = &snd_soc_n810,
333 .codec_dev = &soc_codec_dev_aic3x,
334 .codec_data = &n810_aic33_setup,
335};
336
337static struct platform_device *n810_snd_device; 326static struct platform_device *n810_snd_device;
338 327
339/* temporary i2c device creation until this can be moved into the machine
340 * support file.
341*/
342static struct i2c_board_info i2c_device[] = {
343 { I2C_BOARD_INFO("tlv320aic3x", 0x1b), }
344};
345
346static int __init n810_soc_init(void) 328static int __init n810_soc_init(void)
347{ 329{
348 int err; 330 int err;
@@ -351,15 +333,11 @@ static int __init n810_soc_init(void)
351 if (!(machine_is_nokia_n810() || machine_is_nokia_n810_wimax())) 333 if (!(machine_is_nokia_n810() || machine_is_nokia_n810_wimax()))
352 return -ENODEV; 334 return -ENODEV;
353 335
354 i2c_register_board_info(1, i2c_device, ARRAY_SIZE(i2c_device));
355
356 n810_snd_device = platform_device_alloc("soc-audio", -1); 336 n810_snd_device = platform_device_alloc("soc-audio", -1);
357 if (!n810_snd_device) 337 if (!n810_snd_device)
358 return -ENOMEM; 338 return -ENOMEM;
359 339
360 platform_set_drvdata(n810_snd_device, &n810_snd_devdata); 340 platform_set_drvdata(n810_snd_device, &snd_soc_n810);
361 n810_snd_devdata.dev = &n810_snd_device->dev;
362 *(unsigned int *)n810_dai.cpu_dai->private_data = 1; /* McBSP2 */
363 err = platform_device_add(n810_snd_device); 341 err = platform_device_add(n810_snd_device);
364 if (err) 342 if (err)
365 goto err1; 343 goto err1;
diff --git a/sound/soc/omap/omap-mcbsp.c b/sound/soc/omap/omap-mcbsp.c
index 86f213905e2c..07b772357244 100644
--- a/sound/soc/omap/omap-mcbsp.c
+++ b/sound/soc/omap/omap-mcbsp.c
@@ -4,7 +4,7 @@
4 * Copyright (C) 2008 Nokia Corporation 4 * Copyright (C) 2008 Nokia Corporation
5 * 5 *
6 * Contact: Jarkko Nikula <jhnikula@gmail.com> 6 * Contact: Jarkko Nikula <jhnikula@gmail.com>
7 * Peter Ujfalusi <peter.ujfalusi@nokia.com> 7 * Peter Ujfalusi <peter.ujfalusi@ti.com>
8 * 8 *
9 * This program is free software; you can redistribute it and/or 9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License 10 * modify it under the terms of the GNU General Public License
@@ -31,7 +31,6 @@
31#include <sound/initval.h> 31#include <sound/initval.h>
32#include <sound/soc.h> 32#include <sound/soc.h>
33 33
34#include <plat/control.h>
35#include <plat/dma.h> 34#include <plat/dma.h>
36#include <plat/mcbsp.h> 35#include <plat/mcbsp.h>
37#include "omap-mcbsp.h" 36#include "omap-mcbsp.h"
@@ -62,8 +61,6 @@ struct omap_mcbsp_data {
62 int wlen; 61 int wlen;
63}; 62};
64 63
65#define to_mcbsp(priv) container_of((priv), struct omap_mcbsp_data, bus_id)
66
67static struct omap_mcbsp_data mcbsp_data[NUM_LINKS]; 64static struct omap_mcbsp_data mcbsp_data[NUM_LINKS];
68 65
69/* 66/*
@@ -72,94 +69,16 @@ static struct omap_mcbsp_data mcbsp_data[NUM_LINKS];
72 */ 69 */
73static struct omap_pcm_dma_data omap_mcbsp_dai_dma_params[NUM_LINKS][2]; 70static struct omap_pcm_dma_data omap_mcbsp_dai_dma_params[NUM_LINKS][2];
74 71
75#if defined(CONFIG_ARCH_OMAP15XX) || defined(CONFIG_ARCH_OMAP16XX)
76static const int omap1_dma_reqs[][2] = {
77 { OMAP_DMA_MCBSP1_TX, OMAP_DMA_MCBSP1_RX },
78 { OMAP_DMA_MCBSP2_TX, OMAP_DMA_MCBSP2_RX },
79 { OMAP_DMA_MCBSP3_TX, OMAP_DMA_MCBSP3_RX },
80};
81static const unsigned long omap1_mcbsp_port[][2] = {
82 { OMAP1510_MCBSP1_BASE + OMAP_MCBSP_REG_DXR1,
83 OMAP1510_MCBSP1_BASE + OMAP_MCBSP_REG_DRR1 },
84 { OMAP1510_MCBSP2_BASE + OMAP_MCBSP_REG_DXR1,
85 OMAP1510_MCBSP2_BASE + OMAP_MCBSP_REG_DRR1 },
86 { OMAP1510_MCBSP3_BASE + OMAP_MCBSP_REG_DXR1,
87 OMAP1510_MCBSP3_BASE + OMAP_MCBSP_REG_DRR1 },
88};
89#else
90static const int omap1_dma_reqs[][2] = {};
91static const unsigned long omap1_mcbsp_port[][2] = {};
92#endif
93
94#if defined(CONFIG_ARCH_OMAP2) || defined(CONFIG_ARCH_OMAP3)
95static const int omap24xx_dma_reqs[][2] = {
96 { OMAP24XX_DMA_MCBSP1_TX, OMAP24XX_DMA_MCBSP1_RX },
97 { OMAP24XX_DMA_MCBSP2_TX, OMAP24XX_DMA_MCBSP2_RX },
98#if defined(CONFIG_ARCH_OMAP2430) || defined(CONFIG_ARCH_OMAP3)
99 { OMAP24XX_DMA_MCBSP3_TX, OMAP24XX_DMA_MCBSP3_RX },
100 { OMAP24XX_DMA_MCBSP4_TX, OMAP24XX_DMA_MCBSP4_RX },
101 { OMAP24XX_DMA_MCBSP5_TX, OMAP24XX_DMA_MCBSP5_RX },
102#endif
103};
104#else
105static const int omap24xx_dma_reqs[][2] = {};
106#endif
107
108#if defined(CONFIG_ARCH_OMAP2420)
109static const unsigned long omap2420_mcbsp_port[][2] = {
110 { OMAP24XX_MCBSP1_BASE + OMAP_MCBSP_REG_DXR1,
111 OMAP24XX_MCBSP1_BASE + OMAP_MCBSP_REG_DRR1 },
112 { OMAP24XX_MCBSP2_BASE + OMAP_MCBSP_REG_DXR1,
113 OMAP24XX_MCBSP2_BASE + OMAP_MCBSP_REG_DRR1 },
114};
115#else
116static const unsigned long omap2420_mcbsp_port[][2] = {};
117#endif
118
119#if defined(CONFIG_ARCH_OMAP2430)
120static const unsigned long omap2430_mcbsp_port[][2] = {
121 { OMAP24XX_MCBSP1_BASE + OMAP_MCBSP_REG_DXR,
122 OMAP24XX_MCBSP1_BASE + OMAP_MCBSP_REG_DRR },
123 { OMAP24XX_MCBSP2_BASE + OMAP_MCBSP_REG_DXR,
124 OMAP24XX_MCBSP2_BASE + OMAP_MCBSP_REG_DRR },
125 { OMAP2430_MCBSP3_BASE + OMAP_MCBSP_REG_DXR,
126 OMAP2430_MCBSP3_BASE + OMAP_MCBSP_REG_DRR },
127 { OMAP2430_MCBSP4_BASE + OMAP_MCBSP_REG_DXR,
128 OMAP2430_MCBSP4_BASE + OMAP_MCBSP_REG_DRR },
129 { OMAP2430_MCBSP5_BASE + OMAP_MCBSP_REG_DXR,
130 OMAP2430_MCBSP5_BASE + OMAP_MCBSP_REG_DRR },
131};
132#else
133static const unsigned long omap2430_mcbsp_port[][2] = {};
134#endif
135
136#if defined(CONFIG_ARCH_OMAP3)
137static const unsigned long omap34xx_mcbsp_port[][2] = {
138 { OMAP34XX_MCBSP1_BASE + OMAP_MCBSP_REG_DXR,
139 OMAP34XX_MCBSP1_BASE + OMAP_MCBSP_REG_DRR },
140 { OMAP34XX_MCBSP2_BASE + OMAP_MCBSP_REG_DXR,
141 OMAP34XX_MCBSP2_BASE + OMAP_MCBSP_REG_DRR },
142 { OMAP34XX_MCBSP3_BASE + OMAP_MCBSP_REG_DXR,
143 OMAP34XX_MCBSP3_BASE + OMAP_MCBSP_REG_DRR },
144 { OMAP34XX_MCBSP4_BASE + OMAP_MCBSP_REG_DXR,
145 OMAP34XX_MCBSP4_BASE + OMAP_MCBSP_REG_DRR },
146 { OMAP34XX_MCBSP5_BASE + OMAP_MCBSP_REG_DXR,
147 OMAP34XX_MCBSP5_BASE + OMAP_MCBSP_REG_DRR },
148};
149#else
150static const unsigned long omap34xx_mcbsp_port[][2] = {};
151#endif
152
153static void omap_mcbsp_set_threshold(struct snd_pcm_substream *substream) 72static void omap_mcbsp_set_threshold(struct snd_pcm_substream *substream)
154{ 73{
155 struct snd_soc_pcm_runtime *rtd = substream->private_data; 74 struct snd_soc_pcm_runtime *rtd = substream->private_data;
156 struct snd_soc_dai *cpu_dai = rtd->dai->cpu_dai; 75 struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
157 struct omap_mcbsp_data *mcbsp_data = to_mcbsp(cpu_dai->private_data); 76 struct omap_mcbsp_data *mcbsp_data = snd_soc_dai_get_drvdata(cpu_dai);
158 struct omap_pcm_dma_data *dma_data; 77 struct omap_pcm_dma_data *dma_data;
159 int dma_op_mode = omap_mcbsp_get_dma_op_mode(mcbsp_data->bus_id); 78 int dma_op_mode = omap_mcbsp_get_dma_op_mode(mcbsp_data->bus_id);
160 int words; 79 int words;
161 80
162 dma_data = snd_soc_dai_get_dma_data(rtd->dai->cpu_dai, substream); 81 dma_data = snd_soc_dai_get_dma_data(rtd->cpu_dai, substream);
163 82
164 /* TODO: Currently, MODE_ELEMENT == MODE_FRAME */ 83 /* TODO: Currently, MODE_ELEMENT == MODE_FRAME */
165 if (dma_op_mode == MCBSP_DMA_MODE_THRESHOLD) 84 if (dma_op_mode == MCBSP_DMA_MODE_THRESHOLD)
@@ -203,11 +122,9 @@ static int omap_mcbsp_hwrule_min_buffersize(struct snd_pcm_hw_params *params,
203} 122}
204 123
205static int omap_mcbsp_dai_startup(struct snd_pcm_substream *substream, 124static int omap_mcbsp_dai_startup(struct snd_pcm_substream *substream,
206 struct snd_soc_dai *dai) 125 struct snd_soc_dai *cpu_dai)
207{ 126{
208 struct snd_soc_pcm_runtime *rtd = substream->private_data; 127 struct omap_mcbsp_data *mcbsp_data = snd_soc_dai_get_drvdata(cpu_dai);
209 struct snd_soc_dai *cpu_dai = rtd->dai->cpu_dai;
210 struct omap_mcbsp_data *mcbsp_data = to_mcbsp(cpu_dai->private_data);
211 int bus_id = mcbsp_data->bus_id; 128 int bus_id = mcbsp_data->bus_id;
212 int err = 0; 129 int err = 0;
213 130
@@ -229,7 +146,7 @@ static int omap_mcbsp_dai_startup(struct snd_pcm_substream *substream,
229 * 2 channels (stereo): size is 128 / 2 = 64 frames (2 * 64 words) 146 * 2 channels (stereo): size is 128 / 2 = 64 frames (2 * 64 words)
230 * 4 channels: size is 128 / 4 = 32 frames (4 * 32 words) 147 * 4 channels: size is 128 / 4 = 32 frames (4 * 32 words)
231 */ 148 */
232 if (cpu_is_omap343x()) { 149 if (cpu_is_omap34xx() || cpu_is_omap44xx()) {
233 /* 150 /*
234 * Rule for the buffer size. We should not allow 151 * Rule for the buffer size. We should not allow
235 * smaller buffer than the FIFO size to avoid underruns 152 * smaller buffer than the FIFO size to avoid underruns
@@ -249,11 +166,9 @@ static int omap_mcbsp_dai_startup(struct snd_pcm_substream *substream,
249} 166}
250 167
251static void omap_mcbsp_dai_shutdown(struct snd_pcm_substream *substream, 168static void omap_mcbsp_dai_shutdown(struct snd_pcm_substream *substream,
252 struct snd_soc_dai *dai) 169 struct snd_soc_dai *cpu_dai)
253{ 170{
254 struct snd_soc_pcm_runtime *rtd = substream->private_data; 171 struct omap_mcbsp_data *mcbsp_data = snd_soc_dai_get_drvdata(cpu_dai);
255 struct snd_soc_dai *cpu_dai = rtd->dai->cpu_dai;
256 struct omap_mcbsp_data *mcbsp_data = to_mcbsp(cpu_dai->private_data);
257 172
258 if (!cpu_dai->active) { 173 if (!cpu_dai->active) {
259 omap_mcbsp_free(mcbsp_data->bus_id); 174 omap_mcbsp_free(mcbsp_data->bus_id);
@@ -262,11 +177,9 @@ static void omap_mcbsp_dai_shutdown(struct snd_pcm_substream *substream,
262} 177}
263 178
264static int omap_mcbsp_dai_trigger(struct snd_pcm_substream *substream, int cmd, 179static int omap_mcbsp_dai_trigger(struct snd_pcm_substream *substream, int cmd,
265 struct snd_soc_dai *dai) 180 struct snd_soc_dai *cpu_dai)
266{ 181{
267 struct snd_soc_pcm_runtime *rtd = substream->private_data; 182 struct omap_mcbsp_data *mcbsp_data = snd_soc_dai_get_drvdata(cpu_dai);
268 struct snd_soc_dai *cpu_dai = rtd->dai->cpu_dai;
269 struct omap_mcbsp_data *mcbsp_data = to_mcbsp(cpu_dai->private_data);
270 int err = 0, play = (substream->stream == SNDRV_PCM_STREAM_PLAYBACK); 183 int err = 0, play = (substream->stream == SNDRV_PCM_STREAM_PLAYBACK);
271 184
272 switch (cmd) { 185 switch (cmd) {
@@ -295,8 +208,8 @@ static snd_pcm_sframes_t omap_mcbsp_dai_delay(
295 struct snd_soc_dai *dai) 208 struct snd_soc_dai *dai)
296{ 209{
297 struct snd_soc_pcm_runtime *rtd = substream->private_data; 210 struct snd_soc_pcm_runtime *rtd = substream->private_data;
298 struct snd_soc_dai *cpu_dai = rtd->dai->cpu_dai; 211 struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
299 struct omap_mcbsp_data *mcbsp_data = to_mcbsp(cpu_dai->private_data); 212 struct omap_mcbsp_data *mcbsp_data = snd_soc_dai_get_drvdata(cpu_dai);
300 u16 fifo_use; 213 u16 fifo_use;
301 snd_pcm_sframes_t delay; 214 snd_pcm_sframes_t delay;
302 215
@@ -317,11 +230,9 @@ static snd_pcm_sframes_t omap_mcbsp_dai_delay(
317 230
318static int omap_mcbsp_dai_hw_params(struct snd_pcm_substream *substream, 231static int omap_mcbsp_dai_hw_params(struct snd_pcm_substream *substream,
319 struct snd_pcm_hw_params *params, 232 struct snd_pcm_hw_params *params,
320 struct snd_soc_dai *dai) 233 struct snd_soc_dai *cpu_dai)
321{ 234{
322 struct snd_soc_pcm_runtime *rtd = substream->private_data; 235 struct omap_mcbsp_data *mcbsp_data = snd_soc_dai_get_drvdata(cpu_dai);
323 struct snd_soc_dai *cpu_dai = rtd->dai->cpu_dai;
324 struct omap_mcbsp_data *mcbsp_data = to_mcbsp(cpu_dai->private_data);
325 struct omap_mcbsp_reg_cfg *regs = &mcbsp_data->regs; 236 struct omap_mcbsp_reg_cfg *regs = &mcbsp_data->regs;
326 struct omap_pcm_dma_data *dma_data; 237 struct omap_pcm_dma_data *dma_data;
327 int dma, bus_id = mcbsp_data->bus_id; 238 int dma, bus_id = mcbsp_data->bus_id;
@@ -331,21 +242,10 @@ static int omap_mcbsp_dai_hw_params(struct snd_pcm_substream *substream,
331 unsigned int format, div, framesize, master; 242 unsigned int format, div, framesize, master;
332 243
333 dma_data = &omap_mcbsp_dai_dma_params[cpu_dai->id][substream->stream]; 244 dma_data = &omap_mcbsp_dai_dma_params[cpu_dai->id][substream->stream];
334 if (cpu_class_is_omap1()) { 245
335 dma = omap1_dma_reqs[bus_id][substream->stream]; 246 dma = omap_mcbsp_dma_ch_params(bus_id, substream->stream);
336 port = omap1_mcbsp_port[bus_id][substream->stream]; 247 port = omap_mcbsp_dma_reg_params(bus_id, substream->stream);
337 } else if (cpu_is_omap2420()) { 248
338 dma = omap24xx_dma_reqs[bus_id][substream->stream];
339 port = omap2420_mcbsp_port[bus_id][substream->stream];
340 } else if (cpu_is_omap2430()) {
341 dma = omap24xx_dma_reqs[bus_id][substream->stream];
342 port = omap2430_mcbsp_port[bus_id][substream->stream];
343 } else if (cpu_is_omap343x()) {
344 dma = omap24xx_dma_reqs[bus_id][substream->stream];
345 port = omap34xx_mcbsp_port[bus_id][substream->stream];
346 } else {
347 return -ENODEV;
348 }
349 switch (params_format(params)) { 249 switch (params_format(params)) {
350 case SNDRV_PCM_FORMAT_S16_LE: 250 case SNDRV_PCM_FORMAT_S16_LE:
351 dma_data->data_type = OMAP_DMA_DATA_TYPE_S16; 251 dma_data->data_type = OMAP_DMA_DATA_TYPE_S16;
@@ -358,7 +258,7 @@ static int omap_mcbsp_dai_hw_params(struct snd_pcm_substream *substream,
358 default: 258 default:
359 return -EINVAL; 259 return -EINVAL;
360 } 260 }
361 if (cpu_is_omap343x()) { 261 if (cpu_is_omap34xx()) {
362 dma_data->set_threshold = omap_mcbsp_set_threshold; 262 dma_data->set_threshold = omap_mcbsp_set_threshold;
363 /* TODO: Currently, MODE_ELEMENT == MODE_FRAME */ 263 /* TODO: Currently, MODE_ELEMENT == MODE_FRAME */
364 if (omap_mcbsp_get_dma_op_mode(bus_id) == 264 if (omap_mcbsp_get_dma_op_mode(bus_id) ==
@@ -496,7 +396,7 @@ static int omap_mcbsp_dai_hw_params(struct snd_pcm_substream *substream,
496static int omap_mcbsp_dai_set_dai_fmt(struct snd_soc_dai *cpu_dai, 396static int omap_mcbsp_dai_set_dai_fmt(struct snd_soc_dai *cpu_dai,
497 unsigned int fmt) 397 unsigned int fmt)
498{ 398{
499 struct omap_mcbsp_data *mcbsp_data = to_mcbsp(cpu_dai->private_data); 399 struct omap_mcbsp_data *mcbsp_data = snd_soc_dai_get_drvdata(cpu_dai);
500 struct omap_mcbsp_reg_cfg *regs = &mcbsp_data->regs; 400 struct omap_mcbsp_reg_cfg *regs = &mcbsp_data->regs;
501 unsigned int temp_fmt = fmt; 401 unsigned int temp_fmt = fmt;
502 402
@@ -509,11 +409,11 @@ static int omap_mcbsp_dai_set_dai_fmt(struct snd_soc_dai *cpu_dai,
509 regs->spcr2 |= XINTM(3) | FREE; 409 regs->spcr2 |= XINTM(3) | FREE;
510 regs->spcr1 |= RINTM(3); 410 regs->spcr1 |= RINTM(3);
511 /* RFIG and XFIG are not defined in 34xx */ 411 /* RFIG and XFIG are not defined in 34xx */
512 if (!cpu_is_omap34xx()) { 412 if (!cpu_is_omap34xx() && !cpu_is_omap44xx()) {
513 regs->rcr2 |= RFIG; 413 regs->rcr2 |= RFIG;
514 regs->xcr2 |= XFIG; 414 regs->xcr2 |= XFIG;
515 } 415 }
516 if (cpu_is_omap2430() || cpu_is_omap34xx()) { 416 if (cpu_is_omap2430() || cpu_is_omap34xx() || cpu_is_omap44xx()) {
517 regs->xccr = DXENDLY(1) | XDMAEN | XDISABLE; 417 regs->xccr = DXENDLY(1) | XDMAEN | XDISABLE;
518 regs->rccr = RFULL_CYCLE | RDMAEN | RDISABLE; 418 regs->rccr = RFULL_CYCLE | RDMAEN | RDISABLE;
519 } 419 }
@@ -596,7 +496,7 @@ static int omap_mcbsp_dai_set_dai_fmt(struct snd_soc_dai *cpu_dai,
596static int omap_mcbsp_dai_set_clkdiv(struct snd_soc_dai *cpu_dai, 496static int omap_mcbsp_dai_set_clkdiv(struct snd_soc_dai *cpu_dai,
597 int div_id, int div) 497 int div_id, int div)
598{ 498{
599 struct omap_mcbsp_data *mcbsp_data = to_mcbsp(cpu_dai->private_data); 499 struct omap_mcbsp_data *mcbsp_data = snd_soc_dai_get_drvdata(cpu_dai);
600 struct omap_mcbsp_reg_cfg *regs = &mcbsp_data->regs; 500 struct omap_mcbsp_reg_cfg *regs = &mcbsp_data->regs;
601 501
602 if (div_id != OMAP_MCBSP_CLKGDV) 502 if (div_id != OMAP_MCBSP_CLKGDV)
@@ -608,101 +508,22 @@ static int omap_mcbsp_dai_set_clkdiv(struct snd_soc_dai *cpu_dai,
608 return 0; 508 return 0;
609} 509}
610 510
611static int omap_mcbsp_dai_set_clks_src(struct omap_mcbsp_data *mcbsp_data,
612 int clk_id)
613{
614 int sel_bit;
615 u16 reg, reg_devconf1 = OMAP243X_CONTROL_DEVCONF1;
616
617 if (cpu_class_is_omap1()) {
618 /* OMAP1's can use only external source clock */
619 if (unlikely(clk_id == OMAP_MCBSP_SYSCLK_CLKS_FCLK))
620 return -EINVAL;
621 else
622 return 0;
623 }
624
625 if (cpu_is_omap2420() && mcbsp_data->bus_id > 1)
626 return -EINVAL;
627
628 if (cpu_is_omap343x())
629 reg_devconf1 = OMAP343X_CONTROL_DEVCONF1;
630
631 switch (mcbsp_data->bus_id) {
632 case 0:
633 reg = OMAP2_CONTROL_DEVCONF0;
634 sel_bit = 2;
635 break;
636 case 1:
637 reg = OMAP2_CONTROL_DEVCONF0;
638 sel_bit = 6;
639 break;
640 case 2:
641 reg = reg_devconf1;
642 sel_bit = 0;
643 break;
644 case 3:
645 reg = reg_devconf1;
646 sel_bit = 2;
647 break;
648 case 4:
649 reg = reg_devconf1;
650 sel_bit = 4;
651 break;
652 default:
653 return -EINVAL;
654 }
655
656 if (clk_id == OMAP_MCBSP_SYSCLK_CLKS_FCLK)
657 omap_ctrl_writel(omap_ctrl_readl(reg) & ~(1 << sel_bit), reg);
658 else
659 omap_ctrl_writel(omap_ctrl_readl(reg) | (1 << sel_bit), reg);
660
661 return 0;
662}
663
664static int omap_mcbsp_dai_set_rcvr_src(struct omap_mcbsp_data *mcbsp_data,
665 int clk_id)
666{
667 int sel_bit, set = 0;
668 u16 reg = OMAP2_CONTROL_DEVCONF0;
669
670 if (cpu_class_is_omap1())
671 return -EINVAL; /* TODO: Can this be implemented for OMAP1? */
672 if (mcbsp_data->bus_id != 0)
673 return -EINVAL;
674
675 switch (clk_id) {
676 case OMAP_MCBSP_CLKR_SRC_CLKX:
677 set = 1;
678 case OMAP_MCBSP_CLKR_SRC_CLKR:
679 sel_bit = 3;
680 break;
681 case OMAP_MCBSP_FSR_SRC_FSX:
682 set = 1;
683 case OMAP_MCBSP_FSR_SRC_FSR:
684 sel_bit = 4;
685 break;
686 default:
687 return -EINVAL;
688 }
689
690 if (set)
691 omap_ctrl_writel(omap_ctrl_readl(reg) | (1 << sel_bit), reg);
692 else
693 omap_ctrl_writel(omap_ctrl_readl(reg) & ~(1 << sel_bit), reg);
694
695 return 0;
696}
697
698static int omap_mcbsp_dai_set_dai_sysclk(struct snd_soc_dai *cpu_dai, 511static int omap_mcbsp_dai_set_dai_sysclk(struct snd_soc_dai *cpu_dai,
699 int clk_id, unsigned int freq, 512 int clk_id, unsigned int freq,
700 int dir) 513 int dir)
701{ 514{
702 struct omap_mcbsp_data *mcbsp_data = to_mcbsp(cpu_dai->private_data); 515 struct omap_mcbsp_data *mcbsp_data = snd_soc_dai_get_drvdata(cpu_dai);
703 struct omap_mcbsp_reg_cfg *regs = &mcbsp_data->regs; 516 struct omap_mcbsp_reg_cfg *regs = &mcbsp_data->regs;
704 int err = 0; 517 int err = 0;
705 518
519 /* The McBSP signal muxing functions are only available on McBSP1 */
520 if (clk_id == OMAP_MCBSP_CLKR_SRC_CLKR ||
521 clk_id == OMAP_MCBSP_CLKR_SRC_CLKX ||
522 clk_id == OMAP_MCBSP_FSR_SRC_FSR ||
523 clk_id == OMAP_MCBSP_FSR_SRC_FSX)
524 if (cpu_class_is_omap1() || mcbsp_data->bus_id != 0)
525 return -EINVAL;
526
706 mcbsp_data->in_freq = freq; 527 mcbsp_data->in_freq = freq;
707 528
708 switch (clk_id) { 529 switch (clk_id) {
@@ -710,8 +531,20 @@ static int omap_mcbsp_dai_set_dai_sysclk(struct snd_soc_dai *cpu_dai,
710 regs->srgr2 |= CLKSM; 531 regs->srgr2 |= CLKSM;
711 break; 532 break;
712 case OMAP_MCBSP_SYSCLK_CLKS_FCLK: 533 case OMAP_MCBSP_SYSCLK_CLKS_FCLK:
534 if (cpu_class_is_omap1()) {
535 err = -EINVAL;
536 break;
537 }
538 err = omap2_mcbsp_set_clks_src(mcbsp_data->bus_id,
539 MCBSP_CLKS_PRCM_SRC);
540 break;
713 case OMAP_MCBSP_SYSCLK_CLKS_EXT: 541 case OMAP_MCBSP_SYSCLK_CLKS_EXT:
714 err = omap_mcbsp_dai_set_clks_src(mcbsp_data, clk_id); 542 if (cpu_class_is_omap1()) {
543 err = 0;
544 break;
545 }
546 err = omap2_mcbsp_set_clks_src(mcbsp_data->bus_id,
547 MCBSP_CLKS_PAD_SRC);
715 break; 548 break;
716 549
717 case OMAP_MCBSP_SYSCLK_CLKX_EXT: 550 case OMAP_MCBSP_SYSCLK_CLKX_EXT:
@@ -720,11 +553,26 @@ static int omap_mcbsp_dai_set_dai_sysclk(struct snd_soc_dai *cpu_dai,
720 regs->pcr0 |= SCLKME; 553 regs->pcr0 |= SCLKME;
721 break; 554 break;
722 555
556
723 case OMAP_MCBSP_CLKR_SRC_CLKR: 557 case OMAP_MCBSP_CLKR_SRC_CLKR:
558 if (cpu_class_is_omap1())
559 break;
560 omap2_mcbsp1_mux_clkr_src(CLKR_SRC_CLKR);
561 break;
724 case OMAP_MCBSP_CLKR_SRC_CLKX: 562 case OMAP_MCBSP_CLKR_SRC_CLKX:
563 if (cpu_class_is_omap1())
564 break;
565 omap2_mcbsp1_mux_clkr_src(CLKR_SRC_CLKX);
566 break;
725 case OMAP_MCBSP_FSR_SRC_FSR: 567 case OMAP_MCBSP_FSR_SRC_FSR:
568 if (cpu_class_is_omap1())
569 break;
570 omap2_mcbsp1_mux_fsr_src(FSR_SRC_FSR);
571 break;
726 case OMAP_MCBSP_FSR_SRC_FSX: 572 case OMAP_MCBSP_FSR_SRC_FSX:
727 err = omap_mcbsp_dai_set_rcvr_src(mcbsp_data, clk_id); 573 if (cpu_class_is_omap1())
574 break;
575 omap2_mcbsp1_mux_fsr_src(FSR_SRC_FSX);
728 break; 576 break;
729 default: 577 default:
730 err = -ENODEV; 578 err = -ENODEV;
@@ -733,7 +581,7 @@ static int omap_mcbsp_dai_set_dai_sysclk(struct snd_soc_dai *cpu_dai,
733 return err; 581 return err;
734} 582}
735 583
736static struct snd_soc_dai_ops omap_mcbsp_dai_ops = { 584static struct snd_soc_dai_ops mcbsp_dai_ops = {
737 .startup = omap_mcbsp_dai_startup, 585 .startup = omap_mcbsp_dai_startup,
738 .shutdown = omap_mcbsp_dai_shutdown, 586 .shutdown = omap_mcbsp_dai_shutdown,
739 .trigger = omap_mcbsp_dai_trigger, 587 .trigger = omap_mcbsp_dai_trigger,
@@ -744,43 +592,32 @@ static struct snd_soc_dai_ops omap_mcbsp_dai_ops = {
744 .set_sysclk = omap_mcbsp_dai_set_dai_sysclk, 592 .set_sysclk = omap_mcbsp_dai_set_dai_sysclk,
745}; 593};
746 594
747#define OMAP_MCBSP_DAI_BUILDER(link_id) \ 595static int mcbsp_dai_probe(struct snd_soc_dai *dai)
748{ \ 596{
749 .name = "omap-mcbsp-dai-"#link_id, \ 597 mcbsp_data[dai->id].bus_id = dai->id;
750 .id = (link_id), \ 598 snd_soc_dai_set_drvdata(dai, &mcbsp_data[dai->id].bus_id);
751 .playback = { \ 599 return 0;
752 .channels_min = 1, \
753 .channels_max = 16, \
754 .rates = OMAP_MCBSP_RATES, \
755 .formats = SNDRV_PCM_FMTBIT_S16_LE | \
756 SNDRV_PCM_FMTBIT_S32_LE, \
757 }, \
758 .capture = { \
759 .channels_min = 1, \
760 .channels_max = 16, \
761 .rates = OMAP_MCBSP_RATES, \
762 .formats = SNDRV_PCM_FMTBIT_S16_LE | \
763 SNDRV_PCM_FMTBIT_S32_LE, \
764 }, \
765 .ops = &omap_mcbsp_dai_ops, \
766 .private_data = &mcbsp_data[(link_id)].bus_id, \
767} 600}
768 601
769struct snd_soc_dai omap_mcbsp_dai[] = { 602static struct snd_soc_dai_driver omap_mcbsp_dai =
770 OMAP_MCBSP_DAI_BUILDER(0), 603{
771 OMAP_MCBSP_DAI_BUILDER(1), 604 .probe = mcbsp_dai_probe,
772#if NUM_LINKS >= 3 605 .playback = {
773 OMAP_MCBSP_DAI_BUILDER(2), 606 .channels_min = 1,
774#endif 607 .channels_max = 16,
775#if NUM_LINKS == 5 608 .rates = OMAP_MCBSP_RATES,
776 OMAP_MCBSP_DAI_BUILDER(3), 609 .formats = SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S32_LE,
777 OMAP_MCBSP_DAI_BUILDER(4), 610 },
778#endif 611 .capture = {
612 .channels_min = 1,
613 .channels_max = 16,
614 .rates = OMAP_MCBSP_RATES,
615 .formats = SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S32_LE,
616 },
617 .ops = &mcbsp_dai_ops,
779}; 618};
780 619
781EXPORT_SYMBOL_GPL(omap_mcbsp_dai); 620static int omap_mcbsp_st_info_volsw(struct snd_kcontrol *kcontrol,
782
783int omap_mcbsp_st_info_volsw(struct snd_kcontrol *kcontrol,
784 struct snd_ctl_elem_info *uinfo) 621 struct snd_ctl_elem_info *uinfo)
785{ 622{
786 struct soc_mixer_control *mc = 623 struct soc_mixer_control *mc =
@@ -910,16 +747,36 @@ int omap_mcbsp_st_add_controls(struct snd_soc_codec *codec, int mcbsp_id)
910} 747}
911EXPORT_SYMBOL_GPL(omap_mcbsp_st_add_controls); 748EXPORT_SYMBOL_GPL(omap_mcbsp_st_add_controls);
912 749
750static __devinit int asoc_mcbsp_probe(struct platform_device *pdev)
751{
752 return snd_soc_register_dai(&pdev->dev, &omap_mcbsp_dai);
753}
754
755static int __devexit asoc_mcbsp_remove(struct platform_device *pdev)
756{
757 snd_soc_unregister_dai(&pdev->dev);
758 return 0;
759}
760
761static struct platform_driver asoc_mcbsp_driver = {
762 .driver = {
763 .name = "omap-mcbsp-dai",
764 .owner = THIS_MODULE,
765 },
766
767 .probe = asoc_mcbsp_probe,
768 .remove = __devexit_p(asoc_mcbsp_remove),
769};
770
913static int __init snd_omap_mcbsp_init(void) 771static int __init snd_omap_mcbsp_init(void)
914{ 772{
915 return snd_soc_register_dais(omap_mcbsp_dai, 773 return platform_driver_register(&asoc_mcbsp_driver);
916 ARRAY_SIZE(omap_mcbsp_dai));
917} 774}
918module_init(snd_omap_mcbsp_init); 775module_init(snd_omap_mcbsp_init);
919 776
920static void __exit snd_omap_mcbsp_exit(void) 777static void __exit snd_omap_mcbsp_exit(void)
921{ 778{
922 snd_soc_unregister_dais(omap_mcbsp_dai, ARRAY_SIZE(omap_mcbsp_dai)); 779 platform_driver_unregister(&asoc_mcbsp_driver);
923} 780}
924module_exit(snd_omap_mcbsp_exit); 781module_exit(snd_omap_mcbsp_exit);
925 782
diff --git a/sound/soc/omap/omap-mcbsp.h b/sound/soc/omap/omap-mcbsp.h
index 6c363e5f4387..9a7dedd6f5a9 100644
--- a/sound/soc/omap/omap-mcbsp.h
+++ b/sound/soc/omap/omap-mcbsp.h
@@ -4,7 +4,7 @@
4 * Copyright (C) 2008 Nokia Corporation 4 * Copyright (C) 2008 Nokia Corporation
5 * 5 *
6 * Contact: Jarkko Nikula <jhnikula@gmail.com> 6 * Contact: Jarkko Nikula <jhnikula@gmail.com>
7 * Peter Ujfalusi <peter.ujfalusi@nokia.com> 7 * Peter Ujfalusi <peter.ujfalusi@ti.com>
8 * 8 *
9 * This program is free software; you can redistribute it and/or 9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License 10 * modify it under the terms of the GNU General Public License
@@ -43,20 +43,22 @@ enum omap_mcbsp_div {
43 OMAP_MCBSP_CLKGDV, /* Sample rate generator divider */ 43 OMAP_MCBSP_CLKGDV, /* Sample rate generator divider */
44}; 44};
45 45
46#if defined(CONFIG_ARCH_OMAP2420) 46#if defined(CONFIG_SOC_OMAP2420)
47#define NUM_LINKS 2 47#define NUM_LINKS 2
48#endif 48#endif
49#if defined(CONFIG_ARCH_OMAP15XX) || defined(CONFIG_ARCH_OMAP16XX) 49#if defined(CONFIG_ARCH_OMAP15XX) || defined(CONFIG_ARCH_OMAP16XX)
50#undef NUM_LINKS 50#undef NUM_LINKS
51#define NUM_LINKS 3 51#define NUM_LINKS 3
52#endif 52#endif
53#if defined(CONFIG_ARCH_OMAP2430) || defined(CONFIG_ARCH_OMAP3) 53#if defined(CONFIG_ARCH_OMAP4)
54#undef NUM_LINKS
55#define NUM_LINKS 4
56#endif
57#if defined(CONFIG_ARCH_OMAP3) || defined(CONFIG_SOC_OMAP2430)
54#undef NUM_LINKS 58#undef NUM_LINKS
55#define NUM_LINKS 5 59#define NUM_LINKS 5
56#endif 60#endif
57 61
58extern struct snd_soc_dai omap_mcbsp_dai[NUM_LINKS];
59
60int omap_mcbsp_st_add_controls(struct snd_soc_codec *codec, int mcbsp_id); 62int omap_mcbsp_st_add_controls(struct snd_soc_codec *codec, int mcbsp_id);
61 63
62#endif 64#endif
diff --git a/sound/soc/omap/omap-mcpdm.c b/sound/soc/omap/omap-mcpdm.c
index b7f4f7e015f3..bed09c27e44c 100644
--- a/sound/soc/omap/omap-mcpdm.c
+++ b/sound/soc/omap/omap-mcpdm.c
@@ -32,11 +32,9 @@
32#include <sound/initval.h> 32#include <sound/initval.h>
33#include <sound/soc.h> 33#include <sound/soc.h>
34 34
35#include <plat/control.h>
36#include <plat/dma.h> 35#include <plat/dma.h>
37#include <plat/mcbsp.h> 36#include <plat/mcbsp.h>
38#include "mcpdm.h" 37#include "mcpdm.h"
39#include "omap-mcpdm.h"
40#include "omap-pcm.h" 38#include "omap-pcm.h"
41 39
42struct omap_mcpdm_data { 40struct omap_mcpdm_data {
@@ -89,11 +87,9 @@ static struct omap_pcm_dma_data omap_mcpdm_dai_dma_params[] = {
89static int omap_mcpdm_dai_startup(struct snd_pcm_substream *substream, 87static int omap_mcpdm_dai_startup(struct snd_pcm_substream *substream,
90 struct snd_soc_dai *dai) 88 struct snd_soc_dai *dai)
91{ 89{
92 struct snd_soc_pcm_runtime *rtd = substream->private_data;
93 struct snd_soc_dai *cpu_dai = rtd->dai->cpu_dai;
94 int err = 0; 90 int err = 0;
95 91
96 if (!cpu_dai->active) 92 if (!dai->active)
97 err = omap_mcpdm_request(); 93 err = omap_mcpdm_request();
98 94
99 return err; 95 return err;
@@ -102,19 +98,14 @@ static int omap_mcpdm_dai_startup(struct snd_pcm_substream *substream,
102static void omap_mcpdm_dai_shutdown(struct snd_pcm_substream *substream, 98static void omap_mcpdm_dai_shutdown(struct snd_pcm_substream *substream,
103 struct snd_soc_dai *dai) 99 struct snd_soc_dai *dai)
104{ 100{
105 struct snd_soc_pcm_runtime *rtd = substream->private_data; 101 if (!dai->active)
106 struct snd_soc_dai *cpu_dai = rtd->dai->cpu_dai;
107
108 if (!cpu_dai->active)
109 omap_mcpdm_free(); 102 omap_mcpdm_free();
110} 103}
111 104
112static int omap_mcpdm_dai_trigger(struct snd_pcm_substream *substream, int cmd, 105static int omap_mcpdm_dai_trigger(struct snd_pcm_substream *substream, int cmd,
113 struct snd_soc_dai *dai) 106 struct snd_soc_dai *dai)
114{ 107{
115 struct snd_soc_pcm_runtime *rtd = substream->private_data; 108 struct omap_mcpdm_data *mcpdm_priv = snd_soc_dai_get_drvdata(dai);
116 struct snd_soc_dai *cpu_dai = rtd->dai->cpu_dai;
117 struct omap_mcpdm_data *mcpdm_priv = cpu_dai->private_data;
118 int stream = substream->stream; 109 int stream = substream->stream;
119 int err = 0; 110 int err = 0;
120 111
@@ -143,14 +134,12 @@ static int omap_mcpdm_dai_hw_params(struct snd_pcm_substream *substream,
143 struct snd_pcm_hw_params *params, 134 struct snd_pcm_hw_params *params,
144 struct snd_soc_dai *dai) 135 struct snd_soc_dai *dai)
145{ 136{
146 struct snd_soc_pcm_runtime *rtd = substream->private_data; 137 struct omap_mcpdm_data *mcpdm_priv = snd_soc_dai_get_drvdata(dai);
147 struct snd_soc_dai *cpu_dai = rtd->dai->cpu_dai;
148 struct omap_mcpdm_data *mcpdm_priv = cpu_dai->private_data;
149 struct omap_mcpdm_link *mcpdm_links = mcpdm_priv->links; 138 struct omap_mcpdm_link *mcpdm_links = mcpdm_priv->links;
150 int stream = substream->stream; 139 int stream = substream->stream;
151 int channels, err, link_mask = 0; 140 int channels, err, link_mask = 0;
152 141
153 snd_soc_dai_set_dma_data(cpu_dai, substream, 142 snd_soc_dai_set_dma_data(dai, substream,
154 &omap_mcpdm_dai_dma_params[stream]); 143 &omap_mcpdm_dai_dma_params[stream]);
155 144
156 channels = params_channels(params); 145 channels = params_channels(params);
@@ -189,9 +178,7 @@ static int omap_mcpdm_dai_hw_params(struct snd_pcm_substream *substream,
189static int omap_mcpdm_dai_hw_free(struct snd_pcm_substream *substream, 178static int omap_mcpdm_dai_hw_free(struct snd_pcm_substream *substream,
190 struct snd_soc_dai *dai) 179 struct snd_soc_dai *dai)
191{ 180{
192 struct snd_soc_pcm_runtime *rtd = substream->private_data; 181 struct omap_mcpdm_data *mcpdm_priv = snd_soc_dai_get_drvdata(dai);
193 struct snd_soc_dai *cpu_dai = rtd->dai->cpu_dai;
194 struct omap_mcpdm_data *mcpdm_priv = cpu_dai->private_data;
195 struct omap_mcpdm_link *mcpdm_links = mcpdm_priv->links; 182 struct omap_mcpdm_link *mcpdm_links = mcpdm_priv->links;
196 int stream = substream->stream; 183 int stream = substream->stream;
197 int err; 184 int err;
@@ -215,9 +202,14 @@ static struct snd_soc_dai_ops omap_mcpdm_dai_ops = {
215#define OMAP_MCPDM_RATES (SNDRV_PCM_RATE_88200 | SNDRV_PCM_RATE_96000) 202#define OMAP_MCPDM_RATES (SNDRV_PCM_RATE_88200 | SNDRV_PCM_RATE_96000)
216#define OMAP_MCPDM_FORMATS (SNDRV_PCM_FMTBIT_S32_LE) 203#define OMAP_MCPDM_FORMATS (SNDRV_PCM_FMTBIT_S32_LE)
217 204
218struct snd_soc_dai omap_mcpdm_dai = { 205static int omap_mcpdm_dai_probe(struct snd_soc_dai *dai)
219 .name = "omap-mcpdm", 206{
220 .id = -1, 207 snd_soc_dai_set_drvdata(dai, &mcpdm_data);
208 return 0;
209}
210
211static struct snd_soc_dai_driver omap_mcpdm_dai = {
212 .probe = omap_mcpdm_dai_probe,
221 .playback = { 213 .playback = {
222 .channels_min = 1, 214 .channels_min = 1,
223 .channels_max = 4, 215 .channels_max = 4,
@@ -231,19 +223,47 @@ struct snd_soc_dai omap_mcpdm_dai = {
231 .formats = OMAP_MCPDM_FORMATS, 223 .formats = OMAP_MCPDM_FORMATS,
232 }, 224 },
233 .ops = &omap_mcpdm_dai_ops, 225 .ops = &omap_mcpdm_dai_ops,
234 .private_data = &mcpdm_data,
235}; 226};
236EXPORT_SYMBOL_GPL(omap_mcpdm_dai); 227
228static __devinit int asoc_mcpdm_probe(struct platform_device *pdev)
229{
230 int ret;
231
232 ret = omap_mcpdm_probe(pdev);
233 if (ret < 0)
234 return ret;
235 ret = snd_soc_register_dai(&pdev->dev, &omap_mcpdm_dai);
236 if (ret < 0)
237 omap_mcpdm_remove(pdev);
238 return ret;
239}
240
241static int __devexit asoc_mcpdm_remove(struct platform_device *pdev)
242{
243 snd_soc_unregister_dai(&pdev->dev);
244 omap_mcpdm_remove(pdev);
245 return 0;
246}
247
248static struct platform_driver asoc_mcpdm_driver = {
249 .driver = {
250 .name = "omap-mcpdm-dai",
251 .owner = THIS_MODULE,
252 },
253
254 .probe = asoc_mcpdm_probe,
255 .remove = __devexit_p(asoc_mcpdm_remove),
256};
237 257
238static int __init snd_omap_mcpdm_init(void) 258static int __init snd_omap_mcpdm_init(void)
239{ 259{
240 return snd_soc_register_dai(&omap_mcpdm_dai); 260 return platform_driver_register(&asoc_mcpdm_driver);
241} 261}
242module_init(snd_omap_mcpdm_init); 262module_init(snd_omap_mcpdm_init);
243 263
244static void __exit snd_omap_mcpdm_exit(void) 264static void __exit snd_omap_mcpdm_exit(void)
245{ 265{
246 snd_soc_unregister_dai(&omap_mcpdm_dai); 266 platform_driver_unregister(&asoc_mcpdm_driver);
247} 267}
248module_exit(snd_omap_mcpdm_exit); 268module_exit(snd_omap_mcpdm_exit);
249 269
diff --git a/sound/soc/omap/omap-mcpdm.h b/sound/soc/omap/omap-mcpdm.h
deleted file mode 100644
index 73b80d559345..000000000000
--- a/sound/soc/omap/omap-mcpdm.h
+++ /dev/null
@@ -1,29 +0,0 @@
1/*
2 * omap-mcpdm.h
3 *
4 * Copyright (C) 2009 Texas Instruments
5 *
6 * Contact: Misael Lopez Cruz <x0052729@ti.com>
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * version 2 as published by the Free Software Foundation.
11 *
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20 * 02110-1301 USA
21 *
22 */
23
24#ifndef __OMAP_MCPDM_H__
25#define __OMAP_MCPDM_H__
26
27extern struct snd_soc_dai omap_mcpdm_dai;
28
29#endif /* End of __OMAP_MCPDM_H__ */
diff --git a/sound/soc/omap/omap-pcm.c b/sound/soc/omap/omap-pcm.c
index 1e521904ea64..e6a6b991d05f 100644
--- a/sound/soc/omap/omap-pcm.c
+++ b/sound/soc/omap/omap-pcm.c
@@ -4,7 +4,7 @@
4 * Copyright (C) 2008 Nokia Corporation 4 * Copyright (C) 2008 Nokia Corporation
5 * 5 *
6 * Contact: Jarkko Nikula <jhnikula@gmail.com> 6 * Contact: Jarkko Nikula <jhnikula@gmail.com>
7 * Peter Ujfalusi <peter.ujfalusi@nokia.com> 7 * Peter Ujfalusi <peter.ujfalusi@ti.com>
8 * 8 *
9 * This program is free software; you can redistribute it and/or 9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License 10 * modify it under the terms of the GNU General Public License
@@ -37,7 +37,8 @@ static const struct snd_pcm_hardware omap_pcm_hardware = {
37 SNDRV_PCM_INFO_MMAP_VALID | 37 SNDRV_PCM_INFO_MMAP_VALID |
38 SNDRV_PCM_INFO_INTERLEAVED | 38 SNDRV_PCM_INFO_INTERLEAVED |
39 SNDRV_PCM_INFO_PAUSE | 39 SNDRV_PCM_INFO_PAUSE |
40 SNDRV_PCM_INFO_RESUME, 40 SNDRV_PCM_INFO_RESUME |
41 SNDRV_PCM_INFO_NO_PERIOD_WAKEUP,
41 .formats = SNDRV_PCM_FMTBIT_S16_LE | 42 .formats = SNDRV_PCM_FMTBIT_S16_LE |
42 SNDRV_PCM_FMTBIT_S32_LE, 43 SNDRV_PCM_FMTBIT_S32_LE,
43 .period_bytes_min = 32, 44 .period_bytes_min = 32,
@@ -101,9 +102,10 @@ static int omap_pcm_hw_params(struct snd_pcm_substream *substream,
101 struct snd_soc_pcm_runtime *rtd = substream->private_data; 102 struct snd_soc_pcm_runtime *rtd = substream->private_data;
102 struct omap_runtime_data *prtd = runtime->private_data; 103 struct omap_runtime_data *prtd = runtime->private_data;
103 struct omap_pcm_dma_data *dma_data; 104 struct omap_pcm_dma_data *dma_data;
105
104 int err = 0; 106 int err = 0;
105 107
106 dma_data = snd_soc_dai_get_dma_data(rtd->dai->cpu_dai, substream); 108 dma_data = snd_soc_dai_get_dma_data(rtd->cpu_dai, substream);
107 109
108 /* return if this is a bufferless transfer e.g. 110 /* return if this is a bufferless transfer e.g.
109 * codec <--> BT codec or GSM modem -- lg FIXME */ 111 * codec <--> BT codec or GSM modem -- lg FIXME */
@@ -194,7 +196,7 @@ static int omap_pcm_prepare(struct snd_pcm_substream *substream)
194 if ((cpu_is_omap1510())) 196 if ((cpu_is_omap1510()))
195 omap_enable_dma_irq(prtd->dma_ch, OMAP_DMA_FRAME_IRQ | 197 omap_enable_dma_irq(prtd->dma_ch, OMAP_DMA_FRAME_IRQ |
196 OMAP_DMA_LAST_IRQ | OMAP_DMA_BLOCK_IRQ); 198 OMAP_DMA_LAST_IRQ | OMAP_DMA_BLOCK_IRQ);
197 else 199 else if (!substream->runtime->no_period_wakeup)
198 omap_enable_dma_irq(prtd->dma_ch, OMAP_DMA_FRAME_IRQ); 200 omap_enable_dma_irq(prtd->dma_ch, OMAP_DMA_FRAME_IRQ);
199 201
200 if (!(cpu_class_is_omap1())) { 202 if (!(cpu_class_is_omap1())) {
@@ -374,14 +376,14 @@ static int omap_pcm_new(struct snd_card *card, struct snd_soc_dai *dai,
374 if (!card->dev->coherent_dma_mask) 376 if (!card->dev->coherent_dma_mask)
375 card->dev->coherent_dma_mask = DMA_BIT_MASK(64); 377 card->dev->coherent_dma_mask = DMA_BIT_MASK(64);
376 378
377 if (dai->playback.channels_min) { 379 if (dai->driver->playback.channels_min) {
378 ret = omap_pcm_preallocate_dma_buffer(pcm, 380 ret = omap_pcm_preallocate_dma_buffer(pcm,
379 SNDRV_PCM_STREAM_PLAYBACK); 381 SNDRV_PCM_STREAM_PLAYBACK);
380 if (ret) 382 if (ret)
381 goto out; 383 goto out;
382 } 384 }
383 385
384 if (dai->capture.channels_min) { 386 if (dai->driver->capture.channels_min) {
385 ret = omap_pcm_preallocate_dma_buffer(pcm, 387 ret = omap_pcm_preallocate_dma_buffer(pcm,
386 SNDRV_PCM_STREAM_CAPTURE); 388 SNDRV_PCM_STREAM_CAPTURE);
387 if (ret) 389 if (ret)
@@ -392,25 +394,45 @@ out:
392 return ret; 394 return ret;
393} 395}
394 396
395struct snd_soc_platform omap_soc_platform = { 397static struct snd_soc_platform_driver omap_soc_platform = {
396 .name = "omap-pcm-audio", 398 .ops = &omap_pcm_ops,
397 .pcm_ops = &omap_pcm_ops,
398 .pcm_new = omap_pcm_new, 399 .pcm_new = omap_pcm_new,
399 .pcm_free = omap_pcm_free_dma_buffers, 400 .pcm_free = omap_pcm_free_dma_buffers,
400}; 401};
401EXPORT_SYMBOL_GPL(omap_soc_platform);
402 402
403static int __init omap_soc_platform_init(void) 403static __devinit int omap_pcm_probe(struct platform_device *pdev)
404{
405 return snd_soc_register_platform(&pdev->dev,
406 &omap_soc_platform);
407}
408
409static int __devexit omap_pcm_remove(struct platform_device *pdev)
410{
411 snd_soc_unregister_platform(&pdev->dev);
412 return 0;
413}
414
415static struct platform_driver omap_pcm_driver = {
416 .driver = {
417 .name = "omap-pcm-audio",
418 .owner = THIS_MODULE,
419 },
420
421 .probe = omap_pcm_probe,
422 .remove = __devexit_p(omap_pcm_remove),
423};
424
425static int __init snd_omap_pcm_init(void)
404{ 426{
405 return snd_soc_register_platform(&omap_soc_platform); 427 return platform_driver_register(&omap_pcm_driver);
406} 428}
407module_init(omap_soc_platform_init); 429module_init(snd_omap_pcm_init);
408 430
409static void __exit omap_soc_platform_exit(void) 431static void __exit snd_omap_pcm_exit(void)
410{ 432{
411 snd_soc_unregister_platform(&omap_soc_platform); 433 platform_driver_unregister(&omap_pcm_driver);
412} 434}
413module_exit(omap_soc_platform_exit); 435module_exit(snd_omap_pcm_exit);
414 436
415MODULE_AUTHOR("Jarkko Nikula <jhnikula@gmail.com>"); 437MODULE_AUTHOR("Jarkko Nikula <jhnikula@gmail.com>");
416MODULE_DESCRIPTION("OMAP PCM DMA module"); 438MODULE_DESCRIPTION("OMAP PCM DMA module");
diff --git a/sound/soc/omap/omap-pcm.h b/sound/soc/omap/omap-pcm.h
index b19975d26907..a0ed1dbb52d6 100644
--- a/sound/soc/omap/omap-pcm.h
+++ b/sound/soc/omap/omap-pcm.h
@@ -4,7 +4,7 @@
4 * Copyright (C) 2008 Nokia Corporation 4 * Copyright (C) 2008 Nokia Corporation
5 * 5 *
6 * Contact: Jarkko Nikula <jhnikula@gmail.com> 6 * Contact: Jarkko Nikula <jhnikula@gmail.com>
7 * Peter Ujfalusi <peter.ujfalusi@nokia.com> 7 * Peter Ujfalusi <peter.ujfalusi@ti.com>
8 * 8 *
9 * This program is free software; you can redistribute it and/or 9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License 10 * modify it under the terms of the GNU General Public License
@@ -35,6 +35,4 @@ struct omap_pcm_dma_data {
35 int packet_size; /* packet size only in PACKET mode */ 35 int packet_size; /* packet size only in PACKET mode */
36}; 36};
37 37
38extern struct snd_soc_platform omap_soc_platform;
39
40#endif 38#endif
diff --git a/sound/soc/omap/omap2evm.c b/sound/soc/omap/omap2evm.c
deleted file mode 100644
index c7adea38274c..000000000000
--- a/sound/soc/omap/omap2evm.c
+++ /dev/null
@@ -1,151 +0,0 @@
1/*
2 * omap2evm.c -- SoC audio machine driver for omap2evm board
3 *
4 * Author: Arun KS <arunks@mistralsolutions.com>
5 *
6 * Based on sound/soc/omap/overo.c by Steve Sakoman
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * version 2 as published by the Free Software Foundation.
11 *
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20 * 02110-1301 USA
21 *
22 */
23
24#include <linux/clk.h>
25#include <linux/platform_device.h>
26#include <sound/core.h>
27#include <sound/pcm.h>
28#include <sound/soc.h>
29#include <sound/soc-dapm.h>
30
31#include <asm/mach-types.h>
32#include <mach/hardware.h>
33#include <mach/gpio.h>
34#include <plat/mcbsp.h>
35
36#include "omap-mcbsp.h"
37#include "omap-pcm.h"
38#include "../codecs/twl4030.h"
39
40static int omap2evm_hw_params(struct snd_pcm_substream *substream,
41 struct snd_pcm_hw_params *params,
42 struct snd_soc_dai *dai)
43{
44 struct snd_soc_pcm_runtime *rtd = substream->private_data;
45 struct snd_soc_dai *codec_dai = rtd->dai->codec_dai;
46 struct snd_soc_dai *cpu_dai = rtd->dai->cpu_dai;
47 int ret;
48
49 /* Set codec DAI configuration */
50 ret = snd_soc_dai_set_fmt(codec_dai,
51 SND_SOC_DAIFMT_I2S |
52 SND_SOC_DAIFMT_NB_NF |
53 SND_SOC_DAIFMT_CBM_CFM);
54 if (ret < 0) {
55 printk(KERN_ERR "can't set codec DAI configuration\n");
56 return ret;
57 }
58
59 /* Set cpu DAI configuration */
60 ret = snd_soc_dai_set_fmt(cpu_dai,
61 SND_SOC_DAIFMT_I2S |
62 SND_SOC_DAIFMT_NB_NF |
63 SND_SOC_DAIFMT_CBM_CFM);
64 if (ret < 0) {
65 printk(KERN_ERR "can't set cpu DAI configuration\n");
66 return ret;
67 }
68
69 /* Set the codec system clock for DAC and ADC */
70 ret = snd_soc_dai_set_sysclk(codec_dai, 0, 26000000,
71 SND_SOC_CLOCK_IN);
72 if (ret < 0) {
73 printk(KERN_ERR "can't set codec system clock\n");
74 return ret;
75 }
76
77 return 0;
78}
79
80static struct snd_soc_ops omap2evm_ops = {
81 .hw_params = omap2evm_hw_params,
82};
83
84/* Digital audio interface glue - connects codec <--> CPU */
85static struct snd_soc_dai_link omap2evm_dai = {
86 .name = "TWL4030",
87 .stream_name = "TWL4030",
88 .cpu_dai = &omap_mcbsp_dai[0],
89 .codec_dai = &twl4030_dai[TWL4030_DAI_HIFI],
90 .ops = &omap2evm_ops,
91};
92
93/* Audio machine driver */
94static struct snd_soc_card snd_soc_omap2evm = {
95 .name = "omap2evm",
96 .platform = &omap_soc_platform,
97 .dai_link = &omap2evm_dai,
98 .num_links = 1,
99};
100
101/* Audio subsystem */
102static struct snd_soc_device omap2evm_snd_devdata = {
103 .card = &snd_soc_omap2evm,
104 .codec_dev = &soc_codec_dev_twl4030,
105};
106
107static struct platform_device *omap2evm_snd_device;
108
109static int __init omap2evm_soc_init(void)
110{
111 int ret;
112
113 if (!machine_is_omap2evm()) {
114 pr_debug("Not omap2evm!\n");
115 return -ENODEV;
116 }
117 printk(KERN_INFO "omap2evm SoC init\n");
118
119 omap2evm_snd_device = platform_device_alloc("soc-audio", -1);
120 if (!omap2evm_snd_device) {
121 printk(KERN_ERR "Platform device allocation failed\n");
122 return -ENOMEM;
123 }
124
125 platform_set_drvdata(omap2evm_snd_device, &omap2evm_snd_devdata);
126 omap2evm_snd_devdata.dev = &omap2evm_snd_device->dev;
127 *(unsigned int *)omap2evm_dai.cpu_dai->private_data = 1; /* McBSP2 */
128
129 ret = platform_device_add(omap2evm_snd_device);
130 if (ret)
131 goto err1;
132
133 return 0;
134
135err1:
136 printk(KERN_ERR "Unable to add platform device\n");
137 platform_device_put(omap2evm_snd_device);
138
139 return ret;
140}
141module_init(omap2evm_soc_init);
142
143static void __exit omap2evm_soc_exit(void)
144{
145 platform_device_unregister(omap2evm_snd_device);
146}
147module_exit(omap2evm_soc_exit);
148
149MODULE_AUTHOR("Arun KS <arunks@mistralsolutions.com>");
150MODULE_DESCRIPTION("ALSA SoC omap2evm");
151MODULE_LICENSE("GPL");
diff --git a/sound/soc/omap/omap3beagle.c b/sound/soc/omap/omap3beagle.c
index 240e0975dd6a..40db813c0795 100644
--- a/sound/soc/omap/omap3beagle.c
+++ b/sound/soc/omap/omap3beagle.c
@@ -24,7 +24,6 @@
24#include <sound/core.h> 24#include <sound/core.h>
25#include <sound/pcm.h> 25#include <sound/pcm.h>
26#include <sound/soc.h> 26#include <sound/soc.h>
27#include <sound/soc-dapm.h>
28 27
29#include <asm/mach-types.h> 28#include <asm/mach-types.h>
30#include <mach/hardware.h> 29#include <mach/hardware.h>
@@ -33,14 +32,13 @@
33 32
34#include "omap-mcbsp.h" 33#include "omap-mcbsp.h"
35#include "omap-pcm.h" 34#include "omap-pcm.h"
36#include "../codecs/twl4030.h"
37 35
38static int omap3beagle_hw_params(struct snd_pcm_substream *substream, 36static int omap3beagle_hw_params(struct snd_pcm_substream *substream,
39 struct snd_pcm_hw_params *params) 37 struct snd_pcm_hw_params *params)
40{ 38{
41 struct snd_soc_pcm_runtime *rtd = substream->private_data; 39 struct snd_soc_pcm_runtime *rtd = substream->private_data;
42 struct snd_soc_dai *codec_dai = rtd->dai->codec_dai; 40 struct snd_soc_dai *codec_dai = rtd->codec_dai;
43 struct snd_soc_dai *cpu_dai = rtd->dai->cpu_dai; 41 struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
44 unsigned int fmt; 42 unsigned int fmt;
45 int ret; 43 int ret;
46 44
@@ -92,35 +90,29 @@ static struct snd_soc_ops omap3beagle_ops = {
92static struct snd_soc_dai_link omap3beagle_dai = { 90static struct snd_soc_dai_link omap3beagle_dai = {
93 .name = "TWL4030", 91 .name = "TWL4030",
94 .stream_name = "TWL4030", 92 .stream_name = "TWL4030",
95 .cpu_dai = &omap_mcbsp_dai[0], 93 .cpu_dai_name = "omap-mcbsp-dai.1",
96 .codec_dai = &twl4030_dai[TWL4030_DAI_HIFI], 94 .platform_name = "omap-pcm-audio",
95 .codec_dai_name = "twl4030-hifi",
96 .codec_name = "twl4030-codec",
97 .ops = &omap3beagle_ops, 97 .ops = &omap3beagle_ops,
98}; 98};
99 99
100/* Audio machine driver */ 100/* Audio machine driver */
101static struct snd_soc_card snd_soc_omap3beagle = { 101static struct snd_soc_card snd_soc_omap3beagle = {
102 .name = "omap3beagle", 102 .name = "omap3beagle",
103 .platform = &omap_soc_platform, 103 .owner = THIS_MODULE,
104 .dai_link = &omap3beagle_dai, 104 .dai_link = &omap3beagle_dai,
105 .num_links = 1, 105 .num_links = 1,
106}; 106};
107 107
108/* Audio subsystem */
109static struct snd_soc_device omap3beagle_snd_devdata = {
110 .card = &snd_soc_omap3beagle,
111 .codec_dev = &soc_codec_dev_twl4030,
112};
113
114static struct platform_device *omap3beagle_snd_device; 108static struct platform_device *omap3beagle_snd_device;
115 109
116static int __init omap3beagle_soc_init(void) 110static int __init omap3beagle_soc_init(void)
117{ 111{
118 int ret; 112 int ret;
119 113
120 if (!(machine_is_omap3_beagle() || machine_is_devkit8000())) { 114 if (!(machine_is_omap3_beagle() || machine_is_devkit8000()))
121 pr_debug("Not OMAP3 Beagle or Devkit8000!\n");
122 return -ENODEV; 115 return -ENODEV;
123 }
124 pr_info("OMAP3 Beagle/Devkit8000 SoC init\n"); 116 pr_info("OMAP3 Beagle/Devkit8000 SoC init\n");
125 117
126 omap3beagle_snd_device = platform_device_alloc("soc-audio", -1); 118 omap3beagle_snd_device = platform_device_alloc("soc-audio", -1);
@@ -129,9 +121,7 @@ static int __init omap3beagle_soc_init(void)
129 return -ENOMEM; 121 return -ENOMEM;
130 } 122 }
131 123
132 platform_set_drvdata(omap3beagle_snd_device, &omap3beagle_snd_devdata); 124 platform_set_drvdata(omap3beagle_snd_device, &snd_soc_omap3beagle);
133 omap3beagle_snd_devdata.dev = &omap3beagle_snd_device->dev;
134 *(unsigned int *)omap3beagle_dai.cpu_dai->private_data = 1; /* McBSP2 */
135 125
136 ret = platform_device_add(omap3beagle_snd_device); 126 ret = platform_device_add(omap3beagle_snd_device);
137 if (ret) 127 if (ret)
diff --git a/sound/soc/omap/omap3evm.c b/sound/soc/omap/omap3evm.c
index dfcb344092e4..0daa04469836 100644
--- a/sound/soc/omap/omap3evm.c
+++ b/sound/soc/omap/omap3evm.c
@@ -22,7 +22,6 @@
22#include <sound/core.h> 22#include <sound/core.h>
23#include <sound/pcm.h> 23#include <sound/pcm.h>
24#include <sound/soc.h> 24#include <sound/soc.h>
25#include <sound/soc-dapm.h>
26 25
27#include <asm/mach-types.h> 26#include <asm/mach-types.h>
28#include <mach/hardware.h> 27#include <mach/hardware.h>
@@ -31,14 +30,13 @@
31 30
32#include "omap-mcbsp.h" 31#include "omap-mcbsp.h"
33#include "omap-pcm.h" 32#include "omap-pcm.h"
34#include "../codecs/twl4030.h"
35 33
36static int omap3evm_hw_params(struct snd_pcm_substream *substream, 34static int omap3evm_hw_params(struct snd_pcm_substream *substream,
37 struct snd_pcm_hw_params *params) 35 struct snd_pcm_hw_params *params)
38{ 36{
39 struct snd_soc_pcm_runtime *rtd = substream->private_data; 37 struct snd_soc_pcm_runtime *rtd = substream->private_data;
40 struct snd_soc_dai *codec_dai = rtd->dai->codec_dai; 38 struct snd_soc_dai *codec_dai = rtd->codec_dai;
41 struct snd_soc_dai *cpu_dai = rtd->dai->cpu_dai; 39 struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
42 int ret; 40 int ret;
43 41
44 /* Set codec DAI configuration */ 42 /* Set codec DAI configuration */
@@ -80,42 +78,28 @@ static struct snd_soc_ops omap3evm_ops = {
80static struct snd_soc_dai_link omap3evm_dai = { 78static struct snd_soc_dai_link omap3evm_dai = {
81 .name = "TWL4030", 79 .name = "TWL4030",
82 .stream_name = "TWL4030", 80 .stream_name = "TWL4030",
83 .cpu_dai = &omap_mcbsp_dai[0], 81 .cpu_dai_name = "omap-mcbsp-dai.1",
84 .codec_dai = &twl4030_dai[TWL4030_DAI_HIFI], 82 .codec_dai_name = "twl4030-hifi",
83 .platform_name = "omap-pcm-audio",
84 .codec_name = "twl4030-codec",
85 .ops = &omap3evm_ops, 85 .ops = &omap3evm_ops,
86}; 86};
87 87
88/* Audio machine driver */ 88/* Audio machine driver */
89static struct snd_soc_card snd_soc_omap3evm = { 89static struct snd_soc_card snd_soc_omap3evm = {
90 .name = "omap3evm", 90 .name = "omap3evm",
91 .platform = &omap_soc_platform,
92 .dai_link = &omap3evm_dai, 91 .dai_link = &omap3evm_dai,
93 .num_links = 1, 92 .num_links = 1,
94}; 93};
95 94
96/* twl4030 setup */
97static struct twl4030_setup_data twl4030_setup = {
98 .ramp_delay_value = 4,
99 .sysclk = 26000,
100};
101
102/* Audio subsystem */
103static struct snd_soc_device omap3evm_snd_devdata = {
104 .card = &snd_soc_omap3evm,
105 .codec_dev = &soc_codec_dev_twl4030,
106 .codec_data = &twl4030_setup,
107};
108
109static struct platform_device *omap3evm_snd_device; 95static struct platform_device *omap3evm_snd_device;
110 96
111static int __init omap3evm_soc_init(void) 97static int __init omap3evm_soc_init(void)
112{ 98{
113 int ret; 99 int ret;
114 100
115 if (!machine_is_omap3evm()) { 101 if (!machine_is_omap3evm())
116 pr_err("Not OMAP3 EVM!\n");
117 return -ENODEV; 102 return -ENODEV;
118 }
119 pr_info("OMAP3 EVM SoC init\n"); 103 pr_info("OMAP3 EVM SoC init\n");
120 104
121 omap3evm_snd_device = platform_device_alloc("soc-audio", -1); 105 omap3evm_snd_device = platform_device_alloc("soc-audio", -1);
@@ -124,10 +108,7 @@ static int __init omap3evm_soc_init(void)
124 return -ENOMEM; 108 return -ENOMEM;
125 } 109 }
126 110
127 platform_set_drvdata(omap3evm_snd_device, &omap3evm_snd_devdata); 111 platform_set_drvdata(omap3evm_snd_device, &snd_soc_omap3evm);
128 omap3evm_snd_devdata.dev = &omap3evm_snd_device->dev;
129 *(unsigned int *)omap3evm_dai.cpu_dai->private_data = 1;
130
131 ret = platform_device_add(omap3evm_snd_device); 112 ret = platform_device_add(omap3evm_snd_device);
132 if (ret) 113 if (ret)
133 goto err1; 114 goto err1;
diff --git a/sound/soc/omap/omap3pandora.c b/sound/soc/omap/omap3pandora.c
index 9eecac135bbb..8047c521e318 100644
--- a/sound/soc/omap/omap3pandora.c
+++ b/sound/soc/omap/omap3pandora.c
@@ -28,13 +28,12 @@
28#include <sound/core.h> 28#include <sound/core.h>
29#include <sound/pcm.h> 29#include <sound/pcm.h>
30#include <sound/soc.h> 30#include <sound/soc.h>
31#include <sound/soc-dapm.h>
32 31
33#include <asm/mach-types.h> 32#include <asm/mach-types.h>
33#include <plat/mcbsp.h>
34 34
35#include "omap-mcbsp.h" 35#include "omap-mcbsp.h"
36#include "omap-pcm.h" 36#include "omap-pcm.h"
37#include "../codecs/twl4030.h"
38 37
39#define OMAP3_PANDORA_DAC_POWER_GPIO 118 38#define OMAP3_PANDORA_DAC_POWER_GPIO 118
40#define OMAP3_PANDORA_AMP_POWER_GPIO 14 39#define OMAP3_PANDORA_AMP_POWER_GPIO 14
@@ -47,8 +46,8 @@ static int omap3pandora_hw_params(struct snd_pcm_substream *substream,
47 struct snd_pcm_hw_params *params) 46 struct snd_pcm_hw_params *params)
48{ 47{
49 struct snd_soc_pcm_runtime *rtd = substream->private_data; 48 struct snd_soc_pcm_runtime *rtd = substream->private_data;
50 struct snd_soc_dai *codec_dai = rtd->dai->codec_dai; 49 struct snd_soc_dai *codec_dai = rtd->codec_dai;
51 struct snd_soc_dai *cpu_dai = rtd->dai->cpu_dai; 50 struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
52 int fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF | 51 int fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF |
53 SND_SOC_DAIFMT_CBS_CFS; 52 SND_SOC_DAIFMT_CBS_CFS;
54 int ret; 53 int ret;
@@ -167,52 +166,56 @@ static const struct snd_soc_dapm_route omap3pandora_in_map[] = {
167 {"Mic Bias 2", NULL, "Mic (external)"}, 166 {"Mic Bias 2", NULL, "Mic (external)"},
168}; 167};
169 168
170static int omap3pandora_out_init(struct snd_soc_codec *codec) 169static int omap3pandora_out_init(struct snd_soc_pcm_runtime *rtd)
171{ 170{
171 struct snd_soc_codec *codec = rtd->codec;
172 struct snd_soc_dapm_context *dapm = &codec->dapm;
172 int ret; 173 int ret;
173 174
174 /* All TWL4030 output pins are floating */ 175 /* All TWL4030 output pins are floating */
175 snd_soc_dapm_nc_pin(codec, "EARPIECE"); 176 snd_soc_dapm_nc_pin(dapm, "EARPIECE");
176 snd_soc_dapm_nc_pin(codec, "PREDRIVEL"); 177 snd_soc_dapm_nc_pin(dapm, "PREDRIVEL");
177 snd_soc_dapm_nc_pin(codec, "PREDRIVER"); 178 snd_soc_dapm_nc_pin(dapm, "PREDRIVER");
178 snd_soc_dapm_nc_pin(codec, "HSOL"); 179 snd_soc_dapm_nc_pin(dapm, "HSOL");
179 snd_soc_dapm_nc_pin(codec, "HSOR"); 180 snd_soc_dapm_nc_pin(dapm, "HSOR");
180 snd_soc_dapm_nc_pin(codec, "CARKITL"); 181 snd_soc_dapm_nc_pin(dapm, "CARKITL");
181 snd_soc_dapm_nc_pin(codec, "CARKITR"); 182 snd_soc_dapm_nc_pin(dapm, "CARKITR");
182 snd_soc_dapm_nc_pin(codec, "HFL"); 183 snd_soc_dapm_nc_pin(dapm, "HFL");
183 snd_soc_dapm_nc_pin(codec, "HFR"); 184 snd_soc_dapm_nc_pin(dapm, "HFR");
184 snd_soc_dapm_nc_pin(codec, "VIBRA"); 185 snd_soc_dapm_nc_pin(dapm, "VIBRA");
185 186
186 ret = snd_soc_dapm_new_controls(codec, omap3pandora_out_dapm_widgets, 187 ret = snd_soc_dapm_new_controls(dapm, omap3pandora_out_dapm_widgets,
187 ARRAY_SIZE(omap3pandora_out_dapm_widgets)); 188 ARRAY_SIZE(omap3pandora_out_dapm_widgets));
188 if (ret < 0) 189 if (ret < 0)
189 return ret; 190 return ret;
190 191
191 snd_soc_dapm_add_routes(codec, omap3pandora_out_map, 192 snd_soc_dapm_add_routes(dapm, omap3pandora_out_map,
192 ARRAY_SIZE(omap3pandora_out_map)); 193 ARRAY_SIZE(omap3pandora_out_map));
193 194
194 return snd_soc_dapm_sync(codec); 195 return snd_soc_dapm_sync(dapm);
195} 196}
196 197
197static int omap3pandora_in_init(struct snd_soc_codec *codec) 198static int omap3pandora_in_init(struct snd_soc_pcm_runtime *rtd)
198{ 199{
200 struct snd_soc_codec *codec = rtd->codec;
201 struct snd_soc_dapm_context *dapm = &codec->dapm;
199 int ret; 202 int ret;
200 203
201 /* Not comnnected */ 204 /* Not comnnected */
202 snd_soc_dapm_nc_pin(codec, "HSMIC"); 205 snd_soc_dapm_nc_pin(dapm, "HSMIC");
203 snd_soc_dapm_nc_pin(codec, "CARKITMIC"); 206 snd_soc_dapm_nc_pin(dapm, "CARKITMIC");
204 snd_soc_dapm_nc_pin(codec, "DIGIMIC0"); 207 snd_soc_dapm_nc_pin(dapm, "DIGIMIC0");
205 snd_soc_dapm_nc_pin(codec, "DIGIMIC1"); 208 snd_soc_dapm_nc_pin(dapm, "DIGIMIC1");
206 209
207 ret = snd_soc_dapm_new_controls(codec, omap3pandora_in_dapm_widgets, 210 ret = snd_soc_dapm_new_controls(dapm, omap3pandora_in_dapm_widgets,
208 ARRAY_SIZE(omap3pandora_in_dapm_widgets)); 211 ARRAY_SIZE(omap3pandora_in_dapm_widgets));
209 if (ret < 0) 212 if (ret < 0)
210 return ret; 213 return ret;
211 214
212 snd_soc_dapm_add_routes(codec, omap3pandora_in_map, 215 snd_soc_dapm_add_routes(dapm, omap3pandora_in_map,
213 ARRAY_SIZE(omap3pandora_in_map)); 216 ARRAY_SIZE(omap3pandora_in_map));
214 217
215 return snd_soc_dapm_sync(codec); 218 return snd_soc_dapm_sync(dapm);
216} 219}
217 220
218static struct snd_soc_ops omap3pandora_ops = { 221static struct snd_soc_ops omap3pandora_ops = {
@@ -224,15 +227,19 @@ static struct snd_soc_dai_link omap3pandora_dai[] = {
224 { 227 {
225 .name = "PCM1773", 228 .name = "PCM1773",
226 .stream_name = "HiFi Out", 229 .stream_name = "HiFi Out",
227 .cpu_dai = &omap_mcbsp_dai[0], 230 .cpu_dai_name = "omap-mcbsp-dai.1",
228 .codec_dai = &twl4030_dai[TWL4030_DAI_HIFI], 231 .codec_dai_name = "twl4030-hifi",
232 .platform_name = "omap-pcm-audio",
233 .codec_name = "twl4030-codec",
229 .ops = &omap3pandora_ops, 234 .ops = &omap3pandora_ops,
230 .init = omap3pandora_out_init, 235 .init = omap3pandora_out_init,
231 }, { 236 }, {
232 .name = "TWL4030", 237 .name = "TWL4030",
233 .stream_name = "Line/Mic In", 238 .stream_name = "Line/Mic In",
234 .cpu_dai = &omap_mcbsp_dai[1], 239 .cpu_dai_name = "omap-mcbsp-dai.3",
235 .codec_dai = &twl4030_dai[TWL4030_DAI_HIFI], 240 .codec_dai_name = "twl4030-hifi",
241 .platform_name = "omap-pcm-audio",
242 .codec_name = "twl4030-codec",
236 .ops = &omap3pandora_ops, 243 .ops = &omap3pandora_ops,
237 .init = omap3pandora_in_init, 244 .init = omap3pandora_in_init,
238 } 245 }
@@ -241,17 +248,10 @@ static struct snd_soc_dai_link omap3pandora_dai[] = {
241/* SoC card */ 248/* SoC card */
242static struct snd_soc_card snd_soc_card_omap3pandora = { 249static struct snd_soc_card snd_soc_card_omap3pandora = {
243 .name = "omap3pandora", 250 .name = "omap3pandora",
244 .platform = &omap_soc_platform,
245 .dai_link = omap3pandora_dai, 251 .dai_link = omap3pandora_dai,
246 .num_links = ARRAY_SIZE(omap3pandora_dai), 252 .num_links = ARRAY_SIZE(omap3pandora_dai),
247}; 253};
248 254
249/* Audio subsystem */
250static struct snd_soc_device omap3pandora_snd_data = {
251 .card = &snd_soc_card_omap3pandora,
252 .codec_dev = &soc_codec_dev_twl4030,
253};
254
255static struct platform_device *omap3pandora_snd_device; 255static struct platform_device *omap3pandora_snd_device;
256 256
257static int __init omap3pandora_soc_init(void) 257static int __init omap3pandora_soc_init(void)
@@ -294,10 +294,7 @@ static int __init omap3pandora_soc_init(void)
294 goto fail1; 294 goto fail1;
295 } 295 }
296 296
297 platform_set_drvdata(omap3pandora_snd_device, &omap3pandora_snd_data); 297 platform_set_drvdata(omap3pandora_snd_device, &snd_soc_card_omap3pandora);
298 omap3pandora_snd_data.dev = &omap3pandora_snd_device->dev;
299 *(unsigned int *)omap_mcbsp_dai[0].private_data = 1; /* McBSP2 */
300 *(unsigned int *)omap_mcbsp_dai[1].private_data = 3; /* McBSP4 */
301 298
302 ret = platform_device_add(omap3pandora_snd_device); 299 ret = platform_device_add(omap3pandora_snd_device);
303 if (ret) { 300 if (ret) {
@@ -310,6 +307,7 @@ static int __init omap3pandora_soc_init(void)
310 pr_err(PREFIX "Failed to get DAC regulator from %s: %ld\n", 307 pr_err(PREFIX "Failed to get DAC regulator from %s: %ld\n",
311 dev_name(&omap3pandora_snd_device->dev), 308 dev_name(&omap3pandora_snd_device->dev),
312 PTR_ERR(omap3pandora_dac_reg)); 309 PTR_ERR(omap3pandora_dac_reg));
310 ret = PTR_ERR(omap3pandora_dac_reg);
313 goto fail3; 311 goto fail3;
314 } 312 }
315 313
diff --git a/sound/soc/omap/osk5912.c b/sound/soc/omap/osk5912.c
index 498ca2e03519..7e75e775fb4a 100644
--- a/sound/soc/omap/osk5912.c
+++ b/sound/soc/omap/osk5912.c
@@ -26,7 +26,6 @@
26#include <sound/core.h> 26#include <sound/core.h>
27#include <sound/pcm.h> 27#include <sound/pcm.h>
28#include <sound/soc.h> 28#include <sound/soc.h>
29#include <sound/soc-dapm.h>
30 29
31#include <asm/mach-types.h> 30#include <asm/mach-types.h>
32#include <mach/hardware.h> 31#include <mach/hardware.h>
@@ -55,8 +54,8 @@ static int osk_hw_params(struct snd_pcm_substream *substream,
55 struct snd_pcm_hw_params *params) 54 struct snd_pcm_hw_params *params)
56{ 55{
57 struct snd_soc_pcm_runtime *rtd = substream->private_data; 56 struct snd_soc_pcm_runtime *rtd = substream->private_data;
58 struct snd_soc_dai *codec_dai = rtd->dai->codec_dai; 57 struct snd_soc_dai *codec_dai = rtd->codec_dai;
59 struct snd_soc_dai *cpu_dai = rtd->dai->cpu_dai; 58 struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
60 int err; 59 int err;
61 60
62 /* Set codec DAI configuration */ 61 /* Set codec DAI configuration */
@@ -113,21 +112,23 @@ static const struct snd_soc_dapm_route audio_map[] = {
113 {"MICIN", NULL, "Mic Jack"}, 112 {"MICIN", NULL, "Mic Jack"},
114}; 113};
115 114
116static int osk_tlv320aic23_init(struct snd_soc_codec *codec) 115static int osk_tlv320aic23_init(struct snd_soc_pcm_runtime *rtd)
117{ 116{
117 struct snd_soc_codec *codec = rtd->codec;
118 struct snd_soc_dapm_context *dapm = &codec->dapm;
118 119
119 /* Add osk5912 specific widgets */ 120 /* Add osk5912 specific widgets */
120 snd_soc_dapm_new_controls(codec, tlv320aic23_dapm_widgets, 121 snd_soc_dapm_new_controls(dapm, tlv320aic23_dapm_widgets,
121 ARRAY_SIZE(tlv320aic23_dapm_widgets)); 122 ARRAY_SIZE(tlv320aic23_dapm_widgets));
122 123
123 /* Set up osk5912 specific audio path audio_map */ 124 /* Set up osk5912 specific audio path audio_map */
124 snd_soc_dapm_add_routes(codec, audio_map, ARRAY_SIZE(audio_map)); 125 snd_soc_dapm_add_routes(dapm, audio_map, ARRAY_SIZE(audio_map));
125 126
126 snd_soc_dapm_enable_pin(codec, "Headphone Jack"); 127 snd_soc_dapm_enable_pin(dapm, "Headphone Jack");
127 snd_soc_dapm_enable_pin(codec, "Line In"); 128 snd_soc_dapm_enable_pin(dapm, "Line In");
128 snd_soc_dapm_enable_pin(codec, "Mic Jack"); 129 snd_soc_dapm_enable_pin(dapm, "Mic Jack");
129 130
130 snd_soc_dapm_sync(codec); 131 snd_soc_dapm_sync(dapm);
131 132
132 return 0; 133 return 0;
133} 134}
@@ -136,8 +137,10 @@ static int osk_tlv320aic23_init(struct snd_soc_codec *codec)
136static struct snd_soc_dai_link osk_dai = { 137static struct snd_soc_dai_link osk_dai = {
137 .name = "TLV320AIC23", 138 .name = "TLV320AIC23",
138 .stream_name = "AIC23", 139 .stream_name = "AIC23",
139 .cpu_dai = &omap_mcbsp_dai[0], 140 .cpu_dai_name = "omap-mcbsp-dai.0",
140 .codec_dai = &tlv320aic23_dai, 141 .codec_dai_name = "tlv320aic23-hifi",
142 .platform_name = "omap-pcm-audio",
143 .codec_name = "tlv320aic23-codec",
141 .init = osk_tlv320aic23_init, 144 .init = osk_tlv320aic23_init,
142 .ops = &osk_ops, 145 .ops = &osk_ops,
143}; 146};
@@ -145,17 +148,10 @@ static struct snd_soc_dai_link osk_dai = {
145/* Audio machine driver */ 148/* Audio machine driver */
146static struct snd_soc_card snd_soc_card_osk = { 149static struct snd_soc_card snd_soc_card_osk = {
147 .name = "OSK5912", 150 .name = "OSK5912",
148 .platform = &omap_soc_platform,
149 .dai_link = &osk_dai, 151 .dai_link = &osk_dai,
150 .num_links = 1, 152 .num_links = 1,
151}; 153};
152 154
153/* Audio subsystem */
154static struct snd_soc_device osk_snd_devdata = {
155 .card = &snd_soc_card_osk,
156 .codec_dev = &soc_codec_dev_tlv320aic23,
157};
158
159static struct platform_device *osk_snd_device; 155static struct platform_device *osk_snd_device;
160 156
161static int __init osk_soc_init(void) 157static int __init osk_soc_init(void)
@@ -171,9 +167,7 @@ static int __init osk_soc_init(void)
171 if (!osk_snd_device) 167 if (!osk_snd_device)
172 return -ENOMEM; 168 return -ENOMEM;
173 169
174 platform_set_drvdata(osk_snd_device, &osk_snd_devdata); 170 platform_set_drvdata(osk_snd_device, &snd_soc_card_osk);
175 osk_snd_devdata.dev = &osk_snd_device->dev;
176 *(unsigned int *)osk_dai.cpu_dai->private_data = 0; /* McBSP1 */
177 err = platform_device_add(osk_snd_device); 171 err = platform_device_add(osk_snd_device);
178 if (err) 172 if (err)
179 goto err1; 173 goto err1;
@@ -183,7 +177,8 @@ static int __init osk_soc_init(void)
183 tlv320aic23_mclk = clk_get(dev, "mclk"); 177 tlv320aic23_mclk = clk_get(dev, "mclk");
184 if (IS_ERR(tlv320aic23_mclk)) { 178 if (IS_ERR(tlv320aic23_mclk)) {
185 printk(KERN_ERR "Could not get mclk clock\n"); 179 printk(KERN_ERR "Could not get mclk clock\n");
186 return -ENODEV; 180 err = PTR_ERR(tlv320aic23_mclk);
181 goto err2;
187 } 182 }
188 183
189 /* 184 /*
@@ -194,7 +189,7 @@ static int __init osk_soc_init(void)
194 if (clk_set_rate(tlv320aic23_mclk, CODEC_CLOCK)) { 189 if (clk_set_rate(tlv320aic23_mclk, CODEC_CLOCK)) {
195 printk(KERN_ERR "Cannot set MCLK for AIC23 CODEC\n"); 190 printk(KERN_ERR "Cannot set MCLK for AIC23 CODEC\n");
196 err = -ECANCELED; 191 err = -ECANCELED;
197 goto err1; 192 goto err3;
198 } 193 }
199 } 194 }
200 195
@@ -202,9 +197,12 @@ static int __init osk_soc_init(void)
202 (uint) clk_get_rate(tlv320aic23_mclk), CODEC_CLOCK); 197 (uint) clk_get_rate(tlv320aic23_mclk), CODEC_CLOCK);
203 198
204 return 0; 199 return 0;
205err1: 200
201err3:
206 clk_put(tlv320aic23_mclk); 202 clk_put(tlv320aic23_mclk);
203err2:
207 platform_device_del(osk_snd_device); 204 platform_device_del(osk_snd_device);
205err1:
208 platform_device_put(osk_snd_device); 206 platform_device_put(osk_snd_device);
209 207
210 return err; 208 return err;
@@ -213,6 +211,7 @@ err1:
213 211
214static void __exit osk_soc_exit(void) 212static void __exit osk_soc_exit(void)
215{ 213{
214 clk_put(tlv320aic23_mclk);
216 platform_device_unregister(osk_snd_device); 215 platform_device_unregister(osk_snd_device);
217} 216}
218 217
diff --git a/sound/soc/omap/overo.c b/sound/soc/omap/overo.c
index c25f5276ad6f..bbcf380bfb56 100644
--- a/sound/soc/omap/overo.c
+++ b/sound/soc/omap/overo.c
@@ -24,7 +24,6 @@
24#include <sound/core.h> 24#include <sound/core.h>
25#include <sound/pcm.h> 25#include <sound/pcm.h>
26#include <sound/soc.h> 26#include <sound/soc.h>
27#include <sound/soc-dapm.h>
28 27
29#include <asm/mach-types.h> 28#include <asm/mach-types.h>
30#include <mach/hardware.h> 29#include <mach/hardware.h>
@@ -33,14 +32,13 @@
33 32
34#include "omap-mcbsp.h" 33#include "omap-mcbsp.h"
35#include "omap-pcm.h" 34#include "omap-pcm.h"
36#include "../codecs/twl4030.h"
37 35
38static int overo_hw_params(struct snd_pcm_substream *substream, 36static int overo_hw_params(struct snd_pcm_substream *substream,
39 struct snd_pcm_hw_params *params) 37 struct snd_pcm_hw_params *params)
40{ 38{
41 struct snd_soc_pcm_runtime *rtd = substream->private_data; 39 struct snd_soc_pcm_runtime *rtd = substream->private_data;
42 struct snd_soc_dai *codec_dai = rtd->dai->codec_dai; 40 struct snd_soc_dai *codec_dai = rtd->codec_dai;
43 struct snd_soc_dai *cpu_dai = rtd->dai->cpu_dai; 41 struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
44 int ret; 42 int ret;
45 43
46 /* Set codec DAI configuration */ 44 /* Set codec DAI configuration */
@@ -82,25 +80,20 @@ static struct snd_soc_ops overo_ops = {
82static struct snd_soc_dai_link overo_dai = { 80static struct snd_soc_dai_link overo_dai = {
83 .name = "TWL4030", 81 .name = "TWL4030",
84 .stream_name = "TWL4030", 82 .stream_name = "TWL4030",
85 .cpu_dai = &omap_mcbsp_dai[0], 83 .cpu_dai_name = "omap-mcbsp-dai.1",
86 .codec_dai = &twl4030_dai[TWL4030_DAI_HIFI], 84 .codec_dai_name = "twl4030-hifi",
85 .platform_name = "omap-pcm-audio",
86 .codec_name = "twl4030-codec",
87 .ops = &overo_ops, 87 .ops = &overo_ops,
88}; 88};
89 89
90/* Audio machine driver */ 90/* Audio machine driver */
91static struct snd_soc_card snd_soc_card_overo = { 91static struct snd_soc_card snd_soc_card_overo = {
92 .name = "overo", 92 .name = "overo",
93 .platform = &omap_soc_platform,
94 .dai_link = &overo_dai, 93 .dai_link = &overo_dai,
95 .num_links = 1, 94 .num_links = 1,
96}; 95};
97 96
98/* Audio subsystem */
99static struct snd_soc_device overo_snd_devdata = {
100 .card = &snd_soc_card_overo,
101 .codec_dev = &soc_codec_dev_twl4030,
102};
103
104static struct platform_device *overo_snd_device; 97static struct platform_device *overo_snd_device;
105 98
106static int __init overo_soc_init(void) 99static int __init overo_soc_init(void)
@@ -119,9 +112,7 @@ static int __init overo_soc_init(void)
119 return -ENOMEM; 112 return -ENOMEM;
120 } 113 }
121 114
122 platform_set_drvdata(overo_snd_device, &overo_snd_devdata); 115 platform_set_drvdata(overo_snd_device, &snd_soc_card_overo);
123 overo_snd_devdata.dev = &overo_snd_device->dev;
124 *(unsigned int *)overo_dai.cpu_dai->private_data = 1; /* McBSP2 */
125 116
126 ret = platform_device_add(overo_snd_device); 117 ret = platform_device_add(overo_snd_device);
127 if (ret) 118 if (ret)
diff --git a/sound/soc/omap/rx51.c b/sound/soc/omap/rx51.c
index 88052d29617f..0aae998b6540 100644
--- a/sound/soc/omap/rx51.c
+++ b/sound/soc/omap/rx51.c
@@ -3,7 +3,7 @@
3 * 3 *
4 * Copyright (C) 2008 - 2009 Nokia Corporation 4 * Copyright (C) 2008 - 2009 Nokia Corporation
5 * 5 *
6 * Contact: Peter Ujfalusi <peter.ujfalusi@nokia.com> 6 * Contact: Peter Ujfalusi <peter.ujfalusi@ti.com>
7 * Eduardo Valentin <eduardo.valentin@nokia.com> 7 * Eduardo Valentin <eduardo.valentin@nokia.com>
8 * Jarkko Nikula <jhnikula@gmail.com> 8 * Jarkko Nikula <jhnikula@gmail.com>
9 * 9 *
@@ -30,16 +30,17 @@
30#include <sound/jack.h> 30#include <sound/jack.h>
31#include <sound/pcm.h> 31#include <sound/pcm.h>
32#include <sound/soc.h> 32#include <sound/soc.h>
33#include <sound/soc-dapm.h> 33#include <plat/mcbsp.h>
34#include "../codecs/tpa6130a2.h"
34 35
35#include <asm/mach-types.h> 36#include <asm/mach-types.h>
36 37
37#include "omap-mcbsp.h" 38#include "omap-mcbsp.h"
38#include "omap-pcm.h" 39#include "omap-pcm.h"
39#include "../codecs/tlv320aic3x.h"
40 40
41#define RX51_TVOUT_SEL_GPIO 40 41#define RX51_TVOUT_SEL_GPIO 40
42#define RX51_JACK_DETECT_GPIO 177 42#define RX51_JACK_DETECT_GPIO 177
43#define RX51_ECI_SW_GPIO 182
43/* 44/*
44 * REVISIT: TWL4030 GPIO base in RX-51. Now statically defined to 192. This 45 * REVISIT: TWL4030 GPIO base in RX-51. Now statically defined to 192. This
45 * gpio is reserved in arch/arm/mach-omap2/board-rx51-peripherals.c 46 * gpio is reserved in arch/arm/mach-omap2/board-rx51-peripherals.c
@@ -48,7 +49,9 @@
48 49
49enum { 50enum {
50 RX51_JACK_DISABLED, 51 RX51_JACK_DISABLED,
51 RX51_JACK_TVOUT, /* tv-out */ 52 RX51_JACK_TVOUT, /* tv-out with stereo output */
53 RX51_JACK_HP, /* headphone: stereo output, no mic */
54 RX51_JACK_HS, /* headset: stereo output with mic */
52}; 55};
53 56
54static int rx51_spk_func; 57static int rx51_spk_func;
@@ -57,26 +60,48 @@ static int rx51_jack_func;
57 60
58static void rx51_ext_control(struct snd_soc_codec *codec) 61static void rx51_ext_control(struct snd_soc_codec *codec)
59{ 62{
63 struct snd_soc_dapm_context *dapm = &codec->dapm;
64 int hp = 0, hs = 0, tvout = 0;
65
66 switch (rx51_jack_func) {
67 case RX51_JACK_TVOUT:
68 tvout = 1;
69 hp = 1;
70 break;
71 case RX51_JACK_HS:
72 hs = 1;
73 case RX51_JACK_HP:
74 hp = 1;
75 break;
76 }
77
60 if (rx51_spk_func) 78 if (rx51_spk_func)
61 snd_soc_dapm_enable_pin(codec, "Ext Spk"); 79 snd_soc_dapm_enable_pin(dapm, "Ext Spk");
62 else 80 else
63 snd_soc_dapm_disable_pin(codec, "Ext Spk"); 81 snd_soc_dapm_disable_pin(dapm, "Ext Spk");
64 if (rx51_dmic_func) 82 if (rx51_dmic_func)
65 snd_soc_dapm_enable_pin(codec, "DMic"); 83 snd_soc_dapm_enable_pin(dapm, "DMic");
84 else
85 snd_soc_dapm_disable_pin(dapm, "DMic");
86 if (hp)
87 snd_soc_dapm_enable_pin(dapm, "Headphone Jack");
66 else 88 else
67 snd_soc_dapm_disable_pin(codec, "DMic"); 89 snd_soc_dapm_disable_pin(dapm, "Headphone Jack");
90 if (hs)
91 snd_soc_dapm_enable_pin(dapm, "HS Mic");
92 else
93 snd_soc_dapm_disable_pin(dapm, "HS Mic");
68 94
69 gpio_set_value(RX51_TVOUT_SEL_GPIO, 95 gpio_set_value(RX51_TVOUT_SEL_GPIO, tvout);
70 rx51_jack_func == RX51_JACK_TVOUT);
71 96
72 snd_soc_dapm_sync(codec); 97 snd_soc_dapm_sync(dapm);
73} 98}
74 99
75static int rx51_startup(struct snd_pcm_substream *substream) 100static int rx51_startup(struct snd_pcm_substream *substream)
76{ 101{
77 struct snd_pcm_runtime *runtime = substream->runtime; 102 struct snd_pcm_runtime *runtime = substream->runtime;
78 struct snd_soc_pcm_runtime *rtd = substream->private_data; 103 struct snd_soc_pcm_runtime *rtd = substream->private_data;
79 struct snd_soc_codec *codec = rtd->socdev->card->codec; 104 struct snd_soc_codec *codec = rtd->codec;
80 105
81 snd_pcm_hw_constraint_minmax(runtime, 106 snd_pcm_hw_constraint_minmax(runtime,
82 SNDRV_PCM_HW_PARAM_CHANNELS, 2, 2); 107 SNDRV_PCM_HW_PARAM_CHANNELS, 2, 2);
@@ -89,8 +114,8 @@ static int rx51_hw_params(struct snd_pcm_substream *substream,
89 struct snd_pcm_hw_params *params) 114 struct snd_pcm_hw_params *params)
90{ 115{
91 struct snd_soc_pcm_runtime *rtd = substream->private_data; 116 struct snd_soc_pcm_runtime *rtd = substream->private_data;
92 struct snd_soc_dai *codec_dai = rtd->dai->codec_dai; 117 struct snd_soc_dai *codec_dai = rtd->codec_dai;
93 struct snd_soc_dai *cpu_dai = rtd->dai->cpu_dai; 118 struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
94 int err; 119 int err;
95 120
96 /* Set codec DAI configuration */ 121 /* Set codec DAI configuration */
@@ -145,9 +170,22 @@ static int rx51_spk_event(struct snd_soc_dapm_widget *w,
145 struct snd_kcontrol *k, int event) 170 struct snd_kcontrol *k, int event)
146{ 171{
147 if (SND_SOC_DAPM_EVENT_ON(event)) 172 if (SND_SOC_DAPM_EVENT_ON(event))
148 gpio_set_value(RX51_SPEAKER_AMP_TWL_GPIO, 1); 173 gpio_set_value_cansleep(RX51_SPEAKER_AMP_TWL_GPIO, 1);
174 else
175 gpio_set_value_cansleep(RX51_SPEAKER_AMP_TWL_GPIO, 0);
176
177 return 0;
178}
179
180static int rx51_hp_event(struct snd_soc_dapm_widget *w,
181 struct snd_kcontrol *k, int event)
182{
183 struct snd_soc_codec *codec = w->dapm->codec;
184
185 if (SND_SOC_DAPM_EVENT_ON(event))
186 tpa6130a2_stereo_enable(codec, 1);
149 else 187 else
150 gpio_set_value(RX51_SPEAKER_AMP_TWL_GPIO, 0); 188 tpa6130a2_stereo_enable(codec, 0);
151 189
152 return 0; 190 return 0;
153} 191}
@@ -202,7 +240,7 @@ static struct snd_soc_jack_gpio rx51_av_jack_gpios[] = {
202 { 240 {
203 .gpio = RX51_JACK_DETECT_GPIO, 241 .gpio = RX51_JACK_DETECT_GPIO,
204 .name = "avdet-gpio", 242 .name = "avdet-gpio",
205 .report = SND_JACK_VIDEOOUT, 243 .report = SND_JACK_HEADSET,
206 .invert = 1, 244 .invert = 1,
207 .debounce_time = 200, 245 .debounce_time = 200,
208 }, 246 },
@@ -211,19 +249,38 @@ static struct snd_soc_jack_gpio rx51_av_jack_gpios[] = {
211static const struct snd_soc_dapm_widget aic34_dapm_widgets[] = { 249static const struct snd_soc_dapm_widget aic34_dapm_widgets[] = {
212 SND_SOC_DAPM_SPK("Ext Spk", rx51_spk_event), 250 SND_SOC_DAPM_SPK("Ext Spk", rx51_spk_event),
213 SND_SOC_DAPM_MIC("DMic", NULL), 251 SND_SOC_DAPM_MIC("DMic", NULL),
252 SND_SOC_DAPM_HP("Headphone Jack", rx51_hp_event),
253 SND_SOC_DAPM_MIC("HS Mic", NULL),
254 SND_SOC_DAPM_LINE("FM Transmitter", NULL),
255};
256
257static const struct snd_soc_dapm_widget aic34_dapm_widgetsb[] = {
258 SND_SOC_DAPM_SPK("Earphone", NULL),
214}; 259};
215 260
216static const struct snd_soc_dapm_route audio_map[] = { 261static const struct snd_soc_dapm_route audio_map[] = {
217 {"Ext Spk", NULL, "HPLOUT"}, 262 {"Ext Spk", NULL, "HPLOUT"},
218 {"Ext Spk", NULL, "HPROUT"}, 263 {"Ext Spk", NULL, "HPROUT"},
264 {"Headphone Jack", NULL, "LLOUT"},
265 {"Headphone Jack", NULL, "RLOUT"},
266 {"FM Transmitter", NULL, "LLOUT"},
267 {"FM Transmitter", NULL, "RLOUT"},
219 268
220 {"DMic Rate 64", NULL, "Mic Bias 2V"}, 269 {"DMic Rate 64", NULL, "Mic Bias 2V"},
221 {"Mic Bias 2V", NULL, "DMic"}, 270 {"Mic Bias 2V", NULL, "DMic"},
222}; 271};
223 272
273static const struct snd_soc_dapm_route audio_mapb[] = {
274 {"b LINE2R", NULL, "MONO_LOUT"},
275 {"Earphone", NULL, "b HPLOUT"},
276
277 {"LINE1L", NULL, "b Mic Bias 2.5V"},
278 {"b Mic Bias 2.5V", NULL, "HS Mic"}
279};
280
224static const char *spk_function[] = {"Off", "On"}; 281static const char *spk_function[] = {"Off", "On"};
225static const char *input_function[] = {"ADC", "Digital Mic"}; 282static const char *input_function[] = {"ADC", "Digital Mic"};
226static const char *jack_function[] = {"Off", "TV-OUT"}; 283static const char *jack_function[] = {"Off", "TV-OUT", "Headphone", "Headset"};
227 284
228static const struct soc_enum rx51_enum[] = { 285static const struct soc_enum rx51_enum[] = {
229 SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(spk_function), spk_function), 286 SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(spk_function), spk_function),
@@ -238,17 +295,23 @@ static const struct snd_kcontrol_new aic34_rx51_controls[] = {
238 rx51_get_input, rx51_set_input), 295 rx51_get_input, rx51_set_input),
239 SOC_ENUM_EXT("Jack Function", rx51_enum[2], 296 SOC_ENUM_EXT("Jack Function", rx51_enum[2],
240 rx51_get_jack, rx51_set_jack), 297 rx51_get_jack, rx51_set_jack),
298 SOC_DAPM_PIN_SWITCH("FM Transmitter"),
241}; 299};
242 300
243static int rx51_aic34_init(struct snd_soc_codec *codec) 301static const struct snd_kcontrol_new aic34_rx51_controlsb[] = {
302 SOC_DAPM_PIN_SWITCH("Earphone"),
303};
304
305static int rx51_aic34_init(struct snd_soc_pcm_runtime *rtd)
244{ 306{
245 struct snd_soc_card *card = codec->socdev->card; 307 struct snd_soc_codec *codec = rtd->codec;
308 struct snd_soc_dapm_context *dapm = &codec->dapm;
246 int err; 309 int err;
247 310
248 /* Set up NC codec pins */ 311 /* Set up NC codec pins */
249 snd_soc_dapm_nc_pin(codec, "MIC3L"); 312 snd_soc_dapm_nc_pin(dapm, "MIC3L");
250 snd_soc_dapm_nc_pin(codec, "MIC3R"); 313 snd_soc_dapm_nc_pin(dapm, "MIC3R");
251 snd_soc_dapm_nc_pin(codec, "LINE1R"); 314 snd_soc_dapm_nc_pin(dapm, "LINE1R");
252 315
253 /* Add RX-51 specific controls */ 316 /* Add RX-51 specific controls */
254 err = snd_soc_add_controls(codec, aic34_rx51_controls, 317 err = snd_soc_add_controls(codec, aic34_rx51_controls,
@@ -257,17 +320,27 @@ static int rx51_aic34_init(struct snd_soc_codec *codec)
257 return err; 320 return err;
258 321
259 /* Add RX-51 specific widgets */ 322 /* Add RX-51 specific widgets */
260 snd_soc_dapm_new_controls(codec, aic34_dapm_widgets, 323 snd_soc_dapm_new_controls(dapm, aic34_dapm_widgets,
261 ARRAY_SIZE(aic34_dapm_widgets)); 324 ARRAY_SIZE(aic34_dapm_widgets));
262 325
263 /* Set up RX-51 specific audio path audio_map */ 326 /* Set up RX-51 specific audio path audio_map */
264 snd_soc_dapm_add_routes(codec, audio_map, ARRAY_SIZE(audio_map)); 327 snd_soc_dapm_add_routes(dapm, audio_map, ARRAY_SIZE(audio_map));
265 328
266 snd_soc_dapm_sync(codec); 329 err = tpa6130a2_add_controls(codec);
330 if (err < 0)
331 return err;
332 snd_soc_limit_volume(codec, "TPA6130A2 Headphone Playback Volume", 42);
333
334 err = omap_mcbsp_st_add_controls(codec, 1);
335 if (err < 0)
336 return err;
337
338 snd_soc_dapm_sync(dapm);
267 339
268 /* AV jack detection */ 340 /* AV jack detection */
269 err = snd_soc_jack_new(card, "AV Jack", 341 err = snd_soc_jack_new(codec, "AV Jack",
270 SND_JACK_VIDEOOUT, &rx51_av_jack); 342 SND_JACK_HEADSET | SND_JACK_VIDEOOUT,
343 &rx51_av_jack);
271 if (err) 344 if (err)
272 return err; 345 return err;
273 err = snd_soc_jack_add_gpios(&rx51_av_jack, 346 err = snd_soc_jack_add_gpios(&rx51_av_jack,
@@ -277,22 +350,51 @@ static int rx51_aic34_init(struct snd_soc_codec *codec)
277 return err; 350 return err;
278} 351}
279 352
353static int rx51_aic34b_init(struct snd_soc_dapm_context *dapm)
354{
355 int err;
356
357 err = snd_soc_add_controls(dapm->codec, aic34_rx51_controlsb,
358 ARRAY_SIZE(aic34_rx51_controlsb));
359 if (err < 0)
360 return err;
361
362 err = snd_soc_dapm_new_controls(dapm, aic34_dapm_widgetsb,
363 ARRAY_SIZE(aic34_dapm_widgetsb));
364 if (err < 0)
365 return 0;
366
367 return snd_soc_dapm_add_routes(dapm, audio_mapb,
368 ARRAY_SIZE(audio_mapb));
369}
370
280/* Digital audio interface glue - connects codec <--> CPU */ 371/* Digital audio interface glue - connects codec <--> CPU */
281static struct snd_soc_dai_link rx51_dai[] = { 372static struct snd_soc_dai_link rx51_dai[] = {
282 { 373 {
283 .name = "TLV320AIC34", 374 .name = "TLV320AIC34",
284 .stream_name = "AIC34", 375 .stream_name = "AIC34",
285 .cpu_dai = &omap_mcbsp_dai[0], 376 .cpu_dai_name = "omap-mcbsp-dai.1",
286 .codec_dai = &aic3x_dai, 377 .codec_dai_name = "tlv320aic3x-hifi",
378 .platform_name = "omap-pcm-audio",
379 .codec_name = "tlv320aic3x-codec.2-0018",
287 .init = rx51_aic34_init, 380 .init = rx51_aic34_init,
288 .ops = &rx51_ops, 381 .ops = &rx51_ops,
289 }, 382 },
290}; 383};
291 384
292/* Audio private data */ 385struct snd_soc_aux_dev rx51_aux_dev[] = {
293static struct aic3x_setup_data rx51_aic34_setup = { 386 {
294 .gpio_func[0] = AIC3X_GPIO1_FUNC_DISABLED, 387 .name = "TLV320AIC34b",
295 .gpio_func[1] = AIC3X_GPIO2_FUNC_DIGITAL_MIC_INPUT, 388 .codec_name = "tlv320aic3x-codec.2-0019",
389 .init = rx51_aic34b_init,
390 },
391};
392
393static struct snd_soc_codec_conf rx51_codec_conf[] = {
394 {
395 .dev_name = "tlv320aic3x-codec.2-0019",
396 .name_prefix = "b",
397 },
296}; 398};
297 399
298/* Audio card */ 400/* Audio card */
@@ -300,14 +402,10 @@ static struct snd_soc_card rx51_sound_card = {
300 .name = "RX-51", 402 .name = "RX-51",
301 .dai_link = rx51_dai, 403 .dai_link = rx51_dai,
302 .num_links = ARRAY_SIZE(rx51_dai), 404 .num_links = ARRAY_SIZE(rx51_dai),
303 .platform = &omap_soc_platform, 405 .aux_dev = rx51_aux_dev,
304}; 406 .num_aux_devs = ARRAY_SIZE(rx51_aux_dev),
305 407 .codec_conf = rx51_codec_conf,
306/* Audio subsystem */ 408 .num_configs = ARRAY_SIZE(rx51_codec_conf),
307static struct snd_soc_device rx51_snd_devdata = {
308 .card = &rx51_sound_card,
309 .codec_dev = &soc_codec_dev_aic3x,
310 .codec_data = &rx51_aic34_setup,
311}; 409};
312 410
313static struct platform_device *rx51_snd_device; 411static struct platform_device *rx51_snd_device;
@@ -319,10 +417,14 @@ static int __init rx51_soc_init(void)
319 if (!machine_is_nokia_rx51()) 417 if (!machine_is_nokia_rx51())
320 return -ENODEV; 418 return -ENODEV;
321 419
322 err = gpio_request(RX51_TVOUT_SEL_GPIO, "tvout_sel"); 420 err = gpio_request_one(RX51_TVOUT_SEL_GPIO,
421 GPIOF_DIR_OUT | GPIOF_INIT_LOW, "tvout_sel");
323 if (err) 422 if (err)
324 goto err_gpio_tvout_sel; 423 goto err_gpio_tvout_sel;
325 gpio_direction_output(RX51_TVOUT_SEL_GPIO, 0); 424 err = gpio_request_one(RX51_ECI_SW_GPIO,
425 GPIOF_DIR_OUT | GPIOF_INIT_HIGH, "eci_sw");
426 if (err)
427 goto err_gpio_eci_sw;
326 428
327 rx51_snd_device = platform_device_alloc("soc-audio", -1); 429 rx51_snd_device = platform_device_alloc("soc-audio", -1);
328 if (!rx51_snd_device) { 430 if (!rx51_snd_device) {
@@ -330,9 +432,7 @@ static int __init rx51_soc_init(void)
330 goto err1; 432 goto err1;
331 } 433 }
332 434
333 platform_set_drvdata(rx51_snd_device, &rx51_snd_devdata); 435 platform_set_drvdata(rx51_snd_device, &rx51_sound_card);
334 rx51_snd_devdata.dev = &rx51_snd_device->dev;
335 *(unsigned int *)rx51_dai[0].cpu_dai->private_data = 1; /* McBSP2 */
336 436
337 err = platform_device_add(rx51_snd_device); 437 err = platform_device_add(rx51_snd_device);
338 if (err) 438 if (err)
@@ -342,6 +442,8 @@ static int __init rx51_soc_init(void)
342err2: 442err2:
343 platform_device_put(rx51_snd_device); 443 platform_device_put(rx51_snd_device);
344err1: 444err1:
445 gpio_free(RX51_ECI_SW_GPIO);
446err_gpio_eci_sw:
345 gpio_free(RX51_TVOUT_SEL_GPIO); 447 gpio_free(RX51_TVOUT_SEL_GPIO);
346err_gpio_tvout_sel: 448err_gpio_tvout_sel:
347 449
@@ -354,6 +456,7 @@ static void __exit rx51_soc_exit(void)
354 rx51_av_jack_gpios); 456 rx51_av_jack_gpios);
355 457
356 platform_device_unregister(rx51_snd_device); 458 platform_device_unregister(rx51_snd_device);
459 gpio_free(RX51_ECI_SW_GPIO);
357 gpio_free(RX51_TVOUT_SEL_GPIO); 460 gpio_free(RX51_TVOUT_SEL_GPIO);
358} 461}
359 462
diff --git a/sound/soc/omap/sdp3430.c b/sound/soc/omap/sdp3430.c
index 3c85c0f92823..3f72d17d1ef0 100644
--- a/sound/soc/omap/sdp3430.c
+++ b/sound/soc/omap/sdp3430.c
@@ -28,7 +28,6 @@
28#include <sound/core.h> 28#include <sound/core.h>
29#include <sound/pcm.h> 29#include <sound/pcm.h>
30#include <sound/soc.h> 30#include <sound/soc.h>
31#include <sound/soc-dapm.h>
32#include <sound/jack.h> 31#include <sound/jack.h>
33 32
34#include <asm/mach-types.h> 33#include <asm/mach-types.h>
@@ -36,9 +35,11 @@
36#include <mach/gpio.h> 35#include <mach/gpio.h>
37#include <plat/mcbsp.h> 36#include <plat/mcbsp.h>
38 37
38/* Register descriptions for twl4030 codec part */
39#include <linux/mfd/twl4030-codec.h>
40
39#include "omap-mcbsp.h" 41#include "omap-mcbsp.h"
40#include "omap-pcm.h" 42#include "omap-pcm.h"
41#include "../codecs/twl4030.h"
42 43
43/* TWL4030 PMBR1 Register */ 44/* TWL4030 PMBR1 Register */
44#define TWL4030_INTBR_PMBR1 0x0D 45#define TWL4030_INTBR_PMBR1 0x0D
@@ -51,8 +52,8 @@ static int sdp3430_hw_params(struct snd_pcm_substream *substream,
51 struct snd_pcm_hw_params *params) 52 struct snd_pcm_hw_params *params)
52{ 53{
53 struct snd_soc_pcm_runtime *rtd = substream->private_data; 54 struct snd_soc_pcm_runtime *rtd = substream->private_data;
54 struct snd_soc_dai *codec_dai = rtd->dai->codec_dai; 55 struct snd_soc_dai *codec_dai = rtd->codec_dai;
55 struct snd_soc_dai *cpu_dai = rtd->dai->cpu_dai; 56 struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
56 int ret; 57 int ret;
57 58
58 /* Set codec DAI configuration */ 59 /* Set codec DAI configuration */
@@ -94,8 +95,8 @@ static int sdp3430_hw_voice_params(struct snd_pcm_substream *substream,
94 struct snd_pcm_hw_params *params) 95 struct snd_pcm_hw_params *params)
95{ 96{
96 struct snd_soc_pcm_runtime *rtd = substream->private_data; 97 struct snd_soc_pcm_runtime *rtd = substream->private_data;
97 struct snd_soc_dai *codec_dai = rtd->dai->codec_dai; 98 struct snd_soc_dai *codec_dai = rtd->codec_dai;
98 struct snd_soc_dai *cpu_dai = rtd->dai->cpu_dai; 99 struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
99 int ret; 100 int ret;
100 101
101 /* Set codec DAI configuration */ 102 /* Set codec DAI configuration */
@@ -186,46 +187,48 @@ static const struct snd_soc_dapm_route audio_map[] = {
186 {"Headset Stereophone", NULL, "HSOR"}, 187 {"Headset Stereophone", NULL, "HSOR"},
187}; 188};
188 189
189static int sdp3430_twl4030_init(struct snd_soc_codec *codec) 190static int sdp3430_twl4030_init(struct snd_soc_pcm_runtime *rtd)
190{ 191{
192 struct snd_soc_codec *codec = rtd->codec;
193 struct snd_soc_dapm_context *dapm = &codec->dapm;
191 int ret; 194 int ret;
192 195
193 /* Add SDP3430 specific widgets */ 196 /* Add SDP3430 specific widgets */
194 ret = snd_soc_dapm_new_controls(codec, sdp3430_twl4030_dapm_widgets, 197 ret = snd_soc_dapm_new_controls(dapm, sdp3430_twl4030_dapm_widgets,
195 ARRAY_SIZE(sdp3430_twl4030_dapm_widgets)); 198 ARRAY_SIZE(sdp3430_twl4030_dapm_widgets));
196 if (ret) 199 if (ret)
197 return ret; 200 return ret;
198 201
199 /* Set up SDP3430 specific audio path audio_map */ 202 /* Set up SDP3430 specific audio path audio_map */
200 snd_soc_dapm_add_routes(codec, audio_map, ARRAY_SIZE(audio_map)); 203 snd_soc_dapm_add_routes(dapm, audio_map, ARRAY_SIZE(audio_map));
201 204
202 /* SDP3430 connected pins */ 205 /* SDP3430 connected pins */
203 snd_soc_dapm_enable_pin(codec, "Ext Mic"); 206 snd_soc_dapm_enable_pin(dapm, "Ext Mic");
204 snd_soc_dapm_enable_pin(codec, "Ext Spk"); 207 snd_soc_dapm_enable_pin(dapm, "Ext Spk");
205 snd_soc_dapm_disable_pin(codec, "Headset Mic"); 208 snd_soc_dapm_disable_pin(dapm, "Headset Mic");
206 snd_soc_dapm_disable_pin(codec, "Headset Stereophone"); 209 snd_soc_dapm_disable_pin(dapm, "Headset Stereophone");
207 210
208 /* TWL4030 not connected pins */ 211 /* TWL4030 not connected pins */
209 snd_soc_dapm_nc_pin(codec, "AUXL"); 212 snd_soc_dapm_nc_pin(dapm, "AUXL");
210 snd_soc_dapm_nc_pin(codec, "AUXR"); 213 snd_soc_dapm_nc_pin(dapm, "AUXR");
211 snd_soc_dapm_nc_pin(codec, "CARKITMIC"); 214 snd_soc_dapm_nc_pin(dapm, "CARKITMIC");
212 snd_soc_dapm_nc_pin(codec, "DIGIMIC0"); 215 snd_soc_dapm_nc_pin(dapm, "DIGIMIC0");
213 snd_soc_dapm_nc_pin(codec, "DIGIMIC1"); 216 snd_soc_dapm_nc_pin(dapm, "DIGIMIC1");
214 217
215 snd_soc_dapm_nc_pin(codec, "OUTL"); 218 snd_soc_dapm_nc_pin(dapm, "OUTL");
216 snd_soc_dapm_nc_pin(codec, "OUTR"); 219 snd_soc_dapm_nc_pin(dapm, "OUTR");
217 snd_soc_dapm_nc_pin(codec, "EARPIECE"); 220 snd_soc_dapm_nc_pin(dapm, "EARPIECE");
218 snd_soc_dapm_nc_pin(codec, "PREDRIVEL"); 221 snd_soc_dapm_nc_pin(dapm, "PREDRIVEL");
219 snd_soc_dapm_nc_pin(codec, "PREDRIVER"); 222 snd_soc_dapm_nc_pin(dapm, "PREDRIVER");
220 snd_soc_dapm_nc_pin(codec, "CARKITL"); 223 snd_soc_dapm_nc_pin(dapm, "CARKITL");
221 snd_soc_dapm_nc_pin(codec, "CARKITR"); 224 snd_soc_dapm_nc_pin(dapm, "CARKITR");
222 225
223 ret = snd_soc_dapm_sync(codec); 226 ret = snd_soc_dapm_sync(dapm);
224 if (ret) 227 if (ret)
225 return ret; 228 return ret;
226 229
227 /* Headset jack detection */ 230 /* Headset jack detection */
228 ret = snd_soc_jack_new(&snd_soc_sdp3430, "Headset Jack", 231 ret = snd_soc_jack_new(codec, "Headset Jack",
229 SND_JACK_HEADSET, &hs_jack); 232 SND_JACK_HEADSET, &hs_jack);
230 if (ret) 233 if (ret)
231 return ret; 234 return ret;
@@ -241,14 +244,15 @@ static int sdp3430_twl4030_init(struct snd_soc_codec *codec)
241 return ret; 244 return ret;
242} 245}
243 246
244static int sdp3430_twl4030_voice_init(struct snd_soc_codec *codec) 247static int sdp3430_twl4030_voice_init(struct snd_soc_pcm_runtime *rtd)
245{ 248{
249 struct snd_soc_codec *codec = rtd->codec;
246 unsigned short reg; 250 unsigned short reg;
247 251
248 /* Enable voice interface */ 252 /* Enable voice interface */
249 reg = codec->read(codec, TWL4030_REG_VOICE_IF); 253 reg = codec->driver->read(codec, TWL4030_REG_VOICE_IF);
250 reg |= TWL4030_VIF_DIN_EN | TWL4030_VIF_DOUT_EN | TWL4030_VIF_EN; 254 reg |= TWL4030_VIF_DIN_EN | TWL4030_VIF_DOUT_EN | TWL4030_VIF_EN;
251 codec->write(codec, TWL4030_REG_VOICE_IF, reg); 255 codec->driver->write(codec, TWL4030_REG_VOICE_IF, reg);
252 256
253 return 0; 257 return 0;
254} 258}
@@ -259,16 +263,20 @@ static struct snd_soc_dai_link sdp3430_dai[] = {
259 { 263 {
260 .name = "TWL4030 I2S", 264 .name = "TWL4030 I2S",
261 .stream_name = "TWL4030 Audio", 265 .stream_name = "TWL4030 Audio",
262 .cpu_dai = &omap_mcbsp_dai[0], 266 .cpu_dai_name = "omap-mcbsp-dai.1",
263 .codec_dai = &twl4030_dai[TWL4030_DAI_HIFI], 267 .codec_dai_name = "twl4030-hifi",
268 .platform_name = "omap-pcm-audio",
269 .codec_name = "twl4030-codec",
264 .init = sdp3430_twl4030_init, 270 .init = sdp3430_twl4030_init,
265 .ops = &sdp3430_ops, 271 .ops = &sdp3430_ops,
266 }, 272 },
267 { 273 {
268 .name = "TWL4030 PCM", 274 .name = "TWL4030 PCM",
269 .stream_name = "TWL4030 Voice", 275 .stream_name = "TWL4030 Voice",
270 .cpu_dai = &omap_mcbsp_dai[1], 276 .cpu_dai_name = "omap-mcbsp-dai.2",
271 .codec_dai = &twl4030_dai[TWL4030_DAI_VOICE], 277 .codec_dai_name = "twl4030-voice",
278 .platform_name = "omap-pcm-audio",
279 .codec_name = "twl4030-codec",
272 .init = sdp3430_twl4030_voice_init, 280 .init = sdp3430_twl4030_voice_init,
273 .ops = &sdp3430_voice_ops, 281 .ops = &sdp3430_voice_ops,
274 }, 282 },
@@ -277,25 +285,10 @@ static struct snd_soc_dai_link sdp3430_dai[] = {
277/* Audio machine driver */ 285/* Audio machine driver */
278static struct snd_soc_card snd_soc_sdp3430 = { 286static struct snd_soc_card snd_soc_sdp3430 = {
279 .name = "SDP3430", 287 .name = "SDP3430",
280 .platform = &omap_soc_platform,
281 .dai_link = sdp3430_dai, 288 .dai_link = sdp3430_dai,
282 .num_links = ARRAY_SIZE(sdp3430_dai), 289 .num_links = ARRAY_SIZE(sdp3430_dai),
283}; 290};
284 291
285/* twl4030 setup */
286static struct twl4030_setup_data twl4030_setup = {
287 .ramp_delay_value = 3,
288 .sysclk = 26000,
289 .hs_extmute = 1,
290};
291
292/* Audio subsystem */
293static struct snd_soc_device sdp3430_snd_devdata = {
294 .card = &snd_soc_sdp3430,
295 .codec_dev = &soc_codec_dev_twl4030,
296 .codec_data = &twl4030_setup,
297};
298
299static struct platform_device *sdp3430_snd_device; 292static struct platform_device *sdp3430_snd_device;
300 293
301static int __init sdp3430_soc_init(void) 294static int __init sdp3430_soc_init(void)
@@ -303,10 +296,8 @@ static int __init sdp3430_soc_init(void)
303 int ret; 296 int ret;
304 u8 pin_mux; 297 u8 pin_mux;
305 298
306 if (!machine_is_omap_3430sdp()) { 299 if (!machine_is_omap_3430sdp())
307 pr_debug("Not SDP3430!\n");
308 return -ENODEV; 300 return -ENODEV;
309 }
310 printk(KERN_INFO "SDP3430 SoC init\n"); 301 printk(KERN_INFO "SDP3430 SoC init\n");
311 302
312 sdp3430_snd_device = platform_device_alloc("soc-audio", -1); 303 sdp3430_snd_device = platform_device_alloc("soc-audio", -1);
@@ -315,10 +306,7 @@ static int __init sdp3430_soc_init(void)
315 return -ENOMEM; 306 return -ENOMEM;
316 } 307 }
317 308
318 platform_set_drvdata(sdp3430_snd_device, &sdp3430_snd_devdata); 309 platform_set_drvdata(sdp3430_snd_device, &snd_soc_sdp3430);
319 sdp3430_snd_devdata.dev = &sdp3430_snd_device->dev;
320 *(unsigned int *)sdp3430_dai[0].cpu_dai->private_data = 1; /* McBSP2 */
321 *(unsigned int *)sdp3430_dai[1].cpu_dai->private_data = 2; /* McBSP3 */
322 310
323 /* Set TWL4030 GPIO6 as EXTMUTE signal */ 311 /* Set TWL4030 GPIO6 as EXTMUTE signal */
324 twl_i2c_read_u8(TWL4030_MODULE_INTBR, &pin_mux, 312 twl_i2c_read_u8(TWL4030_MODULE_INTBR, &pin_mux,
diff --git a/sound/soc/omap/sdp4430.c b/sound/soc/omap/sdp4430.c
index 4ebbde6b565f..189e03900637 100644
--- a/sound/soc/omap/sdp4430.c
+++ b/sound/soc/omap/sdp4430.c
@@ -24,14 +24,13 @@
24#include <sound/core.h> 24#include <sound/core.h>
25#include <sound/pcm.h> 25#include <sound/pcm.h>
26#include <sound/soc.h> 26#include <sound/soc.h>
27#include <sound/soc-dapm.h> 27#include <sound/jack.h>
28 28
29#include <asm/mach-types.h> 29#include <asm/mach-types.h>
30#include <plat/hardware.h> 30#include <plat/hardware.h>
31#include <plat/mux.h> 31#include <plat/mux.h>
32 32
33#include "mcpdm.h" 33#include "mcpdm.h"
34#include "omap-mcpdm.h"
35#include "omap-pcm.h" 34#include "omap-pcm.h"
36#include "../codecs/twl6040.h" 35#include "../codecs/twl6040.h"
37 36
@@ -41,7 +40,7 @@ static int sdp4430_hw_params(struct snd_pcm_substream *substream,
41 struct snd_pcm_hw_params *params) 40 struct snd_pcm_hw_params *params)
42{ 41{
43 struct snd_soc_pcm_runtime *rtd = substream->private_data; 42 struct snd_soc_pcm_runtime *rtd = substream->private_data;
44 struct snd_soc_dai *codec_dai = rtd->dai->codec_dai; 43 struct snd_soc_dai *codec_dai = rtd->codec_dai;
45 int clk_id, freq; 44 int clk_id, freq;
46 int ret; 45 int ret;
47 46
@@ -60,12 +59,28 @@ static int sdp4430_hw_params(struct snd_pcm_substream *substream,
60 printk(KERN_ERR "can't set codec system clock\n"); 59 printk(KERN_ERR "can't set codec system clock\n");
61 return ret; 60 return ret;
62 } 61 }
62 return ret;
63} 63}
64 64
65static struct snd_soc_ops sdp4430_ops = { 65static struct snd_soc_ops sdp4430_ops = {
66 .hw_params = sdp4430_hw_params, 66 .hw_params = sdp4430_hw_params,
67}; 67};
68 68
69/* Headset jack */
70static struct snd_soc_jack hs_jack;
71
72/*Headset jack detection DAPM pins */
73static struct snd_soc_jack_pin hs_jack_pins[] = {
74 {
75 .pin = "Headset Mic",
76 .mask = SND_JACK_MICROPHONE,
77 },
78 {
79 .pin = "Headset Stereophone",
80 .mask = SND_JACK_HEADPHONE,
81 },
82};
83
69static int sdp4430_get_power_mode(struct snd_kcontrol *kcontrol, 84static int sdp4430_get_power_mode(struct snd_kcontrol *kcontrol,
70 struct snd_ctl_elem_value *ucontrol) 85 struct snd_ctl_elem_value *ucontrol)
71{ 86{
@@ -102,6 +117,7 @@ static const struct snd_soc_dapm_widget sdp4430_twl6040_dapm_widgets[] = {
102 SND_SOC_DAPM_MIC("Headset Mic", NULL), 117 SND_SOC_DAPM_MIC("Headset Mic", NULL),
103 SND_SOC_DAPM_HP("Headset Stereophone", NULL), 118 SND_SOC_DAPM_HP("Headset Stereophone", NULL),
104 SND_SOC_DAPM_SPK("Earphone Spk", NULL), 119 SND_SOC_DAPM_SPK("Earphone Spk", NULL),
120 SND_SOC_DAPM_INPUT("Aux/FM Stereo In"),
105}; 121};
106 122
107static const struct snd_soc_dapm_route audio_map[] = { 123static const struct snd_soc_dapm_route audio_map[] = {
@@ -124,10 +140,16 @@ static const struct snd_soc_dapm_route audio_map[] = {
124 140
125 /* Earphone speaker */ 141 /* Earphone speaker */
126 {"Earphone Spk", NULL, "EP"}, 142 {"Earphone Spk", NULL, "EP"},
143
144 /* Aux/FM Stereo In: AFML, AFMR */
145 {"AFML", NULL, "Aux/FM Stereo In"},
146 {"AFMR", NULL, "Aux/FM Stereo In"},
127}; 147};
128 148
129static int sdp4430_twl6040_init(struct snd_soc_codec *codec) 149static int sdp4430_twl6040_init(struct snd_soc_pcm_runtime *rtd)
130{ 150{
151 struct snd_soc_codec *codec = rtd->codec;
152 struct snd_soc_dapm_context *dapm = &codec->dapm;
131 int ret; 153 int ret;
132 154
133 /* Add SDP4430 specific controls */ 155 /* Add SDP4430 specific controls */
@@ -137,25 +159,39 @@ static int sdp4430_twl6040_init(struct snd_soc_codec *codec)
137 return ret; 159 return ret;
138 160
139 /* Add SDP4430 specific widgets */ 161 /* Add SDP4430 specific widgets */
140 ret = snd_soc_dapm_new_controls(codec, sdp4430_twl6040_dapm_widgets, 162 ret = snd_soc_dapm_new_controls(dapm, sdp4430_twl6040_dapm_widgets,
141 ARRAY_SIZE(sdp4430_twl6040_dapm_widgets)); 163 ARRAY_SIZE(sdp4430_twl6040_dapm_widgets));
142 if (ret) 164 if (ret)
143 return ret; 165 return ret;
144 166
145 /* Set up SDP4430 specific audio path audio_map */ 167 /* Set up SDP4430 specific audio path audio_map */
146 snd_soc_dapm_add_routes(codec, audio_map, ARRAY_SIZE(audio_map)); 168 snd_soc_dapm_add_routes(dapm, audio_map, ARRAY_SIZE(audio_map));
147 169
148 /* SDP4430 connected pins */ 170 /* SDP4430 connected pins */
149 snd_soc_dapm_enable_pin(codec, "Ext Mic"); 171 snd_soc_dapm_enable_pin(dapm, "Ext Mic");
150 snd_soc_dapm_enable_pin(codec, "Ext Spk"); 172 snd_soc_dapm_enable_pin(dapm, "Ext Spk");
151 snd_soc_dapm_enable_pin(codec, "Headset Mic"); 173 snd_soc_dapm_enable_pin(dapm, "AFML");
152 snd_soc_dapm_enable_pin(codec, "Headset Stereophone"); 174 snd_soc_dapm_enable_pin(dapm, "AFMR");
175 snd_soc_dapm_enable_pin(dapm, "Headset Mic");
176 snd_soc_dapm_enable_pin(dapm, "Headset Stereophone");
177
178 ret = snd_soc_dapm_sync(dapm);
179 if (ret)
180 return ret;
153 181
154 /* TWL6040 not connected pins */ 182 /* Headset jack detection */
155 snd_soc_dapm_nc_pin(codec, "AFML"); 183 ret = snd_soc_jack_new(codec, "Headset Jack",
156 snd_soc_dapm_nc_pin(codec, "AFMR"); 184 SND_JACK_HEADSET, &hs_jack);
185 if (ret)
186 return ret;
187
188 ret = snd_soc_jack_add_pins(&hs_jack, ARRAY_SIZE(hs_jack_pins),
189 hs_jack_pins);
157 190
158 ret = snd_soc_dapm_sync(codec); 191 if (machine_is_omap_4430sdp())
192 twl6040_hs_jack_detect(codec, &hs_jack, SND_JACK_HEADSET);
193 else
194 snd_soc_jack_report(&hs_jack, SND_JACK_HEADSET, SND_JACK_HEADSET);
159 195
160 return ret; 196 return ret;
161} 197}
@@ -164,8 +200,10 @@ static int sdp4430_twl6040_init(struct snd_soc_codec *codec)
164static struct snd_soc_dai_link sdp4430_dai = { 200static struct snd_soc_dai_link sdp4430_dai = {
165 .name = "TWL6040", 201 .name = "TWL6040",
166 .stream_name = "TWL6040", 202 .stream_name = "TWL6040",
167 .cpu_dai = &omap_mcpdm_dai, 203 .cpu_dai_name ="omap-mcpdm-dai",
168 .codec_dai = &twl6040_dai, 204 .codec_dai_name = "twl6040-hifi",
205 .platform_name = "omap-pcm-audio",
206 .codec_name = "twl6040-codec",
169 .init = sdp4430_twl6040_init, 207 .init = sdp4430_twl6040_init,
170 .ops = &sdp4430_ops, 208 .ops = &sdp4430_ops,
171}; 209};
@@ -173,27 +211,18 @@ static struct snd_soc_dai_link sdp4430_dai = {
173/* Audio machine driver */ 211/* Audio machine driver */
174static struct snd_soc_card snd_soc_sdp4430 = { 212static struct snd_soc_card snd_soc_sdp4430 = {
175 .name = "SDP4430", 213 .name = "SDP4430",
176 .platform = &omap_soc_platform,
177 .dai_link = &sdp4430_dai, 214 .dai_link = &sdp4430_dai,
178 .num_links = 1, 215 .num_links = 1,
179}; 216};
180 217
181/* Audio subsystem */
182static struct snd_soc_device sdp4430_snd_devdata = {
183 .card = &snd_soc_sdp4430,
184 .codec_dev = &soc_codec_dev_twl6040,
185};
186
187static struct platform_device *sdp4430_snd_device; 218static struct platform_device *sdp4430_snd_device;
188 219
189static int __init sdp4430_soc_init(void) 220static int __init sdp4430_soc_init(void)
190{ 221{
191 int ret; 222 int ret;
192 223
193 if (!machine_is_omap_4430sdp()) { 224 if (!machine_is_omap_4430sdp())
194 pr_debug("Not SDP4430!\n");
195 return -ENODEV; 225 return -ENODEV;
196 }
197 printk(KERN_INFO "SDP4430 SoC init\n"); 226 printk(KERN_INFO "SDP4430 SoC init\n");
198 227
199 sdp4430_snd_device = platform_device_alloc("soc-audio", -1); 228 sdp4430_snd_device = platform_device_alloc("soc-audio", -1);
@@ -202,8 +231,7 @@ static int __init sdp4430_soc_init(void)
202 return -ENOMEM; 231 return -ENOMEM;
203 } 232 }
204 233
205 platform_set_drvdata(sdp4430_snd_device, &sdp4430_snd_devdata); 234 platform_set_drvdata(sdp4430_snd_device, &snd_soc_sdp4430);
206 sdp4430_snd_devdata.dev = &sdp4430_snd_device->dev;
207 235
208 ret = platform_device_add(sdp4430_snd_device); 236 ret = platform_device_add(sdp4430_snd_device);
209 if (ret) 237 if (ret)
diff --git a/sound/soc/omap/zoom2.c b/sound/soc/omap/zoom2.c
index 50a94ee76ecc..01709940a43c 100644
--- a/sound/soc/omap/zoom2.c
+++ b/sound/soc/omap/zoom2.c
@@ -24,26 +24,27 @@
24#include <sound/core.h> 24#include <sound/core.h>
25#include <sound/pcm.h> 25#include <sound/pcm.h>
26#include <sound/soc.h> 26#include <sound/soc.h>
27#include <sound/soc-dapm.h>
28 27
29#include <asm/mach-types.h> 28#include <asm/mach-types.h>
30#include <mach/hardware.h> 29#include <mach/hardware.h>
31#include <mach/gpio.h> 30#include <mach/gpio.h>
31#include <mach/board-zoom.h>
32#include <plat/mcbsp.h> 32#include <plat/mcbsp.h>
33 33
34/* Register descriptions for twl4030 codec part */
35#include <linux/mfd/twl4030-codec.h>
36
34#include "omap-mcbsp.h" 37#include "omap-mcbsp.h"
35#include "omap-pcm.h" 38#include "omap-pcm.h"
36#include "../codecs/twl4030.h"
37 39
38#define ZOOM2_HEADSET_MUX_GPIO (OMAP_MAX_GPIO_LINES + 15) 40#define ZOOM2_HEADSET_MUX_GPIO (OMAP_MAX_GPIO_LINES + 15)
39#define ZOOM2_HEADSET_EXTMUTE_GPIO 153
40 41
41static int zoom2_hw_params(struct snd_pcm_substream *substream, 42static int zoom2_hw_params(struct snd_pcm_substream *substream,
42 struct snd_pcm_hw_params *params) 43 struct snd_pcm_hw_params *params)
43{ 44{
44 struct snd_soc_pcm_runtime *rtd = substream->private_data; 45 struct snd_soc_pcm_runtime *rtd = substream->private_data;
45 struct snd_soc_dai *codec_dai = rtd->dai->codec_dai; 46 struct snd_soc_dai *codec_dai = rtd->codec_dai;
46 struct snd_soc_dai *cpu_dai = rtd->dai->cpu_dai; 47 struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
47 int ret; 48 int ret;
48 49
49 /* Set codec DAI configuration */ 50 /* Set codec DAI configuration */
@@ -85,8 +86,8 @@ static int zoom2_hw_voice_params(struct snd_pcm_substream *substream,
85 struct snd_pcm_hw_params *params) 86 struct snd_pcm_hw_params *params)
86{ 87{
87 struct snd_soc_pcm_runtime *rtd = substream->private_data; 88 struct snd_soc_pcm_runtime *rtd = substream->private_data;
88 struct snd_soc_dai *codec_dai = rtd->dai->codec_dai; 89 struct snd_soc_dai *codec_dai = rtd->codec_dai;
89 struct snd_soc_dai *cpu_dai = rtd->dai->cpu_dai; 90 struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
90 int ret; 91 int ret;
91 92
92 /* Set codec DAI configuration */ 93 /* Set codec DAI configuration */
@@ -157,49 +158,52 @@ static const struct snd_soc_dapm_route audio_map[] = {
157 {"Aux In", NULL, "AUXR"}, 158 {"Aux In", NULL, "AUXR"},
158}; 159};
159 160
160static int zoom2_twl4030_init(struct snd_soc_codec *codec) 161static int zoom2_twl4030_init(struct snd_soc_pcm_runtime *rtd)
161{ 162{
163 struct snd_soc_codec *codec = rtd->codec;
164 struct snd_soc_dapm_context *dapm = &codec->dapm;
162 int ret; 165 int ret;
163 166
164 /* Add Zoom2 specific widgets */ 167 /* Add Zoom2 specific widgets */
165 ret = snd_soc_dapm_new_controls(codec, zoom2_twl4030_dapm_widgets, 168 ret = snd_soc_dapm_new_controls(dapm, zoom2_twl4030_dapm_widgets,
166 ARRAY_SIZE(zoom2_twl4030_dapm_widgets)); 169 ARRAY_SIZE(zoom2_twl4030_dapm_widgets));
167 if (ret) 170 if (ret)
168 return ret; 171 return ret;
169 172
170 /* Set up Zoom2 specific audio path audio_map */ 173 /* Set up Zoom2 specific audio path audio_map */
171 snd_soc_dapm_add_routes(codec, audio_map, ARRAY_SIZE(audio_map)); 174 snd_soc_dapm_add_routes(dapm, audio_map, ARRAY_SIZE(audio_map));
172 175
173 /* Zoom2 connected pins */ 176 /* Zoom2 connected pins */
174 snd_soc_dapm_enable_pin(codec, "Ext Mic"); 177 snd_soc_dapm_enable_pin(dapm, "Ext Mic");
175 snd_soc_dapm_enable_pin(codec, "Ext Spk"); 178 snd_soc_dapm_enable_pin(dapm, "Ext Spk");
176 snd_soc_dapm_enable_pin(codec, "Headset Mic"); 179 snd_soc_dapm_enable_pin(dapm, "Headset Mic");
177 snd_soc_dapm_enable_pin(codec, "Headset Stereophone"); 180 snd_soc_dapm_enable_pin(dapm, "Headset Stereophone");
178 snd_soc_dapm_enable_pin(codec, "Aux In"); 181 snd_soc_dapm_enable_pin(dapm, "Aux In");
179 182
180 /* TWL4030 not connected pins */ 183 /* TWL4030 not connected pins */
181 snd_soc_dapm_nc_pin(codec, "CARKITMIC"); 184 snd_soc_dapm_nc_pin(dapm, "CARKITMIC");
182 snd_soc_dapm_nc_pin(codec, "DIGIMIC0"); 185 snd_soc_dapm_nc_pin(dapm, "DIGIMIC0");
183 snd_soc_dapm_nc_pin(codec, "DIGIMIC1"); 186 snd_soc_dapm_nc_pin(dapm, "DIGIMIC1");
184 snd_soc_dapm_nc_pin(codec, "EARPIECE"); 187 snd_soc_dapm_nc_pin(dapm, "EARPIECE");
185 snd_soc_dapm_nc_pin(codec, "PREDRIVEL"); 188 snd_soc_dapm_nc_pin(dapm, "PREDRIVEL");
186 snd_soc_dapm_nc_pin(codec, "PREDRIVER"); 189 snd_soc_dapm_nc_pin(dapm, "PREDRIVER");
187 snd_soc_dapm_nc_pin(codec, "CARKITL"); 190 snd_soc_dapm_nc_pin(dapm, "CARKITL");
188 snd_soc_dapm_nc_pin(codec, "CARKITR"); 191 snd_soc_dapm_nc_pin(dapm, "CARKITR");
189 192
190 ret = snd_soc_dapm_sync(codec); 193 ret = snd_soc_dapm_sync(dapm);
191 194
192 return ret; 195 return ret;
193} 196}
194 197
195static int zoom2_twl4030_voice_init(struct snd_soc_codec *codec) 198static int zoom2_twl4030_voice_init(struct snd_soc_pcm_runtime *rtd)
196{ 199{
200 struct snd_soc_codec *codec = rtd->codec;
197 unsigned short reg; 201 unsigned short reg;
198 202
199 /* Enable voice interface */ 203 /* Enable voice interface */
200 reg = codec->read(codec, TWL4030_REG_VOICE_IF); 204 reg = codec->driver->read(codec, TWL4030_REG_VOICE_IF);
201 reg |= TWL4030_VIF_DIN_EN | TWL4030_VIF_DOUT_EN | TWL4030_VIF_EN; 205 reg |= TWL4030_VIF_DIN_EN | TWL4030_VIF_DOUT_EN | TWL4030_VIF_EN;
202 codec->write(codec, TWL4030_REG_VOICE_IF, reg); 206 codec->driver->write(codec, TWL4030_REG_VOICE_IF, reg);
203 207
204 return 0; 208 return 0;
205} 209}
@@ -209,16 +213,20 @@ static struct snd_soc_dai_link zoom2_dai[] = {
209 { 213 {
210 .name = "TWL4030 I2S", 214 .name = "TWL4030 I2S",
211 .stream_name = "TWL4030 Audio", 215 .stream_name = "TWL4030 Audio",
212 .cpu_dai = &omap_mcbsp_dai[0], 216 .cpu_dai_name = "omap-mcbsp-dai.1",
213 .codec_dai = &twl4030_dai[TWL4030_DAI_HIFI], 217 .codec_dai_name = "twl4030-hifi",
218 .platform_name = "omap-pcm-audio",
219 .codec_name = "twl4030-codec",
214 .init = zoom2_twl4030_init, 220 .init = zoom2_twl4030_init,
215 .ops = &zoom2_ops, 221 .ops = &zoom2_ops,
216 }, 222 },
217 { 223 {
218 .name = "TWL4030 PCM", 224 .name = "TWL4030 PCM",
219 .stream_name = "TWL4030 Voice", 225 .stream_name = "TWL4030 Voice",
220 .cpu_dai = &omap_mcbsp_dai[1], 226 .cpu_dai_name = "omap-mcbsp-dai.2",
221 .codec_dai = &twl4030_dai[TWL4030_DAI_VOICE], 227 .codec_dai_name = "twl4030-voice",
228 .platform_name = "omap-pcm-audio",
229 .codec_name = "twl4030-codec",
222 .init = zoom2_twl4030_voice_init, 230 .init = zoom2_twl4030_voice_init,
223 .ops = &zoom2_voice_ops, 231 .ops = &zoom2_voice_ops,
224 }, 232 },
@@ -227,42 +235,18 @@ static struct snd_soc_dai_link zoom2_dai[] = {
227/* Audio machine driver */ 235/* Audio machine driver */
228static struct snd_soc_card snd_soc_zoom2 = { 236static struct snd_soc_card snd_soc_zoom2 = {
229 .name = "Zoom2", 237 .name = "Zoom2",
230 .platform = &omap_soc_platform,
231 .dai_link = zoom2_dai, 238 .dai_link = zoom2_dai,
232 .num_links = ARRAY_SIZE(zoom2_dai), 239 .num_links = ARRAY_SIZE(zoom2_dai),
233}; 240};
234 241
235/* EXTMUTE callback function */
236void zoom2_set_hs_extmute(int mute)
237{
238 gpio_set_value(ZOOM2_HEADSET_EXTMUTE_GPIO, mute);
239}
240
241/* twl4030 setup */
242static struct twl4030_setup_data twl4030_setup = {
243 .ramp_delay_value = 3, /* 161 ms */
244 .sysclk = 26000,
245 .hs_extmute = 1,
246 .set_hs_extmute = zoom2_set_hs_extmute,
247};
248
249/* Audio subsystem */
250static struct snd_soc_device zoom2_snd_devdata = {
251 .card = &snd_soc_zoom2,
252 .codec_dev = &soc_codec_dev_twl4030,
253 .codec_data = &twl4030_setup,
254};
255
256static struct platform_device *zoom2_snd_device; 242static struct platform_device *zoom2_snd_device;
257 243
258static int __init zoom2_soc_init(void) 244static int __init zoom2_soc_init(void)
259{ 245{
260 int ret; 246 int ret;
261 247
262 if (!machine_is_omap_zoom2()) { 248 if (!machine_is_omap_zoom2())
263 pr_debug("Not Zoom2!\n");
264 return -ENODEV; 249 return -ENODEV;
265 }
266 printk(KERN_INFO "Zoom2 SoC init\n"); 250 printk(KERN_INFO "Zoom2 SoC init\n");
267 251
268 zoom2_snd_device = platform_device_alloc("soc-audio", -1); 252 zoom2_snd_device = platform_device_alloc("soc-audio", -1);
@@ -271,11 +255,7 @@ static int __init zoom2_soc_init(void)
271 return -ENOMEM; 255 return -ENOMEM;
272 } 256 }
273 257
274 platform_set_drvdata(zoom2_snd_device, &zoom2_snd_devdata); 258 platform_set_drvdata(zoom2_snd_device, &snd_soc_zoom2);
275 zoom2_snd_devdata.dev = &zoom2_snd_device->dev;
276 *(unsigned int *)zoom2_dai[0].cpu_dai->private_data = 1; /* McBSP2 */
277 *(unsigned int *)zoom2_dai[1].cpu_dai->private_data = 2; /* McBSP3 */
278
279 ret = platform_device_add(zoom2_snd_device); 259 ret = platform_device_add(zoom2_snd_device);
280 if (ret) 260 if (ret)
281 goto err1; 261 goto err1;