Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1 | /* Copyright (c) 2011, Code Aurora Forum. All rights reserved. |
| 2 | * |
| 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> |
Bradley Rubin | 229c6a5 | 2011-07-12 16:18:48 -0700 | [diff] [blame] | 14 | #include <linux/firmware.h> |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 15 | #include <linux/slab.h> |
| 16 | #include <linux/platform_device.h> |
| 17 | #include <linux/printk.h> |
| 18 | #include <linux/ratelimit.h> |
Bradley Rubin | cb3950a | 2011-08-18 13:07:26 -0700 | [diff] [blame] | 19 | #include <linux/debugfs.h> |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 20 | #include <linux/mfd/wcd9310/core.h> |
| 21 | #include <linux/mfd/wcd9310/registers.h> |
Patrick Lai | 3043fba | 2011-08-01 14:15:57 -0700 | [diff] [blame] | 22 | #include <linux/mfd/wcd9310/pdata.h> |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 23 | #include <sound/jack.h> |
| 24 | #include <sound/soc.h> |
| 25 | #include <sound/soc-dapm.h> |
| 26 | #include <sound/tlv.h> |
| 27 | #include <linux/bitops.h> |
| 28 | #include <linux/delay.h> |
| 29 | #include "wcd9310.h" |
| 30 | |
Bhalchandra Gajare | 9a901fd | 2011-08-01 10:07:15 -0700 | [diff] [blame] | 31 | #define WCD9310_RATES (SNDRV_PCM_RATE_8000|SNDRV_PCM_RATE_16000|\ |
| 32 | SNDRV_PCM_RATE_32000|SNDRV_PCM_RATE_48000) |
| 33 | |
| 34 | #define NUM_DECIMATORS 10 |
| 35 | #define NUM_INTERPOLATORS 7 |
| 36 | #define BITS_PER_REG 8 |
| 37 | #define TABLA_RX_DAI_ID 1 |
| 38 | #define TABLA_TX_DAI_ID 2 |
| 39 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 40 | static const DECLARE_TLV_DB_SCALE(digital_gain, 0, 1, 0); |
| 41 | static const DECLARE_TLV_DB_SCALE(line_gain, 0, 7, 1); |
| 42 | static const DECLARE_TLV_DB_SCALE(analog_gain, 0, 25, 1); |
| 43 | |
| 44 | enum tabla_bandgap_type { |
| 45 | TABLA_BANDGAP_OFF = 0, |
| 46 | TABLA_BANDGAP_AUDIO_MODE, |
| 47 | TABLA_BANDGAP_MBHC_MODE, |
| 48 | }; |
| 49 | |
Bhalchandra Gajare | 02d90cd | 2011-09-30 16:14:00 -0700 | [diff] [blame] | 50 | struct mbhc_micbias_regs { |
| 51 | u16 cfilt_val; |
| 52 | u16 cfilt_ctl; |
| 53 | u16 mbhc_reg; |
| 54 | u16 int_rbias; |
| 55 | u16 ctl_reg; |
| 56 | }; |
| 57 | |
Bradley Rubin | 229c6a5 | 2011-07-12 16:18:48 -0700 | [diff] [blame] | 58 | struct tabla_priv { |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 59 | struct snd_soc_codec *codec; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 60 | u32 adc_count; |
Patrick Lai | 3043fba | 2011-08-01 14:15:57 -0700 | [diff] [blame] | 61 | u32 cfilt1_cnt; |
| 62 | u32 cfilt2_cnt; |
| 63 | u32 cfilt3_cnt; |
Kiran Kandi | 6fae8bf | 2011-08-15 10:36:42 -0700 | [diff] [blame] | 64 | u32 rx_bias_count; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 65 | enum tabla_bandgap_type bandgap_type; |
Kiran Kandi | 6fae8bf | 2011-08-15 10:36:42 -0700 | [diff] [blame] | 66 | bool mclk_enabled; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 67 | bool clock_active; |
| 68 | bool config_mode_active; |
| 69 | bool mbhc_polling_active; |
Bradley Rubin | cb1e273 | 2011-06-23 16:49:20 -0700 | [diff] [blame] | 70 | int buttons_pressed; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 71 | |
| 72 | struct tabla_mbhc_calibration *calibration; |
| 73 | |
Bradley Rubin | cb1e273 | 2011-06-23 16:49:20 -0700 | [diff] [blame] | 74 | struct snd_soc_jack *headset_jack; |
| 75 | struct snd_soc_jack *button_jack; |
Bradley Rubin | 229c6a5 | 2011-07-12 16:18:48 -0700 | [diff] [blame] | 76 | |
Patrick Lai | 3043fba | 2011-08-01 14:15:57 -0700 | [diff] [blame] | 77 | struct tabla_pdata *pdata; |
Bradley Rubin | a7096d0 | 2011-08-03 18:29:02 -0700 | [diff] [blame] | 78 | u32 anc_slot; |
Bradley Rubin | cb3950a | 2011-08-18 13:07:26 -0700 | [diff] [blame] | 79 | |
| 80 | bool no_mic_headset_override; |
Bhalchandra Gajare | 0a792b1 | 2011-09-06 16:36:58 -0700 | [diff] [blame] | 81 | /* Delayed work to report long button press */ |
| 82 | struct delayed_work btn0_dwork; |
Bhalchandra Gajare | 02d90cd | 2011-09-30 16:14:00 -0700 | [diff] [blame] | 83 | |
| 84 | struct mbhc_micbias_regs mbhc_bias_regs; |
Bhalchandra Gajare | d9ebb6c | 2011-10-03 19:54:41 -0700 | [diff] [blame] | 85 | u8 cfilt_k_value; |
| 86 | bool mbhc_micbias_switched; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 87 | }; |
| 88 | |
Bradley Rubin | cb3950a | 2011-08-18 13:07:26 -0700 | [diff] [blame] | 89 | #ifdef CONFIG_DEBUG_FS |
| 90 | struct tabla_priv *debug_tabla_priv; |
| 91 | #endif |
| 92 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 93 | static int tabla_codec_enable_charge_pump(struct snd_soc_dapm_widget *w, |
| 94 | struct snd_kcontrol *kcontrol, int event) |
| 95 | { |
| 96 | struct snd_soc_codec *codec = w->codec; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 97 | |
| 98 | pr_debug("%s %d\n", __func__, event); |
| 99 | switch (event) { |
| 100 | case SND_SOC_DAPM_POST_PMU: |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 101 | snd_soc_update_bits(codec, TABLA_A_CDC_CLK_OTHR_CTL, 0x01, |
| 102 | 0x01); |
| 103 | snd_soc_update_bits(codec, TABLA_A_CDC_CLSG_CTL, 0x08, 0x08); |
| 104 | usleep_range(200, 200); |
| 105 | snd_soc_update_bits(codec, TABLA_A_CP_STATIC, 0x10, 0x00); |
| 106 | break; |
| 107 | case SND_SOC_DAPM_PRE_PMD: |
| 108 | snd_soc_update_bits(codec, TABLA_A_CDC_CLK_OTHR_RESET_CTL, 0x10, |
| 109 | 0x10); |
| 110 | usleep_range(20, 20); |
| 111 | snd_soc_update_bits(codec, TABLA_A_CP_STATIC, 0x08, 0x08); |
| 112 | snd_soc_update_bits(codec, TABLA_A_CP_STATIC, 0x10, 0x10); |
| 113 | snd_soc_update_bits(codec, TABLA_A_CDC_CLSG_CTL, 0x08, 0x00); |
| 114 | snd_soc_update_bits(codec, TABLA_A_CDC_CLK_OTHR_CTL, 0x01, |
| 115 | 0x00); |
| 116 | snd_soc_update_bits(codec, TABLA_A_CP_STATIC, 0x08, 0x00); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 117 | break; |
| 118 | } |
| 119 | return 0; |
| 120 | } |
| 121 | |
Bradley Rubin | a7096d0 | 2011-08-03 18:29:02 -0700 | [diff] [blame] | 122 | static int tabla_get_anc_slot(struct snd_kcontrol *kcontrol, |
| 123 | struct snd_ctl_elem_value *ucontrol) |
| 124 | { |
| 125 | struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); |
| 126 | struct tabla_priv *tabla = snd_soc_codec_get_drvdata(codec); |
| 127 | ucontrol->value.integer.value[0] = tabla->anc_slot; |
| 128 | return 0; |
| 129 | } |
| 130 | |
| 131 | static int tabla_put_anc_slot(struct snd_kcontrol *kcontrol, |
| 132 | struct snd_ctl_elem_value *ucontrol) |
| 133 | { |
| 134 | struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); |
| 135 | struct tabla_priv *tabla = snd_soc_codec_get_drvdata(codec); |
| 136 | tabla->anc_slot = ucontrol->value.integer.value[0]; |
| 137 | return 0; |
| 138 | } |
| 139 | |
Kiran Kandi | d2d86b5 | 2011-09-09 17:44:28 -0700 | [diff] [blame] | 140 | static int tabla_pa_gain_get(struct snd_kcontrol *kcontrol, |
| 141 | struct snd_ctl_elem_value *ucontrol) |
| 142 | { |
| 143 | u8 ear_pa_gain; |
| 144 | struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); |
| 145 | |
| 146 | ear_pa_gain = snd_soc_read(codec, TABLA_A_RX_EAR_GAIN); |
| 147 | |
| 148 | ear_pa_gain = ear_pa_gain >> 5; |
| 149 | |
| 150 | if (ear_pa_gain == 0x00) { |
| 151 | ucontrol->value.integer.value[0] = 0; |
| 152 | } else if (ear_pa_gain == 0x04) { |
| 153 | ucontrol->value.integer.value[0] = 1; |
| 154 | } else { |
| 155 | pr_err("%s: ERROR: Unsupported Ear Gain = 0x%x\n", |
| 156 | __func__, ear_pa_gain); |
| 157 | return -EINVAL; |
| 158 | } |
| 159 | |
| 160 | pr_debug("%s: ear_pa_gain = 0x%x\n", __func__, ear_pa_gain); |
| 161 | |
| 162 | return 0; |
| 163 | } |
| 164 | |
| 165 | static int tabla_pa_gain_put(struct snd_kcontrol *kcontrol, |
| 166 | struct snd_ctl_elem_value *ucontrol) |
| 167 | { |
| 168 | u8 ear_pa_gain; |
| 169 | struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); |
| 170 | |
| 171 | pr_debug("%s: ucontrol->value.integer.value[0] = %ld\n", __func__, |
| 172 | ucontrol->value.integer.value[0]); |
| 173 | |
| 174 | switch (ucontrol->value.integer.value[0]) { |
| 175 | case 0: |
| 176 | ear_pa_gain = 0x00; |
| 177 | break; |
| 178 | case 1: |
| 179 | ear_pa_gain = 0x80; |
| 180 | break; |
| 181 | default: |
| 182 | return -EINVAL; |
| 183 | } |
| 184 | |
| 185 | snd_soc_update_bits(codec, TABLA_A_RX_EAR_GAIN, 0xE0, ear_pa_gain); |
| 186 | return 0; |
| 187 | } |
| 188 | |
| 189 | static const char *tabla_ear_pa_gain_text[] = {"POS_6_DB", "POS_2_DB"}; |
| 190 | static const struct soc_enum tabla_ear_pa_gain_enum[] = { |
| 191 | SOC_ENUM_SINGLE_EXT(2, tabla_ear_pa_gain_text), |
| 192 | }; |
| 193 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 194 | static const struct snd_kcontrol_new tabla_snd_controls[] = { |
Kiran Kandi | d2d86b5 | 2011-09-09 17:44:28 -0700 | [diff] [blame] | 195 | |
| 196 | SOC_ENUM_EXT("EAR PA Gain", tabla_ear_pa_gain_enum[0], |
| 197 | tabla_pa_gain_get, tabla_pa_gain_put), |
| 198 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 199 | SOC_SINGLE_TLV("LINEOUT1 Volume", TABLA_A_RX_LINE_1_GAIN, 0, 12, 1, |
| 200 | line_gain), |
Bradley Rubin | 74a9b4a | 2011-06-13 15:03:43 -0700 | [diff] [blame] | 201 | SOC_SINGLE_TLV("LINEOUT2 Volume", TABLA_A_RX_LINE_2_GAIN, 0, 12, 1, |
| 202 | line_gain), |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 203 | SOC_SINGLE_TLV("LINEOUT3 Volume", TABLA_A_RX_LINE_3_GAIN, 0, 12, 1, |
| 204 | line_gain), |
Bradley Rubin | 74a9b4a | 2011-06-13 15:03:43 -0700 | [diff] [blame] | 205 | SOC_SINGLE_TLV("LINEOUT4 Volume", TABLA_A_RX_LINE_4_GAIN, 0, 12, 1, |
| 206 | line_gain), |
Bhalchandra Gajare | 0a8ad17 | 2011-08-12 13:32:22 -0700 | [diff] [blame] | 207 | SOC_SINGLE_TLV("LINEOUT5 Volume", TABLA_A_RX_LINE_5_GAIN, 0, 12, 1, |
| 208 | line_gain), |
Bradley Rubin | 74a9b4a | 2011-06-13 15:03:43 -0700 | [diff] [blame] | 209 | |
| 210 | SOC_SINGLE("RX1 CHAIN INVERT Switch", TABLA_A_CDC_RX1_B6_CTL, 4, 1, 0), |
| 211 | SOC_SINGLE("RX2 CHAIN INVERT Switch", TABLA_A_CDC_RX2_B6_CTL, 4, 1, 0), |
| 212 | SOC_SINGLE("RX3 CHAIN INVERT Switch", TABLA_A_CDC_RX3_B6_CTL, 4, 1, 0), |
| 213 | SOC_SINGLE("RX4 CHAIN INVERT Switch", TABLA_A_CDC_RX4_B6_CTL, 4, 1, 0), |
| 214 | SOC_SINGLE("RX5 CHAIN INVERT Switch", TABLA_A_CDC_RX5_B6_CTL, 4, 1, 0), |
| 215 | SOC_SINGLE("RX6 CHAIN INVERT Switch", TABLA_A_CDC_RX6_B6_CTL, 4, 1, 0), |
| 216 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 217 | SOC_SINGLE_TLV("HPHL Volume", TABLA_A_RX_HPH_L_GAIN, 0, 12, 1, |
| 218 | line_gain), |
| 219 | SOC_SINGLE_TLV("HPHR Volume", TABLA_A_RX_HPH_R_GAIN, 0, 12, 1, |
| 220 | line_gain), |
| 221 | |
Bradley Rubin | 410383f | 2011-07-22 13:44:23 -0700 | [diff] [blame] | 222 | SOC_SINGLE_S8_TLV("RX1 Digital Volume", TABLA_A_CDC_RX1_VOL_CTL_B2_CTL, |
| 223 | -84, 40, digital_gain), |
| 224 | SOC_SINGLE_S8_TLV("RX2 Digital Volume", TABLA_A_CDC_RX2_VOL_CTL_B2_CTL, |
| 225 | -84, 40, digital_gain), |
| 226 | SOC_SINGLE_S8_TLV("RX3 Digital Volume", TABLA_A_CDC_RX3_VOL_CTL_B2_CTL, |
| 227 | -84, 40, digital_gain), |
| 228 | SOC_SINGLE_S8_TLV("RX4 Digital Volume", TABLA_A_CDC_RX4_VOL_CTL_B2_CTL, |
| 229 | -84, 40, digital_gain), |
| 230 | SOC_SINGLE_S8_TLV("RX5 Digital Volume", TABLA_A_CDC_RX5_VOL_CTL_B2_CTL, |
| 231 | -84, 40, digital_gain), |
| 232 | SOC_SINGLE_S8_TLV("RX6 Digital Volume", TABLA_A_CDC_RX6_VOL_CTL_B2_CTL, |
| 233 | -84, 40, digital_gain), |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 234 | |
Bradley Rubin | 410383f | 2011-07-22 13:44:23 -0700 | [diff] [blame] | 235 | SOC_SINGLE_S8_TLV("DEC1 Volume", TABLA_A_CDC_TX1_VOL_CTL_GAIN, -84, 40, |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 236 | digital_gain), |
Bradley Rubin | 410383f | 2011-07-22 13:44:23 -0700 | [diff] [blame] | 237 | SOC_SINGLE_S8_TLV("DEC2 Volume", TABLA_A_CDC_TX2_VOL_CTL_GAIN, -84, 40, |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 238 | digital_gain), |
Bradley Rubin | 410383f | 2011-07-22 13:44:23 -0700 | [diff] [blame] | 239 | SOC_SINGLE_S8_TLV("DEC3 Volume", TABLA_A_CDC_TX3_VOL_CTL_GAIN, -84, 40, |
| 240 | digital_gain), |
| 241 | SOC_SINGLE_S8_TLV("DEC4 Volume", TABLA_A_CDC_TX4_VOL_CTL_GAIN, -84, 40, |
| 242 | digital_gain), |
| 243 | SOC_SINGLE_S8_TLV("DEC5 Volume", TABLA_A_CDC_TX5_VOL_CTL_GAIN, -84, 40, |
| 244 | digital_gain), |
| 245 | SOC_SINGLE_S8_TLV("DEC6 Volume", TABLA_A_CDC_TX6_VOL_CTL_GAIN, -84, 40, |
| 246 | digital_gain), |
| 247 | SOC_SINGLE_S8_TLV("DEC7 Volume", TABLA_A_CDC_TX7_VOL_CTL_GAIN, -84, 40, |
| 248 | digital_gain), |
| 249 | SOC_SINGLE_S8_TLV("DEC8 Volume", TABLA_A_CDC_TX8_VOL_CTL_GAIN, -84, 40, |
| 250 | digital_gain), |
| 251 | SOC_SINGLE_S8_TLV("DEC9 Volume", TABLA_A_CDC_TX9_VOL_CTL_GAIN, -84, 40, |
| 252 | digital_gain), |
| 253 | SOC_SINGLE_S8_TLV("DEC10 Volume", TABLA_A_CDC_TX10_VOL_CTL_GAIN, -84, |
| 254 | 40, digital_gain), |
Patrick Lai | 2900637 | 2011-09-28 17:57:42 -0700 | [diff] [blame] | 255 | SOC_SINGLE_S8_TLV("IIR1 INP1 Volume", TABLA_A_CDC_IIR1_GAIN_B1_CTL, -84, |
| 256 | 40, digital_gain), |
| 257 | SOC_SINGLE_S8_TLV("IIR1 INP2 Volume", TABLA_A_CDC_IIR1_GAIN_B2_CTL, -84, |
| 258 | 40, digital_gain), |
| 259 | SOC_SINGLE_S8_TLV("IIR1 INP3 Volume", TABLA_A_CDC_IIR1_GAIN_B3_CTL, -84, |
| 260 | 40, digital_gain), |
| 261 | SOC_SINGLE_S8_TLV("IIR1 INP4 Volume", TABLA_A_CDC_IIR1_GAIN_B4_CTL, -84, |
| 262 | 40, digital_gain), |
Bhalchandra Gajare | 0d77e1b | 2011-07-08 10:54:14 -0700 | [diff] [blame] | 263 | SOC_SINGLE_TLV("ADC1 Volume", TABLA_A_TX_1_2_EN, 5, 3, 0, analog_gain), |
| 264 | SOC_SINGLE_TLV("ADC2 Volume", TABLA_A_TX_1_2_EN, 1, 3, 0, analog_gain), |
Bhalchandra Gajare | cc6ffa0 | 2011-07-14 18:35:41 -0700 | [diff] [blame] | 265 | SOC_SINGLE_TLV("ADC3 Volume", TABLA_A_TX_3_4_EN, 5, 3, 0, analog_gain), |
| 266 | SOC_SINGLE_TLV("ADC4 Volume", TABLA_A_TX_3_4_EN, 1, 3, 0, analog_gain), |
Bhalchandra Gajare | 0d77e1b | 2011-07-08 10:54:14 -0700 | [diff] [blame] | 267 | SOC_SINGLE_TLV("ADC5 Volume", TABLA_A_TX_5_6_EN, 5, 3, 0, analog_gain), |
| 268 | SOC_SINGLE_TLV("ADC6 Volume", TABLA_A_TX_5_6_EN, 1, 3, 0, analog_gain), |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 269 | |
| 270 | SOC_SINGLE("MICBIAS1 CAPLESS Switch", TABLA_A_MICB_1_CTL, 4, 1, 1), |
Bhalchandra Gajare | cc6ffa0 | 2011-07-14 18:35:41 -0700 | [diff] [blame] | 271 | SOC_SINGLE("MICBIAS3 CAPLESS Switch", TABLA_A_MICB_3_CTL, 4, 1, 1), |
| 272 | SOC_SINGLE("MICBIAS4 CAPLESS Switch", TABLA_A_MICB_4_CTL, 4, 1, 1), |
Bradley Rubin | a7096d0 | 2011-08-03 18:29:02 -0700 | [diff] [blame] | 273 | |
| 274 | SOC_SINGLE_EXT("ANC Slot", SND_SOC_NOPM, 0, 0, 100, tabla_get_anc_slot, |
| 275 | tabla_put_anc_slot), |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 276 | }; |
| 277 | |
| 278 | static const char *rx_mix1_text[] = { |
| 279 | "ZERO", "SRC1", "SRC2", "IIR1", "IIR2", "RX1", "RX2", "RX3", "RX4", |
| 280 | "RX5", "RX6", "RX7" |
| 281 | }; |
| 282 | |
| 283 | static const char *sb_tx1_mux_text[] = { |
| 284 | "ZERO", "RMIX1", "RMIX2", "RMIX3", "RMIX4", "RMIX5", "RMIX6", "RMIX7", |
| 285 | "DEC1" |
| 286 | }; |
| 287 | |
| 288 | static const char *sb_tx5_mux_text[] = { |
| 289 | "ZERO", "RMIX1", "RMIX2", "RMIX3", "RMIX4", "RMIX5", "RMIX6", "RMIX7", |
| 290 | "DEC5" |
| 291 | }; |
| 292 | |
| 293 | static const char *sb_tx6_mux_text[] = { |
| 294 | "ZERO", "RMIX1", "RMIX2", "RMIX3", "RMIX4", "RMIX5", "RMIX6", "RMIX7", |
| 295 | "DEC6" |
| 296 | }; |
| 297 | |
| 298 | static const char const *sb_tx7_to_tx10_mux_text[] = { |
| 299 | "ZERO", "RMIX1", "RMIX2", "RMIX3", "RMIX4", "RMIX5", "RMIX6", "RMIX7", |
| 300 | "DEC1", "DEC2", "DEC3", "DEC4", "DEC5", "DEC6", "DEC7", "DEC8", |
| 301 | "DEC9", "DEC10" |
| 302 | }; |
| 303 | |
| 304 | static const char *dec1_mux_text[] = { |
| 305 | "ZERO", "DMIC1", "ADC6", |
| 306 | }; |
| 307 | |
Bhalchandra Gajare | 0d77e1b | 2011-07-08 10:54:14 -0700 | [diff] [blame] | 308 | static const char *dec2_mux_text[] = { |
| 309 | "ZERO", "DMIC2", "ADC5", |
| 310 | }; |
| 311 | |
Bhalchandra Gajare | cc6ffa0 | 2011-07-14 18:35:41 -0700 | [diff] [blame] | 312 | static const char *dec3_mux_text[] = { |
| 313 | "ZERO", "DMIC3", "ADC4", |
| 314 | }; |
| 315 | |
| 316 | static const char *dec4_mux_text[] = { |
| 317 | "ZERO", "DMIC4", "ADC3", |
| 318 | }; |
| 319 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 320 | static const char *dec5_mux_text[] = { |
| 321 | "ZERO", "DMIC5", "ADC2", |
| 322 | }; |
| 323 | |
| 324 | static const char *dec6_mux_text[] = { |
| 325 | "ZERO", "DMIC6", "ADC1", |
| 326 | }; |
| 327 | |
| 328 | static const char const *dec7_mux_text[] = { |
| 329 | "ZERO", "DMIC1", "DMIC6", "ADC1", "ADC6", "ANC1_FB", "ANC2_FB", |
| 330 | }; |
| 331 | |
Bhalchandra Gajare | 0d77e1b | 2011-07-08 10:54:14 -0700 | [diff] [blame] | 332 | static const char *dec8_mux_text[] = { |
| 333 | "ZERO", "DMIC2", "DMIC5", "ADC2", "ADC5", |
| 334 | }; |
| 335 | |
Bhalchandra Gajare | cc6ffa0 | 2011-07-14 18:35:41 -0700 | [diff] [blame] | 336 | static const char *dec9_mux_text[] = { |
| 337 | "ZERO", "DMIC4", "DMIC5", "ADC2", "ADC3", "ADCMB", "ANC1_FB", "ANC2_FB", |
| 338 | }; |
| 339 | |
| 340 | static const char *dec10_mux_text[] = { |
| 341 | "ZERO", "DMIC3", "DMIC6", "ADC1", "ADC4", "ADCMB", "ANC1_FB", "ANC2_FB", |
| 342 | }; |
| 343 | |
Bradley Rubin | 229c6a5 | 2011-07-12 16:18:48 -0700 | [diff] [blame] | 344 | static const char const *anc_mux_text[] = { |
| 345 | "ZERO", "ADC1", "ADC2", "ADC3", "ADC4", "ADC5", "ADC6", "ADC_MB", |
| 346 | "RSVD_1", "DMIC1", "DMIC2", "DMIC3", "DMIC4", "DMIC5", "DMIC6" |
| 347 | }; |
| 348 | |
| 349 | static const char const *anc1_fb_mux_text[] = { |
| 350 | "ZERO", "EAR_HPH_L", "EAR_LINE_1", |
| 351 | }; |
| 352 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 353 | static const char *iir1_inp1_text[] = { |
| 354 | "ZERO", "DEC1", "DEC2", "DEC3", "DEC4", "DEC5", "DEC6", "DEC7", "DEC8", |
| 355 | "DEC9", "DEC10", "RX1", "RX2", "RX3", "RX4", "RX5", "RX6", "RX7" |
| 356 | }; |
| 357 | |
| 358 | static const struct soc_enum rx_mix1_inp1_chain_enum = |
| 359 | SOC_ENUM_SINGLE(TABLA_A_CDC_CONN_RX1_B1_CTL, 0, 12, rx_mix1_text); |
| 360 | |
Bradley Rubin | 229c6a5 | 2011-07-12 16:18:48 -0700 | [diff] [blame] | 361 | static const struct soc_enum rx_mix1_inp2_chain_enum = |
| 362 | SOC_ENUM_SINGLE(TABLA_A_CDC_CONN_RX1_B1_CTL, 4, 12, rx_mix1_text); |
| 363 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 364 | static const struct soc_enum rx2_mix1_inp1_chain_enum = |
| 365 | SOC_ENUM_SINGLE(TABLA_A_CDC_CONN_RX2_B1_CTL, 0, 12, rx_mix1_text); |
| 366 | |
Bradley Rubin | 229c6a5 | 2011-07-12 16:18:48 -0700 | [diff] [blame] | 367 | static const struct soc_enum rx2_mix1_inp2_chain_enum = |
| 368 | SOC_ENUM_SINGLE(TABLA_A_CDC_CONN_RX2_B1_CTL, 4, 12, rx_mix1_text); |
| 369 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 370 | static const struct soc_enum rx3_mix1_inp1_chain_enum = |
| 371 | SOC_ENUM_SINGLE(TABLA_A_CDC_CONN_RX3_B1_CTL, 0, 12, rx_mix1_text); |
| 372 | |
Bradley Rubin | 74a9b4a | 2011-06-13 15:03:43 -0700 | [diff] [blame] | 373 | static const struct soc_enum rx3_mix1_inp2_chain_enum = |
| 374 | SOC_ENUM_SINGLE(TABLA_A_CDC_CONN_RX3_B1_CTL, 4, 12, rx_mix1_text); |
| 375 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 376 | static const struct soc_enum rx4_mix1_inp1_chain_enum = |
| 377 | SOC_ENUM_SINGLE(TABLA_A_CDC_CONN_RX4_B1_CTL, 0, 12, rx_mix1_text); |
| 378 | |
Bradley Rubin | 74a9b4a | 2011-06-13 15:03:43 -0700 | [diff] [blame] | 379 | static const struct soc_enum rx4_mix1_inp2_chain_enum = |
| 380 | SOC_ENUM_SINGLE(TABLA_A_CDC_CONN_RX4_B1_CTL, 4, 12, rx_mix1_text); |
| 381 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 382 | static const struct soc_enum rx5_mix1_inp1_chain_enum = |
| 383 | SOC_ENUM_SINGLE(TABLA_A_CDC_CONN_RX5_B1_CTL, 0, 12, rx_mix1_text); |
| 384 | |
Bradley Rubin | 74a9b4a | 2011-06-13 15:03:43 -0700 | [diff] [blame] | 385 | static const struct soc_enum rx5_mix1_inp2_chain_enum = |
| 386 | SOC_ENUM_SINGLE(TABLA_A_CDC_CONN_RX5_B1_CTL, 4, 12, rx_mix1_text); |
| 387 | |
| 388 | static const struct soc_enum rx6_mix1_inp1_chain_enum = |
| 389 | SOC_ENUM_SINGLE(TABLA_A_CDC_CONN_RX6_B1_CTL, 0, 12, rx_mix1_text); |
| 390 | |
| 391 | static const struct soc_enum rx6_mix1_inp2_chain_enum = |
| 392 | SOC_ENUM_SINGLE(TABLA_A_CDC_CONN_RX6_B1_CTL, 4, 12, rx_mix1_text); |
| 393 | |
Bhalchandra Gajare | 0a8ad17 | 2011-08-12 13:32:22 -0700 | [diff] [blame] | 394 | static const struct soc_enum rx7_mix1_inp1_chain_enum = |
| 395 | SOC_ENUM_SINGLE(TABLA_A_CDC_CONN_RX7_B1_CTL, 0, 12, rx_mix1_text); |
| 396 | |
| 397 | static const struct soc_enum rx7_mix1_inp2_chain_enum = |
| 398 | SOC_ENUM_SINGLE(TABLA_A_CDC_CONN_RX7_B1_CTL, 4, 12, rx_mix1_text); |
| 399 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 400 | static const struct soc_enum sb_tx5_mux_enum = |
| 401 | SOC_ENUM_SINGLE(TABLA_A_CDC_CONN_TX_SB_B5_CTL, 0, 9, sb_tx5_mux_text); |
| 402 | |
| 403 | static const struct soc_enum sb_tx6_mux_enum = |
| 404 | SOC_ENUM_SINGLE(TABLA_A_CDC_CONN_TX_SB_B6_CTL, 0, 9, sb_tx6_mux_text); |
| 405 | |
| 406 | static const struct soc_enum sb_tx7_mux_enum = |
| 407 | SOC_ENUM_SINGLE(TABLA_A_CDC_CONN_TX_SB_B7_CTL, 0, 18, |
| 408 | sb_tx7_to_tx10_mux_text); |
| 409 | |
| 410 | static const struct soc_enum sb_tx8_mux_enum = |
| 411 | SOC_ENUM_SINGLE(TABLA_A_CDC_CONN_TX_SB_B8_CTL, 0, 18, |
| 412 | sb_tx7_to_tx10_mux_text); |
| 413 | |
| 414 | static const struct soc_enum sb_tx1_mux_enum = |
| 415 | SOC_ENUM_SINGLE(TABLA_A_CDC_CONN_TX_SB_B1_CTL, 0, 9, sb_tx1_mux_text); |
| 416 | |
| 417 | static const struct soc_enum dec1_mux_enum = |
| 418 | SOC_ENUM_SINGLE(TABLA_A_CDC_CONN_TX_B1_CTL, 0, 3, dec1_mux_text); |
| 419 | |
Bhalchandra Gajare | 0d77e1b | 2011-07-08 10:54:14 -0700 | [diff] [blame] | 420 | static const struct soc_enum dec2_mux_enum = |
| 421 | SOC_ENUM_SINGLE(TABLA_A_CDC_CONN_TX_B1_CTL, 2, 3, dec2_mux_text); |
| 422 | |
Bhalchandra Gajare | cc6ffa0 | 2011-07-14 18:35:41 -0700 | [diff] [blame] | 423 | static const struct soc_enum dec3_mux_enum = |
| 424 | SOC_ENUM_SINGLE(TABLA_A_CDC_CONN_TX_B1_CTL, 4, 3, dec3_mux_text); |
| 425 | |
| 426 | static const struct soc_enum dec4_mux_enum = |
| 427 | SOC_ENUM_SINGLE(TABLA_A_CDC_CONN_TX_B1_CTL, 6, 3, dec4_mux_text); |
| 428 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 429 | static const struct soc_enum dec5_mux_enum = |
| 430 | SOC_ENUM_SINGLE(TABLA_A_CDC_CONN_TX_B2_CTL, 0, 3, dec5_mux_text); |
| 431 | |
| 432 | static const struct soc_enum dec6_mux_enum = |
| 433 | SOC_ENUM_SINGLE(TABLA_A_CDC_CONN_TX_B2_CTL, 2, 3, dec6_mux_text); |
| 434 | |
| 435 | static const struct soc_enum dec7_mux_enum = |
| 436 | SOC_ENUM_SINGLE(TABLA_A_CDC_CONN_TX_B2_CTL, 4, 7, dec7_mux_text); |
| 437 | |
Bhalchandra Gajare | 0d77e1b | 2011-07-08 10:54:14 -0700 | [diff] [blame] | 438 | static const struct soc_enum dec8_mux_enum = |
| 439 | SOC_ENUM_SINGLE(TABLA_A_CDC_CONN_TX_B3_CTL, 0, 7, dec8_mux_text); |
| 440 | |
Bhalchandra Gajare | cc6ffa0 | 2011-07-14 18:35:41 -0700 | [diff] [blame] | 441 | static const struct soc_enum dec9_mux_enum = |
| 442 | SOC_ENUM_SINGLE(TABLA_A_CDC_CONN_TX_B3_CTL, 3, 8, dec9_mux_text); |
| 443 | |
| 444 | static const struct soc_enum dec10_mux_enum = |
| 445 | SOC_ENUM_SINGLE(TABLA_A_CDC_CONN_TX_B4_CTL, 0, 8, dec10_mux_text); |
| 446 | |
Bradley Rubin | 229c6a5 | 2011-07-12 16:18:48 -0700 | [diff] [blame] | 447 | static const struct soc_enum anc1_mux_enum = |
| 448 | SOC_ENUM_SINGLE(TABLA_A_CDC_CONN_ANC_B1_CTL, 0, 16, anc_mux_text); |
| 449 | |
| 450 | static const struct soc_enum anc2_mux_enum = |
| 451 | SOC_ENUM_SINGLE(TABLA_A_CDC_CONN_ANC_B1_CTL, 4, 16, anc_mux_text); |
| 452 | |
| 453 | static const struct soc_enum anc1_fb_mux_enum = |
| 454 | SOC_ENUM_SINGLE(TABLA_A_CDC_CONN_ANC_B2_CTL, 0, 3, anc1_fb_mux_text); |
| 455 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 456 | static const struct soc_enum iir1_inp1_mux_enum = |
| 457 | SOC_ENUM_SINGLE(TABLA_A_CDC_CONN_EQ1_B1_CTL, 0, 18, iir1_inp1_text); |
| 458 | |
| 459 | static const struct snd_kcontrol_new rx_mix1_inp1_mux = |
| 460 | SOC_DAPM_ENUM("RX1 MIX1 INP1 Mux", rx_mix1_inp1_chain_enum); |
| 461 | |
Bradley Rubin | 229c6a5 | 2011-07-12 16:18:48 -0700 | [diff] [blame] | 462 | static const struct snd_kcontrol_new rx_mix1_inp2_mux = |
| 463 | SOC_DAPM_ENUM("RX1 MIX1 INP2 Mux", rx_mix1_inp2_chain_enum); |
| 464 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 465 | static const struct snd_kcontrol_new rx2_mix1_inp1_mux = |
| 466 | SOC_DAPM_ENUM("RX2 MIX1 INP1 Mux", rx2_mix1_inp1_chain_enum); |
| 467 | |
Bradley Rubin | 229c6a5 | 2011-07-12 16:18:48 -0700 | [diff] [blame] | 468 | static const struct snd_kcontrol_new rx2_mix1_inp2_mux = |
| 469 | SOC_DAPM_ENUM("RX2 MIX1 INP2 Mux", rx2_mix1_inp2_chain_enum); |
| 470 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 471 | static const struct snd_kcontrol_new rx3_mix1_inp1_mux = |
| 472 | SOC_DAPM_ENUM("RX3 MIX1 INP1 Mux", rx3_mix1_inp1_chain_enum); |
| 473 | |
Bradley Rubin | 74a9b4a | 2011-06-13 15:03:43 -0700 | [diff] [blame] | 474 | static const struct snd_kcontrol_new rx3_mix1_inp2_mux = |
| 475 | SOC_DAPM_ENUM("RX3 MIX1 INP2 Mux", rx3_mix1_inp2_chain_enum); |
| 476 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 477 | static const struct snd_kcontrol_new rx4_mix1_inp1_mux = |
| 478 | SOC_DAPM_ENUM("RX4 MIX1 INP1 Mux", rx4_mix1_inp1_chain_enum); |
| 479 | |
Bradley Rubin | 74a9b4a | 2011-06-13 15:03:43 -0700 | [diff] [blame] | 480 | static const struct snd_kcontrol_new rx4_mix1_inp2_mux = |
| 481 | SOC_DAPM_ENUM("RX4 MIX1 INP2 Mux", rx4_mix1_inp2_chain_enum); |
| 482 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 483 | static const struct snd_kcontrol_new rx5_mix1_inp1_mux = |
| 484 | SOC_DAPM_ENUM("RX5 MIX1 INP1 Mux", rx5_mix1_inp1_chain_enum); |
| 485 | |
Bradley Rubin | 74a9b4a | 2011-06-13 15:03:43 -0700 | [diff] [blame] | 486 | static const struct snd_kcontrol_new rx5_mix1_inp2_mux = |
| 487 | SOC_DAPM_ENUM("RX5 MIX1 INP2 Mux", rx5_mix1_inp2_chain_enum); |
| 488 | |
| 489 | static const struct snd_kcontrol_new rx6_mix1_inp1_mux = |
| 490 | SOC_DAPM_ENUM("RX6 MIX1 INP1 Mux", rx6_mix1_inp1_chain_enum); |
| 491 | |
| 492 | static const struct snd_kcontrol_new rx6_mix1_inp2_mux = |
| 493 | SOC_DAPM_ENUM("RX6 MIX1 INP2 Mux", rx6_mix1_inp2_chain_enum); |
| 494 | |
Bhalchandra Gajare | 0a8ad17 | 2011-08-12 13:32:22 -0700 | [diff] [blame] | 495 | static const struct snd_kcontrol_new rx7_mix1_inp1_mux = |
| 496 | SOC_DAPM_ENUM("RX7 MIX1 INP1 Mux", rx7_mix1_inp1_chain_enum); |
| 497 | |
| 498 | static const struct snd_kcontrol_new rx7_mix1_inp2_mux = |
| 499 | SOC_DAPM_ENUM("RX7 MIX1 INP2 Mux", rx7_mix1_inp2_chain_enum); |
| 500 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 501 | static const struct snd_kcontrol_new sb_tx5_mux = |
| 502 | SOC_DAPM_ENUM("SLIM TX5 MUX Mux", sb_tx5_mux_enum); |
| 503 | |
| 504 | static const struct snd_kcontrol_new sb_tx6_mux = |
| 505 | SOC_DAPM_ENUM("SLIM TX6 MUX Mux", sb_tx6_mux_enum); |
| 506 | |
| 507 | static const struct snd_kcontrol_new sb_tx7_mux = |
| 508 | SOC_DAPM_ENUM("SLIM TX7 MUX Mux", sb_tx7_mux_enum); |
| 509 | |
| 510 | static const struct snd_kcontrol_new sb_tx8_mux = |
| 511 | SOC_DAPM_ENUM("SLIM TX8 MUX Mux", sb_tx8_mux_enum); |
| 512 | |
| 513 | static const struct snd_kcontrol_new sb_tx1_mux = |
| 514 | SOC_DAPM_ENUM("SLIM TX1 MUX Mux", sb_tx1_mux_enum); |
| 515 | |
| 516 | static const struct snd_kcontrol_new dec1_mux = |
| 517 | SOC_DAPM_ENUM("DEC1 MUX Mux", dec1_mux_enum); |
| 518 | |
Bhalchandra Gajare | 0d77e1b | 2011-07-08 10:54:14 -0700 | [diff] [blame] | 519 | static const struct snd_kcontrol_new dec2_mux = |
| 520 | SOC_DAPM_ENUM("DEC2 MUX Mux", dec2_mux_enum); |
| 521 | |
Bhalchandra Gajare | cc6ffa0 | 2011-07-14 18:35:41 -0700 | [diff] [blame] | 522 | static const struct snd_kcontrol_new dec3_mux = |
| 523 | SOC_DAPM_ENUM("DEC3 MUX Mux", dec3_mux_enum); |
| 524 | |
| 525 | static const struct snd_kcontrol_new dec4_mux = |
| 526 | SOC_DAPM_ENUM("DEC4 MUX Mux", dec4_mux_enum); |
| 527 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 528 | static const struct snd_kcontrol_new dec5_mux = |
| 529 | SOC_DAPM_ENUM("DEC5 MUX Mux", dec5_mux_enum); |
| 530 | |
| 531 | static const struct snd_kcontrol_new dec6_mux = |
| 532 | SOC_DAPM_ENUM("DEC6 MUX Mux", dec6_mux_enum); |
| 533 | |
| 534 | static const struct snd_kcontrol_new dec7_mux = |
| 535 | SOC_DAPM_ENUM("DEC7 MUX Mux", dec7_mux_enum); |
| 536 | |
Bradley Rubin | 229c6a5 | 2011-07-12 16:18:48 -0700 | [diff] [blame] | 537 | static const struct snd_kcontrol_new anc1_mux = |
| 538 | SOC_DAPM_ENUM("ANC1 MUX Mux", anc1_mux_enum); |
Bhalchandra Gajare | 0d77e1b | 2011-07-08 10:54:14 -0700 | [diff] [blame] | 539 | static const struct snd_kcontrol_new dec8_mux = |
| 540 | SOC_DAPM_ENUM("DEC8 MUX Mux", dec8_mux_enum); |
| 541 | |
Bhalchandra Gajare | cc6ffa0 | 2011-07-14 18:35:41 -0700 | [diff] [blame] | 542 | static const struct snd_kcontrol_new dec9_mux = |
| 543 | SOC_DAPM_ENUM("DEC9 MUX Mux", dec9_mux_enum); |
| 544 | |
| 545 | static const struct snd_kcontrol_new dec10_mux = |
| 546 | SOC_DAPM_ENUM("DEC10 MUX Mux", dec10_mux_enum); |
| 547 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 548 | static const struct snd_kcontrol_new iir1_inp1_mux = |
| 549 | SOC_DAPM_ENUM("IIR1 INP1 Mux", iir1_inp1_mux_enum); |
| 550 | |
Bradley Rubin | 229c6a5 | 2011-07-12 16:18:48 -0700 | [diff] [blame] | 551 | static const struct snd_kcontrol_new anc2_mux = |
| 552 | SOC_DAPM_ENUM("ANC2 MUX Mux", anc2_mux_enum); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 553 | |
Bradley Rubin | 229c6a5 | 2011-07-12 16:18:48 -0700 | [diff] [blame] | 554 | static const struct snd_kcontrol_new anc1_fb_mux = |
| 555 | SOC_DAPM_ENUM("ANC1 FB MUX Mux", anc1_fb_mux_enum); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 556 | |
Bradley Rubin | 229c6a5 | 2011-07-12 16:18:48 -0700 | [diff] [blame] | 557 | static const struct snd_kcontrol_new dac1_switch[] = { |
| 558 | SOC_DAPM_SINGLE("Switch", TABLA_A_RX_EAR_EN, 5, 1, 0) |
| 559 | }; |
| 560 | static const struct snd_kcontrol_new hphl_switch[] = { |
| 561 | SOC_DAPM_SINGLE("Switch", TABLA_A_RX_HPH_L_DAC_CTL, 6, 1, 0) |
| 562 | }; |
| 563 | static const struct snd_kcontrol_new hphr_switch[] = { |
| 564 | SOC_DAPM_SINGLE("Switch", TABLA_A_RX_HPH_R_DAC_CTL, 6, 1, 0) |
| 565 | }; |
| 566 | static const struct snd_kcontrol_new lineout1_switch[] = { |
| 567 | SOC_DAPM_SINGLE("Switch", TABLA_A_RX_LINE_1_DAC_CTL, 6, 1, 0) |
| 568 | }; |
| 569 | static const struct snd_kcontrol_new lineout2_switch[] = { |
| 570 | SOC_DAPM_SINGLE("Switch", TABLA_A_RX_LINE_2_DAC_CTL, 6, 1, 0) |
| 571 | }; |
| 572 | static const struct snd_kcontrol_new lineout3_switch[] = { |
| 573 | SOC_DAPM_SINGLE("Switch", TABLA_A_RX_LINE_3_DAC_CTL, 6, 1, 0) |
| 574 | }; |
| 575 | static const struct snd_kcontrol_new lineout4_switch[] = { |
| 576 | SOC_DAPM_SINGLE("Switch", TABLA_A_RX_LINE_4_DAC_CTL, 6, 1, 0) |
| 577 | }; |
Bhalchandra Gajare | 0a8ad17 | 2011-08-12 13:32:22 -0700 | [diff] [blame] | 578 | static const struct snd_kcontrol_new lineout5_switch[] = { |
| 579 | SOC_DAPM_SINGLE("Switch", TABLA_A_RX_LINE_5_DAC_CTL, 6, 1, 0) |
| 580 | }; |
Bradley Rubin | 74a9b4a | 2011-06-13 15:03:43 -0700 | [diff] [blame] | 581 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 582 | static void tabla_codec_enable_adc_block(struct snd_soc_codec *codec, |
| 583 | int enable) |
| 584 | { |
| 585 | struct tabla_priv *tabla = snd_soc_codec_get_drvdata(codec); |
| 586 | |
| 587 | pr_debug("%s %d\n", __func__, enable); |
| 588 | |
| 589 | if (enable) { |
| 590 | tabla->adc_count++; |
| 591 | snd_soc_update_bits(codec, TABLA_A_TX_COM_BIAS, 0xE0, 0xE0); |
| 592 | snd_soc_update_bits(codec, TABLA_A_CDC_CLK_OTHR_CTL, 0x2, 0x2); |
| 593 | } else { |
| 594 | tabla->adc_count--; |
| 595 | if (!tabla->adc_count) { |
| 596 | snd_soc_update_bits(codec, TABLA_A_CDC_CLK_OTHR_CTL, |
| 597 | 0x2, 0x0); |
| 598 | if (!tabla->mbhc_polling_active) |
| 599 | snd_soc_update_bits(codec, TABLA_A_TX_COM_BIAS, |
| 600 | 0xE0, 0x0); |
| 601 | } |
| 602 | } |
| 603 | } |
| 604 | |
| 605 | static int tabla_codec_enable_adc(struct snd_soc_dapm_widget *w, |
| 606 | struct snd_kcontrol *kcontrol, int event) |
| 607 | { |
| 608 | struct snd_soc_codec *codec = w->codec; |
| 609 | u16 adc_reg; |
| 610 | |
| 611 | pr_debug("%s %d\n", __func__, event); |
| 612 | |
| 613 | if (w->reg == TABLA_A_TX_1_2_EN) |
| 614 | adc_reg = TABLA_A_TX_1_2_TEST_CTL; |
| 615 | else if (w->reg == TABLA_A_TX_3_4_EN) |
| 616 | adc_reg = TABLA_A_TX_3_4_TEST_CTL; |
| 617 | else if (w->reg == TABLA_A_TX_5_6_EN) |
| 618 | adc_reg = TABLA_A_TX_5_6_TEST_CTL; |
| 619 | else { |
| 620 | pr_err("%s: Error, invalid adc register\n", __func__); |
| 621 | return -EINVAL; |
| 622 | } |
| 623 | |
| 624 | switch (event) { |
| 625 | case SND_SOC_DAPM_PRE_PMU: |
| 626 | tabla_codec_enable_adc_block(codec, 1); |
| 627 | break; |
| 628 | case SND_SOC_DAPM_POST_PMU: |
| 629 | snd_soc_update_bits(codec, adc_reg, 1 << w->shift, |
| 630 | 1 << w->shift); |
| 631 | usleep_range(1000, 1000); |
| 632 | snd_soc_update_bits(codec, adc_reg, 1 << w->shift, 0x00); |
| 633 | usleep_range(1000, 1000); |
| 634 | break; |
| 635 | case SND_SOC_DAPM_POST_PMD: |
| 636 | tabla_codec_enable_adc_block(codec, 0); |
| 637 | break; |
| 638 | } |
| 639 | return 0; |
| 640 | } |
| 641 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 642 | static int tabla_codec_enable_lineout(struct snd_soc_dapm_widget *w, |
| 643 | struct snd_kcontrol *kcontrol, int event) |
| 644 | { |
| 645 | struct snd_soc_codec *codec = w->codec; |
| 646 | u16 lineout_gain_reg; |
| 647 | |
Kiran Kandi | db0a4b0 | 2011-08-23 09:32:09 -0700 | [diff] [blame] | 648 | pr_debug("%s %d %s\n", __func__, event, w->name); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 649 | |
| 650 | switch (w->shift) { |
| 651 | case 0: |
| 652 | lineout_gain_reg = TABLA_A_RX_LINE_1_GAIN; |
| 653 | break; |
| 654 | case 1: |
| 655 | lineout_gain_reg = TABLA_A_RX_LINE_2_GAIN; |
| 656 | break; |
| 657 | case 2: |
| 658 | lineout_gain_reg = TABLA_A_RX_LINE_3_GAIN; |
| 659 | break; |
| 660 | case 3: |
| 661 | lineout_gain_reg = TABLA_A_RX_LINE_4_GAIN; |
| 662 | break; |
| 663 | case 4: |
| 664 | lineout_gain_reg = TABLA_A_RX_LINE_5_GAIN; |
| 665 | break; |
| 666 | default: |
| 667 | pr_err("%s: Error, incorrect lineout register value\n", |
| 668 | __func__); |
| 669 | return -EINVAL; |
| 670 | } |
| 671 | |
| 672 | switch (event) { |
| 673 | case SND_SOC_DAPM_PRE_PMU: |
| 674 | snd_soc_update_bits(codec, lineout_gain_reg, 0x40, 0x40); |
| 675 | break; |
| 676 | case SND_SOC_DAPM_POST_PMU: |
Kiran Kandi | db0a4b0 | 2011-08-23 09:32:09 -0700 | [diff] [blame] | 677 | pr_debug("%s: sleeping 40 ms after %s PA turn on\n", |
| 678 | __func__, w->name); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 679 | usleep_range(40000, 40000); |
| 680 | break; |
| 681 | case SND_SOC_DAPM_POST_PMD: |
| 682 | snd_soc_update_bits(codec, lineout_gain_reg, 0x40, 0x00); |
| 683 | break; |
| 684 | } |
| 685 | return 0; |
| 686 | } |
| 687 | |
Kiran Kandi | cf45f6a | 2011-07-17 21:10:19 -0700 | [diff] [blame] | 688 | |
| 689 | static int tabla_codec_enable_dmic(struct snd_soc_dapm_widget *w, |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 690 | struct snd_kcontrol *kcontrol, int event) |
| 691 | { |
| 692 | struct snd_soc_codec *codec = w->codec; |
Kiran Kandi | cf45f6a | 2011-07-17 21:10:19 -0700 | [diff] [blame] | 693 | u16 tx_mux_ctl_reg, tx_dmic_ctl_reg; |
| 694 | u8 dmic_clk_sel, dmic_clk_en; |
Bhalchandra Gajare | 7cf018e | 2011-08-11 18:58:32 -0700 | [diff] [blame] | 695 | unsigned int dmic; |
| 696 | int ret; |
Kiran Kandi | cf45f6a | 2011-07-17 21:10:19 -0700 | [diff] [blame] | 697 | |
Bhalchandra Gajare | 7cf018e | 2011-08-11 18:58:32 -0700 | [diff] [blame] | 698 | ret = kstrtouint(strpbrk(w->name, "123456"), 10, &dmic); |
| 699 | if (ret < 0) { |
| 700 | pr_err("%s: Invalid DMIC line on the codec\n", __func__); |
Kiran Kandi | cf45f6a | 2011-07-17 21:10:19 -0700 | [diff] [blame] | 701 | return -EINVAL; |
| 702 | } |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 703 | |
Bhalchandra Gajare | 7cf018e | 2011-08-11 18:58:32 -0700 | [diff] [blame] | 704 | switch (dmic) { |
| 705 | case 1: |
| 706 | case 2: |
| 707 | dmic_clk_sel = 0x02; |
| 708 | dmic_clk_en = 0x01; |
| 709 | break; |
| 710 | |
| 711 | case 3: |
| 712 | case 4: |
| 713 | dmic_clk_sel = 0x08; |
| 714 | dmic_clk_en = 0x04; |
| 715 | break; |
| 716 | |
| 717 | case 5: |
| 718 | case 6: |
| 719 | dmic_clk_sel = 0x20; |
| 720 | dmic_clk_en = 0x10; |
| 721 | break; |
| 722 | |
| 723 | default: |
| 724 | pr_err("%s: Invalid DMIC Selection\n", __func__); |
| 725 | return -EINVAL; |
| 726 | } |
| 727 | |
| 728 | tx_mux_ctl_reg = TABLA_A_CDC_TX1_MUX_CTL + 8 * (dmic - 1); |
| 729 | tx_dmic_ctl_reg = TABLA_A_CDC_TX1_DMIC_CTL + 8 * (dmic - 1); |
| 730 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 731 | pr_debug("%s %d\n", __func__, event); |
Kiran Kandi | cf45f6a | 2011-07-17 21:10:19 -0700 | [diff] [blame] | 732 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 733 | switch (event) { |
| 734 | case SND_SOC_DAPM_PRE_PMU: |
Kiran Kandi | cf45f6a | 2011-07-17 21:10:19 -0700 | [diff] [blame] | 735 | snd_soc_update_bits(codec, tx_mux_ctl_reg, 0x1, 0x1); |
| 736 | |
| 737 | snd_soc_update_bits(codec, TABLA_A_CDC_CLK_DMIC_CTL, |
| 738 | dmic_clk_sel, dmic_clk_sel); |
| 739 | |
| 740 | snd_soc_update_bits(codec, tx_dmic_ctl_reg, 0x1, 0x1); |
| 741 | |
| 742 | snd_soc_update_bits(codec, TABLA_A_CDC_CLK_DMIC_CTL, |
| 743 | dmic_clk_en, dmic_clk_en); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 744 | break; |
| 745 | case SND_SOC_DAPM_POST_PMD: |
Kiran Kandi | cf45f6a | 2011-07-17 21:10:19 -0700 | [diff] [blame] | 746 | snd_soc_update_bits(codec, TABLA_A_CDC_CLK_DMIC_CTL, |
| 747 | dmic_clk_en, 0); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 748 | break; |
| 749 | } |
| 750 | return 0; |
| 751 | } |
| 752 | |
Bradley Rubin | 229c6a5 | 2011-07-12 16:18:48 -0700 | [diff] [blame] | 753 | static int tabla_codec_enable_anc(struct snd_soc_dapm_widget *w, |
| 754 | struct snd_kcontrol *kcontrol, int event) |
| 755 | { |
| 756 | struct snd_soc_codec *codec = w->codec; |
| 757 | const char *filename; |
| 758 | const struct firmware *fw; |
| 759 | int i; |
| 760 | int ret; |
Bradley Rubin | a7096d0 | 2011-08-03 18:29:02 -0700 | [diff] [blame] | 761 | int num_anc_slots; |
| 762 | struct anc_header *anc_head; |
Bradley Rubin | 229c6a5 | 2011-07-12 16:18:48 -0700 | [diff] [blame] | 763 | struct tabla_priv *tabla = snd_soc_codec_get_drvdata(codec); |
Bradley Rubin | a7096d0 | 2011-08-03 18:29:02 -0700 | [diff] [blame] | 764 | u32 anc_writes_size = 0; |
| 765 | int anc_size_remaining; |
| 766 | u32 *anc_ptr; |
Bradley Rubin | 229c6a5 | 2011-07-12 16:18:48 -0700 | [diff] [blame] | 767 | u16 reg; |
| 768 | u8 mask, val, old_val; |
| 769 | |
| 770 | pr_debug("%s %d\n", __func__, event); |
| 771 | switch (event) { |
| 772 | case SND_SOC_DAPM_PRE_PMU: |
| 773 | |
Bradley Rubin | 4283a4c | 2011-07-29 16:18:54 -0700 | [diff] [blame] | 774 | filename = "wcd9310/wcd9310_anc.bin"; |
Bradley Rubin | 229c6a5 | 2011-07-12 16:18:48 -0700 | [diff] [blame] | 775 | |
| 776 | ret = request_firmware(&fw, filename, codec->dev); |
| 777 | if (ret != 0) { |
| 778 | dev_err(codec->dev, "Failed to acquire ANC data: %d\n", |
| 779 | ret); |
| 780 | return -ENODEV; |
| 781 | } |
| 782 | |
Bradley Rubin | a7096d0 | 2011-08-03 18:29:02 -0700 | [diff] [blame] | 783 | if (fw->size < sizeof(struct anc_header)) { |
Bradley Rubin | 229c6a5 | 2011-07-12 16:18:48 -0700 | [diff] [blame] | 784 | dev_err(codec->dev, "Not enough data\n"); |
| 785 | release_firmware(fw); |
| 786 | return -ENOMEM; |
| 787 | } |
| 788 | |
| 789 | /* First number is the number of register writes */ |
Bradley Rubin | a7096d0 | 2011-08-03 18:29:02 -0700 | [diff] [blame] | 790 | anc_head = (struct anc_header *)(fw->data); |
| 791 | anc_ptr = (u32 *)((u32)fw->data + sizeof(struct anc_header)); |
| 792 | anc_size_remaining = fw->size - sizeof(struct anc_header); |
| 793 | num_anc_slots = anc_head->num_anc_slots; |
Bradley Rubin | 229c6a5 | 2011-07-12 16:18:48 -0700 | [diff] [blame] | 794 | |
Bradley Rubin | a7096d0 | 2011-08-03 18:29:02 -0700 | [diff] [blame] | 795 | if (tabla->anc_slot >= num_anc_slots) { |
| 796 | dev_err(codec->dev, "Invalid ANC slot selected\n"); |
| 797 | release_firmware(fw); |
| 798 | return -EINVAL; |
| 799 | } |
| 800 | |
| 801 | for (i = 0; i < num_anc_slots; i++) { |
| 802 | |
| 803 | if (anc_size_remaining < TABLA_PACKED_REG_SIZE) { |
| 804 | dev_err(codec->dev, "Invalid register format\n"); |
| 805 | release_firmware(fw); |
| 806 | return -EINVAL; |
| 807 | } |
| 808 | anc_writes_size = (u32)(*anc_ptr); |
| 809 | anc_size_remaining -= sizeof(u32); |
| 810 | anc_ptr += 1; |
| 811 | |
| 812 | if (anc_writes_size * TABLA_PACKED_REG_SIZE |
| 813 | > anc_size_remaining) { |
| 814 | dev_err(codec->dev, "Invalid register format\n"); |
| 815 | release_firmware(fw); |
| 816 | return -ENOMEM; |
| 817 | } |
| 818 | |
| 819 | if (tabla->anc_slot == i) |
| 820 | break; |
| 821 | |
| 822 | anc_size_remaining -= (anc_writes_size * |
| 823 | TABLA_PACKED_REG_SIZE); |
Bradley Rubin | 939ff3f | 2011-08-26 17:19:34 -0700 | [diff] [blame] | 824 | anc_ptr += anc_writes_size; |
Bradley Rubin | a7096d0 | 2011-08-03 18:29:02 -0700 | [diff] [blame] | 825 | } |
| 826 | if (i == num_anc_slots) { |
| 827 | dev_err(codec->dev, "Selected ANC slot not present\n"); |
Bradley Rubin | 229c6a5 | 2011-07-12 16:18:48 -0700 | [diff] [blame] | 828 | release_firmware(fw); |
| 829 | return -ENOMEM; |
| 830 | } |
| 831 | |
Bradley Rubin | a7096d0 | 2011-08-03 18:29:02 -0700 | [diff] [blame] | 832 | for (i = 0; i < anc_writes_size; i++) { |
| 833 | TABLA_CODEC_UNPACK_ENTRY(anc_ptr[i], reg, |
Bradley Rubin | 229c6a5 | 2011-07-12 16:18:48 -0700 | [diff] [blame] | 834 | mask, val); |
| 835 | old_val = snd_soc_read(codec, reg); |
Bradley Rubin | 4283a4c | 2011-07-29 16:18:54 -0700 | [diff] [blame] | 836 | snd_soc_write(codec, reg, (old_val & ~mask) | |
| 837 | (val & mask)); |
Bradley Rubin | 229c6a5 | 2011-07-12 16:18:48 -0700 | [diff] [blame] | 838 | } |
| 839 | release_firmware(fw); |
Bradley Rubin | 229c6a5 | 2011-07-12 16:18:48 -0700 | [diff] [blame] | 840 | |
| 841 | break; |
| 842 | case SND_SOC_DAPM_POST_PMD: |
| 843 | snd_soc_write(codec, TABLA_A_CDC_CLK_ANC_RESET_CTL, 0xFF); |
| 844 | snd_soc_write(codec, TABLA_A_CDC_CLK_ANC_CLK_EN_CTL, 0); |
| 845 | break; |
| 846 | } |
| 847 | return 0; |
| 848 | } |
| 849 | |
Patrick Lai | 3043fba | 2011-08-01 14:15:57 -0700 | [diff] [blame] | 850 | static void tabla_codec_update_cfilt_usage(struct snd_soc_codec *codec, |
| 851 | u8 cfilt_sel, int inc) |
| 852 | { |
| 853 | struct tabla_priv *tabla = snd_soc_codec_get_drvdata(codec); |
| 854 | u32 *cfilt_cnt_ptr = NULL; |
| 855 | u16 micb_cfilt_reg; |
| 856 | |
| 857 | switch (cfilt_sel) { |
| 858 | case TABLA_CFILT1_SEL: |
| 859 | cfilt_cnt_ptr = &tabla->cfilt1_cnt; |
| 860 | micb_cfilt_reg = TABLA_A_MICB_CFILT_1_CTL; |
| 861 | break; |
| 862 | case TABLA_CFILT2_SEL: |
| 863 | cfilt_cnt_ptr = &tabla->cfilt2_cnt; |
| 864 | micb_cfilt_reg = TABLA_A_MICB_CFILT_2_CTL; |
| 865 | break; |
| 866 | case TABLA_CFILT3_SEL: |
| 867 | cfilt_cnt_ptr = &tabla->cfilt3_cnt; |
| 868 | micb_cfilt_reg = TABLA_A_MICB_CFILT_3_CTL; |
| 869 | break; |
| 870 | default: |
| 871 | return; /* should not happen */ |
| 872 | } |
| 873 | |
| 874 | if (inc) { |
| 875 | if (!(*cfilt_cnt_ptr)++) |
| 876 | snd_soc_update_bits(codec, micb_cfilt_reg, 0x80, 0x80); |
| 877 | } else { |
| 878 | /* check if count not zero, decrement |
| 879 | * then check if zero, go ahead disable cfilter |
| 880 | */ |
| 881 | if ((*cfilt_cnt_ptr) && !--(*cfilt_cnt_ptr)) |
| 882 | snd_soc_update_bits(codec, micb_cfilt_reg, 0x80, 0); |
| 883 | } |
| 884 | } |
Bradley Rubin | 229c6a5 | 2011-07-12 16:18:48 -0700 | [diff] [blame] | 885 | |
Bradley Rubin | cb3950a | 2011-08-18 13:07:26 -0700 | [diff] [blame] | 886 | static void tabla_codec_disable_button_presses(struct snd_soc_codec *codec) |
| 887 | { |
| 888 | snd_soc_write(codec, TABLA_A_CDC_MBHC_VOLT_B4_CTL, 0x80); |
| 889 | snd_soc_write(codec, TABLA_A_CDC_MBHC_VOLT_B3_CTL, 0x00); |
| 890 | } |
| 891 | |
Bradley Rubin | 4d09cf4 | 2011-08-17 17:59:16 -0700 | [diff] [blame] | 892 | static void tabla_codec_start_hs_polling(struct snd_soc_codec *codec) |
| 893 | { |
Bradley Rubin | cb3950a | 2011-08-18 13:07:26 -0700 | [diff] [blame] | 894 | struct tabla_priv *tabla = snd_soc_codec_get_drvdata(codec); |
| 895 | |
Bradley Rubin | 4d09cf4 | 2011-08-17 17:59:16 -0700 | [diff] [blame] | 896 | snd_soc_write(codec, TABLA_A_MBHC_SCALING_MUX_1, 0x84); |
Bradley Rubin | 4d09cf4 | 2011-08-17 17:59:16 -0700 | [diff] [blame] | 897 | tabla_enable_irq(codec->control_data, TABLA_IRQ_MBHC_REMOVAL); |
Bradley Rubin | cb3950a | 2011-08-18 13:07:26 -0700 | [diff] [blame] | 898 | if (!tabla->no_mic_headset_override) { |
| 899 | tabla_enable_irq(codec->control_data, TABLA_IRQ_MBHC_POTENTIAL); |
| 900 | tabla_enable_irq(codec->control_data, TABLA_IRQ_MBHC_RELEASE); |
| 901 | } else { |
| 902 | tabla_codec_disable_button_presses(codec); |
| 903 | } |
Bradley Rubin | 4d09cf4 | 2011-08-17 17:59:16 -0700 | [diff] [blame] | 904 | snd_soc_write(codec, TABLA_A_CDC_MBHC_EN_CTL, 0x1); |
| 905 | snd_soc_update_bits(codec, TABLA_A_CDC_MBHC_CLK_CTL, 0x8, 0x0); |
| 906 | snd_soc_write(codec, TABLA_A_CDC_MBHC_EN_CTL, 0x1); |
| 907 | } |
| 908 | |
| 909 | static void tabla_codec_pause_hs_polling(struct snd_soc_codec *codec) |
| 910 | { |
Bradley Rubin | cb3950a | 2011-08-18 13:07:26 -0700 | [diff] [blame] | 911 | struct tabla_priv *tabla = snd_soc_codec_get_drvdata(codec); |
| 912 | |
Bradley Rubin | 4d09cf4 | 2011-08-17 17:59:16 -0700 | [diff] [blame] | 913 | snd_soc_update_bits(codec, TABLA_A_CDC_MBHC_CLK_CTL, 0x8, 0x8); |
| 914 | tabla_disable_irq(codec->control_data, TABLA_IRQ_MBHC_REMOVAL); |
Bradley Rubin | cb3950a | 2011-08-18 13:07:26 -0700 | [diff] [blame] | 915 | if (!tabla->no_mic_headset_override) { |
| 916 | tabla_disable_irq(codec->control_data, |
| 917 | TABLA_IRQ_MBHC_POTENTIAL); |
| 918 | tabla_disable_irq(codec->control_data, TABLA_IRQ_MBHC_RELEASE); |
| 919 | } |
Bradley Rubin | 4d09cf4 | 2011-08-17 17:59:16 -0700 | [diff] [blame] | 920 | } |
| 921 | |
Bhalchandra Gajare | d9ebb6c | 2011-10-03 19:54:41 -0700 | [diff] [blame] | 922 | static int tabla_find_k_value(unsigned int ldoh_v, unsigned int cfilt_mv) |
| 923 | { |
| 924 | int rc = -EINVAL; |
| 925 | unsigned min_mv, max_mv; |
| 926 | |
| 927 | switch (ldoh_v) { |
| 928 | case TABLA_LDOH_1P95_V: |
| 929 | min_mv = 160; |
| 930 | max_mv = 1800; |
| 931 | break; |
| 932 | case TABLA_LDOH_2P35_V: |
| 933 | min_mv = 200; |
| 934 | max_mv = 2200; |
| 935 | break; |
| 936 | case TABLA_LDOH_2P75_V: |
| 937 | min_mv = 240; |
| 938 | max_mv = 2600; |
| 939 | break; |
| 940 | case TABLA_LDOH_2P85_V: |
| 941 | min_mv = 250; |
| 942 | max_mv = 2700; |
| 943 | break; |
| 944 | default: |
| 945 | goto done; |
| 946 | } |
| 947 | |
| 948 | if (cfilt_mv < min_mv || cfilt_mv > max_mv) |
| 949 | goto done; |
| 950 | |
| 951 | for (rc = 4; rc <= 44; rc++) { |
| 952 | min_mv = max_mv * (rc) / 44; |
| 953 | if (min_mv >= cfilt_mv) { |
| 954 | rc -= 4; |
| 955 | break; |
| 956 | } |
| 957 | } |
| 958 | done: |
| 959 | return rc; |
| 960 | } |
| 961 | |
| 962 | static bool tabla_is_hph_pa_on(struct snd_soc_codec *codec) |
| 963 | { |
| 964 | u8 hph_reg_val = 0; |
| 965 | hph_reg_val = snd_soc_read(codec, TABLA_A_RX_HPH_CNP_EN); |
| 966 | |
| 967 | return (hph_reg_val & 0x30) ? true : false; |
| 968 | } |
| 969 | |
| 970 | static void tabla_codec_switch_micbias(struct snd_soc_codec *codec, |
| 971 | int vddio_switch) |
| 972 | { |
| 973 | struct tabla_priv *tabla = snd_soc_codec_get_drvdata(codec); |
| 974 | int cfilt_k_val; |
| 975 | |
| 976 | switch (vddio_switch) { |
| 977 | case 1: |
| 978 | if (tabla->mbhc_polling_active) { |
| 979 | /* Enable Mic Bias switch to VDDIO */ |
| 980 | tabla->cfilt_k_value = snd_soc_read(codec, |
| 981 | tabla->mbhc_bias_regs.cfilt_val); |
| 982 | cfilt_k_val = tabla_find_k_value( |
| 983 | tabla->pdata->micbias.ldoh_v, 1800); |
| 984 | snd_soc_update_bits(codec, |
| 985 | tabla->mbhc_bias_regs.cfilt_val, |
| 986 | 0xFC, (cfilt_k_val << 2)); |
| 987 | |
| 988 | snd_soc_update_bits(codec, |
| 989 | tabla->mbhc_bias_regs.mbhc_reg, 0x80, 0x80); |
| 990 | snd_soc_update_bits(codec, |
| 991 | tabla->mbhc_bias_regs.mbhc_reg, 0x10, 0x00); |
| 992 | |
| 993 | tabla->mbhc_micbias_switched = true; |
| 994 | pr_debug("%s: Enabled MBHC Mic bias to VDDIO Switch\n", |
| 995 | __func__); |
| 996 | } |
| 997 | break; |
| 998 | |
| 999 | case 0: |
| 1000 | if (tabla->mbhc_micbias_switched) { |
| 1001 | /* Disable Mic Bias switch to VDDIO */ |
| 1002 | if (tabla->cfilt_k_value != 0) |
| 1003 | snd_soc_update_bits(codec, |
| 1004 | tabla->mbhc_bias_regs.cfilt_val, 0XFC, |
| 1005 | tabla->cfilt_k_value); |
| 1006 | snd_soc_update_bits(codec, |
| 1007 | tabla->mbhc_bias_regs.mbhc_reg, 0x80, 0x00); |
| 1008 | snd_soc_update_bits(codec, |
| 1009 | tabla->mbhc_bias_regs.mbhc_reg, 0x10, 0x00); |
| 1010 | |
| 1011 | tabla->mbhc_micbias_switched = false; |
| 1012 | pr_debug("%s: Disabled MBHC Mic bias to VDDIO Switch\n", |
| 1013 | __func__); |
| 1014 | } |
| 1015 | break; |
| 1016 | } |
| 1017 | } |
| 1018 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1019 | static int tabla_codec_enable_micbias(struct snd_soc_dapm_widget *w, |
| 1020 | struct snd_kcontrol *kcontrol, int event) |
| 1021 | { |
| 1022 | struct snd_soc_codec *codec = w->codec; |
Patrick Lai | 3043fba | 2011-08-01 14:15:57 -0700 | [diff] [blame] | 1023 | struct tabla_priv *tabla = snd_soc_codec_get_drvdata(codec); |
| 1024 | u16 micb_int_reg; |
Bradley Rubin | 4d09cf4 | 2011-08-17 17:59:16 -0700 | [diff] [blame] | 1025 | int micb_line; |
Bhalchandra Gajare | cc6ffa0 | 2011-07-14 18:35:41 -0700 | [diff] [blame] | 1026 | u8 cfilt_sel_val = 0; |
Bradley Rubin | 229c6a5 | 2011-07-12 16:18:48 -0700 | [diff] [blame] | 1027 | char *internal1_text = "Internal1"; |
| 1028 | char *internal2_text = "Internal2"; |
| 1029 | char *internal3_text = "Internal3"; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1030 | |
| 1031 | pr_debug("%s %d\n", __func__, event); |
| 1032 | switch (w->reg) { |
| 1033 | case TABLA_A_MICB_1_CTL: |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1034 | micb_int_reg = TABLA_A_MICB_1_INT_RBIAS; |
Patrick Lai | 3043fba | 2011-08-01 14:15:57 -0700 | [diff] [blame] | 1035 | cfilt_sel_val = tabla->pdata->micbias.bias1_cfilt_sel; |
Bradley Rubin | 4d09cf4 | 2011-08-17 17:59:16 -0700 | [diff] [blame] | 1036 | micb_line = TABLA_MICBIAS1; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1037 | break; |
| 1038 | case TABLA_A_MICB_2_CTL: |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1039 | micb_int_reg = TABLA_A_MICB_2_INT_RBIAS; |
Patrick Lai | 3043fba | 2011-08-01 14:15:57 -0700 | [diff] [blame] | 1040 | cfilt_sel_val = tabla->pdata->micbias.bias2_cfilt_sel; |
Bradley Rubin | 4d09cf4 | 2011-08-17 17:59:16 -0700 | [diff] [blame] | 1041 | micb_line = TABLA_MICBIAS2; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1042 | break; |
| 1043 | case TABLA_A_MICB_3_CTL: |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1044 | micb_int_reg = TABLA_A_MICB_3_INT_RBIAS; |
Patrick Lai | 3043fba | 2011-08-01 14:15:57 -0700 | [diff] [blame] | 1045 | cfilt_sel_val = tabla->pdata->micbias.bias3_cfilt_sel; |
Bradley Rubin | 4d09cf4 | 2011-08-17 17:59:16 -0700 | [diff] [blame] | 1046 | micb_line = TABLA_MICBIAS3; |
Bhalchandra Gajare | cc6ffa0 | 2011-07-14 18:35:41 -0700 | [diff] [blame] | 1047 | break; |
| 1048 | case TABLA_A_MICB_4_CTL: |
Bhalchandra Gajare | cc6ffa0 | 2011-07-14 18:35:41 -0700 | [diff] [blame] | 1049 | micb_int_reg = TABLA_A_MICB_4_INT_RBIAS; |
Patrick Lai | 3043fba | 2011-08-01 14:15:57 -0700 | [diff] [blame] | 1050 | cfilt_sel_val = tabla->pdata->micbias.bias4_cfilt_sel; |
Bradley Rubin | 4d09cf4 | 2011-08-17 17:59:16 -0700 | [diff] [blame] | 1051 | micb_line = TABLA_MICBIAS4; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1052 | break; |
| 1053 | default: |
| 1054 | pr_err("%s: Error, invalid micbias register\n", __func__); |
| 1055 | return -EINVAL; |
| 1056 | } |
| 1057 | |
| 1058 | switch (event) { |
| 1059 | case SND_SOC_DAPM_PRE_PMU: |
Bhalchandra Gajare | d9ebb6c | 2011-10-03 19:54:41 -0700 | [diff] [blame] | 1060 | /* Decide whether to switch the micbias for MBHC */ |
| 1061 | if ((w->reg == tabla->mbhc_bias_regs.ctl_reg) |
| 1062 | && tabla->mbhc_micbias_switched) |
| 1063 | tabla_codec_switch_micbias(codec, 0); |
| 1064 | |
Bhalchandra Gajare | cc6ffa0 | 2011-07-14 18:35:41 -0700 | [diff] [blame] | 1065 | snd_soc_update_bits(codec, w->reg, 0x0E, 0x0A); |
Patrick Lai | 3043fba | 2011-08-01 14:15:57 -0700 | [diff] [blame] | 1066 | tabla_codec_update_cfilt_usage(codec, cfilt_sel_val, 1); |
Bradley Rubin | 229c6a5 | 2011-07-12 16:18:48 -0700 | [diff] [blame] | 1067 | |
| 1068 | if (strnstr(w->name, internal1_text, 30)) |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1069 | snd_soc_update_bits(codec, micb_int_reg, 0xE0, 0xE0); |
Bradley Rubin | 229c6a5 | 2011-07-12 16:18:48 -0700 | [diff] [blame] | 1070 | else if (strnstr(w->name, internal2_text, 30)) |
| 1071 | snd_soc_update_bits(codec, micb_int_reg, 0x1C, 0x1C); |
| 1072 | else if (strnstr(w->name, internal3_text, 30)) |
| 1073 | snd_soc_update_bits(codec, micb_int_reg, 0x3, 0x3); |
| 1074 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1075 | break; |
Bradley Rubin | 4d09cf4 | 2011-08-17 17:59:16 -0700 | [diff] [blame] | 1076 | case SND_SOC_DAPM_POST_PMU: |
| 1077 | if (tabla->mbhc_polling_active && |
| 1078 | (tabla->calibration->bias == micb_line)) { |
| 1079 | tabla_codec_pause_hs_polling(codec); |
| 1080 | tabla_codec_start_hs_polling(codec); |
| 1081 | } |
| 1082 | break; |
Bhalchandra Gajare | d9ebb6c | 2011-10-03 19:54:41 -0700 | [diff] [blame] | 1083 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1084 | case SND_SOC_DAPM_POST_PMD: |
Bhalchandra Gajare | d9ebb6c | 2011-10-03 19:54:41 -0700 | [diff] [blame] | 1085 | |
| 1086 | if ((w->reg == tabla->mbhc_bias_regs.ctl_reg) |
| 1087 | && tabla_is_hph_pa_on(codec)) |
| 1088 | tabla_codec_switch_micbias(codec, 1); |
| 1089 | |
Bradley Rubin | 229c6a5 | 2011-07-12 16:18:48 -0700 | [diff] [blame] | 1090 | if (strnstr(w->name, internal1_text, 30)) |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1091 | snd_soc_update_bits(codec, micb_int_reg, 0x80, 0x00); |
Bradley Rubin | 229c6a5 | 2011-07-12 16:18:48 -0700 | [diff] [blame] | 1092 | else if (strnstr(w->name, internal2_text, 30)) |
| 1093 | snd_soc_update_bits(codec, micb_int_reg, 0x10, 0x00); |
| 1094 | else if (strnstr(w->name, internal3_text, 30)) |
| 1095 | snd_soc_update_bits(codec, micb_int_reg, 0x2, 0x0); |
| 1096 | |
Patrick Lai | 3043fba | 2011-08-01 14:15:57 -0700 | [diff] [blame] | 1097 | tabla_codec_update_cfilt_usage(codec, cfilt_sel_val, 0); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1098 | break; |
| 1099 | } |
| 1100 | |
| 1101 | return 0; |
| 1102 | } |
| 1103 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1104 | static int tabla_codec_enable_dec(struct snd_soc_dapm_widget *w, |
| 1105 | struct snd_kcontrol *kcontrol, int event) |
| 1106 | { |
| 1107 | struct snd_soc_codec *codec = w->codec; |
| 1108 | u16 dec_reset_reg; |
| 1109 | |
| 1110 | pr_debug("%s %d\n", __func__, event); |
| 1111 | |
| 1112 | if (w->reg == TABLA_A_CDC_CLK_TX_CLK_EN_B1_CTL) |
| 1113 | dec_reset_reg = TABLA_A_CDC_CLK_TX_RESET_B1_CTL; |
| 1114 | else if (w->reg == TABLA_A_CDC_CLK_TX_CLK_EN_B2_CTL) |
| 1115 | dec_reset_reg = TABLA_A_CDC_CLK_TX_RESET_B2_CTL; |
| 1116 | else { |
| 1117 | pr_err("%s: Error, incorrect dec\n", __func__); |
| 1118 | return -EINVAL; |
| 1119 | } |
| 1120 | |
| 1121 | switch (event) { |
| 1122 | case SND_SOC_DAPM_PRE_PMU: |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1123 | snd_soc_update_bits(codec, dec_reset_reg, 1 << w->shift, |
| 1124 | 1 << w->shift); |
| 1125 | snd_soc_update_bits(codec, dec_reset_reg, 1 << w->shift, 0x0); |
| 1126 | break; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1127 | } |
| 1128 | return 0; |
| 1129 | } |
| 1130 | |
Bradley Rubin | 74a9b4a | 2011-06-13 15:03:43 -0700 | [diff] [blame] | 1131 | static int tabla_codec_reset_interpolator(struct snd_soc_dapm_widget *w, |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1132 | struct snd_kcontrol *kcontrol, int event) |
| 1133 | { |
| 1134 | struct snd_soc_codec *codec = w->codec; |
| 1135 | |
| 1136 | switch (event) { |
| 1137 | case SND_SOC_DAPM_PRE_PMU: |
Bradley Rubin | 74a9b4a | 2011-06-13 15:03:43 -0700 | [diff] [blame] | 1138 | snd_soc_update_bits(codec, TABLA_A_CDC_CLK_RX_RESET_CTL, |
| 1139 | 1 << w->shift, 1 << w->shift); |
| 1140 | snd_soc_update_bits(codec, TABLA_A_CDC_CLK_RX_RESET_CTL, |
| 1141 | 1 << w->shift, 0x0); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1142 | break; |
| 1143 | } |
| 1144 | return 0; |
| 1145 | } |
| 1146 | |
Bradley Rubin | 229c6a5 | 2011-07-12 16:18:48 -0700 | [diff] [blame] | 1147 | static int tabla_codec_enable_ldo_h(struct snd_soc_dapm_widget *w, |
| 1148 | struct snd_kcontrol *kcontrol, int event) |
| 1149 | { |
| 1150 | switch (event) { |
| 1151 | case SND_SOC_DAPM_POST_PMU: |
| 1152 | case SND_SOC_DAPM_POST_PMD: |
| 1153 | usleep_range(1000, 1000); |
| 1154 | break; |
| 1155 | } |
| 1156 | return 0; |
| 1157 | } |
| 1158 | |
Kiran Kandi | 6fae8bf | 2011-08-15 10:36:42 -0700 | [diff] [blame] | 1159 | |
| 1160 | static void tabla_enable_rx_bias(struct snd_soc_codec *codec, u32 enable) |
| 1161 | { |
| 1162 | struct tabla_priv *tabla = snd_soc_codec_get_drvdata(codec); |
| 1163 | |
| 1164 | if (enable) { |
| 1165 | tabla->rx_bias_count++; |
| 1166 | if (tabla->rx_bias_count == 1) |
| 1167 | snd_soc_update_bits(codec, TABLA_A_RX_COM_BIAS, |
| 1168 | 0x80, 0x80); |
| 1169 | } else { |
| 1170 | tabla->rx_bias_count--; |
| 1171 | if (!tabla->rx_bias_count) |
| 1172 | snd_soc_update_bits(codec, TABLA_A_RX_COM_BIAS, |
| 1173 | 0x80, 0x00); |
| 1174 | } |
| 1175 | } |
| 1176 | |
| 1177 | static int tabla_codec_enable_rx_bias(struct snd_soc_dapm_widget *w, |
| 1178 | struct snd_kcontrol *kcontrol, int event) |
| 1179 | { |
| 1180 | struct snd_soc_codec *codec = w->codec; |
| 1181 | |
| 1182 | pr_debug("%s %d\n", __func__, event); |
| 1183 | |
| 1184 | switch (event) { |
| 1185 | case SND_SOC_DAPM_PRE_PMU: |
| 1186 | tabla_enable_rx_bias(codec, 1); |
| 1187 | break; |
| 1188 | case SND_SOC_DAPM_POST_PMD: |
| 1189 | tabla_enable_rx_bias(codec, 0); |
| 1190 | break; |
| 1191 | } |
| 1192 | return 0; |
| 1193 | } |
| 1194 | |
Kiran Kandi | bf0b1ff | 2011-09-15 13:55:21 -0700 | [diff] [blame] | 1195 | static int tabla_hph_pa_event(struct snd_soc_dapm_widget *w, |
| 1196 | struct snd_kcontrol *kcontrol, int event) |
| 1197 | { |
Bhalchandra Gajare | d9ebb6c | 2011-10-03 19:54:41 -0700 | [diff] [blame] | 1198 | struct snd_soc_codec *codec = w->codec; |
| 1199 | struct tabla_priv *tabla = snd_soc_codec_get_drvdata(codec); |
| 1200 | u8 mbhc_micb_ctl_val; |
Kiran Kandi | bf0b1ff | 2011-09-15 13:55:21 -0700 | [diff] [blame] | 1201 | pr_debug("%s: event = %d\n", __func__, event); |
| 1202 | |
| 1203 | switch (event) { |
Bhalchandra Gajare | d9ebb6c | 2011-10-03 19:54:41 -0700 | [diff] [blame] | 1204 | case SND_SOC_DAPM_PRE_PMU: |
| 1205 | mbhc_micb_ctl_val = snd_soc_read(codec, |
| 1206 | tabla->mbhc_bias_regs.ctl_reg); |
| 1207 | |
| 1208 | if (!(mbhc_micb_ctl_val & 0x80) |
| 1209 | && !tabla->mbhc_micbias_switched) |
| 1210 | tabla_codec_switch_micbias(codec, 1); |
| 1211 | |
| 1212 | break; |
| 1213 | |
Kiran Kandi | bf0b1ff | 2011-09-15 13:55:21 -0700 | [diff] [blame] | 1214 | case SND_SOC_DAPM_POST_PMD: |
| 1215 | |
Bhalchandra Gajare | d9ebb6c | 2011-10-03 19:54:41 -0700 | [diff] [blame] | 1216 | if (tabla->mbhc_micbias_switched) |
| 1217 | tabla_codec_switch_micbias(codec, 0); |
| 1218 | |
Kiran Kandi | bf0b1ff | 2011-09-15 13:55:21 -0700 | [diff] [blame] | 1219 | pr_debug("%s: sleep 10 ms after %s PA disable.\n", __func__, |
| 1220 | w->name); |
| 1221 | usleep_range(10000, 10000); |
| 1222 | |
| 1223 | break; |
| 1224 | } |
| 1225 | return 0; |
| 1226 | } |
| 1227 | |
Bhalchandra Gajare | 02d90cd | 2011-09-30 16:14:00 -0700 | [diff] [blame] | 1228 | static void tabla_get_mbhc_micbias_regs(struct snd_soc_codec *codec, |
| 1229 | struct mbhc_micbias_regs *micbias_regs) |
| 1230 | { |
| 1231 | struct tabla_priv *tabla = snd_soc_codec_get_drvdata(codec); |
| 1232 | struct tabla_mbhc_calibration *calibration = tabla->calibration; |
| 1233 | unsigned int cfilt; |
| 1234 | |
| 1235 | switch (calibration->bias) { |
| 1236 | case TABLA_MICBIAS1: |
| 1237 | cfilt = tabla->pdata->micbias.bias1_cfilt_sel; |
| 1238 | micbias_regs->mbhc_reg = TABLA_A_MICB_1_MBHC; |
| 1239 | micbias_regs->int_rbias = TABLA_A_MICB_1_INT_RBIAS; |
| 1240 | micbias_regs->ctl_reg = TABLA_A_MICB_1_CTL; |
| 1241 | break; |
| 1242 | case TABLA_MICBIAS2: |
| 1243 | cfilt = tabla->pdata->micbias.bias2_cfilt_sel; |
| 1244 | micbias_regs->mbhc_reg = TABLA_A_MICB_2_MBHC; |
| 1245 | micbias_regs->int_rbias = TABLA_A_MICB_2_INT_RBIAS; |
| 1246 | micbias_regs->ctl_reg = TABLA_A_MICB_2_CTL; |
| 1247 | break; |
| 1248 | case TABLA_MICBIAS3: |
| 1249 | cfilt = tabla->pdata->micbias.bias3_cfilt_sel; |
| 1250 | micbias_regs->mbhc_reg = TABLA_A_MICB_3_MBHC; |
| 1251 | micbias_regs->int_rbias = TABLA_A_MICB_3_INT_RBIAS; |
| 1252 | micbias_regs->ctl_reg = TABLA_A_MICB_3_CTL; |
| 1253 | break; |
| 1254 | case TABLA_MICBIAS4: |
| 1255 | cfilt = tabla->pdata->micbias.bias4_cfilt_sel; |
| 1256 | micbias_regs->mbhc_reg = TABLA_A_MICB_4_MBHC; |
| 1257 | micbias_regs->int_rbias = TABLA_A_MICB_4_INT_RBIAS; |
| 1258 | micbias_regs->ctl_reg = TABLA_A_MICB_4_CTL; |
| 1259 | break; |
| 1260 | default: |
| 1261 | /* Should never reach here */ |
| 1262 | pr_err("%s: Invalid MIC BIAS for MBHC\n", __func__); |
| 1263 | } |
| 1264 | |
| 1265 | switch (cfilt) { |
| 1266 | case TABLA_CFILT1_SEL: |
| 1267 | micbias_regs->cfilt_val = TABLA_A_MICB_CFILT_1_VAL; |
| 1268 | micbias_regs->cfilt_ctl = TABLA_A_MICB_CFILT_1_CTL; |
| 1269 | break; |
| 1270 | case TABLA_CFILT2_SEL: |
| 1271 | micbias_regs->cfilt_val = TABLA_A_MICB_CFILT_2_VAL; |
| 1272 | micbias_regs->cfilt_ctl = TABLA_A_MICB_CFILT_2_CTL; |
| 1273 | break; |
| 1274 | case TABLA_CFILT3_SEL: |
| 1275 | micbias_regs->cfilt_val = TABLA_A_MICB_CFILT_3_VAL; |
| 1276 | micbias_regs->cfilt_ctl = TABLA_A_MICB_CFILT_3_CTL; |
| 1277 | break; |
| 1278 | } |
| 1279 | } |
| 1280 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1281 | static const struct snd_soc_dapm_widget tabla_dapm_widgets[] = { |
| 1282 | /*RX stuff */ |
| 1283 | SND_SOC_DAPM_OUTPUT("EAR"), |
| 1284 | |
Kiran Kandi | d2d86b5 | 2011-09-09 17:44:28 -0700 | [diff] [blame] | 1285 | SND_SOC_DAPM_PGA("EAR PA", TABLA_A_RX_EAR_EN, 4, 0, NULL, 0), |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1286 | |
Bradley Rubin | 229c6a5 | 2011-07-12 16:18:48 -0700 | [diff] [blame] | 1287 | SND_SOC_DAPM_MIXER("DAC1", TABLA_A_RX_EAR_EN, 6, 0, dac1_switch, |
| 1288 | ARRAY_SIZE(dac1_switch)), |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1289 | |
Bradley Rubin | 229c6a5 | 2011-07-12 16:18:48 -0700 | [diff] [blame] | 1290 | SND_SOC_DAPM_AIF_IN("SLIM RX1", "AIF1 Playback", 0, SND_SOC_NOPM, 0, 0), |
| 1291 | SND_SOC_DAPM_AIF_IN("SLIM RX2", "AIF1 Playback", 0, SND_SOC_NOPM, 0, 0), |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1292 | |
| 1293 | /* Headphone */ |
| 1294 | SND_SOC_DAPM_OUTPUT("HEADPHONE"), |
Kiran Kandi | bf0b1ff | 2011-09-15 13:55:21 -0700 | [diff] [blame] | 1295 | SND_SOC_DAPM_PGA_E("HPHL", TABLA_A_RX_HPH_CNP_EN, 5, 0, NULL, 0, |
Bhalchandra Gajare | d9ebb6c | 2011-10-03 19:54:41 -0700 | [diff] [blame] | 1296 | tabla_hph_pa_event, SND_SOC_DAPM_PRE_PMU | |
| 1297 | SND_SOC_DAPM_POST_PMD), |
Bradley Rubin | 229c6a5 | 2011-07-12 16:18:48 -0700 | [diff] [blame] | 1298 | SND_SOC_DAPM_MIXER("HPHL DAC", TABLA_A_RX_HPH_L_DAC_CTL, 7, 0, |
| 1299 | hphl_switch, ARRAY_SIZE(hphl_switch)), |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1300 | |
Kiran Kandi | bf0b1ff | 2011-09-15 13:55:21 -0700 | [diff] [blame] | 1301 | SND_SOC_DAPM_PGA_E("HPHR", TABLA_A_RX_HPH_CNP_EN, 4, 0, NULL, 0, |
Bhalchandra Gajare | d9ebb6c | 2011-10-03 19:54:41 -0700 | [diff] [blame] | 1302 | tabla_hph_pa_event, SND_SOC_DAPM_PRE_PMU | |
| 1303 | SND_SOC_DAPM_POST_PMD), |
Bradley Rubin | 229c6a5 | 2011-07-12 16:18:48 -0700 | [diff] [blame] | 1304 | SND_SOC_DAPM_MIXER("HPHR DAC", TABLA_A_RX_HPH_R_DAC_CTL, 7, 0, |
| 1305 | hphr_switch, ARRAY_SIZE(hphr_switch)), |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1306 | |
| 1307 | /* Speaker */ |
Kiran Kandi | db0a4b0 | 2011-08-23 09:32:09 -0700 | [diff] [blame] | 1308 | SND_SOC_DAPM_OUTPUT("LINEOUT1"), |
| 1309 | SND_SOC_DAPM_OUTPUT("LINEOUT2"), |
| 1310 | SND_SOC_DAPM_OUTPUT("LINEOUT3"), |
| 1311 | SND_SOC_DAPM_OUTPUT("LINEOUT4"), |
| 1312 | SND_SOC_DAPM_OUTPUT("LINEOUT5"), |
Bradley Rubin | 74a9b4a | 2011-06-13 15:03:43 -0700 | [diff] [blame] | 1313 | |
Kiran Kandi | db0a4b0 | 2011-08-23 09:32:09 -0700 | [diff] [blame] | 1314 | SND_SOC_DAPM_PGA_E("LINEOUT1 PA", TABLA_A_RX_LINE_CNP_EN, 0, 0, NULL, |
| 1315 | 0, tabla_codec_enable_lineout, SND_SOC_DAPM_PRE_PMU | |
| 1316 | SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD), |
| 1317 | SND_SOC_DAPM_PGA_E("LINEOUT2 PA", TABLA_A_RX_LINE_CNP_EN, 1, 0, NULL, |
| 1318 | 0, tabla_codec_enable_lineout, SND_SOC_DAPM_PRE_PMU | |
| 1319 | SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD), |
| 1320 | SND_SOC_DAPM_PGA_E("LINEOUT3 PA", TABLA_A_RX_LINE_CNP_EN, 2, 0, NULL, |
| 1321 | 0, tabla_codec_enable_lineout, SND_SOC_DAPM_PRE_PMU | |
| 1322 | SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD), |
| 1323 | SND_SOC_DAPM_PGA_E("LINEOUT4 PA", TABLA_A_RX_LINE_CNP_EN, 3, 0, NULL, |
| 1324 | 0, tabla_codec_enable_lineout, SND_SOC_DAPM_PRE_PMU | |
| 1325 | SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD), |
| 1326 | SND_SOC_DAPM_PGA_E("LINEOUT5 PA", TABLA_A_RX_LINE_CNP_EN, 4, 0, NULL, 0, |
Bhalchandra Gajare | 0a8ad17 | 2011-08-12 13:32:22 -0700 | [diff] [blame] | 1327 | tabla_codec_enable_lineout, SND_SOC_DAPM_PRE_PMU | |
| 1328 | SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD), |
Bradley Rubin | 74a9b4a | 2011-06-13 15:03:43 -0700 | [diff] [blame] | 1329 | |
Bradley Rubin | 229c6a5 | 2011-07-12 16:18:48 -0700 | [diff] [blame] | 1330 | SND_SOC_DAPM_MIXER("LINEOUT1 DAC", TABLA_A_RX_LINE_1_DAC_CTL, 7, 0, |
| 1331 | lineout1_switch, ARRAY_SIZE(lineout1_switch)), |
| 1332 | SND_SOC_DAPM_MIXER("LINEOUT2 DAC", TABLA_A_RX_LINE_2_DAC_CTL, 7, 0, |
| 1333 | lineout2_switch, ARRAY_SIZE(lineout2_switch)), |
| 1334 | SND_SOC_DAPM_MIXER("LINEOUT3 DAC", TABLA_A_RX_LINE_3_DAC_CTL, 7, 0, |
| 1335 | lineout3_switch, ARRAY_SIZE(lineout3_switch)), |
| 1336 | SND_SOC_DAPM_MIXER("LINEOUT4 DAC", TABLA_A_RX_LINE_4_DAC_CTL, 7, 0, |
| 1337 | lineout4_switch, ARRAY_SIZE(lineout4_switch)), |
Bhalchandra Gajare | 0a8ad17 | 2011-08-12 13:32:22 -0700 | [diff] [blame] | 1338 | SND_SOC_DAPM_MIXER("LINEOUT5 DAC", TABLA_A_RX_LINE_5_DAC_CTL, 7, 0, |
| 1339 | lineout5_switch, ARRAY_SIZE(lineout5_switch)), |
Bradley Rubin | 74a9b4a | 2011-06-13 15:03:43 -0700 | [diff] [blame] | 1340 | |
Bradley Rubin | 229c6a5 | 2011-07-12 16:18:48 -0700 | [diff] [blame] | 1341 | SND_SOC_DAPM_MIXER_E("RX1 MIX1", TABLA_A_CDC_CLK_RX_B1_CTL, 0, 0, NULL, |
| 1342 | 0, tabla_codec_reset_interpolator, SND_SOC_DAPM_PRE_PMU), |
| 1343 | SND_SOC_DAPM_MIXER_E("RX2 MIX1", TABLA_A_CDC_CLK_RX_B1_CTL, 1, 0, NULL, |
| 1344 | 0, tabla_codec_reset_interpolator, SND_SOC_DAPM_PRE_PMU), |
| 1345 | SND_SOC_DAPM_MIXER_E("RX3 MIX1", TABLA_A_CDC_CLK_RX_B1_CTL, 2, 0, NULL, |
| 1346 | 0, tabla_codec_reset_interpolator, SND_SOC_DAPM_PRE_PMU), |
| 1347 | SND_SOC_DAPM_MIXER_E("RX4 MIX1", TABLA_A_CDC_CLK_RX_B1_CTL, 3, 0, NULL, |
| 1348 | 0, tabla_codec_reset_interpolator, SND_SOC_DAPM_PRE_PMU), |
| 1349 | SND_SOC_DAPM_MIXER_E("RX5 MIX1", TABLA_A_CDC_CLK_RX_B1_CTL, 4, 0, NULL, |
| 1350 | 0, tabla_codec_reset_interpolator, SND_SOC_DAPM_PRE_PMU), |
| 1351 | SND_SOC_DAPM_MIXER_E("RX6 MIX1", TABLA_A_CDC_CLK_RX_B1_CTL, 5, 0, NULL, |
| 1352 | 0, tabla_codec_reset_interpolator, SND_SOC_DAPM_PRE_PMU), |
Bhalchandra Gajare | 0a8ad17 | 2011-08-12 13:32:22 -0700 | [diff] [blame] | 1353 | SND_SOC_DAPM_MIXER_E("RX7 MIX1", TABLA_A_CDC_CLK_RX_B1_CTL, 6, 0, NULL, |
| 1354 | 0, tabla_codec_reset_interpolator, SND_SOC_DAPM_PRE_PMU), |
Bradley Rubin | 74a9b4a | 2011-06-13 15:03:43 -0700 | [diff] [blame] | 1355 | |
Bradley Rubin | 229c6a5 | 2011-07-12 16:18:48 -0700 | [diff] [blame] | 1356 | SND_SOC_DAPM_MIXER("RX1 CHAIN", TABLA_A_CDC_RX1_B6_CTL, 5, 0, NULL, 0), |
| 1357 | SND_SOC_DAPM_MIXER("RX2 CHAIN", TABLA_A_CDC_RX2_B6_CTL, 5, 0, NULL, 0), |
| 1358 | |
| 1359 | SND_SOC_DAPM_MUX("RX1 MIX1 INP1", SND_SOC_NOPM, 0, 0, |
| 1360 | &rx_mix1_inp1_mux), |
| 1361 | SND_SOC_DAPM_MUX("RX1 MIX1 INP2", SND_SOC_NOPM, 0, 0, |
| 1362 | &rx_mix1_inp2_mux), |
| 1363 | SND_SOC_DAPM_MUX("RX2 MIX1 INP1", SND_SOC_NOPM, 0, 0, |
| 1364 | &rx2_mix1_inp1_mux), |
| 1365 | SND_SOC_DAPM_MUX("RX2 MIX1 INP2", SND_SOC_NOPM, 0, 0, |
| 1366 | &rx2_mix1_inp2_mux), |
Bradley Rubin | 74a9b4a | 2011-06-13 15:03:43 -0700 | [diff] [blame] | 1367 | SND_SOC_DAPM_MUX("RX3 MIX1 INP1", SND_SOC_NOPM, 0, 0, |
| 1368 | &rx3_mix1_inp1_mux), |
| 1369 | SND_SOC_DAPM_MUX("RX3 MIX1 INP2", SND_SOC_NOPM, 0, 0, |
| 1370 | &rx3_mix1_inp2_mux), |
| 1371 | SND_SOC_DAPM_MUX("RX4 MIX1 INP1", SND_SOC_NOPM, 0, 0, |
| 1372 | &rx4_mix1_inp1_mux), |
| 1373 | SND_SOC_DAPM_MUX("RX4 MIX1 INP2", SND_SOC_NOPM, 0, 0, |
| 1374 | &rx4_mix1_inp2_mux), |
| 1375 | SND_SOC_DAPM_MUX("RX5 MIX1 INP1", SND_SOC_NOPM, 0, 0, |
| 1376 | &rx5_mix1_inp1_mux), |
| 1377 | SND_SOC_DAPM_MUX("RX5 MIX1 INP2", SND_SOC_NOPM, 0, 0, |
| 1378 | &rx5_mix1_inp2_mux), |
| 1379 | SND_SOC_DAPM_MUX("RX6 MIX1 INP1", SND_SOC_NOPM, 0, 0, |
| 1380 | &rx6_mix1_inp1_mux), |
| 1381 | SND_SOC_DAPM_MUX("RX6 MIX1 INP2", SND_SOC_NOPM, 0, 0, |
| 1382 | &rx6_mix1_inp2_mux), |
Bhalchandra Gajare | 0a8ad17 | 2011-08-12 13:32:22 -0700 | [diff] [blame] | 1383 | SND_SOC_DAPM_MUX("RX7 MIX1 INP1", SND_SOC_NOPM, 0, 0, |
| 1384 | &rx7_mix1_inp1_mux), |
| 1385 | SND_SOC_DAPM_MUX("RX7 MIX1 INP2", SND_SOC_NOPM, 0, 0, |
| 1386 | &rx7_mix1_inp2_mux), |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1387 | |
Bradley Rubin | 229c6a5 | 2011-07-12 16:18:48 -0700 | [diff] [blame] | 1388 | SND_SOC_DAPM_SUPPLY("CP", TABLA_A_CP_EN, 0, 0, |
| 1389 | tabla_codec_enable_charge_pump, SND_SOC_DAPM_POST_PMU | |
| 1390 | SND_SOC_DAPM_PRE_PMD), |
| 1391 | |
Kiran Kandi | 6fae8bf | 2011-08-15 10:36:42 -0700 | [diff] [blame] | 1392 | SND_SOC_DAPM_SUPPLY("RX_BIAS", SND_SOC_NOPM, 0, 0, |
| 1393 | tabla_codec_enable_rx_bias, SND_SOC_DAPM_PRE_PMU | |
| 1394 | SND_SOC_DAPM_POST_PMD), |
| 1395 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1396 | /* TX */ |
Bradley Rubin | 229c6a5 | 2011-07-12 16:18:48 -0700 | [diff] [blame] | 1397 | |
Bradley Rubin | e1d0862 | 2011-07-20 18:01:35 -0700 | [diff] [blame] | 1398 | SND_SOC_DAPM_SUPPLY("CDC_CONN", TABLA_A_CDC_CLK_OTHR_CTL, 2, 0, NULL, |
| 1399 | 0), |
| 1400 | |
Bradley Rubin | 229c6a5 | 2011-07-12 16:18:48 -0700 | [diff] [blame] | 1401 | SND_SOC_DAPM_SUPPLY("LDO_H", TABLA_A_LDO_H_MODE_1, 7, 0, |
| 1402 | tabla_codec_enable_ldo_h, SND_SOC_DAPM_POST_PMU), |
| 1403 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1404 | SND_SOC_DAPM_INPUT("AMIC1"), |
| 1405 | SND_SOC_DAPM_MICBIAS_E("MIC BIAS1 External", TABLA_A_MICB_1_CTL, 7, 0, |
| 1406 | tabla_codec_enable_micbias, SND_SOC_DAPM_PRE_PMU | |
Bradley Rubin | 4d09cf4 | 2011-08-17 17:59:16 -0700 | [diff] [blame] | 1407 | SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD), |
Bradley Rubin | 229c6a5 | 2011-07-12 16:18:48 -0700 | [diff] [blame] | 1408 | SND_SOC_DAPM_MICBIAS_E("MIC BIAS1 Internal1", TABLA_A_MICB_1_CTL, 7, 0, |
| 1409 | tabla_codec_enable_micbias, SND_SOC_DAPM_PRE_PMU | |
Bradley Rubin | 4d09cf4 | 2011-08-17 17:59:16 -0700 | [diff] [blame] | 1410 | SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD), |
Bradley Rubin | 229c6a5 | 2011-07-12 16:18:48 -0700 | [diff] [blame] | 1411 | SND_SOC_DAPM_MICBIAS_E("MIC BIAS1 Internal2", TABLA_A_MICB_1_CTL, 7, 0, |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1412 | tabla_codec_enable_micbias, SND_SOC_DAPM_PRE_PMU | |
Bradley Rubin | 4d09cf4 | 2011-08-17 17:59:16 -0700 | [diff] [blame] | 1413 | SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD), |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1414 | SND_SOC_DAPM_ADC_E("ADC1", NULL, TABLA_A_TX_1_2_EN, 7, 0, |
| 1415 | tabla_codec_enable_adc, SND_SOC_DAPM_PRE_PMU | |
| 1416 | SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD), |
| 1417 | |
Bhalchandra Gajare | cc6ffa0 | 2011-07-14 18:35:41 -0700 | [diff] [blame] | 1418 | SND_SOC_DAPM_INPUT("AMIC3"), |
| 1419 | SND_SOC_DAPM_ADC_E("ADC3", NULL, TABLA_A_TX_3_4_EN, 7, 0, |
| 1420 | tabla_codec_enable_adc, SND_SOC_DAPM_PRE_PMU | |
| 1421 | SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD), |
| 1422 | |
| 1423 | SND_SOC_DAPM_INPUT("AMIC4"), |
| 1424 | SND_SOC_DAPM_ADC_E("ADC4", NULL, TABLA_A_TX_3_4_EN, 3, 0, |
| 1425 | tabla_codec_enable_adc, SND_SOC_DAPM_PRE_PMU | |
| 1426 | SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD), |
| 1427 | |
| 1428 | SND_SOC_DAPM_MICBIAS_E("MIC BIAS4 External", TABLA_A_MICB_4_CTL, 7, 0, |
| 1429 | tabla_codec_enable_micbias, SND_SOC_DAPM_PRE_PMU | |
Bradley Rubin | 4d09cf4 | 2011-08-17 17:59:16 -0700 | [diff] [blame] | 1430 | SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD), |
Bhalchandra Gajare | cc6ffa0 | 2011-07-14 18:35:41 -0700 | [diff] [blame] | 1431 | |
Bhalchandra Gajare | 0d77e1b | 2011-07-08 10:54:14 -0700 | [diff] [blame] | 1432 | SND_SOC_DAPM_INPUT("AMIC5"), |
| 1433 | SND_SOC_DAPM_ADC_E("ADC5", NULL, TABLA_A_TX_5_6_EN, 7, 0, |
| 1434 | tabla_codec_enable_adc, SND_SOC_DAPM_POST_PMU), |
| 1435 | |
| 1436 | SND_SOC_DAPM_INPUT("AMIC6"), |
| 1437 | SND_SOC_DAPM_ADC_E("ADC6", NULL, TABLA_A_TX_5_6_EN, 3, 0, |
| 1438 | tabla_codec_enable_adc, SND_SOC_DAPM_POST_PMU), |
| 1439 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1440 | SND_SOC_DAPM_MUX_E("DEC1 MUX", TABLA_A_CDC_CLK_TX_CLK_EN_B1_CTL, 0, 0, |
Bradley Rubin | e1d0862 | 2011-07-20 18:01:35 -0700 | [diff] [blame] | 1441 | &dec1_mux, tabla_codec_enable_dec, SND_SOC_DAPM_PRE_PMU), |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1442 | |
Bhalchandra Gajare | 0d77e1b | 2011-07-08 10:54:14 -0700 | [diff] [blame] | 1443 | SND_SOC_DAPM_MUX_E("DEC2 MUX", TABLA_A_CDC_CLK_TX_CLK_EN_B1_CTL, 1, 0, |
Bradley Rubin | e1d0862 | 2011-07-20 18:01:35 -0700 | [diff] [blame] | 1444 | &dec2_mux, tabla_codec_enable_dec, SND_SOC_DAPM_PRE_PMU), |
Bhalchandra Gajare | 0d77e1b | 2011-07-08 10:54:14 -0700 | [diff] [blame] | 1445 | |
Bhalchandra Gajare | cc6ffa0 | 2011-07-14 18:35:41 -0700 | [diff] [blame] | 1446 | SND_SOC_DAPM_MUX_E("DEC3 MUX", TABLA_A_CDC_CLK_TX_CLK_EN_B1_CTL, 2, 0, |
Bradley Rubin | e1d0862 | 2011-07-20 18:01:35 -0700 | [diff] [blame] | 1447 | &dec3_mux, tabla_codec_enable_dec, SND_SOC_DAPM_PRE_PMU), |
Bhalchandra Gajare | cc6ffa0 | 2011-07-14 18:35:41 -0700 | [diff] [blame] | 1448 | |
| 1449 | SND_SOC_DAPM_MUX_E("DEC4 MUX", TABLA_A_CDC_CLK_TX_CLK_EN_B1_CTL, 3, 0, |
Bradley Rubin | e1d0862 | 2011-07-20 18:01:35 -0700 | [diff] [blame] | 1450 | &dec4_mux, tabla_codec_enable_dec, SND_SOC_DAPM_PRE_PMU), |
Bhalchandra Gajare | cc6ffa0 | 2011-07-14 18:35:41 -0700 | [diff] [blame] | 1451 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1452 | SND_SOC_DAPM_MUX_E("DEC5 MUX", TABLA_A_CDC_CLK_TX_CLK_EN_B1_CTL, 4, 0, |
Bradley Rubin | e1d0862 | 2011-07-20 18:01:35 -0700 | [diff] [blame] | 1453 | &dec5_mux, tabla_codec_enable_dec, SND_SOC_DAPM_PRE_PMU), |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1454 | |
| 1455 | SND_SOC_DAPM_MUX_E("DEC6 MUX", TABLA_A_CDC_CLK_TX_CLK_EN_B1_CTL, 5, 0, |
Bradley Rubin | e1d0862 | 2011-07-20 18:01:35 -0700 | [diff] [blame] | 1456 | &dec6_mux, tabla_codec_enable_dec, SND_SOC_DAPM_PRE_PMU), |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1457 | |
| 1458 | SND_SOC_DAPM_MUX_E("DEC7 MUX", TABLA_A_CDC_CLK_TX_CLK_EN_B1_CTL, 6, 0, |
Bradley Rubin | e1d0862 | 2011-07-20 18:01:35 -0700 | [diff] [blame] | 1459 | &dec7_mux, tabla_codec_enable_dec, SND_SOC_DAPM_PRE_PMU), |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1460 | |
Bhalchandra Gajare | 0d77e1b | 2011-07-08 10:54:14 -0700 | [diff] [blame] | 1461 | SND_SOC_DAPM_MUX_E("DEC8 MUX", TABLA_A_CDC_CLK_TX_CLK_EN_B1_CTL, 7, 0, |
Bradley Rubin | e1d0862 | 2011-07-20 18:01:35 -0700 | [diff] [blame] | 1462 | &dec8_mux, tabla_codec_enable_dec, SND_SOC_DAPM_PRE_PMU), |
Bhalchandra Gajare | 0d77e1b | 2011-07-08 10:54:14 -0700 | [diff] [blame] | 1463 | |
Bhalchandra Gajare | cc6ffa0 | 2011-07-14 18:35:41 -0700 | [diff] [blame] | 1464 | SND_SOC_DAPM_MUX_E("DEC9 MUX", TABLA_A_CDC_CLK_TX_CLK_EN_B2_CTL, 0, 0, |
Bradley Rubin | e1d0862 | 2011-07-20 18:01:35 -0700 | [diff] [blame] | 1465 | &dec9_mux, tabla_codec_enable_dec, SND_SOC_DAPM_PRE_PMU), |
Bhalchandra Gajare | cc6ffa0 | 2011-07-14 18:35:41 -0700 | [diff] [blame] | 1466 | |
| 1467 | SND_SOC_DAPM_MUX_E("DEC10 MUX", TABLA_A_CDC_CLK_TX_CLK_EN_B2_CTL, 1, 0, |
Bradley Rubin | e1d0862 | 2011-07-20 18:01:35 -0700 | [diff] [blame] | 1468 | &dec10_mux, tabla_codec_enable_dec, SND_SOC_DAPM_PRE_PMU), |
Bhalchandra Gajare | cc6ffa0 | 2011-07-14 18:35:41 -0700 | [diff] [blame] | 1469 | |
Bradley Rubin | 229c6a5 | 2011-07-12 16:18:48 -0700 | [diff] [blame] | 1470 | SND_SOC_DAPM_MUX("ANC1 MUX", SND_SOC_NOPM, 0, 0, &anc1_mux), |
| 1471 | SND_SOC_DAPM_MUX("ANC2 MUX", SND_SOC_NOPM, 0, 0, &anc2_mux), |
| 1472 | |
| 1473 | SND_SOC_DAPM_MIXER_E("ANC", SND_SOC_NOPM, 0, 0, NULL, 0, |
| 1474 | tabla_codec_enable_anc, SND_SOC_DAPM_PRE_PMU | |
| 1475 | SND_SOC_DAPM_POST_PMD), |
| 1476 | |
| 1477 | SND_SOC_DAPM_MUX("ANC1 FB MUX", SND_SOC_NOPM, 0, 0, &anc1_fb_mux), |
| 1478 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1479 | SND_SOC_DAPM_INPUT("AMIC2"), |
| 1480 | SND_SOC_DAPM_MICBIAS_E("MIC BIAS2 External", TABLA_A_MICB_2_CTL, 7, 0, |
| 1481 | tabla_codec_enable_micbias, SND_SOC_DAPM_PRE_PMU | |
Bradley Rubin | 4d09cf4 | 2011-08-17 17:59:16 -0700 | [diff] [blame] | 1482 | SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD), |
Bradley Rubin | 229c6a5 | 2011-07-12 16:18:48 -0700 | [diff] [blame] | 1483 | SND_SOC_DAPM_MICBIAS_E("MIC BIAS2 Internal1", TABLA_A_MICB_2_CTL, 7, 0, |
| 1484 | tabla_codec_enable_micbias, SND_SOC_DAPM_PRE_PMU | |
Bradley Rubin | 4d09cf4 | 2011-08-17 17:59:16 -0700 | [diff] [blame] | 1485 | SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD), |
Bradley Rubin | 229c6a5 | 2011-07-12 16:18:48 -0700 | [diff] [blame] | 1486 | SND_SOC_DAPM_MICBIAS_E("MIC BIAS2 Internal2", TABLA_A_MICB_2_CTL, 7, 0, |
| 1487 | tabla_codec_enable_micbias, SND_SOC_DAPM_PRE_PMU | |
Bradley Rubin | 4d09cf4 | 2011-08-17 17:59:16 -0700 | [diff] [blame] | 1488 | SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD), |
Bradley Rubin | 229c6a5 | 2011-07-12 16:18:48 -0700 | [diff] [blame] | 1489 | SND_SOC_DAPM_MICBIAS_E("MIC BIAS2 Internal3", TABLA_A_MICB_2_CTL, 7, 0, |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1490 | tabla_codec_enable_micbias, SND_SOC_DAPM_PRE_PMU | |
Bradley Rubin | 4d09cf4 | 2011-08-17 17:59:16 -0700 | [diff] [blame] | 1491 | SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD), |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1492 | SND_SOC_DAPM_MICBIAS_E("MIC BIAS3 External", TABLA_A_MICB_3_CTL, 7, 0, |
| 1493 | tabla_codec_enable_micbias, SND_SOC_DAPM_PRE_PMU | |
Bradley Rubin | 4d09cf4 | 2011-08-17 17:59:16 -0700 | [diff] [blame] | 1494 | SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD), |
Bradley Rubin | 229c6a5 | 2011-07-12 16:18:48 -0700 | [diff] [blame] | 1495 | SND_SOC_DAPM_MICBIAS_E("MIC BIAS3 Internal1", TABLA_A_MICB_3_CTL, 7, 0, |
| 1496 | tabla_codec_enable_micbias, SND_SOC_DAPM_PRE_PMU | |
Bradley Rubin | 4d09cf4 | 2011-08-17 17:59:16 -0700 | [diff] [blame] | 1497 | SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD), |
Bradley Rubin | 229c6a5 | 2011-07-12 16:18:48 -0700 | [diff] [blame] | 1498 | SND_SOC_DAPM_MICBIAS_E("MIC BIAS3 Internal2", TABLA_A_MICB_3_CTL, 7, 0, |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1499 | tabla_codec_enable_micbias, SND_SOC_DAPM_PRE_PMU | |
Bradley Rubin | 4d09cf4 | 2011-08-17 17:59:16 -0700 | [diff] [blame] | 1500 | SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD), |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1501 | SND_SOC_DAPM_ADC_E("ADC2", NULL, TABLA_A_TX_1_2_EN, 3, 0, |
| 1502 | tabla_codec_enable_adc, SND_SOC_DAPM_PRE_PMU | |
| 1503 | SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD), |
| 1504 | |
| 1505 | SND_SOC_DAPM_MUX("SLIM TX1 MUX", SND_SOC_NOPM, 0, 0, &sb_tx1_mux), |
| 1506 | SND_SOC_DAPM_AIF_OUT("SLIM TX1", "AIF1 Capture", NULL, SND_SOC_NOPM, |
| 1507 | 0, 0), |
| 1508 | |
| 1509 | SND_SOC_DAPM_MUX("SLIM TX5 MUX", SND_SOC_NOPM, 0, 0, &sb_tx5_mux), |
| 1510 | SND_SOC_DAPM_AIF_OUT("SLIM TX5", "AIF1 Capture", NULL, SND_SOC_NOPM, |
| 1511 | 4, 0), |
| 1512 | |
| 1513 | SND_SOC_DAPM_MUX("SLIM TX6 MUX", SND_SOC_NOPM, 0, 0, &sb_tx6_mux), |
| 1514 | SND_SOC_DAPM_AIF_OUT("SLIM TX6", "AIF1 Capture", NULL, SND_SOC_NOPM, |
| 1515 | 5, 0), |
| 1516 | |
| 1517 | SND_SOC_DAPM_MUX("SLIM TX7 MUX", SND_SOC_NOPM, 0, 0, &sb_tx7_mux), |
| 1518 | SND_SOC_DAPM_AIF_OUT("SLIM TX7", "AIF1 Capture", NULL, SND_SOC_NOPM, |
| 1519 | 0, 0), |
| 1520 | |
| 1521 | SND_SOC_DAPM_MUX("SLIM TX8 MUX", SND_SOC_NOPM, 0, 0, &sb_tx8_mux), |
| 1522 | SND_SOC_DAPM_AIF_OUT("SLIM TX8", "AIF1 Capture", NULL, SND_SOC_NOPM, |
| 1523 | 0, 0), |
| 1524 | |
Kiran Kandi | cf45f6a | 2011-07-17 21:10:19 -0700 | [diff] [blame] | 1525 | /* Digital Mic Inputs */ |
Bhalchandra Gajare | 7cf018e | 2011-08-11 18:58:32 -0700 | [diff] [blame] | 1526 | SND_SOC_DAPM_ADC_E("DMIC1", NULL, SND_SOC_NOPM, 0, 0, |
| 1527 | tabla_codec_enable_dmic, SND_SOC_DAPM_PRE_PMU | |
| 1528 | SND_SOC_DAPM_POST_PMD), |
| 1529 | |
| 1530 | SND_SOC_DAPM_ADC_E("DMIC2", NULL, SND_SOC_NOPM, 0, 0, |
| 1531 | tabla_codec_enable_dmic, SND_SOC_DAPM_PRE_PMU | |
| 1532 | SND_SOC_DAPM_POST_PMD), |
| 1533 | |
| 1534 | SND_SOC_DAPM_ADC_E("DMIC3", NULL, SND_SOC_NOPM, 0, 0, |
| 1535 | tabla_codec_enable_dmic, SND_SOC_DAPM_PRE_PMU | |
| 1536 | SND_SOC_DAPM_POST_PMD), |
| 1537 | |
| 1538 | SND_SOC_DAPM_ADC_E("DMIC4", NULL, SND_SOC_NOPM, 0, 0, |
| 1539 | tabla_codec_enable_dmic, SND_SOC_DAPM_PRE_PMU | |
| 1540 | SND_SOC_DAPM_POST_PMD), |
| 1541 | |
| 1542 | SND_SOC_DAPM_ADC_E("DMIC5", NULL, SND_SOC_NOPM, 0, 0, |
| 1543 | tabla_codec_enable_dmic, SND_SOC_DAPM_PRE_PMU | |
| 1544 | SND_SOC_DAPM_POST_PMD), |
| 1545 | |
| 1546 | SND_SOC_DAPM_ADC_E("DMIC6", NULL, SND_SOC_NOPM, 0, 0, |
| 1547 | tabla_codec_enable_dmic, SND_SOC_DAPM_PRE_PMU | |
| 1548 | SND_SOC_DAPM_POST_PMD), |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1549 | |
| 1550 | /* Sidetone */ |
| 1551 | SND_SOC_DAPM_MUX("IIR1 INP1 MUX", SND_SOC_NOPM, 0, 0, &iir1_inp1_mux), |
| 1552 | SND_SOC_DAPM_PGA("IIR1", TABLA_A_CDC_CLK_SD_CTL, 0, 0, NULL, 0), |
| 1553 | }; |
| 1554 | |
| 1555 | static const struct snd_soc_dapm_route audio_map[] = { |
| 1556 | /* SLIMBUS Connections */ |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1557 | |
| 1558 | {"SLIM TX1", NULL, "SLIM TX1 MUX"}, |
| 1559 | {"SLIM TX1 MUX", "DEC1", "DEC1 MUX"}, |
| 1560 | |
| 1561 | {"SLIM TX5", NULL, "SLIM TX5 MUX"}, |
| 1562 | {"SLIM TX5 MUX", "DEC5", "DEC5 MUX"}, |
| 1563 | |
| 1564 | {"SLIM TX6", NULL, "SLIM TX6 MUX"}, |
| 1565 | {"SLIM TX6 MUX", "DEC6", "DEC6 MUX"}, |
| 1566 | |
| 1567 | {"SLIM TX7", NULL, "SLIM TX7 MUX"}, |
| 1568 | {"SLIM TX7 MUX", "DEC1", "DEC1 MUX"}, |
Bhalchandra Gajare | 0d77e1b | 2011-07-08 10:54:14 -0700 | [diff] [blame] | 1569 | {"SLIM TX7 MUX", "DEC2", "DEC2 MUX"}, |
Bhalchandra Gajare | cc6ffa0 | 2011-07-14 18:35:41 -0700 | [diff] [blame] | 1570 | {"SLIM TX7 MUX", "DEC3", "DEC3 MUX"}, |
| 1571 | {"SLIM TX7 MUX", "DEC4", "DEC4 MUX"}, |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1572 | {"SLIM TX7 MUX", "DEC5", "DEC5 MUX"}, |
| 1573 | {"SLIM TX7 MUX", "DEC6", "DEC6 MUX"}, |
Bhalchandra Gajare | 0d77e1b | 2011-07-08 10:54:14 -0700 | [diff] [blame] | 1574 | {"SLIM TX7 MUX", "DEC7", "DEC7 MUX"}, |
| 1575 | {"SLIM TX7 MUX", "DEC8", "DEC8 MUX"}, |
Bhalchandra Gajare | cc6ffa0 | 2011-07-14 18:35:41 -0700 | [diff] [blame] | 1576 | {"SLIM TX7 MUX", "DEC9", "DEC9 MUX"}, |
| 1577 | {"SLIM TX7 MUX", "DEC10", "DEC10 MUX"}, |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1578 | |
| 1579 | {"SLIM TX8", NULL, "SLIM TX8 MUX"}, |
Kiran Kandi | cf45f6a | 2011-07-17 21:10:19 -0700 | [diff] [blame] | 1580 | {"SLIM TX8 MUX", "DEC1", "DEC1 MUX"}, |
| 1581 | {"SLIM TX8 MUX", "DEC2", "DEC2 MUX"}, |
| 1582 | {"SLIM TX8 MUX", "DEC3", "DEC3 MUX"}, |
Bhalchandra Gajare | 9ec83cd | 2011-09-23 17:25:07 -0700 | [diff] [blame] | 1583 | {"SLIM TX8 MUX", "DEC4", "DEC4 MUX"}, |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1584 | {"SLIM TX8 MUX", "DEC5", "DEC5 MUX"}, |
| 1585 | {"SLIM TX8 MUX", "DEC6", "DEC6 MUX"}, |
| 1586 | |
| 1587 | /* Earpiece (RX MIX1) */ |
| 1588 | {"EAR", NULL, "EAR PA"}, |
Kiran Kandi | ac034ac | 2011-07-29 16:39:08 -0700 | [diff] [blame] | 1589 | {"EAR PA", NULL, "DAC1"}, |
Bradley Rubin | 229c6a5 | 2011-07-12 16:18:48 -0700 | [diff] [blame] | 1590 | {"DAC1", NULL, "CP"}, |
| 1591 | |
| 1592 | {"ANC1 FB MUX", "EAR_HPH_L", "RX1 MIX1"}, |
| 1593 | {"ANC1 FB MUX", "EAR_LINE_1", "RX2 MIX1"}, |
| 1594 | {"ANC", NULL, "ANC1 FB MUX"}, |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1595 | |
| 1596 | /* Headset (RX MIX1 and RX MIX2) */ |
| 1597 | {"HEADPHONE", NULL, "HPHL"}, |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1598 | {"HEADPHONE", NULL, "HPHR"}, |
Bradley Rubin | 229c6a5 | 2011-07-12 16:18:48 -0700 | [diff] [blame] | 1599 | |
| 1600 | {"HPHL", NULL, "HPHL DAC"}, |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1601 | {"HPHR", NULL, "HPHR DAC"}, |
Bradley Rubin | 229c6a5 | 2011-07-12 16:18:48 -0700 | [diff] [blame] | 1602 | |
| 1603 | {"HPHL DAC", NULL, "CP"}, |
| 1604 | {"HPHR DAC", NULL, "CP"}, |
| 1605 | |
| 1606 | {"ANC", NULL, "ANC1 MUX"}, |
| 1607 | {"ANC", NULL, "ANC2 MUX"}, |
| 1608 | {"ANC1 MUX", "ADC1", "ADC1"}, |
| 1609 | {"ANC1 MUX", "ADC2", "ADC2"}, |
| 1610 | {"ANC1 MUX", "ADC3", "ADC3"}, |
| 1611 | {"ANC1 MUX", "ADC4", "ADC4"}, |
| 1612 | {"ANC2 MUX", "ADC1", "ADC1"}, |
| 1613 | {"ANC2 MUX", "ADC2", "ADC2"}, |
| 1614 | {"ANC2 MUX", "ADC3", "ADC3"}, |
| 1615 | {"ANC2 MUX", "ADC4", "ADC4"}, |
| 1616 | |
Bradley Rubin | e1d0862 | 2011-07-20 18:01:35 -0700 | [diff] [blame] | 1617 | {"ANC", NULL, "CDC_CONN"}, |
| 1618 | |
Bradley Rubin | 229c6a5 | 2011-07-12 16:18:48 -0700 | [diff] [blame] | 1619 | {"DAC1", "Switch", "RX1 CHAIN"}, |
| 1620 | {"HPHL DAC", "Switch", "RX1 CHAIN"}, |
| 1621 | {"HPHR DAC", "Switch", "RX2 CHAIN"}, |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1622 | |
Kiran Kandi | db0a4b0 | 2011-08-23 09:32:09 -0700 | [diff] [blame] | 1623 | {"LINEOUT1", NULL, "LINEOUT1 PA"}, |
| 1624 | {"LINEOUT2", NULL, "LINEOUT2 PA"}, |
| 1625 | {"LINEOUT3", NULL, "LINEOUT3 PA"}, |
| 1626 | {"LINEOUT4", NULL, "LINEOUT4 PA"}, |
| 1627 | {"LINEOUT5", NULL, "LINEOUT5 PA"}, |
Bradley Rubin | 74a9b4a | 2011-06-13 15:03:43 -0700 | [diff] [blame] | 1628 | |
Kiran Kandi | db0a4b0 | 2011-08-23 09:32:09 -0700 | [diff] [blame] | 1629 | {"LINEOUT1 PA", NULL, "LINEOUT1 DAC"}, |
| 1630 | {"LINEOUT2 PA", NULL, "LINEOUT2 DAC"}, |
| 1631 | {"LINEOUT3 PA", NULL, "LINEOUT3 DAC"}, |
| 1632 | {"LINEOUT4 PA", NULL, "LINEOUT4 DAC"}, |
| 1633 | {"LINEOUT5 PA", NULL, "LINEOUT5 DAC"}, |
Bradley Rubin | 74a9b4a | 2011-06-13 15:03:43 -0700 | [diff] [blame] | 1634 | |
Bradley Rubin | 229c6a5 | 2011-07-12 16:18:48 -0700 | [diff] [blame] | 1635 | {"RX1 CHAIN", NULL, "RX1 MIX1"}, |
| 1636 | {"RX2 CHAIN", NULL, "RX2 MIX1"}, |
| 1637 | {"RX1 CHAIN", NULL, "ANC"}, |
| 1638 | {"RX2 CHAIN", NULL, "ANC"}, |
Bradley Rubin | 74a9b4a | 2011-06-13 15:03:43 -0700 | [diff] [blame] | 1639 | {"LINEOUT1 DAC", "Switch", "RX3 MIX1"}, |
| 1640 | {"LINEOUT2 DAC", "Switch", "RX4 MIX1"}, |
Kiran Kandi | ed246a9 | 2011-08-12 14:03:44 -0700 | [diff] [blame] | 1641 | {"LINEOUT3 DAC", "Switch", "RX3 MIX1"}, |
| 1642 | {"LINEOUT4 DAC", "Switch", "RX4 MIX1"}, |
Bhalchandra Gajare | 0a8ad17 | 2011-08-12 13:32:22 -0700 | [diff] [blame] | 1643 | {"LINEOUT5 DAC", "Switch", "RX7 MIX1"}, |
Bradley Rubin | 74a9b4a | 2011-06-13 15:03:43 -0700 | [diff] [blame] | 1644 | |
Kiran Kandi | 6fae8bf | 2011-08-15 10:36:42 -0700 | [diff] [blame] | 1645 | {"CP", NULL, "RX_BIAS"}, |
| 1646 | {"LINEOUT1 DAC", NULL, "RX_BIAS"}, |
| 1647 | {"LINEOUT2 DAC", NULL, "RX_BIAS"}, |
| 1648 | {"LINEOUT3 DAC", NULL, "RX_BIAS"}, |
| 1649 | {"LINEOUT4 DAC", NULL, "RX_BIAS"}, |
| 1650 | |
Bradley Rubin | 229c6a5 | 2011-07-12 16:18:48 -0700 | [diff] [blame] | 1651 | {"RX1 MIX1", NULL, "RX1 MIX1 INP1"}, |
| 1652 | {"RX1 MIX1", NULL, "RX1 MIX1 INP2"}, |
| 1653 | {"RX2 MIX1", NULL, "RX2 MIX1 INP1"}, |
| 1654 | {"RX2 MIX1", NULL, "RX2 MIX1 INP2"}, |
Bradley Rubin | 74a9b4a | 2011-06-13 15:03:43 -0700 | [diff] [blame] | 1655 | {"RX3 MIX1", NULL, "RX3 MIX1 INP1"}, |
| 1656 | {"RX3 MIX1", NULL, "RX3 MIX1 INP2"}, |
| 1657 | {"RX4 MIX1", NULL, "RX4 MIX1 INP1"}, |
| 1658 | {"RX4 MIX1", NULL, "RX4 MIX1 INP2"}, |
| 1659 | {"RX5 MIX1", NULL, "RX5 MIX1 INP1"}, |
| 1660 | {"RX5 MIX1", NULL, "RX5 MIX1 INP2"}, |
| 1661 | {"RX6 MIX1", NULL, "RX6 MIX1 INP1"}, |
| 1662 | {"RX6 MIX1", NULL, "RX6 MIX1 INP2"}, |
Bhalchandra Gajare | 0a8ad17 | 2011-08-12 13:32:22 -0700 | [diff] [blame] | 1663 | {"RX7 MIX1", NULL, "RX7 MIX1 INP1"}, |
| 1664 | {"RX7 MIX1", NULL, "RX7 MIX1 INP2"}, |
Bradley Rubin | 74a9b4a | 2011-06-13 15:03:43 -0700 | [diff] [blame] | 1665 | |
Bradley Rubin | 229c6a5 | 2011-07-12 16:18:48 -0700 | [diff] [blame] | 1666 | {"RX1 MIX1 INP1", "RX1", "SLIM RX1"}, |
| 1667 | {"RX1 MIX1 INP1", "RX2", "SLIM RX2"}, |
| 1668 | {"RX1 MIX1 INP1", "IIR1", "IIR1"}, |
| 1669 | {"RX1 MIX1 INP2", "RX1", "SLIM RX1"}, |
| 1670 | {"RX1 MIX1 INP2", "RX2", "SLIM RX2"}, |
| 1671 | {"RX1 MIX1 INP2", "IIR1", "IIR1"}, |
| 1672 | {"RX2 MIX1 INP1", "RX1", "SLIM RX1"}, |
| 1673 | {"RX2 MIX1 INP1", "RX2", "SLIM RX2"}, |
| 1674 | {"RX2 MIX1 INP2", "RX1", "SLIM RX1"}, |
| 1675 | {"RX2 MIX1 INP2", "RX2", "SLIM RX2"}, |
| 1676 | {"RX3 MIX1 INP1", "RX1", "SLIM RX1"}, |
| 1677 | {"RX3 MIX1 INP1", "RX2", "SLIM RX2"}, |
| 1678 | {"RX3 MIX1 INP2", "RX1", "SLIM RX1"}, |
| 1679 | {"RX3 MIX1 INP2", "RX2", "SLIM RX2"}, |
| 1680 | {"RX4 MIX1 INP1", "RX1", "SLIM RX1"}, |
| 1681 | {"RX4 MIX1 INP1", "RX2", "SLIM RX2"}, |
| 1682 | {"RX4 MIX1 INP2", "RX1", "SLIM RX1"}, |
| 1683 | {"RX4 MIX1 INP2", "RX2", "SLIM RX2"}, |
| 1684 | {"RX5 MIX1 INP1", "RX1", "SLIM RX1"}, |
| 1685 | {"RX5 MIX1 INP1", "RX2", "SLIM RX2"}, |
| 1686 | {"RX5 MIX1 INP2", "RX1", "SLIM RX1"}, |
| 1687 | {"RX5 MIX1 INP2", "RX2", "SLIM RX2"}, |
| 1688 | {"RX6 MIX1 INP1", "RX1", "SLIM RX1"}, |
| 1689 | {"RX6 MIX1 INP1", "RX2", "SLIM RX2"}, |
| 1690 | {"RX6 MIX1 INP2", "RX1", "SLIM RX1"}, |
| 1691 | {"RX6 MIX1 INP2", "RX2", "SLIM RX2"}, |
Bhalchandra Gajare | 0a8ad17 | 2011-08-12 13:32:22 -0700 | [diff] [blame] | 1692 | {"RX7 MIX1 INP1", "RX1", "SLIM RX1"}, |
| 1693 | {"RX7 MIX1 INP1", "RX2", "SLIM RX2"}, |
| 1694 | {"RX7 MIX1 INP2", "RX1", "SLIM RX1"}, |
| 1695 | {"RX7 MIX1 INP2", "RX2", "SLIM RX2"}, |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1696 | |
Bhalchandra Gajare | cc6ffa0 | 2011-07-14 18:35:41 -0700 | [diff] [blame] | 1697 | /* Decimator Inputs */ |
Bhalchandra Gajare | cc6ffa0 | 2011-07-14 18:35:41 -0700 | [diff] [blame] | 1698 | {"DEC1 MUX", "DMIC1", "DMIC1"}, |
Kiran Kandi | cf45f6a | 2011-07-17 21:10:19 -0700 | [diff] [blame] | 1699 | {"DEC1 MUX", "ADC6", "ADC6"}, |
Bradley Rubin | e1d0862 | 2011-07-20 18:01:35 -0700 | [diff] [blame] | 1700 | {"DEC1 MUX", NULL, "CDC_CONN"}, |
Kiran Kandi | cf45f6a | 2011-07-17 21:10:19 -0700 | [diff] [blame] | 1701 | {"DEC2 MUX", "DMIC2", "DMIC2"}, |
Bhalchandra Gajare | cc6ffa0 | 2011-07-14 18:35:41 -0700 | [diff] [blame] | 1702 | {"DEC2 MUX", "ADC5", "ADC5"}, |
Bradley Rubin | e1d0862 | 2011-07-20 18:01:35 -0700 | [diff] [blame] | 1703 | {"DEC2 MUX", NULL, "CDC_CONN"}, |
Kiran Kandi | cf45f6a | 2011-07-17 21:10:19 -0700 | [diff] [blame] | 1704 | {"DEC3 MUX", "DMIC3", "DMIC3"}, |
Bhalchandra Gajare | cc6ffa0 | 2011-07-14 18:35:41 -0700 | [diff] [blame] | 1705 | {"DEC3 MUX", "ADC4", "ADC4"}, |
Bradley Rubin | e1d0862 | 2011-07-20 18:01:35 -0700 | [diff] [blame] | 1706 | {"DEC3 MUX", NULL, "CDC_CONN"}, |
Bhalchandra Gajare | 7cf018e | 2011-08-11 18:58:32 -0700 | [diff] [blame] | 1707 | {"DEC4 MUX", "DMIC4", "DMIC4"}, |
Bhalchandra Gajare | cc6ffa0 | 2011-07-14 18:35:41 -0700 | [diff] [blame] | 1708 | {"DEC4 MUX", "ADC3", "ADC3"}, |
Bradley Rubin | e1d0862 | 2011-07-20 18:01:35 -0700 | [diff] [blame] | 1709 | {"DEC4 MUX", NULL, "CDC_CONN"}, |
Bhalchandra Gajare | 7cf018e | 2011-08-11 18:58:32 -0700 | [diff] [blame] | 1710 | {"DEC5 MUX", "DMIC5", "DMIC5"}, |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1711 | {"DEC5 MUX", "ADC2", "ADC2"}, |
Bradley Rubin | e1d0862 | 2011-07-20 18:01:35 -0700 | [diff] [blame] | 1712 | {"DEC5 MUX", NULL, "CDC_CONN"}, |
Bhalchandra Gajare | 7cf018e | 2011-08-11 18:58:32 -0700 | [diff] [blame] | 1713 | {"DEC6 MUX", "DMIC6", "DMIC6"}, |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1714 | {"DEC6 MUX", "ADC1", "ADC1"}, |
Bradley Rubin | e1d0862 | 2011-07-20 18:01:35 -0700 | [diff] [blame] | 1715 | {"DEC6 MUX", NULL, "CDC_CONN"}, |
Bhalchandra Gajare | cc6ffa0 | 2011-07-14 18:35:41 -0700 | [diff] [blame] | 1716 | {"DEC7 MUX", "DMIC1", "DMIC1"}, |
Kiran Kandi | cf45f6a | 2011-07-17 21:10:19 -0700 | [diff] [blame] | 1717 | {"DEC7 MUX", "ADC6", "ADC6"}, |
Bradley Rubin | e1d0862 | 2011-07-20 18:01:35 -0700 | [diff] [blame] | 1718 | {"DEC7 MUX", NULL, "CDC_CONN"}, |
Bhalchandra Gajare | cc6ffa0 | 2011-07-14 18:35:41 -0700 | [diff] [blame] | 1719 | {"DEC8 MUX", "ADC5", "ADC5"}, |
Bradley Rubin | e1d0862 | 2011-07-20 18:01:35 -0700 | [diff] [blame] | 1720 | {"DEC8 MUX", NULL, "CDC_CONN"}, |
Bhalchandra Gajare | cc6ffa0 | 2011-07-14 18:35:41 -0700 | [diff] [blame] | 1721 | {"DEC9 MUX", "ADC3", "ADC3"}, |
Bradley Rubin | e1d0862 | 2011-07-20 18:01:35 -0700 | [diff] [blame] | 1722 | {"DEC9 MUX", NULL, "CDC_CONN"}, |
Bhalchandra Gajare | cc6ffa0 | 2011-07-14 18:35:41 -0700 | [diff] [blame] | 1723 | {"DEC10 MUX", "ADC4", "ADC4"}, |
Bradley Rubin | e1d0862 | 2011-07-20 18:01:35 -0700 | [diff] [blame] | 1724 | {"DEC10 MUX", NULL, "CDC_CONN"}, |
Bhalchandra Gajare | cc6ffa0 | 2011-07-14 18:35:41 -0700 | [diff] [blame] | 1725 | |
| 1726 | /* ADC Connections */ |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1727 | {"ADC1", NULL, "AMIC1"}, |
| 1728 | {"ADC2", NULL, "AMIC2"}, |
Bhalchandra Gajare | cc6ffa0 | 2011-07-14 18:35:41 -0700 | [diff] [blame] | 1729 | {"ADC3", NULL, "AMIC3"}, |
| 1730 | {"ADC4", NULL, "AMIC4"}, |
| 1731 | {"ADC5", NULL, "AMIC5"}, |
| 1732 | {"ADC6", NULL, "AMIC6"}, |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1733 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1734 | {"IIR1", NULL, "IIR1 INP1 MUX"}, |
| 1735 | {"IIR1 INP1 MUX", "DEC6", "DEC6 MUX"}, |
Bradley Rubin | 229c6a5 | 2011-07-12 16:18:48 -0700 | [diff] [blame] | 1736 | |
| 1737 | {"MIC BIAS1 Internal1", NULL, "LDO_H"}, |
| 1738 | {"MIC BIAS1 Internal2", NULL, "LDO_H"}, |
| 1739 | {"MIC BIAS1 External", NULL, "LDO_H"}, |
| 1740 | {"MIC BIAS2 Internal1", NULL, "LDO_H"}, |
| 1741 | {"MIC BIAS2 Internal2", NULL, "LDO_H"}, |
| 1742 | {"MIC BIAS2 Internal3", NULL, "LDO_H"}, |
| 1743 | {"MIC BIAS2 External", NULL, "LDO_H"}, |
| 1744 | {"MIC BIAS3 Internal1", NULL, "LDO_H"}, |
| 1745 | {"MIC BIAS3 Internal2", NULL, "LDO_H"}, |
| 1746 | {"MIC BIAS3 External", NULL, "LDO_H"}, |
| 1747 | {"MIC BIAS4 External", NULL, "LDO_H"}, |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1748 | }; |
| 1749 | |
| 1750 | static int tabla_readable(struct snd_soc_codec *ssc, unsigned int reg) |
| 1751 | { |
| 1752 | return tabla_reg_readable[reg]; |
| 1753 | } |
| 1754 | |
| 1755 | static int tabla_volatile(struct snd_soc_codec *ssc, unsigned int reg) |
| 1756 | { |
| 1757 | /* Registers lower than 0x100 are top level registers which can be |
| 1758 | * written by the Tabla core driver. |
| 1759 | */ |
| 1760 | |
| 1761 | if ((reg >= TABLA_A_CDC_MBHC_EN_CTL) || (reg < 0x100)) |
| 1762 | return 1; |
| 1763 | |
| 1764 | return 0; |
| 1765 | } |
| 1766 | |
| 1767 | #define TABLA_FORMATS (SNDRV_PCM_FMTBIT_S16_LE) |
| 1768 | static int tabla_write(struct snd_soc_codec *codec, unsigned int reg, |
| 1769 | unsigned int value) |
| 1770 | { |
| 1771 | int ret; |
| 1772 | pr_debug("%s: write reg %x val %x\n", __func__, reg, value); |
| 1773 | |
| 1774 | BUG_ON(reg > TABLA_MAX_REGISTER); |
| 1775 | |
| 1776 | if (!tabla_volatile(codec, reg)) { |
| 1777 | pr_debug("writing to cache\n"); |
| 1778 | ret = snd_soc_cache_write(codec, reg, value); |
| 1779 | if (ret != 0) |
| 1780 | dev_err(codec->dev, "Cache write to %x failed: %d\n", |
| 1781 | reg, ret); |
| 1782 | } |
| 1783 | |
| 1784 | return tabla_reg_write(codec->control_data, reg, value); |
| 1785 | } |
| 1786 | static unsigned int tabla_read(struct snd_soc_codec *codec, |
| 1787 | unsigned int reg) |
| 1788 | { |
| 1789 | unsigned int val; |
| 1790 | int ret; |
| 1791 | |
| 1792 | BUG_ON(reg > TABLA_MAX_REGISTER); |
| 1793 | |
| 1794 | if (!tabla_volatile(codec, reg) && tabla_readable(codec, reg) && |
| 1795 | reg < codec->driver->reg_cache_size) { |
| 1796 | pr_debug("reading from cache\n"); |
| 1797 | ret = snd_soc_cache_read(codec, reg, &val); |
| 1798 | if (ret >= 0) { |
Bradley Rubin | 229c6a5 | 2011-07-12 16:18:48 -0700 | [diff] [blame] | 1799 | pr_debug("register %x, value %x\n", reg, val); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1800 | return val; |
| 1801 | } else |
| 1802 | dev_err(codec->dev, "Cache read from %x failed: %d\n", |
| 1803 | reg, ret); |
| 1804 | } |
| 1805 | |
| 1806 | val = tabla_reg_read(codec->control_data, reg); |
| 1807 | pr_debug("%s: read reg %x val %x\n", __func__, reg, val); |
| 1808 | return val; |
| 1809 | } |
| 1810 | |
| 1811 | static void tabla_codec_enable_audio_mode_bandgap(struct snd_soc_codec *codec) |
| 1812 | { |
| 1813 | snd_soc_write(codec, TABLA_A_BIAS_REF_CTL, 0x1C); |
| 1814 | snd_soc_update_bits(codec, TABLA_A_BIAS_CENTRAL_BG_CTL, 0x80, |
| 1815 | 0x80); |
| 1816 | snd_soc_update_bits(codec, TABLA_A_BIAS_CENTRAL_BG_CTL, 0x04, |
| 1817 | 0x04); |
| 1818 | snd_soc_update_bits(codec, TABLA_A_BIAS_CENTRAL_BG_CTL, 0x01, |
| 1819 | 0x01); |
| 1820 | usleep_range(1000, 1000); |
| 1821 | snd_soc_update_bits(codec, TABLA_A_BIAS_CENTRAL_BG_CTL, 0x80, |
| 1822 | 0x00); |
| 1823 | } |
| 1824 | |
| 1825 | static void tabla_codec_enable_bandgap(struct snd_soc_codec *codec, |
| 1826 | enum tabla_bandgap_type choice) |
| 1827 | { |
| 1828 | struct tabla_priv *tabla = snd_soc_codec_get_drvdata(codec); |
| 1829 | |
| 1830 | /* TODO lock resources accessed by audio streams and threaded |
| 1831 | * interrupt handlers |
| 1832 | */ |
| 1833 | |
| 1834 | pr_debug("%s, choice is %d, current is %d\n", __func__, choice, |
| 1835 | tabla->bandgap_type); |
| 1836 | |
| 1837 | if (tabla->bandgap_type == choice) |
| 1838 | return; |
| 1839 | |
| 1840 | if ((tabla->bandgap_type == TABLA_BANDGAP_OFF) && |
| 1841 | (choice == TABLA_BANDGAP_AUDIO_MODE)) { |
| 1842 | tabla_codec_enable_audio_mode_bandgap(codec); |
| 1843 | } else if ((tabla->bandgap_type == TABLA_BANDGAP_AUDIO_MODE) && |
| 1844 | (choice == TABLA_BANDGAP_MBHC_MODE)) { |
| 1845 | snd_soc_update_bits(codec, TABLA_A_BIAS_CENTRAL_BG_CTL, 0x2, |
| 1846 | 0x2); |
| 1847 | snd_soc_update_bits(codec, TABLA_A_BIAS_CENTRAL_BG_CTL, 0x80, |
| 1848 | 0x80); |
| 1849 | snd_soc_update_bits(codec, TABLA_A_BIAS_CENTRAL_BG_CTL, 0x4, |
| 1850 | 0x4); |
| 1851 | usleep_range(1000, 1000); |
| 1852 | snd_soc_update_bits(codec, TABLA_A_BIAS_CENTRAL_BG_CTL, 0x80, |
| 1853 | 0x00); |
| 1854 | } else if ((tabla->bandgap_type == TABLA_BANDGAP_MBHC_MODE) && |
| 1855 | (choice == TABLA_BANDGAP_AUDIO_MODE)) { |
| 1856 | snd_soc_write(codec, TABLA_A_BIAS_CENTRAL_BG_CTL, 0x00); |
| 1857 | usleep_range(100, 100); |
| 1858 | tabla_codec_enable_audio_mode_bandgap(codec); |
| 1859 | } else if (choice == TABLA_BANDGAP_OFF) { |
| 1860 | snd_soc_write(codec, TABLA_A_BIAS_CENTRAL_BG_CTL, 0x00); |
| 1861 | } else { |
| 1862 | pr_err("%s: Error, Invalid bandgap settings\n", __func__); |
| 1863 | } |
| 1864 | tabla->bandgap_type = choice; |
| 1865 | } |
| 1866 | |
| 1867 | static int tabla_codec_enable_config_mode(struct snd_soc_codec *codec, |
| 1868 | int enable) |
| 1869 | { |
| 1870 | struct tabla_priv *tabla = snd_soc_codec_get_drvdata(codec); |
| 1871 | |
| 1872 | if (enable) { |
| 1873 | snd_soc_update_bits(codec, TABLA_A_CONFIG_MODE_FREQ, 0x10, 0); |
| 1874 | snd_soc_write(codec, TABLA_A_BIAS_CONFIG_MODE_BG_CTL, 0x17); |
| 1875 | usleep_range(5, 5); |
| 1876 | snd_soc_update_bits(codec, TABLA_A_CONFIG_MODE_FREQ, 0x80, |
| 1877 | 0x80); |
| 1878 | snd_soc_update_bits(codec, TABLA_A_CONFIG_MODE_TEST, 0x80, |
| 1879 | 0x80); |
| 1880 | usleep_range(10, 10); |
| 1881 | snd_soc_update_bits(codec, TABLA_A_CONFIG_MODE_TEST, 0x80, 0); |
| 1882 | usleep_range(20, 20); |
| 1883 | snd_soc_update_bits(codec, TABLA_A_CLK_BUFF_EN1, 0x08, 0x08); |
| 1884 | } else { |
| 1885 | snd_soc_update_bits(codec, TABLA_A_BIAS_CONFIG_MODE_BG_CTL, 0x1, |
| 1886 | 0); |
| 1887 | snd_soc_update_bits(codec, TABLA_A_CONFIG_MODE_FREQ, 0x80, 0); |
| 1888 | } |
| 1889 | tabla->config_mode_active = enable ? true : false; |
| 1890 | |
| 1891 | return 0; |
| 1892 | } |
| 1893 | |
| 1894 | static int tabla_codec_enable_clock_block(struct snd_soc_codec *codec, |
| 1895 | int config_mode) |
| 1896 | { |
| 1897 | struct tabla_priv *tabla = snd_soc_codec_get_drvdata(codec); |
| 1898 | |
| 1899 | pr_debug("%s\n", __func__); |
| 1900 | |
| 1901 | if (config_mode) { |
| 1902 | tabla_codec_enable_config_mode(codec, 1); |
| 1903 | snd_soc_write(codec, TABLA_A_CLK_BUFF_EN2, 0x00); |
| 1904 | snd_soc_write(codec, TABLA_A_CLK_BUFF_EN2, 0x02); |
| 1905 | snd_soc_write(codec, TABLA_A_CLK_BUFF_EN1, 0x0D); |
| 1906 | usleep_range(1000, 1000); |
| 1907 | } else |
| 1908 | snd_soc_update_bits(codec, TABLA_A_CLK_BUFF_EN1, 0x08, 0x00); |
| 1909 | |
| 1910 | if (!config_mode && tabla->mbhc_polling_active) { |
| 1911 | snd_soc_write(codec, TABLA_A_CLK_BUFF_EN2, 0x02); |
| 1912 | tabla_codec_enable_config_mode(codec, 0); |
| 1913 | |
| 1914 | } |
| 1915 | |
| 1916 | snd_soc_update_bits(codec, TABLA_A_CLK_BUFF_EN1, 0x05, 0x05); |
| 1917 | snd_soc_update_bits(codec, TABLA_A_CLK_BUFF_EN2, 0x02, 0x00); |
| 1918 | snd_soc_update_bits(codec, TABLA_A_CLK_BUFF_EN2, 0x04, 0x04); |
| 1919 | snd_soc_update_bits(codec, TABLA_A_CDC_CLK_MCLK_CTL, 0x01, 0x01); |
| 1920 | usleep_range(50, 50); |
| 1921 | tabla->clock_active = true; |
| 1922 | return 0; |
| 1923 | } |
| 1924 | static void tabla_codec_disable_clock_block(struct snd_soc_codec *codec) |
| 1925 | { |
| 1926 | struct tabla_priv *tabla = snd_soc_codec_get_drvdata(codec); |
| 1927 | pr_debug("%s\n", __func__); |
| 1928 | snd_soc_update_bits(codec, TABLA_A_CLK_BUFF_EN2, 0x04, 0x00); |
| 1929 | ndelay(160); |
| 1930 | snd_soc_update_bits(codec, TABLA_A_CLK_BUFF_EN2, 0x02, 0x02); |
| 1931 | snd_soc_update_bits(codec, TABLA_A_CLK_BUFF_EN1, 0x05, 0x00); |
| 1932 | tabla->clock_active = false; |
| 1933 | } |
| 1934 | |
Bradley Rubin | cb1e273 | 2011-06-23 16:49:20 -0700 | [diff] [blame] | 1935 | static void tabla_codec_calibrate_hs_polling(struct snd_soc_codec *codec) |
| 1936 | { |
| 1937 | /* TODO store register values in calibration */ |
Bhalchandra Gajare | 30cf484 | 2011-10-17 18:12:52 -0700 | [diff] [blame^] | 1938 | snd_soc_write(codec, TABLA_A_CDC_MBHC_VOLT_B5_CTL, 0x20); |
| 1939 | snd_soc_write(codec, TABLA_A_CDC_MBHC_VOLT_B6_CTL, 0xFF); |
Bradley Rubin | cb1e273 | 2011-06-23 16:49:20 -0700 | [diff] [blame] | 1940 | |
| 1941 | snd_soc_write(codec, TABLA_A_CDC_MBHC_VOLT_B10_CTL, 0xFF); |
Bhalchandra Gajare | 30cf484 | 2011-10-17 18:12:52 -0700 | [diff] [blame^] | 1942 | snd_soc_write(codec, TABLA_A_CDC_MBHC_VOLT_B9_CTL, 0x20); |
Bradley Rubin | cb1e273 | 2011-06-23 16:49:20 -0700 | [diff] [blame] | 1943 | |
| 1944 | snd_soc_write(codec, TABLA_A_CDC_MBHC_VOLT_B4_CTL, 0x08); |
| 1945 | snd_soc_write(codec, TABLA_A_CDC_MBHC_VOLT_B3_CTL, 0xEE); |
| 1946 | snd_soc_write(codec, TABLA_A_CDC_MBHC_VOLT_B2_CTL, 0xFC); |
| 1947 | snd_soc_write(codec, TABLA_A_CDC_MBHC_VOLT_B1_CTL, 0xCE); |
| 1948 | |
| 1949 | snd_soc_write(codec, TABLA_A_CDC_MBHC_TIMER_B1_CTL, 3); |
| 1950 | snd_soc_write(codec, TABLA_A_CDC_MBHC_TIMER_B2_CTL, 9); |
| 1951 | snd_soc_write(codec, TABLA_A_CDC_MBHC_TIMER_B3_CTL, 30); |
| 1952 | snd_soc_write(codec, TABLA_A_CDC_MBHC_TIMER_B6_CTL, 120); |
| 1953 | snd_soc_update_bits(codec, TABLA_A_CDC_MBHC_TIMER_B1_CTL, 0x78, 0x58); |
| 1954 | snd_soc_write(codec, TABLA_A_CDC_MBHC_B2_CTL, 11); |
| 1955 | } |
| 1956 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1957 | static int tabla_startup(struct snd_pcm_substream *substream, |
| 1958 | struct snd_soc_dai *dai) |
| 1959 | { |
Kiran Kandi | 6fae8bf | 2011-08-15 10:36:42 -0700 | [diff] [blame] | 1960 | pr_debug("%s(): substream = %s stream = %d\n" , __func__, |
| 1961 | substream->name, substream->stream); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1962 | |
Kiran Kandi | 6fae8bf | 2011-08-15 10:36:42 -0700 | [diff] [blame] | 1963 | return 0; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1964 | } |
| 1965 | |
| 1966 | static void tabla_shutdown(struct snd_pcm_substream *substream, |
| 1967 | struct snd_soc_dai *dai) |
| 1968 | { |
Kiran Kandi | 6fae8bf | 2011-08-15 10:36:42 -0700 | [diff] [blame] | 1969 | pr_debug("%s(): substream = %s stream = %d\n" , __func__, |
| 1970 | substream->name, substream->stream); |
| 1971 | } |
| 1972 | |
| 1973 | int tabla_mclk_enable(struct snd_soc_codec *codec, int mclk_enable) |
| 1974 | { |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1975 | struct tabla_priv *tabla = snd_soc_codec_get_drvdata(codec); |
| 1976 | |
Kiran Kandi | 6fae8bf | 2011-08-15 10:36:42 -0700 | [diff] [blame] | 1977 | pr_debug("%s() mclk_enable = %u\n", __func__, mclk_enable); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1978 | |
Kiran Kandi | 6fae8bf | 2011-08-15 10:36:42 -0700 | [diff] [blame] | 1979 | if (mclk_enable) { |
| 1980 | tabla->mclk_enabled = true; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1981 | |
Kiran Kandi | 6fae8bf | 2011-08-15 10:36:42 -0700 | [diff] [blame] | 1982 | if (tabla->mbhc_polling_active && (tabla->mclk_enabled)) { |
Bradley Rubin | cb1e273 | 2011-06-23 16:49:20 -0700 | [diff] [blame] | 1983 | tabla_codec_pause_hs_polling(codec); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1984 | tabla_codec_enable_bandgap(codec, |
Kiran Kandi | 6fae8bf | 2011-08-15 10:36:42 -0700 | [diff] [blame] | 1985 | TABLA_BANDGAP_AUDIO_MODE); |
| 1986 | tabla_codec_enable_clock_block(codec, 0); |
Bradley Rubin | cb1e273 | 2011-06-23 16:49:20 -0700 | [diff] [blame] | 1987 | tabla_codec_calibrate_hs_polling(codec); |
| 1988 | tabla_codec_start_hs_polling(codec); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1989 | } |
Kiran Kandi | 6fae8bf | 2011-08-15 10:36:42 -0700 | [diff] [blame] | 1990 | } else { |
| 1991 | |
| 1992 | if (!tabla->mclk_enabled) { |
| 1993 | pr_err("Error, MCLK already diabled\n"); |
| 1994 | return -EINVAL; |
| 1995 | } |
| 1996 | tabla->mclk_enabled = false; |
| 1997 | |
| 1998 | if (tabla->mbhc_polling_active) { |
| 1999 | if (!tabla->mclk_enabled) { |
| 2000 | tabla_codec_pause_hs_polling(codec); |
| 2001 | tabla_codec_enable_bandgap(codec, |
| 2002 | TABLA_BANDGAP_MBHC_MODE); |
| 2003 | tabla_enable_rx_bias(codec, 1); |
| 2004 | tabla_codec_enable_clock_block(codec, 1); |
| 2005 | tabla_codec_calibrate_hs_polling(codec); |
| 2006 | tabla_codec_start_hs_polling(codec); |
| 2007 | } |
| 2008 | snd_soc_update_bits(codec, TABLA_A_CLK_BUFF_EN1, |
| 2009 | 0x05, 0x01); |
| 2010 | } |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 2011 | } |
Kiran Kandi | 6fae8bf | 2011-08-15 10:36:42 -0700 | [diff] [blame] | 2012 | return 0; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 2013 | } |
| 2014 | |
| 2015 | static int tabla_digital_mute(struct snd_soc_dai *codec_dai, int mute) |
| 2016 | { |
| 2017 | struct snd_soc_codec *codec = codec_dai->codec; |
| 2018 | |
| 2019 | pr_debug("%s %d\n", __func__, mute); |
| 2020 | |
| 2021 | /* TODO mute TX */ |
| 2022 | if (mute) |
| 2023 | snd_soc_update_bits(codec, TABLA_A_CDC_RX1_B6_CTL, 0x01, 0x01); |
| 2024 | else |
| 2025 | snd_soc_update_bits(codec, TABLA_A_CDC_RX1_B6_CTL, 0x01, 0x00); |
| 2026 | |
| 2027 | return 0; |
| 2028 | } |
| 2029 | |
| 2030 | static int tabla_set_dai_sysclk(struct snd_soc_dai *dai, |
| 2031 | int clk_id, unsigned int freq, int dir) |
| 2032 | { |
| 2033 | pr_debug("%s\n", __func__); |
| 2034 | return 0; |
| 2035 | } |
| 2036 | |
| 2037 | static int tabla_set_dai_fmt(struct snd_soc_dai *dai, unsigned int fmt) |
| 2038 | { |
| 2039 | pr_debug("%s\n", __func__); |
| 2040 | return 0; |
| 2041 | } |
| 2042 | |
| 2043 | static int tabla_hw_params(struct snd_pcm_substream *substream, |
| 2044 | struct snd_pcm_hw_params *params, |
| 2045 | struct snd_soc_dai *dai) |
| 2046 | { |
Bhalchandra Gajare | 9a901fd | 2011-08-01 10:07:15 -0700 | [diff] [blame] | 2047 | struct snd_soc_codec *codec = dai->codec; |
Bhalchandra Gajare | 038bf3a | 2011-09-02 15:32:30 -0700 | [diff] [blame] | 2048 | u8 path, shift; |
| 2049 | u16 tx_fs_reg, rx_fs_reg; |
Bhalchandra Gajare | 9a901fd | 2011-08-01 10:07:15 -0700 | [diff] [blame] | 2050 | u8 tx_fs_rate, rx_fs_rate, rx_state, tx_state; |
| 2051 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 2052 | pr_debug("%s: DAI-ID %x\n", __func__, dai->id); |
Bhalchandra Gajare | 9a901fd | 2011-08-01 10:07:15 -0700 | [diff] [blame] | 2053 | |
| 2054 | switch (params_rate(params)) { |
| 2055 | case 8000: |
| 2056 | tx_fs_rate = 0x00; |
| 2057 | rx_fs_rate = 0x00; |
| 2058 | break; |
| 2059 | case 16000: |
| 2060 | tx_fs_rate = 0x01; |
| 2061 | rx_fs_rate = 0x20; |
| 2062 | break; |
| 2063 | case 32000: |
| 2064 | tx_fs_rate = 0x02; |
| 2065 | rx_fs_rate = 0x40; |
| 2066 | break; |
| 2067 | case 48000: |
| 2068 | tx_fs_rate = 0x03; |
| 2069 | rx_fs_rate = 0x60; |
| 2070 | break; |
| 2071 | default: |
| 2072 | pr_err("%s: Invalid sampling rate %d\n", __func__, |
| 2073 | params_rate(params)); |
| 2074 | return -EINVAL; |
| 2075 | } |
| 2076 | |
| 2077 | |
| 2078 | /** |
| 2079 | * If current dai is a tx dai, set sample rate to |
| 2080 | * all the txfe paths that are currently not active |
| 2081 | */ |
| 2082 | if (dai->id == TABLA_TX_DAI_ID) { |
| 2083 | |
| 2084 | tx_state = snd_soc_read(codec, |
| 2085 | TABLA_A_CDC_CLK_TX_CLK_EN_B1_CTL); |
| 2086 | |
| 2087 | for (path = 1, shift = 0; |
| 2088 | path <= NUM_DECIMATORS; path++, shift++) { |
| 2089 | |
| 2090 | if (path == BITS_PER_REG + 1) { |
| 2091 | shift = 0; |
| 2092 | tx_state = snd_soc_read(codec, |
| 2093 | TABLA_A_CDC_CLK_TX_CLK_EN_B2_CTL); |
| 2094 | } |
| 2095 | |
| 2096 | if (!(tx_state & (1 << shift))) { |
| 2097 | tx_fs_reg = TABLA_A_CDC_TX1_CLK_FS_CTL |
| 2098 | + (BITS_PER_REG*(path-1)); |
| 2099 | snd_soc_update_bits(codec, tx_fs_reg, |
| 2100 | 0x03, tx_fs_rate); |
| 2101 | } |
| 2102 | } |
| 2103 | } |
| 2104 | |
| 2105 | /** |
| 2106 | * TODO: Need to handle case where same RX chain takes 2 or more inputs |
| 2107 | * with varying sample rates |
| 2108 | */ |
| 2109 | |
| 2110 | /** |
| 2111 | * If current dai is a rx dai, set sample rate to |
| 2112 | * all the rx paths that are currently not active |
| 2113 | */ |
| 2114 | if (dai->id == TABLA_RX_DAI_ID) { |
| 2115 | |
| 2116 | rx_state = snd_soc_read(codec, |
| 2117 | TABLA_A_CDC_CLK_RX_B1_CTL); |
| 2118 | |
| 2119 | for (path = 1, shift = 0; |
| 2120 | path <= NUM_INTERPOLATORS; path++, shift++) { |
| 2121 | |
| 2122 | if (!(rx_state & (1 << shift))) { |
| 2123 | rx_fs_reg = TABLA_A_CDC_RX1_B5_CTL |
| 2124 | + (BITS_PER_REG*(path-1)); |
| 2125 | snd_soc_update_bits(codec, rx_fs_reg, |
| 2126 | 0xE0, rx_fs_rate); |
| 2127 | } |
| 2128 | } |
| 2129 | } |
| 2130 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 2131 | return 0; |
| 2132 | } |
| 2133 | |
| 2134 | static struct snd_soc_dai_ops tabla_dai_ops = { |
| 2135 | .startup = tabla_startup, |
| 2136 | .shutdown = tabla_shutdown, |
| 2137 | .hw_params = tabla_hw_params, |
| 2138 | .set_sysclk = tabla_set_dai_sysclk, |
| 2139 | .set_fmt = tabla_set_dai_fmt, |
| 2140 | .digital_mute = tabla_digital_mute, |
| 2141 | }; |
| 2142 | |
| 2143 | static struct snd_soc_dai_driver tabla_dai[] = { |
| 2144 | { |
| 2145 | .name = "tabla_rx1", |
| 2146 | .id = 1, |
| 2147 | .playback = { |
| 2148 | .stream_name = "AIF1 Playback", |
Bhalchandra Gajare | 9a901fd | 2011-08-01 10:07:15 -0700 | [diff] [blame] | 2149 | .rates = WCD9310_RATES, |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 2150 | .formats = TABLA_FORMATS, |
| 2151 | .rate_max = 48000, |
| 2152 | .rate_min = 8000, |
| 2153 | .channels_min = 1, |
| 2154 | .channels_max = 2, |
| 2155 | }, |
| 2156 | .ops = &tabla_dai_ops, |
| 2157 | }, |
| 2158 | { |
| 2159 | .name = "tabla_tx1", |
| 2160 | .id = 2, |
| 2161 | .capture = { |
| 2162 | .stream_name = "AIF1 Capture", |
Bhalchandra Gajare | 9a901fd | 2011-08-01 10:07:15 -0700 | [diff] [blame] | 2163 | .rates = WCD9310_RATES, |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 2164 | .formats = TABLA_FORMATS, |
| 2165 | .rate_max = 48000, |
| 2166 | .rate_min = 8000, |
| 2167 | .channels_min = 1, |
| 2168 | .channels_max = 2, |
| 2169 | }, |
| 2170 | .ops = &tabla_dai_ops, |
| 2171 | }, |
| 2172 | }; |
Bradley Rubin | 89ffd0a | 2011-07-21 16:04:06 -0700 | [diff] [blame] | 2173 | static short tabla_codec_read_sta_result(struct snd_soc_codec *codec) |
Bradley Rubin | cb1e273 | 2011-06-23 16:49:20 -0700 | [diff] [blame] | 2174 | { |
| 2175 | u8 bias_msb, bias_lsb; |
| 2176 | short bias_value; |
| 2177 | |
Bradley Rubin | 89ffd0a | 2011-07-21 16:04:06 -0700 | [diff] [blame] | 2178 | bias_msb = snd_soc_read(codec, TABLA_A_CDC_MBHC_B3_STATUS); |
| 2179 | bias_lsb = snd_soc_read(codec, TABLA_A_CDC_MBHC_B2_STATUS); |
| 2180 | bias_value = (bias_msb << 8) | bias_lsb; |
| 2181 | return bias_value; |
| 2182 | } |
| 2183 | |
| 2184 | static short tabla_codec_read_dce_result(struct snd_soc_codec *codec) |
| 2185 | { |
| 2186 | u8 bias_msb, bias_lsb; |
| 2187 | short bias_value; |
| 2188 | |
| 2189 | bias_msb = snd_soc_read(codec, TABLA_A_CDC_MBHC_B5_STATUS); |
| 2190 | bias_lsb = snd_soc_read(codec, TABLA_A_CDC_MBHC_B4_STATUS); |
| 2191 | bias_value = (bias_msb << 8) | bias_lsb; |
| 2192 | return bias_value; |
| 2193 | } |
| 2194 | |
| 2195 | static short tabla_codec_measure_micbias_voltage(struct snd_soc_codec *codec, |
| 2196 | int dce) |
| 2197 | { |
| 2198 | short bias_value; |
| 2199 | |
Bradley Rubin | cb1e273 | 2011-06-23 16:49:20 -0700 | [diff] [blame] | 2200 | if (dce) { |
Bradley Rubin | 89ffd0a | 2011-07-21 16:04:06 -0700 | [diff] [blame] | 2201 | snd_soc_update_bits(codec, TABLA_A_CDC_MBHC_CLK_CTL, 0x8, 0x8); |
| 2202 | snd_soc_write(codec, TABLA_A_CDC_MBHC_EN_CTL, 0x4); |
| 2203 | snd_soc_update_bits(codec, TABLA_A_CDC_MBHC_CLK_CTL, 0x8, 0x0); |
| 2204 | snd_soc_write(codec, TABLA_A_CDC_MBHC_EN_CTL, 0x4); |
| 2205 | usleep_range(60000, 60000); |
| 2206 | bias_value = tabla_codec_read_dce_result(codec); |
Bradley Rubin | cb1e273 | 2011-06-23 16:49:20 -0700 | [diff] [blame] | 2207 | } else { |
Bradley Rubin | 89ffd0a | 2011-07-21 16:04:06 -0700 | [diff] [blame] | 2208 | snd_soc_update_bits(codec, TABLA_A_CDC_MBHC_CLK_CTL, 0x8, 0x8); |
Bradley Rubin | cb1e273 | 2011-06-23 16:49:20 -0700 | [diff] [blame] | 2209 | snd_soc_write(codec, TABLA_A_CDC_MBHC_EN_CTL, 0x2); |
| 2210 | snd_soc_update_bits(codec, TABLA_A_CDC_MBHC_CLK_CTL, 0x8, 0x0); |
Bradley Rubin | 89ffd0a | 2011-07-21 16:04:06 -0700 | [diff] [blame] | 2211 | usleep_range(5000, 5000); |
Bradley Rubin | cb1e273 | 2011-06-23 16:49:20 -0700 | [diff] [blame] | 2212 | snd_soc_write(codec, TABLA_A_CDC_MBHC_EN_CTL, 0x2); |
Bradley Rubin | 89ffd0a | 2011-07-21 16:04:06 -0700 | [diff] [blame] | 2213 | usleep_range(50, 50); |
| 2214 | bias_value = tabla_codec_read_sta_result(codec); |
| 2215 | snd_soc_update_bits(codec, TABLA_A_CDC_MBHC_CLK_CTL, 0x8, 0x8); |
| 2216 | snd_soc_write(codec, TABLA_A_CDC_MBHC_EN_CTL, 0x0); |
Bradley Rubin | cb1e273 | 2011-06-23 16:49:20 -0700 | [diff] [blame] | 2217 | } |
| 2218 | |
Bradley Rubin | cb1e273 | 2011-06-23 16:49:20 -0700 | [diff] [blame] | 2219 | pr_debug("read microphone bias value %x\n", bias_value); |
| 2220 | return bias_value; |
| 2221 | } |
| 2222 | |
Bhalchandra Gajare | 343cbb0 | 2011-09-07 18:58:19 -0700 | [diff] [blame] | 2223 | static short tabla_codec_setup_hs_polling(struct snd_soc_codec *codec) |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 2224 | { |
| 2225 | struct tabla_priv *tabla = snd_soc_codec_get_drvdata(codec); |
| 2226 | struct tabla_mbhc_calibration *calibration = tabla->calibration; |
Bhalchandra Gajare | 343cbb0 | 2011-09-07 18:58:19 -0700 | [diff] [blame] | 2227 | short bias_value; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 2228 | |
| 2229 | if (!calibration) { |
| 2230 | pr_err("Error, no tabla calibration\n"); |
Bradley Rubin | cb1e273 | 2011-06-23 16:49:20 -0700 | [diff] [blame] | 2231 | return -ENODEV; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 2232 | } |
| 2233 | |
| 2234 | tabla->mbhc_polling_active = true; |
| 2235 | |
Kiran Kandi | 6fae8bf | 2011-08-15 10:36:42 -0700 | [diff] [blame] | 2236 | if (!tabla->mclk_enabled) { |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 2237 | tabla_codec_enable_bandgap(codec, TABLA_BANDGAP_MBHC_MODE); |
Kiran Kandi | 6fae8bf | 2011-08-15 10:36:42 -0700 | [diff] [blame] | 2238 | tabla_enable_rx_bias(codec, 1); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 2239 | tabla_codec_enable_clock_block(codec, 1); |
| 2240 | } |
| 2241 | |
| 2242 | snd_soc_update_bits(codec, TABLA_A_CLK_BUFF_EN1, 0x05, 0x01); |
| 2243 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 2244 | snd_soc_update_bits(codec, TABLA_A_TX_COM_BIAS, 0xE0, 0xE0); |
| 2245 | |
Patrick Lai | 3043fba | 2011-08-01 14:15:57 -0700 | [diff] [blame] | 2246 | |
Bhalchandra Gajare | 02d90cd | 2011-09-30 16:14:00 -0700 | [diff] [blame] | 2247 | snd_soc_update_bits(codec, |
| 2248 | tabla->mbhc_bias_regs.cfilt_ctl, 0x70, 0x00); |
Patrick Lai | 3043fba | 2011-08-01 14:15:57 -0700 | [diff] [blame] | 2249 | |
Bhalchandra Gajare | 02d90cd | 2011-09-30 16:14:00 -0700 | [diff] [blame] | 2250 | snd_soc_update_bits(codec, |
| 2251 | tabla->mbhc_bias_regs.ctl_reg, 0x1F, 0x16); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 2252 | |
| 2253 | snd_soc_update_bits(codec, TABLA_A_CDC_MBHC_CLK_CTL, 0x2, 0x2); |
Bradley Rubin | cb1e273 | 2011-06-23 16:49:20 -0700 | [diff] [blame] | 2254 | snd_soc_write(codec, TABLA_A_MBHC_SCALING_MUX_1, 0x84); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 2255 | |
| 2256 | snd_soc_update_bits(codec, TABLA_A_TX_7_MBHC_EN, 0x80, 0x80); |
| 2257 | snd_soc_update_bits(codec, TABLA_A_TX_7_MBHC_EN, 0x1F, 0x1C); |
| 2258 | snd_soc_update_bits(codec, TABLA_A_TX_7_MBHC_TEST_CTL, 0x40, 0x40); |
| 2259 | |
| 2260 | snd_soc_update_bits(codec, TABLA_A_TX_7_MBHC_EN, 0x80, 0x00); |
Bradley Rubin | cb1e273 | 2011-06-23 16:49:20 -0700 | [diff] [blame] | 2261 | snd_soc_update_bits(codec, TABLA_A_CDC_MBHC_CLK_CTL, 0x8, 0x8); |
| 2262 | snd_soc_update_bits(codec, TABLA_A_CDC_MBHC_CLK_CTL, 0x8, 0x00); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 2263 | |
Bradley Rubin | cb1e273 | 2011-06-23 16:49:20 -0700 | [diff] [blame] | 2264 | snd_soc_update_bits(codec, TABLA_A_CDC_MBHC_B1_CTL, 0x6, 0x6); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 2265 | snd_soc_update_bits(codec, TABLA_A_CDC_MBHC_CLK_CTL, 0x8, 0x8); |
| 2266 | |
Bradley Rubin | cb1e273 | 2011-06-23 16:49:20 -0700 | [diff] [blame] | 2267 | tabla_codec_calibrate_hs_polling(codec); |
| 2268 | |
| 2269 | bias_value = tabla_codec_measure_micbias_voltage(codec, 0); |
Bhalchandra Gajare | 02d90cd | 2011-09-30 16:14:00 -0700 | [diff] [blame] | 2270 | snd_soc_update_bits(codec, |
| 2271 | tabla->mbhc_bias_regs.cfilt_ctl, 0x40, 0x40); |
Bradley Rubin | 89ffd0a | 2011-07-21 16:04:06 -0700 | [diff] [blame] | 2272 | snd_soc_update_bits(codec, TABLA_A_MBHC_HPH, 0x13, 0x00); |
Bradley Rubin | cb1e273 | 2011-06-23 16:49:20 -0700 | [diff] [blame] | 2273 | |
Bhalchandra Gajare | 343cbb0 | 2011-09-07 18:58:19 -0700 | [diff] [blame] | 2274 | return bias_value; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 2275 | } |
| 2276 | |
| 2277 | static int tabla_codec_enable_hs_detect(struct snd_soc_codec *codec, |
| 2278 | int insertion) |
| 2279 | { |
| 2280 | struct tabla_priv *tabla = snd_soc_codec_get_drvdata(codec); |
| 2281 | struct tabla_mbhc_calibration *calibration = tabla->calibration; |
| 2282 | int central_bias_enabled = 0; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 2283 | |
| 2284 | if (!calibration) { |
| 2285 | pr_err("Error, no tabla calibration\n"); |
| 2286 | return -EINVAL; |
| 2287 | } |
| 2288 | |
| 2289 | snd_soc_update_bits(codec, TABLA_A_CDC_MBHC_INT_CTL, 0x1, 0); |
| 2290 | |
Bhalchandra Gajare | 7fc7233 | 2011-10-13 19:01:55 -0700 | [diff] [blame] | 2291 | if (insertion) { |
| 2292 | /* Make sure mic bias and Mic line schmitt trigger |
| 2293 | * are turned OFF |
| 2294 | */ |
| 2295 | snd_soc_update_bits(codec, tabla->mbhc_bias_regs.ctl_reg, |
| 2296 | 0x81, 0x01); |
| 2297 | snd_soc_update_bits(codec, tabla->mbhc_bias_regs.mbhc_reg, |
| 2298 | 0x90, 0x00); |
| 2299 | |
| 2300 | /* Enable HPH Schmitt Trigger */ |
| 2301 | snd_soc_update_bits(codec, TABLA_A_MBHC_HPH, 0x13, 0x13); |
| 2302 | snd_soc_update_bits(codec, TABLA_A_MBHC_HPH, 0x0C, |
| 2303 | calibration->hph_current << 2); |
| 2304 | |
| 2305 | /* Turn off HPH PAs during insertion detection to avoid false |
| 2306 | * insertion interrupts |
| 2307 | */ |
| 2308 | if (tabla->mbhc_micbias_switched) |
| 2309 | tabla_codec_switch_micbias(codec, 0); |
| 2310 | snd_soc_update_bits(codec, TABLA_A_RX_HPH_CNP_EN, 0x30, 0x00); |
| 2311 | |
| 2312 | /* setup for insetion detection */ |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 2313 | snd_soc_update_bits(codec, TABLA_A_CDC_MBHC_INT_CTL, 0x2, 0); |
Bhalchandra Gajare | 7fc7233 | 2011-10-13 19:01:55 -0700 | [diff] [blame] | 2314 | } else { |
| 2315 | /* Make sure the HPH schmitt trigger is OFF */ |
| 2316 | snd_soc_update_bits(codec, TABLA_A_MBHC_HPH, 0x12, 0x00); |
| 2317 | |
| 2318 | /* enable the mic line schmitt trigger */ |
| 2319 | snd_soc_update_bits(codec, tabla->mbhc_bias_regs.mbhc_reg, 0x60, |
| 2320 | calibration->mic_current << 5); |
| 2321 | snd_soc_update_bits(codec, tabla->mbhc_bias_regs.mbhc_reg, |
| 2322 | 0x80, 0x80); |
| 2323 | usleep_range(calibration->mic_pid, calibration->mic_pid); |
| 2324 | snd_soc_update_bits(codec, tabla->mbhc_bias_regs.mbhc_reg, |
| 2325 | 0x10, 0x10); |
| 2326 | |
| 2327 | /* Setup for low power removal detection */ |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 2328 | snd_soc_update_bits(codec, TABLA_A_CDC_MBHC_INT_CTL, 0x2, 0x2); |
Bhalchandra Gajare | 7fc7233 | 2011-10-13 19:01:55 -0700 | [diff] [blame] | 2329 | } |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 2330 | |
| 2331 | if (snd_soc_read(codec, TABLA_A_CDC_MBHC_B1_CTL) & 0x4) { |
| 2332 | if (!(tabla->clock_active)) { |
| 2333 | tabla_codec_enable_config_mode(codec, 1); |
| 2334 | snd_soc_update_bits(codec, TABLA_A_CDC_MBHC_B1_CTL, |
Bradley Rubin | cb1e273 | 2011-06-23 16:49:20 -0700 | [diff] [blame] | 2335 | 0x06, 0); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 2336 | usleep_range(calibration->shutdown_plug_removal, |
| 2337 | calibration->shutdown_plug_removal); |
| 2338 | tabla_codec_enable_config_mode(codec, 0); |
| 2339 | } else |
| 2340 | snd_soc_update_bits(codec, TABLA_A_CDC_MBHC_B1_CTL, |
Bradley Rubin | cb1e273 | 2011-06-23 16:49:20 -0700 | [diff] [blame] | 2341 | 0x06, 0); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 2342 | } |
| 2343 | |
Bhalchandra Gajare | 02d90cd | 2011-09-30 16:14:00 -0700 | [diff] [blame] | 2344 | snd_soc_update_bits(codec, tabla->mbhc_bias_regs.int_rbias, 0x80, 0); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 2345 | |
| 2346 | /* If central bandgap disabled */ |
| 2347 | if (!(snd_soc_read(codec, TABLA_A_PIN_CTL_OE1) & 1)) { |
| 2348 | snd_soc_update_bits(codec, TABLA_A_PIN_CTL_OE1, 0x3, 0x3); |
| 2349 | usleep_range(calibration->bg_fast_settle, |
| 2350 | calibration->bg_fast_settle); |
| 2351 | central_bias_enabled = 1; |
| 2352 | } |
| 2353 | |
| 2354 | /* If LDO_H disabled */ |
| 2355 | if (snd_soc_read(codec, TABLA_A_PIN_CTL_OE0) & 0x80) { |
| 2356 | snd_soc_update_bits(codec, TABLA_A_PIN_CTL_OE0, 0x10, 0); |
| 2357 | snd_soc_update_bits(codec, TABLA_A_PIN_CTL_OE0, 0x80, 0x80); |
| 2358 | usleep_range(calibration->tldoh, calibration->tldoh); |
| 2359 | snd_soc_update_bits(codec, TABLA_A_PIN_CTL_OE0, 0x80, 0); |
| 2360 | |
| 2361 | if (central_bias_enabled) |
| 2362 | snd_soc_update_bits(codec, TABLA_A_PIN_CTL_OE1, 0x1, 0); |
| 2363 | } |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 2364 | |
| 2365 | snd_soc_update_bits(codec, TABLA_A_MICB_4_MBHC, 0x3, calibration->bias); |
| 2366 | |
| 2367 | tabla_enable_irq(codec->control_data, TABLA_IRQ_MBHC_INSERTION); |
| 2368 | snd_soc_update_bits(codec, TABLA_A_CDC_MBHC_INT_CTL, 0x1, 0x1); |
| 2369 | return 0; |
| 2370 | } |
| 2371 | |
Bhalchandra Gajare | 0a792b1 | 2011-09-06 16:36:58 -0700 | [diff] [blame] | 2372 | static void btn0_lpress_fn(struct work_struct *work) |
| 2373 | { |
| 2374 | struct delayed_work *delayed_work; |
| 2375 | struct tabla_priv *tabla; |
| 2376 | |
| 2377 | pr_debug("%s:\n", __func__); |
| 2378 | |
| 2379 | delayed_work = to_delayed_work(work); |
| 2380 | tabla = container_of(delayed_work, struct tabla_priv, btn0_dwork); |
| 2381 | |
| 2382 | if (tabla) { |
| 2383 | if (tabla->button_jack) { |
| 2384 | pr_debug("%s: Reporting long button press event\n", |
| 2385 | __func__); |
| 2386 | snd_soc_jack_report(tabla->button_jack, SND_JACK_BTN_0, |
| 2387 | SND_JACK_BTN_0); |
| 2388 | } |
| 2389 | } else { |
| 2390 | pr_err("%s: Bad tabla private data\n", __func__); |
| 2391 | } |
| 2392 | |
| 2393 | } |
Bhalchandra Gajare | d9ebb6c | 2011-10-03 19:54:41 -0700 | [diff] [blame] | 2394 | |
Bradley Rubin | cb1e273 | 2011-06-23 16:49:20 -0700 | [diff] [blame] | 2395 | int tabla_hs_detect(struct snd_soc_codec *codec, |
| 2396 | struct snd_soc_jack *headset_jack, struct snd_soc_jack *button_jack, |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 2397 | struct tabla_mbhc_calibration *calibration) |
| 2398 | { |
| 2399 | struct tabla_priv *tabla; |
| 2400 | if (!codec || !calibration) { |
| 2401 | pr_err("Error: no codec or calibration\n"); |
| 2402 | return -EINVAL; |
| 2403 | } |
| 2404 | tabla = snd_soc_codec_get_drvdata(codec); |
Bradley Rubin | cb1e273 | 2011-06-23 16:49:20 -0700 | [diff] [blame] | 2405 | tabla->headset_jack = headset_jack; |
| 2406 | tabla->button_jack = button_jack; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 2407 | tabla->calibration = calibration; |
Bhalchandra Gajare | 02d90cd | 2011-09-30 16:14:00 -0700 | [diff] [blame] | 2408 | tabla_get_mbhc_micbias_regs(codec, &tabla->mbhc_bias_regs); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 2409 | |
Bhalchandra Gajare | 0a792b1 | 2011-09-06 16:36:58 -0700 | [diff] [blame] | 2410 | INIT_DELAYED_WORK(&tabla->btn0_dwork, btn0_lpress_fn); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 2411 | return tabla_codec_enable_hs_detect(codec, 1); |
| 2412 | } |
| 2413 | EXPORT_SYMBOL_GPL(tabla_hs_detect); |
| 2414 | |
Bradley Rubin | cb1e273 | 2011-06-23 16:49:20 -0700 | [diff] [blame] | 2415 | static irqreturn_t tabla_dce_handler(int irq, void *data) |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 2416 | { |
| 2417 | struct tabla_priv *priv = data; |
| 2418 | struct snd_soc_codec *codec = priv->codec; |
Bhalchandra Gajare | 0a792b1 | 2011-09-06 16:36:58 -0700 | [diff] [blame] | 2419 | short bias_value; |
Bradley Rubin | cb1e273 | 2011-06-23 16:49:20 -0700 | [diff] [blame] | 2420 | |
| 2421 | tabla_disable_irq(codec->control_data, TABLA_IRQ_MBHC_REMOVAL); |
| 2422 | tabla_disable_irq(codec->control_data, TABLA_IRQ_MBHC_POTENTIAL); |
| 2423 | |
Bradley Rubin | 89ffd0a | 2011-07-21 16:04:06 -0700 | [diff] [blame] | 2424 | bias_value = tabla_codec_read_dce_result(codec); |
Bhalchandra Gajare | 30cf484 | 2011-10-17 18:12:52 -0700 | [diff] [blame^] | 2425 | pr_debug("%s: button press interrupt, bias value(DCE Read)=%d\n", |
Bhalchandra Gajare | 0a792b1 | 2011-09-06 16:36:58 -0700 | [diff] [blame] | 2426 | __func__, bias_value); |
Bradley Rubin | 89ffd0a | 2011-07-21 16:04:06 -0700 | [diff] [blame] | 2427 | |
Bhalchandra Gajare | 30cf484 | 2011-10-17 18:12:52 -0700 | [diff] [blame^] | 2428 | bias_value = tabla_codec_read_sta_result(codec); |
| 2429 | pr_debug("%s: button press interrupt, bias value(STA Read)=%d\n", |
| 2430 | __func__, bias_value); |
Bhalchandra Gajare | 0a792b1 | 2011-09-06 16:36:58 -0700 | [diff] [blame] | 2431 | /* |
| 2432 | * TODO: If button pressed is not button 0, |
| 2433 | * report the button press event immediately. |
| 2434 | */ |
| 2435 | priv->buttons_pressed |= SND_JACK_BTN_0; |
Bradley Rubin | cb1e273 | 2011-06-23 16:49:20 -0700 | [diff] [blame] | 2436 | |
Bradley Rubin | 688c66a | 2011-08-16 12:25:13 -0700 | [diff] [blame] | 2437 | snd_soc_write(codec, TABLA_A_CDC_MBHC_VOLT_B4_CTL, 0x09); |
| 2438 | msleep(100); |
Bradley Rubin | cb1e273 | 2011-06-23 16:49:20 -0700 | [diff] [blame] | 2439 | |
Bhalchandra Gajare | 0a792b1 | 2011-09-06 16:36:58 -0700 | [diff] [blame] | 2440 | schedule_delayed_work(&priv->btn0_dwork, msecs_to_jiffies(400)); |
| 2441 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 2442 | return IRQ_HANDLED; |
| 2443 | } |
| 2444 | |
Bradley Rubin | cb1e273 | 2011-06-23 16:49:20 -0700 | [diff] [blame] | 2445 | static irqreturn_t tabla_release_handler(int irq, void *data) |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 2446 | { |
| 2447 | struct tabla_priv *priv = data; |
| 2448 | struct snd_soc_codec *codec = priv->codec; |
Bhalchandra Gajare | 0a792b1 | 2011-09-06 16:36:58 -0700 | [diff] [blame] | 2449 | int ret, mic_voltage; |
| 2450 | |
Bradley Rubin | 4d09cf4 | 2011-08-17 17:59:16 -0700 | [diff] [blame] | 2451 | pr_debug("%s\n", __func__); |
| 2452 | tabla_disable_irq(codec->control_data, TABLA_IRQ_MBHC_RELEASE); |
Bhalchandra Gajare | 0a792b1 | 2011-09-06 16:36:58 -0700 | [diff] [blame] | 2453 | |
Bhalchandra Gajare | 30cf484 | 2011-10-17 18:12:52 -0700 | [diff] [blame^] | 2454 | mic_voltage = tabla_codec_read_dce_result(codec); |
| 2455 | pr_debug("%s: Microphone Voltage on release(DCE Read) = %d\n", |
| 2456 | __func__, mic_voltage); |
| 2457 | |
Bradley Rubin | cb1e273 | 2011-06-23 16:49:20 -0700 | [diff] [blame] | 2458 | if (priv->buttons_pressed & SND_JACK_BTN_0) { |
Bhalchandra Gajare | 0a792b1 | 2011-09-06 16:36:58 -0700 | [diff] [blame] | 2459 | ret = cancel_delayed_work(&priv->btn0_dwork); |
| 2460 | |
| 2461 | if (ret == 0) { |
| 2462 | |
| 2463 | pr_debug("%s: Reporting long button release event\n", |
| 2464 | __func__); |
| 2465 | if (priv->button_jack) { |
| 2466 | snd_soc_jack_report(priv->button_jack, 0, |
| 2467 | SND_JACK_BTN_0); |
| 2468 | } |
| 2469 | |
| 2470 | } else { |
| 2471 | |
| 2472 | mic_voltage = |
| 2473 | tabla_codec_measure_micbias_voltage(codec, 0); |
Bhalchandra Gajare | 30cf484 | 2011-10-17 18:12:52 -0700 | [diff] [blame^] | 2474 | pr_debug("%s: Mic Voltage on release(new STA) = %d\n", |
Bhalchandra Gajare | 0a792b1 | 2011-09-06 16:36:58 -0700 | [diff] [blame] | 2475 | __func__, mic_voltage); |
| 2476 | |
| 2477 | if (mic_voltage < -2000 || mic_voltage > -670) { |
| 2478 | pr_debug("%s: Fake buttton press interrupt\n", |
| 2479 | __func__); |
| 2480 | } else { |
| 2481 | |
| 2482 | if (priv->button_jack) { |
| 2483 | pr_debug("%s:reporting short button press and release\n", |
| 2484 | __func__); |
| 2485 | |
| 2486 | snd_soc_jack_report(priv->button_jack, |
| 2487 | SND_JACK_BTN_0, SND_JACK_BTN_0); |
| 2488 | snd_soc_jack_report(priv->button_jack, |
| 2489 | 0, SND_JACK_BTN_0); |
| 2490 | } |
| 2491 | } |
| 2492 | } |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 2493 | |
Bradley Rubin | cb1e273 | 2011-06-23 16:49:20 -0700 | [diff] [blame] | 2494 | priv->buttons_pressed &= ~SND_JACK_BTN_0; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 2495 | } |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 2496 | |
Bradley Rubin | 688c66a | 2011-08-16 12:25:13 -0700 | [diff] [blame] | 2497 | snd_soc_write(codec, TABLA_A_CDC_MBHC_VOLT_B4_CTL, 0x08); |
| 2498 | tabla_codec_start_hs_polling(codec); |
| 2499 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 2500 | return IRQ_HANDLED; |
| 2501 | } |
| 2502 | |
Bradley Rubin | cb1e273 | 2011-06-23 16:49:20 -0700 | [diff] [blame] | 2503 | static void tabla_codec_shutdown_hs_removal_detect(struct snd_soc_codec *codec) |
| 2504 | { |
| 2505 | struct tabla_priv *tabla = snd_soc_codec_get_drvdata(codec); |
| 2506 | struct tabla_mbhc_calibration *calibration = tabla->calibration; |
Bradley Rubin | cb1e273 | 2011-06-23 16:49:20 -0700 | [diff] [blame] | 2507 | |
Kiran Kandi | 6fae8bf | 2011-08-15 10:36:42 -0700 | [diff] [blame] | 2508 | if (!tabla->mclk_enabled && !tabla->mbhc_polling_active) |
Bradley Rubin | cb1e273 | 2011-06-23 16:49:20 -0700 | [diff] [blame] | 2509 | tabla_codec_enable_config_mode(codec, 1); |
| 2510 | |
| 2511 | snd_soc_update_bits(codec, TABLA_A_CDC_MBHC_CLK_CTL, 0x2, 0x2); |
| 2512 | snd_soc_update_bits(codec, TABLA_A_CDC_MBHC_B1_CTL, 0x6, 0x0); |
Bradley Rubin | cb1e273 | 2011-06-23 16:49:20 -0700 | [diff] [blame] | 2513 | |
Bhalchandra Gajare | 02d90cd | 2011-09-30 16:14:00 -0700 | [diff] [blame] | 2514 | snd_soc_update_bits(codec, |
| 2515 | tabla->mbhc_bias_regs.mbhc_reg, 0x80, 0x00); |
Bradley Rubin | cb1e273 | 2011-06-23 16:49:20 -0700 | [diff] [blame] | 2516 | usleep_range(calibration->shutdown_plug_removal, |
| 2517 | calibration->shutdown_plug_removal); |
| 2518 | |
| 2519 | snd_soc_update_bits(codec, TABLA_A_CDC_MBHC_CLK_CTL, 0xA, 0x8); |
Kiran Kandi | 6fae8bf | 2011-08-15 10:36:42 -0700 | [diff] [blame] | 2520 | if (!tabla->mclk_enabled && !tabla->mbhc_polling_active) |
Bradley Rubin | cb1e273 | 2011-06-23 16:49:20 -0700 | [diff] [blame] | 2521 | tabla_codec_enable_config_mode(codec, 0); |
| 2522 | |
| 2523 | snd_soc_write(codec, TABLA_A_MBHC_SCALING_MUX_1, 0x00); |
| 2524 | } |
| 2525 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 2526 | static void tabla_codec_shutdown_hs_polling(struct snd_soc_codec *codec) |
| 2527 | { |
| 2528 | struct tabla_priv *tabla = snd_soc_codec_get_drvdata(codec); |
Bradley Rubin | cb1e273 | 2011-06-23 16:49:20 -0700 | [diff] [blame] | 2529 | |
| 2530 | tabla_codec_shutdown_hs_removal_detect(codec); |
| 2531 | |
Kiran Kandi | 6fae8bf | 2011-08-15 10:36:42 -0700 | [diff] [blame] | 2532 | if (!tabla->mclk_enabled) { |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 2533 | snd_soc_update_bits(codec, TABLA_A_TX_COM_BIAS, 0xE0, 0x00); |
| 2534 | tabla_codec_enable_bandgap(codec, TABLA_BANDGAP_AUDIO_MODE); |
| 2535 | tabla_codec_enable_clock_block(codec, 0); |
| 2536 | } |
| 2537 | |
| 2538 | tabla->mbhc_polling_active = false; |
| 2539 | } |
| 2540 | |
Bradley Rubin | cb1e273 | 2011-06-23 16:49:20 -0700 | [diff] [blame] | 2541 | static irqreturn_t tabla_hs_insert_irq(int irq, void *data) |
| 2542 | { |
| 2543 | struct tabla_priv *priv = data; |
| 2544 | struct snd_soc_codec *codec = priv->codec; |
Bradley Rubin | 355611a | 2011-08-24 14:01:18 -0700 | [diff] [blame] | 2545 | int ldo_h_on, micb_cfilt_on; |
Bhalchandra Gajare | 343cbb0 | 2011-09-07 18:58:19 -0700 | [diff] [blame] | 2546 | short mic_voltage; |
| 2547 | short threshold_no_mic = 0xF7F6; |
| 2548 | short threshold_fake_insert = 0xFD30; |
Bhalchandra Gajare | 7fc7233 | 2011-10-13 19:01:55 -0700 | [diff] [blame] | 2549 | u8 is_removal; |
Bhalchandra Gajare | 343cbb0 | 2011-09-07 18:58:19 -0700 | [diff] [blame] | 2550 | |
Bradley Rubin | cb1e273 | 2011-06-23 16:49:20 -0700 | [diff] [blame] | 2551 | |
Bradley Rubin | 4d09cf4 | 2011-08-17 17:59:16 -0700 | [diff] [blame] | 2552 | pr_debug("%s\n", __func__); |
Bradley Rubin | cb1e273 | 2011-06-23 16:49:20 -0700 | [diff] [blame] | 2553 | tabla_disable_irq(codec->control_data, TABLA_IRQ_MBHC_INSERTION); |
Bhalchandra Gajare | 7fc7233 | 2011-10-13 19:01:55 -0700 | [diff] [blame] | 2554 | is_removal = snd_soc_read(codec, TABLA_A_CDC_MBHC_INT_CTL) & 0x02; |
| 2555 | snd_soc_update_bits(codec, TABLA_A_CDC_MBHC_INT_CTL, 0x03, 0x00); |
| 2556 | |
| 2557 | /* Turn off both HPH and MIC line schmitt triggers */ |
| 2558 | snd_soc_update_bits(codec, priv->mbhc_bias_regs.mbhc_reg, |
| 2559 | 0x90, 0x00); |
| 2560 | snd_soc_update_bits(codec, TABLA_A_MBHC_HPH, 0x13, 0x00); |
Bradley Rubin | cb1e273 | 2011-06-23 16:49:20 -0700 | [diff] [blame] | 2561 | |
Bradley Rubin | 355611a | 2011-08-24 14:01:18 -0700 | [diff] [blame] | 2562 | ldo_h_on = snd_soc_read(codec, TABLA_A_LDO_H_MODE_1) & 0x80; |
Bhalchandra Gajare | 02d90cd | 2011-09-30 16:14:00 -0700 | [diff] [blame] | 2563 | micb_cfilt_on = snd_soc_read(codec, |
| 2564 | priv->mbhc_bias_regs.cfilt_ctl) & 0x80; |
Bradley Rubin | 355611a | 2011-08-24 14:01:18 -0700 | [diff] [blame] | 2565 | |
| 2566 | if (!ldo_h_on) |
| 2567 | snd_soc_update_bits(codec, TABLA_A_LDO_H_MODE_1, 0x80, 0x80); |
| 2568 | if (!micb_cfilt_on) |
Bhalchandra Gajare | 02d90cd | 2011-09-30 16:14:00 -0700 | [diff] [blame] | 2569 | snd_soc_update_bits(codec, priv->mbhc_bias_regs.cfilt_ctl, |
| 2570 | 0x80, 0x80); |
Bradley Rubin | 355611a | 2011-08-24 14:01:18 -0700 | [diff] [blame] | 2571 | |
Bradley Rubin | cb1e273 | 2011-06-23 16:49:20 -0700 | [diff] [blame] | 2572 | usleep_range(priv->calibration->setup_plug_removal_delay, |
| 2573 | priv->calibration->setup_plug_removal_delay); |
| 2574 | |
Bhalchandra Gajare | 7fc7233 | 2011-10-13 19:01:55 -0700 | [diff] [blame] | 2575 | if (!ldo_h_on) |
| 2576 | snd_soc_update_bits(codec, TABLA_A_LDO_H_MODE_1, 0x80, 0x0); |
| 2577 | if (!micb_cfilt_on) |
| 2578 | snd_soc_update_bits(codec, priv->mbhc_bias_regs.cfilt_ctl, |
| 2579 | 0x80, 0x0); |
| 2580 | |
| 2581 | if (is_removal) { |
Bhalchandra Gajare | d9ebb6c | 2011-10-03 19:54:41 -0700 | [diff] [blame] | 2582 | /* |
| 2583 | * If headphone is removed while playback is in progress, |
| 2584 | * it is possible that micbias will be switched to VDDIO. |
| 2585 | */ |
| 2586 | if (priv->mbhc_micbias_switched) |
| 2587 | tabla_codec_switch_micbias(codec, 0); |
Bradley Rubin | cb1e273 | 2011-06-23 16:49:20 -0700 | [diff] [blame] | 2588 | if (priv->headset_jack) { |
| 2589 | pr_debug("%s: Reporting removal\n", __func__); |
| 2590 | snd_soc_jack_report(priv->headset_jack, 0, |
| 2591 | SND_JACK_HEADSET); |
| 2592 | } |
| 2593 | tabla_codec_shutdown_hs_removal_detect(codec); |
| 2594 | tabla_codec_enable_hs_detect(codec, 1); |
| 2595 | return IRQ_HANDLED; |
| 2596 | } |
| 2597 | |
Bhalchandra Gajare | 343cbb0 | 2011-09-07 18:58:19 -0700 | [diff] [blame] | 2598 | mic_voltage = tabla_codec_setup_hs_polling(codec); |
Bradley Rubin | 355611a | 2011-08-24 14:01:18 -0700 | [diff] [blame] | 2599 | |
Bhalchandra Gajare | 343cbb0 | 2011-09-07 18:58:19 -0700 | [diff] [blame] | 2600 | if (mic_voltage > threshold_fake_insert) { |
| 2601 | pr_debug("%s: Fake insertion interrupt, mic_voltage = %x\n", |
| 2602 | __func__, mic_voltage); |
| 2603 | tabla_codec_enable_hs_detect(codec, 1); |
| 2604 | } else if (mic_voltage < threshold_no_mic) { |
| 2605 | pr_debug("%s: Headphone Detected, mic_voltage = %x\n", |
| 2606 | __func__, mic_voltage); |
| 2607 | |
Bradley Rubin | cb1e273 | 2011-06-23 16:49:20 -0700 | [diff] [blame] | 2608 | if (priv->headset_jack) { |
| 2609 | pr_debug("%s: Reporting insertion %d\n", __func__, |
| 2610 | SND_JACK_HEADPHONE); |
| 2611 | snd_soc_jack_report(priv->headset_jack, |
| 2612 | SND_JACK_HEADPHONE, SND_JACK_HEADSET); |
| 2613 | } |
| 2614 | tabla_codec_shutdown_hs_polling(codec); |
| 2615 | tabla_codec_enable_hs_detect(codec, 0); |
Bhalchandra Gajare | 343cbb0 | 2011-09-07 18:58:19 -0700 | [diff] [blame] | 2616 | |
| 2617 | } else { |
| 2618 | pr_debug("%s: Headset detected, mic_voltage = %x\n", |
| 2619 | __func__, mic_voltage); |
Bradley Rubin | cb1e273 | 2011-06-23 16:49:20 -0700 | [diff] [blame] | 2620 | if (priv->headset_jack) { |
| 2621 | pr_debug("%s: Reporting insertion %d\n", __func__, |
| 2622 | SND_JACK_HEADSET); |
| 2623 | snd_soc_jack_report(priv->headset_jack, |
| 2624 | SND_JACK_HEADSET, SND_JACK_HEADSET); |
| 2625 | } |
| 2626 | tabla_codec_start_hs_polling(codec); |
| 2627 | } |
| 2628 | |
| 2629 | return IRQ_HANDLED; |
| 2630 | } |
| 2631 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 2632 | static irqreturn_t tabla_hs_remove_irq(int irq, void *data) |
| 2633 | { |
| 2634 | struct tabla_priv *priv = data; |
| 2635 | struct snd_soc_codec *codec = priv->codec; |
Bradley Rubin | 89ffd0a | 2011-07-21 16:04:06 -0700 | [diff] [blame] | 2636 | short bias_value; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 2637 | |
| 2638 | tabla_disable_irq(codec->control_data, TABLA_IRQ_MBHC_REMOVAL); |
| 2639 | tabla_disable_irq(codec->control_data, TABLA_IRQ_MBHC_POTENTIAL); |
Bradley Rubin | 4d09cf4 | 2011-08-17 17:59:16 -0700 | [diff] [blame] | 2640 | tabla_disable_irq(codec->control_data, TABLA_IRQ_MBHC_RELEASE); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 2641 | |
| 2642 | usleep_range(priv->calibration->shutdown_plug_removal, |
| 2643 | priv->calibration->shutdown_plug_removal); |
| 2644 | |
Bradley Rubin | 89ffd0a | 2011-07-21 16:04:06 -0700 | [diff] [blame] | 2645 | bias_value = tabla_codec_measure_micbias_voltage(codec, 1); |
| 2646 | pr_debug("removal interrupt, bias value is %d\n", bias_value); |
| 2647 | |
| 2648 | if (bias_value < -90) { |
| 2649 | pr_debug("False alarm, headset not actually removed\n"); |
| 2650 | tabla_codec_start_hs_polling(codec); |
| 2651 | } else { |
Bhalchandra Gajare | d9ebb6c | 2011-10-03 19:54:41 -0700 | [diff] [blame] | 2652 | /* |
| 2653 | * If this removal is not false, first check the micbias |
| 2654 | * switch status and switch it to LDOH if it is already |
| 2655 | * switched to VDDIO. |
| 2656 | */ |
| 2657 | if (priv->mbhc_micbias_switched) |
| 2658 | tabla_codec_switch_micbias(codec, 0); |
Bradley Rubin | 89ffd0a | 2011-07-21 16:04:06 -0700 | [diff] [blame] | 2659 | if (priv->headset_jack) { |
| 2660 | pr_debug("%s: Reporting removal\n", __func__); |
| 2661 | snd_soc_jack_report(priv->headset_jack, 0, |
| 2662 | SND_JACK_HEADSET); |
| 2663 | } |
| 2664 | tabla_codec_shutdown_hs_polling(codec); |
| 2665 | |
| 2666 | tabla_codec_enable_hs_detect(codec, 1); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 2667 | } |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 2668 | return IRQ_HANDLED; |
| 2669 | } |
| 2670 | |
| 2671 | static unsigned long slimbus_value; |
| 2672 | |
| 2673 | static irqreturn_t tabla_slimbus_irq(int irq, void *data) |
| 2674 | { |
| 2675 | struct tabla_priv *priv = data; |
| 2676 | struct snd_soc_codec *codec = priv->codec; |
| 2677 | int i, j; |
| 2678 | u8 val; |
| 2679 | |
| 2680 | for (i = 0; i < TABLA_SLIM_NUM_PORT_REG; i++) { |
| 2681 | slimbus_value = tabla_interface_reg_read(codec->control_data, |
| 2682 | TABLA_SLIM_PGD_PORT_INT_STATUS0 + i); |
| 2683 | for_each_set_bit(j, &slimbus_value, BITS_PER_BYTE) { |
| 2684 | val = tabla_interface_reg_read(codec->control_data, |
| 2685 | TABLA_SLIM_PGD_PORT_INT_SOURCE0 + i*8 + j); |
| 2686 | if (val & 0x1) |
| 2687 | pr_err_ratelimited("overflow error on port %x," |
| 2688 | " value %x\n", i*8 + j, val); |
| 2689 | if (val & 0x2) |
| 2690 | pr_err_ratelimited("underflow error on port %x," |
| 2691 | " value %x\n", i*8 + j, val); |
| 2692 | } |
| 2693 | tabla_interface_reg_write(codec->control_data, |
| 2694 | TABLA_SLIM_PGD_PORT_INT_CLR0 + i, 0xFF); |
| 2695 | } |
| 2696 | |
| 2697 | return IRQ_HANDLED; |
| 2698 | } |
| 2699 | |
Patrick Lai | 3043fba | 2011-08-01 14:15:57 -0700 | [diff] [blame] | 2700 | |
| 2701 | static int tabla_handle_pdata(struct tabla_priv *tabla) |
| 2702 | { |
| 2703 | struct snd_soc_codec *codec = tabla->codec; |
| 2704 | struct tabla_pdata *pdata = tabla->pdata; |
| 2705 | int k1, k2, k3, rc = 0; |
| 2706 | |
| 2707 | if (!pdata) { |
| 2708 | rc = -ENODEV; |
| 2709 | goto done; |
| 2710 | } |
| 2711 | |
| 2712 | /* Make sure settings are correct */ |
| 2713 | if ((pdata->micbias.ldoh_v > TABLA_LDOH_2P85_V) || |
| 2714 | (pdata->micbias.bias1_cfilt_sel > TABLA_CFILT3_SEL) || |
| 2715 | (pdata->micbias.bias2_cfilt_sel > TABLA_CFILT3_SEL) || |
| 2716 | (pdata->micbias.bias3_cfilt_sel > TABLA_CFILT3_SEL) || |
| 2717 | (pdata->micbias.bias4_cfilt_sel > TABLA_CFILT3_SEL)) { |
| 2718 | rc = -EINVAL; |
| 2719 | goto done; |
| 2720 | } |
| 2721 | |
| 2722 | /* figure out k value */ |
| 2723 | k1 = tabla_find_k_value(pdata->micbias.ldoh_v, |
| 2724 | pdata->micbias.cfilt1_mv); |
| 2725 | k2 = tabla_find_k_value(pdata->micbias.ldoh_v, |
| 2726 | pdata->micbias.cfilt2_mv); |
| 2727 | k3 = tabla_find_k_value(pdata->micbias.ldoh_v, |
| 2728 | pdata->micbias.cfilt3_mv); |
| 2729 | |
| 2730 | if (IS_ERR_VALUE(k1) || IS_ERR_VALUE(k2) || IS_ERR_VALUE(k3)) { |
| 2731 | rc = -EINVAL; |
| 2732 | goto done; |
| 2733 | } |
| 2734 | |
| 2735 | /* Set voltage level and always use LDO */ |
| 2736 | snd_soc_update_bits(codec, TABLA_A_LDO_H_MODE_1, 0x0C, |
| 2737 | (pdata->micbias.ldoh_v << 2)); |
| 2738 | |
| 2739 | snd_soc_update_bits(codec, TABLA_A_MICB_CFILT_1_VAL, 0xFC, |
| 2740 | (k1 << 2)); |
| 2741 | snd_soc_update_bits(codec, TABLA_A_MICB_CFILT_2_VAL, 0xFC, |
| 2742 | (k2 << 2)); |
| 2743 | snd_soc_update_bits(codec, TABLA_A_MICB_CFILT_3_VAL, 0xFC, |
| 2744 | (k3 << 2)); |
| 2745 | |
| 2746 | snd_soc_update_bits(codec, TABLA_A_MICB_1_CTL, 0x60, |
| 2747 | (pdata->micbias.bias1_cfilt_sel << 5)); |
| 2748 | snd_soc_update_bits(codec, TABLA_A_MICB_2_CTL, 0x60, |
| 2749 | (pdata->micbias.bias2_cfilt_sel << 5)); |
| 2750 | snd_soc_update_bits(codec, TABLA_A_MICB_3_CTL, 0x60, |
| 2751 | (pdata->micbias.bias3_cfilt_sel << 5)); |
| 2752 | snd_soc_update_bits(codec, TABLA_A_MICB_4_CTL, 0x60, |
| 2753 | (pdata->micbias.bias4_cfilt_sel << 5)); |
| 2754 | |
| 2755 | done: |
| 2756 | return rc; |
| 2757 | } |
| 2758 | |
Kiran Kandi | 1f6fd72 | 2011-08-11 10:36:11 -0700 | [diff] [blame] | 2759 | static const struct tabla_reg_mask_val tabla_1_1_reg_defaults[] = { |
| 2760 | |
| 2761 | /* Tabla 1.1 MICBIAS changes */ |
| 2762 | TABLA_REG_VAL(TABLA_A_MICB_1_INT_RBIAS, 0x24), |
| 2763 | TABLA_REG_VAL(TABLA_A_MICB_2_INT_RBIAS, 0x24), |
| 2764 | TABLA_REG_VAL(TABLA_A_MICB_3_INT_RBIAS, 0x24), |
| 2765 | TABLA_REG_VAL(TABLA_A_MICB_4_INT_RBIAS, 0x24), |
| 2766 | |
| 2767 | /* Tabla 1.1 HPH changes */ |
| 2768 | TABLA_REG_VAL(TABLA_A_RX_HPH_BIAS_PA, 0x57), |
| 2769 | TABLA_REG_VAL(TABLA_A_RX_HPH_BIAS_LDO, 0x56), |
| 2770 | |
| 2771 | /* Tabla 1.1 EAR PA changes */ |
| 2772 | TABLA_REG_VAL(TABLA_A_RX_EAR_BIAS_PA, 0xA6), |
| 2773 | TABLA_REG_VAL(TABLA_A_RX_EAR_GAIN, 0x02), |
| 2774 | TABLA_REG_VAL(TABLA_A_RX_EAR_VCM, 0x03), |
| 2775 | |
| 2776 | /* Tabla 1.1 Lineout_5 Changes */ |
| 2777 | TABLA_REG_VAL(TABLA_A_RX_LINE_5_GAIN, 0x10), |
| 2778 | |
| 2779 | /* Tabla 1.1 RX Changes */ |
| 2780 | TABLA_REG_VAL(TABLA_A_CDC_RX1_B5_CTL, 0x78), |
| 2781 | TABLA_REG_VAL(TABLA_A_CDC_RX2_B5_CTL, 0x78), |
| 2782 | TABLA_REG_VAL(TABLA_A_CDC_RX3_B5_CTL, 0x78), |
| 2783 | TABLA_REG_VAL(TABLA_A_CDC_RX4_B5_CTL, 0x78), |
| 2784 | TABLA_REG_VAL(TABLA_A_CDC_RX5_B5_CTL, 0x78), |
| 2785 | TABLA_REG_VAL(TABLA_A_CDC_RX6_B5_CTL, 0x78), |
| 2786 | TABLA_REG_VAL(TABLA_A_CDC_RX7_B5_CTL, 0x78), |
| 2787 | |
| 2788 | /* Tabla 1.1 RX1 and RX2 Changes */ |
| 2789 | TABLA_REG_VAL(TABLA_A_CDC_RX1_B6_CTL, 0xA0), |
| 2790 | TABLA_REG_VAL(TABLA_A_CDC_RX2_B6_CTL, 0xA0), |
| 2791 | |
| 2792 | /* Tabla 1.1 RX3 to RX7 Changes */ |
| 2793 | TABLA_REG_VAL(TABLA_A_CDC_RX3_B6_CTL, 0x80), |
| 2794 | TABLA_REG_VAL(TABLA_A_CDC_RX4_B6_CTL, 0x80), |
| 2795 | TABLA_REG_VAL(TABLA_A_CDC_RX5_B6_CTL, 0x80), |
| 2796 | TABLA_REG_VAL(TABLA_A_CDC_RX6_B6_CTL, 0x80), |
| 2797 | TABLA_REG_VAL(TABLA_A_CDC_RX7_B6_CTL, 0x80), |
| 2798 | |
| 2799 | /* Tabla 1.1 CLASSG Changes */ |
| 2800 | TABLA_REG_VAL(TABLA_A_CDC_CLSG_FREQ_THRESH_B3_CTL, 0x1B), |
| 2801 | }; |
| 2802 | |
| 2803 | static const struct tabla_reg_mask_val tabla_2_0_reg_defaults[] = { |
| 2804 | |
| 2805 | /* Tabla 2.0 MICBIAS changes */ |
| 2806 | TABLA_REG_VAL(TABLA_A_MICB_2_MBHC, 0x02), |
| 2807 | }; |
| 2808 | |
| 2809 | static void tabla_update_reg_defaults(struct snd_soc_codec *codec) |
| 2810 | { |
| 2811 | u32 i; |
| 2812 | |
| 2813 | for (i = 0; i < ARRAY_SIZE(tabla_1_1_reg_defaults); i++) |
| 2814 | snd_soc_write(codec, tabla_1_1_reg_defaults[i].reg, |
| 2815 | tabla_1_1_reg_defaults[i].val); |
| 2816 | |
| 2817 | for (i = 0; i < ARRAY_SIZE(tabla_2_0_reg_defaults); i++) |
| 2818 | snd_soc_write(codec, tabla_2_0_reg_defaults[i].reg, |
| 2819 | tabla_2_0_reg_defaults[i].val); |
| 2820 | } |
| 2821 | |
| 2822 | static const struct tabla_reg_mask_val tabla_codec_reg_init_val[] = { |
| 2823 | |
| 2824 | /* Initialize gain registers to use register gain */ |
| 2825 | {TABLA_A_RX_HPH_L_GAIN, 0x10, 0x10}, |
| 2826 | {TABLA_A_RX_HPH_R_GAIN, 0x10, 0x10}, |
| 2827 | {TABLA_A_RX_LINE_1_GAIN, 0x10, 0x10}, |
| 2828 | {TABLA_A_RX_LINE_2_GAIN, 0x10, 0x10}, |
| 2829 | {TABLA_A_RX_LINE_3_GAIN, 0x10, 0x10}, |
| 2830 | {TABLA_A_RX_LINE_4_GAIN, 0x10, 0x10}, |
| 2831 | |
| 2832 | /* Initialize mic biases to differential mode */ |
| 2833 | {TABLA_A_MICB_1_INT_RBIAS, 0x24, 0x24}, |
| 2834 | {TABLA_A_MICB_2_INT_RBIAS, 0x24, 0x24}, |
| 2835 | {TABLA_A_MICB_3_INT_RBIAS, 0x24, 0x24}, |
| 2836 | {TABLA_A_MICB_4_INT_RBIAS, 0x24, 0x24}, |
| 2837 | |
| 2838 | {TABLA_A_CDC_CONN_CLSG_CTL, 0x3C, 0x14}, |
| 2839 | |
| 2840 | /* Use 16 bit sample size for TX1 to TX6 */ |
| 2841 | {TABLA_A_CDC_CONN_TX_SB_B1_CTL, 0x30, 0x20}, |
| 2842 | {TABLA_A_CDC_CONN_TX_SB_B2_CTL, 0x30, 0x20}, |
| 2843 | {TABLA_A_CDC_CONN_TX_SB_B3_CTL, 0x30, 0x20}, |
| 2844 | {TABLA_A_CDC_CONN_TX_SB_B4_CTL, 0x30, 0x20}, |
| 2845 | {TABLA_A_CDC_CONN_TX_SB_B5_CTL, 0x30, 0x20}, |
| 2846 | {TABLA_A_CDC_CONN_TX_SB_B6_CTL, 0x30, 0x20}, |
| 2847 | |
| 2848 | /* Use 16 bit sample size for TX7 to TX10 */ |
| 2849 | {TABLA_A_CDC_CONN_TX_SB_B7_CTL, 0x60, 0x40}, |
| 2850 | {TABLA_A_CDC_CONN_TX_SB_B8_CTL, 0x60, 0x40}, |
| 2851 | {TABLA_A_CDC_CONN_TX_SB_B9_CTL, 0x60, 0x40}, |
| 2852 | {TABLA_A_CDC_CONN_TX_SB_B10_CTL, 0x60, 0x40}, |
| 2853 | |
| 2854 | /* Use 16 bit sample size for RX */ |
| 2855 | {TABLA_A_CDC_CONN_RX_SB_B1_CTL, 0xFF, 0xAA}, |
| 2856 | {TABLA_A_CDC_CONN_RX_SB_B2_CTL, 0xFF, 0xAA}, |
| 2857 | |
| 2858 | /*enable HPF filter for TX paths */ |
| 2859 | {TABLA_A_CDC_TX1_MUX_CTL, 0x8, 0x0}, |
| 2860 | {TABLA_A_CDC_TX2_MUX_CTL, 0x8, 0x0}, |
| 2861 | {TABLA_A_CDC_TX3_MUX_CTL, 0x8, 0x0}, |
| 2862 | {TABLA_A_CDC_TX4_MUX_CTL, 0x8, 0x0}, |
| 2863 | {TABLA_A_CDC_TX5_MUX_CTL, 0x8, 0x0}, |
| 2864 | {TABLA_A_CDC_TX6_MUX_CTL, 0x8, 0x0}, |
| 2865 | {TABLA_A_CDC_TX7_MUX_CTL, 0x8, 0x0}, |
| 2866 | {TABLA_A_CDC_TX8_MUX_CTL, 0x8, 0x0}, |
| 2867 | {TABLA_A_CDC_TX9_MUX_CTL, 0x8, 0x0}, |
| 2868 | {TABLA_A_CDC_TX10_MUX_CTL, 0x8, 0x0}, |
| 2869 | }; |
| 2870 | |
| 2871 | static void tabla_codec_init_reg(struct snd_soc_codec *codec) |
| 2872 | { |
| 2873 | u32 i; |
| 2874 | |
| 2875 | for (i = 0; i < ARRAY_SIZE(tabla_codec_reg_init_val); i++) |
| 2876 | snd_soc_update_bits(codec, tabla_codec_reg_init_val[i].reg, |
| 2877 | tabla_codec_reg_init_val[i].mask, |
| 2878 | tabla_codec_reg_init_val[i].val); |
| 2879 | } |
| 2880 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 2881 | static int tabla_codec_probe(struct snd_soc_codec *codec) |
| 2882 | { |
| 2883 | struct tabla *control; |
| 2884 | struct tabla_priv *tabla; |
| 2885 | struct snd_soc_dapm_context *dapm = &codec->dapm; |
| 2886 | int ret = 0; |
| 2887 | int i; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 2888 | |
| 2889 | codec->control_data = dev_get_drvdata(codec->dev->parent); |
| 2890 | control = codec->control_data; |
| 2891 | |
| 2892 | tabla = kzalloc(sizeof(struct tabla_priv), GFP_KERNEL); |
| 2893 | if (!tabla) { |
| 2894 | dev_err(codec->dev, "Failed to allocate private data\n"); |
| 2895 | return -ENOMEM; |
| 2896 | } |
| 2897 | |
Bhalchandra Gajare | 02d90cd | 2011-09-30 16:14:00 -0700 | [diff] [blame] | 2898 | /* Make sure mbhc micbias register addresses are zeroed out */ |
| 2899 | memset(&tabla->mbhc_bias_regs, 0, |
| 2900 | sizeof(struct mbhc_micbias_regs)); |
Bhalchandra Gajare | d9ebb6c | 2011-10-03 19:54:41 -0700 | [diff] [blame] | 2901 | tabla->cfilt_k_value = 0; |
| 2902 | tabla->mbhc_micbias_switched = false; |
Bhalchandra Gajare | 02d90cd | 2011-09-30 16:14:00 -0700 | [diff] [blame] | 2903 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 2904 | snd_soc_codec_set_drvdata(codec, tabla); |
| 2905 | |
Kiran Kandi | 6fae8bf | 2011-08-15 10:36:42 -0700 | [diff] [blame] | 2906 | tabla->mclk_enabled = false; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 2907 | tabla->bandgap_type = TABLA_BANDGAP_OFF; |
| 2908 | tabla->clock_active = false; |
| 2909 | tabla->config_mode_active = false; |
| 2910 | tabla->mbhc_polling_active = false; |
Bradley Rubin | cb3950a | 2011-08-18 13:07:26 -0700 | [diff] [blame] | 2911 | tabla->no_mic_headset_override = false; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 2912 | tabla->codec = codec; |
Patrick Lai | 3043fba | 2011-08-01 14:15:57 -0700 | [diff] [blame] | 2913 | tabla->pdata = dev_get_platdata(codec->dev->parent); |
| 2914 | |
| 2915 | ret = tabla_handle_pdata(tabla); |
| 2916 | |
| 2917 | if (IS_ERR_VALUE(ret)) { |
| 2918 | pr_err("%s: bad pdata\n", __func__); |
| 2919 | goto err_pdata; |
| 2920 | } |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 2921 | |
Kiran Kandi | 1f6fd72 | 2011-08-11 10:36:11 -0700 | [diff] [blame] | 2922 | tabla_update_reg_defaults(codec); |
| 2923 | tabla_codec_init_reg(codec); |
| 2924 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 2925 | /* TODO only enable bandgap when necessary in order to save power */ |
| 2926 | tabla_codec_enable_bandgap(codec, TABLA_BANDGAP_AUDIO_MODE); |
| 2927 | tabla_codec_enable_clock_block(codec, 0); |
| 2928 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 2929 | snd_soc_add_controls(codec, tabla_snd_controls, |
| 2930 | ARRAY_SIZE(tabla_snd_controls)); |
| 2931 | snd_soc_dapm_new_controls(dapm, tabla_dapm_widgets, |
| 2932 | ARRAY_SIZE(tabla_dapm_widgets)); |
| 2933 | snd_soc_dapm_add_routes(dapm, audio_map, ARRAY_SIZE(audio_map)); |
| 2934 | snd_soc_dapm_sync(dapm); |
| 2935 | |
| 2936 | ret = tabla_request_irq(codec->control_data, TABLA_IRQ_MBHC_INSERTION, |
| 2937 | tabla_hs_insert_irq, "Headset insert detect", tabla); |
| 2938 | if (ret) { |
| 2939 | pr_err("%s: Failed to request irq %d\n", __func__, |
| 2940 | TABLA_IRQ_MBHC_INSERTION); |
| 2941 | goto err_insert_irq; |
| 2942 | } |
| 2943 | tabla_disable_irq(codec->control_data, TABLA_IRQ_MBHC_INSERTION); |
| 2944 | |
| 2945 | ret = tabla_request_irq(codec->control_data, TABLA_IRQ_MBHC_REMOVAL, |
| 2946 | tabla_hs_remove_irq, "Headset remove detect", tabla); |
| 2947 | if (ret) { |
| 2948 | pr_err("%s: Failed to request irq %d\n", __func__, |
| 2949 | TABLA_IRQ_MBHC_REMOVAL); |
| 2950 | goto err_remove_irq; |
| 2951 | } |
| 2952 | tabla_disable_irq(codec->control_data, TABLA_IRQ_MBHC_REMOVAL); |
| 2953 | |
| 2954 | ret = tabla_request_irq(codec->control_data, TABLA_IRQ_MBHC_POTENTIAL, |
Bradley Rubin | cb1e273 | 2011-06-23 16:49:20 -0700 | [diff] [blame] | 2955 | tabla_dce_handler, "DC Estimation detect", tabla); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 2956 | if (ret) { |
| 2957 | pr_err("%s: Failed to request irq %d\n", __func__, |
| 2958 | TABLA_IRQ_MBHC_POTENTIAL); |
| 2959 | goto err_potential_irq; |
| 2960 | } |
| 2961 | tabla_disable_irq(codec->control_data, TABLA_IRQ_MBHC_POTENTIAL); |
| 2962 | |
Bradley Rubin | cb1e273 | 2011-06-23 16:49:20 -0700 | [diff] [blame] | 2963 | ret = tabla_request_irq(codec->control_data, TABLA_IRQ_MBHC_RELEASE, |
| 2964 | tabla_release_handler, "Button Release detect", tabla); |
| 2965 | if (ret) { |
| 2966 | pr_err("%s: Failed to request irq %d\n", __func__, |
| 2967 | TABLA_IRQ_MBHC_RELEASE); |
| 2968 | goto err_release_irq; |
| 2969 | } |
Bradley Rubin | 4d09cf4 | 2011-08-17 17:59:16 -0700 | [diff] [blame] | 2970 | tabla_disable_irq(codec->control_data, TABLA_IRQ_MBHC_RELEASE); |
Bradley Rubin | cb1e273 | 2011-06-23 16:49:20 -0700 | [diff] [blame] | 2971 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 2972 | ret = tabla_request_irq(codec->control_data, TABLA_IRQ_SLIMBUS, |
| 2973 | tabla_slimbus_irq, "SLIMBUS Slave", tabla); |
| 2974 | if (ret) { |
| 2975 | pr_err("%s: Failed to request irq %d\n", __func__, |
| 2976 | TABLA_IRQ_SLIMBUS); |
| 2977 | goto err_slimbus_irq; |
| 2978 | } |
| 2979 | |
| 2980 | for (i = 0; i < TABLA_SLIM_NUM_PORT_REG; i++) |
| 2981 | tabla_interface_reg_write(codec->control_data, |
| 2982 | TABLA_SLIM_PGD_PORT_INT_EN0 + i, 0xFF); |
| 2983 | |
Bradley Rubin | cb3950a | 2011-08-18 13:07:26 -0700 | [diff] [blame] | 2984 | #ifdef CONFIG_DEBUG_FS |
| 2985 | debug_tabla_priv = tabla; |
| 2986 | #endif |
| 2987 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 2988 | return ret; |
| 2989 | |
| 2990 | err_slimbus_irq: |
Bradley Rubin | cb1e273 | 2011-06-23 16:49:20 -0700 | [diff] [blame] | 2991 | tabla_free_irq(codec->control_data, TABLA_IRQ_MBHC_RELEASE, tabla); |
| 2992 | err_release_irq: |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 2993 | tabla_free_irq(codec->control_data, TABLA_IRQ_MBHC_POTENTIAL, tabla); |
| 2994 | err_potential_irq: |
| 2995 | tabla_free_irq(codec->control_data, TABLA_IRQ_MBHC_REMOVAL, tabla); |
| 2996 | err_remove_irq: |
| 2997 | tabla_free_irq(codec->control_data, TABLA_IRQ_MBHC_INSERTION, tabla); |
| 2998 | err_insert_irq: |
Patrick Lai | 3043fba | 2011-08-01 14:15:57 -0700 | [diff] [blame] | 2999 | err_pdata: |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 3000 | kfree(tabla); |
| 3001 | return ret; |
| 3002 | } |
| 3003 | static int tabla_codec_remove(struct snd_soc_codec *codec) |
| 3004 | { |
| 3005 | struct tabla_priv *tabla = snd_soc_codec_get_drvdata(codec); |
| 3006 | tabla_free_irq(codec->control_data, TABLA_IRQ_SLIMBUS, tabla); |
Bradley Rubin | cb1e273 | 2011-06-23 16:49:20 -0700 | [diff] [blame] | 3007 | tabla_free_irq(codec->control_data, TABLA_IRQ_MBHC_RELEASE, tabla); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 3008 | tabla_free_irq(codec->control_data, TABLA_IRQ_MBHC_POTENTIAL, tabla); |
| 3009 | tabla_free_irq(codec->control_data, TABLA_IRQ_MBHC_REMOVAL, tabla); |
| 3010 | tabla_free_irq(codec->control_data, TABLA_IRQ_MBHC_INSERTION, tabla); |
| 3011 | tabla_codec_disable_clock_block(codec); |
| 3012 | tabla_codec_enable_bandgap(codec, TABLA_BANDGAP_OFF); |
| 3013 | kfree(tabla); |
| 3014 | return 0; |
| 3015 | } |
| 3016 | static struct snd_soc_codec_driver soc_codec_dev_tabla = { |
| 3017 | .probe = tabla_codec_probe, |
| 3018 | .remove = tabla_codec_remove, |
| 3019 | .read = tabla_read, |
| 3020 | .write = tabla_write, |
| 3021 | |
| 3022 | .readable_register = tabla_readable, |
| 3023 | .volatile_register = tabla_volatile, |
| 3024 | |
| 3025 | .reg_cache_size = TABLA_CACHE_SIZE, |
| 3026 | .reg_cache_default = tabla_reg_defaults, |
| 3027 | .reg_word_size = 1, |
| 3028 | }; |
Bradley Rubin | cb3950a | 2011-08-18 13:07:26 -0700 | [diff] [blame] | 3029 | |
| 3030 | #ifdef CONFIG_DEBUG_FS |
| 3031 | static struct dentry *debugfs_poke; |
| 3032 | |
| 3033 | static int codec_debug_open(struct inode *inode, struct file *file) |
| 3034 | { |
| 3035 | file->private_data = inode->i_private; |
| 3036 | return 0; |
| 3037 | } |
| 3038 | |
| 3039 | static ssize_t codec_debug_write(struct file *filp, |
| 3040 | const char __user *ubuf, size_t cnt, loff_t *ppos) |
| 3041 | { |
| 3042 | char lbuf[32]; |
| 3043 | char *buf; |
| 3044 | int rc; |
| 3045 | |
| 3046 | if (cnt > sizeof(lbuf) - 1) |
| 3047 | return -EINVAL; |
| 3048 | |
| 3049 | rc = copy_from_user(lbuf, ubuf, cnt); |
| 3050 | if (rc) |
| 3051 | return -EFAULT; |
| 3052 | |
| 3053 | lbuf[cnt] = '\0'; |
| 3054 | buf = (char *)lbuf; |
| 3055 | debug_tabla_priv->no_mic_headset_override = (*strsep(&buf, " ") == '0') |
| 3056 | ? false : true; |
| 3057 | |
| 3058 | return rc; |
| 3059 | } |
| 3060 | |
| 3061 | static const struct file_operations codec_debug_ops = { |
| 3062 | .open = codec_debug_open, |
| 3063 | .write = codec_debug_write, |
| 3064 | }; |
| 3065 | #endif |
| 3066 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 3067 | static int __devinit tabla_probe(struct platform_device *pdev) |
| 3068 | { |
Bradley Rubin | cb3950a | 2011-08-18 13:07:26 -0700 | [diff] [blame] | 3069 | #ifdef CONFIG_DEBUG_FS |
| 3070 | debugfs_poke = debugfs_create_file("TRRS", |
| 3071 | S_IFREG | S_IRUGO, NULL, (void *) "TRRS", &codec_debug_ops); |
| 3072 | |
| 3073 | #endif |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 3074 | return snd_soc_register_codec(&pdev->dev, &soc_codec_dev_tabla, |
| 3075 | tabla_dai, ARRAY_SIZE(tabla_dai)); |
| 3076 | } |
| 3077 | static int __devexit tabla_remove(struct platform_device *pdev) |
| 3078 | { |
| 3079 | snd_soc_unregister_codec(&pdev->dev); |
Bradley Rubin | cb3950a | 2011-08-18 13:07:26 -0700 | [diff] [blame] | 3080 | |
| 3081 | #ifdef CONFIG_DEBUG_FS |
| 3082 | debugfs_remove(debugfs_poke); |
| 3083 | #endif |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 3084 | return 0; |
| 3085 | } |
| 3086 | static struct platform_driver tabla_codec_driver = { |
| 3087 | .probe = tabla_probe, |
| 3088 | .remove = tabla_remove, |
| 3089 | .driver = { |
| 3090 | .name = "tabla_codec", |
| 3091 | .owner = THIS_MODULE, |
| 3092 | }, |
| 3093 | }; |
| 3094 | |
| 3095 | static int __init tabla_codec_init(void) |
| 3096 | { |
| 3097 | return platform_driver_register(&tabla_codec_driver); |
| 3098 | } |
| 3099 | |
| 3100 | static void __exit tabla_codec_exit(void) |
| 3101 | { |
| 3102 | platform_driver_unregister(&tabla_codec_driver); |
| 3103 | } |
| 3104 | |
| 3105 | module_init(tabla_codec_init); |
| 3106 | module_exit(tabla_codec_exit); |
| 3107 | |
| 3108 | MODULE_DESCRIPTION("Tabla codec driver"); |
| 3109 | MODULE_VERSION("1.0"); |
| 3110 | MODULE_LICENSE("GPL v2"); |