18d78602aSSrinivas Kandagatla // SPDX-License-Identifier: GPL-2.0-only 28d78602aSSrinivas Kandagatla // Copyright (c) 2018-2020, The Linux Foundation. All rights reserved. 38d78602aSSrinivas Kandagatla 48d78602aSSrinivas Kandagatla #include <linux/module.h> 58d78602aSSrinivas Kandagatla #include <linux/slab.h> 68d78602aSSrinivas Kandagatla #include <linux/platform_device.h> 78d78602aSSrinivas Kandagatla #include <linux/device.h> 88d78602aSSrinivas Kandagatla #include <linux/delay.h> 98d78602aSSrinivas Kandagatla #include <linux/kernel.h> 108d78602aSSrinivas Kandagatla #include <linux/pm_runtime.h> 118d78602aSSrinivas Kandagatla #include <linux/component.h> 128d78602aSSrinivas Kandagatla #include <sound/tlv.h> 138d78602aSSrinivas Kandagatla #include <linux/of_gpio.h> 148d78602aSSrinivas Kandagatla #include <linux/of.h> 158d78602aSSrinivas Kandagatla #include <sound/jack.h> 168d78602aSSrinivas Kandagatla #include <sound/pcm.h> 178d78602aSSrinivas Kandagatla #include <sound/pcm_params.h> 188d78602aSSrinivas Kandagatla #include <linux/regmap.h> 198d78602aSSrinivas Kandagatla #include <sound/soc.h> 208d78602aSSrinivas Kandagatla #include <sound/soc-dapm.h> 218d78602aSSrinivas Kandagatla #include <linux/regulator/consumer.h> 228d78602aSSrinivas Kandagatla 238d78602aSSrinivas Kandagatla #include "wcd-clsh-v2.h" 24bcee7ed0SSrinivas Kandagatla #include "wcd-mbhc-v2.h" 258d78602aSSrinivas Kandagatla #include "wcd938x.h" 268d78602aSSrinivas Kandagatla 278d78602aSSrinivas Kandagatla #define WCD938X_MAX_MICBIAS (4) 288d78602aSSrinivas Kandagatla #define WCD938X_MAX_SUPPLY (4) 298d78602aSSrinivas Kandagatla #define WCD938X_MBHC_MAX_BUTTONS (8) 308d78602aSSrinivas Kandagatla #define TX_ADC_MAX (4) 318d78602aSSrinivas Kandagatla #define WCD938X_TX_MAX_SWR_PORTS (5) 328d78602aSSrinivas Kandagatla 338d78602aSSrinivas Kandagatla #define WCD938X_RATES_MASK (SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |\ 348d78602aSSrinivas Kandagatla SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |\ 358d78602aSSrinivas Kandagatla SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_192000) 368d78602aSSrinivas Kandagatla /* Fractional Rates */ 378d78602aSSrinivas Kandagatla #define WCD938X_FRAC_RATES_MASK (SNDRV_PCM_RATE_44100 | SNDRV_PCM_RATE_88200 |\ 388d78602aSSrinivas Kandagatla SNDRV_PCM_RATE_176400) 398d78602aSSrinivas Kandagatla #define WCD938X_FORMATS_S16_S24_LE (SNDRV_PCM_FMTBIT_S16_LE | \ 408d78602aSSrinivas Kandagatla SNDRV_PCM_FMTBIT_S24_LE) 418d78602aSSrinivas Kandagatla /* Convert from vout ctl to micbias voltage in mV */ 428d78602aSSrinivas Kandagatla #define WCD_VOUT_CTL_TO_MICB(v) (1000 + v * 50) 438d78602aSSrinivas Kandagatla #define SWR_CLK_RATE_0P6MHZ (600000) 448d78602aSSrinivas Kandagatla #define SWR_CLK_RATE_1P2MHZ (1200000) 458d78602aSSrinivas Kandagatla #define SWR_CLK_RATE_2P4MHZ (2400000) 468d78602aSSrinivas Kandagatla #define SWR_CLK_RATE_4P8MHZ (4800000) 478d78602aSSrinivas Kandagatla #define SWR_CLK_RATE_9P6MHZ (9600000) 488d78602aSSrinivas Kandagatla #define SWR_CLK_RATE_11P2896MHZ (1128960) 498d78602aSSrinivas Kandagatla 508d78602aSSrinivas Kandagatla #define WCD938X_DRV_NAME "wcd938x_codec" 518d78602aSSrinivas Kandagatla #define WCD938X_VERSION_1_0 (1) 528d78602aSSrinivas Kandagatla #define EAR_RX_PATH_AUX (1) 538d78602aSSrinivas Kandagatla 548d78602aSSrinivas Kandagatla #define ADC_MODE_VAL_HIFI 0x01 558d78602aSSrinivas Kandagatla #define ADC_MODE_VAL_LO_HIF 0x02 568d78602aSSrinivas Kandagatla #define ADC_MODE_VAL_NORMAL 0x03 578d78602aSSrinivas Kandagatla #define ADC_MODE_VAL_LP 0x05 588d78602aSSrinivas Kandagatla #define ADC_MODE_VAL_ULP1 0x09 598d78602aSSrinivas Kandagatla #define ADC_MODE_VAL_ULP2 0x0B 608d78602aSSrinivas Kandagatla 618d78602aSSrinivas Kandagatla /* Z value defined in milliohm */ 628d78602aSSrinivas Kandagatla #define WCD938X_ZDET_VAL_32 (32000) 638d78602aSSrinivas Kandagatla #define WCD938X_ZDET_VAL_400 (400000) 648d78602aSSrinivas Kandagatla #define WCD938X_ZDET_VAL_1200 (1200000) 658d78602aSSrinivas Kandagatla #define WCD938X_ZDET_VAL_100K (100000000) 668d78602aSSrinivas Kandagatla /* Z floating defined in ohms */ 678d78602aSSrinivas Kandagatla #define WCD938X_ZDET_FLOATING_IMPEDANCE (0x0FFFFFFE) 688d78602aSSrinivas Kandagatla #define WCD938X_ZDET_NUM_MEASUREMENTS (900) 698d78602aSSrinivas Kandagatla #define WCD938X_MBHC_GET_C1(c) ((c & 0xC000) >> 14) 708d78602aSSrinivas Kandagatla #define WCD938X_MBHC_GET_X1(x) (x & 0x3FFF) 718d78602aSSrinivas Kandagatla /* Z value compared in milliOhm */ 728d78602aSSrinivas Kandagatla #define WCD938X_MBHC_IS_SECOND_RAMP_REQUIRED(z) ((z > 400000) || (z < 32000)) 738d78602aSSrinivas Kandagatla #define WCD938X_MBHC_ZDET_CONST (86 * 16384) 748d78602aSSrinivas Kandagatla #define WCD938X_MBHC_MOISTURE_RREF R_24_KOHM 758d78602aSSrinivas Kandagatla #define WCD_MBHC_HS_V_MAX 1600 768d78602aSSrinivas Kandagatla 77e8ba1e05SSrinivas Kandagatla #define WCD938X_EAR_PA_GAIN_TLV(xname, reg, shift, max, invert, tlv_array) \ 78e8ba1e05SSrinivas Kandagatla { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \ 79e8ba1e05SSrinivas Kandagatla .access = SNDRV_CTL_ELEM_ACCESS_TLV_READ |\ 80e8ba1e05SSrinivas Kandagatla SNDRV_CTL_ELEM_ACCESS_READWRITE,\ 81e8ba1e05SSrinivas Kandagatla .tlv.p = (tlv_array), \ 82e8ba1e05SSrinivas Kandagatla .info = snd_soc_info_volsw, .get = snd_soc_get_volsw,\ 83e8ba1e05SSrinivas Kandagatla .put = wcd938x_ear_pa_put_gain, \ 84e8ba1e05SSrinivas Kandagatla .private_value = SOC_SINGLE_VALUE(reg, shift, max, invert, 0) } 85e8ba1e05SSrinivas Kandagatla 868d78602aSSrinivas Kandagatla enum { 878d78602aSSrinivas Kandagatla WCD9380 = 0, 888d78602aSSrinivas Kandagatla WCD9385 = 5, 898d78602aSSrinivas Kandagatla }; 908d78602aSSrinivas Kandagatla 918d78602aSSrinivas Kandagatla enum { 928d78602aSSrinivas Kandagatla TX_HDR12 = 0, 938d78602aSSrinivas Kandagatla TX_HDR34, 948d78602aSSrinivas Kandagatla TX_HDR_MAX, 958d78602aSSrinivas Kandagatla }; 968d78602aSSrinivas Kandagatla 978d78602aSSrinivas Kandagatla enum { 988d78602aSSrinivas Kandagatla WCD_RX1, 998d78602aSSrinivas Kandagatla WCD_RX2, 1008d78602aSSrinivas Kandagatla WCD_RX3 1018d78602aSSrinivas Kandagatla }; 1028d78602aSSrinivas Kandagatla 1038d78602aSSrinivas Kandagatla enum { 1048d78602aSSrinivas Kandagatla /* INTR_CTRL_INT_MASK_0 */ 1058d78602aSSrinivas Kandagatla WCD938X_IRQ_MBHC_BUTTON_PRESS_DET = 0, 1068d78602aSSrinivas Kandagatla WCD938X_IRQ_MBHC_BUTTON_RELEASE_DET, 1078d78602aSSrinivas Kandagatla WCD938X_IRQ_MBHC_ELECT_INS_REM_DET, 1088d78602aSSrinivas Kandagatla WCD938X_IRQ_MBHC_ELECT_INS_REM_LEG_DET, 1098d78602aSSrinivas Kandagatla WCD938X_IRQ_MBHC_SW_DET, 1108d78602aSSrinivas Kandagatla WCD938X_IRQ_HPHR_OCP_INT, 1118d78602aSSrinivas Kandagatla WCD938X_IRQ_HPHR_CNP_INT, 1128d78602aSSrinivas Kandagatla WCD938X_IRQ_HPHL_OCP_INT, 1138d78602aSSrinivas Kandagatla 1148d78602aSSrinivas Kandagatla /* INTR_CTRL_INT_MASK_1 */ 1158d78602aSSrinivas Kandagatla WCD938X_IRQ_HPHL_CNP_INT, 1168d78602aSSrinivas Kandagatla WCD938X_IRQ_EAR_CNP_INT, 1178d78602aSSrinivas Kandagatla WCD938X_IRQ_EAR_SCD_INT, 1188d78602aSSrinivas Kandagatla WCD938X_IRQ_AUX_CNP_INT, 1198d78602aSSrinivas Kandagatla WCD938X_IRQ_AUX_SCD_INT, 1208d78602aSSrinivas Kandagatla WCD938X_IRQ_HPHL_PDM_WD_INT, 1218d78602aSSrinivas Kandagatla WCD938X_IRQ_HPHR_PDM_WD_INT, 1228d78602aSSrinivas Kandagatla WCD938X_IRQ_AUX_PDM_WD_INT, 1238d78602aSSrinivas Kandagatla 1248d78602aSSrinivas Kandagatla /* INTR_CTRL_INT_MASK_2 */ 1258d78602aSSrinivas Kandagatla WCD938X_IRQ_LDORT_SCD_INT, 1268d78602aSSrinivas Kandagatla WCD938X_IRQ_MBHC_MOISTURE_INT, 1278d78602aSSrinivas Kandagatla WCD938X_IRQ_HPHL_SURGE_DET_INT, 1288d78602aSSrinivas Kandagatla WCD938X_IRQ_HPHR_SURGE_DET_INT, 1298d78602aSSrinivas Kandagatla WCD938X_NUM_IRQS, 1308d78602aSSrinivas Kandagatla }; 1318d78602aSSrinivas Kandagatla 1328d78602aSSrinivas Kandagatla enum { 1338d78602aSSrinivas Kandagatla WCD_ADC1 = 0, 1348d78602aSSrinivas Kandagatla WCD_ADC2, 1358d78602aSSrinivas Kandagatla WCD_ADC3, 1368d78602aSSrinivas Kandagatla WCD_ADC4, 1378d78602aSSrinivas Kandagatla ALLOW_BUCK_DISABLE, 1388d78602aSSrinivas Kandagatla HPH_COMP_DELAY, 1398d78602aSSrinivas Kandagatla HPH_PA_DELAY, 1408d78602aSSrinivas Kandagatla AMIC2_BCS_ENABLE, 1418d78602aSSrinivas Kandagatla WCD_SUPPLIES_LPM_MODE, 1428d78602aSSrinivas Kandagatla }; 1438d78602aSSrinivas Kandagatla 1448d78602aSSrinivas Kandagatla enum { 1458d78602aSSrinivas Kandagatla ADC_MODE_INVALID = 0, 1468d78602aSSrinivas Kandagatla ADC_MODE_HIFI, 1478d78602aSSrinivas Kandagatla ADC_MODE_LO_HIF, 1488d78602aSSrinivas Kandagatla ADC_MODE_NORMAL, 1498d78602aSSrinivas Kandagatla ADC_MODE_LP, 1508d78602aSSrinivas Kandagatla ADC_MODE_ULP1, 1518d78602aSSrinivas Kandagatla ADC_MODE_ULP2, 1528d78602aSSrinivas Kandagatla }; 1538d78602aSSrinivas Kandagatla 1548d78602aSSrinivas Kandagatla enum { 1558d78602aSSrinivas Kandagatla AIF1_PB = 0, 1568d78602aSSrinivas Kandagatla AIF1_CAP, 1578d78602aSSrinivas Kandagatla NUM_CODEC_DAIS, 1588d78602aSSrinivas Kandagatla }; 1598d78602aSSrinivas Kandagatla 160d5add08fSSrinivas Kandagatla static u8 tx_mode_bit[] = { 161d5add08fSSrinivas Kandagatla [ADC_MODE_INVALID] = 0x00, 162d5add08fSSrinivas Kandagatla [ADC_MODE_HIFI] = 0x01, 163d5add08fSSrinivas Kandagatla [ADC_MODE_LO_HIF] = 0x02, 164d5add08fSSrinivas Kandagatla [ADC_MODE_NORMAL] = 0x04, 165d5add08fSSrinivas Kandagatla [ADC_MODE_LP] = 0x08, 166d5add08fSSrinivas Kandagatla [ADC_MODE_ULP1] = 0x10, 167d5add08fSSrinivas Kandagatla [ADC_MODE_ULP2] = 0x20, 168d5add08fSSrinivas Kandagatla }; 169d5add08fSSrinivas Kandagatla 1708d78602aSSrinivas Kandagatla struct wcd938x_priv { 1718d78602aSSrinivas Kandagatla struct sdw_slave *tx_sdw_dev; 1728d78602aSSrinivas Kandagatla struct wcd938x_sdw_priv *sdw_priv[NUM_CODEC_DAIS]; 1738d78602aSSrinivas Kandagatla struct device *txdev; 1748d78602aSSrinivas Kandagatla struct device *rxdev; 1758d78602aSSrinivas Kandagatla struct device_node *rxnode, *txnode; 1768d78602aSSrinivas Kandagatla struct regmap *regmap; 177bcee7ed0SSrinivas Kandagatla struct mutex micb_lock; 178bcee7ed0SSrinivas Kandagatla /* mbhc module */ 179bcee7ed0SSrinivas Kandagatla struct wcd_mbhc *wcd_mbhc; 180bcee7ed0SSrinivas Kandagatla struct wcd_mbhc_config mbhc_cfg; 181bcee7ed0SSrinivas Kandagatla struct wcd_mbhc_intr intr_ids; 1828d78602aSSrinivas Kandagatla struct wcd_clsh_ctrl *clsh_info; 1838d78602aSSrinivas Kandagatla struct irq_domain *virq; 1848d78602aSSrinivas Kandagatla struct regmap_irq_chip *wcd_regmap_irq_chip; 1858d78602aSSrinivas Kandagatla struct regmap_irq_chip_data *irq_chip; 1868d78602aSSrinivas Kandagatla struct regulator_bulk_data supplies[WCD938X_MAX_SUPPLY]; 1878d78602aSSrinivas Kandagatla struct snd_soc_jack *jack; 1888d78602aSSrinivas Kandagatla unsigned long status_mask; 1898d78602aSSrinivas Kandagatla s32 micb_ref[WCD938X_MAX_MICBIAS]; 1908d78602aSSrinivas Kandagatla s32 pullup_ref[WCD938X_MAX_MICBIAS]; 1918d78602aSSrinivas Kandagatla u32 hph_mode; 1928d78602aSSrinivas Kandagatla u32 tx_mode[TX_ADC_MAX]; 1938d78602aSSrinivas Kandagatla int flyback_cur_det_disable; 1948d78602aSSrinivas Kandagatla int ear_rx_path; 1958d78602aSSrinivas Kandagatla int variant; 1968d78602aSSrinivas Kandagatla int reset_gpio; 1978d78602aSSrinivas Kandagatla u32 micb1_mv; 1988d78602aSSrinivas Kandagatla u32 micb2_mv; 1998d78602aSSrinivas Kandagatla u32 micb3_mv; 2008d78602aSSrinivas Kandagatla u32 micb4_mv; 2018d78602aSSrinivas Kandagatla int hphr_pdm_wd_int; 2028d78602aSSrinivas Kandagatla int hphl_pdm_wd_int; 2038d78602aSSrinivas Kandagatla int aux_pdm_wd_int; 2048d78602aSSrinivas Kandagatla bool comp1_enable; 2058d78602aSSrinivas Kandagatla bool comp2_enable; 2068d78602aSSrinivas Kandagatla bool ldoh; 2078d78602aSSrinivas Kandagatla bool bcs_dis; 2088d78602aSSrinivas Kandagatla }; 2098d78602aSSrinivas Kandagatla 210e8ba1e05SSrinivas Kandagatla static const SNDRV_CTL_TLVD_DECLARE_DB_MINMAX(ear_pa_gain, 600, -1800); 211e8ba1e05SSrinivas Kandagatla static const SNDRV_CTL_TLVD_DECLARE_DB_MINMAX(line_gain, 600, -3000); 212e8ba1e05SSrinivas Kandagatla static const SNDRV_CTL_TLVD_DECLARE_DB_MINMAX(analog_gain, 0, 3000); 213e8ba1e05SSrinivas Kandagatla 214bcee7ed0SSrinivas Kandagatla struct wcd938x_mbhc_zdet_param { 215bcee7ed0SSrinivas Kandagatla u16 ldo_ctl; 216bcee7ed0SSrinivas Kandagatla u16 noff; 217bcee7ed0SSrinivas Kandagatla u16 nshift; 218bcee7ed0SSrinivas Kandagatla u16 btn5; 219bcee7ed0SSrinivas Kandagatla u16 btn6; 220bcee7ed0SSrinivas Kandagatla u16 btn7; 221bcee7ed0SSrinivas Kandagatla }; 222bcee7ed0SSrinivas Kandagatla 223bcee7ed0SSrinivas Kandagatla static struct wcd_mbhc_field wcd_mbhc_fields[WCD_MBHC_REG_FUNC_MAX] = { 224bcee7ed0SSrinivas Kandagatla WCD_MBHC_FIELD(WCD_MBHC_L_DET_EN, WCD938X_ANA_MBHC_MECH, 0x80), 225bcee7ed0SSrinivas Kandagatla WCD_MBHC_FIELD(WCD_MBHC_GND_DET_EN, WCD938X_ANA_MBHC_MECH, 0x40), 226bcee7ed0SSrinivas Kandagatla WCD_MBHC_FIELD(WCD_MBHC_MECH_DETECTION_TYPE, WCD938X_ANA_MBHC_MECH, 0x20), 227bcee7ed0SSrinivas Kandagatla WCD_MBHC_FIELD(WCD_MBHC_MIC_CLAMP_CTL, WCD938X_MBHC_NEW_PLUG_DETECT_CTL, 0x30), 228bcee7ed0SSrinivas Kandagatla WCD_MBHC_FIELD(WCD_MBHC_ELECT_DETECTION_TYPE, WCD938X_ANA_MBHC_ELECT, 0x08), 229bcee7ed0SSrinivas Kandagatla WCD_MBHC_FIELD(WCD_MBHC_HS_L_DET_PULL_UP_CTRL, WCD938X_MBHC_NEW_INT_MECH_DET_CURRENT, 0x1F), 230bcee7ed0SSrinivas Kandagatla WCD_MBHC_FIELD(WCD_MBHC_HS_L_DET_PULL_UP_COMP_CTRL, WCD938X_ANA_MBHC_MECH, 0x04), 231bcee7ed0SSrinivas Kandagatla WCD_MBHC_FIELD(WCD_MBHC_HPHL_PLUG_TYPE, WCD938X_ANA_MBHC_MECH, 0x10), 232bcee7ed0SSrinivas Kandagatla WCD_MBHC_FIELD(WCD_MBHC_GND_PLUG_TYPE, WCD938X_ANA_MBHC_MECH, 0x08), 233bcee7ed0SSrinivas Kandagatla WCD_MBHC_FIELD(WCD_MBHC_SW_HPH_LP_100K_TO_GND, WCD938X_ANA_MBHC_MECH, 0x01), 234bcee7ed0SSrinivas Kandagatla WCD_MBHC_FIELD(WCD_MBHC_ELECT_SCHMT_ISRC, WCD938X_ANA_MBHC_ELECT, 0x06), 235bcee7ed0SSrinivas Kandagatla WCD_MBHC_FIELD(WCD_MBHC_FSM_EN, WCD938X_ANA_MBHC_ELECT, 0x80), 236bcee7ed0SSrinivas Kandagatla WCD_MBHC_FIELD(WCD_MBHC_INSREM_DBNC, WCD938X_MBHC_NEW_PLUG_DETECT_CTL, 0x0F), 237bcee7ed0SSrinivas Kandagatla WCD_MBHC_FIELD(WCD_MBHC_BTN_DBNC, WCD938X_MBHC_NEW_CTL_1, 0x03), 238bcee7ed0SSrinivas Kandagatla WCD_MBHC_FIELD(WCD_MBHC_HS_VREF, WCD938X_MBHC_NEW_CTL_2, 0x03), 239bcee7ed0SSrinivas Kandagatla WCD_MBHC_FIELD(WCD_MBHC_HS_COMP_RESULT, WCD938X_ANA_MBHC_RESULT_3, 0x08), 240bcee7ed0SSrinivas Kandagatla WCD_MBHC_FIELD(WCD_MBHC_IN2P_CLAMP_STATE, WCD938X_ANA_MBHC_RESULT_3, 0x10), 241bcee7ed0SSrinivas Kandagatla WCD_MBHC_FIELD(WCD_MBHC_MIC_SCHMT_RESULT, WCD938X_ANA_MBHC_RESULT_3, 0x20), 242bcee7ed0SSrinivas Kandagatla WCD_MBHC_FIELD(WCD_MBHC_HPHL_SCHMT_RESULT, WCD938X_ANA_MBHC_RESULT_3, 0x80), 243bcee7ed0SSrinivas Kandagatla WCD_MBHC_FIELD(WCD_MBHC_HPHR_SCHMT_RESULT, WCD938X_ANA_MBHC_RESULT_3, 0x40), 244bcee7ed0SSrinivas Kandagatla WCD_MBHC_FIELD(WCD_MBHC_OCP_FSM_EN, WCD938X_HPH_OCP_CTL, 0x10), 245bcee7ed0SSrinivas Kandagatla WCD_MBHC_FIELD(WCD_MBHC_BTN_RESULT, WCD938X_ANA_MBHC_RESULT_3, 0x07), 246bcee7ed0SSrinivas Kandagatla WCD_MBHC_FIELD(WCD_MBHC_BTN_ISRC_CTL, WCD938X_ANA_MBHC_ELECT, 0x70), 247bcee7ed0SSrinivas Kandagatla WCD_MBHC_FIELD(WCD_MBHC_ELECT_RESULT, WCD938X_ANA_MBHC_RESULT_3, 0xFF), 248bcee7ed0SSrinivas Kandagatla WCD_MBHC_FIELD(WCD_MBHC_MICB_CTRL, WCD938X_ANA_MICB2, 0xC0), 249bcee7ed0SSrinivas Kandagatla WCD_MBHC_FIELD(WCD_MBHC_HPH_CNP_WG_TIME, WCD938X_HPH_CNP_WG_TIME, 0xFF), 250bcee7ed0SSrinivas Kandagatla WCD_MBHC_FIELD(WCD_MBHC_HPHR_PA_EN, WCD938X_ANA_HPH, 0x40), 251bcee7ed0SSrinivas Kandagatla WCD_MBHC_FIELD(WCD_MBHC_HPHL_PA_EN, WCD938X_ANA_HPH, 0x80), 252bcee7ed0SSrinivas Kandagatla WCD_MBHC_FIELD(WCD_MBHC_HPH_PA_EN, WCD938X_ANA_HPH, 0xC0), 253bcee7ed0SSrinivas Kandagatla WCD_MBHC_FIELD(WCD_MBHC_SWCH_LEVEL_REMOVE, WCD938X_ANA_MBHC_RESULT_3, 0x10), 254bcee7ed0SSrinivas Kandagatla WCD_MBHC_FIELD(WCD_MBHC_ANC_DET_EN, WCD938X_MBHC_CTL_BCS, 0x02), 255bcee7ed0SSrinivas Kandagatla WCD_MBHC_FIELD(WCD_MBHC_FSM_STATUS, WCD938X_MBHC_NEW_FSM_STATUS, 0x01), 256bcee7ed0SSrinivas Kandagatla WCD_MBHC_FIELD(WCD_MBHC_MUX_CTL, WCD938X_MBHC_NEW_CTL_2, 0x70), 257bcee7ed0SSrinivas Kandagatla WCD_MBHC_FIELD(WCD_MBHC_MOISTURE_STATUS, WCD938X_MBHC_NEW_FSM_STATUS, 0x20), 258bcee7ed0SSrinivas Kandagatla WCD_MBHC_FIELD(WCD_MBHC_HPHR_GND, WCD938X_HPH_PA_CTL2, 0x40), 259bcee7ed0SSrinivas Kandagatla WCD_MBHC_FIELD(WCD_MBHC_HPHL_GND, WCD938X_HPH_PA_CTL2, 0x10), 260bcee7ed0SSrinivas Kandagatla WCD_MBHC_FIELD(WCD_MBHC_HPHL_OCP_DET_EN, WCD938X_HPH_L_TEST, 0x01), 261bcee7ed0SSrinivas Kandagatla WCD_MBHC_FIELD(WCD_MBHC_HPHR_OCP_DET_EN, WCD938X_HPH_R_TEST, 0x01), 262bcee7ed0SSrinivas Kandagatla WCD_MBHC_FIELD(WCD_MBHC_HPHL_OCP_STATUS, WCD938X_DIGITAL_INTR_STATUS_0, 0x80), 263bcee7ed0SSrinivas Kandagatla WCD_MBHC_FIELD(WCD_MBHC_HPHR_OCP_STATUS, WCD938X_DIGITAL_INTR_STATUS_0, 0x20), 264bcee7ed0SSrinivas Kandagatla WCD_MBHC_FIELD(WCD_MBHC_ADC_EN, WCD938X_MBHC_NEW_CTL_1, 0x08), 265bcee7ed0SSrinivas Kandagatla WCD_MBHC_FIELD(WCD_MBHC_ADC_COMPLETE, WCD938X_MBHC_NEW_FSM_STATUS, 0x40), 266bcee7ed0SSrinivas Kandagatla WCD_MBHC_FIELD(WCD_MBHC_ADC_TIMEOUT, WCD938X_MBHC_NEW_FSM_STATUS, 0x80), 267bcee7ed0SSrinivas Kandagatla WCD_MBHC_FIELD(WCD_MBHC_ADC_RESULT, WCD938X_MBHC_NEW_ADC_RESULT, 0xFF), 268bcee7ed0SSrinivas Kandagatla WCD_MBHC_FIELD(WCD_MBHC_MICB2_VOUT, WCD938X_ANA_MICB2, 0x3F), 269bcee7ed0SSrinivas Kandagatla WCD_MBHC_FIELD(WCD_MBHC_ADC_MODE, WCD938X_MBHC_NEW_CTL_1, 0x10), 270bcee7ed0SSrinivas Kandagatla WCD_MBHC_FIELD(WCD_MBHC_DETECTION_DONE, WCD938X_MBHC_NEW_CTL_1, 0x04), 271bcee7ed0SSrinivas Kandagatla WCD_MBHC_FIELD(WCD_MBHC_ELECT_ISRC_EN, WCD938X_ANA_MBHC_ZDET, 0x02), 272bcee7ed0SSrinivas Kandagatla }; 273bcee7ed0SSrinivas Kandagatla 2748d78602aSSrinivas Kandagatla static const struct reg_default wcd938x_defaults[] = { 2758d78602aSSrinivas Kandagatla {WCD938X_ANA_PAGE_REGISTER, 0x00}, 2768d78602aSSrinivas Kandagatla {WCD938X_ANA_BIAS, 0x00}, 2778d78602aSSrinivas Kandagatla {WCD938X_ANA_RX_SUPPLIES, 0x00}, 2788d78602aSSrinivas Kandagatla {WCD938X_ANA_HPH, 0x0C}, 2798d78602aSSrinivas Kandagatla {WCD938X_ANA_EAR, 0x00}, 2808d78602aSSrinivas Kandagatla {WCD938X_ANA_EAR_COMPANDER_CTL, 0x02}, 2818d78602aSSrinivas Kandagatla {WCD938X_ANA_TX_CH1, 0x20}, 2828d78602aSSrinivas Kandagatla {WCD938X_ANA_TX_CH2, 0x00}, 2838d78602aSSrinivas Kandagatla {WCD938X_ANA_TX_CH3, 0x20}, 2848d78602aSSrinivas Kandagatla {WCD938X_ANA_TX_CH4, 0x00}, 2858d78602aSSrinivas Kandagatla {WCD938X_ANA_MICB1_MICB2_DSP_EN_LOGIC, 0x00}, 2868d78602aSSrinivas Kandagatla {WCD938X_ANA_MICB3_DSP_EN_LOGIC, 0x00}, 2878d78602aSSrinivas Kandagatla {WCD938X_ANA_MBHC_MECH, 0x39}, 2888d78602aSSrinivas Kandagatla {WCD938X_ANA_MBHC_ELECT, 0x08}, 2898d78602aSSrinivas Kandagatla {WCD938X_ANA_MBHC_ZDET, 0x00}, 2908d78602aSSrinivas Kandagatla {WCD938X_ANA_MBHC_RESULT_1, 0x00}, 2918d78602aSSrinivas Kandagatla {WCD938X_ANA_MBHC_RESULT_2, 0x00}, 2928d78602aSSrinivas Kandagatla {WCD938X_ANA_MBHC_RESULT_3, 0x00}, 2938d78602aSSrinivas Kandagatla {WCD938X_ANA_MBHC_BTN0, 0x00}, 2948d78602aSSrinivas Kandagatla {WCD938X_ANA_MBHC_BTN1, 0x10}, 2958d78602aSSrinivas Kandagatla {WCD938X_ANA_MBHC_BTN2, 0x20}, 2968d78602aSSrinivas Kandagatla {WCD938X_ANA_MBHC_BTN3, 0x30}, 2978d78602aSSrinivas Kandagatla {WCD938X_ANA_MBHC_BTN4, 0x40}, 2988d78602aSSrinivas Kandagatla {WCD938X_ANA_MBHC_BTN5, 0x50}, 2998d78602aSSrinivas Kandagatla {WCD938X_ANA_MBHC_BTN6, 0x60}, 3008d78602aSSrinivas Kandagatla {WCD938X_ANA_MBHC_BTN7, 0x70}, 3018d78602aSSrinivas Kandagatla {WCD938X_ANA_MICB1, 0x10}, 3028d78602aSSrinivas Kandagatla {WCD938X_ANA_MICB2, 0x10}, 3038d78602aSSrinivas Kandagatla {WCD938X_ANA_MICB2_RAMP, 0x00}, 3048d78602aSSrinivas Kandagatla {WCD938X_ANA_MICB3, 0x10}, 3058d78602aSSrinivas Kandagatla {WCD938X_ANA_MICB4, 0x10}, 3068d78602aSSrinivas Kandagatla {WCD938X_BIAS_CTL, 0x2A}, 3078d78602aSSrinivas Kandagatla {WCD938X_BIAS_VBG_FINE_ADJ, 0x55}, 3088d78602aSSrinivas Kandagatla {WCD938X_LDOL_VDDCX_ADJUST, 0x01}, 3098d78602aSSrinivas Kandagatla {WCD938X_LDOL_DISABLE_LDOL, 0x00}, 3108d78602aSSrinivas Kandagatla {WCD938X_MBHC_CTL_CLK, 0x00}, 3118d78602aSSrinivas Kandagatla {WCD938X_MBHC_CTL_ANA, 0x00}, 3128d78602aSSrinivas Kandagatla {WCD938X_MBHC_CTL_SPARE_1, 0x00}, 3138d78602aSSrinivas Kandagatla {WCD938X_MBHC_CTL_SPARE_2, 0x00}, 3148d78602aSSrinivas Kandagatla {WCD938X_MBHC_CTL_BCS, 0x00}, 3158d78602aSSrinivas Kandagatla {WCD938X_MBHC_MOISTURE_DET_FSM_STATUS, 0x00}, 3168d78602aSSrinivas Kandagatla {WCD938X_MBHC_TEST_CTL, 0x00}, 3178d78602aSSrinivas Kandagatla {WCD938X_LDOH_MODE, 0x2B}, 3188d78602aSSrinivas Kandagatla {WCD938X_LDOH_BIAS, 0x68}, 3198d78602aSSrinivas Kandagatla {WCD938X_LDOH_STB_LOADS, 0x00}, 3208d78602aSSrinivas Kandagatla {WCD938X_LDOH_SLOWRAMP, 0x50}, 3218d78602aSSrinivas Kandagatla {WCD938X_MICB1_TEST_CTL_1, 0x1A}, 3228d78602aSSrinivas Kandagatla {WCD938X_MICB1_TEST_CTL_2, 0x00}, 3238d78602aSSrinivas Kandagatla {WCD938X_MICB1_TEST_CTL_3, 0xA4}, 3248d78602aSSrinivas Kandagatla {WCD938X_MICB2_TEST_CTL_1, 0x1A}, 3258d78602aSSrinivas Kandagatla {WCD938X_MICB2_TEST_CTL_2, 0x00}, 3268d78602aSSrinivas Kandagatla {WCD938X_MICB2_TEST_CTL_3, 0x24}, 3278d78602aSSrinivas Kandagatla {WCD938X_MICB3_TEST_CTL_1, 0x1A}, 3288d78602aSSrinivas Kandagatla {WCD938X_MICB3_TEST_CTL_2, 0x00}, 3298d78602aSSrinivas Kandagatla {WCD938X_MICB3_TEST_CTL_3, 0xA4}, 3308d78602aSSrinivas Kandagatla {WCD938X_MICB4_TEST_CTL_1, 0x1A}, 3318d78602aSSrinivas Kandagatla {WCD938X_MICB4_TEST_CTL_2, 0x00}, 3328d78602aSSrinivas Kandagatla {WCD938X_MICB4_TEST_CTL_3, 0xA4}, 3338d78602aSSrinivas Kandagatla {WCD938X_TX_COM_ADC_VCM, 0x39}, 3348d78602aSSrinivas Kandagatla {WCD938X_TX_COM_BIAS_ATEST, 0xE0}, 3358d78602aSSrinivas Kandagatla {WCD938X_TX_COM_SPARE1, 0x00}, 3368d78602aSSrinivas Kandagatla {WCD938X_TX_COM_SPARE2, 0x00}, 3378d78602aSSrinivas Kandagatla {WCD938X_TX_COM_TXFE_DIV_CTL, 0x22}, 3388d78602aSSrinivas Kandagatla {WCD938X_TX_COM_TXFE_DIV_START, 0x00}, 3398d78602aSSrinivas Kandagatla {WCD938X_TX_COM_SPARE3, 0x00}, 3408d78602aSSrinivas Kandagatla {WCD938X_TX_COM_SPARE4, 0x00}, 3418d78602aSSrinivas Kandagatla {WCD938X_TX_1_2_TEST_EN, 0xCC}, 3428d78602aSSrinivas Kandagatla {WCD938X_TX_1_2_ADC_IB, 0xE9}, 3438d78602aSSrinivas Kandagatla {WCD938X_TX_1_2_ATEST_REFCTL, 0x0A}, 3448d78602aSSrinivas Kandagatla {WCD938X_TX_1_2_TEST_CTL, 0x38}, 3458d78602aSSrinivas Kandagatla {WCD938X_TX_1_2_TEST_BLK_EN1, 0xFF}, 3468d78602aSSrinivas Kandagatla {WCD938X_TX_1_2_TXFE1_CLKDIV, 0x00}, 3478d78602aSSrinivas Kandagatla {WCD938X_TX_1_2_SAR2_ERR, 0x00}, 3488d78602aSSrinivas Kandagatla {WCD938X_TX_1_2_SAR1_ERR, 0x00}, 3498d78602aSSrinivas Kandagatla {WCD938X_TX_3_4_TEST_EN, 0xCC}, 3508d78602aSSrinivas Kandagatla {WCD938X_TX_3_4_ADC_IB, 0xE9}, 3518d78602aSSrinivas Kandagatla {WCD938X_TX_3_4_ATEST_REFCTL, 0x0A}, 3528d78602aSSrinivas Kandagatla {WCD938X_TX_3_4_TEST_CTL, 0x38}, 3538d78602aSSrinivas Kandagatla {WCD938X_TX_3_4_TEST_BLK_EN3, 0xFF}, 3548d78602aSSrinivas Kandagatla {WCD938X_TX_3_4_TXFE3_CLKDIV, 0x00}, 3558d78602aSSrinivas Kandagatla {WCD938X_TX_3_4_SAR4_ERR, 0x00}, 3568d78602aSSrinivas Kandagatla {WCD938X_TX_3_4_SAR3_ERR, 0x00}, 3578d78602aSSrinivas Kandagatla {WCD938X_TX_3_4_TEST_BLK_EN2, 0xFB}, 3588d78602aSSrinivas Kandagatla {WCD938X_TX_3_4_TXFE2_CLKDIV, 0x00}, 3598d78602aSSrinivas Kandagatla {WCD938X_TX_3_4_SPARE1, 0x00}, 3608d78602aSSrinivas Kandagatla {WCD938X_TX_3_4_TEST_BLK_EN4, 0xFB}, 3618d78602aSSrinivas Kandagatla {WCD938X_TX_3_4_TXFE4_CLKDIV, 0x00}, 3628d78602aSSrinivas Kandagatla {WCD938X_TX_3_4_SPARE2, 0x00}, 3638d78602aSSrinivas Kandagatla {WCD938X_CLASSH_MODE_1, 0x40}, 3648d78602aSSrinivas Kandagatla {WCD938X_CLASSH_MODE_2, 0x3A}, 3658d78602aSSrinivas Kandagatla {WCD938X_CLASSH_MODE_3, 0x00}, 3668d78602aSSrinivas Kandagatla {WCD938X_CLASSH_CTRL_VCL_1, 0x70}, 3678d78602aSSrinivas Kandagatla {WCD938X_CLASSH_CTRL_VCL_2, 0x82}, 3688d78602aSSrinivas Kandagatla {WCD938X_CLASSH_CTRL_CCL_1, 0x31}, 3698d78602aSSrinivas Kandagatla {WCD938X_CLASSH_CTRL_CCL_2, 0x80}, 3708d78602aSSrinivas Kandagatla {WCD938X_CLASSH_CTRL_CCL_3, 0x80}, 3718d78602aSSrinivas Kandagatla {WCD938X_CLASSH_CTRL_CCL_4, 0x51}, 3728d78602aSSrinivas Kandagatla {WCD938X_CLASSH_CTRL_CCL_5, 0x00}, 3738d78602aSSrinivas Kandagatla {WCD938X_CLASSH_BUCK_TMUX_A_D, 0x00}, 3748d78602aSSrinivas Kandagatla {WCD938X_CLASSH_BUCK_SW_DRV_CNTL, 0x77}, 3758d78602aSSrinivas Kandagatla {WCD938X_CLASSH_SPARE, 0x00}, 3768d78602aSSrinivas Kandagatla {WCD938X_FLYBACK_EN, 0x4E}, 3778d78602aSSrinivas Kandagatla {WCD938X_FLYBACK_VNEG_CTRL_1, 0x0B}, 3788d78602aSSrinivas Kandagatla {WCD938X_FLYBACK_VNEG_CTRL_2, 0x45}, 3798d78602aSSrinivas Kandagatla {WCD938X_FLYBACK_VNEG_CTRL_3, 0x74}, 3808d78602aSSrinivas Kandagatla {WCD938X_FLYBACK_VNEG_CTRL_4, 0x7F}, 3818d78602aSSrinivas Kandagatla {WCD938X_FLYBACK_VNEG_CTRL_5, 0x83}, 3828d78602aSSrinivas Kandagatla {WCD938X_FLYBACK_VNEG_CTRL_6, 0x98}, 3838d78602aSSrinivas Kandagatla {WCD938X_FLYBACK_VNEG_CTRL_7, 0xA9}, 3848d78602aSSrinivas Kandagatla {WCD938X_FLYBACK_VNEG_CTRL_8, 0x68}, 3858d78602aSSrinivas Kandagatla {WCD938X_FLYBACK_VNEG_CTRL_9, 0x64}, 3868d78602aSSrinivas Kandagatla {WCD938X_FLYBACK_VNEGDAC_CTRL_1, 0xED}, 3878d78602aSSrinivas Kandagatla {WCD938X_FLYBACK_VNEGDAC_CTRL_2, 0xF0}, 3888d78602aSSrinivas Kandagatla {WCD938X_FLYBACK_VNEGDAC_CTRL_3, 0xA6}, 3898d78602aSSrinivas Kandagatla {WCD938X_FLYBACK_CTRL_1, 0x65}, 3908d78602aSSrinivas Kandagatla {WCD938X_FLYBACK_TEST_CTL, 0x00}, 3918d78602aSSrinivas Kandagatla {WCD938X_RX_AUX_SW_CTL, 0x00}, 3928d78602aSSrinivas Kandagatla {WCD938X_RX_PA_AUX_IN_CONN, 0x01}, 3938d78602aSSrinivas Kandagatla {WCD938X_RX_TIMER_DIV, 0x32}, 3948d78602aSSrinivas Kandagatla {WCD938X_RX_OCP_CTL, 0x1F}, 3958d78602aSSrinivas Kandagatla {WCD938X_RX_OCP_COUNT, 0x77}, 3968d78602aSSrinivas Kandagatla {WCD938X_RX_BIAS_EAR_DAC, 0xA0}, 3978d78602aSSrinivas Kandagatla {WCD938X_RX_BIAS_EAR_AMP, 0xAA}, 3988d78602aSSrinivas Kandagatla {WCD938X_RX_BIAS_HPH_LDO, 0xA9}, 3998d78602aSSrinivas Kandagatla {WCD938X_RX_BIAS_HPH_PA, 0xAA}, 4008d78602aSSrinivas Kandagatla {WCD938X_RX_BIAS_HPH_RDACBUFF_CNP2, 0x8A}, 4018d78602aSSrinivas Kandagatla {WCD938X_RX_BIAS_HPH_RDAC_LDO, 0x88}, 4028d78602aSSrinivas Kandagatla {WCD938X_RX_BIAS_HPH_CNP1, 0x82}, 4038d78602aSSrinivas Kandagatla {WCD938X_RX_BIAS_HPH_LOWPOWER, 0x82}, 4048d78602aSSrinivas Kandagatla {WCD938X_RX_BIAS_AUX_DAC, 0xA0}, 4058d78602aSSrinivas Kandagatla {WCD938X_RX_BIAS_AUX_AMP, 0xAA}, 4068d78602aSSrinivas Kandagatla {WCD938X_RX_BIAS_VNEGDAC_BLEEDER, 0x50}, 4078d78602aSSrinivas Kandagatla {WCD938X_RX_BIAS_MISC, 0x00}, 4088d78602aSSrinivas Kandagatla {WCD938X_RX_BIAS_BUCK_RST, 0x08}, 4098d78602aSSrinivas Kandagatla {WCD938X_RX_BIAS_BUCK_VREF_ERRAMP, 0x44}, 4108d78602aSSrinivas Kandagatla {WCD938X_RX_BIAS_FLYB_ERRAMP, 0x40}, 4118d78602aSSrinivas Kandagatla {WCD938X_RX_BIAS_FLYB_BUFF, 0xAA}, 4128d78602aSSrinivas Kandagatla {WCD938X_RX_BIAS_FLYB_MID_RST, 0x14}, 4138d78602aSSrinivas Kandagatla {WCD938X_HPH_L_STATUS, 0x04}, 4148d78602aSSrinivas Kandagatla {WCD938X_HPH_R_STATUS, 0x04}, 4158d78602aSSrinivas Kandagatla {WCD938X_HPH_CNP_EN, 0x80}, 4168d78602aSSrinivas Kandagatla {WCD938X_HPH_CNP_WG_CTL, 0x9A}, 4178d78602aSSrinivas Kandagatla {WCD938X_HPH_CNP_WG_TIME, 0x14}, 4188d78602aSSrinivas Kandagatla {WCD938X_HPH_OCP_CTL, 0x28}, 4198d78602aSSrinivas Kandagatla {WCD938X_HPH_AUTO_CHOP, 0x16}, 4208d78602aSSrinivas Kandagatla {WCD938X_HPH_CHOP_CTL, 0x83}, 4218d78602aSSrinivas Kandagatla {WCD938X_HPH_PA_CTL1, 0x46}, 4228d78602aSSrinivas Kandagatla {WCD938X_HPH_PA_CTL2, 0x50}, 4238d78602aSSrinivas Kandagatla {WCD938X_HPH_L_EN, 0x80}, 4248d78602aSSrinivas Kandagatla {WCD938X_HPH_L_TEST, 0xE0}, 4258d78602aSSrinivas Kandagatla {WCD938X_HPH_L_ATEST, 0x50}, 4268d78602aSSrinivas Kandagatla {WCD938X_HPH_R_EN, 0x80}, 4278d78602aSSrinivas Kandagatla {WCD938X_HPH_R_TEST, 0xE0}, 4288d78602aSSrinivas Kandagatla {WCD938X_HPH_R_ATEST, 0x54}, 4298d78602aSSrinivas Kandagatla {WCD938X_HPH_RDAC_CLK_CTL1, 0x99}, 4308d78602aSSrinivas Kandagatla {WCD938X_HPH_RDAC_CLK_CTL2, 0x9B}, 4318d78602aSSrinivas Kandagatla {WCD938X_HPH_RDAC_LDO_CTL, 0x33}, 4328d78602aSSrinivas Kandagatla {WCD938X_HPH_RDAC_CHOP_CLK_LP_CTL, 0x00}, 4338d78602aSSrinivas Kandagatla {WCD938X_HPH_REFBUFF_UHQA_CTL, 0x68}, 4348d78602aSSrinivas Kandagatla {WCD938X_HPH_REFBUFF_LP_CTL, 0x0E}, 4358d78602aSSrinivas Kandagatla {WCD938X_HPH_L_DAC_CTL, 0x20}, 4368d78602aSSrinivas Kandagatla {WCD938X_HPH_R_DAC_CTL, 0x20}, 4378d78602aSSrinivas Kandagatla {WCD938X_HPH_SURGE_HPHLR_SURGE_COMP_SEL, 0x55}, 4388d78602aSSrinivas Kandagatla {WCD938X_HPH_SURGE_HPHLR_SURGE_EN, 0x19}, 4398d78602aSSrinivas Kandagatla {WCD938X_HPH_SURGE_HPHLR_SURGE_MISC1, 0xA0}, 4408d78602aSSrinivas Kandagatla {WCD938X_HPH_SURGE_HPHLR_SURGE_STATUS, 0x00}, 4418d78602aSSrinivas Kandagatla {WCD938X_EAR_EAR_EN_REG, 0x22}, 4428d78602aSSrinivas Kandagatla {WCD938X_EAR_EAR_PA_CON, 0x44}, 4438d78602aSSrinivas Kandagatla {WCD938X_EAR_EAR_SP_CON, 0xDB}, 4448d78602aSSrinivas Kandagatla {WCD938X_EAR_EAR_DAC_CON, 0x80}, 4458d78602aSSrinivas Kandagatla {WCD938X_EAR_EAR_CNP_FSM_CON, 0xB2}, 4468d78602aSSrinivas Kandagatla {WCD938X_EAR_TEST_CTL, 0x00}, 4478d78602aSSrinivas Kandagatla {WCD938X_EAR_STATUS_REG_1, 0x00}, 4488d78602aSSrinivas Kandagatla {WCD938X_EAR_STATUS_REG_2, 0x08}, 4498d78602aSSrinivas Kandagatla {WCD938X_ANA_NEW_PAGE_REGISTER, 0x00}, 4508d78602aSSrinivas Kandagatla {WCD938X_HPH_NEW_ANA_HPH2, 0x00}, 4518d78602aSSrinivas Kandagatla {WCD938X_HPH_NEW_ANA_HPH3, 0x00}, 4528d78602aSSrinivas Kandagatla {WCD938X_SLEEP_CTL, 0x16}, 4538d78602aSSrinivas Kandagatla {WCD938X_SLEEP_WATCHDOG_CTL, 0x00}, 4548d78602aSSrinivas Kandagatla {WCD938X_MBHC_NEW_ELECT_REM_CLAMP_CTL, 0x00}, 4558d78602aSSrinivas Kandagatla {WCD938X_MBHC_NEW_CTL_1, 0x02}, 4568d78602aSSrinivas Kandagatla {WCD938X_MBHC_NEW_CTL_2, 0x05}, 4578d78602aSSrinivas Kandagatla {WCD938X_MBHC_NEW_PLUG_DETECT_CTL, 0xE9}, 4588d78602aSSrinivas Kandagatla {WCD938X_MBHC_NEW_ZDET_ANA_CTL, 0x0F}, 4598d78602aSSrinivas Kandagatla {WCD938X_MBHC_NEW_ZDET_RAMP_CTL, 0x00}, 4608d78602aSSrinivas Kandagatla {WCD938X_MBHC_NEW_FSM_STATUS, 0x00}, 4618d78602aSSrinivas Kandagatla {WCD938X_MBHC_NEW_ADC_RESULT, 0x00}, 4628d78602aSSrinivas Kandagatla {WCD938X_TX_NEW_AMIC_MUX_CFG, 0x00}, 4638d78602aSSrinivas Kandagatla {WCD938X_AUX_AUXPA, 0x00}, 4648d78602aSSrinivas Kandagatla {WCD938X_LDORXTX_MODE, 0x0C}, 4658d78602aSSrinivas Kandagatla {WCD938X_LDORXTX_CONFIG, 0x10}, 4668d78602aSSrinivas Kandagatla {WCD938X_DIE_CRACK_DIE_CRK_DET_EN, 0x00}, 4678d78602aSSrinivas Kandagatla {WCD938X_DIE_CRACK_DIE_CRK_DET_OUT, 0x00}, 4688d78602aSSrinivas Kandagatla {WCD938X_HPH_NEW_INT_RDAC_GAIN_CTL, 0x40}, 4698d78602aSSrinivas Kandagatla {WCD938X_HPH_NEW_INT_RDAC_HD2_CTL_L, 0x81}, 4708d78602aSSrinivas Kandagatla {WCD938X_HPH_NEW_INT_RDAC_VREF_CTL, 0x10}, 4718d78602aSSrinivas Kandagatla {WCD938X_HPH_NEW_INT_RDAC_OVERRIDE_CTL, 0x00}, 4728d78602aSSrinivas Kandagatla {WCD938X_HPH_NEW_INT_RDAC_HD2_CTL_R, 0x81}, 4738d78602aSSrinivas Kandagatla {WCD938X_HPH_NEW_INT_PA_MISC1, 0x22}, 4748d78602aSSrinivas Kandagatla {WCD938X_HPH_NEW_INT_PA_MISC2, 0x00}, 4758d78602aSSrinivas Kandagatla {WCD938X_HPH_NEW_INT_PA_RDAC_MISC, 0x00}, 4768d78602aSSrinivas Kandagatla {WCD938X_HPH_NEW_INT_HPH_TIMER1, 0xFE}, 4778d78602aSSrinivas Kandagatla {WCD938X_HPH_NEW_INT_HPH_TIMER2, 0x02}, 4788d78602aSSrinivas Kandagatla {WCD938X_HPH_NEW_INT_HPH_TIMER3, 0x4E}, 4798d78602aSSrinivas Kandagatla {WCD938X_HPH_NEW_INT_HPH_TIMER4, 0x54}, 4808d78602aSSrinivas Kandagatla {WCD938X_HPH_NEW_INT_PA_RDAC_MISC2, 0x00}, 4818d78602aSSrinivas Kandagatla {WCD938X_HPH_NEW_INT_PA_RDAC_MISC3, 0x00}, 4828d78602aSSrinivas Kandagatla {WCD938X_HPH_NEW_INT_RDAC_HD2_CTL_L_NEW, 0x90}, 4838d78602aSSrinivas Kandagatla {WCD938X_HPH_NEW_INT_RDAC_HD2_CTL_R_NEW, 0x90}, 4848d78602aSSrinivas Kandagatla {WCD938X_RX_NEW_INT_HPH_RDAC_BIAS_LOHIFI, 0x62}, 4858d78602aSSrinivas Kandagatla {WCD938X_RX_NEW_INT_HPH_RDAC_BIAS_ULP, 0x01}, 4868d78602aSSrinivas Kandagatla {WCD938X_RX_NEW_INT_HPH_RDAC_LDO_LP, 0x11}, 4878d78602aSSrinivas Kandagatla {WCD938X_MBHC_NEW_INT_MOISTURE_DET_DC_CTRL, 0x57}, 4888d78602aSSrinivas Kandagatla {WCD938X_MBHC_NEW_INT_MOISTURE_DET_POLLING_CTRL, 0x01}, 4898d78602aSSrinivas Kandagatla {WCD938X_MBHC_NEW_INT_MECH_DET_CURRENT, 0x00}, 4908d78602aSSrinivas Kandagatla {WCD938X_MBHC_NEW_INT_SPARE_2, 0x00}, 4918d78602aSSrinivas Kandagatla {WCD938X_EAR_INT_NEW_EAR_CHOPPER_CON, 0xA8}, 4928d78602aSSrinivas Kandagatla {WCD938X_EAR_INT_NEW_CNP_VCM_CON1, 0x42}, 4938d78602aSSrinivas Kandagatla {WCD938X_EAR_INT_NEW_CNP_VCM_CON2, 0x22}, 4948d78602aSSrinivas Kandagatla {WCD938X_EAR_INT_NEW_EAR_DYNAMIC_BIAS, 0x00}, 4958d78602aSSrinivas Kandagatla {WCD938X_AUX_INT_EN_REG, 0x00}, 4968d78602aSSrinivas Kandagatla {WCD938X_AUX_INT_PA_CTRL, 0x06}, 4978d78602aSSrinivas Kandagatla {WCD938X_AUX_INT_SP_CTRL, 0xD2}, 4988d78602aSSrinivas Kandagatla {WCD938X_AUX_INT_DAC_CTRL, 0x80}, 4998d78602aSSrinivas Kandagatla {WCD938X_AUX_INT_CLK_CTRL, 0x50}, 5008d78602aSSrinivas Kandagatla {WCD938X_AUX_INT_TEST_CTRL, 0x00}, 5018d78602aSSrinivas Kandagatla {WCD938X_AUX_INT_STATUS_REG, 0x00}, 5028d78602aSSrinivas Kandagatla {WCD938X_AUX_INT_MISC, 0x00}, 5038d78602aSSrinivas Kandagatla {WCD938X_LDORXTX_INT_BIAS, 0x6E}, 5048d78602aSSrinivas Kandagatla {WCD938X_LDORXTX_INT_STB_LOADS_DTEST, 0x50}, 5058d78602aSSrinivas Kandagatla {WCD938X_LDORXTX_INT_TEST0, 0x1C}, 5068d78602aSSrinivas Kandagatla {WCD938X_LDORXTX_INT_STARTUP_TIMER, 0xFF}, 5078d78602aSSrinivas Kandagatla {WCD938X_LDORXTX_INT_TEST1, 0x1F}, 5088d78602aSSrinivas Kandagatla {WCD938X_LDORXTX_INT_STATUS, 0x00}, 5098d78602aSSrinivas Kandagatla {WCD938X_SLEEP_INT_WATCHDOG_CTL_1, 0x0A}, 5108d78602aSSrinivas Kandagatla {WCD938X_SLEEP_INT_WATCHDOG_CTL_2, 0x0A}, 5118d78602aSSrinivas Kandagatla {WCD938X_DIE_CRACK_INT_DIE_CRK_DET_INT1, 0x02}, 5128d78602aSSrinivas Kandagatla {WCD938X_DIE_CRACK_INT_DIE_CRK_DET_INT2, 0x60}, 5138d78602aSSrinivas Kandagatla {WCD938X_TX_COM_NEW_INT_TXFE_DIVSTOP_L2, 0xFF}, 5148d78602aSSrinivas Kandagatla {WCD938X_TX_COM_NEW_INT_TXFE_DIVSTOP_L1, 0x7F}, 5158d78602aSSrinivas Kandagatla {WCD938X_TX_COM_NEW_INT_TXFE_DIVSTOP_L0, 0x3F}, 5168d78602aSSrinivas Kandagatla {WCD938X_TX_COM_NEW_INT_TXFE_DIVSTOP_ULP1P2M, 0x1F}, 5178d78602aSSrinivas Kandagatla {WCD938X_TX_COM_NEW_INT_TXFE_DIVSTOP_ULP0P6M, 0x0F}, 5188d78602aSSrinivas Kandagatla {WCD938X_TX_COM_NEW_INT_TXFE_ICTRL_STG1_L2L1, 0xD7}, 5198d78602aSSrinivas Kandagatla {WCD938X_TX_COM_NEW_INT_TXFE_ICTRL_STG1_L0, 0xC8}, 5208d78602aSSrinivas Kandagatla {WCD938X_TX_COM_NEW_INT_TXFE_ICTRL_STG1_ULP, 0xC6}, 5218d78602aSSrinivas Kandagatla {WCD938X_TX_COM_NEW_INT_TXFE_ICTRL_STG2MAIN_L2L1, 0xD5}, 5228d78602aSSrinivas Kandagatla {WCD938X_TX_COM_NEW_INT_TXFE_ICTRL_STG2MAIN_L0, 0xCA}, 5238d78602aSSrinivas Kandagatla {WCD938X_TX_COM_NEW_INT_TXFE_ICTRL_STG2MAIN_ULP, 0x05}, 5248d78602aSSrinivas Kandagatla {WCD938X_TX_COM_NEW_INT_TXFE_ICTRL_STG2CASC_L2L1L0, 0xA5}, 5258d78602aSSrinivas Kandagatla {WCD938X_TX_COM_NEW_INT_TXFE_ICTRL_STG2CASC_ULP, 0x13}, 5268d78602aSSrinivas Kandagatla {WCD938X_TX_COM_NEW_INT_TXADC_SCBIAS_L2L1, 0x88}, 5278d78602aSSrinivas Kandagatla {WCD938X_TX_COM_NEW_INT_TXADC_SCBIAS_L0ULP, 0x42}, 5288d78602aSSrinivas Kandagatla {WCD938X_TX_COM_NEW_INT_TXADC_INT_L2, 0xFF}, 5298d78602aSSrinivas Kandagatla {WCD938X_TX_COM_NEW_INT_TXADC_INT_L1, 0x64}, 5308d78602aSSrinivas Kandagatla {WCD938X_TX_COM_NEW_INT_TXADC_INT_L0, 0x64}, 5318d78602aSSrinivas Kandagatla {WCD938X_TX_COM_NEW_INT_TXADC_INT_ULP, 0x77}, 5328d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_PAGE_REGISTER, 0x00}, 5338d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_CHIP_ID0, 0x00}, 5348d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_CHIP_ID1, 0x00}, 5358d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_CHIP_ID2, 0x0D}, 5368d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_CHIP_ID3, 0x01}, 5378d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_SWR_TX_CLK_RATE, 0x00}, 5388d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_CDC_RST_CTL, 0x03}, 5398d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_TOP_CLK_CFG, 0x00}, 5408d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_CDC_ANA_CLK_CTL, 0x00}, 5418d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_CDC_DIG_CLK_CTL, 0xF0}, 5428d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_SWR_RST_EN, 0x00}, 5438d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_CDC_PATH_MODE, 0x55}, 5448d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_CDC_RX_RST, 0x00}, 5458d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_CDC_RX0_CTL, 0xFC}, 5468d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_CDC_RX1_CTL, 0xFC}, 5478d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_CDC_RX2_CTL, 0xFC}, 5488d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_CDC_TX_ANA_MODE_0_1, 0x00}, 5498d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_CDC_TX_ANA_MODE_2_3, 0x00}, 5508d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_CDC_COMP_CTL_0, 0x00}, 5518d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_CDC_ANA_TX_CLK_CTL, 0x1E}, 5528d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_CDC_HPH_DSM_A1_0, 0x00}, 5538d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_CDC_HPH_DSM_A1_1, 0x01}, 5548d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_CDC_HPH_DSM_A2_0, 0x63}, 5558d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_CDC_HPH_DSM_A2_1, 0x04}, 5568d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_CDC_HPH_DSM_A3_0, 0xAC}, 5578d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_CDC_HPH_DSM_A3_1, 0x04}, 5588d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_CDC_HPH_DSM_A4_0, 0x1A}, 5598d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_CDC_HPH_DSM_A4_1, 0x03}, 5608d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_CDC_HPH_DSM_A5_0, 0xBC}, 5618d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_CDC_HPH_DSM_A5_1, 0x02}, 5628d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_CDC_HPH_DSM_A6_0, 0xC7}, 5638d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_CDC_HPH_DSM_A7_0, 0xF8}, 5648d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_CDC_HPH_DSM_C_0, 0x47}, 5658d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_CDC_HPH_DSM_C_1, 0x43}, 5668d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_CDC_HPH_DSM_C_2, 0xB1}, 5678d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_CDC_HPH_DSM_C_3, 0x17}, 5688d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_CDC_HPH_DSM_R1, 0x4D}, 5698d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_CDC_HPH_DSM_R2, 0x29}, 5708d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_CDC_HPH_DSM_R3, 0x34}, 5718d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_CDC_HPH_DSM_R4, 0x59}, 5728d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_CDC_HPH_DSM_R5, 0x66}, 5738d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_CDC_HPH_DSM_R6, 0x87}, 5748d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_CDC_HPH_DSM_R7, 0x64}, 5758d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_CDC_AUX_DSM_A1_0, 0x00}, 5768d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_CDC_AUX_DSM_A1_1, 0x01}, 5778d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_CDC_AUX_DSM_A2_0, 0x96}, 5788d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_CDC_AUX_DSM_A2_1, 0x09}, 5798d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_CDC_AUX_DSM_A3_0, 0xAB}, 5808d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_CDC_AUX_DSM_A3_1, 0x05}, 5818d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_CDC_AUX_DSM_A4_0, 0x1C}, 5828d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_CDC_AUX_DSM_A4_1, 0x02}, 5838d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_CDC_AUX_DSM_A5_0, 0x17}, 5848d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_CDC_AUX_DSM_A5_1, 0x02}, 5858d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_CDC_AUX_DSM_A6_0, 0xAA}, 5868d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_CDC_AUX_DSM_A7_0, 0xE3}, 5878d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_CDC_AUX_DSM_C_0, 0x69}, 5888d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_CDC_AUX_DSM_C_1, 0x54}, 5898d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_CDC_AUX_DSM_C_2, 0x02}, 5908d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_CDC_AUX_DSM_C_3, 0x15}, 5918d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_CDC_AUX_DSM_R1, 0xA4}, 5928d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_CDC_AUX_DSM_R2, 0xB5}, 5938d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_CDC_AUX_DSM_R3, 0x86}, 5948d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_CDC_AUX_DSM_R4, 0x85}, 5958d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_CDC_AUX_DSM_R5, 0xAA}, 5968d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_CDC_AUX_DSM_R6, 0xE2}, 5978d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_CDC_AUX_DSM_R7, 0x62}, 5988d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_CDC_HPH_GAIN_RX_0, 0x55}, 5998d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_CDC_HPH_GAIN_RX_1, 0xA9}, 6008d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_CDC_HPH_GAIN_DSD_0, 0x3D}, 6018d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_CDC_HPH_GAIN_DSD_1, 0x2E}, 6028d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_CDC_HPH_GAIN_DSD_2, 0x01}, 6038d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_CDC_AUX_GAIN_DSD_0, 0x00}, 6048d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_CDC_AUX_GAIN_DSD_1, 0xFC}, 6058d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_CDC_AUX_GAIN_DSD_2, 0x01}, 6068d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_CDC_HPH_GAIN_CTL, 0x00}, 6078d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_CDC_AUX_GAIN_CTL, 0x00}, 6088d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_CDC_EAR_PATH_CTL, 0x00}, 6098d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_CDC_SWR_CLH, 0x00}, 6108d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_SWR_CLH_BYP, 0x00}, 6118d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_CDC_TX0_CTL, 0x68}, 6128d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_CDC_TX1_CTL, 0x68}, 6138d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_CDC_TX2_CTL, 0x68}, 6148d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_CDC_TX_RST, 0x00}, 6158d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_CDC_REQ_CTL, 0x01}, 6168d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_CDC_RST, 0x00}, 6178d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_CDC_AMIC_CTL, 0x0F}, 6188d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_CDC_DMIC_CTL, 0x04}, 6198d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_CDC_DMIC1_CTL, 0x01}, 6208d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_CDC_DMIC2_CTL, 0x01}, 6218d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_CDC_DMIC3_CTL, 0x01}, 6228d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_CDC_DMIC4_CTL, 0x01}, 6238d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_EFUSE_PRG_CTL, 0x00}, 6248d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_EFUSE_CTL, 0x2B}, 6258d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_CDC_DMIC_RATE_1_2, 0x11}, 6268d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_CDC_DMIC_RATE_3_4, 0x11}, 6278d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_PDM_WD_CTL0, 0x00}, 6288d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_PDM_WD_CTL1, 0x00}, 6298d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_PDM_WD_CTL2, 0x00}, 6308d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_INTR_MODE, 0x00}, 6318d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_INTR_MASK_0, 0xFF}, 6328d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_INTR_MASK_1, 0xFF}, 6338d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_INTR_MASK_2, 0x3F}, 6348d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_INTR_STATUS_0, 0x00}, 6358d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_INTR_STATUS_1, 0x00}, 6368d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_INTR_STATUS_2, 0x00}, 6378d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_INTR_CLEAR_0, 0x00}, 6388d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_INTR_CLEAR_1, 0x00}, 6398d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_INTR_CLEAR_2, 0x00}, 6408d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_INTR_LEVEL_0, 0x00}, 6418d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_INTR_LEVEL_1, 0x00}, 6428d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_INTR_LEVEL_2, 0x00}, 6438d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_INTR_SET_0, 0x00}, 6448d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_INTR_SET_1, 0x00}, 6458d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_INTR_SET_2, 0x00}, 6468d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_INTR_TEST_0, 0x00}, 6478d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_INTR_TEST_1, 0x00}, 6488d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_INTR_TEST_2, 0x00}, 6498d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_TX_MODE_DBG_EN, 0x00}, 6508d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_TX_MODE_DBG_0_1, 0x00}, 6518d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_TX_MODE_DBG_2_3, 0x00}, 6528d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_LB_IN_SEL_CTL, 0x00}, 6538d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_LOOP_BACK_MODE, 0x00}, 6548d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_SWR_DAC_TEST, 0x00}, 6558d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_SWR_HM_TEST_RX_0, 0x40}, 6568d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_SWR_HM_TEST_TX_0, 0x40}, 6578d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_SWR_HM_TEST_RX_1, 0x00}, 6588d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_SWR_HM_TEST_TX_1, 0x00}, 6598d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_SWR_HM_TEST_TX_2, 0x00}, 6608d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_SWR_HM_TEST_0, 0x00}, 6618d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_SWR_HM_TEST_1, 0x00}, 6628d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_PAD_CTL_SWR_0, 0x8F}, 6638d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_PAD_CTL_SWR_1, 0x06}, 6648d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_I2C_CTL, 0x00}, 6658d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_CDC_TX_TANGGU_SW_MODE, 0x00}, 6668d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_EFUSE_TEST_CTL_0, 0x00}, 6678d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_EFUSE_TEST_CTL_1, 0x00}, 6688d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_EFUSE_T_DATA_0, 0x00}, 6698d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_EFUSE_T_DATA_1, 0x00}, 6708d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_PAD_CTL_PDM_RX0, 0xF1}, 6718d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_PAD_CTL_PDM_RX1, 0xF1}, 6728d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_PAD_CTL_PDM_TX0, 0xF1}, 6738d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_PAD_CTL_PDM_TX1, 0xF1}, 6748d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_PAD_CTL_PDM_TX2, 0xF1}, 6758d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_PAD_INP_DIS_0, 0x00}, 6768d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_PAD_INP_DIS_1, 0x00}, 6778d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_DRIVE_STRENGTH_0, 0x00}, 6788d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_DRIVE_STRENGTH_1, 0x00}, 6798d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_DRIVE_STRENGTH_2, 0x00}, 6808d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_RX_DATA_EDGE_CTL, 0x1F}, 6818d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_TX_DATA_EDGE_CTL, 0x80}, 6828d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_GPIO_MODE, 0x00}, 6838d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_PIN_CTL_OE, 0x00}, 6848d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_PIN_CTL_DATA_0, 0x00}, 6858d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_PIN_CTL_DATA_1, 0x00}, 6868d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_PIN_STATUS_0, 0x00}, 6878d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_PIN_STATUS_1, 0x00}, 6888d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_DIG_DEBUG_CTL, 0x00}, 6898d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_DIG_DEBUG_EN, 0x00}, 6908d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_ANA_CSR_DBG_ADD, 0x00}, 6918d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_ANA_CSR_DBG_CTL, 0x48}, 6928d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_SSP_DBG, 0x00}, 6938d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_MODE_STATUS_0, 0x00}, 6948d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_MODE_STATUS_1, 0x00}, 6958d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_SPARE_0, 0x00}, 6968d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_SPARE_1, 0x00}, 6978d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_SPARE_2, 0x00}, 6988d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_EFUSE_REG_0, 0x00}, 6998d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_EFUSE_REG_1, 0xFF}, 7008d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_EFUSE_REG_2, 0xFF}, 7018d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_EFUSE_REG_3, 0xFF}, 7028d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_EFUSE_REG_4, 0xFF}, 7038d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_EFUSE_REG_5, 0xFF}, 7048d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_EFUSE_REG_6, 0xFF}, 7058d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_EFUSE_REG_7, 0xFF}, 7068d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_EFUSE_REG_8, 0xFF}, 7078d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_EFUSE_REG_9, 0xFF}, 7088d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_EFUSE_REG_10, 0xFF}, 7098d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_EFUSE_REG_11, 0xFF}, 7108d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_EFUSE_REG_12, 0xFF}, 7118d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_EFUSE_REG_13, 0xFF}, 7128d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_EFUSE_REG_14, 0xFF}, 7138d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_EFUSE_REG_15, 0xFF}, 7148d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_EFUSE_REG_16, 0xFF}, 7158d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_EFUSE_REG_17, 0xFF}, 7168d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_EFUSE_REG_18, 0xFF}, 7178d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_EFUSE_REG_19, 0xFF}, 7188d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_EFUSE_REG_20, 0x0E}, 7198d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_EFUSE_REG_21, 0x00}, 7208d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_EFUSE_REG_22, 0x00}, 7218d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_EFUSE_REG_23, 0xF8}, 7228d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_EFUSE_REG_24, 0x16}, 7238d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_EFUSE_REG_25, 0x00}, 7248d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_EFUSE_REG_26, 0x00}, 7258d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_EFUSE_REG_27, 0x00}, 7268d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_EFUSE_REG_28, 0x00}, 7278d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_EFUSE_REG_29, 0x00}, 7288d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_EFUSE_REG_30, 0x00}, 7298d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_EFUSE_REG_31, 0x00}, 7308d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_TX_REQ_FB_CTL_0, 0x88}, 7318d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_TX_REQ_FB_CTL_1, 0x88}, 7328d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_TX_REQ_FB_CTL_2, 0x88}, 7338d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_TX_REQ_FB_CTL_3, 0x88}, 7348d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_TX_REQ_FB_CTL_4, 0x88}, 7358d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_DEM_BYPASS_DATA0, 0x55}, 7368d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_DEM_BYPASS_DATA1, 0x55}, 7378d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_DEM_BYPASS_DATA2, 0x55}, 7388d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_DEM_BYPASS_DATA3, 0x01}, 7398d78602aSSrinivas Kandagatla }; 7408d78602aSSrinivas Kandagatla 7418d78602aSSrinivas Kandagatla static bool wcd938x_rdwr_register(struct device *dev, unsigned int reg) 7428d78602aSSrinivas Kandagatla { 7438d78602aSSrinivas Kandagatla switch (reg) { 7448d78602aSSrinivas Kandagatla case WCD938X_ANA_PAGE_REGISTER: 7458d78602aSSrinivas Kandagatla case WCD938X_ANA_BIAS: 7468d78602aSSrinivas Kandagatla case WCD938X_ANA_RX_SUPPLIES: 7478d78602aSSrinivas Kandagatla case WCD938X_ANA_HPH: 7488d78602aSSrinivas Kandagatla case WCD938X_ANA_EAR: 7498d78602aSSrinivas Kandagatla case WCD938X_ANA_EAR_COMPANDER_CTL: 7508d78602aSSrinivas Kandagatla case WCD938X_ANA_TX_CH1: 7518d78602aSSrinivas Kandagatla case WCD938X_ANA_TX_CH2: 7528d78602aSSrinivas Kandagatla case WCD938X_ANA_TX_CH3: 7538d78602aSSrinivas Kandagatla case WCD938X_ANA_TX_CH4: 7548d78602aSSrinivas Kandagatla case WCD938X_ANA_MICB1_MICB2_DSP_EN_LOGIC: 7558d78602aSSrinivas Kandagatla case WCD938X_ANA_MICB3_DSP_EN_LOGIC: 7568d78602aSSrinivas Kandagatla case WCD938X_ANA_MBHC_MECH: 7578d78602aSSrinivas Kandagatla case WCD938X_ANA_MBHC_ELECT: 7588d78602aSSrinivas Kandagatla case WCD938X_ANA_MBHC_ZDET: 7598d78602aSSrinivas Kandagatla case WCD938X_ANA_MBHC_BTN0: 7608d78602aSSrinivas Kandagatla case WCD938X_ANA_MBHC_BTN1: 7618d78602aSSrinivas Kandagatla case WCD938X_ANA_MBHC_BTN2: 7628d78602aSSrinivas Kandagatla case WCD938X_ANA_MBHC_BTN3: 7638d78602aSSrinivas Kandagatla case WCD938X_ANA_MBHC_BTN4: 7648d78602aSSrinivas Kandagatla case WCD938X_ANA_MBHC_BTN5: 7658d78602aSSrinivas Kandagatla case WCD938X_ANA_MBHC_BTN6: 7668d78602aSSrinivas Kandagatla case WCD938X_ANA_MBHC_BTN7: 7678d78602aSSrinivas Kandagatla case WCD938X_ANA_MICB1: 7688d78602aSSrinivas Kandagatla case WCD938X_ANA_MICB2: 7698d78602aSSrinivas Kandagatla case WCD938X_ANA_MICB2_RAMP: 7708d78602aSSrinivas Kandagatla case WCD938X_ANA_MICB3: 7718d78602aSSrinivas Kandagatla case WCD938X_ANA_MICB4: 7728d78602aSSrinivas Kandagatla case WCD938X_BIAS_CTL: 7738d78602aSSrinivas Kandagatla case WCD938X_BIAS_VBG_FINE_ADJ: 7748d78602aSSrinivas Kandagatla case WCD938X_LDOL_VDDCX_ADJUST: 7758d78602aSSrinivas Kandagatla case WCD938X_LDOL_DISABLE_LDOL: 7768d78602aSSrinivas Kandagatla case WCD938X_MBHC_CTL_CLK: 7778d78602aSSrinivas Kandagatla case WCD938X_MBHC_CTL_ANA: 7788d78602aSSrinivas Kandagatla case WCD938X_MBHC_CTL_SPARE_1: 7798d78602aSSrinivas Kandagatla case WCD938X_MBHC_CTL_SPARE_2: 7808d78602aSSrinivas Kandagatla case WCD938X_MBHC_CTL_BCS: 7818d78602aSSrinivas Kandagatla case WCD938X_MBHC_TEST_CTL: 7828d78602aSSrinivas Kandagatla case WCD938X_LDOH_MODE: 7838d78602aSSrinivas Kandagatla case WCD938X_LDOH_BIAS: 7848d78602aSSrinivas Kandagatla case WCD938X_LDOH_STB_LOADS: 7858d78602aSSrinivas Kandagatla case WCD938X_LDOH_SLOWRAMP: 7868d78602aSSrinivas Kandagatla case WCD938X_MICB1_TEST_CTL_1: 7878d78602aSSrinivas Kandagatla case WCD938X_MICB1_TEST_CTL_2: 7888d78602aSSrinivas Kandagatla case WCD938X_MICB1_TEST_CTL_3: 7898d78602aSSrinivas Kandagatla case WCD938X_MICB2_TEST_CTL_1: 7908d78602aSSrinivas Kandagatla case WCD938X_MICB2_TEST_CTL_2: 7918d78602aSSrinivas Kandagatla case WCD938X_MICB2_TEST_CTL_3: 7928d78602aSSrinivas Kandagatla case WCD938X_MICB3_TEST_CTL_1: 7938d78602aSSrinivas Kandagatla case WCD938X_MICB3_TEST_CTL_2: 7948d78602aSSrinivas Kandagatla case WCD938X_MICB3_TEST_CTL_3: 7958d78602aSSrinivas Kandagatla case WCD938X_MICB4_TEST_CTL_1: 7968d78602aSSrinivas Kandagatla case WCD938X_MICB4_TEST_CTL_2: 7978d78602aSSrinivas Kandagatla case WCD938X_MICB4_TEST_CTL_3: 7988d78602aSSrinivas Kandagatla case WCD938X_TX_COM_ADC_VCM: 7998d78602aSSrinivas Kandagatla case WCD938X_TX_COM_BIAS_ATEST: 8008d78602aSSrinivas Kandagatla case WCD938X_TX_COM_SPARE1: 8018d78602aSSrinivas Kandagatla case WCD938X_TX_COM_SPARE2: 8028d78602aSSrinivas Kandagatla case WCD938X_TX_COM_TXFE_DIV_CTL: 8038d78602aSSrinivas Kandagatla case WCD938X_TX_COM_TXFE_DIV_START: 8048d78602aSSrinivas Kandagatla case WCD938X_TX_COM_SPARE3: 8058d78602aSSrinivas Kandagatla case WCD938X_TX_COM_SPARE4: 8068d78602aSSrinivas Kandagatla case WCD938X_TX_1_2_TEST_EN: 8078d78602aSSrinivas Kandagatla case WCD938X_TX_1_2_ADC_IB: 8088d78602aSSrinivas Kandagatla case WCD938X_TX_1_2_ATEST_REFCTL: 8098d78602aSSrinivas Kandagatla case WCD938X_TX_1_2_TEST_CTL: 8108d78602aSSrinivas Kandagatla case WCD938X_TX_1_2_TEST_BLK_EN1: 8118d78602aSSrinivas Kandagatla case WCD938X_TX_1_2_TXFE1_CLKDIV: 8128d78602aSSrinivas Kandagatla case WCD938X_TX_3_4_TEST_EN: 8138d78602aSSrinivas Kandagatla case WCD938X_TX_3_4_ADC_IB: 8148d78602aSSrinivas Kandagatla case WCD938X_TX_3_4_ATEST_REFCTL: 8158d78602aSSrinivas Kandagatla case WCD938X_TX_3_4_TEST_CTL: 8168d78602aSSrinivas Kandagatla case WCD938X_TX_3_4_TEST_BLK_EN3: 8178d78602aSSrinivas Kandagatla case WCD938X_TX_3_4_TXFE3_CLKDIV: 8188d78602aSSrinivas Kandagatla case WCD938X_TX_3_4_TEST_BLK_EN2: 8198d78602aSSrinivas Kandagatla case WCD938X_TX_3_4_TXFE2_CLKDIV: 8208d78602aSSrinivas Kandagatla case WCD938X_TX_3_4_SPARE1: 8218d78602aSSrinivas Kandagatla case WCD938X_TX_3_4_TEST_BLK_EN4: 8228d78602aSSrinivas Kandagatla case WCD938X_TX_3_4_TXFE4_CLKDIV: 8238d78602aSSrinivas Kandagatla case WCD938X_TX_3_4_SPARE2: 8248d78602aSSrinivas Kandagatla case WCD938X_CLASSH_MODE_1: 8258d78602aSSrinivas Kandagatla case WCD938X_CLASSH_MODE_2: 8268d78602aSSrinivas Kandagatla case WCD938X_CLASSH_MODE_3: 8278d78602aSSrinivas Kandagatla case WCD938X_CLASSH_CTRL_VCL_1: 8288d78602aSSrinivas Kandagatla case WCD938X_CLASSH_CTRL_VCL_2: 8298d78602aSSrinivas Kandagatla case WCD938X_CLASSH_CTRL_CCL_1: 8308d78602aSSrinivas Kandagatla case WCD938X_CLASSH_CTRL_CCL_2: 8318d78602aSSrinivas Kandagatla case WCD938X_CLASSH_CTRL_CCL_3: 8328d78602aSSrinivas Kandagatla case WCD938X_CLASSH_CTRL_CCL_4: 8338d78602aSSrinivas Kandagatla case WCD938X_CLASSH_CTRL_CCL_5: 8348d78602aSSrinivas Kandagatla case WCD938X_CLASSH_BUCK_TMUX_A_D: 8358d78602aSSrinivas Kandagatla case WCD938X_CLASSH_BUCK_SW_DRV_CNTL: 8368d78602aSSrinivas Kandagatla case WCD938X_CLASSH_SPARE: 8378d78602aSSrinivas Kandagatla case WCD938X_FLYBACK_EN: 8388d78602aSSrinivas Kandagatla case WCD938X_FLYBACK_VNEG_CTRL_1: 8398d78602aSSrinivas Kandagatla case WCD938X_FLYBACK_VNEG_CTRL_2: 8408d78602aSSrinivas Kandagatla case WCD938X_FLYBACK_VNEG_CTRL_3: 8418d78602aSSrinivas Kandagatla case WCD938X_FLYBACK_VNEG_CTRL_4: 8428d78602aSSrinivas Kandagatla case WCD938X_FLYBACK_VNEG_CTRL_5: 8438d78602aSSrinivas Kandagatla case WCD938X_FLYBACK_VNEG_CTRL_6: 8448d78602aSSrinivas Kandagatla case WCD938X_FLYBACK_VNEG_CTRL_7: 8458d78602aSSrinivas Kandagatla case WCD938X_FLYBACK_VNEG_CTRL_8: 8468d78602aSSrinivas Kandagatla case WCD938X_FLYBACK_VNEG_CTRL_9: 8478d78602aSSrinivas Kandagatla case WCD938X_FLYBACK_VNEGDAC_CTRL_1: 8488d78602aSSrinivas Kandagatla case WCD938X_FLYBACK_VNEGDAC_CTRL_2: 8498d78602aSSrinivas Kandagatla case WCD938X_FLYBACK_VNEGDAC_CTRL_3: 8508d78602aSSrinivas Kandagatla case WCD938X_FLYBACK_CTRL_1: 8518d78602aSSrinivas Kandagatla case WCD938X_FLYBACK_TEST_CTL: 8528d78602aSSrinivas Kandagatla case WCD938X_RX_AUX_SW_CTL: 8538d78602aSSrinivas Kandagatla case WCD938X_RX_PA_AUX_IN_CONN: 8548d78602aSSrinivas Kandagatla case WCD938X_RX_TIMER_DIV: 8558d78602aSSrinivas Kandagatla case WCD938X_RX_OCP_CTL: 8568d78602aSSrinivas Kandagatla case WCD938X_RX_OCP_COUNT: 8578d78602aSSrinivas Kandagatla case WCD938X_RX_BIAS_EAR_DAC: 8588d78602aSSrinivas Kandagatla case WCD938X_RX_BIAS_EAR_AMP: 8598d78602aSSrinivas Kandagatla case WCD938X_RX_BIAS_HPH_LDO: 8608d78602aSSrinivas Kandagatla case WCD938X_RX_BIAS_HPH_PA: 8618d78602aSSrinivas Kandagatla case WCD938X_RX_BIAS_HPH_RDACBUFF_CNP2: 8628d78602aSSrinivas Kandagatla case WCD938X_RX_BIAS_HPH_RDAC_LDO: 8638d78602aSSrinivas Kandagatla case WCD938X_RX_BIAS_HPH_CNP1: 8648d78602aSSrinivas Kandagatla case WCD938X_RX_BIAS_HPH_LOWPOWER: 8658d78602aSSrinivas Kandagatla case WCD938X_RX_BIAS_AUX_DAC: 8668d78602aSSrinivas Kandagatla case WCD938X_RX_BIAS_AUX_AMP: 8678d78602aSSrinivas Kandagatla case WCD938X_RX_BIAS_VNEGDAC_BLEEDER: 8688d78602aSSrinivas Kandagatla case WCD938X_RX_BIAS_MISC: 8698d78602aSSrinivas Kandagatla case WCD938X_RX_BIAS_BUCK_RST: 8708d78602aSSrinivas Kandagatla case WCD938X_RX_BIAS_BUCK_VREF_ERRAMP: 8718d78602aSSrinivas Kandagatla case WCD938X_RX_BIAS_FLYB_ERRAMP: 8728d78602aSSrinivas Kandagatla case WCD938X_RX_BIAS_FLYB_BUFF: 8738d78602aSSrinivas Kandagatla case WCD938X_RX_BIAS_FLYB_MID_RST: 8748d78602aSSrinivas Kandagatla case WCD938X_HPH_CNP_EN: 8758d78602aSSrinivas Kandagatla case WCD938X_HPH_CNP_WG_CTL: 8768d78602aSSrinivas Kandagatla case WCD938X_HPH_CNP_WG_TIME: 8778d78602aSSrinivas Kandagatla case WCD938X_HPH_OCP_CTL: 8788d78602aSSrinivas Kandagatla case WCD938X_HPH_AUTO_CHOP: 8798d78602aSSrinivas Kandagatla case WCD938X_HPH_CHOP_CTL: 8808d78602aSSrinivas Kandagatla case WCD938X_HPH_PA_CTL1: 8818d78602aSSrinivas Kandagatla case WCD938X_HPH_PA_CTL2: 8828d78602aSSrinivas Kandagatla case WCD938X_HPH_L_EN: 8838d78602aSSrinivas Kandagatla case WCD938X_HPH_L_TEST: 8848d78602aSSrinivas Kandagatla case WCD938X_HPH_L_ATEST: 8858d78602aSSrinivas Kandagatla case WCD938X_HPH_R_EN: 8868d78602aSSrinivas Kandagatla case WCD938X_HPH_R_TEST: 8878d78602aSSrinivas Kandagatla case WCD938X_HPH_R_ATEST: 8888d78602aSSrinivas Kandagatla case WCD938X_HPH_RDAC_CLK_CTL1: 8898d78602aSSrinivas Kandagatla case WCD938X_HPH_RDAC_CLK_CTL2: 8908d78602aSSrinivas Kandagatla case WCD938X_HPH_RDAC_LDO_CTL: 8918d78602aSSrinivas Kandagatla case WCD938X_HPH_RDAC_CHOP_CLK_LP_CTL: 8928d78602aSSrinivas Kandagatla case WCD938X_HPH_REFBUFF_UHQA_CTL: 8938d78602aSSrinivas Kandagatla case WCD938X_HPH_REFBUFF_LP_CTL: 8948d78602aSSrinivas Kandagatla case WCD938X_HPH_L_DAC_CTL: 8958d78602aSSrinivas Kandagatla case WCD938X_HPH_R_DAC_CTL: 8968d78602aSSrinivas Kandagatla case WCD938X_HPH_SURGE_HPHLR_SURGE_COMP_SEL: 8978d78602aSSrinivas Kandagatla case WCD938X_HPH_SURGE_HPHLR_SURGE_EN: 8988d78602aSSrinivas Kandagatla case WCD938X_HPH_SURGE_HPHLR_SURGE_MISC1: 8998d78602aSSrinivas Kandagatla case WCD938X_EAR_EAR_EN_REG: 9008d78602aSSrinivas Kandagatla case WCD938X_EAR_EAR_PA_CON: 9018d78602aSSrinivas Kandagatla case WCD938X_EAR_EAR_SP_CON: 9028d78602aSSrinivas Kandagatla case WCD938X_EAR_EAR_DAC_CON: 9038d78602aSSrinivas Kandagatla case WCD938X_EAR_EAR_CNP_FSM_CON: 9048d78602aSSrinivas Kandagatla case WCD938X_EAR_TEST_CTL: 9058d78602aSSrinivas Kandagatla case WCD938X_ANA_NEW_PAGE_REGISTER: 9068d78602aSSrinivas Kandagatla case WCD938X_HPH_NEW_ANA_HPH2: 9078d78602aSSrinivas Kandagatla case WCD938X_HPH_NEW_ANA_HPH3: 9088d78602aSSrinivas Kandagatla case WCD938X_SLEEP_CTL: 9098d78602aSSrinivas Kandagatla case WCD938X_SLEEP_WATCHDOG_CTL: 9108d78602aSSrinivas Kandagatla case WCD938X_MBHC_NEW_ELECT_REM_CLAMP_CTL: 9118d78602aSSrinivas Kandagatla case WCD938X_MBHC_NEW_CTL_1: 9128d78602aSSrinivas Kandagatla case WCD938X_MBHC_NEW_CTL_2: 9138d78602aSSrinivas Kandagatla case WCD938X_MBHC_NEW_PLUG_DETECT_CTL: 9148d78602aSSrinivas Kandagatla case WCD938X_MBHC_NEW_ZDET_ANA_CTL: 9158d78602aSSrinivas Kandagatla case WCD938X_MBHC_NEW_ZDET_RAMP_CTL: 9168d78602aSSrinivas Kandagatla case WCD938X_TX_NEW_AMIC_MUX_CFG: 9178d78602aSSrinivas Kandagatla case WCD938X_AUX_AUXPA: 9188d78602aSSrinivas Kandagatla case WCD938X_LDORXTX_MODE: 9198d78602aSSrinivas Kandagatla case WCD938X_LDORXTX_CONFIG: 9208d78602aSSrinivas Kandagatla case WCD938X_DIE_CRACK_DIE_CRK_DET_EN: 9218d78602aSSrinivas Kandagatla case WCD938X_HPH_NEW_INT_RDAC_GAIN_CTL: 9228d78602aSSrinivas Kandagatla case WCD938X_HPH_NEW_INT_RDAC_HD2_CTL_L: 9238d78602aSSrinivas Kandagatla case WCD938X_HPH_NEW_INT_RDAC_VREF_CTL: 9248d78602aSSrinivas Kandagatla case WCD938X_HPH_NEW_INT_RDAC_OVERRIDE_CTL: 9258d78602aSSrinivas Kandagatla case WCD938X_HPH_NEW_INT_RDAC_HD2_CTL_R: 9268d78602aSSrinivas Kandagatla case WCD938X_HPH_NEW_INT_PA_MISC1: 9278d78602aSSrinivas Kandagatla case WCD938X_HPH_NEW_INT_PA_MISC2: 9288d78602aSSrinivas Kandagatla case WCD938X_HPH_NEW_INT_PA_RDAC_MISC: 9298d78602aSSrinivas Kandagatla case WCD938X_HPH_NEW_INT_HPH_TIMER1: 9308d78602aSSrinivas Kandagatla case WCD938X_HPH_NEW_INT_HPH_TIMER2: 9318d78602aSSrinivas Kandagatla case WCD938X_HPH_NEW_INT_HPH_TIMER3: 9328d78602aSSrinivas Kandagatla case WCD938X_HPH_NEW_INT_HPH_TIMER4: 9338d78602aSSrinivas Kandagatla case WCD938X_HPH_NEW_INT_PA_RDAC_MISC2: 9348d78602aSSrinivas Kandagatla case WCD938X_HPH_NEW_INT_PA_RDAC_MISC3: 9358d78602aSSrinivas Kandagatla case WCD938X_HPH_NEW_INT_RDAC_HD2_CTL_L_NEW: 9368d78602aSSrinivas Kandagatla case WCD938X_HPH_NEW_INT_RDAC_HD2_CTL_R_NEW: 9378d78602aSSrinivas Kandagatla case WCD938X_RX_NEW_INT_HPH_RDAC_BIAS_LOHIFI: 9388d78602aSSrinivas Kandagatla case WCD938X_RX_NEW_INT_HPH_RDAC_BIAS_ULP: 9398d78602aSSrinivas Kandagatla case WCD938X_RX_NEW_INT_HPH_RDAC_LDO_LP: 9408d78602aSSrinivas Kandagatla case WCD938X_MBHC_NEW_INT_MOISTURE_DET_DC_CTRL: 9418d78602aSSrinivas Kandagatla case WCD938X_MBHC_NEW_INT_MOISTURE_DET_POLLING_CTRL: 9428d78602aSSrinivas Kandagatla case WCD938X_MBHC_NEW_INT_MECH_DET_CURRENT: 9438d78602aSSrinivas Kandagatla case WCD938X_MBHC_NEW_INT_SPARE_2: 9448d78602aSSrinivas Kandagatla case WCD938X_EAR_INT_NEW_EAR_CHOPPER_CON: 9458d78602aSSrinivas Kandagatla case WCD938X_EAR_INT_NEW_CNP_VCM_CON1: 9468d78602aSSrinivas Kandagatla case WCD938X_EAR_INT_NEW_CNP_VCM_CON2: 9478d78602aSSrinivas Kandagatla case WCD938X_EAR_INT_NEW_EAR_DYNAMIC_BIAS: 9488d78602aSSrinivas Kandagatla case WCD938X_AUX_INT_EN_REG: 9498d78602aSSrinivas Kandagatla case WCD938X_AUX_INT_PA_CTRL: 9508d78602aSSrinivas Kandagatla case WCD938X_AUX_INT_SP_CTRL: 9518d78602aSSrinivas Kandagatla case WCD938X_AUX_INT_DAC_CTRL: 9528d78602aSSrinivas Kandagatla case WCD938X_AUX_INT_CLK_CTRL: 9538d78602aSSrinivas Kandagatla case WCD938X_AUX_INT_TEST_CTRL: 9548d78602aSSrinivas Kandagatla case WCD938X_AUX_INT_MISC: 9558d78602aSSrinivas Kandagatla case WCD938X_LDORXTX_INT_BIAS: 9568d78602aSSrinivas Kandagatla case WCD938X_LDORXTX_INT_STB_LOADS_DTEST: 9578d78602aSSrinivas Kandagatla case WCD938X_LDORXTX_INT_TEST0: 9588d78602aSSrinivas Kandagatla case WCD938X_LDORXTX_INT_STARTUP_TIMER: 9598d78602aSSrinivas Kandagatla case WCD938X_LDORXTX_INT_TEST1: 9608d78602aSSrinivas Kandagatla case WCD938X_SLEEP_INT_WATCHDOG_CTL_1: 9618d78602aSSrinivas Kandagatla case WCD938X_SLEEP_INT_WATCHDOG_CTL_2: 9628d78602aSSrinivas Kandagatla case WCD938X_DIE_CRACK_INT_DIE_CRK_DET_INT1: 9638d78602aSSrinivas Kandagatla case WCD938X_DIE_CRACK_INT_DIE_CRK_DET_INT2: 9648d78602aSSrinivas Kandagatla case WCD938X_TX_COM_NEW_INT_TXFE_DIVSTOP_L2: 9658d78602aSSrinivas Kandagatla case WCD938X_TX_COM_NEW_INT_TXFE_DIVSTOP_L1: 9668d78602aSSrinivas Kandagatla case WCD938X_TX_COM_NEW_INT_TXFE_DIVSTOP_L0: 9678d78602aSSrinivas Kandagatla case WCD938X_TX_COM_NEW_INT_TXFE_DIVSTOP_ULP1P2M: 9688d78602aSSrinivas Kandagatla case WCD938X_TX_COM_NEW_INT_TXFE_DIVSTOP_ULP0P6M: 9698d78602aSSrinivas Kandagatla case WCD938X_TX_COM_NEW_INT_TXFE_ICTRL_STG1_L2L1: 9708d78602aSSrinivas Kandagatla case WCD938X_TX_COM_NEW_INT_TXFE_ICTRL_STG1_L0: 9718d78602aSSrinivas Kandagatla case WCD938X_TX_COM_NEW_INT_TXFE_ICTRL_STG1_ULP: 9728d78602aSSrinivas Kandagatla case WCD938X_TX_COM_NEW_INT_TXFE_ICTRL_STG2MAIN_L2L1: 9738d78602aSSrinivas Kandagatla case WCD938X_TX_COM_NEW_INT_TXFE_ICTRL_STG2MAIN_L0: 9748d78602aSSrinivas Kandagatla case WCD938X_TX_COM_NEW_INT_TXFE_ICTRL_STG2MAIN_ULP: 9758d78602aSSrinivas Kandagatla case WCD938X_TX_COM_NEW_INT_TXFE_ICTRL_STG2CASC_L2L1L0: 9768d78602aSSrinivas Kandagatla case WCD938X_TX_COM_NEW_INT_TXFE_ICTRL_STG2CASC_ULP: 9778d78602aSSrinivas Kandagatla case WCD938X_TX_COM_NEW_INT_TXADC_SCBIAS_L2L1: 9788d78602aSSrinivas Kandagatla case WCD938X_TX_COM_NEW_INT_TXADC_SCBIAS_L0ULP: 9798d78602aSSrinivas Kandagatla case WCD938X_TX_COM_NEW_INT_TXADC_INT_L2: 9808d78602aSSrinivas Kandagatla case WCD938X_TX_COM_NEW_INT_TXADC_INT_L1: 9818d78602aSSrinivas Kandagatla case WCD938X_TX_COM_NEW_INT_TXADC_INT_L0: 9828d78602aSSrinivas Kandagatla case WCD938X_TX_COM_NEW_INT_TXADC_INT_ULP: 9838d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_PAGE_REGISTER: 9848d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_SWR_TX_CLK_RATE: 9858d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_CDC_RST_CTL: 9868d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_TOP_CLK_CFG: 9878d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_CDC_ANA_CLK_CTL: 9888d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_CDC_DIG_CLK_CTL: 9898d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_SWR_RST_EN: 9908d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_CDC_PATH_MODE: 9918d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_CDC_RX_RST: 9928d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_CDC_RX0_CTL: 9938d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_CDC_RX1_CTL: 9948d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_CDC_RX2_CTL: 9958d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_CDC_TX_ANA_MODE_0_1: 9968d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_CDC_TX_ANA_MODE_2_3: 9978d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_CDC_COMP_CTL_0: 9988d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_CDC_ANA_TX_CLK_CTL: 9998d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_CDC_HPH_DSM_A1_0: 10008d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_CDC_HPH_DSM_A1_1: 10018d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_CDC_HPH_DSM_A2_0: 10028d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_CDC_HPH_DSM_A2_1: 10038d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_CDC_HPH_DSM_A3_0: 10048d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_CDC_HPH_DSM_A3_1: 10058d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_CDC_HPH_DSM_A4_0: 10068d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_CDC_HPH_DSM_A4_1: 10078d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_CDC_HPH_DSM_A5_0: 10088d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_CDC_HPH_DSM_A5_1: 10098d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_CDC_HPH_DSM_A6_0: 10108d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_CDC_HPH_DSM_A7_0: 10118d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_CDC_HPH_DSM_C_0: 10128d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_CDC_HPH_DSM_C_1: 10138d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_CDC_HPH_DSM_C_2: 10148d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_CDC_HPH_DSM_C_3: 10158d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_CDC_HPH_DSM_R1: 10168d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_CDC_HPH_DSM_R2: 10178d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_CDC_HPH_DSM_R3: 10188d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_CDC_HPH_DSM_R4: 10198d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_CDC_HPH_DSM_R5: 10208d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_CDC_HPH_DSM_R6: 10218d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_CDC_HPH_DSM_R7: 10228d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_CDC_AUX_DSM_A1_0: 10238d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_CDC_AUX_DSM_A1_1: 10248d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_CDC_AUX_DSM_A2_0: 10258d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_CDC_AUX_DSM_A2_1: 10268d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_CDC_AUX_DSM_A3_0: 10278d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_CDC_AUX_DSM_A3_1: 10288d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_CDC_AUX_DSM_A4_0: 10298d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_CDC_AUX_DSM_A4_1: 10308d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_CDC_AUX_DSM_A5_0: 10318d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_CDC_AUX_DSM_A5_1: 10328d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_CDC_AUX_DSM_A6_0: 10338d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_CDC_AUX_DSM_A7_0: 10348d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_CDC_AUX_DSM_C_0: 10358d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_CDC_AUX_DSM_C_1: 10368d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_CDC_AUX_DSM_C_2: 10378d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_CDC_AUX_DSM_C_3: 10388d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_CDC_AUX_DSM_R1: 10398d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_CDC_AUX_DSM_R2: 10408d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_CDC_AUX_DSM_R3: 10418d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_CDC_AUX_DSM_R4: 10428d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_CDC_AUX_DSM_R5: 10438d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_CDC_AUX_DSM_R6: 10448d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_CDC_AUX_DSM_R7: 10458d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_CDC_HPH_GAIN_RX_0: 10468d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_CDC_HPH_GAIN_RX_1: 10478d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_CDC_HPH_GAIN_DSD_0: 10488d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_CDC_HPH_GAIN_DSD_1: 10498d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_CDC_HPH_GAIN_DSD_2: 10508d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_CDC_AUX_GAIN_DSD_0: 10518d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_CDC_AUX_GAIN_DSD_1: 10528d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_CDC_AUX_GAIN_DSD_2: 10538d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_CDC_HPH_GAIN_CTL: 10548d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_CDC_AUX_GAIN_CTL: 10558d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_CDC_EAR_PATH_CTL: 10568d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_CDC_SWR_CLH: 10578d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_SWR_CLH_BYP: 10588d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_CDC_TX0_CTL: 10598d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_CDC_TX1_CTL: 10608d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_CDC_TX2_CTL: 10618d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_CDC_TX_RST: 10628d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_CDC_REQ_CTL: 10638d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_CDC_RST: 10648d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_CDC_AMIC_CTL: 10658d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_CDC_DMIC_CTL: 10668d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_CDC_DMIC1_CTL: 10678d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_CDC_DMIC2_CTL: 10688d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_CDC_DMIC3_CTL: 10698d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_CDC_DMIC4_CTL: 10708d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_EFUSE_PRG_CTL: 10718d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_EFUSE_CTL: 10728d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_CDC_DMIC_RATE_1_2: 10738d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_CDC_DMIC_RATE_3_4: 10748d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_PDM_WD_CTL0: 10758d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_PDM_WD_CTL1: 10768d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_PDM_WD_CTL2: 10778d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_INTR_MODE: 10788d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_INTR_MASK_0: 10798d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_INTR_MASK_1: 10808d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_INTR_MASK_2: 10818d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_INTR_CLEAR_0: 10828d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_INTR_CLEAR_1: 10838d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_INTR_CLEAR_2: 10848d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_INTR_LEVEL_0: 10858d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_INTR_LEVEL_1: 10868d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_INTR_LEVEL_2: 10878d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_INTR_SET_0: 10888d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_INTR_SET_1: 10898d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_INTR_SET_2: 10908d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_INTR_TEST_0: 10918d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_INTR_TEST_1: 10928d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_INTR_TEST_2: 10938d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_TX_MODE_DBG_EN: 10948d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_TX_MODE_DBG_0_1: 10958d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_TX_MODE_DBG_2_3: 10968d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_LB_IN_SEL_CTL: 10978d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_LOOP_BACK_MODE: 10988d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_SWR_DAC_TEST: 10998d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_SWR_HM_TEST_RX_0: 11008d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_SWR_HM_TEST_TX_0: 11018d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_SWR_HM_TEST_RX_1: 11028d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_SWR_HM_TEST_TX_1: 11038d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_SWR_HM_TEST_TX_2: 11048d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_PAD_CTL_SWR_0: 11058d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_PAD_CTL_SWR_1: 11068d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_I2C_CTL: 11078d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_CDC_TX_TANGGU_SW_MODE: 11088d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_EFUSE_TEST_CTL_0: 11098d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_EFUSE_TEST_CTL_1: 11108d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_PAD_CTL_PDM_RX0: 11118d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_PAD_CTL_PDM_RX1: 11128d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_PAD_CTL_PDM_TX0: 11138d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_PAD_CTL_PDM_TX1: 11148d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_PAD_CTL_PDM_TX2: 11158d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_PAD_INP_DIS_0: 11168d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_PAD_INP_DIS_1: 11178d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_DRIVE_STRENGTH_0: 11188d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_DRIVE_STRENGTH_1: 11198d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_DRIVE_STRENGTH_2: 11208d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_RX_DATA_EDGE_CTL: 11218d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_TX_DATA_EDGE_CTL: 11228d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_GPIO_MODE: 11238d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_PIN_CTL_OE: 11248d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_PIN_CTL_DATA_0: 11258d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_PIN_CTL_DATA_1: 11268d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_DIG_DEBUG_CTL: 11278d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_DIG_DEBUG_EN: 11288d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_ANA_CSR_DBG_ADD: 11298d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_ANA_CSR_DBG_CTL: 11308d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_SSP_DBG: 11318d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_SPARE_0: 11328d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_SPARE_1: 11338d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_SPARE_2: 11348d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_TX_REQ_FB_CTL_0: 11358d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_TX_REQ_FB_CTL_1: 11368d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_TX_REQ_FB_CTL_2: 11378d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_TX_REQ_FB_CTL_3: 11388d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_TX_REQ_FB_CTL_4: 11398d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_DEM_BYPASS_DATA0: 11408d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_DEM_BYPASS_DATA1: 11418d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_DEM_BYPASS_DATA2: 11428d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_DEM_BYPASS_DATA3: 11438d78602aSSrinivas Kandagatla return true; 11448d78602aSSrinivas Kandagatla } 11458d78602aSSrinivas Kandagatla 11468d78602aSSrinivas Kandagatla return false; 11478d78602aSSrinivas Kandagatla } 11488d78602aSSrinivas Kandagatla 11498d78602aSSrinivas Kandagatla static bool wcd938x_readonly_register(struct device *dev, unsigned int reg) 11508d78602aSSrinivas Kandagatla { 11518d78602aSSrinivas Kandagatla switch (reg) { 11528d78602aSSrinivas Kandagatla case WCD938X_ANA_MBHC_RESULT_1: 11538d78602aSSrinivas Kandagatla case WCD938X_ANA_MBHC_RESULT_2: 11548d78602aSSrinivas Kandagatla case WCD938X_ANA_MBHC_RESULT_3: 11558d78602aSSrinivas Kandagatla case WCD938X_MBHC_MOISTURE_DET_FSM_STATUS: 11568d78602aSSrinivas Kandagatla case WCD938X_TX_1_2_SAR2_ERR: 11578d78602aSSrinivas Kandagatla case WCD938X_TX_1_2_SAR1_ERR: 11588d78602aSSrinivas Kandagatla case WCD938X_TX_3_4_SAR4_ERR: 11598d78602aSSrinivas Kandagatla case WCD938X_TX_3_4_SAR3_ERR: 11608d78602aSSrinivas Kandagatla case WCD938X_HPH_L_STATUS: 11618d78602aSSrinivas Kandagatla case WCD938X_HPH_R_STATUS: 11628d78602aSSrinivas Kandagatla case WCD938X_HPH_SURGE_HPHLR_SURGE_STATUS: 11638d78602aSSrinivas Kandagatla case WCD938X_EAR_STATUS_REG_1: 11648d78602aSSrinivas Kandagatla case WCD938X_EAR_STATUS_REG_2: 11658d78602aSSrinivas Kandagatla case WCD938X_MBHC_NEW_FSM_STATUS: 11668d78602aSSrinivas Kandagatla case WCD938X_MBHC_NEW_ADC_RESULT: 11678d78602aSSrinivas Kandagatla case WCD938X_DIE_CRACK_DIE_CRK_DET_OUT: 11688d78602aSSrinivas Kandagatla case WCD938X_AUX_INT_STATUS_REG: 11698d78602aSSrinivas Kandagatla case WCD938X_LDORXTX_INT_STATUS: 11708d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_CHIP_ID0: 11718d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_CHIP_ID1: 11728d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_CHIP_ID2: 11738d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_CHIP_ID3: 11748d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_INTR_STATUS_0: 11758d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_INTR_STATUS_1: 11768d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_INTR_STATUS_2: 1177ea157c2bSSrinivas Kandagatla case WCD938X_DIGITAL_INTR_CLEAR_0: 1178ea157c2bSSrinivas Kandagatla case WCD938X_DIGITAL_INTR_CLEAR_1: 1179ea157c2bSSrinivas Kandagatla case WCD938X_DIGITAL_INTR_CLEAR_2: 11808d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_SWR_HM_TEST_0: 11818d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_SWR_HM_TEST_1: 11828d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_EFUSE_T_DATA_0: 11838d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_EFUSE_T_DATA_1: 11848d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_PIN_STATUS_0: 11858d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_PIN_STATUS_1: 11868d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_MODE_STATUS_0: 11878d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_MODE_STATUS_1: 11888d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_EFUSE_REG_0: 11898d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_EFUSE_REG_1: 11908d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_EFUSE_REG_2: 11918d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_EFUSE_REG_3: 11928d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_EFUSE_REG_4: 11938d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_EFUSE_REG_5: 11948d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_EFUSE_REG_6: 11958d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_EFUSE_REG_7: 11968d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_EFUSE_REG_8: 11978d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_EFUSE_REG_9: 11988d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_EFUSE_REG_10: 11998d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_EFUSE_REG_11: 12008d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_EFUSE_REG_12: 12018d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_EFUSE_REG_13: 12028d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_EFUSE_REG_14: 12038d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_EFUSE_REG_15: 12048d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_EFUSE_REG_16: 12058d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_EFUSE_REG_17: 12068d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_EFUSE_REG_18: 12078d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_EFUSE_REG_19: 12088d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_EFUSE_REG_20: 12098d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_EFUSE_REG_21: 12108d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_EFUSE_REG_22: 12118d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_EFUSE_REG_23: 12128d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_EFUSE_REG_24: 12138d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_EFUSE_REG_25: 12148d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_EFUSE_REG_26: 12158d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_EFUSE_REG_27: 12168d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_EFUSE_REG_28: 12178d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_EFUSE_REG_29: 12188d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_EFUSE_REG_30: 12198d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_EFUSE_REG_31: 12208d78602aSSrinivas Kandagatla return true; 12218d78602aSSrinivas Kandagatla } 12228d78602aSSrinivas Kandagatla return false; 12238d78602aSSrinivas Kandagatla } 12248d78602aSSrinivas Kandagatla 12258d78602aSSrinivas Kandagatla static bool wcd938x_readable_register(struct device *dev, unsigned int reg) 12268d78602aSSrinivas Kandagatla { 12278d78602aSSrinivas Kandagatla bool ret; 12288d78602aSSrinivas Kandagatla 12298d78602aSSrinivas Kandagatla ret = wcd938x_readonly_register(dev, reg); 12308d78602aSSrinivas Kandagatla if (!ret) 12318d78602aSSrinivas Kandagatla return wcd938x_rdwr_register(dev, reg); 12328d78602aSSrinivas Kandagatla 12338d78602aSSrinivas Kandagatla return ret; 12348d78602aSSrinivas Kandagatla } 12358d78602aSSrinivas Kandagatla 12368d78602aSSrinivas Kandagatla static bool wcd938x_writeable_register(struct device *dev, unsigned int reg) 12378d78602aSSrinivas Kandagatla { 12388d78602aSSrinivas Kandagatla return wcd938x_rdwr_register(dev, reg); 12398d78602aSSrinivas Kandagatla } 12408d78602aSSrinivas Kandagatla 12418d78602aSSrinivas Kandagatla static bool wcd938x_volatile_register(struct device *dev, unsigned int reg) 12428d78602aSSrinivas Kandagatla { 12438d78602aSSrinivas Kandagatla if (reg <= WCD938X_BASE_ADDRESS) 124483bd5c53SYang Li return false; 12458d78602aSSrinivas Kandagatla 12468d78602aSSrinivas Kandagatla if (reg == WCD938X_DIGITAL_SWR_TX_CLK_RATE) 12478d78602aSSrinivas Kandagatla return true; 12488d78602aSSrinivas Kandagatla 12498d78602aSSrinivas Kandagatla if (wcd938x_readonly_register(dev, reg)) 12508d78602aSSrinivas Kandagatla return true; 12518d78602aSSrinivas Kandagatla 12528d78602aSSrinivas Kandagatla return false; 12538d78602aSSrinivas Kandagatla } 12548d78602aSSrinivas Kandagatla 1255b90d9398SSrinivas Kandagatla static struct regmap_config wcd938x_regmap_config = { 12568d78602aSSrinivas Kandagatla .name = "wcd938x_csr", 12578d78602aSSrinivas Kandagatla .reg_bits = 32, 12588d78602aSSrinivas Kandagatla .val_bits = 8, 12598d78602aSSrinivas Kandagatla .cache_type = REGCACHE_RBTREE, 12608d78602aSSrinivas Kandagatla .reg_defaults = wcd938x_defaults, 12618d78602aSSrinivas Kandagatla .num_reg_defaults = ARRAY_SIZE(wcd938x_defaults), 12628d78602aSSrinivas Kandagatla .max_register = WCD938X_MAX_REGISTER, 12638d78602aSSrinivas Kandagatla .readable_reg = wcd938x_readable_register, 12648d78602aSSrinivas Kandagatla .writeable_reg = wcd938x_writeable_register, 12658d78602aSSrinivas Kandagatla .volatile_reg = wcd938x_volatile_register, 12668d78602aSSrinivas Kandagatla .can_multi_write = true, 12678d78602aSSrinivas Kandagatla }; 12688d78602aSSrinivas Kandagatla 12698d78602aSSrinivas Kandagatla static const struct regmap_irq wcd938x_irqs[WCD938X_NUM_IRQS] = { 12708d78602aSSrinivas Kandagatla REGMAP_IRQ_REG(WCD938X_IRQ_MBHC_BUTTON_PRESS_DET, 0, 0x01), 12718d78602aSSrinivas Kandagatla REGMAP_IRQ_REG(WCD938X_IRQ_MBHC_BUTTON_RELEASE_DET, 0, 0x02), 12728d78602aSSrinivas Kandagatla REGMAP_IRQ_REG(WCD938X_IRQ_MBHC_ELECT_INS_REM_DET, 0, 0x04), 12738d78602aSSrinivas Kandagatla REGMAP_IRQ_REG(WCD938X_IRQ_MBHC_ELECT_INS_REM_LEG_DET, 0, 0x08), 12748d78602aSSrinivas Kandagatla REGMAP_IRQ_REG(WCD938X_IRQ_MBHC_SW_DET, 0, 0x10), 12758d78602aSSrinivas Kandagatla REGMAP_IRQ_REG(WCD938X_IRQ_HPHR_OCP_INT, 0, 0x20), 12768d78602aSSrinivas Kandagatla REGMAP_IRQ_REG(WCD938X_IRQ_HPHR_CNP_INT, 0, 0x40), 12778d78602aSSrinivas Kandagatla REGMAP_IRQ_REG(WCD938X_IRQ_HPHL_OCP_INT, 0, 0x80), 12788d78602aSSrinivas Kandagatla REGMAP_IRQ_REG(WCD938X_IRQ_HPHL_CNP_INT, 1, 0x01), 12798d78602aSSrinivas Kandagatla REGMAP_IRQ_REG(WCD938X_IRQ_EAR_CNP_INT, 1, 0x02), 12808d78602aSSrinivas Kandagatla REGMAP_IRQ_REG(WCD938X_IRQ_EAR_SCD_INT, 1, 0x04), 12818d78602aSSrinivas Kandagatla REGMAP_IRQ_REG(WCD938X_IRQ_AUX_CNP_INT, 1, 0x08), 12828d78602aSSrinivas Kandagatla REGMAP_IRQ_REG(WCD938X_IRQ_AUX_SCD_INT, 1, 0x10), 12838d78602aSSrinivas Kandagatla REGMAP_IRQ_REG(WCD938X_IRQ_HPHL_PDM_WD_INT, 1, 0x20), 12848d78602aSSrinivas Kandagatla REGMAP_IRQ_REG(WCD938X_IRQ_HPHR_PDM_WD_INT, 1, 0x40), 12858d78602aSSrinivas Kandagatla REGMAP_IRQ_REG(WCD938X_IRQ_AUX_PDM_WD_INT, 1, 0x80), 12868d78602aSSrinivas Kandagatla REGMAP_IRQ_REG(WCD938X_IRQ_LDORT_SCD_INT, 2, 0x01), 12878d78602aSSrinivas Kandagatla REGMAP_IRQ_REG(WCD938X_IRQ_MBHC_MOISTURE_INT, 2, 0x02), 12888d78602aSSrinivas Kandagatla REGMAP_IRQ_REG(WCD938X_IRQ_HPHL_SURGE_DET_INT, 2, 0x04), 12898d78602aSSrinivas Kandagatla REGMAP_IRQ_REG(WCD938X_IRQ_HPHR_SURGE_DET_INT, 2, 0x08), 12908d78602aSSrinivas Kandagatla }; 12918d78602aSSrinivas Kandagatla 12928d78602aSSrinivas Kandagatla static struct regmap_irq_chip wcd938x_regmap_irq_chip = { 12938d78602aSSrinivas Kandagatla .name = "wcd938x", 12948d78602aSSrinivas Kandagatla .irqs = wcd938x_irqs, 12958d78602aSSrinivas Kandagatla .num_irqs = ARRAY_SIZE(wcd938x_irqs), 12968d78602aSSrinivas Kandagatla .num_regs = 3, 12978d78602aSSrinivas Kandagatla .status_base = WCD938X_DIGITAL_INTR_STATUS_0, 12988d78602aSSrinivas Kandagatla .mask_base = WCD938X_DIGITAL_INTR_MASK_0, 12998d78602aSSrinivas Kandagatla .type_base = WCD938X_DIGITAL_INTR_LEVEL_0, 13008d78602aSSrinivas Kandagatla .ack_base = WCD938X_DIGITAL_INTR_CLEAR_0, 13018d78602aSSrinivas Kandagatla .use_ack = 1, 13028d78602aSSrinivas Kandagatla .runtime_pm = true, 13038d78602aSSrinivas Kandagatla .irq_drv_data = NULL, 13048d78602aSSrinivas Kandagatla }; 13058d78602aSSrinivas Kandagatla 1306d5add08fSSrinivas Kandagatla static int wcd938x_get_clk_rate(int mode) 1307d5add08fSSrinivas Kandagatla { 1308d5add08fSSrinivas Kandagatla int rate; 1309d5add08fSSrinivas Kandagatla 1310d5add08fSSrinivas Kandagatla switch (mode) { 1311d5add08fSSrinivas Kandagatla case ADC_MODE_ULP2: 1312d5add08fSSrinivas Kandagatla rate = SWR_CLK_RATE_0P6MHZ; 1313d5add08fSSrinivas Kandagatla break; 1314d5add08fSSrinivas Kandagatla case ADC_MODE_ULP1: 1315d5add08fSSrinivas Kandagatla rate = SWR_CLK_RATE_1P2MHZ; 1316d5add08fSSrinivas Kandagatla break; 1317d5add08fSSrinivas Kandagatla case ADC_MODE_LP: 1318d5add08fSSrinivas Kandagatla rate = SWR_CLK_RATE_4P8MHZ; 1319d5add08fSSrinivas Kandagatla break; 1320d5add08fSSrinivas Kandagatla case ADC_MODE_NORMAL: 1321d5add08fSSrinivas Kandagatla case ADC_MODE_LO_HIF: 1322d5add08fSSrinivas Kandagatla case ADC_MODE_HIFI: 1323d5add08fSSrinivas Kandagatla case ADC_MODE_INVALID: 1324d5add08fSSrinivas Kandagatla default: 1325d5add08fSSrinivas Kandagatla rate = SWR_CLK_RATE_9P6MHZ; 1326d5add08fSSrinivas Kandagatla break; 1327d5add08fSSrinivas Kandagatla } 1328d5add08fSSrinivas Kandagatla 1329d5add08fSSrinivas Kandagatla return rate; 1330d5add08fSSrinivas Kandagatla } 1331d5add08fSSrinivas Kandagatla 1332d5add08fSSrinivas Kandagatla static int wcd938x_set_swr_clk_rate(struct snd_soc_component *component, int rate, int bank) 1333d5add08fSSrinivas Kandagatla { 1334d5add08fSSrinivas Kandagatla u8 mask = (bank ? 0xF0 : 0x0F); 1335d5add08fSSrinivas Kandagatla u8 val = 0; 1336d5add08fSSrinivas Kandagatla 1337d5add08fSSrinivas Kandagatla switch (rate) { 1338d5add08fSSrinivas Kandagatla case SWR_CLK_RATE_0P6MHZ: 1339d5add08fSSrinivas Kandagatla val = (bank ? 0x60 : 0x06); 1340d5add08fSSrinivas Kandagatla break; 1341d5add08fSSrinivas Kandagatla case SWR_CLK_RATE_1P2MHZ: 1342d5add08fSSrinivas Kandagatla val = (bank ? 0x50 : 0x05); 1343d5add08fSSrinivas Kandagatla break; 1344d5add08fSSrinivas Kandagatla case SWR_CLK_RATE_2P4MHZ: 1345d5add08fSSrinivas Kandagatla val = (bank ? 0x30 : 0x03); 1346d5add08fSSrinivas Kandagatla break; 1347d5add08fSSrinivas Kandagatla case SWR_CLK_RATE_4P8MHZ: 1348d5add08fSSrinivas Kandagatla val = (bank ? 0x10 : 0x01); 1349d5add08fSSrinivas Kandagatla break; 1350d5add08fSSrinivas Kandagatla case SWR_CLK_RATE_9P6MHZ: 1351d5add08fSSrinivas Kandagatla default: 1352d5add08fSSrinivas Kandagatla val = 0x00; 1353d5add08fSSrinivas Kandagatla break; 1354d5add08fSSrinivas Kandagatla } 1355d5add08fSSrinivas Kandagatla snd_soc_component_update_bits(component, WCD938X_DIGITAL_SWR_TX_CLK_RATE, 1356d5add08fSSrinivas Kandagatla mask, val); 1357d5add08fSSrinivas Kandagatla 1358d5add08fSSrinivas Kandagatla return 0; 1359d5add08fSSrinivas Kandagatla } 1360d5add08fSSrinivas Kandagatla 13618d78602aSSrinivas Kandagatla static int wcd938x_io_init(struct wcd938x_priv *wcd938x) 13628d78602aSSrinivas Kandagatla { 13638d78602aSSrinivas Kandagatla struct regmap *rm = wcd938x->regmap; 13648d78602aSSrinivas Kandagatla 13658d78602aSSrinivas Kandagatla regmap_update_bits(rm, WCD938X_SLEEP_CTL, 0x0E, 0x0E); 13668d78602aSSrinivas Kandagatla regmap_update_bits(rm, WCD938X_SLEEP_CTL, 0x80, 0x80); 13678d78602aSSrinivas Kandagatla /* 1 msec delay as per HW requirement */ 13688d78602aSSrinivas Kandagatla usleep_range(1000, 1010); 13698d78602aSSrinivas Kandagatla regmap_update_bits(rm, WCD938X_SLEEP_CTL, 0x40, 0x40); 13708d78602aSSrinivas Kandagatla /* 1 msec delay as per HW requirement */ 13718d78602aSSrinivas Kandagatla usleep_range(1000, 1010); 13728d78602aSSrinivas Kandagatla regmap_update_bits(rm, WCD938X_LDORXTX_CONFIG, 0x10, 0x00); 13738d78602aSSrinivas Kandagatla regmap_update_bits(rm, WCD938X_BIAS_VBG_FINE_ADJ, 13748d78602aSSrinivas Kandagatla 0xF0, 0x80); 13758d78602aSSrinivas Kandagatla regmap_update_bits(rm, WCD938X_ANA_BIAS, 0x80, 0x80); 13768d78602aSSrinivas Kandagatla regmap_update_bits(rm, WCD938X_ANA_BIAS, 0x40, 0x40); 13778d78602aSSrinivas Kandagatla /* 10 msec delay as per HW requirement */ 13788d78602aSSrinivas Kandagatla usleep_range(10000, 10010); 13798d78602aSSrinivas Kandagatla 13808d78602aSSrinivas Kandagatla regmap_update_bits(rm, WCD938X_ANA_BIAS, 0x40, 0x00); 13818d78602aSSrinivas Kandagatla regmap_update_bits(rm, WCD938X_HPH_NEW_INT_RDAC_GAIN_CTL, 13828d78602aSSrinivas Kandagatla 0xF0, 0x00); 13838d78602aSSrinivas Kandagatla regmap_update_bits(rm, WCD938X_HPH_NEW_INT_RDAC_HD2_CTL_L_NEW, 13848d78602aSSrinivas Kandagatla 0x1F, 0x15); 13858d78602aSSrinivas Kandagatla regmap_update_bits(rm, WCD938X_HPH_NEW_INT_RDAC_HD2_CTL_R_NEW, 13868d78602aSSrinivas Kandagatla 0x1F, 0x15); 13878d78602aSSrinivas Kandagatla regmap_update_bits(rm, WCD938X_HPH_REFBUFF_UHQA_CTL, 13888d78602aSSrinivas Kandagatla 0xC0, 0x80); 13898d78602aSSrinivas Kandagatla regmap_update_bits(rm, WCD938X_DIGITAL_CDC_DMIC_CTL, 13908d78602aSSrinivas Kandagatla 0x02, 0x02); 13918d78602aSSrinivas Kandagatla 13928d78602aSSrinivas Kandagatla regmap_update_bits(rm, WCD938X_TX_COM_NEW_INT_TXFE_ICTRL_STG2CASC_ULP, 13938d78602aSSrinivas Kandagatla 0xFF, 0x14); 13948d78602aSSrinivas Kandagatla regmap_update_bits(rm, WCD938X_TX_COM_NEW_INT_TXFE_ICTRL_STG2MAIN_ULP, 13958d78602aSSrinivas Kandagatla 0x1F, 0x08); 13968d78602aSSrinivas Kandagatla 13978d78602aSSrinivas Kandagatla regmap_update_bits(rm, WCD938X_DIGITAL_TX_REQ_FB_CTL_0, 0xFF, 0x55); 13988d78602aSSrinivas Kandagatla regmap_update_bits(rm, WCD938X_DIGITAL_TX_REQ_FB_CTL_1, 0xFF, 0x44); 13998d78602aSSrinivas Kandagatla regmap_update_bits(rm, WCD938X_DIGITAL_TX_REQ_FB_CTL_2, 0xFF, 0x11); 14008d78602aSSrinivas Kandagatla regmap_update_bits(rm, WCD938X_DIGITAL_TX_REQ_FB_CTL_3, 0xFF, 0x00); 14018d78602aSSrinivas Kandagatla regmap_update_bits(rm, WCD938X_DIGITAL_TX_REQ_FB_CTL_4, 0xFF, 0x00); 14028d78602aSSrinivas Kandagatla 14038d78602aSSrinivas Kandagatla /* Set Noise Filter Resistor value */ 14048d78602aSSrinivas Kandagatla regmap_update_bits(rm, WCD938X_MICB1_TEST_CTL_1, 0xE0, 0xE0); 14058d78602aSSrinivas Kandagatla regmap_update_bits(rm, WCD938X_MICB2_TEST_CTL_1, 0xE0, 0xE0); 14068d78602aSSrinivas Kandagatla regmap_update_bits(rm, WCD938X_MICB3_TEST_CTL_1, 0xE0, 0xE0); 14078d78602aSSrinivas Kandagatla regmap_update_bits(rm, WCD938X_MICB4_TEST_CTL_1, 0xE0, 0xE0); 14088d78602aSSrinivas Kandagatla 14098d78602aSSrinivas Kandagatla regmap_update_bits(rm, WCD938X_TX_3_4_TEST_BLK_EN2, 0x01, 0x00); 14108d78602aSSrinivas Kandagatla regmap_update_bits(rm, WCD938X_HPH_SURGE_HPHLR_SURGE_EN, 0xC0, 0xC0); 14118d78602aSSrinivas Kandagatla 14128d78602aSSrinivas Kandagatla return 0; 14138d78602aSSrinivas Kandagatla 14148d78602aSSrinivas Kandagatla } 14158d78602aSSrinivas Kandagatla 1416e8ba1e05SSrinivas Kandagatla static int wcd938x_sdw_connect_port(struct wcd938x_sdw_ch_info *ch_info, 1417e8ba1e05SSrinivas Kandagatla struct sdw_port_config *port_config, 1418e8ba1e05SSrinivas Kandagatla u8 enable) 1419e8ba1e05SSrinivas Kandagatla { 1420e8ba1e05SSrinivas Kandagatla u8 ch_mask, port_num; 1421e8ba1e05SSrinivas Kandagatla 1422e8ba1e05SSrinivas Kandagatla port_num = ch_info->port_num; 1423e8ba1e05SSrinivas Kandagatla ch_mask = ch_info->ch_mask; 1424e8ba1e05SSrinivas Kandagatla 1425e8ba1e05SSrinivas Kandagatla port_config->num = port_num; 1426e8ba1e05SSrinivas Kandagatla 1427e8ba1e05SSrinivas Kandagatla if (enable) 1428e8ba1e05SSrinivas Kandagatla port_config->ch_mask |= ch_mask; 1429e8ba1e05SSrinivas Kandagatla else 1430e8ba1e05SSrinivas Kandagatla port_config->ch_mask &= ~ch_mask; 1431e8ba1e05SSrinivas Kandagatla 1432e8ba1e05SSrinivas Kandagatla return 0; 1433e8ba1e05SSrinivas Kandagatla } 1434e8ba1e05SSrinivas Kandagatla 1435c5c1546aSSrinivas Kandagatla static int wcd938x_connect_port(struct wcd938x_sdw_priv *wcd, u8 port_num, u8 ch_id, u8 enable) 1436e8ba1e05SSrinivas Kandagatla { 1437e8ba1e05SSrinivas Kandagatla return wcd938x_sdw_connect_port(&wcd->ch_info[ch_id], 1438c5c1546aSSrinivas Kandagatla &wcd->port_config[port_num - 1], 1439e8ba1e05SSrinivas Kandagatla enable); 1440e8ba1e05SSrinivas Kandagatla } 1441e8ba1e05SSrinivas Kandagatla 14428da9db0cSSrinivas Kandagatla static int wcd938x_codec_enable_rxclk(struct snd_soc_dapm_widget *w, 14438da9db0cSSrinivas Kandagatla struct snd_kcontrol *kcontrol, 14448da9db0cSSrinivas Kandagatla int event) 14458da9db0cSSrinivas Kandagatla { 14468da9db0cSSrinivas Kandagatla struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); 14478da9db0cSSrinivas Kandagatla 14488da9db0cSSrinivas Kandagatla switch (event) { 14498da9db0cSSrinivas Kandagatla case SND_SOC_DAPM_PRE_PMU: 14508da9db0cSSrinivas Kandagatla snd_soc_component_write_field(component, WCD938X_DIGITAL_CDC_ANA_CLK_CTL, 14518da9db0cSSrinivas Kandagatla WCD938X_ANA_RX_CLK_EN_MASK, 1); 14528da9db0cSSrinivas Kandagatla snd_soc_component_write_field(component, WCD938X_ANA_RX_SUPPLIES, 14538da9db0cSSrinivas Kandagatla WCD938X_RX_BIAS_EN_MASK, 1); 14548da9db0cSSrinivas Kandagatla snd_soc_component_write_field(component, WCD938X_DIGITAL_CDC_RX0_CTL, 14558da9db0cSSrinivas Kandagatla WCD938X_DEM_DITHER_ENABLE_MASK, 0); 14568da9db0cSSrinivas Kandagatla snd_soc_component_write_field(component, WCD938X_DIGITAL_CDC_RX1_CTL, 14578da9db0cSSrinivas Kandagatla WCD938X_DEM_DITHER_ENABLE_MASK, 0); 14588da9db0cSSrinivas Kandagatla snd_soc_component_write_field(component, WCD938X_DIGITAL_CDC_RX2_CTL, 14598da9db0cSSrinivas Kandagatla WCD938X_DEM_DITHER_ENABLE_MASK, 0); 14608da9db0cSSrinivas Kandagatla snd_soc_component_write_field(component, WCD938X_DIGITAL_CDC_ANA_CLK_CTL, 14618da9db0cSSrinivas Kandagatla WCD938X_ANA_RX_DIV2_CLK_EN_MASK, 1); 14628da9db0cSSrinivas Kandagatla snd_soc_component_write_field(component, WCD938X_AUX_AUXPA, 14638da9db0cSSrinivas Kandagatla WCD938X_AUXPA_CLK_EN_MASK, 1); 14648da9db0cSSrinivas Kandagatla break; 14658da9db0cSSrinivas Kandagatla case SND_SOC_DAPM_POST_PMD: 14668da9db0cSSrinivas Kandagatla snd_soc_component_write_field(component, WCD938X_ANA_RX_SUPPLIES, 14678da9db0cSSrinivas Kandagatla WCD938X_VNEG_EN_MASK, 0); 14688da9db0cSSrinivas Kandagatla snd_soc_component_write_field(component, WCD938X_ANA_RX_SUPPLIES, 14698da9db0cSSrinivas Kandagatla WCD938X_VPOS_EN_MASK, 0); 14708da9db0cSSrinivas Kandagatla snd_soc_component_write_field(component, WCD938X_ANA_RX_SUPPLIES, 14718da9db0cSSrinivas Kandagatla WCD938X_RX_BIAS_EN_MASK, 0); 14728da9db0cSSrinivas Kandagatla snd_soc_component_write_field(component, WCD938X_DIGITAL_CDC_ANA_CLK_CTL, 14738da9db0cSSrinivas Kandagatla WCD938X_ANA_RX_DIV2_CLK_EN_MASK, 0); 14748da9db0cSSrinivas Kandagatla snd_soc_component_write_field(component, WCD938X_DIGITAL_CDC_ANA_CLK_CTL, 14758da9db0cSSrinivas Kandagatla WCD938X_ANA_RX_CLK_EN_MASK, 0); 14768da9db0cSSrinivas Kandagatla break; 14778da9db0cSSrinivas Kandagatla } 14788da9db0cSSrinivas Kandagatla return 0; 14798da9db0cSSrinivas Kandagatla } 14808da9db0cSSrinivas Kandagatla 14818da9db0cSSrinivas Kandagatla static int wcd938x_codec_hphl_dac_event(struct snd_soc_dapm_widget *w, 14828da9db0cSSrinivas Kandagatla struct snd_kcontrol *kcontrol, 14838da9db0cSSrinivas Kandagatla int event) 14848da9db0cSSrinivas Kandagatla { 14858da9db0cSSrinivas Kandagatla struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); 14868da9db0cSSrinivas Kandagatla struct wcd938x_priv *wcd938x = snd_soc_component_get_drvdata(component); 14878da9db0cSSrinivas Kandagatla 14888da9db0cSSrinivas Kandagatla switch (event) { 14898da9db0cSSrinivas Kandagatla case SND_SOC_DAPM_PRE_PMU: 14908da9db0cSSrinivas Kandagatla snd_soc_component_write_field(component, 14918da9db0cSSrinivas Kandagatla WCD938X_DIGITAL_CDC_DIG_CLK_CTL, 14928da9db0cSSrinivas Kandagatla WCD938X_RXD0_CLK_EN_MASK, 0x01); 14938da9db0cSSrinivas Kandagatla snd_soc_component_write_field(component, 14948da9db0cSSrinivas Kandagatla WCD938X_DIGITAL_CDC_HPH_GAIN_CTL, 14958da9db0cSSrinivas Kandagatla WCD938X_HPHL_RX_EN_MASK, 1); 14968da9db0cSSrinivas Kandagatla snd_soc_component_write_field(component, 14978da9db0cSSrinivas Kandagatla WCD938X_HPH_RDAC_CLK_CTL1, 14988da9db0cSSrinivas Kandagatla WCD938X_CHOP_CLK_EN_MASK, 0); 14998da9db0cSSrinivas Kandagatla break; 15008da9db0cSSrinivas Kandagatla case SND_SOC_DAPM_POST_PMU: 15018da9db0cSSrinivas Kandagatla snd_soc_component_write_field(component, 15028da9db0cSSrinivas Kandagatla WCD938X_HPH_NEW_INT_RDAC_HD2_CTL_L, 15038da9db0cSSrinivas Kandagatla WCD938X_HPH_RES_DIV_MASK, 0x02); 15048da9db0cSSrinivas Kandagatla if (wcd938x->comp1_enable) { 15058da9db0cSSrinivas Kandagatla snd_soc_component_write_field(component, 15068da9db0cSSrinivas Kandagatla WCD938X_DIGITAL_CDC_COMP_CTL_0, 15078da9db0cSSrinivas Kandagatla WCD938X_HPHL_COMP_EN_MASK, 1); 15088da9db0cSSrinivas Kandagatla /* 5msec compander delay as per HW requirement */ 15098da9db0cSSrinivas Kandagatla if (!wcd938x->comp2_enable || (snd_soc_component_read(component, 15108da9db0cSSrinivas Kandagatla WCD938X_DIGITAL_CDC_COMP_CTL_0) & 0x01)) 15118da9db0cSSrinivas Kandagatla usleep_range(5000, 5010); 15128da9db0cSSrinivas Kandagatla snd_soc_component_write_field(component, WCD938X_HPH_NEW_INT_HPH_TIMER1, 15138da9db0cSSrinivas Kandagatla WCD938X_AUTOCHOP_TIMER_EN, 0); 15148da9db0cSSrinivas Kandagatla } else { 15158da9db0cSSrinivas Kandagatla snd_soc_component_write_field(component, 15168da9db0cSSrinivas Kandagatla WCD938X_DIGITAL_CDC_COMP_CTL_0, 15178da9db0cSSrinivas Kandagatla WCD938X_HPHL_COMP_EN_MASK, 0); 15188da9db0cSSrinivas Kandagatla snd_soc_component_write_field(component, 15198da9db0cSSrinivas Kandagatla WCD938X_HPH_L_EN, 15208da9db0cSSrinivas Kandagatla WCD938X_GAIN_SRC_SEL_MASK, 15218da9db0cSSrinivas Kandagatla WCD938X_GAIN_SRC_SEL_REGISTER); 15228da9db0cSSrinivas Kandagatla 15238da9db0cSSrinivas Kandagatla } 15248da9db0cSSrinivas Kandagatla break; 15258da9db0cSSrinivas Kandagatla case SND_SOC_DAPM_POST_PMD: 15268da9db0cSSrinivas Kandagatla snd_soc_component_write_field(component, 15278da9db0cSSrinivas Kandagatla WCD938X_HPH_NEW_INT_RDAC_HD2_CTL_R, 15288da9db0cSSrinivas Kandagatla WCD938X_HPH_RES_DIV_MASK, 0x1); 15298da9db0cSSrinivas Kandagatla break; 15308da9db0cSSrinivas Kandagatla } 15318da9db0cSSrinivas Kandagatla 15328da9db0cSSrinivas Kandagatla return 0; 15338da9db0cSSrinivas Kandagatla } 15348da9db0cSSrinivas Kandagatla 15358da9db0cSSrinivas Kandagatla static int wcd938x_codec_hphr_dac_event(struct snd_soc_dapm_widget *w, 15368da9db0cSSrinivas Kandagatla struct snd_kcontrol *kcontrol, 15378da9db0cSSrinivas Kandagatla int event) 15388da9db0cSSrinivas Kandagatla { 15398da9db0cSSrinivas Kandagatla struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); 15408da9db0cSSrinivas Kandagatla struct wcd938x_priv *wcd938x = snd_soc_component_get_drvdata(component); 15418da9db0cSSrinivas Kandagatla 15428da9db0cSSrinivas Kandagatla switch (event) { 15438da9db0cSSrinivas Kandagatla case SND_SOC_DAPM_PRE_PMU: 15448da9db0cSSrinivas Kandagatla snd_soc_component_write_field(component, 15458da9db0cSSrinivas Kandagatla WCD938X_DIGITAL_CDC_DIG_CLK_CTL, 15468da9db0cSSrinivas Kandagatla WCD938X_RXD1_CLK_EN_MASK, 1); 15478da9db0cSSrinivas Kandagatla snd_soc_component_write_field(component, 15488da9db0cSSrinivas Kandagatla WCD938X_DIGITAL_CDC_HPH_GAIN_CTL, 15498da9db0cSSrinivas Kandagatla WCD938X_HPHR_RX_EN_MASK, 1); 15508da9db0cSSrinivas Kandagatla snd_soc_component_write_field(component, 15518da9db0cSSrinivas Kandagatla WCD938X_HPH_RDAC_CLK_CTL1, 15528da9db0cSSrinivas Kandagatla WCD938X_CHOP_CLK_EN_MASK, 0); 15538da9db0cSSrinivas Kandagatla break; 15548da9db0cSSrinivas Kandagatla case SND_SOC_DAPM_POST_PMU: 15558da9db0cSSrinivas Kandagatla snd_soc_component_write_field(component, 15568da9db0cSSrinivas Kandagatla WCD938X_HPH_NEW_INT_RDAC_HD2_CTL_R, 15578da9db0cSSrinivas Kandagatla WCD938X_HPH_RES_DIV_MASK, 0x02); 15588da9db0cSSrinivas Kandagatla if (wcd938x->comp2_enable) { 15598da9db0cSSrinivas Kandagatla snd_soc_component_write_field(component, 15608da9db0cSSrinivas Kandagatla WCD938X_DIGITAL_CDC_COMP_CTL_0, 15618da9db0cSSrinivas Kandagatla WCD938X_HPHR_COMP_EN_MASK, 1); 15628da9db0cSSrinivas Kandagatla /* 5msec compander delay as per HW requirement */ 15638da9db0cSSrinivas Kandagatla if (!wcd938x->comp1_enable || 15648da9db0cSSrinivas Kandagatla (snd_soc_component_read(component, 15658da9db0cSSrinivas Kandagatla WCD938X_DIGITAL_CDC_COMP_CTL_0) & 0x02)) 15668da9db0cSSrinivas Kandagatla usleep_range(5000, 5010); 15678da9db0cSSrinivas Kandagatla snd_soc_component_write_field(component, WCD938X_HPH_NEW_INT_HPH_TIMER1, 15688da9db0cSSrinivas Kandagatla WCD938X_AUTOCHOP_TIMER_EN, 0); 15698da9db0cSSrinivas Kandagatla } else { 15708da9db0cSSrinivas Kandagatla snd_soc_component_write_field(component, 15718da9db0cSSrinivas Kandagatla WCD938X_DIGITAL_CDC_COMP_CTL_0, 15728da9db0cSSrinivas Kandagatla WCD938X_HPHR_COMP_EN_MASK, 0); 15738da9db0cSSrinivas Kandagatla snd_soc_component_write_field(component, 15748da9db0cSSrinivas Kandagatla WCD938X_HPH_R_EN, 15758da9db0cSSrinivas Kandagatla WCD938X_GAIN_SRC_SEL_MASK, 15768da9db0cSSrinivas Kandagatla WCD938X_GAIN_SRC_SEL_REGISTER); 15778da9db0cSSrinivas Kandagatla } 15788da9db0cSSrinivas Kandagatla break; 15798da9db0cSSrinivas Kandagatla case SND_SOC_DAPM_POST_PMD: 15808da9db0cSSrinivas Kandagatla snd_soc_component_write_field(component, 15818da9db0cSSrinivas Kandagatla WCD938X_HPH_NEW_INT_RDAC_HD2_CTL_R, 15828da9db0cSSrinivas Kandagatla WCD938X_HPH_RES_DIV_MASK, 0x01); 15838da9db0cSSrinivas Kandagatla break; 15848da9db0cSSrinivas Kandagatla } 15858da9db0cSSrinivas Kandagatla 15868da9db0cSSrinivas Kandagatla return 0; 15878da9db0cSSrinivas Kandagatla } 15888da9db0cSSrinivas Kandagatla 15898da9db0cSSrinivas Kandagatla static int wcd938x_codec_ear_dac_event(struct snd_soc_dapm_widget *w, 15908da9db0cSSrinivas Kandagatla struct snd_kcontrol *kcontrol, 15918da9db0cSSrinivas Kandagatla int event) 15928da9db0cSSrinivas Kandagatla { 15938da9db0cSSrinivas Kandagatla struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); 15948da9db0cSSrinivas Kandagatla struct wcd938x_priv *wcd938x = snd_soc_component_get_drvdata(component); 15958da9db0cSSrinivas Kandagatla 15968da9db0cSSrinivas Kandagatla switch (event) { 15978da9db0cSSrinivas Kandagatla case SND_SOC_DAPM_PRE_PMU: 15988da9db0cSSrinivas Kandagatla wcd938x->ear_rx_path = 15998da9db0cSSrinivas Kandagatla snd_soc_component_read( 16008da9db0cSSrinivas Kandagatla component, WCD938X_DIGITAL_CDC_EAR_PATH_CTL); 16018da9db0cSSrinivas Kandagatla if (wcd938x->ear_rx_path & EAR_RX_PATH_AUX) { 16028da9db0cSSrinivas Kandagatla snd_soc_component_write_field(component, 16038da9db0cSSrinivas Kandagatla WCD938X_EAR_EAR_DAC_CON, 16048da9db0cSSrinivas Kandagatla WCD938X_DAC_SAMPLE_EDGE_SEL_MASK, 0); 16058da9db0cSSrinivas Kandagatla snd_soc_component_write_field(component, 16068da9db0cSSrinivas Kandagatla WCD938X_DIGITAL_CDC_AUX_GAIN_CTL, 16078da9db0cSSrinivas Kandagatla WCD938X_AUX_EN_MASK, 1); 16088da9db0cSSrinivas Kandagatla snd_soc_component_write_field(component, 16098da9db0cSSrinivas Kandagatla WCD938X_DIGITAL_CDC_DIG_CLK_CTL, 16108da9db0cSSrinivas Kandagatla WCD938X_RXD2_CLK_EN_MASK, 1); 16118da9db0cSSrinivas Kandagatla snd_soc_component_write_field(component, 16128da9db0cSSrinivas Kandagatla WCD938X_ANA_EAR_COMPANDER_CTL, 16138da9db0cSSrinivas Kandagatla WCD938X_GAIN_OVRD_REG_MASK, 1); 16148da9db0cSSrinivas Kandagatla } else { 16158da9db0cSSrinivas Kandagatla snd_soc_component_write_field(component, 16168da9db0cSSrinivas Kandagatla WCD938X_DIGITAL_CDC_HPH_GAIN_CTL, 16178da9db0cSSrinivas Kandagatla WCD938X_HPHL_RX_EN_MASK, 1); 16188da9db0cSSrinivas Kandagatla snd_soc_component_write_field(component, 16198da9db0cSSrinivas Kandagatla WCD938X_DIGITAL_CDC_DIG_CLK_CTL, 16208da9db0cSSrinivas Kandagatla WCD938X_RXD0_CLK_EN_MASK, 1); 16218da9db0cSSrinivas Kandagatla if (wcd938x->comp1_enable) 16228da9db0cSSrinivas Kandagatla snd_soc_component_write_field(component, 16238da9db0cSSrinivas Kandagatla WCD938X_DIGITAL_CDC_COMP_CTL_0, 16248da9db0cSSrinivas Kandagatla WCD938X_HPHL_COMP_EN_MASK, 1); 16258da9db0cSSrinivas Kandagatla } 16268da9db0cSSrinivas Kandagatla /* 5 msec delay as per HW requirement */ 16278da9db0cSSrinivas Kandagatla usleep_range(5000, 5010); 16288da9db0cSSrinivas Kandagatla if (wcd938x->flyback_cur_det_disable == 0) 16298da9db0cSSrinivas Kandagatla snd_soc_component_write_field(component, WCD938X_FLYBACK_EN, 16308da9db0cSSrinivas Kandagatla WCD938X_EN_CUR_DET_MASK, 0); 16318da9db0cSSrinivas Kandagatla wcd938x->flyback_cur_det_disable++; 16328da9db0cSSrinivas Kandagatla wcd_clsh_ctrl_set_state(wcd938x->clsh_info, 16338da9db0cSSrinivas Kandagatla WCD_CLSH_EVENT_PRE_DAC, 16348da9db0cSSrinivas Kandagatla WCD_CLSH_STATE_EAR, 16358da9db0cSSrinivas Kandagatla wcd938x->hph_mode); 16368da9db0cSSrinivas Kandagatla break; 16378da9db0cSSrinivas Kandagatla case SND_SOC_DAPM_POST_PMD: 16388da9db0cSSrinivas Kandagatla if (wcd938x->ear_rx_path & EAR_RX_PATH_AUX) { 16398da9db0cSSrinivas Kandagatla snd_soc_component_write_field(component, 16408da9db0cSSrinivas Kandagatla WCD938X_DIGITAL_CDC_AUX_GAIN_CTL, 16418da9db0cSSrinivas Kandagatla WCD938X_AUX_EN_MASK, 0); 16428da9db0cSSrinivas Kandagatla snd_soc_component_write_field(component, 16438da9db0cSSrinivas Kandagatla WCD938X_DIGITAL_CDC_DIG_CLK_CTL, 16448da9db0cSSrinivas Kandagatla WCD938X_RXD2_CLK_EN_MASK, 0); 16458da9db0cSSrinivas Kandagatla } else { 16468da9db0cSSrinivas Kandagatla snd_soc_component_write_field(component, 16478da9db0cSSrinivas Kandagatla WCD938X_DIGITAL_CDC_HPH_GAIN_CTL, 16488da9db0cSSrinivas Kandagatla WCD938X_HPHL_RX_EN_MASK, 0); 16498da9db0cSSrinivas Kandagatla snd_soc_component_write_field(component, 16508da9db0cSSrinivas Kandagatla WCD938X_DIGITAL_CDC_DIG_CLK_CTL, 16518da9db0cSSrinivas Kandagatla WCD938X_RXD0_CLK_EN_MASK, 0); 16528da9db0cSSrinivas Kandagatla if (wcd938x->comp1_enable) 16538da9db0cSSrinivas Kandagatla snd_soc_component_write_field(component, 16548da9db0cSSrinivas Kandagatla WCD938X_DIGITAL_CDC_COMP_CTL_0, 16558da9db0cSSrinivas Kandagatla WCD938X_HPHL_COMP_EN_MASK, 0); 16568da9db0cSSrinivas Kandagatla } 16578da9db0cSSrinivas Kandagatla snd_soc_component_write_field(component, WCD938X_ANA_EAR_COMPANDER_CTL, 16588da9db0cSSrinivas Kandagatla WCD938X_GAIN_OVRD_REG_MASK, 0); 16598da9db0cSSrinivas Kandagatla snd_soc_component_write_field(component, 16608da9db0cSSrinivas Kandagatla WCD938X_EAR_EAR_DAC_CON, 16618da9db0cSSrinivas Kandagatla WCD938X_DAC_SAMPLE_EDGE_SEL_MASK, 1); 16628da9db0cSSrinivas Kandagatla break; 16638da9db0cSSrinivas Kandagatla } 16648da9db0cSSrinivas Kandagatla return 0; 16658da9db0cSSrinivas Kandagatla 16668da9db0cSSrinivas Kandagatla } 16678da9db0cSSrinivas Kandagatla 16688da9db0cSSrinivas Kandagatla static int wcd938x_codec_aux_dac_event(struct snd_soc_dapm_widget *w, 16698da9db0cSSrinivas Kandagatla struct snd_kcontrol *kcontrol, 16708da9db0cSSrinivas Kandagatla int event) 16718da9db0cSSrinivas Kandagatla { 16728da9db0cSSrinivas Kandagatla struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); 16738da9db0cSSrinivas Kandagatla struct wcd938x_priv *wcd938x = snd_soc_component_get_drvdata(component); 16748da9db0cSSrinivas Kandagatla 16758da9db0cSSrinivas Kandagatla switch (event) { 16768da9db0cSSrinivas Kandagatla case SND_SOC_DAPM_PRE_PMU: 16778da9db0cSSrinivas Kandagatla snd_soc_component_write_field(component, 16788da9db0cSSrinivas Kandagatla WCD938X_DIGITAL_CDC_ANA_CLK_CTL, 16798da9db0cSSrinivas Kandagatla WCD938X_ANA_RX_DIV4_CLK_EN_MASK, 1); 16808da9db0cSSrinivas Kandagatla snd_soc_component_write_field(component, 16818da9db0cSSrinivas Kandagatla WCD938X_DIGITAL_CDC_DIG_CLK_CTL, 16828da9db0cSSrinivas Kandagatla WCD938X_RXD2_CLK_EN_MASK, 1); 16838da9db0cSSrinivas Kandagatla snd_soc_component_write_field(component, 16848da9db0cSSrinivas Kandagatla WCD938X_DIGITAL_CDC_AUX_GAIN_CTL, 16858da9db0cSSrinivas Kandagatla WCD938X_AUX_EN_MASK, 1); 16868da9db0cSSrinivas Kandagatla if (wcd938x->flyback_cur_det_disable == 0) 16878da9db0cSSrinivas Kandagatla snd_soc_component_write_field(component, WCD938X_FLYBACK_EN, 16888da9db0cSSrinivas Kandagatla WCD938X_EN_CUR_DET_MASK, 0); 16898da9db0cSSrinivas Kandagatla wcd938x->flyback_cur_det_disable++; 16908da9db0cSSrinivas Kandagatla wcd_clsh_ctrl_set_state(wcd938x->clsh_info, 16918da9db0cSSrinivas Kandagatla WCD_CLSH_EVENT_PRE_DAC, 16928da9db0cSSrinivas Kandagatla WCD_CLSH_STATE_AUX, 16938da9db0cSSrinivas Kandagatla wcd938x->hph_mode); 16948da9db0cSSrinivas Kandagatla break; 16958da9db0cSSrinivas Kandagatla case SND_SOC_DAPM_POST_PMD: 16968da9db0cSSrinivas Kandagatla snd_soc_component_write_field(component, 16978da9db0cSSrinivas Kandagatla WCD938X_DIGITAL_CDC_ANA_CLK_CTL, 16988da9db0cSSrinivas Kandagatla WCD938X_ANA_RX_DIV4_CLK_EN_MASK, 0); 16998da9db0cSSrinivas Kandagatla break; 17008da9db0cSSrinivas Kandagatla } 17014d0b79ecSkernel test robot return 0; 17028da9db0cSSrinivas Kandagatla 17038da9db0cSSrinivas Kandagatla } 17048da9db0cSSrinivas Kandagatla 17058da9db0cSSrinivas Kandagatla static int wcd938x_codec_enable_hphr_pa(struct snd_soc_dapm_widget *w, 17068da9db0cSSrinivas Kandagatla struct snd_kcontrol *kcontrol, int event) 17078da9db0cSSrinivas Kandagatla { 17088da9db0cSSrinivas Kandagatla struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); 17098da9db0cSSrinivas Kandagatla struct wcd938x_priv *wcd938x = snd_soc_component_get_drvdata(component); 17108da9db0cSSrinivas Kandagatla int hph_mode = wcd938x->hph_mode; 17118da9db0cSSrinivas Kandagatla 17128da9db0cSSrinivas Kandagatla switch (event) { 17138da9db0cSSrinivas Kandagatla case SND_SOC_DAPM_PRE_PMU: 17148da9db0cSSrinivas Kandagatla if (wcd938x->ldoh) 17158da9db0cSSrinivas Kandagatla snd_soc_component_write_field(component, WCD938X_LDOH_MODE, 17168da9db0cSSrinivas Kandagatla WCD938X_LDOH_EN_MASK, 1); 17178da9db0cSSrinivas Kandagatla wcd_clsh_ctrl_set_state(wcd938x->clsh_info, WCD_CLSH_EVENT_PRE_DAC, 17188da9db0cSSrinivas Kandagatla WCD_CLSH_STATE_HPHR, hph_mode); 17198da9db0cSSrinivas Kandagatla wcd_clsh_set_hph_mode(wcd938x->clsh_info, CLS_H_HIFI); 17208da9db0cSSrinivas Kandagatla 17218da9db0cSSrinivas Kandagatla if (hph_mode == CLS_H_LP || hph_mode == CLS_H_LOHIFI || 17228da9db0cSSrinivas Kandagatla hph_mode == CLS_H_ULP) { 17238da9db0cSSrinivas Kandagatla snd_soc_component_write_field(component, 17248da9db0cSSrinivas Kandagatla WCD938X_HPH_REFBUFF_LP_CTL, 17258da9db0cSSrinivas Kandagatla WCD938X_PREREF_FLIT_BYPASS_MASK, 1); 17268da9db0cSSrinivas Kandagatla } 17278da9db0cSSrinivas Kandagatla snd_soc_component_write_field(component, WCD938X_ANA_HPH, 17288da9db0cSSrinivas Kandagatla WCD938X_HPHR_REF_EN_MASK, 1); 17298da9db0cSSrinivas Kandagatla wcd_clsh_set_hph_mode(wcd938x->clsh_info, hph_mode); 17308da9db0cSSrinivas Kandagatla /* 100 usec delay as per HW requirement */ 17318da9db0cSSrinivas Kandagatla usleep_range(100, 110); 17328da9db0cSSrinivas Kandagatla set_bit(HPH_PA_DELAY, &wcd938x->status_mask); 17338da9db0cSSrinivas Kandagatla snd_soc_component_write_field(component, 17348da9db0cSSrinivas Kandagatla WCD938X_DIGITAL_PDM_WD_CTL1, 17358da9db0cSSrinivas Kandagatla WCD938X_PDM_WD_EN_MASK, 0x3); 17368da9db0cSSrinivas Kandagatla break; 17378da9db0cSSrinivas Kandagatla case SND_SOC_DAPM_POST_PMU: 17388da9db0cSSrinivas Kandagatla /* 17398da9db0cSSrinivas Kandagatla * 7ms sleep is required if compander is enabled as per 17408da9db0cSSrinivas Kandagatla * HW requirement. If compander is disabled, then 17418da9db0cSSrinivas Kandagatla * 20ms delay is required. 17428da9db0cSSrinivas Kandagatla */ 17438da9db0cSSrinivas Kandagatla if (test_bit(HPH_PA_DELAY, &wcd938x->status_mask)) { 17448da9db0cSSrinivas Kandagatla if (!wcd938x->comp2_enable) 17458da9db0cSSrinivas Kandagatla usleep_range(20000, 20100); 17468da9db0cSSrinivas Kandagatla else 17478da9db0cSSrinivas Kandagatla usleep_range(7000, 7100); 17488da9db0cSSrinivas Kandagatla 17498da9db0cSSrinivas Kandagatla if (hph_mode == CLS_H_LP || hph_mode == CLS_H_LOHIFI || 17508da9db0cSSrinivas Kandagatla hph_mode == CLS_H_ULP) 17518da9db0cSSrinivas Kandagatla snd_soc_component_write_field(component, 17528da9db0cSSrinivas Kandagatla WCD938X_HPH_REFBUFF_LP_CTL, 17538da9db0cSSrinivas Kandagatla WCD938X_PREREF_FLIT_BYPASS_MASK, 0); 17548da9db0cSSrinivas Kandagatla clear_bit(HPH_PA_DELAY, &wcd938x->status_mask); 17558da9db0cSSrinivas Kandagatla } 17568da9db0cSSrinivas Kandagatla snd_soc_component_write_field(component, WCD938X_HPH_NEW_INT_HPH_TIMER1, 17578da9db0cSSrinivas Kandagatla WCD938X_AUTOCHOP_TIMER_EN, 1); 17588da9db0cSSrinivas Kandagatla if (hph_mode == CLS_AB || hph_mode == CLS_AB_HIFI || 17598da9db0cSSrinivas Kandagatla hph_mode == CLS_AB_LP || hph_mode == CLS_AB_LOHIFI) 17608da9db0cSSrinivas Kandagatla snd_soc_component_write_field(component, WCD938X_ANA_RX_SUPPLIES, 17618da9db0cSSrinivas Kandagatla WCD938X_REGULATOR_MODE_MASK, 17628da9db0cSSrinivas Kandagatla WCD938X_REGULATOR_MODE_CLASS_AB); 17638da9db0cSSrinivas Kandagatla enable_irq(wcd938x->hphr_pdm_wd_int); 17648da9db0cSSrinivas Kandagatla break; 17658da9db0cSSrinivas Kandagatla case SND_SOC_DAPM_PRE_PMD: 17668da9db0cSSrinivas Kandagatla disable_irq_nosync(wcd938x->hphr_pdm_wd_int); 17678da9db0cSSrinivas Kandagatla /* 17688da9db0cSSrinivas Kandagatla * 7ms sleep is required if compander is enabled as per 17698da9db0cSSrinivas Kandagatla * HW requirement. If compander is disabled, then 17708da9db0cSSrinivas Kandagatla * 20ms delay is required. 17718da9db0cSSrinivas Kandagatla */ 17728da9db0cSSrinivas Kandagatla if (!wcd938x->comp2_enable) 17738da9db0cSSrinivas Kandagatla usleep_range(20000, 20100); 17748da9db0cSSrinivas Kandagatla else 17758da9db0cSSrinivas Kandagatla usleep_range(7000, 7100); 17768da9db0cSSrinivas Kandagatla snd_soc_component_write_field(component, WCD938X_ANA_HPH, 17778da9db0cSSrinivas Kandagatla WCD938X_HPHR_EN_MASK, 0); 1778bcee7ed0SSrinivas Kandagatla wcd_mbhc_event_notify(wcd938x->wcd_mbhc, 1779bcee7ed0SSrinivas Kandagatla WCD_EVENT_PRE_HPHR_PA_OFF); 17808da9db0cSSrinivas Kandagatla set_bit(HPH_PA_DELAY, &wcd938x->status_mask); 17818da9db0cSSrinivas Kandagatla break; 17828da9db0cSSrinivas Kandagatla case SND_SOC_DAPM_POST_PMD: 17838da9db0cSSrinivas Kandagatla /* 17848da9db0cSSrinivas Kandagatla * 7ms sleep is required if compander is enabled as per 17858da9db0cSSrinivas Kandagatla * HW requirement. If compander is disabled, then 17868da9db0cSSrinivas Kandagatla * 20ms delay is required. 17878da9db0cSSrinivas Kandagatla */ 17888da9db0cSSrinivas Kandagatla if (test_bit(HPH_PA_DELAY, &wcd938x->status_mask)) { 17898da9db0cSSrinivas Kandagatla if (!wcd938x->comp2_enable) 17908da9db0cSSrinivas Kandagatla usleep_range(20000, 20100); 17918da9db0cSSrinivas Kandagatla else 17928da9db0cSSrinivas Kandagatla usleep_range(7000, 7100); 17938da9db0cSSrinivas Kandagatla clear_bit(HPH_PA_DELAY, &wcd938x->status_mask); 17948da9db0cSSrinivas Kandagatla } 1795bcee7ed0SSrinivas Kandagatla wcd_mbhc_event_notify(wcd938x->wcd_mbhc, 1796bcee7ed0SSrinivas Kandagatla WCD_EVENT_POST_HPHR_PA_OFF); 17978da9db0cSSrinivas Kandagatla snd_soc_component_write_field(component, WCD938X_ANA_HPH, 17988da9db0cSSrinivas Kandagatla WCD938X_HPHR_REF_EN_MASK, 0); 17998da9db0cSSrinivas Kandagatla snd_soc_component_write_field(component, WCD938X_DIGITAL_PDM_WD_CTL1, 18008da9db0cSSrinivas Kandagatla WCD938X_PDM_WD_EN_MASK, 0); 18018da9db0cSSrinivas Kandagatla wcd_clsh_ctrl_set_state(wcd938x->clsh_info, WCD_CLSH_EVENT_POST_PA, 18028da9db0cSSrinivas Kandagatla WCD_CLSH_STATE_HPHR, hph_mode); 18038da9db0cSSrinivas Kandagatla if (wcd938x->ldoh) 18048da9db0cSSrinivas Kandagatla snd_soc_component_write_field(component, WCD938X_LDOH_MODE, 18058da9db0cSSrinivas Kandagatla WCD938X_LDOH_EN_MASK, 0); 18068da9db0cSSrinivas Kandagatla break; 18078da9db0cSSrinivas Kandagatla } 18088da9db0cSSrinivas Kandagatla 18098da9db0cSSrinivas Kandagatla return 0; 18108da9db0cSSrinivas Kandagatla } 18118da9db0cSSrinivas Kandagatla 18128da9db0cSSrinivas Kandagatla static int wcd938x_codec_enable_hphl_pa(struct snd_soc_dapm_widget *w, 18138da9db0cSSrinivas Kandagatla struct snd_kcontrol *kcontrol, int event) 18148da9db0cSSrinivas Kandagatla { 18158da9db0cSSrinivas Kandagatla struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); 18168da9db0cSSrinivas Kandagatla struct wcd938x_priv *wcd938x = snd_soc_component_get_drvdata(component); 18178da9db0cSSrinivas Kandagatla int hph_mode = wcd938x->hph_mode; 18188da9db0cSSrinivas Kandagatla 18198da9db0cSSrinivas Kandagatla switch (event) { 18208da9db0cSSrinivas Kandagatla case SND_SOC_DAPM_PRE_PMU: 18218da9db0cSSrinivas Kandagatla if (wcd938x->ldoh) 18228da9db0cSSrinivas Kandagatla snd_soc_component_write_field(component, WCD938X_LDOH_MODE, 18238da9db0cSSrinivas Kandagatla WCD938X_LDOH_EN_MASK, 1); 18248da9db0cSSrinivas Kandagatla wcd_clsh_ctrl_set_state(wcd938x->clsh_info, WCD_CLSH_EVENT_PRE_DAC, 18258da9db0cSSrinivas Kandagatla WCD_CLSH_STATE_HPHL, hph_mode); 18268da9db0cSSrinivas Kandagatla wcd_clsh_set_hph_mode(wcd938x->clsh_info, CLS_H_HIFI); 18278da9db0cSSrinivas Kandagatla if (hph_mode == CLS_H_LP || hph_mode == CLS_H_LOHIFI || 18288da9db0cSSrinivas Kandagatla hph_mode == CLS_H_ULP) { 18298da9db0cSSrinivas Kandagatla snd_soc_component_write_field(component, 18308da9db0cSSrinivas Kandagatla WCD938X_HPH_REFBUFF_LP_CTL, 18318da9db0cSSrinivas Kandagatla WCD938X_PREREF_FLIT_BYPASS_MASK, 1); 18328da9db0cSSrinivas Kandagatla } 18338da9db0cSSrinivas Kandagatla snd_soc_component_write_field(component, WCD938X_ANA_HPH, 18348da9db0cSSrinivas Kandagatla WCD938X_HPHL_REF_EN_MASK, 1); 18358da9db0cSSrinivas Kandagatla wcd_clsh_set_hph_mode(wcd938x->clsh_info, hph_mode); 18368da9db0cSSrinivas Kandagatla /* 100 usec delay as per HW requirement */ 18378da9db0cSSrinivas Kandagatla usleep_range(100, 110); 18388da9db0cSSrinivas Kandagatla set_bit(HPH_PA_DELAY, &wcd938x->status_mask); 18398da9db0cSSrinivas Kandagatla snd_soc_component_write_field(component, 18408da9db0cSSrinivas Kandagatla WCD938X_DIGITAL_PDM_WD_CTL0, 18418da9db0cSSrinivas Kandagatla WCD938X_PDM_WD_EN_MASK, 0x3); 18428da9db0cSSrinivas Kandagatla break; 18438da9db0cSSrinivas Kandagatla case SND_SOC_DAPM_POST_PMU: 18448da9db0cSSrinivas Kandagatla /* 18458da9db0cSSrinivas Kandagatla * 7ms sleep is required if compander is enabled as per 18468da9db0cSSrinivas Kandagatla * HW requirement. If compander is disabled, then 18478da9db0cSSrinivas Kandagatla * 20ms delay is required. 18488da9db0cSSrinivas Kandagatla */ 18498da9db0cSSrinivas Kandagatla if (test_bit(HPH_PA_DELAY, &wcd938x->status_mask)) { 18508da9db0cSSrinivas Kandagatla if (!wcd938x->comp1_enable) 18518da9db0cSSrinivas Kandagatla usleep_range(20000, 20100); 18528da9db0cSSrinivas Kandagatla else 18538da9db0cSSrinivas Kandagatla usleep_range(7000, 7100); 18548da9db0cSSrinivas Kandagatla if (hph_mode == CLS_H_LP || hph_mode == CLS_H_LOHIFI || 18558da9db0cSSrinivas Kandagatla hph_mode == CLS_H_ULP) 18568da9db0cSSrinivas Kandagatla snd_soc_component_write_field(component, 18578da9db0cSSrinivas Kandagatla WCD938X_HPH_REFBUFF_LP_CTL, 18588da9db0cSSrinivas Kandagatla WCD938X_PREREF_FLIT_BYPASS_MASK, 0); 18598da9db0cSSrinivas Kandagatla clear_bit(HPH_PA_DELAY, &wcd938x->status_mask); 18608da9db0cSSrinivas Kandagatla } 18618da9db0cSSrinivas Kandagatla 18628da9db0cSSrinivas Kandagatla snd_soc_component_write_field(component, WCD938X_HPH_NEW_INT_HPH_TIMER1, 18638da9db0cSSrinivas Kandagatla WCD938X_AUTOCHOP_TIMER_EN, 1); 18648da9db0cSSrinivas Kandagatla if (hph_mode == CLS_AB || hph_mode == CLS_AB_HIFI || 18658da9db0cSSrinivas Kandagatla hph_mode == CLS_AB_LP || hph_mode == CLS_AB_LOHIFI) 18668da9db0cSSrinivas Kandagatla snd_soc_component_write_field(component, WCD938X_ANA_RX_SUPPLIES, 18678da9db0cSSrinivas Kandagatla WCD938X_REGULATOR_MODE_MASK, 18688da9db0cSSrinivas Kandagatla WCD938X_REGULATOR_MODE_CLASS_AB); 18698da9db0cSSrinivas Kandagatla enable_irq(wcd938x->hphl_pdm_wd_int); 18708da9db0cSSrinivas Kandagatla break; 18718da9db0cSSrinivas Kandagatla case SND_SOC_DAPM_PRE_PMD: 18728da9db0cSSrinivas Kandagatla disable_irq_nosync(wcd938x->hphl_pdm_wd_int); 18738da9db0cSSrinivas Kandagatla /* 18748da9db0cSSrinivas Kandagatla * 7ms sleep is required if compander is enabled as per 18758da9db0cSSrinivas Kandagatla * HW requirement. If compander is disabled, then 18768da9db0cSSrinivas Kandagatla * 20ms delay is required. 18778da9db0cSSrinivas Kandagatla */ 18788da9db0cSSrinivas Kandagatla if (!wcd938x->comp1_enable) 18798da9db0cSSrinivas Kandagatla usleep_range(20000, 20100); 18808da9db0cSSrinivas Kandagatla else 18818da9db0cSSrinivas Kandagatla usleep_range(7000, 7100); 18828da9db0cSSrinivas Kandagatla snd_soc_component_write_field(component, WCD938X_ANA_HPH, 18838da9db0cSSrinivas Kandagatla WCD938X_HPHL_EN_MASK, 0); 1884bcee7ed0SSrinivas Kandagatla wcd_mbhc_event_notify(wcd938x->wcd_mbhc, WCD_EVENT_PRE_HPHL_PA_OFF); 18858da9db0cSSrinivas Kandagatla set_bit(HPH_PA_DELAY, &wcd938x->status_mask); 18868da9db0cSSrinivas Kandagatla break; 18878da9db0cSSrinivas Kandagatla case SND_SOC_DAPM_POST_PMD: 18888da9db0cSSrinivas Kandagatla /* 18898da9db0cSSrinivas Kandagatla * 7ms sleep is required if compander is enabled as per 18908da9db0cSSrinivas Kandagatla * HW requirement. If compander is disabled, then 18918da9db0cSSrinivas Kandagatla * 20ms delay is required. 18928da9db0cSSrinivas Kandagatla */ 18938da9db0cSSrinivas Kandagatla if (test_bit(HPH_PA_DELAY, &wcd938x->status_mask)) { 18948da9db0cSSrinivas Kandagatla if (!wcd938x->comp1_enable) 18958da9db0cSSrinivas Kandagatla usleep_range(21000, 21100); 18968da9db0cSSrinivas Kandagatla else 18978da9db0cSSrinivas Kandagatla usleep_range(7000, 7100); 18988da9db0cSSrinivas Kandagatla clear_bit(HPH_PA_DELAY, &wcd938x->status_mask); 18998da9db0cSSrinivas Kandagatla } 1900bcee7ed0SSrinivas Kandagatla wcd_mbhc_event_notify(wcd938x->wcd_mbhc, 1901bcee7ed0SSrinivas Kandagatla WCD_EVENT_POST_HPHL_PA_OFF); 19028da9db0cSSrinivas Kandagatla snd_soc_component_write_field(component, WCD938X_ANA_HPH, 19038da9db0cSSrinivas Kandagatla WCD938X_HPHL_REF_EN_MASK, 0); 19048da9db0cSSrinivas Kandagatla snd_soc_component_write_field(component, WCD938X_DIGITAL_PDM_WD_CTL0, 19058da9db0cSSrinivas Kandagatla WCD938X_PDM_WD_EN_MASK, 0); 19068da9db0cSSrinivas Kandagatla wcd_clsh_ctrl_set_state(wcd938x->clsh_info, WCD_CLSH_EVENT_POST_PA, 19078da9db0cSSrinivas Kandagatla WCD_CLSH_STATE_HPHL, hph_mode); 19088da9db0cSSrinivas Kandagatla if (wcd938x->ldoh) 19098da9db0cSSrinivas Kandagatla snd_soc_component_write_field(component, WCD938X_LDOH_MODE, 19108da9db0cSSrinivas Kandagatla WCD938X_LDOH_EN_MASK, 0); 19118da9db0cSSrinivas Kandagatla break; 19128da9db0cSSrinivas Kandagatla } 19138da9db0cSSrinivas Kandagatla 19148da9db0cSSrinivas Kandagatla return 0; 19158da9db0cSSrinivas Kandagatla } 19168da9db0cSSrinivas Kandagatla 19178da9db0cSSrinivas Kandagatla static int wcd938x_codec_enable_aux_pa(struct snd_soc_dapm_widget *w, 19188da9db0cSSrinivas Kandagatla struct snd_kcontrol *kcontrol, int event) 19198da9db0cSSrinivas Kandagatla { 19208da9db0cSSrinivas Kandagatla struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); 19218da9db0cSSrinivas Kandagatla struct wcd938x_priv *wcd938x = snd_soc_component_get_drvdata(component); 19228da9db0cSSrinivas Kandagatla int hph_mode = wcd938x->hph_mode; 19238da9db0cSSrinivas Kandagatla 19248da9db0cSSrinivas Kandagatla switch (event) { 19258da9db0cSSrinivas Kandagatla case SND_SOC_DAPM_PRE_PMU: 19268da9db0cSSrinivas Kandagatla snd_soc_component_write_field(component, WCD938X_DIGITAL_PDM_WD_CTL2, 19278da9db0cSSrinivas Kandagatla WCD938X_AUX_PDM_WD_EN_MASK, 1); 19288da9db0cSSrinivas Kandagatla break; 19298da9db0cSSrinivas Kandagatla case SND_SOC_DAPM_POST_PMU: 19308da9db0cSSrinivas Kandagatla /* 1 msec delay as per HW requirement */ 19318da9db0cSSrinivas Kandagatla usleep_range(1000, 1010); 19328da9db0cSSrinivas Kandagatla if (hph_mode == CLS_AB || hph_mode == CLS_AB_HIFI || 19338da9db0cSSrinivas Kandagatla hph_mode == CLS_AB_LP || hph_mode == CLS_AB_LOHIFI) 19348da9db0cSSrinivas Kandagatla snd_soc_component_write_field(component, WCD938X_ANA_RX_SUPPLIES, 19358da9db0cSSrinivas Kandagatla WCD938X_REGULATOR_MODE_MASK, 19368da9db0cSSrinivas Kandagatla WCD938X_REGULATOR_MODE_CLASS_AB); 19378da9db0cSSrinivas Kandagatla enable_irq(wcd938x->aux_pdm_wd_int); 19388da9db0cSSrinivas Kandagatla break; 19398da9db0cSSrinivas Kandagatla case SND_SOC_DAPM_PRE_PMD: 19408da9db0cSSrinivas Kandagatla disable_irq_nosync(wcd938x->aux_pdm_wd_int); 19418da9db0cSSrinivas Kandagatla break; 19428da9db0cSSrinivas Kandagatla case SND_SOC_DAPM_POST_PMD: 19438da9db0cSSrinivas Kandagatla /* 1 msec delay as per HW requirement */ 19448da9db0cSSrinivas Kandagatla usleep_range(1000, 1010); 19458da9db0cSSrinivas Kandagatla snd_soc_component_write_field(component, WCD938X_DIGITAL_PDM_WD_CTL2, 19468da9db0cSSrinivas Kandagatla WCD938X_AUX_PDM_WD_EN_MASK, 0); 19478da9db0cSSrinivas Kandagatla wcd_clsh_ctrl_set_state(wcd938x->clsh_info, 19488da9db0cSSrinivas Kandagatla WCD_CLSH_EVENT_POST_PA, 19498da9db0cSSrinivas Kandagatla WCD_CLSH_STATE_AUX, 19508da9db0cSSrinivas Kandagatla hph_mode); 19518da9db0cSSrinivas Kandagatla 19528da9db0cSSrinivas Kandagatla wcd938x->flyback_cur_det_disable--; 19538da9db0cSSrinivas Kandagatla if (wcd938x->flyback_cur_det_disable == 0) 19548da9db0cSSrinivas Kandagatla snd_soc_component_write_field(component, WCD938X_FLYBACK_EN, 19558da9db0cSSrinivas Kandagatla WCD938X_EN_CUR_DET_MASK, 1); 19568da9db0cSSrinivas Kandagatla break; 19578da9db0cSSrinivas Kandagatla } 19584d0b79ecSkernel test robot return 0; 19598da9db0cSSrinivas Kandagatla } 19608da9db0cSSrinivas Kandagatla 19618da9db0cSSrinivas Kandagatla static int wcd938x_codec_enable_ear_pa(struct snd_soc_dapm_widget *w, 19628da9db0cSSrinivas Kandagatla struct snd_kcontrol *kcontrol, int event) 19638da9db0cSSrinivas Kandagatla { 19648da9db0cSSrinivas Kandagatla struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); 19658da9db0cSSrinivas Kandagatla struct wcd938x_priv *wcd938x = snd_soc_component_get_drvdata(component); 19668da9db0cSSrinivas Kandagatla int hph_mode = wcd938x->hph_mode; 19678da9db0cSSrinivas Kandagatla 19688da9db0cSSrinivas Kandagatla switch (event) { 19698da9db0cSSrinivas Kandagatla case SND_SOC_DAPM_PRE_PMU: 19708da9db0cSSrinivas Kandagatla /* 19718da9db0cSSrinivas Kandagatla * Enable watchdog interrupt for HPHL or AUX 19728da9db0cSSrinivas Kandagatla * depending on mux value 19738da9db0cSSrinivas Kandagatla */ 19748da9db0cSSrinivas Kandagatla wcd938x->ear_rx_path = snd_soc_component_read(component, 19758da9db0cSSrinivas Kandagatla WCD938X_DIGITAL_CDC_EAR_PATH_CTL); 19768da9db0cSSrinivas Kandagatla if (wcd938x->ear_rx_path & EAR_RX_PATH_AUX) 19778da9db0cSSrinivas Kandagatla snd_soc_component_write_field(component, WCD938X_DIGITAL_PDM_WD_CTL2, 19788da9db0cSSrinivas Kandagatla WCD938X_AUX_PDM_WD_EN_MASK, 1); 19798da9db0cSSrinivas Kandagatla else 19808da9db0cSSrinivas Kandagatla snd_soc_component_write_field(component, 19818da9db0cSSrinivas Kandagatla WCD938X_DIGITAL_PDM_WD_CTL0, 19828da9db0cSSrinivas Kandagatla WCD938X_PDM_WD_EN_MASK, 0x3); 19838da9db0cSSrinivas Kandagatla if (!wcd938x->comp1_enable) 19848da9db0cSSrinivas Kandagatla snd_soc_component_write_field(component, 19858da9db0cSSrinivas Kandagatla WCD938X_ANA_EAR_COMPANDER_CTL, 19868da9db0cSSrinivas Kandagatla WCD938X_GAIN_OVRD_REG_MASK, 1); 19878da9db0cSSrinivas Kandagatla 19888da9db0cSSrinivas Kandagatla break; 19898da9db0cSSrinivas Kandagatla case SND_SOC_DAPM_POST_PMU: 19908da9db0cSSrinivas Kandagatla /* 6 msec delay as per HW requirement */ 19918da9db0cSSrinivas Kandagatla usleep_range(6000, 6010); 19928da9db0cSSrinivas Kandagatla if (hph_mode == CLS_AB || hph_mode == CLS_AB_HIFI || 19938da9db0cSSrinivas Kandagatla hph_mode == CLS_AB_LP || hph_mode == CLS_AB_LOHIFI) 19948da9db0cSSrinivas Kandagatla snd_soc_component_write_field(component, WCD938X_ANA_RX_SUPPLIES, 19958da9db0cSSrinivas Kandagatla WCD938X_REGULATOR_MODE_MASK, 19968da9db0cSSrinivas Kandagatla WCD938X_REGULATOR_MODE_CLASS_AB); 19978da9db0cSSrinivas Kandagatla if (wcd938x->ear_rx_path & EAR_RX_PATH_AUX) 19988da9db0cSSrinivas Kandagatla enable_irq(wcd938x->aux_pdm_wd_int); 19998da9db0cSSrinivas Kandagatla else 20008da9db0cSSrinivas Kandagatla enable_irq(wcd938x->hphl_pdm_wd_int); 20018da9db0cSSrinivas Kandagatla break; 20028da9db0cSSrinivas Kandagatla case SND_SOC_DAPM_PRE_PMD: 20038da9db0cSSrinivas Kandagatla if (wcd938x->ear_rx_path & EAR_RX_PATH_AUX) 20048da9db0cSSrinivas Kandagatla disable_irq_nosync(wcd938x->aux_pdm_wd_int); 20058da9db0cSSrinivas Kandagatla else 20068da9db0cSSrinivas Kandagatla disable_irq_nosync(wcd938x->hphl_pdm_wd_int); 20078da9db0cSSrinivas Kandagatla break; 20088da9db0cSSrinivas Kandagatla case SND_SOC_DAPM_POST_PMD: 20098da9db0cSSrinivas Kandagatla if (!wcd938x->comp1_enable) 20108da9db0cSSrinivas Kandagatla snd_soc_component_write_field(component, WCD938X_ANA_EAR_COMPANDER_CTL, 20118da9db0cSSrinivas Kandagatla WCD938X_GAIN_OVRD_REG_MASK, 0); 20128da9db0cSSrinivas Kandagatla /* 7 msec delay as per HW requirement */ 20138da9db0cSSrinivas Kandagatla usleep_range(7000, 7010); 20148da9db0cSSrinivas Kandagatla if (wcd938x->ear_rx_path & EAR_RX_PATH_AUX) 20158da9db0cSSrinivas Kandagatla snd_soc_component_write_field(component, WCD938X_DIGITAL_PDM_WD_CTL2, 20168da9db0cSSrinivas Kandagatla WCD938X_AUX_PDM_WD_EN_MASK, 0); 20178da9db0cSSrinivas Kandagatla else 20188da9db0cSSrinivas Kandagatla snd_soc_component_write_field(component, WCD938X_DIGITAL_PDM_WD_CTL0, 20198da9db0cSSrinivas Kandagatla WCD938X_PDM_WD_EN_MASK, 0); 20208da9db0cSSrinivas Kandagatla 20218da9db0cSSrinivas Kandagatla wcd_clsh_ctrl_set_state(wcd938x->clsh_info, WCD_CLSH_EVENT_POST_PA, 20228da9db0cSSrinivas Kandagatla WCD_CLSH_STATE_EAR, hph_mode); 20238da9db0cSSrinivas Kandagatla 20248da9db0cSSrinivas Kandagatla wcd938x->flyback_cur_det_disable--; 20258da9db0cSSrinivas Kandagatla if (wcd938x->flyback_cur_det_disable == 0) 20268da9db0cSSrinivas Kandagatla snd_soc_component_write_field(component, WCD938X_FLYBACK_EN, 20278da9db0cSSrinivas Kandagatla WCD938X_EN_CUR_DET_MASK, 1); 20288da9db0cSSrinivas Kandagatla break; 20298da9db0cSSrinivas Kandagatla } 20308da9db0cSSrinivas Kandagatla 20318da9db0cSSrinivas Kandagatla return 0; 20328da9db0cSSrinivas Kandagatla } 20338da9db0cSSrinivas Kandagatla 2034d5add08fSSrinivas Kandagatla static int wcd938x_codec_enable_dmic(struct snd_soc_dapm_widget *w, 2035d5add08fSSrinivas Kandagatla struct snd_kcontrol *kcontrol, 2036d5add08fSSrinivas Kandagatla int event) 2037d5add08fSSrinivas Kandagatla { 2038d5add08fSSrinivas Kandagatla struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); 2039d5add08fSSrinivas Kandagatla u16 dmic_clk_reg, dmic_clk_en_reg; 2040d5add08fSSrinivas Kandagatla u8 dmic_sel_mask, dmic_clk_mask; 2041d5add08fSSrinivas Kandagatla 2042d5add08fSSrinivas Kandagatla switch (w->shift) { 2043d5add08fSSrinivas Kandagatla case 0: 2044d5add08fSSrinivas Kandagatla case 1: 2045d5add08fSSrinivas Kandagatla dmic_clk_reg = WCD938X_DIGITAL_CDC_DMIC_RATE_1_2; 2046d5add08fSSrinivas Kandagatla dmic_clk_en_reg = WCD938X_DIGITAL_CDC_DMIC1_CTL; 2047d5add08fSSrinivas Kandagatla dmic_clk_mask = WCD938X_DMIC1_RATE_MASK; 2048d5add08fSSrinivas Kandagatla dmic_sel_mask = WCD938X_AMIC1_IN_SEL_MASK; 2049d5add08fSSrinivas Kandagatla break; 2050d5add08fSSrinivas Kandagatla case 2: 2051d5add08fSSrinivas Kandagatla case 3: 2052d5add08fSSrinivas Kandagatla dmic_clk_reg = WCD938X_DIGITAL_CDC_DMIC_RATE_1_2; 2053d5add08fSSrinivas Kandagatla dmic_clk_en_reg = WCD938X_DIGITAL_CDC_DMIC2_CTL; 2054d5add08fSSrinivas Kandagatla dmic_clk_mask = WCD938X_DMIC2_RATE_MASK; 2055d5add08fSSrinivas Kandagatla dmic_sel_mask = WCD938X_AMIC3_IN_SEL_MASK; 2056d5add08fSSrinivas Kandagatla break; 2057d5add08fSSrinivas Kandagatla case 4: 2058d5add08fSSrinivas Kandagatla case 5: 2059d5add08fSSrinivas Kandagatla dmic_clk_reg = WCD938X_DIGITAL_CDC_DMIC_RATE_3_4; 2060d5add08fSSrinivas Kandagatla dmic_clk_en_reg = WCD938X_DIGITAL_CDC_DMIC3_CTL; 2061d5add08fSSrinivas Kandagatla dmic_clk_mask = WCD938X_DMIC3_RATE_MASK; 2062d5add08fSSrinivas Kandagatla dmic_sel_mask = WCD938X_AMIC4_IN_SEL_MASK; 2063d5add08fSSrinivas Kandagatla break; 2064d5add08fSSrinivas Kandagatla case 6: 2065d5add08fSSrinivas Kandagatla case 7: 2066d5add08fSSrinivas Kandagatla dmic_clk_reg = WCD938X_DIGITAL_CDC_DMIC_RATE_3_4; 2067d5add08fSSrinivas Kandagatla dmic_clk_en_reg = WCD938X_DIGITAL_CDC_DMIC4_CTL; 2068d5add08fSSrinivas Kandagatla dmic_clk_mask = WCD938X_DMIC4_RATE_MASK; 2069d5add08fSSrinivas Kandagatla dmic_sel_mask = WCD938X_AMIC5_IN_SEL_MASK; 2070d5add08fSSrinivas Kandagatla break; 2071d5add08fSSrinivas Kandagatla default: 2072d5add08fSSrinivas Kandagatla dev_err(component->dev, "%s: Invalid DMIC Selection\n", 2073d5add08fSSrinivas Kandagatla __func__); 2074d5add08fSSrinivas Kandagatla return -EINVAL; 2075d5add08fSSrinivas Kandagatla } 2076d5add08fSSrinivas Kandagatla 2077d5add08fSSrinivas Kandagatla switch (event) { 2078d5add08fSSrinivas Kandagatla case SND_SOC_DAPM_PRE_PMU: 2079d5add08fSSrinivas Kandagatla snd_soc_component_write_field(component, 2080d5add08fSSrinivas Kandagatla WCD938X_DIGITAL_CDC_AMIC_CTL, 2081d5add08fSSrinivas Kandagatla dmic_sel_mask, 2082d5add08fSSrinivas Kandagatla WCD938X_AMIC1_IN_SEL_DMIC); 2083d5add08fSSrinivas Kandagatla /* 250us sleep as per HW requirement */ 2084d5add08fSSrinivas Kandagatla usleep_range(250, 260); 2085d5add08fSSrinivas Kandagatla /* Setting DMIC clock rate to 2.4MHz */ 2086d5add08fSSrinivas Kandagatla snd_soc_component_write_field(component, dmic_clk_reg, 2087d5add08fSSrinivas Kandagatla dmic_clk_mask, 2088d5add08fSSrinivas Kandagatla WCD938X_DMIC4_RATE_2P4MHZ); 2089d5add08fSSrinivas Kandagatla snd_soc_component_write_field(component, dmic_clk_en_reg, 2090d5add08fSSrinivas Kandagatla WCD938X_DMIC_CLK_EN_MASK, 1); 2091d5add08fSSrinivas Kandagatla /* enable clock scaling */ 2092d5add08fSSrinivas Kandagatla snd_soc_component_write_field(component, WCD938X_DIGITAL_CDC_DMIC_CTL, 2093d5add08fSSrinivas Kandagatla WCD938X_DMIC_CLK_SCALING_EN_MASK, 0x3); 2094d5add08fSSrinivas Kandagatla break; 2095d5add08fSSrinivas Kandagatla case SND_SOC_DAPM_POST_PMD: 2096d5add08fSSrinivas Kandagatla snd_soc_component_write_field(component, 2097d5add08fSSrinivas Kandagatla WCD938X_DIGITAL_CDC_AMIC_CTL, 2098d5add08fSSrinivas Kandagatla dmic_sel_mask, WCD938X_AMIC1_IN_SEL_AMIC); 2099d5add08fSSrinivas Kandagatla snd_soc_component_write_field(component, dmic_clk_en_reg, 2100d5add08fSSrinivas Kandagatla WCD938X_DMIC_CLK_EN_MASK, 0); 2101d5add08fSSrinivas Kandagatla break; 2102d5add08fSSrinivas Kandagatla } 2103d5add08fSSrinivas Kandagatla return 0; 2104d5add08fSSrinivas Kandagatla } 2105d5add08fSSrinivas Kandagatla 2106d5add08fSSrinivas Kandagatla static int wcd938x_tx_swr_ctrl(struct snd_soc_dapm_widget *w, 2107d5add08fSSrinivas Kandagatla struct snd_kcontrol *kcontrol, int event) 2108d5add08fSSrinivas Kandagatla { 2109d5add08fSSrinivas Kandagatla struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); 2110d5add08fSSrinivas Kandagatla struct wcd938x_priv *wcd938x = snd_soc_component_get_drvdata(component); 2111d5add08fSSrinivas Kandagatla int bank; 2112d5add08fSSrinivas Kandagatla int rate; 2113d5add08fSSrinivas Kandagatla 2114d5add08fSSrinivas Kandagatla bank = (wcd938x_swr_get_current_bank(wcd938x->sdw_priv[AIF1_CAP]->sdev)) ? 0 : 1; 2115d5add08fSSrinivas Kandagatla bank = bank ? 0 : 1; 2116d5add08fSSrinivas Kandagatla 2117d5add08fSSrinivas Kandagatla switch (event) { 2118d5add08fSSrinivas Kandagatla case SND_SOC_DAPM_PRE_PMU: 2119d5add08fSSrinivas Kandagatla if (strnstr(w->name, "ADC", sizeof("ADC"))) { 2120d5add08fSSrinivas Kandagatla int i = 0, mode = 0; 2121d5add08fSSrinivas Kandagatla 2122d5add08fSSrinivas Kandagatla if (test_bit(WCD_ADC1, &wcd938x->status_mask)) 2123d5add08fSSrinivas Kandagatla mode |= tx_mode_bit[wcd938x->tx_mode[WCD_ADC1]]; 2124d5add08fSSrinivas Kandagatla if (test_bit(WCD_ADC2, &wcd938x->status_mask)) 2125d5add08fSSrinivas Kandagatla mode |= tx_mode_bit[wcd938x->tx_mode[WCD_ADC2]]; 2126d5add08fSSrinivas Kandagatla if (test_bit(WCD_ADC3, &wcd938x->status_mask)) 2127d5add08fSSrinivas Kandagatla mode |= tx_mode_bit[wcd938x->tx_mode[WCD_ADC3]]; 2128d5add08fSSrinivas Kandagatla if (test_bit(WCD_ADC4, &wcd938x->status_mask)) 2129d5add08fSSrinivas Kandagatla mode |= tx_mode_bit[wcd938x->tx_mode[WCD_ADC4]]; 2130d5add08fSSrinivas Kandagatla 2131d5add08fSSrinivas Kandagatla if (mode != 0) { 2132d5add08fSSrinivas Kandagatla for (i = 0; i < ADC_MODE_ULP2; i++) { 2133d5add08fSSrinivas Kandagatla if (mode & (1 << i)) { 2134d5add08fSSrinivas Kandagatla i++; 2135d5add08fSSrinivas Kandagatla break; 2136d5add08fSSrinivas Kandagatla } 2137d5add08fSSrinivas Kandagatla } 2138d5add08fSSrinivas Kandagatla } 2139d5add08fSSrinivas Kandagatla rate = wcd938x_get_clk_rate(i); 2140d5add08fSSrinivas Kandagatla wcd938x_set_swr_clk_rate(component, rate, bank); 2141d5add08fSSrinivas Kandagatla /* Copy clk settings to active bank */ 2142d5add08fSSrinivas Kandagatla wcd938x_set_swr_clk_rate(component, rate, !bank); 2143d245fff1SSrinivas Kandagatla } 2144d5add08fSSrinivas Kandagatla break; 2145d5add08fSSrinivas Kandagatla case SND_SOC_DAPM_POST_PMD: 2146d5add08fSSrinivas Kandagatla if (strnstr(w->name, "ADC", sizeof("ADC"))) { 2147d5add08fSSrinivas Kandagatla rate = wcd938x_get_clk_rate(ADC_MODE_INVALID); 2148d5add08fSSrinivas Kandagatla wcd938x_set_swr_clk_rate(component, rate, !bank); 2149d5add08fSSrinivas Kandagatla wcd938x_set_swr_clk_rate(component, rate, bank); 2150d5add08fSSrinivas Kandagatla } 2151d5add08fSSrinivas Kandagatla break; 2152d5add08fSSrinivas Kandagatla } 2153d5add08fSSrinivas Kandagatla 2154d5add08fSSrinivas Kandagatla return 0; 2155d5add08fSSrinivas Kandagatla } 2156d5add08fSSrinivas Kandagatla 2157d5add08fSSrinivas Kandagatla static int wcd938x_get_adc_mode(int val) 2158d5add08fSSrinivas Kandagatla { 2159d5add08fSSrinivas Kandagatla int ret = 0; 2160d5add08fSSrinivas Kandagatla 2161d5add08fSSrinivas Kandagatla switch (val) { 2162d5add08fSSrinivas Kandagatla case ADC_MODE_INVALID: 2163d5add08fSSrinivas Kandagatla ret = ADC_MODE_VAL_NORMAL; 2164d5add08fSSrinivas Kandagatla break; 2165d5add08fSSrinivas Kandagatla case ADC_MODE_HIFI: 2166d5add08fSSrinivas Kandagatla ret = ADC_MODE_VAL_HIFI; 2167d5add08fSSrinivas Kandagatla break; 2168d5add08fSSrinivas Kandagatla case ADC_MODE_LO_HIF: 2169d5add08fSSrinivas Kandagatla ret = ADC_MODE_VAL_LO_HIF; 2170d5add08fSSrinivas Kandagatla break; 2171d5add08fSSrinivas Kandagatla case ADC_MODE_NORMAL: 2172d5add08fSSrinivas Kandagatla ret = ADC_MODE_VAL_NORMAL; 2173d5add08fSSrinivas Kandagatla break; 2174d5add08fSSrinivas Kandagatla case ADC_MODE_LP: 2175d5add08fSSrinivas Kandagatla ret = ADC_MODE_VAL_LP; 2176d5add08fSSrinivas Kandagatla break; 2177d5add08fSSrinivas Kandagatla case ADC_MODE_ULP1: 2178d5add08fSSrinivas Kandagatla ret = ADC_MODE_VAL_ULP1; 2179d5add08fSSrinivas Kandagatla break; 2180d5add08fSSrinivas Kandagatla case ADC_MODE_ULP2: 2181d5add08fSSrinivas Kandagatla ret = ADC_MODE_VAL_ULP2; 2182d5add08fSSrinivas Kandagatla break; 2183d5add08fSSrinivas Kandagatla default: 2184d5add08fSSrinivas Kandagatla ret = -EINVAL; 2185d5add08fSSrinivas Kandagatla break; 2186d5add08fSSrinivas Kandagatla } 2187d5add08fSSrinivas Kandagatla return ret; 2188d5add08fSSrinivas Kandagatla } 2189d5add08fSSrinivas Kandagatla 2190d5add08fSSrinivas Kandagatla static int wcd938x_codec_enable_adc(struct snd_soc_dapm_widget *w, 2191d5add08fSSrinivas Kandagatla struct snd_kcontrol *kcontrol, int event) 2192d5add08fSSrinivas Kandagatla { 2193d5add08fSSrinivas Kandagatla struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); 2194d5add08fSSrinivas Kandagatla struct wcd938x_priv *wcd938x = snd_soc_component_get_drvdata(component); 2195d5add08fSSrinivas Kandagatla 2196d5add08fSSrinivas Kandagatla switch (event) { 2197d5add08fSSrinivas Kandagatla case SND_SOC_DAPM_PRE_PMU: 2198d5add08fSSrinivas Kandagatla snd_soc_component_write_field(component, 2199d5add08fSSrinivas Kandagatla WCD938X_DIGITAL_CDC_ANA_CLK_CTL, 2200d5add08fSSrinivas Kandagatla WCD938X_ANA_TX_CLK_EN_MASK, 1); 2201d5add08fSSrinivas Kandagatla snd_soc_component_write_field(component, 2202d5add08fSSrinivas Kandagatla WCD938X_DIGITAL_CDC_ANA_CLK_CTL, 2203d5add08fSSrinivas Kandagatla WCD938X_ANA_TX_DIV2_CLK_EN_MASK, 1); 2204d5add08fSSrinivas Kandagatla set_bit(w->shift, &wcd938x->status_mask); 2205d5add08fSSrinivas Kandagatla break; 2206d5add08fSSrinivas Kandagatla case SND_SOC_DAPM_POST_PMD: 2207d5add08fSSrinivas Kandagatla snd_soc_component_write_field(component, WCD938X_DIGITAL_CDC_ANA_CLK_CTL, 2208d5add08fSSrinivas Kandagatla WCD938X_ANA_TX_CLK_EN_MASK, 0); 2209d5add08fSSrinivas Kandagatla clear_bit(w->shift, &wcd938x->status_mask); 2210d5add08fSSrinivas Kandagatla break; 2211d5add08fSSrinivas Kandagatla } 2212d5add08fSSrinivas Kandagatla 2213d5add08fSSrinivas Kandagatla return 0; 2214d5add08fSSrinivas Kandagatla } 2215d5add08fSSrinivas Kandagatla 2216d5add08fSSrinivas Kandagatla static void wcd938x_tx_channel_config(struct snd_soc_component *component, 2217d5add08fSSrinivas Kandagatla int channel, int mode) 2218d5add08fSSrinivas Kandagatla { 2219d5add08fSSrinivas Kandagatla int reg, mask; 2220d5add08fSSrinivas Kandagatla 2221d5add08fSSrinivas Kandagatla switch (channel) { 2222d5add08fSSrinivas Kandagatla case 0: 2223d5add08fSSrinivas Kandagatla reg = WCD938X_ANA_TX_CH2; 2224d5add08fSSrinivas Kandagatla mask = WCD938X_HPF1_INIT_MASK; 2225d5add08fSSrinivas Kandagatla break; 2226d5add08fSSrinivas Kandagatla case 1: 2227d5add08fSSrinivas Kandagatla reg = WCD938X_ANA_TX_CH2; 2228d5add08fSSrinivas Kandagatla mask = WCD938X_HPF2_INIT_MASK; 2229d5add08fSSrinivas Kandagatla break; 2230d5add08fSSrinivas Kandagatla case 2: 2231d5add08fSSrinivas Kandagatla reg = WCD938X_ANA_TX_CH4; 2232d5add08fSSrinivas Kandagatla mask = WCD938X_HPF3_INIT_MASK; 2233d5add08fSSrinivas Kandagatla break; 2234d5add08fSSrinivas Kandagatla case 3: 2235d5add08fSSrinivas Kandagatla reg = WCD938X_ANA_TX_CH4; 2236d5add08fSSrinivas Kandagatla mask = WCD938X_HPF4_INIT_MASK; 2237d5add08fSSrinivas Kandagatla break; 2238d245fff1SSrinivas Kandagatla default: 2239d245fff1SSrinivas Kandagatla return; 2240d5add08fSSrinivas Kandagatla } 2241d5add08fSSrinivas Kandagatla 2242d5add08fSSrinivas Kandagatla snd_soc_component_write_field(component, reg, mask, mode); 2243d5add08fSSrinivas Kandagatla } 2244d5add08fSSrinivas Kandagatla 2245d5add08fSSrinivas Kandagatla static int wcd938x_adc_enable_req(struct snd_soc_dapm_widget *w, 2246d5add08fSSrinivas Kandagatla struct snd_kcontrol *kcontrol, int event) 2247d5add08fSSrinivas Kandagatla { 2248d5add08fSSrinivas Kandagatla struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); 2249d5add08fSSrinivas Kandagatla struct wcd938x_priv *wcd938x = snd_soc_component_get_drvdata(component); 2250d5add08fSSrinivas Kandagatla int mode; 2251d5add08fSSrinivas Kandagatla 2252d5add08fSSrinivas Kandagatla switch (event) { 2253d5add08fSSrinivas Kandagatla case SND_SOC_DAPM_PRE_PMU: 2254d5add08fSSrinivas Kandagatla snd_soc_component_write_field(component, 2255d5add08fSSrinivas Kandagatla WCD938X_DIGITAL_CDC_REQ_CTL, 2256d5add08fSSrinivas Kandagatla WCD938X_FS_RATE_4P8_MASK, 1); 2257d5add08fSSrinivas Kandagatla snd_soc_component_write_field(component, 2258d5add08fSSrinivas Kandagatla WCD938X_DIGITAL_CDC_REQ_CTL, 2259d5add08fSSrinivas Kandagatla WCD938X_NO_NOTCH_MASK, 0); 2260d5add08fSSrinivas Kandagatla wcd938x_tx_channel_config(component, w->shift, 1); 2261d5add08fSSrinivas Kandagatla mode = wcd938x_get_adc_mode(wcd938x->tx_mode[w->shift]); 2262d5add08fSSrinivas Kandagatla if (mode < 0) { 2263d5add08fSSrinivas Kandagatla dev_info(component->dev, "Invalid ADC mode\n"); 2264d5add08fSSrinivas Kandagatla return -EINVAL; 2265d5add08fSSrinivas Kandagatla } 2266d5add08fSSrinivas Kandagatla switch (w->shift) { 2267d5add08fSSrinivas Kandagatla case 0: 2268d5add08fSSrinivas Kandagatla snd_soc_component_write_field(component, 2269d5add08fSSrinivas Kandagatla WCD938X_DIGITAL_CDC_TX_ANA_MODE_0_1, 2270d5add08fSSrinivas Kandagatla WCD938X_TXD0_MODE_MASK, mode); 2271d5add08fSSrinivas Kandagatla snd_soc_component_write_field(component, 2272d5add08fSSrinivas Kandagatla WCD938X_DIGITAL_CDC_DIG_CLK_CTL, 2273d5add08fSSrinivas Kandagatla WCD938X_TXD0_CLK_EN_MASK, 1); 2274d5add08fSSrinivas Kandagatla break; 2275d5add08fSSrinivas Kandagatla case 1: 2276d5add08fSSrinivas Kandagatla snd_soc_component_write_field(component, 2277d5add08fSSrinivas Kandagatla WCD938X_DIGITAL_CDC_TX_ANA_MODE_0_1, 2278d5add08fSSrinivas Kandagatla WCD938X_TXD1_MODE_MASK, mode); 2279d5add08fSSrinivas Kandagatla snd_soc_component_write_field(component, 2280d5add08fSSrinivas Kandagatla WCD938X_DIGITAL_CDC_DIG_CLK_CTL, 2281d5add08fSSrinivas Kandagatla WCD938X_TXD1_CLK_EN_MASK, 1); 2282d5add08fSSrinivas Kandagatla break; 2283d5add08fSSrinivas Kandagatla case 2: 2284d5add08fSSrinivas Kandagatla snd_soc_component_write_field(component, 2285d5add08fSSrinivas Kandagatla WCD938X_DIGITAL_CDC_TX_ANA_MODE_2_3, 2286d5add08fSSrinivas Kandagatla WCD938X_TXD2_MODE_MASK, mode); 2287d5add08fSSrinivas Kandagatla snd_soc_component_write_field(component, 2288d5add08fSSrinivas Kandagatla WCD938X_DIGITAL_CDC_DIG_CLK_CTL, 2289d5add08fSSrinivas Kandagatla WCD938X_TXD2_CLK_EN_MASK, 1); 2290d5add08fSSrinivas Kandagatla break; 2291d5add08fSSrinivas Kandagatla case 3: 2292d5add08fSSrinivas Kandagatla snd_soc_component_write_field(component, 2293d5add08fSSrinivas Kandagatla WCD938X_DIGITAL_CDC_TX_ANA_MODE_2_3, 2294d5add08fSSrinivas Kandagatla WCD938X_TXD3_MODE_MASK, mode); 2295d5add08fSSrinivas Kandagatla snd_soc_component_write_field(component, 2296d5add08fSSrinivas Kandagatla WCD938X_DIGITAL_CDC_DIG_CLK_CTL, 2297d5add08fSSrinivas Kandagatla WCD938X_TXD3_CLK_EN_MASK, 1); 2298d5add08fSSrinivas Kandagatla break; 2299d5add08fSSrinivas Kandagatla default: 2300d5add08fSSrinivas Kandagatla break; 2301d5add08fSSrinivas Kandagatla } 2302d5add08fSSrinivas Kandagatla 2303d5add08fSSrinivas Kandagatla wcd938x_tx_channel_config(component, w->shift, 0); 2304d5add08fSSrinivas Kandagatla break; 2305d5add08fSSrinivas Kandagatla case SND_SOC_DAPM_POST_PMD: 2306d5add08fSSrinivas Kandagatla switch (w->shift) { 2307d5add08fSSrinivas Kandagatla case 0: 2308d5add08fSSrinivas Kandagatla snd_soc_component_write_field(component, 2309d5add08fSSrinivas Kandagatla WCD938X_DIGITAL_CDC_TX_ANA_MODE_0_1, 2310d5add08fSSrinivas Kandagatla WCD938X_TXD0_MODE_MASK, 0); 2311d5add08fSSrinivas Kandagatla snd_soc_component_write_field(component, 2312d5add08fSSrinivas Kandagatla WCD938X_DIGITAL_CDC_DIG_CLK_CTL, 2313d5add08fSSrinivas Kandagatla WCD938X_TXD0_CLK_EN_MASK, 0); 2314d5add08fSSrinivas Kandagatla break; 2315d5add08fSSrinivas Kandagatla case 1: 2316d5add08fSSrinivas Kandagatla snd_soc_component_write_field(component, 2317d5add08fSSrinivas Kandagatla WCD938X_DIGITAL_CDC_TX_ANA_MODE_0_1, 2318d5add08fSSrinivas Kandagatla WCD938X_TXD1_MODE_MASK, 0); 2319d5add08fSSrinivas Kandagatla snd_soc_component_write_field(component, 2320d5add08fSSrinivas Kandagatla WCD938X_DIGITAL_CDC_DIG_CLK_CTL, 2321d5add08fSSrinivas Kandagatla WCD938X_TXD1_CLK_EN_MASK, 0); 2322d5add08fSSrinivas Kandagatla break; 2323d5add08fSSrinivas Kandagatla case 2: 2324d5add08fSSrinivas Kandagatla snd_soc_component_write_field(component, 2325d5add08fSSrinivas Kandagatla WCD938X_DIGITAL_CDC_TX_ANA_MODE_2_3, 2326d5add08fSSrinivas Kandagatla WCD938X_TXD2_MODE_MASK, 0); 2327d5add08fSSrinivas Kandagatla snd_soc_component_write_field(component, 2328d5add08fSSrinivas Kandagatla WCD938X_DIGITAL_CDC_DIG_CLK_CTL, 2329d5add08fSSrinivas Kandagatla WCD938X_TXD2_CLK_EN_MASK, 0); 2330d5add08fSSrinivas Kandagatla break; 2331d5add08fSSrinivas Kandagatla case 3: 2332d5add08fSSrinivas Kandagatla snd_soc_component_write_field(component, 2333d5add08fSSrinivas Kandagatla WCD938X_DIGITAL_CDC_TX_ANA_MODE_2_3, 2334d5add08fSSrinivas Kandagatla WCD938X_TXD3_MODE_MASK, 0); 2335d5add08fSSrinivas Kandagatla snd_soc_component_write_field(component, 2336d5add08fSSrinivas Kandagatla WCD938X_DIGITAL_CDC_DIG_CLK_CTL, 2337d5add08fSSrinivas Kandagatla WCD938X_TXD3_CLK_EN_MASK, 0); 2338d5add08fSSrinivas Kandagatla break; 2339d5add08fSSrinivas Kandagatla default: 2340d5add08fSSrinivas Kandagatla break; 2341d5add08fSSrinivas Kandagatla } 2342d5add08fSSrinivas Kandagatla snd_soc_component_write_field(component, 2343d5add08fSSrinivas Kandagatla WCD938X_DIGITAL_CDC_ANA_CLK_CTL, 2344d5add08fSSrinivas Kandagatla WCD938X_ANA_TX_DIV2_CLK_EN_MASK, 0); 2345d5add08fSSrinivas Kandagatla break; 2346d5add08fSSrinivas Kandagatla } 2347d5add08fSSrinivas Kandagatla 2348d5add08fSSrinivas Kandagatla return 0; 2349d5add08fSSrinivas Kandagatla } 2350d5add08fSSrinivas Kandagatla 2351d5add08fSSrinivas Kandagatla static int wcd938x_micbias_control(struct snd_soc_component *component, 2352d5add08fSSrinivas Kandagatla int micb_num, int req, bool is_dapm) 2353d5add08fSSrinivas Kandagatla { 2354d5add08fSSrinivas Kandagatla struct wcd938x_priv *wcd938x = snd_soc_component_get_drvdata(component); 2355d5add08fSSrinivas Kandagatla int micb_index = micb_num - 1; 2356d5add08fSSrinivas Kandagatla u16 micb_reg; 2357d5add08fSSrinivas Kandagatla 2358d5add08fSSrinivas Kandagatla switch (micb_num) { 2359d5add08fSSrinivas Kandagatla case MIC_BIAS_1: 2360d5add08fSSrinivas Kandagatla micb_reg = WCD938X_ANA_MICB1; 2361d5add08fSSrinivas Kandagatla break; 2362d5add08fSSrinivas Kandagatla case MIC_BIAS_2: 2363d5add08fSSrinivas Kandagatla micb_reg = WCD938X_ANA_MICB2; 2364d5add08fSSrinivas Kandagatla break; 2365d5add08fSSrinivas Kandagatla case MIC_BIAS_3: 2366d5add08fSSrinivas Kandagatla micb_reg = WCD938X_ANA_MICB3; 2367d5add08fSSrinivas Kandagatla break; 2368d5add08fSSrinivas Kandagatla case MIC_BIAS_4: 2369d5add08fSSrinivas Kandagatla micb_reg = WCD938X_ANA_MICB4; 2370d5add08fSSrinivas Kandagatla break; 2371d5add08fSSrinivas Kandagatla default: 2372d5add08fSSrinivas Kandagatla dev_err(component->dev, "%s: Invalid micbias number: %d\n", 2373d5add08fSSrinivas Kandagatla __func__, micb_num); 2374d5add08fSSrinivas Kandagatla return -EINVAL; 2375d5add08fSSrinivas Kandagatla } 2376d5add08fSSrinivas Kandagatla 2377d5add08fSSrinivas Kandagatla switch (req) { 2378d5add08fSSrinivas Kandagatla case MICB_PULLUP_ENABLE: 2379d5add08fSSrinivas Kandagatla wcd938x->pullup_ref[micb_index]++; 2380d5add08fSSrinivas Kandagatla if ((wcd938x->pullup_ref[micb_index] == 1) && 2381d5add08fSSrinivas Kandagatla (wcd938x->micb_ref[micb_index] == 0)) 2382d5add08fSSrinivas Kandagatla snd_soc_component_write_field(component, micb_reg, 2383d5add08fSSrinivas Kandagatla WCD938X_MICB_EN_MASK, 2384d5add08fSSrinivas Kandagatla WCD938X_MICB_PULL_UP); 2385d5add08fSSrinivas Kandagatla break; 2386d5add08fSSrinivas Kandagatla case MICB_PULLUP_DISABLE: 2387d5add08fSSrinivas Kandagatla if (wcd938x->pullup_ref[micb_index] > 0) 2388d5add08fSSrinivas Kandagatla wcd938x->pullup_ref[micb_index]--; 2389d5add08fSSrinivas Kandagatla 2390d5add08fSSrinivas Kandagatla if ((wcd938x->pullup_ref[micb_index] == 0) && 2391d5add08fSSrinivas Kandagatla (wcd938x->micb_ref[micb_index] == 0)) 2392d5add08fSSrinivas Kandagatla snd_soc_component_write_field(component, micb_reg, 2393d5add08fSSrinivas Kandagatla WCD938X_MICB_EN_MASK, 0); 2394d5add08fSSrinivas Kandagatla break; 2395d5add08fSSrinivas Kandagatla case MICB_ENABLE: 2396d5add08fSSrinivas Kandagatla wcd938x->micb_ref[micb_index]++; 2397d5add08fSSrinivas Kandagatla if (wcd938x->micb_ref[micb_index] == 1) { 2398d5add08fSSrinivas Kandagatla snd_soc_component_write_field(component, 2399d5add08fSSrinivas Kandagatla WCD938X_DIGITAL_CDC_DIG_CLK_CTL, 2400d5add08fSSrinivas Kandagatla WCD938X_TX_CLK_EN_MASK, 0xF); 2401d5add08fSSrinivas Kandagatla snd_soc_component_write_field(component, 2402d5add08fSSrinivas Kandagatla WCD938X_DIGITAL_CDC_ANA_CLK_CTL, 2403d5add08fSSrinivas Kandagatla WCD938X_ANA_TX_DIV2_CLK_EN_MASK, 1); 2404d5add08fSSrinivas Kandagatla snd_soc_component_write_field(component, 2405d5add08fSSrinivas Kandagatla WCD938X_DIGITAL_CDC_ANA_TX_CLK_CTL, 2406d5add08fSSrinivas Kandagatla WCD938X_TX_SC_CLK_EN_MASK, 1); 2407d5add08fSSrinivas Kandagatla 2408d5add08fSSrinivas Kandagatla snd_soc_component_write_field(component, micb_reg, 2409d5add08fSSrinivas Kandagatla WCD938X_MICB_EN_MASK, 2410d5add08fSSrinivas Kandagatla WCD938X_MICB_ENABLE); 2411bcee7ed0SSrinivas Kandagatla if (micb_num == MIC_BIAS_2) 2412bcee7ed0SSrinivas Kandagatla wcd_mbhc_event_notify(wcd938x->wcd_mbhc, 2413bcee7ed0SSrinivas Kandagatla WCD_EVENT_POST_MICBIAS_2_ON); 2414d5add08fSSrinivas Kandagatla } 2415bcee7ed0SSrinivas Kandagatla if (micb_num == MIC_BIAS_2 && is_dapm) 2416bcee7ed0SSrinivas Kandagatla wcd_mbhc_event_notify(wcd938x->wcd_mbhc, 2417bcee7ed0SSrinivas Kandagatla WCD_EVENT_POST_DAPM_MICBIAS_2_ON); 2418bcee7ed0SSrinivas Kandagatla 2419d5add08fSSrinivas Kandagatla 2420d5add08fSSrinivas Kandagatla break; 2421d5add08fSSrinivas Kandagatla case MICB_DISABLE: 2422d5add08fSSrinivas Kandagatla if (wcd938x->micb_ref[micb_index] > 0) 2423d5add08fSSrinivas Kandagatla wcd938x->micb_ref[micb_index]--; 2424d5add08fSSrinivas Kandagatla 2425d5add08fSSrinivas Kandagatla if ((wcd938x->micb_ref[micb_index] == 0) && 2426d5add08fSSrinivas Kandagatla (wcd938x->pullup_ref[micb_index] > 0)) 2427d5add08fSSrinivas Kandagatla snd_soc_component_write_field(component, micb_reg, 2428d5add08fSSrinivas Kandagatla WCD938X_MICB_EN_MASK, 2429d5add08fSSrinivas Kandagatla WCD938X_MICB_PULL_UP); 2430d5add08fSSrinivas Kandagatla else if ((wcd938x->micb_ref[micb_index] == 0) && 2431d5add08fSSrinivas Kandagatla (wcd938x->pullup_ref[micb_index] == 0)) { 2432bcee7ed0SSrinivas Kandagatla if (micb_num == MIC_BIAS_2) 2433bcee7ed0SSrinivas Kandagatla wcd_mbhc_event_notify(wcd938x->wcd_mbhc, 2434bcee7ed0SSrinivas Kandagatla WCD_EVENT_PRE_MICBIAS_2_OFF); 2435d5add08fSSrinivas Kandagatla 2436d5add08fSSrinivas Kandagatla snd_soc_component_write_field(component, micb_reg, 2437d5add08fSSrinivas Kandagatla WCD938X_MICB_EN_MASK, 0); 2438bcee7ed0SSrinivas Kandagatla if (micb_num == MIC_BIAS_2) 2439bcee7ed0SSrinivas Kandagatla wcd_mbhc_event_notify(wcd938x->wcd_mbhc, 2440bcee7ed0SSrinivas Kandagatla WCD_EVENT_POST_MICBIAS_2_OFF); 2441d5add08fSSrinivas Kandagatla } 2442bcee7ed0SSrinivas Kandagatla if (is_dapm && micb_num == MIC_BIAS_2) 2443bcee7ed0SSrinivas Kandagatla wcd_mbhc_event_notify(wcd938x->wcd_mbhc, 2444bcee7ed0SSrinivas Kandagatla WCD_EVENT_POST_DAPM_MICBIAS_2_OFF); 2445d5add08fSSrinivas Kandagatla break; 2446d5add08fSSrinivas Kandagatla } 2447d5add08fSSrinivas Kandagatla 2448d5add08fSSrinivas Kandagatla return 0; 2449d5add08fSSrinivas Kandagatla } 2450d5add08fSSrinivas Kandagatla 2451d5add08fSSrinivas Kandagatla static int wcd938x_codec_enable_micbias(struct snd_soc_dapm_widget *w, 2452d5add08fSSrinivas Kandagatla struct snd_kcontrol *kcontrol, 2453d5add08fSSrinivas Kandagatla int event) 2454d5add08fSSrinivas Kandagatla { 2455d5add08fSSrinivas Kandagatla struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); 2456d5add08fSSrinivas Kandagatla int micb_num = w->shift; 2457d5add08fSSrinivas Kandagatla 2458d5add08fSSrinivas Kandagatla switch (event) { 2459d5add08fSSrinivas Kandagatla case SND_SOC_DAPM_PRE_PMU: 2460d5add08fSSrinivas Kandagatla wcd938x_micbias_control(component, micb_num, MICB_ENABLE, true); 2461d5add08fSSrinivas Kandagatla break; 2462d5add08fSSrinivas Kandagatla case SND_SOC_DAPM_POST_PMU: 2463d5add08fSSrinivas Kandagatla /* 1 msec delay as per HW requirement */ 2464d5add08fSSrinivas Kandagatla usleep_range(1000, 1100); 2465d5add08fSSrinivas Kandagatla break; 2466d5add08fSSrinivas Kandagatla case SND_SOC_DAPM_POST_PMD: 2467d5add08fSSrinivas Kandagatla wcd938x_micbias_control(component, micb_num, MICB_DISABLE, true); 2468d5add08fSSrinivas Kandagatla break; 2469d5add08fSSrinivas Kandagatla } 2470d5add08fSSrinivas Kandagatla 2471d5add08fSSrinivas Kandagatla return 0; 2472d5add08fSSrinivas Kandagatla } 2473d5add08fSSrinivas Kandagatla 2474d5add08fSSrinivas Kandagatla static int wcd938x_codec_enable_micbias_pullup(struct snd_soc_dapm_widget *w, 2475d5add08fSSrinivas Kandagatla struct snd_kcontrol *kcontrol, 2476d5add08fSSrinivas Kandagatla int event) 2477d5add08fSSrinivas Kandagatla { 2478d5add08fSSrinivas Kandagatla struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); 2479d5add08fSSrinivas Kandagatla int micb_num = w->shift; 2480d5add08fSSrinivas Kandagatla 2481d5add08fSSrinivas Kandagatla switch (event) { 2482d5add08fSSrinivas Kandagatla case SND_SOC_DAPM_PRE_PMU: 2483d5add08fSSrinivas Kandagatla wcd938x_micbias_control(component, micb_num, 2484d5add08fSSrinivas Kandagatla MICB_PULLUP_ENABLE, true); 2485d5add08fSSrinivas Kandagatla break; 2486d5add08fSSrinivas Kandagatla case SND_SOC_DAPM_POST_PMU: 2487d5add08fSSrinivas Kandagatla /* 1 msec delay as per HW requirement */ 2488d5add08fSSrinivas Kandagatla usleep_range(1000, 1100); 2489d5add08fSSrinivas Kandagatla break; 2490d5add08fSSrinivas Kandagatla case SND_SOC_DAPM_POST_PMD: 2491d5add08fSSrinivas Kandagatla wcd938x_micbias_control(component, micb_num, 2492d5add08fSSrinivas Kandagatla MICB_PULLUP_DISABLE, true); 2493d5add08fSSrinivas Kandagatla break; 2494d5add08fSSrinivas Kandagatla } 2495d5add08fSSrinivas Kandagatla 2496d5add08fSSrinivas Kandagatla return 0; 2497d5add08fSSrinivas Kandagatla } 2498d5add08fSSrinivas Kandagatla 2499e8ba1e05SSrinivas Kandagatla static int wcd938x_tx_mode_get(struct snd_kcontrol *kcontrol, 2500e8ba1e05SSrinivas Kandagatla struct snd_ctl_elem_value *ucontrol) 2501e8ba1e05SSrinivas Kandagatla { 2502e8ba1e05SSrinivas Kandagatla struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); 2503e8ba1e05SSrinivas Kandagatla struct wcd938x_priv *wcd938x = snd_soc_component_get_drvdata(component); 2504e8ba1e05SSrinivas Kandagatla struct soc_enum *e = (struct soc_enum *)kcontrol->private_value; 2505e8ba1e05SSrinivas Kandagatla int path = e->shift_l; 2506e8ba1e05SSrinivas Kandagatla 2507*cc587b7cSSrinivas Kandagatla ucontrol->value.enumerated.item[0] = wcd938x->tx_mode[path]; 2508e8ba1e05SSrinivas Kandagatla 2509e8ba1e05SSrinivas Kandagatla return 0; 2510e8ba1e05SSrinivas Kandagatla } 2511e8ba1e05SSrinivas Kandagatla 2512e8ba1e05SSrinivas Kandagatla static int wcd938x_tx_mode_put(struct snd_kcontrol *kcontrol, 2513e8ba1e05SSrinivas Kandagatla struct snd_ctl_elem_value *ucontrol) 2514e8ba1e05SSrinivas Kandagatla { 2515e8ba1e05SSrinivas Kandagatla struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); 2516e8ba1e05SSrinivas Kandagatla struct wcd938x_priv *wcd938x = snd_soc_component_get_drvdata(component); 2517e8ba1e05SSrinivas Kandagatla struct soc_enum *e = (struct soc_enum *)kcontrol->private_value; 2518e8ba1e05SSrinivas Kandagatla int path = e->shift_l; 2519e8ba1e05SSrinivas Kandagatla 2520e8ba1e05SSrinivas Kandagatla wcd938x->tx_mode[path] = ucontrol->value.enumerated.item[0]; 2521e8ba1e05SSrinivas Kandagatla 2522e8ba1e05SSrinivas Kandagatla return 1; 2523e8ba1e05SSrinivas Kandagatla } 2524e8ba1e05SSrinivas Kandagatla 2525e8ba1e05SSrinivas Kandagatla static int wcd938x_rx_hph_mode_get(struct snd_kcontrol *kcontrol, 2526e8ba1e05SSrinivas Kandagatla struct snd_ctl_elem_value *ucontrol) 2527e8ba1e05SSrinivas Kandagatla { 2528e8ba1e05SSrinivas Kandagatla struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); 2529e8ba1e05SSrinivas Kandagatla struct wcd938x_priv *wcd938x = snd_soc_component_get_drvdata(component); 2530e8ba1e05SSrinivas Kandagatla 2531*cc587b7cSSrinivas Kandagatla ucontrol->value.enumerated.item[0] = wcd938x->hph_mode; 2532e8ba1e05SSrinivas Kandagatla 2533e8ba1e05SSrinivas Kandagatla return 0; 2534e8ba1e05SSrinivas Kandagatla } 2535e8ba1e05SSrinivas Kandagatla 2536e8ba1e05SSrinivas Kandagatla static int wcd938x_rx_hph_mode_put(struct snd_kcontrol *kcontrol, 2537e8ba1e05SSrinivas Kandagatla struct snd_ctl_elem_value *ucontrol) 2538e8ba1e05SSrinivas Kandagatla { 2539e8ba1e05SSrinivas Kandagatla struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); 2540e8ba1e05SSrinivas Kandagatla struct wcd938x_priv *wcd938x = snd_soc_component_get_drvdata(component); 2541e8ba1e05SSrinivas Kandagatla 2542e8ba1e05SSrinivas Kandagatla wcd938x->hph_mode = ucontrol->value.enumerated.item[0]; 2543e8ba1e05SSrinivas Kandagatla 2544e8ba1e05SSrinivas Kandagatla return 1; 2545e8ba1e05SSrinivas Kandagatla } 2546e8ba1e05SSrinivas Kandagatla 2547e8ba1e05SSrinivas Kandagatla static int wcd938x_ear_pa_put_gain(struct snd_kcontrol *kcontrol, 2548e8ba1e05SSrinivas Kandagatla struct snd_ctl_elem_value *ucontrol) 2549e8ba1e05SSrinivas Kandagatla { 2550e8ba1e05SSrinivas Kandagatla struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); 2551e8ba1e05SSrinivas Kandagatla struct wcd938x_priv *wcd938x = snd_soc_component_get_drvdata(component); 2552e8ba1e05SSrinivas Kandagatla 2553e8ba1e05SSrinivas Kandagatla if (wcd938x->comp1_enable) { 2554e8ba1e05SSrinivas Kandagatla dev_err(component->dev, "Can not set EAR PA Gain, compander1 is enabled\n"); 2555e8ba1e05SSrinivas Kandagatla return -EINVAL; 2556e8ba1e05SSrinivas Kandagatla } 2557e8ba1e05SSrinivas Kandagatla 2558e8ba1e05SSrinivas Kandagatla snd_soc_component_write_field(component, WCD938X_ANA_EAR_COMPANDER_CTL, 2559e8ba1e05SSrinivas Kandagatla WCD938X_EAR_GAIN_MASK, 2560e8ba1e05SSrinivas Kandagatla ucontrol->value.integer.value[0]); 2561e8ba1e05SSrinivas Kandagatla 2562bd2347fdSSrinivas Kandagatla return 1; 2563e8ba1e05SSrinivas Kandagatla } 2564e8ba1e05SSrinivas Kandagatla 2565e8ba1e05SSrinivas Kandagatla static int wcd938x_get_compander(struct snd_kcontrol *kcontrol, 2566e8ba1e05SSrinivas Kandagatla struct snd_ctl_elem_value *ucontrol) 2567e8ba1e05SSrinivas Kandagatla { 2568e8ba1e05SSrinivas Kandagatla 2569e8ba1e05SSrinivas Kandagatla struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); 2570e8ba1e05SSrinivas Kandagatla struct wcd938x_priv *wcd938x = snd_soc_component_get_drvdata(component); 2571e8ba1e05SSrinivas Kandagatla struct soc_mixer_control *mc; 2572e8ba1e05SSrinivas Kandagatla bool hphr; 2573e8ba1e05SSrinivas Kandagatla 2574e8ba1e05SSrinivas Kandagatla mc = (struct soc_mixer_control *)(kcontrol->private_value); 2575e8ba1e05SSrinivas Kandagatla hphr = mc->shift; 2576e8ba1e05SSrinivas Kandagatla 2577e8ba1e05SSrinivas Kandagatla if (hphr) 2578e8ba1e05SSrinivas Kandagatla ucontrol->value.integer.value[0] = wcd938x->comp2_enable; 2579e8ba1e05SSrinivas Kandagatla else 2580e8ba1e05SSrinivas Kandagatla ucontrol->value.integer.value[0] = wcd938x->comp1_enable; 2581e8ba1e05SSrinivas Kandagatla 2582e8ba1e05SSrinivas Kandagatla return 0; 2583e8ba1e05SSrinivas Kandagatla } 2584e8ba1e05SSrinivas Kandagatla 2585e8ba1e05SSrinivas Kandagatla static int wcd938x_set_compander(struct snd_kcontrol *kcontrol, 2586e8ba1e05SSrinivas Kandagatla struct snd_ctl_elem_value *ucontrol) 2587e8ba1e05SSrinivas Kandagatla { 2588e8ba1e05SSrinivas Kandagatla struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); 2589e8ba1e05SSrinivas Kandagatla struct wcd938x_priv *wcd938x = snd_soc_component_get_drvdata(component); 2590e8ba1e05SSrinivas Kandagatla struct wcd938x_sdw_priv *wcd; 2591e8ba1e05SSrinivas Kandagatla int value = ucontrol->value.integer.value[0]; 2592c5c1546aSSrinivas Kandagatla int portidx; 2593e8ba1e05SSrinivas Kandagatla struct soc_mixer_control *mc; 2594e8ba1e05SSrinivas Kandagatla bool hphr; 2595e8ba1e05SSrinivas Kandagatla 2596e8ba1e05SSrinivas Kandagatla mc = (struct soc_mixer_control *)(kcontrol->private_value); 2597e8ba1e05SSrinivas Kandagatla hphr = mc->shift; 2598e8ba1e05SSrinivas Kandagatla 2599e8ba1e05SSrinivas Kandagatla wcd = wcd938x->sdw_priv[AIF1_PB]; 2600e8ba1e05SSrinivas Kandagatla 2601e8ba1e05SSrinivas Kandagatla if (hphr) 2602e8ba1e05SSrinivas Kandagatla wcd938x->comp2_enable = value; 2603e8ba1e05SSrinivas Kandagatla else 2604e8ba1e05SSrinivas Kandagatla wcd938x->comp1_enable = value; 2605e8ba1e05SSrinivas Kandagatla 2606c5c1546aSSrinivas Kandagatla portidx = wcd->ch_info[mc->reg].port_num; 2607c5c1546aSSrinivas Kandagatla 2608e8ba1e05SSrinivas Kandagatla if (value) 2609c5c1546aSSrinivas Kandagatla wcd938x_connect_port(wcd, portidx, mc->reg, true); 2610e8ba1e05SSrinivas Kandagatla else 2611c5c1546aSSrinivas Kandagatla wcd938x_connect_port(wcd, portidx, mc->reg, false); 2612e8ba1e05SSrinivas Kandagatla 2613bd2347fdSSrinivas Kandagatla return 1; 2614e8ba1e05SSrinivas Kandagatla } 2615e8ba1e05SSrinivas Kandagatla 2616e8ba1e05SSrinivas Kandagatla static int wcd938x_ldoh_get(struct snd_kcontrol *kcontrol, 2617e8ba1e05SSrinivas Kandagatla struct snd_ctl_elem_value *ucontrol) 2618e8ba1e05SSrinivas Kandagatla { 2619e8ba1e05SSrinivas Kandagatla struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); 2620e8ba1e05SSrinivas Kandagatla struct wcd938x_priv *wcd938x = snd_soc_component_get_drvdata(component); 2621e8ba1e05SSrinivas Kandagatla 2622e8ba1e05SSrinivas Kandagatla ucontrol->value.integer.value[0] = wcd938x->ldoh; 2623e8ba1e05SSrinivas Kandagatla 2624e8ba1e05SSrinivas Kandagatla return 0; 2625e8ba1e05SSrinivas Kandagatla } 2626e8ba1e05SSrinivas Kandagatla 2627e8ba1e05SSrinivas Kandagatla static int wcd938x_ldoh_put(struct snd_kcontrol *kcontrol, 2628e8ba1e05SSrinivas Kandagatla struct snd_ctl_elem_value *ucontrol) 2629e8ba1e05SSrinivas Kandagatla { 2630e8ba1e05SSrinivas Kandagatla struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); 2631e8ba1e05SSrinivas Kandagatla struct wcd938x_priv *wcd938x = snd_soc_component_get_drvdata(component); 2632e8ba1e05SSrinivas Kandagatla 2633e8ba1e05SSrinivas Kandagatla wcd938x->ldoh = ucontrol->value.integer.value[0]; 2634e8ba1e05SSrinivas Kandagatla 2635e8ba1e05SSrinivas Kandagatla return 1; 2636e8ba1e05SSrinivas Kandagatla } 2637e8ba1e05SSrinivas Kandagatla 2638e8ba1e05SSrinivas Kandagatla static int wcd938x_bcs_get(struct snd_kcontrol *kcontrol, 2639e8ba1e05SSrinivas Kandagatla struct snd_ctl_elem_value *ucontrol) 2640e8ba1e05SSrinivas Kandagatla { 2641e8ba1e05SSrinivas Kandagatla struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); 2642e8ba1e05SSrinivas Kandagatla struct wcd938x_priv *wcd938x = snd_soc_component_get_drvdata(component); 2643e8ba1e05SSrinivas Kandagatla 2644e8ba1e05SSrinivas Kandagatla ucontrol->value.integer.value[0] = wcd938x->bcs_dis; 2645e8ba1e05SSrinivas Kandagatla 2646e8ba1e05SSrinivas Kandagatla return 0; 2647e8ba1e05SSrinivas Kandagatla } 2648e8ba1e05SSrinivas Kandagatla 2649e8ba1e05SSrinivas Kandagatla static int wcd938x_bcs_put(struct snd_kcontrol *kcontrol, 2650e8ba1e05SSrinivas Kandagatla struct snd_ctl_elem_value *ucontrol) 2651e8ba1e05SSrinivas Kandagatla { 2652e8ba1e05SSrinivas Kandagatla struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); 2653e8ba1e05SSrinivas Kandagatla struct wcd938x_priv *wcd938x = snd_soc_component_get_drvdata(component); 2654e8ba1e05SSrinivas Kandagatla 2655e8ba1e05SSrinivas Kandagatla wcd938x->bcs_dis = ucontrol->value.integer.value[0]; 2656e8ba1e05SSrinivas Kandagatla 2657e8ba1e05SSrinivas Kandagatla return 1; 2658e8ba1e05SSrinivas Kandagatla } 2659e8ba1e05SSrinivas Kandagatla 2660e8ba1e05SSrinivas Kandagatla static const char * const tx_mode_mux_text_wcd9380[] = { 2661e8ba1e05SSrinivas Kandagatla "ADC_INVALID", "ADC_HIFI", "ADC_LO_HIF", "ADC_NORMAL", "ADC_LP", 2662e8ba1e05SSrinivas Kandagatla }; 2663e8ba1e05SSrinivas Kandagatla 2664e8ba1e05SSrinivas Kandagatla static const char * const tx_mode_mux_text[] = { 2665e8ba1e05SSrinivas Kandagatla "ADC_INVALID", "ADC_HIFI", "ADC_LO_HIF", "ADC_NORMAL", "ADC_LP", 2666e8ba1e05SSrinivas Kandagatla "ADC_ULP1", "ADC_ULP2", 2667e8ba1e05SSrinivas Kandagatla }; 2668e8ba1e05SSrinivas Kandagatla 2669e8ba1e05SSrinivas Kandagatla static const char * const rx_hph_mode_mux_text_wcd9380[] = { 2670e8ba1e05SSrinivas Kandagatla "CLS_H_INVALID", "CLS_H_INVALID_1", "CLS_H_LP", "CLS_AB", 2671e8ba1e05SSrinivas Kandagatla "CLS_H_LOHIFI", "CLS_H_ULP", "CLS_H_INVALID_2", "CLS_AB_LP", 2672e8ba1e05SSrinivas Kandagatla "CLS_AB_LOHIFI", 2673e8ba1e05SSrinivas Kandagatla }; 2674e8ba1e05SSrinivas Kandagatla 2675e8ba1e05SSrinivas Kandagatla static const char * const rx_hph_mode_mux_text[] = { 2676e8ba1e05SSrinivas Kandagatla "CLS_H_INVALID", "CLS_H_HIFI", "CLS_H_LP", "CLS_AB", "CLS_H_LOHIFI", 2677e8ba1e05SSrinivas Kandagatla "CLS_H_ULP", "CLS_AB_HIFI", "CLS_AB_LP", "CLS_AB_LOHIFI", 2678e8ba1e05SSrinivas Kandagatla }; 2679e8ba1e05SSrinivas Kandagatla 26808da9db0cSSrinivas Kandagatla static const char * const adc2_mux_text[] = { 26818da9db0cSSrinivas Kandagatla "INP2", "INP3" 26828da9db0cSSrinivas Kandagatla }; 26838da9db0cSSrinivas Kandagatla 26848da9db0cSSrinivas Kandagatla static const char * const adc3_mux_text[] = { 26858da9db0cSSrinivas Kandagatla "INP4", "INP6" 26868da9db0cSSrinivas Kandagatla }; 26878da9db0cSSrinivas Kandagatla 26888da9db0cSSrinivas Kandagatla static const char * const adc4_mux_text[] = { 26898da9db0cSSrinivas Kandagatla "INP5", "INP7" 26908da9db0cSSrinivas Kandagatla }; 26918da9db0cSSrinivas Kandagatla 26928da9db0cSSrinivas Kandagatla static const char * const rdac3_mux_text[] = { 26938da9db0cSSrinivas Kandagatla "RX1", "RX3" 26948da9db0cSSrinivas Kandagatla }; 26958da9db0cSSrinivas Kandagatla 26968da9db0cSSrinivas Kandagatla static const char * const hdr12_mux_text[] = { 26978da9db0cSSrinivas Kandagatla "NO_HDR12", "HDR12" 26988da9db0cSSrinivas Kandagatla }; 26998da9db0cSSrinivas Kandagatla 27008da9db0cSSrinivas Kandagatla static const char * const hdr34_mux_text[] = { 27018da9db0cSSrinivas Kandagatla "NO_HDR34", "HDR34" 27028da9db0cSSrinivas Kandagatla }; 27038da9db0cSSrinivas Kandagatla 2704e8ba1e05SSrinivas Kandagatla static const struct soc_enum tx0_mode_enum_wcd9380 = 2705e8ba1e05SSrinivas Kandagatla SOC_ENUM_SINGLE(SND_SOC_NOPM, 0, ARRAY_SIZE(tx_mode_mux_text_wcd9380), 2706e8ba1e05SSrinivas Kandagatla tx_mode_mux_text_wcd9380); 2707e8ba1e05SSrinivas Kandagatla 2708e8ba1e05SSrinivas Kandagatla static const struct soc_enum tx1_mode_enum_wcd9380 = 2709e8ba1e05SSrinivas Kandagatla SOC_ENUM_SINGLE(SND_SOC_NOPM, 1, ARRAY_SIZE(tx_mode_mux_text_wcd9380), 2710e8ba1e05SSrinivas Kandagatla tx_mode_mux_text_wcd9380); 2711e8ba1e05SSrinivas Kandagatla 2712e8ba1e05SSrinivas Kandagatla static const struct soc_enum tx2_mode_enum_wcd9380 = 2713e8ba1e05SSrinivas Kandagatla SOC_ENUM_SINGLE(SND_SOC_NOPM, 2, ARRAY_SIZE(tx_mode_mux_text_wcd9380), 2714e8ba1e05SSrinivas Kandagatla tx_mode_mux_text_wcd9380); 2715e8ba1e05SSrinivas Kandagatla 2716e8ba1e05SSrinivas Kandagatla static const struct soc_enum tx3_mode_enum_wcd9380 = 2717e8ba1e05SSrinivas Kandagatla SOC_ENUM_SINGLE(SND_SOC_NOPM, 3, ARRAY_SIZE(tx_mode_mux_text_wcd9380), 2718e8ba1e05SSrinivas Kandagatla tx_mode_mux_text_wcd9380); 2719e8ba1e05SSrinivas Kandagatla 2720e8ba1e05SSrinivas Kandagatla static const struct soc_enum tx0_mode_enum_wcd9385 = 2721e8ba1e05SSrinivas Kandagatla SOC_ENUM_SINGLE(SND_SOC_NOPM, 0, ARRAY_SIZE(tx_mode_mux_text), 2722e8ba1e05SSrinivas Kandagatla tx_mode_mux_text); 2723e8ba1e05SSrinivas Kandagatla 2724e8ba1e05SSrinivas Kandagatla static const struct soc_enum tx1_mode_enum_wcd9385 = 2725e8ba1e05SSrinivas Kandagatla SOC_ENUM_SINGLE(SND_SOC_NOPM, 1, ARRAY_SIZE(tx_mode_mux_text), 2726e8ba1e05SSrinivas Kandagatla tx_mode_mux_text); 2727e8ba1e05SSrinivas Kandagatla 2728e8ba1e05SSrinivas Kandagatla static const struct soc_enum tx2_mode_enum_wcd9385 = 2729e8ba1e05SSrinivas Kandagatla SOC_ENUM_SINGLE(SND_SOC_NOPM, 2, ARRAY_SIZE(tx_mode_mux_text), 2730e8ba1e05SSrinivas Kandagatla tx_mode_mux_text); 2731e8ba1e05SSrinivas Kandagatla 2732e8ba1e05SSrinivas Kandagatla static const struct soc_enum tx3_mode_enum_wcd9385 = 2733e8ba1e05SSrinivas Kandagatla SOC_ENUM_SINGLE(SND_SOC_NOPM, 3, ARRAY_SIZE(tx_mode_mux_text), 2734e8ba1e05SSrinivas Kandagatla tx_mode_mux_text); 2735e8ba1e05SSrinivas Kandagatla 2736e8ba1e05SSrinivas Kandagatla static const struct soc_enum rx_hph_mode_mux_enum_wcd9380 = 2737e8ba1e05SSrinivas Kandagatla SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(rx_hph_mode_mux_text_wcd9380), 2738e8ba1e05SSrinivas Kandagatla rx_hph_mode_mux_text_wcd9380); 2739e8ba1e05SSrinivas Kandagatla 2740e8ba1e05SSrinivas Kandagatla static const struct soc_enum rx_hph_mode_mux_enum = 2741e8ba1e05SSrinivas Kandagatla SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(rx_hph_mode_mux_text), 2742e8ba1e05SSrinivas Kandagatla rx_hph_mode_mux_text); 2743e8ba1e05SSrinivas Kandagatla 2744d5add08fSSrinivas Kandagatla static const struct soc_enum adc2_enum = 2745d5add08fSSrinivas Kandagatla SOC_ENUM_SINGLE(WCD938X_TX_NEW_AMIC_MUX_CFG, 7, 2746d5add08fSSrinivas Kandagatla ARRAY_SIZE(adc2_mux_text), adc2_mux_text); 2747d5add08fSSrinivas Kandagatla 2748d5add08fSSrinivas Kandagatla static const struct soc_enum adc3_enum = 2749d5add08fSSrinivas Kandagatla SOC_ENUM_SINGLE(WCD938X_TX_NEW_AMIC_MUX_CFG, 6, 2750d5add08fSSrinivas Kandagatla ARRAY_SIZE(adc3_mux_text), adc3_mux_text); 2751d5add08fSSrinivas Kandagatla 2752d5add08fSSrinivas Kandagatla static const struct soc_enum adc4_enum = 2753d5add08fSSrinivas Kandagatla SOC_ENUM_SINGLE(WCD938X_TX_NEW_AMIC_MUX_CFG, 5, 2754d5add08fSSrinivas Kandagatla ARRAY_SIZE(adc4_mux_text), adc4_mux_text); 2755d5add08fSSrinivas Kandagatla 2756d5add08fSSrinivas Kandagatla static const struct soc_enum hdr12_enum = 2757d5add08fSSrinivas Kandagatla SOC_ENUM_SINGLE(WCD938X_TX_NEW_AMIC_MUX_CFG, 4, 2758d5add08fSSrinivas Kandagatla ARRAY_SIZE(hdr12_mux_text), hdr12_mux_text); 2759d5add08fSSrinivas Kandagatla 2760d5add08fSSrinivas Kandagatla static const struct soc_enum hdr34_enum = 2761d5add08fSSrinivas Kandagatla SOC_ENUM_SINGLE(WCD938X_TX_NEW_AMIC_MUX_CFG, 3, 2762d5add08fSSrinivas Kandagatla ARRAY_SIZE(hdr34_mux_text), hdr34_mux_text); 2763d5add08fSSrinivas Kandagatla 27648da9db0cSSrinivas Kandagatla static const struct soc_enum rdac3_enum = 27658da9db0cSSrinivas Kandagatla SOC_ENUM_SINGLE(WCD938X_DIGITAL_CDC_EAR_PATH_CTL, 0, 27668da9db0cSSrinivas Kandagatla ARRAY_SIZE(rdac3_mux_text), rdac3_mux_text); 27678da9db0cSSrinivas Kandagatla 2768d5add08fSSrinivas Kandagatla static const struct snd_kcontrol_new adc1_switch[] = { 2769d5add08fSSrinivas Kandagatla SOC_DAPM_SINGLE("Switch", SND_SOC_NOPM, 0, 1, 0) 2770d5add08fSSrinivas Kandagatla }; 2771d5add08fSSrinivas Kandagatla 2772d5add08fSSrinivas Kandagatla static const struct snd_kcontrol_new adc2_switch[] = { 2773d5add08fSSrinivas Kandagatla SOC_DAPM_SINGLE("Switch", SND_SOC_NOPM, 0, 1, 0) 2774d5add08fSSrinivas Kandagatla }; 2775d5add08fSSrinivas Kandagatla 2776d5add08fSSrinivas Kandagatla static const struct snd_kcontrol_new adc3_switch[] = { 2777d5add08fSSrinivas Kandagatla SOC_DAPM_SINGLE("Switch", SND_SOC_NOPM, 0, 1, 0) 2778d5add08fSSrinivas Kandagatla }; 2779d5add08fSSrinivas Kandagatla 2780d5add08fSSrinivas Kandagatla static const struct snd_kcontrol_new adc4_switch[] = { 2781d5add08fSSrinivas Kandagatla SOC_DAPM_SINGLE("Switch", SND_SOC_NOPM, 0, 1, 0) 2782d5add08fSSrinivas Kandagatla }; 2783d5add08fSSrinivas Kandagatla 2784d5add08fSSrinivas Kandagatla static const struct snd_kcontrol_new dmic1_switch[] = { 2785d5add08fSSrinivas Kandagatla SOC_DAPM_SINGLE("Switch", SND_SOC_NOPM, 0, 1, 0) 2786d5add08fSSrinivas Kandagatla }; 2787d5add08fSSrinivas Kandagatla 2788d5add08fSSrinivas Kandagatla static const struct snd_kcontrol_new dmic2_switch[] = { 2789d5add08fSSrinivas Kandagatla SOC_DAPM_SINGLE("Switch", SND_SOC_NOPM, 0, 1, 0) 2790d5add08fSSrinivas Kandagatla }; 2791d5add08fSSrinivas Kandagatla 2792d5add08fSSrinivas Kandagatla static const struct snd_kcontrol_new dmic3_switch[] = { 2793d5add08fSSrinivas Kandagatla SOC_DAPM_SINGLE("Switch", SND_SOC_NOPM, 0, 1, 0) 2794d5add08fSSrinivas Kandagatla }; 2795d5add08fSSrinivas Kandagatla 2796d5add08fSSrinivas Kandagatla static const struct snd_kcontrol_new dmic4_switch[] = { 2797d5add08fSSrinivas Kandagatla SOC_DAPM_SINGLE("Switch", SND_SOC_NOPM, 0, 1, 0) 2798d5add08fSSrinivas Kandagatla }; 2799d5add08fSSrinivas Kandagatla 2800d5add08fSSrinivas Kandagatla static const struct snd_kcontrol_new dmic5_switch[] = { 2801d5add08fSSrinivas Kandagatla SOC_DAPM_SINGLE("Switch", SND_SOC_NOPM, 0, 1, 0) 2802d5add08fSSrinivas Kandagatla }; 2803d5add08fSSrinivas Kandagatla 2804d5add08fSSrinivas Kandagatla static const struct snd_kcontrol_new dmic6_switch[] = { 2805d5add08fSSrinivas Kandagatla SOC_DAPM_SINGLE("Switch", SND_SOC_NOPM, 0, 1, 0) 2806d5add08fSSrinivas Kandagatla }; 2807d5add08fSSrinivas Kandagatla 2808d5add08fSSrinivas Kandagatla static const struct snd_kcontrol_new dmic7_switch[] = { 2809d5add08fSSrinivas Kandagatla SOC_DAPM_SINGLE("Switch", SND_SOC_NOPM, 0, 1, 0) 2810d5add08fSSrinivas Kandagatla }; 2811d5add08fSSrinivas Kandagatla 2812d5add08fSSrinivas Kandagatla static const struct snd_kcontrol_new dmic8_switch[] = { 2813d5add08fSSrinivas Kandagatla SOC_DAPM_SINGLE("Switch", SND_SOC_NOPM, 0, 1, 0) 2814d5add08fSSrinivas Kandagatla }; 2815d5add08fSSrinivas Kandagatla 28168da9db0cSSrinivas Kandagatla static const struct snd_kcontrol_new ear_rdac_switch[] = { 28178da9db0cSSrinivas Kandagatla SOC_DAPM_SINGLE("Switch", SND_SOC_NOPM, 0, 1, 0) 28188da9db0cSSrinivas Kandagatla }; 28198da9db0cSSrinivas Kandagatla 28208da9db0cSSrinivas Kandagatla static const struct snd_kcontrol_new aux_rdac_switch[] = { 28218da9db0cSSrinivas Kandagatla SOC_DAPM_SINGLE("Switch", SND_SOC_NOPM, 0, 1, 0) 28228da9db0cSSrinivas Kandagatla }; 28238da9db0cSSrinivas Kandagatla 28248da9db0cSSrinivas Kandagatla static const struct snd_kcontrol_new hphl_rdac_switch[] = { 28258da9db0cSSrinivas Kandagatla SOC_DAPM_SINGLE("Switch", SND_SOC_NOPM, 0, 1, 0) 28268da9db0cSSrinivas Kandagatla }; 28278da9db0cSSrinivas Kandagatla 28288da9db0cSSrinivas Kandagatla static const struct snd_kcontrol_new hphr_rdac_switch[] = { 28298da9db0cSSrinivas Kandagatla SOC_DAPM_SINGLE("Switch", SND_SOC_NOPM, 0, 1, 0) 28308da9db0cSSrinivas Kandagatla }; 28318da9db0cSSrinivas Kandagatla 2832d5add08fSSrinivas Kandagatla static const struct snd_kcontrol_new tx_adc2_mux = 2833d5add08fSSrinivas Kandagatla SOC_DAPM_ENUM("ADC2 MUX Mux", adc2_enum); 2834d5add08fSSrinivas Kandagatla 2835d5add08fSSrinivas Kandagatla static const struct snd_kcontrol_new tx_adc3_mux = 2836d5add08fSSrinivas Kandagatla SOC_DAPM_ENUM("ADC3 MUX Mux", adc3_enum); 2837d5add08fSSrinivas Kandagatla 2838d5add08fSSrinivas Kandagatla static const struct snd_kcontrol_new tx_adc4_mux = 2839d5add08fSSrinivas Kandagatla SOC_DAPM_ENUM("ADC4 MUX Mux", adc4_enum); 2840d5add08fSSrinivas Kandagatla 2841d5add08fSSrinivas Kandagatla static const struct snd_kcontrol_new tx_hdr12_mux = 2842d5add08fSSrinivas Kandagatla SOC_DAPM_ENUM("HDR12 MUX Mux", hdr12_enum); 2843d5add08fSSrinivas Kandagatla 2844d5add08fSSrinivas Kandagatla static const struct snd_kcontrol_new tx_hdr34_mux = 2845d5add08fSSrinivas Kandagatla SOC_DAPM_ENUM("HDR34 MUX Mux", hdr34_enum); 2846d5add08fSSrinivas Kandagatla 28478da9db0cSSrinivas Kandagatla static const struct snd_kcontrol_new rx_rdac3_mux = 28488da9db0cSSrinivas Kandagatla SOC_DAPM_ENUM("RDAC3_MUX Mux", rdac3_enum); 28498da9db0cSSrinivas Kandagatla 2850e8ba1e05SSrinivas Kandagatla static const struct snd_kcontrol_new wcd9380_snd_controls[] = { 2851e8ba1e05SSrinivas Kandagatla SOC_ENUM_EXT("RX HPH Mode", rx_hph_mode_mux_enum_wcd9380, 2852e8ba1e05SSrinivas Kandagatla wcd938x_rx_hph_mode_get, wcd938x_rx_hph_mode_put), 2853e8ba1e05SSrinivas Kandagatla SOC_ENUM_EXT("TX0 MODE", tx0_mode_enum_wcd9380, 2854e8ba1e05SSrinivas Kandagatla wcd938x_tx_mode_get, wcd938x_tx_mode_put), 2855e8ba1e05SSrinivas Kandagatla SOC_ENUM_EXT("TX1 MODE", tx1_mode_enum_wcd9380, 2856e8ba1e05SSrinivas Kandagatla wcd938x_tx_mode_get, wcd938x_tx_mode_put), 2857e8ba1e05SSrinivas Kandagatla SOC_ENUM_EXT("TX2 MODE", tx2_mode_enum_wcd9380, 2858e8ba1e05SSrinivas Kandagatla wcd938x_tx_mode_get, wcd938x_tx_mode_put), 2859e8ba1e05SSrinivas Kandagatla SOC_ENUM_EXT("TX3 MODE", tx3_mode_enum_wcd9380, 2860e8ba1e05SSrinivas Kandagatla wcd938x_tx_mode_get, wcd938x_tx_mode_put), 2861e8ba1e05SSrinivas Kandagatla }; 2862e8ba1e05SSrinivas Kandagatla 2863e8ba1e05SSrinivas Kandagatla static const struct snd_kcontrol_new wcd9385_snd_controls[] = { 2864e8ba1e05SSrinivas Kandagatla SOC_ENUM_EXT("RX HPH Mode", rx_hph_mode_mux_enum, 2865e8ba1e05SSrinivas Kandagatla wcd938x_rx_hph_mode_get, wcd938x_rx_hph_mode_put), 2866e8ba1e05SSrinivas Kandagatla SOC_ENUM_EXT("TX0 MODE", tx0_mode_enum_wcd9385, 2867e8ba1e05SSrinivas Kandagatla wcd938x_tx_mode_get, wcd938x_tx_mode_put), 2868e8ba1e05SSrinivas Kandagatla SOC_ENUM_EXT("TX1 MODE", tx1_mode_enum_wcd9385, 2869e8ba1e05SSrinivas Kandagatla wcd938x_tx_mode_get, wcd938x_tx_mode_put), 2870e8ba1e05SSrinivas Kandagatla SOC_ENUM_EXT("TX2 MODE", tx2_mode_enum_wcd9385, 2871e8ba1e05SSrinivas Kandagatla wcd938x_tx_mode_get, wcd938x_tx_mode_put), 2872e8ba1e05SSrinivas Kandagatla SOC_ENUM_EXT("TX3 MODE", tx3_mode_enum_wcd9385, 2873e8ba1e05SSrinivas Kandagatla wcd938x_tx_mode_get, wcd938x_tx_mode_put), 2874e8ba1e05SSrinivas Kandagatla }; 2875e8ba1e05SSrinivas Kandagatla 2876e8ba1e05SSrinivas Kandagatla static int wcd938x_get_swr_port(struct snd_kcontrol *kcontrol, 2877e8ba1e05SSrinivas Kandagatla struct snd_ctl_elem_value *ucontrol) 2878e8ba1e05SSrinivas Kandagatla { 2879e8ba1e05SSrinivas Kandagatla struct snd_soc_component *comp = snd_soc_kcontrol_component(kcontrol); 2880e8ba1e05SSrinivas Kandagatla struct wcd938x_priv *wcd938x = snd_soc_component_get_drvdata(comp); 2881e8ba1e05SSrinivas Kandagatla struct wcd938x_sdw_priv *wcd; 2882e8ba1e05SSrinivas Kandagatla struct soc_mixer_control *mixer = (struct soc_mixer_control *)kcontrol->private_value; 2883e8ba1e05SSrinivas Kandagatla int dai_id = mixer->shift; 2884c5c1546aSSrinivas Kandagatla int portidx, ch_idx = mixer->reg; 2885c5c1546aSSrinivas Kandagatla 2886e8ba1e05SSrinivas Kandagatla 2887e8ba1e05SSrinivas Kandagatla wcd = wcd938x->sdw_priv[dai_id]; 2888c5c1546aSSrinivas Kandagatla portidx = wcd->ch_info[ch_idx].port_num; 2889e8ba1e05SSrinivas Kandagatla 2890e8ba1e05SSrinivas Kandagatla ucontrol->value.integer.value[0] = wcd->port_enable[portidx]; 2891e8ba1e05SSrinivas Kandagatla 2892e8ba1e05SSrinivas Kandagatla return 0; 2893e8ba1e05SSrinivas Kandagatla } 2894e8ba1e05SSrinivas Kandagatla 2895e8ba1e05SSrinivas Kandagatla static int wcd938x_set_swr_port(struct snd_kcontrol *kcontrol, 2896e8ba1e05SSrinivas Kandagatla struct snd_ctl_elem_value *ucontrol) 2897e8ba1e05SSrinivas Kandagatla { 2898e8ba1e05SSrinivas Kandagatla struct snd_soc_component *comp = snd_soc_kcontrol_component(kcontrol); 2899e8ba1e05SSrinivas Kandagatla struct wcd938x_priv *wcd938x = snd_soc_component_get_drvdata(comp); 2900e8ba1e05SSrinivas Kandagatla struct wcd938x_sdw_priv *wcd; 2901e8ba1e05SSrinivas Kandagatla struct soc_mixer_control *mixer = 2902e8ba1e05SSrinivas Kandagatla (struct soc_mixer_control *)kcontrol->private_value; 2903c5c1546aSSrinivas Kandagatla int ch_idx = mixer->reg; 2904c5c1546aSSrinivas Kandagatla int portidx; 2905e8ba1e05SSrinivas Kandagatla int dai_id = mixer->shift; 2906e8ba1e05SSrinivas Kandagatla bool enable; 2907e8ba1e05SSrinivas Kandagatla 2908e8ba1e05SSrinivas Kandagatla wcd = wcd938x->sdw_priv[dai_id]; 2909e8ba1e05SSrinivas Kandagatla 2910c5c1546aSSrinivas Kandagatla portidx = wcd->ch_info[ch_idx].port_num; 2911e8ba1e05SSrinivas Kandagatla if (ucontrol->value.integer.value[0]) 2912e8ba1e05SSrinivas Kandagatla enable = true; 2913e8ba1e05SSrinivas Kandagatla else 2914e8ba1e05SSrinivas Kandagatla enable = false; 2915e8ba1e05SSrinivas Kandagatla 2916e8ba1e05SSrinivas Kandagatla wcd->port_enable[portidx] = enable; 2917e8ba1e05SSrinivas Kandagatla 2918c5c1546aSSrinivas Kandagatla wcd938x_connect_port(wcd, portidx, ch_idx, enable); 2919e8ba1e05SSrinivas Kandagatla 2920bd2347fdSSrinivas Kandagatla return 1; 2921e8ba1e05SSrinivas Kandagatla 2922e8ba1e05SSrinivas Kandagatla } 2923e8ba1e05SSrinivas Kandagatla 2924bcee7ed0SSrinivas Kandagatla /* MBHC related */ 2925bcee7ed0SSrinivas Kandagatla static void wcd938x_mbhc_clk_setup(struct snd_soc_component *component, 2926bcee7ed0SSrinivas Kandagatla bool enable) 2927bcee7ed0SSrinivas Kandagatla { 2928bcee7ed0SSrinivas Kandagatla snd_soc_component_write_field(component, WCD938X_MBHC_NEW_CTL_1, 2929bcee7ed0SSrinivas Kandagatla WCD938X_MBHC_CTL_RCO_EN_MASK, enable); 2930bcee7ed0SSrinivas Kandagatla } 2931bcee7ed0SSrinivas Kandagatla 2932bcee7ed0SSrinivas Kandagatla static void wcd938x_mbhc_mbhc_bias_control(struct snd_soc_component *component, 2933bcee7ed0SSrinivas Kandagatla bool enable) 2934bcee7ed0SSrinivas Kandagatla { 2935bcee7ed0SSrinivas Kandagatla snd_soc_component_write_field(component, WCD938X_ANA_MBHC_ELECT, 2936bcee7ed0SSrinivas Kandagatla WCD938X_ANA_MBHC_BIAS_EN, enable); 2937bcee7ed0SSrinivas Kandagatla } 2938bcee7ed0SSrinivas Kandagatla 2939bcee7ed0SSrinivas Kandagatla static void wcd938x_mbhc_program_btn_thr(struct snd_soc_component *component, 2940bcee7ed0SSrinivas Kandagatla int *btn_low, int *btn_high, 2941bcee7ed0SSrinivas Kandagatla int num_btn, bool is_micbias) 2942bcee7ed0SSrinivas Kandagatla { 2943bcee7ed0SSrinivas Kandagatla int i, vth; 2944bcee7ed0SSrinivas Kandagatla 2945bcee7ed0SSrinivas Kandagatla if (num_btn > WCD_MBHC_DEF_BUTTONS) { 2946bcee7ed0SSrinivas Kandagatla dev_err(component->dev, "%s: invalid number of buttons: %d\n", 2947bcee7ed0SSrinivas Kandagatla __func__, num_btn); 2948bcee7ed0SSrinivas Kandagatla return; 2949bcee7ed0SSrinivas Kandagatla } 2950bcee7ed0SSrinivas Kandagatla 2951bcee7ed0SSrinivas Kandagatla for (i = 0; i < num_btn; i++) { 2952bcee7ed0SSrinivas Kandagatla vth = ((btn_high[i] * 2) / 25) & 0x3F; 2953bcee7ed0SSrinivas Kandagatla snd_soc_component_write_field(component, WCD938X_ANA_MBHC_BTN0 + i, 2954bcee7ed0SSrinivas Kandagatla WCD938X_MBHC_BTN_VTH_MASK, vth); 2955bcee7ed0SSrinivas Kandagatla dev_dbg(component->dev, "%s: btn_high[%d]: %d, vth: %d\n", 2956bcee7ed0SSrinivas Kandagatla __func__, i, btn_high[i], vth); 2957bcee7ed0SSrinivas Kandagatla } 2958bcee7ed0SSrinivas Kandagatla } 2959bcee7ed0SSrinivas Kandagatla 2960bcee7ed0SSrinivas Kandagatla static bool wcd938x_mbhc_micb_en_status(struct snd_soc_component *component, int micb_num) 2961bcee7ed0SSrinivas Kandagatla { 2962bcee7ed0SSrinivas Kandagatla u8 val; 2963bcee7ed0SSrinivas Kandagatla 2964bcee7ed0SSrinivas Kandagatla if (micb_num == MIC_BIAS_2) { 2965bcee7ed0SSrinivas Kandagatla val = snd_soc_component_read_field(component, 2966bcee7ed0SSrinivas Kandagatla WCD938X_ANA_MICB2, 2967bcee7ed0SSrinivas Kandagatla WCD938X_ANA_MICB2_ENABLE_MASK); 2968bcee7ed0SSrinivas Kandagatla if (val == WCD938X_MICB_ENABLE) 2969bcee7ed0SSrinivas Kandagatla return true; 2970bcee7ed0SSrinivas Kandagatla } 2971bcee7ed0SSrinivas Kandagatla return false; 2972bcee7ed0SSrinivas Kandagatla } 2973bcee7ed0SSrinivas Kandagatla 2974bcee7ed0SSrinivas Kandagatla static void wcd938x_mbhc_hph_l_pull_up_control(struct snd_soc_component *component, 2975bcee7ed0SSrinivas Kandagatla int pull_up_cur) 2976bcee7ed0SSrinivas Kandagatla { 2977bcee7ed0SSrinivas Kandagatla /* Default pull up current to 2uA */ 2978bcee7ed0SSrinivas Kandagatla if (pull_up_cur > HS_PULLUP_I_OFF || pull_up_cur < HS_PULLUP_I_3P0_UA) 2979bcee7ed0SSrinivas Kandagatla pull_up_cur = HS_PULLUP_I_2P0_UA; 2980bcee7ed0SSrinivas Kandagatla 2981bcee7ed0SSrinivas Kandagatla snd_soc_component_write_field(component, 2982bcee7ed0SSrinivas Kandagatla WCD938X_MBHC_NEW_INT_MECH_DET_CURRENT, 2983bcee7ed0SSrinivas Kandagatla WCD938X_HSDET_PULLUP_C_MASK, pull_up_cur); 2984bcee7ed0SSrinivas Kandagatla } 2985bcee7ed0SSrinivas Kandagatla 2986bcee7ed0SSrinivas Kandagatla static int wcd938x_mbhc_request_micbias(struct snd_soc_component *component, 2987bcee7ed0SSrinivas Kandagatla int micb_num, int req) 2988bcee7ed0SSrinivas Kandagatla { 2989bcee7ed0SSrinivas Kandagatla return wcd938x_micbias_control(component, micb_num, req, false); 2990bcee7ed0SSrinivas Kandagatla } 2991bcee7ed0SSrinivas Kandagatla 2992bcee7ed0SSrinivas Kandagatla static void wcd938x_mbhc_micb_ramp_control(struct snd_soc_component *component, 2993bcee7ed0SSrinivas Kandagatla bool enable) 2994bcee7ed0SSrinivas Kandagatla { 2995bcee7ed0SSrinivas Kandagatla if (enable) { 2996bcee7ed0SSrinivas Kandagatla snd_soc_component_write_field(component, WCD938X_ANA_MICB2_RAMP, 2997bcee7ed0SSrinivas Kandagatla WCD938X_RAMP_SHIFT_CTRL_MASK, 0x0C); 2998bcee7ed0SSrinivas Kandagatla snd_soc_component_write_field(component, WCD938X_ANA_MICB2_RAMP, 2999bcee7ed0SSrinivas Kandagatla WCD938X_RAMP_EN_MASK, 1); 3000bcee7ed0SSrinivas Kandagatla } else { 3001bcee7ed0SSrinivas Kandagatla snd_soc_component_write_field(component, WCD938X_ANA_MICB2_RAMP, 3002bcee7ed0SSrinivas Kandagatla WCD938X_RAMP_EN_MASK, 0); 3003bcee7ed0SSrinivas Kandagatla snd_soc_component_write_field(component, WCD938X_ANA_MICB2_RAMP, 3004bcee7ed0SSrinivas Kandagatla WCD938X_RAMP_SHIFT_CTRL_MASK, 0); 3005bcee7ed0SSrinivas Kandagatla } 3006bcee7ed0SSrinivas Kandagatla } 3007bcee7ed0SSrinivas Kandagatla 3008bcee7ed0SSrinivas Kandagatla static int wcd938x_get_micb_vout_ctl_val(u32 micb_mv) 3009bcee7ed0SSrinivas Kandagatla { 3010bcee7ed0SSrinivas Kandagatla /* min micbias voltage is 1V and maximum is 2.85V */ 3011bcee7ed0SSrinivas Kandagatla if (micb_mv < 1000 || micb_mv > 2850) 3012bcee7ed0SSrinivas Kandagatla return -EINVAL; 3013bcee7ed0SSrinivas Kandagatla 3014bcee7ed0SSrinivas Kandagatla return (micb_mv - 1000) / 50; 3015bcee7ed0SSrinivas Kandagatla } 3016bcee7ed0SSrinivas Kandagatla 3017bcee7ed0SSrinivas Kandagatla static int wcd938x_mbhc_micb_adjust_voltage(struct snd_soc_component *component, 3018bcee7ed0SSrinivas Kandagatla int req_volt, int micb_num) 3019bcee7ed0SSrinivas Kandagatla { 3020bcee7ed0SSrinivas Kandagatla struct wcd938x_priv *wcd938x = snd_soc_component_get_drvdata(component); 3021bcee7ed0SSrinivas Kandagatla int cur_vout_ctl, req_vout_ctl, micb_reg, micb_en, ret = 0; 3022bcee7ed0SSrinivas Kandagatla 3023bcee7ed0SSrinivas Kandagatla switch (micb_num) { 3024bcee7ed0SSrinivas Kandagatla case MIC_BIAS_1: 3025bcee7ed0SSrinivas Kandagatla micb_reg = WCD938X_ANA_MICB1; 3026bcee7ed0SSrinivas Kandagatla break; 3027bcee7ed0SSrinivas Kandagatla case MIC_BIAS_2: 3028bcee7ed0SSrinivas Kandagatla micb_reg = WCD938X_ANA_MICB2; 3029bcee7ed0SSrinivas Kandagatla break; 3030bcee7ed0SSrinivas Kandagatla case MIC_BIAS_3: 3031bcee7ed0SSrinivas Kandagatla micb_reg = WCD938X_ANA_MICB3; 3032bcee7ed0SSrinivas Kandagatla break; 3033bcee7ed0SSrinivas Kandagatla case MIC_BIAS_4: 3034bcee7ed0SSrinivas Kandagatla micb_reg = WCD938X_ANA_MICB4; 3035bcee7ed0SSrinivas Kandagatla break; 3036bcee7ed0SSrinivas Kandagatla default: 3037bcee7ed0SSrinivas Kandagatla return -EINVAL; 3038bcee7ed0SSrinivas Kandagatla } 3039bcee7ed0SSrinivas Kandagatla mutex_lock(&wcd938x->micb_lock); 3040bcee7ed0SSrinivas Kandagatla /* 3041bcee7ed0SSrinivas Kandagatla * If requested micbias voltage is same as current micbias 3042bcee7ed0SSrinivas Kandagatla * voltage, then just return. Otherwise, adjust voltage as 3043bcee7ed0SSrinivas Kandagatla * per requested value. If micbias is already enabled, then 3044bcee7ed0SSrinivas Kandagatla * to avoid slow micbias ramp-up or down enable pull-up 3045bcee7ed0SSrinivas Kandagatla * momentarily, change the micbias value and then re-enable 3046bcee7ed0SSrinivas Kandagatla * micbias. 3047bcee7ed0SSrinivas Kandagatla */ 3048bcee7ed0SSrinivas Kandagatla micb_en = snd_soc_component_read_field(component, micb_reg, 3049bcee7ed0SSrinivas Kandagatla WCD938X_MICB_EN_MASK); 3050bcee7ed0SSrinivas Kandagatla cur_vout_ctl = snd_soc_component_read_field(component, micb_reg, 3051bcee7ed0SSrinivas Kandagatla WCD938X_MICB_VOUT_MASK); 3052bcee7ed0SSrinivas Kandagatla 3053bcee7ed0SSrinivas Kandagatla req_vout_ctl = wcd938x_get_micb_vout_ctl_val(req_volt); 3054bcee7ed0SSrinivas Kandagatla if (req_vout_ctl < 0) { 3055bcee7ed0SSrinivas Kandagatla ret = -EINVAL; 3056bcee7ed0SSrinivas Kandagatla goto exit; 3057bcee7ed0SSrinivas Kandagatla } 3058bcee7ed0SSrinivas Kandagatla 3059bcee7ed0SSrinivas Kandagatla if (cur_vout_ctl == req_vout_ctl) { 3060bcee7ed0SSrinivas Kandagatla ret = 0; 3061bcee7ed0SSrinivas Kandagatla goto exit; 3062bcee7ed0SSrinivas Kandagatla } 3063bcee7ed0SSrinivas Kandagatla 3064bcee7ed0SSrinivas Kandagatla if (micb_en == WCD938X_MICB_ENABLE) 3065bcee7ed0SSrinivas Kandagatla snd_soc_component_write_field(component, micb_reg, 3066bcee7ed0SSrinivas Kandagatla WCD938X_MICB_EN_MASK, 3067bcee7ed0SSrinivas Kandagatla WCD938X_MICB_PULL_UP); 3068bcee7ed0SSrinivas Kandagatla 3069bcee7ed0SSrinivas Kandagatla snd_soc_component_write_field(component, micb_reg, 3070bcee7ed0SSrinivas Kandagatla WCD938X_MICB_VOUT_MASK, 3071bcee7ed0SSrinivas Kandagatla req_vout_ctl); 3072bcee7ed0SSrinivas Kandagatla 3073bcee7ed0SSrinivas Kandagatla if (micb_en == WCD938X_MICB_ENABLE) { 3074bcee7ed0SSrinivas Kandagatla snd_soc_component_write_field(component, micb_reg, 3075bcee7ed0SSrinivas Kandagatla WCD938X_MICB_EN_MASK, 3076bcee7ed0SSrinivas Kandagatla WCD938X_MICB_ENABLE); 3077bcee7ed0SSrinivas Kandagatla /* 3078bcee7ed0SSrinivas Kandagatla * Add 2ms delay as per HW requirement after enabling 3079bcee7ed0SSrinivas Kandagatla * micbias 3080bcee7ed0SSrinivas Kandagatla */ 3081bcee7ed0SSrinivas Kandagatla usleep_range(2000, 2100); 3082bcee7ed0SSrinivas Kandagatla } 3083bcee7ed0SSrinivas Kandagatla exit: 3084bcee7ed0SSrinivas Kandagatla mutex_unlock(&wcd938x->micb_lock); 3085bcee7ed0SSrinivas Kandagatla return ret; 3086bcee7ed0SSrinivas Kandagatla } 3087bcee7ed0SSrinivas Kandagatla 3088bcee7ed0SSrinivas Kandagatla static int wcd938x_mbhc_micb_ctrl_threshold_mic(struct snd_soc_component *component, 3089bcee7ed0SSrinivas Kandagatla int micb_num, bool req_en) 3090bcee7ed0SSrinivas Kandagatla { 3091bcee7ed0SSrinivas Kandagatla struct wcd938x_priv *wcd938x = snd_soc_component_get_drvdata(component); 3092b2fde4deSchiminghao int micb_mv; 3093bcee7ed0SSrinivas Kandagatla 3094bcee7ed0SSrinivas Kandagatla if (micb_num != MIC_BIAS_2) 3095bcee7ed0SSrinivas Kandagatla return -EINVAL; 3096bcee7ed0SSrinivas Kandagatla /* 3097bcee7ed0SSrinivas Kandagatla * If device tree micbias level is already above the minimum 3098bcee7ed0SSrinivas Kandagatla * voltage needed to detect threshold microphone, then do 3099bcee7ed0SSrinivas Kandagatla * not change the micbias, just return. 3100bcee7ed0SSrinivas Kandagatla */ 3101bcee7ed0SSrinivas Kandagatla if (wcd938x->micb2_mv >= WCD_MBHC_THR_HS_MICB_MV) 3102bcee7ed0SSrinivas Kandagatla return 0; 3103bcee7ed0SSrinivas Kandagatla 3104bcee7ed0SSrinivas Kandagatla micb_mv = req_en ? WCD_MBHC_THR_HS_MICB_MV : wcd938x->micb2_mv; 3105bcee7ed0SSrinivas Kandagatla 3106b2fde4deSchiminghao return wcd938x_mbhc_micb_adjust_voltage(component, micb_mv, MIC_BIAS_2); 3107bcee7ed0SSrinivas Kandagatla } 3108bcee7ed0SSrinivas Kandagatla 3109bcee7ed0SSrinivas Kandagatla static inline void wcd938x_mbhc_get_result_params(struct wcd938x_priv *wcd938x, 3110bcee7ed0SSrinivas Kandagatla s16 *d1_a, u16 noff, 3111bcee7ed0SSrinivas Kandagatla int32_t *zdet) 3112bcee7ed0SSrinivas Kandagatla { 3113bcee7ed0SSrinivas Kandagatla int i; 3114bcee7ed0SSrinivas Kandagatla int val, val1; 3115bcee7ed0SSrinivas Kandagatla s16 c1; 3116bcee7ed0SSrinivas Kandagatla s32 x1, d1; 3117bcee7ed0SSrinivas Kandagatla int32_t denom; 3118bcee7ed0SSrinivas Kandagatla int minCode_param[] = { 3119bcee7ed0SSrinivas Kandagatla 3277, 1639, 820, 410, 205, 103, 52, 26 3120bcee7ed0SSrinivas Kandagatla }; 3121bcee7ed0SSrinivas Kandagatla 3122bcee7ed0SSrinivas Kandagatla regmap_update_bits(wcd938x->regmap, WCD938X_ANA_MBHC_ZDET, 0x20, 0x20); 3123bcee7ed0SSrinivas Kandagatla for (i = 0; i < WCD938X_ZDET_NUM_MEASUREMENTS; i++) { 3124bcee7ed0SSrinivas Kandagatla regmap_read(wcd938x->regmap, WCD938X_ANA_MBHC_RESULT_2, &val); 3125bcee7ed0SSrinivas Kandagatla if (val & 0x80) 3126bcee7ed0SSrinivas Kandagatla break; 3127bcee7ed0SSrinivas Kandagatla } 3128bcee7ed0SSrinivas Kandagatla val = val << 0x8; 3129bcee7ed0SSrinivas Kandagatla regmap_read(wcd938x->regmap, WCD938X_ANA_MBHC_RESULT_1, &val1); 3130bcee7ed0SSrinivas Kandagatla val |= val1; 3131bcee7ed0SSrinivas Kandagatla regmap_update_bits(wcd938x->regmap, WCD938X_ANA_MBHC_ZDET, 0x20, 0x00); 3132bcee7ed0SSrinivas Kandagatla x1 = WCD938X_MBHC_GET_X1(val); 3133bcee7ed0SSrinivas Kandagatla c1 = WCD938X_MBHC_GET_C1(val); 3134bcee7ed0SSrinivas Kandagatla /* If ramp is not complete, give additional 5ms */ 3135bcee7ed0SSrinivas Kandagatla if ((c1 < 2) && x1) 3136bcee7ed0SSrinivas Kandagatla usleep_range(5000, 5050); 3137bcee7ed0SSrinivas Kandagatla 3138bcee7ed0SSrinivas Kandagatla if (!c1 || !x1) { 3139bcee7ed0SSrinivas Kandagatla pr_err("%s: Impedance detect ramp error, c1=%d, x1=0x%x\n", 3140bcee7ed0SSrinivas Kandagatla __func__, c1, x1); 3141bcee7ed0SSrinivas Kandagatla goto ramp_down; 3142bcee7ed0SSrinivas Kandagatla } 3143bcee7ed0SSrinivas Kandagatla d1 = d1_a[c1]; 3144bcee7ed0SSrinivas Kandagatla denom = (x1 * d1) - (1 << (14 - noff)); 3145bcee7ed0SSrinivas Kandagatla if (denom > 0) 3146bcee7ed0SSrinivas Kandagatla *zdet = (WCD938X_MBHC_ZDET_CONST * 1000) / denom; 3147bcee7ed0SSrinivas Kandagatla else if (x1 < minCode_param[noff]) 3148bcee7ed0SSrinivas Kandagatla *zdet = WCD938X_ZDET_FLOATING_IMPEDANCE; 3149bcee7ed0SSrinivas Kandagatla 3150bcee7ed0SSrinivas Kandagatla pr_err("%s: d1=%d, c1=%d, x1=0x%x, z_val=%d(milliOhm)\n", 3151bcee7ed0SSrinivas Kandagatla __func__, d1, c1, x1, *zdet); 3152bcee7ed0SSrinivas Kandagatla ramp_down: 3153bcee7ed0SSrinivas Kandagatla i = 0; 3154bcee7ed0SSrinivas Kandagatla while (x1) { 3155bcee7ed0SSrinivas Kandagatla regmap_read(wcd938x->regmap, 3156bcee7ed0SSrinivas Kandagatla WCD938X_ANA_MBHC_RESULT_1, &val); 3157bcee7ed0SSrinivas Kandagatla regmap_read(wcd938x->regmap, 3158bcee7ed0SSrinivas Kandagatla WCD938X_ANA_MBHC_RESULT_2, &val1); 3159bcee7ed0SSrinivas Kandagatla val = val << 0x08; 3160bcee7ed0SSrinivas Kandagatla val |= val1; 3161bcee7ed0SSrinivas Kandagatla x1 = WCD938X_MBHC_GET_X1(val); 3162bcee7ed0SSrinivas Kandagatla i++; 3163bcee7ed0SSrinivas Kandagatla if (i == WCD938X_ZDET_NUM_MEASUREMENTS) 3164bcee7ed0SSrinivas Kandagatla break; 3165bcee7ed0SSrinivas Kandagatla } 3166bcee7ed0SSrinivas Kandagatla } 3167bcee7ed0SSrinivas Kandagatla 3168bcee7ed0SSrinivas Kandagatla static void wcd938x_mbhc_zdet_ramp(struct snd_soc_component *component, 3169bcee7ed0SSrinivas Kandagatla struct wcd938x_mbhc_zdet_param *zdet_param, 3170bcee7ed0SSrinivas Kandagatla int32_t *zl, int32_t *zr, s16 *d1_a) 3171bcee7ed0SSrinivas Kandagatla { 3172bcee7ed0SSrinivas Kandagatla struct wcd938x_priv *wcd938x = snd_soc_component_get_drvdata(component); 3173bcee7ed0SSrinivas Kandagatla int32_t zdet = 0; 3174bcee7ed0SSrinivas Kandagatla 3175bcee7ed0SSrinivas Kandagatla snd_soc_component_write_field(component, WCD938X_MBHC_NEW_ZDET_ANA_CTL, 3176bcee7ed0SSrinivas Kandagatla WCD938X_ZDET_MAXV_CTL_MASK, zdet_param->ldo_ctl); 3177bcee7ed0SSrinivas Kandagatla snd_soc_component_update_bits(component, WCD938X_ANA_MBHC_BTN5, 3178bcee7ed0SSrinivas Kandagatla WCD938X_VTH_MASK, zdet_param->btn5); 3179bcee7ed0SSrinivas Kandagatla snd_soc_component_update_bits(component, WCD938X_ANA_MBHC_BTN6, 3180bcee7ed0SSrinivas Kandagatla WCD938X_VTH_MASK, zdet_param->btn6); 3181bcee7ed0SSrinivas Kandagatla snd_soc_component_update_bits(component, WCD938X_ANA_MBHC_BTN7, 3182bcee7ed0SSrinivas Kandagatla WCD938X_VTH_MASK, zdet_param->btn7); 3183bcee7ed0SSrinivas Kandagatla snd_soc_component_write_field(component, WCD938X_MBHC_NEW_ZDET_ANA_CTL, 3184bcee7ed0SSrinivas Kandagatla WCD938X_ZDET_RANGE_CTL_MASK, zdet_param->noff); 3185bcee7ed0SSrinivas Kandagatla snd_soc_component_update_bits(component, WCD938X_MBHC_NEW_ZDET_RAMP_CTL, 3186bcee7ed0SSrinivas Kandagatla 0x0F, zdet_param->nshift); 3187bcee7ed0SSrinivas Kandagatla 3188bcee7ed0SSrinivas Kandagatla if (!zl) 3189bcee7ed0SSrinivas Kandagatla goto z_right; 3190bcee7ed0SSrinivas Kandagatla /* Start impedance measurement for HPH_L */ 3191bcee7ed0SSrinivas Kandagatla regmap_update_bits(wcd938x->regmap, 3192bcee7ed0SSrinivas Kandagatla WCD938X_ANA_MBHC_ZDET, 0x80, 0x80); 3193bcee7ed0SSrinivas Kandagatla dev_dbg(component->dev, "%s: ramp for HPH_L, noff = %d\n", 3194bcee7ed0SSrinivas Kandagatla __func__, zdet_param->noff); 3195bcee7ed0SSrinivas Kandagatla wcd938x_mbhc_get_result_params(wcd938x, d1_a, zdet_param->noff, &zdet); 3196bcee7ed0SSrinivas Kandagatla regmap_update_bits(wcd938x->regmap, 3197bcee7ed0SSrinivas Kandagatla WCD938X_ANA_MBHC_ZDET, 0x80, 0x00); 3198bcee7ed0SSrinivas Kandagatla 3199bcee7ed0SSrinivas Kandagatla *zl = zdet; 3200bcee7ed0SSrinivas Kandagatla 3201bcee7ed0SSrinivas Kandagatla z_right: 3202bcee7ed0SSrinivas Kandagatla if (!zr) 3203bcee7ed0SSrinivas Kandagatla return; 3204bcee7ed0SSrinivas Kandagatla /* Start impedance measurement for HPH_R */ 3205bcee7ed0SSrinivas Kandagatla regmap_update_bits(wcd938x->regmap, 3206bcee7ed0SSrinivas Kandagatla WCD938X_ANA_MBHC_ZDET, 0x40, 0x40); 3207bcee7ed0SSrinivas Kandagatla dev_dbg(component->dev, "%s: ramp for HPH_R, noff = %d\n", 3208bcee7ed0SSrinivas Kandagatla __func__, zdet_param->noff); 3209bcee7ed0SSrinivas Kandagatla wcd938x_mbhc_get_result_params(wcd938x, d1_a, zdet_param->noff, &zdet); 3210bcee7ed0SSrinivas Kandagatla regmap_update_bits(wcd938x->regmap, 3211bcee7ed0SSrinivas Kandagatla WCD938X_ANA_MBHC_ZDET, 0x40, 0x00); 3212bcee7ed0SSrinivas Kandagatla 3213bcee7ed0SSrinivas Kandagatla *zr = zdet; 3214bcee7ed0SSrinivas Kandagatla } 3215bcee7ed0SSrinivas Kandagatla 3216bcee7ed0SSrinivas Kandagatla static inline void wcd938x_wcd_mbhc_qfuse_cal(struct snd_soc_component *component, 3217bcee7ed0SSrinivas Kandagatla int32_t *z_val, int flag_l_r) 3218bcee7ed0SSrinivas Kandagatla { 3219bcee7ed0SSrinivas Kandagatla s16 q1; 3220bcee7ed0SSrinivas Kandagatla int q1_cal; 3221bcee7ed0SSrinivas Kandagatla 3222bcee7ed0SSrinivas Kandagatla if (*z_val < (WCD938X_ZDET_VAL_400/1000)) 3223bcee7ed0SSrinivas Kandagatla q1 = snd_soc_component_read(component, 3224bcee7ed0SSrinivas Kandagatla WCD938X_DIGITAL_EFUSE_REG_23 + (2 * flag_l_r)); 3225bcee7ed0SSrinivas Kandagatla else 3226bcee7ed0SSrinivas Kandagatla q1 = snd_soc_component_read(component, 3227bcee7ed0SSrinivas Kandagatla WCD938X_DIGITAL_EFUSE_REG_24 + (2 * flag_l_r)); 3228bcee7ed0SSrinivas Kandagatla if (q1 & 0x80) 3229bcee7ed0SSrinivas Kandagatla q1_cal = (10000 - ((q1 & 0x7F) * 25)); 3230bcee7ed0SSrinivas Kandagatla else 3231bcee7ed0SSrinivas Kandagatla q1_cal = (10000 + (q1 * 25)); 3232bcee7ed0SSrinivas Kandagatla if (q1_cal > 0) 3233bcee7ed0SSrinivas Kandagatla *z_val = ((*z_val) * 10000) / q1_cal; 3234bcee7ed0SSrinivas Kandagatla } 3235bcee7ed0SSrinivas Kandagatla 3236bcee7ed0SSrinivas Kandagatla static void wcd938x_wcd_mbhc_calc_impedance(struct snd_soc_component *component, 3237bcee7ed0SSrinivas Kandagatla uint32_t *zl, uint32_t *zr) 3238bcee7ed0SSrinivas Kandagatla { 3239bcee7ed0SSrinivas Kandagatla struct wcd938x_priv *wcd938x = snd_soc_component_get_drvdata(component); 3240bcee7ed0SSrinivas Kandagatla s16 reg0, reg1, reg2, reg3, reg4; 3241bcee7ed0SSrinivas Kandagatla int32_t z1L, z1R, z1Ls; 3242bcee7ed0SSrinivas Kandagatla int zMono, z_diff1, z_diff2; 3243bcee7ed0SSrinivas Kandagatla bool is_fsm_disable = false; 3244bcee7ed0SSrinivas Kandagatla struct wcd938x_mbhc_zdet_param zdet_param[] = { 3245bcee7ed0SSrinivas Kandagatla {4, 0, 4, 0x08, 0x14, 0x18}, /* < 32ohm */ 3246bcee7ed0SSrinivas Kandagatla {2, 0, 3, 0x18, 0x7C, 0x90}, /* 32ohm < Z < 400ohm */ 3247bcee7ed0SSrinivas Kandagatla {1, 4, 5, 0x18, 0x7C, 0x90}, /* 400ohm < Z < 1200ohm */ 3248bcee7ed0SSrinivas Kandagatla {1, 6, 7, 0x18, 0x7C, 0x90}, /* >1200ohm */ 3249bcee7ed0SSrinivas Kandagatla }; 3250bcee7ed0SSrinivas Kandagatla struct wcd938x_mbhc_zdet_param *zdet_param_ptr = NULL; 3251bcee7ed0SSrinivas Kandagatla s16 d1_a[][4] = { 3252bcee7ed0SSrinivas Kandagatla {0, 30, 90, 30}, 3253bcee7ed0SSrinivas Kandagatla {0, 30, 30, 5}, 3254bcee7ed0SSrinivas Kandagatla {0, 30, 30, 5}, 3255bcee7ed0SSrinivas Kandagatla {0, 30, 30, 5}, 3256bcee7ed0SSrinivas Kandagatla }; 3257bcee7ed0SSrinivas Kandagatla s16 *d1 = NULL; 3258bcee7ed0SSrinivas Kandagatla 3259bcee7ed0SSrinivas Kandagatla reg0 = snd_soc_component_read(component, WCD938X_ANA_MBHC_BTN5); 3260bcee7ed0SSrinivas Kandagatla reg1 = snd_soc_component_read(component, WCD938X_ANA_MBHC_BTN6); 3261bcee7ed0SSrinivas Kandagatla reg2 = snd_soc_component_read(component, WCD938X_ANA_MBHC_BTN7); 3262bcee7ed0SSrinivas Kandagatla reg3 = snd_soc_component_read(component, WCD938X_MBHC_CTL_CLK); 3263bcee7ed0SSrinivas Kandagatla reg4 = snd_soc_component_read(component, WCD938X_MBHC_NEW_ZDET_ANA_CTL); 3264bcee7ed0SSrinivas Kandagatla 3265bcee7ed0SSrinivas Kandagatla if (snd_soc_component_read(component, WCD938X_ANA_MBHC_ELECT) & 0x80) { 3266bcee7ed0SSrinivas Kandagatla is_fsm_disable = true; 3267bcee7ed0SSrinivas Kandagatla regmap_update_bits(wcd938x->regmap, 3268bcee7ed0SSrinivas Kandagatla WCD938X_ANA_MBHC_ELECT, 0x80, 0x00); 3269bcee7ed0SSrinivas Kandagatla } 3270bcee7ed0SSrinivas Kandagatla 3271bcee7ed0SSrinivas Kandagatla /* For NO-jack, disable L_DET_EN before Z-det measurements */ 3272bcee7ed0SSrinivas Kandagatla if (wcd938x->mbhc_cfg.hphl_swh) 3273bcee7ed0SSrinivas Kandagatla regmap_update_bits(wcd938x->regmap, 3274bcee7ed0SSrinivas Kandagatla WCD938X_ANA_MBHC_MECH, 0x80, 0x00); 3275bcee7ed0SSrinivas Kandagatla 3276bcee7ed0SSrinivas Kandagatla /* Turn off 100k pull down on HPHL */ 3277bcee7ed0SSrinivas Kandagatla regmap_update_bits(wcd938x->regmap, 3278bcee7ed0SSrinivas Kandagatla WCD938X_ANA_MBHC_MECH, 0x01, 0x00); 3279bcee7ed0SSrinivas Kandagatla 3280bcee7ed0SSrinivas Kandagatla /* Disable surge protection before impedance detection. 3281bcee7ed0SSrinivas Kandagatla * This is done to give correct value for high impedance. 3282bcee7ed0SSrinivas Kandagatla */ 3283bcee7ed0SSrinivas Kandagatla regmap_update_bits(wcd938x->regmap, 3284bcee7ed0SSrinivas Kandagatla WCD938X_HPH_SURGE_HPHLR_SURGE_EN, 0xC0, 0x00); 3285bcee7ed0SSrinivas Kandagatla /* 1ms delay needed after disable surge protection */ 3286bcee7ed0SSrinivas Kandagatla usleep_range(1000, 1010); 3287bcee7ed0SSrinivas Kandagatla 3288bcee7ed0SSrinivas Kandagatla /* First get impedance on Left */ 3289bcee7ed0SSrinivas Kandagatla d1 = d1_a[1]; 3290bcee7ed0SSrinivas Kandagatla zdet_param_ptr = &zdet_param[1]; 3291bcee7ed0SSrinivas Kandagatla wcd938x_mbhc_zdet_ramp(component, zdet_param_ptr, &z1L, NULL, d1); 3292bcee7ed0SSrinivas Kandagatla 3293bcee7ed0SSrinivas Kandagatla if (!WCD938X_MBHC_IS_SECOND_RAMP_REQUIRED(z1L)) 3294bcee7ed0SSrinivas Kandagatla goto left_ch_impedance; 3295bcee7ed0SSrinivas Kandagatla 3296bcee7ed0SSrinivas Kandagatla /* Second ramp for left ch */ 3297bcee7ed0SSrinivas Kandagatla if (z1L < WCD938X_ZDET_VAL_32) { 3298bcee7ed0SSrinivas Kandagatla zdet_param_ptr = &zdet_param[0]; 3299bcee7ed0SSrinivas Kandagatla d1 = d1_a[0]; 3300bcee7ed0SSrinivas Kandagatla } else if ((z1L > WCD938X_ZDET_VAL_400) && 3301bcee7ed0SSrinivas Kandagatla (z1L <= WCD938X_ZDET_VAL_1200)) { 3302bcee7ed0SSrinivas Kandagatla zdet_param_ptr = &zdet_param[2]; 3303bcee7ed0SSrinivas Kandagatla d1 = d1_a[2]; 3304bcee7ed0SSrinivas Kandagatla } else if (z1L > WCD938X_ZDET_VAL_1200) { 3305bcee7ed0SSrinivas Kandagatla zdet_param_ptr = &zdet_param[3]; 3306bcee7ed0SSrinivas Kandagatla d1 = d1_a[3]; 3307bcee7ed0SSrinivas Kandagatla } 3308bcee7ed0SSrinivas Kandagatla wcd938x_mbhc_zdet_ramp(component, zdet_param_ptr, &z1L, NULL, d1); 3309bcee7ed0SSrinivas Kandagatla 3310bcee7ed0SSrinivas Kandagatla left_ch_impedance: 3311bcee7ed0SSrinivas Kandagatla if ((z1L == WCD938X_ZDET_FLOATING_IMPEDANCE) || 3312bcee7ed0SSrinivas Kandagatla (z1L > WCD938X_ZDET_VAL_100K)) { 3313bcee7ed0SSrinivas Kandagatla *zl = WCD938X_ZDET_FLOATING_IMPEDANCE; 3314bcee7ed0SSrinivas Kandagatla zdet_param_ptr = &zdet_param[1]; 3315bcee7ed0SSrinivas Kandagatla d1 = d1_a[1]; 3316bcee7ed0SSrinivas Kandagatla } else { 3317bcee7ed0SSrinivas Kandagatla *zl = z1L/1000; 3318bcee7ed0SSrinivas Kandagatla wcd938x_wcd_mbhc_qfuse_cal(component, zl, 0); 3319bcee7ed0SSrinivas Kandagatla } 3320bcee7ed0SSrinivas Kandagatla dev_dbg(component->dev, "%s: impedance on HPH_L = %d(ohms)\n", 3321bcee7ed0SSrinivas Kandagatla __func__, *zl); 3322bcee7ed0SSrinivas Kandagatla 3323bcee7ed0SSrinivas Kandagatla /* Start of right impedance ramp and calculation */ 3324bcee7ed0SSrinivas Kandagatla wcd938x_mbhc_zdet_ramp(component, zdet_param_ptr, NULL, &z1R, d1); 3325bcee7ed0SSrinivas Kandagatla if (WCD938X_MBHC_IS_SECOND_RAMP_REQUIRED(z1R)) { 3326bcee7ed0SSrinivas Kandagatla if (((z1R > WCD938X_ZDET_VAL_1200) && 3327bcee7ed0SSrinivas Kandagatla (zdet_param_ptr->noff == 0x6)) || 3328bcee7ed0SSrinivas Kandagatla ((*zl) != WCD938X_ZDET_FLOATING_IMPEDANCE)) 3329bcee7ed0SSrinivas Kandagatla goto right_ch_impedance; 3330bcee7ed0SSrinivas Kandagatla /* Second ramp for right ch */ 3331bcee7ed0SSrinivas Kandagatla if (z1R < WCD938X_ZDET_VAL_32) { 3332bcee7ed0SSrinivas Kandagatla zdet_param_ptr = &zdet_param[0]; 3333bcee7ed0SSrinivas Kandagatla d1 = d1_a[0]; 3334bcee7ed0SSrinivas Kandagatla } else if ((z1R > WCD938X_ZDET_VAL_400) && 3335bcee7ed0SSrinivas Kandagatla (z1R <= WCD938X_ZDET_VAL_1200)) { 3336bcee7ed0SSrinivas Kandagatla zdet_param_ptr = &zdet_param[2]; 3337bcee7ed0SSrinivas Kandagatla d1 = d1_a[2]; 3338bcee7ed0SSrinivas Kandagatla } else if (z1R > WCD938X_ZDET_VAL_1200) { 3339bcee7ed0SSrinivas Kandagatla zdet_param_ptr = &zdet_param[3]; 3340bcee7ed0SSrinivas Kandagatla d1 = d1_a[3]; 3341bcee7ed0SSrinivas Kandagatla } 3342bcee7ed0SSrinivas Kandagatla wcd938x_mbhc_zdet_ramp(component, zdet_param_ptr, NULL, &z1R, d1); 3343bcee7ed0SSrinivas Kandagatla } 3344bcee7ed0SSrinivas Kandagatla right_ch_impedance: 3345bcee7ed0SSrinivas Kandagatla if ((z1R == WCD938X_ZDET_FLOATING_IMPEDANCE) || 3346bcee7ed0SSrinivas Kandagatla (z1R > WCD938X_ZDET_VAL_100K)) { 3347bcee7ed0SSrinivas Kandagatla *zr = WCD938X_ZDET_FLOATING_IMPEDANCE; 3348bcee7ed0SSrinivas Kandagatla } else { 3349bcee7ed0SSrinivas Kandagatla *zr = z1R/1000; 3350bcee7ed0SSrinivas Kandagatla wcd938x_wcd_mbhc_qfuse_cal(component, zr, 1); 3351bcee7ed0SSrinivas Kandagatla } 3352bcee7ed0SSrinivas Kandagatla dev_dbg(component->dev, "%s: impedance on HPH_R = %d(ohms)\n", 3353bcee7ed0SSrinivas Kandagatla __func__, *zr); 3354bcee7ed0SSrinivas Kandagatla 3355bcee7ed0SSrinivas Kandagatla /* Mono/stereo detection */ 3356bcee7ed0SSrinivas Kandagatla if ((*zl == WCD938X_ZDET_FLOATING_IMPEDANCE) && 3357bcee7ed0SSrinivas Kandagatla (*zr == WCD938X_ZDET_FLOATING_IMPEDANCE)) { 3358bcee7ed0SSrinivas Kandagatla dev_dbg(component->dev, 3359bcee7ed0SSrinivas Kandagatla "%s: plug type is invalid or extension cable\n", 3360bcee7ed0SSrinivas Kandagatla __func__); 3361bcee7ed0SSrinivas Kandagatla goto zdet_complete; 3362bcee7ed0SSrinivas Kandagatla } 3363bcee7ed0SSrinivas Kandagatla if ((*zl == WCD938X_ZDET_FLOATING_IMPEDANCE) || 3364bcee7ed0SSrinivas Kandagatla (*zr == WCD938X_ZDET_FLOATING_IMPEDANCE) || 3365bcee7ed0SSrinivas Kandagatla ((*zl < WCD_MONO_HS_MIN_THR) && (*zr > WCD_MONO_HS_MIN_THR)) || 3366bcee7ed0SSrinivas Kandagatla ((*zl > WCD_MONO_HS_MIN_THR) && (*zr < WCD_MONO_HS_MIN_THR))) { 3367bcee7ed0SSrinivas Kandagatla dev_dbg(component->dev, 3368bcee7ed0SSrinivas Kandagatla "%s: Mono plug type with one ch floating or shorted to GND\n", 3369bcee7ed0SSrinivas Kandagatla __func__); 3370bcee7ed0SSrinivas Kandagatla wcd_mbhc_set_hph_type(wcd938x->wcd_mbhc, WCD_MBHC_HPH_MONO); 3371bcee7ed0SSrinivas Kandagatla goto zdet_complete; 3372bcee7ed0SSrinivas Kandagatla } 3373bcee7ed0SSrinivas Kandagatla snd_soc_component_write_field(component, WCD938X_HPH_R_ATEST, 3374bcee7ed0SSrinivas Kandagatla WCD938X_HPHPA_GND_OVR_MASK, 1); 3375bcee7ed0SSrinivas Kandagatla snd_soc_component_write_field(component, WCD938X_HPH_PA_CTL2, 3376bcee7ed0SSrinivas Kandagatla WCD938X_HPHPA_GND_R_MASK, 1); 3377bcee7ed0SSrinivas Kandagatla if (*zl < (WCD938X_ZDET_VAL_32/1000)) 3378bcee7ed0SSrinivas Kandagatla wcd938x_mbhc_zdet_ramp(component, &zdet_param[0], &z1Ls, NULL, d1); 3379bcee7ed0SSrinivas Kandagatla else 3380bcee7ed0SSrinivas Kandagatla wcd938x_mbhc_zdet_ramp(component, &zdet_param[1], &z1Ls, NULL, d1); 3381bcee7ed0SSrinivas Kandagatla snd_soc_component_write_field(component, WCD938X_HPH_PA_CTL2, 3382bcee7ed0SSrinivas Kandagatla WCD938X_HPHPA_GND_R_MASK, 0); 3383bcee7ed0SSrinivas Kandagatla snd_soc_component_write_field(component, WCD938X_HPH_R_ATEST, 3384bcee7ed0SSrinivas Kandagatla WCD938X_HPHPA_GND_OVR_MASK, 0); 3385bcee7ed0SSrinivas Kandagatla z1Ls /= 1000; 3386bcee7ed0SSrinivas Kandagatla wcd938x_wcd_mbhc_qfuse_cal(component, &z1Ls, 0); 3387bcee7ed0SSrinivas Kandagatla /* Parallel of left Z and 9 ohm pull down resistor */ 3388bcee7ed0SSrinivas Kandagatla zMono = ((*zl) * 9) / ((*zl) + 9); 3389bcee7ed0SSrinivas Kandagatla z_diff1 = (z1Ls > zMono) ? (z1Ls - zMono) : (zMono - z1Ls); 3390bcee7ed0SSrinivas Kandagatla z_diff2 = ((*zl) > z1Ls) ? ((*zl) - z1Ls) : (z1Ls - (*zl)); 3391bcee7ed0SSrinivas Kandagatla if ((z_diff1 * (*zl + z1Ls)) > (z_diff2 * (z1Ls + zMono))) { 3392bcee7ed0SSrinivas Kandagatla dev_dbg(component->dev, "%s: stereo plug type detected\n", 3393bcee7ed0SSrinivas Kandagatla __func__); 3394bcee7ed0SSrinivas Kandagatla wcd_mbhc_set_hph_type(wcd938x->wcd_mbhc, WCD_MBHC_HPH_STEREO); 3395bcee7ed0SSrinivas Kandagatla } else { 3396bcee7ed0SSrinivas Kandagatla dev_dbg(component->dev, "%s: MONO plug type detected\n", 3397bcee7ed0SSrinivas Kandagatla __func__); 3398bcee7ed0SSrinivas Kandagatla wcd_mbhc_set_hph_type(wcd938x->wcd_mbhc, WCD_MBHC_HPH_MONO); 3399bcee7ed0SSrinivas Kandagatla } 3400bcee7ed0SSrinivas Kandagatla 3401bcee7ed0SSrinivas Kandagatla /* Enable surge protection again after impedance detection */ 3402bcee7ed0SSrinivas Kandagatla regmap_update_bits(wcd938x->regmap, 3403bcee7ed0SSrinivas Kandagatla WCD938X_HPH_SURGE_HPHLR_SURGE_EN, 0xC0, 0xC0); 3404bcee7ed0SSrinivas Kandagatla zdet_complete: 3405bcee7ed0SSrinivas Kandagatla snd_soc_component_write(component, WCD938X_ANA_MBHC_BTN5, reg0); 3406bcee7ed0SSrinivas Kandagatla snd_soc_component_write(component, WCD938X_ANA_MBHC_BTN6, reg1); 3407bcee7ed0SSrinivas Kandagatla snd_soc_component_write(component, WCD938X_ANA_MBHC_BTN7, reg2); 3408bcee7ed0SSrinivas Kandagatla /* Turn on 100k pull down on HPHL */ 3409bcee7ed0SSrinivas Kandagatla regmap_update_bits(wcd938x->regmap, 3410bcee7ed0SSrinivas Kandagatla WCD938X_ANA_MBHC_MECH, 0x01, 0x01); 3411bcee7ed0SSrinivas Kandagatla 3412bcee7ed0SSrinivas Kandagatla /* For NO-jack, re-enable L_DET_EN after Z-det measurements */ 3413bcee7ed0SSrinivas Kandagatla if (wcd938x->mbhc_cfg.hphl_swh) 3414bcee7ed0SSrinivas Kandagatla regmap_update_bits(wcd938x->regmap, 3415bcee7ed0SSrinivas Kandagatla WCD938X_ANA_MBHC_MECH, 0x80, 0x80); 3416bcee7ed0SSrinivas Kandagatla 3417bcee7ed0SSrinivas Kandagatla snd_soc_component_write(component, WCD938X_MBHC_NEW_ZDET_ANA_CTL, reg4); 3418bcee7ed0SSrinivas Kandagatla snd_soc_component_write(component, WCD938X_MBHC_CTL_CLK, reg3); 3419bcee7ed0SSrinivas Kandagatla if (is_fsm_disable) 3420bcee7ed0SSrinivas Kandagatla regmap_update_bits(wcd938x->regmap, 3421bcee7ed0SSrinivas Kandagatla WCD938X_ANA_MBHC_ELECT, 0x80, 0x80); 3422bcee7ed0SSrinivas Kandagatla } 3423bcee7ed0SSrinivas Kandagatla 3424bcee7ed0SSrinivas Kandagatla static void wcd938x_mbhc_gnd_det_ctrl(struct snd_soc_component *component, 3425bcee7ed0SSrinivas Kandagatla bool enable) 3426bcee7ed0SSrinivas Kandagatla { 3427bcee7ed0SSrinivas Kandagatla if (enable) { 3428bcee7ed0SSrinivas Kandagatla snd_soc_component_write_field(component, WCD938X_ANA_MBHC_MECH, 3429bcee7ed0SSrinivas Kandagatla WCD938X_MBHC_HSG_PULLUP_COMP_EN, 1); 3430bcee7ed0SSrinivas Kandagatla snd_soc_component_write_field(component, WCD938X_ANA_MBHC_MECH, 3431bcee7ed0SSrinivas Kandagatla WCD938X_MBHC_GND_DET_EN_MASK, 1); 3432bcee7ed0SSrinivas Kandagatla } else { 3433bcee7ed0SSrinivas Kandagatla snd_soc_component_write_field(component, WCD938X_ANA_MBHC_MECH, 3434bcee7ed0SSrinivas Kandagatla WCD938X_MBHC_GND_DET_EN_MASK, 0); 3435bcee7ed0SSrinivas Kandagatla snd_soc_component_write_field(component, WCD938X_ANA_MBHC_MECH, 3436bcee7ed0SSrinivas Kandagatla WCD938X_MBHC_HSG_PULLUP_COMP_EN, 0); 3437bcee7ed0SSrinivas Kandagatla } 3438bcee7ed0SSrinivas Kandagatla } 3439bcee7ed0SSrinivas Kandagatla 3440bcee7ed0SSrinivas Kandagatla static void wcd938x_mbhc_hph_pull_down_ctrl(struct snd_soc_component *component, 3441bcee7ed0SSrinivas Kandagatla bool enable) 3442bcee7ed0SSrinivas Kandagatla { 3443bcee7ed0SSrinivas Kandagatla snd_soc_component_write_field(component, WCD938X_HPH_PA_CTL2, 3444bcee7ed0SSrinivas Kandagatla WCD938X_HPHPA_GND_R_MASK, enable); 3445bcee7ed0SSrinivas Kandagatla snd_soc_component_write_field(component, WCD938X_HPH_PA_CTL2, 3446bcee7ed0SSrinivas Kandagatla WCD938X_HPHPA_GND_L_MASK, enable); 3447bcee7ed0SSrinivas Kandagatla } 3448bcee7ed0SSrinivas Kandagatla 3449bcee7ed0SSrinivas Kandagatla static void wcd938x_mbhc_moisture_config(struct snd_soc_component *component) 3450bcee7ed0SSrinivas Kandagatla { 3451bcee7ed0SSrinivas Kandagatla struct wcd938x_priv *wcd938x = snd_soc_component_get_drvdata(component); 3452bcee7ed0SSrinivas Kandagatla 3453bcee7ed0SSrinivas Kandagatla if (wcd938x->mbhc_cfg.moist_rref == R_OFF) { 3454bcee7ed0SSrinivas Kandagatla snd_soc_component_write_field(component, WCD938X_MBHC_NEW_CTL_2, 3455bcee7ed0SSrinivas Kandagatla WCD938X_M_RTH_CTL_MASK, R_OFF); 3456bcee7ed0SSrinivas Kandagatla return; 3457bcee7ed0SSrinivas Kandagatla } 3458bcee7ed0SSrinivas Kandagatla 3459bcee7ed0SSrinivas Kandagatla /* Do not enable moisture detection if jack type is NC */ 3460bcee7ed0SSrinivas Kandagatla if (!wcd938x->mbhc_cfg.hphl_swh) { 3461bcee7ed0SSrinivas Kandagatla dev_dbg(component->dev, "%s: disable moisture detection for NC\n", 3462bcee7ed0SSrinivas Kandagatla __func__); 3463bcee7ed0SSrinivas Kandagatla snd_soc_component_write_field(component, WCD938X_MBHC_NEW_CTL_2, 3464bcee7ed0SSrinivas Kandagatla WCD938X_M_RTH_CTL_MASK, R_OFF); 3465bcee7ed0SSrinivas Kandagatla return; 3466bcee7ed0SSrinivas Kandagatla } 3467bcee7ed0SSrinivas Kandagatla 3468bcee7ed0SSrinivas Kandagatla snd_soc_component_write_field(component, WCD938X_MBHC_NEW_CTL_2, 3469bcee7ed0SSrinivas Kandagatla WCD938X_M_RTH_CTL_MASK, wcd938x->mbhc_cfg.moist_rref); 3470bcee7ed0SSrinivas Kandagatla } 3471bcee7ed0SSrinivas Kandagatla 3472bcee7ed0SSrinivas Kandagatla static void wcd938x_mbhc_moisture_detect_en(struct snd_soc_component *component, bool enable) 3473bcee7ed0SSrinivas Kandagatla { 3474bcee7ed0SSrinivas Kandagatla struct wcd938x_priv *wcd938x = snd_soc_component_get_drvdata(component); 3475bcee7ed0SSrinivas Kandagatla 3476bcee7ed0SSrinivas Kandagatla if (enable) 3477bcee7ed0SSrinivas Kandagatla snd_soc_component_write_field(component, WCD938X_MBHC_NEW_CTL_2, 3478bcee7ed0SSrinivas Kandagatla WCD938X_M_RTH_CTL_MASK, wcd938x->mbhc_cfg.moist_rref); 3479bcee7ed0SSrinivas Kandagatla else 3480bcee7ed0SSrinivas Kandagatla snd_soc_component_write_field(component, WCD938X_MBHC_NEW_CTL_2, 3481bcee7ed0SSrinivas Kandagatla WCD938X_M_RTH_CTL_MASK, R_OFF); 3482bcee7ed0SSrinivas Kandagatla } 3483bcee7ed0SSrinivas Kandagatla 3484bcee7ed0SSrinivas Kandagatla static bool wcd938x_mbhc_get_moisture_status(struct snd_soc_component *component) 3485bcee7ed0SSrinivas Kandagatla { 3486bcee7ed0SSrinivas Kandagatla struct wcd938x_priv *wcd938x = snd_soc_component_get_drvdata(component); 3487bcee7ed0SSrinivas Kandagatla bool ret = false; 3488bcee7ed0SSrinivas Kandagatla 3489bcee7ed0SSrinivas Kandagatla if (wcd938x->mbhc_cfg.moist_rref == R_OFF) { 3490bcee7ed0SSrinivas Kandagatla snd_soc_component_write_field(component, WCD938X_MBHC_NEW_CTL_2, 3491bcee7ed0SSrinivas Kandagatla WCD938X_M_RTH_CTL_MASK, R_OFF); 3492bcee7ed0SSrinivas Kandagatla goto done; 3493bcee7ed0SSrinivas Kandagatla } 3494bcee7ed0SSrinivas Kandagatla 3495bcee7ed0SSrinivas Kandagatla /* Do not enable moisture detection if jack type is NC */ 3496bcee7ed0SSrinivas Kandagatla if (!wcd938x->mbhc_cfg.hphl_swh) { 3497bcee7ed0SSrinivas Kandagatla dev_dbg(component->dev, "%s: disable moisture detection for NC\n", 3498bcee7ed0SSrinivas Kandagatla __func__); 3499bcee7ed0SSrinivas Kandagatla snd_soc_component_write_field(component, WCD938X_MBHC_NEW_CTL_2, 3500bcee7ed0SSrinivas Kandagatla WCD938X_M_RTH_CTL_MASK, R_OFF); 3501bcee7ed0SSrinivas Kandagatla goto done; 3502bcee7ed0SSrinivas Kandagatla } 3503bcee7ed0SSrinivas Kandagatla 3504bcee7ed0SSrinivas Kandagatla /* 3505bcee7ed0SSrinivas Kandagatla * If moisture_en is already enabled, then skip to plug type 3506bcee7ed0SSrinivas Kandagatla * detection. 3507bcee7ed0SSrinivas Kandagatla */ 3508bcee7ed0SSrinivas Kandagatla if (snd_soc_component_read_field(component, WCD938X_MBHC_NEW_CTL_2, WCD938X_M_RTH_CTL_MASK)) 3509bcee7ed0SSrinivas Kandagatla goto done; 3510bcee7ed0SSrinivas Kandagatla 3511bcee7ed0SSrinivas Kandagatla wcd938x_mbhc_moisture_detect_en(component, true); 3512bcee7ed0SSrinivas Kandagatla /* Read moisture comparator status */ 3513bcee7ed0SSrinivas Kandagatla ret = ((snd_soc_component_read(component, WCD938X_MBHC_NEW_FSM_STATUS) 3514bcee7ed0SSrinivas Kandagatla & 0x20) ? 0 : 1); 3515bcee7ed0SSrinivas Kandagatla 3516bcee7ed0SSrinivas Kandagatla done: 3517bcee7ed0SSrinivas Kandagatla return ret; 3518bcee7ed0SSrinivas Kandagatla 3519bcee7ed0SSrinivas Kandagatla } 3520bcee7ed0SSrinivas Kandagatla 3521bcee7ed0SSrinivas Kandagatla static void wcd938x_mbhc_moisture_polling_ctrl(struct snd_soc_component *component, 3522bcee7ed0SSrinivas Kandagatla bool enable) 3523bcee7ed0SSrinivas Kandagatla { 3524bcee7ed0SSrinivas Kandagatla snd_soc_component_write_field(component, 3525bcee7ed0SSrinivas Kandagatla WCD938X_MBHC_NEW_INT_MOISTURE_DET_POLLING_CTRL, 3526bcee7ed0SSrinivas Kandagatla WCD938X_MOISTURE_EN_POLLING_MASK, enable); 3527bcee7ed0SSrinivas Kandagatla } 3528bcee7ed0SSrinivas Kandagatla 3529bcee7ed0SSrinivas Kandagatla static const struct wcd_mbhc_cb mbhc_cb = { 3530bcee7ed0SSrinivas Kandagatla .clk_setup = wcd938x_mbhc_clk_setup, 3531bcee7ed0SSrinivas Kandagatla .mbhc_bias = wcd938x_mbhc_mbhc_bias_control, 3532bcee7ed0SSrinivas Kandagatla .set_btn_thr = wcd938x_mbhc_program_btn_thr, 3533bcee7ed0SSrinivas Kandagatla .micbias_enable_status = wcd938x_mbhc_micb_en_status, 3534bcee7ed0SSrinivas Kandagatla .hph_pull_up_control_v2 = wcd938x_mbhc_hph_l_pull_up_control, 3535bcee7ed0SSrinivas Kandagatla .mbhc_micbias_control = wcd938x_mbhc_request_micbias, 3536bcee7ed0SSrinivas Kandagatla .mbhc_micb_ramp_control = wcd938x_mbhc_micb_ramp_control, 3537bcee7ed0SSrinivas Kandagatla .mbhc_micb_ctrl_thr_mic = wcd938x_mbhc_micb_ctrl_threshold_mic, 3538bcee7ed0SSrinivas Kandagatla .compute_impedance = wcd938x_wcd_mbhc_calc_impedance, 3539bcee7ed0SSrinivas Kandagatla .mbhc_gnd_det_ctrl = wcd938x_mbhc_gnd_det_ctrl, 3540bcee7ed0SSrinivas Kandagatla .hph_pull_down_ctrl = wcd938x_mbhc_hph_pull_down_ctrl, 3541bcee7ed0SSrinivas Kandagatla .mbhc_moisture_config = wcd938x_mbhc_moisture_config, 3542bcee7ed0SSrinivas Kandagatla .mbhc_get_moisture_status = wcd938x_mbhc_get_moisture_status, 3543bcee7ed0SSrinivas Kandagatla .mbhc_moisture_polling_ctrl = wcd938x_mbhc_moisture_polling_ctrl, 3544bcee7ed0SSrinivas Kandagatla .mbhc_moisture_detect_en = wcd938x_mbhc_moisture_detect_en, 3545bcee7ed0SSrinivas Kandagatla }; 3546bcee7ed0SSrinivas Kandagatla 3547bcee7ed0SSrinivas Kandagatla static int wcd938x_get_hph_type(struct snd_kcontrol *kcontrol, 3548bcee7ed0SSrinivas Kandagatla struct snd_ctl_elem_value *ucontrol) 3549bcee7ed0SSrinivas Kandagatla { 3550bcee7ed0SSrinivas Kandagatla struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); 3551bcee7ed0SSrinivas Kandagatla struct wcd938x_priv *wcd938x = snd_soc_component_get_drvdata(component); 3552bcee7ed0SSrinivas Kandagatla 3553bcee7ed0SSrinivas Kandagatla ucontrol->value.integer.value[0] = wcd_mbhc_get_hph_type(wcd938x->wcd_mbhc); 3554bcee7ed0SSrinivas Kandagatla 3555bcee7ed0SSrinivas Kandagatla return 0; 3556bcee7ed0SSrinivas Kandagatla } 3557bcee7ed0SSrinivas Kandagatla 3558bcee7ed0SSrinivas Kandagatla static int wcd938x_hph_impedance_get(struct snd_kcontrol *kcontrol, 3559bcee7ed0SSrinivas Kandagatla struct snd_ctl_elem_value *ucontrol) 3560bcee7ed0SSrinivas Kandagatla { 3561bcee7ed0SSrinivas Kandagatla uint32_t zl, zr; 3562bcee7ed0SSrinivas Kandagatla bool hphr; 3563bcee7ed0SSrinivas Kandagatla struct soc_mixer_control *mc; 3564bcee7ed0SSrinivas Kandagatla struct snd_soc_component *component = 3565bcee7ed0SSrinivas Kandagatla snd_soc_kcontrol_component(kcontrol); 3566bcee7ed0SSrinivas Kandagatla struct wcd938x_priv *wcd938x = snd_soc_component_get_drvdata(component); 3567bcee7ed0SSrinivas Kandagatla 3568bcee7ed0SSrinivas Kandagatla mc = (struct soc_mixer_control *)(kcontrol->private_value); 3569bcee7ed0SSrinivas Kandagatla hphr = mc->shift; 3570bcee7ed0SSrinivas Kandagatla wcd_mbhc_get_impedance(wcd938x->wcd_mbhc, &zl, &zr); 3571bcee7ed0SSrinivas Kandagatla dev_dbg(component->dev, "%s: zl=%u(ohms), zr=%u(ohms)\n", __func__, zl, zr); 3572bcee7ed0SSrinivas Kandagatla ucontrol->value.integer.value[0] = hphr ? zr : zl; 3573bcee7ed0SSrinivas Kandagatla 3574bcee7ed0SSrinivas Kandagatla return 0; 3575bcee7ed0SSrinivas Kandagatla } 3576bcee7ed0SSrinivas Kandagatla 3577bcee7ed0SSrinivas Kandagatla static const struct snd_kcontrol_new hph_type_detect_controls[] = { 3578bcee7ed0SSrinivas Kandagatla SOC_SINGLE_EXT("HPH Type", 0, 0, UINT_MAX, 0, 3579bcee7ed0SSrinivas Kandagatla wcd938x_get_hph_type, NULL), 3580bcee7ed0SSrinivas Kandagatla }; 3581bcee7ed0SSrinivas Kandagatla 3582bcee7ed0SSrinivas Kandagatla static const struct snd_kcontrol_new impedance_detect_controls[] = { 3583bcee7ed0SSrinivas Kandagatla SOC_SINGLE_EXT("HPHL Impedance", 0, 0, UINT_MAX, 0, 3584bcee7ed0SSrinivas Kandagatla wcd938x_hph_impedance_get, NULL), 3585bcee7ed0SSrinivas Kandagatla SOC_SINGLE_EXT("HPHR Impedance", 0, 1, UINT_MAX, 0, 3586bcee7ed0SSrinivas Kandagatla wcd938x_hph_impedance_get, NULL), 3587bcee7ed0SSrinivas Kandagatla }; 3588bcee7ed0SSrinivas Kandagatla 3589bcee7ed0SSrinivas Kandagatla static int wcd938x_mbhc_init(struct snd_soc_component *component) 3590bcee7ed0SSrinivas Kandagatla { 3591bcee7ed0SSrinivas Kandagatla struct wcd938x_priv *wcd938x = snd_soc_component_get_drvdata(component); 3592bcee7ed0SSrinivas Kandagatla struct wcd_mbhc_intr *intr_ids = &wcd938x->intr_ids; 3593bcee7ed0SSrinivas Kandagatla 3594bcee7ed0SSrinivas Kandagatla intr_ids->mbhc_sw_intr = regmap_irq_get_virq(wcd938x->irq_chip, 3595bcee7ed0SSrinivas Kandagatla WCD938X_IRQ_MBHC_SW_DET); 3596bcee7ed0SSrinivas Kandagatla intr_ids->mbhc_btn_press_intr = regmap_irq_get_virq(wcd938x->irq_chip, 3597bcee7ed0SSrinivas Kandagatla WCD938X_IRQ_MBHC_BUTTON_PRESS_DET); 3598bcee7ed0SSrinivas Kandagatla intr_ids->mbhc_btn_release_intr = regmap_irq_get_virq(wcd938x->irq_chip, 3599bcee7ed0SSrinivas Kandagatla WCD938X_IRQ_MBHC_BUTTON_RELEASE_DET); 3600bcee7ed0SSrinivas Kandagatla intr_ids->mbhc_hs_ins_intr = regmap_irq_get_virq(wcd938x->irq_chip, 3601bcee7ed0SSrinivas Kandagatla WCD938X_IRQ_MBHC_ELECT_INS_REM_LEG_DET); 3602bcee7ed0SSrinivas Kandagatla intr_ids->mbhc_hs_rem_intr = regmap_irq_get_virq(wcd938x->irq_chip, 3603bcee7ed0SSrinivas Kandagatla WCD938X_IRQ_MBHC_ELECT_INS_REM_DET); 3604bcee7ed0SSrinivas Kandagatla intr_ids->hph_left_ocp = regmap_irq_get_virq(wcd938x->irq_chip, 3605bcee7ed0SSrinivas Kandagatla WCD938X_IRQ_HPHL_OCP_INT); 3606bcee7ed0SSrinivas Kandagatla intr_ids->hph_right_ocp = regmap_irq_get_virq(wcd938x->irq_chip, 3607bcee7ed0SSrinivas Kandagatla WCD938X_IRQ_HPHR_OCP_INT); 3608bcee7ed0SSrinivas Kandagatla 3609bcee7ed0SSrinivas Kandagatla wcd938x->wcd_mbhc = wcd_mbhc_init(component, &mbhc_cb, intr_ids, wcd_mbhc_fields, true); 3610bcee7ed0SSrinivas Kandagatla 3611bcee7ed0SSrinivas Kandagatla snd_soc_add_component_controls(component, impedance_detect_controls, 3612bcee7ed0SSrinivas Kandagatla ARRAY_SIZE(impedance_detect_controls)); 3613bcee7ed0SSrinivas Kandagatla snd_soc_add_component_controls(component, hph_type_detect_controls, 3614bcee7ed0SSrinivas Kandagatla ARRAY_SIZE(hph_type_detect_controls)); 3615bcee7ed0SSrinivas Kandagatla 3616bcee7ed0SSrinivas Kandagatla return 0; 3617bcee7ed0SSrinivas Kandagatla } 3618bcee7ed0SSrinivas Kandagatla /* END MBHC */ 3619bcee7ed0SSrinivas Kandagatla 3620e8ba1e05SSrinivas Kandagatla static const struct snd_kcontrol_new wcd938x_snd_controls[] = { 3621e8ba1e05SSrinivas Kandagatla SOC_SINGLE_EXT("HPHL_COMP Switch", WCD938X_COMP_L, 0, 1, 0, 3622e8ba1e05SSrinivas Kandagatla wcd938x_get_compander, wcd938x_set_compander), 3623e8ba1e05SSrinivas Kandagatla SOC_SINGLE_EXT("HPHR_COMP Switch", WCD938X_COMP_R, 1, 1, 0, 3624e8ba1e05SSrinivas Kandagatla wcd938x_get_compander, wcd938x_set_compander), 3625e8ba1e05SSrinivas Kandagatla SOC_SINGLE_EXT("HPHL Switch", WCD938X_HPH_L, 0, 1, 0, 3626e8ba1e05SSrinivas Kandagatla wcd938x_get_swr_port, wcd938x_set_swr_port), 3627e8ba1e05SSrinivas Kandagatla SOC_SINGLE_EXT("HPHR Switch", WCD938X_HPH_R, 0, 1, 0, 3628e8ba1e05SSrinivas Kandagatla wcd938x_get_swr_port, wcd938x_set_swr_port), 3629e8ba1e05SSrinivas Kandagatla SOC_SINGLE_EXT("CLSH Switch", WCD938X_CLSH, 0, 1, 0, 3630e8ba1e05SSrinivas Kandagatla wcd938x_get_swr_port, wcd938x_set_swr_port), 3631e8ba1e05SSrinivas Kandagatla SOC_SINGLE_EXT("LO Switch", WCD938X_LO, 0, 1, 0, 3632e8ba1e05SSrinivas Kandagatla wcd938x_get_swr_port, wcd938x_set_swr_port), 3633e8ba1e05SSrinivas Kandagatla SOC_SINGLE_EXT("DSD_L Switch", WCD938X_DSD_L, 0, 1, 0, 3634e8ba1e05SSrinivas Kandagatla wcd938x_get_swr_port, wcd938x_set_swr_port), 3635e8ba1e05SSrinivas Kandagatla SOC_SINGLE_EXT("DSD_R Switch", WCD938X_DSD_R, 0, 1, 0, 3636e8ba1e05SSrinivas Kandagatla wcd938x_get_swr_port, wcd938x_set_swr_port), 3637e8ba1e05SSrinivas Kandagatla SOC_SINGLE_TLV("HPHL Volume", WCD938X_HPH_L_EN, 0, 0x18, 0, line_gain), 3638e8ba1e05SSrinivas Kandagatla SOC_SINGLE_TLV("HPHR Volume", WCD938X_HPH_R_EN, 0, 0x18, 0, line_gain), 3639e8ba1e05SSrinivas Kandagatla WCD938X_EAR_PA_GAIN_TLV("EAR_PA Volume", WCD938X_ANA_EAR_COMPANDER_CTL, 3640e8ba1e05SSrinivas Kandagatla 2, 0x10, 0, ear_pa_gain), 3641e8ba1e05SSrinivas Kandagatla SOC_SINGLE_EXT("ADC1 Switch", WCD938X_ADC1, 1, 1, 0, 3642e8ba1e05SSrinivas Kandagatla wcd938x_get_swr_port, wcd938x_set_swr_port), 3643e8ba1e05SSrinivas Kandagatla SOC_SINGLE_EXT("ADC2 Switch", WCD938X_ADC2, 1, 1, 0, 3644e8ba1e05SSrinivas Kandagatla wcd938x_get_swr_port, wcd938x_set_swr_port), 3645e8ba1e05SSrinivas Kandagatla SOC_SINGLE_EXT("ADC3 Switch", WCD938X_ADC3, 1, 1, 0, 3646e8ba1e05SSrinivas Kandagatla wcd938x_get_swr_port, wcd938x_set_swr_port), 3647e8ba1e05SSrinivas Kandagatla SOC_SINGLE_EXT("ADC4 Switch", WCD938X_ADC4, 1, 1, 0, 3648e8ba1e05SSrinivas Kandagatla wcd938x_get_swr_port, wcd938x_set_swr_port), 3649e8ba1e05SSrinivas Kandagatla SOC_SINGLE_EXT("DMIC0 Switch", WCD938X_DMIC0, 1, 1, 0, 3650e8ba1e05SSrinivas Kandagatla wcd938x_get_swr_port, wcd938x_set_swr_port), 3651e8ba1e05SSrinivas Kandagatla SOC_SINGLE_EXT("DMIC1 Switch", WCD938X_DMIC1, 1, 1, 0, 3652e8ba1e05SSrinivas Kandagatla wcd938x_get_swr_port, wcd938x_set_swr_port), 3653e8ba1e05SSrinivas Kandagatla SOC_SINGLE_EXT("MBHC Switch", WCD938X_MBHC, 1, 1, 0, 3654e8ba1e05SSrinivas Kandagatla wcd938x_get_swr_port, wcd938x_set_swr_port), 3655e8ba1e05SSrinivas Kandagatla SOC_SINGLE_EXT("DMIC2 Switch", WCD938X_DMIC2, 1, 1, 0, 3656e8ba1e05SSrinivas Kandagatla wcd938x_get_swr_port, wcd938x_set_swr_port), 3657e8ba1e05SSrinivas Kandagatla SOC_SINGLE_EXT("DMIC3 Switch", WCD938X_DMIC3, 1, 1, 0, 3658e8ba1e05SSrinivas Kandagatla wcd938x_get_swr_port, wcd938x_set_swr_port), 3659e8ba1e05SSrinivas Kandagatla SOC_SINGLE_EXT("DMIC4 Switch", WCD938X_DMIC4, 1, 1, 0, 3660e8ba1e05SSrinivas Kandagatla wcd938x_get_swr_port, wcd938x_set_swr_port), 3661e8ba1e05SSrinivas Kandagatla SOC_SINGLE_EXT("DMIC5 Switch", WCD938X_DMIC5, 1, 1, 0, 3662e8ba1e05SSrinivas Kandagatla wcd938x_get_swr_port, wcd938x_set_swr_port), 3663e8ba1e05SSrinivas Kandagatla SOC_SINGLE_EXT("DMIC6 Switch", WCD938X_DMIC6, 1, 1, 0, 3664e8ba1e05SSrinivas Kandagatla wcd938x_get_swr_port, wcd938x_set_swr_port), 3665e8ba1e05SSrinivas Kandagatla SOC_SINGLE_EXT("DMIC7 Switch", WCD938X_DMIC7, 1, 1, 0, 3666e8ba1e05SSrinivas Kandagatla wcd938x_get_swr_port, wcd938x_set_swr_port), 3667e8ba1e05SSrinivas Kandagatla SOC_SINGLE_EXT("LDOH Enable Switch", SND_SOC_NOPM, 0, 1, 0, 3668e8ba1e05SSrinivas Kandagatla wcd938x_ldoh_get, wcd938x_ldoh_put), 3669e8ba1e05SSrinivas Kandagatla SOC_SINGLE_EXT("ADC2_BCS Disable Switch", SND_SOC_NOPM, 0, 1, 0, 3670e8ba1e05SSrinivas Kandagatla wcd938x_bcs_get, wcd938x_bcs_put), 3671e8ba1e05SSrinivas Kandagatla 3672e8ba1e05SSrinivas Kandagatla SOC_SINGLE_TLV("ADC1 Volume", WCD938X_ANA_TX_CH1, 0, 20, 0, analog_gain), 3673e8ba1e05SSrinivas Kandagatla SOC_SINGLE_TLV("ADC2 Volume", WCD938X_ANA_TX_CH2, 0, 20, 0, analog_gain), 3674e8ba1e05SSrinivas Kandagatla SOC_SINGLE_TLV("ADC3 Volume", WCD938X_ANA_TX_CH3, 0, 20, 0, analog_gain), 3675e8ba1e05SSrinivas Kandagatla SOC_SINGLE_TLV("ADC4 Volume", WCD938X_ANA_TX_CH4, 0, 20, 0, analog_gain), 3676e8ba1e05SSrinivas Kandagatla }; 3677e8ba1e05SSrinivas Kandagatla 36788da9db0cSSrinivas Kandagatla static const struct snd_soc_dapm_widget wcd938x_dapm_widgets[] = { 3679d5add08fSSrinivas Kandagatla 3680d5add08fSSrinivas Kandagatla /*input widgets*/ 3681d5add08fSSrinivas Kandagatla SND_SOC_DAPM_INPUT("AMIC1"), 3682d5add08fSSrinivas Kandagatla SND_SOC_DAPM_INPUT("AMIC2"), 3683d5add08fSSrinivas Kandagatla SND_SOC_DAPM_INPUT("AMIC3"), 3684d5add08fSSrinivas Kandagatla SND_SOC_DAPM_INPUT("AMIC4"), 3685d5add08fSSrinivas Kandagatla SND_SOC_DAPM_INPUT("AMIC5"), 3686d5add08fSSrinivas Kandagatla SND_SOC_DAPM_INPUT("AMIC6"), 3687d5add08fSSrinivas Kandagatla SND_SOC_DAPM_INPUT("AMIC7"), 3688d5add08fSSrinivas Kandagatla SND_SOC_DAPM_MIC("Analog Mic1", NULL), 3689d5add08fSSrinivas Kandagatla SND_SOC_DAPM_MIC("Analog Mic2", NULL), 3690d5add08fSSrinivas Kandagatla SND_SOC_DAPM_MIC("Analog Mic3", NULL), 3691d5add08fSSrinivas Kandagatla SND_SOC_DAPM_MIC("Analog Mic4", NULL), 3692d5add08fSSrinivas Kandagatla SND_SOC_DAPM_MIC("Analog Mic5", NULL), 3693d5add08fSSrinivas Kandagatla 3694d5add08fSSrinivas Kandagatla /*tx widgets*/ 3695d5add08fSSrinivas Kandagatla SND_SOC_DAPM_ADC_E("ADC1", NULL, SND_SOC_NOPM, 0, 0, 3696d5add08fSSrinivas Kandagatla wcd938x_codec_enable_adc, 3697d5add08fSSrinivas Kandagatla SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD), 3698d5add08fSSrinivas Kandagatla SND_SOC_DAPM_ADC_E("ADC2", NULL, SND_SOC_NOPM, 1, 0, 3699d5add08fSSrinivas Kandagatla wcd938x_codec_enable_adc, 3700d5add08fSSrinivas Kandagatla SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD), 3701d5add08fSSrinivas Kandagatla SND_SOC_DAPM_ADC_E("ADC3", NULL, SND_SOC_NOPM, 2, 0, 3702d5add08fSSrinivas Kandagatla wcd938x_codec_enable_adc, 3703d5add08fSSrinivas Kandagatla SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD), 3704d5add08fSSrinivas Kandagatla SND_SOC_DAPM_ADC_E("ADC4", NULL, SND_SOC_NOPM, 3, 0, 3705d5add08fSSrinivas Kandagatla wcd938x_codec_enable_adc, 3706d5add08fSSrinivas Kandagatla SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD), 3707d5add08fSSrinivas Kandagatla SND_SOC_DAPM_ADC_E("DMIC1", NULL, SND_SOC_NOPM, 0, 0, 3708d5add08fSSrinivas Kandagatla wcd938x_codec_enable_dmic, 3709d5add08fSSrinivas Kandagatla SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD), 3710d5add08fSSrinivas Kandagatla SND_SOC_DAPM_ADC_E("DMIC2", NULL, SND_SOC_NOPM, 1, 0, 3711d5add08fSSrinivas Kandagatla wcd938x_codec_enable_dmic, 3712d5add08fSSrinivas Kandagatla SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD), 3713d5add08fSSrinivas Kandagatla SND_SOC_DAPM_ADC_E("DMIC3", NULL, SND_SOC_NOPM, 2, 0, 3714d5add08fSSrinivas Kandagatla wcd938x_codec_enable_dmic, 3715d5add08fSSrinivas Kandagatla SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD), 3716d5add08fSSrinivas Kandagatla SND_SOC_DAPM_ADC_E("DMIC4", NULL, SND_SOC_NOPM, 3, 0, 3717d5add08fSSrinivas Kandagatla wcd938x_codec_enable_dmic, 3718d5add08fSSrinivas Kandagatla SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD), 3719d5add08fSSrinivas Kandagatla SND_SOC_DAPM_ADC_E("DMIC5", NULL, SND_SOC_NOPM, 4, 0, 3720d5add08fSSrinivas Kandagatla wcd938x_codec_enable_dmic, 3721d5add08fSSrinivas Kandagatla SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD), 3722d5add08fSSrinivas Kandagatla SND_SOC_DAPM_ADC_E("DMIC6", NULL, SND_SOC_NOPM, 5, 0, 3723d5add08fSSrinivas Kandagatla wcd938x_codec_enable_dmic, 3724d5add08fSSrinivas Kandagatla SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD), 3725d5add08fSSrinivas Kandagatla SND_SOC_DAPM_ADC_E("DMIC7", NULL, SND_SOC_NOPM, 6, 0, 3726d5add08fSSrinivas Kandagatla wcd938x_codec_enable_dmic, 3727d5add08fSSrinivas Kandagatla SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD), 3728d5add08fSSrinivas Kandagatla SND_SOC_DAPM_ADC_E("DMIC8", NULL, SND_SOC_NOPM, 7, 0, 3729d5add08fSSrinivas Kandagatla wcd938x_codec_enable_dmic, 3730d5add08fSSrinivas Kandagatla SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD), 3731d5add08fSSrinivas Kandagatla 3732d5add08fSSrinivas Kandagatla SND_SOC_DAPM_MIXER_E("ADC1 REQ", SND_SOC_NOPM, 0, 0, 3733d5add08fSSrinivas Kandagatla NULL, 0, wcd938x_adc_enable_req, 3734d5add08fSSrinivas Kandagatla SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD), 3735d5add08fSSrinivas Kandagatla SND_SOC_DAPM_MIXER_E("ADC2 REQ", SND_SOC_NOPM, 1, 0, 3736d5add08fSSrinivas Kandagatla NULL, 0, wcd938x_adc_enable_req, 3737d5add08fSSrinivas Kandagatla SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD), 3738d5add08fSSrinivas Kandagatla SND_SOC_DAPM_MIXER_E("ADC3 REQ", SND_SOC_NOPM, 2, 0, 3739d5add08fSSrinivas Kandagatla NULL, 0, wcd938x_adc_enable_req, 3740d5add08fSSrinivas Kandagatla SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD), 3741d5add08fSSrinivas Kandagatla SND_SOC_DAPM_MIXER_E("ADC4 REQ", SND_SOC_NOPM, 3, 0, NULL, 0, 3742d5add08fSSrinivas Kandagatla wcd938x_adc_enable_req, 3743d5add08fSSrinivas Kandagatla SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD), 3744d5add08fSSrinivas Kandagatla 3745d5add08fSSrinivas Kandagatla SND_SOC_DAPM_MUX("ADC2 MUX", SND_SOC_NOPM, 0, 0, &tx_adc2_mux), 3746d5add08fSSrinivas Kandagatla SND_SOC_DAPM_MUX("ADC3 MUX", SND_SOC_NOPM, 0, 0, &tx_adc3_mux), 3747d5add08fSSrinivas Kandagatla SND_SOC_DAPM_MUX("ADC4 MUX", SND_SOC_NOPM, 0, 0, &tx_adc4_mux), 3748d5add08fSSrinivas Kandagatla SND_SOC_DAPM_MUX("HDR12 MUX", SND_SOC_NOPM, 0, 0, &tx_hdr12_mux), 3749d5add08fSSrinivas Kandagatla SND_SOC_DAPM_MUX("HDR34 MUX", SND_SOC_NOPM, 0, 0, &tx_hdr34_mux), 3750d5add08fSSrinivas Kandagatla 3751d5add08fSSrinivas Kandagatla /*tx mixers*/ 3752d5add08fSSrinivas Kandagatla SND_SOC_DAPM_MIXER_E("ADC1_MIXER", SND_SOC_NOPM, 0, 0, adc1_switch, 3753d5add08fSSrinivas Kandagatla ARRAY_SIZE(adc1_switch), wcd938x_tx_swr_ctrl, 3754d5add08fSSrinivas Kandagatla SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD), 3755d5add08fSSrinivas Kandagatla SND_SOC_DAPM_MIXER_E("ADC2_MIXER", SND_SOC_NOPM, 0, 0, adc2_switch, 3756d5add08fSSrinivas Kandagatla ARRAY_SIZE(adc2_switch), wcd938x_tx_swr_ctrl, 3757d5add08fSSrinivas Kandagatla SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD), 3758d5add08fSSrinivas Kandagatla SND_SOC_DAPM_MIXER_E("ADC3_MIXER", SND_SOC_NOPM, 0, 0, adc3_switch, 3759d5add08fSSrinivas Kandagatla ARRAY_SIZE(adc3_switch), wcd938x_tx_swr_ctrl, 3760d5add08fSSrinivas Kandagatla SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD), 3761d5add08fSSrinivas Kandagatla SND_SOC_DAPM_MIXER_E("ADC4_MIXER", SND_SOC_NOPM, 0, 0, adc4_switch, 3762d5add08fSSrinivas Kandagatla ARRAY_SIZE(adc4_switch), wcd938x_tx_swr_ctrl, 3763d5add08fSSrinivas Kandagatla SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD), 3764d5add08fSSrinivas Kandagatla SND_SOC_DAPM_MIXER_E("DMIC1_MIXER", SND_SOC_NOPM, 0, 0, dmic1_switch, 3765d5add08fSSrinivas Kandagatla ARRAY_SIZE(dmic1_switch), wcd938x_tx_swr_ctrl, 3766d5add08fSSrinivas Kandagatla SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD), 3767d5add08fSSrinivas Kandagatla SND_SOC_DAPM_MIXER_E("DMIC2_MIXER", SND_SOC_NOPM, 0, 0, dmic2_switch, 3768d5add08fSSrinivas Kandagatla ARRAY_SIZE(dmic2_switch), wcd938x_tx_swr_ctrl, 3769d5add08fSSrinivas Kandagatla SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD), 3770d5add08fSSrinivas Kandagatla SND_SOC_DAPM_MIXER_E("DMIC3_MIXER", SND_SOC_NOPM, 0, 0, dmic3_switch, 3771d5add08fSSrinivas Kandagatla ARRAY_SIZE(dmic3_switch), wcd938x_tx_swr_ctrl, 3772d5add08fSSrinivas Kandagatla SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD), 3773d5add08fSSrinivas Kandagatla SND_SOC_DAPM_MIXER_E("DMIC4_MIXER", SND_SOC_NOPM, 0, 0, dmic4_switch, 3774d5add08fSSrinivas Kandagatla ARRAY_SIZE(dmic4_switch), wcd938x_tx_swr_ctrl, 3775d5add08fSSrinivas Kandagatla SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD), 3776d5add08fSSrinivas Kandagatla SND_SOC_DAPM_MIXER_E("DMIC5_MIXER", SND_SOC_NOPM, 0, 0, dmic5_switch, 3777d5add08fSSrinivas Kandagatla ARRAY_SIZE(dmic5_switch), wcd938x_tx_swr_ctrl, 3778d5add08fSSrinivas Kandagatla SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD), 3779d5add08fSSrinivas Kandagatla SND_SOC_DAPM_MIXER_E("DMIC6_MIXER", SND_SOC_NOPM, 0, 0, dmic6_switch, 3780d5add08fSSrinivas Kandagatla ARRAY_SIZE(dmic6_switch), wcd938x_tx_swr_ctrl, 3781d5add08fSSrinivas Kandagatla SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD), 3782d5add08fSSrinivas Kandagatla SND_SOC_DAPM_MIXER_E("DMIC7_MIXER", SND_SOC_NOPM, 0, 0, dmic7_switch, 3783d5add08fSSrinivas Kandagatla ARRAY_SIZE(dmic7_switch), wcd938x_tx_swr_ctrl, 3784d5add08fSSrinivas Kandagatla SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD), 3785d5add08fSSrinivas Kandagatla SND_SOC_DAPM_MIXER_E("DMIC8_MIXER", SND_SOC_NOPM, 0, 0, dmic8_switch, 3786d5add08fSSrinivas Kandagatla ARRAY_SIZE(dmic8_switch), wcd938x_tx_swr_ctrl, 3787d5add08fSSrinivas Kandagatla SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD), 3788d5add08fSSrinivas Kandagatla /* micbias widgets*/ 3789d5add08fSSrinivas Kandagatla SND_SOC_DAPM_SUPPLY("MIC BIAS1", SND_SOC_NOPM, MIC_BIAS_1, 0, 3790d5add08fSSrinivas Kandagatla wcd938x_codec_enable_micbias, 3791d5add08fSSrinivas Kandagatla SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU | 3792d5add08fSSrinivas Kandagatla SND_SOC_DAPM_POST_PMD), 3793d5add08fSSrinivas Kandagatla SND_SOC_DAPM_SUPPLY("MIC BIAS2", SND_SOC_NOPM, MIC_BIAS_2, 0, 3794d5add08fSSrinivas Kandagatla wcd938x_codec_enable_micbias, 3795d5add08fSSrinivas Kandagatla SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU | 3796d5add08fSSrinivas Kandagatla SND_SOC_DAPM_POST_PMD), 3797d5add08fSSrinivas Kandagatla SND_SOC_DAPM_SUPPLY("MIC BIAS3", SND_SOC_NOPM, MIC_BIAS_3, 0, 3798d5add08fSSrinivas Kandagatla wcd938x_codec_enable_micbias, 3799d5add08fSSrinivas Kandagatla SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU | 3800d5add08fSSrinivas Kandagatla SND_SOC_DAPM_POST_PMD), 3801d5add08fSSrinivas Kandagatla SND_SOC_DAPM_SUPPLY("MIC BIAS4", SND_SOC_NOPM, MIC_BIAS_4, 0, 3802d5add08fSSrinivas Kandagatla wcd938x_codec_enable_micbias, 3803d5add08fSSrinivas Kandagatla SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU | 3804d5add08fSSrinivas Kandagatla SND_SOC_DAPM_POST_PMD), 3805d5add08fSSrinivas Kandagatla 3806d5add08fSSrinivas Kandagatla /* micbias pull up widgets*/ 3807d5add08fSSrinivas Kandagatla SND_SOC_DAPM_SUPPLY("VA MIC BIAS1", SND_SOC_NOPM, MIC_BIAS_1, 0, 3808d5add08fSSrinivas Kandagatla wcd938x_codec_enable_micbias_pullup, 3809d5add08fSSrinivas Kandagatla SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU | 3810d5add08fSSrinivas Kandagatla SND_SOC_DAPM_POST_PMD), 3811d5add08fSSrinivas Kandagatla SND_SOC_DAPM_SUPPLY("VA MIC BIAS2", SND_SOC_NOPM, MIC_BIAS_2, 0, 3812d5add08fSSrinivas Kandagatla wcd938x_codec_enable_micbias_pullup, 3813d5add08fSSrinivas Kandagatla SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU | 3814d5add08fSSrinivas Kandagatla SND_SOC_DAPM_POST_PMD), 3815d5add08fSSrinivas Kandagatla SND_SOC_DAPM_SUPPLY("VA MIC BIAS3", SND_SOC_NOPM, MIC_BIAS_3, 0, 3816d5add08fSSrinivas Kandagatla wcd938x_codec_enable_micbias_pullup, 3817d5add08fSSrinivas Kandagatla SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU | 3818d5add08fSSrinivas Kandagatla SND_SOC_DAPM_POST_PMD), 3819d5add08fSSrinivas Kandagatla SND_SOC_DAPM_SUPPLY("VA MIC BIAS4", SND_SOC_NOPM, MIC_BIAS_4, 0, 3820d5add08fSSrinivas Kandagatla wcd938x_codec_enable_micbias_pullup, 3821d5add08fSSrinivas Kandagatla SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU | 3822d5add08fSSrinivas Kandagatla SND_SOC_DAPM_POST_PMD), 3823d5add08fSSrinivas Kandagatla 3824d5add08fSSrinivas Kandagatla /*output widgets tx*/ 3825d5add08fSSrinivas Kandagatla SND_SOC_DAPM_OUTPUT("ADC1_OUTPUT"), 3826d5add08fSSrinivas Kandagatla SND_SOC_DAPM_OUTPUT("ADC2_OUTPUT"), 3827d5add08fSSrinivas Kandagatla SND_SOC_DAPM_OUTPUT("ADC3_OUTPUT"), 3828d5add08fSSrinivas Kandagatla SND_SOC_DAPM_OUTPUT("ADC4_OUTPUT"), 3829d5add08fSSrinivas Kandagatla SND_SOC_DAPM_OUTPUT("DMIC1_OUTPUT"), 3830d5add08fSSrinivas Kandagatla SND_SOC_DAPM_OUTPUT("DMIC2_OUTPUT"), 3831d5add08fSSrinivas Kandagatla SND_SOC_DAPM_OUTPUT("DMIC3_OUTPUT"), 3832d5add08fSSrinivas Kandagatla SND_SOC_DAPM_OUTPUT("DMIC4_OUTPUT"), 3833d5add08fSSrinivas Kandagatla SND_SOC_DAPM_OUTPUT("DMIC5_OUTPUT"), 3834d5add08fSSrinivas Kandagatla SND_SOC_DAPM_OUTPUT("DMIC6_OUTPUT"), 3835d5add08fSSrinivas Kandagatla SND_SOC_DAPM_OUTPUT("DMIC7_OUTPUT"), 3836d5add08fSSrinivas Kandagatla SND_SOC_DAPM_OUTPUT("DMIC8_OUTPUT"), 3837d5add08fSSrinivas Kandagatla 38388da9db0cSSrinivas Kandagatla SND_SOC_DAPM_INPUT("IN1_HPHL"), 38398da9db0cSSrinivas Kandagatla SND_SOC_DAPM_INPUT("IN2_HPHR"), 38408da9db0cSSrinivas Kandagatla SND_SOC_DAPM_INPUT("IN3_AUX"), 38418da9db0cSSrinivas Kandagatla 38428da9db0cSSrinivas Kandagatla /*rx widgets*/ 38438da9db0cSSrinivas Kandagatla SND_SOC_DAPM_PGA_E("EAR PGA", WCD938X_ANA_EAR, 7, 0, NULL, 0, 38448da9db0cSSrinivas Kandagatla wcd938x_codec_enable_ear_pa, 38458da9db0cSSrinivas Kandagatla SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU | 38468da9db0cSSrinivas Kandagatla SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD), 38478da9db0cSSrinivas Kandagatla SND_SOC_DAPM_PGA_E("AUX PGA", WCD938X_AUX_AUXPA, 7, 0, NULL, 0, 38488da9db0cSSrinivas Kandagatla wcd938x_codec_enable_aux_pa, 38498da9db0cSSrinivas Kandagatla SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU | 38508da9db0cSSrinivas Kandagatla SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD), 38518da9db0cSSrinivas Kandagatla SND_SOC_DAPM_PGA_E("HPHL PGA", WCD938X_ANA_HPH, 7, 0, NULL, 0, 38528da9db0cSSrinivas Kandagatla wcd938x_codec_enable_hphl_pa, 38538da9db0cSSrinivas Kandagatla SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU | 38548da9db0cSSrinivas Kandagatla SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD), 38558da9db0cSSrinivas Kandagatla SND_SOC_DAPM_PGA_E("HPHR PGA", WCD938X_ANA_HPH, 6, 0, NULL, 0, 38568da9db0cSSrinivas Kandagatla wcd938x_codec_enable_hphr_pa, 38578da9db0cSSrinivas Kandagatla SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU | 38588da9db0cSSrinivas Kandagatla SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD), 38598da9db0cSSrinivas Kandagatla 38608da9db0cSSrinivas Kandagatla SND_SOC_DAPM_DAC_E("RDAC1", NULL, SND_SOC_NOPM, 0, 0, 38618da9db0cSSrinivas Kandagatla wcd938x_codec_hphl_dac_event, 38628da9db0cSSrinivas Kandagatla SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU | 38638da9db0cSSrinivas Kandagatla SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD), 38648da9db0cSSrinivas Kandagatla SND_SOC_DAPM_DAC_E("RDAC2", NULL, SND_SOC_NOPM, 0, 0, 38658da9db0cSSrinivas Kandagatla wcd938x_codec_hphr_dac_event, 38668da9db0cSSrinivas Kandagatla SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU | 38678da9db0cSSrinivas Kandagatla SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD), 38688da9db0cSSrinivas Kandagatla SND_SOC_DAPM_DAC_E("RDAC3", NULL, SND_SOC_NOPM, 0, 0, 38698da9db0cSSrinivas Kandagatla wcd938x_codec_ear_dac_event, 38708da9db0cSSrinivas Kandagatla SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU | 38718da9db0cSSrinivas Kandagatla SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD), 38728da9db0cSSrinivas Kandagatla SND_SOC_DAPM_DAC_E("RDAC4", NULL, SND_SOC_NOPM, 0, 0, 38738da9db0cSSrinivas Kandagatla wcd938x_codec_aux_dac_event, 38748da9db0cSSrinivas Kandagatla SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU | 38758da9db0cSSrinivas Kandagatla SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD), 38768da9db0cSSrinivas Kandagatla 38778da9db0cSSrinivas Kandagatla SND_SOC_DAPM_MUX("RDAC3_MUX", SND_SOC_NOPM, 0, 0, &rx_rdac3_mux), 38788da9db0cSSrinivas Kandagatla 38798da9db0cSSrinivas Kandagatla SND_SOC_DAPM_SUPPLY("VDD_BUCK", SND_SOC_NOPM, 0, 0, NULL, 0), 38808da9db0cSSrinivas Kandagatla SND_SOC_DAPM_SUPPLY("RXCLK", SND_SOC_NOPM, 0, 0, 38818da9db0cSSrinivas Kandagatla wcd938x_codec_enable_rxclk, 38828da9db0cSSrinivas Kandagatla SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU | 38838da9db0cSSrinivas Kandagatla SND_SOC_DAPM_POST_PMD), 38848da9db0cSSrinivas Kandagatla 38858da9db0cSSrinivas Kandagatla SND_SOC_DAPM_SUPPLY_S("CLS_H_PORT", 1, SND_SOC_NOPM, 0, 0, NULL, 0), 38868da9db0cSSrinivas Kandagatla 38878da9db0cSSrinivas Kandagatla SND_SOC_DAPM_MIXER_E("RX1", SND_SOC_NOPM, 0, 0, NULL, 0, NULL, 0), 38888da9db0cSSrinivas Kandagatla SND_SOC_DAPM_MIXER_E("RX2", SND_SOC_NOPM, 0, 0, NULL, 0, NULL, 0), 38898da9db0cSSrinivas Kandagatla SND_SOC_DAPM_MIXER_E("RX3", SND_SOC_NOPM, 0, 0, NULL, 0, NULL, 0), 38908da9db0cSSrinivas Kandagatla 38918da9db0cSSrinivas Kandagatla /* rx mixer widgets*/ 38928da9db0cSSrinivas Kandagatla SND_SOC_DAPM_MIXER("EAR_RDAC", SND_SOC_NOPM, 0, 0, 38938da9db0cSSrinivas Kandagatla ear_rdac_switch, ARRAY_SIZE(ear_rdac_switch)), 38948da9db0cSSrinivas Kandagatla SND_SOC_DAPM_MIXER("AUX_RDAC", SND_SOC_NOPM, 0, 0, 38958da9db0cSSrinivas Kandagatla aux_rdac_switch, ARRAY_SIZE(aux_rdac_switch)), 38968da9db0cSSrinivas Kandagatla SND_SOC_DAPM_MIXER("HPHL_RDAC", SND_SOC_NOPM, 0, 0, 38978da9db0cSSrinivas Kandagatla hphl_rdac_switch, ARRAY_SIZE(hphl_rdac_switch)), 38988da9db0cSSrinivas Kandagatla SND_SOC_DAPM_MIXER("HPHR_RDAC", SND_SOC_NOPM, 0, 0, 38998da9db0cSSrinivas Kandagatla hphr_rdac_switch, ARRAY_SIZE(hphr_rdac_switch)), 39008da9db0cSSrinivas Kandagatla 39018da9db0cSSrinivas Kandagatla /*output widgets rx*/ 39028da9db0cSSrinivas Kandagatla SND_SOC_DAPM_OUTPUT("EAR"), 39038da9db0cSSrinivas Kandagatla SND_SOC_DAPM_OUTPUT("AUX"), 39048da9db0cSSrinivas Kandagatla SND_SOC_DAPM_OUTPUT("HPHL"), 39058da9db0cSSrinivas Kandagatla SND_SOC_DAPM_OUTPUT("HPHR"), 390604544222SSrinivas Kandagatla 390704544222SSrinivas Kandagatla }; 390804544222SSrinivas Kandagatla 390904544222SSrinivas Kandagatla static const struct snd_soc_dapm_route wcd938x_audio_map[] = { 391004544222SSrinivas Kandagatla {"ADC1_OUTPUT", NULL, "ADC1_MIXER"}, 391104544222SSrinivas Kandagatla {"ADC1_MIXER", "Switch", "ADC1 REQ"}, 391204544222SSrinivas Kandagatla {"ADC1 REQ", NULL, "ADC1"}, 391304544222SSrinivas Kandagatla {"ADC1", NULL, "AMIC1"}, 391404544222SSrinivas Kandagatla 391504544222SSrinivas Kandagatla {"ADC2_OUTPUT", NULL, "ADC2_MIXER"}, 391604544222SSrinivas Kandagatla {"ADC2_MIXER", "Switch", "ADC2 REQ"}, 391704544222SSrinivas Kandagatla {"ADC2 REQ", NULL, "ADC2"}, 391804544222SSrinivas Kandagatla {"ADC2", NULL, "HDR12 MUX"}, 391904544222SSrinivas Kandagatla {"HDR12 MUX", "NO_HDR12", "ADC2 MUX"}, 392004544222SSrinivas Kandagatla {"HDR12 MUX", "HDR12", "AMIC1"}, 392104544222SSrinivas Kandagatla {"ADC2 MUX", "INP3", "AMIC3"}, 392204544222SSrinivas Kandagatla {"ADC2 MUX", "INP2", "AMIC2"}, 392304544222SSrinivas Kandagatla 392404544222SSrinivas Kandagatla {"ADC3_OUTPUT", NULL, "ADC3_MIXER"}, 392504544222SSrinivas Kandagatla {"ADC3_MIXER", "Switch", "ADC3 REQ"}, 392604544222SSrinivas Kandagatla {"ADC3 REQ", NULL, "ADC3"}, 392704544222SSrinivas Kandagatla {"ADC3", NULL, "HDR34 MUX"}, 392804544222SSrinivas Kandagatla {"HDR34 MUX", "NO_HDR34", "ADC3 MUX"}, 392904544222SSrinivas Kandagatla {"HDR34 MUX", "HDR34", "AMIC5"}, 393004544222SSrinivas Kandagatla {"ADC3 MUX", "INP4", "AMIC4"}, 393104544222SSrinivas Kandagatla {"ADC3 MUX", "INP6", "AMIC6"}, 393204544222SSrinivas Kandagatla 393304544222SSrinivas Kandagatla {"ADC4_OUTPUT", NULL, "ADC4_MIXER"}, 393404544222SSrinivas Kandagatla {"ADC4_MIXER", "Switch", "ADC4 REQ"}, 393504544222SSrinivas Kandagatla {"ADC4 REQ", NULL, "ADC4"}, 393604544222SSrinivas Kandagatla {"ADC4", NULL, "ADC4 MUX"}, 393704544222SSrinivas Kandagatla {"ADC4 MUX", "INP5", "AMIC5"}, 393804544222SSrinivas Kandagatla {"ADC4 MUX", "INP7", "AMIC7"}, 393904544222SSrinivas Kandagatla 394004544222SSrinivas Kandagatla {"DMIC1_OUTPUT", NULL, "DMIC1_MIXER"}, 394104544222SSrinivas Kandagatla {"DMIC1_MIXER", "Switch", "DMIC1"}, 394204544222SSrinivas Kandagatla 394304544222SSrinivas Kandagatla {"DMIC2_OUTPUT", NULL, "DMIC2_MIXER"}, 394404544222SSrinivas Kandagatla {"DMIC2_MIXER", "Switch", "DMIC2"}, 394504544222SSrinivas Kandagatla 394604544222SSrinivas Kandagatla {"DMIC3_OUTPUT", NULL, "DMIC3_MIXER"}, 394704544222SSrinivas Kandagatla {"DMIC3_MIXER", "Switch", "DMIC3"}, 394804544222SSrinivas Kandagatla 394904544222SSrinivas Kandagatla {"DMIC4_OUTPUT", NULL, "DMIC4_MIXER"}, 395004544222SSrinivas Kandagatla {"DMIC4_MIXER", "Switch", "DMIC4"}, 395104544222SSrinivas Kandagatla 395204544222SSrinivas Kandagatla {"DMIC5_OUTPUT", NULL, "DMIC5_MIXER"}, 395304544222SSrinivas Kandagatla {"DMIC5_MIXER", "Switch", "DMIC5"}, 395404544222SSrinivas Kandagatla 395504544222SSrinivas Kandagatla {"DMIC6_OUTPUT", NULL, "DMIC6_MIXER"}, 395604544222SSrinivas Kandagatla {"DMIC6_MIXER", "Switch", "DMIC6"}, 395704544222SSrinivas Kandagatla 395804544222SSrinivas Kandagatla {"DMIC7_OUTPUT", NULL, "DMIC7_MIXER"}, 395904544222SSrinivas Kandagatla {"DMIC7_MIXER", "Switch", "DMIC7"}, 396004544222SSrinivas Kandagatla 396104544222SSrinivas Kandagatla {"DMIC8_OUTPUT", NULL, "DMIC8_MIXER"}, 396204544222SSrinivas Kandagatla {"DMIC8_MIXER", "Switch", "DMIC8"}, 396304544222SSrinivas Kandagatla 396404544222SSrinivas Kandagatla {"IN1_HPHL", NULL, "VDD_BUCK"}, 396504544222SSrinivas Kandagatla {"IN1_HPHL", NULL, "CLS_H_PORT"}, 396604544222SSrinivas Kandagatla 396704544222SSrinivas Kandagatla {"RX1", NULL, "IN1_HPHL"}, 396804544222SSrinivas Kandagatla {"RX1", NULL, "RXCLK"}, 396904544222SSrinivas Kandagatla {"RDAC1", NULL, "RX1"}, 397004544222SSrinivas Kandagatla {"HPHL_RDAC", "Switch", "RDAC1"}, 397104544222SSrinivas Kandagatla {"HPHL PGA", NULL, "HPHL_RDAC"}, 397204544222SSrinivas Kandagatla {"HPHL", NULL, "HPHL PGA"}, 397304544222SSrinivas Kandagatla 397404544222SSrinivas Kandagatla {"IN2_HPHR", NULL, "VDD_BUCK"}, 397504544222SSrinivas Kandagatla {"IN2_HPHR", NULL, "CLS_H_PORT"}, 397604544222SSrinivas Kandagatla {"RX2", NULL, "IN2_HPHR"}, 397704544222SSrinivas Kandagatla {"RDAC2", NULL, "RX2"}, 397804544222SSrinivas Kandagatla {"RX2", NULL, "RXCLK"}, 397904544222SSrinivas Kandagatla {"HPHR_RDAC", "Switch", "RDAC2"}, 398004544222SSrinivas Kandagatla {"HPHR PGA", NULL, "HPHR_RDAC"}, 398104544222SSrinivas Kandagatla {"HPHR", NULL, "HPHR PGA"}, 398204544222SSrinivas Kandagatla 398304544222SSrinivas Kandagatla {"IN3_AUX", NULL, "VDD_BUCK"}, 398404544222SSrinivas Kandagatla {"IN3_AUX", NULL, "CLS_H_PORT"}, 398504544222SSrinivas Kandagatla {"RX3", NULL, "IN3_AUX"}, 398604544222SSrinivas Kandagatla {"RDAC4", NULL, "RX3"}, 398704544222SSrinivas Kandagatla {"RX3", NULL, "RXCLK"}, 398804544222SSrinivas Kandagatla {"AUX_RDAC", "Switch", "RDAC4"}, 398904544222SSrinivas Kandagatla {"AUX PGA", NULL, "AUX_RDAC"}, 399004544222SSrinivas Kandagatla {"AUX", NULL, "AUX PGA"}, 399104544222SSrinivas Kandagatla 399204544222SSrinivas Kandagatla {"RDAC3_MUX", "RX3", "RX3"}, 399304544222SSrinivas Kandagatla {"RDAC3_MUX", "RX1", "RX1"}, 399404544222SSrinivas Kandagatla {"RDAC3", NULL, "RDAC3_MUX"}, 399504544222SSrinivas Kandagatla {"EAR_RDAC", "Switch", "RDAC3"}, 399604544222SSrinivas Kandagatla {"EAR PGA", NULL, "EAR_RDAC"}, 399704544222SSrinivas Kandagatla {"EAR", NULL, "EAR PGA"}, 39988da9db0cSSrinivas Kandagatla }; 39998da9db0cSSrinivas Kandagatla 40008d78602aSSrinivas Kandagatla static int wcd938x_set_micbias_data(struct wcd938x_priv *wcd938x) 40018d78602aSSrinivas Kandagatla { 40028d78602aSSrinivas Kandagatla int vout_ctl_1, vout_ctl_2, vout_ctl_3, vout_ctl_4; 40038d78602aSSrinivas Kandagatla 40048d78602aSSrinivas Kandagatla /* set micbias voltage */ 40058d78602aSSrinivas Kandagatla vout_ctl_1 = wcd938x_get_micb_vout_ctl_val(wcd938x->micb1_mv); 40068d78602aSSrinivas Kandagatla vout_ctl_2 = wcd938x_get_micb_vout_ctl_val(wcd938x->micb2_mv); 40078d78602aSSrinivas Kandagatla vout_ctl_3 = wcd938x_get_micb_vout_ctl_val(wcd938x->micb3_mv); 40088d78602aSSrinivas Kandagatla vout_ctl_4 = wcd938x_get_micb_vout_ctl_val(wcd938x->micb4_mv); 40098d78602aSSrinivas Kandagatla if (vout_ctl_1 < 0 || vout_ctl_2 < 0 || vout_ctl_3 < 0 || vout_ctl_4 < 0) 40108d78602aSSrinivas Kandagatla return -EINVAL; 40118d78602aSSrinivas Kandagatla 40128d78602aSSrinivas Kandagatla regmap_update_bits(wcd938x->regmap, WCD938X_ANA_MICB1, 40138d78602aSSrinivas Kandagatla WCD938X_MICB_VOUT_MASK, vout_ctl_1); 40148d78602aSSrinivas Kandagatla regmap_update_bits(wcd938x->regmap, WCD938X_ANA_MICB2, 40158d78602aSSrinivas Kandagatla WCD938X_MICB_VOUT_MASK, vout_ctl_2); 40168d78602aSSrinivas Kandagatla regmap_update_bits(wcd938x->regmap, WCD938X_ANA_MICB3, 40178d78602aSSrinivas Kandagatla WCD938X_MICB_VOUT_MASK, vout_ctl_3); 40188d78602aSSrinivas Kandagatla regmap_update_bits(wcd938x->regmap, WCD938X_ANA_MICB4, 40198d78602aSSrinivas Kandagatla WCD938X_MICB_VOUT_MASK, vout_ctl_4); 40208d78602aSSrinivas Kandagatla 40218d78602aSSrinivas Kandagatla return 0; 40228d78602aSSrinivas Kandagatla } 40238d78602aSSrinivas Kandagatla 40248d78602aSSrinivas Kandagatla static irqreturn_t wcd938x_wd_handle_irq(int irq, void *data) 40258d78602aSSrinivas Kandagatla { 40268d78602aSSrinivas Kandagatla return IRQ_HANDLED; 40278d78602aSSrinivas Kandagatla } 40288d78602aSSrinivas Kandagatla 40298d78602aSSrinivas Kandagatla static struct irq_chip wcd_irq_chip = { 40308d78602aSSrinivas Kandagatla .name = "WCD938x", 40318d78602aSSrinivas Kandagatla }; 40328d78602aSSrinivas Kandagatla 40338d78602aSSrinivas Kandagatla static int wcd_irq_chip_map(struct irq_domain *irqd, unsigned int virq, 40348d78602aSSrinivas Kandagatla irq_hw_number_t hw) 40358d78602aSSrinivas Kandagatla { 40368d78602aSSrinivas Kandagatla irq_set_chip_and_handler(virq, &wcd_irq_chip, handle_simple_irq); 40378d78602aSSrinivas Kandagatla irq_set_nested_thread(virq, 1); 40388d78602aSSrinivas Kandagatla irq_set_noprobe(virq); 40398d78602aSSrinivas Kandagatla 40408d78602aSSrinivas Kandagatla return 0; 40418d78602aSSrinivas Kandagatla } 40428d78602aSSrinivas Kandagatla 40438d78602aSSrinivas Kandagatla static const struct irq_domain_ops wcd_domain_ops = { 40448d78602aSSrinivas Kandagatla .map = wcd_irq_chip_map, 40458d78602aSSrinivas Kandagatla }; 40468d78602aSSrinivas Kandagatla 40478d78602aSSrinivas Kandagatla static int wcd938x_irq_init(struct wcd938x_priv *wcd, struct device *dev) 40488d78602aSSrinivas Kandagatla { 40498d78602aSSrinivas Kandagatla 40508d78602aSSrinivas Kandagatla wcd->virq = irq_domain_add_linear(NULL, 1, &wcd_domain_ops, NULL); 40518d78602aSSrinivas Kandagatla if (!(wcd->virq)) { 40528d78602aSSrinivas Kandagatla dev_err(dev, "%s: Failed to add IRQ domain\n", __func__); 40538d78602aSSrinivas Kandagatla return -EINVAL; 40548d78602aSSrinivas Kandagatla } 40558d78602aSSrinivas Kandagatla 40568d78602aSSrinivas Kandagatla return devm_regmap_add_irq_chip(dev, wcd->regmap, 40578d78602aSSrinivas Kandagatla irq_create_mapping(wcd->virq, 0), 40588d78602aSSrinivas Kandagatla IRQF_ONESHOT, 0, &wcd938x_regmap_irq_chip, 40598d78602aSSrinivas Kandagatla &wcd->irq_chip); 40608d78602aSSrinivas Kandagatla } 40618d78602aSSrinivas Kandagatla 40628d78602aSSrinivas Kandagatla static int wcd938x_soc_codec_probe(struct snd_soc_component *component) 40638d78602aSSrinivas Kandagatla { 40648d78602aSSrinivas Kandagatla struct wcd938x_priv *wcd938x = snd_soc_component_get_drvdata(component); 40658d78602aSSrinivas Kandagatla struct device *dev = component->dev; 40668d78602aSSrinivas Kandagatla int ret, i; 40678d78602aSSrinivas Kandagatla 40688d78602aSSrinivas Kandagatla snd_soc_component_init_regmap(component, wcd938x->regmap); 40698d78602aSSrinivas Kandagatla 40708d78602aSSrinivas Kandagatla wcd938x->variant = snd_soc_component_read_field(component, 40718d78602aSSrinivas Kandagatla WCD938X_DIGITAL_EFUSE_REG_0, 40728d78602aSSrinivas Kandagatla WCD938X_ID_MASK); 40738d78602aSSrinivas Kandagatla 40748d78602aSSrinivas Kandagatla wcd938x->clsh_info = wcd_clsh_ctrl_alloc(component, WCD938X); 40758d78602aSSrinivas Kandagatla 40768d78602aSSrinivas Kandagatla wcd938x_io_init(wcd938x); 40778d78602aSSrinivas Kandagatla /* Set all interrupts as edge triggered */ 40788d78602aSSrinivas Kandagatla for (i = 0; i < wcd938x_regmap_irq_chip.num_regs; i++) { 40798d78602aSSrinivas Kandagatla regmap_write(wcd938x->regmap, 40808d78602aSSrinivas Kandagatla (WCD938X_DIGITAL_INTR_LEVEL_0 + i), 0); 40818d78602aSSrinivas Kandagatla } 40828d78602aSSrinivas Kandagatla 40838d78602aSSrinivas Kandagatla wcd938x->hphr_pdm_wd_int = regmap_irq_get_virq(wcd938x->irq_chip, 40848d78602aSSrinivas Kandagatla WCD938X_IRQ_HPHR_PDM_WD_INT); 40858d78602aSSrinivas Kandagatla wcd938x->hphl_pdm_wd_int = regmap_irq_get_virq(wcd938x->irq_chip, 40868d78602aSSrinivas Kandagatla WCD938X_IRQ_HPHL_PDM_WD_INT); 40878d78602aSSrinivas Kandagatla wcd938x->aux_pdm_wd_int = regmap_irq_get_virq(wcd938x->irq_chip, 40888d78602aSSrinivas Kandagatla WCD938X_IRQ_AUX_PDM_WD_INT); 40898d78602aSSrinivas Kandagatla 40908d78602aSSrinivas Kandagatla /* Request for watchdog interrupt */ 40918d78602aSSrinivas Kandagatla ret = request_threaded_irq(wcd938x->hphr_pdm_wd_int, NULL, wcd938x_wd_handle_irq, 40928d78602aSSrinivas Kandagatla IRQF_ONESHOT | IRQF_TRIGGER_RISING, 40938d78602aSSrinivas Kandagatla "HPHR PDM WD INT", wcd938x); 40948d78602aSSrinivas Kandagatla if (ret) 40958d78602aSSrinivas Kandagatla dev_err(dev, "Failed to request HPHR WD interrupt (%d)\n", ret); 40968d78602aSSrinivas Kandagatla 40978d78602aSSrinivas Kandagatla ret = request_threaded_irq(wcd938x->hphl_pdm_wd_int, NULL, wcd938x_wd_handle_irq, 40988d78602aSSrinivas Kandagatla IRQF_ONESHOT | IRQF_TRIGGER_RISING, 40998d78602aSSrinivas Kandagatla "HPHL PDM WD INT", wcd938x); 41008d78602aSSrinivas Kandagatla if (ret) 41018d78602aSSrinivas Kandagatla dev_err(dev, "Failed to request HPHL WD interrupt (%d)\n", ret); 41028d78602aSSrinivas Kandagatla 41038d78602aSSrinivas Kandagatla ret = request_threaded_irq(wcd938x->aux_pdm_wd_int, NULL, wcd938x_wd_handle_irq, 41048d78602aSSrinivas Kandagatla IRQF_ONESHOT | IRQF_TRIGGER_RISING, 41058d78602aSSrinivas Kandagatla "AUX PDM WD INT", wcd938x); 41068d78602aSSrinivas Kandagatla if (ret) 41078d78602aSSrinivas Kandagatla dev_err(dev, "Failed to request Aux WD interrupt (%d)\n", ret); 41088d78602aSSrinivas Kandagatla 41098d78602aSSrinivas Kandagatla /* Disable watchdog interrupt for HPH and AUX */ 41108d78602aSSrinivas Kandagatla disable_irq_nosync(wcd938x->hphr_pdm_wd_int); 41118d78602aSSrinivas Kandagatla disable_irq_nosync(wcd938x->hphl_pdm_wd_int); 41128d78602aSSrinivas Kandagatla disable_irq_nosync(wcd938x->aux_pdm_wd_int); 41138d78602aSSrinivas Kandagatla 4114e8ba1e05SSrinivas Kandagatla switch (wcd938x->variant) { 4115e8ba1e05SSrinivas Kandagatla case WCD9380: 4116e8ba1e05SSrinivas Kandagatla ret = snd_soc_add_component_controls(component, wcd9380_snd_controls, 4117e8ba1e05SSrinivas Kandagatla ARRAY_SIZE(wcd9380_snd_controls)); 4118e8ba1e05SSrinivas Kandagatla if (ret < 0) { 4119e8ba1e05SSrinivas Kandagatla dev_err(component->dev, 4120e8ba1e05SSrinivas Kandagatla "%s: Failed to add snd ctrls for variant: %d\n", 4121e8ba1e05SSrinivas Kandagatla __func__, wcd938x->variant); 4122e8ba1e05SSrinivas Kandagatla goto err; 4123e8ba1e05SSrinivas Kandagatla } 4124e8ba1e05SSrinivas Kandagatla break; 4125e8ba1e05SSrinivas Kandagatla case WCD9385: 4126e8ba1e05SSrinivas Kandagatla ret = snd_soc_add_component_controls(component, wcd9385_snd_controls, 4127e8ba1e05SSrinivas Kandagatla ARRAY_SIZE(wcd9385_snd_controls)); 4128e8ba1e05SSrinivas Kandagatla if (ret < 0) { 4129e8ba1e05SSrinivas Kandagatla dev_err(component->dev, 4130e8ba1e05SSrinivas Kandagatla "%s: Failed to add snd ctrls for variant: %d\n", 4131e8ba1e05SSrinivas Kandagatla __func__, wcd938x->variant); 4132e8ba1e05SSrinivas Kandagatla goto err; 4133e8ba1e05SSrinivas Kandagatla } 4134e8ba1e05SSrinivas Kandagatla break; 4135e8ba1e05SSrinivas Kandagatla default: 4136e8ba1e05SSrinivas Kandagatla break; 4137e8ba1e05SSrinivas Kandagatla } 4138bcee7ed0SSrinivas Kandagatla 4139bcee7ed0SSrinivas Kandagatla ret = wcd938x_mbhc_init(component); 4140bcee7ed0SSrinivas Kandagatla if (ret) 4141bcee7ed0SSrinivas Kandagatla dev_err(component->dev, "mbhc initialization failed\n"); 4142e8ba1e05SSrinivas Kandagatla err: 41438d78602aSSrinivas Kandagatla return ret; 41448d78602aSSrinivas Kandagatla } 41458d78602aSSrinivas Kandagatla 4146bcee7ed0SSrinivas Kandagatla static int wcd938x_codec_set_jack(struct snd_soc_component *comp, 4147bcee7ed0SSrinivas Kandagatla struct snd_soc_jack *jack, void *data) 4148bcee7ed0SSrinivas Kandagatla { 4149bcee7ed0SSrinivas Kandagatla struct wcd938x_priv *wcd = dev_get_drvdata(comp->dev); 4150bcee7ed0SSrinivas Kandagatla 4151db0767b8SSrinivasa Rao Mandadapu if (jack) 4152bcee7ed0SSrinivas Kandagatla return wcd_mbhc_start(wcd->wcd_mbhc, &wcd->mbhc_cfg, jack); 4153db0767b8SSrinivasa Rao Mandadapu else 4154bcee7ed0SSrinivas Kandagatla wcd_mbhc_stop(wcd->wcd_mbhc); 4155bcee7ed0SSrinivas Kandagatla 4156bcee7ed0SSrinivas Kandagatla return 0; 4157bcee7ed0SSrinivas Kandagatla } 4158bcee7ed0SSrinivas Kandagatla 41598d78602aSSrinivas Kandagatla static const struct snd_soc_component_driver soc_codec_dev_wcd938x = { 41608d78602aSSrinivas Kandagatla .name = "wcd938x_codec", 41618d78602aSSrinivas Kandagatla .probe = wcd938x_soc_codec_probe, 4162e8ba1e05SSrinivas Kandagatla .controls = wcd938x_snd_controls, 4163e8ba1e05SSrinivas Kandagatla .num_controls = ARRAY_SIZE(wcd938x_snd_controls), 41648da9db0cSSrinivas Kandagatla .dapm_widgets = wcd938x_dapm_widgets, 41658da9db0cSSrinivas Kandagatla .num_dapm_widgets = ARRAY_SIZE(wcd938x_dapm_widgets), 416604544222SSrinivas Kandagatla .dapm_routes = wcd938x_audio_map, 416704544222SSrinivas Kandagatla .num_dapm_routes = ARRAY_SIZE(wcd938x_audio_map), 4168bcee7ed0SSrinivas Kandagatla .set_jack = wcd938x_codec_set_jack, 41698d78602aSSrinivas Kandagatla }; 41708d78602aSSrinivas Kandagatla 41718d78602aSSrinivas Kandagatla static void wcd938x_dt_parse_micbias_info(struct device *dev, struct wcd938x_priv *wcd) 41728d78602aSSrinivas Kandagatla { 41738d78602aSSrinivas Kandagatla struct device_node *np = dev->of_node; 41748d78602aSSrinivas Kandagatla u32 prop_val = 0; 41758d78602aSSrinivas Kandagatla int rc = 0; 41768d78602aSSrinivas Kandagatla 41778d78602aSSrinivas Kandagatla rc = of_property_read_u32(np, "qcom,micbias1-microvolt", &prop_val); 41788d78602aSSrinivas Kandagatla if (!rc) 41798d78602aSSrinivas Kandagatla wcd->micb1_mv = prop_val/1000; 41808d78602aSSrinivas Kandagatla else 41818d78602aSSrinivas Kandagatla dev_info(dev, "%s: Micbias1 DT property not found\n", __func__); 41828d78602aSSrinivas Kandagatla 41838d78602aSSrinivas Kandagatla rc = of_property_read_u32(np, "qcom,micbias2-microvolt", &prop_val); 41848d78602aSSrinivas Kandagatla if (!rc) 41858d78602aSSrinivas Kandagatla wcd->micb2_mv = prop_val/1000; 41868d78602aSSrinivas Kandagatla else 41878d78602aSSrinivas Kandagatla dev_info(dev, "%s: Micbias2 DT property not found\n", __func__); 41888d78602aSSrinivas Kandagatla 41898d78602aSSrinivas Kandagatla rc = of_property_read_u32(np, "qcom,micbias3-microvolt", &prop_val); 41908d78602aSSrinivas Kandagatla if (!rc) 41918d78602aSSrinivas Kandagatla wcd->micb3_mv = prop_val/1000; 41928d78602aSSrinivas Kandagatla else 41938d78602aSSrinivas Kandagatla dev_info(dev, "%s: Micbias3 DT property not found\n", __func__); 41948d78602aSSrinivas Kandagatla 41958d78602aSSrinivas Kandagatla rc = of_property_read_u32(np, "qcom,micbias4-microvolt", &prop_val); 41968d78602aSSrinivas Kandagatla if (!rc) 41978d78602aSSrinivas Kandagatla wcd->micb4_mv = prop_val/1000; 41988d78602aSSrinivas Kandagatla else 41998d78602aSSrinivas Kandagatla dev_info(dev, "%s: Micbias4 DT property not found\n", __func__); 42008d78602aSSrinivas Kandagatla } 42018d78602aSSrinivas Kandagatla 42028d78602aSSrinivas Kandagatla static int wcd938x_populate_dt_data(struct wcd938x_priv *wcd938x, struct device *dev) 42038d78602aSSrinivas Kandagatla { 4204bcee7ed0SSrinivas Kandagatla struct wcd_mbhc_config *cfg = &wcd938x->mbhc_cfg; 42058d78602aSSrinivas Kandagatla int ret; 42068d78602aSSrinivas Kandagatla 42078d78602aSSrinivas Kandagatla wcd938x->reset_gpio = of_get_named_gpio(dev->of_node, "reset-gpios", 0); 42088d78602aSSrinivas Kandagatla if (wcd938x->reset_gpio < 0) { 42098d78602aSSrinivas Kandagatla dev_err(dev, "Failed to get reset gpio: err = %d\n", 42108d78602aSSrinivas Kandagatla wcd938x->reset_gpio); 42118d78602aSSrinivas Kandagatla return wcd938x->reset_gpio; 42128d78602aSSrinivas Kandagatla } 42138d78602aSSrinivas Kandagatla 42148d78602aSSrinivas Kandagatla wcd938x->supplies[0].supply = "vdd-rxtx"; 42158d78602aSSrinivas Kandagatla wcd938x->supplies[1].supply = "vdd-io"; 42168d78602aSSrinivas Kandagatla wcd938x->supplies[2].supply = "vdd-buck"; 42178d78602aSSrinivas Kandagatla wcd938x->supplies[3].supply = "vdd-mic-bias"; 42188d78602aSSrinivas Kandagatla 42198d78602aSSrinivas Kandagatla ret = regulator_bulk_get(dev, WCD938X_MAX_SUPPLY, wcd938x->supplies); 42208d78602aSSrinivas Kandagatla if (ret) { 42218d78602aSSrinivas Kandagatla dev_err(dev, "Failed to get supplies: err = %d\n", ret); 42228d78602aSSrinivas Kandagatla return ret; 42238d78602aSSrinivas Kandagatla } 42248d78602aSSrinivas Kandagatla 42258d78602aSSrinivas Kandagatla ret = regulator_bulk_enable(WCD938X_MAX_SUPPLY, wcd938x->supplies); 42268d78602aSSrinivas Kandagatla if (ret) { 42278d78602aSSrinivas Kandagatla dev_err(dev, "Failed to enable supplies: err = %d\n", ret); 42288d78602aSSrinivas Kandagatla return ret; 42298d78602aSSrinivas Kandagatla } 42308d78602aSSrinivas Kandagatla 42318d78602aSSrinivas Kandagatla wcd938x_dt_parse_micbias_info(dev, wcd938x); 42328d78602aSSrinivas Kandagatla 4233bcee7ed0SSrinivas Kandagatla cfg->mbhc_micbias = MIC_BIAS_2; 4234bcee7ed0SSrinivas Kandagatla cfg->anc_micbias = MIC_BIAS_2; 4235bcee7ed0SSrinivas Kandagatla cfg->v_hs_max = WCD_MBHC_HS_V_MAX; 4236bcee7ed0SSrinivas Kandagatla cfg->num_btn = WCD938X_MBHC_MAX_BUTTONS; 4237bcee7ed0SSrinivas Kandagatla cfg->micb_mv = wcd938x->micb2_mv; 4238bcee7ed0SSrinivas Kandagatla cfg->linein_th = 5000; 4239bcee7ed0SSrinivas Kandagatla cfg->hs_thr = 1700; 4240bcee7ed0SSrinivas Kandagatla cfg->hph_thr = 50; 4241bcee7ed0SSrinivas Kandagatla 4242bcee7ed0SSrinivas Kandagatla wcd_dt_parse_mbhc_data(dev, cfg); 4243bcee7ed0SSrinivas Kandagatla 42448d78602aSSrinivas Kandagatla return 0; 42458d78602aSSrinivas Kandagatla } 42468d78602aSSrinivas Kandagatla 42478d78602aSSrinivas Kandagatla static int wcd938x_reset(struct wcd938x_priv *wcd938x) 42488d78602aSSrinivas Kandagatla { 42498d78602aSSrinivas Kandagatla gpio_direction_output(wcd938x->reset_gpio, 0); 42508d78602aSSrinivas Kandagatla /* 20us sleep required after pulling the reset gpio to LOW */ 42518d78602aSSrinivas Kandagatla usleep_range(20, 30); 42528d78602aSSrinivas Kandagatla gpio_set_value(wcd938x->reset_gpio, 1); 42538d78602aSSrinivas Kandagatla /* 20us sleep required after pulling the reset gpio to HIGH */ 42548d78602aSSrinivas Kandagatla usleep_range(20, 30); 42558d78602aSSrinivas Kandagatla 42568d78602aSSrinivas Kandagatla return 0; 42578d78602aSSrinivas Kandagatla } 42588d78602aSSrinivas Kandagatla 425916572522SSrinivas Kandagatla static int wcd938x_codec_hw_params(struct snd_pcm_substream *substream, 426016572522SSrinivas Kandagatla struct snd_pcm_hw_params *params, 426116572522SSrinivas Kandagatla struct snd_soc_dai *dai) 426216572522SSrinivas Kandagatla { 426316572522SSrinivas Kandagatla struct wcd938x_priv *wcd938x = dev_get_drvdata(dai->dev); 426416572522SSrinivas Kandagatla struct wcd938x_sdw_priv *wcd = wcd938x->sdw_priv[dai->id]; 426516572522SSrinivas Kandagatla 426616572522SSrinivas Kandagatla return wcd938x_sdw_hw_params(wcd, substream, params, dai); 426716572522SSrinivas Kandagatla } 426816572522SSrinivas Kandagatla 426916572522SSrinivas Kandagatla static int wcd938x_codec_free(struct snd_pcm_substream *substream, 427016572522SSrinivas Kandagatla struct snd_soc_dai *dai) 427116572522SSrinivas Kandagatla { 427216572522SSrinivas Kandagatla struct wcd938x_priv *wcd938x = dev_get_drvdata(dai->dev); 427316572522SSrinivas Kandagatla struct wcd938x_sdw_priv *wcd = wcd938x->sdw_priv[dai->id]; 427416572522SSrinivas Kandagatla 427516572522SSrinivas Kandagatla return wcd938x_sdw_free(wcd, substream, dai); 427616572522SSrinivas Kandagatla } 427716572522SSrinivas Kandagatla 427816572522SSrinivas Kandagatla static int wcd938x_codec_set_sdw_stream(struct snd_soc_dai *dai, 427916572522SSrinivas Kandagatla void *stream, int direction) 428016572522SSrinivas Kandagatla { 428116572522SSrinivas Kandagatla struct wcd938x_priv *wcd938x = dev_get_drvdata(dai->dev); 428216572522SSrinivas Kandagatla struct wcd938x_sdw_priv *wcd = wcd938x->sdw_priv[dai->id]; 428316572522SSrinivas Kandagatla 428416572522SSrinivas Kandagatla return wcd938x_sdw_set_sdw_stream(wcd, dai, stream, direction); 428516572522SSrinivas Kandagatla 428616572522SSrinivas Kandagatla } 428716572522SSrinivas Kandagatla 4288355af6c0SPu Lehui static const struct snd_soc_dai_ops wcd938x_sdw_dai_ops = { 428916572522SSrinivas Kandagatla .hw_params = wcd938x_codec_hw_params, 429016572522SSrinivas Kandagatla .hw_free = wcd938x_codec_free, 4291e8444560SPierre-Louis Bossart .set_stream = wcd938x_codec_set_sdw_stream, 42928d78602aSSrinivas Kandagatla }; 42938d78602aSSrinivas Kandagatla 42948d78602aSSrinivas Kandagatla static struct snd_soc_dai_driver wcd938x_dais[] = { 42958d78602aSSrinivas Kandagatla [0] = { 42968d78602aSSrinivas Kandagatla .name = "wcd938x-sdw-rx", 42978d78602aSSrinivas Kandagatla .playback = { 42988d78602aSSrinivas Kandagatla .stream_name = "WCD AIF1 Playback", 42998d78602aSSrinivas Kandagatla .rates = WCD938X_RATES_MASK | WCD938X_FRAC_RATES_MASK, 43008d78602aSSrinivas Kandagatla .formats = WCD938X_FORMATS_S16_S24_LE, 43018d78602aSSrinivas Kandagatla .rate_max = 192000, 43028d78602aSSrinivas Kandagatla .rate_min = 8000, 43038d78602aSSrinivas Kandagatla .channels_min = 1, 43048d78602aSSrinivas Kandagatla .channels_max = 2, 43058d78602aSSrinivas Kandagatla }, 43068d78602aSSrinivas Kandagatla .ops = &wcd938x_sdw_dai_ops, 43078d78602aSSrinivas Kandagatla }, 43088d78602aSSrinivas Kandagatla [1] = { 43098d78602aSSrinivas Kandagatla .name = "wcd938x-sdw-tx", 43108d78602aSSrinivas Kandagatla .capture = { 43118d78602aSSrinivas Kandagatla .stream_name = "WCD AIF1 Capture", 43128d78602aSSrinivas Kandagatla .rates = WCD938X_RATES_MASK, 43138d78602aSSrinivas Kandagatla .formats = SNDRV_PCM_FMTBIT_S16_LE, 43148d78602aSSrinivas Kandagatla .rate_min = 8000, 43158d78602aSSrinivas Kandagatla .rate_max = 192000, 43168d78602aSSrinivas Kandagatla .channels_min = 1, 43178d78602aSSrinivas Kandagatla .channels_max = 4, 43188d78602aSSrinivas Kandagatla }, 43198d78602aSSrinivas Kandagatla .ops = &wcd938x_sdw_dai_ops, 43208d78602aSSrinivas Kandagatla }, 43218d78602aSSrinivas Kandagatla }; 43228d78602aSSrinivas Kandagatla 43238d78602aSSrinivas Kandagatla static int wcd938x_bind(struct device *dev) 43248d78602aSSrinivas Kandagatla { 43258d78602aSSrinivas Kandagatla struct wcd938x_priv *wcd938x = dev_get_drvdata(dev); 43268d78602aSSrinivas Kandagatla int ret; 43278d78602aSSrinivas Kandagatla 43288d78602aSSrinivas Kandagatla ret = component_bind_all(dev, wcd938x); 43298d78602aSSrinivas Kandagatla if (ret) { 43308d78602aSSrinivas Kandagatla dev_err(dev, "%s: Slave bind failed, ret = %d\n", 43318d78602aSSrinivas Kandagatla __func__, ret); 43328d78602aSSrinivas Kandagatla return ret; 43338d78602aSSrinivas Kandagatla } 43348d78602aSSrinivas Kandagatla 433516572522SSrinivas Kandagatla wcd938x->rxdev = wcd938x_sdw_device_get(wcd938x->rxnode); 433616572522SSrinivas Kandagatla if (!wcd938x->rxdev) { 433716572522SSrinivas Kandagatla dev_err(dev, "could not find slave with matching of node\n"); 433816572522SSrinivas Kandagatla return -EINVAL; 433916572522SSrinivas Kandagatla } 434016572522SSrinivas Kandagatla wcd938x->sdw_priv[AIF1_PB] = dev_get_drvdata(wcd938x->rxdev); 434116572522SSrinivas Kandagatla wcd938x->sdw_priv[AIF1_PB]->wcd938x = wcd938x; 434216572522SSrinivas Kandagatla 434316572522SSrinivas Kandagatla wcd938x->txdev = wcd938x_sdw_device_get(wcd938x->txnode); 434416572522SSrinivas Kandagatla if (!wcd938x->txdev) { 434516572522SSrinivas Kandagatla dev_err(dev, "could not find txslave with matching of node\n"); 434616572522SSrinivas Kandagatla return -EINVAL; 434716572522SSrinivas Kandagatla } 434816572522SSrinivas Kandagatla wcd938x->sdw_priv[AIF1_CAP] = dev_get_drvdata(wcd938x->txdev); 434916572522SSrinivas Kandagatla wcd938x->sdw_priv[AIF1_CAP]->wcd938x = wcd938x; 435016572522SSrinivas Kandagatla wcd938x->tx_sdw_dev = dev_to_sdw_dev(wcd938x->txdev); 435116572522SSrinivas Kandagatla if (!wcd938x->tx_sdw_dev) { 435216572522SSrinivas Kandagatla dev_err(dev, "could not get txslave with matching of dev\n"); 435316572522SSrinivas Kandagatla return -EINVAL; 435416572522SSrinivas Kandagatla } 435516572522SSrinivas Kandagatla 435616572522SSrinivas Kandagatla /* As TX is main CSR reg interface, which should not be suspended first. 435716572522SSrinivas Kandagatla * expicilty add the dependency link */ 435816572522SSrinivas Kandagatla if (!device_link_add(wcd938x->rxdev, wcd938x->txdev, DL_FLAG_STATELESS | 435916572522SSrinivas Kandagatla DL_FLAG_PM_RUNTIME)) { 436016572522SSrinivas Kandagatla dev_err(dev, "could not devlink tx and rx\n"); 436116572522SSrinivas Kandagatla return -EINVAL; 436216572522SSrinivas Kandagatla } 436316572522SSrinivas Kandagatla 436416572522SSrinivas Kandagatla if (!device_link_add(dev, wcd938x->txdev, DL_FLAG_STATELESS | 436516572522SSrinivas Kandagatla DL_FLAG_PM_RUNTIME)) { 436616572522SSrinivas Kandagatla dev_err(dev, "could not devlink wcd and tx\n"); 436716572522SSrinivas Kandagatla return -EINVAL; 436816572522SSrinivas Kandagatla } 436916572522SSrinivas Kandagatla 437016572522SSrinivas Kandagatla if (!device_link_add(dev, wcd938x->rxdev, DL_FLAG_STATELESS | 437116572522SSrinivas Kandagatla DL_FLAG_PM_RUNTIME)) { 437216572522SSrinivas Kandagatla dev_err(dev, "could not devlink wcd and rx\n"); 437316572522SSrinivas Kandagatla return -EINVAL; 437416572522SSrinivas Kandagatla } 437516572522SSrinivas Kandagatla 4376b90d9398SSrinivas Kandagatla wcd938x->regmap = devm_regmap_init_sdw(wcd938x->tx_sdw_dev, &wcd938x_regmap_config); 4377b90d9398SSrinivas Kandagatla if (IS_ERR(wcd938x->regmap)) { 437816572522SSrinivas Kandagatla dev_err(dev, "%s: tx csr regmap not found\n", __func__); 437916572522SSrinivas Kandagatla return PTR_ERR(wcd938x->regmap); 438016572522SSrinivas Kandagatla } 438116572522SSrinivas Kandagatla 4382f99986c0SSrinivas Kandagatla ret = wcd938x_irq_init(wcd938x, dev); 4383f99986c0SSrinivas Kandagatla if (ret) { 4384f99986c0SSrinivas Kandagatla dev_err(dev, "%s: IRQ init failed: %d\n", __func__, ret); 4385f99986c0SSrinivas Kandagatla return ret; 4386f99986c0SSrinivas Kandagatla } 4387f99986c0SSrinivas Kandagatla 4388f99986c0SSrinivas Kandagatla wcd938x->sdw_priv[AIF1_PB]->slave_irq = wcd938x->virq; 4389f99986c0SSrinivas Kandagatla wcd938x->sdw_priv[AIF1_CAP]->slave_irq = wcd938x->virq; 4390f99986c0SSrinivas Kandagatla 43918d78602aSSrinivas Kandagatla ret = wcd938x_set_micbias_data(wcd938x); 43928d78602aSSrinivas Kandagatla if (ret < 0) { 43938d78602aSSrinivas Kandagatla dev_err(dev, "%s: bad micbias pdata\n", __func__); 43948d78602aSSrinivas Kandagatla return ret; 43958d78602aSSrinivas Kandagatla } 43968d78602aSSrinivas Kandagatla 43978d78602aSSrinivas Kandagatla ret = snd_soc_register_component(dev, &soc_codec_dev_wcd938x, 43988d78602aSSrinivas Kandagatla wcd938x_dais, ARRAY_SIZE(wcd938x_dais)); 43998d78602aSSrinivas Kandagatla if (ret) 44008d78602aSSrinivas Kandagatla dev_err(dev, "%s: Codec registration failed\n", 44018d78602aSSrinivas Kandagatla __func__); 44028d78602aSSrinivas Kandagatla 44038d78602aSSrinivas Kandagatla return ret; 44048d78602aSSrinivas Kandagatla 44058d78602aSSrinivas Kandagatla } 44068d78602aSSrinivas Kandagatla 44078d78602aSSrinivas Kandagatla static void wcd938x_unbind(struct device *dev) 44088d78602aSSrinivas Kandagatla { 44098d78602aSSrinivas Kandagatla struct wcd938x_priv *wcd938x = dev_get_drvdata(dev); 44108d78602aSSrinivas Kandagatla 441116572522SSrinivas Kandagatla device_link_remove(dev, wcd938x->txdev); 441216572522SSrinivas Kandagatla device_link_remove(dev, wcd938x->rxdev); 441316572522SSrinivas Kandagatla device_link_remove(wcd938x->rxdev, wcd938x->txdev); 44148d78602aSSrinivas Kandagatla snd_soc_unregister_component(dev); 44158d78602aSSrinivas Kandagatla component_unbind_all(dev, wcd938x); 44168d78602aSSrinivas Kandagatla } 44178d78602aSSrinivas Kandagatla 44188d78602aSSrinivas Kandagatla static const struct component_master_ops wcd938x_comp_ops = { 44198d78602aSSrinivas Kandagatla .bind = wcd938x_bind, 44208d78602aSSrinivas Kandagatla .unbind = wcd938x_unbind, 44218d78602aSSrinivas Kandagatla }; 44228d78602aSSrinivas Kandagatla 44238d78602aSSrinivas Kandagatla static int wcd938x_compare_of(struct device *dev, void *data) 44248d78602aSSrinivas Kandagatla { 44258d78602aSSrinivas Kandagatla return dev->of_node == data; 44268d78602aSSrinivas Kandagatla } 44278d78602aSSrinivas Kandagatla 44288d78602aSSrinivas Kandagatla static void wcd938x_release_of(struct device *dev, void *data) 44298d78602aSSrinivas Kandagatla { 44308d78602aSSrinivas Kandagatla of_node_put(data); 44318d78602aSSrinivas Kandagatla } 44328d78602aSSrinivas Kandagatla 44338d78602aSSrinivas Kandagatla static int wcd938x_add_slave_components(struct wcd938x_priv *wcd938x, 44348d78602aSSrinivas Kandagatla struct device *dev, 44358d78602aSSrinivas Kandagatla struct component_match **matchptr) 44368d78602aSSrinivas Kandagatla { 44378d78602aSSrinivas Kandagatla struct device_node *np; 44388d78602aSSrinivas Kandagatla 44398d78602aSSrinivas Kandagatla np = dev->of_node; 44408d78602aSSrinivas Kandagatla 44418d78602aSSrinivas Kandagatla wcd938x->rxnode = of_parse_phandle(np, "qcom,rx-device", 0); 44428d78602aSSrinivas Kandagatla if (!wcd938x->rxnode) { 44438d78602aSSrinivas Kandagatla dev_err(dev, "%s: Rx-device node not defined\n", __func__); 44448d78602aSSrinivas Kandagatla return -ENODEV; 44458d78602aSSrinivas Kandagatla } 44468d78602aSSrinivas Kandagatla 44478d78602aSSrinivas Kandagatla of_node_get(wcd938x->rxnode); 44488d78602aSSrinivas Kandagatla component_match_add_release(dev, matchptr, wcd938x_release_of, 44498d78602aSSrinivas Kandagatla wcd938x_compare_of, wcd938x->rxnode); 44508d78602aSSrinivas Kandagatla 44518d78602aSSrinivas Kandagatla wcd938x->txnode = of_parse_phandle(np, "qcom,tx-device", 0); 44528d78602aSSrinivas Kandagatla if (!wcd938x->txnode) { 44538d78602aSSrinivas Kandagatla dev_err(dev, "%s: Tx-device node not defined\n", __func__); 44548d78602aSSrinivas Kandagatla return -ENODEV; 44558d78602aSSrinivas Kandagatla } 44568d78602aSSrinivas Kandagatla of_node_get(wcd938x->txnode); 44578d78602aSSrinivas Kandagatla component_match_add_release(dev, matchptr, wcd938x_release_of, 44588d78602aSSrinivas Kandagatla wcd938x_compare_of, wcd938x->txnode); 44598d78602aSSrinivas Kandagatla return 0; 44608d78602aSSrinivas Kandagatla } 44618d78602aSSrinivas Kandagatla 44628d78602aSSrinivas Kandagatla static int wcd938x_probe(struct platform_device *pdev) 44638d78602aSSrinivas Kandagatla { 44648d78602aSSrinivas Kandagatla struct component_match *match = NULL; 44658d78602aSSrinivas Kandagatla struct wcd938x_priv *wcd938x = NULL; 44668d78602aSSrinivas Kandagatla struct device *dev = &pdev->dev; 44678d78602aSSrinivas Kandagatla int ret; 44688d78602aSSrinivas Kandagatla 44698d78602aSSrinivas Kandagatla wcd938x = devm_kzalloc(dev, sizeof(struct wcd938x_priv), 44708d78602aSSrinivas Kandagatla GFP_KERNEL); 44718d78602aSSrinivas Kandagatla if (!wcd938x) 44728d78602aSSrinivas Kandagatla return -ENOMEM; 44738d78602aSSrinivas Kandagatla 44748d78602aSSrinivas Kandagatla dev_set_drvdata(dev, wcd938x); 4475bcee7ed0SSrinivas Kandagatla mutex_init(&wcd938x->micb_lock); 44768d78602aSSrinivas Kandagatla 44778d78602aSSrinivas Kandagatla ret = wcd938x_populate_dt_data(wcd938x, dev); 44788d78602aSSrinivas Kandagatla if (ret) { 44798d78602aSSrinivas Kandagatla dev_err(dev, "%s: Fail to obtain platform data\n", __func__); 44808d78602aSSrinivas Kandagatla return -EINVAL; 44818d78602aSSrinivas Kandagatla } 44828d78602aSSrinivas Kandagatla 44838d78602aSSrinivas Kandagatla ret = wcd938x_add_slave_components(wcd938x, dev, &match); 44848d78602aSSrinivas Kandagatla if (ret) 44858d78602aSSrinivas Kandagatla return ret; 44868d78602aSSrinivas Kandagatla 44878d78602aSSrinivas Kandagatla wcd938x_reset(wcd938x); 44888d78602aSSrinivas Kandagatla 44898d78602aSSrinivas Kandagatla ret = component_master_add_with_match(dev, &wcd938x_comp_ops, match); 44908d78602aSSrinivas Kandagatla if (ret) 44918d78602aSSrinivas Kandagatla return ret; 44928d78602aSSrinivas Kandagatla 44938d78602aSSrinivas Kandagatla pm_runtime_set_autosuspend_delay(dev, 1000); 44948d78602aSSrinivas Kandagatla pm_runtime_use_autosuspend(dev); 44958d78602aSSrinivas Kandagatla pm_runtime_mark_last_busy(dev); 44968d78602aSSrinivas Kandagatla pm_runtime_set_active(dev); 44978d78602aSSrinivas Kandagatla pm_runtime_enable(dev); 44988d78602aSSrinivas Kandagatla pm_runtime_idle(dev); 44998d78602aSSrinivas Kandagatla 45008c62dbcbSPierre-Louis Bossart return 0; 45018d78602aSSrinivas Kandagatla } 45028d78602aSSrinivas Kandagatla 45038d78602aSSrinivas Kandagatla static int wcd938x_remove(struct platform_device *pdev) 45048d78602aSSrinivas Kandagatla { 45058d78602aSSrinivas Kandagatla component_master_del(&pdev->dev, &wcd938x_comp_ops); 45068d78602aSSrinivas Kandagatla 45078d78602aSSrinivas Kandagatla return 0; 45088d78602aSSrinivas Kandagatla } 45098d78602aSSrinivas Kandagatla 45108c4863c2SSrinivas Kandagatla #if defined(CONFIG_OF) 45118d78602aSSrinivas Kandagatla static const struct of_device_id wcd938x_dt_match[] = { 45128d78602aSSrinivas Kandagatla { .compatible = "qcom,wcd9380-codec" }, 45138d78602aSSrinivas Kandagatla { .compatible = "qcom,wcd9385-codec" }, 45148d78602aSSrinivas Kandagatla {} 45158d78602aSSrinivas Kandagatla }; 45168d78602aSSrinivas Kandagatla MODULE_DEVICE_TABLE(of, wcd938x_dt_match); 45178c4863c2SSrinivas Kandagatla #endif 45188d78602aSSrinivas Kandagatla 45198d78602aSSrinivas Kandagatla static struct platform_driver wcd938x_codec_driver = { 45208d78602aSSrinivas Kandagatla .probe = wcd938x_probe, 45218d78602aSSrinivas Kandagatla .remove = wcd938x_remove, 45228d78602aSSrinivas Kandagatla .driver = { 45238d78602aSSrinivas Kandagatla .name = "wcd938x_codec", 45248d78602aSSrinivas Kandagatla .of_match_table = of_match_ptr(wcd938x_dt_match), 45258d78602aSSrinivas Kandagatla .suppress_bind_attrs = true, 45268d78602aSSrinivas Kandagatla }, 45278d78602aSSrinivas Kandagatla }; 45288d78602aSSrinivas Kandagatla 45298d78602aSSrinivas Kandagatla module_platform_driver(wcd938x_codec_driver); 45308d78602aSSrinivas Kandagatla MODULE_DESCRIPTION("WCD938X Codec driver"); 45318d78602aSSrinivas Kandagatla MODULE_LICENSE("GPL"); 4532