ASoC: wm8960: remove 'dres' field from platform data structure
[deliverable/linux.git] / sound / soc / codecs / twl4030.c
CommitLineData
cc17557e
SS
1/*
2 * ALSA SoC TWL4030 codec driver
3 *
4 * Author: Steve Sakoman, <steve@sakoman.com>
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * version 2 as published by the Free Software Foundation.
9 *
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
18 * 02110-1301 USA
19 *
20 */
21
22#include <linux/module.h>
23#include <linux/moduleparam.h>
24#include <linux/init.h>
25#include <linux/delay.h>
26#include <linux/pm.h>
27#include <linux/i2c.h>
28#include <linux/platform_device.h>
b07682b6 29#include <linux/i2c/twl.h>
5a0e3ad6 30#include <linux/slab.h>
cc17557e
SS
31#include <sound/core.h>
32#include <sound/pcm.h>
33#include <sound/pcm_params.h>
34#include <sound/soc.h>
cc17557e 35#include <sound/initval.h>
c10b82cf 36#include <sound/tlv.h>
cc17557e 37
f0fba2ad 38/* Register descriptions are here */
57fe7251 39#include <linux/mfd/twl4030-audio.h>
f0fba2ad
LG
40
41/* Shadow register used by the audio driver */
42#define TWL4030_REG_SW_SHADOW 0x4A
43#define TWL4030_CACHEREGNUM (TWL4030_REG_SW_SHADOW + 1)
44
45/* TWL4030_REG_SW_SHADOW (0x4A) Fields */
46#define TWL4030_HFL_EN 0x01
47#define TWL4030_HFR_EN 0x02
cc17557e
SS
48
49/*
50 * twl4030 register cache & default register settings
51 */
52static const u8 twl4030_reg[TWL4030_CACHEREGNUM] = {
53 0x00, /* this register not used */
33f92ed4 54 0x00, /* REG_CODEC_MODE (0x1) */
ee4ccac7 55 0x00, /* REG_OPTION (0x2) */
cc17557e
SS
56 0x00, /* REG_UNKNOWN (0x3) */
57 0x00, /* REG_MICBIAS_CTL (0x4) */
979bb1f4 58 0x00, /* REG_ANAMICL (0x5) */
5920b453
GI
59 0x00, /* REG_ANAMICR (0x6) */
60 0x00, /* REG_AVADC_CTL (0x7) */
cc17557e
SS
61 0x00, /* REG_ADCMICSEL (0x8) */
62 0x00, /* REG_DIGMIXING (0x9) */
33f92ed4
PU
63 0x0f, /* REG_ATXL1PGA (0xA) */
64 0x0f, /* REG_ATXR1PGA (0xB) */
65 0x0f, /* REG_AVTXL2PGA (0xC) */
66 0x0f, /* REG_AVTXR2PGA (0xD) */
c42a59ea 67 0x00, /* REG_AUDIO_IF (0xE) */
cc17557e 68 0x00, /* REG_VOICE_IF (0xF) */
33f92ed4
PU
69 0x3f, /* REG_ARXR1PGA (0x10) */
70 0x3f, /* REG_ARXL1PGA (0x11) */
71 0x3f, /* REG_ARXR2PGA (0x12) */
72 0x3f, /* REG_ARXL2PGA (0x13) */
73 0x25, /* REG_VRXPGA (0x14) */
cc17557e
SS
74 0x00, /* REG_VSTPGA (0x15) */
75 0x00, /* REG_VRX2ARXPGA (0x16) */
c8124593 76 0x00, /* REG_AVDAC_CTL (0x17) */
cc17557e 77 0x00, /* REG_ARX2VTXPGA (0x18) */
33f92ed4
PU
78 0x32, /* REG_ARXL1_APGA_CTL (0x19) */
79 0x32, /* REG_ARXR1_APGA_CTL (0x1A) */
80 0x32, /* REG_ARXL2_APGA_CTL (0x1B) */
81 0x32, /* REG_ARXR2_APGA_CTL (0x1C) */
cc17557e
SS
82 0x00, /* REG_ATX2ARXPGA (0x1D) */
83 0x00, /* REG_BT_IF (0x1E) */
33f92ed4 84 0x55, /* REG_BTPGA (0x1F) */
cc17557e
SS
85 0x00, /* REG_BTSTPGA (0x20) */
86 0x00, /* REG_EAR_CTL (0x21) */
e47c796d
PU
87 0x00, /* REG_HS_SEL (0x22) */
88 0x00, /* REG_HS_GAIN_SET (0x23) */
cc17557e
SS
89 0x00, /* REG_HS_POPN_SET (0x24) */
90 0x00, /* REG_PREDL_CTL (0x25) */
91 0x00, /* REG_PREDR_CTL (0x26) */
92 0x00, /* REG_PRECKL_CTL (0x27) */
93 0x00, /* REG_PRECKR_CTL (0x28) */
94 0x00, /* REG_HFL_CTL (0x29) */
95 0x00, /* REG_HFR_CTL (0x2A) */
33f92ed4 96 0x05, /* REG_ALC_CTL (0x2B) */
cc17557e
SS
97 0x00, /* REG_ALC_SET1 (0x2C) */
98 0x00, /* REG_ALC_SET2 (0x2D) */
99 0x00, /* REG_BOOST_CTL (0x2E) */
f8d05bdb 100 0x00, /* REG_SOFTVOL_CTL (0x2F) */
33f92ed4 101 0x13, /* REG_DTMF_FREQSEL (0x30) */
cc17557e
SS
102 0x00, /* REG_DTMF_TONEXT1H (0x31) */
103 0x00, /* REG_DTMF_TONEXT1L (0x32) */
104 0x00, /* REG_DTMF_TONEXT2H (0x33) */
105 0x00, /* REG_DTMF_TONEXT2L (0x34) */
33f92ed4
PU
106 0x79, /* REG_DTMF_TONOFF (0x35) */
107 0x11, /* REG_DTMF_WANONOFF (0x36) */
cc17557e
SS
108 0x00, /* REG_I2S_RX_SCRAMBLE_H (0x37) */
109 0x00, /* REG_I2S_RX_SCRAMBLE_M (0x38) */
110 0x00, /* REG_I2S_RX_SCRAMBLE_L (0x39) */
c8124593 111 0x06, /* REG_APLL_CTL (0x3A) */
cc17557e 112 0x00, /* REG_DTMF_CTL (0x3B) */
33f92ed4
PU
113 0x44, /* REG_DTMF_PGA_CTL2 (0x3C) */
114 0x69, /* REG_DTMF_PGA_CTL1 (0x3D) */
cc17557e
SS
115 0x00, /* REG_MISC_SET_1 (0x3E) */
116 0x00, /* REG_PCMBTMUX (0x3F) */
117 0x00, /* not used (0x40) */
118 0x00, /* not used (0x41) */
119 0x00, /* not used (0x42) */
120 0x00, /* REG_RX_PATH_SEL (0x43) */
33f92ed4 121 0x32, /* REG_VDL_APGA_CTL (0x44) */
cc17557e
SS
122 0x00, /* REG_VIBRA_CTL (0x45) */
123 0x00, /* REG_VIBRA_SET (0x46) */
124 0x00, /* REG_VIBRA_PWM_SET (0x47) */
125 0x00, /* REG_ANAMIC_GAIN (0x48) */
126 0x00, /* REG_MISC_SET_2 (0x49) */
f3b5d300 127 0x00, /* REG_SW_SHADOW (0x4A) - Shadow, non HW register */
cc17557e
SS
128};
129
7393958f
PU
130/* codec private data */
131struct twl4030_priv {
7a1fecf5
PU
132 struct snd_soc_codec codec;
133
7393958f 134 unsigned int codec_powered;
7b4c734e
PU
135
136 /* reference counts of AIF/APLL users */
2845fa13 137 unsigned int apll_enabled;
7220b9f4
PU
138
139 struct snd_pcm_substream *master_substream;
140 struct snd_pcm_substream *slave_substream;
6b87a91f
PU
141
142 unsigned int configured;
143 unsigned int rate;
144 unsigned int sample_bits;
145 unsigned int channels;
6943c92e
PU
146
147 unsigned int sysclk;
148
c96907f2
PU
149 /* Output (with associated amp) states */
150 u8 hsl_enabled, hsr_enabled;
151 u8 earpiece_enabled;
152 u8 predrivel_enabled, predriver_enabled;
153 u8 carkitl_enabled, carkitr_enabled;
01ea6ba2
PU
154
155 /* Delay needed after enabling the digimic interface */
156 unsigned int digimic_delay;
7393958f
PU
157};
158
cc17557e
SS
159/*
160 * read twl4030 register cache
161 */
162static inline unsigned int twl4030_read_reg_cache(struct snd_soc_codec *codec,
163 unsigned int reg)
164{
d08664fd 165 u8 *cache = codec->reg_cache;
cc17557e 166
91432e97
IM
167 if (reg >= TWL4030_CACHEREGNUM)
168 return -EIO;
169
cc17557e
SS
170 return cache[reg];
171}
172
173/*
174 * write twl4030 register cache
175 */
176static inline void twl4030_write_reg_cache(struct snd_soc_codec *codec,
177 u8 reg, u8 value)
178{
179 u8 *cache = codec->reg_cache;
180
181 if (reg >= TWL4030_CACHEREGNUM)
182 return;
183 cache[reg] = value;
184}
185
186/*
187 * write to the twl4030 register space
188 */
189static int twl4030_write(struct snd_soc_codec *codec,
190 unsigned int reg, unsigned int value)
191{
b2c812e2 192 struct twl4030_priv *twl4030 = snd_soc_codec_get_drvdata(codec);
c96907f2
PU
193 int write_to_reg = 0;
194
cc17557e 195 twl4030_write_reg_cache(codec, reg, value);
c96907f2
PU
196 if (likely(reg < TWL4030_REG_SW_SHADOW)) {
197 /* Decide if the given register can be written */
198 switch (reg) {
199 case TWL4030_REG_EAR_CTL:
200 if (twl4030->earpiece_enabled)
201 write_to_reg = 1;
202 break;
203 case TWL4030_REG_PREDL_CTL:
204 if (twl4030->predrivel_enabled)
205 write_to_reg = 1;
206 break;
207 case TWL4030_REG_PREDR_CTL:
208 if (twl4030->predriver_enabled)
209 write_to_reg = 1;
210 break;
211 case TWL4030_REG_PRECKL_CTL:
212 if (twl4030->carkitl_enabled)
213 write_to_reg = 1;
214 break;
215 case TWL4030_REG_PRECKR_CTL:
216 if (twl4030->carkitr_enabled)
217 write_to_reg = 1;
218 break;
219 case TWL4030_REG_HS_GAIN_SET:
220 if (twl4030->hsl_enabled || twl4030->hsr_enabled)
221 write_to_reg = 1;
222 break;
223 default:
224 /* All other register can be written */
225 write_to_reg = 1;
226 break;
227 }
228 if (write_to_reg)
229 return twl_i2c_write_u8(TWL4030_MODULE_AUDIO_VOICE,
230 value, reg);
231 }
232 return 0;
cc17557e
SS
233}
234
7e6120c5
PU
235static inline void twl4030_wait_ms(int time)
236{
237 if (time < 60) {
238 time *= 1000;
239 usleep_range(time, time + 500);
240 } else {
241 msleep(time);
242 }
243}
244
db04e2c5 245static void twl4030_codec_enable(struct snd_soc_codec *codec, int enable)
cc17557e 246{
b2c812e2 247 struct twl4030_priv *twl4030 = snd_soc_codec_get_drvdata(codec);
7a1fecf5 248 int mode;
cc17557e 249
7393958f
PU
250 if (enable == twl4030->codec_powered)
251 return;
252
db04e2c5 253 if (enable)
57fe7251 254 mode = twl4030_audio_enable_resource(TWL4030_AUDIO_RES_POWER);
db04e2c5 255 else
57fe7251 256 mode = twl4030_audio_disable_resource(TWL4030_AUDIO_RES_POWER);
cc17557e 257
7a1fecf5
PU
258 if (mode >= 0) {
259 twl4030_write_reg_cache(codec, TWL4030_REG_CODEC_MODE, mode);
260 twl4030->codec_powered = enable;
261 }
cc17557e
SS
262
263 /* REVISIT: this delay is present in TI sample drivers */
264 /* but there seems to be no TRM requirement for it */
265 udelay(10);
266}
267
9fdcc0f7 268static inline void twl4030_check_defaults(struct snd_soc_codec *codec)
cc17557e 269{
9fdcc0f7
PU
270 int i, difference = 0;
271 u8 val;
272
273 dev_dbg(codec->dev, "Checking TWL audio default configuration\n");
274 for (i = 1; i <= TWL4030_REG_MISC_SET_2; i++) {
275 twl_i2c_read_u8(TWL4030_MODULE_AUDIO_VOICE, &val, i);
276 if (val != twl4030_reg[i]) {
277 difference++;
278 dev_dbg(codec->dev,
279 "Reg 0x%02x: chip: 0x%02x driver: 0x%02x\n",
280 i, val, twl4030_reg[i]);
281 }
282 }
25985edc 283 dev_dbg(codec->dev, "Found %d non-matching registers. %s\n",
9fdcc0f7
PU
284 difference, difference ? "Not OK" : "OK");
285}
cc17557e 286
a3a29b55
PU
287static inline void twl4030_reset_registers(struct snd_soc_codec *codec)
288{
289 int i;
cc17557e
SS
290
291 /* set all audio section registers to reasonable defaults */
292 for (i = TWL4030_REG_OPTION; i <= TWL4030_REG_MISC_SET_2; i++)
68d01955 293 if (i != TWL4030_REG_APLL_CTL)
a3a29b55 294 twl4030_write(codec, i, twl4030_reg[i]);
cc17557e
SS
295
296}
297
f0fba2ad 298static void twl4030_init_chip(struct snd_soc_codec *codec)
7393958f 299{
4ae6df5e 300 struct twl4030_codec_data *pdata = dev_get_platdata(codec->dev);
b2c812e2 301 struct twl4030_priv *twl4030 = snd_soc_codec_get_drvdata(codec);
ee4ccac7
PU
302 u8 reg, byte;
303 int i = 0;
7393958f 304
9fdcc0f7 305 /* Check defaults, if instructed before anything else */
f0fba2ad 306 if (pdata && pdata->check_defaults)
9fdcc0f7 307 twl4030_check_defaults(codec);
7a1fecf5 308
a3a29b55 309 /* Reset registers, if no setup data or if instructed to do so */
f0fba2ad 310 if (!pdata || (pdata && pdata->reset_registers))
a3a29b55 311 twl4030_reset_registers(codec);
7393958f 312
ee4ccac7 313 /* Refresh APLL_CTL register from HW */
9fdcc0f7 314 twl_i2c_read_u8(TWL4030_MODULE_AUDIO_VOICE, &byte,
ee4ccac7
PU
315 TWL4030_REG_APLL_CTL);
316 twl4030_write_reg_cache(codec, TWL4030_REG_APLL_CTL, byte);
006f367e 317
ee4ccac7
PU
318 /* anti-pop when changing analog gain */
319 reg = twl4030_read_reg_cache(codec, TWL4030_REG_MISC_SET_1);
320 twl4030_write(codec, TWL4030_REG_MISC_SET_1,
321 reg | TWL4030_SMOOTH_ANAVOL_EN);
7393958f 322
ee4ccac7
PU
323 twl4030_write(codec, TWL4030_REG_OPTION,
324 TWL4030_ATXL1_EN | TWL4030_ATXR1_EN |
325 TWL4030_ARXL2_EN | TWL4030_ARXR2_EN);
006f367e 326
3c36cc68
PU
327 /* REG_ARXR2_APGA_CTL reset according to the TRM: 0dB, DA_EN */
328 twl4030_write(codec, TWL4030_REG_ARXR2_APGA_CTL, 0x32);
329
ee4ccac7 330 /* Machine dependent setup */
f0fba2ad 331 if (!pdata)
7393958f
PU
332 return;
333
f0fba2ad 334 twl4030->digimic_delay = pdata->digimic_delay;
ee4ccac7
PU
335
336 reg = twl4030_read_reg_cache(codec, TWL4030_REG_HS_POPN_SET);
337 reg &= ~TWL4030_RAMP_DELAY;
f0fba2ad 338 reg |= (pdata->ramp_delay_value << 2);
ee4ccac7 339 twl4030_write_reg_cache(codec, TWL4030_REG_HS_POPN_SET, reg);
006f367e
PU
340
341 /* initiate offset cancellation */
ee4ccac7
PU
342 twl4030_codec_enable(codec, 1);
343
344 reg = twl4030_read_reg_cache(codec, TWL4030_REG_ANAMICL);
345 reg &= ~TWL4030_OFFSET_CNCL_SEL;
f0fba2ad 346 reg |= pdata->offset_cncl_path;
006f367e 347 twl4030_write(codec, TWL4030_REG_ANAMICL,
ee4ccac7 348 reg | TWL4030_CNCL_OFFSET_START);
006f367e 349
7e6120c5
PU
350 /*
351 * Wait for offset cancellation to complete.
352 * Since this takes a while, do not slam the i2c.
353 * Start polling the status after ~20ms.
354 */
355 msleep(20);
006f367e 356 do {
7e6120c5 357 usleep_range(1000, 2000);
fc7b92fc 358 twl_i2c_read_u8(TWL4030_MODULE_AUDIO_VOICE, &byte,
006f367e
PU
359 TWL4030_REG_ANAMICL);
360 } while ((i++ < 100) &&
361 ((byte & TWL4030_CNCL_OFFSET_START) ==
362 TWL4030_CNCL_OFFSET_START));
363
364 /* Make sure that the reg_cache has the same value as the HW */
365 twl4030_write_reg_cache(codec, TWL4030_REG_ANAMICL, byte);
366
006f367e 367 twl4030_codec_enable(codec, 0);
006f367e
PU
368}
369
ee4ccac7 370static void twl4030_apll_enable(struct snd_soc_codec *codec, int enable)
006f367e 371{
ee4ccac7
PU
372 struct twl4030_priv *twl4030 = snd_soc_codec_get_drvdata(codec);
373 int status = -1;
374
375 if (enable) {
376 twl4030->apll_enabled++;
377 if (twl4030->apll_enabled == 1)
57fe7251
PU
378 status = twl4030_audio_enable_resource(
379 TWL4030_AUDIO_RES_APLL);
ee4ccac7
PU
380 } else {
381 twl4030->apll_enabled--;
382 if (!twl4030->apll_enabled)
57fe7251
PU
383 status = twl4030_audio_disable_resource(
384 TWL4030_AUDIO_RES_APLL);
ee4ccac7
PU
385 }
386
387 if (status >= 0)
388 twl4030_write_reg_cache(codec, TWL4030_REG_APLL_CTL, status);
006f367e
PU
389}
390
5e98a464 391/* Earpiece */
1a787e7a
JS
392static const struct snd_kcontrol_new twl4030_dapm_earpiece_controls[] = {
393 SOC_DAPM_SINGLE("Voice", TWL4030_REG_EAR_CTL, 0, 1, 0),
394 SOC_DAPM_SINGLE("AudioL1", TWL4030_REG_EAR_CTL, 1, 1, 0),
395 SOC_DAPM_SINGLE("AudioL2", TWL4030_REG_EAR_CTL, 2, 1, 0),
396 SOC_DAPM_SINGLE("AudioR1", TWL4030_REG_EAR_CTL, 3, 1, 0),
397};
5e98a464 398
2a6f5c58 399/* PreDrive Left */
1a787e7a
JS
400static const struct snd_kcontrol_new twl4030_dapm_predrivel_controls[] = {
401 SOC_DAPM_SINGLE("Voice", TWL4030_REG_PREDL_CTL, 0, 1, 0),
402 SOC_DAPM_SINGLE("AudioL1", TWL4030_REG_PREDL_CTL, 1, 1, 0),
403 SOC_DAPM_SINGLE("AudioL2", TWL4030_REG_PREDL_CTL, 2, 1, 0),
404 SOC_DAPM_SINGLE("AudioR2", TWL4030_REG_PREDL_CTL, 3, 1, 0),
405};
2a6f5c58
PU
406
407/* PreDrive Right */
1a787e7a
JS
408static const struct snd_kcontrol_new twl4030_dapm_predriver_controls[] = {
409 SOC_DAPM_SINGLE("Voice", TWL4030_REG_PREDR_CTL, 0, 1, 0),
410 SOC_DAPM_SINGLE("AudioR1", TWL4030_REG_PREDR_CTL, 1, 1, 0),
411 SOC_DAPM_SINGLE("AudioR2", TWL4030_REG_PREDR_CTL, 2, 1, 0),
412 SOC_DAPM_SINGLE("AudioL2", TWL4030_REG_PREDR_CTL, 3, 1, 0),
413};
2a6f5c58 414
dfad21a2 415/* Headset Left */
1a787e7a
JS
416static const struct snd_kcontrol_new twl4030_dapm_hsol_controls[] = {
417 SOC_DAPM_SINGLE("Voice", TWL4030_REG_HS_SEL, 0, 1, 0),
418 SOC_DAPM_SINGLE("AudioL1", TWL4030_REG_HS_SEL, 1, 1, 0),
419 SOC_DAPM_SINGLE("AudioL2", TWL4030_REG_HS_SEL, 2, 1, 0),
420};
dfad21a2
PU
421
422/* Headset Right */
1a787e7a
JS
423static const struct snd_kcontrol_new twl4030_dapm_hsor_controls[] = {
424 SOC_DAPM_SINGLE("Voice", TWL4030_REG_HS_SEL, 3, 1, 0),
425 SOC_DAPM_SINGLE("AudioR1", TWL4030_REG_HS_SEL, 4, 1, 0),
426 SOC_DAPM_SINGLE("AudioR2", TWL4030_REG_HS_SEL, 5, 1, 0),
427};
dfad21a2 428
5152d8c2 429/* Carkit Left */
1a787e7a
JS
430static const struct snd_kcontrol_new twl4030_dapm_carkitl_controls[] = {
431 SOC_DAPM_SINGLE("Voice", TWL4030_REG_PRECKL_CTL, 0, 1, 0),
432 SOC_DAPM_SINGLE("AudioL1", TWL4030_REG_PRECKL_CTL, 1, 1, 0),
433 SOC_DAPM_SINGLE("AudioL2", TWL4030_REG_PRECKL_CTL, 2, 1, 0),
434};
5152d8c2
PU
435
436/* Carkit Right */
1a787e7a
JS
437static const struct snd_kcontrol_new twl4030_dapm_carkitr_controls[] = {
438 SOC_DAPM_SINGLE("Voice", TWL4030_REG_PRECKR_CTL, 0, 1, 0),
439 SOC_DAPM_SINGLE("AudioR1", TWL4030_REG_PRECKR_CTL, 1, 1, 0),
440 SOC_DAPM_SINGLE("AudioR2", TWL4030_REG_PRECKR_CTL, 2, 1, 0),
441};
5152d8c2 442
df339804
PU
443/* Handsfree Left */
444static const char *twl4030_handsfreel_texts[] =
1a787e7a 445 {"Voice", "AudioL1", "AudioL2", "AudioR2"};
df339804
PU
446
447static const struct soc_enum twl4030_handsfreel_enum =
448 SOC_ENUM_SINGLE(TWL4030_REG_HFL_CTL, 0,
449 ARRAY_SIZE(twl4030_handsfreel_texts),
450 twl4030_handsfreel_texts);
451
452static const struct snd_kcontrol_new twl4030_dapm_handsfreel_control =
453SOC_DAPM_ENUM("Route", twl4030_handsfreel_enum);
454
0f89bdca
PU
455/* Handsfree Left virtual mute */
456static const struct snd_kcontrol_new twl4030_dapm_handsfreelmute_control =
457 SOC_DAPM_SINGLE("Switch", TWL4030_REG_SW_SHADOW, 0, 1, 0);
458
df339804
PU
459/* Handsfree Right */
460static const char *twl4030_handsfreer_texts[] =
1a787e7a 461 {"Voice", "AudioR1", "AudioR2", "AudioL2"};
df339804
PU
462
463static const struct soc_enum twl4030_handsfreer_enum =
464 SOC_ENUM_SINGLE(TWL4030_REG_HFR_CTL, 0,
465 ARRAY_SIZE(twl4030_handsfreer_texts),
466 twl4030_handsfreer_texts);
467
468static const struct snd_kcontrol_new twl4030_dapm_handsfreer_control =
469SOC_DAPM_ENUM("Route", twl4030_handsfreer_enum);
470
0f89bdca
PU
471/* Handsfree Right virtual mute */
472static const struct snd_kcontrol_new twl4030_dapm_handsfreermute_control =
473 SOC_DAPM_SINGLE("Switch", TWL4030_REG_SW_SHADOW, 1, 1, 0);
474
376f7839
PU
475/* Vibra */
476/* Vibra audio path selection */
477static const char *twl4030_vibra_texts[] =
478 {"AudioL1", "AudioR1", "AudioL2", "AudioR2"};
479
480static const struct soc_enum twl4030_vibra_enum =
481 SOC_ENUM_SINGLE(TWL4030_REG_VIBRA_CTL, 2,
482 ARRAY_SIZE(twl4030_vibra_texts),
483 twl4030_vibra_texts);
484
485static const struct snd_kcontrol_new twl4030_dapm_vibra_control =
486SOC_DAPM_ENUM("Route", twl4030_vibra_enum);
487
488/* Vibra path selection: local vibrator (PWM) or audio driven */
489static const char *twl4030_vibrapath_texts[] =
490 {"Local vibrator", "Audio"};
491
492static const struct soc_enum twl4030_vibrapath_enum =
493 SOC_ENUM_SINGLE(TWL4030_REG_VIBRA_CTL, 4,
494 ARRAY_SIZE(twl4030_vibrapath_texts),
495 twl4030_vibrapath_texts);
496
497static const struct snd_kcontrol_new twl4030_dapm_vibrapath_control =
498SOC_DAPM_ENUM("Route", twl4030_vibrapath_enum);
499
276c6222 500/* Left analog microphone selection */
97b8096d 501static const struct snd_kcontrol_new twl4030_dapm_analoglmic_controls[] = {
9028935d
PU
502 SOC_DAPM_SINGLE("Main Mic Capture Switch",
503 TWL4030_REG_ANAMICL, 0, 1, 0),
504 SOC_DAPM_SINGLE("Headset Mic Capture Switch",
505 TWL4030_REG_ANAMICL, 1, 1, 0),
506 SOC_DAPM_SINGLE("AUXL Capture Switch",
507 TWL4030_REG_ANAMICL, 2, 1, 0),
508 SOC_DAPM_SINGLE("Carkit Mic Capture Switch",
509 TWL4030_REG_ANAMICL, 3, 1, 0),
97b8096d 510};
276c6222
PU
511
512/* Right analog microphone selection */
97b8096d 513static const struct snd_kcontrol_new twl4030_dapm_analogrmic_controls[] = {
9028935d
PU
514 SOC_DAPM_SINGLE("Sub Mic Capture Switch", TWL4030_REG_ANAMICR, 0, 1, 0),
515 SOC_DAPM_SINGLE("AUXR Capture Switch", TWL4030_REG_ANAMICR, 2, 1, 0),
97b8096d 516};
276c6222
PU
517
518/* TX1 L/R Analog/Digital microphone selection */
519static const char *twl4030_micpathtx1_texts[] =
520 {"Analog", "Digimic0"};
521
522static const struct soc_enum twl4030_micpathtx1_enum =
523 SOC_ENUM_SINGLE(TWL4030_REG_ADCMICSEL, 0,
524 ARRAY_SIZE(twl4030_micpathtx1_texts),
525 twl4030_micpathtx1_texts);
526
527static const struct snd_kcontrol_new twl4030_dapm_micpathtx1_control =
528SOC_DAPM_ENUM("Route", twl4030_micpathtx1_enum);
529
530/* TX2 L/R Analog/Digital microphone selection */
531static const char *twl4030_micpathtx2_texts[] =
532 {"Analog", "Digimic1"};
533
534static const struct soc_enum twl4030_micpathtx2_enum =
535 SOC_ENUM_SINGLE(TWL4030_REG_ADCMICSEL, 2,
536 ARRAY_SIZE(twl4030_micpathtx2_texts),
537 twl4030_micpathtx2_texts);
538
539static const struct snd_kcontrol_new twl4030_dapm_micpathtx2_control =
540SOC_DAPM_ENUM("Route", twl4030_micpathtx2_enum);
541
7393958f
PU
542/* Analog bypass for AudioR1 */
543static const struct snd_kcontrol_new twl4030_dapm_abypassr1_control =
544 SOC_DAPM_SINGLE("Switch", TWL4030_REG_ARXR1_APGA_CTL, 2, 1, 0);
545
546/* Analog bypass for AudioL1 */
547static const struct snd_kcontrol_new twl4030_dapm_abypassl1_control =
548 SOC_DAPM_SINGLE("Switch", TWL4030_REG_ARXL1_APGA_CTL, 2, 1, 0);
549
550/* Analog bypass for AudioR2 */
551static const struct snd_kcontrol_new twl4030_dapm_abypassr2_control =
552 SOC_DAPM_SINGLE("Switch", TWL4030_REG_ARXR2_APGA_CTL, 2, 1, 0);
553
554/* Analog bypass for AudioL2 */
555static const struct snd_kcontrol_new twl4030_dapm_abypassl2_control =
556 SOC_DAPM_SINGLE("Switch", TWL4030_REG_ARXL2_APGA_CTL, 2, 1, 0);
557
fcd274a3
LCM
558/* Analog bypass for Voice */
559static const struct snd_kcontrol_new twl4030_dapm_abypassv_control =
560 SOC_DAPM_SINGLE("Switch", TWL4030_REG_VDL_APGA_CTL, 2, 1, 0);
561
8b0d3153 562/* Digital bypass gain, mute instead of -30dB */
6bab83fd 563static const unsigned int twl4030_dapm_dbypass_tlv[] = {
8b0d3153
PU
564 TLV_DB_RANGE_HEAD(3),
565 0, 1, TLV_DB_SCALE_ITEM(-3000, 600, 1),
566 2, 3, TLV_DB_SCALE_ITEM(-2400, 0, 0),
6bab83fd
PU
567 4, 7, TLV_DB_SCALE_ITEM(-1800, 600, 0),
568};
569
570/* Digital bypass left (TX1L -> RX2L) */
571static const struct snd_kcontrol_new twl4030_dapm_dbypassl_control =
572 SOC_DAPM_SINGLE_TLV("Volume",
573 TWL4030_REG_ATX2ARXPGA, 3, 7, 0,
574 twl4030_dapm_dbypass_tlv);
575
576/* Digital bypass right (TX1R -> RX2R) */
577static const struct snd_kcontrol_new twl4030_dapm_dbypassr_control =
578 SOC_DAPM_SINGLE_TLV("Volume",
579 TWL4030_REG_ATX2ARXPGA, 0, 7, 0,
580 twl4030_dapm_dbypass_tlv);
581
ee8f6894
LCM
582/*
583 * Voice Sidetone GAIN volume control:
584 * from -51 to -10 dB in 1 dB steps (mute instead of -51 dB)
585 */
586static DECLARE_TLV_DB_SCALE(twl4030_dapm_dbypassv_tlv, -5100, 100, 1);
587
588/* Digital bypass voice: sidetone (VUL -> VDL)*/
589static const struct snd_kcontrol_new twl4030_dapm_dbypassv_control =
590 SOC_DAPM_SINGLE_TLV("Volume",
591 TWL4030_REG_VSTPGA, 0, 0x29, 0,
592 twl4030_dapm_dbypassv_tlv);
593
9008adf9
PU
594/*
595 * Output PGA builder:
596 * Handle the muting and unmuting of the given output (turning off the
597 * amplifier associated with the output pin)
c96907f2
PU
598 * On mute bypass the reg_cache and write 0 to the register
599 * On unmute: restore the register content from the reg_cache
9008adf9
PU
600 * Outputs handled in this way: Earpiece, PreDrivL/R, CarkitL/R
601 */
602#define TWL4030_OUTPUT_PGA(pin_name, reg, mask) \
603static int pin_name##pga_event(struct snd_soc_dapm_widget *w, \
604 struct snd_kcontrol *kcontrol, int event) \
605{ \
b2c812e2 606 struct twl4030_priv *twl4030 = snd_soc_codec_get_drvdata(w->codec); \
9008adf9
PU
607 \
608 switch (event) { \
609 case SND_SOC_DAPM_POST_PMU: \
c96907f2 610 twl4030->pin_name##_enabled = 1; \
9008adf9
PU
611 twl4030_write(w->codec, reg, \
612 twl4030_read_reg_cache(w->codec, reg)); \
613 break; \
614 case SND_SOC_DAPM_POST_PMD: \
c96907f2
PU
615 twl4030->pin_name##_enabled = 0; \
616 twl_i2c_write_u8(TWL4030_MODULE_AUDIO_VOICE, \
617 0, reg); \
9008adf9
PU
618 break; \
619 } \
620 return 0; \
621}
622
623TWL4030_OUTPUT_PGA(earpiece, TWL4030_REG_EAR_CTL, TWL4030_EAR_GAIN);
624TWL4030_OUTPUT_PGA(predrivel, TWL4030_REG_PREDL_CTL, TWL4030_PREDL_GAIN);
625TWL4030_OUTPUT_PGA(predriver, TWL4030_REG_PREDR_CTL, TWL4030_PREDR_GAIN);
626TWL4030_OUTPUT_PGA(carkitl, TWL4030_REG_PRECKL_CTL, TWL4030_PRECKL_GAIN);
627TWL4030_OUTPUT_PGA(carkitr, TWL4030_REG_PRECKR_CTL, TWL4030_PRECKR_GAIN);
628
5a2e9a48 629static void handsfree_ramp(struct snd_soc_codec *codec, int reg, int ramp)
49d92c7d 630{
49d92c7d
SM
631 unsigned char hs_ctl;
632
5a2e9a48 633 hs_ctl = twl4030_read_reg_cache(codec, reg);
49d92c7d 634
5a2e9a48
PU
635 if (ramp) {
636 /* HF ramp-up */
637 hs_ctl |= TWL4030_HF_CTL_REF_EN;
638 twl4030_write(codec, reg, hs_ctl);
639 udelay(10);
49d92c7d 640 hs_ctl |= TWL4030_HF_CTL_RAMP_EN;
5a2e9a48
PU
641 twl4030_write(codec, reg, hs_ctl);
642 udelay(40);
49d92c7d 643 hs_ctl |= TWL4030_HF_CTL_LOOP_EN;
49d92c7d 644 hs_ctl |= TWL4030_HF_CTL_HB_EN;
5a2e9a48 645 twl4030_write(codec, reg, hs_ctl);
49d92c7d 646 } else {
5a2e9a48
PU
647 /* HF ramp-down */
648 hs_ctl &= ~TWL4030_HF_CTL_LOOP_EN;
649 hs_ctl &= ~TWL4030_HF_CTL_HB_EN;
650 twl4030_write(codec, reg, hs_ctl);
651 hs_ctl &= ~TWL4030_HF_CTL_RAMP_EN;
652 twl4030_write(codec, reg, hs_ctl);
653 udelay(40);
654 hs_ctl &= ~TWL4030_HF_CTL_REF_EN;
655 twl4030_write(codec, reg, hs_ctl);
49d92c7d 656 }
5a2e9a48 657}
49d92c7d 658
5a2e9a48
PU
659static int handsfreelpga_event(struct snd_soc_dapm_widget *w,
660 struct snd_kcontrol *kcontrol, int event)
661{
662 switch (event) {
663 case SND_SOC_DAPM_POST_PMU:
664 handsfree_ramp(w->codec, TWL4030_REG_HFL_CTL, 1);
665 break;
666 case SND_SOC_DAPM_POST_PMD:
667 handsfree_ramp(w->codec, TWL4030_REG_HFL_CTL, 0);
668 break;
669 }
670 return 0;
671}
672
673static int handsfreerpga_event(struct snd_soc_dapm_widget *w,
674 struct snd_kcontrol *kcontrol, int event)
675{
676 switch (event) {
677 case SND_SOC_DAPM_POST_PMU:
678 handsfree_ramp(w->codec, TWL4030_REG_HFR_CTL, 1);
679 break;
680 case SND_SOC_DAPM_POST_PMD:
681 handsfree_ramp(w->codec, TWL4030_REG_HFR_CTL, 0);
682 break;
683 }
49d92c7d
SM
684 return 0;
685}
686
86139a13
JV
687static int vibramux_event(struct snd_soc_dapm_widget *w,
688 struct snd_kcontrol *kcontrol, int event)
689{
690 twl4030_write(w->codec, TWL4030_REG_VIBRA_SET, 0xff);
691 return 0;
692}
693
7729cf74
PU
694static int apll_event(struct snd_soc_dapm_widget *w,
695 struct snd_kcontrol *kcontrol, int event)
696{
697 switch (event) {
698 case SND_SOC_DAPM_PRE_PMU:
699 twl4030_apll_enable(w->codec, 1);
700 break;
701 case SND_SOC_DAPM_POST_PMD:
702 twl4030_apll_enable(w->codec, 0);
703 break;
704 }
705 return 0;
706}
707
7b4c734e
PU
708static int aif_event(struct snd_soc_dapm_widget *w,
709 struct snd_kcontrol *kcontrol, int event)
710{
711 u8 audio_if;
712
713 audio_if = twl4030_read_reg_cache(w->codec, TWL4030_REG_AUDIO_IF);
714 switch (event) {
715 case SND_SOC_DAPM_PRE_PMU:
716 /* Enable AIF */
717 /* enable the PLL before we use it to clock the DAI */
718 twl4030_apll_enable(w->codec, 1);
719
720 twl4030_write(w->codec, TWL4030_REG_AUDIO_IF,
721 audio_if | TWL4030_AIF_EN);
722 break;
723 case SND_SOC_DAPM_POST_PMD:
724 /* disable the DAI before we stop it's source PLL */
725 twl4030_write(w->codec, TWL4030_REG_AUDIO_IF,
726 audio_if & ~TWL4030_AIF_EN);
727 twl4030_apll_enable(w->codec, 0);
728 break;
729 }
730 return 0;
731}
732
6943c92e 733static void headset_ramp(struct snd_soc_codec *codec, int ramp)
aad749e5 734{
4ae6df5e 735 struct twl4030_codec_data *pdata = codec->dev->platform_data;
aad749e5 736 unsigned char hs_gain, hs_pop;
b2c812e2 737 struct twl4030_priv *twl4030 = snd_soc_codec_get_drvdata(codec);
6943c92e
PU
738 /* Base values for ramp delay calculation: 2^19 - 2^26 */
739 unsigned int ramp_base[] = {524288, 1048576, 2097152, 4194304,
740 8388608, 16777216, 33554432, 67108864};
7e6120c5 741 unsigned int delay;
aad749e5 742
6943c92e
PU
743 hs_gain = twl4030_read_reg_cache(codec, TWL4030_REG_HS_GAIN_SET);
744 hs_pop = twl4030_read_reg_cache(codec, TWL4030_REG_HS_POPN_SET);
7e6120c5
PU
745 delay = (ramp_base[(hs_pop & TWL4030_RAMP_DELAY) >> 2] /
746 twl4030->sysclk) + 1;
aad749e5 747
4e49ffd1
CVJ
748 /* Enable external mute control, this dramatically reduces
749 * the pop-noise */
f0fba2ad
LG
750 if (pdata && pdata->hs_extmute) {
751 if (pdata->set_hs_extmute) {
752 pdata->set_hs_extmute(1);
4e49ffd1
CVJ
753 } else {
754 hs_pop |= TWL4030_EXTMUTE;
755 twl4030_write(codec, TWL4030_REG_HS_POPN_SET, hs_pop);
756 }
757 }
758
6943c92e
PU
759 if (ramp) {
760 /* Headset ramp-up according to the TRM */
aad749e5 761 hs_pop |= TWL4030_VMID_EN;
6943c92e 762 twl4030_write(codec, TWL4030_REG_HS_POPN_SET, hs_pop);
c96907f2
PU
763 /* Actually write to the register */
764 twl_i2c_write_u8(TWL4030_MODULE_AUDIO_VOICE,
765 hs_gain,
766 TWL4030_REG_HS_GAIN_SET);
aad749e5 767 hs_pop |= TWL4030_RAMP_EN;
6943c92e 768 twl4030_write(codec, TWL4030_REG_HS_POPN_SET, hs_pop);
4e49ffd1 769 /* Wait ramp delay time + 1, so the VMID can settle */
7e6120c5 770 twl4030_wait_ms(delay);
6943c92e
PU
771 } else {
772 /* Headset ramp-down _not_ according to
773 * the TRM, but in a way that it is working */
aad749e5 774 hs_pop &= ~TWL4030_RAMP_EN;
6943c92e
PU
775 twl4030_write(codec, TWL4030_REG_HS_POPN_SET, hs_pop);
776 /* Wait ramp delay time + 1, so the VMID can settle */
7e6120c5 777 twl4030_wait_ms(delay);
aad749e5 778 /* Bypass the reg_cache to mute the headset */
fc7b92fc 779 twl_i2c_write_u8(TWL4030_MODULE_AUDIO_VOICE,
aad749e5
PU
780 hs_gain & (~0x0f),
781 TWL4030_REG_HS_GAIN_SET);
6943c92e 782
aad749e5 783 hs_pop &= ~TWL4030_VMID_EN;
6943c92e
PU
784 twl4030_write(codec, TWL4030_REG_HS_POPN_SET, hs_pop);
785 }
4e49ffd1
CVJ
786
787 /* Disable external mute */
f0fba2ad
LG
788 if (pdata && pdata->hs_extmute) {
789 if (pdata->set_hs_extmute) {
790 pdata->set_hs_extmute(0);
4e49ffd1
CVJ
791 } else {
792 hs_pop &= ~TWL4030_EXTMUTE;
793 twl4030_write(codec, TWL4030_REG_HS_POPN_SET, hs_pop);
794 }
795 }
6943c92e
PU
796}
797
798static int headsetlpga_event(struct snd_soc_dapm_widget *w,
799 struct snd_kcontrol *kcontrol, int event)
800{
b2c812e2 801 struct twl4030_priv *twl4030 = snd_soc_codec_get_drvdata(w->codec);
6943c92e
PU
802
803 switch (event) {
804 case SND_SOC_DAPM_POST_PMU:
805 /* Do the ramp-up only once */
806 if (!twl4030->hsr_enabled)
807 headset_ramp(w->codec, 1);
808
809 twl4030->hsl_enabled = 1;
810 break;
811 case SND_SOC_DAPM_POST_PMD:
812 /* Do the ramp-down only if both headsetL/R is disabled */
813 if (!twl4030->hsr_enabled)
814 headset_ramp(w->codec, 0);
815
816 twl4030->hsl_enabled = 0;
817 break;
818 }
819 return 0;
820}
821
822static int headsetrpga_event(struct snd_soc_dapm_widget *w,
823 struct snd_kcontrol *kcontrol, int event)
824{
b2c812e2 825 struct twl4030_priv *twl4030 = snd_soc_codec_get_drvdata(w->codec);
6943c92e
PU
826
827 switch (event) {
828 case SND_SOC_DAPM_POST_PMU:
829 /* Do the ramp-up only once */
830 if (!twl4030->hsl_enabled)
831 headset_ramp(w->codec, 1);
832
833 twl4030->hsr_enabled = 1;
834 break;
835 case SND_SOC_DAPM_POST_PMD:
836 /* Do the ramp-down only if both headsetL/R is disabled */
837 if (!twl4030->hsl_enabled)
838 headset_ramp(w->codec, 0);
839
840 twl4030->hsr_enabled = 0;
aad749e5
PU
841 break;
842 }
843 return 0;
844}
845
01ea6ba2
PU
846static int digimic_event(struct snd_soc_dapm_widget *w,
847 struct snd_kcontrol *kcontrol, int event)
848{
849 struct twl4030_priv *twl4030 = snd_soc_codec_get_drvdata(w->codec);
850
851 if (twl4030->digimic_delay)
7e6120c5 852 twl4030_wait_ms(twl4030->digimic_delay);
01ea6ba2
PU
853 return 0;
854}
855
b0bd53a7
PU
856/*
857 * Some of the gain controls in TWL (mostly those which are associated with
858 * the outputs) are implemented in an interesting way:
859 * 0x0 : Power down (mute)
860 * 0x1 : 6dB
861 * 0x2 : 0 dB
862 * 0x3 : -6 dB
863 * Inverting not going to help with these.
864 * Custom volsw and volsw_2r get/put functions to handle these gain bits.
865 */
b0bd53a7
PU
866static int snd_soc_get_volsw_twl4030(struct snd_kcontrol *kcontrol,
867 struct snd_ctl_elem_value *ucontrol)
868{
869 struct soc_mixer_control *mc =
870 (struct soc_mixer_control *)kcontrol->private_value;
871 struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
872 unsigned int reg = mc->reg;
873 unsigned int shift = mc->shift;
874 unsigned int rshift = mc->rshift;
875 int max = mc->max;
876 int mask = (1 << fls(max)) - 1;
877
878 ucontrol->value.integer.value[0] =
879 (snd_soc_read(codec, reg) >> shift) & mask;
880 if (ucontrol->value.integer.value[0])
881 ucontrol->value.integer.value[0] =
882 max + 1 - ucontrol->value.integer.value[0];
883
884 if (shift != rshift) {
885 ucontrol->value.integer.value[1] =
886 (snd_soc_read(codec, reg) >> rshift) & mask;
887 if (ucontrol->value.integer.value[1])
888 ucontrol->value.integer.value[1] =
889 max + 1 - ucontrol->value.integer.value[1];
890 }
891
892 return 0;
893}
894
895static int snd_soc_put_volsw_twl4030(struct snd_kcontrol *kcontrol,
896 struct snd_ctl_elem_value *ucontrol)
897{
898 struct soc_mixer_control *mc =
899 (struct soc_mixer_control *)kcontrol->private_value;
900 struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
901 unsigned int reg = mc->reg;
902 unsigned int shift = mc->shift;
903 unsigned int rshift = mc->rshift;
904 int max = mc->max;
905 int mask = (1 << fls(max)) - 1;
906 unsigned short val, val2, val_mask;
907
908 val = (ucontrol->value.integer.value[0] & mask);
909
910 val_mask = mask << shift;
911 if (val)
912 val = max + 1 - val;
913 val = val << shift;
914 if (shift != rshift) {
915 val2 = (ucontrol->value.integer.value[1] & mask);
916 val_mask |= mask << rshift;
917 if (val2)
918 val2 = max + 1 - val2;
919 val |= val2 << rshift;
920 }
921 return snd_soc_update_bits(codec, reg, val_mask, val);
922}
923
924static int snd_soc_get_volsw_r2_twl4030(struct snd_kcontrol *kcontrol,
925 struct snd_ctl_elem_value *ucontrol)
926{
927 struct soc_mixer_control *mc =
928 (struct soc_mixer_control *)kcontrol->private_value;
929 struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
930 unsigned int reg = mc->reg;
931 unsigned int reg2 = mc->rreg;
932 unsigned int shift = mc->shift;
933 int max = mc->max;
934 int mask = (1<<fls(max))-1;
935
936 ucontrol->value.integer.value[0] =
937 (snd_soc_read(codec, reg) >> shift) & mask;
938 ucontrol->value.integer.value[1] =
939 (snd_soc_read(codec, reg2) >> shift) & mask;
940
941 if (ucontrol->value.integer.value[0])
942 ucontrol->value.integer.value[0] =
943 max + 1 - ucontrol->value.integer.value[0];
944 if (ucontrol->value.integer.value[1])
945 ucontrol->value.integer.value[1] =
946 max + 1 - ucontrol->value.integer.value[1];
947
948 return 0;
949}
950
951static int snd_soc_put_volsw_r2_twl4030(struct snd_kcontrol *kcontrol,
952 struct snd_ctl_elem_value *ucontrol)
953{
954 struct soc_mixer_control *mc =
955 (struct soc_mixer_control *)kcontrol->private_value;
956 struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
957 unsigned int reg = mc->reg;
958 unsigned int reg2 = mc->rreg;
959 unsigned int shift = mc->shift;
960 int max = mc->max;
961 int mask = (1 << fls(max)) - 1;
962 int err;
963 unsigned short val, val2, val_mask;
964
965 val_mask = mask << shift;
966 val = (ucontrol->value.integer.value[0] & mask);
967 val2 = (ucontrol->value.integer.value[1] & mask);
968
969 if (val)
970 val = max + 1 - val;
971 if (val2)
972 val2 = max + 1 - val2;
973
974 val = val << shift;
975 val2 = val2 << shift;
976
977 err = snd_soc_update_bits(codec, reg, val_mask, val);
978 if (err < 0)
979 return err;
980
981 err = snd_soc_update_bits(codec, reg2, val_mask, val2);
982 return err;
983}
984
b74bd40f
LCM
985/* Codec operation modes */
986static const char *twl4030_op_modes_texts[] = {
987 "Option 2 (voice/audio)", "Option 1 (audio)"
988};
989
990static const struct soc_enum twl4030_op_modes_enum =
991 SOC_ENUM_SINGLE(TWL4030_REG_CODEC_MODE, 0,
992 ARRAY_SIZE(twl4030_op_modes_texts),
993 twl4030_op_modes_texts);
994
423c238d 995static int snd_soc_put_twl4030_opmode_enum_double(struct snd_kcontrol *kcontrol,
b74bd40f
LCM
996 struct snd_ctl_elem_value *ucontrol)
997{
998 struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
b2c812e2 999 struct twl4030_priv *twl4030 = snd_soc_codec_get_drvdata(codec);
b74bd40f
LCM
1000 struct soc_enum *e = (struct soc_enum *)kcontrol->private_value;
1001 unsigned short val;
86767b7d 1002 unsigned short mask;
b74bd40f
LCM
1003
1004 if (twl4030->configured) {
3b8a0795
PU
1005 dev_err(codec->dev,
1006 "operation mode cannot be changed on-the-fly\n");
b74bd40f
LCM
1007 return -EBUSY;
1008 }
1009
b74bd40f
LCM
1010 if (ucontrol->value.enumerated.item[0] > e->max - 1)
1011 return -EINVAL;
1012
1013 val = ucontrol->value.enumerated.item[0] << e->shift_l;
86767b7d 1014 mask = e->mask << e->shift_l;
b74bd40f
LCM
1015 if (e->shift_l != e->shift_r) {
1016 if (ucontrol->value.enumerated.item[1] > e->max - 1)
1017 return -EINVAL;
1018 val |= ucontrol->value.enumerated.item[1] << e->shift_r;
86767b7d 1019 mask |= e->mask << e->shift_r;
b74bd40f
LCM
1020 }
1021
1022 return snd_soc_update_bits(codec, e->reg, mask, val);
1023}
1024
c10b82cf
PU
1025/*
1026 * FGAIN volume control:
1027 * from -62 to 0 dB in 1 dB steps (mute instead of -63 dB)
1028 */
d889a72c 1029static DECLARE_TLV_DB_SCALE(digital_fine_tlv, -6300, 100, 1);
c10b82cf 1030
0d33ea0b
PU
1031/*
1032 * CGAIN volume control:
1033 * 0 dB to 12 dB in 6 dB steps
1034 * value 2 and 3 means 12 dB
1035 */
d889a72c
PU
1036static DECLARE_TLV_DB_SCALE(digital_coarse_tlv, 0, 600, 0);
1037
1a787e7a
JS
1038/*
1039 * Voice Downlink GAIN volume control:
1040 * from -37 to 12 dB in 1 dB steps (mute instead of -37 dB)
1041 */
1042static DECLARE_TLV_DB_SCALE(digital_voice_downlink_tlv, -3700, 100, 1);
1043
d889a72c
PU
1044/*
1045 * Analog playback gain
1046 * -24 dB to 12 dB in 2 dB steps
1047 */
1048static DECLARE_TLV_DB_SCALE(analog_tlv, -2400, 200, 0);
0d33ea0b 1049
4290239c
PU
1050/*
1051 * Gain controls tied to outputs
1052 * -6 dB to 6 dB in 6 dB steps (mute instead of -12)
1053 */
1054static DECLARE_TLV_DB_SCALE(output_tvl, -1200, 600, 1);
1055
18cc8d8d
JS
1056/*
1057 * Gain control for earpiece amplifier
1058 * 0 dB to 12 dB in 6 dB steps (mute instead of -6)
1059 */
1060static DECLARE_TLV_DB_SCALE(output_ear_tvl, -600, 600, 1);
1061
381a22b5
PU
1062/*
1063 * Capture gain after the ADCs
1064 * from 0 dB to 31 dB in 1 dB steps
1065 */
1066static DECLARE_TLV_DB_SCALE(digital_capture_tlv, 0, 100, 0);
1067
5920b453
GI
1068/*
1069 * Gain control for input amplifiers
1070 * 0 dB to 30 dB in 6 dB steps
1071 */
1072static DECLARE_TLV_DB_SCALE(input_gain_tlv, 0, 600, 0);
1073
328d0a13
LCM
1074/* AVADC clock priority */
1075static const char *twl4030_avadc_clk_priority_texts[] = {
1076 "Voice high priority", "HiFi high priority"
1077};
1078
1079static const struct soc_enum twl4030_avadc_clk_priority_enum =
1080 SOC_ENUM_SINGLE(TWL4030_REG_AVADC_CTL, 2,
1081 ARRAY_SIZE(twl4030_avadc_clk_priority_texts),
1082 twl4030_avadc_clk_priority_texts);
1083
89492be8
PU
1084static const char *twl4030_rampdelay_texts[] = {
1085 "27/20/14 ms", "55/40/27 ms", "109/81/55 ms", "218/161/109 ms",
1086 "437/323/218 ms", "874/645/437 ms", "1748/1291/874 ms",
1087 "3495/2581/1748 ms"
1088};
1089
1090static const struct soc_enum twl4030_rampdelay_enum =
1091 SOC_ENUM_SINGLE(TWL4030_REG_HS_POPN_SET, 2,
1092 ARRAY_SIZE(twl4030_rampdelay_texts),
1093 twl4030_rampdelay_texts);
1094
376f7839
PU
1095/* Vibra H-bridge direction mode */
1096static const char *twl4030_vibradirmode_texts[] = {
1097 "Vibra H-bridge direction", "Audio data MSB",
1098};
1099
1100static const struct soc_enum twl4030_vibradirmode_enum =
1101 SOC_ENUM_SINGLE(TWL4030_REG_VIBRA_CTL, 5,
1102 ARRAY_SIZE(twl4030_vibradirmode_texts),
1103 twl4030_vibradirmode_texts);
1104
1105/* Vibra H-bridge direction */
1106static const char *twl4030_vibradir_texts[] = {
1107 "Positive polarity", "Negative polarity",
1108};
1109
1110static const struct soc_enum twl4030_vibradir_enum =
1111 SOC_ENUM_SINGLE(TWL4030_REG_VIBRA_CTL, 1,
1112 ARRAY_SIZE(twl4030_vibradir_texts),
1113 twl4030_vibradir_texts);
1114
36aeff61
PU
1115/* Digimic Left and right swapping */
1116static const char *twl4030_digimicswap_texts[] = {
1117 "Not swapped", "Swapped",
1118};
1119
1120static const struct soc_enum twl4030_digimicswap_enum =
1121 SOC_ENUM_SINGLE(TWL4030_REG_MISC_SET_1, 0,
1122 ARRAY_SIZE(twl4030_digimicswap_texts),
1123 twl4030_digimicswap_texts);
1124
cc17557e 1125static const struct snd_kcontrol_new twl4030_snd_controls[] = {
b74bd40f
LCM
1126 /* Codec operation mode control */
1127 SOC_ENUM_EXT("Codec Operation Mode", twl4030_op_modes_enum,
1128 snd_soc_get_enum_double,
1129 snd_soc_put_twl4030_opmode_enum_double),
1130
d889a72c
PU
1131 /* Common playback gain controls */
1132 SOC_DOUBLE_R_TLV("DAC1 Digital Fine Playback Volume",
1133 TWL4030_REG_ARXL1PGA, TWL4030_REG_ARXR1PGA,
1134 0, 0x3f, 0, digital_fine_tlv),
1135 SOC_DOUBLE_R_TLV("DAC2 Digital Fine Playback Volume",
1136 TWL4030_REG_ARXL2PGA, TWL4030_REG_ARXR2PGA,
1137 0, 0x3f, 0, digital_fine_tlv),
1138
1139 SOC_DOUBLE_R_TLV("DAC1 Digital Coarse Playback Volume",
1140 TWL4030_REG_ARXL1PGA, TWL4030_REG_ARXR1PGA,
1141 6, 0x2, 0, digital_coarse_tlv),
1142 SOC_DOUBLE_R_TLV("DAC2 Digital Coarse Playback Volume",
1143 TWL4030_REG_ARXL2PGA, TWL4030_REG_ARXR2PGA,
1144 6, 0x2, 0, digital_coarse_tlv),
1145
1146 SOC_DOUBLE_R_TLV("DAC1 Analog Playback Volume",
1147 TWL4030_REG_ARXL1_APGA_CTL, TWL4030_REG_ARXR1_APGA_CTL,
1148 3, 0x12, 1, analog_tlv),
1149 SOC_DOUBLE_R_TLV("DAC2 Analog Playback Volume",
1150 TWL4030_REG_ARXL2_APGA_CTL, TWL4030_REG_ARXR2_APGA_CTL,
1151 3, 0x12, 1, analog_tlv),
44c55870
PU
1152 SOC_DOUBLE_R("DAC1 Analog Playback Switch",
1153 TWL4030_REG_ARXL1_APGA_CTL, TWL4030_REG_ARXR1_APGA_CTL,
1154 1, 1, 0),
1155 SOC_DOUBLE_R("DAC2 Analog Playback Switch",
1156 TWL4030_REG_ARXL2_APGA_CTL, TWL4030_REG_ARXR2_APGA_CTL,
1157 1, 1, 0),
381a22b5 1158
1a787e7a
JS
1159 /* Common voice downlink gain controls */
1160 SOC_SINGLE_TLV("DAC Voice Digital Downlink Volume",
1161 TWL4030_REG_VRXPGA, 0, 0x31, 0, digital_voice_downlink_tlv),
1162
1163 SOC_SINGLE_TLV("DAC Voice Analog Downlink Volume",
1164 TWL4030_REG_VDL_APGA_CTL, 3, 0x12, 1, analog_tlv),
1165
1166 SOC_SINGLE("DAC Voice Analog Downlink Switch",
1167 TWL4030_REG_VDL_APGA_CTL, 1, 1, 0),
1168
4290239c 1169 /* Separate output gain controls */
0f9887d1 1170 SOC_DOUBLE_R_EXT_TLV("PreDriv Playback Volume",
4290239c 1171 TWL4030_REG_PREDL_CTL, TWL4030_REG_PREDR_CTL,
0f9887d1
PU
1172 4, 3, 0, snd_soc_get_volsw_r2_twl4030,
1173 snd_soc_put_volsw_r2_twl4030, output_tvl),
4290239c 1174
0f9887d1
PU
1175 SOC_DOUBLE_EXT_TLV("Headset Playback Volume",
1176 TWL4030_REG_HS_GAIN_SET, 0, 2, 3, 0, snd_soc_get_volsw_twl4030,
1177 snd_soc_put_volsw_twl4030, output_tvl),
4290239c 1178
0f9887d1 1179 SOC_DOUBLE_R_EXT_TLV("Carkit Playback Volume",
4290239c 1180 TWL4030_REG_PRECKL_CTL, TWL4030_REG_PRECKR_CTL,
0f9887d1
PU
1181 4, 3, 0, snd_soc_get_volsw_r2_twl4030,
1182 snd_soc_put_volsw_r2_twl4030, output_tvl),
4290239c 1183
0f9887d1
PU
1184 SOC_SINGLE_EXT_TLV("Earpiece Playback Volume",
1185 TWL4030_REG_EAR_CTL, 4, 3, 0, snd_soc_get_volsw_twl4030,
1186 snd_soc_put_volsw_twl4030, output_ear_tvl),
4290239c 1187
381a22b5 1188 /* Common capture gain controls */
276c6222 1189 SOC_DOUBLE_R_TLV("TX1 Digital Capture Volume",
381a22b5
PU
1190 TWL4030_REG_ATXL1PGA, TWL4030_REG_ATXR1PGA,
1191 0, 0x1f, 0, digital_capture_tlv),
276c6222
PU
1192 SOC_DOUBLE_R_TLV("TX2 Digital Capture Volume",
1193 TWL4030_REG_AVTXL2PGA, TWL4030_REG_AVTXR2PGA,
1194 0, 0x1f, 0, digital_capture_tlv),
5920b453 1195
276c6222 1196 SOC_DOUBLE_TLV("Analog Capture Volume", TWL4030_REG_ANAMIC_GAIN,
5920b453 1197 0, 3, 5, 0, input_gain_tlv),
89492be8 1198
328d0a13
LCM
1199 SOC_ENUM("AVADC Clock Priority", twl4030_avadc_clk_priority_enum),
1200
89492be8 1201 SOC_ENUM("HS ramp delay", twl4030_rampdelay_enum),
376f7839
PU
1202
1203 SOC_ENUM("Vibra H-bridge mode", twl4030_vibradirmode_enum),
1204 SOC_ENUM("Vibra H-bridge direction", twl4030_vibradir_enum),
36aeff61
PU
1205
1206 SOC_ENUM("Digimic LR Swap", twl4030_digimicswap_enum),
cc17557e
SS
1207};
1208
cc17557e 1209static const struct snd_soc_dapm_widget twl4030_dapm_widgets[] = {
276c6222
PU
1210 /* Left channel inputs */
1211 SND_SOC_DAPM_INPUT("MAINMIC"),
1212 SND_SOC_DAPM_INPUT("HSMIC"),
1213 SND_SOC_DAPM_INPUT("AUXL"),
1214 SND_SOC_DAPM_INPUT("CARKITMIC"),
1215 /* Right channel inputs */
1216 SND_SOC_DAPM_INPUT("SUBMIC"),
1217 SND_SOC_DAPM_INPUT("AUXR"),
1218 /* Digital microphones (Stereo) */
1219 SND_SOC_DAPM_INPUT("DIGIMIC0"),
1220 SND_SOC_DAPM_INPUT("DIGIMIC1"),
1221
1222 /* Outputs */
5e98a464 1223 SND_SOC_DAPM_OUTPUT("EARPIECE"),
2a6f5c58
PU
1224 SND_SOC_DAPM_OUTPUT("PREDRIVEL"),
1225 SND_SOC_DAPM_OUTPUT("PREDRIVER"),
dfad21a2
PU
1226 SND_SOC_DAPM_OUTPUT("HSOL"),
1227 SND_SOC_DAPM_OUTPUT("HSOR"),
6a1bee4a
PU
1228 SND_SOC_DAPM_OUTPUT("CARKITL"),
1229 SND_SOC_DAPM_OUTPUT("CARKITR"),
df339804
PU
1230 SND_SOC_DAPM_OUTPUT("HFL"),
1231 SND_SOC_DAPM_OUTPUT("HFR"),
376f7839 1232 SND_SOC_DAPM_OUTPUT("VIBRA"),
cc17557e 1233
7b4c734e
PU
1234 /* AIF and APLL clocks for running DAIs (including loopback) */
1235 SND_SOC_DAPM_OUTPUT("Virtual HiFi OUT"),
1236 SND_SOC_DAPM_INPUT("Virtual HiFi IN"),
1237 SND_SOC_DAPM_OUTPUT("Virtual Voice OUT"),
1238
53b5047d 1239 /* DACs */
b4852b79 1240 SND_SOC_DAPM_DAC("DAC Right1", "Right Front HiFi Playback",
7393958f 1241 SND_SOC_NOPM, 0, 0),
b4852b79 1242 SND_SOC_DAPM_DAC("DAC Left1", "Left Front HiFi Playback",
7393958f 1243 SND_SOC_NOPM, 0, 0),
b4852b79 1244 SND_SOC_DAPM_DAC("DAC Right2", "Right Rear HiFi Playback",
7393958f 1245 SND_SOC_NOPM, 0, 0),
b4852b79 1246 SND_SOC_DAPM_DAC("DAC Left2", "Left Rear HiFi Playback",
7393958f 1247 SND_SOC_NOPM, 0, 0),
1a787e7a 1248 SND_SOC_DAPM_DAC("DAC Voice", "Voice Playback",
fcd274a3 1249 SND_SOC_NOPM, 0, 0),
cc17557e 1250
7393958f 1251 /* Analog bypasses */
78e08e2f
PU
1252 SND_SOC_DAPM_SWITCH("Right1 Analog Loopback", SND_SOC_NOPM, 0, 0,
1253 &twl4030_dapm_abypassr1_control),
1254 SND_SOC_DAPM_SWITCH("Left1 Analog Loopback", SND_SOC_NOPM, 0, 0,
1255 &twl4030_dapm_abypassl1_control),
1256 SND_SOC_DAPM_SWITCH("Right2 Analog Loopback", SND_SOC_NOPM, 0, 0,
1257 &twl4030_dapm_abypassr2_control),
1258 SND_SOC_DAPM_SWITCH("Left2 Analog Loopback", SND_SOC_NOPM, 0, 0,
1259 &twl4030_dapm_abypassl2_control),
1260 SND_SOC_DAPM_SWITCH("Voice Analog Loopback", SND_SOC_NOPM, 0, 0,
1261 &twl4030_dapm_abypassv_control),
1262
1263 /* Master analog loopback switch */
1264 SND_SOC_DAPM_SUPPLY("FM Loop Enable", TWL4030_REG_MISC_SET_1, 5, 0,
1265 NULL, 0),
7393958f 1266
6bab83fd 1267 /* Digital bypasses */
78e08e2f
PU
1268 SND_SOC_DAPM_SWITCH("Left Digital Loopback", SND_SOC_NOPM, 0, 0,
1269 &twl4030_dapm_dbypassl_control),
1270 SND_SOC_DAPM_SWITCH("Right Digital Loopback", SND_SOC_NOPM, 0, 0,
1271 &twl4030_dapm_dbypassr_control),
1272 SND_SOC_DAPM_SWITCH("Voice Digital Loopback", SND_SOC_NOPM, 0, 0,
1273 &twl4030_dapm_dbypassv_control),
6bab83fd 1274
4005d39a
PU
1275 /* Digital mixers, power control for the physical DACs */
1276 SND_SOC_DAPM_MIXER("Digital R1 Playback Mixer",
1277 TWL4030_REG_AVDAC_CTL, 0, 0, NULL, 0),
1278 SND_SOC_DAPM_MIXER("Digital L1 Playback Mixer",
1279 TWL4030_REG_AVDAC_CTL, 1, 0, NULL, 0),
1280 SND_SOC_DAPM_MIXER("Digital R2 Playback Mixer",
1281 TWL4030_REG_AVDAC_CTL, 2, 0, NULL, 0),
1282 SND_SOC_DAPM_MIXER("Digital L2 Playback Mixer",
1283 TWL4030_REG_AVDAC_CTL, 3, 0, NULL, 0),
1284 SND_SOC_DAPM_MIXER("Digital Voice Playback Mixer",
1285 TWL4030_REG_AVDAC_CTL, 4, 0, NULL, 0),
1286
1287 /* Analog mixers, power control for the physical PGAs */
1288 SND_SOC_DAPM_MIXER("Analog R1 Playback Mixer",
1289 TWL4030_REG_ARXR1_APGA_CTL, 0, 0, NULL, 0),
1290 SND_SOC_DAPM_MIXER("Analog L1 Playback Mixer",
1291 TWL4030_REG_ARXL1_APGA_CTL, 0, 0, NULL, 0),
1292 SND_SOC_DAPM_MIXER("Analog R2 Playback Mixer",
1293 TWL4030_REG_ARXR2_APGA_CTL, 0, 0, NULL, 0),
1294 SND_SOC_DAPM_MIXER("Analog L2 Playback Mixer",
1295 TWL4030_REG_ARXL2_APGA_CTL, 0, 0, NULL, 0),
1296 SND_SOC_DAPM_MIXER("Analog Voice Playback Mixer",
1297 TWL4030_REG_VDL_APGA_CTL, 0, 0, NULL, 0),
7393958f 1298
7729cf74
PU
1299 SND_SOC_DAPM_SUPPLY("APLL Enable", SND_SOC_NOPM, 0, 0, apll_event,
1300 SND_SOC_DAPM_PRE_PMU|SND_SOC_DAPM_POST_PMD),
1301
7b4c734e
PU
1302 SND_SOC_DAPM_SUPPLY("AIF Enable", SND_SOC_NOPM, 0, 0, aif_event,
1303 SND_SOC_DAPM_PRE_PMU|SND_SOC_DAPM_POST_PMD),
c42a59ea 1304
1a787e7a 1305 /* Output MIXER controls */
5e98a464 1306 /* Earpiece */
1a787e7a
JS
1307 SND_SOC_DAPM_MIXER("Earpiece Mixer", SND_SOC_NOPM, 0, 0,
1308 &twl4030_dapm_earpiece_controls[0],
1309 ARRAY_SIZE(twl4030_dapm_earpiece_controls)),
9008adf9
PU
1310 SND_SOC_DAPM_PGA_E("Earpiece PGA", SND_SOC_NOPM,
1311 0, 0, NULL, 0, earpiecepga_event,
1312 SND_SOC_DAPM_POST_PMU|SND_SOC_DAPM_POST_PMD),
2a6f5c58 1313 /* PreDrivL/R */
1a787e7a
JS
1314 SND_SOC_DAPM_MIXER("PredriveL Mixer", SND_SOC_NOPM, 0, 0,
1315 &twl4030_dapm_predrivel_controls[0],
1316 ARRAY_SIZE(twl4030_dapm_predrivel_controls)),
9008adf9
PU
1317 SND_SOC_DAPM_PGA_E("PredriveL PGA", SND_SOC_NOPM,
1318 0, 0, NULL, 0, predrivelpga_event,
1319 SND_SOC_DAPM_POST_PMU|SND_SOC_DAPM_POST_PMD),
1a787e7a
JS
1320 SND_SOC_DAPM_MIXER("PredriveR Mixer", SND_SOC_NOPM, 0, 0,
1321 &twl4030_dapm_predriver_controls[0],
1322 ARRAY_SIZE(twl4030_dapm_predriver_controls)),
9008adf9
PU
1323 SND_SOC_DAPM_PGA_E("PredriveR PGA", SND_SOC_NOPM,
1324 0, 0, NULL, 0, predriverpga_event,
1325 SND_SOC_DAPM_POST_PMU|SND_SOC_DAPM_POST_PMD),
dfad21a2 1326 /* HeadsetL/R */
6943c92e 1327 SND_SOC_DAPM_MIXER("HeadsetL Mixer", SND_SOC_NOPM, 0, 0,
1a787e7a 1328 &twl4030_dapm_hsol_controls[0],
6943c92e
PU
1329 ARRAY_SIZE(twl4030_dapm_hsol_controls)),
1330 SND_SOC_DAPM_PGA_E("HeadsetL PGA", SND_SOC_NOPM,
1331 0, 0, NULL, 0, headsetlpga_event,
1a787e7a
JS
1332 SND_SOC_DAPM_POST_PMU|SND_SOC_DAPM_POST_PMD),
1333 SND_SOC_DAPM_MIXER("HeadsetR Mixer", SND_SOC_NOPM, 0, 0,
1334 &twl4030_dapm_hsor_controls[0],
1335 ARRAY_SIZE(twl4030_dapm_hsor_controls)),
6943c92e
PU
1336 SND_SOC_DAPM_PGA_E("HeadsetR PGA", SND_SOC_NOPM,
1337 0, 0, NULL, 0, headsetrpga_event,
1338 SND_SOC_DAPM_POST_PMU|SND_SOC_DAPM_POST_PMD),
5152d8c2 1339 /* CarkitL/R */
1a787e7a
JS
1340 SND_SOC_DAPM_MIXER("CarkitL Mixer", SND_SOC_NOPM, 0, 0,
1341 &twl4030_dapm_carkitl_controls[0],
1342 ARRAY_SIZE(twl4030_dapm_carkitl_controls)),
9008adf9
PU
1343 SND_SOC_DAPM_PGA_E("CarkitL PGA", SND_SOC_NOPM,
1344 0, 0, NULL, 0, carkitlpga_event,
1345 SND_SOC_DAPM_POST_PMU|SND_SOC_DAPM_POST_PMD),
1a787e7a
JS
1346 SND_SOC_DAPM_MIXER("CarkitR Mixer", SND_SOC_NOPM, 0, 0,
1347 &twl4030_dapm_carkitr_controls[0],
1348 ARRAY_SIZE(twl4030_dapm_carkitr_controls)),
9008adf9
PU
1349 SND_SOC_DAPM_PGA_E("CarkitR PGA", SND_SOC_NOPM,
1350 0, 0, NULL, 0, carkitrpga_event,
1351 SND_SOC_DAPM_POST_PMU|SND_SOC_DAPM_POST_PMD),
1a787e7a
JS
1352
1353 /* Output MUX controls */
df339804 1354 /* HandsfreeL/R */
5a2e9a48
PU
1355 SND_SOC_DAPM_MUX("HandsfreeL Mux", SND_SOC_NOPM, 0, 0,
1356 &twl4030_dapm_handsfreel_control),
e3c7dbb0 1357 SND_SOC_DAPM_SWITCH("HandsfreeL", SND_SOC_NOPM, 0, 0,
0f89bdca 1358 &twl4030_dapm_handsfreelmute_control),
5a2e9a48
PU
1359 SND_SOC_DAPM_PGA_E("HandsfreeL PGA", SND_SOC_NOPM,
1360 0, 0, NULL, 0, handsfreelpga_event,
1361 SND_SOC_DAPM_POST_PMU|SND_SOC_DAPM_POST_PMD),
1362 SND_SOC_DAPM_MUX("HandsfreeR Mux", SND_SOC_NOPM, 5, 0,
1363 &twl4030_dapm_handsfreer_control),
e3c7dbb0 1364 SND_SOC_DAPM_SWITCH("HandsfreeR", SND_SOC_NOPM, 0, 0,
0f89bdca 1365 &twl4030_dapm_handsfreermute_control),
5a2e9a48
PU
1366 SND_SOC_DAPM_PGA_E("HandsfreeR PGA", SND_SOC_NOPM,
1367 0, 0, NULL, 0, handsfreerpga_event,
1368 SND_SOC_DAPM_POST_PMU|SND_SOC_DAPM_POST_PMD),
376f7839 1369 /* Vibra */
86139a13
JV
1370 SND_SOC_DAPM_MUX_E("Vibra Mux", TWL4030_REG_VIBRA_CTL, 0, 0,
1371 &twl4030_dapm_vibra_control, vibramux_event,
1372 SND_SOC_DAPM_PRE_PMU),
376f7839
PU
1373 SND_SOC_DAPM_MUX("Vibra Route", SND_SOC_NOPM, 0, 0,
1374 &twl4030_dapm_vibrapath_control),
5e98a464 1375
276c6222
PU
1376 /* Introducing four virtual ADC, since TWL4030 have four channel for
1377 capture */
1378 SND_SOC_DAPM_ADC("ADC Virtual Left1", "Left Front Capture",
1379 SND_SOC_NOPM, 0, 0),
1380 SND_SOC_DAPM_ADC("ADC Virtual Right1", "Right Front Capture",
1381 SND_SOC_NOPM, 0, 0),
1382 SND_SOC_DAPM_ADC("ADC Virtual Left2", "Left Rear Capture",
1383 SND_SOC_NOPM, 0, 0),
1384 SND_SOC_DAPM_ADC("ADC Virtual Right2", "Right Rear Capture",
1385 SND_SOC_NOPM, 0, 0),
1386
1387 /* Analog/Digital mic path selection.
1388 TX1 Left/Right: either analog Left/Right or Digimic0
1389 TX2 Left/Right: either analog Left/Right or Digimic1 */
bda7d2a8
PU
1390 SND_SOC_DAPM_MUX("TX1 Capture Route", SND_SOC_NOPM, 0, 0,
1391 &twl4030_dapm_micpathtx1_control),
1392 SND_SOC_DAPM_MUX("TX2 Capture Route", SND_SOC_NOPM, 0, 0,
1393 &twl4030_dapm_micpathtx2_control),
276c6222 1394
97b8096d 1395 /* Analog input mixers for the capture amplifiers */
9028935d 1396 SND_SOC_DAPM_MIXER("Analog Left",
97b8096d
JS
1397 TWL4030_REG_ANAMICL, 4, 0,
1398 &twl4030_dapm_analoglmic_controls[0],
1399 ARRAY_SIZE(twl4030_dapm_analoglmic_controls)),
9028935d 1400 SND_SOC_DAPM_MIXER("Analog Right",
97b8096d
JS
1401 TWL4030_REG_ANAMICR, 4, 0,
1402 &twl4030_dapm_analogrmic_controls[0],
1403 ARRAY_SIZE(twl4030_dapm_analogrmic_controls)),
276c6222 1404
fb2a2f84
PU
1405 SND_SOC_DAPM_PGA("ADC Physical Left",
1406 TWL4030_REG_AVADC_CTL, 3, 0, NULL, 0),
1407 SND_SOC_DAPM_PGA("ADC Physical Right",
1408 TWL4030_REG_AVADC_CTL, 1, 0, NULL, 0),
276c6222 1409
01ea6ba2
PU
1410 SND_SOC_DAPM_PGA_E("Digimic0 Enable",
1411 TWL4030_REG_ADCMICSEL, 1, 0, NULL, 0,
1412 digimic_event, SND_SOC_DAPM_POST_PMU),
1413 SND_SOC_DAPM_PGA_E("Digimic1 Enable",
1414 TWL4030_REG_ADCMICSEL, 3, 0, NULL, 0,
1415 digimic_event, SND_SOC_DAPM_POST_PMU),
276c6222 1416
bda7d2a8
PU
1417 SND_SOC_DAPM_SUPPLY("micbias1 select", TWL4030_REG_MICBIAS_CTL, 5, 0,
1418 NULL, 0),
1419 SND_SOC_DAPM_SUPPLY("micbias2 select", TWL4030_REG_MICBIAS_CTL, 6, 0,
1420 NULL, 0),
1421
276c6222
PU
1422 SND_SOC_DAPM_MICBIAS("Mic Bias 1", TWL4030_REG_MICBIAS_CTL, 0, 0),
1423 SND_SOC_DAPM_MICBIAS("Mic Bias 2", TWL4030_REG_MICBIAS_CTL, 1, 0),
1424 SND_SOC_DAPM_MICBIAS("Headset Mic Bias", TWL4030_REG_MICBIAS_CTL, 2, 0),
7393958f 1425
cc17557e
SS
1426};
1427
1428static const struct snd_soc_dapm_route intercon[] = {
4005d39a
PU
1429 {"Digital L1 Playback Mixer", NULL, "DAC Left1"},
1430 {"Digital R1 Playback Mixer", NULL, "DAC Right1"},
1431 {"Digital L2 Playback Mixer", NULL, "DAC Left2"},
1432 {"Digital R2 Playback Mixer", NULL, "DAC Right2"},
1433 {"Digital Voice Playback Mixer", NULL, "DAC Voice"},
1434
7729cf74 1435 /* Supply for the digital part (APLL) */
7729cf74
PU
1436 {"Digital Voice Playback Mixer", NULL, "APLL Enable"},
1437
27eeb1fe
PU
1438 {"DAC Left1", NULL, "AIF Enable"},
1439 {"DAC Right1", NULL, "AIF Enable"},
1440 {"DAC Left2", NULL, "AIF Enable"},
1441 {"DAC Right1", NULL, "AIF Enable"},
1442
c42a59ea
PU
1443 {"Digital R2 Playback Mixer", NULL, "AIF Enable"},
1444 {"Digital L2 Playback Mixer", NULL, "AIF Enable"},
1445
4005d39a
PU
1446 {"Analog L1 Playback Mixer", NULL, "Digital L1 Playback Mixer"},
1447 {"Analog R1 Playback Mixer", NULL, "Digital R1 Playback Mixer"},
1448 {"Analog L2 Playback Mixer", NULL, "Digital L2 Playback Mixer"},
1449 {"Analog R2 Playback Mixer", NULL, "Digital R2 Playback Mixer"},
1450 {"Analog Voice Playback Mixer", NULL, "Digital Voice Playback Mixer"},
1a787e7a 1451
5e98a464
PU
1452 /* Internal playback routings */
1453 /* Earpiece */
4005d39a
PU
1454 {"Earpiece Mixer", "Voice", "Analog Voice Playback Mixer"},
1455 {"Earpiece Mixer", "AudioL1", "Analog L1 Playback Mixer"},
1456 {"Earpiece Mixer", "AudioL2", "Analog L2 Playback Mixer"},
1457 {"Earpiece Mixer", "AudioR1", "Analog R1 Playback Mixer"},
9008adf9 1458 {"Earpiece PGA", NULL, "Earpiece Mixer"},
2a6f5c58 1459 /* PreDrivL */
4005d39a
PU
1460 {"PredriveL Mixer", "Voice", "Analog Voice Playback Mixer"},
1461 {"PredriveL Mixer", "AudioL1", "Analog L1 Playback Mixer"},
1462 {"PredriveL Mixer", "AudioL2", "Analog L2 Playback Mixer"},
1463 {"PredriveL Mixer", "AudioR2", "Analog R2 Playback Mixer"},
9008adf9 1464 {"PredriveL PGA", NULL, "PredriveL Mixer"},
2a6f5c58 1465 /* PreDrivR */
4005d39a
PU
1466 {"PredriveR Mixer", "Voice", "Analog Voice Playback Mixer"},
1467 {"PredriveR Mixer", "AudioR1", "Analog R1 Playback Mixer"},
1468 {"PredriveR Mixer", "AudioR2", "Analog R2 Playback Mixer"},
1469 {"PredriveR Mixer", "AudioL2", "Analog L2 Playback Mixer"},
9008adf9 1470 {"PredriveR PGA", NULL, "PredriveR Mixer"},
dfad21a2 1471 /* HeadsetL */
4005d39a
PU
1472 {"HeadsetL Mixer", "Voice", "Analog Voice Playback Mixer"},
1473 {"HeadsetL Mixer", "AudioL1", "Analog L1 Playback Mixer"},
1474 {"HeadsetL Mixer", "AudioL2", "Analog L2 Playback Mixer"},
6943c92e 1475 {"HeadsetL PGA", NULL, "HeadsetL Mixer"},
dfad21a2 1476 /* HeadsetR */
4005d39a
PU
1477 {"HeadsetR Mixer", "Voice", "Analog Voice Playback Mixer"},
1478 {"HeadsetR Mixer", "AudioR1", "Analog R1 Playback Mixer"},
1479 {"HeadsetR Mixer", "AudioR2", "Analog R2 Playback Mixer"},
6943c92e 1480 {"HeadsetR PGA", NULL, "HeadsetR Mixer"},
5152d8c2 1481 /* CarkitL */
4005d39a
PU
1482 {"CarkitL Mixer", "Voice", "Analog Voice Playback Mixer"},
1483 {"CarkitL Mixer", "AudioL1", "Analog L1 Playback Mixer"},
1484 {"CarkitL Mixer", "AudioL2", "Analog L2 Playback Mixer"},
9008adf9 1485 {"CarkitL PGA", NULL, "CarkitL Mixer"},
5152d8c2 1486 /* CarkitR */
4005d39a
PU
1487 {"CarkitR Mixer", "Voice", "Analog Voice Playback Mixer"},
1488 {"CarkitR Mixer", "AudioR1", "Analog R1 Playback Mixer"},
1489 {"CarkitR Mixer", "AudioR2", "Analog R2 Playback Mixer"},
9008adf9 1490 {"CarkitR PGA", NULL, "CarkitR Mixer"},
df339804 1491 /* HandsfreeL */
4005d39a
PU
1492 {"HandsfreeL Mux", "Voice", "Analog Voice Playback Mixer"},
1493 {"HandsfreeL Mux", "AudioL1", "Analog L1 Playback Mixer"},
1494 {"HandsfreeL Mux", "AudioL2", "Analog L2 Playback Mixer"},
1495 {"HandsfreeL Mux", "AudioR2", "Analog R2 Playback Mixer"},
e3c7dbb0
LCM
1496 {"HandsfreeL", "Switch", "HandsfreeL Mux"},
1497 {"HandsfreeL PGA", NULL, "HandsfreeL"},
df339804 1498 /* HandsfreeR */
4005d39a
PU
1499 {"HandsfreeR Mux", "Voice", "Analog Voice Playback Mixer"},
1500 {"HandsfreeR Mux", "AudioR1", "Analog R1 Playback Mixer"},
1501 {"HandsfreeR Mux", "AudioR2", "Analog R2 Playback Mixer"},
1502 {"HandsfreeR Mux", "AudioL2", "Analog L2 Playback Mixer"},
e3c7dbb0
LCM
1503 {"HandsfreeR", "Switch", "HandsfreeR Mux"},
1504 {"HandsfreeR PGA", NULL, "HandsfreeR"},
376f7839
PU
1505 /* Vibra */
1506 {"Vibra Mux", "AudioL1", "DAC Left1"},
1507 {"Vibra Mux", "AudioR1", "DAC Right1"},
1508 {"Vibra Mux", "AudioL2", "DAC Left2"},
1509 {"Vibra Mux", "AudioR2", "DAC Right2"},
5e98a464 1510
cc17557e 1511 /* outputs */
7b4c734e 1512 /* Must be always connected (for AIF and APLL) */
27eeb1fe
PU
1513 {"Virtual HiFi OUT", NULL, "DAC Left1"},
1514 {"Virtual HiFi OUT", NULL, "DAC Right1"},
1515 {"Virtual HiFi OUT", NULL, "DAC Left2"},
1516 {"Virtual HiFi OUT", NULL, "DAC Right2"},
7b4c734e
PU
1517 /* Must be always connected (for APLL) */
1518 {"Virtual Voice OUT", NULL, "Digital Voice Playback Mixer"},
1519 /* Physical outputs */
9008adf9
PU
1520 {"EARPIECE", NULL, "Earpiece PGA"},
1521 {"PREDRIVEL", NULL, "PredriveL PGA"},
1522 {"PREDRIVER", NULL, "PredriveR PGA"},
6943c92e
PU
1523 {"HSOL", NULL, "HeadsetL PGA"},
1524 {"HSOR", NULL, "HeadsetR PGA"},
9008adf9
PU
1525 {"CARKITL", NULL, "CarkitL PGA"},
1526 {"CARKITR", NULL, "CarkitR PGA"},
5a2e9a48
PU
1527 {"HFL", NULL, "HandsfreeL PGA"},
1528 {"HFR", NULL, "HandsfreeR PGA"},
376f7839
PU
1529 {"Vibra Route", "Audio", "Vibra Mux"},
1530 {"VIBRA", NULL, "Vibra Route"},
cc17557e 1531
276c6222 1532 /* Capture path */
7b4c734e
PU
1533 /* Must be always connected (for AIF and APLL) */
1534 {"ADC Virtual Left1", NULL, "Virtual HiFi IN"},
1535 {"ADC Virtual Right1", NULL, "Virtual HiFi IN"},
1536 {"ADC Virtual Left2", NULL, "Virtual HiFi IN"},
1537 {"ADC Virtual Right2", NULL, "Virtual HiFi IN"},
1538 /* Physical inputs */
9028935d
PU
1539 {"Analog Left", "Main Mic Capture Switch", "MAINMIC"},
1540 {"Analog Left", "Headset Mic Capture Switch", "HSMIC"},
1541 {"Analog Left", "AUXL Capture Switch", "AUXL"},
1542 {"Analog Left", "Carkit Mic Capture Switch", "CARKITMIC"},
276c6222 1543
9028935d
PU
1544 {"Analog Right", "Sub Mic Capture Switch", "SUBMIC"},
1545 {"Analog Right", "AUXR Capture Switch", "AUXR"},
276c6222 1546
9028935d
PU
1547 {"ADC Physical Left", NULL, "Analog Left"},
1548 {"ADC Physical Right", NULL, "Analog Right"},
276c6222
PU
1549
1550 {"Digimic0 Enable", NULL, "DIGIMIC0"},
1551 {"Digimic1 Enable", NULL, "DIGIMIC1"},
1552
bda7d2a8
PU
1553 {"DIGIMIC0", NULL, "micbias1 select"},
1554 {"DIGIMIC1", NULL, "micbias2 select"},
1555
276c6222 1556 /* TX1 Left capture path */
fb2a2f84 1557 {"TX1 Capture Route", "Analog", "ADC Physical Left"},
276c6222
PU
1558 {"TX1 Capture Route", "Digimic0", "Digimic0 Enable"},
1559 /* TX1 Right capture path */
fb2a2f84 1560 {"TX1 Capture Route", "Analog", "ADC Physical Right"},
276c6222
PU
1561 {"TX1 Capture Route", "Digimic0", "Digimic0 Enable"},
1562 /* TX2 Left capture path */
fb2a2f84 1563 {"TX2 Capture Route", "Analog", "ADC Physical Left"},
276c6222
PU
1564 {"TX2 Capture Route", "Digimic1", "Digimic1 Enable"},
1565 /* TX2 Right capture path */
fb2a2f84 1566 {"TX2 Capture Route", "Analog", "ADC Physical Right"},
276c6222
PU
1567 {"TX2 Capture Route", "Digimic1", "Digimic1 Enable"},
1568
1569 {"ADC Virtual Left1", NULL, "TX1 Capture Route"},
1570 {"ADC Virtual Right1", NULL, "TX1 Capture Route"},
1571 {"ADC Virtual Left2", NULL, "TX2 Capture Route"},
1572 {"ADC Virtual Right2", NULL, "TX2 Capture Route"},
1573
c42a59ea
PU
1574 {"ADC Virtual Left1", NULL, "AIF Enable"},
1575 {"ADC Virtual Right1", NULL, "AIF Enable"},
1576 {"ADC Virtual Left2", NULL, "AIF Enable"},
1577 {"ADC Virtual Right2", NULL, "AIF Enable"},
1578
7393958f 1579 /* Analog bypass routes */
9028935d
PU
1580 {"Right1 Analog Loopback", "Switch", "Analog Right"},
1581 {"Left1 Analog Loopback", "Switch", "Analog Left"},
1582 {"Right2 Analog Loopback", "Switch", "Analog Right"},
1583 {"Left2 Analog Loopback", "Switch", "Analog Left"},
1584 {"Voice Analog Loopback", "Switch", "Analog Left"},
7393958f 1585
78e08e2f
PU
1586 /* Supply for the Analog loopbacks */
1587 {"Right1 Analog Loopback", NULL, "FM Loop Enable"},
1588 {"Left1 Analog Loopback", NULL, "FM Loop Enable"},
1589 {"Right2 Analog Loopback", NULL, "FM Loop Enable"},
1590 {"Left2 Analog Loopback", NULL, "FM Loop Enable"},
1591 {"Voice Analog Loopback", NULL, "FM Loop Enable"},
1592
7393958f
PU
1593 {"Analog R1 Playback Mixer", NULL, "Right1 Analog Loopback"},
1594 {"Analog L1 Playback Mixer", NULL, "Left1 Analog Loopback"},
1595 {"Analog R2 Playback Mixer", NULL, "Right2 Analog Loopback"},
1596 {"Analog L2 Playback Mixer", NULL, "Left2 Analog Loopback"},
fcd274a3 1597 {"Analog Voice Playback Mixer", NULL, "Voice Analog Loopback"},
7393958f 1598
6bab83fd
PU
1599 /* Digital bypass routes */
1600 {"Right Digital Loopback", "Volume", "TX1 Capture Route"},
1601 {"Left Digital Loopback", "Volume", "TX1 Capture Route"},
ee8f6894 1602 {"Voice Digital Loopback", "Volume", "TX2 Capture Route"},
6bab83fd 1603
4005d39a
PU
1604 {"Digital R2 Playback Mixer", NULL, "Right Digital Loopback"},
1605 {"Digital L2 Playback Mixer", NULL, "Left Digital Loopback"},
1606 {"Digital Voice Playback Mixer", NULL, "Voice Digital Loopback"},
6bab83fd 1607
cc17557e
SS
1608};
1609
cc17557e
SS
1610static int twl4030_set_bias_level(struct snd_soc_codec *codec,
1611 enum snd_soc_bias_level level)
1612{
1613 switch (level) {
1614 case SND_SOC_BIAS_ON:
cc17557e
SS
1615 break;
1616 case SND_SOC_BIAS_PREPARE:
cc17557e
SS
1617 break;
1618 case SND_SOC_BIAS_STANDBY:
ce6120cc 1619 if (codec->dapm.bias_level == SND_SOC_BIAS_OFF)
ee4ccac7 1620 twl4030_codec_enable(codec, 1);
cc17557e
SS
1621 break;
1622 case SND_SOC_BIAS_OFF:
cbd2db12 1623 twl4030_codec_enable(codec, 0);
cc17557e
SS
1624 break;
1625 }
ce6120cc 1626 codec->dapm.bias_level = level;
cc17557e
SS
1627
1628 return 0;
1629}
1630
6b87a91f
PU
1631static void twl4030_constraints(struct twl4030_priv *twl4030,
1632 struct snd_pcm_substream *mst_substream)
1633{
1634 struct snd_pcm_substream *slv_substream;
1635
1636 /* Pick the stream, which need to be constrained */
1637 if (mst_substream == twl4030->master_substream)
1638 slv_substream = twl4030->slave_substream;
1639 else if (mst_substream == twl4030->slave_substream)
1640 slv_substream = twl4030->master_substream;
1641 else /* This should not happen.. */
1642 return;
1643
1644 /* Set the constraints according to the already configured stream */
1645 snd_pcm_hw_constraint_minmax(slv_substream->runtime,
1646 SNDRV_PCM_HW_PARAM_RATE,
1647 twl4030->rate,
1648 twl4030->rate);
1649
1650 snd_pcm_hw_constraint_minmax(slv_substream->runtime,
1651 SNDRV_PCM_HW_PARAM_SAMPLE_BITS,
1652 twl4030->sample_bits,
1653 twl4030->sample_bits);
1654
1655 snd_pcm_hw_constraint_minmax(slv_substream->runtime,
1656 SNDRV_PCM_HW_PARAM_CHANNELS,
1657 twl4030->channels,
1658 twl4030->channels);
1659}
1660
8a1f936a
PU
1661/* In case of 4 channel mode, the RX1 L/R for playback and the TX2 L/R for
1662 * capture has to be enabled/disabled. */
1663static void twl4030_tdm_enable(struct snd_soc_codec *codec, int direction,
1664 int enable)
1665{
1666 u8 reg, mask;
1667
1668 reg = twl4030_read_reg_cache(codec, TWL4030_REG_OPTION);
1669
1670 if (direction == SNDRV_PCM_STREAM_PLAYBACK)
1671 mask = TWL4030_ARXL1_VRX_EN | TWL4030_ARXR1_EN;
1672 else
1673 mask = TWL4030_ATXL2_VTXL_EN | TWL4030_ATXR2_VTXR_EN;
1674
1675 if (enable)
1676 reg |= mask;
1677 else
1678 reg &= ~mask;
1679
1680 twl4030_write(codec, TWL4030_REG_OPTION, reg);
1681}
1682
d6648da1
PU
1683static int twl4030_startup(struct snd_pcm_substream *substream,
1684 struct snd_soc_dai *dai)
7220b9f4 1685{
e6968a17 1686 struct snd_soc_codec *codec = dai->codec;
b2c812e2 1687 struct twl4030_priv *twl4030 = snd_soc_codec_get_drvdata(codec);
7220b9f4 1688
7220b9f4 1689 if (twl4030->master_substream) {
7220b9f4 1690 twl4030->slave_substream = substream;
6b87a91f
PU
1691 /* The DAI has one configuration for playback and capture, so
1692 * if the DAI has been already configured then constrain this
1693 * substream to match it. */
1694 if (twl4030->configured)
1695 twl4030_constraints(twl4030, twl4030->master_substream);
1696 } else {
8a1f936a
PU
1697 if (!(twl4030_read_reg_cache(codec, TWL4030_REG_CODEC_MODE) &
1698 TWL4030_OPTION_1)) {
1699 /* In option2 4 channel is not supported, set the
1700 * constraint for the first stream for channels, the
1701 * second stream will 'inherit' this cosntraint */
1702 snd_pcm_hw_constraint_minmax(substream->runtime,
1703 SNDRV_PCM_HW_PARAM_CHANNELS,
1704 2, 2);
1705 }
7220b9f4 1706 twl4030->master_substream = substream;
6b87a91f 1707 }
7220b9f4
PU
1708
1709 return 0;
1710}
1711
d6648da1
PU
1712static void twl4030_shutdown(struct snd_pcm_substream *substream,
1713 struct snd_soc_dai *dai)
7220b9f4 1714{
e6968a17 1715 struct snd_soc_codec *codec = dai->codec;
b2c812e2 1716 struct twl4030_priv *twl4030 = snd_soc_codec_get_drvdata(codec);
7220b9f4
PU
1717
1718 if (twl4030->master_substream == substream)
1719 twl4030->master_substream = twl4030->slave_substream;
1720
1721 twl4030->slave_substream = NULL;
6b87a91f
PU
1722
1723 /* If all streams are closed, or the remaining stream has not yet
1724 * been configured than set the DAI as not configured. */
1725 if (!twl4030->master_substream)
1726 twl4030->configured = 0;
1727 else if (!twl4030->master_substream->runtime->channels)
1728 twl4030->configured = 0;
8a1f936a
PU
1729
1730 /* If the closing substream had 4 channel, do the necessary cleanup */
1731 if (substream->runtime->channels == 4)
1732 twl4030_tdm_enable(codec, substream->stream, 0);
7220b9f4
PU
1733}
1734
cc17557e 1735static int twl4030_hw_params(struct snd_pcm_substream *substream,
dee89c4d
MB
1736 struct snd_pcm_hw_params *params,
1737 struct snd_soc_dai *dai)
cc17557e 1738{
e6968a17 1739 struct snd_soc_codec *codec = dai->codec;
b2c812e2 1740 struct twl4030_priv *twl4030 = snd_soc_codec_get_drvdata(codec);
cc17557e
SS
1741 u8 mode, old_mode, format, old_format;
1742
8a1f936a
PU
1743 /* If the substream has 4 channel, do the necessary setup */
1744 if (params_channels(params) == 4) {
eaf1ac8b
PU
1745 format = twl4030_read_reg_cache(codec, TWL4030_REG_AUDIO_IF);
1746 mode = twl4030_read_reg_cache(codec, TWL4030_REG_CODEC_MODE);
1747
1748 /* Safety check: are we in the correct operating mode and
1749 * the interface is in TDM mode? */
1750 if ((mode & TWL4030_OPTION_1) &&
1751 ((format & TWL4030_AIF_FORMAT) == TWL4030_AIF_FORMAT_TDM))
8a1f936a
PU
1752 twl4030_tdm_enable(codec, substream->stream, 1);
1753 else
1754 return -EINVAL;
1755 }
1756
6b87a91f
PU
1757 if (twl4030->configured)
1758 /* Ignoring hw_params for already configured DAI */
7220b9f4
PU
1759 return 0;
1760
cc17557e
SS
1761 /* bit rate */
1762 old_mode = twl4030_read_reg_cache(codec,
1763 TWL4030_REG_CODEC_MODE) & ~TWL4030_CODECPDZ;
1764 mode = old_mode & ~TWL4030_APLL_RATE;
1765
1766 switch (params_rate(params)) {
1767 case 8000:
1768 mode |= TWL4030_APLL_RATE_8000;
1769 break;
1770 case 11025:
1771 mode |= TWL4030_APLL_RATE_11025;
1772 break;
1773 case 12000:
1774 mode |= TWL4030_APLL_RATE_12000;
1775 break;
1776 case 16000:
1777 mode |= TWL4030_APLL_RATE_16000;
1778 break;
1779 case 22050:
1780 mode |= TWL4030_APLL_RATE_22050;
1781 break;
1782 case 24000:
1783 mode |= TWL4030_APLL_RATE_24000;
1784 break;
1785 case 32000:
1786 mode |= TWL4030_APLL_RATE_32000;
1787 break;
1788 case 44100:
1789 mode |= TWL4030_APLL_RATE_44100;
1790 break;
1791 case 48000:
1792 mode |= TWL4030_APLL_RATE_48000;
1793 break;
103f211d
PU
1794 case 96000:
1795 mode |= TWL4030_APLL_RATE_96000;
1796 break;
cc17557e 1797 default:
3b8a0795 1798 dev_err(codec->dev, "%s: unknown rate %d\n", __func__,
cc17557e
SS
1799 params_rate(params));
1800 return -EINVAL;
1801 }
1802
cc17557e
SS
1803 /* sample size */
1804 old_format = twl4030_read_reg_cache(codec, TWL4030_REG_AUDIO_IF);
1805 format = old_format;
1806 format &= ~TWL4030_DATA_WIDTH;
1807 switch (params_format(params)) {
1808 case SNDRV_PCM_FORMAT_S16_LE:
1809 format |= TWL4030_DATA_WIDTH_16S_16W;
1810 break;
dcdeda4a 1811 case SNDRV_PCM_FORMAT_S32_LE:
cc17557e
SS
1812 format |= TWL4030_DATA_WIDTH_32S_24W;
1813 break;
1814 default:
3b8a0795 1815 dev_err(codec->dev, "%s: unknown format %d\n", __func__,
cc17557e
SS
1816 params_format(params));
1817 return -EINVAL;
1818 }
1819
2046f175
PU
1820 if (format != old_format || mode != old_mode) {
1821 if (twl4030->codec_powered) {
1822 /*
1823 * If the codec is powered, than we need to toggle the
1824 * codec power.
1825 */
1826 twl4030_codec_enable(codec, 0);
1827 twl4030_write(codec, TWL4030_REG_CODEC_MODE, mode);
1828 twl4030_write(codec, TWL4030_REG_AUDIO_IF, format);
1829 twl4030_codec_enable(codec, 1);
1830 } else {
1831 twl4030_write(codec, TWL4030_REG_CODEC_MODE, mode);
1832 twl4030_write(codec, TWL4030_REG_AUDIO_IF, format);
1833 }
cc17557e 1834 }
6b87a91f
PU
1835
1836 /* Store the important parameters for the DAI configuration and set
1837 * the DAI as configured */
1838 twl4030->configured = 1;
1839 twl4030->rate = params_rate(params);
1840 twl4030->sample_bits = hw_param_interval(params,
1841 SNDRV_PCM_HW_PARAM_SAMPLE_BITS)->min;
1842 twl4030->channels = params_channels(params);
1843
1844 /* If both playback and capture streams are open, and one of them
1845 * is setting the hw parameters right now (since we are here), set
1846 * constraints to the other stream to match the current one. */
1847 if (twl4030->slave_substream)
1848 twl4030_constraints(twl4030, substream);
1849
cc17557e
SS
1850 return 0;
1851}
1852
1853static int twl4030_set_dai_sysclk(struct snd_soc_dai *codec_dai,
1854 int clk_id, unsigned int freq, int dir)
1855{
1856 struct snd_soc_codec *codec = codec_dai->codec;
b2c812e2 1857 struct twl4030_priv *twl4030 = snd_soc_codec_get_drvdata(codec);
cc17557e
SS
1858
1859 switch (freq) {
1860 case 19200000:
cc17557e 1861 case 26000000:
cc17557e 1862 case 38400000:
cc17557e
SS
1863 break;
1864 default:
3b8a0795 1865 dev_err(codec->dev, "Unsupported HFCLKIN: %u\n", freq);
cc17557e
SS
1866 return -EINVAL;
1867 }
1868
68d01955
PU
1869 if ((freq / 1000) != twl4030->sysclk) {
1870 dev_err(codec->dev,
3b8a0795 1871 "Mismatch in HFCLKIN: %u (configured: %u)\n",
68d01955
PU
1872 freq, twl4030->sysclk * 1000);
1873 return -EINVAL;
1874 }
cc17557e
SS
1875
1876 return 0;
1877}
1878
1879static int twl4030_set_dai_fmt(struct snd_soc_dai *codec_dai,
1880 unsigned int fmt)
1881{
1882 struct snd_soc_codec *codec = codec_dai->codec;
2046f175 1883 struct twl4030_priv *twl4030 = snd_soc_codec_get_drvdata(codec);
cc17557e
SS
1884 u8 old_format, format;
1885
1886 /* get format */
1887 old_format = twl4030_read_reg_cache(codec, TWL4030_REG_AUDIO_IF);
1888 format = old_format;
1889
1890 /* set master/slave audio interface */
1891 switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) {
1892 case SND_SOC_DAIFMT_CBM_CFM:
1893 format &= ~(TWL4030_AIF_SLAVE_EN);
e18c94d2 1894 format &= ~(TWL4030_CLK256FS_EN);
cc17557e
SS
1895 break;
1896 case SND_SOC_DAIFMT_CBS_CFS:
cc17557e 1897 format |= TWL4030_AIF_SLAVE_EN;
e18c94d2 1898 format |= TWL4030_CLK256FS_EN;
cc17557e
SS
1899 break;
1900 default:
1901 return -EINVAL;
1902 }
1903
1904 /* interface format */
1905 format &= ~TWL4030_AIF_FORMAT;
1906 switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) {
1907 case SND_SOC_DAIFMT_I2S:
1908 format |= TWL4030_AIF_FORMAT_CODEC;
1909 break;
8a1f936a
PU
1910 case SND_SOC_DAIFMT_DSP_A:
1911 format |= TWL4030_AIF_FORMAT_TDM;
1912 break;
cc17557e
SS
1913 default:
1914 return -EINVAL;
1915 }
1916
1917 if (format != old_format) {
2046f175
PU
1918 if (twl4030->codec_powered) {
1919 /*
1920 * If the codec is powered, than we need to toggle the
1921 * codec power.
1922 */
1923 twl4030_codec_enable(codec, 0);
1924 twl4030_write(codec, TWL4030_REG_AUDIO_IF, format);
1925 twl4030_codec_enable(codec, 1);
1926 } else {
1927 twl4030_write(codec, TWL4030_REG_AUDIO_IF, format);
1928 }
cc17557e
SS
1929 }
1930
1931 return 0;
1932}
1933
68140443
LCM
1934static int twl4030_set_tristate(struct snd_soc_dai *dai, int tristate)
1935{
1936 struct snd_soc_codec *codec = dai->codec;
1937 u8 reg = twl4030_read_reg_cache(codec, TWL4030_REG_AUDIO_IF);
1938
1939 if (tristate)
1940 reg |= TWL4030_AIF_TRI_EN;
1941 else
1942 reg &= ~TWL4030_AIF_TRI_EN;
1943
1944 return twl4030_write(codec, TWL4030_REG_AUDIO_IF, reg);
1945}
1946
b7a755a8
MLC
1947/* In case of voice mode, the RX1 L(VRX) for downlink and the TX2 L/R
1948 * (VTXL, VTXR) for uplink has to be enabled/disabled. */
1949static void twl4030_voice_enable(struct snd_soc_codec *codec, int direction,
1950 int enable)
1951{
1952 u8 reg, mask;
1953
1954 reg = twl4030_read_reg_cache(codec, TWL4030_REG_OPTION);
1955
1956 if (direction == SNDRV_PCM_STREAM_PLAYBACK)
1957 mask = TWL4030_ARXL1_VRX_EN;
1958 else
1959 mask = TWL4030_ATXL2_VTXL_EN | TWL4030_ATXR2_VTXR_EN;
1960
1961 if (enable)
1962 reg |= mask;
1963 else
1964 reg &= ~mask;
1965
1966 twl4030_write(codec, TWL4030_REG_OPTION, reg);
1967}
1968
7154b3e8
JS
1969static int twl4030_voice_startup(struct snd_pcm_substream *substream,
1970 struct snd_soc_dai *dai)
1971{
e6968a17 1972 struct snd_soc_codec *codec = dai->codec;
b2c812e2 1973 struct twl4030_priv *twl4030 = snd_soc_codec_get_drvdata(codec);
7154b3e8
JS
1974 u8 mode;
1975
1976 /* If the system master clock is not 26MHz, the voice PCM interface is
25985edc 1977 * not available.
7154b3e8 1978 */
68d01955 1979 if (twl4030->sysclk != 26000) {
3b8a0795
PU
1980 dev_err(codec->dev,
1981 "%s: HFCLKIN is %u KHz, voice interface needs 26MHz\n",
1982 __func__, twl4030->sysclk);
7154b3e8
JS
1983 return -EINVAL;
1984 }
1985
1986 /* If the codec mode is not option2, the voice PCM interface is not
25985edc 1987 * available.
7154b3e8
JS
1988 */
1989 mode = twl4030_read_reg_cache(codec, TWL4030_REG_CODEC_MODE)
1990 & TWL4030_OPT_MODE;
1991
1992 if (mode != TWL4030_OPTION_2) {
3b8a0795
PU
1993 dev_err(codec->dev, "%s: the codec mode is not option2\n",
1994 __func__);
7154b3e8
JS
1995 return -EINVAL;
1996 }
1997
1998 return 0;
1999}
2000
b7a755a8
MLC
2001static void twl4030_voice_shutdown(struct snd_pcm_substream *substream,
2002 struct snd_soc_dai *dai)
2003{
e6968a17 2004 struct snd_soc_codec *codec = dai->codec;
b7a755a8
MLC
2005
2006 /* Enable voice digital filters */
2007 twl4030_voice_enable(codec, substream->stream, 0);
2008}
2009
7154b3e8
JS
2010static int twl4030_voice_hw_params(struct snd_pcm_substream *substream,
2011 struct snd_pcm_hw_params *params, struct snd_soc_dai *dai)
2012{
e6968a17 2013 struct snd_soc_codec *codec = dai->codec;
2046f175 2014 struct twl4030_priv *twl4030 = snd_soc_codec_get_drvdata(codec);
7154b3e8
JS
2015 u8 old_mode, mode;
2016
b7a755a8
MLC
2017 /* Enable voice digital filters */
2018 twl4030_voice_enable(codec, substream->stream, 1);
2019
7154b3e8
JS
2020 /* bit rate */
2021 old_mode = twl4030_read_reg_cache(codec, TWL4030_REG_CODEC_MODE)
2022 & ~(TWL4030_CODECPDZ);
2023 mode = old_mode;
2024
2025 switch (params_rate(params)) {
2026 case 8000:
2027 mode &= ~(TWL4030_SEL_16K);
2028 break;
2029 case 16000:
2030 mode |= TWL4030_SEL_16K;
2031 break;
2032 default:
3b8a0795 2033 dev_err(codec->dev, "%s: unknown rate %d\n", __func__,
7154b3e8
JS
2034 params_rate(params));
2035 return -EINVAL;
2036 }
2037
2038 if (mode != old_mode) {
2046f175
PU
2039 if (twl4030->codec_powered) {
2040 /*
2041 * If the codec is powered, than we need to toggle the
2042 * codec power.
2043 */
2044 twl4030_codec_enable(codec, 0);
2045 twl4030_write(codec, TWL4030_REG_CODEC_MODE, mode);
2046 twl4030_codec_enable(codec, 1);
2047 } else {
2048 twl4030_write(codec, TWL4030_REG_CODEC_MODE, mode);
2049 }
7154b3e8
JS
2050 }
2051
2052 return 0;
2053}
2054
2055static int twl4030_voice_set_dai_sysclk(struct snd_soc_dai *codec_dai,
2056 int clk_id, unsigned int freq, int dir)
2057{
2058 struct snd_soc_codec *codec = codec_dai->codec;
d4a8ca24 2059 struct twl4030_priv *twl4030 = snd_soc_codec_get_drvdata(codec);
7154b3e8 2060
68d01955 2061 if (freq != 26000000) {
3b8a0795
PU
2062 dev_err(codec->dev,
2063 "%s: HFCLKIN is %u KHz, voice interface needs 26MHz\n",
2064 __func__, freq / 1000);
68d01955
PU
2065 return -EINVAL;
2066 }
2067 if ((freq / 1000) != twl4030->sysclk) {
2068 dev_err(codec->dev,
3b8a0795 2069 "Mismatch in HFCLKIN: %u (configured: %u)\n",
68d01955 2070 freq, twl4030->sysclk * 1000);
7154b3e8
JS
2071 return -EINVAL;
2072 }
7154b3e8
JS
2073 return 0;
2074}
2075
2076static int twl4030_voice_set_dai_fmt(struct snd_soc_dai *codec_dai,
2077 unsigned int fmt)
2078{
2079 struct snd_soc_codec *codec = codec_dai->codec;
2046f175 2080 struct twl4030_priv *twl4030 = snd_soc_codec_get_drvdata(codec);
7154b3e8
JS
2081 u8 old_format, format;
2082
2083 /* get format */
2084 old_format = twl4030_read_reg_cache(codec, TWL4030_REG_VOICE_IF);
2085 format = old_format;
2086
2087 /* set master/slave audio interface */
2088 switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) {
c264301c 2089 case SND_SOC_DAIFMT_CBM_CFM:
7154b3e8
JS
2090 format &= ~(TWL4030_VIF_SLAVE_EN);
2091 break;
2092 case SND_SOC_DAIFMT_CBS_CFS:
2093 format |= TWL4030_VIF_SLAVE_EN;
2094 break;
2095 default:
2096 return -EINVAL;
2097 }
2098
2099 /* clock inversion */
2100 switch (fmt & SND_SOC_DAIFMT_INV_MASK) {
2101 case SND_SOC_DAIFMT_IB_NF:
2102 format &= ~(TWL4030_VIF_FORMAT);
2103 break;
2104 case SND_SOC_DAIFMT_NB_IF:
2105 format |= TWL4030_VIF_FORMAT;
2106 break;
2107 default:
2108 return -EINVAL;
2109 }
2110
2111 if (format != old_format) {
2046f175
PU
2112 if (twl4030->codec_powered) {
2113 /*
2114 * If the codec is powered, than we need to toggle the
2115 * codec power.
2116 */
2117 twl4030_codec_enable(codec, 0);
2118 twl4030_write(codec, TWL4030_REG_VOICE_IF, format);
2119 twl4030_codec_enable(codec, 1);
2120 } else {
2121 twl4030_write(codec, TWL4030_REG_VOICE_IF, format);
2122 }
7154b3e8
JS
2123 }
2124
2125 return 0;
2126}
2127
68140443
LCM
2128static int twl4030_voice_set_tristate(struct snd_soc_dai *dai, int tristate)
2129{
2130 struct snd_soc_codec *codec = dai->codec;
2131 u8 reg = twl4030_read_reg_cache(codec, TWL4030_REG_VOICE_IF);
2132
2133 if (tristate)
2134 reg |= TWL4030_VIF_TRI_EN;
2135 else
2136 reg &= ~TWL4030_VIF_TRI_EN;
2137
2138 return twl4030_write(codec, TWL4030_REG_VOICE_IF, reg);
2139}
2140
bbba9444 2141#define TWL4030_RATES (SNDRV_PCM_RATE_8000_48000)
dcdeda4a 2142#define TWL4030_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S32_LE)
cc17557e 2143
85e7652d 2144static const struct snd_soc_dai_ops twl4030_dai_hifi_ops = {
7220b9f4
PU
2145 .startup = twl4030_startup,
2146 .shutdown = twl4030_shutdown,
10d9e3d9
JS
2147 .hw_params = twl4030_hw_params,
2148 .set_sysclk = twl4030_set_dai_sysclk,
2149 .set_fmt = twl4030_set_dai_fmt,
68140443 2150 .set_tristate = twl4030_set_tristate,
10d9e3d9
JS
2151};
2152
85e7652d 2153static const struct snd_soc_dai_ops twl4030_dai_voice_ops = {
7154b3e8 2154 .startup = twl4030_voice_startup,
b7a755a8 2155 .shutdown = twl4030_voice_shutdown,
7154b3e8
JS
2156 .hw_params = twl4030_voice_hw_params,
2157 .set_sysclk = twl4030_voice_set_dai_sysclk,
2158 .set_fmt = twl4030_voice_set_dai_fmt,
68140443 2159 .set_tristate = twl4030_voice_set_tristate,
7154b3e8
JS
2160};
2161
f0fba2ad 2162static struct snd_soc_dai_driver twl4030_dai[] = {
7154b3e8 2163{
f0fba2ad 2164 .name = "twl4030-hifi",
cc17557e 2165 .playback = {
b4852b79 2166 .stream_name = "HiFi Playback",
cc17557e 2167 .channels_min = 2,
8a1f936a 2168 .channels_max = 4,
31ad0f31 2169 .rates = TWL4030_RATES | SNDRV_PCM_RATE_96000,
8819f65c
PU
2170 .formats = TWL4030_FORMATS,
2171 .sig_bits = 24,},
cc17557e
SS
2172 .capture = {
2173 .stream_name = "Capture",
2174 .channels_min = 2,
8a1f936a 2175 .channels_max = 4,
cc17557e 2176 .rates = TWL4030_RATES,
8819f65c
PU
2177 .formats = TWL4030_FORMATS,
2178 .sig_bits = 24,},
f0fba2ad 2179 .ops = &twl4030_dai_hifi_ops,
7154b3e8
JS
2180},
2181{
f0fba2ad 2182 .name = "twl4030-voice",
7154b3e8 2183 .playback = {
b4852b79 2184 .stream_name = "Voice Playback",
7154b3e8
JS
2185 .channels_min = 1,
2186 .channels_max = 1,
2187 .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000,
2188 .formats = SNDRV_PCM_FMTBIT_S16_LE,},
2189 .capture = {
2190 .stream_name = "Capture",
2191 .channels_min = 1,
2192 .channels_max = 2,
2193 .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000,
2194 .formats = SNDRV_PCM_FMTBIT_S16_LE,},
2195 .ops = &twl4030_dai_voice_ops,
2196},
cc17557e 2197};
cc17557e 2198
84b315ee 2199static int twl4030_soc_suspend(struct snd_soc_codec *codec)
cc17557e 2200{
cc17557e 2201 twl4030_set_bias_level(codec, SND_SOC_BIAS_OFF);
cc17557e
SS
2202 return 0;
2203}
2204
f0fba2ad 2205static int twl4030_soc_resume(struct snd_soc_codec *codec)
cc17557e 2206{
cc17557e 2207 twl4030_set_bias_level(codec, SND_SOC_BIAS_STANDBY);
cc17557e
SS
2208 return 0;
2209}
2210
f0fba2ad 2211static int twl4030_soc_probe(struct snd_soc_codec *codec)
cc17557e 2212{
f0fba2ad 2213 struct twl4030_priv *twl4030;
9da28c7b 2214
f0fba2ad
LG
2215 twl4030 = kzalloc(sizeof(struct twl4030_priv), GFP_KERNEL);
2216 if (twl4030 == NULL) {
3b8a0795 2217 dev_err(codec->dev, "Can not allocate memory\n");
f0fba2ad 2218 return -ENOMEM;
cc17557e 2219 }
f0fba2ad
LG
2220 snd_soc_codec_set_drvdata(codec, twl4030);
2221 /* Set the defaults, and power up the codec */
57fe7251 2222 twl4030->sysclk = twl4030_audio_get_mclk() / 1000;
f0fba2ad
LG
2223
2224 twl4030_init_chip(codec);
cc17557e 2225
7a1fecf5 2226 return 0;
cc17557e
SS
2227}
2228
f0fba2ad 2229static int twl4030_soc_remove(struct snd_soc_codec *codec)
cc17557e 2230{
5b3b0fa8
AL
2231 struct twl4030_priv *twl4030 = snd_soc_codec_get_drvdata(codec);
2232
5dcba5d6
PU
2233 /* Reset registers to their chip default before leaving */
2234 twl4030_reset_registers(codec);
7a1fecf5 2235 twl4030_set_bias_level(codec, SND_SOC_BIAS_OFF);
5b3b0fa8 2236 kfree(twl4030);
7a1fecf5
PU
2237 return 0;
2238}
2239
f0fba2ad
LG
2240static struct snd_soc_codec_driver soc_codec_dev_twl4030 = {
2241 .probe = twl4030_soc_probe,
2242 .remove = twl4030_soc_remove,
2243 .suspend = twl4030_soc_suspend,
2244 .resume = twl4030_soc_resume,
2245 .read = twl4030_read_reg_cache,
2246 .write = twl4030_write,
2247 .set_bias_level = twl4030_set_bias_level,
eb3032f8 2248 .idle_bias_off = true,
f0fba2ad
LG
2249 .reg_cache_size = sizeof(twl4030_reg),
2250 .reg_word_size = sizeof(u8),
2251 .reg_cache_default = twl4030_reg,
f7c93f01
PU
2252
2253 .controls = twl4030_snd_controls,
2254 .num_controls = ARRAY_SIZE(twl4030_snd_controls),
2255 .dapm_widgets = twl4030_dapm_widgets,
2256 .num_dapm_widgets = ARRAY_SIZE(twl4030_dapm_widgets),
2257 .dapm_routes = intercon,
2258 .num_dapm_routes = ARRAY_SIZE(intercon),
f0fba2ad
LG
2259};
2260
7a1fecf5
PU
2261static int __devinit twl4030_codec_probe(struct platform_device *pdev)
2262{
4ae6df5e 2263 struct twl4030_codec_data *pdata = pdev->dev.platform_data;
cc17557e 2264
68d01955
PU
2265 if (!pdata) {
2266 dev_err(&pdev->dev, "platform_data is missing\n");
7a1fecf5
PU
2267 return -EINVAL;
2268 }
cc17557e 2269
f0fba2ad
LG
2270 return snd_soc_register_codec(&pdev->dev, &soc_codec_dev_twl4030,
2271 twl4030_dai, ARRAY_SIZE(twl4030_dai));
cc17557e
SS
2272}
2273
7a1fecf5 2274static int __devexit twl4030_codec_remove(struct platform_device *pdev)
cc17557e 2275{
f0fba2ad 2276 snd_soc_unregister_codec(&pdev->dev);
cc17557e
SS
2277 return 0;
2278}
2279
f0fba2ad 2280MODULE_ALIAS("platform:twl4030-codec");
7a1fecf5
PU
2281
2282static struct platform_driver twl4030_codec_driver = {
2283 .probe = twl4030_codec_probe,
2284 .remove = __devexit_p(twl4030_codec_remove),
2285 .driver = {
f0fba2ad 2286 .name = "twl4030-codec",
7a1fecf5
PU
2287 .owner = THIS_MODULE,
2288 },
cc17557e 2289};
cc17557e 2290
5bbcc3c0 2291module_platform_driver(twl4030_codec_driver);
64089b84 2292
cc17557e
SS
2293MODULE_DESCRIPTION("ASoC TWL4030 codec driver");
2294MODULE_AUTHOR("Steve Sakoman");
2295MODULE_LICENSE("GPL");
This page took 0.431604 seconds and 5 git commands to generate.