blob: f48dbf1fa40060b23aca95d4e3c7b7f5d0f0e208 [file] [log] [blame]
Ravishankar Sarawadi839fcf32012-11-14 12:13:00 -08001/* Copyright (c) 2012-2013, The Linux Foundation. All rights reserved.
Kiran Kandic3b24402012-06-11 00:05:59 -07002 *
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License version 2 and
5 * only version 2 as published by the Free Software Foundation.
6 *
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
11 */
12#include <linux/module.h>
13#include <linux/init.h>
14#include <linux/firmware.h>
15#include <linux/slab.h>
16#include <linux/platform_device.h>
17#include <linux/device.h>
18#include <linux/printk.h>
19#include <linux/ratelimit.h>
20#include <linux/debugfs.h>
Joonwoo Park9bbb4d12012-11-09 19:58:11 -080021#include <linux/wait.h>
22#include <linux/bitops.h>
Kiran Kandic3b24402012-06-11 00:05:59 -070023#include <linux/mfd/wcd9xxx/core.h>
24#include <linux/mfd/wcd9xxx/wcd9xxx_registers.h>
25#include <linux/mfd/wcd9xxx/wcd9320_registers.h>
26#include <linux/mfd/wcd9xxx/pdata.h>
27#include <sound/pcm.h>
28#include <sound/pcm_params.h>
29#include <sound/soc.h>
30#include <sound/soc-dapm.h>
31#include <sound/tlv.h>
32#include <linux/bitops.h>
33#include <linux/delay.h>
34#include <linux/pm_runtime.h>
35#include <linux/kernel.h>
36#include <linux/gpio.h>
37#include "wcd9320.h"
Joonwoo Parka8890262012-10-15 12:04:27 -070038#include "wcd9xxx-resmgr.h"
Bhalchandra Gajare87fef4c2013-02-19 14:57:03 -080039#include "wcd9xxx-common.h"
Kiran Kandic3b24402012-06-11 00:05:59 -070040
Joonwoo Park125cd4e2012-12-11 15:16:11 -080041static atomic_t kp_taiko_priv;
42static int spkr_drv_wrnd_param_set(const char *val,
43 const struct kernel_param *kp);
44static int spkr_drv_wrnd = 1;
45
46static struct kernel_param_ops spkr_drv_wrnd_param_ops = {
47 .set = spkr_drv_wrnd_param_set,
48 .get = param_get_int,
49};
50module_param_cb(spkr_drv_wrnd, &spkr_drv_wrnd_param_ops, &spkr_drv_wrnd, 0644);
51MODULE_PARM_DESC(spkr_drv_wrnd,
52 "Run software workaround to avoid leakage on the speaker drive");
53
Kiran Kandic3b24402012-06-11 00:05:59 -070054#define WCD9320_RATES (SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |\
55 SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |\
56 SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_192000)
57
Kiran Kandic3b24402012-06-11 00:05:59 -070058#define NUM_DECIMATORS 10
59#define NUM_INTERPOLATORS 7
60#define BITS_PER_REG 8
Kuirong Wang906ac472012-07-09 12:54:44 -070061#define TAIKO_TX_PORT_NUMBER 16
Kiran Kandic3b24402012-06-11 00:05:59 -070062
Kiran Kandic3b24402012-06-11 00:05:59 -070063#define TAIKO_I2S_MASTER_MODE_MASK 0x08
Venkat Sudhira41630a2012-10-27 00:57:31 -070064#define TAIKO_MCLK_CLK_12P288MHZ 12288000
65#define TAIKO_MCLK_CLK_9P6HZ 9600000
Joonwoo Park9bbb4d12012-11-09 19:58:11 -080066
67#define TAIKO_SLIM_CLOSE_TIMEOUT 1000
68#define TAIKO_SLIM_IRQ_OVERFLOW (1 << 0)
69#define TAIKO_SLIM_IRQ_UNDERFLOW (1 << 1)
70#define TAIKO_SLIM_IRQ_PORT_CLOSED (1 << 2)
Venkat Sudhira50a3762012-11-26 12:12:15 -080071#define TAIKO_MCLK_CLK_12P288MHZ 12288000
72#define TAIKO_MCLK_CLK_9P6HZ 9600000
Bhalchandra Gajare87fef4c2013-02-19 14:57:03 -080073
Bhalchandra Gajare5b40c532013-02-19 13:36:47 -080074#define TAIKO_FORMATS_S16_S24_LE (SNDRV_PCM_FMTBIT_S16_LE | \
75 SNDRV_PCM_FORMAT_S24_LE)
76
77#define TAIKO_FORMATS (SNDRV_PCM_FMTBIT_S16_LE)
78
Kuirong Wang906ac472012-07-09 12:54:44 -070079enum {
80 AIF1_PB = 0,
81 AIF1_CAP,
82 AIF2_PB,
83 AIF2_CAP,
84 AIF3_PB,
85 AIF3_CAP,
86 NUM_CODEC_DAIS,
Kiran Kandic3b24402012-06-11 00:05:59 -070087};
88
Kuirong Wang906ac472012-07-09 12:54:44 -070089enum {
90 RX_MIX1_INP_SEL_ZERO = 0,
91 RX_MIX1_INP_SEL_SRC1,
92 RX_MIX1_INP_SEL_SRC2,
93 RX_MIX1_INP_SEL_IIR1,
94 RX_MIX1_INP_SEL_IIR2,
95 RX_MIX1_INP_SEL_RX1,
96 RX_MIX1_INP_SEL_RX2,
97 RX_MIX1_INP_SEL_RX3,
98 RX_MIX1_INP_SEL_RX4,
99 RX_MIX1_INP_SEL_RX5,
100 RX_MIX1_INP_SEL_RX6,
101 RX_MIX1_INP_SEL_RX7,
102 RX_MIX1_INP_SEL_AUXRX,
103};
104
105#define TAIKO_COMP_DIGITAL_GAIN_OFFSET 3
106
Kiran Kandic3b24402012-06-11 00:05:59 -0700107static const DECLARE_TLV_DB_SCALE(digital_gain, 0, 1, 0);
108static const DECLARE_TLV_DB_SCALE(line_gain, 0, 7, 1);
109static const DECLARE_TLV_DB_SCALE(analog_gain, 0, 25, 1);
110static struct snd_soc_dai_driver taiko_dai[];
111static const DECLARE_TLV_DB_SCALE(aux_pga_gain, 0, 2, 0);
112
Kiran Kandic3b24402012-06-11 00:05:59 -0700113/* Codec supports 2 IIR filters */
114enum {
115 IIR1 = 0,
116 IIR2,
117 IIR_MAX,
118};
119/* Codec supports 5 bands */
120enum {
121 BAND1 = 0,
122 BAND2,
123 BAND3,
124 BAND4,
125 BAND5,
126 BAND_MAX,
127};
128
129enum {
Joonwoo Parkc7731432012-10-17 12:41:44 -0700130 COMPANDER_0,
131 COMPANDER_1,
Kiran Kandic3b24402012-06-11 00:05:59 -0700132 COMPANDER_2,
133 COMPANDER_MAX,
134};
135
136enum {
137 COMPANDER_FS_8KHZ = 0,
138 COMPANDER_FS_16KHZ,
139 COMPANDER_FS_32KHZ,
140 COMPANDER_FS_48KHZ,
141 COMPANDER_FS_96KHZ,
142 COMPANDER_FS_192KHZ,
143 COMPANDER_FS_MAX,
144};
145
Kiran Kandic3b24402012-06-11 00:05:59 -0700146struct comp_sample_dependent_params {
147 u32 peak_det_timeout;
148 u32 rms_meter_div_fact;
149 u32 rms_meter_resamp_fact;
150};
151
Kiran Kandic3b24402012-06-11 00:05:59 -0700152struct hpf_work {
153 struct taiko_priv *taiko;
154 u32 decimator;
155 u8 tx_hpf_cut_of_freq;
156 struct delayed_work dwork;
157};
158
159static struct hpf_work tx_hpf_work[NUM_DECIMATORS];
160
Kuirong Wang906ac472012-07-09 12:54:44 -0700161static const struct wcd9xxx_ch taiko_rx_chs[TAIKO_RX_MAX] = {
162 WCD9XXX_CH(16, 0),
163 WCD9XXX_CH(17, 1),
164 WCD9XXX_CH(18, 2),
165 WCD9XXX_CH(19, 3),
166 WCD9XXX_CH(20, 4),
167 WCD9XXX_CH(21, 5),
168 WCD9XXX_CH(22, 6),
169 WCD9XXX_CH(23, 7),
170 WCD9XXX_CH(24, 8),
171 WCD9XXX_CH(25, 9),
172 WCD9XXX_CH(26, 10),
173 WCD9XXX_CH(27, 11),
174 WCD9XXX_CH(28, 12),
175};
176
177static const struct wcd9xxx_ch taiko_tx_chs[TAIKO_TX_MAX] = {
178 WCD9XXX_CH(0, 0),
179 WCD9XXX_CH(1, 1),
180 WCD9XXX_CH(2, 2),
181 WCD9XXX_CH(3, 3),
182 WCD9XXX_CH(4, 4),
183 WCD9XXX_CH(5, 5),
184 WCD9XXX_CH(6, 6),
185 WCD9XXX_CH(7, 7),
186 WCD9XXX_CH(8, 8),
187 WCD9XXX_CH(9, 9),
188 WCD9XXX_CH(10, 10),
189 WCD9XXX_CH(11, 11),
190 WCD9XXX_CH(12, 12),
191 WCD9XXX_CH(13, 13),
192 WCD9XXX_CH(14, 14),
193 WCD9XXX_CH(15, 15),
194};
195
196static const u32 vport_check_table[NUM_CODEC_DAIS] = {
197 0, /* AIF1_PB */
198 (1 << AIF2_CAP) | (1 << AIF3_CAP), /* AIF1_CAP */
199 0, /* AIF2_PB */
200 (1 << AIF1_CAP) | (1 << AIF3_CAP), /* AIF2_CAP */
201 0, /* AIF2_PB */
202 (1 << AIF1_CAP) | (1 << AIF2_CAP), /* AIF2_CAP */
203};
204
Venkat Sudhir96dd28c2012-12-04 17:00:19 -0800205static const u32 vport_i2s_check_table[NUM_CODEC_DAIS] = {
206 0, /* AIF1_PB */
207 0, /* AIF1_CAP */
Venkat Sudhir994193b2012-12-17 17:30:51 -0800208 0, /* AIF2_PB */
209 0, /* AIF2_CAP */
Venkat Sudhir96dd28c2012-12-04 17:00:19 -0800210};
211
Kiran Kandic3b24402012-06-11 00:05:59 -0700212struct taiko_priv {
213 struct snd_soc_codec *codec;
Kiran Kandic3b24402012-06-11 00:05:59 -0700214 u32 adc_count;
Kiran Kandic3b24402012-06-11 00:05:59 -0700215 u32 rx_bias_count;
216 s32 dmic_1_2_clk_cnt;
217 s32 dmic_3_4_clk_cnt;
218 s32 dmic_5_6_clk_cnt;
219
Kiran Kandic3b24402012-06-11 00:05:59 -0700220 u32 anc_slot;
221
Kiran Kandic3b24402012-06-11 00:05:59 -0700222 /*track taiko interface type*/
223 u8 intf_type;
224
Kiran Kandic3b24402012-06-11 00:05:59 -0700225 /* num of slim ports required */
Kuirong Wang906ac472012-07-09 12:54:44 -0700226 struct wcd9xxx_codec_dai_data dai[NUM_CODEC_DAIS];
Kiran Kandic3b24402012-06-11 00:05:59 -0700227
228 /*compander*/
229 int comp_enabled[COMPANDER_MAX];
230 u32 comp_fs[COMPANDER_MAX];
231
232 /* Maintain the status of AUX PGA */
233 int aux_pga_cnt;
234 u8 aux_l_gain;
235 u8 aux_r_gain;
236
Joonwoo Park125cd4e2012-12-11 15:16:11 -0800237 bool spkr_pa_widget_on;
238
Joonwoo Parka8890262012-10-15 12:04:27 -0700239 /* resmgr module */
240 struct wcd9xxx_resmgr resmgr;
241 /* mbhc module */
242 struct wcd9xxx_mbhc mbhc;
Bhalchandra Gajare87fef4c2013-02-19 14:57:03 -0800243
244 /* class h specific data */
245 struct wcd9xxx_clsh_cdc_data clsh_d;
246
Kiran Kandic3b24402012-06-11 00:05:59 -0700247};
248
Kiran Kandic3b24402012-06-11 00:05:59 -0700249static const u32 comp_shift[] = {
Joonwoo Parkc7731432012-10-17 12:41:44 -0700250 4, /* Compander 0's clock source is on interpolator 7 */
Kiran Kandic3b24402012-06-11 00:05:59 -0700251 0,
252 2,
253};
254
255static const int comp_rx_path[] = {
256 COMPANDER_1,
257 COMPANDER_1,
258 COMPANDER_2,
259 COMPANDER_2,
260 COMPANDER_2,
261 COMPANDER_2,
Joonwoo Parkc7731432012-10-17 12:41:44 -0700262 COMPANDER_0,
Kiran Kandic3b24402012-06-11 00:05:59 -0700263 COMPANDER_MAX,
264};
265
266static const struct comp_sample_dependent_params comp_samp_params[] = {
267 {
Joonwoo Parkc7731432012-10-17 12:41:44 -0700268 /* 8 Khz */
269 .peak_det_timeout = 0x02,
270 .rms_meter_div_fact = 0x09,
271 .rms_meter_resamp_fact = 0x06,
Kiran Kandic3b24402012-06-11 00:05:59 -0700272 },
273 {
Joonwoo Parkc7731432012-10-17 12:41:44 -0700274 /* 16 Khz */
275 .peak_det_timeout = 0x03,
276 .rms_meter_div_fact = 0x0A,
277 .rms_meter_resamp_fact = 0x0C,
278 },
279 {
280 /* 32 Khz */
281 .peak_det_timeout = 0x05,
282 .rms_meter_div_fact = 0x0B,
283 .rms_meter_resamp_fact = 0x1E,
284 },
285 {
286 /* 48 Khz */
287 .peak_det_timeout = 0x05,
288 .rms_meter_div_fact = 0x0B,
Kiran Kandic3b24402012-06-11 00:05:59 -0700289 .rms_meter_resamp_fact = 0x28,
290 },
Kiran Kandic3b24402012-06-11 00:05:59 -0700291 {
Joonwoo Parkc7731432012-10-17 12:41:44 -0700292 /* 96 Khz */
293 .peak_det_timeout = 0x06,
294 .rms_meter_div_fact = 0x0C,
295 .rms_meter_resamp_fact = 0x50,
Kiran Kandic3b24402012-06-11 00:05:59 -0700296 },
Kiran Kandic3b24402012-06-11 00:05:59 -0700297 {
Joonwoo Parkc7731432012-10-17 12:41:44 -0700298 /* 192 Khz */
299 .peak_det_timeout = 0x07,
300 .rms_meter_div_fact = 0xD,
301 .rms_meter_resamp_fact = 0xA0,
Kiran Kandic3b24402012-06-11 00:05:59 -0700302 },
303};
304
305static unsigned short rx_digital_gain_reg[] = {
306 TAIKO_A_CDC_RX1_VOL_CTL_B2_CTL,
307 TAIKO_A_CDC_RX2_VOL_CTL_B2_CTL,
308 TAIKO_A_CDC_RX3_VOL_CTL_B2_CTL,
309 TAIKO_A_CDC_RX4_VOL_CTL_B2_CTL,
310 TAIKO_A_CDC_RX5_VOL_CTL_B2_CTL,
311 TAIKO_A_CDC_RX6_VOL_CTL_B2_CTL,
312 TAIKO_A_CDC_RX7_VOL_CTL_B2_CTL,
313};
314
315
316static unsigned short tx_digital_gain_reg[] = {
317 TAIKO_A_CDC_TX1_VOL_CTL_GAIN,
318 TAIKO_A_CDC_TX2_VOL_CTL_GAIN,
319 TAIKO_A_CDC_TX3_VOL_CTL_GAIN,
320 TAIKO_A_CDC_TX4_VOL_CTL_GAIN,
321 TAIKO_A_CDC_TX5_VOL_CTL_GAIN,
322 TAIKO_A_CDC_TX6_VOL_CTL_GAIN,
323 TAIKO_A_CDC_TX7_VOL_CTL_GAIN,
324 TAIKO_A_CDC_TX8_VOL_CTL_GAIN,
325 TAIKO_A_CDC_TX9_VOL_CTL_GAIN,
326 TAIKO_A_CDC_TX10_VOL_CTL_GAIN,
327};
328
Joonwoo Park125cd4e2012-12-11 15:16:11 -0800329static int spkr_drv_wrnd_param_set(const char *val,
330 const struct kernel_param *kp)
331{
332 struct snd_soc_codec *codec;
333 int ret, old;
334 struct taiko_priv *priv;
335
336 priv = (struct taiko_priv *)atomic_read(&kp_taiko_priv);
337 if (!priv) {
338 pr_debug("%s: codec isn't yet registered\n", __func__);
339 return 0;
340 }
341
342 WCD9XXX_BCL_LOCK(&priv->resmgr);
343 old = spkr_drv_wrnd;
344 ret = param_set_int(val, kp);
345 if (ret) {
346 WCD9XXX_BCL_UNLOCK(&priv->resmgr);
347 return ret;
348 }
349
350 pr_debug("%s: spkr_drv_wrnd %d -> %d\n", __func__, old, spkr_drv_wrnd);
351 codec = priv->codec;
352 if (old == 0 && spkr_drv_wrnd == 1) {
353 wcd9xxx_resmgr_get_bandgap(&priv->resmgr,
354 WCD9XXX_BANDGAP_AUDIO_MODE);
355 snd_soc_update_bits(codec, TAIKO_A_SPKR_DRV_EN, 0x80, 0x80);
356 } else if (old == 1 && spkr_drv_wrnd == 0) {
357 wcd9xxx_resmgr_put_bandgap(&priv->resmgr,
358 WCD9XXX_BANDGAP_AUDIO_MODE);
359 if (!priv->spkr_pa_widget_on)
360 snd_soc_update_bits(codec, TAIKO_A_SPKR_DRV_EN, 0x80,
361 0x00);
362 }
363
364 WCD9XXX_BCL_UNLOCK(&priv->resmgr);
365 return 0;
366}
367
Kiran Kandic3b24402012-06-11 00:05:59 -0700368static int taiko_get_anc_slot(struct snd_kcontrol *kcontrol,
369 struct snd_ctl_elem_value *ucontrol)
370{
371 struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
372 struct taiko_priv *taiko = snd_soc_codec_get_drvdata(codec);
373 ucontrol->value.integer.value[0] = taiko->anc_slot;
374 return 0;
375}
376
377static int taiko_put_anc_slot(struct snd_kcontrol *kcontrol,
378 struct snd_ctl_elem_value *ucontrol)
379{
380 struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
381 struct taiko_priv *taiko = snd_soc_codec_get_drvdata(codec);
382 taiko->anc_slot = ucontrol->value.integer.value[0];
383 return 0;
384}
385
386static int taiko_pa_gain_get(struct snd_kcontrol *kcontrol,
387 struct snd_ctl_elem_value *ucontrol)
388{
389 u8 ear_pa_gain;
390 struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
391
392 ear_pa_gain = snd_soc_read(codec, TAIKO_A_RX_EAR_GAIN);
393
394 ear_pa_gain = ear_pa_gain >> 5;
395
396 if (ear_pa_gain == 0x00) {
397 ucontrol->value.integer.value[0] = 0;
398 } else if (ear_pa_gain == 0x04) {
399 ucontrol->value.integer.value[0] = 1;
400 } else {
401 pr_err("%s: ERROR: Unsupported Ear Gain = 0x%x\n",
402 __func__, ear_pa_gain);
403 return -EINVAL;
404 }
405
406 pr_debug("%s: ear_pa_gain = 0x%x\n", __func__, ear_pa_gain);
407
408 return 0;
409}
410
411static int taiko_pa_gain_put(struct snd_kcontrol *kcontrol,
412 struct snd_ctl_elem_value *ucontrol)
413{
414 u8 ear_pa_gain;
415 struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
416
417 pr_debug("%s: ucontrol->value.integer.value[0] = %ld\n", __func__,
418 ucontrol->value.integer.value[0]);
419
420 switch (ucontrol->value.integer.value[0]) {
421 case 0:
422 ear_pa_gain = 0x00;
423 break;
424 case 1:
425 ear_pa_gain = 0x80;
426 break;
427 default:
428 return -EINVAL;
429 }
430
431 snd_soc_update_bits(codec, TAIKO_A_RX_EAR_GAIN, 0xE0, ear_pa_gain);
432 return 0;
433}
434
435static int taiko_get_iir_enable_audio_mixer(
436 struct snd_kcontrol *kcontrol,
437 struct snd_ctl_elem_value *ucontrol)
438{
439 struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
440 int iir_idx = ((struct soc_multi_mixer_control *)
441 kcontrol->private_value)->reg;
442 int band_idx = ((struct soc_multi_mixer_control *)
443 kcontrol->private_value)->shift;
444
445 ucontrol->value.integer.value[0] =
Ben Romberger205e14d2013-02-06 12:31:53 -0800446 (snd_soc_read(codec, (TAIKO_A_CDC_IIR1_CTL + 16 * iir_idx)) &
447 (1 << band_idx)) != 0;
Kiran Kandic3b24402012-06-11 00:05:59 -0700448
449 pr_debug("%s: IIR #%d band #%d enable %d\n", __func__,
450 iir_idx, band_idx,
451 (uint32_t)ucontrol->value.integer.value[0]);
452 return 0;
453}
454
455static int taiko_put_iir_enable_audio_mixer(
456 struct snd_kcontrol *kcontrol,
457 struct snd_ctl_elem_value *ucontrol)
458{
459 struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
460 int iir_idx = ((struct soc_multi_mixer_control *)
461 kcontrol->private_value)->reg;
462 int band_idx = ((struct soc_multi_mixer_control *)
463 kcontrol->private_value)->shift;
464 int value = ucontrol->value.integer.value[0];
465
466 /* Mask first 5 bits, 6-8 are reserved */
467 snd_soc_update_bits(codec, (TAIKO_A_CDC_IIR1_CTL + 16 * iir_idx),
468 (1 << band_idx), (value << band_idx));
469
470 pr_debug("%s: IIR #%d band #%d enable %d\n", __func__,
Ben Romberger205e14d2013-02-06 12:31:53 -0800471 iir_idx, band_idx,
472 ((snd_soc_read(codec, (TAIKO_A_CDC_IIR1_CTL + 16 * iir_idx)) &
473 (1 << band_idx)) != 0));
Kiran Kandic3b24402012-06-11 00:05:59 -0700474 return 0;
475}
476static uint32_t get_iir_band_coeff(struct snd_soc_codec *codec,
477 int iir_idx, int band_idx,
478 int coeff_idx)
479{
Ben Romberger205e14d2013-02-06 12:31:53 -0800480 uint32_t value = 0;
481
Kiran Kandic3b24402012-06-11 00:05:59 -0700482 /* Address does not automatically update if reading */
483 snd_soc_write(codec,
484 (TAIKO_A_CDC_IIR1_COEF_B1_CTL + 16 * iir_idx),
Ben Romberger205e14d2013-02-06 12:31:53 -0800485 ((band_idx * BAND_MAX + coeff_idx)
486 * sizeof(uint32_t)) & 0x7F);
487
488 value |= snd_soc_read(codec,
489 (TAIKO_A_CDC_IIR1_COEF_B2_CTL + 16 * iir_idx));
490
491 snd_soc_write(codec,
492 (TAIKO_A_CDC_IIR1_COEF_B1_CTL + 16 * iir_idx),
493 ((band_idx * BAND_MAX + coeff_idx)
494 * sizeof(uint32_t) + 1) & 0x7F);
495
496 value |= (snd_soc_read(codec,
497 (TAIKO_A_CDC_IIR1_COEF_B2_CTL + 16 * iir_idx)) << 8);
498
499 snd_soc_write(codec,
500 (TAIKO_A_CDC_IIR1_COEF_B1_CTL + 16 * iir_idx),
501 ((band_idx * BAND_MAX + coeff_idx)
502 * sizeof(uint32_t) + 2) & 0x7F);
503
504 value |= (snd_soc_read(codec,
505 (TAIKO_A_CDC_IIR1_COEF_B2_CTL + 16 * iir_idx)) << 16);
506
507 snd_soc_write(codec,
508 (TAIKO_A_CDC_IIR1_COEF_B1_CTL + 16 * iir_idx),
509 ((band_idx * BAND_MAX + coeff_idx)
510 * sizeof(uint32_t) + 3) & 0x7F);
Kiran Kandic3b24402012-06-11 00:05:59 -0700511
512 /* Mask bits top 2 bits since they are reserved */
Ben Romberger205e14d2013-02-06 12:31:53 -0800513 value |= ((snd_soc_read(codec,
514 (TAIKO_A_CDC_IIR1_COEF_B2_CTL + 16 * iir_idx)) & 0x3F) << 24);
515
516 return value;
Kiran Kandic3b24402012-06-11 00:05:59 -0700517}
518
519static int taiko_get_iir_band_audio_mixer(
520 struct snd_kcontrol *kcontrol,
521 struct snd_ctl_elem_value *ucontrol)
522{
523 struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
524 int iir_idx = ((struct soc_multi_mixer_control *)
525 kcontrol->private_value)->reg;
526 int band_idx = ((struct soc_multi_mixer_control *)
527 kcontrol->private_value)->shift;
528
529 ucontrol->value.integer.value[0] =
530 get_iir_band_coeff(codec, iir_idx, band_idx, 0);
531 ucontrol->value.integer.value[1] =
532 get_iir_band_coeff(codec, iir_idx, band_idx, 1);
533 ucontrol->value.integer.value[2] =
534 get_iir_band_coeff(codec, iir_idx, band_idx, 2);
535 ucontrol->value.integer.value[3] =
536 get_iir_band_coeff(codec, iir_idx, band_idx, 3);
537 ucontrol->value.integer.value[4] =
538 get_iir_band_coeff(codec, iir_idx, band_idx, 4);
539
540 pr_debug("%s: IIR #%d band #%d b0 = 0x%x\n"
541 "%s: IIR #%d band #%d b1 = 0x%x\n"
542 "%s: IIR #%d band #%d b2 = 0x%x\n"
543 "%s: IIR #%d band #%d a1 = 0x%x\n"
544 "%s: IIR #%d band #%d a2 = 0x%x\n",
545 __func__, iir_idx, band_idx,
546 (uint32_t)ucontrol->value.integer.value[0],
547 __func__, iir_idx, band_idx,
548 (uint32_t)ucontrol->value.integer.value[1],
549 __func__, iir_idx, band_idx,
550 (uint32_t)ucontrol->value.integer.value[2],
551 __func__, iir_idx, band_idx,
552 (uint32_t)ucontrol->value.integer.value[3],
553 __func__, iir_idx, band_idx,
554 (uint32_t)ucontrol->value.integer.value[4]);
555 return 0;
556}
557
558static void set_iir_band_coeff(struct snd_soc_codec *codec,
559 int iir_idx, int band_idx,
Ben Romberger205e14d2013-02-06 12:31:53 -0800560 uint32_t value)
Kiran Kandic3b24402012-06-11 00:05:59 -0700561{
Kiran Kandic3b24402012-06-11 00:05:59 -0700562 snd_soc_write(codec,
Ben Romberger205e14d2013-02-06 12:31:53 -0800563 (TAIKO_A_CDC_IIR1_COEF_B2_CTL + 16 * iir_idx),
564 (value & 0xFF));
565
566 snd_soc_write(codec,
567 (TAIKO_A_CDC_IIR1_COEF_B2_CTL + 16 * iir_idx),
568 (value >> 8) & 0xFF);
569
570 snd_soc_write(codec,
571 (TAIKO_A_CDC_IIR1_COEF_B2_CTL + 16 * iir_idx),
572 (value >> 16) & 0xFF);
Kiran Kandic3b24402012-06-11 00:05:59 -0700573
574 /* Mask top 2 bits, 7-8 are reserved */
575 snd_soc_write(codec,
576 (TAIKO_A_CDC_IIR1_COEF_B2_CTL + 16 * iir_idx),
577 (value >> 24) & 0x3F);
Kiran Kandic3b24402012-06-11 00:05:59 -0700578}
579
580static int taiko_put_iir_band_audio_mixer(
581 struct snd_kcontrol *kcontrol,
582 struct snd_ctl_elem_value *ucontrol)
583{
584 struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
585 int iir_idx = ((struct soc_multi_mixer_control *)
586 kcontrol->private_value)->reg;
587 int band_idx = ((struct soc_multi_mixer_control *)
588 kcontrol->private_value)->shift;
589
Ben Romberger205e14d2013-02-06 12:31:53 -0800590 /* Mask top bit it is reserved */
591 /* Updates addr automatically for each B2 write */
592 snd_soc_write(codec,
593 (TAIKO_A_CDC_IIR1_COEF_B1_CTL + 16 * iir_idx),
594 (band_idx * BAND_MAX * sizeof(uint32_t)) & 0x7F);
595
596 set_iir_band_coeff(codec, iir_idx, band_idx,
Kiran Kandic3b24402012-06-11 00:05:59 -0700597 ucontrol->value.integer.value[0]);
Ben Romberger205e14d2013-02-06 12:31:53 -0800598 set_iir_band_coeff(codec, iir_idx, band_idx,
Kiran Kandic3b24402012-06-11 00:05:59 -0700599 ucontrol->value.integer.value[1]);
Ben Romberger205e14d2013-02-06 12:31:53 -0800600 set_iir_band_coeff(codec, iir_idx, band_idx,
Kiran Kandic3b24402012-06-11 00:05:59 -0700601 ucontrol->value.integer.value[2]);
Ben Romberger205e14d2013-02-06 12:31:53 -0800602 set_iir_band_coeff(codec, iir_idx, band_idx,
Kiran Kandic3b24402012-06-11 00:05:59 -0700603 ucontrol->value.integer.value[3]);
Ben Romberger205e14d2013-02-06 12:31:53 -0800604 set_iir_band_coeff(codec, iir_idx, band_idx,
Kiran Kandic3b24402012-06-11 00:05:59 -0700605 ucontrol->value.integer.value[4]);
606
607 pr_debug("%s: IIR #%d band #%d b0 = 0x%x\n"
608 "%s: IIR #%d band #%d b1 = 0x%x\n"
609 "%s: IIR #%d band #%d b2 = 0x%x\n"
610 "%s: IIR #%d band #%d a1 = 0x%x\n"
611 "%s: IIR #%d band #%d a2 = 0x%x\n",
612 __func__, iir_idx, band_idx,
613 get_iir_band_coeff(codec, iir_idx, band_idx, 0),
614 __func__, iir_idx, band_idx,
615 get_iir_band_coeff(codec, iir_idx, band_idx, 1),
616 __func__, iir_idx, band_idx,
617 get_iir_band_coeff(codec, iir_idx, band_idx, 2),
618 __func__, iir_idx, band_idx,
619 get_iir_band_coeff(codec, iir_idx, band_idx, 3),
620 __func__, iir_idx, band_idx,
621 get_iir_band_coeff(codec, iir_idx, band_idx, 4));
622 return 0;
623}
624
Kiran Kandic3b24402012-06-11 00:05:59 -0700625static int taiko_get_compander(struct snd_kcontrol *kcontrol,
Joonwoo Parkc7731432012-10-17 12:41:44 -0700626 struct snd_ctl_elem_value *ucontrol)
Kiran Kandic3b24402012-06-11 00:05:59 -0700627{
628
629 struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
630 int comp = ((struct soc_multi_mixer_control *)
Joonwoo Parkc7731432012-10-17 12:41:44 -0700631 kcontrol->private_value)->shift;
Kiran Kandic3b24402012-06-11 00:05:59 -0700632 struct taiko_priv *taiko = snd_soc_codec_get_drvdata(codec);
633
634 ucontrol->value.integer.value[0] = taiko->comp_enabled[comp];
Kiran Kandic3b24402012-06-11 00:05:59 -0700635 return 0;
636}
637
638static int taiko_set_compander(struct snd_kcontrol *kcontrol,
Joonwoo Parkc7731432012-10-17 12:41:44 -0700639 struct snd_ctl_elem_value *ucontrol)
Kiran Kandic3b24402012-06-11 00:05:59 -0700640{
641 struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
642 struct taiko_priv *taiko = snd_soc_codec_get_drvdata(codec);
643 int comp = ((struct soc_multi_mixer_control *)
Joonwoo Parkc7731432012-10-17 12:41:44 -0700644 kcontrol->private_value)->shift;
Kiran Kandic3b24402012-06-11 00:05:59 -0700645 int value = ucontrol->value.integer.value[0];
646
Joonwoo Parkc7731432012-10-17 12:41:44 -0700647 pr_debug("%s: Compander %d enable current %d, new %d\n",
648 __func__, comp, taiko->comp_enabled[comp], value);
Kiran Kandic3b24402012-06-11 00:05:59 -0700649 taiko->comp_enabled[comp] = value;
650 return 0;
651}
652
Joonwoo Parkc7731432012-10-17 12:41:44 -0700653static int taiko_config_gain_compander(struct snd_soc_codec *codec,
654 int comp, bool enable)
655{
656 int ret = 0;
657
658 switch (comp) {
659 case COMPANDER_0:
660 snd_soc_update_bits(codec, TAIKO_A_SPKR_DRV_GAIN,
661 1 << 2, !enable << 2);
662 break;
663 case COMPANDER_1:
664 snd_soc_update_bits(codec, TAIKO_A_RX_HPH_L_GAIN,
665 1 << 5, !enable << 5);
666 snd_soc_update_bits(codec, TAIKO_A_RX_HPH_R_GAIN,
667 1 << 5, !enable << 5);
668 break;
669 case COMPANDER_2:
670 snd_soc_update_bits(codec, TAIKO_A_RX_LINE_1_GAIN,
671 1 << 5, !enable << 5);
672 snd_soc_update_bits(codec, TAIKO_A_RX_LINE_3_GAIN,
673 1 << 5, !enable << 5);
674 snd_soc_update_bits(codec, TAIKO_A_RX_LINE_2_GAIN,
675 1 << 5, !enable << 5);
676 snd_soc_update_bits(codec, TAIKO_A_RX_LINE_4_GAIN,
677 1 << 5, !enable << 5);
678 break;
679 default:
680 WARN_ON(1);
681 ret = -EINVAL;
682 }
683
684 return ret;
685}
686
687static void taiko_discharge_comp(struct snd_soc_codec *codec, int comp)
688{
689 /* Update RSM to 1, DIVF to 5 */
690 snd_soc_write(codec, TAIKO_A_CDC_COMP0_B3_CTL + (comp * 8), 1);
691 snd_soc_update_bits(codec, TAIKO_A_CDC_COMP0_B2_CTL + (comp * 8), 0xF0,
692 1 << 5);
693 /* Wait for 1ms */
694 usleep_range(1000, 1000);
695}
Kiran Kandic3b24402012-06-11 00:05:59 -0700696
697static int taiko_config_compander(struct snd_soc_dapm_widget *w,
Joonwoo Parkc7731432012-10-17 12:41:44 -0700698 struct snd_kcontrol *kcontrol, int event)
Kiran Kandic3b24402012-06-11 00:05:59 -0700699{
Joonwoo Parkc7731432012-10-17 12:41:44 -0700700 int mask, emask;
701 bool timedout;
702 unsigned long timeout;
Kiran Kandic3b24402012-06-11 00:05:59 -0700703 struct snd_soc_codec *codec = w->codec;
704 struct taiko_priv *taiko = snd_soc_codec_get_drvdata(codec);
Joonwoo Parkc7731432012-10-17 12:41:44 -0700705 const int comp = w->shift;
706 const u32 rate = taiko->comp_fs[comp];
707 const struct comp_sample_dependent_params *comp_params =
708 &comp_samp_params[rate];
Kiran Kandic3b24402012-06-11 00:05:59 -0700709
Joonwoo Parkc7731432012-10-17 12:41:44 -0700710 pr_debug("%s: %s event %d compander %d, enabled %d", __func__,
711 w->name, event, comp, taiko->comp_enabled[comp]);
712
713 if (!taiko->comp_enabled[comp])
714 return 0;
715
716 /* Compander 0 has single channel */
717 mask = (comp == COMPANDER_0 ? 0x01 : 0x03);
718 emask = (comp == COMPANDER_0 ? 0x02 : 0x03);
Kiran Kandid2b46332012-10-05 12:04:00 -0700719
Kiran Kandic3b24402012-06-11 00:05:59 -0700720 switch (event) {
721 case SND_SOC_DAPM_PRE_PMU:
Joonwoo Parkc7731432012-10-17 12:41:44 -0700722 /* Set gain source to compander */
723 taiko_config_gain_compander(codec, comp, true);
724 /* Enable RX interpolation path clocks */
725 snd_soc_update_bits(codec, TAIKO_A_CDC_CLK_RX_B2_CTL,
726 mask << comp_shift[comp],
727 mask << comp_shift[comp]);
728
729 taiko_discharge_comp(codec, comp);
730
731 /* Clear compander halt */
732 snd_soc_update_bits(codec, TAIKO_A_CDC_COMP0_B1_CTL +
733 (comp * 8),
734 1 << 2, 0);
735 /* Toggle compander reset bits */
736 snd_soc_update_bits(codec, TAIKO_A_CDC_CLK_OTHR_RESET_B2_CTL,
737 mask << comp_shift[comp],
738 mask << comp_shift[comp]);
739 snd_soc_update_bits(codec, TAIKO_A_CDC_CLK_OTHR_RESET_B2_CTL,
740 mask << comp_shift[comp], 0);
Kiran Kandic3b24402012-06-11 00:05:59 -0700741 break;
742 case SND_SOC_DAPM_POST_PMU:
Joonwoo Parkc7731432012-10-17 12:41:44 -0700743 /* Set sample rate dependent paramater */
744 snd_soc_update_bits(codec,
745 TAIKO_A_CDC_COMP0_FS_CFG + (comp * 8),
746 0x07, rate);
747 snd_soc_write(codec, TAIKO_A_CDC_COMP0_B3_CTL + (comp * 8),
748 comp_params->rms_meter_resamp_fact);
749 snd_soc_update_bits(codec,
750 TAIKO_A_CDC_COMP0_B2_CTL + (comp * 8),
751 0x0F, comp_params->peak_det_timeout);
752 snd_soc_update_bits(codec,
753 TAIKO_A_CDC_COMP0_B2_CTL + (comp * 8),
754 0xF0, comp_params->rms_meter_div_fact << 4);
755 /* Compander enable */
756 snd_soc_update_bits(codec, TAIKO_A_CDC_COMP0_B1_CTL +
757 (comp * 8), emask, emask);
Kiran Kandic3b24402012-06-11 00:05:59 -0700758 break;
759 case SND_SOC_DAPM_PRE_PMD:
Joonwoo Parkc7731432012-10-17 12:41:44 -0700760 /* Halt compander */
761 snd_soc_update_bits(codec,
762 TAIKO_A_CDC_COMP0_B1_CTL + (comp * 8),
763 1 << 2, 1 << 2);
764 /* Wait up to a second for shutdown complete */
765 timeout = jiffies + HZ;
766 do {
767 if ((snd_soc_read(codec,
768 TAIKO_A_CDC_COMP0_SHUT_DOWN_STATUS +
769 (comp * 8)) & mask) == mask)
770 break;
771 } while (!(timedout = time_after(jiffies, timeout)));
772 pr_debug("%s: Compander %d shutdown %s in %dms\n", __func__,
773 comp, timedout ? "timedout" : "completed",
774 jiffies_to_msecs(timeout - HZ - jiffies));
Kiran Kandic3b24402012-06-11 00:05:59 -0700775 break;
776 case SND_SOC_DAPM_POST_PMD:
Joonwoo Parkc7731432012-10-17 12:41:44 -0700777 /* Disable compander */
778 snd_soc_update_bits(codec,
779 TAIKO_A_CDC_COMP0_B1_CTL + (comp * 8),
780 emask, 0x00);
781 /* Turn off the clock for compander in pair */
782 snd_soc_update_bits(codec, TAIKO_A_CDC_CLK_RX_B2_CTL,
783 mask << comp_shift[comp], 0);
784 /* Set gain source to register */
785 taiko_config_gain_compander(codec, comp, false);
Kiran Kandic3b24402012-06-11 00:05:59 -0700786 break;
787 }
788 return 0;
789}
790
791static const char * const taiko_ear_pa_gain_text[] = {"POS_6_DB", "POS_2_DB"};
792static const struct soc_enum taiko_ear_pa_gain_enum[] = {
793 SOC_ENUM_SINGLE_EXT(2, taiko_ear_pa_gain_text),
794};
795
796/*cut of frequency for high pass filter*/
797static const char * const cf_text[] = {
798 "MIN_3DB_4Hz", "MIN_3DB_75Hz", "MIN_3DB_150Hz"
799};
800
801static const struct soc_enum cf_dec1_enum =
802 SOC_ENUM_SINGLE(TAIKO_A_CDC_TX1_MUX_CTL, 4, 3, cf_text);
803
804static const struct soc_enum cf_dec2_enum =
805 SOC_ENUM_SINGLE(TAIKO_A_CDC_TX2_MUX_CTL, 4, 3, cf_text);
806
807static const struct soc_enum cf_dec3_enum =
808 SOC_ENUM_SINGLE(TAIKO_A_CDC_TX3_MUX_CTL, 4, 3, cf_text);
809
810static const struct soc_enum cf_dec4_enum =
811 SOC_ENUM_SINGLE(TAIKO_A_CDC_TX4_MUX_CTL, 4, 3, cf_text);
812
813static const struct soc_enum cf_dec5_enum =
814 SOC_ENUM_SINGLE(TAIKO_A_CDC_TX5_MUX_CTL, 4, 3, cf_text);
815
816static const struct soc_enum cf_dec6_enum =
817 SOC_ENUM_SINGLE(TAIKO_A_CDC_TX6_MUX_CTL, 4, 3, cf_text);
818
819static const struct soc_enum cf_dec7_enum =
820 SOC_ENUM_SINGLE(TAIKO_A_CDC_TX7_MUX_CTL, 4, 3, cf_text);
821
822static const struct soc_enum cf_dec8_enum =
823 SOC_ENUM_SINGLE(TAIKO_A_CDC_TX8_MUX_CTL, 4, 3, cf_text);
824
825static const struct soc_enum cf_dec9_enum =
826 SOC_ENUM_SINGLE(TAIKO_A_CDC_TX9_MUX_CTL, 4, 3, cf_text);
827
828static const struct soc_enum cf_dec10_enum =
829 SOC_ENUM_SINGLE(TAIKO_A_CDC_TX10_MUX_CTL, 4, 3, cf_text);
830
831static const struct soc_enum cf_rxmix1_enum =
832 SOC_ENUM_SINGLE(TAIKO_A_CDC_RX1_B4_CTL, 1, 3, cf_text);
833
834static const struct soc_enum cf_rxmix2_enum =
835 SOC_ENUM_SINGLE(TAIKO_A_CDC_RX2_B4_CTL, 1, 3, cf_text);
836
837static const struct soc_enum cf_rxmix3_enum =
838 SOC_ENUM_SINGLE(TAIKO_A_CDC_RX3_B4_CTL, 1, 3, cf_text);
839
840static const struct soc_enum cf_rxmix4_enum =
841 SOC_ENUM_SINGLE(TAIKO_A_CDC_RX4_B4_CTL, 1, 3, cf_text);
842
843static const struct soc_enum cf_rxmix5_enum =
844 SOC_ENUM_SINGLE(TAIKO_A_CDC_RX5_B4_CTL, 1, 3, cf_text)
845;
846static const struct soc_enum cf_rxmix6_enum =
847 SOC_ENUM_SINGLE(TAIKO_A_CDC_RX6_B4_CTL, 1, 3, cf_text);
848
849static const struct soc_enum cf_rxmix7_enum =
850 SOC_ENUM_SINGLE(TAIKO_A_CDC_RX7_B4_CTL, 1, 3, cf_text);
851
Bhalchandra Gajare87fef4c2013-02-19 14:57:03 -0800852static const char * const class_h_dsm_text[] = {
853 "ZERO", "DSM_HPHL_RX1", "DSM_SPKR_RX7"
854};
855
856static const struct soc_enum class_h_dsm_enum =
857 SOC_ENUM_SINGLE(TAIKO_A_CDC_CONN_CLSH_CTL, 4, 3, class_h_dsm_text);
858
859static const struct snd_kcontrol_new class_h_dsm_mux =
860 SOC_DAPM_ENUM("CLASS_H_DSM MUX Mux", class_h_dsm_enum);
861
862
Kiran Kandic3b24402012-06-11 00:05:59 -0700863static const struct snd_kcontrol_new taiko_snd_controls[] = {
864
865 SOC_ENUM_EXT("EAR PA Gain", taiko_ear_pa_gain_enum[0],
866 taiko_pa_gain_get, taiko_pa_gain_put),
867
868 SOC_SINGLE_TLV("LINEOUT1 Volume", TAIKO_A_RX_LINE_1_GAIN, 0, 12, 1,
869 line_gain),
870 SOC_SINGLE_TLV("LINEOUT2 Volume", TAIKO_A_RX_LINE_2_GAIN, 0, 12, 1,
871 line_gain),
872 SOC_SINGLE_TLV("LINEOUT3 Volume", TAIKO_A_RX_LINE_3_GAIN, 0, 12, 1,
873 line_gain),
874 SOC_SINGLE_TLV("LINEOUT4 Volume", TAIKO_A_RX_LINE_4_GAIN, 0, 12, 1,
875 line_gain),
876
877 SOC_SINGLE_TLV("HPHL Volume", TAIKO_A_RX_HPH_L_GAIN, 0, 12, 1,
878 line_gain),
879 SOC_SINGLE_TLV("HPHR Volume", TAIKO_A_RX_HPH_R_GAIN, 0, 12, 1,
880 line_gain),
881
Kiran Kandifd0a1da2013-01-21 09:58:45 -0800882 SOC_SINGLE_TLV("SPK DRV Volume", TAIKO_A_SPKR_DRV_GAIN, 3, 7, 1,
883 line_gain),
884
Kiran Kandic3b24402012-06-11 00:05:59 -0700885 SOC_SINGLE_S8_TLV("RX1 Digital Volume", TAIKO_A_CDC_RX1_VOL_CTL_B2_CTL,
886 -84, 40, digital_gain),
887 SOC_SINGLE_S8_TLV("RX2 Digital Volume", TAIKO_A_CDC_RX2_VOL_CTL_B2_CTL,
888 -84, 40, digital_gain),
889 SOC_SINGLE_S8_TLV("RX3 Digital Volume", TAIKO_A_CDC_RX3_VOL_CTL_B2_CTL,
890 -84, 40, digital_gain),
891 SOC_SINGLE_S8_TLV("RX4 Digital Volume", TAIKO_A_CDC_RX4_VOL_CTL_B2_CTL,
892 -84, 40, digital_gain),
893 SOC_SINGLE_S8_TLV("RX5 Digital Volume", TAIKO_A_CDC_RX5_VOL_CTL_B2_CTL,
894 -84, 40, digital_gain),
895 SOC_SINGLE_S8_TLV("RX6 Digital Volume", TAIKO_A_CDC_RX6_VOL_CTL_B2_CTL,
896 -84, 40, digital_gain),
897 SOC_SINGLE_S8_TLV("RX7 Digital Volume", TAIKO_A_CDC_RX7_VOL_CTL_B2_CTL,
898 -84, 40, digital_gain),
899
900 SOC_SINGLE_S8_TLV("DEC1 Volume", TAIKO_A_CDC_TX1_VOL_CTL_GAIN, -84, 40,
901 digital_gain),
902 SOC_SINGLE_S8_TLV("DEC2 Volume", TAIKO_A_CDC_TX2_VOL_CTL_GAIN, -84, 40,
903 digital_gain),
904 SOC_SINGLE_S8_TLV("DEC3 Volume", TAIKO_A_CDC_TX3_VOL_CTL_GAIN, -84, 40,
905 digital_gain),
906 SOC_SINGLE_S8_TLV("DEC4 Volume", TAIKO_A_CDC_TX4_VOL_CTL_GAIN, -84, 40,
907 digital_gain),
908 SOC_SINGLE_S8_TLV("DEC5 Volume", TAIKO_A_CDC_TX5_VOL_CTL_GAIN, -84, 40,
909 digital_gain),
910 SOC_SINGLE_S8_TLV("DEC6 Volume", TAIKO_A_CDC_TX6_VOL_CTL_GAIN, -84, 40,
911 digital_gain),
912 SOC_SINGLE_S8_TLV("DEC7 Volume", TAIKO_A_CDC_TX7_VOL_CTL_GAIN, -84, 40,
913 digital_gain),
914 SOC_SINGLE_S8_TLV("DEC8 Volume", TAIKO_A_CDC_TX8_VOL_CTL_GAIN, -84, 40,
915 digital_gain),
916 SOC_SINGLE_S8_TLV("DEC9 Volume", TAIKO_A_CDC_TX9_VOL_CTL_GAIN, -84, 40,
917 digital_gain),
918 SOC_SINGLE_S8_TLV("DEC10 Volume", TAIKO_A_CDC_TX10_VOL_CTL_GAIN, -84,
919 40, digital_gain),
920 SOC_SINGLE_S8_TLV("IIR1 INP1 Volume", TAIKO_A_CDC_IIR1_GAIN_B1_CTL, -84,
921 40, digital_gain),
922 SOC_SINGLE_S8_TLV("IIR1 INP2 Volume", TAIKO_A_CDC_IIR1_GAIN_B2_CTL, -84,
923 40, digital_gain),
924 SOC_SINGLE_S8_TLV("IIR1 INP3 Volume", TAIKO_A_CDC_IIR1_GAIN_B3_CTL, -84,
925 40, digital_gain),
926 SOC_SINGLE_S8_TLV("IIR1 INP4 Volume", TAIKO_A_CDC_IIR1_GAIN_B4_CTL, -84,
927 40, digital_gain),
928 SOC_SINGLE_TLV("ADC1 Volume", TAIKO_A_TX_1_2_EN, 5, 3, 0, analog_gain),
929 SOC_SINGLE_TLV("ADC2 Volume", TAIKO_A_TX_1_2_EN, 1, 3, 0, analog_gain),
930 SOC_SINGLE_TLV("ADC3 Volume", TAIKO_A_TX_3_4_EN, 5, 3, 0, analog_gain),
931 SOC_SINGLE_TLV("ADC4 Volume", TAIKO_A_TX_3_4_EN, 1, 3, 0, analog_gain),
932 SOC_SINGLE_TLV("ADC5 Volume", TAIKO_A_TX_5_6_EN, 5, 3, 0, analog_gain),
933 SOC_SINGLE_TLV("ADC6 Volume", TAIKO_A_TX_5_6_EN, 1, 3, 0, analog_gain),
934
935
936 SOC_SINGLE("MICBIAS1 CAPLESS Switch", TAIKO_A_MICB_1_CTL, 4, 1, 1),
937 SOC_SINGLE("MICBIAS2 CAPLESS Switch", TAIKO_A_MICB_2_CTL, 4, 1, 1),
938 SOC_SINGLE("MICBIAS3 CAPLESS Switch", TAIKO_A_MICB_3_CTL, 4, 1, 1),
939 SOC_SINGLE("MICBIAS4 CAPLESS Switch", TAIKO_A_MICB_4_CTL, 4, 1, 1),
940
941 SOC_SINGLE_EXT("ANC Slot", SND_SOC_NOPM, 0, 0, 100, taiko_get_anc_slot,
942 taiko_put_anc_slot),
943 SOC_ENUM("TX1 HPF cut off", cf_dec1_enum),
944 SOC_ENUM("TX2 HPF cut off", cf_dec2_enum),
945 SOC_ENUM("TX3 HPF cut off", cf_dec3_enum),
946 SOC_ENUM("TX4 HPF cut off", cf_dec4_enum),
947 SOC_ENUM("TX5 HPF cut off", cf_dec5_enum),
948 SOC_ENUM("TX6 HPF cut off", cf_dec6_enum),
949 SOC_ENUM("TX7 HPF cut off", cf_dec7_enum),
950 SOC_ENUM("TX8 HPF cut off", cf_dec8_enum),
951 SOC_ENUM("TX9 HPF cut off", cf_dec9_enum),
952 SOC_ENUM("TX10 HPF cut off", cf_dec10_enum),
953
954 SOC_SINGLE("TX1 HPF Switch", TAIKO_A_CDC_TX1_MUX_CTL, 3, 1, 0),
955 SOC_SINGLE("TX2 HPF Switch", TAIKO_A_CDC_TX2_MUX_CTL, 3, 1, 0),
956 SOC_SINGLE("TX3 HPF Switch", TAIKO_A_CDC_TX3_MUX_CTL, 3, 1, 0),
957 SOC_SINGLE("TX4 HPF Switch", TAIKO_A_CDC_TX4_MUX_CTL, 3, 1, 0),
958 SOC_SINGLE("TX5 HPF Switch", TAIKO_A_CDC_TX5_MUX_CTL, 3, 1, 0),
959 SOC_SINGLE("TX6 HPF Switch", TAIKO_A_CDC_TX6_MUX_CTL, 3, 1, 0),
960 SOC_SINGLE("TX7 HPF Switch", TAIKO_A_CDC_TX7_MUX_CTL, 3, 1, 0),
961 SOC_SINGLE("TX8 HPF Switch", TAIKO_A_CDC_TX8_MUX_CTL, 3, 1, 0),
962 SOC_SINGLE("TX9 HPF Switch", TAIKO_A_CDC_TX9_MUX_CTL, 3, 1, 0),
963 SOC_SINGLE("TX10 HPF Switch", TAIKO_A_CDC_TX10_MUX_CTL, 3, 1, 0),
964
965 SOC_SINGLE("RX1 HPF Switch", TAIKO_A_CDC_RX1_B5_CTL, 2, 1, 0),
966 SOC_SINGLE("RX2 HPF Switch", TAIKO_A_CDC_RX2_B5_CTL, 2, 1, 0),
967 SOC_SINGLE("RX3 HPF Switch", TAIKO_A_CDC_RX3_B5_CTL, 2, 1, 0),
968 SOC_SINGLE("RX4 HPF Switch", TAIKO_A_CDC_RX4_B5_CTL, 2, 1, 0),
969 SOC_SINGLE("RX5 HPF Switch", TAIKO_A_CDC_RX5_B5_CTL, 2, 1, 0),
970 SOC_SINGLE("RX6 HPF Switch", TAIKO_A_CDC_RX6_B5_CTL, 2, 1, 0),
971 SOC_SINGLE("RX7 HPF Switch", TAIKO_A_CDC_RX7_B5_CTL, 2, 1, 0),
972
973 SOC_ENUM("RX1 HPF cut off", cf_rxmix1_enum),
974 SOC_ENUM("RX2 HPF cut off", cf_rxmix2_enum),
975 SOC_ENUM("RX3 HPF cut off", cf_rxmix3_enum),
976 SOC_ENUM("RX4 HPF cut off", cf_rxmix4_enum),
977 SOC_ENUM("RX5 HPF cut off", cf_rxmix5_enum),
978 SOC_ENUM("RX6 HPF cut off", cf_rxmix6_enum),
979 SOC_ENUM("RX7 HPF cut off", cf_rxmix7_enum),
980
981 SOC_SINGLE_EXT("IIR1 Enable Band1", IIR1, BAND1, 1, 0,
982 taiko_get_iir_enable_audio_mixer, taiko_put_iir_enable_audio_mixer),
983 SOC_SINGLE_EXT("IIR1 Enable Band2", IIR1, BAND2, 1, 0,
984 taiko_get_iir_enable_audio_mixer, taiko_put_iir_enable_audio_mixer),
985 SOC_SINGLE_EXT("IIR1 Enable Band3", IIR1, BAND3, 1, 0,
986 taiko_get_iir_enable_audio_mixer, taiko_put_iir_enable_audio_mixer),
987 SOC_SINGLE_EXT("IIR1 Enable Band4", IIR1, BAND4, 1, 0,
988 taiko_get_iir_enable_audio_mixer, taiko_put_iir_enable_audio_mixer),
989 SOC_SINGLE_EXT("IIR1 Enable Band5", IIR1, BAND5, 1, 0,
990 taiko_get_iir_enable_audio_mixer, taiko_put_iir_enable_audio_mixer),
991 SOC_SINGLE_EXT("IIR2 Enable Band1", IIR2, BAND1, 1, 0,
992 taiko_get_iir_enable_audio_mixer, taiko_put_iir_enable_audio_mixer),
993 SOC_SINGLE_EXT("IIR2 Enable Band2", IIR2, BAND2, 1, 0,
994 taiko_get_iir_enable_audio_mixer, taiko_put_iir_enable_audio_mixer),
995 SOC_SINGLE_EXT("IIR2 Enable Band3", IIR2, BAND3, 1, 0,
996 taiko_get_iir_enable_audio_mixer, taiko_put_iir_enable_audio_mixer),
997 SOC_SINGLE_EXT("IIR2 Enable Band4", IIR2, BAND4, 1, 0,
998 taiko_get_iir_enable_audio_mixer, taiko_put_iir_enable_audio_mixer),
999 SOC_SINGLE_EXT("IIR2 Enable Band5", IIR2, BAND5, 1, 0,
1000 taiko_get_iir_enable_audio_mixer, taiko_put_iir_enable_audio_mixer),
1001
1002 SOC_SINGLE_MULTI_EXT("IIR1 Band1", IIR1, BAND1, 255, 0, 5,
1003 taiko_get_iir_band_audio_mixer, taiko_put_iir_band_audio_mixer),
1004 SOC_SINGLE_MULTI_EXT("IIR1 Band2", IIR1, BAND2, 255, 0, 5,
1005 taiko_get_iir_band_audio_mixer, taiko_put_iir_band_audio_mixer),
1006 SOC_SINGLE_MULTI_EXT("IIR1 Band3", IIR1, BAND3, 255, 0, 5,
1007 taiko_get_iir_band_audio_mixer, taiko_put_iir_band_audio_mixer),
1008 SOC_SINGLE_MULTI_EXT("IIR1 Band4", IIR1, BAND4, 255, 0, 5,
1009 taiko_get_iir_band_audio_mixer, taiko_put_iir_band_audio_mixer),
1010 SOC_SINGLE_MULTI_EXT("IIR1 Band5", IIR1, BAND5, 255, 0, 5,
1011 taiko_get_iir_band_audio_mixer, taiko_put_iir_band_audio_mixer),
1012 SOC_SINGLE_MULTI_EXT("IIR2 Band1", IIR2, BAND1, 255, 0, 5,
1013 taiko_get_iir_band_audio_mixer, taiko_put_iir_band_audio_mixer),
1014 SOC_SINGLE_MULTI_EXT("IIR2 Band2", IIR2, BAND2, 255, 0, 5,
1015 taiko_get_iir_band_audio_mixer, taiko_put_iir_band_audio_mixer),
1016 SOC_SINGLE_MULTI_EXT("IIR2 Band3", IIR2, BAND3, 255, 0, 5,
1017 taiko_get_iir_band_audio_mixer, taiko_put_iir_band_audio_mixer),
1018 SOC_SINGLE_MULTI_EXT("IIR2 Band4", IIR2, BAND4, 255, 0, 5,
1019 taiko_get_iir_band_audio_mixer, taiko_put_iir_band_audio_mixer),
1020 SOC_SINGLE_MULTI_EXT("IIR2 Band5", IIR2, BAND5, 255, 0, 5,
1021 taiko_get_iir_band_audio_mixer, taiko_put_iir_band_audio_mixer),
1022
Joonwoo Parkc7731432012-10-17 12:41:44 -07001023 SOC_SINGLE_EXT("COMP0 Switch", SND_SOC_NOPM, COMPANDER_0, 1, 0,
1024 taiko_get_compander, taiko_set_compander),
1025 SOC_SINGLE_EXT("COMP1 Switch", SND_SOC_NOPM, COMPANDER_1, 1, 0,
1026 taiko_get_compander, taiko_set_compander),
1027 SOC_SINGLE_EXT("COMP2 Switch", SND_SOC_NOPM, COMPANDER_2, 1, 0,
1028 taiko_get_compander, taiko_set_compander),
Kiran Kandic3b24402012-06-11 00:05:59 -07001029
1030};
1031
1032static const char * const rx_mix1_text[] = {
1033 "ZERO", "SRC1", "SRC2", "IIR1", "IIR2", "RX1", "RX2", "RX3", "RX4",
1034 "RX5", "RX6", "RX7"
1035};
1036
1037static const char * const rx_mix2_text[] = {
1038 "ZERO", "SRC1", "SRC2", "IIR1", "IIR2"
1039};
1040
Tanya Finkeldaaa6d12012-10-25 11:22:48 +02001041static const char * const rx_rdac5_text[] = {
1042 "DEM4", "DEM3_INV"
Kiran Kandic3b24402012-06-11 00:05:59 -07001043};
1044
Tanya Finkeldaaa6d12012-10-25 11:22:48 +02001045static const char * const rx_rdac7_text[] = {
1046 "DEM6", "DEM5_INV"
1047};
1048
1049
Kiran Kandic3b24402012-06-11 00:05:59 -07001050static const char * const sb_tx1_mux_text[] = {
1051 "ZERO", "RMIX1", "RMIX2", "RMIX3", "RMIX4", "RMIX5", "RMIX6", "RMIX7",
1052 "DEC1"
1053};
1054
1055static const char * const sb_tx2_mux_text[] = {
1056 "ZERO", "RMIX1", "RMIX2", "RMIX3", "RMIX4", "RMIX5", "RMIX6", "RMIX7",
1057 "DEC2"
1058};
1059
1060static const char * const sb_tx3_mux_text[] = {
1061 "ZERO", "RMIX1", "RMIX2", "RMIX3", "RMIX4", "RMIX5", "RMIX6", "RMIX7",
1062 "DEC3"
1063};
1064
1065static const char * const sb_tx4_mux_text[] = {
1066 "ZERO", "RMIX1", "RMIX2", "RMIX3", "RMIX4", "RMIX5", "RMIX6", "RMIX7",
1067 "DEC4"
1068};
1069
1070static const char * const sb_tx5_mux_text[] = {
1071 "ZERO", "RMIX1", "RMIX2", "RMIX3", "RMIX4", "RMIX5", "RMIX6", "RMIX7",
1072 "DEC5"
1073};
1074
1075static const char * const sb_tx6_mux_text[] = {
1076 "ZERO", "RMIX1", "RMIX2", "RMIX3", "RMIX4", "RMIX5", "RMIX6", "RMIX7",
1077 "DEC6"
1078};
1079
1080static const char * const sb_tx7_to_tx10_mux_text[] = {
1081 "ZERO", "RMIX1", "RMIX2", "RMIX3", "RMIX4", "RMIX5", "RMIX6", "RMIX7",
1082 "DEC1", "DEC2", "DEC3", "DEC4", "DEC5", "DEC6", "DEC7", "DEC8",
1083 "DEC9", "DEC10"
1084};
1085
1086static const char * const dec1_mux_text[] = {
1087 "ZERO", "DMIC1", "ADC6",
1088};
1089
1090static const char * const dec2_mux_text[] = {
1091 "ZERO", "DMIC2", "ADC5",
1092};
1093
1094static const char * const dec3_mux_text[] = {
1095 "ZERO", "DMIC3", "ADC4",
1096};
1097
1098static const char * const dec4_mux_text[] = {
1099 "ZERO", "DMIC4", "ADC3",
1100};
1101
1102static const char * const dec5_mux_text[] = {
1103 "ZERO", "DMIC5", "ADC2",
1104};
1105
1106static const char * const dec6_mux_text[] = {
1107 "ZERO", "DMIC6", "ADC1",
1108};
1109
1110static const char * const dec7_mux_text[] = {
1111 "ZERO", "DMIC1", "DMIC6", "ADC1", "ADC6", "ANC1_FB", "ANC2_FB",
1112};
1113
1114static const char * const dec8_mux_text[] = {
1115 "ZERO", "DMIC2", "DMIC5", "ADC2", "ADC5",
1116};
1117
1118static const char * const dec9_mux_text[] = {
1119 "ZERO", "DMIC4", "DMIC5", "ADC2", "ADC3", "ADCMB", "ANC1_FB", "ANC2_FB",
1120};
1121
1122static const char * const dec10_mux_text[] = {
1123 "ZERO", "DMIC3", "DMIC6", "ADC1", "ADC4", "ADCMB", "ANC1_FB", "ANC2_FB",
1124};
1125
1126static const char * const anc_mux_text[] = {
1127 "ZERO", "ADC1", "ADC2", "ADC3", "ADC4", "ADC5", "ADC6", "ADC_MB",
1128 "RSVD_1", "DMIC1", "DMIC2", "DMIC3", "DMIC4", "DMIC5", "DMIC6"
1129};
1130
1131static const char * const anc1_fb_mux_text[] = {
1132 "ZERO", "EAR_HPH_L", "EAR_LINE_1",
1133};
1134
1135static const char * const iir1_inp1_text[] = {
1136 "ZERO", "DEC1", "DEC2", "DEC3", "DEC4", "DEC5", "DEC6", "DEC7", "DEC8",
1137 "DEC9", "DEC10", "RX1", "RX2", "RX3", "RX4", "RX5", "RX6", "RX7"
1138};
1139
1140static const struct soc_enum rx_mix1_inp1_chain_enum =
1141 SOC_ENUM_SINGLE(TAIKO_A_CDC_CONN_RX1_B1_CTL, 0, 12, rx_mix1_text);
1142
1143static const struct soc_enum rx_mix1_inp2_chain_enum =
1144 SOC_ENUM_SINGLE(TAIKO_A_CDC_CONN_RX1_B1_CTL, 4, 12, rx_mix1_text);
1145
1146static const struct soc_enum rx_mix1_inp3_chain_enum =
1147 SOC_ENUM_SINGLE(TAIKO_A_CDC_CONN_RX1_B2_CTL, 0, 12, rx_mix1_text);
1148
1149static const struct soc_enum rx2_mix1_inp1_chain_enum =
1150 SOC_ENUM_SINGLE(TAIKO_A_CDC_CONN_RX2_B1_CTL, 0, 12, rx_mix1_text);
1151
1152static const struct soc_enum rx2_mix1_inp2_chain_enum =
1153 SOC_ENUM_SINGLE(TAIKO_A_CDC_CONN_RX2_B1_CTL, 4, 12, rx_mix1_text);
1154
1155static const struct soc_enum rx3_mix1_inp1_chain_enum =
1156 SOC_ENUM_SINGLE(TAIKO_A_CDC_CONN_RX3_B1_CTL, 0, 12, rx_mix1_text);
1157
1158static const struct soc_enum rx3_mix1_inp2_chain_enum =
1159 SOC_ENUM_SINGLE(TAIKO_A_CDC_CONN_RX3_B1_CTL, 4, 12, rx_mix1_text);
1160
1161static const struct soc_enum rx4_mix1_inp1_chain_enum =
1162 SOC_ENUM_SINGLE(TAIKO_A_CDC_CONN_RX4_B1_CTL, 0, 12, rx_mix1_text);
1163
1164static const struct soc_enum rx4_mix1_inp2_chain_enum =
1165 SOC_ENUM_SINGLE(TAIKO_A_CDC_CONN_RX4_B1_CTL, 4, 12, rx_mix1_text);
1166
1167static const struct soc_enum rx5_mix1_inp1_chain_enum =
1168 SOC_ENUM_SINGLE(TAIKO_A_CDC_CONN_RX5_B1_CTL, 0, 12, rx_mix1_text);
1169
1170static const struct soc_enum rx5_mix1_inp2_chain_enum =
1171 SOC_ENUM_SINGLE(TAIKO_A_CDC_CONN_RX5_B1_CTL, 4, 12, rx_mix1_text);
1172
1173static const struct soc_enum rx6_mix1_inp1_chain_enum =
1174 SOC_ENUM_SINGLE(TAIKO_A_CDC_CONN_RX6_B1_CTL, 0, 12, rx_mix1_text);
1175
1176static const struct soc_enum rx6_mix1_inp2_chain_enum =
1177 SOC_ENUM_SINGLE(TAIKO_A_CDC_CONN_RX6_B1_CTL, 4, 12, rx_mix1_text);
1178
1179static const struct soc_enum rx7_mix1_inp1_chain_enum =
1180 SOC_ENUM_SINGLE(TAIKO_A_CDC_CONN_RX7_B1_CTL, 0, 12, rx_mix1_text);
1181
1182static const struct soc_enum rx7_mix1_inp2_chain_enum =
1183 SOC_ENUM_SINGLE(TAIKO_A_CDC_CONN_RX7_B1_CTL, 4, 12, rx_mix1_text);
1184
1185static const struct soc_enum rx1_mix2_inp1_chain_enum =
1186 SOC_ENUM_SINGLE(TAIKO_A_CDC_CONN_RX1_B3_CTL, 0, 5, rx_mix2_text);
1187
1188static const struct soc_enum rx1_mix2_inp2_chain_enum =
1189 SOC_ENUM_SINGLE(TAIKO_A_CDC_CONN_RX1_B3_CTL, 3, 5, rx_mix2_text);
1190
1191static const struct soc_enum rx2_mix2_inp1_chain_enum =
1192 SOC_ENUM_SINGLE(TAIKO_A_CDC_CONN_RX2_B3_CTL, 0, 5, rx_mix2_text);
1193
1194static const struct soc_enum rx2_mix2_inp2_chain_enum =
1195 SOC_ENUM_SINGLE(TAIKO_A_CDC_CONN_RX2_B3_CTL, 3, 5, rx_mix2_text);
1196
1197static const struct soc_enum rx7_mix2_inp1_chain_enum =
1198 SOC_ENUM_SINGLE(TAIKO_A_CDC_CONN_RX7_B3_CTL, 0, 5, rx_mix2_text);
1199
1200static const struct soc_enum rx7_mix2_inp2_chain_enum =
1201 SOC_ENUM_SINGLE(TAIKO_A_CDC_CONN_RX7_B3_CTL, 3, 5, rx_mix2_text);
1202
Tanya Finkeldaaa6d12012-10-25 11:22:48 +02001203static const struct soc_enum rx_rdac5_enum =
1204 SOC_ENUM_SINGLE(TAIKO_A_CDC_CONN_MISC, 2, 2, rx_rdac5_text);
Kiran Kandic3b24402012-06-11 00:05:59 -07001205
Tanya Finkeldaaa6d12012-10-25 11:22:48 +02001206static const struct soc_enum rx_rdac7_enum =
1207 SOC_ENUM_SINGLE(TAIKO_A_CDC_CONN_MISC, 1, 2, rx_rdac7_text);
Kiran Kandic3b24402012-06-11 00:05:59 -07001208
1209static const struct soc_enum sb_tx1_mux_enum =
1210 SOC_ENUM_SINGLE(TAIKO_A_CDC_CONN_TX_SB_B1_CTL, 0, 9, sb_tx1_mux_text);
1211
1212static const struct soc_enum sb_tx2_mux_enum =
1213 SOC_ENUM_SINGLE(TAIKO_A_CDC_CONN_TX_SB_B2_CTL, 0, 9, sb_tx2_mux_text);
1214
1215static const struct soc_enum sb_tx3_mux_enum =
1216 SOC_ENUM_SINGLE(TAIKO_A_CDC_CONN_TX_SB_B3_CTL, 0, 9, sb_tx3_mux_text);
1217
1218static const struct soc_enum sb_tx4_mux_enum =
1219 SOC_ENUM_SINGLE(TAIKO_A_CDC_CONN_TX_SB_B4_CTL, 0, 9, sb_tx4_mux_text);
1220
1221static const struct soc_enum sb_tx5_mux_enum =
1222 SOC_ENUM_SINGLE(TAIKO_A_CDC_CONN_TX_SB_B5_CTL, 0, 9, sb_tx5_mux_text);
1223
1224static const struct soc_enum sb_tx6_mux_enum =
1225 SOC_ENUM_SINGLE(TAIKO_A_CDC_CONN_TX_SB_B6_CTL, 0, 9, sb_tx6_mux_text);
1226
1227static const struct soc_enum sb_tx7_mux_enum =
1228 SOC_ENUM_SINGLE(TAIKO_A_CDC_CONN_TX_SB_B7_CTL, 0, 18,
1229 sb_tx7_to_tx10_mux_text);
1230
1231static const struct soc_enum sb_tx8_mux_enum =
1232 SOC_ENUM_SINGLE(TAIKO_A_CDC_CONN_TX_SB_B8_CTL, 0, 18,
1233 sb_tx7_to_tx10_mux_text);
1234
1235static const struct soc_enum sb_tx9_mux_enum =
1236 SOC_ENUM_SINGLE(TAIKO_A_CDC_CONN_TX_SB_B9_CTL, 0, 18,
1237 sb_tx7_to_tx10_mux_text);
1238
1239static const struct soc_enum sb_tx10_mux_enum =
1240 SOC_ENUM_SINGLE(TAIKO_A_CDC_CONN_TX_SB_B10_CTL, 0, 18,
1241 sb_tx7_to_tx10_mux_text);
1242
1243static const struct soc_enum dec1_mux_enum =
1244 SOC_ENUM_SINGLE(TAIKO_A_CDC_CONN_TX_B1_CTL, 0, 3, dec1_mux_text);
1245
1246static const struct soc_enum dec2_mux_enum =
1247 SOC_ENUM_SINGLE(TAIKO_A_CDC_CONN_TX_B1_CTL, 2, 3, dec2_mux_text);
1248
1249static const struct soc_enum dec3_mux_enum =
1250 SOC_ENUM_SINGLE(TAIKO_A_CDC_CONN_TX_B1_CTL, 4, 3, dec3_mux_text);
1251
1252static const struct soc_enum dec4_mux_enum =
1253 SOC_ENUM_SINGLE(TAIKO_A_CDC_CONN_TX_B1_CTL, 6, 3, dec4_mux_text);
1254
1255static const struct soc_enum dec5_mux_enum =
1256 SOC_ENUM_SINGLE(TAIKO_A_CDC_CONN_TX_B2_CTL, 0, 3, dec5_mux_text);
1257
1258static const struct soc_enum dec6_mux_enum =
1259 SOC_ENUM_SINGLE(TAIKO_A_CDC_CONN_TX_B2_CTL, 2, 3, dec6_mux_text);
1260
1261static const struct soc_enum dec7_mux_enum =
1262 SOC_ENUM_SINGLE(TAIKO_A_CDC_CONN_TX_B2_CTL, 4, 7, dec7_mux_text);
1263
1264static const struct soc_enum dec8_mux_enum =
1265 SOC_ENUM_SINGLE(TAIKO_A_CDC_CONN_TX_B3_CTL, 0, 7, dec8_mux_text);
1266
1267static const struct soc_enum dec9_mux_enum =
1268 SOC_ENUM_SINGLE(TAIKO_A_CDC_CONN_TX_B3_CTL, 3, 8, dec9_mux_text);
1269
1270static const struct soc_enum dec10_mux_enum =
1271 SOC_ENUM_SINGLE(TAIKO_A_CDC_CONN_TX_B4_CTL, 0, 8, dec10_mux_text);
1272
1273static const struct soc_enum anc1_mux_enum =
1274 SOC_ENUM_SINGLE(TAIKO_A_CDC_CONN_ANC_B1_CTL, 0, 16, anc_mux_text);
1275
1276static const struct soc_enum anc2_mux_enum =
1277 SOC_ENUM_SINGLE(TAIKO_A_CDC_CONN_ANC_B1_CTL, 4, 16, anc_mux_text);
1278
1279static const struct soc_enum anc1_fb_mux_enum =
1280 SOC_ENUM_SINGLE(TAIKO_A_CDC_CONN_ANC_B2_CTL, 0, 3, anc1_fb_mux_text);
1281
1282static const struct soc_enum iir1_inp1_mux_enum =
1283 SOC_ENUM_SINGLE(TAIKO_A_CDC_CONN_EQ1_B1_CTL, 0, 18, iir1_inp1_text);
1284
1285static const struct snd_kcontrol_new rx_mix1_inp1_mux =
1286 SOC_DAPM_ENUM("RX1 MIX1 INP1 Mux", rx_mix1_inp1_chain_enum);
1287
1288static const struct snd_kcontrol_new rx_mix1_inp2_mux =
1289 SOC_DAPM_ENUM("RX1 MIX1 INP2 Mux", rx_mix1_inp2_chain_enum);
1290
1291static const struct snd_kcontrol_new rx_mix1_inp3_mux =
1292 SOC_DAPM_ENUM("RX1 MIX1 INP3 Mux", rx_mix1_inp3_chain_enum);
1293
1294static const struct snd_kcontrol_new rx2_mix1_inp1_mux =
1295 SOC_DAPM_ENUM("RX2 MIX1 INP1 Mux", rx2_mix1_inp1_chain_enum);
1296
1297static const struct snd_kcontrol_new rx2_mix1_inp2_mux =
1298 SOC_DAPM_ENUM("RX2 MIX1 INP2 Mux", rx2_mix1_inp2_chain_enum);
1299
1300static const struct snd_kcontrol_new rx3_mix1_inp1_mux =
1301 SOC_DAPM_ENUM("RX3 MIX1 INP1 Mux", rx3_mix1_inp1_chain_enum);
1302
1303static const struct snd_kcontrol_new rx3_mix1_inp2_mux =
1304 SOC_DAPM_ENUM("RX3 MIX1 INP2 Mux", rx3_mix1_inp2_chain_enum);
1305
1306static const struct snd_kcontrol_new rx4_mix1_inp1_mux =
1307 SOC_DAPM_ENUM("RX4 MIX1 INP1 Mux", rx4_mix1_inp1_chain_enum);
1308
1309static const struct snd_kcontrol_new rx4_mix1_inp2_mux =
1310 SOC_DAPM_ENUM("RX4 MIX1 INP2 Mux", rx4_mix1_inp2_chain_enum);
1311
1312static const struct snd_kcontrol_new rx5_mix1_inp1_mux =
1313 SOC_DAPM_ENUM("RX5 MIX1 INP1 Mux", rx5_mix1_inp1_chain_enum);
1314
1315static const struct snd_kcontrol_new rx5_mix1_inp2_mux =
1316 SOC_DAPM_ENUM("RX5 MIX1 INP2 Mux", rx5_mix1_inp2_chain_enum);
1317
1318static const struct snd_kcontrol_new rx6_mix1_inp1_mux =
1319 SOC_DAPM_ENUM("RX6 MIX1 INP1 Mux", rx6_mix1_inp1_chain_enum);
1320
1321static const struct snd_kcontrol_new rx6_mix1_inp2_mux =
1322 SOC_DAPM_ENUM("RX6 MIX1 INP2 Mux", rx6_mix1_inp2_chain_enum);
1323
1324static const struct snd_kcontrol_new rx7_mix1_inp1_mux =
1325 SOC_DAPM_ENUM("RX7 MIX1 INP1 Mux", rx7_mix1_inp1_chain_enum);
1326
1327static const struct snd_kcontrol_new rx7_mix1_inp2_mux =
1328 SOC_DAPM_ENUM("RX7 MIX1 INP2 Mux", rx7_mix1_inp2_chain_enum);
1329
1330static const struct snd_kcontrol_new rx1_mix2_inp1_mux =
1331 SOC_DAPM_ENUM("RX1 MIX2 INP1 Mux", rx1_mix2_inp1_chain_enum);
1332
1333static const struct snd_kcontrol_new rx1_mix2_inp2_mux =
1334 SOC_DAPM_ENUM("RX1 MIX2 INP2 Mux", rx1_mix2_inp2_chain_enum);
1335
1336static const struct snd_kcontrol_new rx2_mix2_inp1_mux =
1337 SOC_DAPM_ENUM("RX2 MIX2 INP1 Mux", rx2_mix2_inp1_chain_enum);
1338
1339static const struct snd_kcontrol_new rx2_mix2_inp2_mux =
1340 SOC_DAPM_ENUM("RX2 MIX2 INP2 Mux", rx2_mix2_inp2_chain_enum);
1341
1342static const struct snd_kcontrol_new rx7_mix2_inp1_mux =
1343 SOC_DAPM_ENUM("RX7 MIX2 INP1 Mux", rx7_mix2_inp1_chain_enum);
1344
1345static const struct snd_kcontrol_new rx7_mix2_inp2_mux =
1346 SOC_DAPM_ENUM("RX7 MIX2 INP2 Mux", rx7_mix2_inp2_chain_enum);
1347
Tanya Finkeldaaa6d12012-10-25 11:22:48 +02001348static const struct snd_kcontrol_new rx_dac5_mux =
1349 SOC_DAPM_ENUM("RDAC5 MUX Mux", rx_rdac5_enum);
Kiran Kandic3b24402012-06-11 00:05:59 -07001350
Tanya Finkeldaaa6d12012-10-25 11:22:48 +02001351static const struct snd_kcontrol_new rx_dac7_mux =
1352 SOC_DAPM_ENUM("RDAC7 MUX Mux", rx_rdac7_enum);
Kiran Kandic3b24402012-06-11 00:05:59 -07001353
1354static const struct snd_kcontrol_new sb_tx1_mux =
1355 SOC_DAPM_ENUM("SLIM TX1 MUX Mux", sb_tx1_mux_enum);
1356
1357static const struct snd_kcontrol_new sb_tx2_mux =
1358 SOC_DAPM_ENUM("SLIM TX2 MUX Mux", sb_tx2_mux_enum);
1359
1360static const struct snd_kcontrol_new sb_tx3_mux =
1361 SOC_DAPM_ENUM("SLIM TX3 MUX Mux", sb_tx3_mux_enum);
1362
1363static const struct snd_kcontrol_new sb_tx4_mux =
1364 SOC_DAPM_ENUM("SLIM TX4 MUX Mux", sb_tx4_mux_enum);
1365
1366static const struct snd_kcontrol_new sb_tx5_mux =
1367 SOC_DAPM_ENUM("SLIM TX5 MUX Mux", sb_tx5_mux_enum);
1368
1369static const struct snd_kcontrol_new sb_tx6_mux =
1370 SOC_DAPM_ENUM("SLIM TX6 MUX Mux", sb_tx6_mux_enum);
1371
1372static const struct snd_kcontrol_new sb_tx7_mux =
1373 SOC_DAPM_ENUM("SLIM TX7 MUX Mux", sb_tx7_mux_enum);
1374
1375static const struct snd_kcontrol_new sb_tx8_mux =
1376 SOC_DAPM_ENUM("SLIM TX8 MUX Mux", sb_tx8_mux_enum);
1377
1378static const struct snd_kcontrol_new sb_tx9_mux =
1379 SOC_DAPM_ENUM("SLIM TX9 MUX Mux", sb_tx9_mux_enum);
1380
1381static const struct snd_kcontrol_new sb_tx10_mux =
1382 SOC_DAPM_ENUM("SLIM TX10 MUX Mux", sb_tx10_mux_enum);
1383
1384
1385static int wcd9320_put_dec_enum(struct snd_kcontrol *kcontrol,
1386 struct snd_ctl_elem_value *ucontrol)
1387{
1388 struct snd_soc_dapm_widget_list *wlist = snd_kcontrol_chip(kcontrol);
1389 struct snd_soc_dapm_widget *w = wlist->widgets[0];
1390 struct snd_soc_codec *codec = w->codec;
1391 struct soc_enum *e = (struct soc_enum *)kcontrol->private_value;
1392 unsigned int dec_mux, decimator;
1393 char *dec_name = NULL;
1394 char *widget_name = NULL;
1395 char *temp;
1396 u16 tx_mux_ctl_reg;
1397 u8 adc_dmic_sel = 0x0;
1398 int ret = 0;
1399
1400 if (ucontrol->value.enumerated.item[0] > e->max - 1)
1401 return -EINVAL;
1402
1403 dec_mux = ucontrol->value.enumerated.item[0];
1404
1405 widget_name = kstrndup(w->name, 15, GFP_KERNEL);
1406 if (!widget_name)
1407 return -ENOMEM;
1408 temp = widget_name;
1409
1410 dec_name = strsep(&widget_name, " ");
1411 widget_name = temp;
1412 if (!dec_name) {
1413 pr_err("%s: Invalid decimator = %s\n", __func__, w->name);
1414 ret = -EINVAL;
1415 goto out;
1416 }
1417
1418 ret = kstrtouint(strpbrk(dec_name, "123456789"), 10, &decimator);
1419 if (ret < 0) {
1420 pr_err("%s: Invalid decimator = %s\n", __func__, dec_name);
1421 ret = -EINVAL;
1422 goto out;
1423 }
1424
1425 dev_dbg(w->dapm->dev, "%s(): widget = %s decimator = %u dec_mux = %u\n"
1426 , __func__, w->name, decimator, dec_mux);
1427
1428
1429 switch (decimator) {
1430 case 1:
1431 case 2:
1432 case 3:
1433 case 4:
1434 case 5:
1435 case 6:
1436 if (dec_mux == 1)
1437 adc_dmic_sel = 0x1;
1438 else
1439 adc_dmic_sel = 0x0;
1440 break;
1441 case 7:
1442 case 8:
1443 case 9:
1444 case 10:
1445 if ((dec_mux == 1) || (dec_mux == 2))
1446 adc_dmic_sel = 0x1;
1447 else
1448 adc_dmic_sel = 0x0;
1449 break;
1450 default:
1451 pr_err("%s: Invalid Decimator = %u\n", __func__, decimator);
1452 ret = -EINVAL;
1453 goto out;
1454 }
1455
1456 tx_mux_ctl_reg = TAIKO_A_CDC_TX1_MUX_CTL + 8 * (decimator - 1);
1457
1458 snd_soc_update_bits(codec, tx_mux_ctl_reg, 0x1, adc_dmic_sel);
1459
1460 ret = snd_soc_dapm_put_enum_double(kcontrol, ucontrol);
1461
1462out:
1463 kfree(widget_name);
1464 return ret;
1465}
1466
1467#define WCD9320_DEC_ENUM(xname, xenum) \
1468{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \
1469 .info = snd_soc_info_enum_double, \
1470 .get = snd_soc_dapm_get_enum_double, \
1471 .put = wcd9320_put_dec_enum, \
1472 .private_value = (unsigned long)&xenum }
1473
1474static const struct snd_kcontrol_new dec1_mux =
1475 WCD9320_DEC_ENUM("DEC1 MUX Mux", dec1_mux_enum);
1476
1477static const struct snd_kcontrol_new dec2_mux =
1478 WCD9320_DEC_ENUM("DEC2 MUX Mux", dec2_mux_enum);
1479
1480static const struct snd_kcontrol_new dec3_mux =
1481 WCD9320_DEC_ENUM("DEC3 MUX Mux", dec3_mux_enum);
1482
1483static const struct snd_kcontrol_new dec4_mux =
1484 WCD9320_DEC_ENUM("DEC4 MUX Mux", dec4_mux_enum);
1485
1486static const struct snd_kcontrol_new dec5_mux =
1487 WCD9320_DEC_ENUM("DEC5 MUX Mux", dec5_mux_enum);
1488
1489static const struct snd_kcontrol_new dec6_mux =
1490 WCD9320_DEC_ENUM("DEC6 MUX Mux", dec6_mux_enum);
1491
1492static const struct snd_kcontrol_new dec7_mux =
1493 WCD9320_DEC_ENUM("DEC7 MUX Mux", dec7_mux_enum);
1494
1495static const struct snd_kcontrol_new dec8_mux =
1496 WCD9320_DEC_ENUM("DEC8 MUX Mux", dec8_mux_enum);
1497
1498static const struct snd_kcontrol_new dec9_mux =
1499 WCD9320_DEC_ENUM("DEC9 MUX Mux", dec9_mux_enum);
1500
1501static const struct snd_kcontrol_new dec10_mux =
1502 WCD9320_DEC_ENUM("DEC10 MUX Mux", dec10_mux_enum);
1503
1504static const struct snd_kcontrol_new iir1_inp1_mux =
1505 SOC_DAPM_ENUM("IIR1 INP1 Mux", iir1_inp1_mux_enum);
1506
1507static const struct snd_kcontrol_new anc1_mux =
1508 SOC_DAPM_ENUM("ANC1 MUX Mux", anc1_mux_enum);
1509
1510static const struct snd_kcontrol_new anc2_mux =
1511 SOC_DAPM_ENUM("ANC2 MUX Mux", anc2_mux_enum);
1512
1513static const struct snd_kcontrol_new anc1_fb_mux =
1514 SOC_DAPM_ENUM("ANC1 FB MUX Mux", anc1_fb_mux_enum);
1515
1516static const struct snd_kcontrol_new dac1_switch[] = {
1517 SOC_DAPM_SINGLE("Switch", TAIKO_A_RX_EAR_EN, 5, 1, 0)
1518};
1519static const struct snd_kcontrol_new hphl_switch[] = {
1520 SOC_DAPM_SINGLE("Switch", TAIKO_A_RX_HPH_L_DAC_CTL, 6, 1, 0)
1521};
1522
1523static const struct snd_kcontrol_new hphl_pa_mix[] = {
1524 SOC_DAPM_SINGLE("AUX_PGA_L Switch", TAIKO_A_RX_PA_AUX_IN_CONN,
1525 7, 1, 0),
1526};
1527
1528static const struct snd_kcontrol_new hphr_pa_mix[] = {
1529 SOC_DAPM_SINGLE("AUX_PGA_R Switch", TAIKO_A_RX_PA_AUX_IN_CONN,
1530 6, 1, 0),
1531};
1532
1533static const struct snd_kcontrol_new ear_pa_mix[] = {
1534 SOC_DAPM_SINGLE("AUX_PGA_L Switch", TAIKO_A_RX_PA_AUX_IN_CONN,
1535 5, 1, 0),
1536};
1537static const struct snd_kcontrol_new lineout1_pa_mix[] = {
1538 SOC_DAPM_SINGLE("AUX_PGA_L Switch", TAIKO_A_RX_PA_AUX_IN_CONN,
1539 4, 1, 0),
1540};
1541
1542static const struct snd_kcontrol_new lineout2_pa_mix[] = {
1543 SOC_DAPM_SINGLE("AUX_PGA_R Switch", TAIKO_A_RX_PA_AUX_IN_CONN,
1544 3, 1, 0),
1545};
1546
1547static const struct snd_kcontrol_new lineout3_pa_mix[] = {
1548 SOC_DAPM_SINGLE("AUX_PGA_L Switch", TAIKO_A_RX_PA_AUX_IN_CONN,
1549 2, 1, 0),
1550};
1551
1552static const struct snd_kcontrol_new lineout4_pa_mix[] = {
1553 SOC_DAPM_SINGLE("AUX_PGA_R Switch", TAIKO_A_RX_PA_AUX_IN_CONN,
1554 1, 1, 0),
1555};
1556
1557static const struct snd_kcontrol_new lineout3_ground_switch =
1558 SOC_DAPM_SINGLE("Switch", TAIKO_A_RX_LINE_3_DAC_CTL, 6, 1, 0);
1559
1560static const struct snd_kcontrol_new lineout4_ground_switch =
1561 SOC_DAPM_SINGLE("Switch", TAIKO_A_RX_LINE_4_DAC_CTL, 6, 1, 0);
1562
Kuirong Wang906ac472012-07-09 12:54:44 -07001563/* virtual port entries */
1564static int slim_tx_mixer_get(struct snd_kcontrol *kcontrol,
1565 struct snd_ctl_elem_value *ucontrol)
1566{
1567 struct snd_soc_dapm_widget_list *wlist = snd_kcontrol_chip(kcontrol);
1568 struct snd_soc_dapm_widget *widget = wlist->widgets[0];
1569
1570 ucontrol->value.integer.value[0] = widget->value;
1571 return 0;
1572}
1573
1574static int slim_tx_mixer_put(struct snd_kcontrol *kcontrol,
1575 struct snd_ctl_elem_value *ucontrol)
1576{
1577 struct snd_soc_dapm_widget_list *wlist = snd_kcontrol_chip(kcontrol);
1578 struct snd_soc_dapm_widget *widget = wlist->widgets[0];
1579 struct snd_soc_codec *codec = widget->codec;
1580 struct taiko_priv *taiko_p = snd_soc_codec_get_drvdata(codec);
1581 struct wcd9xxx *core = dev_get_drvdata(codec->dev->parent);
1582 struct soc_multi_mixer_control *mixer =
1583 ((struct soc_multi_mixer_control *)kcontrol->private_value);
1584 u32 dai_id = widget->shift;
1585 u32 port_id = mixer->shift;
1586 u32 enable = ucontrol->value.integer.value[0];
Venkat Sudhir96dd28c2012-12-04 17:00:19 -08001587 u32 vtable = vport_check_table[dai_id];
Kuirong Wang906ac472012-07-09 12:54:44 -07001588
1589
1590 pr_debug("%s: wname %s cname %s value %u shift %d item %ld\n", __func__,
1591 widget->name, ucontrol->id.name, widget->value, widget->shift,
1592 ucontrol->value.integer.value[0]);
1593
1594 mutex_lock(&codec->mutex);
1595
1596 if (taiko_p->intf_type != WCD9XXX_INTERFACE_TYPE_SLIMBUS) {
1597 if (dai_id != AIF1_CAP) {
1598 dev_err(codec->dev, "%s: invalid AIF for I2C mode\n",
1599 __func__);
1600 mutex_unlock(&codec->mutex);
1601 return -EINVAL;
1602 }
1603 }
Venkat Sudhira41630a2012-10-27 00:57:31 -07001604 switch (dai_id) {
1605 case AIF1_CAP:
1606 case AIF2_CAP:
1607 case AIF3_CAP:
1608 /* only add to the list if value not set
1609 */
1610 if (enable && !(widget->value & 1 << port_id)) {
Venkat Sudhir96dd28c2012-12-04 17:00:19 -08001611
1612 if (taiko_p->intf_type ==
1613 WCD9XXX_INTERFACE_TYPE_SLIMBUS)
1614 vtable = vport_check_table[dai_id];
1615 if (taiko_p->intf_type ==
1616 WCD9XXX_INTERFACE_TYPE_I2C)
1617 vtable = vport_i2s_check_table[dai_id];
1618
Venkat Sudhira41630a2012-10-27 00:57:31 -07001619 if (wcd9xxx_tx_vport_validation(
Venkat Sudhir96dd28c2012-12-04 17:00:19 -08001620 vtable,
Kuirong Wangdcc392e2012-10-19 00:33:38 -07001621 port_id,
1622 taiko_p->dai)) {
Venkat Sudhira41630a2012-10-27 00:57:31 -07001623 pr_debug("%s: TX%u is used by other\n"
1624 "virtual port\n",
1625 __func__, port_id + 1);
1626 mutex_unlock(&codec->mutex);
1627 return -EINVAL;
1628 }
1629 widget->value |= 1 << port_id;
1630 list_add_tail(&core->tx_chs[port_id].list,
Kuirong Wang906ac472012-07-09 12:54:44 -07001631 &taiko_p->dai[dai_id].wcd9xxx_ch_list
Venkat Sudhira41630a2012-10-27 00:57:31 -07001632 );
1633 } else if (!enable && (widget->value & 1 << port_id)) {
1634 widget->value &= ~(1 << port_id);
1635 list_del_init(&core->tx_chs[port_id].list);
1636 } else {
1637 if (enable)
1638 pr_debug("%s: TX%u port is used by\n"
1639 "this virtual port\n",
1640 __func__, port_id + 1);
1641 else
1642 pr_debug("%s: TX%u port is not used by\n"
1643 "this virtual port\n",
1644 __func__, port_id + 1);
1645 /* avoid update power function */
1646 mutex_unlock(&codec->mutex);
1647 return 0;
1648 }
1649 break;
1650 default:
1651 pr_err("Unknown AIF %d\n", dai_id);
Kuirong Wang906ac472012-07-09 12:54:44 -07001652 mutex_unlock(&codec->mutex);
Venkat Sudhira41630a2012-10-27 00:57:31 -07001653 return -EINVAL;
Kuirong Wang906ac472012-07-09 12:54:44 -07001654 }
Kuirong Wang906ac472012-07-09 12:54:44 -07001655 pr_debug("%s: name %s sname %s updated value %u shift %d\n", __func__,
1656 widget->name, widget->sname, widget->value, widget->shift);
1657
1658 snd_soc_dapm_mixer_update_power(widget, kcontrol, enable);
1659
1660 mutex_unlock(&codec->mutex);
1661 return 0;
1662}
1663
1664static int slim_rx_mux_get(struct snd_kcontrol *kcontrol,
1665 struct snd_ctl_elem_value *ucontrol)
1666{
1667 struct snd_soc_dapm_widget_list *wlist = snd_kcontrol_chip(kcontrol);
1668 struct snd_soc_dapm_widget *widget = wlist->widgets[0];
1669
1670 ucontrol->value.enumerated.item[0] = widget->value;
1671 return 0;
1672}
1673
1674static const char *const slim_rx_mux_text[] = {
1675 "ZERO", "AIF1_PB", "AIF2_PB", "AIF3_PB"
1676};
1677
1678static int slim_rx_mux_put(struct snd_kcontrol *kcontrol,
1679 struct snd_ctl_elem_value *ucontrol)
1680{
1681 struct snd_soc_dapm_widget_list *wlist = snd_kcontrol_chip(kcontrol);
1682 struct snd_soc_dapm_widget *widget = wlist->widgets[0];
1683 struct snd_soc_codec *codec = widget->codec;
1684 struct taiko_priv *taiko_p = snd_soc_codec_get_drvdata(codec);
1685 struct wcd9xxx *core = dev_get_drvdata(codec->dev->parent);
1686 struct soc_enum *e = (struct soc_enum *)kcontrol->private_value;
1687 u32 port_id = widget->shift;
1688
1689 pr_debug("%s: wname %s cname %s value %u shift %d item %ld\n", __func__,
1690 widget->name, ucontrol->id.name, widget->value, widget->shift,
1691 ucontrol->value.integer.value[0]);
1692
1693 widget->value = ucontrol->value.enumerated.item[0];
1694
1695 mutex_lock(&codec->mutex);
1696
1697 if (taiko_p->intf_type != WCD9XXX_INTERFACE_TYPE_SLIMBUS) {
Venkat Sudhir994193b2012-12-17 17:30:51 -08001698 if (widget->value > 2) {
Kuirong Wang906ac472012-07-09 12:54:44 -07001699 dev_err(codec->dev, "%s: invalid AIF for I2C mode\n",
1700 __func__);
Kuirong Wangdcc392e2012-10-19 00:33:38 -07001701 goto err;
Kuirong Wang906ac472012-07-09 12:54:44 -07001702 }
1703 }
1704 /* value need to match the Virtual port and AIF number
1705 */
1706 switch (widget->value) {
1707 case 0:
1708 list_del_init(&core->rx_chs[port_id].list);
1709 break;
1710 case 1:
Kuirong Wangdcc392e2012-10-19 00:33:38 -07001711 if (wcd9xxx_rx_vport_validation(port_id + core->num_tx_port,
1712 &taiko_p->dai[AIF1_PB].wcd9xxx_ch_list))
1713 goto pr_err;
Kuirong Wang906ac472012-07-09 12:54:44 -07001714 list_add_tail(&core->rx_chs[port_id].list,
1715 &taiko_p->dai[AIF1_PB].wcd9xxx_ch_list);
1716 break;
1717 case 2:
Kuirong Wangdcc392e2012-10-19 00:33:38 -07001718 if (wcd9xxx_rx_vport_validation(port_id + core->num_tx_port,
Gopikrishnaiah Anandana8aec1f2013-01-23 14:26:27 -05001719 &taiko_p->dai[AIF2_PB].wcd9xxx_ch_list))
Kuirong Wangdcc392e2012-10-19 00:33:38 -07001720 goto pr_err;
Kuirong Wang906ac472012-07-09 12:54:44 -07001721 list_add_tail(&core->rx_chs[port_id].list,
1722 &taiko_p->dai[AIF2_PB].wcd9xxx_ch_list);
1723 break;
1724 case 3:
Kuirong Wangdcc392e2012-10-19 00:33:38 -07001725 if (wcd9xxx_rx_vport_validation(port_id + core->num_tx_port,
Gopikrishnaiah Anandana8aec1f2013-01-23 14:26:27 -05001726 &taiko_p->dai[AIF3_PB].wcd9xxx_ch_list))
Kuirong Wangdcc392e2012-10-19 00:33:38 -07001727 goto pr_err;
Kuirong Wang906ac472012-07-09 12:54:44 -07001728 list_add_tail(&core->rx_chs[port_id].list,
1729 &taiko_p->dai[AIF3_PB].wcd9xxx_ch_list);
1730 break;
1731 default:
1732 pr_err("Unknown AIF %d\n", widget->value);
Kuirong Wangdcc392e2012-10-19 00:33:38 -07001733 goto err;
Kuirong Wang906ac472012-07-09 12:54:44 -07001734 }
1735
1736 snd_soc_dapm_mux_update_power(widget, kcontrol, 1, widget->value, e);
1737
1738 mutex_unlock(&codec->mutex);
1739 return 0;
Kuirong Wangdcc392e2012-10-19 00:33:38 -07001740pr_err:
1741 pr_err("%s: RX%u is used by current requesting AIF_PB itself\n",
1742 __func__, port_id + 1);
1743err:
1744 mutex_unlock(&codec->mutex);
1745 return -EINVAL;
Kuirong Wang906ac472012-07-09 12:54:44 -07001746}
1747
1748static const struct soc_enum slim_rx_mux_enum =
1749 SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(slim_rx_mux_text), slim_rx_mux_text);
1750
1751static const struct snd_kcontrol_new slim_rx_mux[TAIKO_RX_MAX] = {
1752 SOC_DAPM_ENUM_EXT("SLIM RX1 Mux", slim_rx_mux_enum,
1753 slim_rx_mux_get, slim_rx_mux_put),
1754 SOC_DAPM_ENUM_EXT("SLIM RX2 Mux", slim_rx_mux_enum,
1755 slim_rx_mux_get, slim_rx_mux_put),
1756 SOC_DAPM_ENUM_EXT("SLIM RX3 Mux", slim_rx_mux_enum,
1757 slim_rx_mux_get, slim_rx_mux_put),
1758 SOC_DAPM_ENUM_EXT("SLIM RX4 Mux", slim_rx_mux_enum,
1759 slim_rx_mux_get, slim_rx_mux_put),
1760 SOC_DAPM_ENUM_EXT("SLIM RX5 Mux", slim_rx_mux_enum,
1761 slim_rx_mux_get, slim_rx_mux_put),
1762 SOC_DAPM_ENUM_EXT("SLIM RX6 Mux", slim_rx_mux_enum,
1763 slim_rx_mux_get, slim_rx_mux_put),
1764 SOC_DAPM_ENUM_EXT("SLIM RX7 Mux", slim_rx_mux_enum,
1765 slim_rx_mux_get, slim_rx_mux_put),
1766};
1767
1768static const struct snd_kcontrol_new aif_cap_mixer[] = {
1769 SOC_SINGLE_EXT("SLIM TX1", SND_SOC_NOPM, TAIKO_TX1, 1, 0,
1770 slim_tx_mixer_get, slim_tx_mixer_put),
1771 SOC_SINGLE_EXT("SLIM TX2", SND_SOC_NOPM, TAIKO_TX2, 1, 0,
1772 slim_tx_mixer_get, slim_tx_mixer_put),
1773 SOC_SINGLE_EXT("SLIM TX3", SND_SOC_NOPM, TAIKO_TX3, 1, 0,
1774 slim_tx_mixer_get, slim_tx_mixer_put),
1775 SOC_SINGLE_EXT("SLIM TX4", SND_SOC_NOPM, TAIKO_TX4, 1, 0,
1776 slim_tx_mixer_get, slim_tx_mixer_put),
1777 SOC_SINGLE_EXT("SLIM TX5", SND_SOC_NOPM, TAIKO_TX5, 1, 0,
1778 slim_tx_mixer_get, slim_tx_mixer_put),
1779 SOC_SINGLE_EXT("SLIM TX6", SND_SOC_NOPM, TAIKO_TX6, 1, 0,
1780 slim_tx_mixer_get, slim_tx_mixer_put),
1781 SOC_SINGLE_EXT("SLIM TX7", SND_SOC_NOPM, TAIKO_TX7, 1, 0,
1782 slim_tx_mixer_get, slim_tx_mixer_put),
1783 SOC_SINGLE_EXT("SLIM TX8", SND_SOC_NOPM, TAIKO_TX8, 1, 0,
1784 slim_tx_mixer_get, slim_tx_mixer_put),
1785 SOC_SINGLE_EXT("SLIM TX9", SND_SOC_NOPM, TAIKO_TX9, 1, 0,
1786 slim_tx_mixer_get, slim_tx_mixer_put),
1787 SOC_SINGLE_EXT("SLIM TX10", SND_SOC_NOPM, TAIKO_TX10, 1, 0,
1788 slim_tx_mixer_get, slim_tx_mixer_put),
1789};
1790
Kiran Kandic3b24402012-06-11 00:05:59 -07001791static void taiko_codec_enable_adc_block(struct snd_soc_codec *codec,
1792 int enable)
1793{
1794 struct taiko_priv *taiko = snd_soc_codec_get_drvdata(codec);
1795
1796 pr_debug("%s %d\n", __func__, enable);
1797
1798 if (enable) {
1799 taiko->adc_count++;
Bhalchandra Gajare87fef4c2013-02-19 14:57:03 -08001800 snd_soc_update_bits(codec, WCD9XXX_A_CDC_CLK_OTHR_CTL,
1801 0x2, 0x2);
Kiran Kandic3b24402012-06-11 00:05:59 -07001802 } else {
1803 taiko->adc_count--;
1804 if (!taiko->adc_count)
Bhalchandra Gajare87fef4c2013-02-19 14:57:03 -08001805 snd_soc_update_bits(codec, WCD9XXX_A_CDC_CLK_OTHR_CTL,
Kiran Kandic3b24402012-06-11 00:05:59 -07001806 0x2, 0x0);
1807 }
1808}
1809
1810static int taiko_codec_enable_adc(struct snd_soc_dapm_widget *w,
1811 struct snd_kcontrol *kcontrol, int event)
1812{
1813 struct snd_soc_codec *codec = w->codec;
1814 u16 adc_reg;
1815 u8 init_bit_shift;
1816
1817 pr_debug("%s %d\n", __func__, event);
1818
1819 if (w->reg == TAIKO_A_TX_1_2_EN)
1820 adc_reg = TAIKO_A_TX_1_2_TEST_CTL;
1821 else if (w->reg == TAIKO_A_TX_3_4_EN)
1822 adc_reg = TAIKO_A_TX_3_4_TEST_CTL;
1823 else if (w->reg == TAIKO_A_TX_5_6_EN)
1824 adc_reg = TAIKO_A_TX_5_6_TEST_CTL;
1825 else {
1826 pr_err("%s: Error, invalid adc register\n", __func__);
1827 return -EINVAL;
1828 }
1829
1830 if (w->shift == 3)
1831 init_bit_shift = 6;
1832 else if (w->shift == 7)
1833 init_bit_shift = 7;
1834 else {
1835 pr_err("%s: Error, invalid init bit postion adc register\n",
1836 __func__);
1837 return -EINVAL;
1838 }
1839
1840 switch (event) {
1841 case SND_SOC_DAPM_PRE_PMU:
1842 taiko_codec_enable_adc_block(codec, 1);
1843 snd_soc_update_bits(codec, adc_reg, 1 << init_bit_shift,
1844 1 << init_bit_shift);
1845 break;
1846 case SND_SOC_DAPM_POST_PMU:
1847
1848 snd_soc_update_bits(codec, adc_reg, 1 << init_bit_shift, 0x00);
1849
1850 break;
1851 case SND_SOC_DAPM_POST_PMD:
1852 taiko_codec_enable_adc_block(codec, 0);
1853 break;
1854 }
1855 return 0;
1856}
1857
Kiran Kandic3b24402012-06-11 00:05:59 -07001858static int taiko_codec_enable_aux_pga(struct snd_soc_dapm_widget *w,
1859 struct snd_kcontrol *kcontrol, int event)
1860{
1861 struct snd_soc_codec *codec = w->codec;
1862 struct taiko_priv *taiko = snd_soc_codec_get_drvdata(codec);
1863
1864 pr_debug("%s: %d\n", __func__, event);
1865
1866 switch (event) {
1867 case SND_SOC_DAPM_PRE_PMU:
Joonwoo Parka8890262012-10-15 12:04:27 -07001868 WCD9XXX_BCL_LOCK(&taiko->resmgr);
1869 wcd9xxx_resmgr_get_bandgap(&taiko->resmgr,
1870 WCD9XXX_BANDGAP_AUDIO_MODE);
1871 /* AUX PGA requires RCO or MCLK */
1872 wcd9xxx_resmgr_get_clk_block(&taiko->resmgr, WCD9XXX_CLK_RCO);
1873 wcd9xxx_resmgr_enable_rx_bias(&taiko->resmgr, 1);
1874 WCD9XXX_BCL_UNLOCK(&taiko->resmgr);
Kiran Kandic3b24402012-06-11 00:05:59 -07001875 break;
1876
1877 case SND_SOC_DAPM_POST_PMD:
Joonwoo Parka8890262012-10-15 12:04:27 -07001878 WCD9XXX_BCL_LOCK(&taiko->resmgr);
1879 wcd9xxx_resmgr_enable_rx_bias(&taiko->resmgr, 0);
1880 wcd9xxx_resmgr_put_bandgap(&taiko->resmgr,
1881 WCD9XXX_BANDGAP_AUDIO_MODE);
1882 wcd9xxx_resmgr_put_clk_block(&taiko->resmgr, WCD9XXX_CLK_RCO);
1883 WCD9XXX_BCL_UNLOCK(&taiko->resmgr);
Kiran Kandic3b24402012-06-11 00:05:59 -07001884 break;
1885 }
1886 return 0;
1887}
1888
1889static int taiko_codec_enable_lineout(struct snd_soc_dapm_widget *w,
1890 struct snd_kcontrol *kcontrol, int event)
1891{
1892 struct snd_soc_codec *codec = w->codec;
Bhalchandra Gajare87fef4c2013-02-19 14:57:03 -08001893 struct taiko_priv *taiko = snd_soc_codec_get_drvdata(codec);
Kiran Kandic3b24402012-06-11 00:05:59 -07001894 u16 lineout_gain_reg;
1895
1896 pr_debug("%s %d %s\n", __func__, event, w->name);
1897
1898 switch (w->shift) {
1899 case 0:
1900 lineout_gain_reg = TAIKO_A_RX_LINE_1_GAIN;
1901 break;
1902 case 1:
1903 lineout_gain_reg = TAIKO_A_RX_LINE_2_GAIN;
1904 break;
1905 case 2:
1906 lineout_gain_reg = TAIKO_A_RX_LINE_3_GAIN;
1907 break;
1908 case 3:
1909 lineout_gain_reg = TAIKO_A_RX_LINE_4_GAIN;
1910 break;
1911 default:
1912 pr_err("%s: Error, incorrect lineout register value\n",
1913 __func__);
1914 return -EINVAL;
1915 }
1916
1917 switch (event) {
1918 case SND_SOC_DAPM_PRE_PMU:
1919 snd_soc_update_bits(codec, lineout_gain_reg, 0x40, 0x40);
1920 break;
1921 case SND_SOC_DAPM_POST_PMU:
Bhalchandra Gajare87fef4c2013-02-19 14:57:03 -08001922 wcd9xxx_clsh_fsm(codec, &taiko->clsh_d,
1923 WCD9XXX_CLSH_STATE_LO,
1924 WCD9XXX_CLSH_REQ_ENABLE,
1925 WCD9XXX_CLSH_EVENT_POST_PA);
1926 pr_debug("%s: sleeping 3 ms after %s PA turn on\n",
Kiran Kandic3b24402012-06-11 00:05:59 -07001927 __func__, w->name);
Bhalchandra Gajare87fef4c2013-02-19 14:57:03 -08001928 usleep_range(3000, 3000);
Kiran Kandic3b24402012-06-11 00:05:59 -07001929 break;
1930 case SND_SOC_DAPM_POST_PMD:
Bhalchandra Gajare87fef4c2013-02-19 14:57:03 -08001931 wcd9xxx_clsh_fsm(codec, &taiko->clsh_d,
1932 WCD9XXX_CLSH_STATE_LO,
1933 WCD9XXX_CLSH_REQ_DISABLE,
1934 WCD9XXX_CLSH_EVENT_POST_PA);
Kiran Kandic3b24402012-06-11 00:05:59 -07001935 snd_soc_update_bits(codec, lineout_gain_reg, 0x40, 0x00);
1936 break;
1937 }
1938 return 0;
1939}
1940
Joonwoo Park7680b9f2012-07-13 11:36:48 -07001941static int taiko_codec_enable_spk_pa(struct snd_soc_dapm_widget *w,
1942 struct snd_kcontrol *kcontrol, int event)
1943{
Joonwoo Park125cd4e2012-12-11 15:16:11 -08001944 struct snd_soc_codec *codec = w->codec;
1945 struct taiko_priv *taiko = snd_soc_codec_get_drvdata(codec);
1946
1947 pr_debug("%s: %d %s\n", __func__, event, w->name);
1948 WCD9XXX_BCL_LOCK(&taiko->resmgr);
1949 switch (event) {
1950 case SND_SOC_DAPM_PRE_PMU:
1951 taiko->spkr_pa_widget_on = true;
1952 snd_soc_update_bits(codec, TAIKO_A_SPKR_DRV_EN, 0x80, 0x80);
1953 break;
1954 case SND_SOC_DAPM_POST_PMD:
1955 taiko->spkr_pa_widget_on = false;
1956 snd_soc_update_bits(codec, TAIKO_A_SPKR_DRV_EN, 0x80, 0x00);
1957 break;
1958 }
1959 WCD9XXX_BCL_UNLOCK(&taiko->resmgr);
Joonwoo Park7680b9f2012-07-13 11:36:48 -07001960 return 0;
1961}
Kiran Kandic3b24402012-06-11 00:05:59 -07001962
1963static int taiko_codec_enable_dmic(struct snd_soc_dapm_widget *w,
1964 struct snd_kcontrol *kcontrol, int event)
1965{
1966 struct snd_soc_codec *codec = w->codec;
1967 struct taiko_priv *taiko = snd_soc_codec_get_drvdata(codec);
1968 u8 dmic_clk_en;
1969 u16 dmic_clk_reg;
1970 s32 *dmic_clk_cnt;
1971 unsigned int dmic;
1972 int ret;
1973
1974 ret = kstrtouint(strpbrk(w->name, "123456"), 10, &dmic);
1975 if (ret < 0) {
1976 pr_err("%s: Invalid DMIC line on the codec\n", __func__);
1977 return -EINVAL;
1978 }
1979
1980 switch (dmic) {
1981 case 1:
1982 case 2:
1983 dmic_clk_en = 0x01;
1984 dmic_clk_cnt = &(taiko->dmic_1_2_clk_cnt);
1985 dmic_clk_reg = TAIKO_A_CDC_CLK_DMIC_B1_CTL;
1986 pr_debug("%s() event %d DMIC%d dmic_1_2_clk_cnt %d\n",
1987 __func__, event, dmic, *dmic_clk_cnt);
1988
1989 break;
1990
1991 case 3:
1992 case 4:
1993 dmic_clk_en = 0x10;
1994 dmic_clk_cnt = &(taiko->dmic_3_4_clk_cnt);
1995 dmic_clk_reg = TAIKO_A_CDC_CLK_DMIC_B1_CTL;
1996
1997 pr_debug("%s() event %d DMIC%d dmic_3_4_clk_cnt %d\n",
1998 __func__, event, dmic, *dmic_clk_cnt);
1999 break;
2000
2001 case 5:
2002 case 6:
2003 dmic_clk_en = 0x01;
2004 dmic_clk_cnt = &(taiko->dmic_5_6_clk_cnt);
2005 dmic_clk_reg = TAIKO_A_CDC_CLK_DMIC_B2_CTL;
2006
2007 pr_debug("%s() event %d DMIC%d dmic_5_6_clk_cnt %d\n",
2008 __func__, event, dmic, *dmic_clk_cnt);
2009
2010 break;
2011
2012 default:
2013 pr_err("%s: Invalid DMIC Selection\n", __func__);
2014 return -EINVAL;
2015 }
2016
2017 switch (event) {
2018 case SND_SOC_DAPM_PRE_PMU:
2019
2020 (*dmic_clk_cnt)++;
2021 if (*dmic_clk_cnt == 1)
2022 snd_soc_update_bits(codec, dmic_clk_reg,
2023 dmic_clk_en, dmic_clk_en);
2024
2025 break;
2026 case SND_SOC_DAPM_POST_PMD:
2027
2028 (*dmic_clk_cnt)--;
2029 if (*dmic_clk_cnt == 0)
2030 snd_soc_update_bits(codec, dmic_clk_reg,
2031 dmic_clk_en, 0);
2032 break;
2033 }
2034 return 0;
2035}
2036
2037static int taiko_codec_enable_anc(struct snd_soc_dapm_widget *w,
2038 struct snd_kcontrol *kcontrol, int event)
2039{
2040 struct snd_soc_codec *codec = w->codec;
2041 const char *filename;
2042 const struct firmware *fw;
2043 int i;
2044 int ret;
2045 int num_anc_slots;
2046 struct anc_header *anc_head;
2047 struct taiko_priv *taiko = snd_soc_codec_get_drvdata(codec);
2048 u32 anc_writes_size = 0;
2049 int anc_size_remaining;
2050 u32 *anc_ptr;
2051 u16 reg;
Kiran Kandi1b2d1ef2012-10-23 15:29:00 -07002052 u8 mask, val;
Kiran Kandic3b24402012-06-11 00:05:59 -07002053
2054 pr_debug("%s %d\n", __func__, event);
2055 switch (event) {
2056 case SND_SOC_DAPM_PRE_PMU:
2057
2058 filename = "wcd9320/wcd9320_anc.bin";
2059
2060 ret = request_firmware(&fw, filename, codec->dev);
2061 if (ret != 0) {
2062 dev_err(codec->dev, "Failed to acquire ANC data: %d\n",
2063 ret);
2064 return -ENODEV;
2065 }
2066
2067 if (fw->size < sizeof(struct anc_header)) {
2068 dev_err(codec->dev, "Not enough data\n");
2069 release_firmware(fw);
2070 return -ENOMEM;
2071 }
2072
2073 /* First number is the number of register writes */
2074 anc_head = (struct anc_header *)(fw->data);
2075 anc_ptr = (u32 *)((u32)fw->data + sizeof(struct anc_header));
2076 anc_size_remaining = fw->size - sizeof(struct anc_header);
2077 num_anc_slots = anc_head->num_anc_slots;
2078
2079 if (taiko->anc_slot >= num_anc_slots) {
2080 dev_err(codec->dev, "Invalid ANC slot selected\n");
2081 release_firmware(fw);
2082 return -EINVAL;
2083 }
2084
2085 for (i = 0; i < num_anc_slots; i++) {
2086
2087 if (anc_size_remaining < TAIKO_PACKED_REG_SIZE) {
2088 dev_err(codec->dev, "Invalid register format\n");
2089 release_firmware(fw);
2090 return -EINVAL;
2091 }
2092 anc_writes_size = (u32)(*anc_ptr);
2093 anc_size_remaining -= sizeof(u32);
2094 anc_ptr += 1;
2095
2096 if (anc_writes_size * TAIKO_PACKED_REG_SIZE
2097 > anc_size_remaining) {
2098 dev_err(codec->dev, "Invalid register format\n");
2099 release_firmware(fw);
2100 return -ENOMEM;
2101 }
2102
2103 if (taiko->anc_slot == i)
2104 break;
2105
2106 anc_size_remaining -= (anc_writes_size *
2107 TAIKO_PACKED_REG_SIZE);
2108 anc_ptr += anc_writes_size;
2109 }
2110 if (i == num_anc_slots) {
2111 dev_err(codec->dev, "Selected ANC slot not present\n");
2112 release_firmware(fw);
2113 return -ENOMEM;
2114 }
2115
2116 for (i = 0; i < anc_writes_size; i++) {
2117 TAIKO_CODEC_UNPACK_ENTRY(anc_ptr[i], reg,
2118 mask, val);
Kiran Kandi1b2d1ef2012-10-23 15:29:00 -07002119 snd_soc_write(codec, reg, val);
Kiran Kandic3b24402012-06-11 00:05:59 -07002120 }
2121 release_firmware(fw);
2122
2123 break;
2124 case SND_SOC_DAPM_POST_PMD:
2125 snd_soc_write(codec, TAIKO_A_CDC_CLK_ANC_RESET_CTL, 0xFF);
2126 snd_soc_write(codec, TAIKO_A_CDC_CLK_ANC_CLK_EN_CTL, 0);
2127 break;
2128 }
2129 return 0;
2130}
2131
Kiran Kandic3b24402012-06-11 00:05:59 -07002132static int taiko_codec_enable_micbias(struct snd_soc_dapm_widget *w,
2133 struct snd_kcontrol *kcontrol, int event)
2134{
2135 struct snd_soc_codec *codec = w->codec;
2136 struct taiko_priv *taiko = snd_soc_codec_get_drvdata(codec);
Joonwoo Park3699ca32013-02-08 12:06:15 -08002137 u16 micb_int_reg = 0, micb_ctl_reg = 0;
Kiran Kandic3b24402012-06-11 00:05:59 -07002138 u8 cfilt_sel_val = 0;
2139 char *internal1_text = "Internal1";
2140 char *internal2_text = "Internal2";
2141 char *internal3_text = "Internal3";
Joonwoo Parka8890262012-10-15 12:04:27 -07002142 enum wcd9xxx_notify_event e_post_off, e_pre_on, e_post_on;
Kiran Kandic3b24402012-06-11 00:05:59 -07002143
Joonwoo Park3699ca32013-02-08 12:06:15 -08002144 pr_debug("%s: w->name %s event %d\n", __func__, w->name, event);
2145 if (strnstr(w->name, "MIC BIAS1", sizeof("MIC BIAS1"))) {
2146 micb_ctl_reg = TAIKO_A_MICB_1_CTL;
Kiran Kandic3b24402012-06-11 00:05:59 -07002147 micb_int_reg = TAIKO_A_MICB_1_INT_RBIAS;
Joonwoo Parka8890262012-10-15 12:04:27 -07002148 cfilt_sel_val = taiko->resmgr.pdata->micbias.bias1_cfilt_sel;
2149 e_pre_on = WCD9XXX_EVENT_PRE_MICBIAS_1_ON;
2150 e_post_on = WCD9XXX_EVENT_POST_MICBIAS_1_ON;
2151 e_post_off = WCD9XXX_EVENT_POST_MICBIAS_1_OFF;
Joonwoo Park3699ca32013-02-08 12:06:15 -08002152 } else if (strnstr(w->name, "MIC BIAS2", sizeof("MIC BIAS2"))) {
2153 micb_ctl_reg = TAIKO_A_MICB_2_CTL;
Kiran Kandic3b24402012-06-11 00:05:59 -07002154 micb_int_reg = TAIKO_A_MICB_2_INT_RBIAS;
Joonwoo Parka8890262012-10-15 12:04:27 -07002155 cfilt_sel_val = taiko->resmgr.pdata->micbias.bias2_cfilt_sel;
2156 e_pre_on = WCD9XXX_EVENT_PRE_MICBIAS_2_ON;
2157 e_post_on = WCD9XXX_EVENT_POST_MICBIAS_2_ON;
2158 e_post_off = WCD9XXX_EVENT_POST_MICBIAS_2_OFF;
Joonwoo Park3699ca32013-02-08 12:06:15 -08002159 } else if (strnstr(w->name, "MIC BIAS3", sizeof("MIC BIAS3"))) {
2160 micb_ctl_reg = TAIKO_A_MICB_2_CTL;
Kiran Kandic3b24402012-06-11 00:05:59 -07002161 micb_int_reg = TAIKO_A_MICB_3_INT_RBIAS;
Joonwoo Parka8890262012-10-15 12:04:27 -07002162 cfilt_sel_val = taiko->resmgr.pdata->micbias.bias3_cfilt_sel;
2163 e_pre_on = WCD9XXX_EVENT_PRE_MICBIAS_3_ON;
2164 e_post_on = WCD9XXX_EVENT_POST_MICBIAS_3_ON;
2165 e_post_off = WCD9XXX_EVENT_POST_MICBIAS_3_OFF;
Joonwoo Park3699ca32013-02-08 12:06:15 -08002166 } else if (strnstr(w->name, "MIC BIAS4", sizeof("MIC BIAS4"))) {
2167 micb_ctl_reg = TAIKO_A_MICB_2_CTL;
Joonwoo Parka8890262012-10-15 12:04:27 -07002168 micb_int_reg = taiko->resmgr.reg_addr->micb_4_int_rbias;
2169 cfilt_sel_val = taiko->resmgr.pdata->micbias.bias4_cfilt_sel;
2170 e_pre_on = WCD9XXX_EVENT_PRE_MICBIAS_4_ON;
2171 e_post_on = WCD9XXX_EVENT_POST_MICBIAS_4_ON;
2172 e_post_off = WCD9XXX_EVENT_POST_MICBIAS_4_OFF;
Joonwoo Park3699ca32013-02-08 12:06:15 -08002173 } else {
2174 pr_err("%s: Error, invalid micbias %s\n", __func__, w->name);
Kiran Kandic3b24402012-06-11 00:05:59 -07002175 return -EINVAL;
2176 }
2177
2178 switch (event) {
2179 case SND_SOC_DAPM_PRE_PMU:
Joonwoo Parka8890262012-10-15 12:04:27 -07002180 /* Let MBHC module know so micbias switch to be off */
2181 wcd9xxx_resmgr_notifier_call(&taiko->resmgr, e_pre_on);
Kiran Kandic3b24402012-06-11 00:05:59 -07002182
Joonwoo Parka8890262012-10-15 12:04:27 -07002183 /* Get cfilt */
2184 wcd9xxx_resmgr_cfilt_get(&taiko->resmgr, cfilt_sel_val);
Kiran Kandic3b24402012-06-11 00:05:59 -07002185
2186 if (strnstr(w->name, internal1_text, 30))
2187 snd_soc_update_bits(codec, micb_int_reg, 0xE0, 0xE0);
2188 else if (strnstr(w->name, internal2_text, 30))
2189 snd_soc_update_bits(codec, micb_int_reg, 0x1C, 0x1C);
2190 else if (strnstr(w->name, internal3_text, 30))
2191 snd_soc_update_bits(codec, micb_int_reg, 0x3, 0x3);
2192
Joonwoo Park3699ca32013-02-08 12:06:15 -08002193 if (micb_ctl_reg == TAIKO_A_MICB_2_CTL) {
2194 WCD9XXX_BCL_LOCK(&taiko->resmgr);
2195 wcd9xxx_resmgr_add_cond_update_bits(&taiko->resmgr,
2196 WCD9XXX_COND_HPH_MIC,
2197 micb_ctl_reg, w->shift,
2198 false);
2199 WCD9XXX_BCL_UNLOCK(&taiko->resmgr);
2200 } else
2201 snd_soc_update_bits(codec, micb_ctl_reg, 1 << w->shift,
2202 1 << w->shift);
Kiran Kandic3b24402012-06-11 00:05:59 -07002203 break;
2204 case SND_SOC_DAPM_POST_PMU:
Kiran Kandic3b24402012-06-11 00:05:59 -07002205 usleep_range(20000, 20000);
Joonwoo Parka8890262012-10-15 12:04:27 -07002206 /* Let MBHC module know so micbias is on */
2207 wcd9xxx_resmgr_notifier_call(&taiko->resmgr, e_post_on);
Kiran Kandic3b24402012-06-11 00:05:59 -07002208 break;
Kiran Kandic3b24402012-06-11 00:05:59 -07002209 case SND_SOC_DAPM_POST_PMD:
Joonwoo Park3699ca32013-02-08 12:06:15 -08002210 if (micb_ctl_reg == TAIKO_A_MICB_2_CTL) {
2211 WCD9XXX_BCL_LOCK(&taiko->resmgr);
2212 wcd9xxx_resmgr_rm_cond_update_bits(&taiko->resmgr,
2213 WCD9XXX_COND_HPH_MIC,
2214 micb_ctl_reg, 7, false);
2215 WCD9XXX_BCL_UNLOCK(&taiko->resmgr);
2216 } else
2217 snd_soc_update_bits(codec, micb_ctl_reg, 1 << w->shift,
2218 0);
2219
Joonwoo Parka8890262012-10-15 12:04:27 -07002220 /* Let MBHC module know so micbias switch to be off */
2221 wcd9xxx_resmgr_notifier_call(&taiko->resmgr, e_post_off);
Kiran Kandic3b24402012-06-11 00:05:59 -07002222
2223 if (strnstr(w->name, internal1_text, 30))
2224 snd_soc_update_bits(codec, micb_int_reg, 0x80, 0x00);
2225 else if (strnstr(w->name, internal2_text, 30))
2226 snd_soc_update_bits(codec, micb_int_reg, 0x10, 0x00);
2227 else if (strnstr(w->name, internal3_text, 30))
2228 snd_soc_update_bits(codec, micb_int_reg, 0x2, 0x0);
2229
Joonwoo Parka8890262012-10-15 12:04:27 -07002230 /* Put cfilt */
2231 wcd9xxx_resmgr_cfilt_put(&taiko->resmgr, cfilt_sel_val);
Kiran Kandic3b24402012-06-11 00:05:59 -07002232 break;
2233 }
2234
2235 return 0;
2236}
2237
2238
2239static void tx_hpf_corner_freq_callback(struct work_struct *work)
2240{
2241 struct delayed_work *hpf_delayed_work;
2242 struct hpf_work *hpf_work;
2243 struct taiko_priv *taiko;
2244 struct snd_soc_codec *codec;
2245 u16 tx_mux_ctl_reg;
2246 u8 hpf_cut_of_freq;
2247
2248 hpf_delayed_work = to_delayed_work(work);
2249 hpf_work = container_of(hpf_delayed_work, struct hpf_work, dwork);
2250 taiko = hpf_work->taiko;
2251 codec = hpf_work->taiko->codec;
2252 hpf_cut_of_freq = hpf_work->tx_hpf_cut_of_freq;
2253
2254 tx_mux_ctl_reg = TAIKO_A_CDC_TX1_MUX_CTL +
2255 (hpf_work->decimator - 1) * 8;
2256
2257 pr_debug("%s(): decimator %u hpf_cut_of_freq 0x%x\n", __func__,
2258 hpf_work->decimator, (unsigned int)hpf_cut_of_freq);
2259
2260 snd_soc_update_bits(codec, tx_mux_ctl_reg, 0x30, hpf_cut_of_freq << 4);
2261}
2262
2263#define TX_MUX_CTL_CUT_OFF_FREQ_MASK 0x30
2264#define CF_MIN_3DB_4HZ 0x0
2265#define CF_MIN_3DB_75HZ 0x1
2266#define CF_MIN_3DB_150HZ 0x2
2267
2268static int taiko_codec_enable_dec(struct snd_soc_dapm_widget *w,
2269 struct snd_kcontrol *kcontrol, int event)
2270{
2271 struct snd_soc_codec *codec = w->codec;
2272 unsigned int decimator;
2273 char *dec_name = NULL;
2274 char *widget_name = NULL;
2275 char *temp;
2276 int ret = 0;
2277 u16 dec_reset_reg, tx_vol_ctl_reg, tx_mux_ctl_reg;
2278 u8 dec_hpf_cut_of_freq;
2279 int offset;
2280
2281
2282 pr_debug("%s %d\n", __func__, event);
2283
2284 widget_name = kstrndup(w->name, 15, GFP_KERNEL);
2285 if (!widget_name)
2286 return -ENOMEM;
2287 temp = widget_name;
2288
2289 dec_name = strsep(&widget_name, " ");
2290 widget_name = temp;
2291 if (!dec_name) {
2292 pr_err("%s: Invalid decimator = %s\n", __func__, w->name);
2293 ret = -EINVAL;
2294 goto out;
2295 }
2296
2297 ret = kstrtouint(strpbrk(dec_name, "123456789"), 10, &decimator);
2298 if (ret < 0) {
2299 pr_err("%s: Invalid decimator = %s\n", __func__, dec_name);
2300 ret = -EINVAL;
2301 goto out;
2302 }
2303
2304 pr_debug("%s(): widget = %s dec_name = %s decimator = %u\n", __func__,
2305 w->name, dec_name, decimator);
2306
2307 if (w->reg == TAIKO_A_CDC_CLK_TX_CLK_EN_B1_CTL) {
2308 dec_reset_reg = TAIKO_A_CDC_CLK_TX_RESET_B1_CTL;
2309 offset = 0;
2310 } else if (w->reg == TAIKO_A_CDC_CLK_TX_CLK_EN_B2_CTL) {
2311 dec_reset_reg = TAIKO_A_CDC_CLK_TX_RESET_B2_CTL;
2312 offset = 8;
2313 } else {
2314 pr_err("%s: Error, incorrect dec\n", __func__);
2315 return -EINVAL;
2316 }
2317
2318 tx_vol_ctl_reg = TAIKO_A_CDC_TX1_VOL_CTL_CFG + 8 * (decimator - 1);
2319 tx_mux_ctl_reg = TAIKO_A_CDC_TX1_MUX_CTL + 8 * (decimator - 1);
2320
2321 switch (event) {
2322 case SND_SOC_DAPM_PRE_PMU:
2323
2324 /* Enableable TX digital mute */
2325 snd_soc_update_bits(codec, tx_vol_ctl_reg, 0x01, 0x01);
2326
2327 snd_soc_update_bits(codec, dec_reset_reg, 1 << w->shift,
2328 1 << w->shift);
2329 snd_soc_update_bits(codec, dec_reset_reg, 1 << w->shift, 0x0);
2330
2331 dec_hpf_cut_of_freq = snd_soc_read(codec, tx_mux_ctl_reg);
2332
2333 dec_hpf_cut_of_freq = (dec_hpf_cut_of_freq & 0x30) >> 4;
2334
2335 tx_hpf_work[decimator - 1].tx_hpf_cut_of_freq =
2336 dec_hpf_cut_of_freq;
2337
2338 if ((dec_hpf_cut_of_freq != CF_MIN_3DB_150HZ)) {
2339
2340 /* set cut of freq to CF_MIN_3DB_150HZ (0x1); */
2341 snd_soc_update_bits(codec, tx_mux_ctl_reg, 0x30,
2342 CF_MIN_3DB_150HZ << 4);
2343 }
2344
2345 /* enable HPF */
2346 snd_soc_update_bits(codec, tx_mux_ctl_reg , 0x08, 0x00);
2347
2348 break;
2349
2350 case SND_SOC_DAPM_POST_PMU:
2351
2352 /* Disable TX digital mute */
2353 snd_soc_update_bits(codec, tx_vol_ctl_reg, 0x01, 0x00);
2354
2355 if (tx_hpf_work[decimator - 1].tx_hpf_cut_of_freq !=
2356 CF_MIN_3DB_150HZ) {
2357
2358 schedule_delayed_work(&tx_hpf_work[decimator - 1].dwork,
2359 msecs_to_jiffies(300));
2360 }
2361 /* apply the digital gain after the decimator is enabled*/
Damir Didjustoed406e22012-11-16 15:44:57 -08002362 if ((w->shift + offset) < ARRAY_SIZE(tx_digital_gain_reg))
Kiran Kandic3b24402012-06-11 00:05:59 -07002363 snd_soc_write(codec,
2364 tx_digital_gain_reg[w->shift + offset],
2365 snd_soc_read(codec,
2366 tx_digital_gain_reg[w->shift + offset])
2367 );
2368
2369 break;
2370
2371 case SND_SOC_DAPM_PRE_PMD:
2372
2373 snd_soc_update_bits(codec, tx_vol_ctl_reg, 0x01, 0x01);
2374 cancel_delayed_work_sync(&tx_hpf_work[decimator - 1].dwork);
2375 break;
2376
2377 case SND_SOC_DAPM_POST_PMD:
2378
2379 snd_soc_update_bits(codec, tx_mux_ctl_reg, 0x08, 0x08);
2380 snd_soc_update_bits(codec, tx_mux_ctl_reg, 0x30,
2381 (tx_hpf_work[decimator - 1].tx_hpf_cut_of_freq) << 4);
2382
2383 break;
2384 }
2385out:
2386 kfree(widget_name);
2387 return ret;
2388}
2389
Joonwoo Park125cd4e2012-12-11 15:16:11 -08002390static int taiko_codec_enable_vdd_spkr(struct snd_soc_dapm_widget *w,
2391 struct snd_kcontrol *kcontrol, int event)
2392{
2393 int ret = 0;
2394 struct snd_soc_codec *codec = w->codec;
2395 struct wcd9xxx *core = dev_get_drvdata(codec->dev->parent);
2396
2397 pr_debug("%s: %d %s\n", __func__, event, w->name);
2398 switch (event) {
2399 case SND_SOC_DAPM_PRE_PMU:
2400 if (spkr_drv_wrnd > 0) {
2401 WARN_ON(!(snd_soc_read(codec, TAIKO_A_SPKR_DRV_EN) &
2402 0x80));
2403 snd_soc_update_bits(codec, TAIKO_A_SPKR_DRV_EN, 0x80,
2404 0x00);
2405 }
2406 if (TAIKO_IS_1_0(core->version))
2407 snd_soc_update_bits(codec, TAIKO_A_SPKR_DRV_DBG_PWRSTG,
2408 0x24, 0x00);
2409 break;
2410 case SND_SOC_DAPM_POST_PMD:
2411 if (TAIKO_IS_1_0(core->version))
2412 snd_soc_update_bits(codec, TAIKO_A_SPKR_DRV_DBG_PWRSTG,
2413 0x24, 0x24);
2414 if (spkr_drv_wrnd > 0) {
2415 WARN_ON(!!(snd_soc_read(codec, TAIKO_A_SPKR_DRV_EN) &
2416 0x80));
2417 snd_soc_update_bits(codec, TAIKO_A_SPKR_DRV_EN, 0x80,
2418 0x80);
2419 }
2420 break;
2421 }
2422
2423 return ret;
2424}
2425
Kiran Kandi7b7d2ff2012-09-14 14:52:14 -07002426static int taiko_codec_enable_interpolator(struct snd_soc_dapm_widget *w,
Kiran Kandic3b24402012-06-11 00:05:59 -07002427 struct snd_kcontrol *kcontrol, int event)
2428{
2429 struct snd_soc_codec *codec = w->codec;
2430
2431 pr_debug("%s %d %s\n", __func__, event, w->name);
2432
2433 switch (event) {
2434 case SND_SOC_DAPM_PRE_PMU:
2435 snd_soc_update_bits(codec, TAIKO_A_CDC_CLK_RX_RESET_CTL,
2436 1 << w->shift, 1 << w->shift);
2437 snd_soc_update_bits(codec, TAIKO_A_CDC_CLK_RX_RESET_CTL,
2438 1 << w->shift, 0x0);
2439 break;
2440 case SND_SOC_DAPM_POST_PMU:
2441 /* apply the digital gain after the interpolator is enabled*/
2442 if ((w->shift) < ARRAY_SIZE(rx_digital_gain_reg))
2443 snd_soc_write(codec,
2444 rx_digital_gain_reg[w->shift],
2445 snd_soc_read(codec,
2446 rx_digital_gain_reg[w->shift])
2447 );
2448 break;
2449 }
2450 return 0;
2451}
2452
2453static int taiko_codec_enable_ldo_h(struct snd_soc_dapm_widget *w,
2454 struct snd_kcontrol *kcontrol, int event)
2455{
2456 switch (event) {
2457 case SND_SOC_DAPM_POST_PMU:
2458 case SND_SOC_DAPM_POST_PMD:
2459 usleep_range(1000, 1000);
2460 break;
2461 }
2462 return 0;
2463}
2464
2465static int taiko_codec_enable_rx_bias(struct snd_soc_dapm_widget *w,
2466 struct snd_kcontrol *kcontrol, int event)
2467{
2468 struct snd_soc_codec *codec = w->codec;
Joonwoo Parka8890262012-10-15 12:04:27 -07002469 struct taiko_priv *taiko = snd_soc_codec_get_drvdata(codec);
Kiran Kandic3b24402012-06-11 00:05:59 -07002470
2471 pr_debug("%s %d\n", __func__, event);
2472
2473 switch (event) {
2474 case SND_SOC_DAPM_PRE_PMU:
Joonwoo Parka8890262012-10-15 12:04:27 -07002475 wcd9xxx_resmgr_enable_rx_bias(&taiko->resmgr, 1);
Kiran Kandic3b24402012-06-11 00:05:59 -07002476 break;
2477 case SND_SOC_DAPM_POST_PMD:
Joonwoo Parka8890262012-10-15 12:04:27 -07002478 wcd9xxx_resmgr_enable_rx_bias(&taiko->resmgr, 0);
Kiran Kandic3b24402012-06-11 00:05:59 -07002479 break;
2480 }
2481 return 0;
2482}
Bhalchandra Gajare87fef4c2013-02-19 14:57:03 -08002483
2484static int taiko_hphl_dac_event(struct snd_soc_dapm_widget *w,
Kiran Kandic3b24402012-06-11 00:05:59 -07002485 struct snd_kcontrol *kcontrol, int event)
2486{
2487 struct snd_soc_codec *codec = w->codec;
Bhalchandra Gajare87fef4c2013-02-19 14:57:03 -08002488 struct taiko_priv *taiko_p = snd_soc_codec_get_drvdata(codec);
Kiran Kandic3b24402012-06-11 00:05:59 -07002489
2490 pr_debug("%s %s %d\n", __func__, w->name, event);
2491
2492 switch (event) {
2493 case SND_SOC_DAPM_PRE_PMU:
Bhalchandra Gajare87fef4c2013-02-19 14:57:03 -08002494 snd_soc_update_bits(codec, TAIKO_A_CDC_CLK_RDAC_CLK_EN_CTL,
2495 0x02, 0x02);
2496 wcd9xxx_clsh_fsm(codec, &taiko_p->clsh_d,
2497 WCD9XXX_CLSH_STATE_HPHL,
2498 WCD9XXX_CLSH_REQ_ENABLE,
2499 WCD9XXX_CLSH_EVENT_PRE_DAC);
Kiran Kandic3b24402012-06-11 00:05:59 -07002500 break;
2501 case SND_SOC_DAPM_POST_PMD:
Bhalchandra Gajare87fef4c2013-02-19 14:57:03 -08002502 snd_soc_update_bits(codec, TAIKO_A_CDC_CLK_RDAC_CLK_EN_CTL,
2503 0x02, 0x00);
2504 }
2505 return 0;
2506}
2507
2508static int taiko_hphr_dac_event(struct snd_soc_dapm_widget *w,
2509 struct snd_kcontrol *kcontrol, int event)
2510{
2511 struct snd_soc_codec *codec = w->codec;
2512 struct taiko_priv *taiko_p = snd_soc_codec_get_drvdata(codec);
2513
2514 pr_debug("%s %s %d\n", __func__, w->name, event);
2515
2516 switch (event) {
2517 case SND_SOC_DAPM_PRE_PMU:
2518 snd_soc_update_bits(codec, TAIKO_A_CDC_CLK_RDAC_CLK_EN_CTL,
2519 0x04, 0x04);
2520 snd_soc_update_bits(codec, w->reg, 0x40, 0x40);
2521 wcd9xxx_clsh_fsm(codec, &taiko_p->clsh_d,
2522 WCD9XXX_CLSH_STATE_HPHR,
2523 WCD9XXX_CLSH_REQ_ENABLE,
2524 WCD9XXX_CLSH_EVENT_PRE_DAC);
2525 break;
2526 case SND_SOC_DAPM_POST_PMD:
2527 snd_soc_update_bits(codec, TAIKO_A_CDC_CLK_RDAC_CLK_EN_CTL,
2528 0x04, 0x00);
Kiran Kandic3b24402012-06-11 00:05:59 -07002529 snd_soc_update_bits(codec, w->reg, 0x40, 0x00);
2530 break;
2531 }
2532 return 0;
2533}
2534
Kiran Kandic3b24402012-06-11 00:05:59 -07002535static int taiko_hph_pa_event(struct snd_soc_dapm_widget *w,
Joonwoo Parka8890262012-10-15 12:04:27 -07002536 struct snd_kcontrol *kcontrol, int event)
Kiran Kandic3b24402012-06-11 00:05:59 -07002537{
2538 struct snd_soc_codec *codec = w->codec;
2539 struct taiko_priv *taiko = snd_soc_codec_get_drvdata(codec);
Joonwoo Parka8890262012-10-15 12:04:27 -07002540 enum wcd9xxx_notify_event e_pre_on, e_post_off;
Bhalchandra Gajare87fef4c2013-02-19 14:57:03 -08002541 u8 req_clsh_state;
Joonwoo Parka8890262012-10-15 12:04:27 -07002542
Kiran Kandi4c56c592012-07-25 11:04:55 -07002543 pr_debug("%s: %s event = %d\n", __func__, w->name, event);
Joonwoo Parka8890262012-10-15 12:04:27 -07002544 if (w->shift == 5) {
2545 e_pre_on = WCD9XXX_EVENT_PRE_HPHR_PA_ON;
2546 e_post_off = WCD9XXX_EVENT_POST_HPHR_PA_OFF;
Bhalchandra Gajare87fef4c2013-02-19 14:57:03 -08002547 req_clsh_state = WCD9XXX_CLSH_STATE_HPHL;
Joonwoo Parka8890262012-10-15 12:04:27 -07002548 } else if (w->shift == 4) {
2549 e_pre_on = WCD9XXX_EVENT_PRE_HPHL_PA_ON;
2550 e_post_off = WCD9XXX_EVENT_POST_HPHL_PA_OFF;
Bhalchandra Gajare87fef4c2013-02-19 14:57:03 -08002551 req_clsh_state = WCD9XXX_CLSH_STATE_HPHR;
Joonwoo Parka8890262012-10-15 12:04:27 -07002552 } else {
2553 pr_err("%s: Invalid w->shift %d\n", __func__, w->shift);
2554 return -EINVAL;
2555 }
Kiran Kandic3b24402012-06-11 00:05:59 -07002556
2557 switch (event) {
2558 case SND_SOC_DAPM_PRE_PMU:
Joonwoo Parka8890262012-10-15 12:04:27 -07002559 /* Let MBHC module know PA is turning on */
2560 wcd9xxx_resmgr_notifier_call(&taiko->resmgr, e_pre_on);
Kiran Kandic3b24402012-06-11 00:05:59 -07002561 break;
2562
Kiran Kandi4c56c592012-07-25 11:04:55 -07002563 case SND_SOC_DAPM_POST_PMU:
Bhalchandra Gajare87fef4c2013-02-19 14:57:03 -08002564 wcd9xxx_clsh_fsm(codec, &taiko->clsh_d,
2565 req_clsh_state,
2566 WCD9XXX_CLSH_REQ_ENABLE,
2567 WCD9XXX_CLSH_EVENT_POST_PA);
Kiran Kandi4c56c592012-07-25 11:04:55 -07002568
Kiran Kandi4c56c592012-07-25 11:04:55 -07002569
Bhalchandra Gajare87fef4c2013-02-19 14:57:03 -08002570 usleep_range(5000, 5000);
Kiran Kandi4c56c592012-07-25 11:04:55 -07002571 break;
2572
Kiran Kandic3b24402012-06-11 00:05:59 -07002573 case SND_SOC_DAPM_POST_PMD:
Joonwoo Parka8890262012-10-15 12:04:27 -07002574 /* Let MBHC module know PA turned off */
2575 wcd9xxx_resmgr_notifier_call(&taiko->resmgr, e_post_off);
2576
Bhalchandra Gajare87fef4c2013-02-19 14:57:03 -08002577 wcd9xxx_clsh_fsm(codec, &taiko->clsh_d,
2578 req_clsh_state,
2579 WCD9XXX_CLSH_REQ_DISABLE,
2580 WCD9XXX_CLSH_EVENT_POST_PA);
2581
Kiran Kandic3b24402012-06-11 00:05:59 -07002582 pr_debug("%s: sleep 10 ms after %s PA disable.\n", __func__,
Joonwoo Parka8890262012-10-15 12:04:27 -07002583 w->name);
Bhalchandra Gajare87fef4c2013-02-19 14:57:03 -08002584 usleep_range(5000, 5000);
Kiran Kandic3b24402012-06-11 00:05:59 -07002585 break;
2586 }
2587 return 0;
2588}
2589
Kiran Kandic3b24402012-06-11 00:05:59 -07002590static const struct snd_soc_dapm_widget taiko_dapm_i2s_widgets[] = {
2591 SND_SOC_DAPM_SUPPLY("RX_I2S_CLK", TAIKO_A_CDC_CLK_RX_I2S_CTL,
2592 4, 0, NULL, 0),
2593 SND_SOC_DAPM_SUPPLY("TX_I2S_CLK", TAIKO_A_CDC_CLK_TX_I2S_CTL, 4,
2594 0, NULL, 0),
2595};
2596
2597static int taiko_lineout_dac_event(struct snd_soc_dapm_widget *w,
2598 struct snd_kcontrol *kcontrol, int event)
2599{
2600 struct snd_soc_codec *codec = w->codec;
Bhalchandra Gajare87fef4c2013-02-19 14:57:03 -08002601 struct taiko_priv *taiko = snd_soc_codec_get_drvdata(codec);
Kiran Kandic3b24402012-06-11 00:05:59 -07002602
2603 pr_debug("%s %s %d\n", __func__, w->name, event);
2604
2605 switch (event) {
2606 case SND_SOC_DAPM_PRE_PMU:
Bhalchandra Gajare87fef4c2013-02-19 14:57:03 -08002607 wcd9xxx_clsh_fsm(codec, &taiko->clsh_d,
2608 WCD9XXX_CLSH_STATE_LO,
2609 WCD9XXX_CLSH_REQ_ENABLE,
2610 WCD9XXX_CLSH_EVENT_PRE_DAC);
Kiran Kandic3b24402012-06-11 00:05:59 -07002611 snd_soc_update_bits(codec, w->reg, 0x40, 0x40);
2612 break;
2613
2614 case SND_SOC_DAPM_POST_PMD:
2615 snd_soc_update_bits(codec, w->reg, 0x40, 0x00);
2616 break;
2617 }
2618 return 0;
2619}
2620
Joonwoo Park7680b9f2012-07-13 11:36:48 -07002621static int taiko_spk_dac_event(struct snd_soc_dapm_widget *w,
2622 struct snd_kcontrol *kcontrol, int event)
2623{
2624 pr_debug("%s %s %d\n", __func__, w->name, event);
2625 return 0;
2626}
2627
Kiran Kandic3b24402012-06-11 00:05:59 -07002628static const struct snd_soc_dapm_route audio_i2s_map[] = {
Kiran Kandic3b24402012-06-11 00:05:59 -07002629 {"SLIM RX1", NULL, "RX_I2S_CLK"},
2630 {"SLIM RX2", NULL, "RX_I2S_CLK"},
2631 {"SLIM RX3", NULL, "RX_I2S_CLK"},
2632 {"SLIM RX4", NULL, "RX_I2S_CLK"},
2633
Venkat Sudhira41630a2012-10-27 00:57:31 -07002634 {"SLIM TX7 MUX", NULL, "TX_I2S_CLK"},
2635 {"SLIM TX8 MUX", NULL, "TX_I2S_CLK"},
2636 {"SLIM TX9 MUX", NULL, "TX_I2S_CLK"},
2637 {"SLIM TX10 MUX", NULL, "TX_I2S_CLK"},
Kiran Kandic3b24402012-06-11 00:05:59 -07002638};
2639
Joonwoo Park559a5bf2013-02-15 14:46:36 -08002640static const struct snd_soc_dapm_route audio_i2s_map_1_0[] = {
2641 {"RX_I2S_CLK", NULL, "CDC_CONN"},
2642};
2643
2644static const struct snd_soc_dapm_route audio_i2s_map_2_0[] = {
2645 {"RX_I2S_CLK", NULL, "CDC_I2S_RX_CONN"},
2646};
2647
Kiran Kandic3b24402012-06-11 00:05:59 -07002648static const struct snd_soc_dapm_route audio_map[] = {
2649 /* SLIMBUS Connections */
Kuirong Wang906ac472012-07-09 12:54:44 -07002650 {"AIF1 CAP", NULL, "AIF1_CAP Mixer"},
2651 {"AIF2 CAP", NULL, "AIF2_CAP Mixer"},
2652 {"AIF3 CAP", NULL, "AIF3_CAP Mixer"},
Kiran Kandic3b24402012-06-11 00:05:59 -07002653
Kuirong Wang906ac472012-07-09 12:54:44 -07002654 /* SLIM_MIXER("AIF1_CAP Mixer"),*/
2655 {"AIF1_CAP Mixer", "SLIM TX1", "SLIM TX1 MUX"},
2656 {"AIF1_CAP Mixer", "SLIM TX2", "SLIM TX2 MUX"},
2657 {"AIF1_CAP Mixer", "SLIM TX3", "SLIM TX3 MUX"},
2658 {"AIF1_CAP Mixer", "SLIM TX4", "SLIM TX4 MUX"},
2659 {"AIF1_CAP Mixer", "SLIM TX5", "SLIM TX5 MUX"},
2660 {"AIF1_CAP Mixer", "SLIM TX6", "SLIM TX6 MUX"},
2661 {"AIF1_CAP Mixer", "SLIM TX7", "SLIM TX7 MUX"},
2662 {"AIF1_CAP Mixer", "SLIM TX8", "SLIM TX8 MUX"},
2663 {"AIF1_CAP Mixer", "SLIM TX9", "SLIM TX9 MUX"},
2664 {"AIF1_CAP Mixer", "SLIM TX10", "SLIM TX10 MUX"},
2665 /* SLIM_MIXER("AIF2_CAP Mixer"),*/
2666 {"AIF2_CAP Mixer", "SLIM TX1", "SLIM TX1 MUX"},
2667 {"AIF2_CAP Mixer", "SLIM TX2", "SLIM TX2 MUX"},
2668 {"AIF2_CAP Mixer", "SLIM TX3", "SLIM TX3 MUX"},
2669 {"AIF2_CAP Mixer", "SLIM TX4", "SLIM TX4 MUX"},
2670 {"AIF2_CAP Mixer", "SLIM TX5", "SLIM TX5 MUX"},
2671 {"AIF2_CAP Mixer", "SLIM TX6", "SLIM TX6 MUX"},
2672 {"AIF2_CAP Mixer", "SLIM TX7", "SLIM TX7 MUX"},
2673 {"AIF2_CAP Mixer", "SLIM TX8", "SLIM TX8 MUX"},
2674 {"AIF2_CAP Mixer", "SLIM TX9", "SLIM TX9 MUX"},
2675 {"AIF2_CAP Mixer", "SLIM TX10", "SLIM TX10 MUX"},
2676 /* SLIM_MIXER("AIF3_CAP Mixer"),*/
2677 {"AIF3_CAP Mixer", "SLIM TX1", "SLIM TX1 MUX"},
2678 {"AIF3_CAP Mixer", "SLIM TX2", "SLIM TX2 MUX"},
2679 {"AIF3_CAP Mixer", "SLIM TX3", "SLIM TX3 MUX"},
2680 {"AIF3_CAP Mixer", "SLIM TX4", "SLIM TX4 MUX"},
2681 {"AIF3_CAP Mixer", "SLIM TX5", "SLIM TX5 MUX"},
2682 {"AIF3_CAP Mixer", "SLIM TX6", "SLIM TX6 MUX"},
2683 {"AIF3_CAP Mixer", "SLIM TX7", "SLIM TX7 MUX"},
2684 {"AIF3_CAP Mixer", "SLIM TX8", "SLIM TX8 MUX"},
2685 {"AIF3_CAP Mixer", "SLIM TX9", "SLIM TX9 MUX"},
2686 {"AIF3_CAP Mixer", "SLIM TX10", "SLIM TX10 MUX"},
2687
Kiran Kandic3b24402012-06-11 00:05:59 -07002688 {"SLIM TX1 MUX", "DEC1", "DEC1 MUX"},
2689
Kiran Kandic3b24402012-06-11 00:05:59 -07002690 {"SLIM TX2 MUX", "DEC2", "DEC2 MUX"},
2691
Kiran Kandic3b24402012-06-11 00:05:59 -07002692 {"SLIM TX3 MUX", "DEC3", "DEC3 MUX"},
2693 {"SLIM TX3 MUX", "RMIX1", "RX1 MIX1"},
2694 {"SLIM TX3 MUX", "RMIX2", "RX2 MIX1"},
2695 {"SLIM TX3 MUX", "RMIX3", "RX3 MIX1"},
2696 {"SLIM TX3 MUX", "RMIX4", "RX4 MIX1"},
2697 {"SLIM TX3 MUX", "RMIX5", "RX5 MIX1"},
2698 {"SLIM TX3 MUX", "RMIX6", "RX6 MIX1"},
2699 {"SLIM TX3 MUX", "RMIX7", "RX7 MIX1"},
2700
Kiran Kandic3b24402012-06-11 00:05:59 -07002701 {"SLIM TX4 MUX", "DEC4", "DEC4 MUX"},
2702
Kiran Kandic3b24402012-06-11 00:05:59 -07002703 {"SLIM TX5 MUX", "DEC5", "DEC5 MUX"},
2704 {"SLIM TX5 MUX", "RMIX1", "RX1 MIX1"},
2705 {"SLIM TX5 MUX", "RMIX2", "RX2 MIX1"},
2706 {"SLIM TX5 MUX", "RMIX3", "RX3 MIX1"},
2707 {"SLIM TX5 MUX", "RMIX4", "RX4 MIX1"},
2708 {"SLIM TX5 MUX", "RMIX5", "RX5 MIX1"},
2709 {"SLIM TX5 MUX", "RMIX6", "RX6 MIX1"},
2710 {"SLIM TX5 MUX", "RMIX7", "RX7 MIX1"},
2711
Kiran Kandic3b24402012-06-11 00:05:59 -07002712 {"SLIM TX6 MUX", "DEC6", "DEC6 MUX"},
2713
Kiran Kandic3b24402012-06-11 00:05:59 -07002714 {"SLIM TX7 MUX", "DEC1", "DEC1 MUX"},
2715 {"SLIM TX7 MUX", "DEC2", "DEC2 MUX"},
2716 {"SLIM TX7 MUX", "DEC3", "DEC3 MUX"},
2717 {"SLIM TX7 MUX", "DEC4", "DEC4 MUX"},
2718 {"SLIM TX7 MUX", "DEC5", "DEC5 MUX"},
2719 {"SLIM TX7 MUX", "DEC6", "DEC6 MUX"},
2720 {"SLIM TX7 MUX", "DEC7", "DEC7 MUX"},
2721 {"SLIM TX7 MUX", "DEC8", "DEC8 MUX"},
2722 {"SLIM TX7 MUX", "DEC9", "DEC9 MUX"},
2723 {"SLIM TX7 MUX", "DEC10", "DEC10 MUX"},
2724 {"SLIM TX7 MUX", "RMIX1", "RX1 MIX1"},
2725 {"SLIM TX7 MUX", "RMIX2", "RX2 MIX1"},
2726 {"SLIM TX7 MUX", "RMIX3", "RX3 MIX1"},
2727 {"SLIM TX7 MUX", "RMIX4", "RX4 MIX1"},
2728 {"SLIM TX7 MUX", "RMIX5", "RX5 MIX1"},
2729 {"SLIM TX7 MUX", "RMIX6", "RX6 MIX1"},
2730 {"SLIM TX7 MUX", "RMIX7", "RX7 MIX1"},
2731
Kiran Kandic3b24402012-06-11 00:05:59 -07002732 {"SLIM TX8 MUX", "DEC1", "DEC1 MUX"},
2733 {"SLIM TX8 MUX", "DEC2", "DEC2 MUX"},
2734 {"SLIM TX8 MUX", "DEC3", "DEC3 MUX"},
2735 {"SLIM TX8 MUX", "DEC4", "DEC4 MUX"},
2736 {"SLIM TX8 MUX", "DEC5", "DEC5 MUX"},
2737 {"SLIM TX8 MUX", "DEC6", "DEC6 MUX"},
2738 {"SLIM TX8 MUX", "DEC7", "DEC7 MUX"},
2739 {"SLIM TX8 MUX", "DEC8", "DEC8 MUX"},
2740 {"SLIM TX8 MUX", "DEC9", "DEC9 MUX"},
2741 {"SLIM TX8 MUX", "DEC10", "DEC10 MUX"},
2742
Kiran Kandic3b24402012-06-11 00:05:59 -07002743 {"SLIM TX9 MUX", "DEC1", "DEC1 MUX"},
2744 {"SLIM TX9 MUX", "DEC2", "DEC2 MUX"},
2745 {"SLIM TX9 MUX", "DEC3", "DEC3 MUX"},
2746 {"SLIM TX9 MUX", "DEC4", "DEC4 MUX"},
2747 {"SLIM TX9 MUX", "DEC5", "DEC5 MUX"},
2748 {"SLIM TX9 MUX", "DEC6", "DEC6 MUX"},
2749 {"SLIM TX9 MUX", "DEC7", "DEC7 MUX"},
2750 {"SLIM TX9 MUX", "DEC8", "DEC8 MUX"},
2751 {"SLIM TX9 MUX", "DEC9", "DEC9 MUX"},
2752 {"SLIM TX9 MUX", "DEC10", "DEC10 MUX"},
2753
Kiran Kandic3b24402012-06-11 00:05:59 -07002754 {"SLIM TX10 MUX", "DEC1", "DEC1 MUX"},
2755 {"SLIM TX10 MUX", "DEC2", "DEC2 MUX"},
2756 {"SLIM TX10 MUX", "DEC3", "DEC3 MUX"},
2757 {"SLIM TX10 MUX", "DEC4", "DEC4 MUX"},
2758 {"SLIM TX10 MUX", "DEC5", "DEC5 MUX"},
2759 {"SLIM TX10 MUX", "DEC6", "DEC6 MUX"},
2760 {"SLIM TX10 MUX", "DEC7", "DEC7 MUX"},
2761 {"SLIM TX10 MUX", "DEC8", "DEC8 MUX"},
2762 {"SLIM TX10 MUX", "DEC9", "DEC9 MUX"},
2763 {"SLIM TX10 MUX", "DEC10", "DEC10 MUX"},
2764
2765 /* Earpiece (RX MIX1) */
2766 {"EAR", NULL, "EAR PA"},
2767 {"EAR PA", NULL, "EAR_PA_MIXER"},
2768 {"EAR_PA_MIXER", NULL, "DAC1"},
Bhalchandra Gajare87fef4c2013-02-19 14:57:03 -08002769 {"DAC1", NULL, "RX_BIAS"},
Kiran Kandic3b24402012-06-11 00:05:59 -07002770
2771 {"ANC1 FB MUX", "EAR_HPH_L", "RX1 MIX2"},
2772 {"ANC1 FB MUX", "EAR_LINE_1", "RX2 MIX2"},
2773 {"ANC", NULL, "ANC1 FB MUX"},
2774
2775 /* Headset (RX MIX1 and RX MIX2) */
2776 {"HEADPHONE", NULL, "HPHL"},
2777 {"HEADPHONE", NULL, "HPHR"},
2778
2779 {"HPHL", NULL, "HPHL_PA_MIXER"},
2780 {"HPHL_PA_MIXER", NULL, "HPHL DAC"},
Bhalchandra Gajare87fef4c2013-02-19 14:57:03 -08002781 {"HPHL DAC", NULL, "RX_BIAS"},
Kiran Kandic3b24402012-06-11 00:05:59 -07002782
2783 {"HPHR", NULL, "HPHR_PA_MIXER"},
2784 {"HPHR_PA_MIXER", NULL, "HPHR DAC"},
Bhalchandra Gajare87fef4c2013-02-19 14:57:03 -08002785 {"HPHR DAC", NULL, "RX_BIAS"},
Kiran Kandic3b24402012-06-11 00:05:59 -07002786
2787 {"ANC", NULL, "ANC1 MUX"},
2788 {"ANC", NULL, "ANC2 MUX"},
2789 {"ANC1 MUX", "ADC1", "ADC1"},
2790 {"ANC1 MUX", "ADC2", "ADC2"},
2791 {"ANC1 MUX", "ADC3", "ADC3"},
2792 {"ANC1 MUX", "ADC4", "ADC4"},
2793 {"ANC2 MUX", "ADC1", "ADC1"},
2794 {"ANC2 MUX", "ADC2", "ADC2"},
2795 {"ANC2 MUX", "ADC3", "ADC3"},
2796 {"ANC2 MUX", "ADC4", "ADC4"},
2797
2798 {"ANC", NULL, "CDC_CONN"},
2799
Bhalchandra Gajare87fef4c2013-02-19 14:57:03 -08002800 {"DAC1", "Switch", "CLASS_H_DSM MUX"},
2801 {"HPHL DAC", "Switch", "CLASS_H_DSM MUX"},
Kiran Kandic3b24402012-06-11 00:05:59 -07002802 {"HPHR DAC", NULL, "RX2 CHAIN"},
2803
2804 {"LINEOUT1", NULL, "LINEOUT1 PA"},
2805 {"LINEOUT2", NULL, "LINEOUT2 PA"},
2806 {"LINEOUT3", NULL, "LINEOUT3 PA"},
2807 {"LINEOUT4", NULL, "LINEOUT4 PA"},
Joonwoo Park7680b9f2012-07-13 11:36:48 -07002808 {"SPK_OUT", NULL, "SPK PA"},
Kiran Kandic3b24402012-06-11 00:05:59 -07002809
2810 {"LINEOUT1 PA", NULL, "LINEOUT1_PA_MIXER"},
2811 {"LINEOUT1_PA_MIXER", NULL, "LINEOUT1 DAC"},
Tanya Finkelfe634462012-10-23 22:12:07 +02002812
Kiran Kandic3b24402012-06-11 00:05:59 -07002813 {"LINEOUT2 PA", NULL, "LINEOUT2_PA_MIXER"},
2814 {"LINEOUT2_PA_MIXER", NULL, "LINEOUT2 DAC"},
Tanya Finkelfe634462012-10-23 22:12:07 +02002815
Kiran Kandic3b24402012-06-11 00:05:59 -07002816 {"LINEOUT3 PA", NULL, "LINEOUT3_PA_MIXER"},
2817 {"LINEOUT3_PA_MIXER", NULL, "LINEOUT3 DAC"},
Tanya Finkelfe634462012-10-23 22:12:07 +02002818
Kiran Kandic3b24402012-06-11 00:05:59 -07002819 {"LINEOUT4 PA", NULL, "LINEOUT4_PA_MIXER"},
2820 {"LINEOUT4_PA_MIXER", NULL, "LINEOUT4 DAC"},
2821
2822 {"LINEOUT1 DAC", NULL, "RX3 MIX1"},
2823
Tanya Finkeldaaa6d12012-10-25 11:22:48 +02002824 {"RDAC5 MUX", "DEM3_INV", "RX3 MIX1"},
2825 {"RDAC5 MUX", "DEM4", "RX4 MIX1"},
2826
2827 {"LINEOUT3 DAC", NULL, "RDAC5 MUX"},
Kiran Kandic3b24402012-06-11 00:05:59 -07002828
2829 {"LINEOUT2 DAC", NULL, "RX5 MIX1"},
2830
Tanya Finkeldaaa6d12012-10-25 11:22:48 +02002831 {"RDAC7 MUX", "DEM5_INV", "RX5 MIX1"},
2832 {"RDAC7 MUX", "DEM6", "RX6 MIX1"},
2833
2834 {"LINEOUT4 DAC", NULL, "RDAC7 MUX"},
Kiran Kandic3b24402012-06-11 00:05:59 -07002835
Joonwoo Park7680b9f2012-07-13 11:36:48 -07002836 {"SPK PA", NULL, "SPK DAC"},
Kiran Kandid2b46332012-10-05 12:04:00 -07002837 {"SPK DAC", NULL, "RX7 MIX2"},
Joonwoo Park125cd4e2012-12-11 15:16:11 -08002838 {"SPK DAC", NULL, "VDD_SPKDRV"},
Joonwoo Park7680b9f2012-07-13 11:36:48 -07002839
Bhalchandra Gajare87fef4c2013-02-19 14:57:03 -08002840 {"CLASS_H_DSM MUX", "DSM_HPHL_RX1", "RX1 CHAIN"},
2841
Kiran Kandic3b24402012-06-11 00:05:59 -07002842 {"RX1 CHAIN", NULL, "RX1 MIX2"},
2843 {"RX2 CHAIN", NULL, "RX2 MIX2"},
2844 {"RX1 CHAIN", NULL, "ANC"},
2845 {"RX2 CHAIN", NULL, "ANC"},
2846
Kiran Kandic3b24402012-06-11 00:05:59 -07002847 {"LINEOUT1 DAC", NULL, "RX_BIAS"},
2848 {"LINEOUT2 DAC", NULL, "RX_BIAS"},
2849 {"LINEOUT3 DAC", NULL, "RX_BIAS"},
2850 {"LINEOUT4 DAC", NULL, "RX_BIAS"},
Joonwoo Park7680b9f2012-07-13 11:36:48 -07002851 {"SPK DAC", NULL, "RX_BIAS"},
Kiran Kandic3b24402012-06-11 00:05:59 -07002852
Joonwoo Parkc7731432012-10-17 12:41:44 -07002853 {"RX7 MIX1", NULL, "COMP0_CLK"},
Kiran Kandic3b24402012-06-11 00:05:59 -07002854 {"RX1 MIX1", NULL, "COMP1_CLK"},
2855 {"RX2 MIX1", NULL, "COMP1_CLK"},
2856 {"RX3 MIX1", NULL, "COMP2_CLK"},
2857 {"RX5 MIX1", NULL, "COMP2_CLK"},
2858
Kiran Kandic3b24402012-06-11 00:05:59 -07002859 {"RX1 MIX1", NULL, "RX1 MIX1 INP1"},
2860 {"RX1 MIX1", NULL, "RX1 MIX1 INP2"},
2861 {"RX1 MIX1", NULL, "RX1 MIX1 INP3"},
2862 {"RX2 MIX1", NULL, "RX2 MIX1 INP1"},
2863 {"RX2 MIX1", NULL, "RX2 MIX1 INP2"},
2864 {"RX3 MIX1", NULL, "RX3 MIX1 INP1"},
2865 {"RX3 MIX1", NULL, "RX3 MIX1 INP2"},
2866 {"RX4 MIX1", NULL, "RX4 MIX1 INP1"},
2867 {"RX4 MIX1", NULL, "RX4 MIX1 INP2"},
2868 {"RX5 MIX1", NULL, "RX5 MIX1 INP1"},
2869 {"RX5 MIX1", NULL, "RX5 MIX1 INP2"},
2870 {"RX6 MIX1", NULL, "RX6 MIX1 INP1"},
2871 {"RX6 MIX1", NULL, "RX6 MIX1 INP2"},
2872 {"RX7 MIX1", NULL, "RX7 MIX1 INP1"},
2873 {"RX7 MIX1", NULL, "RX7 MIX1 INP2"},
2874 {"RX1 MIX2", NULL, "RX1 MIX1"},
2875 {"RX1 MIX2", NULL, "RX1 MIX2 INP1"},
2876 {"RX1 MIX2", NULL, "RX1 MIX2 INP2"},
2877 {"RX2 MIX2", NULL, "RX2 MIX1"},
2878 {"RX2 MIX2", NULL, "RX2 MIX2 INP1"},
2879 {"RX2 MIX2", NULL, "RX2 MIX2 INP2"},
2880 {"RX7 MIX2", NULL, "RX7 MIX1"},
2881 {"RX7 MIX2", NULL, "RX7 MIX2 INP1"},
2882 {"RX7 MIX2", NULL, "RX7 MIX2 INP2"},
2883
Kuirong Wang906ac472012-07-09 12:54:44 -07002884 /* SLIM_MUX("AIF1_PB", "AIF1 PB"),*/
2885 {"SLIM RX1 MUX", "AIF1_PB", "AIF1 PB"},
2886 {"SLIM RX2 MUX", "AIF1_PB", "AIF1 PB"},
2887 {"SLIM RX3 MUX", "AIF1_PB", "AIF1 PB"},
2888 {"SLIM RX4 MUX", "AIF1_PB", "AIF1 PB"},
2889 {"SLIM RX5 MUX", "AIF1_PB", "AIF1 PB"},
2890 {"SLIM RX6 MUX", "AIF1_PB", "AIF1 PB"},
2891 {"SLIM RX7 MUX", "AIF1_PB", "AIF1 PB"},
2892 /* SLIM_MUX("AIF2_PB", "AIF2 PB"),*/
2893 {"SLIM RX1 MUX", "AIF2_PB", "AIF2 PB"},
2894 {"SLIM RX2 MUX", "AIF2_PB", "AIF2 PB"},
2895 {"SLIM RX3 MUX", "AIF2_PB", "AIF2 PB"},
2896 {"SLIM RX4 MUX", "AIF2_PB", "AIF2 PB"},
2897 {"SLIM RX5 MUX", "AIF2_PB", "AIF2 PB"},
2898 {"SLIM RX6 MUX", "AIF2_PB", "AIF2 PB"},
2899 {"SLIM RX7 MUX", "AIF2_PB", "AIF2 PB"},
2900 /* SLIM_MUX("AIF3_PB", "AIF3 PB"),*/
2901 {"SLIM RX1 MUX", "AIF3_PB", "AIF3 PB"},
2902 {"SLIM RX2 MUX", "AIF3_PB", "AIF3 PB"},
2903 {"SLIM RX3 MUX", "AIF3_PB", "AIF3 PB"},
2904 {"SLIM RX4 MUX", "AIF3_PB", "AIF3 PB"},
2905 {"SLIM RX5 MUX", "AIF3_PB", "AIF3 PB"},
2906 {"SLIM RX6 MUX", "AIF3_PB", "AIF3 PB"},
2907 {"SLIM RX7 MUX", "AIF3_PB", "AIF3 PB"},
2908
2909 {"SLIM RX1", NULL, "SLIM RX1 MUX"},
2910 {"SLIM RX2", NULL, "SLIM RX2 MUX"},
2911 {"SLIM RX3", NULL, "SLIM RX3 MUX"},
2912 {"SLIM RX4", NULL, "SLIM RX4 MUX"},
2913 {"SLIM RX5", NULL, "SLIM RX5 MUX"},
2914 {"SLIM RX6", NULL, "SLIM RX6 MUX"},
2915 {"SLIM RX7", NULL, "SLIM RX7 MUX"},
2916
Kiran Kandic3b24402012-06-11 00:05:59 -07002917 {"RX1 MIX1 INP1", "RX1", "SLIM RX1"},
2918 {"RX1 MIX1 INP1", "RX2", "SLIM RX2"},
2919 {"RX1 MIX1 INP1", "RX3", "SLIM RX3"},
2920 {"RX1 MIX1 INP1", "RX4", "SLIM RX4"},
2921 {"RX1 MIX1 INP1", "RX5", "SLIM RX5"},
2922 {"RX1 MIX1 INP1", "RX6", "SLIM RX6"},
2923 {"RX1 MIX1 INP1", "RX7", "SLIM RX7"},
2924 {"RX1 MIX1 INP1", "IIR1", "IIR1"},
2925 {"RX1 MIX1 INP2", "RX1", "SLIM RX1"},
2926 {"RX1 MIX1 INP2", "RX2", "SLIM RX2"},
2927 {"RX1 MIX1 INP2", "RX3", "SLIM RX3"},
2928 {"RX1 MIX1 INP2", "RX4", "SLIM RX4"},
2929 {"RX1 MIX1 INP2", "RX5", "SLIM RX5"},
2930 {"RX1 MIX1 INP2", "RX6", "SLIM RX6"},
2931 {"RX1 MIX1 INP2", "RX7", "SLIM RX7"},
2932 {"RX1 MIX1 INP2", "IIR1", "IIR1"},
2933 {"RX1 MIX1 INP3", "RX1", "SLIM RX1"},
2934 {"RX1 MIX1 INP3", "RX2", "SLIM RX2"},
2935 {"RX1 MIX1 INP3", "RX3", "SLIM RX3"},
2936 {"RX1 MIX1 INP3", "RX4", "SLIM RX4"},
2937 {"RX1 MIX1 INP3", "RX5", "SLIM RX5"},
2938 {"RX1 MIX1 INP3", "RX6", "SLIM RX6"},
2939 {"RX1 MIX1 INP3", "RX7", "SLIM RX7"},
2940 {"RX2 MIX1 INP1", "RX1", "SLIM RX1"},
2941 {"RX2 MIX1 INP1", "RX2", "SLIM RX2"},
2942 {"RX2 MIX1 INP1", "RX3", "SLIM RX3"},
2943 {"RX2 MIX1 INP1", "RX4", "SLIM RX4"},
2944 {"RX2 MIX1 INP1", "RX5", "SLIM RX5"},
2945 {"RX2 MIX1 INP1", "RX6", "SLIM RX6"},
2946 {"RX2 MIX1 INP1", "RX7", "SLIM RX7"},
2947 {"RX2 MIX1 INP1", "IIR1", "IIR1"},
2948 {"RX2 MIX1 INP2", "RX1", "SLIM RX1"},
2949 {"RX2 MIX1 INP2", "RX2", "SLIM RX2"},
2950 {"RX2 MIX1 INP2", "RX3", "SLIM RX3"},
2951 {"RX2 MIX1 INP2", "RX4", "SLIM RX4"},
2952 {"RX2 MIX1 INP2", "RX5", "SLIM RX5"},
2953 {"RX2 MIX1 INP2", "RX6", "SLIM RX6"},
2954 {"RX2 MIX1 INP2", "RX7", "SLIM RX7"},
2955 {"RX2 MIX1 INP2", "IIR1", "IIR1"},
2956 {"RX3 MIX1 INP1", "RX1", "SLIM RX1"},
2957 {"RX3 MIX1 INP1", "RX2", "SLIM RX2"},
2958 {"RX3 MIX1 INP1", "RX3", "SLIM RX3"},
2959 {"RX3 MIX1 INP1", "RX4", "SLIM RX4"},
2960 {"RX3 MIX1 INP1", "RX5", "SLIM RX5"},
2961 {"RX3 MIX1 INP1", "RX6", "SLIM RX6"},
2962 {"RX3 MIX1 INP1", "RX7", "SLIM RX7"},
2963 {"RX3 MIX1 INP1", "IIR1", "IIR1"},
2964 {"RX3 MIX1 INP2", "RX1", "SLIM RX1"},
2965 {"RX3 MIX1 INP2", "RX2", "SLIM RX2"},
2966 {"RX3 MIX1 INP2", "RX3", "SLIM RX3"},
2967 {"RX3 MIX1 INP2", "RX4", "SLIM RX4"},
2968 {"RX3 MIX1 INP2", "RX5", "SLIM RX5"},
2969 {"RX3 MIX1 INP2", "RX6", "SLIM RX6"},
2970 {"RX3 MIX1 INP2", "RX7", "SLIM RX7"},
2971 {"RX3 MIX1 INP2", "IIR1", "IIR1"},
2972 {"RX4 MIX1 INP1", "RX1", "SLIM RX1"},
2973 {"RX4 MIX1 INP1", "RX2", "SLIM RX2"},
2974 {"RX4 MIX1 INP1", "RX3", "SLIM RX3"},
2975 {"RX4 MIX1 INP1", "RX4", "SLIM RX4"},
2976 {"RX4 MIX1 INP1", "RX5", "SLIM RX5"},
2977 {"RX4 MIX1 INP1", "RX6", "SLIM RX6"},
2978 {"RX4 MIX1 INP1", "RX7", "SLIM RX7"},
2979 {"RX4 MIX1 INP1", "IIR1", "IIR1"},
2980 {"RX4 MIX1 INP2", "RX1", "SLIM RX1"},
2981 {"RX4 MIX1 INP2", "RX2", "SLIM RX2"},
2982 {"RX4 MIX1 INP2", "RX3", "SLIM RX3"},
2983 {"RX4 MIX1 INP2", "RX5", "SLIM RX5"},
2984 {"RX4 MIX1 INP2", "RX4", "SLIM RX4"},
2985 {"RX4 MIX1 INP2", "RX6", "SLIM RX6"},
2986 {"RX4 MIX1 INP2", "RX7", "SLIM RX7"},
2987 {"RX4 MIX1 INP2", "IIR1", "IIR1"},
2988 {"RX5 MIX1 INP1", "RX1", "SLIM RX1"},
2989 {"RX5 MIX1 INP1", "RX2", "SLIM RX2"},
2990 {"RX5 MIX1 INP1", "RX3", "SLIM RX3"},
2991 {"RX5 MIX1 INP1", "RX4", "SLIM RX4"},
2992 {"RX5 MIX1 INP1", "RX5", "SLIM RX5"},
2993 {"RX5 MIX1 INP1", "RX6", "SLIM RX6"},
2994 {"RX5 MIX1 INP1", "RX7", "SLIM RX7"},
2995 {"RX5 MIX1 INP1", "IIR1", "IIR1"},
2996 {"RX5 MIX1 INP2", "RX1", "SLIM RX1"},
2997 {"RX5 MIX1 INP2", "RX2", "SLIM RX2"},
2998 {"RX5 MIX1 INP2", "RX3", "SLIM RX3"},
2999 {"RX5 MIX1 INP2", "RX4", "SLIM RX4"},
3000 {"RX5 MIX1 INP2", "RX5", "SLIM RX5"},
3001 {"RX5 MIX1 INP2", "RX6", "SLIM RX6"},
3002 {"RX5 MIX1 INP2", "RX7", "SLIM RX7"},
3003 {"RX5 MIX1 INP2", "IIR1", "IIR1"},
3004 {"RX6 MIX1 INP1", "RX1", "SLIM RX1"},
3005 {"RX6 MIX1 INP1", "RX2", "SLIM RX2"},
3006 {"RX6 MIX1 INP1", "RX3", "SLIM RX3"},
3007 {"RX6 MIX1 INP1", "RX4", "SLIM RX4"},
3008 {"RX6 MIX1 INP1", "RX5", "SLIM RX5"},
3009 {"RX6 MIX1 INP1", "RX6", "SLIM RX6"},
3010 {"RX6 MIX1 INP1", "RX7", "SLIM RX7"},
3011 {"RX6 MIX1 INP1", "IIR1", "IIR1"},
3012 {"RX6 MIX1 INP2", "RX1", "SLIM RX1"},
3013 {"RX6 MIX1 INP2", "RX2", "SLIM RX2"},
3014 {"RX6 MIX1 INP2", "RX3", "SLIM RX3"},
3015 {"RX6 MIX1 INP2", "RX4", "SLIM RX4"},
3016 {"RX6 MIX1 INP2", "RX5", "SLIM RX5"},
3017 {"RX6 MIX1 INP2", "RX6", "SLIM RX6"},
3018 {"RX6 MIX1 INP2", "RX7", "SLIM RX7"},
3019 {"RX6 MIX1 INP2", "IIR1", "IIR1"},
3020 {"RX7 MIX1 INP1", "RX1", "SLIM RX1"},
3021 {"RX7 MIX1 INP1", "RX2", "SLIM RX2"},
3022 {"RX7 MIX1 INP1", "RX3", "SLIM RX3"},
3023 {"RX7 MIX1 INP1", "RX4", "SLIM RX4"},
3024 {"RX7 MIX1 INP1", "RX5", "SLIM RX5"},
3025 {"RX7 MIX1 INP1", "RX6", "SLIM RX6"},
3026 {"RX7 MIX1 INP1", "RX7", "SLIM RX7"},
3027 {"RX7 MIX1 INP1", "IIR1", "IIR1"},
3028 {"RX7 MIX1 INP2", "RX1", "SLIM RX1"},
3029 {"RX7 MIX1 INP2", "RX2", "SLIM RX2"},
3030 {"RX7 MIX1 INP2", "RX3", "SLIM RX3"},
3031 {"RX7 MIX1 INP2", "RX4", "SLIM RX4"},
3032 {"RX7 MIX1 INP2", "RX5", "SLIM RX5"},
3033 {"RX7 MIX1 INP2", "RX6", "SLIM RX6"},
3034 {"RX7 MIX1 INP2", "RX7", "SLIM RX7"},
3035 {"RX7 MIX1 INP2", "IIR1", "IIR1"},
3036 {"RX1 MIX2 INP1", "IIR1", "IIR1"},
3037 {"RX1 MIX2 INP2", "IIR1", "IIR1"},
3038 {"RX2 MIX2 INP1", "IIR1", "IIR1"},
3039 {"RX2 MIX2 INP2", "IIR1", "IIR1"},
3040 {"RX7 MIX2 INP1", "IIR1", "IIR1"},
3041 {"RX7 MIX2 INP2", "IIR1", "IIR1"},
3042
3043 /* Decimator Inputs */
3044 {"DEC1 MUX", "DMIC1", "DMIC1"},
3045 {"DEC1 MUX", "ADC6", "ADC6"},
3046 {"DEC1 MUX", NULL, "CDC_CONN"},
3047 {"DEC2 MUX", "DMIC2", "DMIC2"},
3048 {"DEC2 MUX", "ADC5", "ADC5"},
3049 {"DEC2 MUX", NULL, "CDC_CONN"},
3050 {"DEC3 MUX", "DMIC3", "DMIC3"},
3051 {"DEC3 MUX", "ADC4", "ADC4"},
3052 {"DEC3 MUX", NULL, "CDC_CONN"},
3053 {"DEC4 MUX", "DMIC4", "DMIC4"},
3054 {"DEC4 MUX", "ADC3", "ADC3"},
3055 {"DEC4 MUX", NULL, "CDC_CONN"},
3056 {"DEC5 MUX", "DMIC5", "DMIC5"},
3057 {"DEC5 MUX", "ADC2", "ADC2"},
3058 {"DEC5 MUX", NULL, "CDC_CONN"},
3059 {"DEC6 MUX", "DMIC6", "DMIC6"},
3060 {"DEC6 MUX", "ADC1", "ADC1"},
3061 {"DEC6 MUX", NULL, "CDC_CONN"},
3062 {"DEC7 MUX", "DMIC1", "DMIC1"},
3063 {"DEC7 MUX", "DMIC6", "DMIC6"},
3064 {"DEC7 MUX", "ADC1", "ADC1"},
3065 {"DEC7 MUX", "ADC6", "ADC6"},
3066 {"DEC7 MUX", NULL, "CDC_CONN"},
3067 {"DEC8 MUX", "DMIC2", "DMIC2"},
3068 {"DEC8 MUX", "DMIC5", "DMIC5"},
3069 {"DEC8 MUX", "ADC2", "ADC2"},
3070 {"DEC8 MUX", "ADC5", "ADC5"},
3071 {"DEC8 MUX", NULL, "CDC_CONN"},
3072 {"DEC9 MUX", "DMIC4", "DMIC4"},
3073 {"DEC9 MUX", "DMIC5", "DMIC5"},
3074 {"DEC9 MUX", "ADC2", "ADC2"},
3075 {"DEC9 MUX", "ADC3", "ADC3"},
3076 {"DEC9 MUX", NULL, "CDC_CONN"},
3077 {"DEC10 MUX", "DMIC3", "DMIC3"},
3078 {"DEC10 MUX", "DMIC6", "DMIC6"},
3079 {"DEC10 MUX", "ADC1", "ADC1"},
3080 {"DEC10 MUX", "ADC4", "ADC4"},
3081 {"DEC10 MUX", NULL, "CDC_CONN"},
3082
3083 /* ADC Connections */
3084 {"ADC1", NULL, "AMIC1"},
3085 {"ADC2", NULL, "AMIC2"},
3086 {"ADC3", NULL, "AMIC3"},
3087 {"ADC4", NULL, "AMIC4"},
3088 {"ADC5", NULL, "AMIC5"},
3089 {"ADC6", NULL, "AMIC6"},
3090
3091 /* AUX PGA Connections */
Kiran Kandic3b24402012-06-11 00:05:59 -07003092 {"EAR_PA_MIXER", "AUX_PGA_L Switch", "AUX_PGA_Left"},
Kiran Kandi4c56c592012-07-25 11:04:55 -07003093 {"HPHL_PA_MIXER", "AUX_PGA_L Switch", "AUX_PGA_Left"},
3094 {"HPHR_PA_MIXER", "AUX_PGA_R Switch", "AUX_PGA_Right"},
3095 {"LINEOUT1_PA_MIXER", "AUX_PGA_L Switch", "AUX_PGA_Left"},
3096 {"LINEOUT2_PA_MIXER", "AUX_PGA_R Switch", "AUX_PGA_Right"},
3097 {"LINEOUT3_PA_MIXER", "AUX_PGA_L Switch", "AUX_PGA_Left"},
3098 {"LINEOUT4_PA_MIXER", "AUX_PGA_R Switch", "AUX_PGA_Right"},
Kiran Kandic3b24402012-06-11 00:05:59 -07003099 {"AUX_PGA_Left", NULL, "AMIC5"},
3100 {"AUX_PGA_Right", NULL, "AMIC6"},
3101
Kiran Kandic3b24402012-06-11 00:05:59 -07003102 {"IIR1", NULL, "IIR1 INP1 MUX"},
3103 {"IIR1 INP1 MUX", "DEC1", "DEC1 MUX"},
3104 {"IIR1 INP1 MUX", "DEC2", "DEC2 MUX"},
3105 {"IIR1 INP1 MUX", "DEC3", "DEC3 MUX"},
3106 {"IIR1 INP1 MUX", "DEC4", "DEC4 MUX"},
3107 {"IIR1 INP1 MUX", "DEC5", "DEC5 MUX"},
3108 {"IIR1 INP1 MUX", "DEC6", "DEC6 MUX"},
3109 {"IIR1 INP1 MUX", "DEC7", "DEC7 MUX"},
3110 {"IIR1 INP1 MUX", "DEC8", "DEC8 MUX"},
3111 {"IIR1 INP1 MUX", "DEC9", "DEC9 MUX"},
3112 {"IIR1 INP1 MUX", "DEC10", "DEC10 MUX"},
3113
3114 {"MIC BIAS1 Internal1", NULL, "LDO_H"},
3115 {"MIC BIAS1 Internal2", NULL, "LDO_H"},
3116 {"MIC BIAS1 External", NULL, "LDO_H"},
3117 {"MIC BIAS2 Internal1", NULL, "LDO_H"},
3118 {"MIC BIAS2 Internal2", NULL, "LDO_H"},
3119 {"MIC BIAS2 Internal3", NULL, "LDO_H"},
3120 {"MIC BIAS2 External", NULL, "LDO_H"},
3121 {"MIC BIAS3 Internal1", NULL, "LDO_H"},
3122 {"MIC BIAS3 Internal2", NULL, "LDO_H"},
3123 {"MIC BIAS3 External", NULL, "LDO_H"},
3124 {"MIC BIAS4 External", NULL, "LDO_H"},
3125};
3126
3127static int taiko_readable(struct snd_soc_codec *ssc, unsigned int reg)
3128{
3129 return taiko_reg_readable[reg];
3130}
3131
3132static bool taiko_is_digital_gain_register(unsigned int reg)
3133{
3134 bool rtn = false;
3135 switch (reg) {
3136 case TAIKO_A_CDC_RX1_VOL_CTL_B2_CTL:
3137 case TAIKO_A_CDC_RX2_VOL_CTL_B2_CTL:
3138 case TAIKO_A_CDC_RX3_VOL_CTL_B2_CTL:
3139 case TAIKO_A_CDC_RX4_VOL_CTL_B2_CTL:
3140 case TAIKO_A_CDC_RX5_VOL_CTL_B2_CTL:
3141 case TAIKO_A_CDC_RX6_VOL_CTL_B2_CTL:
3142 case TAIKO_A_CDC_RX7_VOL_CTL_B2_CTL:
3143 case TAIKO_A_CDC_TX1_VOL_CTL_GAIN:
3144 case TAIKO_A_CDC_TX2_VOL_CTL_GAIN:
3145 case TAIKO_A_CDC_TX3_VOL_CTL_GAIN:
3146 case TAIKO_A_CDC_TX4_VOL_CTL_GAIN:
3147 case TAIKO_A_CDC_TX5_VOL_CTL_GAIN:
3148 case TAIKO_A_CDC_TX6_VOL_CTL_GAIN:
3149 case TAIKO_A_CDC_TX7_VOL_CTL_GAIN:
3150 case TAIKO_A_CDC_TX8_VOL_CTL_GAIN:
3151 case TAIKO_A_CDC_TX9_VOL_CTL_GAIN:
3152 case TAIKO_A_CDC_TX10_VOL_CTL_GAIN:
3153 rtn = true;
3154 break;
3155 default:
3156 break;
3157 }
3158 return rtn;
3159}
3160
3161static int taiko_volatile(struct snd_soc_codec *ssc, unsigned int reg)
3162{
3163 /* Registers lower than 0x100 are top level registers which can be
3164 * written by the Taiko core driver.
3165 */
3166
3167 if ((reg >= TAIKO_A_CDC_MBHC_EN_CTL) || (reg < 0x100))
3168 return 1;
3169
3170 /* IIR Coeff registers are not cacheable */
3171 if ((reg >= TAIKO_A_CDC_IIR1_COEF_B1_CTL) &&
3172 (reg <= TAIKO_A_CDC_IIR2_COEF_B2_CTL))
3173 return 1;
3174
3175 /* Digital gain register is not cacheable so we have to write
3176 * the setting even it is the same
3177 */
3178 if (taiko_is_digital_gain_register(reg))
3179 return 1;
3180
3181 /* HPH status registers */
3182 if (reg == TAIKO_A_RX_HPH_L_STATUS || reg == TAIKO_A_RX_HPH_R_STATUS)
3183 return 1;
3184
Joonwoo Parka8890262012-10-15 12:04:27 -07003185 if (reg == TAIKO_A_MBHC_INSERT_DET_STATUS)
3186 return 1;
3187
Joonwoo Park559a5bf2013-02-15 14:46:36 -08003188 switch (reg) {
3189 case TAIKO_A_CDC_SPKR_CLIPDET_VAL0:
3190 case TAIKO_A_CDC_SPKR_CLIPDET_VAL1:
3191 case TAIKO_A_CDC_SPKR_CLIPDET_VAL2:
3192 case TAIKO_A_CDC_SPKR_CLIPDET_VAL3:
3193 case TAIKO_A_CDC_SPKR_CLIPDET_VAL4:
3194 case TAIKO_A_CDC_SPKR_CLIPDET_VAL5:
3195 case TAIKO_A_CDC_SPKR_CLIPDET_VAL6:
3196 case TAIKO_A_CDC_SPKR_CLIPDET_VAL7:
3197 case TAIKO_A_CDC_VBAT_GAIN_MON_VAL:
3198 return 1;
3199 }
3200
Kiran Kandic3b24402012-06-11 00:05:59 -07003201 return 0;
3202}
3203
Kiran Kandic3b24402012-06-11 00:05:59 -07003204static int taiko_write(struct snd_soc_codec *codec, unsigned int reg,
3205 unsigned int value)
3206{
3207 int ret;
Kuirong Wang906ac472012-07-09 12:54:44 -07003208
3209 if (reg == SND_SOC_NOPM)
3210 return 0;
3211
Kiran Kandic3b24402012-06-11 00:05:59 -07003212 BUG_ON(reg > TAIKO_MAX_REGISTER);
3213
3214 if (!taiko_volatile(codec, reg)) {
3215 ret = snd_soc_cache_write(codec, reg, value);
3216 if (ret != 0)
3217 dev_err(codec->dev, "Cache write to %x failed: %d\n",
3218 reg, ret);
3219 }
3220
3221 return wcd9xxx_reg_write(codec->control_data, reg, value);
3222}
3223static unsigned int taiko_read(struct snd_soc_codec *codec,
3224 unsigned int reg)
3225{
3226 unsigned int val;
3227 int ret;
3228
Kuirong Wang906ac472012-07-09 12:54:44 -07003229 if (reg == SND_SOC_NOPM)
3230 return 0;
3231
Kiran Kandic3b24402012-06-11 00:05:59 -07003232 BUG_ON(reg > TAIKO_MAX_REGISTER);
3233
3234 if (!taiko_volatile(codec, reg) && taiko_readable(codec, reg) &&
3235 reg < codec->driver->reg_cache_size) {
3236 ret = snd_soc_cache_read(codec, reg, &val);
3237 if (ret >= 0) {
3238 return val;
3239 } else
3240 dev_err(codec->dev, "Cache read from %x failed: %d\n",
3241 reg, ret);
3242 }
3243
3244 val = wcd9xxx_reg_read(codec->control_data, reg);
3245 return val;
3246}
3247
Kiran Kandic3b24402012-06-11 00:05:59 -07003248static int taiko_startup(struct snd_pcm_substream *substream,
3249 struct snd_soc_dai *dai)
3250{
3251 struct wcd9xxx *taiko_core = dev_get_drvdata(dai->codec->dev->parent);
3252 pr_debug("%s(): substream = %s stream = %d\n" , __func__,
3253 substream->name, substream->stream);
3254 if ((taiko_core != NULL) &&
3255 (taiko_core->dev != NULL) &&
3256 (taiko_core->dev->parent != NULL))
3257 pm_runtime_get_sync(taiko_core->dev->parent);
3258
3259 return 0;
3260}
3261
3262static void taiko_shutdown(struct snd_pcm_substream *substream,
3263 struct snd_soc_dai *dai)
3264{
3265 struct wcd9xxx *taiko_core = dev_get_drvdata(dai->codec->dev->parent);
3266 pr_debug("%s(): substream = %s stream = %d\n" , __func__,
3267 substream->name, substream->stream);
3268 if ((taiko_core != NULL) &&
3269 (taiko_core->dev != NULL) &&
3270 (taiko_core->dev->parent != NULL)) {
3271 pm_runtime_mark_last_busy(taiko_core->dev->parent);
3272 pm_runtime_put(taiko_core->dev->parent);
3273 }
3274}
3275
3276int taiko_mclk_enable(struct snd_soc_codec *codec, int mclk_enable, bool dapm)
3277{
3278 struct taiko_priv *taiko = snd_soc_codec_get_drvdata(codec);
3279
3280 pr_debug("%s: mclk_enable = %u, dapm = %d\n", __func__, mclk_enable,
3281 dapm);
Joonwoo Parka8890262012-10-15 12:04:27 -07003282
3283 WCD9XXX_BCL_LOCK(&taiko->resmgr);
Kiran Kandic3b24402012-06-11 00:05:59 -07003284 if (mclk_enable) {
Joonwoo Parka8890262012-10-15 12:04:27 -07003285 wcd9xxx_resmgr_get_bandgap(&taiko->resmgr,
3286 WCD9XXX_BANDGAP_AUDIO_MODE);
3287 wcd9xxx_resmgr_get_clk_block(&taiko->resmgr, WCD9XXX_CLK_MCLK);
Kiran Kandic3b24402012-06-11 00:05:59 -07003288 } else {
Joonwoo Parka8890262012-10-15 12:04:27 -07003289 /* Put clock and BG */
3290 wcd9xxx_resmgr_put_clk_block(&taiko->resmgr, WCD9XXX_CLK_MCLK);
3291 wcd9xxx_resmgr_put_bandgap(&taiko->resmgr,
3292 WCD9XXX_BANDGAP_AUDIO_MODE);
Kiran Kandic3b24402012-06-11 00:05:59 -07003293 }
Joonwoo Parka8890262012-10-15 12:04:27 -07003294 WCD9XXX_BCL_UNLOCK(&taiko->resmgr);
3295
Kiran Kandic3b24402012-06-11 00:05:59 -07003296 return 0;
3297}
3298
3299static int taiko_set_dai_sysclk(struct snd_soc_dai *dai,
3300 int clk_id, unsigned int freq, int dir)
3301{
Venkat Sudhira50a3762012-11-26 12:12:15 -08003302 pr_debug("%s\n", __func__);
Kiran Kandic3b24402012-06-11 00:05:59 -07003303 return 0;
3304}
3305
3306static int taiko_set_dai_fmt(struct snd_soc_dai *dai, unsigned int fmt)
3307{
3308 u8 val = 0;
3309 struct taiko_priv *taiko = snd_soc_codec_get_drvdata(dai->codec);
3310
3311 pr_debug("%s\n", __func__);
3312 switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) {
3313 case SND_SOC_DAIFMT_CBS_CFS:
3314 /* CPU is master */
3315 if (taiko->intf_type == WCD9XXX_INTERFACE_TYPE_I2C) {
3316 if (dai->id == AIF1_CAP)
3317 snd_soc_update_bits(dai->codec,
3318 TAIKO_A_CDC_CLK_TX_I2S_CTL,
3319 TAIKO_I2S_MASTER_MODE_MASK, 0);
3320 else if (dai->id == AIF1_PB)
3321 snd_soc_update_bits(dai->codec,
3322 TAIKO_A_CDC_CLK_RX_I2S_CTL,
3323 TAIKO_I2S_MASTER_MODE_MASK, 0);
3324 }
3325 break;
3326 case SND_SOC_DAIFMT_CBM_CFM:
3327 /* CPU is slave */
3328 if (taiko->intf_type == WCD9XXX_INTERFACE_TYPE_I2C) {
3329 val = TAIKO_I2S_MASTER_MODE_MASK;
3330 if (dai->id == AIF1_CAP)
3331 snd_soc_update_bits(dai->codec,
3332 TAIKO_A_CDC_CLK_TX_I2S_CTL, val, val);
3333 else if (dai->id == AIF1_PB)
3334 snd_soc_update_bits(dai->codec,
3335 TAIKO_A_CDC_CLK_RX_I2S_CTL, val, val);
3336 }
3337 break;
3338 default:
3339 return -EINVAL;
3340 }
3341 return 0;
3342}
3343
3344static int taiko_set_channel_map(struct snd_soc_dai *dai,
3345 unsigned int tx_num, unsigned int *tx_slot,
3346 unsigned int rx_num, unsigned int *rx_slot)
3347
3348{
3349 struct taiko_priv *taiko = snd_soc_codec_get_drvdata(dai->codec);
Kuirong Wang906ac472012-07-09 12:54:44 -07003350 struct wcd9xxx *core = dev_get_drvdata(dai->codec->dev->parent);
Kiran Kandic3b24402012-06-11 00:05:59 -07003351 if (!tx_slot && !rx_slot) {
3352 pr_err("%s: Invalid\n", __func__);
3353 return -EINVAL;
3354 }
Kuirong Wang906ac472012-07-09 12:54:44 -07003355 pr_debug("%s(): dai_name = %s DAI-ID %x tx_ch %d rx_ch %d\n"
3356 "taiko->intf_type %d\n",
3357 __func__, dai->name, dai->id, tx_num, rx_num,
3358 taiko->intf_type);
Kiran Kandic3b24402012-06-11 00:05:59 -07003359
Kuirong Wang906ac472012-07-09 12:54:44 -07003360 if (taiko->intf_type == WCD9XXX_INTERFACE_TYPE_SLIMBUS)
3361 wcd9xxx_init_slimslave(core, core->slim->laddr,
3362 tx_num, tx_slot, rx_num, rx_slot);
3363 return 0;
3364}
3365
3366static int taiko_get_channel_map(struct snd_soc_dai *dai,
3367 unsigned int *tx_num, unsigned int *tx_slot,
3368 unsigned int *rx_num, unsigned int *rx_slot)
3369
3370{
3371 struct taiko_priv *taiko_p = snd_soc_codec_get_drvdata(dai->codec);
3372 u32 i = 0;
3373 struct wcd9xxx_ch *ch;
3374
3375 switch (dai->id) {
3376 case AIF1_PB:
3377 case AIF2_PB:
3378 case AIF3_PB:
3379 if (!rx_slot || !rx_num) {
3380 pr_err("%s: Invalid rx_slot %d or rx_num %d\n",
3381 __func__, (u32) rx_slot, (u32) rx_num);
3382 return -EINVAL;
Kiran Kandic3b24402012-06-11 00:05:59 -07003383 }
Kuirong Wang906ac472012-07-09 12:54:44 -07003384 list_for_each_entry(ch, &taiko_p->dai[dai->id].wcd9xxx_ch_list,
3385 list) {
Gopikrishnaiah Anandana8aec1f2013-01-23 14:26:27 -05003386 pr_debug("%s: slot_num %u ch->ch_num %d\n",
3387 __func__, i, ch->ch_num);
Kuirong Wang906ac472012-07-09 12:54:44 -07003388 rx_slot[i++] = ch->ch_num;
3389 }
3390 pr_debug("%s: rx_num %d\n", __func__, i);
3391 *rx_num = i;
3392 break;
3393 case AIF1_CAP:
3394 case AIF2_CAP:
3395 case AIF3_CAP:
3396 if (!tx_slot || !tx_num) {
3397 pr_err("%s: Invalid tx_slot %d or tx_num %d\n",
3398 __func__, (u32) tx_slot, (u32) tx_num);
3399 return -EINVAL;
3400 }
3401 list_for_each_entry(ch, &taiko_p->dai[dai->id].wcd9xxx_ch_list,
3402 list) {
Gopikrishnaiah Anandana8aec1f2013-01-23 14:26:27 -05003403 pr_debug("%s: slot_num %u ch->ch_num %d\n",
3404 __func__, i, ch->ch_num);
Kuirong Wang906ac472012-07-09 12:54:44 -07003405 tx_slot[i++] = ch->ch_num;
3406 }
3407 pr_debug("%s: tx_num %d\n", __func__, i);
3408 *tx_num = i;
3409 break;
3410
3411 default:
3412 pr_err("%s: Invalid DAI ID %x\n", __func__, dai->id);
3413 break;
3414 }
3415
3416 return 0;
3417}
3418
3419static int taiko_set_interpolator_rate(struct snd_soc_dai *dai,
3420 u8 rx_fs_rate_reg_val, u32 compander_fs, u32 sample_rate)
3421{
3422 u32 j;
3423 u8 rx_mix1_inp;
3424 u16 rx_mix_1_reg_1, rx_mix_1_reg_2;
3425 u16 rx_fs_reg;
3426 u8 rx_mix_1_reg_1_val, rx_mix_1_reg_2_val;
3427 struct snd_soc_codec *codec = dai->codec;
3428 struct wcd9xxx_ch *ch;
3429 struct taiko_priv *taiko = snd_soc_codec_get_drvdata(codec);
3430
3431 list_for_each_entry(ch, &taiko->dai[dai->id].wcd9xxx_ch_list, list) {
3432 /* for RX port starting from 16 instead of 10 like tabla */
3433 rx_mix1_inp = ch->port + RX_MIX1_INP_SEL_RX1 -
3434 TAIKO_TX_PORT_NUMBER;
3435 if ((rx_mix1_inp < RX_MIX1_INP_SEL_RX1) ||
3436 (rx_mix1_inp > RX_MIX1_INP_SEL_RX7)) {
3437 pr_err("%s: Invalid TAIKO_RX%u port. Dai ID is %d\n",
3438 __func__, rx_mix1_inp - 5 , dai->id);
3439 return -EINVAL;
3440 }
3441
3442 rx_mix_1_reg_1 = TAIKO_A_CDC_CONN_RX1_B1_CTL;
3443
3444 for (j = 0; j < NUM_INTERPOLATORS; j++) {
3445 rx_mix_1_reg_2 = rx_mix_1_reg_1 + 1;
3446
3447 rx_mix_1_reg_1_val = snd_soc_read(codec,
3448 rx_mix_1_reg_1);
3449 rx_mix_1_reg_2_val = snd_soc_read(codec,
3450 rx_mix_1_reg_2);
3451
3452 if (((rx_mix_1_reg_1_val & 0x0F) == rx_mix1_inp) ||
3453 (((rx_mix_1_reg_1_val >> 4) & 0x0F)
3454 == rx_mix1_inp) ||
3455 ((rx_mix_1_reg_2_val & 0x0F) == rx_mix1_inp)) {
3456
3457 rx_fs_reg = TAIKO_A_CDC_RX1_B5_CTL + 8 * j;
3458
3459 pr_debug("%s: AIF_PB DAI(%d) connected to RX%u\n",
3460 __func__, dai->id, j + 1);
3461
3462 pr_debug("%s: set RX%u sample rate to %u\n",
3463 __func__, j + 1, sample_rate);
3464
3465 snd_soc_update_bits(codec, rx_fs_reg,
3466 0xE0, rx_fs_rate_reg_val);
3467
3468 if (comp_rx_path[j] < COMPANDER_MAX)
3469 taiko->comp_fs[comp_rx_path[j]]
3470 = compander_fs;
3471 }
3472 if (j <= 2)
3473 rx_mix_1_reg_1 += 3;
3474 else
3475 rx_mix_1_reg_1 += 2;
Kiran Kandic3b24402012-06-11 00:05:59 -07003476 }
3477 }
3478 return 0;
3479}
3480
Kuirong Wang906ac472012-07-09 12:54:44 -07003481static int taiko_set_decimator_rate(struct snd_soc_dai *dai,
3482 u8 tx_fs_rate_reg_val, u32 sample_rate)
Kiran Kandic3b24402012-06-11 00:05:59 -07003483{
Kuirong Wang906ac472012-07-09 12:54:44 -07003484 struct snd_soc_codec *codec = dai->codec;
3485 struct wcd9xxx_ch *ch;
3486 struct taiko_priv *taiko = snd_soc_codec_get_drvdata(codec);
3487 u32 tx_port;
3488 u16 tx_port_reg, tx_fs_reg;
3489 u8 tx_port_reg_val;
3490 s8 decimator;
Kiran Kandic3b24402012-06-11 00:05:59 -07003491
Kuirong Wang906ac472012-07-09 12:54:44 -07003492 list_for_each_entry(ch, &taiko->dai[dai->id].wcd9xxx_ch_list, list) {
Kiran Kandic3b24402012-06-11 00:05:59 -07003493
Kuirong Wang906ac472012-07-09 12:54:44 -07003494 tx_port = ch->port + 1;
3495 pr_debug("%s: dai->id = %d, tx_port = %d",
3496 __func__, dai->id, tx_port);
3497
3498 if ((tx_port < 1) || (tx_port > NUM_DECIMATORS)) {
3499 pr_err("%s: Invalid SLIM TX%u port. DAI ID is %d\n",
3500 __func__, tx_port, dai->id);
3501 return -EINVAL;
3502 }
3503
3504 tx_port_reg = TAIKO_A_CDC_CONN_TX_SB_B1_CTL + (tx_port - 1);
3505 tx_port_reg_val = snd_soc_read(codec, tx_port_reg);
3506
3507 decimator = 0;
3508
3509 if ((tx_port >= 1) && (tx_port <= 6)) {
3510
3511 tx_port_reg_val = tx_port_reg_val & 0x0F;
3512 if (tx_port_reg_val == 0x8)
3513 decimator = tx_port;
3514
3515 } else if ((tx_port >= 7) && (tx_port <= NUM_DECIMATORS)) {
3516
3517 tx_port_reg_val = tx_port_reg_val & 0x1F;
3518
3519 if ((tx_port_reg_val >= 0x8) &&
3520 (tx_port_reg_val <= 0x11)) {
3521
3522 decimator = (tx_port_reg_val - 0x8) + 1;
3523 }
3524 }
3525
3526 if (decimator) { /* SLIM_TX port has a DEC as input */
3527
3528 tx_fs_reg = TAIKO_A_CDC_TX1_CLK_FS_CTL +
3529 8 * (decimator - 1);
3530
3531 pr_debug("%s: set DEC%u (-> SLIM_TX%u) rate to %u\n",
3532 __func__, decimator, tx_port, sample_rate);
3533
3534 snd_soc_update_bits(codec, tx_fs_reg, 0x07,
3535 tx_fs_rate_reg_val);
3536
3537 } else {
3538 if ((tx_port_reg_val >= 0x1) &&
3539 (tx_port_reg_val <= 0x7)) {
3540
3541 pr_debug("%s: RMIX%u going to SLIM TX%u\n",
3542 __func__, tx_port_reg_val, tx_port);
3543
3544 } else if ((tx_port_reg_val >= 0x8) &&
3545 (tx_port_reg_val <= 0x11)) {
3546
3547 pr_err("%s: ERROR: Should not be here\n",
3548 __func__);
3549 pr_err("%s: ERROR: DEC connected to SLIM TX%u\n",
3550 __func__, tx_port);
3551 return -EINVAL;
3552
3553 } else if (tx_port_reg_val == 0) {
3554 pr_debug("%s: no signal to SLIM TX%u\n",
3555 __func__, tx_port);
3556 } else {
3557 pr_err("%s: ERROR: wrong signal to SLIM TX%u\n",
3558 __func__, tx_port);
3559 pr_err("%s: ERROR: wrong signal = %u\n",
3560 __func__, tx_port_reg_val);
3561 return -EINVAL;
3562 }
3563 }
Kiran Kandic3b24402012-06-11 00:05:59 -07003564 }
Kiran Kandic3b24402012-06-11 00:05:59 -07003565 return 0;
3566}
3567
3568static int taiko_hw_params(struct snd_pcm_substream *substream,
3569 struct snd_pcm_hw_params *params,
3570 struct snd_soc_dai *dai)
3571{
3572 struct snd_soc_codec *codec = dai->codec;
3573 struct taiko_priv *taiko = snd_soc_codec_get_drvdata(dai->codec);
Kuirong Wang906ac472012-07-09 12:54:44 -07003574 u8 tx_fs_rate, rx_fs_rate;
Kiran Kandic3b24402012-06-11 00:05:59 -07003575 u32 compander_fs;
Kuirong Wang906ac472012-07-09 12:54:44 -07003576 int ret;
Kiran Kandic3b24402012-06-11 00:05:59 -07003577
3578 pr_debug("%s: dai_name = %s DAI-ID %x rate %d num_ch %d\n", __func__,
3579 dai->name, dai->id, params_rate(params),
3580 params_channels(params));
3581
3582 switch (params_rate(params)) {
3583 case 8000:
3584 tx_fs_rate = 0x00;
3585 rx_fs_rate = 0x00;
3586 compander_fs = COMPANDER_FS_8KHZ;
3587 break;
3588 case 16000:
3589 tx_fs_rate = 0x01;
3590 rx_fs_rate = 0x20;
3591 compander_fs = COMPANDER_FS_16KHZ;
3592 break;
3593 case 32000:
3594 tx_fs_rate = 0x02;
3595 rx_fs_rate = 0x40;
3596 compander_fs = COMPANDER_FS_32KHZ;
3597 break;
3598 case 48000:
3599 tx_fs_rate = 0x03;
3600 rx_fs_rate = 0x60;
3601 compander_fs = COMPANDER_FS_48KHZ;
3602 break;
3603 case 96000:
3604 tx_fs_rate = 0x04;
3605 rx_fs_rate = 0x80;
3606 compander_fs = COMPANDER_FS_96KHZ;
3607 break;
3608 case 192000:
3609 tx_fs_rate = 0x05;
3610 rx_fs_rate = 0xA0;
3611 compander_fs = COMPANDER_FS_192KHZ;
3612 break;
3613 default:
3614 pr_err("%s: Invalid sampling rate %d\n", __func__,
Kuirong Wang906ac472012-07-09 12:54:44 -07003615 params_rate(params));
Kiran Kandic3b24402012-06-11 00:05:59 -07003616 return -EINVAL;
3617 }
3618
Kuirong Wang906ac472012-07-09 12:54:44 -07003619 switch (substream->stream) {
3620 case SNDRV_PCM_STREAM_CAPTURE:
3621 ret = taiko_set_decimator_rate(dai, tx_fs_rate,
3622 params_rate(params));
3623 if (ret < 0) {
3624 pr_err("%s: set decimator rate failed %d\n", __func__,
3625 ret);
3626 return ret;
Kiran Kandic3b24402012-06-11 00:05:59 -07003627 }
Kuirong Wang906ac472012-07-09 12:54:44 -07003628
Kiran Kandic3b24402012-06-11 00:05:59 -07003629 if (taiko->intf_type == WCD9XXX_INTERFACE_TYPE_I2C) {
3630 switch (params_format(params)) {
3631 case SNDRV_PCM_FORMAT_S16_LE:
3632 snd_soc_update_bits(codec,
3633 TAIKO_A_CDC_CLK_TX_I2S_CTL,
3634 0x20, 0x20);
3635 break;
3636 case SNDRV_PCM_FORMAT_S32_LE:
3637 snd_soc_update_bits(codec,
3638 TAIKO_A_CDC_CLK_TX_I2S_CTL,
3639 0x20, 0x00);
3640 break;
3641 default:
3642 pr_err("invalid format\n");
3643 break;
3644 }
3645 snd_soc_update_bits(codec, TAIKO_A_CDC_CLK_TX_I2S_CTL,
Kuirong Wang906ac472012-07-09 12:54:44 -07003646 0x07, tx_fs_rate);
Kiran Kandic3b24402012-06-11 00:05:59 -07003647 } else {
Kuirong Wang906ac472012-07-09 12:54:44 -07003648 taiko->dai[dai->id].rate = params_rate(params);
Kiran Kandic3b24402012-06-11 00:05:59 -07003649 }
Kuirong Wang906ac472012-07-09 12:54:44 -07003650 break;
Kiran Kandic3b24402012-06-11 00:05:59 -07003651
Kuirong Wang906ac472012-07-09 12:54:44 -07003652 case SNDRV_PCM_STREAM_PLAYBACK:
3653 ret = taiko_set_interpolator_rate(dai, rx_fs_rate,
3654 compander_fs,
3655 params_rate(params));
3656 if (ret < 0) {
3657 pr_err("%s: set decimator rate failed %d\n", __func__,
3658 ret);
3659 return ret;
Kiran Kandic3b24402012-06-11 00:05:59 -07003660 }
3661 if (taiko->intf_type == WCD9XXX_INTERFACE_TYPE_I2C) {
3662 switch (params_format(params)) {
3663 case SNDRV_PCM_FORMAT_S16_LE:
3664 snd_soc_update_bits(codec,
3665 TAIKO_A_CDC_CLK_RX_I2S_CTL,
3666 0x20, 0x20);
3667 break;
3668 case SNDRV_PCM_FORMAT_S32_LE:
3669 snd_soc_update_bits(codec,
3670 TAIKO_A_CDC_CLK_RX_I2S_CTL,
3671 0x20, 0x00);
3672 break;
3673 default:
3674 pr_err("invalid format\n");
3675 break;
3676 }
3677 snd_soc_update_bits(codec, TAIKO_A_CDC_CLK_RX_I2S_CTL,
Kuirong Wang906ac472012-07-09 12:54:44 -07003678 0x03, (rx_fs_rate >> 0x05));
Kiran Kandic3b24402012-06-11 00:05:59 -07003679 } else {
Bhalchandra Gajare5b40c532013-02-19 13:36:47 -08003680 switch (params_format(params)) {
3681 case SNDRV_PCM_FORMAT_S16_LE:
3682 snd_soc_update_bits(codec,
3683 TAIKO_A_CDC_CONN_RX_SB_B1_CTL,
3684 0xFF, 0xAA);
3685 snd_soc_update_bits(codec,
3686 TAIKO_A_CDC_CONN_RX_SB_B2_CTL,
3687 0xFF, 0x2A);
3688 taiko->dai[dai->id].bit_width = 16;
3689 break;
3690 case SNDRV_PCM_FORMAT_S24_LE:
3691 snd_soc_update_bits(codec,
3692 TAIKO_A_CDC_CONN_RX_SB_B1_CTL,
3693 0xFF, 0x00);
3694 snd_soc_update_bits(codec,
3695 TAIKO_A_CDC_CONN_RX_SB_B2_CTL,
3696 0xFF, 0x00);
3697 taiko->dai[dai->id].bit_width = 24;
3698 break;
3699 default:
3700 dev_err(codec->dev, "Invalid format\n");
3701 break;
3702 }
Kuirong Wang906ac472012-07-09 12:54:44 -07003703 taiko->dai[dai->id].rate = params_rate(params);
Kiran Kandic3b24402012-06-11 00:05:59 -07003704 }
Kuirong Wang906ac472012-07-09 12:54:44 -07003705 break;
3706 default:
3707 pr_err("%s: Invalid stream type %d\n", __func__,
3708 substream->stream);
3709 return -EINVAL;
Kiran Kandic3b24402012-06-11 00:05:59 -07003710 }
3711
3712 return 0;
3713}
3714
3715static struct snd_soc_dai_ops taiko_dai_ops = {
3716 .startup = taiko_startup,
3717 .shutdown = taiko_shutdown,
3718 .hw_params = taiko_hw_params,
3719 .set_sysclk = taiko_set_dai_sysclk,
3720 .set_fmt = taiko_set_dai_fmt,
3721 .set_channel_map = taiko_set_channel_map,
3722 .get_channel_map = taiko_get_channel_map,
3723};
3724
3725static struct snd_soc_dai_driver taiko_dai[] = {
3726 {
3727 .name = "taiko_rx1",
3728 .id = AIF1_PB,
3729 .playback = {
3730 .stream_name = "AIF1 Playback",
3731 .rates = WCD9320_RATES,
Bhalchandra Gajare5b40c532013-02-19 13:36:47 -08003732 .formats = TAIKO_FORMATS_S16_S24_LE,
Kiran Kandic3b24402012-06-11 00:05:59 -07003733 .rate_max = 192000,
3734 .rate_min = 8000,
3735 .channels_min = 1,
3736 .channels_max = 2,
3737 },
3738 .ops = &taiko_dai_ops,
3739 },
3740 {
3741 .name = "taiko_tx1",
3742 .id = AIF1_CAP,
3743 .capture = {
3744 .stream_name = "AIF1 Capture",
3745 .rates = WCD9320_RATES,
3746 .formats = TAIKO_FORMATS,
3747 .rate_max = 192000,
3748 .rate_min = 8000,
3749 .channels_min = 1,
3750 .channels_max = 4,
3751 },
3752 .ops = &taiko_dai_ops,
3753 },
3754 {
3755 .name = "taiko_rx2",
3756 .id = AIF2_PB,
3757 .playback = {
3758 .stream_name = "AIF2 Playback",
3759 .rates = WCD9320_RATES,
Bhalchandra Gajare5b40c532013-02-19 13:36:47 -08003760 .formats = TAIKO_FORMATS_S16_S24_LE,
Kiran Kandic3b24402012-06-11 00:05:59 -07003761 .rate_min = 8000,
3762 .rate_max = 192000,
3763 .channels_min = 1,
3764 .channels_max = 2,
3765 },
3766 .ops = &taiko_dai_ops,
3767 },
3768 {
3769 .name = "taiko_tx2",
3770 .id = AIF2_CAP,
3771 .capture = {
3772 .stream_name = "AIF2 Capture",
3773 .rates = WCD9320_RATES,
3774 .formats = TAIKO_FORMATS,
3775 .rate_max = 192000,
3776 .rate_min = 8000,
3777 .channels_min = 1,
3778 .channels_max = 4,
3779 },
3780 .ops = &taiko_dai_ops,
3781 },
3782 {
3783 .name = "taiko_tx3",
3784 .id = AIF3_CAP,
3785 .capture = {
3786 .stream_name = "AIF3 Capture",
3787 .rates = WCD9320_RATES,
3788 .formats = TAIKO_FORMATS,
3789 .rate_max = 48000,
3790 .rate_min = 8000,
3791 .channels_min = 1,
3792 .channels_max = 2,
3793 },
3794 .ops = &taiko_dai_ops,
3795 },
3796 {
3797 .name = "taiko_rx3",
3798 .id = AIF3_PB,
3799 .playback = {
3800 .stream_name = "AIF3 Playback",
3801 .rates = WCD9320_RATES,
Bhalchandra Gajare5b40c532013-02-19 13:36:47 -08003802 .formats = TAIKO_FORMATS_S16_S24_LE,
Kiran Kandic3b24402012-06-11 00:05:59 -07003803 .rate_min = 8000,
3804 .rate_max = 192000,
3805 .channels_min = 1,
3806 .channels_max = 2,
3807 },
3808 .ops = &taiko_dai_ops,
3809 },
3810};
3811
3812static struct snd_soc_dai_driver taiko_i2s_dai[] = {
3813 {
3814 .name = "taiko_i2s_rx1",
Kuirong Wang906ac472012-07-09 12:54:44 -07003815 .id = AIF1_PB,
Kiran Kandic3b24402012-06-11 00:05:59 -07003816 .playback = {
3817 .stream_name = "AIF1 Playback",
3818 .rates = WCD9320_RATES,
3819 .formats = TAIKO_FORMATS,
3820 .rate_max = 192000,
3821 .rate_min = 8000,
3822 .channels_min = 1,
3823 .channels_max = 4,
3824 },
3825 .ops = &taiko_dai_ops,
3826 },
3827 {
3828 .name = "taiko_i2s_tx1",
Kuirong Wang906ac472012-07-09 12:54:44 -07003829 .id = AIF1_CAP,
Kiran Kandic3b24402012-06-11 00:05:59 -07003830 .capture = {
3831 .stream_name = "AIF1 Capture",
3832 .rates = WCD9320_RATES,
3833 .formats = TAIKO_FORMATS,
3834 .rate_max = 192000,
3835 .rate_min = 8000,
3836 .channels_min = 1,
3837 .channels_max = 4,
3838 },
3839 .ops = &taiko_dai_ops,
3840 },
Venkat Sudhir994193b2012-12-17 17:30:51 -08003841 {
3842 .name = "taiko_i2s_rx2",
3843 .id = AIF1_PB,
3844 .playback = {
3845 .stream_name = "AIF2 Playback",
3846 .rates = WCD9320_RATES,
3847 .formats = TAIKO_FORMATS,
3848 .rate_max = 192000,
3849 .rate_min = 8000,
3850 .channels_min = 1,
3851 .channels_max = 4,
3852 },
3853 .ops = &taiko_dai_ops,
3854 },
3855 {
3856 .name = "taiko_i2s_tx2",
3857 .id = AIF1_CAP,
3858 .capture = {
3859 .stream_name = "AIF2 Capture",
3860 .rates = WCD9320_RATES,
3861 .formats = TAIKO_FORMATS,
3862 .rate_max = 192000,
3863 .rate_min = 8000,
3864 .channels_min = 1,
3865 .channels_max = 4,
3866 },
3867 .ops = &taiko_dai_ops,
3868 },
Kiran Kandic3b24402012-06-11 00:05:59 -07003869};
3870
Joonwoo Park9bbb4d12012-11-09 19:58:11 -08003871static int taiko_codec_enable_slim_chmask(struct wcd9xxx_codec_dai_data *dai,
3872 bool up)
3873{
3874 int ret = 0;
3875 struct wcd9xxx_ch *ch;
3876
3877 if (up) {
3878 list_for_each_entry(ch, &dai->wcd9xxx_ch_list, list) {
3879 ret = wcd9xxx_get_slave_port(ch->ch_num);
3880 if (ret < 0) {
3881 pr_err("%s: Invalid slave port ID: %d\n",
3882 __func__, ret);
3883 ret = -EINVAL;
3884 } else {
3885 set_bit(ret, &dai->ch_mask);
3886 }
3887 }
3888 } else {
3889 ret = wait_event_timeout(dai->dai_wait, (dai->ch_mask == 0),
3890 msecs_to_jiffies(
3891 TAIKO_SLIM_CLOSE_TIMEOUT));
3892 if (!ret) {
3893 pr_err("%s: Slim close tx/rx wait timeout\n", __func__);
3894 ret = -ETIMEDOUT;
3895 } else {
3896 ret = 0;
3897 }
3898 }
3899 return ret;
3900}
3901
Kiran Kandic3b24402012-06-11 00:05:59 -07003902static int taiko_codec_enable_slimrx(struct snd_soc_dapm_widget *w,
Kuirong Wang906ac472012-07-09 12:54:44 -07003903 struct snd_kcontrol *kcontrol,
3904 int event)
Kiran Kandic3b24402012-06-11 00:05:59 -07003905{
Kuirong Wang906ac472012-07-09 12:54:44 -07003906 struct wcd9xxx *core;
Kiran Kandic3b24402012-06-11 00:05:59 -07003907 struct snd_soc_codec *codec = w->codec;
3908 struct taiko_priv *taiko_p = snd_soc_codec_get_drvdata(codec);
Joonwoo Park9bbb4d12012-11-09 19:58:11 -08003909 int ret = 0;
Kuirong Wang906ac472012-07-09 12:54:44 -07003910 struct wcd9xxx_codec_dai_data *dai;
3911
3912 core = dev_get_drvdata(codec->dev->parent);
3913
3914 pr_debug("%s: event called! codec name %s num_dai %d\n"
3915 "stream name %s event %d\n",
3916 __func__, w->codec->name, w->codec->num_dai, w->sname, event);
3917
Kiran Kandic3b24402012-06-11 00:05:59 -07003918 /* Execute the callback only if interface type is slimbus */
3919 if (taiko_p->intf_type != WCD9XXX_INTERFACE_TYPE_SLIMBUS)
3920 return 0;
3921
Kuirong Wang906ac472012-07-09 12:54:44 -07003922 dai = &taiko_p->dai[w->shift];
3923 pr_debug("%s: w->name %s w->shift %d event %d\n",
3924 __func__, w->name, w->shift, event);
Kiran Kandic3b24402012-06-11 00:05:59 -07003925
3926 switch (event) {
3927 case SND_SOC_DAPM_POST_PMU:
Joonwoo Park9bbb4d12012-11-09 19:58:11 -08003928 (void) taiko_codec_enable_slim_chmask(dai, true);
Kuirong Wang906ac472012-07-09 12:54:44 -07003929 ret = wcd9xxx_cfg_slim_sch_rx(core, &dai->wcd9xxx_ch_list,
3930 dai->rate, dai->bit_width,
3931 &dai->grph);
Kiran Kandic3b24402012-06-11 00:05:59 -07003932 break;
3933 case SND_SOC_DAPM_POST_PMD:
Kuirong Wang906ac472012-07-09 12:54:44 -07003934 ret = wcd9xxx_close_slim_sch_rx(core, &dai->wcd9xxx_ch_list,
3935 dai->grph);
Joonwoo Park9bbb4d12012-11-09 19:58:11 -08003936 ret = taiko_codec_enable_slim_chmask(dai, false);
3937 if (ret < 0) {
3938 ret = wcd9xxx_disconnect_port(core,
3939 &dai->wcd9xxx_ch_list,
3940 dai->grph);
3941 pr_debug("%s: Disconnect RX port, ret = %d\n",
3942 __func__, ret);
3943 }
Kuirong Wang906ac472012-07-09 12:54:44 -07003944 break;
Kiran Kandic3b24402012-06-11 00:05:59 -07003945 }
3946 return ret;
3947}
3948
3949static int taiko_codec_enable_slimtx(struct snd_soc_dapm_widget *w,
Kuirong Wang906ac472012-07-09 12:54:44 -07003950 struct snd_kcontrol *kcontrol,
3951 int event)
Kiran Kandic3b24402012-06-11 00:05:59 -07003952{
Kuirong Wang906ac472012-07-09 12:54:44 -07003953 struct wcd9xxx *core;
Kiran Kandic3b24402012-06-11 00:05:59 -07003954 struct snd_soc_codec *codec = w->codec;
3955 struct taiko_priv *taiko_p = snd_soc_codec_get_drvdata(codec);
Kiran Kandic3b24402012-06-11 00:05:59 -07003956 u32 ret = 0;
Kuirong Wang906ac472012-07-09 12:54:44 -07003957 struct wcd9xxx_codec_dai_data *dai;
Kiran Kandic3b24402012-06-11 00:05:59 -07003958
Kuirong Wang906ac472012-07-09 12:54:44 -07003959 core = dev_get_drvdata(codec->dev->parent);
3960
3961 pr_debug("%s: event called! codec name %s num_dai %d stream name %s\n",
3962 __func__, w->codec->name, w->codec->num_dai, w->sname);
Kiran Kandic3b24402012-06-11 00:05:59 -07003963
3964 /* Execute the callback only if interface type is slimbus */
3965 if (taiko_p->intf_type != WCD9XXX_INTERFACE_TYPE_SLIMBUS)
3966 return 0;
3967
Kuirong Wang906ac472012-07-09 12:54:44 -07003968 pr_debug("%s(): w->name %s event %d w->shift %d\n",
3969 __func__, w->name, event, w->shift);
Kiran Kandic3b24402012-06-11 00:05:59 -07003970
Kuirong Wang906ac472012-07-09 12:54:44 -07003971 dai = &taiko_p->dai[w->shift];
Kiran Kandic3b24402012-06-11 00:05:59 -07003972 switch (event) {
3973 case SND_SOC_DAPM_POST_PMU:
Joonwoo Park9bbb4d12012-11-09 19:58:11 -08003974 (void) taiko_codec_enable_slim_chmask(dai, true);
Kuirong Wang906ac472012-07-09 12:54:44 -07003975 ret = wcd9xxx_cfg_slim_sch_tx(core, &dai->wcd9xxx_ch_list,
3976 dai->rate, dai->bit_width,
3977 &dai->grph);
Kiran Kandic3b24402012-06-11 00:05:59 -07003978 break;
3979 case SND_SOC_DAPM_POST_PMD:
Kuirong Wang906ac472012-07-09 12:54:44 -07003980 ret = wcd9xxx_close_slim_sch_tx(core, &dai->wcd9xxx_ch_list,
3981 dai->grph);
Joonwoo Park9bbb4d12012-11-09 19:58:11 -08003982 ret = taiko_codec_enable_slim_chmask(dai, false);
3983 if (ret < 0) {
3984 ret = wcd9xxx_disconnect_port(core,
3985 &dai->wcd9xxx_ch_list,
3986 dai->grph);
3987 pr_debug("%s: Disconnect RX port, ret = %d\n",
3988 __func__, ret);
3989 }
Kuirong Wang906ac472012-07-09 12:54:44 -07003990 break;
Kiran Kandic3b24402012-06-11 00:05:59 -07003991 }
3992 return ret;
3993}
3994
Kiran Kandi4c56c592012-07-25 11:04:55 -07003995static int taiko_codec_enable_ear_pa(struct snd_soc_dapm_widget *w,
3996 struct snd_kcontrol *kcontrol, int event)
3997{
3998 struct snd_soc_codec *codec = w->codec;
Bhalchandra Gajare87fef4c2013-02-19 14:57:03 -08003999 struct taiko_priv *taiko_p = snd_soc_codec_get_drvdata(codec);
Kiran Kandi4c56c592012-07-25 11:04:55 -07004000
4001 pr_debug("%s %s %d\n", __func__, w->name, event);
4002
4003 switch (event) {
Kiran Kandi4c56c592012-07-25 11:04:55 -07004004 case SND_SOC_DAPM_POST_PMU:
Bhalchandra Gajare87fef4c2013-02-19 14:57:03 -08004005 wcd9xxx_clsh_fsm(codec, &taiko_p->clsh_d,
4006 WCD9XXX_CLSH_STATE_EAR,
4007 WCD9XXX_CLSH_REQ_ENABLE,
4008 WCD9XXX_CLSH_EVENT_POST_PA);
Kiran Kandi4c56c592012-07-25 11:04:55 -07004009
4010 usleep_range(5000, 5000);
4011 break;
Bhalchandra Gajare87fef4c2013-02-19 14:57:03 -08004012 case SND_SOC_DAPM_POST_PMD:
4013 wcd9xxx_clsh_fsm(codec, &taiko_p->clsh_d,
4014 WCD9XXX_CLSH_STATE_EAR,
4015 WCD9XXX_CLSH_REQ_DISABLE,
4016 WCD9XXX_CLSH_EVENT_POST_PA);
4017 usleep_range(5000, 5000);
4018 }
4019 return 0;
4020}
4021
4022static int taiko_codec_ear_dac_event(struct snd_soc_dapm_widget *w,
4023 struct snd_kcontrol *kcontrol, int event)
4024{
4025 struct snd_soc_codec *codec = w->codec;
4026 struct taiko_priv *taiko_p = snd_soc_codec_get_drvdata(codec);
4027
4028 pr_debug("%s %s %d\n", __func__, w->name, event);
4029
4030 switch (event) {
4031 case SND_SOC_DAPM_PRE_PMU:
4032 wcd9xxx_clsh_fsm(codec, &taiko_p->clsh_d,
4033 WCD9XXX_CLSH_STATE_EAR,
4034 WCD9XXX_CLSH_REQ_ENABLE,
4035 WCD9XXX_CLSH_EVENT_PRE_DAC);
4036 break;
4037 }
4038
4039 return 0;
4040}
4041
4042static int taiko_codec_dsm_mux_event(struct snd_soc_dapm_widget *w,
4043 struct snd_kcontrol *kcontrol, int event)
4044{
4045 struct snd_soc_codec *codec = w->codec;
4046 u8 reg_val, zoh_mux_val = 0x00;
4047
4048 pr_debug("%s: event = %d\n", __func__, event);
4049
4050 switch (event) {
4051 case SND_SOC_DAPM_POST_PMU:
4052 reg_val = snd_soc_read(codec, TAIKO_A_CDC_CONN_CLSH_CTL);
4053
4054 if ((reg_val & 0x30) == 0x10)
4055 zoh_mux_val = 0x04;
4056 else if ((reg_val & 0x30) == 0x20)
4057 zoh_mux_val = 0x08;
4058
4059 if (zoh_mux_val != 0x00)
4060 snd_soc_update_bits(codec,
4061 TAIKO_A_CDC_CONN_CLSH_CTL,
4062 0x0C, zoh_mux_val);
4063 break;
4064
4065 case SND_SOC_DAPM_POST_PMD:
4066 snd_soc_update_bits(codec, TAIKO_A_CDC_CONN_CLSH_CTL,
4067 0x0C, 0x00);
4068 break;
Kiran Kandi4c56c592012-07-25 11:04:55 -07004069 }
4070 return 0;
4071}
4072
Bhalchandra Gajare87fef4c2013-02-19 14:57:03 -08004073
Kiran Kandic3b24402012-06-11 00:05:59 -07004074/* Todo: Have seperate dapm widgets for I2S and Slimbus.
4075 * Might Need to have callbacks registered only for slimbus
4076 */
4077static const struct snd_soc_dapm_widget taiko_dapm_widgets[] = {
4078 /*RX stuff */
4079 SND_SOC_DAPM_OUTPUT("EAR"),
4080
Kiran Kandi4c56c592012-07-25 11:04:55 -07004081 SND_SOC_DAPM_PGA_E("EAR PA", TAIKO_A_RX_EAR_EN, 4, 0, NULL, 0,
Bhalchandra Gajare87fef4c2013-02-19 14:57:03 -08004082 taiko_codec_enable_ear_pa, SND_SOC_DAPM_POST_PMU |
4083 SND_SOC_DAPM_POST_PMD),
Kiran Kandic3b24402012-06-11 00:05:59 -07004084
Bhalchandra Gajare87fef4c2013-02-19 14:57:03 -08004085 SND_SOC_DAPM_MIXER_E("DAC1", TAIKO_A_RX_EAR_EN, 6, 0, dac1_switch,
4086 ARRAY_SIZE(dac1_switch), taiko_codec_ear_dac_event,
4087 SND_SOC_DAPM_PRE_PMU),
Kiran Kandic3b24402012-06-11 00:05:59 -07004088
Kuirong Wang906ac472012-07-09 12:54:44 -07004089 SND_SOC_DAPM_AIF_IN_E("AIF1 PB", "AIF1 Playback", 0, SND_SOC_NOPM,
4090 AIF1_PB, 0, taiko_codec_enable_slimrx,
Kiran Kandic3b24402012-06-11 00:05:59 -07004091 SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD),
Kuirong Wang906ac472012-07-09 12:54:44 -07004092 SND_SOC_DAPM_AIF_IN_E("AIF2 PB", "AIF2 Playback", 0, SND_SOC_NOPM,
4093 AIF2_PB, 0, taiko_codec_enable_slimrx,
Kiran Kandic3b24402012-06-11 00:05:59 -07004094 SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD),
Kuirong Wang906ac472012-07-09 12:54:44 -07004095 SND_SOC_DAPM_AIF_IN_E("AIF3 PB", "AIF3 Playback", 0, SND_SOC_NOPM,
4096 AIF3_PB, 0, taiko_codec_enable_slimrx,
Kiran Kandic3b24402012-06-11 00:05:59 -07004097 SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD),
4098
Kuirong Wang906ac472012-07-09 12:54:44 -07004099 SND_SOC_DAPM_MUX("SLIM RX1 MUX", SND_SOC_NOPM, TAIKO_RX1, 0,
4100 &slim_rx_mux[TAIKO_RX1]),
4101 SND_SOC_DAPM_MUX("SLIM RX2 MUX", SND_SOC_NOPM, TAIKO_RX2, 0,
4102 &slim_rx_mux[TAIKO_RX2]),
4103 SND_SOC_DAPM_MUX("SLIM RX3 MUX", SND_SOC_NOPM, TAIKO_RX3, 0,
4104 &slim_rx_mux[TAIKO_RX3]),
4105 SND_SOC_DAPM_MUX("SLIM RX4 MUX", SND_SOC_NOPM, TAIKO_RX4, 0,
4106 &slim_rx_mux[TAIKO_RX4]),
4107 SND_SOC_DAPM_MUX("SLIM RX5 MUX", SND_SOC_NOPM, TAIKO_RX5, 0,
4108 &slim_rx_mux[TAIKO_RX5]),
4109 SND_SOC_DAPM_MUX("SLIM RX6 MUX", SND_SOC_NOPM, TAIKO_RX6, 0,
4110 &slim_rx_mux[TAIKO_RX6]),
4111 SND_SOC_DAPM_MUX("SLIM RX7 MUX", SND_SOC_NOPM, TAIKO_RX7, 0,
4112 &slim_rx_mux[TAIKO_RX7]),
Kiran Kandic3b24402012-06-11 00:05:59 -07004113
Kuirong Wang906ac472012-07-09 12:54:44 -07004114 SND_SOC_DAPM_MIXER("SLIM RX1", SND_SOC_NOPM, 0, 0, NULL, 0),
4115 SND_SOC_DAPM_MIXER("SLIM RX2", SND_SOC_NOPM, 0, 0, NULL, 0),
4116 SND_SOC_DAPM_MIXER("SLIM RX3", SND_SOC_NOPM, 0, 0, NULL, 0),
4117 SND_SOC_DAPM_MIXER("SLIM RX4", SND_SOC_NOPM, 0, 0, NULL, 0),
4118 SND_SOC_DAPM_MIXER("SLIM RX5", SND_SOC_NOPM, 0, 0, NULL, 0),
4119 SND_SOC_DAPM_MIXER("SLIM RX6", SND_SOC_NOPM, 0, 0, NULL, 0),
4120 SND_SOC_DAPM_MIXER("SLIM RX7", SND_SOC_NOPM, 0, 0, NULL, 0),
Kiran Kandic3b24402012-06-11 00:05:59 -07004121
4122 /* Headphone */
4123 SND_SOC_DAPM_OUTPUT("HEADPHONE"),
4124 SND_SOC_DAPM_PGA_E("HPHL", TAIKO_A_RX_HPH_CNP_EN, 5, 0, NULL, 0,
4125 taiko_hph_pa_event, SND_SOC_DAPM_PRE_PMU |
Kiran Kandi4c56c592012-07-25 11:04:55 -07004126 SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD),
Bhalchandra Gajare87fef4c2013-02-19 14:57:03 -08004127 SND_SOC_DAPM_MIXER_E("HPHL DAC", TAIKO_A_RX_HPH_L_DAC_CTL, 7, 0,
4128 hphl_switch, ARRAY_SIZE(hphl_switch), taiko_hphl_dac_event,
4129 SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
Kiran Kandic3b24402012-06-11 00:05:59 -07004130
4131 SND_SOC_DAPM_PGA_E("HPHR", TAIKO_A_RX_HPH_CNP_EN, 4, 0, NULL, 0,
4132 taiko_hph_pa_event, SND_SOC_DAPM_PRE_PMU |
Kiran Kandi4c56c592012-07-25 11:04:55 -07004133 SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD),
Kiran Kandic3b24402012-06-11 00:05:59 -07004134
4135 SND_SOC_DAPM_DAC_E("HPHR DAC", NULL, TAIKO_A_RX_HPH_R_DAC_CTL, 7, 0,
4136 taiko_hphr_dac_event,
4137 SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
4138
4139 /* Speaker */
4140 SND_SOC_DAPM_OUTPUT("LINEOUT1"),
4141 SND_SOC_DAPM_OUTPUT("LINEOUT2"),
4142 SND_SOC_DAPM_OUTPUT("LINEOUT3"),
4143 SND_SOC_DAPM_OUTPUT("LINEOUT4"),
Joonwoo Park7680b9f2012-07-13 11:36:48 -07004144 SND_SOC_DAPM_OUTPUT("SPK_OUT"),
Kiran Kandic3b24402012-06-11 00:05:59 -07004145
4146 SND_SOC_DAPM_PGA_E("LINEOUT1 PA", TAIKO_A_RX_LINE_CNP_EN, 0, 0, NULL,
4147 0, taiko_codec_enable_lineout, SND_SOC_DAPM_PRE_PMU |
4148 SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD),
4149 SND_SOC_DAPM_PGA_E("LINEOUT2 PA", TAIKO_A_RX_LINE_CNP_EN, 1, 0, NULL,
4150 0, taiko_codec_enable_lineout, SND_SOC_DAPM_PRE_PMU |
4151 SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD),
4152 SND_SOC_DAPM_PGA_E("LINEOUT3 PA", TAIKO_A_RX_LINE_CNP_EN, 2, 0, NULL,
4153 0, taiko_codec_enable_lineout, SND_SOC_DAPM_PRE_PMU |
4154 SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD),
4155 SND_SOC_DAPM_PGA_E("LINEOUT4 PA", TAIKO_A_RX_LINE_CNP_EN, 3, 0, NULL,
4156 0, taiko_codec_enable_lineout, SND_SOC_DAPM_PRE_PMU |
4157 SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD),
Joonwoo Park125cd4e2012-12-11 15:16:11 -08004158 SND_SOC_DAPM_PGA_E("SPK PA", SND_SOC_NOPM, 0, 0 , NULL,
4159 0, taiko_codec_enable_spk_pa,
4160 SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
Kiran Kandic3b24402012-06-11 00:05:59 -07004161
4162 SND_SOC_DAPM_DAC_E("LINEOUT1 DAC", NULL, TAIKO_A_RX_LINE_1_DAC_CTL, 7, 0
4163 , taiko_lineout_dac_event,
4164 SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
4165 SND_SOC_DAPM_DAC_E("LINEOUT2 DAC", NULL, TAIKO_A_RX_LINE_2_DAC_CTL, 7, 0
4166 , taiko_lineout_dac_event,
4167 SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
4168 SND_SOC_DAPM_DAC_E("LINEOUT3 DAC", NULL, TAIKO_A_RX_LINE_3_DAC_CTL, 7, 0
4169 , taiko_lineout_dac_event,
4170 SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
4171 SND_SOC_DAPM_SWITCH("LINEOUT3 DAC GROUND", SND_SOC_NOPM, 0, 0,
4172 &lineout3_ground_switch),
4173 SND_SOC_DAPM_DAC_E("LINEOUT4 DAC", NULL, TAIKO_A_RX_LINE_4_DAC_CTL, 7, 0
4174 , taiko_lineout_dac_event,
4175 SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
4176 SND_SOC_DAPM_SWITCH("LINEOUT4 DAC GROUND", SND_SOC_NOPM, 0, 0,
4177 &lineout4_ground_switch),
4178
Joonwoo Park7680b9f2012-07-13 11:36:48 -07004179 SND_SOC_DAPM_DAC_E("SPK DAC", NULL, SND_SOC_NOPM, 0, 0,
4180 taiko_spk_dac_event,
4181 SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
4182
Joonwoo Park125cd4e2012-12-11 15:16:11 -08004183 SND_SOC_DAPM_SUPPLY("VDD_SPKDRV", SND_SOC_NOPM, 0, 0,
4184 taiko_codec_enable_vdd_spkr,
4185 SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
4186
Kiran Kandid2b46332012-10-05 12:04:00 -07004187 SND_SOC_DAPM_MIXER("RX1 MIX1", SND_SOC_NOPM, 0, 0, NULL, 0),
4188 SND_SOC_DAPM_MIXER("RX2 MIX1", SND_SOC_NOPM, 0, 0, NULL, 0),
4189 SND_SOC_DAPM_MIXER("RX7 MIX1", SND_SOC_NOPM, 0, 0, NULL, 0),
4190
Kiran Kandic3b24402012-06-11 00:05:59 -07004191 SND_SOC_DAPM_MIXER_E("RX1 MIX2", TAIKO_A_CDC_CLK_RX_B1_CTL, 0, 0, NULL,
Kiran Kandi7b7d2ff2012-09-14 14:52:14 -07004192 0, taiko_codec_enable_interpolator, SND_SOC_DAPM_PRE_PMU |
Kiran Kandic3b24402012-06-11 00:05:59 -07004193 SND_SOC_DAPM_POST_PMU),
4194 SND_SOC_DAPM_MIXER_E("RX2 MIX2", TAIKO_A_CDC_CLK_RX_B1_CTL, 1, 0, NULL,
Kiran Kandi7b7d2ff2012-09-14 14:52:14 -07004195 0, taiko_codec_enable_interpolator, SND_SOC_DAPM_PRE_PMU |
Kiran Kandic3b24402012-06-11 00:05:59 -07004196 SND_SOC_DAPM_POST_PMU),
Kiran Kandid2b46332012-10-05 12:04:00 -07004197 SND_SOC_DAPM_MIXER_E("RX3 MIX1", TAIKO_A_CDC_CLK_RX_B1_CTL, 2, 0, NULL,
Kiran Kandi7b7d2ff2012-09-14 14:52:14 -07004198 0, taiko_codec_enable_interpolator, SND_SOC_DAPM_PRE_PMU |
Kiran Kandic3b24402012-06-11 00:05:59 -07004199 SND_SOC_DAPM_POST_PMU),
4200 SND_SOC_DAPM_MIXER_E("RX4 MIX1", TAIKO_A_CDC_CLK_RX_B1_CTL, 3, 0, NULL,
Kiran Kandi7b7d2ff2012-09-14 14:52:14 -07004201 0, taiko_codec_enable_interpolator, SND_SOC_DAPM_PRE_PMU |
Kiran Kandic3b24402012-06-11 00:05:59 -07004202 SND_SOC_DAPM_POST_PMU),
4203 SND_SOC_DAPM_MIXER_E("RX5 MIX1", TAIKO_A_CDC_CLK_RX_B1_CTL, 4, 0, NULL,
Kiran Kandi7b7d2ff2012-09-14 14:52:14 -07004204 0, taiko_codec_enable_interpolator, SND_SOC_DAPM_PRE_PMU |
Kiran Kandic3b24402012-06-11 00:05:59 -07004205 SND_SOC_DAPM_POST_PMU),
4206 SND_SOC_DAPM_MIXER_E("RX6 MIX1", TAIKO_A_CDC_CLK_RX_B1_CTL, 5, 0, NULL,
Kiran Kandi7b7d2ff2012-09-14 14:52:14 -07004207 0, taiko_codec_enable_interpolator, SND_SOC_DAPM_PRE_PMU |
Kiran Kandic3b24402012-06-11 00:05:59 -07004208 SND_SOC_DAPM_POST_PMU),
Kiran Kandid2b46332012-10-05 12:04:00 -07004209 SND_SOC_DAPM_MIXER_E("RX7 MIX2", TAIKO_A_CDC_CLK_RX_B1_CTL, 6, 0, NULL,
Kiran Kandi7b7d2ff2012-09-14 14:52:14 -07004210 0, taiko_codec_enable_interpolator, SND_SOC_DAPM_PRE_PMU |
Kiran Kandic3b24402012-06-11 00:05:59 -07004211 SND_SOC_DAPM_POST_PMU),
4212
Kiran Kandic3b24402012-06-11 00:05:59 -07004213
4214 SND_SOC_DAPM_MIXER("RX1 CHAIN", TAIKO_A_CDC_RX1_B6_CTL, 5, 0, NULL, 0),
4215 SND_SOC_DAPM_MIXER("RX2 CHAIN", TAIKO_A_CDC_RX2_B6_CTL, 5, 0, NULL, 0),
4216
4217 SND_SOC_DAPM_MUX("RX1 MIX1 INP1", SND_SOC_NOPM, 0, 0,
4218 &rx_mix1_inp1_mux),
4219 SND_SOC_DAPM_MUX("RX1 MIX1 INP2", SND_SOC_NOPM, 0, 0,
4220 &rx_mix1_inp2_mux),
4221 SND_SOC_DAPM_MUX("RX1 MIX1 INP3", SND_SOC_NOPM, 0, 0,
4222 &rx_mix1_inp3_mux),
4223 SND_SOC_DAPM_MUX("RX2 MIX1 INP1", SND_SOC_NOPM, 0, 0,
4224 &rx2_mix1_inp1_mux),
4225 SND_SOC_DAPM_MUX("RX2 MIX1 INP2", SND_SOC_NOPM, 0, 0,
4226 &rx2_mix1_inp2_mux),
4227 SND_SOC_DAPM_MUX("RX3 MIX1 INP1", SND_SOC_NOPM, 0, 0,
4228 &rx3_mix1_inp1_mux),
4229 SND_SOC_DAPM_MUX("RX3 MIX1 INP2", SND_SOC_NOPM, 0, 0,
4230 &rx3_mix1_inp2_mux),
4231 SND_SOC_DAPM_MUX("RX4 MIX1 INP1", SND_SOC_NOPM, 0, 0,
4232 &rx4_mix1_inp1_mux),
4233 SND_SOC_DAPM_MUX("RX4 MIX1 INP2", SND_SOC_NOPM, 0, 0,
4234 &rx4_mix1_inp2_mux),
4235 SND_SOC_DAPM_MUX("RX5 MIX1 INP1", SND_SOC_NOPM, 0, 0,
4236 &rx5_mix1_inp1_mux),
4237 SND_SOC_DAPM_MUX("RX5 MIX1 INP2", SND_SOC_NOPM, 0, 0,
4238 &rx5_mix1_inp2_mux),
4239 SND_SOC_DAPM_MUX("RX6 MIX1 INP1", SND_SOC_NOPM, 0, 0,
4240 &rx6_mix1_inp1_mux),
4241 SND_SOC_DAPM_MUX("RX6 MIX1 INP2", SND_SOC_NOPM, 0, 0,
4242 &rx6_mix1_inp2_mux),
4243 SND_SOC_DAPM_MUX("RX7 MIX1 INP1", SND_SOC_NOPM, 0, 0,
4244 &rx7_mix1_inp1_mux),
4245 SND_SOC_DAPM_MUX("RX7 MIX1 INP2", SND_SOC_NOPM, 0, 0,
4246 &rx7_mix1_inp2_mux),
4247 SND_SOC_DAPM_MUX("RX1 MIX2 INP1", SND_SOC_NOPM, 0, 0,
4248 &rx1_mix2_inp1_mux),
4249 SND_SOC_DAPM_MUX("RX1 MIX2 INP2", SND_SOC_NOPM, 0, 0,
4250 &rx1_mix2_inp2_mux),
4251 SND_SOC_DAPM_MUX("RX2 MIX2 INP1", SND_SOC_NOPM, 0, 0,
4252 &rx2_mix2_inp1_mux),
4253 SND_SOC_DAPM_MUX("RX2 MIX2 INP2", SND_SOC_NOPM, 0, 0,
4254 &rx2_mix2_inp2_mux),
4255 SND_SOC_DAPM_MUX("RX7 MIX2 INP1", SND_SOC_NOPM, 0, 0,
4256 &rx7_mix2_inp1_mux),
4257 SND_SOC_DAPM_MUX("RX7 MIX2 INP2", SND_SOC_NOPM, 0, 0,
4258 &rx7_mix2_inp2_mux),
4259
Tanya Finkeldaaa6d12012-10-25 11:22:48 +02004260 SND_SOC_DAPM_MUX("RDAC5 MUX", SND_SOC_NOPM, 0, 0,
4261 &rx_dac5_mux),
4262 SND_SOC_DAPM_MUX("RDAC7 MUX", SND_SOC_NOPM, 0, 0,
4263 &rx_dac7_mux),
4264
Bhalchandra Gajare87fef4c2013-02-19 14:57:03 -08004265 SND_SOC_DAPM_MUX_E("CLASS_H_DSM MUX", SND_SOC_NOPM, 0, 0,
4266 &class_h_dsm_mux, taiko_codec_dsm_mux_event,
4267 SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD),
Kiran Kandi4c56c592012-07-25 11:04:55 -07004268
Kiran Kandic3b24402012-06-11 00:05:59 -07004269 SND_SOC_DAPM_SUPPLY("RX_BIAS", SND_SOC_NOPM, 0, 0,
4270 taiko_codec_enable_rx_bias, SND_SOC_DAPM_PRE_PMU |
4271 SND_SOC_DAPM_POST_PMD),
4272
Bhalchandra Gajare87fef4c2013-02-19 14:57:03 -08004273 SND_SOC_DAPM_SUPPLY("CDC_I2S_RX_CONN", WCD9XXX_A_CDC_CLK_OTHR_CTL, 5, 0,
Joonwoo Park559a5bf2013-02-15 14:46:36 -08004274 NULL, 0),
4275
Kiran Kandic3b24402012-06-11 00:05:59 -07004276 /* TX */
4277
Bhalchandra Gajare87fef4c2013-02-19 14:57:03 -08004278 SND_SOC_DAPM_SUPPLY("CDC_CONN", WCD9XXX_A_CDC_CLK_OTHR_CTL, 2, 0, NULL,
Kiran Kandic3b24402012-06-11 00:05:59 -07004279 0),
4280
4281 SND_SOC_DAPM_SUPPLY("LDO_H", TAIKO_A_LDO_H_MODE_1, 7, 0,
4282 taiko_codec_enable_ldo_h, SND_SOC_DAPM_POST_PMU),
4283
Joonwoo Parkc7731432012-10-17 12:41:44 -07004284 SND_SOC_DAPM_SUPPLY("COMP0_CLK", SND_SOC_NOPM, 0, 0,
Kiran Kandic3b24402012-06-11 00:05:59 -07004285 taiko_config_compander, SND_SOC_DAPM_PRE_PMU |
4286 SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_PRE_POST_PMD),
Joonwoo Parkc7731432012-10-17 12:41:44 -07004287 SND_SOC_DAPM_SUPPLY("COMP1_CLK", SND_SOC_NOPM, 1, 0,
4288 taiko_config_compander, SND_SOC_DAPM_PRE_PMU |
4289 SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_PRE_POST_PMD),
4290 SND_SOC_DAPM_SUPPLY("COMP2_CLK", SND_SOC_NOPM, 2, 0,
Kiran Kandic3b24402012-06-11 00:05:59 -07004291 taiko_config_compander, SND_SOC_DAPM_PRE_PMU |
4292 SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_PRE_POST_PMD),
4293
4294
4295 SND_SOC_DAPM_INPUT("AMIC1"),
Joonwoo Park3699ca32013-02-08 12:06:15 -08004296 SND_SOC_DAPM_MICBIAS_E("MIC BIAS1 External", SND_SOC_NOPM, 7, 0,
4297 taiko_codec_enable_micbias,
4298 SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
4299 SND_SOC_DAPM_POST_PMD),
4300 SND_SOC_DAPM_MICBIAS_E("MIC BIAS1 Internal1", SND_SOC_NOPM, 7, 0,
4301 taiko_codec_enable_micbias,
4302 SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
4303 SND_SOC_DAPM_POST_PMD),
4304 SND_SOC_DAPM_MICBIAS_E("MIC BIAS1 Internal2", SND_SOC_NOPM, 7, 0,
4305 taiko_codec_enable_micbias,
4306 SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
4307 SND_SOC_DAPM_POST_PMD),
Kiran Kandic3b24402012-06-11 00:05:59 -07004308 SND_SOC_DAPM_ADC_E("ADC1", NULL, TAIKO_A_TX_1_2_EN, 7, 0,
4309 taiko_codec_enable_adc, SND_SOC_DAPM_PRE_PMU |
4310 SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD),
4311
4312 SND_SOC_DAPM_INPUT("AMIC3"),
4313 SND_SOC_DAPM_ADC_E("ADC3", NULL, TAIKO_A_TX_3_4_EN, 7, 0,
4314 taiko_codec_enable_adc, SND_SOC_DAPM_PRE_PMU |
4315 SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD),
4316
4317 SND_SOC_DAPM_INPUT("AMIC4"),
4318 SND_SOC_DAPM_ADC_E("ADC4", NULL, TAIKO_A_TX_3_4_EN, 3, 0,
4319 taiko_codec_enable_adc, SND_SOC_DAPM_PRE_PMU |
4320 SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD),
4321
4322 SND_SOC_DAPM_INPUT("AMIC5"),
4323 SND_SOC_DAPM_ADC_E("ADC5", NULL, TAIKO_A_TX_5_6_EN, 7, 0,
4324 taiko_codec_enable_adc, SND_SOC_DAPM_POST_PMU),
4325
4326 SND_SOC_DAPM_INPUT("AMIC6"),
4327 SND_SOC_DAPM_ADC_E("ADC6", NULL, TAIKO_A_TX_5_6_EN, 3, 0,
4328 taiko_codec_enable_adc, SND_SOC_DAPM_POST_PMU),
4329
4330 SND_SOC_DAPM_MUX_E("DEC1 MUX", TAIKO_A_CDC_CLK_TX_CLK_EN_B1_CTL, 0, 0,
4331 &dec1_mux, taiko_codec_enable_dec,
4332 SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
4333 SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD),
4334
4335 SND_SOC_DAPM_MUX_E("DEC2 MUX", TAIKO_A_CDC_CLK_TX_CLK_EN_B1_CTL, 1, 0,
4336 &dec2_mux, taiko_codec_enable_dec,
4337 SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
4338 SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD),
4339
4340 SND_SOC_DAPM_MUX_E("DEC3 MUX", TAIKO_A_CDC_CLK_TX_CLK_EN_B1_CTL, 2, 0,
4341 &dec3_mux, taiko_codec_enable_dec,
4342 SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
4343 SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD),
4344
4345 SND_SOC_DAPM_MUX_E("DEC4 MUX", TAIKO_A_CDC_CLK_TX_CLK_EN_B1_CTL, 3, 0,
4346 &dec4_mux, taiko_codec_enable_dec,
4347 SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
4348 SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD),
4349
4350 SND_SOC_DAPM_MUX_E("DEC5 MUX", TAIKO_A_CDC_CLK_TX_CLK_EN_B1_CTL, 4, 0,
4351 &dec5_mux, taiko_codec_enable_dec,
4352 SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
4353 SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD),
4354
4355 SND_SOC_DAPM_MUX_E("DEC6 MUX", TAIKO_A_CDC_CLK_TX_CLK_EN_B1_CTL, 5, 0,
4356 &dec6_mux, taiko_codec_enable_dec,
4357 SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
4358 SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD),
4359
4360 SND_SOC_DAPM_MUX_E("DEC7 MUX", TAIKO_A_CDC_CLK_TX_CLK_EN_B1_CTL, 6, 0,
4361 &dec7_mux, taiko_codec_enable_dec,
4362 SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
4363 SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD),
4364
4365 SND_SOC_DAPM_MUX_E("DEC8 MUX", TAIKO_A_CDC_CLK_TX_CLK_EN_B1_CTL, 7, 0,
4366 &dec8_mux, taiko_codec_enable_dec,
4367 SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
4368 SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD),
4369
4370 SND_SOC_DAPM_MUX_E("DEC9 MUX", TAIKO_A_CDC_CLK_TX_CLK_EN_B2_CTL, 0, 0,
4371 &dec9_mux, taiko_codec_enable_dec,
4372 SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
4373 SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD),
4374
4375 SND_SOC_DAPM_MUX_E("DEC10 MUX", TAIKO_A_CDC_CLK_TX_CLK_EN_B2_CTL, 1, 0,
4376 &dec10_mux, taiko_codec_enable_dec,
4377 SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
4378 SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD),
4379
4380 SND_SOC_DAPM_MUX("ANC1 MUX", SND_SOC_NOPM, 0, 0, &anc1_mux),
4381 SND_SOC_DAPM_MUX("ANC2 MUX", SND_SOC_NOPM, 0, 0, &anc2_mux),
4382
4383 SND_SOC_DAPM_MIXER_E("ANC", SND_SOC_NOPM, 0, 0, NULL, 0,
4384 taiko_codec_enable_anc, SND_SOC_DAPM_PRE_PMU |
4385 SND_SOC_DAPM_POST_PMD),
4386
4387 SND_SOC_DAPM_MUX("ANC1 FB MUX", SND_SOC_NOPM, 0, 0, &anc1_fb_mux),
4388
4389 SND_SOC_DAPM_INPUT("AMIC2"),
Joonwoo Park3699ca32013-02-08 12:06:15 -08004390 SND_SOC_DAPM_MICBIAS_E("MIC BIAS2 External", SND_SOC_NOPM, 7, 0,
4391 taiko_codec_enable_micbias,
4392 SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
4393 SND_SOC_DAPM_POST_PMD),
4394 SND_SOC_DAPM_MICBIAS_E("MIC BIAS2 Internal1", SND_SOC_NOPM, 7, 0,
4395 taiko_codec_enable_micbias,
4396 SND_SOC_DAPM_PRE_PMU |
4397 SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD),
4398 SND_SOC_DAPM_MICBIAS_E("MIC BIAS2 Internal2", SND_SOC_NOPM, 7, 0,
4399 taiko_codec_enable_micbias,
4400 SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
4401 SND_SOC_DAPM_POST_PMD),
4402 SND_SOC_DAPM_MICBIAS_E("MIC BIAS2 Internal3", SND_SOC_NOPM, 7, 0,
4403 taiko_codec_enable_micbias,
4404 SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
4405 SND_SOC_DAPM_POST_PMD),
4406 SND_SOC_DAPM_MICBIAS_E("MIC BIAS3 External", SND_SOC_NOPM, 7, 0,
4407 taiko_codec_enable_micbias,
4408 SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
4409 SND_SOC_DAPM_POST_PMD),
4410 SND_SOC_DAPM_MICBIAS_E("MIC BIAS3 Internal1", SND_SOC_NOPM, 7, 0,
4411 taiko_codec_enable_micbias,
4412 SND_SOC_DAPM_PRE_PMU |
4413 SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD),
4414 SND_SOC_DAPM_MICBIAS_E("MIC BIAS3 Internal2", SND_SOC_NOPM, 7, 0,
4415 taiko_codec_enable_micbias,
4416 SND_SOC_DAPM_PRE_PMU |
4417 SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD),
4418 SND_SOC_DAPM_MICBIAS_E("MIC BIAS4 External", SND_SOC_NOPM, 7,
4419 0, taiko_codec_enable_micbias,
4420 SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
4421 SND_SOC_DAPM_POST_PMD),
Kiran Kandic3b24402012-06-11 00:05:59 -07004422
4423 SND_SOC_DAPM_ADC_E("ADC2", NULL, TAIKO_A_TX_1_2_EN, 3, 0,
4424 taiko_codec_enable_adc, SND_SOC_DAPM_PRE_PMU |
4425 SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD),
4426
Kuirong Wang906ac472012-07-09 12:54:44 -07004427 SND_SOC_DAPM_AIF_OUT_E("AIF1 CAP", "AIF1 Capture", 0, SND_SOC_NOPM,
4428 AIF1_CAP, 0, taiko_codec_enable_slimtx,
4429 SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD),
Kiran Kandic3b24402012-06-11 00:05:59 -07004430
Kuirong Wang906ac472012-07-09 12:54:44 -07004431 SND_SOC_DAPM_AIF_OUT_E("AIF2 CAP", "AIF2 Capture", 0, SND_SOC_NOPM,
4432 AIF2_CAP, 0, taiko_codec_enable_slimtx,
4433 SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD),
Kiran Kandic3b24402012-06-11 00:05:59 -07004434
Kuirong Wang906ac472012-07-09 12:54:44 -07004435 SND_SOC_DAPM_AIF_OUT_E("AIF3 CAP", "AIF3 Capture", 0, SND_SOC_NOPM,
4436 AIF3_CAP, 0, taiko_codec_enable_slimtx,
4437 SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD),
Kiran Kandic3b24402012-06-11 00:05:59 -07004438
Kuirong Wang906ac472012-07-09 12:54:44 -07004439 SND_SOC_DAPM_MIXER("AIF1_CAP Mixer", SND_SOC_NOPM, AIF1_CAP, 0,
4440 aif_cap_mixer, ARRAY_SIZE(aif_cap_mixer)),
Kiran Kandic3b24402012-06-11 00:05:59 -07004441
Kuirong Wang906ac472012-07-09 12:54:44 -07004442 SND_SOC_DAPM_MIXER("AIF2_CAP Mixer", SND_SOC_NOPM, AIF2_CAP, 0,
4443 aif_cap_mixer, ARRAY_SIZE(aif_cap_mixer)),
Kiran Kandic3b24402012-06-11 00:05:59 -07004444
Kuirong Wang906ac472012-07-09 12:54:44 -07004445 SND_SOC_DAPM_MIXER("AIF3_CAP Mixer", SND_SOC_NOPM, AIF3_CAP, 0,
4446 aif_cap_mixer, ARRAY_SIZE(aif_cap_mixer)),
Kiran Kandic3b24402012-06-11 00:05:59 -07004447
Kuirong Wang906ac472012-07-09 12:54:44 -07004448 SND_SOC_DAPM_MUX("SLIM TX1 MUX", SND_SOC_NOPM, TAIKO_TX1, 0,
4449 &sb_tx1_mux),
4450 SND_SOC_DAPM_MUX("SLIM TX2 MUX", SND_SOC_NOPM, TAIKO_TX2, 0,
4451 &sb_tx2_mux),
4452 SND_SOC_DAPM_MUX("SLIM TX3 MUX", SND_SOC_NOPM, TAIKO_TX3, 0,
4453 &sb_tx3_mux),
4454 SND_SOC_DAPM_MUX("SLIM TX4 MUX", SND_SOC_NOPM, TAIKO_TX4, 0,
4455 &sb_tx4_mux),
4456 SND_SOC_DAPM_MUX("SLIM TX5 MUX", SND_SOC_NOPM, TAIKO_TX5, 0,
4457 &sb_tx5_mux),
4458 SND_SOC_DAPM_MUX("SLIM TX6 MUX", SND_SOC_NOPM, TAIKO_TX6, 0,
4459 &sb_tx6_mux),
4460 SND_SOC_DAPM_MUX("SLIM TX7 MUX", SND_SOC_NOPM, TAIKO_TX7, 0,
4461 &sb_tx7_mux),
4462 SND_SOC_DAPM_MUX("SLIM TX8 MUX", SND_SOC_NOPM, TAIKO_TX8, 0,
4463 &sb_tx8_mux),
4464 SND_SOC_DAPM_MUX("SLIM TX9 MUX", SND_SOC_NOPM, TAIKO_TX9, 0,
4465 &sb_tx9_mux),
4466 SND_SOC_DAPM_MUX("SLIM TX10 MUX", SND_SOC_NOPM, TAIKO_TX10, 0,
4467 &sb_tx10_mux),
Kiran Kandic3b24402012-06-11 00:05:59 -07004468
4469 /* Digital Mic Inputs */
4470 SND_SOC_DAPM_ADC_E("DMIC1", NULL, SND_SOC_NOPM, 0, 0,
4471 taiko_codec_enable_dmic, SND_SOC_DAPM_PRE_PMU |
4472 SND_SOC_DAPM_POST_PMD),
4473
4474 SND_SOC_DAPM_ADC_E("DMIC2", NULL, SND_SOC_NOPM, 0, 0,
4475 taiko_codec_enable_dmic, SND_SOC_DAPM_PRE_PMU |
4476 SND_SOC_DAPM_POST_PMD),
4477
4478 SND_SOC_DAPM_ADC_E("DMIC3", NULL, SND_SOC_NOPM, 0, 0,
4479 taiko_codec_enable_dmic, SND_SOC_DAPM_PRE_PMU |
4480 SND_SOC_DAPM_POST_PMD),
4481
4482 SND_SOC_DAPM_ADC_E("DMIC4", NULL, SND_SOC_NOPM, 0, 0,
4483 taiko_codec_enable_dmic, SND_SOC_DAPM_PRE_PMU |
4484 SND_SOC_DAPM_POST_PMD),
4485
4486 SND_SOC_DAPM_ADC_E("DMIC5", NULL, SND_SOC_NOPM, 0, 0,
4487 taiko_codec_enable_dmic, SND_SOC_DAPM_PRE_PMU |
4488 SND_SOC_DAPM_POST_PMD),
4489 SND_SOC_DAPM_ADC_E("DMIC6", NULL, SND_SOC_NOPM, 0, 0,
4490 taiko_codec_enable_dmic, SND_SOC_DAPM_PRE_PMU |
4491 SND_SOC_DAPM_POST_PMD),
4492
4493 /* Sidetone */
4494 SND_SOC_DAPM_MUX("IIR1 INP1 MUX", SND_SOC_NOPM, 0, 0, &iir1_inp1_mux),
4495 SND_SOC_DAPM_PGA("IIR1", TAIKO_A_CDC_CLK_SD_CTL, 0, 0, NULL, 0),
4496
4497 /* AUX PGA */
4498 SND_SOC_DAPM_ADC_E("AUX_PGA_Left", NULL, TAIKO_A_RX_AUX_SW_CTL, 7, 0,
4499 taiko_codec_enable_aux_pga, SND_SOC_DAPM_PRE_PMU |
4500 SND_SOC_DAPM_POST_PMD),
4501
4502 SND_SOC_DAPM_ADC_E("AUX_PGA_Right", NULL, TAIKO_A_RX_AUX_SW_CTL, 6, 0,
4503 taiko_codec_enable_aux_pga, SND_SOC_DAPM_PRE_PMU |
4504 SND_SOC_DAPM_POST_PMD),
4505
4506 /* Lineout, ear and HPH PA Mixers */
4507
4508 SND_SOC_DAPM_MIXER("EAR_PA_MIXER", SND_SOC_NOPM, 0, 0,
4509 ear_pa_mix, ARRAY_SIZE(ear_pa_mix)),
4510
4511 SND_SOC_DAPM_MIXER("HPHL_PA_MIXER", SND_SOC_NOPM, 0, 0,
4512 hphl_pa_mix, ARRAY_SIZE(hphl_pa_mix)),
4513
4514 SND_SOC_DAPM_MIXER("HPHR_PA_MIXER", SND_SOC_NOPM, 0, 0,
4515 hphr_pa_mix, ARRAY_SIZE(hphr_pa_mix)),
4516
4517 SND_SOC_DAPM_MIXER("LINEOUT1_PA_MIXER", SND_SOC_NOPM, 0, 0,
4518 lineout1_pa_mix, ARRAY_SIZE(lineout1_pa_mix)),
4519
4520 SND_SOC_DAPM_MIXER("LINEOUT2_PA_MIXER", SND_SOC_NOPM, 0, 0,
4521 lineout2_pa_mix, ARRAY_SIZE(lineout2_pa_mix)),
4522
4523 SND_SOC_DAPM_MIXER("LINEOUT3_PA_MIXER", SND_SOC_NOPM, 0, 0,
4524 lineout3_pa_mix, ARRAY_SIZE(lineout3_pa_mix)),
4525
4526 SND_SOC_DAPM_MIXER("LINEOUT4_PA_MIXER", SND_SOC_NOPM, 0, 0,
4527 lineout4_pa_mix, ARRAY_SIZE(lineout4_pa_mix)),
4528
4529};
4530
Kiran Kandic3b24402012-06-11 00:05:59 -07004531static irqreturn_t taiko_slimbus_irq(int irq, void *data)
4532{
4533 struct taiko_priv *priv = data;
4534 struct snd_soc_codec *codec = priv->codec;
Joonwoo Park9bbb4d12012-11-09 19:58:11 -08004535 unsigned long status = 0;
4536 int i, j, port_id, k;
4537 u32 bit;
Kiran Kandic3b24402012-06-11 00:05:59 -07004538 u8 val;
Joonwoo Park9bbb4d12012-11-09 19:58:11 -08004539 bool tx, cleared;
Kiran Kandic3b24402012-06-11 00:05:59 -07004540
Joonwoo Park9bbb4d12012-11-09 19:58:11 -08004541 for (i = TAIKO_SLIM_PGD_PORT_INT_STATUS_RX_0, j = 0;
4542 i <= TAIKO_SLIM_PGD_PORT_INT_STATUS_TX_1; i++, j++) {
4543 val = wcd9xxx_interface_reg_read(codec->control_data, i);
4544 status |= ((u32)val << (8 * j));
4545 }
4546
4547 for_each_set_bit(j, &status, 32) {
4548 tx = (j >= 16 ? true : false);
4549 port_id = (tx ? j - 16 : j);
4550 val = wcd9xxx_interface_reg_read(codec->control_data,
4551 TAIKO_SLIM_PGD_PORT_INT_RX_SOURCE0 + j);
4552 if (val & TAIKO_SLIM_IRQ_OVERFLOW)
4553 pr_err_ratelimited(
4554 "%s: overflow error on %s port %d, value %x\n",
4555 __func__, (tx ? "TX" : "RX"), port_id, val);
4556 if (val & TAIKO_SLIM_IRQ_UNDERFLOW)
4557 pr_err_ratelimited(
4558 "%s: underflow error on %s port %d, value %x\n",
4559 __func__, (tx ? "TX" : "RX"), port_id, val);
4560 if (val & TAIKO_SLIM_IRQ_PORT_CLOSED) {
4561 /*
4562 * INT SOURCE register starts from RX to TX
4563 * but port number in the ch_mask is in opposite way
4564 */
4565 bit = (tx ? j - 16 : j + 16);
4566 pr_debug("%s: %s port %d closed value %x, bit %u\n",
4567 __func__, (tx ? "TX" : "RX"), port_id, val,
4568 bit);
4569 for (k = 0, cleared = false; k < NUM_CODEC_DAIS; k++) {
4570 pr_debug("%s: priv->dai[%d].ch_mask = 0x%lx\n",
4571 __func__, k, priv->dai[k].ch_mask);
4572 if (test_and_clear_bit(bit,
4573 &priv->dai[k].ch_mask)) {
4574 cleared = true;
4575 if (!priv->dai[k].ch_mask)
4576 wake_up(&priv->dai[k].dai_wait);
4577 /*
4578 * There are cases when multiple DAIs
4579 * might be using the same slimbus
4580 * channel. Hence don't break here.
4581 */
4582 }
4583 }
4584 WARN(!cleared,
4585 "Couldn't find slimbus %s port %d for closing\n",
4586 (tx ? "TX" : "RX"), port_id);
Kiran Kandic3b24402012-06-11 00:05:59 -07004587 }
4588 wcd9xxx_interface_reg_write(codec->control_data,
Joonwoo Park9bbb4d12012-11-09 19:58:11 -08004589 TAIKO_SLIM_PGD_PORT_INT_CLR_RX_0 +
4590 (j / 8),
4591 1 << (j % 8));
Joonwoo Parka8890262012-10-15 12:04:27 -07004592 }
Joonwoo Park9bbb4d12012-11-09 19:58:11 -08004593
Kiran Kandic3b24402012-06-11 00:05:59 -07004594 return IRQ_HANDLED;
4595}
4596
4597static int taiko_handle_pdata(struct taiko_priv *taiko)
4598{
4599 struct snd_soc_codec *codec = taiko->codec;
Joonwoo Parka8890262012-10-15 12:04:27 -07004600 struct wcd9xxx_pdata *pdata = taiko->resmgr.pdata;
Kiran Kandic3b24402012-06-11 00:05:59 -07004601 int k1, k2, k3, rc = 0;
Kiran Kandi725f8492012-08-06 13:45:16 -07004602 u8 leg_mode, txfe_bypass, txfe_buff, flag;
Kiran Kandic3b24402012-06-11 00:05:59 -07004603 u8 i = 0, j = 0;
4604 u8 val_txfe = 0, value = 0;
4605
4606 if (!pdata) {
Kiran Kandi725f8492012-08-06 13:45:16 -07004607 pr_err("%s: NULL pdata\n", __func__);
Kiran Kandic3b24402012-06-11 00:05:59 -07004608 rc = -ENODEV;
4609 goto done;
4610 }
4611
Kiran Kandi725f8492012-08-06 13:45:16 -07004612 leg_mode = pdata->amic_settings.legacy_mode;
4613 txfe_bypass = pdata->amic_settings.txfe_enable;
4614 txfe_buff = pdata->amic_settings.txfe_buff;
4615 flag = pdata->amic_settings.use_pdata;
4616
Kiran Kandic3b24402012-06-11 00:05:59 -07004617 /* Make sure settings are correct */
Joonwoo Parka8890262012-10-15 12:04:27 -07004618 if ((pdata->micbias.ldoh_v > WCD9XXX_LDOH_3P0_V) ||
4619 (pdata->micbias.bias1_cfilt_sel > WCD9XXX_CFILT3_SEL) ||
4620 (pdata->micbias.bias2_cfilt_sel > WCD9XXX_CFILT3_SEL) ||
4621 (pdata->micbias.bias3_cfilt_sel > WCD9XXX_CFILT3_SEL) ||
4622 (pdata->micbias.bias4_cfilt_sel > WCD9XXX_CFILT3_SEL)) {
Kiran Kandic3b24402012-06-11 00:05:59 -07004623 rc = -EINVAL;
4624 goto done;
4625 }
Kiran Kandic3b24402012-06-11 00:05:59 -07004626 /* figure out k value */
Joonwoo Parka8890262012-10-15 12:04:27 -07004627 k1 = wcd9xxx_resmgr_get_k_val(&taiko->resmgr, pdata->micbias.cfilt1_mv);
4628 k2 = wcd9xxx_resmgr_get_k_val(&taiko->resmgr, pdata->micbias.cfilt2_mv);
4629 k3 = wcd9xxx_resmgr_get_k_val(&taiko->resmgr, pdata->micbias.cfilt3_mv);
Kiran Kandic3b24402012-06-11 00:05:59 -07004630
4631 if (IS_ERR_VALUE(k1) || IS_ERR_VALUE(k2) || IS_ERR_VALUE(k3)) {
4632 rc = -EINVAL;
4633 goto done;
4634 }
Kiran Kandic3b24402012-06-11 00:05:59 -07004635 /* Set voltage level and always use LDO */
4636 snd_soc_update_bits(codec, TAIKO_A_LDO_H_MODE_1, 0x0C,
Joonwoo Parka8890262012-10-15 12:04:27 -07004637 (pdata->micbias.ldoh_v << 2));
Kiran Kandic3b24402012-06-11 00:05:59 -07004638
Joonwoo Parka8890262012-10-15 12:04:27 -07004639 snd_soc_update_bits(codec, TAIKO_A_MICB_CFILT_1_VAL, 0xFC, (k1 << 2));
4640 snd_soc_update_bits(codec, TAIKO_A_MICB_CFILT_2_VAL, 0xFC, (k2 << 2));
4641 snd_soc_update_bits(codec, TAIKO_A_MICB_CFILT_3_VAL, 0xFC, (k3 << 2));
Kiran Kandic3b24402012-06-11 00:05:59 -07004642
4643 snd_soc_update_bits(codec, TAIKO_A_MICB_1_CTL, 0x60,
Joonwoo Parka8890262012-10-15 12:04:27 -07004644 (pdata->micbias.bias1_cfilt_sel << 5));
Kiran Kandic3b24402012-06-11 00:05:59 -07004645 snd_soc_update_bits(codec, TAIKO_A_MICB_2_CTL, 0x60,
Joonwoo Parka8890262012-10-15 12:04:27 -07004646 (pdata->micbias.bias2_cfilt_sel << 5));
Kiran Kandic3b24402012-06-11 00:05:59 -07004647 snd_soc_update_bits(codec, TAIKO_A_MICB_3_CTL, 0x60,
Joonwoo Parka8890262012-10-15 12:04:27 -07004648 (pdata->micbias.bias3_cfilt_sel << 5));
4649 snd_soc_update_bits(codec, taiko->resmgr.reg_addr->micb_4_ctl, 0x60,
Kiran Kandic3b24402012-06-11 00:05:59 -07004650 (pdata->micbias.bias4_cfilt_sel << 5));
4651
4652 for (i = 0; i < 6; j++, i += 2) {
4653 if (flag & (0x01 << i)) {
4654 value = (leg_mode & (0x01 << i)) ? 0x10 : 0x00;
4655 val_txfe = (txfe_bypass & (0x01 << i)) ? 0x20 : 0x00;
4656 val_txfe = val_txfe |
4657 ((txfe_buff & (0x01 << i)) ? 0x10 : 0x00);
4658 snd_soc_update_bits(codec, TAIKO_A_TX_1_2_EN + j * 10,
4659 0x10, value);
4660 snd_soc_update_bits(codec,
4661 TAIKO_A_TX_1_2_TEST_EN + j * 10,
4662 0x30, val_txfe);
4663 }
4664 if (flag & (0x01 << (i + 1))) {
4665 value = (leg_mode & (0x01 << (i + 1))) ? 0x01 : 0x00;
4666 val_txfe = (txfe_bypass &
4667 (0x01 << (i + 1))) ? 0x02 : 0x00;
4668 val_txfe |= (txfe_buff &
4669 (0x01 << (i + 1))) ? 0x01 : 0x00;
4670 snd_soc_update_bits(codec, TAIKO_A_TX_1_2_EN + j * 10,
4671 0x01, value);
4672 snd_soc_update_bits(codec,
4673 TAIKO_A_TX_1_2_TEST_EN + j * 10,
4674 0x03, val_txfe);
4675 }
4676 }
4677 if (flag & 0x40) {
4678 value = (leg_mode & 0x40) ? 0x10 : 0x00;
4679 value = value | ((txfe_bypass & 0x40) ? 0x02 : 0x00);
4680 value = value | ((txfe_buff & 0x40) ? 0x01 : 0x00);
4681 snd_soc_update_bits(codec, TAIKO_A_TX_7_MBHC_EN,
4682 0x13, value);
4683 }
4684
4685 if (pdata->ocp.use_pdata) {
4686 /* not defined in CODEC specification */
4687 if (pdata->ocp.hph_ocp_limit == 1 ||
4688 pdata->ocp.hph_ocp_limit == 5) {
4689 rc = -EINVAL;
4690 goto done;
4691 }
4692 snd_soc_update_bits(codec, TAIKO_A_RX_COM_OCP_CTL,
4693 0x0F, pdata->ocp.num_attempts);
4694 snd_soc_write(codec, TAIKO_A_RX_COM_OCP_COUNT,
4695 ((pdata->ocp.run_time << 4) | pdata->ocp.wait_time));
4696 snd_soc_update_bits(codec, TAIKO_A_RX_HPH_OCP_CTL,
4697 0xE0, (pdata->ocp.hph_ocp_limit << 5));
4698 }
4699
4700 for (i = 0; i < ARRAY_SIZE(pdata->regulator); i++) {
4701 if (!strncmp(pdata->regulator[i].name, "CDC_VDDA_RX", 11)) {
4702 if (pdata->regulator[i].min_uV == 1800000 &&
4703 pdata->regulator[i].max_uV == 1800000) {
4704 snd_soc_write(codec, TAIKO_A_BIAS_REF_CTL,
4705 0x1C);
4706 } else if (pdata->regulator[i].min_uV == 2200000 &&
4707 pdata->regulator[i].max_uV == 2200000) {
4708 snd_soc_write(codec, TAIKO_A_BIAS_REF_CTL,
4709 0x1E);
4710 } else {
4711 pr_err("%s: unsupported CDC_VDDA_RX voltage\n"
4712 "min %d, max %d\n", __func__,
4713 pdata->regulator[i].min_uV,
4714 pdata->regulator[i].max_uV);
4715 rc = -EINVAL;
4716 }
4717 break;
4718 }
4719 }
Kiran Kandi4c56c592012-07-25 11:04:55 -07004720
Joonwoo Park1848c762012-10-18 13:16:01 -07004721 /* Set micbias capless mode with tail current */
4722 value = (pdata->micbias.bias1_cap_mode == MICBIAS_EXT_BYP_CAP ?
4723 0x00 : 0x16);
4724 snd_soc_update_bits(codec, TAIKO_A_MICB_1_CTL, 0x1E, value);
4725 value = (pdata->micbias.bias2_cap_mode == MICBIAS_EXT_BYP_CAP ?
4726 0x00 : 0x16);
4727 snd_soc_update_bits(codec, TAIKO_A_MICB_2_CTL, 0x1E, value);
4728 value = (pdata->micbias.bias3_cap_mode == MICBIAS_EXT_BYP_CAP ?
4729 0x00 : 0x16);
4730 snd_soc_update_bits(codec, TAIKO_A_MICB_3_CTL, 0x1E, value);
4731 value = (pdata->micbias.bias4_cap_mode == MICBIAS_EXT_BYP_CAP ?
4732 0x00 : 0x16);
4733 snd_soc_update_bits(codec, TAIKO_A_MICB_4_CTL, 0x1E, value);
4734
Kiran Kandic3b24402012-06-11 00:05:59 -07004735done:
4736 return rc;
4737}
4738
Bhalchandra Gajare87fef4c2013-02-19 14:57:03 -08004739static const struct wcd9xxx_reg_mask_val taiko_reg_defaults[] = {
Kiran Kandic3b24402012-06-11 00:05:59 -07004740
Kiran Kandi4c56c592012-07-25 11:04:55 -07004741 /* set MCLk to 9.6 */
Gopikrishnaiah Anandana8aec1f2013-01-23 14:26:27 -05004742 TAIKO_REG_VAL(TAIKO_A_CHIP_CTL, 0x02),
Kiran Kandi4c56c592012-07-25 11:04:55 -07004743 TAIKO_REG_VAL(TAIKO_A_CDC_CLK_POWER_CTL, 0x03),
Kiran Kandic3b24402012-06-11 00:05:59 -07004744
Kiran Kandi4c56c592012-07-25 11:04:55 -07004745 /* EAR PA deafults */
4746 TAIKO_REG_VAL(TAIKO_A_RX_EAR_CMBUFF, 0x05),
Kiran Kandic3b24402012-06-11 00:05:59 -07004747
Kiran Kandi4c56c592012-07-25 11:04:55 -07004748 /* RX deafults */
Kiran Kandic3b24402012-06-11 00:05:59 -07004749 TAIKO_REG_VAL(TAIKO_A_CDC_RX1_B5_CTL, 0x78),
4750 TAIKO_REG_VAL(TAIKO_A_CDC_RX2_B5_CTL, 0x78),
4751 TAIKO_REG_VAL(TAIKO_A_CDC_RX3_B5_CTL, 0x78),
4752 TAIKO_REG_VAL(TAIKO_A_CDC_RX4_B5_CTL, 0x78),
4753 TAIKO_REG_VAL(TAIKO_A_CDC_RX5_B5_CTL, 0x78),
4754 TAIKO_REG_VAL(TAIKO_A_CDC_RX6_B5_CTL, 0x78),
4755 TAIKO_REG_VAL(TAIKO_A_CDC_RX7_B5_CTL, 0x78),
4756
Kiran Kandi4c56c592012-07-25 11:04:55 -07004757 /* RX1 and RX2 defaults */
Kiran Kandic3b24402012-06-11 00:05:59 -07004758 TAIKO_REG_VAL(TAIKO_A_CDC_RX1_B6_CTL, 0xA0),
4759 TAIKO_REG_VAL(TAIKO_A_CDC_RX2_B6_CTL, 0xA0),
4760
Kiran Kandi4c56c592012-07-25 11:04:55 -07004761 /* RX3 to RX7 defaults */
Kiran Kandic3b24402012-06-11 00:05:59 -07004762 TAIKO_REG_VAL(TAIKO_A_CDC_RX3_B6_CTL, 0x80),
4763 TAIKO_REG_VAL(TAIKO_A_CDC_RX4_B6_CTL, 0x80),
4764 TAIKO_REG_VAL(TAIKO_A_CDC_RX5_B6_CTL, 0x80),
4765 TAIKO_REG_VAL(TAIKO_A_CDC_RX6_B6_CTL, 0x80),
4766 TAIKO_REG_VAL(TAIKO_A_CDC_RX7_B6_CTL, 0x80),
Kiran Kandic3b24402012-06-11 00:05:59 -07004767};
4768
Bhalchandra Gajare87fef4c2013-02-19 14:57:03 -08004769static const struct wcd9xxx_reg_mask_val taiko_1_0_reg_defaults[] = {
Kiran Kandi7b7d2ff2012-09-14 14:52:14 -07004770 /*
4771 * The following only need to be written for Taiko 1.0 parts.
4772 * Taiko 2.0 will have appropriate defaults for these registers.
4773 */
Joonwoo Park559a5bf2013-02-15 14:46:36 -08004774
4775 /* BUCK default */
Bhalchandra Gajare87fef4c2013-02-19 14:57:03 -08004776 TAIKO_REG_VAL(WCD9XXX_A_BUCK_CTRL_CCL_4, 0x50),
4777
4778 /* Required defaults for class H operation */
4779 TAIKO_REG_VAL(TAIKO_A_RX_HPH_CHOP_CTL, 0xF4),
4780 TAIKO_REG_VAL(TAIKO_A_BIAS_CURR_CTL_2, 0x08),
4781 TAIKO_REG_VAL(WCD9XXX_A_BUCK_CTRL_CCL_1, 0x5B),
4782 TAIKO_REG_VAL(WCD9XXX_A_BUCK_CTRL_CCL_3, 0x60),
Joonwoo Park559a5bf2013-02-15 14:46:36 -08004783
Kiran Kandi7b7d2ff2012-09-14 14:52:14 -07004784 /* Choose max non-overlap time for NCP */
4785 TAIKO_REG_VAL(TAIKO_A_NCP_CLK, 0xFC),
4786 /* Use 25mV/50mV for deltap/m to reduce ripple */
Bhalchandra Gajare87fef4c2013-02-19 14:57:03 -08004787 TAIKO_REG_VAL(WCD9XXX_A_BUCK_CTRL_VCL_1, 0x08),
Kiran Kandi7b7d2ff2012-09-14 14:52:14 -07004788 /*
4789 * Set DISABLE_MODE_SEL<1:0> to 0b10 (disable PWM in auto mode).
4790 * Note that the other bits of this register will be changed during
4791 * Rx PA bring up.
4792 */
Bhalchandra Gajare87fef4c2013-02-19 14:57:03 -08004793 TAIKO_REG_VAL(WCD9XXX_A_BUCK_MODE_3, 0xCE),
Kiran Kandi7b7d2ff2012-09-14 14:52:14 -07004794 /* Reduce HPH DAC bias to 70% */
4795 TAIKO_REG_VAL(TAIKO_A_RX_HPH_BIAS_PA, 0x7A),
4796 /*Reduce EAR DAC bias to 70% */
4797 TAIKO_REG_VAL(TAIKO_A_RX_EAR_BIAS_PA, 0x76),
4798 /* Reduce LINE DAC bias to 70% */
4799 TAIKO_REG_VAL(TAIKO_A_RX_LINE_BIAS_PA, 0x78),
Joonwoo Parkd87ec4c2012-10-30 15:44:18 -07004800
4801 /*
4802 * There is a diode to pull down the micbias while doing
4803 * insertion detection. This diode can cause leakage.
4804 * Set bit 0 to 1 to prevent leakage.
4805 * Setting this bit of micbias 2 prevents leakage for all other micbias.
4806 */
4807 TAIKO_REG_VAL(TAIKO_A_MICB_2_MBHC, 0x41),
Joonwoo Park3c7bca62012-10-31 12:44:23 -07004808
4809 /* Disable TX7 internal biasing path which can cause leakage */
4810 TAIKO_REG_VAL(TAIKO_A_TX_SUP_SWITCH_CTRL_1, 0xBF),
Joonwoo Park03604052012-11-06 18:40:25 -08004811 /* Enable MICB 4 VDDIO switch to prevent leakage */
4812 TAIKO_REG_VAL(TAIKO_A_MICB_4_MBHC, 0x81),
Joonwoo Park125cd4e2012-12-11 15:16:11 -08004813
4814 /* Close leakage on the spkdrv */
4815 TAIKO_REG_VAL(TAIKO_A_SPKR_DRV_DBG_PWRSTG, 0x24),
Kiran Kandi7b7d2ff2012-09-14 14:52:14 -07004816};
4817
Joonwoo Park559a5bf2013-02-15 14:46:36 -08004818/*
4819 * Don't update TAIKO_A_CHIP_CTL, TAIKO_A_BUCK_CTRL_CCL_1 and
4820 * TAIKO_A_RX_EAR_CMBUFF as those are updated in taiko_reg_defaults
4821 */
Bhalchandra Gajare87fef4c2013-02-19 14:57:03 -08004822static const struct wcd9xxx_reg_mask_val taiko_2_0_reg_defaults[] = {
Joonwoo Park559a5bf2013-02-15 14:46:36 -08004823 TAIKO_REG_VAL(TAIKO_A_CDC_TX_1_GAIN, 0x2),
4824 TAIKO_REG_VAL(TAIKO_A_CDC_TX_2_GAIN, 0x2),
4825 TAIKO_REG_VAL(TAIKO_A_CDC_TX_1_2_ADC_IB, 0x44),
4826 TAIKO_REG_VAL(TAIKO_A_CDC_TX_3_GAIN, 0x2),
4827 TAIKO_REG_VAL(TAIKO_A_CDC_TX_4_GAIN, 0x2),
4828 TAIKO_REG_VAL(TAIKO_A_CDC_TX_3_4_ADC_IB, 0x44),
4829 TAIKO_REG_VAL(TAIKO_A_CDC_TX_5_GAIN, 0x2),
4830 TAIKO_REG_VAL(TAIKO_A_CDC_TX_6_GAIN, 0x2),
4831 TAIKO_REG_VAL(TAIKO_A_CDC_TX_5_6_ADC_IB, 0x44),
Bhalchandra Gajare87fef4c2013-02-19 14:57:03 -08004832 TAIKO_REG_VAL(WCD9XXX_A_BUCK_MODE_3, 0xCE),
4833 TAIKO_REG_VAL(WCD9XXX_A_BUCK_CTRL_VCL_1, 0x8),
4834 TAIKO_REG_VAL(WCD9XXX_A_BUCK_CTRL_CCL_4, 0x51),
Joonwoo Park559a5bf2013-02-15 14:46:36 -08004835 TAIKO_REG_VAL(TAIKO_A_NCP_DTEST, 0x10),
4836 TAIKO_REG_VAL(TAIKO_A_RX_HPH_CHOP_CTL, 0xA4),
4837 TAIKO_REG_VAL(TAIKO_A_RX_HPH_BIAS_PA, 0x7A),
4838 TAIKO_REG_VAL(TAIKO_A_RX_HPH_OCP_CTL, 0x69),
4839 TAIKO_REG_VAL(TAIKO_A_RX_HPH_CNP_WG_CTL, 0xDA),
4840 TAIKO_REG_VAL(TAIKO_A_RX_HPH_CNP_WG_TIME, 0x15),
4841 TAIKO_REG_VAL(TAIKO_A_RX_EAR_BIAS_PA, 0x76),
4842 TAIKO_REG_VAL(TAIKO_A_RX_EAR_CNP, 0xC0),
4843 TAIKO_REG_VAL(TAIKO_A_RX_LINE_BIAS_PA, 0x78),
4844 TAIKO_REG_VAL(TAIKO_A_RX_LINE_1_TEST, 0x2),
4845 TAIKO_REG_VAL(TAIKO_A_RX_LINE_2_TEST, 0x2),
4846 TAIKO_REG_VAL(TAIKO_A_RX_LINE_3_TEST, 0x2),
4847 TAIKO_REG_VAL(TAIKO_A_RX_LINE_4_TEST, 0x2),
4848 TAIKO_REG_VAL(TAIKO_A_SPKR_DRV_OCP_CTL, 0x97),
4849 TAIKO_REG_VAL(TAIKO_A_SPKR_DRV_CLIP_DET, 0x1),
4850 TAIKO_REG_VAL(TAIKO_A_SPKR_DRV_IEC, 0x0),
4851 TAIKO_REG_VAL(TAIKO_A_CDC_TX1_MUX_CTL, 0x48),
4852 TAIKO_REG_VAL(TAIKO_A_CDC_TX2_MUX_CTL, 0x48),
4853 TAIKO_REG_VAL(TAIKO_A_CDC_TX3_MUX_CTL, 0x48),
4854 TAIKO_REG_VAL(TAIKO_A_CDC_TX4_MUX_CTL, 0x48),
4855 TAIKO_REG_VAL(TAIKO_A_CDC_TX5_MUX_CTL, 0x48),
4856 TAIKO_REG_VAL(TAIKO_A_CDC_TX6_MUX_CTL, 0x48),
4857 TAIKO_REG_VAL(TAIKO_A_CDC_TX7_MUX_CTL, 0x48),
4858 TAIKO_REG_VAL(TAIKO_A_CDC_TX8_MUX_CTL, 0x48),
4859 TAIKO_REG_VAL(TAIKO_A_CDC_TX9_MUX_CTL, 0x48),
4860 TAIKO_REG_VAL(TAIKO_A_CDC_TX10_MUX_CTL, 0x48),
4861 TAIKO_REG_VAL(TAIKO_A_CDC_RX1_B4_CTL, 0x8),
4862 TAIKO_REG_VAL(TAIKO_A_CDC_VBAT_GAIN_UPD_MON, 0x0),
4863 TAIKO_REG_VAL(TAIKO_A_CDC_PA_RAMP_B1_CTL, 0x0),
4864 TAIKO_REG_VAL(TAIKO_A_CDC_PA_RAMP_B2_CTL, 0x0),
4865 TAIKO_REG_VAL(TAIKO_A_CDC_PA_RAMP_B3_CTL, 0x0),
4866 TAIKO_REG_VAL(TAIKO_A_CDC_PA_RAMP_B4_CTL, 0x0),
4867 TAIKO_REG_VAL(TAIKO_A_CDC_SPKR_CLIPDET_B1_CTL, 0x0),
4868 TAIKO_REG_VAL(TAIKO_A_CDC_COMP0_B4_CTL, 0x37),
4869 TAIKO_REG_VAL(TAIKO_A_CDC_COMP0_B5_CTL, 0x7f),
4870};
4871
Kiran Kandic3b24402012-06-11 00:05:59 -07004872static void taiko_update_reg_defaults(struct snd_soc_codec *codec)
4873{
4874 u32 i;
Kiran Kandi7b7d2ff2012-09-14 14:52:14 -07004875 struct wcd9xxx *taiko_core = dev_get_drvdata(codec->dev->parent);
Kiran Kandic3b24402012-06-11 00:05:59 -07004876
Kiran Kandi7b7d2ff2012-09-14 14:52:14 -07004877 for (i = 0; i < ARRAY_SIZE(taiko_reg_defaults); i++)
4878 snd_soc_write(codec, taiko_reg_defaults[i].reg,
Joonwoo Park559a5bf2013-02-15 14:46:36 -08004879 taiko_reg_defaults[i].val);
Kiran Kandi7b7d2ff2012-09-14 14:52:14 -07004880
4881 if (TAIKO_IS_1_0(taiko_core->version)) {
4882 for (i = 0; i < ARRAY_SIZE(taiko_1_0_reg_defaults); i++)
4883 snd_soc_write(codec, taiko_1_0_reg_defaults[i].reg,
Joonwoo Park559a5bf2013-02-15 14:46:36 -08004884 taiko_1_0_reg_defaults[i].val);
4885 if (spkr_drv_wrnd == 1)
4886 snd_soc_write(codec, TAIKO_A_SPKR_DRV_EN, 0xEF);
4887 } else {
4888 for (i = 0; i < ARRAY_SIZE(taiko_2_0_reg_defaults); i++)
4889 snd_soc_write(codec, taiko_2_0_reg_defaults[i].reg,
4890 taiko_2_0_reg_defaults[i].val);
Joonwoo Park125cd4e2012-12-11 15:16:11 -08004891 spkr_drv_wrnd = -1;
Joonwoo Park559a5bf2013-02-15 14:46:36 -08004892 }
Kiran Kandic3b24402012-06-11 00:05:59 -07004893}
4894
Bhalchandra Gajare87fef4c2013-02-19 14:57:03 -08004895static const struct wcd9xxx_reg_mask_val taiko_codec_reg_init_val[] = {
Kiran Kandic3b24402012-06-11 00:05:59 -07004896 /* Initialize current threshold to 350MA
4897 * number of wait and run cycles to 4096
4898 */
Kiran Kandi7b7d2ff2012-09-14 14:52:14 -07004899 {TAIKO_A_RX_HPH_OCP_CTL, 0xE1, 0x61},
Kiran Kandic3b24402012-06-11 00:05:59 -07004900 {TAIKO_A_RX_COM_OCP_COUNT, 0xFF, 0xFF},
Patrick Lai92833bf2012-12-01 10:31:35 -08004901 {TAIKO_A_RX_HPH_L_TEST, 0x01, 0x01},
4902 {TAIKO_A_RX_HPH_R_TEST, 0x01, 0x01},
Kiran Kandic3b24402012-06-11 00:05:59 -07004903
Kiran Kandic3b24402012-06-11 00:05:59 -07004904 /* Initialize gain registers to use register gain */
Kiran Kandi4c56c592012-07-25 11:04:55 -07004905 {TAIKO_A_RX_HPH_L_GAIN, 0x20, 0x20},
4906 {TAIKO_A_RX_HPH_R_GAIN, 0x20, 0x20},
4907 {TAIKO_A_RX_LINE_1_GAIN, 0x20, 0x20},
4908 {TAIKO_A_RX_LINE_2_GAIN, 0x20, 0x20},
4909 {TAIKO_A_RX_LINE_3_GAIN, 0x20, 0x20},
4910 {TAIKO_A_RX_LINE_4_GAIN, 0x20, 0x20},
Joonwoo Parkc7731432012-10-17 12:41:44 -07004911 {TAIKO_A_SPKR_DRV_GAIN, 0x04, 0x04},
Kiran Kandic3b24402012-06-11 00:05:59 -07004912
Kiran Kandic3b24402012-06-11 00:05:59 -07004913 /* Use 16 bit sample size for TX1 to TX6 */
4914 {TAIKO_A_CDC_CONN_TX_SB_B1_CTL, 0x30, 0x20},
4915 {TAIKO_A_CDC_CONN_TX_SB_B2_CTL, 0x30, 0x20},
4916 {TAIKO_A_CDC_CONN_TX_SB_B3_CTL, 0x30, 0x20},
4917 {TAIKO_A_CDC_CONN_TX_SB_B4_CTL, 0x30, 0x20},
4918 {TAIKO_A_CDC_CONN_TX_SB_B5_CTL, 0x30, 0x20},
4919 {TAIKO_A_CDC_CONN_TX_SB_B6_CTL, 0x30, 0x20},
4920
4921 /* Use 16 bit sample size for TX7 to TX10 */
4922 {TAIKO_A_CDC_CONN_TX_SB_B7_CTL, 0x60, 0x40},
4923 {TAIKO_A_CDC_CONN_TX_SB_B8_CTL, 0x60, 0x40},
4924 {TAIKO_A_CDC_CONN_TX_SB_B9_CTL, 0x60, 0x40},
4925 {TAIKO_A_CDC_CONN_TX_SB_B10_CTL, 0x60, 0x40},
4926
Kiran Kandic3b24402012-06-11 00:05:59 -07004927 /*enable HPF filter for TX paths */
4928 {TAIKO_A_CDC_TX1_MUX_CTL, 0x8, 0x0},
4929 {TAIKO_A_CDC_TX2_MUX_CTL, 0x8, 0x0},
4930 {TAIKO_A_CDC_TX3_MUX_CTL, 0x8, 0x0},
4931 {TAIKO_A_CDC_TX4_MUX_CTL, 0x8, 0x0},
4932 {TAIKO_A_CDC_TX5_MUX_CTL, 0x8, 0x0},
4933 {TAIKO_A_CDC_TX6_MUX_CTL, 0x8, 0x0},
4934 {TAIKO_A_CDC_TX7_MUX_CTL, 0x8, 0x0},
4935 {TAIKO_A_CDC_TX8_MUX_CTL, 0x8, 0x0},
4936 {TAIKO_A_CDC_TX9_MUX_CTL, 0x8, 0x0},
4937 {TAIKO_A_CDC_TX10_MUX_CTL, 0x8, 0x0},
4938
Kiran Kandi4c56c592012-07-25 11:04:55 -07004939 /* config Decimator for DMIC CLK_MODE_1(3.2Mhz@9.6Mhz mclk) */
4940 {TAIKO_A_CDC_TX1_DMIC_CTL, 0x7, 0x1},
4941 {TAIKO_A_CDC_TX2_DMIC_CTL, 0x7, 0x1},
4942 {TAIKO_A_CDC_TX3_DMIC_CTL, 0x7, 0x1},
4943 {TAIKO_A_CDC_TX4_DMIC_CTL, 0x7, 0x1},
4944 {TAIKO_A_CDC_TX5_DMIC_CTL, 0x7, 0x1},
4945 {TAIKO_A_CDC_TX6_DMIC_CTL, 0x7, 0x1},
4946 {TAIKO_A_CDC_TX7_DMIC_CTL, 0x7, 0x1},
4947 {TAIKO_A_CDC_TX8_DMIC_CTL, 0x7, 0x1},
4948 {TAIKO_A_CDC_TX9_DMIC_CTL, 0x7, 0x1},
4949 {TAIKO_A_CDC_TX10_DMIC_CTL, 0x7, 0x1},
Kiran Kandic3b24402012-06-11 00:05:59 -07004950
Kiran Kandi4c56c592012-07-25 11:04:55 -07004951 /* config DMIC clk to CLK_MODE_1 (3.2Mhz@9.6Mhz mclk) */
4952 {TAIKO_A_CDC_CLK_DMIC_B1_CTL, 0xEE, 0x22},
4953 {TAIKO_A_CDC_CLK_DMIC_B2_CTL, 0x0E, 0x02},
4954
Joonwoo Parkc7731432012-10-17 12:41:44 -07004955 /* Compander zone selection */
4956 {TAIKO_A_CDC_COMP0_B4_CTL, 0x3F, 0x37},
4957 {TAIKO_A_CDC_COMP1_B4_CTL, 0x3F, 0x37},
4958 {TAIKO_A_CDC_COMP2_B4_CTL, 0x3F, 0x37},
4959 {TAIKO_A_CDC_COMP0_B5_CTL, 0x7F, 0x7F},
4960 {TAIKO_A_CDC_COMP1_B5_CTL, 0x7F, 0x7F},
4961 {TAIKO_A_CDC_COMP2_B5_CTL, 0x7F, 0x7F},
Kiran Kandic3b24402012-06-11 00:05:59 -07004962};
4963
4964static void taiko_codec_init_reg(struct snd_soc_codec *codec)
4965{
4966 u32 i;
4967
4968 for (i = 0; i < ARRAY_SIZE(taiko_codec_reg_init_val); i++)
4969 snd_soc_update_bits(codec, taiko_codec_reg_init_val[i].reg,
4970 taiko_codec_reg_init_val[i].mask,
4971 taiko_codec_reg_init_val[i].val);
4972}
4973
Joonwoo Park7680b9f2012-07-13 11:36:48 -07004974static int taiko_setup_irqs(struct taiko_priv *taiko)
4975{
Joonwoo Park7680b9f2012-07-13 11:36:48 -07004976 int i;
Joonwoo Parka8890262012-10-15 12:04:27 -07004977 int ret = 0;
Joonwoo Park7680b9f2012-07-13 11:36:48 -07004978 struct snd_soc_codec *codec = taiko->codec;
4979
Joonwoo Parkf6574c72012-10-10 17:29:57 -07004980 ret = wcd9xxx_request_irq(codec->control_data, WCD9XXX_IRQ_SLIMBUS,
Joonwoo Park7680b9f2012-07-13 11:36:48 -07004981 taiko_slimbus_irq, "SLIMBUS Slave", taiko);
4982 if (ret) {
4983 pr_err("%s: Failed to request irq %d\n", __func__,
Joonwoo Parkf6574c72012-10-10 17:29:57 -07004984 WCD9XXX_IRQ_SLIMBUS);
Joonwoo Parka8890262012-10-15 12:04:27 -07004985 goto exit;
Joonwoo Park7680b9f2012-07-13 11:36:48 -07004986 }
4987
4988 for (i = 0; i < WCD9XXX_SLIM_NUM_PORT_REG; i++)
4989 wcd9xxx_interface_reg_write(codec->control_data,
Joonwoo Parka8890262012-10-15 12:04:27 -07004990 TAIKO_SLIM_PGD_PORT_INT_EN0 + i,
4991 0xFF);
4992exit:
Joonwoo Park7680b9f2012-07-13 11:36:48 -07004993 return ret;
4994}
4995
Joonwoo Parka8890262012-10-15 12:04:27 -07004996int taiko_hs_detect(struct snd_soc_codec *codec,
4997 struct wcd9xxx_mbhc_config *mbhc_cfg)
4998{
4999 struct taiko_priv *taiko = snd_soc_codec_get_drvdata(codec);
5000 return wcd9xxx_mbhc_start(&taiko->mbhc, mbhc_cfg);
5001}
5002EXPORT_SYMBOL_GPL(taiko_hs_detect);
5003
Ravishankar Sarawadi839fcf32012-11-14 12:13:00 -08005004static int taiko_post_reset_cb(struct wcd9xxx *wcd9xxx)
5005{
5006 int ret = 0;
5007 struct snd_soc_codec *codec;
5008 struct taiko_priv *taiko;
5009
5010 codec = (struct snd_soc_codec *)(wcd9xxx->ssr_priv);
5011 taiko = snd_soc_codec_get_drvdata(codec);
5012 mutex_lock(&codec->mutex);
5013 WCD9XXX_BCL_LOCK(&taiko->resmgr);
Ravishankar Sarawadi839fcf32012-11-14 12:13:00 -08005014
5015 if (codec->reg_def_copy) {
5016 pr_debug("%s: Update ASOC cache", __func__);
5017 kfree(codec->reg_cache);
5018 codec->reg_cache = kmemdup(codec->reg_def_copy,
5019 codec->reg_size, GFP_KERNEL);
5020 }
5021
Ravishankar Sarawadi2293efe2013-01-11 16:37:23 -08005022 wcd9xxx_resmgr_post_ssr(&taiko->resmgr);
5023 if (spkr_drv_wrnd == 1)
5024 snd_soc_update_bits(codec, TAIKO_A_SPKR_DRV_EN, 0x80, 0x80);
5025 WCD9XXX_BCL_UNLOCK(&taiko->resmgr);
5026
Ravishankar Sarawadi839fcf32012-11-14 12:13:00 -08005027 taiko_update_reg_defaults(codec);
5028 taiko_codec_init_reg(codec);
5029 ret = taiko_handle_pdata(taiko);
5030 if (IS_ERR_VALUE(ret))
5031 pr_err("%s: bad pdata\n", __func__);
Ravishankar Sarawadi2293efe2013-01-11 16:37:23 -08005032
5033 wcd9xxx_mbhc_deinit(&taiko->mbhc);
5034 ret = wcd9xxx_mbhc_init(&taiko->mbhc, &taiko->resmgr, codec);
5035 if (ret)
5036 pr_err("%s: mbhc init failed %d\n", __func__, ret);
5037 else
5038 wcd9xxx_mbhc_start(&taiko->mbhc, taiko->mbhc.mbhc_cfg);
Ravishankar Sarawadi839fcf32012-11-14 12:13:00 -08005039 mutex_unlock(&codec->mutex);
5040 return ret;
5041}
5042
5043
Joonwoo Parka8890262012-10-15 12:04:27 -07005044static struct wcd9xxx_reg_address taiko_reg_address = {
5045 .micb_4_mbhc = TAIKO_A_MICB_4_MBHC,
5046 .micb_4_int_rbias = TAIKO_A_MICB_4_INT_RBIAS,
5047 .micb_4_ctl = TAIKO_A_MICB_4_CTL,
5048};
5049
Ravishankar Sarawadi839fcf32012-11-14 12:13:00 -08005050static int wcd9xxx_ssr_register(struct wcd9xxx *control,
5051 int (*post_reset_cb)(struct wcd9xxx *wcd9xxx), void *priv)
5052{
5053 control->post_reset = post_reset_cb;
5054 control->ssr_priv = priv;
5055 return 0;
5056}
5057
Bhalchandra Gajare87fef4c2013-02-19 14:57:03 -08005058static int taiko_codec_get_buck_mv(struct snd_soc_codec *codec)
5059{
5060 int buck_volt = WCD9XXX_CDC_BUCK_UNSUPPORTED;
5061 struct taiko_priv *taiko = snd_soc_codec_get_drvdata(codec);
5062 struct wcd9xxx_pdata *pdata = taiko->resmgr.pdata;
5063 int i;
5064
5065 for (i = 0; i < ARRAY_SIZE(pdata->regulator); i++) {
5066 if (!strncmp(pdata->regulator[i].name,
5067 WCD9XXX_SUPPLY_BUCK_NAME,
5068 sizeof(WCD9XXX_SUPPLY_BUCK_NAME))) {
5069 buck_volt = pdata->regulator[i].min_uV;
5070 break;
5071 }
5072 }
5073 return buck_volt;
5074}
5075
Kiran Kandic3b24402012-06-11 00:05:59 -07005076static int taiko_codec_probe(struct snd_soc_codec *codec)
5077{
5078 struct wcd9xxx *control;
5079 struct taiko_priv *taiko;
Joonwoo Parka8890262012-10-15 12:04:27 -07005080 struct wcd9xxx_pdata *pdata;
5081 struct wcd9xxx *wcd9xxx;
Kiran Kandic3b24402012-06-11 00:05:59 -07005082 struct snd_soc_dapm_context *dapm = &codec->dapm;
5083 int ret = 0;
5084 int i;
Kuirong Wang906ac472012-07-09 12:54:44 -07005085 void *ptr = NULL;
Joonwoo Park559a5bf2013-02-15 14:46:36 -08005086 struct wcd9xxx *core = dev_get_drvdata(codec->dev->parent);
Kiran Kandic3b24402012-06-11 00:05:59 -07005087
5088 codec->control_data = dev_get_drvdata(codec->dev->parent);
5089 control = codec->control_data;
5090
Ravishankar Sarawadi839fcf32012-11-14 12:13:00 -08005091 wcd9xxx_ssr_register(control, taiko_post_reset_cb, (void *)codec);
5092
Kiran Kandi4c56c592012-07-25 11:04:55 -07005093 dev_info(codec->dev, "%s()\n", __func__);
5094
Kiran Kandic3b24402012-06-11 00:05:59 -07005095 taiko = kzalloc(sizeof(struct taiko_priv), GFP_KERNEL);
5096 if (!taiko) {
5097 dev_err(codec->dev, "Failed to allocate private data\n");
5098 return -ENOMEM;
5099 }
5100 for (i = 0 ; i < NUM_DECIMATORS; i++) {
5101 tx_hpf_work[i].taiko = taiko;
5102 tx_hpf_work[i].decimator = i + 1;
5103 INIT_DELAYED_WORK(&tx_hpf_work[i].dwork,
5104 tx_hpf_corner_freq_callback);
5105 }
5106
Bhalchandra Gajare87fef4c2013-02-19 14:57:03 -08005107
Kiran Kandic3b24402012-06-11 00:05:59 -07005108 snd_soc_codec_set_drvdata(codec, taiko);
5109
Bhalchandra Gajare87fef4c2013-02-19 14:57:03 -08005110
Joonwoo Parka8890262012-10-15 12:04:27 -07005111 /* codec resmgr module init */
5112 wcd9xxx = codec->control_data;
5113 pdata = dev_get_platdata(codec->dev->parent);
5114 ret = wcd9xxx_resmgr_init(&taiko->resmgr, codec, wcd9xxx, pdata,
5115 &taiko_reg_address);
5116 if (ret) {
5117 pr_err("%s: wcd9xxx init failed %d\n", __func__, ret);
5118 return ret;
5119 }
5120
Bhalchandra Gajare87fef4c2013-02-19 14:57:03 -08005121 taiko->clsh_d.buck_mv = taiko_codec_get_buck_mv(codec);
5122 wcd9xxx_clsh_init(&taiko->clsh_d);
5123
Joonwoo Parka8890262012-10-15 12:04:27 -07005124 /* init and start mbhc */
5125 ret = wcd9xxx_mbhc_init(&taiko->mbhc, &taiko->resmgr, codec);
5126 if (ret) {
5127 pr_err("%s: mbhc init failed %d\n", __func__, ret);
5128 return ret;
5129 }
5130
Kiran Kandic3b24402012-06-11 00:05:59 -07005131 taiko->codec = codec;
Kiran Kandic3b24402012-06-11 00:05:59 -07005132 for (i = 0; i < COMPANDER_MAX; i++) {
5133 taiko->comp_enabled[i] = 0;
5134 taiko->comp_fs[i] = COMPANDER_FS_48KHZ;
5135 }
Kiran Kandic3b24402012-06-11 00:05:59 -07005136 taiko->intf_type = wcd9xxx_get_intf_type();
5137 taiko->aux_pga_cnt = 0;
5138 taiko->aux_l_gain = 0x1F;
5139 taiko->aux_r_gain = 0x1F;
Kiran Kandic3b24402012-06-11 00:05:59 -07005140 taiko_update_reg_defaults(codec);
Venkat Sudhira50a3762012-11-26 12:12:15 -08005141 pr_debug("%s: MCLK Rate = %x\n", __func__, wcd9xxx->mclk_rate);
5142 if (wcd9xxx->mclk_rate == TAIKO_MCLK_CLK_12P288MHZ)
Venkat Sudhir16d95e62013-02-04 16:57:33 -08005143 snd_soc_update_bits(codec, TAIKO_A_CHIP_CTL, 0x06, 0x0);
Venkat Sudhira50a3762012-11-26 12:12:15 -08005144 else if (wcd9xxx->mclk_rate == TAIKO_MCLK_CLK_9P6HZ)
Venkat Sudhir16d95e62013-02-04 16:57:33 -08005145 snd_soc_update_bits(codec, TAIKO_A_CHIP_CTL, 0x06, 0x2);
Kiran Kandic3b24402012-06-11 00:05:59 -07005146 taiko_codec_init_reg(codec);
5147 ret = taiko_handle_pdata(taiko);
5148 if (IS_ERR_VALUE(ret)) {
5149 pr_err("%s: bad pdata\n", __func__);
5150 goto err_pdata;
5151 }
5152
Joonwoo Park125cd4e2012-12-11 15:16:11 -08005153 if (spkr_drv_wrnd > 0) {
5154 WCD9XXX_BCL_LOCK(&taiko->resmgr);
5155 wcd9xxx_resmgr_get_bandgap(&taiko->resmgr,
5156 WCD9XXX_BANDGAP_AUDIO_MODE);
5157 WCD9XXX_BCL_UNLOCK(&taiko->resmgr);
5158 }
5159
Kuirong Wang906ac472012-07-09 12:54:44 -07005160 ptr = kmalloc((sizeof(taiko_rx_chs) +
5161 sizeof(taiko_tx_chs)), GFP_KERNEL);
5162 if (!ptr) {
5163 pr_err("%s: no mem for slim chan ctl data\n", __func__);
5164 ret = -ENOMEM;
5165 goto err_nomem_slimch;
5166 }
5167
Kiran Kandic3b24402012-06-11 00:05:59 -07005168 if (taiko->intf_type == WCD9XXX_INTERFACE_TYPE_I2C) {
5169 snd_soc_dapm_new_controls(dapm, taiko_dapm_i2s_widgets,
5170 ARRAY_SIZE(taiko_dapm_i2s_widgets));
5171 snd_soc_dapm_add_routes(dapm, audio_i2s_map,
5172 ARRAY_SIZE(audio_i2s_map));
Joonwoo Park559a5bf2013-02-15 14:46:36 -08005173 if (TAIKO_IS_1_0(core->version))
5174 snd_soc_dapm_add_routes(dapm, audio_i2s_map_1_0,
5175 ARRAY_SIZE(audio_i2s_map_1_0));
5176 else
5177 snd_soc_dapm_add_routes(dapm, audio_i2s_map_2_0,
5178 ARRAY_SIZE(audio_i2s_map_2_0));
Kuirong Wang906ac472012-07-09 12:54:44 -07005179 for (i = 0; i < ARRAY_SIZE(taiko_i2s_dai); i++)
5180 INIT_LIST_HEAD(&taiko->dai[i].wcd9xxx_ch_list);
5181 } else if (taiko->intf_type == WCD9XXX_INTERFACE_TYPE_SLIMBUS) {
5182 for (i = 0; i < NUM_CODEC_DAIS; i++) {
5183 INIT_LIST_HEAD(&taiko->dai[i].wcd9xxx_ch_list);
5184 init_waitqueue_head(&taiko->dai[i].dai_wait);
5185 }
Kiran Kandic3b24402012-06-11 00:05:59 -07005186 }
5187
Kuirong Wang906ac472012-07-09 12:54:44 -07005188 control->num_rx_port = TAIKO_RX_MAX;
5189 control->rx_chs = ptr;
5190 memcpy(control->rx_chs, taiko_rx_chs, sizeof(taiko_rx_chs));
5191 control->num_tx_port = TAIKO_TX_MAX;
5192 control->tx_chs = ptr + sizeof(taiko_rx_chs);
5193 memcpy(control->tx_chs, taiko_tx_chs, sizeof(taiko_tx_chs));
5194
Kiran Kandic3b24402012-06-11 00:05:59 -07005195 snd_soc_dapm_sync(dapm);
5196
Joonwoo Park7680b9f2012-07-13 11:36:48 -07005197 (void) taiko_setup_irqs(taiko);
Kiran Kandic3b24402012-06-11 00:05:59 -07005198
Joonwoo Park125cd4e2012-12-11 15:16:11 -08005199 atomic_set(&kp_taiko_priv, (unsigned long)taiko);
5200
Kiran Kandic3b24402012-06-11 00:05:59 -07005201 codec->ignore_pmdown_time = 1;
5202 return ret;
5203
Kiran Kandic3b24402012-06-11 00:05:59 -07005204err_pdata:
Kuirong Wang906ac472012-07-09 12:54:44 -07005205 kfree(ptr);
5206err_nomem_slimch:
Kiran Kandic3b24402012-06-11 00:05:59 -07005207 kfree(taiko);
5208 return ret;
5209}
5210static int taiko_codec_remove(struct snd_soc_codec *codec)
5211{
Kiran Kandic3b24402012-06-11 00:05:59 -07005212 struct taiko_priv *taiko = snd_soc_codec_get_drvdata(codec);
Joonwoo Parka8890262012-10-15 12:04:27 -07005213
Joonwoo Park125cd4e2012-12-11 15:16:11 -08005214 WCD9XXX_BCL_LOCK(&taiko->resmgr);
5215 atomic_set(&kp_taiko_priv, 0);
5216
5217 if (spkr_drv_wrnd > 0)
5218 wcd9xxx_resmgr_put_bandgap(&taiko->resmgr,
5219 WCD9XXX_BANDGAP_AUDIO_MODE);
5220 WCD9XXX_BCL_UNLOCK(&taiko->resmgr);
5221
Joonwoo Parka8890262012-10-15 12:04:27 -07005222 /* cleanup MBHC */
5223 wcd9xxx_mbhc_deinit(&taiko->mbhc);
5224 /* cleanup resmgr */
5225 wcd9xxx_resmgr_deinit(&taiko->resmgr);
5226
Kiran Kandic3b24402012-06-11 00:05:59 -07005227 kfree(taiko);
5228 return 0;
5229}
5230static struct snd_soc_codec_driver soc_codec_dev_taiko = {
5231 .probe = taiko_codec_probe,
5232 .remove = taiko_codec_remove,
5233
5234 .read = taiko_read,
5235 .write = taiko_write,
5236
5237 .readable_register = taiko_readable,
5238 .volatile_register = taiko_volatile,
5239
5240 .reg_cache_size = TAIKO_CACHE_SIZE,
Kiran Kandi7b7d2ff2012-09-14 14:52:14 -07005241 .reg_cache_default = taiko_reset_reg_defaults,
Kiran Kandic3b24402012-06-11 00:05:59 -07005242 .reg_word_size = 1,
5243
5244 .controls = taiko_snd_controls,
5245 .num_controls = ARRAY_SIZE(taiko_snd_controls),
5246 .dapm_widgets = taiko_dapm_widgets,
5247 .num_dapm_widgets = ARRAY_SIZE(taiko_dapm_widgets),
5248 .dapm_routes = audio_map,
5249 .num_dapm_routes = ARRAY_SIZE(audio_map),
5250};
5251
5252#ifdef CONFIG_PM
5253static int taiko_suspend(struct device *dev)
5254{
5255 dev_dbg(dev, "%s: system suspend\n", __func__);
5256 return 0;
5257}
5258
5259static int taiko_resume(struct device *dev)
5260{
5261 struct platform_device *pdev = to_platform_device(dev);
5262 struct taiko_priv *taiko = platform_get_drvdata(pdev);
5263 dev_dbg(dev, "%s: system resume\n", __func__);
Joonwoo Parka8890262012-10-15 12:04:27 -07005264 /* Notify */
5265 wcd9xxx_resmgr_notifier_call(&taiko->resmgr, WCD9XXX_EVENT_POST_RESUME);
Kiran Kandic3b24402012-06-11 00:05:59 -07005266 return 0;
5267}
5268
5269static const struct dev_pm_ops taiko_pm_ops = {
5270 .suspend = taiko_suspend,
5271 .resume = taiko_resume,
5272};
5273#endif
5274
5275static int __devinit taiko_probe(struct platform_device *pdev)
5276{
5277 int ret = 0;
5278 if (wcd9xxx_get_intf_type() == WCD9XXX_INTERFACE_TYPE_SLIMBUS)
5279 ret = snd_soc_register_codec(&pdev->dev, &soc_codec_dev_taiko,
5280 taiko_dai, ARRAY_SIZE(taiko_dai));
5281 else if (wcd9xxx_get_intf_type() == WCD9XXX_INTERFACE_TYPE_I2C)
5282 ret = snd_soc_register_codec(&pdev->dev, &soc_codec_dev_taiko,
5283 taiko_i2s_dai, ARRAY_SIZE(taiko_i2s_dai));
5284 return ret;
5285}
5286static int __devexit taiko_remove(struct platform_device *pdev)
5287{
5288 snd_soc_unregister_codec(&pdev->dev);
5289 return 0;
5290}
5291static struct platform_driver taiko_codec_driver = {
5292 .probe = taiko_probe,
5293 .remove = taiko_remove,
5294 .driver = {
5295 .name = "taiko_codec",
5296 .owner = THIS_MODULE,
5297#ifdef CONFIG_PM
5298 .pm = &taiko_pm_ops,
5299#endif
5300 },
5301};
5302
5303static int __init taiko_codec_init(void)
5304{
5305 return platform_driver_register(&taiko_codec_driver);
5306}
5307
5308static void __exit taiko_codec_exit(void)
5309{
5310 platform_driver_unregister(&taiko_codec_driver);
5311}
5312
5313module_init(taiko_codec_init);
5314module_exit(taiko_codec_exit);
5315
5316MODULE_DESCRIPTION("Taiko codec driver");
5317MODULE_LICENSE("GPL v2");