Ravishankar Sarawadi | 839fcf3 | 2012-11-14 12:13:00 -0800 | [diff] [blame] | 1 | /* Copyright (c) 2012-2013, The Linux Foundation. All rights reserved. |
Kiran Kandi | c3b2440 | 2012-06-11 00:05:59 -0700 | [diff] [blame] | 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> |
| 14 | #include <linux/firmware.h> |
| 15 | #include <linux/slab.h> |
| 16 | #include <linux/platform_device.h> |
| 17 | #include <linux/device.h> |
| 18 | #include <linux/printk.h> |
| 19 | #include <linux/ratelimit.h> |
| 20 | #include <linux/debugfs.h> |
Joonwoo Park | 9bbb4d1 | 2012-11-09 19:58:11 -0800 | [diff] [blame] | 21 | #include <linux/wait.h> |
| 22 | #include <linux/bitops.h> |
Kiran Kandi | c3b2440 | 2012-06-11 00:05:59 -0700 | [diff] [blame] | 23 | #include <linux/mfd/wcd9xxx/core.h> |
| 24 | #include <linux/mfd/wcd9xxx/wcd9xxx_registers.h> |
| 25 | #include <linux/mfd/wcd9xxx/wcd9320_registers.h> |
| 26 | #include <linux/mfd/wcd9xxx/pdata.h> |
| 27 | #include <sound/pcm.h> |
| 28 | #include <sound/pcm_params.h> |
| 29 | #include <sound/soc.h> |
| 30 | #include <sound/soc-dapm.h> |
| 31 | #include <sound/tlv.h> |
| 32 | #include <linux/bitops.h> |
| 33 | #include <linux/delay.h> |
| 34 | #include <linux/pm_runtime.h> |
| 35 | #include <linux/kernel.h> |
| 36 | #include <linux/gpio.h> |
| 37 | #include "wcd9320.h" |
Joonwoo Park | a889026 | 2012-10-15 12:04:27 -0700 | [diff] [blame] | 38 | #include "wcd9xxx-resmgr.h" |
Kiran Kandi | c3b2440 | 2012-06-11 00:05:59 -0700 | [diff] [blame] | 39 | |
Joonwoo Park | 125cd4e | 2012-12-11 15:16:11 -0800 | [diff] [blame] | 40 | static atomic_t kp_taiko_priv; |
| 41 | static int spkr_drv_wrnd_param_set(const char *val, |
| 42 | const struct kernel_param *kp); |
| 43 | static int spkr_drv_wrnd = 1; |
| 44 | |
| 45 | static struct kernel_param_ops spkr_drv_wrnd_param_ops = { |
| 46 | .set = spkr_drv_wrnd_param_set, |
| 47 | .get = param_get_int, |
| 48 | }; |
| 49 | module_param_cb(spkr_drv_wrnd, &spkr_drv_wrnd_param_ops, &spkr_drv_wrnd, 0644); |
| 50 | MODULE_PARM_DESC(spkr_drv_wrnd, |
| 51 | "Run software workaround to avoid leakage on the speaker drive"); |
| 52 | |
Kiran Kandi | c3b2440 | 2012-06-11 00:05:59 -0700 | [diff] [blame] | 53 | #define WCD9320_RATES (SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |\ |
| 54 | SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |\ |
| 55 | SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_192000) |
| 56 | |
Kiran Kandi | c3b2440 | 2012-06-11 00:05:59 -0700 | [diff] [blame] | 57 | #define NUM_DECIMATORS 10 |
| 58 | #define NUM_INTERPOLATORS 7 |
| 59 | #define BITS_PER_REG 8 |
Kuirong Wang | 906ac47 | 2012-07-09 12:54:44 -0700 | [diff] [blame] | 60 | #define TAIKO_TX_PORT_NUMBER 16 |
Kiran Kandi | c3b2440 | 2012-06-11 00:05:59 -0700 | [diff] [blame] | 61 | |
Kiran Kandi | c3b2440 | 2012-06-11 00:05:59 -0700 | [diff] [blame] | 62 | #define TAIKO_I2S_MASTER_MODE_MASK 0x08 |
Venkat Sudhir | a41630a | 2012-10-27 00:57:31 -0700 | [diff] [blame] | 63 | #define TAIKO_MCLK_CLK_12P288MHZ 12288000 |
| 64 | #define TAIKO_MCLK_CLK_9P6HZ 9600000 |
Joonwoo Park | 9bbb4d1 | 2012-11-09 19:58:11 -0800 | [diff] [blame] | 65 | |
| 66 | #define TAIKO_SLIM_CLOSE_TIMEOUT 1000 |
| 67 | #define TAIKO_SLIM_IRQ_OVERFLOW (1 << 0) |
| 68 | #define TAIKO_SLIM_IRQ_UNDERFLOW (1 << 1) |
| 69 | #define TAIKO_SLIM_IRQ_PORT_CLOSED (1 << 2) |
Venkat Sudhir | a50a376 | 2012-11-26 12:12:15 -0800 | [diff] [blame] | 70 | #define TAIKO_MCLK_CLK_12P288MHZ 12288000 |
| 71 | #define TAIKO_MCLK_CLK_9P6HZ 9600000 |
Kuirong Wang | 906ac47 | 2012-07-09 12:54:44 -0700 | [diff] [blame] | 72 | enum { |
| 73 | AIF1_PB = 0, |
| 74 | AIF1_CAP, |
| 75 | AIF2_PB, |
| 76 | AIF2_CAP, |
| 77 | AIF3_PB, |
| 78 | AIF3_CAP, |
| 79 | NUM_CODEC_DAIS, |
Kiran Kandi | c3b2440 | 2012-06-11 00:05:59 -0700 | [diff] [blame] | 80 | }; |
| 81 | |
Kuirong Wang | 906ac47 | 2012-07-09 12:54:44 -0700 | [diff] [blame] | 82 | enum { |
| 83 | RX_MIX1_INP_SEL_ZERO = 0, |
| 84 | RX_MIX1_INP_SEL_SRC1, |
| 85 | RX_MIX1_INP_SEL_SRC2, |
| 86 | RX_MIX1_INP_SEL_IIR1, |
| 87 | RX_MIX1_INP_SEL_IIR2, |
| 88 | RX_MIX1_INP_SEL_RX1, |
| 89 | RX_MIX1_INP_SEL_RX2, |
| 90 | RX_MIX1_INP_SEL_RX3, |
| 91 | RX_MIX1_INP_SEL_RX4, |
| 92 | RX_MIX1_INP_SEL_RX5, |
| 93 | RX_MIX1_INP_SEL_RX6, |
| 94 | RX_MIX1_INP_SEL_RX7, |
| 95 | RX_MIX1_INP_SEL_AUXRX, |
| 96 | }; |
| 97 | |
| 98 | #define TAIKO_COMP_DIGITAL_GAIN_OFFSET 3 |
| 99 | |
Kiran Kandi | c3b2440 | 2012-06-11 00:05:59 -0700 | [diff] [blame] | 100 | static const DECLARE_TLV_DB_SCALE(digital_gain, 0, 1, 0); |
| 101 | static const DECLARE_TLV_DB_SCALE(line_gain, 0, 7, 1); |
| 102 | static const DECLARE_TLV_DB_SCALE(analog_gain, 0, 25, 1); |
| 103 | static struct snd_soc_dai_driver taiko_dai[]; |
| 104 | static const DECLARE_TLV_DB_SCALE(aux_pga_gain, 0, 2, 0); |
| 105 | |
Kiran Kandi | c3b2440 | 2012-06-11 00:05:59 -0700 | [diff] [blame] | 106 | /* Codec supports 2 IIR filters */ |
| 107 | enum { |
| 108 | IIR1 = 0, |
| 109 | IIR2, |
| 110 | IIR_MAX, |
| 111 | }; |
| 112 | /* Codec supports 5 bands */ |
| 113 | enum { |
| 114 | BAND1 = 0, |
| 115 | BAND2, |
| 116 | BAND3, |
| 117 | BAND4, |
| 118 | BAND5, |
| 119 | BAND_MAX, |
| 120 | }; |
| 121 | |
| 122 | enum { |
Joonwoo Park | c773143 | 2012-10-17 12:41:44 -0700 | [diff] [blame] | 123 | COMPANDER_0, |
| 124 | COMPANDER_1, |
Kiran Kandi | c3b2440 | 2012-06-11 00:05:59 -0700 | [diff] [blame] | 125 | COMPANDER_2, |
| 126 | COMPANDER_MAX, |
| 127 | }; |
| 128 | |
| 129 | enum { |
| 130 | COMPANDER_FS_8KHZ = 0, |
| 131 | COMPANDER_FS_16KHZ, |
| 132 | COMPANDER_FS_32KHZ, |
| 133 | COMPANDER_FS_48KHZ, |
| 134 | COMPANDER_FS_96KHZ, |
| 135 | COMPANDER_FS_192KHZ, |
| 136 | COMPANDER_FS_MAX, |
| 137 | }; |
| 138 | |
Kiran Kandi | c3b2440 | 2012-06-11 00:05:59 -0700 | [diff] [blame] | 139 | struct comp_sample_dependent_params { |
| 140 | u32 peak_det_timeout; |
| 141 | u32 rms_meter_div_fact; |
| 142 | u32 rms_meter_resamp_fact; |
| 143 | }; |
| 144 | |
Kiran Kandi | c3b2440 | 2012-06-11 00:05:59 -0700 | [diff] [blame] | 145 | struct hpf_work { |
| 146 | struct taiko_priv *taiko; |
| 147 | u32 decimator; |
| 148 | u8 tx_hpf_cut_of_freq; |
| 149 | struct delayed_work dwork; |
| 150 | }; |
| 151 | |
| 152 | static struct hpf_work tx_hpf_work[NUM_DECIMATORS]; |
| 153 | |
Kuirong Wang | 906ac47 | 2012-07-09 12:54:44 -0700 | [diff] [blame] | 154 | static const struct wcd9xxx_ch taiko_rx_chs[TAIKO_RX_MAX] = { |
| 155 | WCD9XXX_CH(16, 0), |
| 156 | WCD9XXX_CH(17, 1), |
| 157 | WCD9XXX_CH(18, 2), |
| 158 | WCD9XXX_CH(19, 3), |
| 159 | WCD9XXX_CH(20, 4), |
| 160 | WCD9XXX_CH(21, 5), |
| 161 | WCD9XXX_CH(22, 6), |
| 162 | WCD9XXX_CH(23, 7), |
| 163 | WCD9XXX_CH(24, 8), |
| 164 | WCD9XXX_CH(25, 9), |
| 165 | WCD9XXX_CH(26, 10), |
| 166 | WCD9XXX_CH(27, 11), |
| 167 | WCD9XXX_CH(28, 12), |
| 168 | }; |
| 169 | |
| 170 | static const struct wcd9xxx_ch taiko_tx_chs[TAIKO_TX_MAX] = { |
| 171 | WCD9XXX_CH(0, 0), |
| 172 | WCD9XXX_CH(1, 1), |
| 173 | WCD9XXX_CH(2, 2), |
| 174 | WCD9XXX_CH(3, 3), |
| 175 | WCD9XXX_CH(4, 4), |
| 176 | WCD9XXX_CH(5, 5), |
| 177 | WCD9XXX_CH(6, 6), |
| 178 | WCD9XXX_CH(7, 7), |
| 179 | WCD9XXX_CH(8, 8), |
| 180 | WCD9XXX_CH(9, 9), |
| 181 | WCD9XXX_CH(10, 10), |
| 182 | WCD9XXX_CH(11, 11), |
| 183 | WCD9XXX_CH(12, 12), |
| 184 | WCD9XXX_CH(13, 13), |
| 185 | WCD9XXX_CH(14, 14), |
| 186 | WCD9XXX_CH(15, 15), |
| 187 | }; |
| 188 | |
| 189 | static const u32 vport_check_table[NUM_CODEC_DAIS] = { |
| 190 | 0, /* AIF1_PB */ |
| 191 | (1 << AIF2_CAP) | (1 << AIF3_CAP), /* AIF1_CAP */ |
| 192 | 0, /* AIF2_PB */ |
| 193 | (1 << AIF1_CAP) | (1 << AIF3_CAP), /* AIF2_CAP */ |
| 194 | 0, /* AIF2_PB */ |
| 195 | (1 << AIF1_CAP) | (1 << AIF2_CAP), /* AIF2_CAP */ |
| 196 | }; |
| 197 | |
Venkat Sudhir | 96dd28c | 2012-12-04 17:00:19 -0800 | [diff] [blame] | 198 | static const u32 vport_i2s_check_table[NUM_CODEC_DAIS] = { |
| 199 | 0, /* AIF1_PB */ |
| 200 | 0, /* AIF1_CAP */ |
Venkat Sudhir | 994193b | 2012-12-17 17:30:51 -0800 | [diff] [blame] | 201 | 0, /* AIF2_PB */ |
| 202 | 0, /* AIF2_CAP */ |
Venkat Sudhir | 96dd28c | 2012-12-04 17:00:19 -0800 | [diff] [blame] | 203 | }; |
| 204 | |
Kiran Kandi | c3b2440 | 2012-06-11 00:05:59 -0700 | [diff] [blame] | 205 | struct taiko_priv { |
| 206 | struct snd_soc_codec *codec; |
Kiran Kandi | c3b2440 | 2012-06-11 00:05:59 -0700 | [diff] [blame] | 207 | u32 adc_count; |
Kiran Kandi | c3b2440 | 2012-06-11 00:05:59 -0700 | [diff] [blame] | 208 | u32 rx_bias_count; |
| 209 | s32 dmic_1_2_clk_cnt; |
| 210 | s32 dmic_3_4_clk_cnt; |
| 211 | s32 dmic_5_6_clk_cnt; |
| 212 | |
Kiran Kandi | c3b2440 | 2012-06-11 00:05:59 -0700 | [diff] [blame] | 213 | u32 anc_slot; |
| 214 | |
Kiran Kandi | c3b2440 | 2012-06-11 00:05:59 -0700 | [diff] [blame] | 215 | /*track taiko interface type*/ |
| 216 | u8 intf_type; |
| 217 | |
Kiran Kandi | c3b2440 | 2012-06-11 00:05:59 -0700 | [diff] [blame] | 218 | /* num of slim ports required */ |
Kuirong Wang | 906ac47 | 2012-07-09 12:54:44 -0700 | [diff] [blame] | 219 | struct wcd9xxx_codec_dai_data dai[NUM_CODEC_DAIS]; |
Kiran Kandi | c3b2440 | 2012-06-11 00:05:59 -0700 | [diff] [blame] | 220 | |
| 221 | /*compander*/ |
| 222 | int comp_enabled[COMPANDER_MAX]; |
| 223 | u32 comp_fs[COMPANDER_MAX]; |
| 224 | |
| 225 | /* Maintain the status of AUX PGA */ |
| 226 | int aux_pga_cnt; |
| 227 | u8 aux_l_gain; |
| 228 | u8 aux_r_gain; |
| 229 | |
Joonwoo Park | 125cd4e | 2012-12-11 15:16:11 -0800 | [diff] [blame] | 230 | bool spkr_pa_widget_on; |
| 231 | |
Joonwoo Park | a889026 | 2012-10-15 12:04:27 -0700 | [diff] [blame] | 232 | /* resmgr module */ |
| 233 | struct wcd9xxx_resmgr resmgr; |
| 234 | /* mbhc module */ |
| 235 | struct wcd9xxx_mbhc mbhc; |
Kiran Kandi | c3b2440 | 2012-06-11 00:05:59 -0700 | [diff] [blame] | 236 | }; |
| 237 | |
Kiran Kandi | c3b2440 | 2012-06-11 00:05:59 -0700 | [diff] [blame] | 238 | static const u32 comp_shift[] = { |
Joonwoo Park | c773143 | 2012-10-17 12:41:44 -0700 | [diff] [blame] | 239 | 4, /* Compander 0's clock source is on interpolator 7 */ |
Kiran Kandi | c3b2440 | 2012-06-11 00:05:59 -0700 | [diff] [blame] | 240 | 0, |
| 241 | 2, |
| 242 | }; |
| 243 | |
| 244 | static const int comp_rx_path[] = { |
| 245 | COMPANDER_1, |
| 246 | COMPANDER_1, |
| 247 | COMPANDER_2, |
| 248 | COMPANDER_2, |
| 249 | COMPANDER_2, |
| 250 | COMPANDER_2, |
Joonwoo Park | c773143 | 2012-10-17 12:41:44 -0700 | [diff] [blame] | 251 | COMPANDER_0, |
Kiran Kandi | c3b2440 | 2012-06-11 00:05:59 -0700 | [diff] [blame] | 252 | COMPANDER_MAX, |
| 253 | }; |
| 254 | |
| 255 | static const struct comp_sample_dependent_params comp_samp_params[] = { |
| 256 | { |
Joonwoo Park | c773143 | 2012-10-17 12:41:44 -0700 | [diff] [blame] | 257 | /* 8 Khz */ |
| 258 | .peak_det_timeout = 0x02, |
| 259 | .rms_meter_div_fact = 0x09, |
| 260 | .rms_meter_resamp_fact = 0x06, |
Kiran Kandi | c3b2440 | 2012-06-11 00:05:59 -0700 | [diff] [blame] | 261 | }, |
| 262 | { |
Joonwoo Park | c773143 | 2012-10-17 12:41:44 -0700 | [diff] [blame] | 263 | /* 16 Khz */ |
| 264 | .peak_det_timeout = 0x03, |
| 265 | .rms_meter_div_fact = 0x0A, |
| 266 | .rms_meter_resamp_fact = 0x0C, |
| 267 | }, |
| 268 | { |
| 269 | /* 32 Khz */ |
| 270 | .peak_det_timeout = 0x05, |
| 271 | .rms_meter_div_fact = 0x0B, |
| 272 | .rms_meter_resamp_fact = 0x1E, |
| 273 | }, |
| 274 | { |
| 275 | /* 48 Khz */ |
| 276 | .peak_det_timeout = 0x05, |
| 277 | .rms_meter_div_fact = 0x0B, |
Kiran Kandi | c3b2440 | 2012-06-11 00:05:59 -0700 | [diff] [blame] | 278 | .rms_meter_resamp_fact = 0x28, |
| 279 | }, |
Kiran Kandi | c3b2440 | 2012-06-11 00:05:59 -0700 | [diff] [blame] | 280 | { |
Joonwoo Park | c773143 | 2012-10-17 12:41:44 -0700 | [diff] [blame] | 281 | /* 96 Khz */ |
| 282 | .peak_det_timeout = 0x06, |
| 283 | .rms_meter_div_fact = 0x0C, |
| 284 | .rms_meter_resamp_fact = 0x50, |
Kiran Kandi | c3b2440 | 2012-06-11 00:05:59 -0700 | [diff] [blame] | 285 | }, |
Kiran Kandi | c3b2440 | 2012-06-11 00:05:59 -0700 | [diff] [blame] | 286 | { |
Joonwoo Park | c773143 | 2012-10-17 12:41:44 -0700 | [diff] [blame] | 287 | /* 192 Khz */ |
| 288 | .peak_det_timeout = 0x07, |
| 289 | .rms_meter_div_fact = 0xD, |
| 290 | .rms_meter_resamp_fact = 0xA0, |
Kiran Kandi | c3b2440 | 2012-06-11 00:05:59 -0700 | [diff] [blame] | 291 | }, |
| 292 | }; |
| 293 | |
| 294 | static unsigned short rx_digital_gain_reg[] = { |
| 295 | TAIKO_A_CDC_RX1_VOL_CTL_B2_CTL, |
| 296 | TAIKO_A_CDC_RX2_VOL_CTL_B2_CTL, |
| 297 | TAIKO_A_CDC_RX3_VOL_CTL_B2_CTL, |
| 298 | TAIKO_A_CDC_RX4_VOL_CTL_B2_CTL, |
| 299 | TAIKO_A_CDC_RX5_VOL_CTL_B2_CTL, |
| 300 | TAIKO_A_CDC_RX6_VOL_CTL_B2_CTL, |
| 301 | TAIKO_A_CDC_RX7_VOL_CTL_B2_CTL, |
| 302 | }; |
| 303 | |
| 304 | |
| 305 | static unsigned short tx_digital_gain_reg[] = { |
| 306 | TAIKO_A_CDC_TX1_VOL_CTL_GAIN, |
| 307 | TAIKO_A_CDC_TX2_VOL_CTL_GAIN, |
| 308 | TAIKO_A_CDC_TX3_VOL_CTL_GAIN, |
| 309 | TAIKO_A_CDC_TX4_VOL_CTL_GAIN, |
| 310 | TAIKO_A_CDC_TX5_VOL_CTL_GAIN, |
| 311 | TAIKO_A_CDC_TX6_VOL_CTL_GAIN, |
| 312 | TAIKO_A_CDC_TX7_VOL_CTL_GAIN, |
| 313 | TAIKO_A_CDC_TX8_VOL_CTL_GAIN, |
| 314 | TAIKO_A_CDC_TX9_VOL_CTL_GAIN, |
| 315 | TAIKO_A_CDC_TX10_VOL_CTL_GAIN, |
| 316 | }; |
| 317 | |
Joonwoo Park | 125cd4e | 2012-12-11 15:16:11 -0800 | [diff] [blame] | 318 | static int spkr_drv_wrnd_param_set(const char *val, |
| 319 | const struct kernel_param *kp) |
| 320 | { |
| 321 | struct snd_soc_codec *codec; |
| 322 | int ret, old; |
| 323 | struct taiko_priv *priv; |
| 324 | |
| 325 | priv = (struct taiko_priv *)atomic_read(&kp_taiko_priv); |
| 326 | if (!priv) { |
| 327 | pr_debug("%s: codec isn't yet registered\n", __func__); |
| 328 | return 0; |
| 329 | } |
| 330 | |
| 331 | WCD9XXX_BCL_LOCK(&priv->resmgr); |
| 332 | old = spkr_drv_wrnd; |
| 333 | ret = param_set_int(val, kp); |
| 334 | if (ret) { |
| 335 | WCD9XXX_BCL_UNLOCK(&priv->resmgr); |
| 336 | return ret; |
| 337 | } |
| 338 | |
| 339 | pr_debug("%s: spkr_drv_wrnd %d -> %d\n", __func__, old, spkr_drv_wrnd); |
| 340 | codec = priv->codec; |
| 341 | if (old == 0 && spkr_drv_wrnd == 1) { |
| 342 | wcd9xxx_resmgr_get_bandgap(&priv->resmgr, |
| 343 | WCD9XXX_BANDGAP_AUDIO_MODE); |
| 344 | snd_soc_update_bits(codec, TAIKO_A_SPKR_DRV_EN, 0x80, 0x80); |
| 345 | } else if (old == 1 && spkr_drv_wrnd == 0) { |
| 346 | wcd9xxx_resmgr_put_bandgap(&priv->resmgr, |
| 347 | WCD9XXX_BANDGAP_AUDIO_MODE); |
| 348 | if (!priv->spkr_pa_widget_on) |
| 349 | snd_soc_update_bits(codec, TAIKO_A_SPKR_DRV_EN, 0x80, |
| 350 | 0x00); |
| 351 | } |
| 352 | |
| 353 | WCD9XXX_BCL_UNLOCK(&priv->resmgr); |
| 354 | return 0; |
| 355 | } |
| 356 | |
Kiran Kandi | 4c56c59 | 2012-07-25 11:04:55 -0700 | [diff] [blame] | 357 | static int taiko_codec_enable_class_h_clk(struct snd_soc_dapm_widget *w, |
Kiran Kandi | c3b2440 | 2012-06-11 00:05:59 -0700 | [diff] [blame] | 358 | struct snd_kcontrol *kcontrol, int event) |
| 359 | { |
| 360 | struct snd_soc_codec *codec = w->codec; |
| 361 | |
Kiran Kandi | 4c56c59 | 2012-07-25 11:04:55 -0700 | [diff] [blame] | 362 | pr_debug("%s %s %d\n", __func__, w->name, event); |
Kiran Kandi | c3b2440 | 2012-06-11 00:05:59 -0700 | [diff] [blame] | 363 | |
Kiran Kandi | c3b2440 | 2012-06-11 00:05:59 -0700 | [diff] [blame] | 364 | switch (event) { |
Kiran Kandi | 4c56c59 | 2012-07-25 11:04:55 -0700 | [diff] [blame] | 365 | case SND_SOC_DAPM_PRE_PMU: |
| 366 | snd_soc_update_bits(codec, TAIKO_A_CDC_CLSH_B1_CTL, 0x01, 0x01); |
Kiran Kandi | c3b2440 | 2012-06-11 00:05:59 -0700 | [diff] [blame] | 367 | break; |
| 368 | case SND_SOC_DAPM_PRE_PMD: |
Kiran Kandi | 4c56c59 | 2012-07-25 11:04:55 -0700 | [diff] [blame] | 369 | snd_soc_update_bits(codec, TAIKO_A_BUCK_MODE_1, 0x80, 0x00); |
| 370 | snd_soc_update_bits(codec, TAIKO_A_CDC_CLSH_B1_CTL, 0x01, 0x00); |
Kiran Kandi | c3b2440 | 2012-06-11 00:05:59 -0700 | [diff] [blame] | 371 | break; |
| 372 | } |
| 373 | return 0; |
| 374 | } |
| 375 | |
Kiran Kandi | 4c56c59 | 2012-07-25 11:04:55 -0700 | [diff] [blame] | 376 | static int taiko_codec_enable_class_h(struct snd_soc_dapm_widget *w, |
| 377 | struct snd_kcontrol *kcontrol, int event) |
| 378 | { |
| 379 | struct snd_soc_codec *codec = w->codec; |
| 380 | |
| 381 | pr_debug("%s %s %d\n", __func__, w->name, event); |
| 382 | |
| 383 | switch (event) { |
| 384 | case SND_SOC_DAPM_POST_PMU: |
| 385 | snd_soc_update_bits(codec, TAIKO_A_BUCK_MODE_5, 0x02, 0x02); |
| 386 | snd_soc_update_bits(codec, TAIKO_A_BUCK_MODE_4, 0xFF, 0xFF); |
| 387 | snd_soc_update_bits(codec, TAIKO_A_BUCK_MODE_1, 0x04, 0x04); |
Tanya Finkel | fe63446 | 2012-10-23 22:12:07 +0200 | [diff] [blame] | 388 | snd_soc_update_bits(codec, TAIKO_A_BUCK_MODE_1, 0x04, 0x00); |
Kiran Kandi | 4c56c59 | 2012-07-25 11:04:55 -0700 | [diff] [blame] | 389 | snd_soc_update_bits(codec, TAIKO_A_BUCK_MODE_3, 0x04, 0x00); |
| 390 | snd_soc_update_bits(codec, TAIKO_A_BUCK_MODE_3, 0x08, 0x00); |
| 391 | snd_soc_update_bits(codec, TAIKO_A_BUCK_MODE_1, 0x80, 0x80); |
| 392 | usleep_range(1000, 1000); |
| 393 | break; |
| 394 | } |
| 395 | return 0; |
| 396 | } |
| 397 | |
| 398 | static int taiko_codec_enable_charge_pump(struct snd_soc_dapm_widget *w, |
| 399 | struct snd_kcontrol *kcontrol, int event) |
| 400 | { |
Tanya Finkel | fe63446 | 2012-10-23 22:12:07 +0200 | [diff] [blame] | 401 | struct snd_soc_codec *codec = w->codec; |
| 402 | |
Kiran Kandi | 4c56c59 | 2012-07-25 11:04:55 -0700 | [diff] [blame] | 403 | pr_debug("%s %s %d\n", __func__, w->name, event); |
| 404 | |
| 405 | switch (event) { |
Tanya Finkel | fe63446 | 2012-10-23 22:12:07 +0200 | [diff] [blame] | 406 | case SND_SOC_DAPM_PRE_PMU: |
| 407 | snd_soc_update_bits(codec, w->reg, 0x01, 0x01); |
| 408 | snd_soc_update_bits(codec, w->reg, 0x40, 0x00); |
Tanya Finkel | fe63446 | 2012-10-23 22:12:07 +0200 | [diff] [blame] | 409 | break; |
| 410 | |
Kiran Kandi | 4c56c59 | 2012-07-25 11:04:55 -0700 | [diff] [blame] | 411 | case SND_SOC_DAPM_POST_PMU: |
| 412 | usleep_range(1000, 1000); |
| 413 | break; |
Tanya Finkel | fe63446 | 2012-10-23 22:12:07 +0200 | [diff] [blame] | 414 | |
| 415 | case SND_SOC_DAPM_PRE_PMD: |
| 416 | snd_soc_update_bits(codec, w->reg, 0x01, 0x00); |
| 417 | snd_soc_update_bits(codec, w->reg, 0x40, 0x40); |
Tanya Finkel | fe63446 | 2012-10-23 22:12:07 +0200 | [diff] [blame] | 418 | break; |
Kiran Kandi | 4c56c59 | 2012-07-25 11:04:55 -0700 | [diff] [blame] | 419 | } |
| 420 | return 0; |
| 421 | } |
| 422 | |
| 423 | |
Kiran Kandi | c3b2440 | 2012-06-11 00:05:59 -0700 | [diff] [blame] | 424 | static int taiko_get_anc_slot(struct snd_kcontrol *kcontrol, |
| 425 | struct snd_ctl_elem_value *ucontrol) |
| 426 | { |
| 427 | struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); |
| 428 | struct taiko_priv *taiko = snd_soc_codec_get_drvdata(codec); |
| 429 | ucontrol->value.integer.value[0] = taiko->anc_slot; |
| 430 | return 0; |
| 431 | } |
| 432 | |
| 433 | static int taiko_put_anc_slot(struct snd_kcontrol *kcontrol, |
| 434 | struct snd_ctl_elem_value *ucontrol) |
| 435 | { |
| 436 | struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); |
| 437 | struct taiko_priv *taiko = snd_soc_codec_get_drvdata(codec); |
| 438 | taiko->anc_slot = ucontrol->value.integer.value[0]; |
| 439 | return 0; |
| 440 | } |
| 441 | |
| 442 | static int taiko_pa_gain_get(struct snd_kcontrol *kcontrol, |
| 443 | struct snd_ctl_elem_value *ucontrol) |
| 444 | { |
| 445 | u8 ear_pa_gain; |
| 446 | struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); |
| 447 | |
| 448 | ear_pa_gain = snd_soc_read(codec, TAIKO_A_RX_EAR_GAIN); |
| 449 | |
| 450 | ear_pa_gain = ear_pa_gain >> 5; |
| 451 | |
| 452 | if (ear_pa_gain == 0x00) { |
| 453 | ucontrol->value.integer.value[0] = 0; |
| 454 | } else if (ear_pa_gain == 0x04) { |
| 455 | ucontrol->value.integer.value[0] = 1; |
| 456 | } else { |
| 457 | pr_err("%s: ERROR: Unsupported Ear Gain = 0x%x\n", |
| 458 | __func__, ear_pa_gain); |
| 459 | return -EINVAL; |
| 460 | } |
| 461 | |
| 462 | pr_debug("%s: ear_pa_gain = 0x%x\n", __func__, ear_pa_gain); |
| 463 | |
| 464 | return 0; |
| 465 | } |
| 466 | |
| 467 | static int taiko_pa_gain_put(struct snd_kcontrol *kcontrol, |
| 468 | struct snd_ctl_elem_value *ucontrol) |
| 469 | { |
| 470 | u8 ear_pa_gain; |
| 471 | struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); |
| 472 | |
| 473 | pr_debug("%s: ucontrol->value.integer.value[0] = %ld\n", __func__, |
| 474 | ucontrol->value.integer.value[0]); |
| 475 | |
| 476 | switch (ucontrol->value.integer.value[0]) { |
| 477 | case 0: |
| 478 | ear_pa_gain = 0x00; |
| 479 | break; |
| 480 | case 1: |
| 481 | ear_pa_gain = 0x80; |
| 482 | break; |
| 483 | default: |
| 484 | return -EINVAL; |
| 485 | } |
| 486 | |
| 487 | snd_soc_update_bits(codec, TAIKO_A_RX_EAR_GAIN, 0xE0, ear_pa_gain); |
| 488 | return 0; |
| 489 | } |
| 490 | |
| 491 | static int taiko_get_iir_enable_audio_mixer( |
| 492 | struct snd_kcontrol *kcontrol, |
| 493 | struct snd_ctl_elem_value *ucontrol) |
| 494 | { |
| 495 | struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); |
| 496 | int iir_idx = ((struct soc_multi_mixer_control *) |
| 497 | kcontrol->private_value)->reg; |
| 498 | int band_idx = ((struct soc_multi_mixer_control *) |
| 499 | kcontrol->private_value)->shift; |
| 500 | |
| 501 | ucontrol->value.integer.value[0] = |
Ben Romberger | 205e14d | 2013-02-06 12:31:53 -0800 | [diff] [blame] | 502 | (snd_soc_read(codec, (TAIKO_A_CDC_IIR1_CTL + 16 * iir_idx)) & |
| 503 | (1 << band_idx)) != 0; |
Kiran Kandi | c3b2440 | 2012-06-11 00:05:59 -0700 | [diff] [blame] | 504 | |
| 505 | pr_debug("%s: IIR #%d band #%d enable %d\n", __func__, |
| 506 | iir_idx, band_idx, |
| 507 | (uint32_t)ucontrol->value.integer.value[0]); |
| 508 | return 0; |
| 509 | } |
| 510 | |
| 511 | static int taiko_put_iir_enable_audio_mixer( |
| 512 | struct snd_kcontrol *kcontrol, |
| 513 | struct snd_ctl_elem_value *ucontrol) |
| 514 | { |
| 515 | struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); |
| 516 | int iir_idx = ((struct soc_multi_mixer_control *) |
| 517 | kcontrol->private_value)->reg; |
| 518 | int band_idx = ((struct soc_multi_mixer_control *) |
| 519 | kcontrol->private_value)->shift; |
| 520 | int value = ucontrol->value.integer.value[0]; |
| 521 | |
| 522 | /* Mask first 5 bits, 6-8 are reserved */ |
| 523 | snd_soc_update_bits(codec, (TAIKO_A_CDC_IIR1_CTL + 16 * iir_idx), |
| 524 | (1 << band_idx), (value << band_idx)); |
| 525 | |
| 526 | pr_debug("%s: IIR #%d band #%d enable %d\n", __func__, |
Ben Romberger | 205e14d | 2013-02-06 12:31:53 -0800 | [diff] [blame] | 527 | iir_idx, band_idx, |
| 528 | ((snd_soc_read(codec, (TAIKO_A_CDC_IIR1_CTL + 16 * iir_idx)) & |
| 529 | (1 << band_idx)) != 0)); |
Kiran Kandi | c3b2440 | 2012-06-11 00:05:59 -0700 | [diff] [blame] | 530 | return 0; |
| 531 | } |
| 532 | static uint32_t get_iir_band_coeff(struct snd_soc_codec *codec, |
| 533 | int iir_idx, int band_idx, |
| 534 | int coeff_idx) |
| 535 | { |
Ben Romberger | 205e14d | 2013-02-06 12:31:53 -0800 | [diff] [blame] | 536 | uint32_t value = 0; |
| 537 | |
Kiran Kandi | c3b2440 | 2012-06-11 00:05:59 -0700 | [diff] [blame] | 538 | /* Address does not automatically update if reading */ |
| 539 | snd_soc_write(codec, |
| 540 | (TAIKO_A_CDC_IIR1_COEF_B1_CTL + 16 * iir_idx), |
Ben Romberger | 205e14d | 2013-02-06 12:31:53 -0800 | [diff] [blame] | 541 | ((band_idx * BAND_MAX + coeff_idx) |
| 542 | * sizeof(uint32_t)) & 0x7F); |
| 543 | |
| 544 | value |= snd_soc_read(codec, |
| 545 | (TAIKO_A_CDC_IIR1_COEF_B2_CTL + 16 * iir_idx)); |
| 546 | |
| 547 | snd_soc_write(codec, |
| 548 | (TAIKO_A_CDC_IIR1_COEF_B1_CTL + 16 * iir_idx), |
| 549 | ((band_idx * BAND_MAX + coeff_idx) |
| 550 | * sizeof(uint32_t) + 1) & 0x7F); |
| 551 | |
| 552 | value |= (snd_soc_read(codec, |
| 553 | (TAIKO_A_CDC_IIR1_COEF_B2_CTL + 16 * iir_idx)) << 8); |
| 554 | |
| 555 | snd_soc_write(codec, |
| 556 | (TAIKO_A_CDC_IIR1_COEF_B1_CTL + 16 * iir_idx), |
| 557 | ((band_idx * BAND_MAX + coeff_idx) |
| 558 | * sizeof(uint32_t) + 2) & 0x7F); |
| 559 | |
| 560 | value |= (snd_soc_read(codec, |
| 561 | (TAIKO_A_CDC_IIR1_COEF_B2_CTL + 16 * iir_idx)) << 16); |
| 562 | |
| 563 | snd_soc_write(codec, |
| 564 | (TAIKO_A_CDC_IIR1_COEF_B1_CTL + 16 * iir_idx), |
| 565 | ((band_idx * BAND_MAX + coeff_idx) |
| 566 | * sizeof(uint32_t) + 3) & 0x7F); |
Kiran Kandi | c3b2440 | 2012-06-11 00:05:59 -0700 | [diff] [blame] | 567 | |
| 568 | /* Mask bits top 2 bits since they are reserved */ |
Ben Romberger | 205e14d | 2013-02-06 12:31:53 -0800 | [diff] [blame] | 569 | value |= ((snd_soc_read(codec, |
| 570 | (TAIKO_A_CDC_IIR1_COEF_B2_CTL + 16 * iir_idx)) & 0x3F) << 24); |
| 571 | |
| 572 | return value; |
Kiran Kandi | c3b2440 | 2012-06-11 00:05:59 -0700 | [diff] [blame] | 573 | } |
| 574 | |
| 575 | static int taiko_get_iir_band_audio_mixer( |
| 576 | struct snd_kcontrol *kcontrol, |
| 577 | struct snd_ctl_elem_value *ucontrol) |
| 578 | { |
| 579 | struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); |
| 580 | int iir_idx = ((struct soc_multi_mixer_control *) |
| 581 | kcontrol->private_value)->reg; |
| 582 | int band_idx = ((struct soc_multi_mixer_control *) |
| 583 | kcontrol->private_value)->shift; |
| 584 | |
| 585 | ucontrol->value.integer.value[0] = |
| 586 | get_iir_band_coeff(codec, iir_idx, band_idx, 0); |
| 587 | ucontrol->value.integer.value[1] = |
| 588 | get_iir_band_coeff(codec, iir_idx, band_idx, 1); |
| 589 | ucontrol->value.integer.value[2] = |
| 590 | get_iir_band_coeff(codec, iir_idx, band_idx, 2); |
| 591 | ucontrol->value.integer.value[3] = |
| 592 | get_iir_band_coeff(codec, iir_idx, band_idx, 3); |
| 593 | ucontrol->value.integer.value[4] = |
| 594 | get_iir_band_coeff(codec, iir_idx, band_idx, 4); |
| 595 | |
| 596 | pr_debug("%s: IIR #%d band #%d b0 = 0x%x\n" |
| 597 | "%s: IIR #%d band #%d b1 = 0x%x\n" |
| 598 | "%s: IIR #%d band #%d b2 = 0x%x\n" |
| 599 | "%s: IIR #%d band #%d a1 = 0x%x\n" |
| 600 | "%s: IIR #%d band #%d a2 = 0x%x\n", |
| 601 | __func__, iir_idx, band_idx, |
| 602 | (uint32_t)ucontrol->value.integer.value[0], |
| 603 | __func__, iir_idx, band_idx, |
| 604 | (uint32_t)ucontrol->value.integer.value[1], |
| 605 | __func__, iir_idx, band_idx, |
| 606 | (uint32_t)ucontrol->value.integer.value[2], |
| 607 | __func__, iir_idx, band_idx, |
| 608 | (uint32_t)ucontrol->value.integer.value[3], |
| 609 | __func__, iir_idx, band_idx, |
| 610 | (uint32_t)ucontrol->value.integer.value[4]); |
| 611 | return 0; |
| 612 | } |
| 613 | |
| 614 | static void set_iir_band_coeff(struct snd_soc_codec *codec, |
| 615 | int iir_idx, int band_idx, |
Ben Romberger | 205e14d | 2013-02-06 12:31:53 -0800 | [diff] [blame] | 616 | uint32_t value) |
Kiran Kandi | c3b2440 | 2012-06-11 00:05:59 -0700 | [diff] [blame] | 617 | { |
Kiran Kandi | c3b2440 | 2012-06-11 00:05:59 -0700 | [diff] [blame] | 618 | snd_soc_write(codec, |
Ben Romberger | 205e14d | 2013-02-06 12:31:53 -0800 | [diff] [blame] | 619 | (TAIKO_A_CDC_IIR1_COEF_B2_CTL + 16 * iir_idx), |
| 620 | (value & 0xFF)); |
| 621 | |
| 622 | snd_soc_write(codec, |
| 623 | (TAIKO_A_CDC_IIR1_COEF_B2_CTL + 16 * iir_idx), |
| 624 | (value >> 8) & 0xFF); |
| 625 | |
| 626 | snd_soc_write(codec, |
| 627 | (TAIKO_A_CDC_IIR1_COEF_B2_CTL + 16 * iir_idx), |
| 628 | (value >> 16) & 0xFF); |
Kiran Kandi | c3b2440 | 2012-06-11 00:05:59 -0700 | [diff] [blame] | 629 | |
| 630 | /* Mask top 2 bits, 7-8 are reserved */ |
| 631 | snd_soc_write(codec, |
| 632 | (TAIKO_A_CDC_IIR1_COEF_B2_CTL + 16 * iir_idx), |
| 633 | (value >> 24) & 0x3F); |
Kiran Kandi | c3b2440 | 2012-06-11 00:05:59 -0700 | [diff] [blame] | 634 | } |
| 635 | |
| 636 | static int taiko_put_iir_band_audio_mixer( |
| 637 | struct snd_kcontrol *kcontrol, |
| 638 | struct snd_ctl_elem_value *ucontrol) |
| 639 | { |
| 640 | struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); |
| 641 | int iir_idx = ((struct soc_multi_mixer_control *) |
| 642 | kcontrol->private_value)->reg; |
| 643 | int band_idx = ((struct soc_multi_mixer_control *) |
| 644 | kcontrol->private_value)->shift; |
| 645 | |
Ben Romberger | 205e14d | 2013-02-06 12:31:53 -0800 | [diff] [blame] | 646 | /* Mask top bit it is reserved */ |
| 647 | /* Updates addr automatically for each B2 write */ |
| 648 | snd_soc_write(codec, |
| 649 | (TAIKO_A_CDC_IIR1_COEF_B1_CTL + 16 * iir_idx), |
| 650 | (band_idx * BAND_MAX * sizeof(uint32_t)) & 0x7F); |
| 651 | |
| 652 | set_iir_band_coeff(codec, iir_idx, band_idx, |
Kiran Kandi | c3b2440 | 2012-06-11 00:05:59 -0700 | [diff] [blame] | 653 | ucontrol->value.integer.value[0]); |
Ben Romberger | 205e14d | 2013-02-06 12:31:53 -0800 | [diff] [blame] | 654 | set_iir_band_coeff(codec, iir_idx, band_idx, |
Kiran Kandi | c3b2440 | 2012-06-11 00:05:59 -0700 | [diff] [blame] | 655 | ucontrol->value.integer.value[1]); |
Ben Romberger | 205e14d | 2013-02-06 12:31:53 -0800 | [diff] [blame] | 656 | set_iir_band_coeff(codec, iir_idx, band_idx, |
Kiran Kandi | c3b2440 | 2012-06-11 00:05:59 -0700 | [diff] [blame] | 657 | ucontrol->value.integer.value[2]); |
Ben Romberger | 205e14d | 2013-02-06 12:31:53 -0800 | [diff] [blame] | 658 | set_iir_band_coeff(codec, iir_idx, band_idx, |
Kiran Kandi | c3b2440 | 2012-06-11 00:05:59 -0700 | [diff] [blame] | 659 | ucontrol->value.integer.value[3]); |
Ben Romberger | 205e14d | 2013-02-06 12:31:53 -0800 | [diff] [blame] | 660 | set_iir_band_coeff(codec, iir_idx, band_idx, |
Kiran Kandi | c3b2440 | 2012-06-11 00:05:59 -0700 | [diff] [blame] | 661 | ucontrol->value.integer.value[4]); |
| 662 | |
| 663 | pr_debug("%s: IIR #%d band #%d b0 = 0x%x\n" |
| 664 | "%s: IIR #%d band #%d b1 = 0x%x\n" |
| 665 | "%s: IIR #%d band #%d b2 = 0x%x\n" |
| 666 | "%s: IIR #%d band #%d a1 = 0x%x\n" |
| 667 | "%s: IIR #%d band #%d a2 = 0x%x\n", |
| 668 | __func__, iir_idx, band_idx, |
| 669 | get_iir_band_coeff(codec, iir_idx, band_idx, 0), |
| 670 | __func__, iir_idx, band_idx, |
| 671 | get_iir_band_coeff(codec, iir_idx, band_idx, 1), |
| 672 | __func__, iir_idx, band_idx, |
| 673 | get_iir_band_coeff(codec, iir_idx, band_idx, 2), |
| 674 | __func__, iir_idx, band_idx, |
| 675 | get_iir_band_coeff(codec, iir_idx, band_idx, 3), |
| 676 | __func__, iir_idx, band_idx, |
| 677 | get_iir_band_coeff(codec, iir_idx, band_idx, 4)); |
| 678 | return 0; |
| 679 | } |
| 680 | |
Kiran Kandi | c3b2440 | 2012-06-11 00:05:59 -0700 | [diff] [blame] | 681 | static int taiko_get_compander(struct snd_kcontrol *kcontrol, |
Joonwoo Park | c773143 | 2012-10-17 12:41:44 -0700 | [diff] [blame] | 682 | struct snd_ctl_elem_value *ucontrol) |
Kiran Kandi | c3b2440 | 2012-06-11 00:05:59 -0700 | [diff] [blame] | 683 | { |
| 684 | |
| 685 | struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); |
| 686 | int comp = ((struct soc_multi_mixer_control *) |
Joonwoo Park | c773143 | 2012-10-17 12:41:44 -0700 | [diff] [blame] | 687 | kcontrol->private_value)->shift; |
Kiran Kandi | c3b2440 | 2012-06-11 00:05:59 -0700 | [diff] [blame] | 688 | struct taiko_priv *taiko = snd_soc_codec_get_drvdata(codec); |
| 689 | |
| 690 | ucontrol->value.integer.value[0] = taiko->comp_enabled[comp]; |
Kiran Kandi | c3b2440 | 2012-06-11 00:05:59 -0700 | [diff] [blame] | 691 | return 0; |
| 692 | } |
| 693 | |
| 694 | static int taiko_set_compander(struct snd_kcontrol *kcontrol, |
Joonwoo Park | c773143 | 2012-10-17 12:41:44 -0700 | [diff] [blame] | 695 | struct snd_ctl_elem_value *ucontrol) |
Kiran Kandi | c3b2440 | 2012-06-11 00:05:59 -0700 | [diff] [blame] | 696 | { |
| 697 | struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); |
| 698 | struct taiko_priv *taiko = snd_soc_codec_get_drvdata(codec); |
| 699 | int comp = ((struct soc_multi_mixer_control *) |
Joonwoo Park | c773143 | 2012-10-17 12:41:44 -0700 | [diff] [blame] | 700 | kcontrol->private_value)->shift; |
Kiran Kandi | c3b2440 | 2012-06-11 00:05:59 -0700 | [diff] [blame] | 701 | int value = ucontrol->value.integer.value[0]; |
| 702 | |
Joonwoo Park | c773143 | 2012-10-17 12:41:44 -0700 | [diff] [blame] | 703 | pr_debug("%s: Compander %d enable current %d, new %d\n", |
| 704 | __func__, comp, taiko->comp_enabled[comp], value); |
Kiran Kandi | c3b2440 | 2012-06-11 00:05:59 -0700 | [diff] [blame] | 705 | taiko->comp_enabled[comp] = value; |
| 706 | return 0; |
| 707 | } |
| 708 | |
Joonwoo Park | c773143 | 2012-10-17 12:41:44 -0700 | [diff] [blame] | 709 | static int taiko_config_gain_compander(struct snd_soc_codec *codec, |
| 710 | int comp, bool enable) |
| 711 | { |
| 712 | int ret = 0; |
| 713 | |
| 714 | switch (comp) { |
| 715 | case COMPANDER_0: |
| 716 | snd_soc_update_bits(codec, TAIKO_A_SPKR_DRV_GAIN, |
| 717 | 1 << 2, !enable << 2); |
| 718 | break; |
| 719 | case COMPANDER_1: |
| 720 | snd_soc_update_bits(codec, TAIKO_A_RX_HPH_L_GAIN, |
| 721 | 1 << 5, !enable << 5); |
| 722 | snd_soc_update_bits(codec, TAIKO_A_RX_HPH_R_GAIN, |
| 723 | 1 << 5, !enable << 5); |
| 724 | break; |
| 725 | case COMPANDER_2: |
| 726 | snd_soc_update_bits(codec, TAIKO_A_RX_LINE_1_GAIN, |
| 727 | 1 << 5, !enable << 5); |
| 728 | snd_soc_update_bits(codec, TAIKO_A_RX_LINE_3_GAIN, |
| 729 | 1 << 5, !enable << 5); |
| 730 | snd_soc_update_bits(codec, TAIKO_A_RX_LINE_2_GAIN, |
| 731 | 1 << 5, !enable << 5); |
| 732 | snd_soc_update_bits(codec, TAIKO_A_RX_LINE_4_GAIN, |
| 733 | 1 << 5, !enable << 5); |
| 734 | break; |
| 735 | default: |
| 736 | WARN_ON(1); |
| 737 | ret = -EINVAL; |
| 738 | } |
| 739 | |
| 740 | return ret; |
| 741 | } |
| 742 | |
| 743 | static void taiko_discharge_comp(struct snd_soc_codec *codec, int comp) |
| 744 | { |
| 745 | /* Update RSM to 1, DIVF to 5 */ |
| 746 | snd_soc_write(codec, TAIKO_A_CDC_COMP0_B3_CTL + (comp * 8), 1); |
| 747 | snd_soc_update_bits(codec, TAIKO_A_CDC_COMP0_B2_CTL + (comp * 8), 0xF0, |
| 748 | 1 << 5); |
| 749 | /* Wait for 1ms */ |
| 750 | usleep_range(1000, 1000); |
| 751 | } |
Kiran Kandi | c3b2440 | 2012-06-11 00:05:59 -0700 | [diff] [blame] | 752 | |
| 753 | static int taiko_config_compander(struct snd_soc_dapm_widget *w, |
Joonwoo Park | c773143 | 2012-10-17 12:41:44 -0700 | [diff] [blame] | 754 | struct snd_kcontrol *kcontrol, int event) |
Kiran Kandi | c3b2440 | 2012-06-11 00:05:59 -0700 | [diff] [blame] | 755 | { |
Joonwoo Park | c773143 | 2012-10-17 12:41:44 -0700 | [diff] [blame] | 756 | int mask, emask; |
| 757 | bool timedout; |
| 758 | unsigned long timeout; |
Kiran Kandi | c3b2440 | 2012-06-11 00:05:59 -0700 | [diff] [blame] | 759 | struct snd_soc_codec *codec = w->codec; |
| 760 | struct taiko_priv *taiko = snd_soc_codec_get_drvdata(codec); |
Joonwoo Park | c773143 | 2012-10-17 12:41:44 -0700 | [diff] [blame] | 761 | const int comp = w->shift; |
| 762 | const u32 rate = taiko->comp_fs[comp]; |
| 763 | const struct comp_sample_dependent_params *comp_params = |
| 764 | &comp_samp_params[rate]; |
Kiran Kandi | c3b2440 | 2012-06-11 00:05:59 -0700 | [diff] [blame] | 765 | |
Joonwoo Park | c773143 | 2012-10-17 12:41:44 -0700 | [diff] [blame] | 766 | pr_debug("%s: %s event %d compander %d, enabled %d", __func__, |
| 767 | w->name, event, comp, taiko->comp_enabled[comp]); |
| 768 | |
| 769 | if (!taiko->comp_enabled[comp]) |
| 770 | return 0; |
| 771 | |
| 772 | /* Compander 0 has single channel */ |
| 773 | mask = (comp == COMPANDER_0 ? 0x01 : 0x03); |
| 774 | emask = (comp == COMPANDER_0 ? 0x02 : 0x03); |
Kiran Kandi | d2b4633 | 2012-10-05 12:04:00 -0700 | [diff] [blame] | 775 | |
Kiran Kandi | c3b2440 | 2012-06-11 00:05:59 -0700 | [diff] [blame] | 776 | switch (event) { |
| 777 | case SND_SOC_DAPM_PRE_PMU: |
Joonwoo Park | c773143 | 2012-10-17 12:41:44 -0700 | [diff] [blame] | 778 | /* Set gain source to compander */ |
| 779 | taiko_config_gain_compander(codec, comp, true); |
| 780 | /* Enable RX interpolation path clocks */ |
| 781 | snd_soc_update_bits(codec, TAIKO_A_CDC_CLK_RX_B2_CTL, |
| 782 | mask << comp_shift[comp], |
| 783 | mask << comp_shift[comp]); |
| 784 | |
| 785 | taiko_discharge_comp(codec, comp); |
| 786 | |
| 787 | /* Clear compander halt */ |
| 788 | snd_soc_update_bits(codec, TAIKO_A_CDC_COMP0_B1_CTL + |
| 789 | (comp * 8), |
| 790 | 1 << 2, 0); |
| 791 | /* Toggle compander reset bits */ |
| 792 | snd_soc_update_bits(codec, TAIKO_A_CDC_CLK_OTHR_RESET_B2_CTL, |
| 793 | mask << comp_shift[comp], |
| 794 | mask << comp_shift[comp]); |
| 795 | snd_soc_update_bits(codec, TAIKO_A_CDC_CLK_OTHR_RESET_B2_CTL, |
| 796 | mask << comp_shift[comp], 0); |
Kiran Kandi | c3b2440 | 2012-06-11 00:05:59 -0700 | [diff] [blame] | 797 | break; |
| 798 | case SND_SOC_DAPM_POST_PMU: |
Joonwoo Park | c773143 | 2012-10-17 12:41:44 -0700 | [diff] [blame] | 799 | /* Set sample rate dependent paramater */ |
| 800 | snd_soc_update_bits(codec, |
| 801 | TAIKO_A_CDC_COMP0_FS_CFG + (comp * 8), |
| 802 | 0x07, rate); |
| 803 | snd_soc_write(codec, TAIKO_A_CDC_COMP0_B3_CTL + (comp * 8), |
| 804 | comp_params->rms_meter_resamp_fact); |
| 805 | snd_soc_update_bits(codec, |
| 806 | TAIKO_A_CDC_COMP0_B2_CTL + (comp * 8), |
| 807 | 0x0F, comp_params->peak_det_timeout); |
| 808 | snd_soc_update_bits(codec, |
| 809 | TAIKO_A_CDC_COMP0_B2_CTL + (comp * 8), |
| 810 | 0xF0, comp_params->rms_meter_div_fact << 4); |
| 811 | /* Compander enable */ |
| 812 | snd_soc_update_bits(codec, TAIKO_A_CDC_COMP0_B1_CTL + |
| 813 | (comp * 8), emask, emask); |
Kiran Kandi | c3b2440 | 2012-06-11 00:05:59 -0700 | [diff] [blame] | 814 | break; |
| 815 | case SND_SOC_DAPM_PRE_PMD: |
Joonwoo Park | c773143 | 2012-10-17 12:41:44 -0700 | [diff] [blame] | 816 | /* Halt compander */ |
| 817 | snd_soc_update_bits(codec, |
| 818 | TAIKO_A_CDC_COMP0_B1_CTL + (comp * 8), |
| 819 | 1 << 2, 1 << 2); |
| 820 | /* Wait up to a second for shutdown complete */ |
| 821 | timeout = jiffies + HZ; |
| 822 | do { |
| 823 | if ((snd_soc_read(codec, |
| 824 | TAIKO_A_CDC_COMP0_SHUT_DOWN_STATUS + |
| 825 | (comp * 8)) & mask) == mask) |
| 826 | break; |
| 827 | } while (!(timedout = time_after(jiffies, timeout))); |
| 828 | pr_debug("%s: Compander %d shutdown %s in %dms\n", __func__, |
| 829 | comp, timedout ? "timedout" : "completed", |
| 830 | jiffies_to_msecs(timeout - HZ - jiffies)); |
Kiran Kandi | c3b2440 | 2012-06-11 00:05:59 -0700 | [diff] [blame] | 831 | break; |
| 832 | case SND_SOC_DAPM_POST_PMD: |
Joonwoo Park | c773143 | 2012-10-17 12:41:44 -0700 | [diff] [blame] | 833 | /* Disable compander */ |
| 834 | snd_soc_update_bits(codec, |
| 835 | TAIKO_A_CDC_COMP0_B1_CTL + (comp * 8), |
| 836 | emask, 0x00); |
| 837 | /* Turn off the clock for compander in pair */ |
| 838 | snd_soc_update_bits(codec, TAIKO_A_CDC_CLK_RX_B2_CTL, |
| 839 | mask << comp_shift[comp], 0); |
| 840 | /* Set gain source to register */ |
| 841 | taiko_config_gain_compander(codec, comp, false); |
Kiran Kandi | c3b2440 | 2012-06-11 00:05:59 -0700 | [diff] [blame] | 842 | break; |
| 843 | } |
| 844 | return 0; |
| 845 | } |
| 846 | |
| 847 | static const char * const taiko_ear_pa_gain_text[] = {"POS_6_DB", "POS_2_DB"}; |
| 848 | static const struct soc_enum taiko_ear_pa_gain_enum[] = { |
| 849 | SOC_ENUM_SINGLE_EXT(2, taiko_ear_pa_gain_text), |
| 850 | }; |
| 851 | |
| 852 | /*cut of frequency for high pass filter*/ |
| 853 | static const char * const cf_text[] = { |
| 854 | "MIN_3DB_4Hz", "MIN_3DB_75Hz", "MIN_3DB_150Hz" |
| 855 | }; |
| 856 | |
| 857 | static const struct soc_enum cf_dec1_enum = |
| 858 | SOC_ENUM_SINGLE(TAIKO_A_CDC_TX1_MUX_CTL, 4, 3, cf_text); |
| 859 | |
| 860 | static const struct soc_enum cf_dec2_enum = |
| 861 | SOC_ENUM_SINGLE(TAIKO_A_CDC_TX2_MUX_CTL, 4, 3, cf_text); |
| 862 | |
| 863 | static const struct soc_enum cf_dec3_enum = |
| 864 | SOC_ENUM_SINGLE(TAIKO_A_CDC_TX3_MUX_CTL, 4, 3, cf_text); |
| 865 | |
| 866 | static const struct soc_enum cf_dec4_enum = |
| 867 | SOC_ENUM_SINGLE(TAIKO_A_CDC_TX4_MUX_CTL, 4, 3, cf_text); |
| 868 | |
| 869 | static const struct soc_enum cf_dec5_enum = |
| 870 | SOC_ENUM_SINGLE(TAIKO_A_CDC_TX5_MUX_CTL, 4, 3, cf_text); |
| 871 | |
| 872 | static const struct soc_enum cf_dec6_enum = |
| 873 | SOC_ENUM_SINGLE(TAIKO_A_CDC_TX6_MUX_CTL, 4, 3, cf_text); |
| 874 | |
| 875 | static const struct soc_enum cf_dec7_enum = |
| 876 | SOC_ENUM_SINGLE(TAIKO_A_CDC_TX7_MUX_CTL, 4, 3, cf_text); |
| 877 | |
| 878 | static const struct soc_enum cf_dec8_enum = |
| 879 | SOC_ENUM_SINGLE(TAIKO_A_CDC_TX8_MUX_CTL, 4, 3, cf_text); |
| 880 | |
| 881 | static const struct soc_enum cf_dec9_enum = |
| 882 | SOC_ENUM_SINGLE(TAIKO_A_CDC_TX9_MUX_CTL, 4, 3, cf_text); |
| 883 | |
| 884 | static const struct soc_enum cf_dec10_enum = |
| 885 | SOC_ENUM_SINGLE(TAIKO_A_CDC_TX10_MUX_CTL, 4, 3, cf_text); |
| 886 | |
| 887 | static const struct soc_enum cf_rxmix1_enum = |
| 888 | SOC_ENUM_SINGLE(TAIKO_A_CDC_RX1_B4_CTL, 1, 3, cf_text); |
| 889 | |
| 890 | static const struct soc_enum cf_rxmix2_enum = |
| 891 | SOC_ENUM_SINGLE(TAIKO_A_CDC_RX2_B4_CTL, 1, 3, cf_text); |
| 892 | |
| 893 | static const struct soc_enum cf_rxmix3_enum = |
| 894 | SOC_ENUM_SINGLE(TAIKO_A_CDC_RX3_B4_CTL, 1, 3, cf_text); |
| 895 | |
| 896 | static const struct soc_enum cf_rxmix4_enum = |
| 897 | SOC_ENUM_SINGLE(TAIKO_A_CDC_RX4_B4_CTL, 1, 3, cf_text); |
| 898 | |
| 899 | static const struct soc_enum cf_rxmix5_enum = |
| 900 | SOC_ENUM_SINGLE(TAIKO_A_CDC_RX5_B4_CTL, 1, 3, cf_text) |
| 901 | ; |
| 902 | static const struct soc_enum cf_rxmix6_enum = |
| 903 | SOC_ENUM_SINGLE(TAIKO_A_CDC_RX6_B4_CTL, 1, 3, cf_text); |
| 904 | |
| 905 | static const struct soc_enum cf_rxmix7_enum = |
| 906 | SOC_ENUM_SINGLE(TAIKO_A_CDC_RX7_B4_CTL, 1, 3, cf_text); |
| 907 | |
| 908 | static const struct snd_kcontrol_new taiko_snd_controls[] = { |
| 909 | |
| 910 | SOC_ENUM_EXT("EAR PA Gain", taiko_ear_pa_gain_enum[0], |
| 911 | taiko_pa_gain_get, taiko_pa_gain_put), |
| 912 | |
| 913 | SOC_SINGLE_TLV("LINEOUT1 Volume", TAIKO_A_RX_LINE_1_GAIN, 0, 12, 1, |
| 914 | line_gain), |
| 915 | SOC_SINGLE_TLV("LINEOUT2 Volume", TAIKO_A_RX_LINE_2_GAIN, 0, 12, 1, |
| 916 | line_gain), |
| 917 | SOC_SINGLE_TLV("LINEOUT3 Volume", TAIKO_A_RX_LINE_3_GAIN, 0, 12, 1, |
| 918 | line_gain), |
| 919 | SOC_SINGLE_TLV("LINEOUT4 Volume", TAIKO_A_RX_LINE_4_GAIN, 0, 12, 1, |
| 920 | line_gain), |
| 921 | |
| 922 | SOC_SINGLE_TLV("HPHL Volume", TAIKO_A_RX_HPH_L_GAIN, 0, 12, 1, |
| 923 | line_gain), |
| 924 | SOC_SINGLE_TLV("HPHR Volume", TAIKO_A_RX_HPH_R_GAIN, 0, 12, 1, |
| 925 | line_gain), |
| 926 | |
Kiran Kandi | fd0a1da | 2013-01-21 09:58:45 -0800 | [diff] [blame] | 927 | SOC_SINGLE_TLV("SPK DRV Volume", TAIKO_A_SPKR_DRV_GAIN, 3, 7, 1, |
| 928 | line_gain), |
| 929 | |
Kiran Kandi | c3b2440 | 2012-06-11 00:05:59 -0700 | [diff] [blame] | 930 | SOC_SINGLE_S8_TLV("RX1 Digital Volume", TAIKO_A_CDC_RX1_VOL_CTL_B2_CTL, |
| 931 | -84, 40, digital_gain), |
| 932 | SOC_SINGLE_S8_TLV("RX2 Digital Volume", TAIKO_A_CDC_RX2_VOL_CTL_B2_CTL, |
| 933 | -84, 40, digital_gain), |
| 934 | SOC_SINGLE_S8_TLV("RX3 Digital Volume", TAIKO_A_CDC_RX3_VOL_CTL_B2_CTL, |
| 935 | -84, 40, digital_gain), |
| 936 | SOC_SINGLE_S8_TLV("RX4 Digital Volume", TAIKO_A_CDC_RX4_VOL_CTL_B2_CTL, |
| 937 | -84, 40, digital_gain), |
| 938 | SOC_SINGLE_S8_TLV("RX5 Digital Volume", TAIKO_A_CDC_RX5_VOL_CTL_B2_CTL, |
| 939 | -84, 40, digital_gain), |
| 940 | SOC_SINGLE_S8_TLV("RX6 Digital Volume", TAIKO_A_CDC_RX6_VOL_CTL_B2_CTL, |
| 941 | -84, 40, digital_gain), |
| 942 | SOC_SINGLE_S8_TLV("RX7 Digital Volume", TAIKO_A_CDC_RX7_VOL_CTL_B2_CTL, |
| 943 | -84, 40, digital_gain), |
| 944 | |
| 945 | SOC_SINGLE_S8_TLV("DEC1 Volume", TAIKO_A_CDC_TX1_VOL_CTL_GAIN, -84, 40, |
| 946 | digital_gain), |
| 947 | SOC_SINGLE_S8_TLV("DEC2 Volume", TAIKO_A_CDC_TX2_VOL_CTL_GAIN, -84, 40, |
| 948 | digital_gain), |
| 949 | SOC_SINGLE_S8_TLV("DEC3 Volume", TAIKO_A_CDC_TX3_VOL_CTL_GAIN, -84, 40, |
| 950 | digital_gain), |
| 951 | SOC_SINGLE_S8_TLV("DEC4 Volume", TAIKO_A_CDC_TX4_VOL_CTL_GAIN, -84, 40, |
| 952 | digital_gain), |
| 953 | SOC_SINGLE_S8_TLV("DEC5 Volume", TAIKO_A_CDC_TX5_VOL_CTL_GAIN, -84, 40, |
| 954 | digital_gain), |
| 955 | SOC_SINGLE_S8_TLV("DEC6 Volume", TAIKO_A_CDC_TX6_VOL_CTL_GAIN, -84, 40, |
| 956 | digital_gain), |
| 957 | SOC_SINGLE_S8_TLV("DEC7 Volume", TAIKO_A_CDC_TX7_VOL_CTL_GAIN, -84, 40, |
| 958 | digital_gain), |
| 959 | SOC_SINGLE_S8_TLV("DEC8 Volume", TAIKO_A_CDC_TX8_VOL_CTL_GAIN, -84, 40, |
| 960 | digital_gain), |
| 961 | SOC_SINGLE_S8_TLV("DEC9 Volume", TAIKO_A_CDC_TX9_VOL_CTL_GAIN, -84, 40, |
| 962 | digital_gain), |
| 963 | SOC_SINGLE_S8_TLV("DEC10 Volume", TAIKO_A_CDC_TX10_VOL_CTL_GAIN, -84, |
| 964 | 40, digital_gain), |
| 965 | SOC_SINGLE_S8_TLV("IIR1 INP1 Volume", TAIKO_A_CDC_IIR1_GAIN_B1_CTL, -84, |
| 966 | 40, digital_gain), |
| 967 | SOC_SINGLE_S8_TLV("IIR1 INP2 Volume", TAIKO_A_CDC_IIR1_GAIN_B2_CTL, -84, |
| 968 | 40, digital_gain), |
| 969 | SOC_SINGLE_S8_TLV("IIR1 INP3 Volume", TAIKO_A_CDC_IIR1_GAIN_B3_CTL, -84, |
| 970 | 40, digital_gain), |
| 971 | SOC_SINGLE_S8_TLV("IIR1 INP4 Volume", TAIKO_A_CDC_IIR1_GAIN_B4_CTL, -84, |
| 972 | 40, digital_gain), |
| 973 | SOC_SINGLE_TLV("ADC1 Volume", TAIKO_A_TX_1_2_EN, 5, 3, 0, analog_gain), |
| 974 | SOC_SINGLE_TLV("ADC2 Volume", TAIKO_A_TX_1_2_EN, 1, 3, 0, analog_gain), |
| 975 | SOC_SINGLE_TLV("ADC3 Volume", TAIKO_A_TX_3_4_EN, 5, 3, 0, analog_gain), |
| 976 | SOC_SINGLE_TLV("ADC4 Volume", TAIKO_A_TX_3_4_EN, 1, 3, 0, analog_gain), |
| 977 | SOC_SINGLE_TLV("ADC5 Volume", TAIKO_A_TX_5_6_EN, 5, 3, 0, analog_gain), |
| 978 | SOC_SINGLE_TLV("ADC6 Volume", TAIKO_A_TX_5_6_EN, 1, 3, 0, analog_gain), |
| 979 | |
| 980 | |
| 981 | SOC_SINGLE("MICBIAS1 CAPLESS Switch", TAIKO_A_MICB_1_CTL, 4, 1, 1), |
| 982 | SOC_SINGLE("MICBIAS2 CAPLESS Switch", TAIKO_A_MICB_2_CTL, 4, 1, 1), |
| 983 | SOC_SINGLE("MICBIAS3 CAPLESS Switch", TAIKO_A_MICB_3_CTL, 4, 1, 1), |
| 984 | SOC_SINGLE("MICBIAS4 CAPLESS Switch", TAIKO_A_MICB_4_CTL, 4, 1, 1), |
| 985 | |
| 986 | SOC_SINGLE_EXT("ANC Slot", SND_SOC_NOPM, 0, 0, 100, taiko_get_anc_slot, |
| 987 | taiko_put_anc_slot), |
| 988 | SOC_ENUM("TX1 HPF cut off", cf_dec1_enum), |
| 989 | SOC_ENUM("TX2 HPF cut off", cf_dec2_enum), |
| 990 | SOC_ENUM("TX3 HPF cut off", cf_dec3_enum), |
| 991 | SOC_ENUM("TX4 HPF cut off", cf_dec4_enum), |
| 992 | SOC_ENUM("TX5 HPF cut off", cf_dec5_enum), |
| 993 | SOC_ENUM("TX6 HPF cut off", cf_dec6_enum), |
| 994 | SOC_ENUM("TX7 HPF cut off", cf_dec7_enum), |
| 995 | SOC_ENUM("TX8 HPF cut off", cf_dec8_enum), |
| 996 | SOC_ENUM("TX9 HPF cut off", cf_dec9_enum), |
| 997 | SOC_ENUM("TX10 HPF cut off", cf_dec10_enum), |
| 998 | |
| 999 | SOC_SINGLE("TX1 HPF Switch", TAIKO_A_CDC_TX1_MUX_CTL, 3, 1, 0), |
| 1000 | SOC_SINGLE("TX2 HPF Switch", TAIKO_A_CDC_TX2_MUX_CTL, 3, 1, 0), |
| 1001 | SOC_SINGLE("TX3 HPF Switch", TAIKO_A_CDC_TX3_MUX_CTL, 3, 1, 0), |
| 1002 | SOC_SINGLE("TX4 HPF Switch", TAIKO_A_CDC_TX4_MUX_CTL, 3, 1, 0), |
| 1003 | SOC_SINGLE("TX5 HPF Switch", TAIKO_A_CDC_TX5_MUX_CTL, 3, 1, 0), |
| 1004 | SOC_SINGLE("TX6 HPF Switch", TAIKO_A_CDC_TX6_MUX_CTL, 3, 1, 0), |
| 1005 | SOC_SINGLE("TX7 HPF Switch", TAIKO_A_CDC_TX7_MUX_CTL, 3, 1, 0), |
| 1006 | SOC_SINGLE("TX8 HPF Switch", TAIKO_A_CDC_TX8_MUX_CTL, 3, 1, 0), |
| 1007 | SOC_SINGLE("TX9 HPF Switch", TAIKO_A_CDC_TX9_MUX_CTL, 3, 1, 0), |
| 1008 | SOC_SINGLE("TX10 HPF Switch", TAIKO_A_CDC_TX10_MUX_CTL, 3, 1, 0), |
| 1009 | |
| 1010 | SOC_SINGLE("RX1 HPF Switch", TAIKO_A_CDC_RX1_B5_CTL, 2, 1, 0), |
| 1011 | SOC_SINGLE("RX2 HPF Switch", TAIKO_A_CDC_RX2_B5_CTL, 2, 1, 0), |
| 1012 | SOC_SINGLE("RX3 HPF Switch", TAIKO_A_CDC_RX3_B5_CTL, 2, 1, 0), |
| 1013 | SOC_SINGLE("RX4 HPF Switch", TAIKO_A_CDC_RX4_B5_CTL, 2, 1, 0), |
| 1014 | SOC_SINGLE("RX5 HPF Switch", TAIKO_A_CDC_RX5_B5_CTL, 2, 1, 0), |
| 1015 | SOC_SINGLE("RX6 HPF Switch", TAIKO_A_CDC_RX6_B5_CTL, 2, 1, 0), |
| 1016 | SOC_SINGLE("RX7 HPF Switch", TAIKO_A_CDC_RX7_B5_CTL, 2, 1, 0), |
| 1017 | |
| 1018 | SOC_ENUM("RX1 HPF cut off", cf_rxmix1_enum), |
| 1019 | SOC_ENUM("RX2 HPF cut off", cf_rxmix2_enum), |
| 1020 | SOC_ENUM("RX3 HPF cut off", cf_rxmix3_enum), |
| 1021 | SOC_ENUM("RX4 HPF cut off", cf_rxmix4_enum), |
| 1022 | SOC_ENUM("RX5 HPF cut off", cf_rxmix5_enum), |
| 1023 | SOC_ENUM("RX6 HPF cut off", cf_rxmix6_enum), |
| 1024 | SOC_ENUM("RX7 HPF cut off", cf_rxmix7_enum), |
| 1025 | |
| 1026 | SOC_SINGLE_EXT("IIR1 Enable Band1", IIR1, BAND1, 1, 0, |
| 1027 | taiko_get_iir_enable_audio_mixer, taiko_put_iir_enable_audio_mixer), |
| 1028 | SOC_SINGLE_EXT("IIR1 Enable Band2", IIR1, BAND2, 1, 0, |
| 1029 | taiko_get_iir_enable_audio_mixer, taiko_put_iir_enable_audio_mixer), |
| 1030 | SOC_SINGLE_EXT("IIR1 Enable Band3", IIR1, BAND3, 1, 0, |
| 1031 | taiko_get_iir_enable_audio_mixer, taiko_put_iir_enable_audio_mixer), |
| 1032 | SOC_SINGLE_EXT("IIR1 Enable Band4", IIR1, BAND4, 1, 0, |
| 1033 | taiko_get_iir_enable_audio_mixer, taiko_put_iir_enable_audio_mixer), |
| 1034 | SOC_SINGLE_EXT("IIR1 Enable Band5", IIR1, BAND5, 1, 0, |
| 1035 | taiko_get_iir_enable_audio_mixer, taiko_put_iir_enable_audio_mixer), |
| 1036 | SOC_SINGLE_EXT("IIR2 Enable Band1", IIR2, BAND1, 1, 0, |
| 1037 | taiko_get_iir_enable_audio_mixer, taiko_put_iir_enable_audio_mixer), |
| 1038 | SOC_SINGLE_EXT("IIR2 Enable Band2", IIR2, BAND2, 1, 0, |
| 1039 | taiko_get_iir_enable_audio_mixer, taiko_put_iir_enable_audio_mixer), |
| 1040 | SOC_SINGLE_EXT("IIR2 Enable Band3", IIR2, BAND3, 1, 0, |
| 1041 | taiko_get_iir_enable_audio_mixer, taiko_put_iir_enable_audio_mixer), |
| 1042 | SOC_SINGLE_EXT("IIR2 Enable Band4", IIR2, BAND4, 1, 0, |
| 1043 | taiko_get_iir_enable_audio_mixer, taiko_put_iir_enable_audio_mixer), |
| 1044 | SOC_SINGLE_EXT("IIR2 Enable Band5", IIR2, BAND5, 1, 0, |
| 1045 | taiko_get_iir_enable_audio_mixer, taiko_put_iir_enable_audio_mixer), |
| 1046 | |
| 1047 | SOC_SINGLE_MULTI_EXT("IIR1 Band1", IIR1, BAND1, 255, 0, 5, |
| 1048 | taiko_get_iir_band_audio_mixer, taiko_put_iir_band_audio_mixer), |
| 1049 | SOC_SINGLE_MULTI_EXT("IIR1 Band2", IIR1, BAND2, 255, 0, 5, |
| 1050 | taiko_get_iir_band_audio_mixer, taiko_put_iir_band_audio_mixer), |
| 1051 | SOC_SINGLE_MULTI_EXT("IIR1 Band3", IIR1, BAND3, 255, 0, 5, |
| 1052 | taiko_get_iir_band_audio_mixer, taiko_put_iir_band_audio_mixer), |
| 1053 | SOC_SINGLE_MULTI_EXT("IIR1 Band4", IIR1, BAND4, 255, 0, 5, |
| 1054 | taiko_get_iir_band_audio_mixer, taiko_put_iir_band_audio_mixer), |
| 1055 | SOC_SINGLE_MULTI_EXT("IIR1 Band5", IIR1, BAND5, 255, 0, 5, |
| 1056 | taiko_get_iir_band_audio_mixer, taiko_put_iir_band_audio_mixer), |
| 1057 | SOC_SINGLE_MULTI_EXT("IIR2 Band1", IIR2, BAND1, 255, 0, 5, |
| 1058 | taiko_get_iir_band_audio_mixer, taiko_put_iir_band_audio_mixer), |
| 1059 | SOC_SINGLE_MULTI_EXT("IIR2 Band2", IIR2, BAND2, 255, 0, 5, |
| 1060 | taiko_get_iir_band_audio_mixer, taiko_put_iir_band_audio_mixer), |
| 1061 | SOC_SINGLE_MULTI_EXT("IIR2 Band3", IIR2, BAND3, 255, 0, 5, |
| 1062 | taiko_get_iir_band_audio_mixer, taiko_put_iir_band_audio_mixer), |
| 1063 | SOC_SINGLE_MULTI_EXT("IIR2 Band4", IIR2, BAND4, 255, 0, 5, |
| 1064 | taiko_get_iir_band_audio_mixer, taiko_put_iir_band_audio_mixer), |
| 1065 | SOC_SINGLE_MULTI_EXT("IIR2 Band5", IIR2, BAND5, 255, 0, 5, |
| 1066 | taiko_get_iir_band_audio_mixer, taiko_put_iir_band_audio_mixer), |
| 1067 | |
Joonwoo Park | c773143 | 2012-10-17 12:41:44 -0700 | [diff] [blame] | 1068 | SOC_SINGLE_EXT("COMP0 Switch", SND_SOC_NOPM, COMPANDER_0, 1, 0, |
| 1069 | taiko_get_compander, taiko_set_compander), |
| 1070 | SOC_SINGLE_EXT("COMP1 Switch", SND_SOC_NOPM, COMPANDER_1, 1, 0, |
| 1071 | taiko_get_compander, taiko_set_compander), |
| 1072 | SOC_SINGLE_EXT("COMP2 Switch", SND_SOC_NOPM, COMPANDER_2, 1, 0, |
| 1073 | taiko_get_compander, taiko_set_compander), |
Kiran Kandi | c3b2440 | 2012-06-11 00:05:59 -0700 | [diff] [blame] | 1074 | |
| 1075 | }; |
| 1076 | |
| 1077 | static const char * const rx_mix1_text[] = { |
| 1078 | "ZERO", "SRC1", "SRC2", "IIR1", "IIR2", "RX1", "RX2", "RX3", "RX4", |
| 1079 | "RX5", "RX6", "RX7" |
| 1080 | }; |
| 1081 | |
| 1082 | static const char * const rx_mix2_text[] = { |
| 1083 | "ZERO", "SRC1", "SRC2", "IIR1", "IIR2" |
| 1084 | }; |
| 1085 | |
Tanya Finkel | daaa6d1 | 2012-10-25 11:22:48 +0200 | [diff] [blame] | 1086 | static const char * const rx_rdac5_text[] = { |
| 1087 | "DEM4", "DEM3_INV" |
Kiran Kandi | c3b2440 | 2012-06-11 00:05:59 -0700 | [diff] [blame] | 1088 | }; |
| 1089 | |
Tanya Finkel | daaa6d1 | 2012-10-25 11:22:48 +0200 | [diff] [blame] | 1090 | static const char * const rx_rdac7_text[] = { |
| 1091 | "DEM6", "DEM5_INV" |
| 1092 | }; |
| 1093 | |
| 1094 | |
Kiran Kandi | c3b2440 | 2012-06-11 00:05:59 -0700 | [diff] [blame] | 1095 | static const char * const sb_tx1_mux_text[] = { |
| 1096 | "ZERO", "RMIX1", "RMIX2", "RMIX3", "RMIX4", "RMIX5", "RMIX6", "RMIX7", |
| 1097 | "DEC1" |
| 1098 | }; |
| 1099 | |
| 1100 | static const char * const sb_tx2_mux_text[] = { |
| 1101 | "ZERO", "RMIX1", "RMIX2", "RMIX3", "RMIX4", "RMIX5", "RMIX6", "RMIX7", |
| 1102 | "DEC2" |
| 1103 | }; |
| 1104 | |
| 1105 | static const char * const sb_tx3_mux_text[] = { |
| 1106 | "ZERO", "RMIX1", "RMIX2", "RMIX3", "RMIX4", "RMIX5", "RMIX6", "RMIX7", |
| 1107 | "DEC3" |
| 1108 | }; |
| 1109 | |
| 1110 | static const char * const sb_tx4_mux_text[] = { |
| 1111 | "ZERO", "RMIX1", "RMIX2", "RMIX3", "RMIX4", "RMIX5", "RMIX6", "RMIX7", |
| 1112 | "DEC4" |
| 1113 | }; |
| 1114 | |
| 1115 | static const char * const sb_tx5_mux_text[] = { |
| 1116 | "ZERO", "RMIX1", "RMIX2", "RMIX3", "RMIX4", "RMIX5", "RMIX6", "RMIX7", |
| 1117 | "DEC5" |
| 1118 | }; |
| 1119 | |
| 1120 | static const char * const sb_tx6_mux_text[] = { |
| 1121 | "ZERO", "RMIX1", "RMIX2", "RMIX3", "RMIX4", "RMIX5", "RMIX6", "RMIX7", |
| 1122 | "DEC6" |
| 1123 | }; |
| 1124 | |
| 1125 | static const char * const sb_tx7_to_tx10_mux_text[] = { |
| 1126 | "ZERO", "RMIX1", "RMIX2", "RMIX3", "RMIX4", "RMIX5", "RMIX6", "RMIX7", |
| 1127 | "DEC1", "DEC2", "DEC3", "DEC4", "DEC5", "DEC6", "DEC7", "DEC8", |
| 1128 | "DEC9", "DEC10" |
| 1129 | }; |
| 1130 | |
| 1131 | static const char * const dec1_mux_text[] = { |
| 1132 | "ZERO", "DMIC1", "ADC6", |
| 1133 | }; |
| 1134 | |
| 1135 | static const char * const dec2_mux_text[] = { |
| 1136 | "ZERO", "DMIC2", "ADC5", |
| 1137 | }; |
| 1138 | |
| 1139 | static const char * const dec3_mux_text[] = { |
| 1140 | "ZERO", "DMIC3", "ADC4", |
| 1141 | }; |
| 1142 | |
| 1143 | static const char * const dec4_mux_text[] = { |
| 1144 | "ZERO", "DMIC4", "ADC3", |
| 1145 | }; |
| 1146 | |
| 1147 | static const char * const dec5_mux_text[] = { |
| 1148 | "ZERO", "DMIC5", "ADC2", |
| 1149 | }; |
| 1150 | |
| 1151 | static const char * const dec6_mux_text[] = { |
| 1152 | "ZERO", "DMIC6", "ADC1", |
| 1153 | }; |
| 1154 | |
| 1155 | static const char * const dec7_mux_text[] = { |
| 1156 | "ZERO", "DMIC1", "DMIC6", "ADC1", "ADC6", "ANC1_FB", "ANC2_FB", |
| 1157 | }; |
| 1158 | |
| 1159 | static const char * const dec8_mux_text[] = { |
| 1160 | "ZERO", "DMIC2", "DMIC5", "ADC2", "ADC5", |
| 1161 | }; |
| 1162 | |
| 1163 | static const char * const dec9_mux_text[] = { |
| 1164 | "ZERO", "DMIC4", "DMIC5", "ADC2", "ADC3", "ADCMB", "ANC1_FB", "ANC2_FB", |
| 1165 | }; |
| 1166 | |
| 1167 | static const char * const dec10_mux_text[] = { |
| 1168 | "ZERO", "DMIC3", "DMIC6", "ADC1", "ADC4", "ADCMB", "ANC1_FB", "ANC2_FB", |
| 1169 | }; |
| 1170 | |
| 1171 | static const char * const anc_mux_text[] = { |
| 1172 | "ZERO", "ADC1", "ADC2", "ADC3", "ADC4", "ADC5", "ADC6", "ADC_MB", |
| 1173 | "RSVD_1", "DMIC1", "DMIC2", "DMIC3", "DMIC4", "DMIC5", "DMIC6" |
| 1174 | }; |
| 1175 | |
| 1176 | static const char * const anc1_fb_mux_text[] = { |
| 1177 | "ZERO", "EAR_HPH_L", "EAR_LINE_1", |
| 1178 | }; |
| 1179 | |
| 1180 | static const char * const iir1_inp1_text[] = { |
| 1181 | "ZERO", "DEC1", "DEC2", "DEC3", "DEC4", "DEC5", "DEC6", "DEC7", "DEC8", |
| 1182 | "DEC9", "DEC10", "RX1", "RX2", "RX3", "RX4", "RX5", "RX6", "RX7" |
| 1183 | }; |
| 1184 | |
| 1185 | static const struct soc_enum rx_mix1_inp1_chain_enum = |
| 1186 | SOC_ENUM_SINGLE(TAIKO_A_CDC_CONN_RX1_B1_CTL, 0, 12, rx_mix1_text); |
| 1187 | |
| 1188 | static const struct soc_enum rx_mix1_inp2_chain_enum = |
| 1189 | SOC_ENUM_SINGLE(TAIKO_A_CDC_CONN_RX1_B1_CTL, 4, 12, rx_mix1_text); |
| 1190 | |
| 1191 | static const struct soc_enum rx_mix1_inp3_chain_enum = |
| 1192 | SOC_ENUM_SINGLE(TAIKO_A_CDC_CONN_RX1_B2_CTL, 0, 12, rx_mix1_text); |
| 1193 | |
| 1194 | static const struct soc_enum rx2_mix1_inp1_chain_enum = |
| 1195 | SOC_ENUM_SINGLE(TAIKO_A_CDC_CONN_RX2_B1_CTL, 0, 12, rx_mix1_text); |
| 1196 | |
| 1197 | static const struct soc_enum rx2_mix1_inp2_chain_enum = |
| 1198 | SOC_ENUM_SINGLE(TAIKO_A_CDC_CONN_RX2_B1_CTL, 4, 12, rx_mix1_text); |
| 1199 | |
| 1200 | static const struct soc_enum rx3_mix1_inp1_chain_enum = |
| 1201 | SOC_ENUM_SINGLE(TAIKO_A_CDC_CONN_RX3_B1_CTL, 0, 12, rx_mix1_text); |
| 1202 | |
| 1203 | static const struct soc_enum rx3_mix1_inp2_chain_enum = |
| 1204 | SOC_ENUM_SINGLE(TAIKO_A_CDC_CONN_RX3_B1_CTL, 4, 12, rx_mix1_text); |
| 1205 | |
| 1206 | static const struct soc_enum rx4_mix1_inp1_chain_enum = |
| 1207 | SOC_ENUM_SINGLE(TAIKO_A_CDC_CONN_RX4_B1_CTL, 0, 12, rx_mix1_text); |
| 1208 | |
| 1209 | static const struct soc_enum rx4_mix1_inp2_chain_enum = |
| 1210 | SOC_ENUM_SINGLE(TAIKO_A_CDC_CONN_RX4_B1_CTL, 4, 12, rx_mix1_text); |
| 1211 | |
| 1212 | static const struct soc_enum rx5_mix1_inp1_chain_enum = |
| 1213 | SOC_ENUM_SINGLE(TAIKO_A_CDC_CONN_RX5_B1_CTL, 0, 12, rx_mix1_text); |
| 1214 | |
| 1215 | static const struct soc_enum rx5_mix1_inp2_chain_enum = |
| 1216 | SOC_ENUM_SINGLE(TAIKO_A_CDC_CONN_RX5_B1_CTL, 4, 12, rx_mix1_text); |
| 1217 | |
| 1218 | static const struct soc_enum rx6_mix1_inp1_chain_enum = |
| 1219 | SOC_ENUM_SINGLE(TAIKO_A_CDC_CONN_RX6_B1_CTL, 0, 12, rx_mix1_text); |
| 1220 | |
| 1221 | static const struct soc_enum rx6_mix1_inp2_chain_enum = |
| 1222 | SOC_ENUM_SINGLE(TAIKO_A_CDC_CONN_RX6_B1_CTL, 4, 12, rx_mix1_text); |
| 1223 | |
| 1224 | static const struct soc_enum rx7_mix1_inp1_chain_enum = |
| 1225 | SOC_ENUM_SINGLE(TAIKO_A_CDC_CONN_RX7_B1_CTL, 0, 12, rx_mix1_text); |
| 1226 | |
| 1227 | static const struct soc_enum rx7_mix1_inp2_chain_enum = |
| 1228 | SOC_ENUM_SINGLE(TAIKO_A_CDC_CONN_RX7_B1_CTL, 4, 12, rx_mix1_text); |
| 1229 | |
| 1230 | static const struct soc_enum rx1_mix2_inp1_chain_enum = |
| 1231 | SOC_ENUM_SINGLE(TAIKO_A_CDC_CONN_RX1_B3_CTL, 0, 5, rx_mix2_text); |
| 1232 | |
| 1233 | static const struct soc_enum rx1_mix2_inp2_chain_enum = |
| 1234 | SOC_ENUM_SINGLE(TAIKO_A_CDC_CONN_RX1_B3_CTL, 3, 5, rx_mix2_text); |
| 1235 | |
| 1236 | static const struct soc_enum rx2_mix2_inp1_chain_enum = |
| 1237 | SOC_ENUM_SINGLE(TAIKO_A_CDC_CONN_RX2_B3_CTL, 0, 5, rx_mix2_text); |
| 1238 | |
| 1239 | static const struct soc_enum rx2_mix2_inp2_chain_enum = |
| 1240 | SOC_ENUM_SINGLE(TAIKO_A_CDC_CONN_RX2_B3_CTL, 3, 5, rx_mix2_text); |
| 1241 | |
| 1242 | static const struct soc_enum rx7_mix2_inp1_chain_enum = |
| 1243 | SOC_ENUM_SINGLE(TAIKO_A_CDC_CONN_RX7_B3_CTL, 0, 5, rx_mix2_text); |
| 1244 | |
| 1245 | static const struct soc_enum rx7_mix2_inp2_chain_enum = |
| 1246 | SOC_ENUM_SINGLE(TAIKO_A_CDC_CONN_RX7_B3_CTL, 3, 5, rx_mix2_text); |
| 1247 | |
Tanya Finkel | daaa6d1 | 2012-10-25 11:22:48 +0200 | [diff] [blame] | 1248 | static const struct soc_enum rx_rdac5_enum = |
| 1249 | SOC_ENUM_SINGLE(TAIKO_A_CDC_CONN_MISC, 2, 2, rx_rdac5_text); |
Kiran Kandi | c3b2440 | 2012-06-11 00:05:59 -0700 | [diff] [blame] | 1250 | |
Tanya Finkel | daaa6d1 | 2012-10-25 11:22:48 +0200 | [diff] [blame] | 1251 | static const struct soc_enum rx_rdac7_enum = |
| 1252 | SOC_ENUM_SINGLE(TAIKO_A_CDC_CONN_MISC, 1, 2, rx_rdac7_text); |
Kiran Kandi | c3b2440 | 2012-06-11 00:05:59 -0700 | [diff] [blame] | 1253 | |
| 1254 | static const struct soc_enum sb_tx1_mux_enum = |
| 1255 | SOC_ENUM_SINGLE(TAIKO_A_CDC_CONN_TX_SB_B1_CTL, 0, 9, sb_tx1_mux_text); |
| 1256 | |
| 1257 | static const struct soc_enum sb_tx2_mux_enum = |
| 1258 | SOC_ENUM_SINGLE(TAIKO_A_CDC_CONN_TX_SB_B2_CTL, 0, 9, sb_tx2_mux_text); |
| 1259 | |
| 1260 | static const struct soc_enum sb_tx3_mux_enum = |
| 1261 | SOC_ENUM_SINGLE(TAIKO_A_CDC_CONN_TX_SB_B3_CTL, 0, 9, sb_tx3_mux_text); |
| 1262 | |
| 1263 | static const struct soc_enum sb_tx4_mux_enum = |
| 1264 | SOC_ENUM_SINGLE(TAIKO_A_CDC_CONN_TX_SB_B4_CTL, 0, 9, sb_tx4_mux_text); |
| 1265 | |
| 1266 | static const struct soc_enum sb_tx5_mux_enum = |
| 1267 | SOC_ENUM_SINGLE(TAIKO_A_CDC_CONN_TX_SB_B5_CTL, 0, 9, sb_tx5_mux_text); |
| 1268 | |
| 1269 | static const struct soc_enum sb_tx6_mux_enum = |
| 1270 | SOC_ENUM_SINGLE(TAIKO_A_CDC_CONN_TX_SB_B6_CTL, 0, 9, sb_tx6_mux_text); |
| 1271 | |
| 1272 | static const struct soc_enum sb_tx7_mux_enum = |
| 1273 | SOC_ENUM_SINGLE(TAIKO_A_CDC_CONN_TX_SB_B7_CTL, 0, 18, |
| 1274 | sb_tx7_to_tx10_mux_text); |
| 1275 | |
| 1276 | static const struct soc_enum sb_tx8_mux_enum = |
| 1277 | SOC_ENUM_SINGLE(TAIKO_A_CDC_CONN_TX_SB_B8_CTL, 0, 18, |
| 1278 | sb_tx7_to_tx10_mux_text); |
| 1279 | |
| 1280 | static const struct soc_enum sb_tx9_mux_enum = |
| 1281 | SOC_ENUM_SINGLE(TAIKO_A_CDC_CONN_TX_SB_B9_CTL, 0, 18, |
| 1282 | sb_tx7_to_tx10_mux_text); |
| 1283 | |
| 1284 | static const struct soc_enum sb_tx10_mux_enum = |
| 1285 | SOC_ENUM_SINGLE(TAIKO_A_CDC_CONN_TX_SB_B10_CTL, 0, 18, |
| 1286 | sb_tx7_to_tx10_mux_text); |
| 1287 | |
| 1288 | static const struct soc_enum dec1_mux_enum = |
| 1289 | SOC_ENUM_SINGLE(TAIKO_A_CDC_CONN_TX_B1_CTL, 0, 3, dec1_mux_text); |
| 1290 | |
| 1291 | static const struct soc_enum dec2_mux_enum = |
| 1292 | SOC_ENUM_SINGLE(TAIKO_A_CDC_CONN_TX_B1_CTL, 2, 3, dec2_mux_text); |
| 1293 | |
| 1294 | static const struct soc_enum dec3_mux_enum = |
| 1295 | SOC_ENUM_SINGLE(TAIKO_A_CDC_CONN_TX_B1_CTL, 4, 3, dec3_mux_text); |
| 1296 | |
| 1297 | static const struct soc_enum dec4_mux_enum = |
| 1298 | SOC_ENUM_SINGLE(TAIKO_A_CDC_CONN_TX_B1_CTL, 6, 3, dec4_mux_text); |
| 1299 | |
| 1300 | static const struct soc_enum dec5_mux_enum = |
| 1301 | SOC_ENUM_SINGLE(TAIKO_A_CDC_CONN_TX_B2_CTL, 0, 3, dec5_mux_text); |
| 1302 | |
| 1303 | static const struct soc_enum dec6_mux_enum = |
| 1304 | SOC_ENUM_SINGLE(TAIKO_A_CDC_CONN_TX_B2_CTL, 2, 3, dec6_mux_text); |
| 1305 | |
| 1306 | static const struct soc_enum dec7_mux_enum = |
| 1307 | SOC_ENUM_SINGLE(TAIKO_A_CDC_CONN_TX_B2_CTL, 4, 7, dec7_mux_text); |
| 1308 | |
| 1309 | static const struct soc_enum dec8_mux_enum = |
| 1310 | SOC_ENUM_SINGLE(TAIKO_A_CDC_CONN_TX_B3_CTL, 0, 7, dec8_mux_text); |
| 1311 | |
| 1312 | static const struct soc_enum dec9_mux_enum = |
| 1313 | SOC_ENUM_SINGLE(TAIKO_A_CDC_CONN_TX_B3_CTL, 3, 8, dec9_mux_text); |
| 1314 | |
| 1315 | static const struct soc_enum dec10_mux_enum = |
| 1316 | SOC_ENUM_SINGLE(TAIKO_A_CDC_CONN_TX_B4_CTL, 0, 8, dec10_mux_text); |
| 1317 | |
| 1318 | static const struct soc_enum anc1_mux_enum = |
| 1319 | SOC_ENUM_SINGLE(TAIKO_A_CDC_CONN_ANC_B1_CTL, 0, 16, anc_mux_text); |
| 1320 | |
| 1321 | static const struct soc_enum anc2_mux_enum = |
| 1322 | SOC_ENUM_SINGLE(TAIKO_A_CDC_CONN_ANC_B1_CTL, 4, 16, anc_mux_text); |
| 1323 | |
| 1324 | static const struct soc_enum anc1_fb_mux_enum = |
| 1325 | SOC_ENUM_SINGLE(TAIKO_A_CDC_CONN_ANC_B2_CTL, 0, 3, anc1_fb_mux_text); |
| 1326 | |
| 1327 | static const struct soc_enum iir1_inp1_mux_enum = |
| 1328 | SOC_ENUM_SINGLE(TAIKO_A_CDC_CONN_EQ1_B1_CTL, 0, 18, iir1_inp1_text); |
| 1329 | |
| 1330 | static const struct snd_kcontrol_new rx_mix1_inp1_mux = |
| 1331 | SOC_DAPM_ENUM("RX1 MIX1 INP1 Mux", rx_mix1_inp1_chain_enum); |
| 1332 | |
| 1333 | static const struct snd_kcontrol_new rx_mix1_inp2_mux = |
| 1334 | SOC_DAPM_ENUM("RX1 MIX1 INP2 Mux", rx_mix1_inp2_chain_enum); |
| 1335 | |
| 1336 | static const struct snd_kcontrol_new rx_mix1_inp3_mux = |
| 1337 | SOC_DAPM_ENUM("RX1 MIX1 INP3 Mux", rx_mix1_inp3_chain_enum); |
| 1338 | |
| 1339 | static const struct snd_kcontrol_new rx2_mix1_inp1_mux = |
| 1340 | SOC_DAPM_ENUM("RX2 MIX1 INP1 Mux", rx2_mix1_inp1_chain_enum); |
| 1341 | |
| 1342 | static const struct snd_kcontrol_new rx2_mix1_inp2_mux = |
| 1343 | SOC_DAPM_ENUM("RX2 MIX1 INP2 Mux", rx2_mix1_inp2_chain_enum); |
| 1344 | |
| 1345 | static const struct snd_kcontrol_new rx3_mix1_inp1_mux = |
| 1346 | SOC_DAPM_ENUM("RX3 MIX1 INP1 Mux", rx3_mix1_inp1_chain_enum); |
| 1347 | |
| 1348 | static const struct snd_kcontrol_new rx3_mix1_inp2_mux = |
| 1349 | SOC_DAPM_ENUM("RX3 MIX1 INP2 Mux", rx3_mix1_inp2_chain_enum); |
| 1350 | |
| 1351 | static const struct snd_kcontrol_new rx4_mix1_inp1_mux = |
| 1352 | SOC_DAPM_ENUM("RX4 MIX1 INP1 Mux", rx4_mix1_inp1_chain_enum); |
| 1353 | |
| 1354 | static const struct snd_kcontrol_new rx4_mix1_inp2_mux = |
| 1355 | SOC_DAPM_ENUM("RX4 MIX1 INP2 Mux", rx4_mix1_inp2_chain_enum); |
| 1356 | |
| 1357 | static const struct snd_kcontrol_new rx5_mix1_inp1_mux = |
| 1358 | SOC_DAPM_ENUM("RX5 MIX1 INP1 Mux", rx5_mix1_inp1_chain_enum); |
| 1359 | |
| 1360 | static const struct snd_kcontrol_new rx5_mix1_inp2_mux = |
| 1361 | SOC_DAPM_ENUM("RX5 MIX1 INP2 Mux", rx5_mix1_inp2_chain_enum); |
| 1362 | |
| 1363 | static const struct snd_kcontrol_new rx6_mix1_inp1_mux = |
| 1364 | SOC_DAPM_ENUM("RX6 MIX1 INP1 Mux", rx6_mix1_inp1_chain_enum); |
| 1365 | |
| 1366 | static const struct snd_kcontrol_new rx6_mix1_inp2_mux = |
| 1367 | SOC_DAPM_ENUM("RX6 MIX1 INP2 Mux", rx6_mix1_inp2_chain_enum); |
| 1368 | |
| 1369 | static const struct snd_kcontrol_new rx7_mix1_inp1_mux = |
| 1370 | SOC_DAPM_ENUM("RX7 MIX1 INP1 Mux", rx7_mix1_inp1_chain_enum); |
| 1371 | |
| 1372 | static const struct snd_kcontrol_new rx7_mix1_inp2_mux = |
| 1373 | SOC_DAPM_ENUM("RX7 MIX1 INP2 Mux", rx7_mix1_inp2_chain_enum); |
| 1374 | |
| 1375 | static const struct snd_kcontrol_new rx1_mix2_inp1_mux = |
| 1376 | SOC_DAPM_ENUM("RX1 MIX2 INP1 Mux", rx1_mix2_inp1_chain_enum); |
| 1377 | |
| 1378 | static const struct snd_kcontrol_new rx1_mix2_inp2_mux = |
| 1379 | SOC_DAPM_ENUM("RX1 MIX2 INP2 Mux", rx1_mix2_inp2_chain_enum); |
| 1380 | |
| 1381 | static const struct snd_kcontrol_new rx2_mix2_inp1_mux = |
| 1382 | SOC_DAPM_ENUM("RX2 MIX2 INP1 Mux", rx2_mix2_inp1_chain_enum); |
| 1383 | |
| 1384 | static const struct snd_kcontrol_new rx2_mix2_inp2_mux = |
| 1385 | SOC_DAPM_ENUM("RX2 MIX2 INP2 Mux", rx2_mix2_inp2_chain_enum); |
| 1386 | |
| 1387 | static const struct snd_kcontrol_new rx7_mix2_inp1_mux = |
| 1388 | SOC_DAPM_ENUM("RX7 MIX2 INP1 Mux", rx7_mix2_inp1_chain_enum); |
| 1389 | |
| 1390 | static const struct snd_kcontrol_new rx7_mix2_inp2_mux = |
| 1391 | SOC_DAPM_ENUM("RX7 MIX2 INP2 Mux", rx7_mix2_inp2_chain_enum); |
| 1392 | |
Tanya Finkel | daaa6d1 | 2012-10-25 11:22:48 +0200 | [diff] [blame] | 1393 | static const struct snd_kcontrol_new rx_dac5_mux = |
| 1394 | SOC_DAPM_ENUM("RDAC5 MUX Mux", rx_rdac5_enum); |
Kiran Kandi | c3b2440 | 2012-06-11 00:05:59 -0700 | [diff] [blame] | 1395 | |
Tanya Finkel | daaa6d1 | 2012-10-25 11:22:48 +0200 | [diff] [blame] | 1396 | static const struct snd_kcontrol_new rx_dac7_mux = |
| 1397 | SOC_DAPM_ENUM("RDAC7 MUX Mux", rx_rdac7_enum); |
Kiran Kandi | c3b2440 | 2012-06-11 00:05:59 -0700 | [diff] [blame] | 1398 | |
| 1399 | static const struct snd_kcontrol_new sb_tx1_mux = |
| 1400 | SOC_DAPM_ENUM("SLIM TX1 MUX Mux", sb_tx1_mux_enum); |
| 1401 | |
| 1402 | static const struct snd_kcontrol_new sb_tx2_mux = |
| 1403 | SOC_DAPM_ENUM("SLIM TX2 MUX Mux", sb_tx2_mux_enum); |
| 1404 | |
| 1405 | static const struct snd_kcontrol_new sb_tx3_mux = |
| 1406 | SOC_DAPM_ENUM("SLIM TX3 MUX Mux", sb_tx3_mux_enum); |
| 1407 | |
| 1408 | static const struct snd_kcontrol_new sb_tx4_mux = |
| 1409 | SOC_DAPM_ENUM("SLIM TX4 MUX Mux", sb_tx4_mux_enum); |
| 1410 | |
| 1411 | static const struct snd_kcontrol_new sb_tx5_mux = |
| 1412 | SOC_DAPM_ENUM("SLIM TX5 MUX Mux", sb_tx5_mux_enum); |
| 1413 | |
| 1414 | static const struct snd_kcontrol_new sb_tx6_mux = |
| 1415 | SOC_DAPM_ENUM("SLIM TX6 MUX Mux", sb_tx6_mux_enum); |
| 1416 | |
| 1417 | static const struct snd_kcontrol_new sb_tx7_mux = |
| 1418 | SOC_DAPM_ENUM("SLIM TX7 MUX Mux", sb_tx7_mux_enum); |
| 1419 | |
| 1420 | static const struct snd_kcontrol_new sb_tx8_mux = |
| 1421 | SOC_DAPM_ENUM("SLIM TX8 MUX Mux", sb_tx8_mux_enum); |
| 1422 | |
| 1423 | static const struct snd_kcontrol_new sb_tx9_mux = |
| 1424 | SOC_DAPM_ENUM("SLIM TX9 MUX Mux", sb_tx9_mux_enum); |
| 1425 | |
| 1426 | static const struct snd_kcontrol_new sb_tx10_mux = |
| 1427 | SOC_DAPM_ENUM("SLIM TX10 MUX Mux", sb_tx10_mux_enum); |
| 1428 | |
| 1429 | |
| 1430 | static int wcd9320_put_dec_enum(struct snd_kcontrol *kcontrol, |
| 1431 | struct snd_ctl_elem_value *ucontrol) |
| 1432 | { |
| 1433 | struct snd_soc_dapm_widget_list *wlist = snd_kcontrol_chip(kcontrol); |
| 1434 | struct snd_soc_dapm_widget *w = wlist->widgets[0]; |
| 1435 | struct snd_soc_codec *codec = w->codec; |
| 1436 | struct soc_enum *e = (struct soc_enum *)kcontrol->private_value; |
| 1437 | unsigned int dec_mux, decimator; |
| 1438 | char *dec_name = NULL; |
| 1439 | char *widget_name = NULL; |
| 1440 | char *temp; |
| 1441 | u16 tx_mux_ctl_reg; |
| 1442 | u8 adc_dmic_sel = 0x0; |
| 1443 | int ret = 0; |
| 1444 | |
| 1445 | if (ucontrol->value.enumerated.item[0] > e->max - 1) |
| 1446 | return -EINVAL; |
| 1447 | |
| 1448 | dec_mux = ucontrol->value.enumerated.item[0]; |
| 1449 | |
| 1450 | widget_name = kstrndup(w->name, 15, GFP_KERNEL); |
| 1451 | if (!widget_name) |
| 1452 | return -ENOMEM; |
| 1453 | temp = widget_name; |
| 1454 | |
| 1455 | dec_name = strsep(&widget_name, " "); |
| 1456 | widget_name = temp; |
| 1457 | if (!dec_name) { |
| 1458 | pr_err("%s: Invalid decimator = %s\n", __func__, w->name); |
| 1459 | ret = -EINVAL; |
| 1460 | goto out; |
| 1461 | } |
| 1462 | |
| 1463 | ret = kstrtouint(strpbrk(dec_name, "123456789"), 10, &decimator); |
| 1464 | if (ret < 0) { |
| 1465 | pr_err("%s: Invalid decimator = %s\n", __func__, dec_name); |
| 1466 | ret = -EINVAL; |
| 1467 | goto out; |
| 1468 | } |
| 1469 | |
| 1470 | dev_dbg(w->dapm->dev, "%s(): widget = %s decimator = %u dec_mux = %u\n" |
| 1471 | , __func__, w->name, decimator, dec_mux); |
| 1472 | |
| 1473 | |
| 1474 | switch (decimator) { |
| 1475 | case 1: |
| 1476 | case 2: |
| 1477 | case 3: |
| 1478 | case 4: |
| 1479 | case 5: |
| 1480 | case 6: |
| 1481 | if (dec_mux == 1) |
| 1482 | adc_dmic_sel = 0x1; |
| 1483 | else |
| 1484 | adc_dmic_sel = 0x0; |
| 1485 | break; |
| 1486 | case 7: |
| 1487 | case 8: |
| 1488 | case 9: |
| 1489 | case 10: |
| 1490 | if ((dec_mux == 1) || (dec_mux == 2)) |
| 1491 | adc_dmic_sel = 0x1; |
| 1492 | else |
| 1493 | adc_dmic_sel = 0x0; |
| 1494 | break; |
| 1495 | default: |
| 1496 | pr_err("%s: Invalid Decimator = %u\n", __func__, decimator); |
| 1497 | ret = -EINVAL; |
| 1498 | goto out; |
| 1499 | } |
| 1500 | |
| 1501 | tx_mux_ctl_reg = TAIKO_A_CDC_TX1_MUX_CTL + 8 * (decimator - 1); |
| 1502 | |
| 1503 | snd_soc_update_bits(codec, tx_mux_ctl_reg, 0x1, adc_dmic_sel); |
| 1504 | |
| 1505 | ret = snd_soc_dapm_put_enum_double(kcontrol, ucontrol); |
| 1506 | |
| 1507 | out: |
| 1508 | kfree(widget_name); |
| 1509 | return ret; |
| 1510 | } |
| 1511 | |
| 1512 | #define WCD9320_DEC_ENUM(xname, xenum) \ |
| 1513 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \ |
| 1514 | .info = snd_soc_info_enum_double, \ |
| 1515 | .get = snd_soc_dapm_get_enum_double, \ |
| 1516 | .put = wcd9320_put_dec_enum, \ |
| 1517 | .private_value = (unsigned long)&xenum } |
| 1518 | |
| 1519 | static const struct snd_kcontrol_new dec1_mux = |
| 1520 | WCD9320_DEC_ENUM("DEC1 MUX Mux", dec1_mux_enum); |
| 1521 | |
| 1522 | static const struct snd_kcontrol_new dec2_mux = |
| 1523 | WCD9320_DEC_ENUM("DEC2 MUX Mux", dec2_mux_enum); |
| 1524 | |
| 1525 | static const struct snd_kcontrol_new dec3_mux = |
| 1526 | WCD9320_DEC_ENUM("DEC3 MUX Mux", dec3_mux_enum); |
| 1527 | |
| 1528 | static const struct snd_kcontrol_new dec4_mux = |
| 1529 | WCD9320_DEC_ENUM("DEC4 MUX Mux", dec4_mux_enum); |
| 1530 | |
| 1531 | static const struct snd_kcontrol_new dec5_mux = |
| 1532 | WCD9320_DEC_ENUM("DEC5 MUX Mux", dec5_mux_enum); |
| 1533 | |
| 1534 | static const struct snd_kcontrol_new dec6_mux = |
| 1535 | WCD9320_DEC_ENUM("DEC6 MUX Mux", dec6_mux_enum); |
| 1536 | |
| 1537 | static const struct snd_kcontrol_new dec7_mux = |
| 1538 | WCD9320_DEC_ENUM("DEC7 MUX Mux", dec7_mux_enum); |
| 1539 | |
| 1540 | static const struct snd_kcontrol_new dec8_mux = |
| 1541 | WCD9320_DEC_ENUM("DEC8 MUX Mux", dec8_mux_enum); |
| 1542 | |
| 1543 | static const struct snd_kcontrol_new dec9_mux = |
| 1544 | WCD9320_DEC_ENUM("DEC9 MUX Mux", dec9_mux_enum); |
| 1545 | |
| 1546 | static const struct snd_kcontrol_new dec10_mux = |
| 1547 | WCD9320_DEC_ENUM("DEC10 MUX Mux", dec10_mux_enum); |
| 1548 | |
| 1549 | static const struct snd_kcontrol_new iir1_inp1_mux = |
| 1550 | SOC_DAPM_ENUM("IIR1 INP1 Mux", iir1_inp1_mux_enum); |
| 1551 | |
| 1552 | static const struct snd_kcontrol_new anc1_mux = |
| 1553 | SOC_DAPM_ENUM("ANC1 MUX Mux", anc1_mux_enum); |
| 1554 | |
| 1555 | static const struct snd_kcontrol_new anc2_mux = |
| 1556 | SOC_DAPM_ENUM("ANC2 MUX Mux", anc2_mux_enum); |
| 1557 | |
| 1558 | static const struct snd_kcontrol_new anc1_fb_mux = |
| 1559 | SOC_DAPM_ENUM("ANC1 FB MUX Mux", anc1_fb_mux_enum); |
| 1560 | |
| 1561 | static const struct snd_kcontrol_new dac1_switch[] = { |
| 1562 | SOC_DAPM_SINGLE("Switch", TAIKO_A_RX_EAR_EN, 5, 1, 0) |
| 1563 | }; |
| 1564 | static const struct snd_kcontrol_new hphl_switch[] = { |
| 1565 | SOC_DAPM_SINGLE("Switch", TAIKO_A_RX_HPH_L_DAC_CTL, 6, 1, 0) |
| 1566 | }; |
| 1567 | |
| 1568 | static const struct snd_kcontrol_new hphl_pa_mix[] = { |
| 1569 | SOC_DAPM_SINGLE("AUX_PGA_L Switch", TAIKO_A_RX_PA_AUX_IN_CONN, |
| 1570 | 7, 1, 0), |
| 1571 | }; |
| 1572 | |
| 1573 | static const struct snd_kcontrol_new hphr_pa_mix[] = { |
| 1574 | SOC_DAPM_SINGLE("AUX_PGA_R Switch", TAIKO_A_RX_PA_AUX_IN_CONN, |
| 1575 | 6, 1, 0), |
| 1576 | }; |
| 1577 | |
| 1578 | static const struct snd_kcontrol_new ear_pa_mix[] = { |
| 1579 | SOC_DAPM_SINGLE("AUX_PGA_L Switch", TAIKO_A_RX_PA_AUX_IN_CONN, |
| 1580 | 5, 1, 0), |
| 1581 | }; |
| 1582 | static const struct snd_kcontrol_new lineout1_pa_mix[] = { |
| 1583 | SOC_DAPM_SINGLE("AUX_PGA_L Switch", TAIKO_A_RX_PA_AUX_IN_CONN, |
| 1584 | 4, 1, 0), |
| 1585 | }; |
| 1586 | |
| 1587 | static const struct snd_kcontrol_new lineout2_pa_mix[] = { |
| 1588 | SOC_DAPM_SINGLE("AUX_PGA_R Switch", TAIKO_A_RX_PA_AUX_IN_CONN, |
| 1589 | 3, 1, 0), |
| 1590 | }; |
| 1591 | |
| 1592 | static const struct snd_kcontrol_new lineout3_pa_mix[] = { |
| 1593 | SOC_DAPM_SINGLE("AUX_PGA_L Switch", TAIKO_A_RX_PA_AUX_IN_CONN, |
| 1594 | 2, 1, 0), |
| 1595 | }; |
| 1596 | |
| 1597 | static const struct snd_kcontrol_new lineout4_pa_mix[] = { |
| 1598 | SOC_DAPM_SINGLE("AUX_PGA_R Switch", TAIKO_A_RX_PA_AUX_IN_CONN, |
| 1599 | 1, 1, 0), |
| 1600 | }; |
| 1601 | |
| 1602 | static const struct snd_kcontrol_new lineout3_ground_switch = |
| 1603 | SOC_DAPM_SINGLE("Switch", TAIKO_A_RX_LINE_3_DAC_CTL, 6, 1, 0); |
| 1604 | |
| 1605 | static const struct snd_kcontrol_new lineout4_ground_switch = |
| 1606 | SOC_DAPM_SINGLE("Switch", TAIKO_A_RX_LINE_4_DAC_CTL, 6, 1, 0); |
| 1607 | |
Kuirong Wang | 906ac47 | 2012-07-09 12:54:44 -0700 | [diff] [blame] | 1608 | /* virtual port entries */ |
| 1609 | static int slim_tx_mixer_get(struct snd_kcontrol *kcontrol, |
| 1610 | struct snd_ctl_elem_value *ucontrol) |
| 1611 | { |
| 1612 | struct snd_soc_dapm_widget_list *wlist = snd_kcontrol_chip(kcontrol); |
| 1613 | struct snd_soc_dapm_widget *widget = wlist->widgets[0]; |
| 1614 | |
| 1615 | ucontrol->value.integer.value[0] = widget->value; |
| 1616 | return 0; |
| 1617 | } |
| 1618 | |
| 1619 | static int slim_tx_mixer_put(struct snd_kcontrol *kcontrol, |
| 1620 | struct snd_ctl_elem_value *ucontrol) |
| 1621 | { |
| 1622 | struct snd_soc_dapm_widget_list *wlist = snd_kcontrol_chip(kcontrol); |
| 1623 | struct snd_soc_dapm_widget *widget = wlist->widgets[0]; |
| 1624 | struct snd_soc_codec *codec = widget->codec; |
| 1625 | struct taiko_priv *taiko_p = snd_soc_codec_get_drvdata(codec); |
| 1626 | struct wcd9xxx *core = dev_get_drvdata(codec->dev->parent); |
| 1627 | struct soc_multi_mixer_control *mixer = |
| 1628 | ((struct soc_multi_mixer_control *)kcontrol->private_value); |
| 1629 | u32 dai_id = widget->shift; |
| 1630 | u32 port_id = mixer->shift; |
| 1631 | u32 enable = ucontrol->value.integer.value[0]; |
Venkat Sudhir | 96dd28c | 2012-12-04 17:00:19 -0800 | [diff] [blame] | 1632 | u32 vtable = vport_check_table[dai_id]; |
Kuirong Wang | 906ac47 | 2012-07-09 12:54:44 -0700 | [diff] [blame] | 1633 | |
| 1634 | |
| 1635 | pr_debug("%s: wname %s cname %s value %u shift %d item %ld\n", __func__, |
| 1636 | widget->name, ucontrol->id.name, widget->value, widget->shift, |
| 1637 | ucontrol->value.integer.value[0]); |
| 1638 | |
| 1639 | mutex_lock(&codec->mutex); |
| 1640 | |
| 1641 | if (taiko_p->intf_type != WCD9XXX_INTERFACE_TYPE_SLIMBUS) { |
| 1642 | if (dai_id != AIF1_CAP) { |
| 1643 | dev_err(codec->dev, "%s: invalid AIF for I2C mode\n", |
| 1644 | __func__); |
| 1645 | mutex_unlock(&codec->mutex); |
| 1646 | return -EINVAL; |
| 1647 | } |
| 1648 | } |
Venkat Sudhir | a41630a | 2012-10-27 00:57:31 -0700 | [diff] [blame] | 1649 | switch (dai_id) { |
| 1650 | case AIF1_CAP: |
| 1651 | case AIF2_CAP: |
| 1652 | case AIF3_CAP: |
| 1653 | /* only add to the list if value not set |
| 1654 | */ |
| 1655 | if (enable && !(widget->value & 1 << port_id)) { |
Venkat Sudhir | 96dd28c | 2012-12-04 17:00:19 -0800 | [diff] [blame] | 1656 | |
| 1657 | if (taiko_p->intf_type == |
| 1658 | WCD9XXX_INTERFACE_TYPE_SLIMBUS) |
| 1659 | vtable = vport_check_table[dai_id]; |
| 1660 | if (taiko_p->intf_type == |
| 1661 | WCD9XXX_INTERFACE_TYPE_I2C) |
| 1662 | vtable = vport_i2s_check_table[dai_id]; |
| 1663 | |
Venkat Sudhir | a41630a | 2012-10-27 00:57:31 -0700 | [diff] [blame] | 1664 | if (wcd9xxx_tx_vport_validation( |
Venkat Sudhir | 96dd28c | 2012-12-04 17:00:19 -0800 | [diff] [blame] | 1665 | vtable, |
Kuirong Wang | dcc392e | 2012-10-19 00:33:38 -0700 | [diff] [blame] | 1666 | port_id, |
| 1667 | taiko_p->dai)) { |
Venkat Sudhir | a41630a | 2012-10-27 00:57:31 -0700 | [diff] [blame] | 1668 | pr_debug("%s: TX%u is used by other\n" |
| 1669 | "virtual port\n", |
| 1670 | __func__, port_id + 1); |
| 1671 | mutex_unlock(&codec->mutex); |
| 1672 | return -EINVAL; |
| 1673 | } |
| 1674 | widget->value |= 1 << port_id; |
| 1675 | list_add_tail(&core->tx_chs[port_id].list, |
Kuirong Wang | 906ac47 | 2012-07-09 12:54:44 -0700 | [diff] [blame] | 1676 | &taiko_p->dai[dai_id].wcd9xxx_ch_list |
Venkat Sudhir | a41630a | 2012-10-27 00:57:31 -0700 | [diff] [blame] | 1677 | ); |
| 1678 | } else if (!enable && (widget->value & 1 << port_id)) { |
| 1679 | widget->value &= ~(1 << port_id); |
| 1680 | list_del_init(&core->tx_chs[port_id].list); |
| 1681 | } else { |
| 1682 | if (enable) |
| 1683 | pr_debug("%s: TX%u port is used by\n" |
| 1684 | "this virtual port\n", |
| 1685 | __func__, port_id + 1); |
| 1686 | else |
| 1687 | pr_debug("%s: TX%u port is not used by\n" |
| 1688 | "this virtual port\n", |
| 1689 | __func__, port_id + 1); |
| 1690 | /* avoid update power function */ |
| 1691 | mutex_unlock(&codec->mutex); |
| 1692 | return 0; |
| 1693 | } |
| 1694 | break; |
| 1695 | default: |
| 1696 | pr_err("Unknown AIF %d\n", dai_id); |
Kuirong Wang | 906ac47 | 2012-07-09 12:54:44 -0700 | [diff] [blame] | 1697 | mutex_unlock(&codec->mutex); |
Venkat Sudhir | a41630a | 2012-10-27 00:57:31 -0700 | [diff] [blame] | 1698 | return -EINVAL; |
Kuirong Wang | 906ac47 | 2012-07-09 12:54:44 -0700 | [diff] [blame] | 1699 | } |
Kuirong Wang | 906ac47 | 2012-07-09 12:54:44 -0700 | [diff] [blame] | 1700 | pr_debug("%s: name %s sname %s updated value %u shift %d\n", __func__, |
| 1701 | widget->name, widget->sname, widget->value, widget->shift); |
| 1702 | |
| 1703 | snd_soc_dapm_mixer_update_power(widget, kcontrol, enable); |
| 1704 | |
| 1705 | mutex_unlock(&codec->mutex); |
| 1706 | return 0; |
| 1707 | } |
| 1708 | |
| 1709 | static int slim_rx_mux_get(struct snd_kcontrol *kcontrol, |
| 1710 | struct snd_ctl_elem_value *ucontrol) |
| 1711 | { |
| 1712 | struct snd_soc_dapm_widget_list *wlist = snd_kcontrol_chip(kcontrol); |
| 1713 | struct snd_soc_dapm_widget *widget = wlist->widgets[0]; |
| 1714 | |
| 1715 | ucontrol->value.enumerated.item[0] = widget->value; |
| 1716 | return 0; |
| 1717 | } |
| 1718 | |
| 1719 | static const char *const slim_rx_mux_text[] = { |
| 1720 | "ZERO", "AIF1_PB", "AIF2_PB", "AIF3_PB" |
| 1721 | }; |
| 1722 | |
| 1723 | static int slim_rx_mux_put(struct snd_kcontrol *kcontrol, |
| 1724 | struct snd_ctl_elem_value *ucontrol) |
| 1725 | { |
| 1726 | struct snd_soc_dapm_widget_list *wlist = snd_kcontrol_chip(kcontrol); |
| 1727 | struct snd_soc_dapm_widget *widget = wlist->widgets[0]; |
| 1728 | struct snd_soc_codec *codec = widget->codec; |
| 1729 | struct taiko_priv *taiko_p = snd_soc_codec_get_drvdata(codec); |
| 1730 | struct wcd9xxx *core = dev_get_drvdata(codec->dev->parent); |
| 1731 | struct soc_enum *e = (struct soc_enum *)kcontrol->private_value; |
| 1732 | u32 port_id = widget->shift; |
| 1733 | |
| 1734 | pr_debug("%s: wname %s cname %s value %u shift %d item %ld\n", __func__, |
| 1735 | widget->name, ucontrol->id.name, widget->value, widget->shift, |
| 1736 | ucontrol->value.integer.value[0]); |
| 1737 | |
| 1738 | widget->value = ucontrol->value.enumerated.item[0]; |
| 1739 | |
| 1740 | mutex_lock(&codec->mutex); |
| 1741 | |
| 1742 | if (taiko_p->intf_type != WCD9XXX_INTERFACE_TYPE_SLIMBUS) { |
Venkat Sudhir | 994193b | 2012-12-17 17:30:51 -0800 | [diff] [blame] | 1743 | if (widget->value > 2) { |
Kuirong Wang | 906ac47 | 2012-07-09 12:54:44 -0700 | [diff] [blame] | 1744 | dev_err(codec->dev, "%s: invalid AIF for I2C mode\n", |
| 1745 | __func__); |
Kuirong Wang | dcc392e | 2012-10-19 00:33:38 -0700 | [diff] [blame] | 1746 | goto err; |
Kuirong Wang | 906ac47 | 2012-07-09 12:54:44 -0700 | [diff] [blame] | 1747 | } |
| 1748 | } |
| 1749 | /* value need to match the Virtual port and AIF number |
| 1750 | */ |
| 1751 | switch (widget->value) { |
| 1752 | case 0: |
| 1753 | list_del_init(&core->rx_chs[port_id].list); |
| 1754 | break; |
| 1755 | case 1: |
Kuirong Wang | dcc392e | 2012-10-19 00:33:38 -0700 | [diff] [blame] | 1756 | if (wcd9xxx_rx_vport_validation(port_id + core->num_tx_port, |
| 1757 | &taiko_p->dai[AIF1_PB].wcd9xxx_ch_list)) |
| 1758 | goto pr_err; |
Kuirong Wang | 906ac47 | 2012-07-09 12:54:44 -0700 | [diff] [blame] | 1759 | list_add_tail(&core->rx_chs[port_id].list, |
| 1760 | &taiko_p->dai[AIF1_PB].wcd9xxx_ch_list); |
| 1761 | break; |
| 1762 | case 2: |
Kuirong Wang | dcc392e | 2012-10-19 00:33:38 -0700 | [diff] [blame] | 1763 | if (wcd9xxx_rx_vport_validation(port_id + core->num_tx_port, |
Gopikrishnaiah Anandan | a8aec1f | 2013-01-23 14:26:27 -0500 | [diff] [blame] | 1764 | &taiko_p->dai[AIF2_PB].wcd9xxx_ch_list)) |
Kuirong Wang | dcc392e | 2012-10-19 00:33:38 -0700 | [diff] [blame] | 1765 | goto pr_err; |
Kuirong Wang | 906ac47 | 2012-07-09 12:54:44 -0700 | [diff] [blame] | 1766 | list_add_tail(&core->rx_chs[port_id].list, |
| 1767 | &taiko_p->dai[AIF2_PB].wcd9xxx_ch_list); |
| 1768 | break; |
| 1769 | case 3: |
Kuirong Wang | dcc392e | 2012-10-19 00:33:38 -0700 | [diff] [blame] | 1770 | if (wcd9xxx_rx_vport_validation(port_id + core->num_tx_port, |
Gopikrishnaiah Anandan | a8aec1f | 2013-01-23 14:26:27 -0500 | [diff] [blame] | 1771 | &taiko_p->dai[AIF3_PB].wcd9xxx_ch_list)) |
Kuirong Wang | dcc392e | 2012-10-19 00:33:38 -0700 | [diff] [blame] | 1772 | goto pr_err; |
Kuirong Wang | 906ac47 | 2012-07-09 12:54:44 -0700 | [diff] [blame] | 1773 | list_add_tail(&core->rx_chs[port_id].list, |
| 1774 | &taiko_p->dai[AIF3_PB].wcd9xxx_ch_list); |
| 1775 | break; |
| 1776 | default: |
| 1777 | pr_err("Unknown AIF %d\n", widget->value); |
Kuirong Wang | dcc392e | 2012-10-19 00:33:38 -0700 | [diff] [blame] | 1778 | goto err; |
Kuirong Wang | 906ac47 | 2012-07-09 12:54:44 -0700 | [diff] [blame] | 1779 | } |
| 1780 | |
| 1781 | snd_soc_dapm_mux_update_power(widget, kcontrol, 1, widget->value, e); |
| 1782 | |
| 1783 | mutex_unlock(&codec->mutex); |
| 1784 | return 0; |
Kuirong Wang | dcc392e | 2012-10-19 00:33:38 -0700 | [diff] [blame] | 1785 | pr_err: |
| 1786 | pr_err("%s: RX%u is used by current requesting AIF_PB itself\n", |
| 1787 | __func__, port_id + 1); |
| 1788 | err: |
| 1789 | mutex_unlock(&codec->mutex); |
| 1790 | return -EINVAL; |
Kuirong Wang | 906ac47 | 2012-07-09 12:54:44 -0700 | [diff] [blame] | 1791 | } |
| 1792 | |
| 1793 | static const struct soc_enum slim_rx_mux_enum = |
| 1794 | SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(slim_rx_mux_text), slim_rx_mux_text); |
| 1795 | |
| 1796 | static const struct snd_kcontrol_new slim_rx_mux[TAIKO_RX_MAX] = { |
| 1797 | SOC_DAPM_ENUM_EXT("SLIM RX1 Mux", slim_rx_mux_enum, |
| 1798 | slim_rx_mux_get, slim_rx_mux_put), |
| 1799 | SOC_DAPM_ENUM_EXT("SLIM RX2 Mux", slim_rx_mux_enum, |
| 1800 | slim_rx_mux_get, slim_rx_mux_put), |
| 1801 | SOC_DAPM_ENUM_EXT("SLIM RX3 Mux", slim_rx_mux_enum, |
| 1802 | slim_rx_mux_get, slim_rx_mux_put), |
| 1803 | SOC_DAPM_ENUM_EXT("SLIM RX4 Mux", slim_rx_mux_enum, |
| 1804 | slim_rx_mux_get, slim_rx_mux_put), |
| 1805 | SOC_DAPM_ENUM_EXT("SLIM RX5 Mux", slim_rx_mux_enum, |
| 1806 | slim_rx_mux_get, slim_rx_mux_put), |
| 1807 | SOC_DAPM_ENUM_EXT("SLIM RX6 Mux", slim_rx_mux_enum, |
| 1808 | slim_rx_mux_get, slim_rx_mux_put), |
| 1809 | SOC_DAPM_ENUM_EXT("SLIM RX7 Mux", slim_rx_mux_enum, |
| 1810 | slim_rx_mux_get, slim_rx_mux_put), |
| 1811 | }; |
| 1812 | |
| 1813 | static const struct snd_kcontrol_new aif_cap_mixer[] = { |
| 1814 | SOC_SINGLE_EXT("SLIM TX1", SND_SOC_NOPM, TAIKO_TX1, 1, 0, |
| 1815 | slim_tx_mixer_get, slim_tx_mixer_put), |
| 1816 | SOC_SINGLE_EXT("SLIM TX2", SND_SOC_NOPM, TAIKO_TX2, 1, 0, |
| 1817 | slim_tx_mixer_get, slim_tx_mixer_put), |
| 1818 | SOC_SINGLE_EXT("SLIM TX3", SND_SOC_NOPM, TAIKO_TX3, 1, 0, |
| 1819 | slim_tx_mixer_get, slim_tx_mixer_put), |
| 1820 | SOC_SINGLE_EXT("SLIM TX4", SND_SOC_NOPM, TAIKO_TX4, 1, 0, |
| 1821 | slim_tx_mixer_get, slim_tx_mixer_put), |
| 1822 | SOC_SINGLE_EXT("SLIM TX5", SND_SOC_NOPM, TAIKO_TX5, 1, 0, |
| 1823 | slim_tx_mixer_get, slim_tx_mixer_put), |
| 1824 | SOC_SINGLE_EXT("SLIM TX6", SND_SOC_NOPM, TAIKO_TX6, 1, 0, |
| 1825 | slim_tx_mixer_get, slim_tx_mixer_put), |
| 1826 | SOC_SINGLE_EXT("SLIM TX7", SND_SOC_NOPM, TAIKO_TX7, 1, 0, |
| 1827 | slim_tx_mixer_get, slim_tx_mixer_put), |
| 1828 | SOC_SINGLE_EXT("SLIM TX8", SND_SOC_NOPM, TAIKO_TX8, 1, 0, |
| 1829 | slim_tx_mixer_get, slim_tx_mixer_put), |
| 1830 | SOC_SINGLE_EXT("SLIM TX9", SND_SOC_NOPM, TAIKO_TX9, 1, 0, |
| 1831 | slim_tx_mixer_get, slim_tx_mixer_put), |
| 1832 | SOC_SINGLE_EXT("SLIM TX10", SND_SOC_NOPM, TAIKO_TX10, 1, 0, |
| 1833 | slim_tx_mixer_get, slim_tx_mixer_put), |
| 1834 | }; |
| 1835 | |
Kiran Kandi | c3b2440 | 2012-06-11 00:05:59 -0700 | [diff] [blame] | 1836 | static void taiko_codec_enable_adc_block(struct snd_soc_codec *codec, |
| 1837 | int enable) |
| 1838 | { |
| 1839 | struct taiko_priv *taiko = snd_soc_codec_get_drvdata(codec); |
| 1840 | |
| 1841 | pr_debug("%s %d\n", __func__, enable); |
| 1842 | |
| 1843 | if (enable) { |
| 1844 | taiko->adc_count++; |
| 1845 | snd_soc_update_bits(codec, TAIKO_A_CDC_CLK_OTHR_CTL, 0x2, 0x2); |
| 1846 | } else { |
| 1847 | taiko->adc_count--; |
| 1848 | if (!taiko->adc_count) |
| 1849 | snd_soc_update_bits(codec, TAIKO_A_CDC_CLK_OTHR_CTL, |
| 1850 | 0x2, 0x0); |
| 1851 | } |
| 1852 | } |
| 1853 | |
| 1854 | static int taiko_codec_enable_adc(struct snd_soc_dapm_widget *w, |
| 1855 | struct snd_kcontrol *kcontrol, int event) |
| 1856 | { |
| 1857 | struct snd_soc_codec *codec = w->codec; |
| 1858 | u16 adc_reg; |
| 1859 | u8 init_bit_shift; |
| 1860 | |
| 1861 | pr_debug("%s %d\n", __func__, event); |
| 1862 | |
| 1863 | if (w->reg == TAIKO_A_TX_1_2_EN) |
| 1864 | adc_reg = TAIKO_A_TX_1_2_TEST_CTL; |
| 1865 | else if (w->reg == TAIKO_A_TX_3_4_EN) |
| 1866 | adc_reg = TAIKO_A_TX_3_4_TEST_CTL; |
| 1867 | else if (w->reg == TAIKO_A_TX_5_6_EN) |
| 1868 | adc_reg = TAIKO_A_TX_5_6_TEST_CTL; |
| 1869 | else { |
| 1870 | pr_err("%s: Error, invalid adc register\n", __func__); |
| 1871 | return -EINVAL; |
| 1872 | } |
| 1873 | |
| 1874 | if (w->shift == 3) |
| 1875 | init_bit_shift = 6; |
| 1876 | else if (w->shift == 7) |
| 1877 | init_bit_shift = 7; |
| 1878 | else { |
| 1879 | pr_err("%s: Error, invalid init bit postion adc register\n", |
| 1880 | __func__); |
| 1881 | return -EINVAL; |
| 1882 | } |
| 1883 | |
| 1884 | switch (event) { |
| 1885 | case SND_SOC_DAPM_PRE_PMU: |
| 1886 | taiko_codec_enable_adc_block(codec, 1); |
| 1887 | snd_soc_update_bits(codec, adc_reg, 1 << init_bit_shift, |
| 1888 | 1 << init_bit_shift); |
| 1889 | break; |
| 1890 | case SND_SOC_DAPM_POST_PMU: |
| 1891 | |
| 1892 | snd_soc_update_bits(codec, adc_reg, 1 << init_bit_shift, 0x00); |
| 1893 | |
| 1894 | break; |
| 1895 | case SND_SOC_DAPM_POST_PMD: |
| 1896 | taiko_codec_enable_adc_block(codec, 0); |
| 1897 | break; |
| 1898 | } |
| 1899 | return 0; |
| 1900 | } |
| 1901 | |
Kiran Kandi | c3b2440 | 2012-06-11 00:05:59 -0700 | [diff] [blame] | 1902 | static int taiko_codec_enable_aux_pga(struct snd_soc_dapm_widget *w, |
| 1903 | struct snd_kcontrol *kcontrol, int event) |
| 1904 | { |
| 1905 | struct snd_soc_codec *codec = w->codec; |
| 1906 | struct taiko_priv *taiko = snd_soc_codec_get_drvdata(codec); |
| 1907 | |
| 1908 | pr_debug("%s: %d\n", __func__, event); |
| 1909 | |
| 1910 | switch (event) { |
| 1911 | case SND_SOC_DAPM_PRE_PMU: |
Joonwoo Park | a889026 | 2012-10-15 12:04:27 -0700 | [diff] [blame] | 1912 | WCD9XXX_BCL_LOCK(&taiko->resmgr); |
| 1913 | wcd9xxx_resmgr_get_bandgap(&taiko->resmgr, |
| 1914 | WCD9XXX_BANDGAP_AUDIO_MODE); |
| 1915 | /* AUX PGA requires RCO or MCLK */ |
| 1916 | wcd9xxx_resmgr_get_clk_block(&taiko->resmgr, WCD9XXX_CLK_RCO); |
| 1917 | wcd9xxx_resmgr_enable_rx_bias(&taiko->resmgr, 1); |
| 1918 | WCD9XXX_BCL_UNLOCK(&taiko->resmgr); |
Kiran Kandi | c3b2440 | 2012-06-11 00:05:59 -0700 | [diff] [blame] | 1919 | break; |
| 1920 | |
| 1921 | case SND_SOC_DAPM_POST_PMD: |
Joonwoo Park | a889026 | 2012-10-15 12:04:27 -0700 | [diff] [blame] | 1922 | WCD9XXX_BCL_LOCK(&taiko->resmgr); |
| 1923 | wcd9xxx_resmgr_enable_rx_bias(&taiko->resmgr, 0); |
| 1924 | wcd9xxx_resmgr_put_bandgap(&taiko->resmgr, |
| 1925 | WCD9XXX_BANDGAP_AUDIO_MODE); |
| 1926 | wcd9xxx_resmgr_put_clk_block(&taiko->resmgr, WCD9XXX_CLK_RCO); |
| 1927 | WCD9XXX_BCL_UNLOCK(&taiko->resmgr); |
Kiran Kandi | c3b2440 | 2012-06-11 00:05:59 -0700 | [diff] [blame] | 1928 | break; |
| 1929 | } |
| 1930 | return 0; |
| 1931 | } |
| 1932 | |
| 1933 | static int taiko_codec_enable_lineout(struct snd_soc_dapm_widget *w, |
| 1934 | struct snd_kcontrol *kcontrol, int event) |
| 1935 | { |
| 1936 | struct snd_soc_codec *codec = w->codec; |
| 1937 | u16 lineout_gain_reg; |
| 1938 | |
| 1939 | pr_debug("%s %d %s\n", __func__, event, w->name); |
| 1940 | |
| 1941 | switch (w->shift) { |
| 1942 | case 0: |
| 1943 | lineout_gain_reg = TAIKO_A_RX_LINE_1_GAIN; |
| 1944 | break; |
| 1945 | case 1: |
| 1946 | lineout_gain_reg = TAIKO_A_RX_LINE_2_GAIN; |
| 1947 | break; |
| 1948 | case 2: |
| 1949 | lineout_gain_reg = TAIKO_A_RX_LINE_3_GAIN; |
| 1950 | break; |
| 1951 | case 3: |
| 1952 | lineout_gain_reg = TAIKO_A_RX_LINE_4_GAIN; |
| 1953 | break; |
| 1954 | default: |
| 1955 | pr_err("%s: Error, incorrect lineout register value\n", |
| 1956 | __func__); |
| 1957 | return -EINVAL; |
| 1958 | } |
| 1959 | |
| 1960 | switch (event) { |
| 1961 | case SND_SOC_DAPM_PRE_PMU: |
| 1962 | snd_soc_update_bits(codec, lineout_gain_reg, 0x40, 0x40); |
| 1963 | break; |
| 1964 | case SND_SOC_DAPM_POST_PMU: |
| 1965 | pr_debug("%s: sleeping 16 ms after %s PA turn on\n", |
| 1966 | __func__, w->name); |
| 1967 | usleep_range(16000, 16000); |
| 1968 | break; |
| 1969 | case SND_SOC_DAPM_POST_PMD: |
| 1970 | snd_soc_update_bits(codec, lineout_gain_reg, 0x40, 0x00); |
| 1971 | break; |
| 1972 | } |
| 1973 | return 0; |
| 1974 | } |
| 1975 | |
Joonwoo Park | 7680b9f | 2012-07-13 11:36:48 -0700 | [diff] [blame] | 1976 | static int taiko_codec_enable_spk_pa(struct snd_soc_dapm_widget *w, |
| 1977 | struct snd_kcontrol *kcontrol, int event) |
| 1978 | { |
Joonwoo Park | 125cd4e | 2012-12-11 15:16:11 -0800 | [diff] [blame] | 1979 | struct snd_soc_codec *codec = w->codec; |
| 1980 | struct taiko_priv *taiko = snd_soc_codec_get_drvdata(codec); |
| 1981 | |
| 1982 | pr_debug("%s: %d %s\n", __func__, event, w->name); |
| 1983 | WCD9XXX_BCL_LOCK(&taiko->resmgr); |
| 1984 | switch (event) { |
| 1985 | case SND_SOC_DAPM_PRE_PMU: |
| 1986 | taiko->spkr_pa_widget_on = true; |
| 1987 | snd_soc_update_bits(codec, TAIKO_A_SPKR_DRV_EN, 0x80, 0x80); |
| 1988 | break; |
| 1989 | case SND_SOC_DAPM_POST_PMD: |
| 1990 | taiko->spkr_pa_widget_on = false; |
| 1991 | snd_soc_update_bits(codec, TAIKO_A_SPKR_DRV_EN, 0x80, 0x00); |
| 1992 | break; |
| 1993 | } |
| 1994 | WCD9XXX_BCL_UNLOCK(&taiko->resmgr); |
Joonwoo Park | 7680b9f | 2012-07-13 11:36:48 -0700 | [diff] [blame] | 1995 | return 0; |
| 1996 | } |
Kiran Kandi | c3b2440 | 2012-06-11 00:05:59 -0700 | [diff] [blame] | 1997 | |
| 1998 | static int taiko_codec_enable_dmic(struct snd_soc_dapm_widget *w, |
| 1999 | struct snd_kcontrol *kcontrol, int event) |
| 2000 | { |
| 2001 | struct snd_soc_codec *codec = w->codec; |
| 2002 | struct taiko_priv *taiko = snd_soc_codec_get_drvdata(codec); |
| 2003 | u8 dmic_clk_en; |
| 2004 | u16 dmic_clk_reg; |
| 2005 | s32 *dmic_clk_cnt; |
| 2006 | unsigned int dmic; |
| 2007 | int ret; |
| 2008 | |
| 2009 | ret = kstrtouint(strpbrk(w->name, "123456"), 10, &dmic); |
| 2010 | if (ret < 0) { |
| 2011 | pr_err("%s: Invalid DMIC line on the codec\n", __func__); |
| 2012 | return -EINVAL; |
| 2013 | } |
| 2014 | |
| 2015 | switch (dmic) { |
| 2016 | case 1: |
| 2017 | case 2: |
| 2018 | dmic_clk_en = 0x01; |
| 2019 | dmic_clk_cnt = &(taiko->dmic_1_2_clk_cnt); |
| 2020 | dmic_clk_reg = TAIKO_A_CDC_CLK_DMIC_B1_CTL; |
| 2021 | pr_debug("%s() event %d DMIC%d dmic_1_2_clk_cnt %d\n", |
| 2022 | __func__, event, dmic, *dmic_clk_cnt); |
| 2023 | |
| 2024 | break; |
| 2025 | |
| 2026 | case 3: |
| 2027 | case 4: |
| 2028 | dmic_clk_en = 0x10; |
| 2029 | dmic_clk_cnt = &(taiko->dmic_3_4_clk_cnt); |
| 2030 | dmic_clk_reg = TAIKO_A_CDC_CLK_DMIC_B1_CTL; |
| 2031 | |
| 2032 | pr_debug("%s() event %d DMIC%d dmic_3_4_clk_cnt %d\n", |
| 2033 | __func__, event, dmic, *dmic_clk_cnt); |
| 2034 | break; |
| 2035 | |
| 2036 | case 5: |
| 2037 | case 6: |
| 2038 | dmic_clk_en = 0x01; |
| 2039 | dmic_clk_cnt = &(taiko->dmic_5_6_clk_cnt); |
| 2040 | dmic_clk_reg = TAIKO_A_CDC_CLK_DMIC_B2_CTL; |
| 2041 | |
| 2042 | pr_debug("%s() event %d DMIC%d dmic_5_6_clk_cnt %d\n", |
| 2043 | __func__, event, dmic, *dmic_clk_cnt); |
| 2044 | |
| 2045 | break; |
| 2046 | |
| 2047 | default: |
| 2048 | pr_err("%s: Invalid DMIC Selection\n", __func__); |
| 2049 | return -EINVAL; |
| 2050 | } |
| 2051 | |
| 2052 | switch (event) { |
| 2053 | case SND_SOC_DAPM_PRE_PMU: |
| 2054 | |
| 2055 | (*dmic_clk_cnt)++; |
| 2056 | if (*dmic_clk_cnt == 1) |
| 2057 | snd_soc_update_bits(codec, dmic_clk_reg, |
| 2058 | dmic_clk_en, dmic_clk_en); |
| 2059 | |
| 2060 | break; |
| 2061 | case SND_SOC_DAPM_POST_PMD: |
| 2062 | |
| 2063 | (*dmic_clk_cnt)--; |
| 2064 | if (*dmic_clk_cnt == 0) |
| 2065 | snd_soc_update_bits(codec, dmic_clk_reg, |
| 2066 | dmic_clk_en, 0); |
| 2067 | break; |
| 2068 | } |
| 2069 | return 0; |
| 2070 | } |
| 2071 | |
| 2072 | static int taiko_codec_enable_anc(struct snd_soc_dapm_widget *w, |
| 2073 | struct snd_kcontrol *kcontrol, int event) |
| 2074 | { |
| 2075 | struct snd_soc_codec *codec = w->codec; |
| 2076 | const char *filename; |
| 2077 | const struct firmware *fw; |
| 2078 | int i; |
| 2079 | int ret; |
| 2080 | int num_anc_slots; |
| 2081 | struct anc_header *anc_head; |
| 2082 | struct taiko_priv *taiko = snd_soc_codec_get_drvdata(codec); |
| 2083 | u32 anc_writes_size = 0; |
| 2084 | int anc_size_remaining; |
| 2085 | u32 *anc_ptr; |
| 2086 | u16 reg; |
Kiran Kandi | 1b2d1ef | 2012-10-23 15:29:00 -0700 | [diff] [blame] | 2087 | u8 mask, val; |
Kiran Kandi | c3b2440 | 2012-06-11 00:05:59 -0700 | [diff] [blame] | 2088 | |
| 2089 | pr_debug("%s %d\n", __func__, event); |
| 2090 | switch (event) { |
| 2091 | case SND_SOC_DAPM_PRE_PMU: |
| 2092 | |
| 2093 | filename = "wcd9320/wcd9320_anc.bin"; |
| 2094 | |
| 2095 | ret = request_firmware(&fw, filename, codec->dev); |
| 2096 | if (ret != 0) { |
| 2097 | dev_err(codec->dev, "Failed to acquire ANC data: %d\n", |
| 2098 | ret); |
| 2099 | return -ENODEV; |
| 2100 | } |
| 2101 | |
| 2102 | if (fw->size < sizeof(struct anc_header)) { |
| 2103 | dev_err(codec->dev, "Not enough data\n"); |
| 2104 | release_firmware(fw); |
| 2105 | return -ENOMEM; |
| 2106 | } |
| 2107 | |
| 2108 | /* First number is the number of register writes */ |
| 2109 | anc_head = (struct anc_header *)(fw->data); |
| 2110 | anc_ptr = (u32 *)((u32)fw->data + sizeof(struct anc_header)); |
| 2111 | anc_size_remaining = fw->size - sizeof(struct anc_header); |
| 2112 | num_anc_slots = anc_head->num_anc_slots; |
| 2113 | |
| 2114 | if (taiko->anc_slot >= num_anc_slots) { |
| 2115 | dev_err(codec->dev, "Invalid ANC slot selected\n"); |
| 2116 | release_firmware(fw); |
| 2117 | return -EINVAL; |
| 2118 | } |
| 2119 | |
| 2120 | for (i = 0; i < num_anc_slots; i++) { |
| 2121 | |
| 2122 | if (anc_size_remaining < TAIKO_PACKED_REG_SIZE) { |
| 2123 | dev_err(codec->dev, "Invalid register format\n"); |
| 2124 | release_firmware(fw); |
| 2125 | return -EINVAL; |
| 2126 | } |
| 2127 | anc_writes_size = (u32)(*anc_ptr); |
| 2128 | anc_size_remaining -= sizeof(u32); |
| 2129 | anc_ptr += 1; |
| 2130 | |
| 2131 | if (anc_writes_size * TAIKO_PACKED_REG_SIZE |
| 2132 | > anc_size_remaining) { |
| 2133 | dev_err(codec->dev, "Invalid register format\n"); |
| 2134 | release_firmware(fw); |
| 2135 | return -ENOMEM; |
| 2136 | } |
| 2137 | |
| 2138 | if (taiko->anc_slot == i) |
| 2139 | break; |
| 2140 | |
| 2141 | anc_size_remaining -= (anc_writes_size * |
| 2142 | TAIKO_PACKED_REG_SIZE); |
| 2143 | anc_ptr += anc_writes_size; |
| 2144 | } |
| 2145 | if (i == num_anc_slots) { |
| 2146 | dev_err(codec->dev, "Selected ANC slot not present\n"); |
| 2147 | release_firmware(fw); |
| 2148 | return -ENOMEM; |
| 2149 | } |
| 2150 | |
| 2151 | for (i = 0; i < anc_writes_size; i++) { |
| 2152 | TAIKO_CODEC_UNPACK_ENTRY(anc_ptr[i], reg, |
| 2153 | mask, val); |
Kiran Kandi | 1b2d1ef | 2012-10-23 15:29:00 -0700 | [diff] [blame] | 2154 | snd_soc_write(codec, reg, val); |
Kiran Kandi | c3b2440 | 2012-06-11 00:05:59 -0700 | [diff] [blame] | 2155 | } |
| 2156 | release_firmware(fw); |
| 2157 | |
| 2158 | break; |
| 2159 | case SND_SOC_DAPM_POST_PMD: |
| 2160 | snd_soc_write(codec, TAIKO_A_CDC_CLK_ANC_RESET_CTL, 0xFF); |
| 2161 | snd_soc_write(codec, TAIKO_A_CDC_CLK_ANC_CLK_EN_CTL, 0); |
| 2162 | break; |
| 2163 | } |
| 2164 | return 0; |
| 2165 | } |
| 2166 | |
Kiran Kandi | c3b2440 | 2012-06-11 00:05:59 -0700 | [diff] [blame] | 2167 | static int taiko_codec_enable_micbias(struct snd_soc_dapm_widget *w, |
| 2168 | struct snd_kcontrol *kcontrol, int event) |
| 2169 | { |
| 2170 | struct snd_soc_codec *codec = w->codec; |
| 2171 | struct taiko_priv *taiko = snd_soc_codec_get_drvdata(codec); |
Joonwoo Park | 3699ca3 | 2013-02-08 12:06:15 -0800 | [diff] [blame] | 2172 | u16 micb_int_reg = 0, micb_ctl_reg = 0; |
Kiran Kandi | c3b2440 | 2012-06-11 00:05:59 -0700 | [diff] [blame] | 2173 | u8 cfilt_sel_val = 0; |
| 2174 | char *internal1_text = "Internal1"; |
| 2175 | char *internal2_text = "Internal2"; |
| 2176 | char *internal3_text = "Internal3"; |
Joonwoo Park | a889026 | 2012-10-15 12:04:27 -0700 | [diff] [blame] | 2177 | enum wcd9xxx_notify_event e_post_off, e_pre_on, e_post_on; |
Kiran Kandi | c3b2440 | 2012-06-11 00:05:59 -0700 | [diff] [blame] | 2178 | |
Joonwoo Park | 3699ca3 | 2013-02-08 12:06:15 -0800 | [diff] [blame] | 2179 | pr_debug("%s: w->name %s event %d\n", __func__, w->name, event); |
| 2180 | if (strnstr(w->name, "MIC BIAS1", sizeof("MIC BIAS1"))) { |
| 2181 | micb_ctl_reg = TAIKO_A_MICB_1_CTL; |
Kiran Kandi | c3b2440 | 2012-06-11 00:05:59 -0700 | [diff] [blame] | 2182 | micb_int_reg = TAIKO_A_MICB_1_INT_RBIAS; |
Joonwoo Park | a889026 | 2012-10-15 12:04:27 -0700 | [diff] [blame] | 2183 | cfilt_sel_val = taiko->resmgr.pdata->micbias.bias1_cfilt_sel; |
| 2184 | e_pre_on = WCD9XXX_EVENT_PRE_MICBIAS_1_ON; |
| 2185 | e_post_on = WCD9XXX_EVENT_POST_MICBIAS_1_ON; |
| 2186 | e_post_off = WCD9XXX_EVENT_POST_MICBIAS_1_OFF; |
Joonwoo Park | 3699ca3 | 2013-02-08 12:06:15 -0800 | [diff] [blame] | 2187 | } else if (strnstr(w->name, "MIC BIAS2", sizeof("MIC BIAS2"))) { |
| 2188 | micb_ctl_reg = TAIKO_A_MICB_2_CTL; |
Kiran Kandi | c3b2440 | 2012-06-11 00:05:59 -0700 | [diff] [blame] | 2189 | micb_int_reg = TAIKO_A_MICB_2_INT_RBIAS; |
Joonwoo Park | a889026 | 2012-10-15 12:04:27 -0700 | [diff] [blame] | 2190 | cfilt_sel_val = taiko->resmgr.pdata->micbias.bias2_cfilt_sel; |
| 2191 | e_pre_on = WCD9XXX_EVENT_PRE_MICBIAS_2_ON; |
| 2192 | e_post_on = WCD9XXX_EVENT_POST_MICBIAS_2_ON; |
| 2193 | e_post_off = WCD9XXX_EVENT_POST_MICBIAS_2_OFF; |
Joonwoo Park | 3699ca3 | 2013-02-08 12:06:15 -0800 | [diff] [blame] | 2194 | } else if (strnstr(w->name, "MIC BIAS3", sizeof("MIC BIAS3"))) { |
| 2195 | micb_ctl_reg = TAIKO_A_MICB_2_CTL; |
Kiran Kandi | c3b2440 | 2012-06-11 00:05:59 -0700 | [diff] [blame] | 2196 | micb_int_reg = TAIKO_A_MICB_3_INT_RBIAS; |
Joonwoo Park | a889026 | 2012-10-15 12:04:27 -0700 | [diff] [blame] | 2197 | cfilt_sel_val = taiko->resmgr.pdata->micbias.bias3_cfilt_sel; |
| 2198 | e_pre_on = WCD9XXX_EVENT_PRE_MICBIAS_3_ON; |
| 2199 | e_post_on = WCD9XXX_EVENT_POST_MICBIAS_3_ON; |
| 2200 | e_post_off = WCD9XXX_EVENT_POST_MICBIAS_3_OFF; |
Joonwoo Park | 3699ca3 | 2013-02-08 12:06:15 -0800 | [diff] [blame] | 2201 | } else if (strnstr(w->name, "MIC BIAS4", sizeof("MIC BIAS4"))) { |
| 2202 | micb_ctl_reg = TAIKO_A_MICB_2_CTL; |
Joonwoo Park | a889026 | 2012-10-15 12:04:27 -0700 | [diff] [blame] | 2203 | micb_int_reg = taiko->resmgr.reg_addr->micb_4_int_rbias; |
| 2204 | cfilt_sel_val = taiko->resmgr.pdata->micbias.bias4_cfilt_sel; |
| 2205 | e_pre_on = WCD9XXX_EVENT_PRE_MICBIAS_4_ON; |
| 2206 | e_post_on = WCD9XXX_EVENT_POST_MICBIAS_4_ON; |
| 2207 | e_post_off = WCD9XXX_EVENT_POST_MICBIAS_4_OFF; |
Joonwoo Park | 3699ca3 | 2013-02-08 12:06:15 -0800 | [diff] [blame] | 2208 | } else { |
| 2209 | pr_err("%s: Error, invalid micbias %s\n", __func__, w->name); |
Kiran Kandi | c3b2440 | 2012-06-11 00:05:59 -0700 | [diff] [blame] | 2210 | return -EINVAL; |
| 2211 | } |
| 2212 | |
| 2213 | switch (event) { |
| 2214 | case SND_SOC_DAPM_PRE_PMU: |
Joonwoo Park | a889026 | 2012-10-15 12:04:27 -0700 | [diff] [blame] | 2215 | /* Let MBHC module know so micbias switch to be off */ |
| 2216 | wcd9xxx_resmgr_notifier_call(&taiko->resmgr, e_pre_on); |
Kiran Kandi | c3b2440 | 2012-06-11 00:05:59 -0700 | [diff] [blame] | 2217 | |
Joonwoo Park | a889026 | 2012-10-15 12:04:27 -0700 | [diff] [blame] | 2218 | /* Get cfilt */ |
| 2219 | wcd9xxx_resmgr_cfilt_get(&taiko->resmgr, cfilt_sel_val); |
Kiran Kandi | c3b2440 | 2012-06-11 00:05:59 -0700 | [diff] [blame] | 2220 | |
| 2221 | if (strnstr(w->name, internal1_text, 30)) |
| 2222 | snd_soc_update_bits(codec, micb_int_reg, 0xE0, 0xE0); |
| 2223 | else if (strnstr(w->name, internal2_text, 30)) |
| 2224 | snd_soc_update_bits(codec, micb_int_reg, 0x1C, 0x1C); |
| 2225 | else if (strnstr(w->name, internal3_text, 30)) |
| 2226 | snd_soc_update_bits(codec, micb_int_reg, 0x3, 0x3); |
| 2227 | |
Joonwoo Park | 3699ca3 | 2013-02-08 12:06:15 -0800 | [diff] [blame] | 2228 | if (micb_ctl_reg == TAIKO_A_MICB_2_CTL) { |
| 2229 | WCD9XXX_BCL_LOCK(&taiko->resmgr); |
| 2230 | wcd9xxx_resmgr_add_cond_update_bits(&taiko->resmgr, |
| 2231 | WCD9XXX_COND_HPH_MIC, |
| 2232 | micb_ctl_reg, w->shift, |
| 2233 | false); |
| 2234 | WCD9XXX_BCL_UNLOCK(&taiko->resmgr); |
| 2235 | } else |
| 2236 | snd_soc_update_bits(codec, micb_ctl_reg, 1 << w->shift, |
| 2237 | 1 << w->shift); |
Kiran Kandi | c3b2440 | 2012-06-11 00:05:59 -0700 | [diff] [blame] | 2238 | break; |
| 2239 | case SND_SOC_DAPM_POST_PMU: |
Kiran Kandi | c3b2440 | 2012-06-11 00:05:59 -0700 | [diff] [blame] | 2240 | usleep_range(20000, 20000); |
Joonwoo Park | a889026 | 2012-10-15 12:04:27 -0700 | [diff] [blame] | 2241 | /* Let MBHC module know so micbias is on */ |
| 2242 | wcd9xxx_resmgr_notifier_call(&taiko->resmgr, e_post_on); |
Kiran Kandi | c3b2440 | 2012-06-11 00:05:59 -0700 | [diff] [blame] | 2243 | break; |
Kiran Kandi | c3b2440 | 2012-06-11 00:05:59 -0700 | [diff] [blame] | 2244 | case SND_SOC_DAPM_POST_PMD: |
Joonwoo Park | 3699ca3 | 2013-02-08 12:06:15 -0800 | [diff] [blame] | 2245 | if (micb_ctl_reg == TAIKO_A_MICB_2_CTL) { |
| 2246 | WCD9XXX_BCL_LOCK(&taiko->resmgr); |
| 2247 | wcd9xxx_resmgr_rm_cond_update_bits(&taiko->resmgr, |
| 2248 | WCD9XXX_COND_HPH_MIC, |
| 2249 | micb_ctl_reg, 7, false); |
| 2250 | WCD9XXX_BCL_UNLOCK(&taiko->resmgr); |
| 2251 | } else |
| 2252 | snd_soc_update_bits(codec, micb_ctl_reg, 1 << w->shift, |
| 2253 | 0); |
| 2254 | |
Joonwoo Park | a889026 | 2012-10-15 12:04:27 -0700 | [diff] [blame] | 2255 | /* Let MBHC module know so micbias switch to be off */ |
| 2256 | wcd9xxx_resmgr_notifier_call(&taiko->resmgr, e_post_off); |
Kiran Kandi | c3b2440 | 2012-06-11 00:05:59 -0700 | [diff] [blame] | 2257 | |
| 2258 | if (strnstr(w->name, internal1_text, 30)) |
| 2259 | snd_soc_update_bits(codec, micb_int_reg, 0x80, 0x00); |
| 2260 | else if (strnstr(w->name, internal2_text, 30)) |
| 2261 | snd_soc_update_bits(codec, micb_int_reg, 0x10, 0x00); |
| 2262 | else if (strnstr(w->name, internal3_text, 30)) |
| 2263 | snd_soc_update_bits(codec, micb_int_reg, 0x2, 0x0); |
| 2264 | |
Joonwoo Park | a889026 | 2012-10-15 12:04:27 -0700 | [diff] [blame] | 2265 | /* Put cfilt */ |
| 2266 | wcd9xxx_resmgr_cfilt_put(&taiko->resmgr, cfilt_sel_val); |
Kiran Kandi | c3b2440 | 2012-06-11 00:05:59 -0700 | [diff] [blame] | 2267 | break; |
| 2268 | } |
| 2269 | |
| 2270 | return 0; |
| 2271 | } |
| 2272 | |
| 2273 | |
| 2274 | static void tx_hpf_corner_freq_callback(struct work_struct *work) |
| 2275 | { |
| 2276 | struct delayed_work *hpf_delayed_work; |
| 2277 | struct hpf_work *hpf_work; |
| 2278 | struct taiko_priv *taiko; |
| 2279 | struct snd_soc_codec *codec; |
| 2280 | u16 tx_mux_ctl_reg; |
| 2281 | u8 hpf_cut_of_freq; |
| 2282 | |
| 2283 | hpf_delayed_work = to_delayed_work(work); |
| 2284 | hpf_work = container_of(hpf_delayed_work, struct hpf_work, dwork); |
| 2285 | taiko = hpf_work->taiko; |
| 2286 | codec = hpf_work->taiko->codec; |
| 2287 | hpf_cut_of_freq = hpf_work->tx_hpf_cut_of_freq; |
| 2288 | |
| 2289 | tx_mux_ctl_reg = TAIKO_A_CDC_TX1_MUX_CTL + |
| 2290 | (hpf_work->decimator - 1) * 8; |
| 2291 | |
| 2292 | pr_debug("%s(): decimator %u hpf_cut_of_freq 0x%x\n", __func__, |
| 2293 | hpf_work->decimator, (unsigned int)hpf_cut_of_freq); |
| 2294 | |
| 2295 | snd_soc_update_bits(codec, tx_mux_ctl_reg, 0x30, hpf_cut_of_freq << 4); |
| 2296 | } |
| 2297 | |
| 2298 | #define TX_MUX_CTL_CUT_OFF_FREQ_MASK 0x30 |
| 2299 | #define CF_MIN_3DB_4HZ 0x0 |
| 2300 | #define CF_MIN_3DB_75HZ 0x1 |
| 2301 | #define CF_MIN_3DB_150HZ 0x2 |
| 2302 | |
| 2303 | static int taiko_codec_enable_dec(struct snd_soc_dapm_widget *w, |
| 2304 | struct snd_kcontrol *kcontrol, int event) |
| 2305 | { |
| 2306 | struct snd_soc_codec *codec = w->codec; |
| 2307 | unsigned int decimator; |
| 2308 | char *dec_name = NULL; |
| 2309 | char *widget_name = NULL; |
| 2310 | char *temp; |
| 2311 | int ret = 0; |
| 2312 | u16 dec_reset_reg, tx_vol_ctl_reg, tx_mux_ctl_reg; |
| 2313 | u8 dec_hpf_cut_of_freq; |
| 2314 | int offset; |
| 2315 | |
| 2316 | |
| 2317 | pr_debug("%s %d\n", __func__, event); |
| 2318 | |
| 2319 | widget_name = kstrndup(w->name, 15, GFP_KERNEL); |
| 2320 | if (!widget_name) |
| 2321 | return -ENOMEM; |
| 2322 | temp = widget_name; |
| 2323 | |
| 2324 | dec_name = strsep(&widget_name, " "); |
| 2325 | widget_name = temp; |
| 2326 | if (!dec_name) { |
| 2327 | pr_err("%s: Invalid decimator = %s\n", __func__, w->name); |
| 2328 | ret = -EINVAL; |
| 2329 | goto out; |
| 2330 | } |
| 2331 | |
| 2332 | ret = kstrtouint(strpbrk(dec_name, "123456789"), 10, &decimator); |
| 2333 | if (ret < 0) { |
| 2334 | pr_err("%s: Invalid decimator = %s\n", __func__, dec_name); |
| 2335 | ret = -EINVAL; |
| 2336 | goto out; |
| 2337 | } |
| 2338 | |
| 2339 | pr_debug("%s(): widget = %s dec_name = %s decimator = %u\n", __func__, |
| 2340 | w->name, dec_name, decimator); |
| 2341 | |
| 2342 | if (w->reg == TAIKO_A_CDC_CLK_TX_CLK_EN_B1_CTL) { |
| 2343 | dec_reset_reg = TAIKO_A_CDC_CLK_TX_RESET_B1_CTL; |
| 2344 | offset = 0; |
| 2345 | } else if (w->reg == TAIKO_A_CDC_CLK_TX_CLK_EN_B2_CTL) { |
| 2346 | dec_reset_reg = TAIKO_A_CDC_CLK_TX_RESET_B2_CTL; |
| 2347 | offset = 8; |
| 2348 | } else { |
| 2349 | pr_err("%s: Error, incorrect dec\n", __func__); |
| 2350 | return -EINVAL; |
| 2351 | } |
| 2352 | |
| 2353 | tx_vol_ctl_reg = TAIKO_A_CDC_TX1_VOL_CTL_CFG + 8 * (decimator - 1); |
| 2354 | tx_mux_ctl_reg = TAIKO_A_CDC_TX1_MUX_CTL + 8 * (decimator - 1); |
| 2355 | |
| 2356 | switch (event) { |
| 2357 | case SND_SOC_DAPM_PRE_PMU: |
| 2358 | |
| 2359 | /* Enableable TX digital mute */ |
| 2360 | snd_soc_update_bits(codec, tx_vol_ctl_reg, 0x01, 0x01); |
| 2361 | |
| 2362 | snd_soc_update_bits(codec, dec_reset_reg, 1 << w->shift, |
| 2363 | 1 << w->shift); |
| 2364 | snd_soc_update_bits(codec, dec_reset_reg, 1 << w->shift, 0x0); |
| 2365 | |
| 2366 | dec_hpf_cut_of_freq = snd_soc_read(codec, tx_mux_ctl_reg); |
| 2367 | |
| 2368 | dec_hpf_cut_of_freq = (dec_hpf_cut_of_freq & 0x30) >> 4; |
| 2369 | |
| 2370 | tx_hpf_work[decimator - 1].tx_hpf_cut_of_freq = |
| 2371 | dec_hpf_cut_of_freq; |
| 2372 | |
| 2373 | if ((dec_hpf_cut_of_freq != CF_MIN_3DB_150HZ)) { |
| 2374 | |
| 2375 | /* set cut of freq to CF_MIN_3DB_150HZ (0x1); */ |
| 2376 | snd_soc_update_bits(codec, tx_mux_ctl_reg, 0x30, |
| 2377 | CF_MIN_3DB_150HZ << 4); |
| 2378 | } |
| 2379 | |
| 2380 | /* enable HPF */ |
| 2381 | snd_soc_update_bits(codec, tx_mux_ctl_reg , 0x08, 0x00); |
| 2382 | |
| 2383 | break; |
| 2384 | |
| 2385 | case SND_SOC_DAPM_POST_PMU: |
| 2386 | |
| 2387 | /* Disable TX digital mute */ |
| 2388 | snd_soc_update_bits(codec, tx_vol_ctl_reg, 0x01, 0x00); |
| 2389 | |
| 2390 | if (tx_hpf_work[decimator - 1].tx_hpf_cut_of_freq != |
| 2391 | CF_MIN_3DB_150HZ) { |
| 2392 | |
| 2393 | schedule_delayed_work(&tx_hpf_work[decimator - 1].dwork, |
| 2394 | msecs_to_jiffies(300)); |
| 2395 | } |
| 2396 | /* apply the digital gain after the decimator is enabled*/ |
Damir Didjusto | ed406e2 | 2012-11-16 15:44:57 -0800 | [diff] [blame] | 2397 | if ((w->shift + offset) < ARRAY_SIZE(tx_digital_gain_reg)) |
Kiran Kandi | c3b2440 | 2012-06-11 00:05:59 -0700 | [diff] [blame] | 2398 | snd_soc_write(codec, |
| 2399 | tx_digital_gain_reg[w->shift + offset], |
| 2400 | snd_soc_read(codec, |
| 2401 | tx_digital_gain_reg[w->shift + offset]) |
| 2402 | ); |
| 2403 | |
| 2404 | break; |
| 2405 | |
| 2406 | case SND_SOC_DAPM_PRE_PMD: |
| 2407 | |
| 2408 | snd_soc_update_bits(codec, tx_vol_ctl_reg, 0x01, 0x01); |
| 2409 | cancel_delayed_work_sync(&tx_hpf_work[decimator - 1].dwork); |
| 2410 | break; |
| 2411 | |
| 2412 | case SND_SOC_DAPM_POST_PMD: |
| 2413 | |
| 2414 | snd_soc_update_bits(codec, tx_mux_ctl_reg, 0x08, 0x08); |
| 2415 | snd_soc_update_bits(codec, tx_mux_ctl_reg, 0x30, |
| 2416 | (tx_hpf_work[decimator - 1].tx_hpf_cut_of_freq) << 4); |
| 2417 | |
| 2418 | break; |
| 2419 | } |
| 2420 | out: |
| 2421 | kfree(widget_name); |
| 2422 | return ret; |
| 2423 | } |
| 2424 | |
Joonwoo Park | 125cd4e | 2012-12-11 15:16:11 -0800 | [diff] [blame] | 2425 | static int taiko_codec_enable_vdd_spkr(struct snd_soc_dapm_widget *w, |
| 2426 | struct snd_kcontrol *kcontrol, int event) |
| 2427 | { |
| 2428 | int ret = 0; |
| 2429 | struct snd_soc_codec *codec = w->codec; |
| 2430 | struct wcd9xxx *core = dev_get_drvdata(codec->dev->parent); |
| 2431 | |
| 2432 | pr_debug("%s: %d %s\n", __func__, event, w->name); |
| 2433 | switch (event) { |
| 2434 | case SND_SOC_DAPM_PRE_PMU: |
| 2435 | if (spkr_drv_wrnd > 0) { |
| 2436 | WARN_ON(!(snd_soc_read(codec, TAIKO_A_SPKR_DRV_EN) & |
| 2437 | 0x80)); |
| 2438 | snd_soc_update_bits(codec, TAIKO_A_SPKR_DRV_EN, 0x80, |
| 2439 | 0x00); |
| 2440 | } |
| 2441 | if (TAIKO_IS_1_0(core->version)) |
| 2442 | snd_soc_update_bits(codec, TAIKO_A_SPKR_DRV_DBG_PWRSTG, |
| 2443 | 0x24, 0x00); |
| 2444 | break; |
| 2445 | case SND_SOC_DAPM_POST_PMD: |
| 2446 | if (TAIKO_IS_1_0(core->version)) |
| 2447 | snd_soc_update_bits(codec, TAIKO_A_SPKR_DRV_DBG_PWRSTG, |
| 2448 | 0x24, 0x24); |
| 2449 | if (spkr_drv_wrnd > 0) { |
| 2450 | WARN_ON(!!(snd_soc_read(codec, TAIKO_A_SPKR_DRV_EN) & |
| 2451 | 0x80)); |
| 2452 | snd_soc_update_bits(codec, TAIKO_A_SPKR_DRV_EN, 0x80, |
| 2453 | 0x80); |
| 2454 | } |
| 2455 | break; |
| 2456 | } |
| 2457 | |
| 2458 | return ret; |
| 2459 | } |
| 2460 | |
Kiran Kandi | 7b7d2ff | 2012-09-14 14:52:14 -0700 | [diff] [blame] | 2461 | static int taiko_codec_enable_interpolator(struct snd_soc_dapm_widget *w, |
Kiran Kandi | c3b2440 | 2012-06-11 00:05:59 -0700 | [diff] [blame] | 2462 | struct snd_kcontrol *kcontrol, int event) |
| 2463 | { |
| 2464 | struct snd_soc_codec *codec = w->codec; |
| 2465 | |
| 2466 | pr_debug("%s %d %s\n", __func__, event, w->name); |
| 2467 | |
| 2468 | switch (event) { |
| 2469 | case SND_SOC_DAPM_PRE_PMU: |
| 2470 | snd_soc_update_bits(codec, TAIKO_A_CDC_CLK_RX_RESET_CTL, |
| 2471 | 1 << w->shift, 1 << w->shift); |
| 2472 | snd_soc_update_bits(codec, TAIKO_A_CDC_CLK_RX_RESET_CTL, |
| 2473 | 1 << w->shift, 0x0); |
| 2474 | break; |
| 2475 | case SND_SOC_DAPM_POST_PMU: |
| 2476 | /* apply the digital gain after the interpolator is enabled*/ |
| 2477 | if ((w->shift) < ARRAY_SIZE(rx_digital_gain_reg)) |
| 2478 | snd_soc_write(codec, |
| 2479 | rx_digital_gain_reg[w->shift], |
| 2480 | snd_soc_read(codec, |
| 2481 | rx_digital_gain_reg[w->shift]) |
| 2482 | ); |
| 2483 | break; |
| 2484 | } |
| 2485 | return 0; |
| 2486 | } |
| 2487 | |
| 2488 | static int taiko_codec_enable_ldo_h(struct snd_soc_dapm_widget *w, |
| 2489 | struct snd_kcontrol *kcontrol, int event) |
| 2490 | { |
| 2491 | switch (event) { |
| 2492 | case SND_SOC_DAPM_POST_PMU: |
| 2493 | case SND_SOC_DAPM_POST_PMD: |
| 2494 | usleep_range(1000, 1000); |
| 2495 | break; |
| 2496 | } |
| 2497 | return 0; |
| 2498 | } |
| 2499 | |
| 2500 | static int taiko_codec_enable_rx_bias(struct snd_soc_dapm_widget *w, |
| 2501 | struct snd_kcontrol *kcontrol, int event) |
| 2502 | { |
| 2503 | struct snd_soc_codec *codec = w->codec; |
Joonwoo Park | a889026 | 2012-10-15 12:04:27 -0700 | [diff] [blame] | 2504 | struct taiko_priv *taiko = snd_soc_codec_get_drvdata(codec); |
Kiran Kandi | c3b2440 | 2012-06-11 00:05:59 -0700 | [diff] [blame] | 2505 | |
| 2506 | pr_debug("%s %d\n", __func__, event); |
| 2507 | |
| 2508 | switch (event) { |
| 2509 | case SND_SOC_DAPM_PRE_PMU: |
Joonwoo Park | a889026 | 2012-10-15 12:04:27 -0700 | [diff] [blame] | 2510 | wcd9xxx_resmgr_enable_rx_bias(&taiko->resmgr, 1); |
Kiran Kandi | c3b2440 | 2012-06-11 00:05:59 -0700 | [diff] [blame] | 2511 | break; |
| 2512 | case SND_SOC_DAPM_POST_PMD: |
Joonwoo Park | a889026 | 2012-10-15 12:04:27 -0700 | [diff] [blame] | 2513 | wcd9xxx_resmgr_enable_rx_bias(&taiko->resmgr, 0); |
Kiran Kandi | c3b2440 | 2012-06-11 00:05:59 -0700 | [diff] [blame] | 2514 | break; |
| 2515 | } |
| 2516 | return 0; |
| 2517 | } |
| 2518 | static int taiko_hphr_dac_event(struct snd_soc_dapm_widget *w, |
| 2519 | struct snd_kcontrol *kcontrol, int event) |
| 2520 | { |
| 2521 | struct snd_soc_codec *codec = w->codec; |
| 2522 | |
| 2523 | pr_debug("%s %s %d\n", __func__, w->name, event); |
| 2524 | |
| 2525 | switch (event) { |
| 2526 | case SND_SOC_DAPM_PRE_PMU: |
| 2527 | snd_soc_update_bits(codec, w->reg, 0x40, 0x40); |
| 2528 | break; |
| 2529 | case SND_SOC_DAPM_POST_PMD: |
| 2530 | snd_soc_update_bits(codec, w->reg, 0x40, 0x00); |
| 2531 | break; |
| 2532 | } |
| 2533 | return 0; |
| 2534 | } |
| 2535 | |
Kiran Kandi | c3b2440 | 2012-06-11 00:05:59 -0700 | [diff] [blame] | 2536 | static int taiko_hph_pa_event(struct snd_soc_dapm_widget *w, |
Joonwoo Park | a889026 | 2012-10-15 12:04:27 -0700 | [diff] [blame] | 2537 | struct snd_kcontrol *kcontrol, int event) |
Kiran Kandi | c3b2440 | 2012-06-11 00:05:59 -0700 | [diff] [blame] | 2538 | { |
| 2539 | struct snd_soc_codec *codec = w->codec; |
| 2540 | struct taiko_priv *taiko = snd_soc_codec_get_drvdata(codec); |
Joonwoo Park | a889026 | 2012-10-15 12:04:27 -0700 | [diff] [blame] | 2541 | enum wcd9xxx_notify_event e_pre_on, e_post_off; |
| 2542 | |
Kiran Kandi | 4c56c59 | 2012-07-25 11:04:55 -0700 | [diff] [blame] | 2543 | pr_debug("%s: %s event = %d\n", __func__, w->name, event); |
Joonwoo Park | a889026 | 2012-10-15 12:04:27 -0700 | [diff] [blame] | 2544 | if (w->shift == 5) { |
| 2545 | e_pre_on = WCD9XXX_EVENT_PRE_HPHR_PA_ON; |
| 2546 | e_post_off = WCD9XXX_EVENT_POST_HPHR_PA_OFF; |
| 2547 | } else if (w->shift == 4) { |
| 2548 | e_pre_on = WCD9XXX_EVENT_PRE_HPHL_PA_ON; |
| 2549 | e_post_off = WCD9XXX_EVENT_POST_HPHL_PA_OFF; |
| 2550 | } else { |
| 2551 | pr_err("%s: Invalid w->shift %d\n", __func__, w->shift); |
| 2552 | return -EINVAL; |
| 2553 | } |
Kiran Kandi | c3b2440 | 2012-06-11 00:05:59 -0700 | [diff] [blame] | 2554 | |
| 2555 | switch (event) { |
| 2556 | case SND_SOC_DAPM_PRE_PMU: |
Joonwoo Park | a889026 | 2012-10-15 12:04:27 -0700 | [diff] [blame] | 2557 | /* Let MBHC module know PA is turning on */ |
| 2558 | wcd9xxx_resmgr_notifier_call(&taiko->resmgr, e_pre_on); |
Kiran Kandi | c3b2440 | 2012-06-11 00:05:59 -0700 | [diff] [blame] | 2559 | break; |
| 2560 | |
Kiran Kandi | 4c56c59 | 2012-07-25 11:04:55 -0700 | [diff] [blame] | 2561 | case SND_SOC_DAPM_POST_PMU: |
Kiran Kandi | 4c56c59 | 2012-07-25 11:04:55 -0700 | [diff] [blame] | 2562 | usleep_range(10000, 10000); |
| 2563 | |
| 2564 | snd_soc_update_bits(codec, TAIKO_A_BUCK_MODE_5, 0x02, 0x00); |
| 2565 | snd_soc_update_bits(codec, TAIKO_A_NCP_STATIC, 0x20, 0x00); |
| 2566 | snd_soc_update_bits(codec, TAIKO_A_BUCK_MODE_3, 0x04, 0x04); |
| 2567 | snd_soc_update_bits(codec, TAIKO_A_BUCK_MODE_3, 0x08, 0x00); |
| 2568 | |
| 2569 | usleep_range(10, 10); |
Kiran Kandi | 4c56c59 | 2012-07-25 11:04:55 -0700 | [diff] [blame] | 2570 | break; |
| 2571 | |
Kiran Kandi | c3b2440 | 2012-06-11 00:05:59 -0700 | [diff] [blame] | 2572 | case SND_SOC_DAPM_POST_PMD: |
Joonwoo Park | a889026 | 2012-10-15 12:04:27 -0700 | [diff] [blame] | 2573 | /* Let MBHC module know PA turned off */ |
| 2574 | wcd9xxx_resmgr_notifier_call(&taiko->resmgr, e_post_off); |
| 2575 | |
| 2576 | /* |
| 2577 | * schedule work is required because at the time HPH PA DAPM |
Kiran Kandi | c3b2440 | 2012-06-11 00:05:59 -0700 | [diff] [blame] | 2578 | * event callback is called by DAPM framework, CODEC dapm mutex |
| 2579 | * would have been locked while snd_soc_jack_report also |
| 2580 | * attempts to acquire same lock. |
| 2581 | */ |
Kiran Kandi | c3b2440 | 2012-06-11 00:05:59 -0700 | [diff] [blame] | 2582 | pr_debug("%s: sleep 10 ms after %s PA disable.\n", __func__, |
Joonwoo Park | a889026 | 2012-10-15 12:04:27 -0700 | [diff] [blame] | 2583 | w->name); |
Kiran Kandi | c3b2440 | 2012-06-11 00:05:59 -0700 | [diff] [blame] | 2584 | usleep_range(10000, 10000); |
| 2585 | break; |
| 2586 | } |
| 2587 | return 0; |
| 2588 | } |
| 2589 | |
Kiran Kandi | c3b2440 | 2012-06-11 00:05:59 -0700 | [diff] [blame] | 2590 | static const struct snd_soc_dapm_widget taiko_dapm_i2s_widgets[] = { |
| 2591 | SND_SOC_DAPM_SUPPLY("RX_I2S_CLK", TAIKO_A_CDC_CLK_RX_I2S_CTL, |
| 2592 | 4, 0, NULL, 0), |
| 2593 | SND_SOC_DAPM_SUPPLY("TX_I2S_CLK", TAIKO_A_CDC_CLK_TX_I2S_CTL, 4, |
| 2594 | 0, NULL, 0), |
| 2595 | }; |
| 2596 | |
| 2597 | static int taiko_lineout_dac_event(struct snd_soc_dapm_widget *w, |
| 2598 | struct snd_kcontrol *kcontrol, int event) |
| 2599 | { |
| 2600 | struct snd_soc_codec *codec = w->codec; |
| 2601 | |
| 2602 | pr_debug("%s %s %d\n", __func__, w->name, event); |
| 2603 | |
| 2604 | switch (event) { |
| 2605 | case SND_SOC_DAPM_PRE_PMU: |
| 2606 | snd_soc_update_bits(codec, w->reg, 0x40, 0x40); |
| 2607 | break; |
| 2608 | |
| 2609 | case SND_SOC_DAPM_POST_PMD: |
| 2610 | snd_soc_update_bits(codec, w->reg, 0x40, 0x00); |
| 2611 | break; |
| 2612 | } |
| 2613 | return 0; |
| 2614 | } |
| 2615 | |
Joonwoo Park | 7680b9f | 2012-07-13 11:36:48 -0700 | [diff] [blame] | 2616 | static int taiko_spk_dac_event(struct snd_soc_dapm_widget *w, |
| 2617 | struct snd_kcontrol *kcontrol, int event) |
| 2618 | { |
| 2619 | pr_debug("%s %s %d\n", __func__, w->name, event); |
| 2620 | return 0; |
| 2621 | } |
| 2622 | |
Kiran Kandi | c3b2440 | 2012-06-11 00:05:59 -0700 | [diff] [blame] | 2623 | static const struct snd_soc_dapm_route audio_i2s_map[] = { |
Kiran Kandi | c3b2440 | 2012-06-11 00:05:59 -0700 | [diff] [blame] | 2624 | {"SLIM RX1", NULL, "RX_I2S_CLK"}, |
| 2625 | {"SLIM RX2", NULL, "RX_I2S_CLK"}, |
| 2626 | {"SLIM RX3", NULL, "RX_I2S_CLK"}, |
| 2627 | {"SLIM RX4", NULL, "RX_I2S_CLK"}, |
| 2628 | |
Venkat Sudhir | a41630a | 2012-10-27 00:57:31 -0700 | [diff] [blame] | 2629 | {"SLIM TX7 MUX", NULL, "TX_I2S_CLK"}, |
| 2630 | {"SLIM TX8 MUX", NULL, "TX_I2S_CLK"}, |
| 2631 | {"SLIM TX9 MUX", NULL, "TX_I2S_CLK"}, |
| 2632 | {"SLIM TX10 MUX", NULL, "TX_I2S_CLK"}, |
Kiran Kandi | c3b2440 | 2012-06-11 00:05:59 -0700 | [diff] [blame] | 2633 | }; |
| 2634 | |
Joonwoo Park | 559a5bf | 2013-02-15 14:46:36 -0800 | [diff] [blame] | 2635 | static const struct snd_soc_dapm_route audio_i2s_map_1_0[] = { |
| 2636 | {"RX_I2S_CLK", NULL, "CDC_CONN"}, |
| 2637 | }; |
| 2638 | |
| 2639 | static const struct snd_soc_dapm_route audio_i2s_map_2_0[] = { |
| 2640 | {"RX_I2S_CLK", NULL, "CDC_I2S_RX_CONN"}, |
| 2641 | }; |
| 2642 | |
Kiran Kandi | c3b2440 | 2012-06-11 00:05:59 -0700 | [diff] [blame] | 2643 | static const struct snd_soc_dapm_route audio_map[] = { |
| 2644 | /* SLIMBUS Connections */ |
Kuirong Wang | 906ac47 | 2012-07-09 12:54:44 -0700 | [diff] [blame] | 2645 | {"AIF1 CAP", NULL, "AIF1_CAP Mixer"}, |
| 2646 | {"AIF2 CAP", NULL, "AIF2_CAP Mixer"}, |
| 2647 | {"AIF3 CAP", NULL, "AIF3_CAP Mixer"}, |
Kiran Kandi | c3b2440 | 2012-06-11 00:05:59 -0700 | [diff] [blame] | 2648 | |
Kuirong Wang | 906ac47 | 2012-07-09 12:54:44 -0700 | [diff] [blame] | 2649 | /* SLIM_MIXER("AIF1_CAP Mixer"),*/ |
| 2650 | {"AIF1_CAP Mixer", "SLIM TX1", "SLIM TX1 MUX"}, |
| 2651 | {"AIF1_CAP Mixer", "SLIM TX2", "SLIM TX2 MUX"}, |
| 2652 | {"AIF1_CAP Mixer", "SLIM TX3", "SLIM TX3 MUX"}, |
| 2653 | {"AIF1_CAP Mixer", "SLIM TX4", "SLIM TX4 MUX"}, |
| 2654 | {"AIF1_CAP Mixer", "SLIM TX5", "SLIM TX5 MUX"}, |
| 2655 | {"AIF1_CAP Mixer", "SLIM TX6", "SLIM TX6 MUX"}, |
| 2656 | {"AIF1_CAP Mixer", "SLIM TX7", "SLIM TX7 MUX"}, |
| 2657 | {"AIF1_CAP Mixer", "SLIM TX8", "SLIM TX8 MUX"}, |
| 2658 | {"AIF1_CAP Mixer", "SLIM TX9", "SLIM TX9 MUX"}, |
| 2659 | {"AIF1_CAP Mixer", "SLIM TX10", "SLIM TX10 MUX"}, |
| 2660 | /* SLIM_MIXER("AIF2_CAP Mixer"),*/ |
| 2661 | {"AIF2_CAP Mixer", "SLIM TX1", "SLIM TX1 MUX"}, |
| 2662 | {"AIF2_CAP Mixer", "SLIM TX2", "SLIM TX2 MUX"}, |
| 2663 | {"AIF2_CAP Mixer", "SLIM TX3", "SLIM TX3 MUX"}, |
| 2664 | {"AIF2_CAP Mixer", "SLIM TX4", "SLIM TX4 MUX"}, |
| 2665 | {"AIF2_CAP Mixer", "SLIM TX5", "SLIM TX5 MUX"}, |
| 2666 | {"AIF2_CAP Mixer", "SLIM TX6", "SLIM TX6 MUX"}, |
| 2667 | {"AIF2_CAP Mixer", "SLIM TX7", "SLIM TX7 MUX"}, |
| 2668 | {"AIF2_CAP Mixer", "SLIM TX8", "SLIM TX8 MUX"}, |
| 2669 | {"AIF2_CAP Mixer", "SLIM TX9", "SLIM TX9 MUX"}, |
| 2670 | {"AIF2_CAP Mixer", "SLIM TX10", "SLIM TX10 MUX"}, |
| 2671 | /* SLIM_MIXER("AIF3_CAP Mixer"),*/ |
| 2672 | {"AIF3_CAP Mixer", "SLIM TX1", "SLIM TX1 MUX"}, |
| 2673 | {"AIF3_CAP Mixer", "SLIM TX2", "SLIM TX2 MUX"}, |
| 2674 | {"AIF3_CAP Mixer", "SLIM TX3", "SLIM TX3 MUX"}, |
| 2675 | {"AIF3_CAP Mixer", "SLIM TX4", "SLIM TX4 MUX"}, |
| 2676 | {"AIF3_CAP Mixer", "SLIM TX5", "SLIM TX5 MUX"}, |
| 2677 | {"AIF3_CAP Mixer", "SLIM TX6", "SLIM TX6 MUX"}, |
| 2678 | {"AIF3_CAP Mixer", "SLIM TX7", "SLIM TX7 MUX"}, |
| 2679 | {"AIF3_CAP Mixer", "SLIM TX8", "SLIM TX8 MUX"}, |
| 2680 | {"AIF3_CAP Mixer", "SLIM TX9", "SLIM TX9 MUX"}, |
| 2681 | {"AIF3_CAP Mixer", "SLIM TX10", "SLIM TX10 MUX"}, |
| 2682 | |
Kiran Kandi | c3b2440 | 2012-06-11 00:05:59 -0700 | [diff] [blame] | 2683 | {"SLIM TX1 MUX", "DEC1", "DEC1 MUX"}, |
| 2684 | |
Kiran Kandi | c3b2440 | 2012-06-11 00:05:59 -0700 | [diff] [blame] | 2685 | {"SLIM TX2 MUX", "DEC2", "DEC2 MUX"}, |
| 2686 | |
Kiran Kandi | c3b2440 | 2012-06-11 00:05:59 -0700 | [diff] [blame] | 2687 | {"SLIM TX3 MUX", "DEC3", "DEC3 MUX"}, |
| 2688 | {"SLIM TX3 MUX", "RMIX1", "RX1 MIX1"}, |
| 2689 | {"SLIM TX3 MUX", "RMIX2", "RX2 MIX1"}, |
| 2690 | {"SLIM TX3 MUX", "RMIX3", "RX3 MIX1"}, |
| 2691 | {"SLIM TX3 MUX", "RMIX4", "RX4 MIX1"}, |
| 2692 | {"SLIM TX3 MUX", "RMIX5", "RX5 MIX1"}, |
| 2693 | {"SLIM TX3 MUX", "RMIX6", "RX6 MIX1"}, |
| 2694 | {"SLIM TX3 MUX", "RMIX7", "RX7 MIX1"}, |
| 2695 | |
Kiran Kandi | c3b2440 | 2012-06-11 00:05:59 -0700 | [diff] [blame] | 2696 | {"SLIM TX4 MUX", "DEC4", "DEC4 MUX"}, |
| 2697 | |
Kiran Kandi | c3b2440 | 2012-06-11 00:05:59 -0700 | [diff] [blame] | 2698 | {"SLIM TX5 MUX", "DEC5", "DEC5 MUX"}, |
| 2699 | {"SLIM TX5 MUX", "RMIX1", "RX1 MIX1"}, |
| 2700 | {"SLIM TX5 MUX", "RMIX2", "RX2 MIX1"}, |
| 2701 | {"SLIM TX5 MUX", "RMIX3", "RX3 MIX1"}, |
| 2702 | {"SLIM TX5 MUX", "RMIX4", "RX4 MIX1"}, |
| 2703 | {"SLIM TX5 MUX", "RMIX5", "RX5 MIX1"}, |
| 2704 | {"SLIM TX5 MUX", "RMIX6", "RX6 MIX1"}, |
| 2705 | {"SLIM TX5 MUX", "RMIX7", "RX7 MIX1"}, |
| 2706 | |
Kiran Kandi | c3b2440 | 2012-06-11 00:05:59 -0700 | [diff] [blame] | 2707 | {"SLIM TX6 MUX", "DEC6", "DEC6 MUX"}, |
| 2708 | |
Kiran Kandi | c3b2440 | 2012-06-11 00:05:59 -0700 | [diff] [blame] | 2709 | {"SLIM TX7 MUX", "DEC1", "DEC1 MUX"}, |
| 2710 | {"SLIM TX7 MUX", "DEC2", "DEC2 MUX"}, |
| 2711 | {"SLIM TX7 MUX", "DEC3", "DEC3 MUX"}, |
| 2712 | {"SLIM TX7 MUX", "DEC4", "DEC4 MUX"}, |
| 2713 | {"SLIM TX7 MUX", "DEC5", "DEC5 MUX"}, |
| 2714 | {"SLIM TX7 MUX", "DEC6", "DEC6 MUX"}, |
| 2715 | {"SLIM TX7 MUX", "DEC7", "DEC7 MUX"}, |
| 2716 | {"SLIM TX7 MUX", "DEC8", "DEC8 MUX"}, |
| 2717 | {"SLIM TX7 MUX", "DEC9", "DEC9 MUX"}, |
| 2718 | {"SLIM TX7 MUX", "DEC10", "DEC10 MUX"}, |
| 2719 | {"SLIM TX7 MUX", "RMIX1", "RX1 MIX1"}, |
| 2720 | {"SLIM TX7 MUX", "RMIX2", "RX2 MIX1"}, |
| 2721 | {"SLIM TX7 MUX", "RMIX3", "RX3 MIX1"}, |
| 2722 | {"SLIM TX7 MUX", "RMIX4", "RX4 MIX1"}, |
| 2723 | {"SLIM TX7 MUX", "RMIX5", "RX5 MIX1"}, |
| 2724 | {"SLIM TX7 MUX", "RMIX6", "RX6 MIX1"}, |
| 2725 | {"SLIM TX7 MUX", "RMIX7", "RX7 MIX1"}, |
| 2726 | |
Kiran Kandi | c3b2440 | 2012-06-11 00:05:59 -0700 | [diff] [blame] | 2727 | {"SLIM TX8 MUX", "DEC1", "DEC1 MUX"}, |
| 2728 | {"SLIM TX8 MUX", "DEC2", "DEC2 MUX"}, |
| 2729 | {"SLIM TX8 MUX", "DEC3", "DEC3 MUX"}, |
| 2730 | {"SLIM TX8 MUX", "DEC4", "DEC4 MUX"}, |
| 2731 | {"SLIM TX8 MUX", "DEC5", "DEC5 MUX"}, |
| 2732 | {"SLIM TX8 MUX", "DEC6", "DEC6 MUX"}, |
| 2733 | {"SLIM TX8 MUX", "DEC7", "DEC7 MUX"}, |
| 2734 | {"SLIM TX8 MUX", "DEC8", "DEC8 MUX"}, |
| 2735 | {"SLIM TX8 MUX", "DEC9", "DEC9 MUX"}, |
| 2736 | {"SLIM TX8 MUX", "DEC10", "DEC10 MUX"}, |
| 2737 | |
Kiran Kandi | c3b2440 | 2012-06-11 00:05:59 -0700 | [diff] [blame] | 2738 | {"SLIM TX9 MUX", "DEC1", "DEC1 MUX"}, |
| 2739 | {"SLIM TX9 MUX", "DEC2", "DEC2 MUX"}, |
| 2740 | {"SLIM TX9 MUX", "DEC3", "DEC3 MUX"}, |
| 2741 | {"SLIM TX9 MUX", "DEC4", "DEC4 MUX"}, |
| 2742 | {"SLIM TX9 MUX", "DEC5", "DEC5 MUX"}, |
| 2743 | {"SLIM TX9 MUX", "DEC6", "DEC6 MUX"}, |
| 2744 | {"SLIM TX9 MUX", "DEC7", "DEC7 MUX"}, |
| 2745 | {"SLIM TX9 MUX", "DEC8", "DEC8 MUX"}, |
| 2746 | {"SLIM TX9 MUX", "DEC9", "DEC9 MUX"}, |
| 2747 | {"SLIM TX9 MUX", "DEC10", "DEC10 MUX"}, |
| 2748 | |
Kiran Kandi | c3b2440 | 2012-06-11 00:05:59 -0700 | [diff] [blame] | 2749 | {"SLIM TX10 MUX", "DEC1", "DEC1 MUX"}, |
| 2750 | {"SLIM TX10 MUX", "DEC2", "DEC2 MUX"}, |
| 2751 | {"SLIM TX10 MUX", "DEC3", "DEC3 MUX"}, |
| 2752 | {"SLIM TX10 MUX", "DEC4", "DEC4 MUX"}, |
| 2753 | {"SLIM TX10 MUX", "DEC5", "DEC5 MUX"}, |
| 2754 | {"SLIM TX10 MUX", "DEC6", "DEC6 MUX"}, |
| 2755 | {"SLIM TX10 MUX", "DEC7", "DEC7 MUX"}, |
| 2756 | {"SLIM TX10 MUX", "DEC8", "DEC8 MUX"}, |
| 2757 | {"SLIM TX10 MUX", "DEC9", "DEC9 MUX"}, |
| 2758 | {"SLIM TX10 MUX", "DEC10", "DEC10 MUX"}, |
| 2759 | |
Joonwoo Park | e2bb544 | 2013-01-22 13:30:17 -0800 | [diff] [blame] | 2760 | /* Change Pump */ |
| 2761 | {"CP", NULL, "CLASS_H_CLK"}, |
| 2762 | |
Kiran Kandi | c3b2440 | 2012-06-11 00:05:59 -0700 | [diff] [blame] | 2763 | /* Earpiece (RX MIX1) */ |
| 2764 | {"EAR", NULL, "EAR PA"}, |
| 2765 | {"EAR PA", NULL, "EAR_PA_MIXER"}, |
| 2766 | {"EAR_PA_MIXER", NULL, "DAC1"}, |
Joonwoo Park | e2bb544 | 2013-01-22 13:30:17 -0800 | [diff] [blame] | 2767 | {"DAC1", NULL, "CLASS_H_EAR"}, |
| 2768 | {"CLASS_H_EAR", NULL, "CP"}, |
Kiran Kandi | c3b2440 | 2012-06-11 00:05:59 -0700 | [diff] [blame] | 2769 | |
| 2770 | {"ANC1 FB MUX", "EAR_HPH_L", "RX1 MIX2"}, |
| 2771 | {"ANC1 FB MUX", "EAR_LINE_1", "RX2 MIX2"}, |
| 2772 | {"ANC", NULL, "ANC1 FB MUX"}, |
| 2773 | |
| 2774 | /* Headset (RX MIX1 and RX MIX2) */ |
| 2775 | {"HEADPHONE", NULL, "HPHL"}, |
| 2776 | {"HEADPHONE", NULL, "HPHR"}, |
| 2777 | |
| 2778 | {"HPHL", NULL, "HPHL_PA_MIXER"}, |
| 2779 | {"HPHL_PA_MIXER", NULL, "HPHL DAC"}, |
| 2780 | |
| 2781 | {"HPHR", NULL, "HPHR_PA_MIXER"}, |
| 2782 | {"HPHR_PA_MIXER", NULL, "HPHR DAC"}, |
| 2783 | |
Joonwoo Park | e2bb544 | 2013-01-22 13:30:17 -0800 | [diff] [blame] | 2784 | {"HPHL DAC", NULL, "CLASS_H_HPH_L"}, |
| 2785 | {"CLASS_H_HPH_L", NULL, "CP"}, |
Kiran Kandi | 4c56c59 | 2012-07-25 11:04:55 -0700 | [diff] [blame] | 2786 | |
Joonwoo Park | e2bb544 | 2013-01-22 13:30:17 -0800 | [diff] [blame] | 2787 | {"HPHR DAC", NULL, "CLASS_H_HPH_R"}, |
| 2788 | {"CLASS_H_HPH_R", NULL, "CP"}, |
Kiran Kandi | c3b2440 | 2012-06-11 00:05:59 -0700 | [diff] [blame] | 2789 | |
| 2790 | {"ANC", NULL, "ANC1 MUX"}, |
| 2791 | {"ANC", NULL, "ANC2 MUX"}, |
| 2792 | {"ANC1 MUX", "ADC1", "ADC1"}, |
| 2793 | {"ANC1 MUX", "ADC2", "ADC2"}, |
| 2794 | {"ANC1 MUX", "ADC3", "ADC3"}, |
| 2795 | {"ANC1 MUX", "ADC4", "ADC4"}, |
| 2796 | {"ANC2 MUX", "ADC1", "ADC1"}, |
| 2797 | {"ANC2 MUX", "ADC2", "ADC2"}, |
| 2798 | {"ANC2 MUX", "ADC3", "ADC3"}, |
| 2799 | {"ANC2 MUX", "ADC4", "ADC4"}, |
| 2800 | |
| 2801 | {"ANC", NULL, "CDC_CONN"}, |
| 2802 | |
| 2803 | {"DAC1", "Switch", "RX1 CHAIN"}, |
| 2804 | {"HPHL DAC", "Switch", "RX1 CHAIN"}, |
| 2805 | {"HPHR DAC", NULL, "RX2 CHAIN"}, |
| 2806 | |
| 2807 | {"LINEOUT1", NULL, "LINEOUT1 PA"}, |
| 2808 | {"LINEOUT2", NULL, "LINEOUT2 PA"}, |
| 2809 | {"LINEOUT3", NULL, "LINEOUT3 PA"}, |
| 2810 | {"LINEOUT4", NULL, "LINEOUT4 PA"}, |
Joonwoo Park | 7680b9f | 2012-07-13 11:36:48 -0700 | [diff] [blame] | 2811 | {"SPK_OUT", NULL, "SPK PA"}, |
Kiran Kandi | c3b2440 | 2012-06-11 00:05:59 -0700 | [diff] [blame] | 2812 | |
Tanya Finkel | fe63446 | 2012-10-23 22:12:07 +0200 | [diff] [blame] | 2813 | {"LINEOUT1 PA", NULL, "CP"}, |
Kiran Kandi | c3b2440 | 2012-06-11 00:05:59 -0700 | [diff] [blame] | 2814 | {"LINEOUT1 PA", NULL, "LINEOUT1_PA_MIXER"}, |
| 2815 | {"LINEOUT1_PA_MIXER", NULL, "LINEOUT1 DAC"}, |
Tanya Finkel | fe63446 | 2012-10-23 22:12:07 +0200 | [diff] [blame] | 2816 | |
| 2817 | {"LINEOUT2 PA", NULL, "CP"}, |
Kiran Kandi | c3b2440 | 2012-06-11 00:05:59 -0700 | [diff] [blame] | 2818 | {"LINEOUT2 PA", NULL, "LINEOUT2_PA_MIXER"}, |
| 2819 | {"LINEOUT2_PA_MIXER", NULL, "LINEOUT2 DAC"}, |
Tanya Finkel | fe63446 | 2012-10-23 22:12:07 +0200 | [diff] [blame] | 2820 | |
| 2821 | {"LINEOUT3 PA", NULL, "CP"}, |
Kiran Kandi | c3b2440 | 2012-06-11 00:05:59 -0700 | [diff] [blame] | 2822 | {"LINEOUT3 PA", NULL, "LINEOUT3_PA_MIXER"}, |
| 2823 | {"LINEOUT3_PA_MIXER", NULL, "LINEOUT3 DAC"}, |
Tanya Finkel | fe63446 | 2012-10-23 22:12:07 +0200 | [diff] [blame] | 2824 | |
| 2825 | {"LINEOUT4 PA", NULL, "CP"}, |
Kiran Kandi | c3b2440 | 2012-06-11 00:05:59 -0700 | [diff] [blame] | 2826 | {"LINEOUT4 PA", NULL, "LINEOUT4_PA_MIXER"}, |
| 2827 | {"LINEOUT4_PA_MIXER", NULL, "LINEOUT4 DAC"}, |
| 2828 | |
Tanya Finkel | fe63446 | 2012-10-23 22:12:07 +0200 | [diff] [blame] | 2829 | {"CP", NULL, "CLASS_H_LINEOUTS_PA"}, |
| 2830 | {"CLASS_H_LINEOUTS_PA", NULL, "CLASS_H_CLK"}, |
| 2831 | |
| 2832 | |
| 2833 | |
Kiran Kandi | c3b2440 | 2012-06-11 00:05:59 -0700 | [diff] [blame] | 2834 | {"LINEOUT1 DAC", NULL, "RX3 MIX1"}, |
| 2835 | |
Tanya Finkel | daaa6d1 | 2012-10-25 11:22:48 +0200 | [diff] [blame] | 2836 | |
| 2837 | {"RDAC5 MUX", "DEM3_INV", "RX3 MIX1"}, |
| 2838 | {"RDAC5 MUX", "DEM4", "RX4 MIX1"}, |
| 2839 | |
| 2840 | {"LINEOUT3 DAC", NULL, "RDAC5 MUX"}, |
Kiran Kandi | c3b2440 | 2012-06-11 00:05:59 -0700 | [diff] [blame] | 2841 | |
| 2842 | {"LINEOUT2 DAC", NULL, "RX5 MIX1"}, |
| 2843 | |
Tanya Finkel | daaa6d1 | 2012-10-25 11:22:48 +0200 | [diff] [blame] | 2844 | {"RDAC7 MUX", "DEM5_INV", "RX5 MIX1"}, |
| 2845 | {"RDAC7 MUX", "DEM6", "RX6 MIX1"}, |
| 2846 | |
| 2847 | {"LINEOUT4 DAC", NULL, "RDAC7 MUX"}, |
Kiran Kandi | c3b2440 | 2012-06-11 00:05:59 -0700 | [diff] [blame] | 2848 | |
Joonwoo Park | 7680b9f | 2012-07-13 11:36:48 -0700 | [diff] [blame] | 2849 | {"SPK PA", NULL, "SPK DAC"}, |
Kiran Kandi | d2b4633 | 2012-10-05 12:04:00 -0700 | [diff] [blame] | 2850 | {"SPK DAC", NULL, "RX7 MIX2"}, |
Joonwoo Park | 125cd4e | 2012-12-11 15:16:11 -0800 | [diff] [blame] | 2851 | {"SPK DAC", NULL, "VDD_SPKDRV"}, |
Joonwoo Park | 7680b9f | 2012-07-13 11:36:48 -0700 | [diff] [blame] | 2852 | |
Kiran Kandi | c3b2440 | 2012-06-11 00:05:59 -0700 | [diff] [blame] | 2853 | {"RX1 CHAIN", NULL, "RX1 MIX2"}, |
| 2854 | {"RX2 CHAIN", NULL, "RX2 MIX2"}, |
| 2855 | {"RX1 CHAIN", NULL, "ANC"}, |
| 2856 | {"RX2 CHAIN", NULL, "ANC"}, |
| 2857 | |
Kiran Kandi | 4c56c59 | 2012-07-25 11:04:55 -0700 | [diff] [blame] | 2858 | {"CLASS_H_CLK", NULL, "RX_BIAS"}, |
Kiran Kandi | c3b2440 | 2012-06-11 00:05:59 -0700 | [diff] [blame] | 2859 | {"LINEOUT1 DAC", NULL, "RX_BIAS"}, |
| 2860 | {"LINEOUT2 DAC", NULL, "RX_BIAS"}, |
| 2861 | {"LINEOUT3 DAC", NULL, "RX_BIAS"}, |
| 2862 | {"LINEOUT4 DAC", NULL, "RX_BIAS"}, |
Joonwoo Park | 7680b9f | 2012-07-13 11:36:48 -0700 | [diff] [blame] | 2863 | {"SPK DAC", NULL, "RX_BIAS"}, |
Kiran Kandi | c3b2440 | 2012-06-11 00:05:59 -0700 | [diff] [blame] | 2864 | |
Joonwoo Park | c773143 | 2012-10-17 12:41:44 -0700 | [diff] [blame] | 2865 | {"RX7 MIX1", NULL, "COMP0_CLK"}, |
Kiran Kandi | c3b2440 | 2012-06-11 00:05:59 -0700 | [diff] [blame] | 2866 | {"RX1 MIX1", NULL, "COMP1_CLK"}, |
| 2867 | {"RX2 MIX1", NULL, "COMP1_CLK"}, |
| 2868 | {"RX3 MIX1", NULL, "COMP2_CLK"}, |
| 2869 | {"RX5 MIX1", NULL, "COMP2_CLK"}, |
| 2870 | |
Kiran Kandi | c3b2440 | 2012-06-11 00:05:59 -0700 | [diff] [blame] | 2871 | {"RX1 MIX1", NULL, "RX1 MIX1 INP1"}, |
| 2872 | {"RX1 MIX1", NULL, "RX1 MIX1 INP2"}, |
| 2873 | {"RX1 MIX1", NULL, "RX1 MIX1 INP3"}, |
| 2874 | {"RX2 MIX1", NULL, "RX2 MIX1 INP1"}, |
| 2875 | {"RX2 MIX1", NULL, "RX2 MIX1 INP2"}, |
| 2876 | {"RX3 MIX1", NULL, "RX3 MIX1 INP1"}, |
| 2877 | {"RX3 MIX1", NULL, "RX3 MIX1 INP2"}, |
| 2878 | {"RX4 MIX1", NULL, "RX4 MIX1 INP1"}, |
| 2879 | {"RX4 MIX1", NULL, "RX4 MIX1 INP2"}, |
| 2880 | {"RX5 MIX1", NULL, "RX5 MIX1 INP1"}, |
| 2881 | {"RX5 MIX1", NULL, "RX5 MIX1 INP2"}, |
| 2882 | {"RX6 MIX1", NULL, "RX6 MIX1 INP1"}, |
| 2883 | {"RX6 MIX1", NULL, "RX6 MIX1 INP2"}, |
| 2884 | {"RX7 MIX1", NULL, "RX7 MIX1 INP1"}, |
| 2885 | {"RX7 MIX1", NULL, "RX7 MIX1 INP2"}, |
| 2886 | {"RX1 MIX2", NULL, "RX1 MIX1"}, |
| 2887 | {"RX1 MIX2", NULL, "RX1 MIX2 INP1"}, |
| 2888 | {"RX1 MIX2", NULL, "RX1 MIX2 INP2"}, |
| 2889 | {"RX2 MIX2", NULL, "RX2 MIX1"}, |
| 2890 | {"RX2 MIX2", NULL, "RX2 MIX2 INP1"}, |
| 2891 | {"RX2 MIX2", NULL, "RX2 MIX2 INP2"}, |
| 2892 | {"RX7 MIX2", NULL, "RX7 MIX1"}, |
| 2893 | {"RX7 MIX2", NULL, "RX7 MIX2 INP1"}, |
| 2894 | {"RX7 MIX2", NULL, "RX7 MIX2 INP2"}, |
| 2895 | |
Kuirong Wang | 906ac47 | 2012-07-09 12:54:44 -0700 | [diff] [blame] | 2896 | /* SLIM_MUX("AIF1_PB", "AIF1 PB"),*/ |
| 2897 | {"SLIM RX1 MUX", "AIF1_PB", "AIF1 PB"}, |
| 2898 | {"SLIM RX2 MUX", "AIF1_PB", "AIF1 PB"}, |
| 2899 | {"SLIM RX3 MUX", "AIF1_PB", "AIF1 PB"}, |
| 2900 | {"SLIM RX4 MUX", "AIF1_PB", "AIF1 PB"}, |
| 2901 | {"SLIM RX5 MUX", "AIF1_PB", "AIF1 PB"}, |
| 2902 | {"SLIM RX6 MUX", "AIF1_PB", "AIF1 PB"}, |
| 2903 | {"SLIM RX7 MUX", "AIF1_PB", "AIF1 PB"}, |
| 2904 | /* SLIM_MUX("AIF2_PB", "AIF2 PB"),*/ |
| 2905 | {"SLIM RX1 MUX", "AIF2_PB", "AIF2 PB"}, |
| 2906 | {"SLIM RX2 MUX", "AIF2_PB", "AIF2 PB"}, |
| 2907 | {"SLIM RX3 MUX", "AIF2_PB", "AIF2 PB"}, |
| 2908 | {"SLIM RX4 MUX", "AIF2_PB", "AIF2 PB"}, |
| 2909 | {"SLIM RX5 MUX", "AIF2_PB", "AIF2 PB"}, |
| 2910 | {"SLIM RX6 MUX", "AIF2_PB", "AIF2 PB"}, |
| 2911 | {"SLIM RX7 MUX", "AIF2_PB", "AIF2 PB"}, |
| 2912 | /* SLIM_MUX("AIF3_PB", "AIF3 PB"),*/ |
| 2913 | {"SLIM RX1 MUX", "AIF3_PB", "AIF3 PB"}, |
| 2914 | {"SLIM RX2 MUX", "AIF3_PB", "AIF3 PB"}, |
| 2915 | {"SLIM RX3 MUX", "AIF3_PB", "AIF3 PB"}, |
| 2916 | {"SLIM RX4 MUX", "AIF3_PB", "AIF3 PB"}, |
| 2917 | {"SLIM RX5 MUX", "AIF3_PB", "AIF3 PB"}, |
| 2918 | {"SLIM RX6 MUX", "AIF3_PB", "AIF3 PB"}, |
| 2919 | {"SLIM RX7 MUX", "AIF3_PB", "AIF3 PB"}, |
| 2920 | |
| 2921 | {"SLIM RX1", NULL, "SLIM RX1 MUX"}, |
| 2922 | {"SLIM RX2", NULL, "SLIM RX2 MUX"}, |
| 2923 | {"SLIM RX3", NULL, "SLIM RX3 MUX"}, |
| 2924 | {"SLIM RX4", NULL, "SLIM RX4 MUX"}, |
| 2925 | {"SLIM RX5", NULL, "SLIM RX5 MUX"}, |
| 2926 | {"SLIM RX6", NULL, "SLIM RX6 MUX"}, |
| 2927 | {"SLIM RX7", NULL, "SLIM RX7 MUX"}, |
| 2928 | |
Kiran Kandi | c3b2440 | 2012-06-11 00:05:59 -0700 | [diff] [blame] | 2929 | {"RX1 MIX1 INP1", "RX1", "SLIM RX1"}, |
| 2930 | {"RX1 MIX1 INP1", "RX2", "SLIM RX2"}, |
| 2931 | {"RX1 MIX1 INP1", "RX3", "SLIM RX3"}, |
| 2932 | {"RX1 MIX1 INP1", "RX4", "SLIM RX4"}, |
| 2933 | {"RX1 MIX1 INP1", "RX5", "SLIM RX5"}, |
| 2934 | {"RX1 MIX1 INP1", "RX6", "SLIM RX6"}, |
| 2935 | {"RX1 MIX1 INP1", "RX7", "SLIM RX7"}, |
| 2936 | {"RX1 MIX1 INP1", "IIR1", "IIR1"}, |
| 2937 | {"RX1 MIX1 INP2", "RX1", "SLIM RX1"}, |
| 2938 | {"RX1 MIX1 INP2", "RX2", "SLIM RX2"}, |
| 2939 | {"RX1 MIX1 INP2", "RX3", "SLIM RX3"}, |
| 2940 | {"RX1 MIX1 INP2", "RX4", "SLIM RX4"}, |
| 2941 | {"RX1 MIX1 INP2", "RX5", "SLIM RX5"}, |
| 2942 | {"RX1 MIX1 INP2", "RX6", "SLIM RX6"}, |
| 2943 | {"RX1 MIX1 INP2", "RX7", "SLIM RX7"}, |
| 2944 | {"RX1 MIX1 INP2", "IIR1", "IIR1"}, |
| 2945 | {"RX1 MIX1 INP3", "RX1", "SLIM RX1"}, |
| 2946 | {"RX1 MIX1 INP3", "RX2", "SLIM RX2"}, |
| 2947 | {"RX1 MIX1 INP3", "RX3", "SLIM RX3"}, |
| 2948 | {"RX1 MIX1 INP3", "RX4", "SLIM RX4"}, |
| 2949 | {"RX1 MIX1 INP3", "RX5", "SLIM RX5"}, |
| 2950 | {"RX1 MIX1 INP3", "RX6", "SLIM RX6"}, |
| 2951 | {"RX1 MIX1 INP3", "RX7", "SLIM RX7"}, |
| 2952 | {"RX2 MIX1 INP1", "RX1", "SLIM RX1"}, |
| 2953 | {"RX2 MIX1 INP1", "RX2", "SLIM RX2"}, |
| 2954 | {"RX2 MIX1 INP1", "RX3", "SLIM RX3"}, |
| 2955 | {"RX2 MIX1 INP1", "RX4", "SLIM RX4"}, |
| 2956 | {"RX2 MIX1 INP1", "RX5", "SLIM RX5"}, |
| 2957 | {"RX2 MIX1 INP1", "RX6", "SLIM RX6"}, |
| 2958 | {"RX2 MIX1 INP1", "RX7", "SLIM RX7"}, |
| 2959 | {"RX2 MIX1 INP1", "IIR1", "IIR1"}, |
| 2960 | {"RX2 MIX1 INP2", "RX1", "SLIM RX1"}, |
| 2961 | {"RX2 MIX1 INP2", "RX2", "SLIM RX2"}, |
| 2962 | {"RX2 MIX1 INP2", "RX3", "SLIM RX3"}, |
| 2963 | {"RX2 MIX1 INP2", "RX4", "SLIM RX4"}, |
| 2964 | {"RX2 MIX1 INP2", "RX5", "SLIM RX5"}, |
| 2965 | {"RX2 MIX1 INP2", "RX6", "SLIM RX6"}, |
| 2966 | {"RX2 MIX1 INP2", "RX7", "SLIM RX7"}, |
| 2967 | {"RX2 MIX1 INP2", "IIR1", "IIR1"}, |
| 2968 | {"RX3 MIX1 INP1", "RX1", "SLIM RX1"}, |
| 2969 | {"RX3 MIX1 INP1", "RX2", "SLIM RX2"}, |
| 2970 | {"RX3 MIX1 INP1", "RX3", "SLIM RX3"}, |
| 2971 | {"RX3 MIX1 INP1", "RX4", "SLIM RX4"}, |
| 2972 | {"RX3 MIX1 INP1", "RX5", "SLIM RX5"}, |
| 2973 | {"RX3 MIX1 INP1", "RX6", "SLIM RX6"}, |
| 2974 | {"RX3 MIX1 INP1", "RX7", "SLIM RX7"}, |
| 2975 | {"RX3 MIX1 INP1", "IIR1", "IIR1"}, |
| 2976 | {"RX3 MIX1 INP2", "RX1", "SLIM RX1"}, |
| 2977 | {"RX3 MIX1 INP2", "RX2", "SLIM RX2"}, |
| 2978 | {"RX3 MIX1 INP2", "RX3", "SLIM RX3"}, |
| 2979 | {"RX3 MIX1 INP2", "RX4", "SLIM RX4"}, |
| 2980 | {"RX3 MIX1 INP2", "RX5", "SLIM RX5"}, |
| 2981 | {"RX3 MIX1 INP2", "RX6", "SLIM RX6"}, |
| 2982 | {"RX3 MIX1 INP2", "RX7", "SLIM RX7"}, |
| 2983 | {"RX3 MIX1 INP2", "IIR1", "IIR1"}, |
| 2984 | {"RX4 MIX1 INP1", "RX1", "SLIM RX1"}, |
| 2985 | {"RX4 MIX1 INP1", "RX2", "SLIM RX2"}, |
| 2986 | {"RX4 MIX1 INP1", "RX3", "SLIM RX3"}, |
| 2987 | {"RX4 MIX1 INP1", "RX4", "SLIM RX4"}, |
| 2988 | {"RX4 MIX1 INP1", "RX5", "SLIM RX5"}, |
| 2989 | {"RX4 MIX1 INP1", "RX6", "SLIM RX6"}, |
| 2990 | {"RX4 MIX1 INP1", "RX7", "SLIM RX7"}, |
| 2991 | {"RX4 MIX1 INP1", "IIR1", "IIR1"}, |
| 2992 | {"RX4 MIX1 INP2", "RX1", "SLIM RX1"}, |
| 2993 | {"RX4 MIX1 INP2", "RX2", "SLIM RX2"}, |
| 2994 | {"RX4 MIX1 INP2", "RX3", "SLIM RX3"}, |
| 2995 | {"RX4 MIX1 INP2", "RX5", "SLIM RX5"}, |
| 2996 | {"RX4 MIX1 INP2", "RX4", "SLIM RX4"}, |
| 2997 | {"RX4 MIX1 INP2", "RX6", "SLIM RX6"}, |
| 2998 | {"RX4 MIX1 INP2", "RX7", "SLIM RX7"}, |
| 2999 | {"RX4 MIX1 INP2", "IIR1", "IIR1"}, |
| 3000 | {"RX5 MIX1 INP1", "RX1", "SLIM RX1"}, |
| 3001 | {"RX5 MIX1 INP1", "RX2", "SLIM RX2"}, |
| 3002 | {"RX5 MIX1 INP1", "RX3", "SLIM RX3"}, |
| 3003 | {"RX5 MIX1 INP1", "RX4", "SLIM RX4"}, |
| 3004 | {"RX5 MIX1 INP1", "RX5", "SLIM RX5"}, |
| 3005 | {"RX5 MIX1 INP1", "RX6", "SLIM RX6"}, |
| 3006 | {"RX5 MIX1 INP1", "RX7", "SLIM RX7"}, |
| 3007 | {"RX5 MIX1 INP1", "IIR1", "IIR1"}, |
| 3008 | {"RX5 MIX1 INP2", "RX1", "SLIM RX1"}, |
| 3009 | {"RX5 MIX1 INP2", "RX2", "SLIM RX2"}, |
| 3010 | {"RX5 MIX1 INP2", "RX3", "SLIM RX3"}, |
| 3011 | {"RX5 MIX1 INP2", "RX4", "SLIM RX4"}, |
| 3012 | {"RX5 MIX1 INP2", "RX5", "SLIM RX5"}, |
| 3013 | {"RX5 MIX1 INP2", "RX6", "SLIM RX6"}, |
| 3014 | {"RX5 MIX1 INP2", "RX7", "SLIM RX7"}, |
| 3015 | {"RX5 MIX1 INP2", "IIR1", "IIR1"}, |
| 3016 | {"RX6 MIX1 INP1", "RX1", "SLIM RX1"}, |
| 3017 | {"RX6 MIX1 INP1", "RX2", "SLIM RX2"}, |
| 3018 | {"RX6 MIX1 INP1", "RX3", "SLIM RX3"}, |
| 3019 | {"RX6 MIX1 INP1", "RX4", "SLIM RX4"}, |
| 3020 | {"RX6 MIX1 INP1", "RX5", "SLIM RX5"}, |
| 3021 | {"RX6 MIX1 INP1", "RX6", "SLIM RX6"}, |
| 3022 | {"RX6 MIX1 INP1", "RX7", "SLIM RX7"}, |
| 3023 | {"RX6 MIX1 INP1", "IIR1", "IIR1"}, |
| 3024 | {"RX6 MIX1 INP2", "RX1", "SLIM RX1"}, |
| 3025 | {"RX6 MIX1 INP2", "RX2", "SLIM RX2"}, |
| 3026 | {"RX6 MIX1 INP2", "RX3", "SLIM RX3"}, |
| 3027 | {"RX6 MIX1 INP2", "RX4", "SLIM RX4"}, |
| 3028 | {"RX6 MIX1 INP2", "RX5", "SLIM RX5"}, |
| 3029 | {"RX6 MIX1 INP2", "RX6", "SLIM RX6"}, |
| 3030 | {"RX6 MIX1 INP2", "RX7", "SLIM RX7"}, |
| 3031 | {"RX6 MIX1 INP2", "IIR1", "IIR1"}, |
| 3032 | {"RX7 MIX1 INP1", "RX1", "SLIM RX1"}, |
| 3033 | {"RX7 MIX1 INP1", "RX2", "SLIM RX2"}, |
| 3034 | {"RX7 MIX1 INP1", "RX3", "SLIM RX3"}, |
| 3035 | {"RX7 MIX1 INP1", "RX4", "SLIM RX4"}, |
| 3036 | {"RX7 MIX1 INP1", "RX5", "SLIM RX5"}, |
| 3037 | {"RX7 MIX1 INP1", "RX6", "SLIM RX6"}, |
| 3038 | {"RX7 MIX1 INP1", "RX7", "SLIM RX7"}, |
| 3039 | {"RX7 MIX1 INP1", "IIR1", "IIR1"}, |
| 3040 | {"RX7 MIX1 INP2", "RX1", "SLIM RX1"}, |
| 3041 | {"RX7 MIX1 INP2", "RX2", "SLIM RX2"}, |
| 3042 | {"RX7 MIX1 INP2", "RX3", "SLIM RX3"}, |
| 3043 | {"RX7 MIX1 INP2", "RX4", "SLIM RX4"}, |
| 3044 | {"RX7 MIX1 INP2", "RX5", "SLIM RX5"}, |
| 3045 | {"RX7 MIX1 INP2", "RX6", "SLIM RX6"}, |
| 3046 | {"RX7 MIX1 INP2", "RX7", "SLIM RX7"}, |
| 3047 | {"RX7 MIX1 INP2", "IIR1", "IIR1"}, |
| 3048 | {"RX1 MIX2 INP1", "IIR1", "IIR1"}, |
| 3049 | {"RX1 MIX2 INP2", "IIR1", "IIR1"}, |
| 3050 | {"RX2 MIX2 INP1", "IIR1", "IIR1"}, |
| 3051 | {"RX2 MIX2 INP2", "IIR1", "IIR1"}, |
| 3052 | {"RX7 MIX2 INP1", "IIR1", "IIR1"}, |
| 3053 | {"RX7 MIX2 INP2", "IIR1", "IIR1"}, |
| 3054 | |
| 3055 | /* Decimator Inputs */ |
| 3056 | {"DEC1 MUX", "DMIC1", "DMIC1"}, |
| 3057 | {"DEC1 MUX", "ADC6", "ADC6"}, |
| 3058 | {"DEC1 MUX", NULL, "CDC_CONN"}, |
| 3059 | {"DEC2 MUX", "DMIC2", "DMIC2"}, |
| 3060 | {"DEC2 MUX", "ADC5", "ADC5"}, |
| 3061 | {"DEC2 MUX", NULL, "CDC_CONN"}, |
| 3062 | {"DEC3 MUX", "DMIC3", "DMIC3"}, |
| 3063 | {"DEC3 MUX", "ADC4", "ADC4"}, |
| 3064 | {"DEC3 MUX", NULL, "CDC_CONN"}, |
| 3065 | {"DEC4 MUX", "DMIC4", "DMIC4"}, |
| 3066 | {"DEC4 MUX", "ADC3", "ADC3"}, |
| 3067 | {"DEC4 MUX", NULL, "CDC_CONN"}, |
| 3068 | {"DEC5 MUX", "DMIC5", "DMIC5"}, |
| 3069 | {"DEC5 MUX", "ADC2", "ADC2"}, |
| 3070 | {"DEC5 MUX", NULL, "CDC_CONN"}, |
| 3071 | {"DEC6 MUX", "DMIC6", "DMIC6"}, |
| 3072 | {"DEC6 MUX", "ADC1", "ADC1"}, |
| 3073 | {"DEC6 MUX", NULL, "CDC_CONN"}, |
| 3074 | {"DEC7 MUX", "DMIC1", "DMIC1"}, |
| 3075 | {"DEC7 MUX", "DMIC6", "DMIC6"}, |
| 3076 | {"DEC7 MUX", "ADC1", "ADC1"}, |
| 3077 | {"DEC7 MUX", "ADC6", "ADC6"}, |
| 3078 | {"DEC7 MUX", NULL, "CDC_CONN"}, |
| 3079 | {"DEC8 MUX", "DMIC2", "DMIC2"}, |
| 3080 | {"DEC8 MUX", "DMIC5", "DMIC5"}, |
| 3081 | {"DEC8 MUX", "ADC2", "ADC2"}, |
| 3082 | {"DEC8 MUX", "ADC5", "ADC5"}, |
| 3083 | {"DEC8 MUX", NULL, "CDC_CONN"}, |
| 3084 | {"DEC9 MUX", "DMIC4", "DMIC4"}, |
| 3085 | {"DEC9 MUX", "DMIC5", "DMIC5"}, |
| 3086 | {"DEC9 MUX", "ADC2", "ADC2"}, |
| 3087 | {"DEC9 MUX", "ADC3", "ADC3"}, |
| 3088 | {"DEC9 MUX", NULL, "CDC_CONN"}, |
| 3089 | {"DEC10 MUX", "DMIC3", "DMIC3"}, |
| 3090 | {"DEC10 MUX", "DMIC6", "DMIC6"}, |
| 3091 | {"DEC10 MUX", "ADC1", "ADC1"}, |
| 3092 | {"DEC10 MUX", "ADC4", "ADC4"}, |
| 3093 | {"DEC10 MUX", NULL, "CDC_CONN"}, |
| 3094 | |
| 3095 | /* ADC Connections */ |
| 3096 | {"ADC1", NULL, "AMIC1"}, |
| 3097 | {"ADC2", NULL, "AMIC2"}, |
| 3098 | {"ADC3", NULL, "AMIC3"}, |
| 3099 | {"ADC4", NULL, "AMIC4"}, |
| 3100 | {"ADC5", NULL, "AMIC5"}, |
| 3101 | {"ADC6", NULL, "AMIC6"}, |
| 3102 | |
| 3103 | /* AUX PGA Connections */ |
Kiran Kandi | c3b2440 | 2012-06-11 00:05:59 -0700 | [diff] [blame] | 3104 | {"EAR_PA_MIXER", "AUX_PGA_L Switch", "AUX_PGA_Left"}, |
Kiran Kandi | 4c56c59 | 2012-07-25 11:04:55 -0700 | [diff] [blame] | 3105 | {"HPHL_PA_MIXER", "AUX_PGA_L Switch", "AUX_PGA_Left"}, |
| 3106 | {"HPHR_PA_MIXER", "AUX_PGA_R Switch", "AUX_PGA_Right"}, |
| 3107 | {"LINEOUT1_PA_MIXER", "AUX_PGA_L Switch", "AUX_PGA_Left"}, |
| 3108 | {"LINEOUT2_PA_MIXER", "AUX_PGA_R Switch", "AUX_PGA_Right"}, |
| 3109 | {"LINEOUT3_PA_MIXER", "AUX_PGA_L Switch", "AUX_PGA_Left"}, |
| 3110 | {"LINEOUT4_PA_MIXER", "AUX_PGA_R Switch", "AUX_PGA_Right"}, |
Kiran Kandi | c3b2440 | 2012-06-11 00:05:59 -0700 | [diff] [blame] | 3111 | {"AUX_PGA_Left", NULL, "AMIC5"}, |
| 3112 | {"AUX_PGA_Right", NULL, "AMIC6"}, |
| 3113 | |
Kiran Kandi | c3b2440 | 2012-06-11 00:05:59 -0700 | [diff] [blame] | 3114 | {"IIR1", NULL, "IIR1 INP1 MUX"}, |
| 3115 | {"IIR1 INP1 MUX", "DEC1", "DEC1 MUX"}, |
| 3116 | {"IIR1 INP1 MUX", "DEC2", "DEC2 MUX"}, |
| 3117 | {"IIR1 INP1 MUX", "DEC3", "DEC3 MUX"}, |
| 3118 | {"IIR1 INP1 MUX", "DEC4", "DEC4 MUX"}, |
| 3119 | {"IIR1 INP1 MUX", "DEC5", "DEC5 MUX"}, |
| 3120 | {"IIR1 INP1 MUX", "DEC6", "DEC6 MUX"}, |
| 3121 | {"IIR1 INP1 MUX", "DEC7", "DEC7 MUX"}, |
| 3122 | {"IIR1 INP1 MUX", "DEC8", "DEC8 MUX"}, |
| 3123 | {"IIR1 INP1 MUX", "DEC9", "DEC9 MUX"}, |
| 3124 | {"IIR1 INP1 MUX", "DEC10", "DEC10 MUX"}, |
| 3125 | |
| 3126 | {"MIC BIAS1 Internal1", NULL, "LDO_H"}, |
| 3127 | {"MIC BIAS1 Internal2", NULL, "LDO_H"}, |
| 3128 | {"MIC BIAS1 External", NULL, "LDO_H"}, |
| 3129 | {"MIC BIAS2 Internal1", NULL, "LDO_H"}, |
| 3130 | {"MIC BIAS2 Internal2", NULL, "LDO_H"}, |
| 3131 | {"MIC BIAS2 Internal3", NULL, "LDO_H"}, |
| 3132 | {"MIC BIAS2 External", NULL, "LDO_H"}, |
| 3133 | {"MIC BIAS3 Internal1", NULL, "LDO_H"}, |
| 3134 | {"MIC BIAS3 Internal2", NULL, "LDO_H"}, |
| 3135 | {"MIC BIAS3 External", NULL, "LDO_H"}, |
| 3136 | {"MIC BIAS4 External", NULL, "LDO_H"}, |
| 3137 | }; |
| 3138 | |
| 3139 | static int taiko_readable(struct snd_soc_codec *ssc, unsigned int reg) |
| 3140 | { |
| 3141 | return taiko_reg_readable[reg]; |
| 3142 | } |
| 3143 | |
| 3144 | static bool taiko_is_digital_gain_register(unsigned int reg) |
| 3145 | { |
| 3146 | bool rtn = false; |
| 3147 | switch (reg) { |
| 3148 | case TAIKO_A_CDC_RX1_VOL_CTL_B2_CTL: |
| 3149 | case TAIKO_A_CDC_RX2_VOL_CTL_B2_CTL: |
| 3150 | case TAIKO_A_CDC_RX3_VOL_CTL_B2_CTL: |
| 3151 | case TAIKO_A_CDC_RX4_VOL_CTL_B2_CTL: |
| 3152 | case TAIKO_A_CDC_RX5_VOL_CTL_B2_CTL: |
| 3153 | case TAIKO_A_CDC_RX6_VOL_CTL_B2_CTL: |
| 3154 | case TAIKO_A_CDC_RX7_VOL_CTL_B2_CTL: |
| 3155 | case TAIKO_A_CDC_TX1_VOL_CTL_GAIN: |
| 3156 | case TAIKO_A_CDC_TX2_VOL_CTL_GAIN: |
| 3157 | case TAIKO_A_CDC_TX3_VOL_CTL_GAIN: |
| 3158 | case TAIKO_A_CDC_TX4_VOL_CTL_GAIN: |
| 3159 | case TAIKO_A_CDC_TX5_VOL_CTL_GAIN: |
| 3160 | case TAIKO_A_CDC_TX6_VOL_CTL_GAIN: |
| 3161 | case TAIKO_A_CDC_TX7_VOL_CTL_GAIN: |
| 3162 | case TAIKO_A_CDC_TX8_VOL_CTL_GAIN: |
| 3163 | case TAIKO_A_CDC_TX9_VOL_CTL_GAIN: |
| 3164 | case TAIKO_A_CDC_TX10_VOL_CTL_GAIN: |
| 3165 | rtn = true; |
| 3166 | break; |
| 3167 | default: |
| 3168 | break; |
| 3169 | } |
| 3170 | return rtn; |
| 3171 | } |
| 3172 | |
| 3173 | static int taiko_volatile(struct snd_soc_codec *ssc, unsigned int reg) |
| 3174 | { |
| 3175 | /* Registers lower than 0x100 are top level registers which can be |
| 3176 | * written by the Taiko core driver. |
| 3177 | */ |
| 3178 | |
| 3179 | if ((reg >= TAIKO_A_CDC_MBHC_EN_CTL) || (reg < 0x100)) |
| 3180 | return 1; |
| 3181 | |
| 3182 | /* IIR Coeff registers are not cacheable */ |
| 3183 | if ((reg >= TAIKO_A_CDC_IIR1_COEF_B1_CTL) && |
| 3184 | (reg <= TAIKO_A_CDC_IIR2_COEF_B2_CTL)) |
| 3185 | return 1; |
| 3186 | |
| 3187 | /* Digital gain register is not cacheable so we have to write |
| 3188 | * the setting even it is the same |
| 3189 | */ |
| 3190 | if (taiko_is_digital_gain_register(reg)) |
| 3191 | return 1; |
| 3192 | |
| 3193 | /* HPH status registers */ |
| 3194 | if (reg == TAIKO_A_RX_HPH_L_STATUS || reg == TAIKO_A_RX_HPH_R_STATUS) |
| 3195 | return 1; |
| 3196 | |
Joonwoo Park | a889026 | 2012-10-15 12:04:27 -0700 | [diff] [blame] | 3197 | if (reg == TAIKO_A_MBHC_INSERT_DET_STATUS) |
| 3198 | return 1; |
| 3199 | |
Joonwoo Park | 559a5bf | 2013-02-15 14:46:36 -0800 | [diff] [blame] | 3200 | switch (reg) { |
| 3201 | case TAIKO_A_CDC_SPKR_CLIPDET_VAL0: |
| 3202 | case TAIKO_A_CDC_SPKR_CLIPDET_VAL1: |
| 3203 | case TAIKO_A_CDC_SPKR_CLIPDET_VAL2: |
| 3204 | case TAIKO_A_CDC_SPKR_CLIPDET_VAL3: |
| 3205 | case TAIKO_A_CDC_SPKR_CLIPDET_VAL4: |
| 3206 | case TAIKO_A_CDC_SPKR_CLIPDET_VAL5: |
| 3207 | case TAIKO_A_CDC_SPKR_CLIPDET_VAL6: |
| 3208 | case TAIKO_A_CDC_SPKR_CLIPDET_VAL7: |
| 3209 | case TAIKO_A_CDC_VBAT_GAIN_MON_VAL: |
| 3210 | return 1; |
| 3211 | } |
| 3212 | |
Kiran Kandi | c3b2440 | 2012-06-11 00:05:59 -0700 | [diff] [blame] | 3213 | return 0; |
| 3214 | } |
| 3215 | |
| 3216 | #define TAIKO_FORMATS (SNDRV_PCM_FMTBIT_S16_LE) |
| 3217 | static int taiko_write(struct snd_soc_codec *codec, unsigned int reg, |
| 3218 | unsigned int value) |
| 3219 | { |
| 3220 | int ret; |
Kuirong Wang | 906ac47 | 2012-07-09 12:54:44 -0700 | [diff] [blame] | 3221 | |
| 3222 | if (reg == SND_SOC_NOPM) |
| 3223 | return 0; |
| 3224 | |
Kiran Kandi | c3b2440 | 2012-06-11 00:05:59 -0700 | [diff] [blame] | 3225 | BUG_ON(reg > TAIKO_MAX_REGISTER); |
| 3226 | |
| 3227 | if (!taiko_volatile(codec, reg)) { |
| 3228 | ret = snd_soc_cache_write(codec, reg, value); |
| 3229 | if (ret != 0) |
| 3230 | dev_err(codec->dev, "Cache write to %x failed: %d\n", |
| 3231 | reg, ret); |
| 3232 | } |
| 3233 | |
| 3234 | return wcd9xxx_reg_write(codec->control_data, reg, value); |
| 3235 | } |
| 3236 | static unsigned int taiko_read(struct snd_soc_codec *codec, |
| 3237 | unsigned int reg) |
| 3238 | { |
| 3239 | unsigned int val; |
| 3240 | int ret; |
| 3241 | |
Kuirong Wang | 906ac47 | 2012-07-09 12:54:44 -0700 | [diff] [blame] | 3242 | if (reg == SND_SOC_NOPM) |
| 3243 | return 0; |
| 3244 | |
Kiran Kandi | c3b2440 | 2012-06-11 00:05:59 -0700 | [diff] [blame] | 3245 | BUG_ON(reg > TAIKO_MAX_REGISTER); |
| 3246 | |
| 3247 | if (!taiko_volatile(codec, reg) && taiko_readable(codec, reg) && |
| 3248 | reg < codec->driver->reg_cache_size) { |
| 3249 | ret = snd_soc_cache_read(codec, reg, &val); |
| 3250 | if (ret >= 0) { |
| 3251 | return val; |
| 3252 | } else |
| 3253 | dev_err(codec->dev, "Cache read from %x failed: %d\n", |
| 3254 | reg, ret); |
| 3255 | } |
| 3256 | |
| 3257 | val = wcd9xxx_reg_read(codec->control_data, reg); |
| 3258 | return val; |
| 3259 | } |
| 3260 | |
Kiran Kandi | c3b2440 | 2012-06-11 00:05:59 -0700 | [diff] [blame] | 3261 | static int taiko_startup(struct snd_pcm_substream *substream, |
| 3262 | struct snd_soc_dai *dai) |
| 3263 | { |
| 3264 | struct wcd9xxx *taiko_core = dev_get_drvdata(dai->codec->dev->parent); |
| 3265 | pr_debug("%s(): substream = %s stream = %d\n" , __func__, |
| 3266 | substream->name, substream->stream); |
| 3267 | if ((taiko_core != NULL) && |
| 3268 | (taiko_core->dev != NULL) && |
| 3269 | (taiko_core->dev->parent != NULL)) |
| 3270 | pm_runtime_get_sync(taiko_core->dev->parent); |
| 3271 | |
| 3272 | return 0; |
| 3273 | } |
| 3274 | |
| 3275 | static void taiko_shutdown(struct snd_pcm_substream *substream, |
| 3276 | struct snd_soc_dai *dai) |
| 3277 | { |
| 3278 | struct wcd9xxx *taiko_core = dev_get_drvdata(dai->codec->dev->parent); |
| 3279 | pr_debug("%s(): substream = %s stream = %d\n" , __func__, |
| 3280 | substream->name, substream->stream); |
| 3281 | if ((taiko_core != NULL) && |
| 3282 | (taiko_core->dev != NULL) && |
| 3283 | (taiko_core->dev->parent != NULL)) { |
| 3284 | pm_runtime_mark_last_busy(taiko_core->dev->parent); |
| 3285 | pm_runtime_put(taiko_core->dev->parent); |
| 3286 | } |
| 3287 | } |
| 3288 | |
| 3289 | int taiko_mclk_enable(struct snd_soc_codec *codec, int mclk_enable, bool dapm) |
| 3290 | { |
| 3291 | struct taiko_priv *taiko = snd_soc_codec_get_drvdata(codec); |
| 3292 | |
| 3293 | pr_debug("%s: mclk_enable = %u, dapm = %d\n", __func__, mclk_enable, |
| 3294 | dapm); |
Joonwoo Park | a889026 | 2012-10-15 12:04:27 -0700 | [diff] [blame] | 3295 | |
| 3296 | WCD9XXX_BCL_LOCK(&taiko->resmgr); |
Kiran Kandi | c3b2440 | 2012-06-11 00:05:59 -0700 | [diff] [blame] | 3297 | if (mclk_enable) { |
Joonwoo Park | a889026 | 2012-10-15 12:04:27 -0700 | [diff] [blame] | 3298 | wcd9xxx_resmgr_get_bandgap(&taiko->resmgr, |
| 3299 | WCD9XXX_BANDGAP_AUDIO_MODE); |
| 3300 | wcd9xxx_resmgr_get_clk_block(&taiko->resmgr, WCD9XXX_CLK_MCLK); |
Kiran Kandi | c3b2440 | 2012-06-11 00:05:59 -0700 | [diff] [blame] | 3301 | } else { |
Joonwoo Park | a889026 | 2012-10-15 12:04:27 -0700 | [diff] [blame] | 3302 | /* Put clock and BG */ |
| 3303 | wcd9xxx_resmgr_put_clk_block(&taiko->resmgr, WCD9XXX_CLK_MCLK); |
| 3304 | wcd9xxx_resmgr_put_bandgap(&taiko->resmgr, |
| 3305 | WCD9XXX_BANDGAP_AUDIO_MODE); |
Kiran Kandi | c3b2440 | 2012-06-11 00:05:59 -0700 | [diff] [blame] | 3306 | } |
Joonwoo Park | a889026 | 2012-10-15 12:04:27 -0700 | [diff] [blame] | 3307 | WCD9XXX_BCL_UNLOCK(&taiko->resmgr); |
| 3308 | |
Kiran Kandi | c3b2440 | 2012-06-11 00:05:59 -0700 | [diff] [blame] | 3309 | return 0; |
| 3310 | } |
| 3311 | |
| 3312 | static int taiko_set_dai_sysclk(struct snd_soc_dai *dai, |
| 3313 | int clk_id, unsigned int freq, int dir) |
| 3314 | { |
Venkat Sudhir | a50a376 | 2012-11-26 12:12:15 -0800 | [diff] [blame] | 3315 | pr_debug("%s\n", __func__); |
Kiran Kandi | c3b2440 | 2012-06-11 00:05:59 -0700 | [diff] [blame] | 3316 | return 0; |
| 3317 | } |
| 3318 | |
| 3319 | static int taiko_set_dai_fmt(struct snd_soc_dai *dai, unsigned int fmt) |
| 3320 | { |
| 3321 | u8 val = 0; |
| 3322 | struct taiko_priv *taiko = snd_soc_codec_get_drvdata(dai->codec); |
| 3323 | |
| 3324 | pr_debug("%s\n", __func__); |
| 3325 | switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { |
| 3326 | case SND_SOC_DAIFMT_CBS_CFS: |
| 3327 | /* CPU is master */ |
| 3328 | if (taiko->intf_type == WCD9XXX_INTERFACE_TYPE_I2C) { |
| 3329 | if (dai->id == AIF1_CAP) |
| 3330 | snd_soc_update_bits(dai->codec, |
| 3331 | TAIKO_A_CDC_CLK_TX_I2S_CTL, |
| 3332 | TAIKO_I2S_MASTER_MODE_MASK, 0); |
| 3333 | else if (dai->id == AIF1_PB) |
| 3334 | snd_soc_update_bits(dai->codec, |
| 3335 | TAIKO_A_CDC_CLK_RX_I2S_CTL, |
| 3336 | TAIKO_I2S_MASTER_MODE_MASK, 0); |
| 3337 | } |
| 3338 | break; |
| 3339 | case SND_SOC_DAIFMT_CBM_CFM: |
| 3340 | /* CPU is slave */ |
| 3341 | if (taiko->intf_type == WCD9XXX_INTERFACE_TYPE_I2C) { |
| 3342 | val = TAIKO_I2S_MASTER_MODE_MASK; |
| 3343 | if (dai->id == AIF1_CAP) |
| 3344 | snd_soc_update_bits(dai->codec, |
| 3345 | TAIKO_A_CDC_CLK_TX_I2S_CTL, val, val); |
| 3346 | else if (dai->id == AIF1_PB) |
| 3347 | snd_soc_update_bits(dai->codec, |
| 3348 | TAIKO_A_CDC_CLK_RX_I2S_CTL, val, val); |
| 3349 | } |
| 3350 | break; |
| 3351 | default: |
| 3352 | return -EINVAL; |
| 3353 | } |
| 3354 | return 0; |
| 3355 | } |
| 3356 | |
| 3357 | static int taiko_set_channel_map(struct snd_soc_dai *dai, |
| 3358 | unsigned int tx_num, unsigned int *tx_slot, |
| 3359 | unsigned int rx_num, unsigned int *rx_slot) |
| 3360 | |
| 3361 | { |
| 3362 | struct taiko_priv *taiko = snd_soc_codec_get_drvdata(dai->codec); |
Kuirong Wang | 906ac47 | 2012-07-09 12:54:44 -0700 | [diff] [blame] | 3363 | struct wcd9xxx *core = dev_get_drvdata(dai->codec->dev->parent); |
Kiran Kandi | c3b2440 | 2012-06-11 00:05:59 -0700 | [diff] [blame] | 3364 | if (!tx_slot && !rx_slot) { |
| 3365 | pr_err("%s: Invalid\n", __func__); |
| 3366 | return -EINVAL; |
| 3367 | } |
Kuirong Wang | 906ac47 | 2012-07-09 12:54:44 -0700 | [diff] [blame] | 3368 | pr_debug("%s(): dai_name = %s DAI-ID %x tx_ch %d rx_ch %d\n" |
| 3369 | "taiko->intf_type %d\n", |
| 3370 | __func__, dai->name, dai->id, tx_num, rx_num, |
| 3371 | taiko->intf_type); |
Kiran Kandi | c3b2440 | 2012-06-11 00:05:59 -0700 | [diff] [blame] | 3372 | |
Kuirong Wang | 906ac47 | 2012-07-09 12:54:44 -0700 | [diff] [blame] | 3373 | if (taiko->intf_type == WCD9XXX_INTERFACE_TYPE_SLIMBUS) |
| 3374 | wcd9xxx_init_slimslave(core, core->slim->laddr, |
| 3375 | tx_num, tx_slot, rx_num, rx_slot); |
| 3376 | return 0; |
| 3377 | } |
| 3378 | |
| 3379 | static int taiko_get_channel_map(struct snd_soc_dai *dai, |
| 3380 | unsigned int *tx_num, unsigned int *tx_slot, |
| 3381 | unsigned int *rx_num, unsigned int *rx_slot) |
| 3382 | |
| 3383 | { |
| 3384 | struct taiko_priv *taiko_p = snd_soc_codec_get_drvdata(dai->codec); |
| 3385 | u32 i = 0; |
| 3386 | struct wcd9xxx_ch *ch; |
| 3387 | |
| 3388 | switch (dai->id) { |
| 3389 | case AIF1_PB: |
| 3390 | case AIF2_PB: |
| 3391 | case AIF3_PB: |
| 3392 | if (!rx_slot || !rx_num) { |
| 3393 | pr_err("%s: Invalid rx_slot %d or rx_num %d\n", |
| 3394 | __func__, (u32) rx_slot, (u32) rx_num); |
| 3395 | return -EINVAL; |
Kiran Kandi | c3b2440 | 2012-06-11 00:05:59 -0700 | [diff] [blame] | 3396 | } |
Kuirong Wang | 906ac47 | 2012-07-09 12:54:44 -0700 | [diff] [blame] | 3397 | list_for_each_entry(ch, &taiko_p->dai[dai->id].wcd9xxx_ch_list, |
| 3398 | list) { |
Gopikrishnaiah Anandan | a8aec1f | 2013-01-23 14:26:27 -0500 | [diff] [blame] | 3399 | pr_debug("%s: slot_num %u ch->ch_num %d\n", |
| 3400 | __func__, i, ch->ch_num); |
Kuirong Wang | 906ac47 | 2012-07-09 12:54:44 -0700 | [diff] [blame] | 3401 | rx_slot[i++] = ch->ch_num; |
| 3402 | } |
| 3403 | pr_debug("%s: rx_num %d\n", __func__, i); |
| 3404 | *rx_num = i; |
| 3405 | break; |
| 3406 | case AIF1_CAP: |
| 3407 | case AIF2_CAP: |
| 3408 | case AIF3_CAP: |
| 3409 | if (!tx_slot || !tx_num) { |
| 3410 | pr_err("%s: Invalid tx_slot %d or tx_num %d\n", |
| 3411 | __func__, (u32) tx_slot, (u32) tx_num); |
| 3412 | return -EINVAL; |
| 3413 | } |
| 3414 | list_for_each_entry(ch, &taiko_p->dai[dai->id].wcd9xxx_ch_list, |
| 3415 | list) { |
Gopikrishnaiah Anandan | a8aec1f | 2013-01-23 14:26:27 -0500 | [diff] [blame] | 3416 | pr_debug("%s: slot_num %u ch->ch_num %d\n", |
| 3417 | __func__, i, ch->ch_num); |
Kuirong Wang | 906ac47 | 2012-07-09 12:54:44 -0700 | [diff] [blame] | 3418 | tx_slot[i++] = ch->ch_num; |
| 3419 | } |
| 3420 | pr_debug("%s: tx_num %d\n", __func__, i); |
| 3421 | *tx_num = i; |
| 3422 | break; |
| 3423 | |
| 3424 | default: |
| 3425 | pr_err("%s: Invalid DAI ID %x\n", __func__, dai->id); |
| 3426 | break; |
| 3427 | } |
| 3428 | |
| 3429 | return 0; |
| 3430 | } |
| 3431 | |
| 3432 | static int taiko_set_interpolator_rate(struct snd_soc_dai *dai, |
| 3433 | u8 rx_fs_rate_reg_val, u32 compander_fs, u32 sample_rate) |
| 3434 | { |
| 3435 | u32 j; |
| 3436 | u8 rx_mix1_inp; |
| 3437 | u16 rx_mix_1_reg_1, rx_mix_1_reg_2; |
| 3438 | u16 rx_fs_reg; |
| 3439 | u8 rx_mix_1_reg_1_val, rx_mix_1_reg_2_val; |
| 3440 | struct snd_soc_codec *codec = dai->codec; |
| 3441 | struct wcd9xxx_ch *ch; |
| 3442 | struct taiko_priv *taiko = snd_soc_codec_get_drvdata(codec); |
| 3443 | |
| 3444 | list_for_each_entry(ch, &taiko->dai[dai->id].wcd9xxx_ch_list, list) { |
| 3445 | /* for RX port starting from 16 instead of 10 like tabla */ |
| 3446 | rx_mix1_inp = ch->port + RX_MIX1_INP_SEL_RX1 - |
| 3447 | TAIKO_TX_PORT_NUMBER; |
| 3448 | if ((rx_mix1_inp < RX_MIX1_INP_SEL_RX1) || |
| 3449 | (rx_mix1_inp > RX_MIX1_INP_SEL_RX7)) { |
| 3450 | pr_err("%s: Invalid TAIKO_RX%u port. Dai ID is %d\n", |
| 3451 | __func__, rx_mix1_inp - 5 , dai->id); |
| 3452 | return -EINVAL; |
| 3453 | } |
| 3454 | |
| 3455 | rx_mix_1_reg_1 = TAIKO_A_CDC_CONN_RX1_B1_CTL; |
| 3456 | |
| 3457 | for (j = 0; j < NUM_INTERPOLATORS; j++) { |
| 3458 | rx_mix_1_reg_2 = rx_mix_1_reg_1 + 1; |
| 3459 | |
| 3460 | rx_mix_1_reg_1_val = snd_soc_read(codec, |
| 3461 | rx_mix_1_reg_1); |
| 3462 | rx_mix_1_reg_2_val = snd_soc_read(codec, |
| 3463 | rx_mix_1_reg_2); |
| 3464 | |
| 3465 | if (((rx_mix_1_reg_1_val & 0x0F) == rx_mix1_inp) || |
| 3466 | (((rx_mix_1_reg_1_val >> 4) & 0x0F) |
| 3467 | == rx_mix1_inp) || |
| 3468 | ((rx_mix_1_reg_2_val & 0x0F) == rx_mix1_inp)) { |
| 3469 | |
| 3470 | rx_fs_reg = TAIKO_A_CDC_RX1_B5_CTL + 8 * j; |
| 3471 | |
| 3472 | pr_debug("%s: AIF_PB DAI(%d) connected to RX%u\n", |
| 3473 | __func__, dai->id, j + 1); |
| 3474 | |
| 3475 | pr_debug("%s: set RX%u sample rate to %u\n", |
| 3476 | __func__, j + 1, sample_rate); |
| 3477 | |
| 3478 | snd_soc_update_bits(codec, rx_fs_reg, |
| 3479 | 0xE0, rx_fs_rate_reg_val); |
| 3480 | |
| 3481 | if (comp_rx_path[j] < COMPANDER_MAX) |
| 3482 | taiko->comp_fs[comp_rx_path[j]] |
| 3483 | = compander_fs; |
| 3484 | } |
| 3485 | if (j <= 2) |
| 3486 | rx_mix_1_reg_1 += 3; |
| 3487 | else |
| 3488 | rx_mix_1_reg_1 += 2; |
Kiran Kandi | c3b2440 | 2012-06-11 00:05:59 -0700 | [diff] [blame] | 3489 | } |
| 3490 | } |
| 3491 | return 0; |
| 3492 | } |
| 3493 | |
Kuirong Wang | 906ac47 | 2012-07-09 12:54:44 -0700 | [diff] [blame] | 3494 | static int taiko_set_decimator_rate(struct snd_soc_dai *dai, |
| 3495 | u8 tx_fs_rate_reg_val, u32 sample_rate) |
Kiran Kandi | c3b2440 | 2012-06-11 00:05:59 -0700 | [diff] [blame] | 3496 | { |
Kuirong Wang | 906ac47 | 2012-07-09 12:54:44 -0700 | [diff] [blame] | 3497 | struct snd_soc_codec *codec = dai->codec; |
| 3498 | struct wcd9xxx_ch *ch; |
| 3499 | struct taiko_priv *taiko = snd_soc_codec_get_drvdata(codec); |
| 3500 | u32 tx_port; |
| 3501 | u16 tx_port_reg, tx_fs_reg; |
| 3502 | u8 tx_port_reg_val; |
| 3503 | s8 decimator; |
Kiran Kandi | c3b2440 | 2012-06-11 00:05:59 -0700 | [diff] [blame] | 3504 | |
Kuirong Wang | 906ac47 | 2012-07-09 12:54:44 -0700 | [diff] [blame] | 3505 | list_for_each_entry(ch, &taiko->dai[dai->id].wcd9xxx_ch_list, list) { |
Kiran Kandi | c3b2440 | 2012-06-11 00:05:59 -0700 | [diff] [blame] | 3506 | |
Kuirong Wang | 906ac47 | 2012-07-09 12:54:44 -0700 | [diff] [blame] | 3507 | tx_port = ch->port + 1; |
| 3508 | pr_debug("%s: dai->id = %d, tx_port = %d", |
| 3509 | __func__, dai->id, tx_port); |
| 3510 | |
| 3511 | if ((tx_port < 1) || (tx_port > NUM_DECIMATORS)) { |
| 3512 | pr_err("%s: Invalid SLIM TX%u port. DAI ID is %d\n", |
| 3513 | __func__, tx_port, dai->id); |
| 3514 | return -EINVAL; |
| 3515 | } |
| 3516 | |
| 3517 | tx_port_reg = TAIKO_A_CDC_CONN_TX_SB_B1_CTL + (tx_port - 1); |
| 3518 | tx_port_reg_val = snd_soc_read(codec, tx_port_reg); |
| 3519 | |
| 3520 | decimator = 0; |
| 3521 | |
| 3522 | if ((tx_port >= 1) && (tx_port <= 6)) { |
| 3523 | |
| 3524 | tx_port_reg_val = tx_port_reg_val & 0x0F; |
| 3525 | if (tx_port_reg_val == 0x8) |
| 3526 | decimator = tx_port; |
| 3527 | |
| 3528 | } else if ((tx_port >= 7) && (tx_port <= NUM_DECIMATORS)) { |
| 3529 | |
| 3530 | tx_port_reg_val = tx_port_reg_val & 0x1F; |
| 3531 | |
| 3532 | if ((tx_port_reg_val >= 0x8) && |
| 3533 | (tx_port_reg_val <= 0x11)) { |
| 3534 | |
| 3535 | decimator = (tx_port_reg_val - 0x8) + 1; |
| 3536 | } |
| 3537 | } |
| 3538 | |
| 3539 | if (decimator) { /* SLIM_TX port has a DEC as input */ |
| 3540 | |
| 3541 | tx_fs_reg = TAIKO_A_CDC_TX1_CLK_FS_CTL + |
| 3542 | 8 * (decimator - 1); |
| 3543 | |
| 3544 | pr_debug("%s: set DEC%u (-> SLIM_TX%u) rate to %u\n", |
| 3545 | __func__, decimator, tx_port, sample_rate); |
| 3546 | |
| 3547 | snd_soc_update_bits(codec, tx_fs_reg, 0x07, |
| 3548 | tx_fs_rate_reg_val); |
| 3549 | |
| 3550 | } else { |
| 3551 | if ((tx_port_reg_val >= 0x1) && |
| 3552 | (tx_port_reg_val <= 0x7)) { |
| 3553 | |
| 3554 | pr_debug("%s: RMIX%u going to SLIM TX%u\n", |
| 3555 | __func__, tx_port_reg_val, tx_port); |
| 3556 | |
| 3557 | } else if ((tx_port_reg_val >= 0x8) && |
| 3558 | (tx_port_reg_val <= 0x11)) { |
| 3559 | |
| 3560 | pr_err("%s: ERROR: Should not be here\n", |
| 3561 | __func__); |
| 3562 | pr_err("%s: ERROR: DEC connected to SLIM TX%u\n", |
| 3563 | __func__, tx_port); |
| 3564 | return -EINVAL; |
| 3565 | |
| 3566 | } else if (tx_port_reg_val == 0) { |
| 3567 | pr_debug("%s: no signal to SLIM TX%u\n", |
| 3568 | __func__, tx_port); |
| 3569 | } else { |
| 3570 | pr_err("%s: ERROR: wrong signal to SLIM TX%u\n", |
| 3571 | __func__, tx_port); |
| 3572 | pr_err("%s: ERROR: wrong signal = %u\n", |
| 3573 | __func__, tx_port_reg_val); |
| 3574 | return -EINVAL; |
| 3575 | } |
| 3576 | } |
Kiran Kandi | c3b2440 | 2012-06-11 00:05:59 -0700 | [diff] [blame] | 3577 | } |
Kiran Kandi | c3b2440 | 2012-06-11 00:05:59 -0700 | [diff] [blame] | 3578 | return 0; |
| 3579 | } |
| 3580 | |
| 3581 | static int taiko_hw_params(struct snd_pcm_substream *substream, |
| 3582 | struct snd_pcm_hw_params *params, |
| 3583 | struct snd_soc_dai *dai) |
| 3584 | { |
| 3585 | struct snd_soc_codec *codec = dai->codec; |
| 3586 | struct taiko_priv *taiko = snd_soc_codec_get_drvdata(dai->codec); |
Kuirong Wang | 906ac47 | 2012-07-09 12:54:44 -0700 | [diff] [blame] | 3587 | u8 tx_fs_rate, rx_fs_rate; |
Kiran Kandi | c3b2440 | 2012-06-11 00:05:59 -0700 | [diff] [blame] | 3588 | u32 compander_fs; |
Kuirong Wang | 906ac47 | 2012-07-09 12:54:44 -0700 | [diff] [blame] | 3589 | int ret; |
Kiran Kandi | c3b2440 | 2012-06-11 00:05:59 -0700 | [diff] [blame] | 3590 | |
| 3591 | pr_debug("%s: dai_name = %s DAI-ID %x rate %d num_ch %d\n", __func__, |
| 3592 | dai->name, dai->id, params_rate(params), |
| 3593 | params_channels(params)); |
| 3594 | |
| 3595 | switch (params_rate(params)) { |
| 3596 | case 8000: |
| 3597 | tx_fs_rate = 0x00; |
| 3598 | rx_fs_rate = 0x00; |
| 3599 | compander_fs = COMPANDER_FS_8KHZ; |
| 3600 | break; |
| 3601 | case 16000: |
| 3602 | tx_fs_rate = 0x01; |
| 3603 | rx_fs_rate = 0x20; |
| 3604 | compander_fs = COMPANDER_FS_16KHZ; |
| 3605 | break; |
| 3606 | case 32000: |
| 3607 | tx_fs_rate = 0x02; |
| 3608 | rx_fs_rate = 0x40; |
| 3609 | compander_fs = COMPANDER_FS_32KHZ; |
| 3610 | break; |
| 3611 | case 48000: |
| 3612 | tx_fs_rate = 0x03; |
| 3613 | rx_fs_rate = 0x60; |
| 3614 | compander_fs = COMPANDER_FS_48KHZ; |
| 3615 | break; |
| 3616 | case 96000: |
| 3617 | tx_fs_rate = 0x04; |
| 3618 | rx_fs_rate = 0x80; |
| 3619 | compander_fs = COMPANDER_FS_96KHZ; |
| 3620 | break; |
| 3621 | case 192000: |
| 3622 | tx_fs_rate = 0x05; |
| 3623 | rx_fs_rate = 0xA0; |
| 3624 | compander_fs = COMPANDER_FS_192KHZ; |
| 3625 | break; |
| 3626 | default: |
| 3627 | pr_err("%s: Invalid sampling rate %d\n", __func__, |
Kuirong Wang | 906ac47 | 2012-07-09 12:54:44 -0700 | [diff] [blame] | 3628 | params_rate(params)); |
Kiran Kandi | c3b2440 | 2012-06-11 00:05:59 -0700 | [diff] [blame] | 3629 | return -EINVAL; |
| 3630 | } |
| 3631 | |
Kuirong Wang | 906ac47 | 2012-07-09 12:54:44 -0700 | [diff] [blame] | 3632 | switch (substream->stream) { |
| 3633 | case SNDRV_PCM_STREAM_CAPTURE: |
| 3634 | ret = taiko_set_decimator_rate(dai, tx_fs_rate, |
| 3635 | params_rate(params)); |
| 3636 | if (ret < 0) { |
| 3637 | pr_err("%s: set decimator rate failed %d\n", __func__, |
| 3638 | ret); |
| 3639 | return ret; |
Kiran Kandi | c3b2440 | 2012-06-11 00:05:59 -0700 | [diff] [blame] | 3640 | } |
Kuirong Wang | 906ac47 | 2012-07-09 12:54:44 -0700 | [diff] [blame] | 3641 | |
Kiran Kandi | c3b2440 | 2012-06-11 00:05:59 -0700 | [diff] [blame] | 3642 | if (taiko->intf_type == WCD9XXX_INTERFACE_TYPE_I2C) { |
| 3643 | switch (params_format(params)) { |
| 3644 | case SNDRV_PCM_FORMAT_S16_LE: |
| 3645 | snd_soc_update_bits(codec, |
| 3646 | TAIKO_A_CDC_CLK_TX_I2S_CTL, |
| 3647 | 0x20, 0x20); |
| 3648 | break; |
| 3649 | case SNDRV_PCM_FORMAT_S32_LE: |
| 3650 | snd_soc_update_bits(codec, |
| 3651 | TAIKO_A_CDC_CLK_TX_I2S_CTL, |
| 3652 | 0x20, 0x00); |
| 3653 | break; |
| 3654 | default: |
| 3655 | pr_err("invalid format\n"); |
| 3656 | break; |
| 3657 | } |
| 3658 | snd_soc_update_bits(codec, TAIKO_A_CDC_CLK_TX_I2S_CTL, |
Kuirong Wang | 906ac47 | 2012-07-09 12:54:44 -0700 | [diff] [blame] | 3659 | 0x07, tx_fs_rate); |
Kiran Kandi | c3b2440 | 2012-06-11 00:05:59 -0700 | [diff] [blame] | 3660 | } else { |
Kuirong Wang | 906ac47 | 2012-07-09 12:54:44 -0700 | [diff] [blame] | 3661 | taiko->dai[dai->id].rate = params_rate(params); |
Kiran Kandi | c3b2440 | 2012-06-11 00:05:59 -0700 | [diff] [blame] | 3662 | } |
Kuirong Wang | 906ac47 | 2012-07-09 12:54:44 -0700 | [diff] [blame] | 3663 | break; |
Kiran Kandi | c3b2440 | 2012-06-11 00:05:59 -0700 | [diff] [blame] | 3664 | |
Kuirong Wang | 906ac47 | 2012-07-09 12:54:44 -0700 | [diff] [blame] | 3665 | case SNDRV_PCM_STREAM_PLAYBACK: |
| 3666 | ret = taiko_set_interpolator_rate(dai, rx_fs_rate, |
| 3667 | compander_fs, |
| 3668 | params_rate(params)); |
| 3669 | if (ret < 0) { |
| 3670 | pr_err("%s: set decimator rate failed %d\n", __func__, |
| 3671 | ret); |
| 3672 | return ret; |
Kiran Kandi | c3b2440 | 2012-06-11 00:05:59 -0700 | [diff] [blame] | 3673 | } |
| 3674 | if (taiko->intf_type == WCD9XXX_INTERFACE_TYPE_I2C) { |
| 3675 | switch (params_format(params)) { |
| 3676 | case SNDRV_PCM_FORMAT_S16_LE: |
| 3677 | snd_soc_update_bits(codec, |
| 3678 | TAIKO_A_CDC_CLK_RX_I2S_CTL, |
| 3679 | 0x20, 0x20); |
| 3680 | break; |
| 3681 | case SNDRV_PCM_FORMAT_S32_LE: |
| 3682 | snd_soc_update_bits(codec, |
| 3683 | TAIKO_A_CDC_CLK_RX_I2S_CTL, |
| 3684 | 0x20, 0x00); |
| 3685 | break; |
| 3686 | default: |
| 3687 | pr_err("invalid format\n"); |
| 3688 | break; |
| 3689 | } |
| 3690 | snd_soc_update_bits(codec, TAIKO_A_CDC_CLK_RX_I2S_CTL, |
Kuirong Wang | 906ac47 | 2012-07-09 12:54:44 -0700 | [diff] [blame] | 3691 | 0x03, (rx_fs_rate >> 0x05)); |
Kiran Kandi | c3b2440 | 2012-06-11 00:05:59 -0700 | [diff] [blame] | 3692 | } else { |
Kuirong Wang | 906ac47 | 2012-07-09 12:54:44 -0700 | [diff] [blame] | 3693 | taiko->dai[dai->id].rate = params_rate(params); |
Kiran Kandi | c3b2440 | 2012-06-11 00:05:59 -0700 | [diff] [blame] | 3694 | } |
Kuirong Wang | 906ac47 | 2012-07-09 12:54:44 -0700 | [diff] [blame] | 3695 | break; |
| 3696 | default: |
| 3697 | pr_err("%s: Invalid stream type %d\n", __func__, |
| 3698 | substream->stream); |
| 3699 | return -EINVAL; |
Kiran Kandi | c3b2440 | 2012-06-11 00:05:59 -0700 | [diff] [blame] | 3700 | } |
| 3701 | |
| 3702 | return 0; |
| 3703 | } |
| 3704 | |
| 3705 | static struct snd_soc_dai_ops taiko_dai_ops = { |
| 3706 | .startup = taiko_startup, |
| 3707 | .shutdown = taiko_shutdown, |
| 3708 | .hw_params = taiko_hw_params, |
| 3709 | .set_sysclk = taiko_set_dai_sysclk, |
| 3710 | .set_fmt = taiko_set_dai_fmt, |
| 3711 | .set_channel_map = taiko_set_channel_map, |
| 3712 | .get_channel_map = taiko_get_channel_map, |
| 3713 | }; |
| 3714 | |
| 3715 | static struct snd_soc_dai_driver taiko_dai[] = { |
| 3716 | { |
| 3717 | .name = "taiko_rx1", |
| 3718 | .id = AIF1_PB, |
| 3719 | .playback = { |
| 3720 | .stream_name = "AIF1 Playback", |
| 3721 | .rates = WCD9320_RATES, |
| 3722 | .formats = TAIKO_FORMATS, |
| 3723 | .rate_max = 192000, |
| 3724 | .rate_min = 8000, |
| 3725 | .channels_min = 1, |
| 3726 | .channels_max = 2, |
| 3727 | }, |
| 3728 | .ops = &taiko_dai_ops, |
| 3729 | }, |
| 3730 | { |
| 3731 | .name = "taiko_tx1", |
| 3732 | .id = AIF1_CAP, |
| 3733 | .capture = { |
| 3734 | .stream_name = "AIF1 Capture", |
| 3735 | .rates = WCD9320_RATES, |
| 3736 | .formats = TAIKO_FORMATS, |
| 3737 | .rate_max = 192000, |
| 3738 | .rate_min = 8000, |
| 3739 | .channels_min = 1, |
| 3740 | .channels_max = 4, |
| 3741 | }, |
| 3742 | .ops = &taiko_dai_ops, |
| 3743 | }, |
| 3744 | { |
| 3745 | .name = "taiko_rx2", |
| 3746 | .id = AIF2_PB, |
| 3747 | .playback = { |
| 3748 | .stream_name = "AIF2 Playback", |
| 3749 | .rates = WCD9320_RATES, |
| 3750 | .formats = TAIKO_FORMATS, |
| 3751 | .rate_min = 8000, |
| 3752 | .rate_max = 192000, |
| 3753 | .channels_min = 1, |
| 3754 | .channels_max = 2, |
| 3755 | }, |
| 3756 | .ops = &taiko_dai_ops, |
| 3757 | }, |
| 3758 | { |
| 3759 | .name = "taiko_tx2", |
| 3760 | .id = AIF2_CAP, |
| 3761 | .capture = { |
| 3762 | .stream_name = "AIF2 Capture", |
| 3763 | .rates = WCD9320_RATES, |
| 3764 | .formats = TAIKO_FORMATS, |
| 3765 | .rate_max = 192000, |
| 3766 | .rate_min = 8000, |
| 3767 | .channels_min = 1, |
| 3768 | .channels_max = 4, |
| 3769 | }, |
| 3770 | .ops = &taiko_dai_ops, |
| 3771 | }, |
| 3772 | { |
| 3773 | .name = "taiko_tx3", |
| 3774 | .id = AIF3_CAP, |
| 3775 | .capture = { |
| 3776 | .stream_name = "AIF3 Capture", |
| 3777 | .rates = WCD9320_RATES, |
| 3778 | .formats = TAIKO_FORMATS, |
| 3779 | .rate_max = 48000, |
| 3780 | .rate_min = 8000, |
| 3781 | .channels_min = 1, |
| 3782 | .channels_max = 2, |
| 3783 | }, |
| 3784 | .ops = &taiko_dai_ops, |
| 3785 | }, |
| 3786 | { |
| 3787 | .name = "taiko_rx3", |
| 3788 | .id = AIF3_PB, |
| 3789 | .playback = { |
| 3790 | .stream_name = "AIF3 Playback", |
| 3791 | .rates = WCD9320_RATES, |
| 3792 | .formats = TAIKO_FORMATS, |
| 3793 | .rate_min = 8000, |
| 3794 | .rate_max = 192000, |
| 3795 | .channels_min = 1, |
| 3796 | .channels_max = 2, |
| 3797 | }, |
| 3798 | .ops = &taiko_dai_ops, |
| 3799 | }, |
| 3800 | }; |
| 3801 | |
| 3802 | static struct snd_soc_dai_driver taiko_i2s_dai[] = { |
| 3803 | { |
| 3804 | .name = "taiko_i2s_rx1", |
Kuirong Wang | 906ac47 | 2012-07-09 12:54:44 -0700 | [diff] [blame] | 3805 | .id = AIF1_PB, |
Kiran Kandi | c3b2440 | 2012-06-11 00:05:59 -0700 | [diff] [blame] | 3806 | .playback = { |
| 3807 | .stream_name = "AIF1 Playback", |
| 3808 | .rates = WCD9320_RATES, |
| 3809 | .formats = TAIKO_FORMATS, |
| 3810 | .rate_max = 192000, |
| 3811 | .rate_min = 8000, |
| 3812 | .channels_min = 1, |
| 3813 | .channels_max = 4, |
| 3814 | }, |
| 3815 | .ops = &taiko_dai_ops, |
| 3816 | }, |
| 3817 | { |
| 3818 | .name = "taiko_i2s_tx1", |
Kuirong Wang | 906ac47 | 2012-07-09 12:54:44 -0700 | [diff] [blame] | 3819 | .id = AIF1_CAP, |
Kiran Kandi | c3b2440 | 2012-06-11 00:05:59 -0700 | [diff] [blame] | 3820 | .capture = { |
| 3821 | .stream_name = "AIF1 Capture", |
| 3822 | .rates = WCD9320_RATES, |
| 3823 | .formats = TAIKO_FORMATS, |
| 3824 | .rate_max = 192000, |
| 3825 | .rate_min = 8000, |
| 3826 | .channels_min = 1, |
| 3827 | .channels_max = 4, |
| 3828 | }, |
| 3829 | .ops = &taiko_dai_ops, |
| 3830 | }, |
Venkat Sudhir | 994193b | 2012-12-17 17:30:51 -0800 | [diff] [blame] | 3831 | { |
| 3832 | .name = "taiko_i2s_rx2", |
| 3833 | .id = AIF1_PB, |
| 3834 | .playback = { |
| 3835 | .stream_name = "AIF2 Playback", |
| 3836 | .rates = WCD9320_RATES, |
| 3837 | .formats = TAIKO_FORMATS, |
| 3838 | .rate_max = 192000, |
| 3839 | .rate_min = 8000, |
| 3840 | .channels_min = 1, |
| 3841 | .channels_max = 4, |
| 3842 | }, |
| 3843 | .ops = &taiko_dai_ops, |
| 3844 | }, |
| 3845 | { |
| 3846 | .name = "taiko_i2s_tx2", |
| 3847 | .id = AIF1_CAP, |
| 3848 | .capture = { |
| 3849 | .stream_name = "AIF2 Capture", |
| 3850 | .rates = WCD9320_RATES, |
| 3851 | .formats = TAIKO_FORMATS, |
| 3852 | .rate_max = 192000, |
| 3853 | .rate_min = 8000, |
| 3854 | .channels_min = 1, |
| 3855 | .channels_max = 4, |
| 3856 | }, |
| 3857 | .ops = &taiko_dai_ops, |
| 3858 | }, |
Kiran Kandi | c3b2440 | 2012-06-11 00:05:59 -0700 | [diff] [blame] | 3859 | }; |
| 3860 | |
Joonwoo Park | 9bbb4d1 | 2012-11-09 19:58:11 -0800 | [diff] [blame] | 3861 | static int taiko_codec_enable_slim_chmask(struct wcd9xxx_codec_dai_data *dai, |
| 3862 | bool up) |
| 3863 | { |
| 3864 | int ret = 0; |
| 3865 | struct wcd9xxx_ch *ch; |
| 3866 | |
| 3867 | if (up) { |
| 3868 | list_for_each_entry(ch, &dai->wcd9xxx_ch_list, list) { |
| 3869 | ret = wcd9xxx_get_slave_port(ch->ch_num); |
| 3870 | if (ret < 0) { |
| 3871 | pr_err("%s: Invalid slave port ID: %d\n", |
| 3872 | __func__, ret); |
| 3873 | ret = -EINVAL; |
| 3874 | } else { |
| 3875 | set_bit(ret, &dai->ch_mask); |
| 3876 | } |
| 3877 | } |
| 3878 | } else { |
| 3879 | ret = wait_event_timeout(dai->dai_wait, (dai->ch_mask == 0), |
| 3880 | msecs_to_jiffies( |
| 3881 | TAIKO_SLIM_CLOSE_TIMEOUT)); |
| 3882 | if (!ret) { |
| 3883 | pr_err("%s: Slim close tx/rx wait timeout\n", __func__); |
| 3884 | ret = -ETIMEDOUT; |
| 3885 | } else { |
| 3886 | ret = 0; |
| 3887 | } |
| 3888 | } |
| 3889 | return ret; |
| 3890 | } |
| 3891 | |
Kiran Kandi | c3b2440 | 2012-06-11 00:05:59 -0700 | [diff] [blame] | 3892 | static int taiko_codec_enable_slimrx(struct snd_soc_dapm_widget *w, |
Kuirong Wang | 906ac47 | 2012-07-09 12:54:44 -0700 | [diff] [blame] | 3893 | struct snd_kcontrol *kcontrol, |
| 3894 | int event) |
Kiran Kandi | c3b2440 | 2012-06-11 00:05:59 -0700 | [diff] [blame] | 3895 | { |
Kuirong Wang | 906ac47 | 2012-07-09 12:54:44 -0700 | [diff] [blame] | 3896 | struct wcd9xxx *core; |
Kiran Kandi | c3b2440 | 2012-06-11 00:05:59 -0700 | [diff] [blame] | 3897 | struct snd_soc_codec *codec = w->codec; |
| 3898 | struct taiko_priv *taiko_p = snd_soc_codec_get_drvdata(codec); |
Joonwoo Park | 9bbb4d1 | 2012-11-09 19:58:11 -0800 | [diff] [blame] | 3899 | int ret = 0; |
Kuirong Wang | 906ac47 | 2012-07-09 12:54:44 -0700 | [diff] [blame] | 3900 | struct wcd9xxx_codec_dai_data *dai; |
| 3901 | |
| 3902 | core = dev_get_drvdata(codec->dev->parent); |
| 3903 | |
| 3904 | pr_debug("%s: event called! codec name %s num_dai %d\n" |
| 3905 | "stream name %s event %d\n", |
| 3906 | __func__, w->codec->name, w->codec->num_dai, w->sname, event); |
| 3907 | |
Kiran Kandi | c3b2440 | 2012-06-11 00:05:59 -0700 | [diff] [blame] | 3908 | /* Execute the callback only if interface type is slimbus */ |
| 3909 | if (taiko_p->intf_type != WCD9XXX_INTERFACE_TYPE_SLIMBUS) |
| 3910 | return 0; |
| 3911 | |
Kuirong Wang | 906ac47 | 2012-07-09 12:54:44 -0700 | [diff] [blame] | 3912 | dai = &taiko_p->dai[w->shift]; |
| 3913 | pr_debug("%s: w->name %s w->shift %d event %d\n", |
| 3914 | __func__, w->name, w->shift, event); |
Kiran Kandi | c3b2440 | 2012-06-11 00:05:59 -0700 | [diff] [blame] | 3915 | |
| 3916 | switch (event) { |
| 3917 | case SND_SOC_DAPM_POST_PMU: |
Joonwoo Park | 9bbb4d1 | 2012-11-09 19:58:11 -0800 | [diff] [blame] | 3918 | (void) taiko_codec_enable_slim_chmask(dai, true); |
Kuirong Wang | 906ac47 | 2012-07-09 12:54:44 -0700 | [diff] [blame] | 3919 | ret = wcd9xxx_cfg_slim_sch_rx(core, &dai->wcd9xxx_ch_list, |
| 3920 | dai->rate, dai->bit_width, |
| 3921 | &dai->grph); |
Kiran Kandi | c3b2440 | 2012-06-11 00:05:59 -0700 | [diff] [blame] | 3922 | break; |
| 3923 | case SND_SOC_DAPM_POST_PMD: |
Kuirong Wang | 906ac47 | 2012-07-09 12:54:44 -0700 | [diff] [blame] | 3924 | ret = wcd9xxx_close_slim_sch_rx(core, &dai->wcd9xxx_ch_list, |
| 3925 | dai->grph); |
Joonwoo Park | 9bbb4d1 | 2012-11-09 19:58:11 -0800 | [diff] [blame] | 3926 | ret = taiko_codec_enable_slim_chmask(dai, false); |
| 3927 | if (ret < 0) { |
| 3928 | ret = wcd9xxx_disconnect_port(core, |
| 3929 | &dai->wcd9xxx_ch_list, |
| 3930 | dai->grph); |
| 3931 | pr_debug("%s: Disconnect RX port, ret = %d\n", |
| 3932 | __func__, ret); |
| 3933 | } |
Kuirong Wang | 906ac47 | 2012-07-09 12:54:44 -0700 | [diff] [blame] | 3934 | break; |
Kiran Kandi | c3b2440 | 2012-06-11 00:05:59 -0700 | [diff] [blame] | 3935 | } |
| 3936 | return ret; |
| 3937 | } |
| 3938 | |
| 3939 | static int taiko_codec_enable_slimtx(struct snd_soc_dapm_widget *w, |
Kuirong Wang | 906ac47 | 2012-07-09 12:54:44 -0700 | [diff] [blame] | 3940 | struct snd_kcontrol *kcontrol, |
| 3941 | int event) |
Kiran Kandi | c3b2440 | 2012-06-11 00:05:59 -0700 | [diff] [blame] | 3942 | { |
Kuirong Wang | 906ac47 | 2012-07-09 12:54:44 -0700 | [diff] [blame] | 3943 | struct wcd9xxx *core; |
Kiran Kandi | c3b2440 | 2012-06-11 00:05:59 -0700 | [diff] [blame] | 3944 | struct snd_soc_codec *codec = w->codec; |
| 3945 | struct taiko_priv *taiko_p = snd_soc_codec_get_drvdata(codec); |
Kiran Kandi | c3b2440 | 2012-06-11 00:05:59 -0700 | [diff] [blame] | 3946 | u32 ret = 0; |
Kuirong Wang | 906ac47 | 2012-07-09 12:54:44 -0700 | [diff] [blame] | 3947 | struct wcd9xxx_codec_dai_data *dai; |
Kiran Kandi | c3b2440 | 2012-06-11 00:05:59 -0700 | [diff] [blame] | 3948 | |
Kuirong Wang | 906ac47 | 2012-07-09 12:54:44 -0700 | [diff] [blame] | 3949 | core = dev_get_drvdata(codec->dev->parent); |
| 3950 | |
| 3951 | pr_debug("%s: event called! codec name %s num_dai %d stream name %s\n", |
| 3952 | __func__, w->codec->name, w->codec->num_dai, w->sname); |
Kiran Kandi | c3b2440 | 2012-06-11 00:05:59 -0700 | [diff] [blame] | 3953 | |
| 3954 | /* Execute the callback only if interface type is slimbus */ |
| 3955 | if (taiko_p->intf_type != WCD9XXX_INTERFACE_TYPE_SLIMBUS) |
| 3956 | return 0; |
| 3957 | |
Kuirong Wang | 906ac47 | 2012-07-09 12:54:44 -0700 | [diff] [blame] | 3958 | pr_debug("%s(): w->name %s event %d w->shift %d\n", |
| 3959 | __func__, w->name, event, w->shift); |
Kiran Kandi | c3b2440 | 2012-06-11 00:05:59 -0700 | [diff] [blame] | 3960 | |
Kuirong Wang | 906ac47 | 2012-07-09 12:54:44 -0700 | [diff] [blame] | 3961 | dai = &taiko_p->dai[w->shift]; |
Kiran Kandi | c3b2440 | 2012-06-11 00:05:59 -0700 | [diff] [blame] | 3962 | switch (event) { |
| 3963 | case SND_SOC_DAPM_POST_PMU: |
Joonwoo Park | 9bbb4d1 | 2012-11-09 19:58:11 -0800 | [diff] [blame] | 3964 | (void) taiko_codec_enable_slim_chmask(dai, true); |
Kuirong Wang | 906ac47 | 2012-07-09 12:54:44 -0700 | [diff] [blame] | 3965 | ret = wcd9xxx_cfg_slim_sch_tx(core, &dai->wcd9xxx_ch_list, |
| 3966 | dai->rate, dai->bit_width, |
| 3967 | &dai->grph); |
Kiran Kandi | c3b2440 | 2012-06-11 00:05:59 -0700 | [diff] [blame] | 3968 | break; |
| 3969 | case SND_SOC_DAPM_POST_PMD: |
Kuirong Wang | 906ac47 | 2012-07-09 12:54:44 -0700 | [diff] [blame] | 3970 | ret = wcd9xxx_close_slim_sch_tx(core, &dai->wcd9xxx_ch_list, |
| 3971 | dai->grph); |
Joonwoo Park | 9bbb4d1 | 2012-11-09 19:58:11 -0800 | [diff] [blame] | 3972 | ret = taiko_codec_enable_slim_chmask(dai, false); |
| 3973 | if (ret < 0) { |
| 3974 | ret = wcd9xxx_disconnect_port(core, |
| 3975 | &dai->wcd9xxx_ch_list, |
| 3976 | dai->grph); |
| 3977 | pr_debug("%s: Disconnect RX port, ret = %d\n", |
| 3978 | __func__, ret); |
| 3979 | } |
Kuirong Wang | 906ac47 | 2012-07-09 12:54:44 -0700 | [diff] [blame] | 3980 | break; |
Kiran Kandi | c3b2440 | 2012-06-11 00:05:59 -0700 | [diff] [blame] | 3981 | } |
| 3982 | return ret; |
| 3983 | } |
| 3984 | |
Kiran Kandi | 4c56c59 | 2012-07-25 11:04:55 -0700 | [diff] [blame] | 3985 | static int taiko_codec_enable_ear_pa(struct snd_soc_dapm_widget *w, |
| 3986 | struct snd_kcontrol *kcontrol, int event) |
| 3987 | { |
| 3988 | struct snd_soc_codec *codec = w->codec; |
| 3989 | |
| 3990 | pr_debug("%s %s %d\n", __func__, w->name, event); |
| 3991 | |
| 3992 | switch (event) { |
| 3993 | break; |
| 3994 | case SND_SOC_DAPM_POST_PMU: |
| 3995 | |
| 3996 | snd_soc_update_bits(codec, TAIKO_A_BUCK_MODE_5, 0x02, 0x00); |
| 3997 | snd_soc_update_bits(codec, TAIKO_A_NCP_STATIC, 0x20, 0x00); |
| 3998 | snd_soc_update_bits(codec, TAIKO_A_BUCK_MODE_3, 0x04, 0x04); |
| 3999 | snd_soc_update_bits(codec, TAIKO_A_BUCK_MODE_3, 0x08, 0x00); |
| 4000 | |
| 4001 | usleep_range(5000, 5000); |
| 4002 | break; |
| 4003 | } |
| 4004 | return 0; |
| 4005 | } |
| 4006 | |
Kiran Kandi | c3b2440 | 2012-06-11 00:05:59 -0700 | [diff] [blame] | 4007 | /* Todo: Have seperate dapm widgets for I2S and Slimbus. |
| 4008 | * Might Need to have callbacks registered only for slimbus |
| 4009 | */ |
| 4010 | static const struct snd_soc_dapm_widget taiko_dapm_widgets[] = { |
| 4011 | /*RX stuff */ |
| 4012 | SND_SOC_DAPM_OUTPUT("EAR"), |
| 4013 | |
Kiran Kandi | 4c56c59 | 2012-07-25 11:04:55 -0700 | [diff] [blame] | 4014 | SND_SOC_DAPM_PGA_E("EAR PA", TAIKO_A_RX_EAR_EN, 4, 0, NULL, 0, |
| 4015 | taiko_codec_enable_ear_pa, SND_SOC_DAPM_POST_PMU), |
Kiran Kandi | c3b2440 | 2012-06-11 00:05:59 -0700 | [diff] [blame] | 4016 | |
| 4017 | SND_SOC_DAPM_MIXER("DAC1", TAIKO_A_RX_EAR_EN, 6, 0, dac1_switch, |
| 4018 | ARRAY_SIZE(dac1_switch)), |
| 4019 | |
Kuirong Wang | 906ac47 | 2012-07-09 12:54:44 -0700 | [diff] [blame] | 4020 | SND_SOC_DAPM_AIF_IN_E("AIF1 PB", "AIF1 Playback", 0, SND_SOC_NOPM, |
| 4021 | AIF1_PB, 0, taiko_codec_enable_slimrx, |
Kiran Kandi | c3b2440 | 2012-06-11 00:05:59 -0700 | [diff] [blame] | 4022 | SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD), |
Kuirong Wang | 906ac47 | 2012-07-09 12:54:44 -0700 | [diff] [blame] | 4023 | SND_SOC_DAPM_AIF_IN_E("AIF2 PB", "AIF2 Playback", 0, SND_SOC_NOPM, |
| 4024 | AIF2_PB, 0, taiko_codec_enable_slimrx, |
Kiran Kandi | c3b2440 | 2012-06-11 00:05:59 -0700 | [diff] [blame] | 4025 | SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD), |
Kuirong Wang | 906ac47 | 2012-07-09 12:54:44 -0700 | [diff] [blame] | 4026 | SND_SOC_DAPM_AIF_IN_E("AIF3 PB", "AIF3 Playback", 0, SND_SOC_NOPM, |
| 4027 | AIF3_PB, 0, taiko_codec_enable_slimrx, |
Kiran Kandi | c3b2440 | 2012-06-11 00:05:59 -0700 | [diff] [blame] | 4028 | SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD), |
| 4029 | |
Kuirong Wang | 906ac47 | 2012-07-09 12:54:44 -0700 | [diff] [blame] | 4030 | SND_SOC_DAPM_MUX("SLIM RX1 MUX", SND_SOC_NOPM, TAIKO_RX1, 0, |
| 4031 | &slim_rx_mux[TAIKO_RX1]), |
| 4032 | SND_SOC_DAPM_MUX("SLIM RX2 MUX", SND_SOC_NOPM, TAIKO_RX2, 0, |
| 4033 | &slim_rx_mux[TAIKO_RX2]), |
| 4034 | SND_SOC_DAPM_MUX("SLIM RX3 MUX", SND_SOC_NOPM, TAIKO_RX3, 0, |
| 4035 | &slim_rx_mux[TAIKO_RX3]), |
| 4036 | SND_SOC_DAPM_MUX("SLIM RX4 MUX", SND_SOC_NOPM, TAIKO_RX4, 0, |
| 4037 | &slim_rx_mux[TAIKO_RX4]), |
| 4038 | SND_SOC_DAPM_MUX("SLIM RX5 MUX", SND_SOC_NOPM, TAIKO_RX5, 0, |
| 4039 | &slim_rx_mux[TAIKO_RX5]), |
| 4040 | SND_SOC_DAPM_MUX("SLIM RX6 MUX", SND_SOC_NOPM, TAIKO_RX6, 0, |
| 4041 | &slim_rx_mux[TAIKO_RX6]), |
| 4042 | SND_SOC_DAPM_MUX("SLIM RX7 MUX", SND_SOC_NOPM, TAIKO_RX7, 0, |
| 4043 | &slim_rx_mux[TAIKO_RX7]), |
Kiran Kandi | c3b2440 | 2012-06-11 00:05:59 -0700 | [diff] [blame] | 4044 | |
Kuirong Wang | 906ac47 | 2012-07-09 12:54:44 -0700 | [diff] [blame] | 4045 | SND_SOC_DAPM_MIXER("SLIM RX1", SND_SOC_NOPM, 0, 0, NULL, 0), |
| 4046 | SND_SOC_DAPM_MIXER("SLIM RX2", SND_SOC_NOPM, 0, 0, NULL, 0), |
| 4047 | SND_SOC_DAPM_MIXER("SLIM RX3", SND_SOC_NOPM, 0, 0, NULL, 0), |
| 4048 | SND_SOC_DAPM_MIXER("SLIM RX4", SND_SOC_NOPM, 0, 0, NULL, 0), |
| 4049 | SND_SOC_DAPM_MIXER("SLIM RX5", SND_SOC_NOPM, 0, 0, NULL, 0), |
| 4050 | SND_SOC_DAPM_MIXER("SLIM RX6", SND_SOC_NOPM, 0, 0, NULL, 0), |
| 4051 | SND_SOC_DAPM_MIXER("SLIM RX7", SND_SOC_NOPM, 0, 0, NULL, 0), |
Kiran Kandi | c3b2440 | 2012-06-11 00:05:59 -0700 | [diff] [blame] | 4052 | |
| 4053 | /* Headphone */ |
| 4054 | SND_SOC_DAPM_OUTPUT("HEADPHONE"), |
| 4055 | SND_SOC_DAPM_PGA_E("HPHL", TAIKO_A_RX_HPH_CNP_EN, 5, 0, NULL, 0, |
| 4056 | taiko_hph_pa_event, SND_SOC_DAPM_PRE_PMU | |
Kiran Kandi | 4c56c59 | 2012-07-25 11:04:55 -0700 | [diff] [blame] | 4057 | SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD), |
Kiran Kandi | c3b2440 | 2012-06-11 00:05:59 -0700 | [diff] [blame] | 4058 | SND_SOC_DAPM_MIXER("HPHL DAC", TAIKO_A_RX_HPH_L_DAC_CTL, 7, 0, |
| 4059 | hphl_switch, ARRAY_SIZE(hphl_switch)), |
| 4060 | |
| 4061 | SND_SOC_DAPM_PGA_E("HPHR", TAIKO_A_RX_HPH_CNP_EN, 4, 0, NULL, 0, |
| 4062 | taiko_hph_pa_event, SND_SOC_DAPM_PRE_PMU | |
Kiran Kandi | 4c56c59 | 2012-07-25 11:04:55 -0700 | [diff] [blame] | 4063 | SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD), |
Kiran Kandi | c3b2440 | 2012-06-11 00:05:59 -0700 | [diff] [blame] | 4064 | |
| 4065 | SND_SOC_DAPM_DAC_E("HPHR DAC", NULL, TAIKO_A_RX_HPH_R_DAC_CTL, 7, 0, |
| 4066 | taiko_hphr_dac_event, |
| 4067 | SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD), |
| 4068 | |
| 4069 | /* Speaker */ |
| 4070 | SND_SOC_DAPM_OUTPUT("LINEOUT1"), |
| 4071 | SND_SOC_DAPM_OUTPUT("LINEOUT2"), |
| 4072 | SND_SOC_DAPM_OUTPUT("LINEOUT3"), |
| 4073 | SND_SOC_DAPM_OUTPUT("LINEOUT4"), |
Joonwoo Park | 7680b9f | 2012-07-13 11:36:48 -0700 | [diff] [blame] | 4074 | SND_SOC_DAPM_OUTPUT("SPK_OUT"), |
Kiran Kandi | c3b2440 | 2012-06-11 00:05:59 -0700 | [diff] [blame] | 4075 | |
| 4076 | SND_SOC_DAPM_PGA_E("LINEOUT1 PA", TAIKO_A_RX_LINE_CNP_EN, 0, 0, NULL, |
| 4077 | 0, taiko_codec_enable_lineout, SND_SOC_DAPM_PRE_PMU | |
| 4078 | SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD), |
| 4079 | SND_SOC_DAPM_PGA_E("LINEOUT2 PA", TAIKO_A_RX_LINE_CNP_EN, 1, 0, NULL, |
| 4080 | 0, taiko_codec_enable_lineout, SND_SOC_DAPM_PRE_PMU | |
| 4081 | SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD), |
| 4082 | SND_SOC_DAPM_PGA_E("LINEOUT3 PA", TAIKO_A_RX_LINE_CNP_EN, 2, 0, NULL, |
| 4083 | 0, taiko_codec_enable_lineout, SND_SOC_DAPM_PRE_PMU | |
| 4084 | SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD), |
| 4085 | SND_SOC_DAPM_PGA_E("LINEOUT4 PA", TAIKO_A_RX_LINE_CNP_EN, 3, 0, NULL, |
| 4086 | 0, taiko_codec_enable_lineout, SND_SOC_DAPM_PRE_PMU | |
| 4087 | SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD), |
Joonwoo Park | 125cd4e | 2012-12-11 15:16:11 -0800 | [diff] [blame] | 4088 | SND_SOC_DAPM_PGA_E("SPK PA", SND_SOC_NOPM, 0, 0 , NULL, |
| 4089 | 0, taiko_codec_enable_spk_pa, |
| 4090 | SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD), |
Kiran Kandi | c3b2440 | 2012-06-11 00:05:59 -0700 | [diff] [blame] | 4091 | |
| 4092 | SND_SOC_DAPM_DAC_E("LINEOUT1 DAC", NULL, TAIKO_A_RX_LINE_1_DAC_CTL, 7, 0 |
| 4093 | , taiko_lineout_dac_event, |
| 4094 | SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD), |
| 4095 | SND_SOC_DAPM_DAC_E("LINEOUT2 DAC", NULL, TAIKO_A_RX_LINE_2_DAC_CTL, 7, 0 |
| 4096 | , taiko_lineout_dac_event, |
| 4097 | SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD), |
| 4098 | SND_SOC_DAPM_DAC_E("LINEOUT3 DAC", NULL, TAIKO_A_RX_LINE_3_DAC_CTL, 7, 0 |
| 4099 | , taiko_lineout_dac_event, |
| 4100 | SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD), |
| 4101 | SND_SOC_DAPM_SWITCH("LINEOUT3 DAC GROUND", SND_SOC_NOPM, 0, 0, |
| 4102 | &lineout3_ground_switch), |
| 4103 | SND_SOC_DAPM_DAC_E("LINEOUT4 DAC", NULL, TAIKO_A_RX_LINE_4_DAC_CTL, 7, 0 |
| 4104 | , taiko_lineout_dac_event, |
| 4105 | SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD), |
| 4106 | SND_SOC_DAPM_SWITCH("LINEOUT4 DAC GROUND", SND_SOC_NOPM, 0, 0, |
| 4107 | &lineout4_ground_switch), |
| 4108 | |
Joonwoo Park | 7680b9f | 2012-07-13 11:36:48 -0700 | [diff] [blame] | 4109 | SND_SOC_DAPM_DAC_E("SPK DAC", NULL, SND_SOC_NOPM, 0, 0, |
| 4110 | taiko_spk_dac_event, |
| 4111 | SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD), |
| 4112 | |
Joonwoo Park | 125cd4e | 2012-12-11 15:16:11 -0800 | [diff] [blame] | 4113 | SND_SOC_DAPM_SUPPLY("VDD_SPKDRV", SND_SOC_NOPM, 0, 0, |
| 4114 | taiko_codec_enable_vdd_spkr, |
| 4115 | SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD), |
| 4116 | |
Kiran Kandi | d2b4633 | 2012-10-05 12:04:00 -0700 | [diff] [blame] | 4117 | SND_SOC_DAPM_MIXER("RX1 MIX1", SND_SOC_NOPM, 0, 0, NULL, 0), |
| 4118 | SND_SOC_DAPM_MIXER("RX2 MIX1", SND_SOC_NOPM, 0, 0, NULL, 0), |
| 4119 | SND_SOC_DAPM_MIXER("RX7 MIX1", SND_SOC_NOPM, 0, 0, NULL, 0), |
| 4120 | |
Kiran Kandi | c3b2440 | 2012-06-11 00:05:59 -0700 | [diff] [blame] | 4121 | SND_SOC_DAPM_MIXER_E("RX1 MIX2", TAIKO_A_CDC_CLK_RX_B1_CTL, 0, 0, NULL, |
Kiran Kandi | 7b7d2ff | 2012-09-14 14:52:14 -0700 | [diff] [blame] | 4122 | 0, taiko_codec_enable_interpolator, SND_SOC_DAPM_PRE_PMU | |
Kiran Kandi | c3b2440 | 2012-06-11 00:05:59 -0700 | [diff] [blame] | 4123 | SND_SOC_DAPM_POST_PMU), |
| 4124 | SND_SOC_DAPM_MIXER_E("RX2 MIX2", TAIKO_A_CDC_CLK_RX_B1_CTL, 1, 0, NULL, |
Kiran Kandi | 7b7d2ff | 2012-09-14 14:52:14 -0700 | [diff] [blame] | 4125 | 0, taiko_codec_enable_interpolator, SND_SOC_DAPM_PRE_PMU | |
Kiran Kandi | c3b2440 | 2012-06-11 00:05:59 -0700 | [diff] [blame] | 4126 | SND_SOC_DAPM_POST_PMU), |
Kiran Kandi | d2b4633 | 2012-10-05 12:04:00 -0700 | [diff] [blame] | 4127 | SND_SOC_DAPM_MIXER_E("RX3 MIX1", TAIKO_A_CDC_CLK_RX_B1_CTL, 2, 0, NULL, |
Kiran Kandi | 7b7d2ff | 2012-09-14 14:52:14 -0700 | [diff] [blame] | 4128 | 0, taiko_codec_enable_interpolator, SND_SOC_DAPM_PRE_PMU | |
Kiran Kandi | c3b2440 | 2012-06-11 00:05:59 -0700 | [diff] [blame] | 4129 | SND_SOC_DAPM_POST_PMU), |
| 4130 | SND_SOC_DAPM_MIXER_E("RX4 MIX1", TAIKO_A_CDC_CLK_RX_B1_CTL, 3, 0, NULL, |
Kiran Kandi | 7b7d2ff | 2012-09-14 14:52:14 -0700 | [diff] [blame] | 4131 | 0, taiko_codec_enable_interpolator, SND_SOC_DAPM_PRE_PMU | |
Kiran Kandi | c3b2440 | 2012-06-11 00:05:59 -0700 | [diff] [blame] | 4132 | SND_SOC_DAPM_POST_PMU), |
| 4133 | SND_SOC_DAPM_MIXER_E("RX5 MIX1", TAIKO_A_CDC_CLK_RX_B1_CTL, 4, 0, NULL, |
Kiran Kandi | 7b7d2ff | 2012-09-14 14:52:14 -0700 | [diff] [blame] | 4134 | 0, taiko_codec_enable_interpolator, SND_SOC_DAPM_PRE_PMU | |
Kiran Kandi | c3b2440 | 2012-06-11 00:05:59 -0700 | [diff] [blame] | 4135 | SND_SOC_DAPM_POST_PMU), |
| 4136 | SND_SOC_DAPM_MIXER_E("RX6 MIX1", TAIKO_A_CDC_CLK_RX_B1_CTL, 5, 0, NULL, |
Kiran Kandi | 7b7d2ff | 2012-09-14 14:52:14 -0700 | [diff] [blame] | 4137 | 0, taiko_codec_enable_interpolator, SND_SOC_DAPM_PRE_PMU | |
Kiran Kandi | c3b2440 | 2012-06-11 00:05:59 -0700 | [diff] [blame] | 4138 | SND_SOC_DAPM_POST_PMU), |
Kiran Kandi | d2b4633 | 2012-10-05 12:04:00 -0700 | [diff] [blame] | 4139 | SND_SOC_DAPM_MIXER_E("RX7 MIX2", TAIKO_A_CDC_CLK_RX_B1_CTL, 6, 0, NULL, |
Kiran Kandi | 7b7d2ff | 2012-09-14 14:52:14 -0700 | [diff] [blame] | 4140 | 0, taiko_codec_enable_interpolator, SND_SOC_DAPM_PRE_PMU | |
Kiran Kandi | c3b2440 | 2012-06-11 00:05:59 -0700 | [diff] [blame] | 4141 | SND_SOC_DAPM_POST_PMU), |
| 4142 | |
Kiran Kandi | c3b2440 | 2012-06-11 00:05:59 -0700 | [diff] [blame] | 4143 | |
| 4144 | SND_SOC_DAPM_MIXER("RX1 CHAIN", TAIKO_A_CDC_RX1_B6_CTL, 5, 0, NULL, 0), |
| 4145 | SND_SOC_DAPM_MIXER("RX2 CHAIN", TAIKO_A_CDC_RX2_B6_CTL, 5, 0, NULL, 0), |
| 4146 | |
| 4147 | SND_SOC_DAPM_MUX("RX1 MIX1 INP1", SND_SOC_NOPM, 0, 0, |
| 4148 | &rx_mix1_inp1_mux), |
| 4149 | SND_SOC_DAPM_MUX("RX1 MIX1 INP2", SND_SOC_NOPM, 0, 0, |
| 4150 | &rx_mix1_inp2_mux), |
| 4151 | SND_SOC_DAPM_MUX("RX1 MIX1 INP3", SND_SOC_NOPM, 0, 0, |
| 4152 | &rx_mix1_inp3_mux), |
| 4153 | SND_SOC_DAPM_MUX("RX2 MIX1 INP1", SND_SOC_NOPM, 0, 0, |
| 4154 | &rx2_mix1_inp1_mux), |
| 4155 | SND_SOC_DAPM_MUX("RX2 MIX1 INP2", SND_SOC_NOPM, 0, 0, |
| 4156 | &rx2_mix1_inp2_mux), |
| 4157 | SND_SOC_DAPM_MUX("RX3 MIX1 INP1", SND_SOC_NOPM, 0, 0, |
| 4158 | &rx3_mix1_inp1_mux), |
| 4159 | SND_SOC_DAPM_MUX("RX3 MIX1 INP2", SND_SOC_NOPM, 0, 0, |
| 4160 | &rx3_mix1_inp2_mux), |
| 4161 | SND_SOC_DAPM_MUX("RX4 MIX1 INP1", SND_SOC_NOPM, 0, 0, |
| 4162 | &rx4_mix1_inp1_mux), |
| 4163 | SND_SOC_DAPM_MUX("RX4 MIX1 INP2", SND_SOC_NOPM, 0, 0, |
| 4164 | &rx4_mix1_inp2_mux), |
| 4165 | SND_SOC_DAPM_MUX("RX5 MIX1 INP1", SND_SOC_NOPM, 0, 0, |
| 4166 | &rx5_mix1_inp1_mux), |
| 4167 | SND_SOC_DAPM_MUX("RX5 MIX1 INP2", SND_SOC_NOPM, 0, 0, |
| 4168 | &rx5_mix1_inp2_mux), |
| 4169 | SND_SOC_DAPM_MUX("RX6 MIX1 INP1", SND_SOC_NOPM, 0, 0, |
| 4170 | &rx6_mix1_inp1_mux), |
| 4171 | SND_SOC_DAPM_MUX("RX6 MIX1 INP2", SND_SOC_NOPM, 0, 0, |
| 4172 | &rx6_mix1_inp2_mux), |
| 4173 | SND_SOC_DAPM_MUX("RX7 MIX1 INP1", SND_SOC_NOPM, 0, 0, |
| 4174 | &rx7_mix1_inp1_mux), |
| 4175 | SND_SOC_DAPM_MUX("RX7 MIX1 INP2", SND_SOC_NOPM, 0, 0, |
| 4176 | &rx7_mix1_inp2_mux), |
| 4177 | SND_SOC_DAPM_MUX("RX1 MIX2 INP1", SND_SOC_NOPM, 0, 0, |
| 4178 | &rx1_mix2_inp1_mux), |
| 4179 | SND_SOC_DAPM_MUX("RX1 MIX2 INP2", SND_SOC_NOPM, 0, 0, |
| 4180 | &rx1_mix2_inp2_mux), |
| 4181 | SND_SOC_DAPM_MUX("RX2 MIX2 INP1", SND_SOC_NOPM, 0, 0, |
| 4182 | &rx2_mix2_inp1_mux), |
| 4183 | SND_SOC_DAPM_MUX("RX2 MIX2 INP2", SND_SOC_NOPM, 0, 0, |
| 4184 | &rx2_mix2_inp2_mux), |
| 4185 | SND_SOC_DAPM_MUX("RX7 MIX2 INP1", SND_SOC_NOPM, 0, 0, |
| 4186 | &rx7_mix2_inp1_mux), |
| 4187 | SND_SOC_DAPM_MUX("RX7 MIX2 INP2", SND_SOC_NOPM, 0, 0, |
| 4188 | &rx7_mix2_inp2_mux), |
| 4189 | |
Tanya Finkel | daaa6d1 | 2012-10-25 11:22:48 +0200 | [diff] [blame] | 4190 | SND_SOC_DAPM_MUX("RDAC5 MUX", SND_SOC_NOPM, 0, 0, |
| 4191 | &rx_dac5_mux), |
| 4192 | SND_SOC_DAPM_MUX("RDAC7 MUX", SND_SOC_NOPM, 0, 0, |
| 4193 | &rx_dac7_mux), |
| 4194 | |
Kiran Kandi | 4c56c59 | 2012-07-25 11:04:55 -0700 | [diff] [blame] | 4195 | SND_SOC_DAPM_SUPPLY("CLASS_H_CLK", TAIKO_A_CDC_CLK_OTHR_CTL, 0, 0, |
| 4196 | taiko_codec_enable_class_h_clk, SND_SOC_DAPM_PRE_PMU | |
Kiran Kandi | c3b2440 | 2012-06-11 00:05:59 -0700 | [diff] [blame] | 4197 | SND_SOC_DAPM_PRE_PMD), |
| 4198 | |
Kiran Kandi | 4c56c59 | 2012-07-25 11:04:55 -0700 | [diff] [blame] | 4199 | SND_SOC_DAPM_SUPPLY("CLASS_H_EAR", TAIKO_A_CDC_CLSH_B1_CTL, 4, 0, |
| 4200 | taiko_codec_enable_class_h, SND_SOC_DAPM_POST_PMU), |
| 4201 | |
Kiran Kandi | 7b7d2ff | 2012-09-14 14:52:14 -0700 | [diff] [blame] | 4202 | SND_SOC_DAPM_SUPPLY("CLASS_H_HPH_L", TAIKO_A_CDC_CLSH_B1_CTL, 3, 0, |
Kiran Kandi | 4c56c59 | 2012-07-25 11:04:55 -0700 | [diff] [blame] | 4203 | taiko_codec_enable_class_h, SND_SOC_DAPM_POST_PMU), |
| 4204 | |
Kiran Kandi | 7b7d2ff | 2012-09-14 14:52:14 -0700 | [diff] [blame] | 4205 | SND_SOC_DAPM_SUPPLY("CLASS_H_HPH_R", TAIKO_A_CDC_CLSH_B1_CTL, 2, 0, |
Kiran Kandi | 4c56c59 | 2012-07-25 11:04:55 -0700 | [diff] [blame] | 4206 | taiko_codec_enable_class_h, SND_SOC_DAPM_POST_PMU), |
| 4207 | |
Tanya Finkel | fe63446 | 2012-10-23 22:12:07 +0200 | [diff] [blame] | 4208 | SND_SOC_DAPM_SUPPLY("CLASS_H_LINEOUTS_PA", SND_SOC_NOPM, 0, 0, |
| 4209 | taiko_codec_enable_class_h, SND_SOC_DAPM_POST_PMU), |
| 4210 | |
Kiran Kandi | 4c56c59 | 2012-07-25 11:04:55 -0700 | [diff] [blame] | 4211 | SND_SOC_DAPM_SUPPLY("CP", TAIKO_A_NCP_EN, 0, 0, |
| 4212 | taiko_codec_enable_charge_pump, SND_SOC_DAPM_PRE_PMU | |
| 4213 | SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_PRE_PMD), |
| 4214 | |
Kiran Kandi | c3b2440 | 2012-06-11 00:05:59 -0700 | [diff] [blame] | 4215 | SND_SOC_DAPM_SUPPLY("RX_BIAS", SND_SOC_NOPM, 0, 0, |
| 4216 | taiko_codec_enable_rx_bias, SND_SOC_DAPM_PRE_PMU | |
| 4217 | SND_SOC_DAPM_POST_PMD), |
| 4218 | |
Joonwoo Park | 559a5bf | 2013-02-15 14:46:36 -0800 | [diff] [blame] | 4219 | SND_SOC_DAPM_SUPPLY("CDC_I2S_RX_CONN", TAIKO_A_CDC_CLK_OTHR_CTL, 5, 0, |
| 4220 | NULL, 0), |
| 4221 | |
Kiran Kandi | c3b2440 | 2012-06-11 00:05:59 -0700 | [diff] [blame] | 4222 | /* TX */ |
| 4223 | |
| 4224 | SND_SOC_DAPM_SUPPLY("CDC_CONN", TAIKO_A_CDC_CLK_OTHR_CTL, 2, 0, NULL, |
| 4225 | 0), |
| 4226 | |
| 4227 | SND_SOC_DAPM_SUPPLY("LDO_H", TAIKO_A_LDO_H_MODE_1, 7, 0, |
| 4228 | taiko_codec_enable_ldo_h, SND_SOC_DAPM_POST_PMU), |
| 4229 | |
Joonwoo Park | c773143 | 2012-10-17 12:41:44 -0700 | [diff] [blame] | 4230 | SND_SOC_DAPM_SUPPLY("COMP0_CLK", SND_SOC_NOPM, 0, 0, |
Kiran Kandi | c3b2440 | 2012-06-11 00:05:59 -0700 | [diff] [blame] | 4231 | taiko_config_compander, SND_SOC_DAPM_PRE_PMU | |
| 4232 | SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_PRE_POST_PMD), |
Joonwoo Park | c773143 | 2012-10-17 12:41:44 -0700 | [diff] [blame] | 4233 | SND_SOC_DAPM_SUPPLY("COMP1_CLK", SND_SOC_NOPM, 1, 0, |
| 4234 | taiko_config_compander, SND_SOC_DAPM_PRE_PMU | |
| 4235 | SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_PRE_POST_PMD), |
| 4236 | SND_SOC_DAPM_SUPPLY("COMP2_CLK", SND_SOC_NOPM, 2, 0, |
Kiran Kandi | c3b2440 | 2012-06-11 00:05:59 -0700 | [diff] [blame] | 4237 | taiko_config_compander, SND_SOC_DAPM_PRE_PMU | |
| 4238 | SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_PRE_POST_PMD), |
| 4239 | |
| 4240 | |
| 4241 | SND_SOC_DAPM_INPUT("AMIC1"), |
Joonwoo Park | 3699ca3 | 2013-02-08 12:06:15 -0800 | [diff] [blame] | 4242 | SND_SOC_DAPM_MICBIAS_E("MIC BIAS1 External", SND_SOC_NOPM, 7, 0, |
| 4243 | taiko_codec_enable_micbias, |
| 4244 | SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU | |
| 4245 | SND_SOC_DAPM_POST_PMD), |
| 4246 | SND_SOC_DAPM_MICBIAS_E("MIC BIAS1 Internal1", SND_SOC_NOPM, 7, 0, |
| 4247 | taiko_codec_enable_micbias, |
| 4248 | SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU | |
| 4249 | SND_SOC_DAPM_POST_PMD), |
| 4250 | SND_SOC_DAPM_MICBIAS_E("MIC BIAS1 Internal2", SND_SOC_NOPM, 7, 0, |
| 4251 | taiko_codec_enable_micbias, |
| 4252 | SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU | |
| 4253 | SND_SOC_DAPM_POST_PMD), |
Kiran Kandi | c3b2440 | 2012-06-11 00:05:59 -0700 | [diff] [blame] | 4254 | SND_SOC_DAPM_ADC_E("ADC1", NULL, TAIKO_A_TX_1_2_EN, 7, 0, |
| 4255 | taiko_codec_enable_adc, SND_SOC_DAPM_PRE_PMU | |
| 4256 | SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD), |
| 4257 | |
| 4258 | SND_SOC_DAPM_INPUT("AMIC3"), |
| 4259 | SND_SOC_DAPM_ADC_E("ADC3", NULL, TAIKO_A_TX_3_4_EN, 7, 0, |
| 4260 | taiko_codec_enable_adc, SND_SOC_DAPM_PRE_PMU | |
| 4261 | SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD), |
| 4262 | |
| 4263 | SND_SOC_DAPM_INPUT("AMIC4"), |
| 4264 | SND_SOC_DAPM_ADC_E("ADC4", NULL, TAIKO_A_TX_3_4_EN, 3, 0, |
| 4265 | taiko_codec_enable_adc, SND_SOC_DAPM_PRE_PMU | |
| 4266 | SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD), |
| 4267 | |
| 4268 | SND_SOC_DAPM_INPUT("AMIC5"), |
| 4269 | SND_SOC_DAPM_ADC_E("ADC5", NULL, TAIKO_A_TX_5_6_EN, 7, 0, |
| 4270 | taiko_codec_enable_adc, SND_SOC_DAPM_POST_PMU), |
| 4271 | |
| 4272 | SND_SOC_DAPM_INPUT("AMIC6"), |
| 4273 | SND_SOC_DAPM_ADC_E("ADC6", NULL, TAIKO_A_TX_5_6_EN, 3, 0, |
| 4274 | taiko_codec_enable_adc, SND_SOC_DAPM_POST_PMU), |
| 4275 | |
| 4276 | SND_SOC_DAPM_MUX_E("DEC1 MUX", TAIKO_A_CDC_CLK_TX_CLK_EN_B1_CTL, 0, 0, |
| 4277 | &dec1_mux, taiko_codec_enable_dec, |
| 4278 | SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU | |
| 4279 | SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD), |
| 4280 | |
| 4281 | SND_SOC_DAPM_MUX_E("DEC2 MUX", TAIKO_A_CDC_CLK_TX_CLK_EN_B1_CTL, 1, 0, |
| 4282 | &dec2_mux, taiko_codec_enable_dec, |
| 4283 | SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU | |
| 4284 | SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD), |
| 4285 | |
| 4286 | SND_SOC_DAPM_MUX_E("DEC3 MUX", TAIKO_A_CDC_CLK_TX_CLK_EN_B1_CTL, 2, 0, |
| 4287 | &dec3_mux, taiko_codec_enable_dec, |
| 4288 | SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU | |
| 4289 | SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD), |
| 4290 | |
| 4291 | SND_SOC_DAPM_MUX_E("DEC4 MUX", TAIKO_A_CDC_CLK_TX_CLK_EN_B1_CTL, 3, 0, |
| 4292 | &dec4_mux, taiko_codec_enable_dec, |
| 4293 | SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU | |
| 4294 | SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD), |
| 4295 | |
| 4296 | SND_SOC_DAPM_MUX_E("DEC5 MUX", TAIKO_A_CDC_CLK_TX_CLK_EN_B1_CTL, 4, 0, |
| 4297 | &dec5_mux, taiko_codec_enable_dec, |
| 4298 | SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU | |
| 4299 | SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD), |
| 4300 | |
| 4301 | SND_SOC_DAPM_MUX_E("DEC6 MUX", TAIKO_A_CDC_CLK_TX_CLK_EN_B1_CTL, 5, 0, |
| 4302 | &dec6_mux, taiko_codec_enable_dec, |
| 4303 | SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU | |
| 4304 | SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD), |
| 4305 | |
| 4306 | SND_SOC_DAPM_MUX_E("DEC7 MUX", TAIKO_A_CDC_CLK_TX_CLK_EN_B1_CTL, 6, 0, |
| 4307 | &dec7_mux, taiko_codec_enable_dec, |
| 4308 | SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU | |
| 4309 | SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD), |
| 4310 | |
| 4311 | SND_SOC_DAPM_MUX_E("DEC8 MUX", TAIKO_A_CDC_CLK_TX_CLK_EN_B1_CTL, 7, 0, |
| 4312 | &dec8_mux, taiko_codec_enable_dec, |
| 4313 | SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU | |
| 4314 | SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD), |
| 4315 | |
| 4316 | SND_SOC_DAPM_MUX_E("DEC9 MUX", TAIKO_A_CDC_CLK_TX_CLK_EN_B2_CTL, 0, 0, |
| 4317 | &dec9_mux, taiko_codec_enable_dec, |
| 4318 | SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU | |
| 4319 | SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD), |
| 4320 | |
| 4321 | SND_SOC_DAPM_MUX_E("DEC10 MUX", TAIKO_A_CDC_CLK_TX_CLK_EN_B2_CTL, 1, 0, |
| 4322 | &dec10_mux, taiko_codec_enable_dec, |
| 4323 | SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU | |
| 4324 | SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD), |
| 4325 | |
| 4326 | SND_SOC_DAPM_MUX("ANC1 MUX", SND_SOC_NOPM, 0, 0, &anc1_mux), |
| 4327 | SND_SOC_DAPM_MUX("ANC2 MUX", SND_SOC_NOPM, 0, 0, &anc2_mux), |
| 4328 | |
| 4329 | SND_SOC_DAPM_MIXER_E("ANC", SND_SOC_NOPM, 0, 0, NULL, 0, |
| 4330 | taiko_codec_enable_anc, SND_SOC_DAPM_PRE_PMU | |
| 4331 | SND_SOC_DAPM_POST_PMD), |
| 4332 | |
| 4333 | SND_SOC_DAPM_MUX("ANC1 FB MUX", SND_SOC_NOPM, 0, 0, &anc1_fb_mux), |
| 4334 | |
| 4335 | SND_SOC_DAPM_INPUT("AMIC2"), |
Joonwoo Park | 3699ca3 | 2013-02-08 12:06:15 -0800 | [diff] [blame] | 4336 | SND_SOC_DAPM_MICBIAS_E("MIC BIAS2 External", SND_SOC_NOPM, 7, 0, |
| 4337 | taiko_codec_enable_micbias, |
| 4338 | SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU | |
| 4339 | SND_SOC_DAPM_POST_PMD), |
| 4340 | SND_SOC_DAPM_MICBIAS_E("MIC BIAS2 Internal1", SND_SOC_NOPM, 7, 0, |
| 4341 | taiko_codec_enable_micbias, |
| 4342 | SND_SOC_DAPM_PRE_PMU | |
| 4343 | SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD), |
| 4344 | SND_SOC_DAPM_MICBIAS_E("MIC BIAS2 Internal2", SND_SOC_NOPM, 7, 0, |
| 4345 | taiko_codec_enable_micbias, |
| 4346 | SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU | |
| 4347 | SND_SOC_DAPM_POST_PMD), |
| 4348 | SND_SOC_DAPM_MICBIAS_E("MIC BIAS2 Internal3", SND_SOC_NOPM, 7, 0, |
| 4349 | taiko_codec_enable_micbias, |
| 4350 | SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU | |
| 4351 | SND_SOC_DAPM_POST_PMD), |
| 4352 | SND_SOC_DAPM_MICBIAS_E("MIC BIAS3 External", SND_SOC_NOPM, 7, 0, |
| 4353 | taiko_codec_enable_micbias, |
| 4354 | SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU | |
| 4355 | SND_SOC_DAPM_POST_PMD), |
| 4356 | SND_SOC_DAPM_MICBIAS_E("MIC BIAS3 Internal1", SND_SOC_NOPM, 7, 0, |
| 4357 | taiko_codec_enable_micbias, |
| 4358 | SND_SOC_DAPM_PRE_PMU | |
| 4359 | SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD), |
| 4360 | SND_SOC_DAPM_MICBIAS_E("MIC BIAS3 Internal2", SND_SOC_NOPM, 7, 0, |
| 4361 | taiko_codec_enable_micbias, |
| 4362 | SND_SOC_DAPM_PRE_PMU | |
| 4363 | SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD), |
| 4364 | SND_SOC_DAPM_MICBIAS_E("MIC BIAS4 External", SND_SOC_NOPM, 7, |
| 4365 | 0, taiko_codec_enable_micbias, |
| 4366 | SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU | |
| 4367 | SND_SOC_DAPM_POST_PMD), |
Kiran Kandi | c3b2440 | 2012-06-11 00:05:59 -0700 | [diff] [blame] | 4368 | |
| 4369 | SND_SOC_DAPM_ADC_E("ADC2", NULL, TAIKO_A_TX_1_2_EN, 3, 0, |
| 4370 | taiko_codec_enable_adc, SND_SOC_DAPM_PRE_PMU | |
| 4371 | SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD), |
| 4372 | |
Kuirong Wang | 906ac47 | 2012-07-09 12:54:44 -0700 | [diff] [blame] | 4373 | SND_SOC_DAPM_AIF_OUT_E("AIF1 CAP", "AIF1 Capture", 0, SND_SOC_NOPM, |
| 4374 | AIF1_CAP, 0, taiko_codec_enable_slimtx, |
| 4375 | SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD), |
Kiran Kandi | c3b2440 | 2012-06-11 00:05:59 -0700 | [diff] [blame] | 4376 | |
Kuirong Wang | 906ac47 | 2012-07-09 12:54:44 -0700 | [diff] [blame] | 4377 | SND_SOC_DAPM_AIF_OUT_E("AIF2 CAP", "AIF2 Capture", 0, SND_SOC_NOPM, |
| 4378 | AIF2_CAP, 0, taiko_codec_enable_slimtx, |
| 4379 | SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD), |
Kiran Kandi | c3b2440 | 2012-06-11 00:05:59 -0700 | [diff] [blame] | 4380 | |
Kuirong Wang | 906ac47 | 2012-07-09 12:54:44 -0700 | [diff] [blame] | 4381 | SND_SOC_DAPM_AIF_OUT_E("AIF3 CAP", "AIF3 Capture", 0, SND_SOC_NOPM, |
| 4382 | AIF3_CAP, 0, taiko_codec_enable_slimtx, |
| 4383 | SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD), |
Kiran Kandi | c3b2440 | 2012-06-11 00:05:59 -0700 | [diff] [blame] | 4384 | |
Kuirong Wang | 906ac47 | 2012-07-09 12:54:44 -0700 | [diff] [blame] | 4385 | SND_SOC_DAPM_MIXER("AIF1_CAP Mixer", SND_SOC_NOPM, AIF1_CAP, 0, |
| 4386 | aif_cap_mixer, ARRAY_SIZE(aif_cap_mixer)), |
Kiran Kandi | c3b2440 | 2012-06-11 00:05:59 -0700 | [diff] [blame] | 4387 | |
Kuirong Wang | 906ac47 | 2012-07-09 12:54:44 -0700 | [diff] [blame] | 4388 | SND_SOC_DAPM_MIXER("AIF2_CAP Mixer", SND_SOC_NOPM, AIF2_CAP, 0, |
| 4389 | aif_cap_mixer, ARRAY_SIZE(aif_cap_mixer)), |
Kiran Kandi | c3b2440 | 2012-06-11 00:05:59 -0700 | [diff] [blame] | 4390 | |
Kuirong Wang | 906ac47 | 2012-07-09 12:54:44 -0700 | [diff] [blame] | 4391 | SND_SOC_DAPM_MIXER("AIF3_CAP Mixer", SND_SOC_NOPM, AIF3_CAP, 0, |
| 4392 | aif_cap_mixer, ARRAY_SIZE(aif_cap_mixer)), |
Kiran Kandi | c3b2440 | 2012-06-11 00:05:59 -0700 | [diff] [blame] | 4393 | |
Kuirong Wang | 906ac47 | 2012-07-09 12:54:44 -0700 | [diff] [blame] | 4394 | SND_SOC_DAPM_MUX("SLIM TX1 MUX", SND_SOC_NOPM, TAIKO_TX1, 0, |
| 4395 | &sb_tx1_mux), |
| 4396 | SND_SOC_DAPM_MUX("SLIM TX2 MUX", SND_SOC_NOPM, TAIKO_TX2, 0, |
| 4397 | &sb_tx2_mux), |
| 4398 | SND_SOC_DAPM_MUX("SLIM TX3 MUX", SND_SOC_NOPM, TAIKO_TX3, 0, |
| 4399 | &sb_tx3_mux), |
| 4400 | SND_SOC_DAPM_MUX("SLIM TX4 MUX", SND_SOC_NOPM, TAIKO_TX4, 0, |
| 4401 | &sb_tx4_mux), |
| 4402 | SND_SOC_DAPM_MUX("SLIM TX5 MUX", SND_SOC_NOPM, TAIKO_TX5, 0, |
| 4403 | &sb_tx5_mux), |
| 4404 | SND_SOC_DAPM_MUX("SLIM TX6 MUX", SND_SOC_NOPM, TAIKO_TX6, 0, |
| 4405 | &sb_tx6_mux), |
| 4406 | SND_SOC_DAPM_MUX("SLIM TX7 MUX", SND_SOC_NOPM, TAIKO_TX7, 0, |
| 4407 | &sb_tx7_mux), |
| 4408 | SND_SOC_DAPM_MUX("SLIM TX8 MUX", SND_SOC_NOPM, TAIKO_TX8, 0, |
| 4409 | &sb_tx8_mux), |
| 4410 | SND_SOC_DAPM_MUX("SLIM TX9 MUX", SND_SOC_NOPM, TAIKO_TX9, 0, |
| 4411 | &sb_tx9_mux), |
| 4412 | SND_SOC_DAPM_MUX("SLIM TX10 MUX", SND_SOC_NOPM, TAIKO_TX10, 0, |
| 4413 | &sb_tx10_mux), |
Kiran Kandi | c3b2440 | 2012-06-11 00:05:59 -0700 | [diff] [blame] | 4414 | |
| 4415 | /* Digital Mic Inputs */ |
| 4416 | SND_SOC_DAPM_ADC_E("DMIC1", NULL, SND_SOC_NOPM, 0, 0, |
| 4417 | taiko_codec_enable_dmic, SND_SOC_DAPM_PRE_PMU | |
| 4418 | SND_SOC_DAPM_POST_PMD), |
| 4419 | |
| 4420 | SND_SOC_DAPM_ADC_E("DMIC2", NULL, SND_SOC_NOPM, 0, 0, |
| 4421 | taiko_codec_enable_dmic, SND_SOC_DAPM_PRE_PMU | |
| 4422 | SND_SOC_DAPM_POST_PMD), |
| 4423 | |
| 4424 | SND_SOC_DAPM_ADC_E("DMIC3", NULL, SND_SOC_NOPM, 0, 0, |
| 4425 | taiko_codec_enable_dmic, SND_SOC_DAPM_PRE_PMU | |
| 4426 | SND_SOC_DAPM_POST_PMD), |
| 4427 | |
| 4428 | SND_SOC_DAPM_ADC_E("DMIC4", NULL, SND_SOC_NOPM, 0, 0, |
| 4429 | taiko_codec_enable_dmic, SND_SOC_DAPM_PRE_PMU | |
| 4430 | SND_SOC_DAPM_POST_PMD), |
| 4431 | |
| 4432 | SND_SOC_DAPM_ADC_E("DMIC5", NULL, SND_SOC_NOPM, 0, 0, |
| 4433 | taiko_codec_enable_dmic, SND_SOC_DAPM_PRE_PMU | |
| 4434 | SND_SOC_DAPM_POST_PMD), |
| 4435 | SND_SOC_DAPM_ADC_E("DMIC6", NULL, SND_SOC_NOPM, 0, 0, |
| 4436 | taiko_codec_enable_dmic, SND_SOC_DAPM_PRE_PMU | |
| 4437 | SND_SOC_DAPM_POST_PMD), |
| 4438 | |
| 4439 | /* Sidetone */ |
| 4440 | SND_SOC_DAPM_MUX("IIR1 INP1 MUX", SND_SOC_NOPM, 0, 0, &iir1_inp1_mux), |
| 4441 | SND_SOC_DAPM_PGA("IIR1", TAIKO_A_CDC_CLK_SD_CTL, 0, 0, NULL, 0), |
| 4442 | |
| 4443 | /* AUX PGA */ |
| 4444 | SND_SOC_DAPM_ADC_E("AUX_PGA_Left", NULL, TAIKO_A_RX_AUX_SW_CTL, 7, 0, |
| 4445 | taiko_codec_enable_aux_pga, SND_SOC_DAPM_PRE_PMU | |
| 4446 | SND_SOC_DAPM_POST_PMD), |
| 4447 | |
| 4448 | SND_SOC_DAPM_ADC_E("AUX_PGA_Right", NULL, TAIKO_A_RX_AUX_SW_CTL, 6, 0, |
| 4449 | taiko_codec_enable_aux_pga, SND_SOC_DAPM_PRE_PMU | |
| 4450 | SND_SOC_DAPM_POST_PMD), |
| 4451 | |
| 4452 | /* Lineout, ear and HPH PA Mixers */ |
| 4453 | |
| 4454 | SND_SOC_DAPM_MIXER("EAR_PA_MIXER", SND_SOC_NOPM, 0, 0, |
| 4455 | ear_pa_mix, ARRAY_SIZE(ear_pa_mix)), |
| 4456 | |
| 4457 | SND_SOC_DAPM_MIXER("HPHL_PA_MIXER", SND_SOC_NOPM, 0, 0, |
| 4458 | hphl_pa_mix, ARRAY_SIZE(hphl_pa_mix)), |
| 4459 | |
| 4460 | SND_SOC_DAPM_MIXER("HPHR_PA_MIXER", SND_SOC_NOPM, 0, 0, |
| 4461 | hphr_pa_mix, ARRAY_SIZE(hphr_pa_mix)), |
| 4462 | |
| 4463 | SND_SOC_DAPM_MIXER("LINEOUT1_PA_MIXER", SND_SOC_NOPM, 0, 0, |
| 4464 | lineout1_pa_mix, ARRAY_SIZE(lineout1_pa_mix)), |
| 4465 | |
| 4466 | SND_SOC_DAPM_MIXER("LINEOUT2_PA_MIXER", SND_SOC_NOPM, 0, 0, |
| 4467 | lineout2_pa_mix, ARRAY_SIZE(lineout2_pa_mix)), |
| 4468 | |
| 4469 | SND_SOC_DAPM_MIXER("LINEOUT3_PA_MIXER", SND_SOC_NOPM, 0, 0, |
| 4470 | lineout3_pa_mix, ARRAY_SIZE(lineout3_pa_mix)), |
| 4471 | |
| 4472 | SND_SOC_DAPM_MIXER("LINEOUT4_PA_MIXER", SND_SOC_NOPM, 0, 0, |
| 4473 | lineout4_pa_mix, ARRAY_SIZE(lineout4_pa_mix)), |
| 4474 | |
| 4475 | }; |
| 4476 | |
Kiran Kandi | c3b2440 | 2012-06-11 00:05:59 -0700 | [diff] [blame] | 4477 | static irqreturn_t taiko_slimbus_irq(int irq, void *data) |
| 4478 | { |
| 4479 | struct taiko_priv *priv = data; |
| 4480 | struct snd_soc_codec *codec = priv->codec; |
Joonwoo Park | 9bbb4d1 | 2012-11-09 19:58:11 -0800 | [diff] [blame] | 4481 | unsigned long status = 0; |
| 4482 | int i, j, port_id, k; |
| 4483 | u32 bit; |
Kiran Kandi | c3b2440 | 2012-06-11 00:05:59 -0700 | [diff] [blame] | 4484 | u8 val; |
Joonwoo Park | 9bbb4d1 | 2012-11-09 19:58:11 -0800 | [diff] [blame] | 4485 | bool tx, cleared; |
Kiran Kandi | c3b2440 | 2012-06-11 00:05:59 -0700 | [diff] [blame] | 4486 | |
Joonwoo Park | 9bbb4d1 | 2012-11-09 19:58:11 -0800 | [diff] [blame] | 4487 | for (i = TAIKO_SLIM_PGD_PORT_INT_STATUS_RX_0, j = 0; |
| 4488 | i <= TAIKO_SLIM_PGD_PORT_INT_STATUS_TX_1; i++, j++) { |
| 4489 | val = wcd9xxx_interface_reg_read(codec->control_data, i); |
| 4490 | status |= ((u32)val << (8 * j)); |
| 4491 | } |
| 4492 | |
| 4493 | for_each_set_bit(j, &status, 32) { |
| 4494 | tx = (j >= 16 ? true : false); |
| 4495 | port_id = (tx ? j - 16 : j); |
| 4496 | val = wcd9xxx_interface_reg_read(codec->control_data, |
| 4497 | TAIKO_SLIM_PGD_PORT_INT_RX_SOURCE0 + j); |
| 4498 | if (val & TAIKO_SLIM_IRQ_OVERFLOW) |
| 4499 | pr_err_ratelimited( |
| 4500 | "%s: overflow error on %s port %d, value %x\n", |
| 4501 | __func__, (tx ? "TX" : "RX"), port_id, val); |
| 4502 | if (val & TAIKO_SLIM_IRQ_UNDERFLOW) |
| 4503 | pr_err_ratelimited( |
| 4504 | "%s: underflow error on %s port %d, value %x\n", |
| 4505 | __func__, (tx ? "TX" : "RX"), port_id, val); |
| 4506 | if (val & TAIKO_SLIM_IRQ_PORT_CLOSED) { |
| 4507 | /* |
| 4508 | * INT SOURCE register starts from RX to TX |
| 4509 | * but port number in the ch_mask is in opposite way |
| 4510 | */ |
| 4511 | bit = (tx ? j - 16 : j + 16); |
| 4512 | pr_debug("%s: %s port %d closed value %x, bit %u\n", |
| 4513 | __func__, (tx ? "TX" : "RX"), port_id, val, |
| 4514 | bit); |
| 4515 | for (k = 0, cleared = false; k < NUM_CODEC_DAIS; k++) { |
| 4516 | pr_debug("%s: priv->dai[%d].ch_mask = 0x%lx\n", |
| 4517 | __func__, k, priv->dai[k].ch_mask); |
| 4518 | if (test_and_clear_bit(bit, |
| 4519 | &priv->dai[k].ch_mask)) { |
| 4520 | cleared = true; |
| 4521 | if (!priv->dai[k].ch_mask) |
| 4522 | wake_up(&priv->dai[k].dai_wait); |
| 4523 | /* |
| 4524 | * There are cases when multiple DAIs |
| 4525 | * might be using the same slimbus |
| 4526 | * channel. Hence don't break here. |
| 4527 | */ |
| 4528 | } |
| 4529 | } |
| 4530 | WARN(!cleared, |
| 4531 | "Couldn't find slimbus %s port %d for closing\n", |
| 4532 | (tx ? "TX" : "RX"), port_id); |
Kiran Kandi | c3b2440 | 2012-06-11 00:05:59 -0700 | [diff] [blame] | 4533 | } |
| 4534 | wcd9xxx_interface_reg_write(codec->control_data, |
Joonwoo Park | 9bbb4d1 | 2012-11-09 19:58:11 -0800 | [diff] [blame] | 4535 | TAIKO_SLIM_PGD_PORT_INT_CLR_RX_0 + |
| 4536 | (j / 8), |
| 4537 | 1 << (j % 8)); |
Joonwoo Park | a889026 | 2012-10-15 12:04:27 -0700 | [diff] [blame] | 4538 | } |
Joonwoo Park | 9bbb4d1 | 2012-11-09 19:58:11 -0800 | [diff] [blame] | 4539 | |
Kiran Kandi | c3b2440 | 2012-06-11 00:05:59 -0700 | [diff] [blame] | 4540 | return IRQ_HANDLED; |
| 4541 | } |
| 4542 | |
Kiran Kandi | 4c56c59 | 2012-07-25 11:04:55 -0700 | [diff] [blame] | 4543 | static const struct taiko_reg_mask_val taiko_1_0_class_h_ear[] = { |
| 4544 | |
| 4545 | /* CLASS-H EAR IDLE_THRESHOLD Table */ |
| 4546 | TAIKO_REG_VAL(TAIKO_A_CDC_CLSH_IDLE_EAR_THSD, 0x26), |
| 4547 | TAIKO_REG_VAL(TAIKO_A_CDC_CLSH_FCLKONLY_EAR_THSD, 0x2C), |
| 4548 | |
| 4549 | /* CLASS-H EAR I_PA_FACT Table. */ |
| 4550 | TAIKO_REG_VAL(TAIKO_A_CDC_CLSH_I_PA_FACT_EAR_L, 0xA9), |
| 4551 | TAIKO_REG_VAL(TAIKO_A_CDC_CLSH_I_PA_FACT_EAR_U, 0x07), |
| 4552 | |
| 4553 | /* CLASS-H EAR Voltage Headroom , Voltage Min. */ |
| 4554 | TAIKO_REG_VAL(TAIKO_A_CDC_CLSH_V_PA_HD_EAR, 0x0D), |
| 4555 | TAIKO_REG_VAL(TAIKO_A_CDC_CLSH_V_PA_MIN_EAR, 0x3A), |
| 4556 | |
| 4557 | /* CLASS-H EAR K values --chnages from load. */ |
| 4558 | TAIKO_REG_VAL(TAIKO_A_CDC_CLSH_K_ADDR, 0x08), |
| 4559 | TAIKO_REG_VAL(TAIKO_A_CDC_CLSH_K_DATA, 0x1B), |
| 4560 | TAIKO_REG_VAL(TAIKO_A_CDC_CLSH_K_DATA, 0x00), |
| 4561 | TAIKO_REG_VAL(TAIKO_A_CDC_CLSH_K_DATA, 0x2D), |
| 4562 | TAIKO_REG_VAL(TAIKO_A_CDC_CLSH_K_DATA, 0x00), |
| 4563 | TAIKO_REG_VAL(TAIKO_A_CDC_CLSH_K_DATA, 0x36), |
| 4564 | TAIKO_REG_VAL(TAIKO_A_CDC_CLSH_K_DATA, 0x00), |
| 4565 | TAIKO_REG_VAL(TAIKO_A_CDC_CLSH_K_DATA, 0x37), |
| 4566 | TAIKO_REG_VAL(TAIKO_A_CDC_CLSH_K_DATA, 0x00), |
| 4567 | /** end of Ear PA load 32 */ |
| 4568 | }; |
| 4569 | |
Kiran Kandi | 4c56c59 | 2012-07-25 11:04:55 -0700 | [diff] [blame] | 4570 | static const struct taiko_reg_mask_val taiko_1_0_class_h_hph[] = { |
| 4571 | |
| 4572 | /* CLASS-H HPH IDLE_THRESHOLD Table */ |
| 4573 | TAIKO_REG_VAL(TAIKO_A_CDC_CLSH_IDLE_HPH_THSD, 0x13), |
| 4574 | TAIKO_REG_VAL(TAIKO_A_CDC_CLSH_FCLKONLY_HPH_THSD, 0x19), |
| 4575 | |
| 4576 | /* CLASS-H HPH I_PA_FACT Table */ |
| 4577 | TAIKO_REG_VAL(TAIKO_A_CDC_CLSH_I_PA_FACT_HPH_L, 0x9A), |
| 4578 | TAIKO_REG_VAL(TAIKO_A_CDC_CLSH_I_PA_FACT_HPH_U, 0x06), |
| 4579 | |
| 4580 | /* CLASS-H HPH Voltage Headroom , Voltage Min */ |
| 4581 | TAIKO_REG_VAL(TAIKO_A_CDC_CLSH_V_PA_HD_HPH, 0x0D), |
| 4582 | TAIKO_REG_VAL(TAIKO_A_CDC_CLSH_V_PA_MIN_HPH, 0x1D), |
| 4583 | |
| 4584 | /* CLASS-H HPH K values --chnages from load .*/ |
| 4585 | TAIKO_REG_VAL(TAIKO_A_CDC_CLSH_K_ADDR, 0x00), |
| 4586 | TAIKO_REG_VAL(TAIKO_A_CDC_CLSH_K_DATA, 0xAE), |
| 4587 | TAIKO_REG_VAL(TAIKO_A_CDC_CLSH_K_DATA, 0x01), |
| 4588 | TAIKO_REG_VAL(TAIKO_A_CDC_CLSH_K_DATA, 0x1C), |
| 4589 | TAIKO_REG_VAL(TAIKO_A_CDC_CLSH_K_DATA, 0x00), |
| 4590 | TAIKO_REG_VAL(TAIKO_A_CDC_CLSH_K_DATA, 0x25), |
| 4591 | TAIKO_REG_VAL(TAIKO_A_CDC_CLSH_K_DATA, 0x00), |
| 4592 | TAIKO_REG_VAL(TAIKO_A_CDC_CLSH_K_DATA, 0x27), |
| 4593 | TAIKO_REG_VAL(TAIKO_A_CDC_CLSH_K_DATA, 0x00), |
| 4594 | }; |
| 4595 | |
| 4596 | static int taiko_config_ear_class_h(struct snd_soc_codec *codec, u32 ear_load) |
| 4597 | { |
| 4598 | u32 i; |
| 4599 | |
| 4600 | if (ear_load != 32) |
| 4601 | return -EINVAL; |
| 4602 | |
| 4603 | for (i = 0; i < ARRAY_SIZE(taiko_1_0_class_h_ear); i++) |
| 4604 | snd_soc_write(codec, taiko_1_0_class_h_ear[i].reg, |
| 4605 | taiko_1_0_class_h_ear[i].val); |
| 4606 | return 0; |
| 4607 | } |
| 4608 | |
| 4609 | static int taiko_config_hph_class_h(struct snd_soc_codec *codec, u32 hph_load) |
| 4610 | { |
| 4611 | u32 i; |
| 4612 | if (hph_load != 16) |
| 4613 | return -EINVAL; |
| 4614 | |
| 4615 | for (i = 0; i < ARRAY_SIZE(taiko_1_0_class_h_hph); i++) |
| 4616 | snd_soc_write(codec, taiko_1_0_class_h_hph[i].reg, |
| 4617 | taiko_1_0_class_h_hph[i].val); |
| 4618 | return 0; |
| 4619 | } |
| 4620 | |
Kiran Kandi | c3b2440 | 2012-06-11 00:05:59 -0700 | [diff] [blame] | 4621 | static int taiko_handle_pdata(struct taiko_priv *taiko) |
| 4622 | { |
| 4623 | struct snd_soc_codec *codec = taiko->codec; |
Joonwoo Park | a889026 | 2012-10-15 12:04:27 -0700 | [diff] [blame] | 4624 | struct wcd9xxx_pdata *pdata = taiko->resmgr.pdata; |
Kiran Kandi | c3b2440 | 2012-06-11 00:05:59 -0700 | [diff] [blame] | 4625 | int k1, k2, k3, rc = 0; |
Kiran Kandi | 725f849 | 2012-08-06 13:45:16 -0700 | [diff] [blame] | 4626 | u8 leg_mode, txfe_bypass, txfe_buff, flag; |
Kiran Kandi | c3b2440 | 2012-06-11 00:05:59 -0700 | [diff] [blame] | 4627 | u8 i = 0, j = 0; |
| 4628 | u8 val_txfe = 0, value = 0; |
| 4629 | |
| 4630 | if (!pdata) { |
Kiran Kandi | 725f849 | 2012-08-06 13:45:16 -0700 | [diff] [blame] | 4631 | pr_err("%s: NULL pdata\n", __func__); |
Kiran Kandi | c3b2440 | 2012-06-11 00:05:59 -0700 | [diff] [blame] | 4632 | rc = -ENODEV; |
| 4633 | goto done; |
| 4634 | } |
| 4635 | |
Kiran Kandi | 725f849 | 2012-08-06 13:45:16 -0700 | [diff] [blame] | 4636 | leg_mode = pdata->amic_settings.legacy_mode; |
| 4637 | txfe_bypass = pdata->amic_settings.txfe_enable; |
| 4638 | txfe_buff = pdata->amic_settings.txfe_buff; |
| 4639 | flag = pdata->amic_settings.use_pdata; |
| 4640 | |
Kiran Kandi | c3b2440 | 2012-06-11 00:05:59 -0700 | [diff] [blame] | 4641 | /* Make sure settings are correct */ |
Joonwoo Park | a889026 | 2012-10-15 12:04:27 -0700 | [diff] [blame] | 4642 | if ((pdata->micbias.ldoh_v > WCD9XXX_LDOH_3P0_V) || |
| 4643 | (pdata->micbias.bias1_cfilt_sel > WCD9XXX_CFILT3_SEL) || |
| 4644 | (pdata->micbias.bias2_cfilt_sel > WCD9XXX_CFILT3_SEL) || |
| 4645 | (pdata->micbias.bias3_cfilt_sel > WCD9XXX_CFILT3_SEL) || |
| 4646 | (pdata->micbias.bias4_cfilt_sel > WCD9XXX_CFILT3_SEL)) { |
Kiran Kandi | c3b2440 | 2012-06-11 00:05:59 -0700 | [diff] [blame] | 4647 | rc = -EINVAL; |
| 4648 | goto done; |
| 4649 | } |
Kiran Kandi | c3b2440 | 2012-06-11 00:05:59 -0700 | [diff] [blame] | 4650 | /* figure out k value */ |
Joonwoo Park | a889026 | 2012-10-15 12:04:27 -0700 | [diff] [blame] | 4651 | k1 = wcd9xxx_resmgr_get_k_val(&taiko->resmgr, pdata->micbias.cfilt1_mv); |
| 4652 | k2 = wcd9xxx_resmgr_get_k_val(&taiko->resmgr, pdata->micbias.cfilt2_mv); |
| 4653 | k3 = wcd9xxx_resmgr_get_k_val(&taiko->resmgr, pdata->micbias.cfilt3_mv); |
Kiran Kandi | c3b2440 | 2012-06-11 00:05:59 -0700 | [diff] [blame] | 4654 | |
| 4655 | if (IS_ERR_VALUE(k1) || IS_ERR_VALUE(k2) || IS_ERR_VALUE(k3)) { |
| 4656 | rc = -EINVAL; |
| 4657 | goto done; |
| 4658 | } |
Kiran Kandi | c3b2440 | 2012-06-11 00:05:59 -0700 | [diff] [blame] | 4659 | /* Set voltage level and always use LDO */ |
| 4660 | snd_soc_update_bits(codec, TAIKO_A_LDO_H_MODE_1, 0x0C, |
Joonwoo Park | a889026 | 2012-10-15 12:04:27 -0700 | [diff] [blame] | 4661 | (pdata->micbias.ldoh_v << 2)); |
Kiran Kandi | c3b2440 | 2012-06-11 00:05:59 -0700 | [diff] [blame] | 4662 | |
Joonwoo Park | a889026 | 2012-10-15 12:04:27 -0700 | [diff] [blame] | 4663 | snd_soc_update_bits(codec, TAIKO_A_MICB_CFILT_1_VAL, 0xFC, (k1 << 2)); |
| 4664 | snd_soc_update_bits(codec, TAIKO_A_MICB_CFILT_2_VAL, 0xFC, (k2 << 2)); |
| 4665 | snd_soc_update_bits(codec, TAIKO_A_MICB_CFILT_3_VAL, 0xFC, (k3 << 2)); |
Kiran Kandi | c3b2440 | 2012-06-11 00:05:59 -0700 | [diff] [blame] | 4666 | |
| 4667 | snd_soc_update_bits(codec, TAIKO_A_MICB_1_CTL, 0x60, |
Joonwoo Park | a889026 | 2012-10-15 12:04:27 -0700 | [diff] [blame] | 4668 | (pdata->micbias.bias1_cfilt_sel << 5)); |
Kiran Kandi | c3b2440 | 2012-06-11 00:05:59 -0700 | [diff] [blame] | 4669 | snd_soc_update_bits(codec, TAIKO_A_MICB_2_CTL, 0x60, |
Joonwoo Park | a889026 | 2012-10-15 12:04:27 -0700 | [diff] [blame] | 4670 | (pdata->micbias.bias2_cfilt_sel << 5)); |
Kiran Kandi | c3b2440 | 2012-06-11 00:05:59 -0700 | [diff] [blame] | 4671 | snd_soc_update_bits(codec, TAIKO_A_MICB_3_CTL, 0x60, |
Joonwoo Park | a889026 | 2012-10-15 12:04:27 -0700 | [diff] [blame] | 4672 | (pdata->micbias.bias3_cfilt_sel << 5)); |
| 4673 | snd_soc_update_bits(codec, taiko->resmgr.reg_addr->micb_4_ctl, 0x60, |
Kiran Kandi | c3b2440 | 2012-06-11 00:05:59 -0700 | [diff] [blame] | 4674 | (pdata->micbias.bias4_cfilt_sel << 5)); |
| 4675 | |
| 4676 | for (i = 0; i < 6; j++, i += 2) { |
| 4677 | if (flag & (0x01 << i)) { |
| 4678 | value = (leg_mode & (0x01 << i)) ? 0x10 : 0x00; |
| 4679 | val_txfe = (txfe_bypass & (0x01 << i)) ? 0x20 : 0x00; |
| 4680 | val_txfe = val_txfe | |
| 4681 | ((txfe_buff & (0x01 << i)) ? 0x10 : 0x00); |
| 4682 | snd_soc_update_bits(codec, TAIKO_A_TX_1_2_EN + j * 10, |
| 4683 | 0x10, value); |
| 4684 | snd_soc_update_bits(codec, |
| 4685 | TAIKO_A_TX_1_2_TEST_EN + j * 10, |
| 4686 | 0x30, val_txfe); |
| 4687 | } |
| 4688 | if (flag & (0x01 << (i + 1))) { |
| 4689 | value = (leg_mode & (0x01 << (i + 1))) ? 0x01 : 0x00; |
| 4690 | val_txfe = (txfe_bypass & |
| 4691 | (0x01 << (i + 1))) ? 0x02 : 0x00; |
| 4692 | val_txfe |= (txfe_buff & |
| 4693 | (0x01 << (i + 1))) ? 0x01 : 0x00; |
| 4694 | snd_soc_update_bits(codec, TAIKO_A_TX_1_2_EN + j * 10, |
| 4695 | 0x01, value); |
| 4696 | snd_soc_update_bits(codec, |
| 4697 | TAIKO_A_TX_1_2_TEST_EN + j * 10, |
| 4698 | 0x03, val_txfe); |
| 4699 | } |
| 4700 | } |
| 4701 | if (flag & 0x40) { |
| 4702 | value = (leg_mode & 0x40) ? 0x10 : 0x00; |
| 4703 | value = value | ((txfe_bypass & 0x40) ? 0x02 : 0x00); |
| 4704 | value = value | ((txfe_buff & 0x40) ? 0x01 : 0x00); |
| 4705 | snd_soc_update_bits(codec, TAIKO_A_TX_7_MBHC_EN, |
| 4706 | 0x13, value); |
| 4707 | } |
| 4708 | |
| 4709 | if (pdata->ocp.use_pdata) { |
| 4710 | /* not defined in CODEC specification */ |
| 4711 | if (pdata->ocp.hph_ocp_limit == 1 || |
| 4712 | pdata->ocp.hph_ocp_limit == 5) { |
| 4713 | rc = -EINVAL; |
| 4714 | goto done; |
| 4715 | } |
| 4716 | snd_soc_update_bits(codec, TAIKO_A_RX_COM_OCP_CTL, |
| 4717 | 0x0F, pdata->ocp.num_attempts); |
| 4718 | snd_soc_write(codec, TAIKO_A_RX_COM_OCP_COUNT, |
| 4719 | ((pdata->ocp.run_time << 4) | pdata->ocp.wait_time)); |
| 4720 | snd_soc_update_bits(codec, TAIKO_A_RX_HPH_OCP_CTL, |
| 4721 | 0xE0, (pdata->ocp.hph_ocp_limit << 5)); |
| 4722 | } |
| 4723 | |
| 4724 | for (i = 0; i < ARRAY_SIZE(pdata->regulator); i++) { |
| 4725 | if (!strncmp(pdata->regulator[i].name, "CDC_VDDA_RX", 11)) { |
| 4726 | if (pdata->regulator[i].min_uV == 1800000 && |
| 4727 | pdata->regulator[i].max_uV == 1800000) { |
| 4728 | snd_soc_write(codec, TAIKO_A_BIAS_REF_CTL, |
| 4729 | 0x1C); |
| 4730 | } else if (pdata->regulator[i].min_uV == 2200000 && |
| 4731 | pdata->regulator[i].max_uV == 2200000) { |
| 4732 | snd_soc_write(codec, TAIKO_A_BIAS_REF_CTL, |
| 4733 | 0x1E); |
| 4734 | } else { |
| 4735 | pr_err("%s: unsupported CDC_VDDA_RX voltage\n" |
| 4736 | "min %d, max %d\n", __func__, |
| 4737 | pdata->regulator[i].min_uV, |
| 4738 | pdata->regulator[i].max_uV); |
| 4739 | rc = -EINVAL; |
| 4740 | } |
| 4741 | break; |
| 4742 | } |
| 4743 | } |
Kiran Kandi | 4c56c59 | 2012-07-25 11:04:55 -0700 | [diff] [blame] | 4744 | |
Joonwoo Park | 1848c76 | 2012-10-18 13:16:01 -0700 | [diff] [blame] | 4745 | /* Set micbias capless mode with tail current */ |
| 4746 | value = (pdata->micbias.bias1_cap_mode == MICBIAS_EXT_BYP_CAP ? |
| 4747 | 0x00 : 0x16); |
| 4748 | snd_soc_update_bits(codec, TAIKO_A_MICB_1_CTL, 0x1E, value); |
| 4749 | value = (pdata->micbias.bias2_cap_mode == MICBIAS_EXT_BYP_CAP ? |
| 4750 | 0x00 : 0x16); |
| 4751 | snd_soc_update_bits(codec, TAIKO_A_MICB_2_CTL, 0x1E, value); |
| 4752 | value = (pdata->micbias.bias3_cap_mode == MICBIAS_EXT_BYP_CAP ? |
| 4753 | 0x00 : 0x16); |
| 4754 | snd_soc_update_bits(codec, TAIKO_A_MICB_3_CTL, 0x1E, value); |
| 4755 | value = (pdata->micbias.bias4_cap_mode == MICBIAS_EXT_BYP_CAP ? |
| 4756 | 0x00 : 0x16); |
| 4757 | snd_soc_update_bits(codec, TAIKO_A_MICB_4_CTL, 0x1E, value); |
| 4758 | |
Kiran Kandi | 4c56c59 | 2012-07-25 11:04:55 -0700 | [diff] [blame] | 4759 | taiko_config_ear_class_h(codec, 32); |
| 4760 | taiko_config_hph_class_h(codec, 16); |
| 4761 | |
Kiran Kandi | c3b2440 | 2012-06-11 00:05:59 -0700 | [diff] [blame] | 4762 | done: |
| 4763 | return rc; |
| 4764 | } |
| 4765 | |
Kiran Kandi | 7b7d2ff | 2012-09-14 14:52:14 -0700 | [diff] [blame] | 4766 | static const struct taiko_reg_mask_val taiko_reg_defaults[] = { |
Kiran Kandi | c3b2440 | 2012-06-11 00:05:59 -0700 | [diff] [blame] | 4767 | |
Kiran Kandi | 4c56c59 | 2012-07-25 11:04:55 -0700 | [diff] [blame] | 4768 | /* set MCLk to 9.6 */ |
Gopikrishnaiah Anandan | a8aec1f | 2013-01-23 14:26:27 -0500 | [diff] [blame] | 4769 | TAIKO_REG_VAL(TAIKO_A_CHIP_CTL, 0x02), |
Kiran Kandi | 4c56c59 | 2012-07-25 11:04:55 -0700 | [diff] [blame] | 4770 | TAIKO_REG_VAL(TAIKO_A_CDC_CLK_POWER_CTL, 0x03), |
Kiran Kandi | c3b2440 | 2012-06-11 00:05:59 -0700 | [diff] [blame] | 4771 | |
Kiran Kandi | 4c56c59 | 2012-07-25 11:04:55 -0700 | [diff] [blame] | 4772 | /* EAR PA deafults */ |
| 4773 | TAIKO_REG_VAL(TAIKO_A_RX_EAR_CMBUFF, 0x05), |
Kiran Kandi | c3b2440 | 2012-06-11 00:05:59 -0700 | [diff] [blame] | 4774 | |
Joonwoo Park | 559a5bf | 2013-02-15 14:46:36 -0800 | [diff] [blame] | 4775 | /* BUCK and NCP defaults for EAR and HS */ |
Kiran Kandi | 4c56c59 | 2012-07-25 11:04:55 -0700 | [diff] [blame] | 4776 | TAIKO_REG_VAL(TAIKO_A_BUCK_CTRL_CCL_1, 0x5B), |
Kiran Kandi | 4c56c59 | 2012-07-25 11:04:55 -0700 | [diff] [blame] | 4777 | |
| 4778 | /* CLASS-H defaults for EAR and HS */ |
| 4779 | TAIKO_REG_VAL(TAIKO_A_CDC_CLSH_BUCK_NCP_VARS, 0x00), |
| 4780 | TAIKO_REG_VAL(TAIKO_A_CDC_CLSH_BUCK_NCP_VARS, 0x04), |
| 4781 | TAIKO_REG_VAL(TAIKO_A_CDC_CLSH_B2_CTL, 0x01), |
| 4782 | TAIKO_REG_VAL(TAIKO_A_CDC_CLSH_B2_CTL, 0x05), |
| 4783 | TAIKO_REG_VAL(TAIKO_A_CDC_CLSH_B2_CTL, 0x35), |
| 4784 | TAIKO_REG_VAL(TAIKO_A_CDC_CLSH_B3_CTL, 0x30), |
| 4785 | TAIKO_REG_VAL(TAIKO_A_CDC_CLSH_B3_CTL, 0x3B), |
| 4786 | |
| 4787 | /* |
| 4788 | * For CLASS-H, Enable ANC delay buffer, |
| 4789 | * set HPHL and EAR PA ref gain to 0 DB. |
| 4790 | */ |
| 4791 | TAIKO_REG_VAL(TAIKO_A_CDC_CLSH_B1_CTL, 0x26), |
Kiran Kandi | c3b2440 | 2012-06-11 00:05:59 -0700 | [diff] [blame] | 4792 | |
Kiran Kandi | 4c56c59 | 2012-07-25 11:04:55 -0700 | [diff] [blame] | 4793 | /* RX deafults */ |
Kiran Kandi | c3b2440 | 2012-06-11 00:05:59 -0700 | [diff] [blame] | 4794 | TAIKO_REG_VAL(TAIKO_A_CDC_RX1_B5_CTL, 0x78), |
| 4795 | TAIKO_REG_VAL(TAIKO_A_CDC_RX2_B5_CTL, 0x78), |
| 4796 | TAIKO_REG_VAL(TAIKO_A_CDC_RX3_B5_CTL, 0x78), |
| 4797 | TAIKO_REG_VAL(TAIKO_A_CDC_RX4_B5_CTL, 0x78), |
| 4798 | TAIKO_REG_VAL(TAIKO_A_CDC_RX5_B5_CTL, 0x78), |
| 4799 | TAIKO_REG_VAL(TAIKO_A_CDC_RX6_B5_CTL, 0x78), |
| 4800 | TAIKO_REG_VAL(TAIKO_A_CDC_RX7_B5_CTL, 0x78), |
| 4801 | |
Kiran Kandi | 4c56c59 | 2012-07-25 11:04:55 -0700 | [diff] [blame] | 4802 | /* RX1 and RX2 defaults */ |
Kiran Kandi | c3b2440 | 2012-06-11 00:05:59 -0700 | [diff] [blame] | 4803 | TAIKO_REG_VAL(TAIKO_A_CDC_RX1_B6_CTL, 0xA0), |
| 4804 | TAIKO_REG_VAL(TAIKO_A_CDC_RX2_B6_CTL, 0xA0), |
| 4805 | |
Kiran Kandi | 4c56c59 | 2012-07-25 11:04:55 -0700 | [diff] [blame] | 4806 | /* RX3 to RX7 defaults */ |
Kiran Kandi | c3b2440 | 2012-06-11 00:05:59 -0700 | [diff] [blame] | 4807 | TAIKO_REG_VAL(TAIKO_A_CDC_RX3_B6_CTL, 0x80), |
| 4808 | TAIKO_REG_VAL(TAIKO_A_CDC_RX4_B6_CTL, 0x80), |
| 4809 | TAIKO_REG_VAL(TAIKO_A_CDC_RX5_B6_CTL, 0x80), |
| 4810 | TAIKO_REG_VAL(TAIKO_A_CDC_RX6_B6_CTL, 0x80), |
| 4811 | TAIKO_REG_VAL(TAIKO_A_CDC_RX7_B6_CTL, 0x80), |
Kiran Kandi | c3b2440 | 2012-06-11 00:05:59 -0700 | [diff] [blame] | 4812 | }; |
| 4813 | |
Kiran Kandi | 7b7d2ff | 2012-09-14 14:52:14 -0700 | [diff] [blame] | 4814 | static const struct taiko_reg_mask_val taiko_1_0_reg_defaults[] = { |
| 4815 | /* |
| 4816 | * The following only need to be written for Taiko 1.0 parts. |
| 4817 | * Taiko 2.0 will have appropriate defaults for these registers. |
| 4818 | */ |
Joonwoo Park | 559a5bf | 2013-02-15 14:46:36 -0800 | [diff] [blame] | 4819 | |
| 4820 | /* BUCK default */ |
| 4821 | TAIKO_REG_VAL(TAIKO_A_BUCK_CTRL_CCL_4, 0x50), |
| 4822 | |
Kiran Kandi | 7b7d2ff | 2012-09-14 14:52:14 -0700 | [diff] [blame] | 4823 | /* Choose max non-overlap time for NCP */ |
| 4824 | TAIKO_REG_VAL(TAIKO_A_NCP_CLK, 0xFC), |
| 4825 | /* Use 25mV/50mV for deltap/m to reduce ripple */ |
| 4826 | TAIKO_REG_VAL(TAIKO_A_BUCK_CTRL_VCL_1, 0x08), |
| 4827 | /* |
| 4828 | * Set DISABLE_MODE_SEL<1:0> to 0b10 (disable PWM in auto mode). |
| 4829 | * Note that the other bits of this register will be changed during |
| 4830 | * Rx PA bring up. |
| 4831 | */ |
| 4832 | TAIKO_REG_VAL(TAIKO_A_BUCK_MODE_3, 0xCE), |
| 4833 | /* Reduce HPH DAC bias to 70% */ |
| 4834 | TAIKO_REG_VAL(TAIKO_A_RX_HPH_BIAS_PA, 0x7A), |
| 4835 | /*Reduce EAR DAC bias to 70% */ |
| 4836 | TAIKO_REG_VAL(TAIKO_A_RX_EAR_BIAS_PA, 0x76), |
| 4837 | /* Reduce LINE DAC bias to 70% */ |
| 4838 | TAIKO_REG_VAL(TAIKO_A_RX_LINE_BIAS_PA, 0x78), |
Joonwoo Park | d87ec4c | 2012-10-30 15:44:18 -0700 | [diff] [blame] | 4839 | |
| 4840 | /* |
| 4841 | * There is a diode to pull down the micbias while doing |
| 4842 | * insertion detection. This diode can cause leakage. |
| 4843 | * Set bit 0 to 1 to prevent leakage. |
| 4844 | * Setting this bit of micbias 2 prevents leakage for all other micbias. |
| 4845 | */ |
| 4846 | TAIKO_REG_VAL(TAIKO_A_MICB_2_MBHC, 0x41), |
Joonwoo Park | 3c7bca6 | 2012-10-31 12:44:23 -0700 | [diff] [blame] | 4847 | |
| 4848 | /* Disable TX7 internal biasing path which can cause leakage */ |
| 4849 | TAIKO_REG_VAL(TAIKO_A_TX_SUP_SWITCH_CTRL_1, 0xBF), |
Joonwoo Park | 0360405 | 2012-11-06 18:40:25 -0800 | [diff] [blame] | 4850 | /* Enable MICB 4 VDDIO switch to prevent leakage */ |
| 4851 | TAIKO_REG_VAL(TAIKO_A_MICB_4_MBHC, 0x81), |
Joonwoo Park | 125cd4e | 2012-12-11 15:16:11 -0800 | [diff] [blame] | 4852 | |
| 4853 | /* Close leakage on the spkdrv */ |
| 4854 | TAIKO_REG_VAL(TAIKO_A_SPKR_DRV_DBG_PWRSTG, 0x24), |
Kiran Kandi | 7b7d2ff | 2012-09-14 14:52:14 -0700 | [diff] [blame] | 4855 | }; |
| 4856 | |
Joonwoo Park | 559a5bf | 2013-02-15 14:46:36 -0800 | [diff] [blame] | 4857 | /* |
| 4858 | * Don't update TAIKO_A_CHIP_CTL, TAIKO_A_BUCK_CTRL_CCL_1 and |
| 4859 | * TAIKO_A_RX_EAR_CMBUFF as those are updated in taiko_reg_defaults |
| 4860 | */ |
| 4861 | static const struct taiko_reg_mask_val taiko_2_0_reg_defaults[] = { |
| 4862 | TAIKO_REG_VAL(TAIKO_A_CDC_TX_1_GAIN, 0x2), |
| 4863 | TAIKO_REG_VAL(TAIKO_A_CDC_TX_2_GAIN, 0x2), |
| 4864 | TAIKO_REG_VAL(TAIKO_A_CDC_TX_1_2_ADC_IB, 0x44), |
| 4865 | TAIKO_REG_VAL(TAIKO_A_CDC_TX_3_GAIN, 0x2), |
| 4866 | TAIKO_REG_VAL(TAIKO_A_CDC_TX_4_GAIN, 0x2), |
| 4867 | TAIKO_REG_VAL(TAIKO_A_CDC_TX_3_4_ADC_IB, 0x44), |
| 4868 | TAIKO_REG_VAL(TAIKO_A_CDC_TX_5_GAIN, 0x2), |
| 4869 | TAIKO_REG_VAL(TAIKO_A_CDC_TX_6_GAIN, 0x2), |
| 4870 | TAIKO_REG_VAL(TAIKO_A_CDC_TX_5_6_ADC_IB, 0x44), |
| 4871 | TAIKO_REG_VAL(TAIKO_A_BUCK_MODE_3, 0xCE), |
| 4872 | TAIKO_REG_VAL(TAIKO_A_BUCK_CTRL_VCL_1, 0x8), |
| 4873 | TAIKO_REG_VAL(TAIKO_A_BUCK_CTRL_CCL_4, 0x51), |
| 4874 | TAIKO_REG_VAL(TAIKO_A_NCP_DTEST, 0x10), |
| 4875 | TAIKO_REG_VAL(TAIKO_A_RX_HPH_CHOP_CTL, 0xA4), |
| 4876 | TAIKO_REG_VAL(TAIKO_A_RX_HPH_BIAS_PA, 0x7A), |
| 4877 | TAIKO_REG_VAL(TAIKO_A_RX_HPH_OCP_CTL, 0x69), |
| 4878 | TAIKO_REG_VAL(TAIKO_A_RX_HPH_CNP_WG_CTL, 0xDA), |
| 4879 | TAIKO_REG_VAL(TAIKO_A_RX_HPH_CNP_WG_TIME, 0x15), |
| 4880 | TAIKO_REG_VAL(TAIKO_A_RX_EAR_BIAS_PA, 0x76), |
| 4881 | TAIKO_REG_VAL(TAIKO_A_RX_EAR_CNP, 0xC0), |
| 4882 | TAIKO_REG_VAL(TAIKO_A_RX_LINE_BIAS_PA, 0x78), |
| 4883 | TAIKO_REG_VAL(TAIKO_A_RX_LINE_1_TEST, 0x2), |
| 4884 | TAIKO_REG_VAL(TAIKO_A_RX_LINE_2_TEST, 0x2), |
| 4885 | TAIKO_REG_VAL(TAIKO_A_RX_LINE_3_TEST, 0x2), |
| 4886 | TAIKO_REG_VAL(TAIKO_A_RX_LINE_4_TEST, 0x2), |
| 4887 | TAIKO_REG_VAL(TAIKO_A_SPKR_DRV_OCP_CTL, 0x97), |
| 4888 | TAIKO_REG_VAL(TAIKO_A_SPKR_DRV_CLIP_DET, 0x1), |
| 4889 | TAIKO_REG_VAL(TAIKO_A_SPKR_DRV_IEC, 0x0), |
| 4890 | TAIKO_REG_VAL(TAIKO_A_CDC_TX1_MUX_CTL, 0x48), |
| 4891 | TAIKO_REG_VAL(TAIKO_A_CDC_TX2_MUX_CTL, 0x48), |
| 4892 | TAIKO_REG_VAL(TAIKO_A_CDC_TX3_MUX_CTL, 0x48), |
| 4893 | TAIKO_REG_VAL(TAIKO_A_CDC_TX4_MUX_CTL, 0x48), |
| 4894 | TAIKO_REG_VAL(TAIKO_A_CDC_TX5_MUX_CTL, 0x48), |
| 4895 | TAIKO_REG_VAL(TAIKO_A_CDC_TX6_MUX_CTL, 0x48), |
| 4896 | TAIKO_REG_VAL(TAIKO_A_CDC_TX7_MUX_CTL, 0x48), |
| 4897 | TAIKO_REG_VAL(TAIKO_A_CDC_TX8_MUX_CTL, 0x48), |
| 4898 | TAIKO_REG_VAL(TAIKO_A_CDC_TX9_MUX_CTL, 0x48), |
| 4899 | TAIKO_REG_VAL(TAIKO_A_CDC_TX10_MUX_CTL, 0x48), |
| 4900 | TAIKO_REG_VAL(TAIKO_A_CDC_RX1_B4_CTL, 0x8), |
| 4901 | TAIKO_REG_VAL(TAIKO_A_CDC_VBAT_GAIN_UPD_MON, 0x0), |
| 4902 | TAIKO_REG_VAL(TAIKO_A_CDC_PA_RAMP_B1_CTL, 0x0), |
| 4903 | TAIKO_REG_VAL(TAIKO_A_CDC_PA_RAMP_B2_CTL, 0x0), |
| 4904 | TAIKO_REG_VAL(TAIKO_A_CDC_PA_RAMP_B3_CTL, 0x0), |
| 4905 | TAIKO_REG_VAL(TAIKO_A_CDC_PA_RAMP_B4_CTL, 0x0), |
| 4906 | TAIKO_REG_VAL(TAIKO_A_CDC_SPKR_CLIPDET_B1_CTL, 0x0), |
| 4907 | TAIKO_REG_VAL(TAIKO_A_CDC_COMP0_B4_CTL, 0x37), |
| 4908 | TAIKO_REG_VAL(TAIKO_A_CDC_COMP0_B5_CTL, 0x7f), |
| 4909 | }; |
| 4910 | |
Kiran Kandi | c3b2440 | 2012-06-11 00:05:59 -0700 | [diff] [blame] | 4911 | static void taiko_update_reg_defaults(struct snd_soc_codec *codec) |
| 4912 | { |
| 4913 | u32 i; |
Kiran Kandi | 7b7d2ff | 2012-09-14 14:52:14 -0700 | [diff] [blame] | 4914 | struct wcd9xxx *taiko_core = dev_get_drvdata(codec->dev->parent); |
Kiran Kandi | c3b2440 | 2012-06-11 00:05:59 -0700 | [diff] [blame] | 4915 | |
Kiran Kandi | 7b7d2ff | 2012-09-14 14:52:14 -0700 | [diff] [blame] | 4916 | for (i = 0; i < ARRAY_SIZE(taiko_reg_defaults); i++) |
| 4917 | snd_soc_write(codec, taiko_reg_defaults[i].reg, |
Joonwoo Park | 559a5bf | 2013-02-15 14:46:36 -0800 | [diff] [blame] | 4918 | taiko_reg_defaults[i].val); |
Kiran Kandi | 7b7d2ff | 2012-09-14 14:52:14 -0700 | [diff] [blame] | 4919 | |
| 4920 | if (TAIKO_IS_1_0(taiko_core->version)) { |
| 4921 | for (i = 0; i < ARRAY_SIZE(taiko_1_0_reg_defaults); i++) |
| 4922 | snd_soc_write(codec, taiko_1_0_reg_defaults[i].reg, |
Joonwoo Park | 559a5bf | 2013-02-15 14:46:36 -0800 | [diff] [blame] | 4923 | taiko_1_0_reg_defaults[i].val); |
| 4924 | if (spkr_drv_wrnd == 1) |
| 4925 | snd_soc_write(codec, TAIKO_A_SPKR_DRV_EN, 0xEF); |
| 4926 | } else { |
| 4927 | for (i = 0; i < ARRAY_SIZE(taiko_2_0_reg_defaults); i++) |
| 4928 | snd_soc_write(codec, taiko_2_0_reg_defaults[i].reg, |
| 4929 | taiko_2_0_reg_defaults[i].val); |
Joonwoo Park | 125cd4e | 2012-12-11 15:16:11 -0800 | [diff] [blame] | 4930 | spkr_drv_wrnd = -1; |
Joonwoo Park | 559a5bf | 2013-02-15 14:46:36 -0800 | [diff] [blame] | 4931 | } |
Kiran Kandi | c3b2440 | 2012-06-11 00:05:59 -0700 | [diff] [blame] | 4932 | } |
| 4933 | |
| 4934 | static const struct taiko_reg_mask_val taiko_codec_reg_init_val[] = { |
| 4935 | /* Initialize current threshold to 350MA |
| 4936 | * number of wait and run cycles to 4096 |
| 4937 | */ |
Kiran Kandi | 7b7d2ff | 2012-09-14 14:52:14 -0700 | [diff] [blame] | 4938 | {TAIKO_A_RX_HPH_OCP_CTL, 0xE1, 0x61}, |
Kiran Kandi | c3b2440 | 2012-06-11 00:05:59 -0700 | [diff] [blame] | 4939 | {TAIKO_A_RX_COM_OCP_COUNT, 0xFF, 0xFF}, |
Patrick Lai | 92833bf | 2012-12-01 10:31:35 -0800 | [diff] [blame] | 4940 | {TAIKO_A_RX_HPH_L_TEST, 0x01, 0x01}, |
| 4941 | {TAIKO_A_RX_HPH_R_TEST, 0x01, 0x01}, |
Kiran Kandi | c3b2440 | 2012-06-11 00:05:59 -0700 | [diff] [blame] | 4942 | |
Kiran Kandi | c3b2440 | 2012-06-11 00:05:59 -0700 | [diff] [blame] | 4943 | /* Initialize gain registers to use register gain */ |
Kiran Kandi | 4c56c59 | 2012-07-25 11:04:55 -0700 | [diff] [blame] | 4944 | {TAIKO_A_RX_HPH_L_GAIN, 0x20, 0x20}, |
| 4945 | {TAIKO_A_RX_HPH_R_GAIN, 0x20, 0x20}, |
| 4946 | {TAIKO_A_RX_LINE_1_GAIN, 0x20, 0x20}, |
| 4947 | {TAIKO_A_RX_LINE_2_GAIN, 0x20, 0x20}, |
| 4948 | {TAIKO_A_RX_LINE_3_GAIN, 0x20, 0x20}, |
| 4949 | {TAIKO_A_RX_LINE_4_GAIN, 0x20, 0x20}, |
Joonwoo Park | c773143 | 2012-10-17 12:41:44 -0700 | [diff] [blame] | 4950 | {TAIKO_A_SPKR_DRV_GAIN, 0x04, 0x04}, |
Kiran Kandi | c3b2440 | 2012-06-11 00:05:59 -0700 | [diff] [blame] | 4951 | |
Kiran Kandi | 4c56c59 | 2012-07-25 11:04:55 -0700 | [diff] [blame] | 4952 | /* CLASS H config */ |
| 4953 | {TAIKO_A_CDC_CONN_CLSH_CTL, 0x3C, 0x14}, |
Kiran Kandi | c3b2440 | 2012-06-11 00:05:59 -0700 | [diff] [blame] | 4954 | |
| 4955 | /* Use 16 bit sample size for TX1 to TX6 */ |
| 4956 | {TAIKO_A_CDC_CONN_TX_SB_B1_CTL, 0x30, 0x20}, |
| 4957 | {TAIKO_A_CDC_CONN_TX_SB_B2_CTL, 0x30, 0x20}, |
| 4958 | {TAIKO_A_CDC_CONN_TX_SB_B3_CTL, 0x30, 0x20}, |
| 4959 | {TAIKO_A_CDC_CONN_TX_SB_B4_CTL, 0x30, 0x20}, |
| 4960 | {TAIKO_A_CDC_CONN_TX_SB_B5_CTL, 0x30, 0x20}, |
| 4961 | {TAIKO_A_CDC_CONN_TX_SB_B6_CTL, 0x30, 0x20}, |
| 4962 | |
| 4963 | /* Use 16 bit sample size for TX7 to TX10 */ |
| 4964 | {TAIKO_A_CDC_CONN_TX_SB_B7_CTL, 0x60, 0x40}, |
| 4965 | {TAIKO_A_CDC_CONN_TX_SB_B8_CTL, 0x60, 0x40}, |
| 4966 | {TAIKO_A_CDC_CONN_TX_SB_B9_CTL, 0x60, 0x40}, |
| 4967 | {TAIKO_A_CDC_CONN_TX_SB_B10_CTL, 0x60, 0x40}, |
| 4968 | |
| 4969 | /* Use 16 bit sample size for RX */ |
| 4970 | {TAIKO_A_CDC_CONN_RX_SB_B1_CTL, 0xFF, 0xAA}, |
Kiran Kandi | 7b7d2ff | 2012-09-14 14:52:14 -0700 | [diff] [blame] | 4971 | {TAIKO_A_CDC_CONN_RX_SB_B2_CTL, 0xFF, 0x2A}, |
Kiran Kandi | c3b2440 | 2012-06-11 00:05:59 -0700 | [diff] [blame] | 4972 | |
| 4973 | /*enable HPF filter for TX paths */ |
| 4974 | {TAIKO_A_CDC_TX1_MUX_CTL, 0x8, 0x0}, |
| 4975 | {TAIKO_A_CDC_TX2_MUX_CTL, 0x8, 0x0}, |
| 4976 | {TAIKO_A_CDC_TX3_MUX_CTL, 0x8, 0x0}, |
| 4977 | {TAIKO_A_CDC_TX4_MUX_CTL, 0x8, 0x0}, |
| 4978 | {TAIKO_A_CDC_TX5_MUX_CTL, 0x8, 0x0}, |
| 4979 | {TAIKO_A_CDC_TX6_MUX_CTL, 0x8, 0x0}, |
| 4980 | {TAIKO_A_CDC_TX7_MUX_CTL, 0x8, 0x0}, |
| 4981 | {TAIKO_A_CDC_TX8_MUX_CTL, 0x8, 0x0}, |
| 4982 | {TAIKO_A_CDC_TX9_MUX_CTL, 0x8, 0x0}, |
| 4983 | {TAIKO_A_CDC_TX10_MUX_CTL, 0x8, 0x0}, |
| 4984 | |
Kiran Kandi | 4c56c59 | 2012-07-25 11:04:55 -0700 | [diff] [blame] | 4985 | /* config Decimator for DMIC CLK_MODE_1(3.2Mhz@9.6Mhz mclk) */ |
| 4986 | {TAIKO_A_CDC_TX1_DMIC_CTL, 0x7, 0x1}, |
| 4987 | {TAIKO_A_CDC_TX2_DMIC_CTL, 0x7, 0x1}, |
| 4988 | {TAIKO_A_CDC_TX3_DMIC_CTL, 0x7, 0x1}, |
| 4989 | {TAIKO_A_CDC_TX4_DMIC_CTL, 0x7, 0x1}, |
| 4990 | {TAIKO_A_CDC_TX5_DMIC_CTL, 0x7, 0x1}, |
| 4991 | {TAIKO_A_CDC_TX6_DMIC_CTL, 0x7, 0x1}, |
| 4992 | {TAIKO_A_CDC_TX7_DMIC_CTL, 0x7, 0x1}, |
| 4993 | {TAIKO_A_CDC_TX8_DMIC_CTL, 0x7, 0x1}, |
| 4994 | {TAIKO_A_CDC_TX9_DMIC_CTL, 0x7, 0x1}, |
| 4995 | {TAIKO_A_CDC_TX10_DMIC_CTL, 0x7, 0x1}, |
Kiran Kandi | c3b2440 | 2012-06-11 00:05:59 -0700 | [diff] [blame] | 4996 | |
Kiran Kandi | 4c56c59 | 2012-07-25 11:04:55 -0700 | [diff] [blame] | 4997 | /* config DMIC clk to CLK_MODE_1 (3.2Mhz@9.6Mhz mclk) */ |
| 4998 | {TAIKO_A_CDC_CLK_DMIC_B1_CTL, 0xEE, 0x22}, |
| 4999 | {TAIKO_A_CDC_CLK_DMIC_B2_CTL, 0x0E, 0x02}, |
| 5000 | |
Joonwoo Park | c773143 | 2012-10-17 12:41:44 -0700 | [diff] [blame] | 5001 | /* Compander zone selection */ |
| 5002 | {TAIKO_A_CDC_COMP0_B4_CTL, 0x3F, 0x37}, |
| 5003 | {TAIKO_A_CDC_COMP1_B4_CTL, 0x3F, 0x37}, |
| 5004 | {TAIKO_A_CDC_COMP2_B4_CTL, 0x3F, 0x37}, |
| 5005 | {TAIKO_A_CDC_COMP0_B5_CTL, 0x7F, 0x7F}, |
| 5006 | {TAIKO_A_CDC_COMP1_B5_CTL, 0x7F, 0x7F}, |
| 5007 | {TAIKO_A_CDC_COMP2_B5_CTL, 0x7F, 0x7F}, |
Kiran Kandi | c3b2440 | 2012-06-11 00:05:59 -0700 | [diff] [blame] | 5008 | }; |
| 5009 | |
| 5010 | static void taiko_codec_init_reg(struct snd_soc_codec *codec) |
| 5011 | { |
| 5012 | u32 i; |
| 5013 | |
| 5014 | for (i = 0; i < ARRAY_SIZE(taiko_codec_reg_init_val); i++) |
| 5015 | snd_soc_update_bits(codec, taiko_codec_reg_init_val[i].reg, |
| 5016 | taiko_codec_reg_init_val[i].mask, |
| 5017 | taiko_codec_reg_init_val[i].val); |
| 5018 | } |
| 5019 | |
Joonwoo Park | 7680b9f | 2012-07-13 11:36:48 -0700 | [diff] [blame] | 5020 | static int taiko_setup_irqs(struct taiko_priv *taiko) |
| 5021 | { |
Joonwoo Park | 7680b9f | 2012-07-13 11:36:48 -0700 | [diff] [blame] | 5022 | int i; |
Joonwoo Park | a889026 | 2012-10-15 12:04:27 -0700 | [diff] [blame] | 5023 | int ret = 0; |
Joonwoo Park | 7680b9f | 2012-07-13 11:36:48 -0700 | [diff] [blame] | 5024 | struct snd_soc_codec *codec = taiko->codec; |
| 5025 | |
Joonwoo Park | f6574c7 | 2012-10-10 17:29:57 -0700 | [diff] [blame] | 5026 | ret = wcd9xxx_request_irq(codec->control_data, WCD9XXX_IRQ_SLIMBUS, |
Joonwoo Park | 7680b9f | 2012-07-13 11:36:48 -0700 | [diff] [blame] | 5027 | taiko_slimbus_irq, "SLIMBUS Slave", taiko); |
| 5028 | if (ret) { |
| 5029 | pr_err("%s: Failed to request irq %d\n", __func__, |
Joonwoo Park | f6574c7 | 2012-10-10 17:29:57 -0700 | [diff] [blame] | 5030 | WCD9XXX_IRQ_SLIMBUS); |
Joonwoo Park | a889026 | 2012-10-15 12:04:27 -0700 | [diff] [blame] | 5031 | goto exit; |
Joonwoo Park | 7680b9f | 2012-07-13 11:36:48 -0700 | [diff] [blame] | 5032 | } |
| 5033 | |
| 5034 | for (i = 0; i < WCD9XXX_SLIM_NUM_PORT_REG; i++) |
| 5035 | wcd9xxx_interface_reg_write(codec->control_data, |
Joonwoo Park | a889026 | 2012-10-15 12:04:27 -0700 | [diff] [blame] | 5036 | TAIKO_SLIM_PGD_PORT_INT_EN0 + i, |
| 5037 | 0xFF); |
| 5038 | exit: |
Joonwoo Park | 7680b9f | 2012-07-13 11:36:48 -0700 | [diff] [blame] | 5039 | return ret; |
| 5040 | } |
| 5041 | |
Joonwoo Park | a889026 | 2012-10-15 12:04:27 -0700 | [diff] [blame] | 5042 | int taiko_hs_detect(struct snd_soc_codec *codec, |
| 5043 | struct wcd9xxx_mbhc_config *mbhc_cfg) |
| 5044 | { |
| 5045 | struct taiko_priv *taiko = snd_soc_codec_get_drvdata(codec); |
| 5046 | return wcd9xxx_mbhc_start(&taiko->mbhc, mbhc_cfg); |
| 5047 | } |
| 5048 | EXPORT_SYMBOL_GPL(taiko_hs_detect); |
| 5049 | |
Ravishankar Sarawadi | 839fcf3 | 2012-11-14 12:13:00 -0800 | [diff] [blame] | 5050 | static int taiko_post_reset_cb(struct wcd9xxx *wcd9xxx) |
| 5051 | { |
| 5052 | int ret = 0; |
| 5053 | struct snd_soc_codec *codec; |
| 5054 | struct taiko_priv *taiko; |
| 5055 | |
| 5056 | codec = (struct snd_soc_codec *)(wcd9xxx->ssr_priv); |
| 5057 | taiko = snd_soc_codec_get_drvdata(codec); |
| 5058 | mutex_lock(&codec->mutex); |
| 5059 | WCD9XXX_BCL_LOCK(&taiko->resmgr); |
Ravishankar Sarawadi | 839fcf3 | 2012-11-14 12:13:00 -0800 | [diff] [blame] | 5060 | |
| 5061 | if (codec->reg_def_copy) { |
| 5062 | pr_debug("%s: Update ASOC cache", __func__); |
| 5063 | kfree(codec->reg_cache); |
| 5064 | codec->reg_cache = kmemdup(codec->reg_def_copy, |
| 5065 | codec->reg_size, GFP_KERNEL); |
| 5066 | } |
| 5067 | |
Ravishankar Sarawadi | 2293efe | 2013-01-11 16:37:23 -0800 | [diff] [blame] | 5068 | wcd9xxx_resmgr_post_ssr(&taiko->resmgr); |
| 5069 | if (spkr_drv_wrnd == 1) |
| 5070 | snd_soc_update_bits(codec, TAIKO_A_SPKR_DRV_EN, 0x80, 0x80); |
| 5071 | WCD9XXX_BCL_UNLOCK(&taiko->resmgr); |
| 5072 | |
Ravishankar Sarawadi | 839fcf3 | 2012-11-14 12:13:00 -0800 | [diff] [blame] | 5073 | taiko_update_reg_defaults(codec); |
| 5074 | taiko_codec_init_reg(codec); |
| 5075 | ret = taiko_handle_pdata(taiko); |
| 5076 | if (IS_ERR_VALUE(ret)) |
| 5077 | pr_err("%s: bad pdata\n", __func__); |
Ravishankar Sarawadi | 2293efe | 2013-01-11 16:37:23 -0800 | [diff] [blame] | 5078 | |
| 5079 | wcd9xxx_mbhc_deinit(&taiko->mbhc); |
| 5080 | ret = wcd9xxx_mbhc_init(&taiko->mbhc, &taiko->resmgr, codec); |
| 5081 | if (ret) |
| 5082 | pr_err("%s: mbhc init failed %d\n", __func__, ret); |
| 5083 | else |
| 5084 | wcd9xxx_mbhc_start(&taiko->mbhc, taiko->mbhc.mbhc_cfg); |
Ravishankar Sarawadi | 839fcf3 | 2012-11-14 12:13:00 -0800 | [diff] [blame] | 5085 | mutex_unlock(&codec->mutex); |
| 5086 | return ret; |
| 5087 | } |
| 5088 | |
| 5089 | |
Joonwoo Park | a889026 | 2012-10-15 12:04:27 -0700 | [diff] [blame] | 5090 | static struct wcd9xxx_reg_address taiko_reg_address = { |
| 5091 | .micb_4_mbhc = TAIKO_A_MICB_4_MBHC, |
| 5092 | .micb_4_int_rbias = TAIKO_A_MICB_4_INT_RBIAS, |
| 5093 | .micb_4_ctl = TAIKO_A_MICB_4_CTL, |
| 5094 | }; |
| 5095 | |
Ravishankar Sarawadi | 839fcf3 | 2012-11-14 12:13:00 -0800 | [diff] [blame] | 5096 | static int wcd9xxx_ssr_register(struct wcd9xxx *control, |
| 5097 | int (*post_reset_cb)(struct wcd9xxx *wcd9xxx), void *priv) |
| 5098 | { |
| 5099 | control->post_reset = post_reset_cb; |
| 5100 | control->ssr_priv = priv; |
| 5101 | return 0; |
| 5102 | } |
| 5103 | |
Kiran Kandi | c3b2440 | 2012-06-11 00:05:59 -0700 | [diff] [blame] | 5104 | static int taiko_codec_probe(struct snd_soc_codec *codec) |
| 5105 | { |
| 5106 | struct wcd9xxx *control; |
| 5107 | struct taiko_priv *taiko; |
Joonwoo Park | a889026 | 2012-10-15 12:04:27 -0700 | [diff] [blame] | 5108 | struct wcd9xxx_pdata *pdata; |
| 5109 | struct wcd9xxx *wcd9xxx; |
Kiran Kandi | c3b2440 | 2012-06-11 00:05:59 -0700 | [diff] [blame] | 5110 | struct snd_soc_dapm_context *dapm = &codec->dapm; |
| 5111 | int ret = 0; |
| 5112 | int i; |
Kuirong Wang | 906ac47 | 2012-07-09 12:54:44 -0700 | [diff] [blame] | 5113 | void *ptr = NULL; |
Joonwoo Park | 559a5bf | 2013-02-15 14:46:36 -0800 | [diff] [blame] | 5114 | struct wcd9xxx *core = dev_get_drvdata(codec->dev->parent); |
Kiran Kandi | c3b2440 | 2012-06-11 00:05:59 -0700 | [diff] [blame] | 5115 | |
| 5116 | codec->control_data = dev_get_drvdata(codec->dev->parent); |
| 5117 | control = codec->control_data; |
| 5118 | |
Ravishankar Sarawadi | 839fcf3 | 2012-11-14 12:13:00 -0800 | [diff] [blame] | 5119 | wcd9xxx_ssr_register(control, taiko_post_reset_cb, (void *)codec); |
| 5120 | |
Kiran Kandi | 4c56c59 | 2012-07-25 11:04:55 -0700 | [diff] [blame] | 5121 | dev_info(codec->dev, "%s()\n", __func__); |
| 5122 | |
Kiran Kandi | c3b2440 | 2012-06-11 00:05:59 -0700 | [diff] [blame] | 5123 | taiko = kzalloc(sizeof(struct taiko_priv), GFP_KERNEL); |
| 5124 | if (!taiko) { |
| 5125 | dev_err(codec->dev, "Failed to allocate private data\n"); |
| 5126 | return -ENOMEM; |
| 5127 | } |
| 5128 | for (i = 0 ; i < NUM_DECIMATORS; i++) { |
| 5129 | tx_hpf_work[i].taiko = taiko; |
| 5130 | tx_hpf_work[i].decimator = i + 1; |
| 5131 | INIT_DELAYED_WORK(&tx_hpf_work[i].dwork, |
| 5132 | tx_hpf_corner_freq_callback); |
| 5133 | } |
| 5134 | |
Kiran Kandi | c3b2440 | 2012-06-11 00:05:59 -0700 | [diff] [blame] | 5135 | snd_soc_codec_set_drvdata(codec, taiko); |
| 5136 | |
Joonwoo Park | a889026 | 2012-10-15 12:04:27 -0700 | [diff] [blame] | 5137 | /* codec resmgr module init */ |
| 5138 | wcd9xxx = codec->control_data; |
| 5139 | pdata = dev_get_platdata(codec->dev->parent); |
| 5140 | ret = wcd9xxx_resmgr_init(&taiko->resmgr, codec, wcd9xxx, pdata, |
| 5141 | &taiko_reg_address); |
| 5142 | if (ret) { |
| 5143 | pr_err("%s: wcd9xxx init failed %d\n", __func__, ret); |
| 5144 | return ret; |
| 5145 | } |
| 5146 | |
| 5147 | /* init and start mbhc */ |
| 5148 | ret = wcd9xxx_mbhc_init(&taiko->mbhc, &taiko->resmgr, codec); |
| 5149 | if (ret) { |
| 5150 | pr_err("%s: mbhc init failed %d\n", __func__, ret); |
| 5151 | return ret; |
| 5152 | } |
| 5153 | |
Kiran Kandi | c3b2440 | 2012-06-11 00:05:59 -0700 | [diff] [blame] | 5154 | taiko->codec = codec; |
Kiran Kandi | c3b2440 | 2012-06-11 00:05:59 -0700 | [diff] [blame] | 5155 | for (i = 0; i < COMPANDER_MAX; i++) { |
| 5156 | taiko->comp_enabled[i] = 0; |
| 5157 | taiko->comp_fs[i] = COMPANDER_FS_48KHZ; |
| 5158 | } |
Kiran Kandi | c3b2440 | 2012-06-11 00:05:59 -0700 | [diff] [blame] | 5159 | taiko->intf_type = wcd9xxx_get_intf_type(); |
| 5160 | taiko->aux_pga_cnt = 0; |
| 5161 | taiko->aux_l_gain = 0x1F; |
| 5162 | taiko->aux_r_gain = 0x1F; |
Kiran Kandi | c3b2440 | 2012-06-11 00:05:59 -0700 | [diff] [blame] | 5163 | taiko_update_reg_defaults(codec); |
Venkat Sudhir | a50a376 | 2012-11-26 12:12:15 -0800 | [diff] [blame] | 5164 | pr_debug("%s: MCLK Rate = %x\n", __func__, wcd9xxx->mclk_rate); |
| 5165 | if (wcd9xxx->mclk_rate == TAIKO_MCLK_CLK_12P288MHZ) |
Venkat Sudhir | 16d95e6 | 2013-02-04 16:57:33 -0800 | [diff] [blame] | 5166 | snd_soc_update_bits(codec, TAIKO_A_CHIP_CTL, 0x06, 0x0); |
Venkat Sudhir | a50a376 | 2012-11-26 12:12:15 -0800 | [diff] [blame] | 5167 | else if (wcd9xxx->mclk_rate == TAIKO_MCLK_CLK_9P6HZ) |
Venkat Sudhir | 16d95e6 | 2013-02-04 16:57:33 -0800 | [diff] [blame] | 5168 | snd_soc_update_bits(codec, TAIKO_A_CHIP_CTL, 0x06, 0x2); |
Kiran Kandi | c3b2440 | 2012-06-11 00:05:59 -0700 | [diff] [blame] | 5169 | taiko_codec_init_reg(codec); |
| 5170 | ret = taiko_handle_pdata(taiko); |
| 5171 | if (IS_ERR_VALUE(ret)) { |
| 5172 | pr_err("%s: bad pdata\n", __func__); |
| 5173 | goto err_pdata; |
| 5174 | } |
| 5175 | |
Joonwoo Park | 125cd4e | 2012-12-11 15:16:11 -0800 | [diff] [blame] | 5176 | if (spkr_drv_wrnd > 0) { |
| 5177 | WCD9XXX_BCL_LOCK(&taiko->resmgr); |
| 5178 | wcd9xxx_resmgr_get_bandgap(&taiko->resmgr, |
| 5179 | WCD9XXX_BANDGAP_AUDIO_MODE); |
| 5180 | WCD9XXX_BCL_UNLOCK(&taiko->resmgr); |
| 5181 | } |
| 5182 | |
Kuirong Wang | 906ac47 | 2012-07-09 12:54:44 -0700 | [diff] [blame] | 5183 | ptr = kmalloc((sizeof(taiko_rx_chs) + |
| 5184 | sizeof(taiko_tx_chs)), GFP_KERNEL); |
| 5185 | if (!ptr) { |
| 5186 | pr_err("%s: no mem for slim chan ctl data\n", __func__); |
| 5187 | ret = -ENOMEM; |
| 5188 | goto err_nomem_slimch; |
| 5189 | } |
| 5190 | |
Kiran Kandi | c3b2440 | 2012-06-11 00:05:59 -0700 | [diff] [blame] | 5191 | if (taiko->intf_type == WCD9XXX_INTERFACE_TYPE_I2C) { |
| 5192 | snd_soc_dapm_new_controls(dapm, taiko_dapm_i2s_widgets, |
| 5193 | ARRAY_SIZE(taiko_dapm_i2s_widgets)); |
| 5194 | snd_soc_dapm_add_routes(dapm, audio_i2s_map, |
| 5195 | ARRAY_SIZE(audio_i2s_map)); |
Joonwoo Park | 559a5bf | 2013-02-15 14:46:36 -0800 | [diff] [blame] | 5196 | if (TAIKO_IS_1_0(core->version)) |
| 5197 | snd_soc_dapm_add_routes(dapm, audio_i2s_map_1_0, |
| 5198 | ARRAY_SIZE(audio_i2s_map_1_0)); |
| 5199 | else |
| 5200 | snd_soc_dapm_add_routes(dapm, audio_i2s_map_2_0, |
| 5201 | ARRAY_SIZE(audio_i2s_map_2_0)); |
Kuirong Wang | 906ac47 | 2012-07-09 12:54:44 -0700 | [diff] [blame] | 5202 | for (i = 0; i < ARRAY_SIZE(taiko_i2s_dai); i++) |
| 5203 | INIT_LIST_HEAD(&taiko->dai[i].wcd9xxx_ch_list); |
| 5204 | } else if (taiko->intf_type == WCD9XXX_INTERFACE_TYPE_SLIMBUS) { |
| 5205 | for (i = 0; i < NUM_CODEC_DAIS; i++) { |
| 5206 | INIT_LIST_HEAD(&taiko->dai[i].wcd9xxx_ch_list); |
| 5207 | init_waitqueue_head(&taiko->dai[i].dai_wait); |
| 5208 | } |
Kiran Kandi | c3b2440 | 2012-06-11 00:05:59 -0700 | [diff] [blame] | 5209 | } |
| 5210 | |
Kuirong Wang | 906ac47 | 2012-07-09 12:54:44 -0700 | [diff] [blame] | 5211 | control->num_rx_port = TAIKO_RX_MAX; |
| 5212 | control->rx_chs = ptr; |
| 5213 | memcpy(control->rx_chs, taiko_rx_chs, sizeof(taiko_rx_chs)); |
| 5214 | control->num_tx_port = TAIKO_TX_MAX; |
| 5215 | control->tx_chs = ptr + sizeof(taiko_rx_chs); |
| 5216 | memcpy(control->tx_chs, taiko_tx_chs, sizeof(taiko_tx_chs)); |
| 5217 | |
Kiran Kandi | c3b2440 | 2012-06-11 00:05:59 -0700 | [diff] [blame] | 5218 | snd_soc_dapm_sync(dapm); |
| 5219 | |
Joonwoo Park | 7680b9f | 2012-07-13 11:36:48 -0700 | [diff] [blame] | 5220 | (void) taiko_setup_irqs(taiko); |
Kiran Kandi | c3b2440 | 2012-06-11 00:05:59 -0700 | [diff] [blame] | 5221 | |
Joonwoo Park | 125cd4e | 2012-12-11 15:16:11 -0800 | [diff] [blame] | 5222 | atomic_set(&kp_taiko_priv, (unsigned long)taiko); |
| 5223 | |
Kiran Kandi | c3b2440 | 2012-06-11 00:05:59 -0700 | [diff] [blame] | 5224 | codec->ignore_pmdown_time = 1; |
| 5225 | return ret; |
| 5226 | |
Kiran Kandi | c3b2440 | 2012-06-11 00:05:59 -0700 | [diff] [blame] | 5227 | err_pdata: |
Kuirong Wang | 906ac47 | 2012-07-09 12:54:44 -0700 | [diff] [blame] | 5228 | kfree(ptr); |
| 5229 | err_nomem_slimch: |
Kiran Kandi | c3b2440 | 2012-06-11 00:05:59 -0700 | [diff] [blame] | 5230 | kfree(taiko); |
| 5231 | return ret; |
| 5232 | } |
| 5233 | static int taiko_codec_remove(struct snd_soc_codec *codec) |
| 5234 | { |
Kiran Kandi | c3b2440 | 2012-06-11 00:05:59 -0700 | [diff] [blame] | 5235 | struct taiko_priv *taiko = snd_soc_codec_get_drvdata(codec); |
Joonwoo Park | a889026 | 2012-10-15 12:04:27 -0700 | [diff] [blame] | 5236 | |
Joonwoo Park | 125cd4e | 2012-12-11 15:16:11 -0800 | [diff] [blame] | 5237 | WCD9XXX_BCL_LOCK(&taiko->resmgr); |
| 5238 | atomic_set(&kp_taiko_priv, 0); |
| 5239 | |
| 5240 | if (spkr_drv_wrnd > 0) |
| 5241 | wcd9xxx_resmgr_put_bandgap(&taiko->resmgr, |
| 5242 | WCD9XXX_BANDGAP_AUDIO_MODE); |
| 5243 | WCD9XXX_BCL_UNLOCK(&taiko->resmgr); |
| 5244 | |
Joonwoo Park | a889026 | 2012-10-15 12:04:27 -0700 | [diff] [blame] | 5245 | /* cleanup MBHC */ |
| 5246 | wcd9xxx_mbhc_deinit(&taiko->mbhc); |
| 5247 | /* cleanup resmgr */ |
| 5248 | wcd9xxx_resmgr_deinit(&taiko->resmgr); |
| 5249 | |
Kiran Kandi | c3b2440 | 2012-06-11 00:05:59 -0700 | [diff] [blame] | 5250 | kfree(taiko); |
| 5251 | return 0; |
| 5252 | } |
| 5253 | static struct snd_soc_codec_driver soc_codec_dev_taiko = { |
| 5254 | .probe = taiko_codec_probe, |
| 5255 | .remove = taiko_codec_remove, |
| 5256 | |
| 5257 | .read = taiko_read, |
| 5258 | .write = taiko_write, |
| 5259 | |
| 5260 | .readable_register = taiko_readable, |
| 5261 | .volatile_register = taiko_volatile, |
| 5262 | |
| 5263 | .reg_cache_size = TAIKO_CACHE_SIZE, |
Kiran Kandi | 7b7d2ff | 2012-09-14 14:52:14 -0700 | [diff] [blame] | 5264 | .reg_cache_default = taiko_reset_reg_defaults, |
Kiran Kandi | c3b2440 | 2012-06-11 00:05:59 -0700 | [diff] [blame] | 5265 | .reg_word_size = 1, |
| 5266 | |
| 5267 | .controls = taiko_snd_controls, |
| 5268 | .num_controls = ARRAY_SIZE(taiko_snd_controls), |
| 5269 | .dapm_widgets = taiko_dapm_widgets, |
| 5270 | .num_dapm_widgets = ARRAY_SIZE(taiko_dapm_widgets), |
| 5271 | .dapm_routes = audio_map, |
| 5272 | .num_dapm_routes = ARRAY_SIZE(audio_map), |
| 5273 | }; |
| 5274 | |
| 5275 | #ifdef CONFIG_PM |
| 5276 | static int taiko_suspend(struct device *dev) |
| 5277 | { |
| 5278 | dev_dbg(dev, "%s: system suspend\n", __func__); |
| 5279 | return 0; |
| 5280 | } |
| 5281 | |
| 5282 | static int taiko_resume(struct device *dev) |
| 5283 | { |
| 5284 | struct platform_device *pdev = to_platform_device(dev); |
| 5285 | struct taiko_priv *taiko = platform_get_drvdata(pdev); |
| 5286 | dev_dbg(dev, "%s: system resume\n", __func__); |
Joonwoo Park | a889026 | 2012-10-15 12:04:27 -0700 | [diff] [blame] | 5287 | /* Notify */ |
| 5288 | wcd9xxx_resmgr_notifier_call(&taiko->resmgr, WCD9XXX_EVENT_POST_RESUME); |
Kiran Kandi | c3b2440 | 2012-06-11 00:05:59 -0700 | [diff] [blame] | 5289 | return 0; |
| 5290 | } |
| 5291 | |
| 5292 | static const struct dev_pm_ops taiko_pm_ops = { |
| 5293 | .suspend = taiko_suspend, |
| 5294 | .resume = taiko_resume, |
| 5295 | }; |
| 5296 | #endif |
| 5297 | |
| 5298 | static int __devinit taiko_probe(struct platform_device *pdev) |
| 5299 | { |
| 5300 | int ret = 0; |
| 5301 | if (wcd9xxx_get_intf_type() == WCD9XXX_INTERFACE_TYPE_SLIMBUS) |
| 5302 | ret = snd_soc_register_codec(&pdev->dev, &soc_codec_dev_taiko, |
| 5303 | taiko_dai, ARRAY_SIZE(taiko_dai)); |
| 5304 | else if (wcd9xxx_get_intf_type() == WCD9XXX_INTERFACE_TYPE_I2C) |
| 5305 | ret = snd_soc_register_codec(&pdev->dev, &soc_codec_dev_taiko, |
| 5306 | taiko_i2s_dai, ARRAY_SIZE(taiko_i2s_dai)); |
| 5307 | return ret; |
| 5308 | } |
| 5309 | static int __devexit taiko_remove(struct platform_device *pdev) |
| 5310 | { |
| 5311 | snd_soc_unregister_codec(&pdev->dev); |
| 5312 | return 0; |
| 5313 | } |
| 5314 | static struct platform_driver taiko_codec_driver = { |
| 5315 | .probe = taiko_probe, |
| 5316 | .remove = taiko_remove, |
| 5317 | .driver = { |
| 5318 | .name = "taiko_codec", |
| 5319 | .owner = THIS_MODULE, |
| 5320 | #ifdef CONFIG_PM |
| 5321 | .pm = &taiko_pm_ops, |
| 5322 | #endif |
| 5323 | }, |
| 5324 | }; |
| 5325 | |
| 5326 | static int __init taiko_codec_init(void) |
| 5327 | { |
| 5328 | return platform_driver_register(&taiko_codec_driver); |
| 5329 | } |
| 5330 | |
| 5331 | static void __exit taiko_codec_exit(void) |
| 5332 | { |
| 5333 | platform_driver_unregister(&taiko_codec_driver); |
| 5334 | } |
| 5335 | |
| 5336 | module_init(taiko_codec_init); |
| 5337 | module_exit(taiko_codec_exit); |
| 5338 | |
| 5339 | MODULE_DESCRIPTION("Taiko codec driver"); |
| 5340 | MODULE_LICENSE("GPL v2"); |