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/soc.h> 138d78602aSSrinivas Kandagatla #include <sound/tlv.h> 148d78602aSSrinivas Kandagatla #include <linux/of_gpio.h> 158d78602aSSrinivas Kandagatla #include <linux/of.h> 168d78602aSSrinivas Kandagatla #include <sound/jack.h> 178d78602aSSrinivas Kandagatla #include <sound/pcm.h> 188d78602aSSrinivas Kandagatla #include <sound/pcm_params.h> 198d78602aSSrinivas Kandagatla #include <linux/regmap.h> 208d78602aSSrinivas Kandagatla #include <sound/soc.h> 218d78602aSSrinivas Kandagatla #include <sound/soc-dapm.h> 228d78602aSSrinivas Kandagatla #include <linux/regulator/consumer.h> 238d78602aSSrinivas Kandagatla 248d78602aSSrinivas Kandagatla #include "wcd-clsh-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; 1778d78602aSSrinivas Kandagatla struct wcd_clsh_ctrl *clsh_info; 1788d78602aSSrinivas Kandagatla struct irq_domain *virq; 1798d78602aSSrinivas Kandagatla struct regmap_irq_chip *wcd_regmap_irq_chip; 1808d78602aSSrinivas Kandagatla struct regmap_irq_chip_data *irq_chip; 1818d78602aSSrinivas Kandagatla struct regulator_bulk_data supplies[WCD938X_MAX_SUPPLY]; 1828d78602aSSrinivas Kandagatla struct snd_soc_jack *jack; 1838d78602aSSrinivas Kandagatla unsigned long status_mask; 1848d78602aSSrinivas Kandagatla s32 micb_ref[WCD938X_MAX_MICBIAS]; 1858d78602aSSrinivas Kandagatla s32 pullup_ref[WCD938X_MAX_MICBIAS]; 1868d78602aSSrinivas Kandagatla u32 hph_mode; 1878d78602aSSrinivas Kandagatla u32 tx_mode[TX_ADC_MAX]; 1888d78602aSSrinivas Kandagatla int flyback_cur_det_disable; 1898d78602aSSrinivas Kandagatla int ear_rx_path; 1908d78602aSSrinivas Kandagatla int variant; 1918d78602aSSrinivas Kandagatla int reset_gpio; 1928d78602aSSrinivas Kandagatla u32 micb1_mv; 1938d78602aSSrinivas Kandagatla u32 micb2_mv; 1948d78602aSSrinivas Kandagatla u32 micb3_mv; 1958d78602aSSrinivas Kandagatla u32 micb4_mv; 1968d78602aSSrinivas Kandagatla int hphr_pdm_wd_int; 1978d78602aSSrinivas Kandagatla int hphl_pdm_wd_int; 1988d78602aSSrinivas Kandagatla int aux_pdm_wd_int; 1998d78602aSSrinivas Kandagatla bool comp1_enable; 2008d78602aSSrinivas Kandagatla bool comp2_enable; 2018d78602aSSrinivas Kandagatla bool ldoh; 2028d78602aSSrinivas Kandagatla bool bcs_dis; 2038d78602aSSrinivas Kandagatla }; 2048d78602aSSrinivas Kandagatla 2058d78602aSSrinivas Kandagatla enum { 2068d78602aSSrinivas Kandagatla MIC_BIAS_1 = 1, 2078d78602aSSrinivas Kandagatla MIC_BIAS_2, 2088d78602aSSrinivas Kandagatla MIC_BIAS_3, 2098d78602aSSrinivas Kandagatla MIC_BIAS_4 2108d78602aSSrinivas Kandagatla }; 2118d78602aSSrinivas Kandagatla 2128d78602aSSrinivas Kandagatla enum { 2138d78602aSSrinivas Kandagatla MICB_PULLUP_ENABLE, 2148d78602aSSrinivas Kandagatla MICB_PULLUP_DISABLE, 2158d78602aSSrinivas Kandagatla MICB_ENABLE, 2168d78602aSSrinivas Kandagatla MICB_DISABLE, 2178d78602aSSrinivas Kandagatla }; 2188d78602aSSrinivas Kandagatla 219e8ba1e05SSrinivas Kandagatla static const SNDRV_CTL_TLVD_DECLARE_DB_MINMAX(ear_pa_gain, 600, -1800); 220e8ba1e05SSrinivas Kandagatla static const SNDRV_CTL_TLVD_DECLARE_DB_MINMAX(line_gain, 600, -3000); 221e8ba1e05SSrinivas Kandagatla static const SNDRV_CTL_TLVD_DECLARE_DB_MINMAX(analog_gain, 0, 3000); 222e8ba1e05SSrinivas Kandagatla 2238d78602aSSrinivas Kandagatla static const struct reg_default wcd938x_defaults[] = { 2248d78602aSSrinivas Kandagatla {WCD938X_ANA_PAGE_REGISTER, 0x00}, 2258d78602aSSrinivas Kandagatla {WCD938X_ANA_BIAS, 0x00}, 2268d78602aSSrinivas Kandagatla {WCD938X_ANA_RX_SUPPLIES, 0x00}, 2278d78602aSSrinivas Kandagatla {WCD938X_ANA_HPH, 0x0C}, 2288d78602aSSrinivas Kandagatla {WCD938X_ANA_EAR, 0x00}, 2298d78602aSSrinivas Kandagatla {WCD938X_ANA_EAR_COMPANDER_CTL, 0x02}, 2308d78602aSSrinivas Kandagatla {WCD938X_ANA_TX_CH1, 0x20}, 2318d78602aSSrinivas Kandagatla {WCD938X_ANA_TX_CH2, 0x00}, 2328d78602aSSrinivas Kandagatla {WCD938X_ANA_TX_CH3, 0x20}, 2338d78602aSSrinivas Kandagatla {WCD938X_ANA_TX_CH4, 0x00}, 2348d78602aSSrinivas Kandagatla {WCD938X_ANA_MICB1_MICB2_DSP_EN_LOGIC, 0x00}, 2358d78602aSSrinivas Kandagatla {WCD938X_ANA_MICB3_DSP_EN_LOGIC, 0x00}, 2368d78602aSSrinivas Kandagatla {WCD938X_ANA_MBHC_MECH, 0x39}, 2378d78602aSSrinivas Kandagatla {WCD938X_ANA_MBHC_ELECT, 0x08}, 2388d78602aSSrinivas Kandagatla {WCD938X_ANA_MBHC_ZDET, 0x00}, 2398d78602aSSrinivas Kandagatla {WCD938X_ANA_MBHC_RESULT_1, 0x00}, 2408d78602aSSrinivas Kandagatla {WCD938X_ANA_MBHC_RESULT_2, 0x00}, 2418d78602aSSrinivas Kandagatla {WCD938X_ANA_MBHC_RESULT_3, 0x00}, 2428d78602aSSrinivas Kandagatla {WCD938X_ANA_MBHC_BTN0, 0x00}, 2438d78602aSSrinivas Kandagatla {WCD938X_ANA_MBHC_BTN1, 0x10}, 2448d78602aSSrinivas Kandagatla {WCD938X_ANA_MBHC_BTN2, 0x20}, 2458d78602aSSrinivas Kandagatla {WCD938X_ANA_MBHC_BTN3, 0x30}, 2468d78602aSSrinivas Kandagatla {WCD938X_ANA_MBHC_BTN4, 0x40}, 2478d78602aSSrinivas Kandagatla {WCD938X_ANA_MBHC_BTN5, 0x50}, 2488d78602aSSrinivas Kandagatla {WCD938X_ANA_MBHC_BTN6, 0x60}, 2498d78602aSSrinivas Kandagatla {WCD938X_ANA_MBHC_BTN7, 0x70}, 2508d78602aSSrinivas Kandagatla {WCD938X_ANA_MICB1, 0x10}, 2518d78602aSSrinivas Kandagatla {WCD938X_ANA_MICB2, 0x10}, 2528d78602aSSrinivas Kandagatla {WCD938X_ANA_MICB2_RAMP, 0x00}, 2538d78602aSSrinivas Kandagatla {WCD938X_ANA_MICB3, 0x10}, 2548d78602aSSrinivas Kandagatla {WCD938X_ANA_MICB4, 0x10}, 2558d78602aSSrinivas Kandagatla {WCD938X_BIAS_CTL, 0x2A}, 2568d78602aSSrinivas Kandagatla {WCD938X_BIAS_VBG_FINE_ADJ, 0x55}, 2578d78602aSSrinivas Kandagatla {WCD938X_LDOL_VDDCX_ADJUST, 0x01}, 2588d78602aSSrinivas Kandagatla {WCD938X_LDOL_DISABLE_LDOL, 0x00}, 2598d78602aSSrinivas Kandagatla {WCD938X_MBHC_CTL_CLK, 0x00}, 2608d78602aSSrinivas Kandagatla {WCD938X_MBHC_CTL_ANA, 0x00}, 2618d78602aSSrinivas Kandagatla {WCD938X_MBHC_CTL_SPARE_1, 0x00}, 2628d78602aSSrinivas Kandagatla {WCD938X_MBHC_CTL_SPARE_2, 0x00}, 2638d78602aSSrinivas Kandagatla {WCD938X_MBHC_CTL_BCS, 0x00}, 2648d78602aSSrinivas Kandagatla {WCD938X_MBHC_MOISTURE_DET_FSM_STATUS, 0x00}, 2658d78602aSSrinivas Kandagatla {WCD938X_MBHC_TEST_CTL, 0x00}, 2668d78602aSSrinivas Kandagatla {WCD938X_LDOH_MODE, 0x2B}, 2678d78602aSSrinivas Kandagatla {WCD938X_LDOH_BIAS, 0x68}, 2688d78602aSSrinivas Kandagatla {WCD938X_LDOH_STB_LOADS, 0x00}, 2698d78602aSSrinivas Kandagatla {WCD938X_LDOH_SLOWRAMP, 0x50}, 2708d78602aSSrinivas Kandagatla {WCD938X_MICB1_TEST_CTL_1, 0x1A}, 2718d78602aSSrinivas Kandagatla {WCD938X_MICB1_TEST_CTL_2, 0x00}, 2728d78602aSSrinivas Kandagatla {WCD938X_MICB1_TEST_CTL_3, 0xA4}, 2738d78602aSSrinivas Kandagatla {WCD938X_MICB2_TEST_CTL_1, 0x1A}, 2748d78602aSSrinivas Kandagatla {WCD938X_MICB2_TEST_CTL_2, 0x00}, 2758d78602aSSrinivas Kandagatla {WCD938X_MICB2_TEST_CTL_3, 0x24}, 2768d78602aSSrinivas Kandagatla {WCD938X_MICB3_TEST_CTL_1, 0x1A}, 2778d78602aSSrinivas Kandagatla {WCD938X_MICB3_TEST_CTL_2, 0x00}, 2788d78602aSSrinivas Kandagatla {WCD938X_MICB3_TEST_CTL_3, 0xA4}, 2798d78602aSSrinivas Kandagatla {WCD938X_MICB4_TEST_CTL_1, 0x1A}, 2808d78602aSSrinivas Kandagatla {WCD938X_MICB4_TEST_CTL_2, 0x00}, 2818d78602aSSrinivas Kandagatla {WCD938X_MICB4_TEST_CTL_3, 0xA4}, 2828d78602aSSrinivas Kandagatla {WCD938X_TX_COM_ADC_VCM, 0x39}, 2838d78602aSSrinivas Kandagatla {WCD938X_TX_COM_BIAS_ATEST, 0xE0}, 2848d78602aSSrinivas Kandagatla {WCD938X_TX_COM_SPARE1, 0x00}, 2858d78602aSSrinivas Kandagatla {WCD938X_TX_COM_SPARE2, 0x00}, 2868d78602aSSrinivas Kandagatla {WCD938X_TX_COM_TXFE_DIV_CTL, 0x22}, 2878d78602aSSrinivas Kandagatla {WCD938X_TX_COM_TXFE_DIV_START, 0x00}, 2888d78602aSSrinivas Kandagatla {WCD938X_TX_COM_SPARE3, 0x00}, 2898d78602aSSrinivas Kandagatla {WCD938X_TX_COM_SPARE4, 0x00}, 2908d78602aSSrinivas Kandagatla {WCD938X_TX_1_2_TEST_EN, 0xCC}, 2918d78602aSSrinivas Kandagatla {WCD938X_TX_1_2_ADC_IB, 0xE9}, 2928d78602aSSrinivas Kandagatla {WCD938X_TX_1_2_ATEST_REFCTL, 0x0A}, 2938d78602aSSrinivas Kandagatla {WCD938X_TX_1_2_TEST_CTL, 0x38}, 2948d78602aSSrinivas Kandagatla {WCD938X_TX_1_2_TEST_BLK_EN1, 0xFF}, 2958d78602aSSrinivas Kandagatla {WCD938X_TX_1_2_TXFE1_CLKDIV, 0x00}, 2968d78602aSSrinivas Kandagatla {WCD938X_TX_1_2_SAR2_ERR, 0x00}, 2978d78602aSSrinivas Kandagatla {WCD938X_TX_1_2_SAR1_ERR, 0x00}, 2988d78602aSSrinivas Kandagatla {WCD938X_TX_3_4_TEST_EN, 0xCC}, 2998d78602aSSrinivas Kandagatla {WCD938X_TX_3_4_ADC_IB, 0xE9}, 3008d78602aSSrinivas Kandagatla {WCD938X_TX_3_4_ATEST_REFCTL, 0x0A}, 3018d78602aSSrinivas Kandagatla {WCD938X_TX_3_4_TEST_CTL, 0x38}, 3028d78602aSSrinivas Kandagatla {WCD938X_TX_3_4_TEST_BLK_EN3, 0xFF}, 3038d78602aSSrinivas Kandagatla {WCD938X_TX_3_4_TXFE3_CLKDIV, 0x00}, 3048d78602aSSrinivas Kandagatla {WCD938X_TX_3_4_SAR4_ERR, 0x00}, 3058d78602aSSrinivas Kandagatla {WCD938X_TX_3_4_SAR3_ERR, 0x00}, 3068d78602aSSrinivas Kandagatla {WCD938X_TX_3_4_TEST_BLK_EN2, 0xFB}, 3078d78602aSSrinivas Kandagatla {WCD938X_TX_3_4_TXFE2_CLKDIV, 0x00}, 3088d78602aSSrinivas Kandagatla {WCD938X_TX_3_4_SPARE1, 0x00}, 3098d78602aSSrinivas Kandagatla {WCD938X_TX_3_4_TEST_BLK_EN4, 0xFB}, 3108d78602aSSrinivas Kandagatla {WCD938X_TX_3_4_TXFE4_CLKDIV, 0x00}, 3118d78602aSSrinivas Kandagatla {WCD938X_TX_3_4_SPARE2, 0x00}, 3128d78602aSSrinivas Kandagatla {WCD938X_CLASSH_MODE_1, 0x40}, 3138d78602aSSrinivas Kandagatla {WCD938X_CLASSH_MODE_2, 0x3A}, 3148d78602aSSrinivas Kandagatla {WCD938X_CLASSH_MODE_3, 0x00}, 3158d78602aSSrinivas Kandagatla {WCD938X_CLASSH_CTRL_VCL_1, 0x70}, 3168d78602aSSrinivas Kandagatla {WCD938X_CLASSH_CTRL_VCL_2, 0x82}, 3178d78602aSSrinivas Kandagatla {WCD938X_CLASSH_CTRL_CCL_1, 0x31}, 3188d78602aSSrinivas Kandagatla {WCD938X_CLASSH_CTRL_CCL_2, 0x80}, 3198d78602aSSrinivas Kandagatla {WCD938X_CLASSH_CTRL_CCL_3, 0x80}, 3208d78602aSSrinivas Kandagatla {WCD938X_CLASSH_CTRL_CCL_4, 0x51}, 3218d78602aSSrinivas Kandagatla {WCD938X_CLASSH_CTRL_CCL_5, 0x00}, 3228d78602aSSrinivas Kandagatla {WCD938X_CLASSH_BUCK_TMUX_A_D, 0x00}, 3238d78602aSSrinivas Kandagatla {WCD938X_CLASSH_BUCK_SW_DRV_CNTL, 0x77}, 3248d78602aSSrinivas Kandagatla {WCD938X_CLASSH_SPARE, 0x00}, 3258d78602aSSrinivas Kandagatla {WCD938X_FLYBACK_EN, 0x4E}, 3268d78602aSSrinivas Kandagatla {WCD938X_FLYBACK_VNEG_CTRL_1, 0x0B}, 3278d78602aSSrinivas Kandagatla {WCD938X_FLYBACK_VNEG_CTRL_2, 0x45}, 3288d78602aSSrinivas Kandagatla {WCD938X_FLYBACK_VNEG_CTRL_3, 0x74}, 3298d78602aSSrinivas Kandagatla {WCD938X_FLYBACK_VNEG_CTRL_4, 0x7F}, 3308d78602aSSrinivas Kandagatla {WCD938X_FLYBACK_VNEG_CTRL_5, 0x83}, 3318d78602aSSrinivas Kandagatla {WCD938X_FLYBACK_VNEG_CTRL_6, 0x98}, 3328d78602aSSrinivas Kandagatla {WCD938X_FLYBACK_VNEG_CTRL_7, 0xA9}, 3338d78602aSSrinivas Kandagatla {WCD938X_FLYBACK_VNEG_CTRL_8, 0x68}, 3348d78602aSSrinivas Kandagatla {WCD938X_FLYBACK_VNEG_CTRL_9, 0x64}, 3358d78602aSSrinivas Kandagatla {WCD938X_FLYBACK_VNEGDAC_CTRL_1, 0xED}, 3368d78602aSSrinivas Kandagatla {WCD938X_FLYBACK_VNEGDAC_CTRL_2, 0xF0}, 3378d78602aSSrinivas Kandagatla {WCD938X_FLYBACK_VNEGDAC_CTRL_3, 0xA6}, 3388d78602aSSrinivas Kandagatla {WCD938X_FLYBACK_CTRL_1, 0x65}, 3398d78602aSSrinivas Kandagatla {WCD938X_FLYBACK_TEST_CTL, 0x00}, 3408d78602aSSrinivas Kandagatla {WCD938X_RX_AUX_SW_CTL, 0x00}, 3418d78602aSSrinivas Kandagatla {WCD938X_RX_PA_AUX_IN_CONN, 0x01}, 3428d78602aSSrinivas Kandagatla {WCD938X_RX_TIMER_DIV, 0x32}, 3438d78602aSSrinivas Kandagatla {WCD938X_RX_OCP_CTL, 0x1F}, 3448d78602aSSrinivas Kandagatla {WCD938X_RX_OCP_COUNT, 0x77}, 3458d78602aSSrinivas Kandagatla {WCD938X_RX_BIAS_EAR_DAC, 0xA0}, 3468d78602aSSrinivas Kandagatla {WCD938X_RX_BIAS_EAR_AMP, 0xAA}, 3478d78602aSSrinivas Kandagatla {WCD938X_RX_BIAS_HPH_LDO, 0xA9}, 3488d78602aSSrinivas Kandagatla {WCD938X_RX_BIAS_HPH_PA, 0xAA}, 3498d78602aSSrinivas Kandagatla {WCD938X_RX_BIAS_HPH_RDACBUFF_CNP2, 0x8A}, 3508d78602aSSrinivas Kandagatla {WCD938X_RX_BIAS_HPH_RDAC_LDO, 0x88}, 3518d78602aSSrinivas Kandagatla {WCD938X_RX_BIAS_HPH_CNP1, 0x82}, 3528d78602aSSrinivas Kandagatla {WCD938X_RX_BIAS_HPH_LOWPOWER, 0x82}, 3538d78602aSSrinivas Kandagatla {WCD938X_RX_BIAS_AUX_DAC, 0xA0}, 3548d78602aSSrinivas Kandagatla {WCD938X_RX_BIAS_AUX_AMP, 0xAA}, 3558d78602aSSrinivas Kandagatla {WCD938X_RX_BIAS_VNEGDAC_BLEEDER, 0x50}, 3568d78602aSSrinivas Kandagatla {WCD938X_RX_BIAS_MISC, 0x00}, 3578d78602aSSrinivas Kandagatla {WCD938X_RX_BIAS_BUCK_RST, 0x08}, 3588d78602aSSrinivas Kandagatla {WCD938X_RX_BIAS_BUCK_VREF_ERRAMP, 0x44}, 3598d78602aSSrinivas Kandagatla {WCD938X_RX_BIAS_FLYB_ERRAMP, 0x40}, 3608d78602aSSrinivas Kandagatla {WCD938X_RX_BIAS_FLYB_BUFF, 0xAA}, 3618d78602aSSrinivas Kandagatla {WCD938X_RX_BIAS_FLYB_MID_RST, 0x14}, 3628d78602aSSrinivas Kandagatla {WCD938X_HPH_L_STATUS, 0x04}, 3638d78602aSSrinivas Kandagatla {WCD938X_HPH_R_STATUS, 0x04}, 3648d78602aSSrinivas Kandagatla {WCD938X_HPH_CNP_EN, 0x80}, 3658d78602aSSrinivas Kandagatla {WCD938X_HPH_CNP_WG_CTL, 0x9A}, 3668d78602aSSrinivas Kandagatla {WCD938X_HPH_CNP_WG_TIME, 0x14}, 3678d78602aSSrinivas Kandagatla {WCD938X_HPH_OCP_CTL, 0x28}, 3688d78602aSSrinivas Kandagatla {WCD938X_HPH_AUTO_CHOP, 0x16}, 3698d78602aSSrinivas Kandagatla {WCD938X_HPH_CHOP_CTL, 0x83}, 3708d78602aSSrinivas Kandagatla {WCD938X_HPH_PA_CTL1, 0x46}, 3718d78602aSSrinivas Kandagatla {WCD938X_HPH_PA_CTL2, 0x50}, 3728d78602aSSrinivas Kandagatla {WCD938X_HPH_L_EN, 0x80}, 3738d78602aSSrinivas Kandagatla {WCD938X_HPH_L_TEST, 0xE0}, 3748d78602aSSrinivas Kandagatla {WCD938X_HPH_L_ATEST, 0x50}, 3758d78602aSSrinivas Kandagatla {WCD938X_HPH_R_EN, 0x80}, 3768d78602aSSrinivas Kandagatla {WCD938X_HPH_R_TEST, 0xE0}, 3778d78602aSSrinivas Kandagatla {WCD938X_HPH_R_ATEST, 0x54}, 3788d78602aSSrinivas Kandagatla {WCD938X_HPH_RDAC_CLK_CTL1, 0x99}, 3798d78602aSSrinivas Kandagatla {WCD938X_HPH_RDAC_CLK_CTL2, 0x9B}, 3808d78602aSSrinivas Kandagatla {WCD938X_HPH_RDAC_LDO_CTL, 0x33}, 3818d78602aSSrinivas Kandagatla {WCD938X_HPH_RDAC_CHOP_CLK_LP_CTL, 0x00}, 3828d78602aSSrinivas Kandagatla {WCD938X_HPH_REFBUFF_UHQA_CTL, 0x68}, 3838d78602aSSrinivas Kandagatla {WCD938X_HPH_REFBUFF_LP_CTL, 0x0E}, 3848d78602aSSrinivas Kandagatla {WCD938X_HPH_L_DAC_CTL, 0x20}, 3858d78602aSSrinivas Kandagatla {WCD938X_HPH_R_DAC_CTL, 0x20}, 3868d78602aSSrinivas Kandagatla {WCD938X_HPH_SURGE_HPHLR_SURGE_COMP_SEL, 0x55}, 3878d78602aSSrinivas Kandagatla {WCD938X_HPH_SURGE_HPHLR_SURGE_EN, 0x19}, 3888d78602aSSrinivas Kandagatla {WCD938X_HPH_SURGE_HPHLR_SURGE_MISC1, 0xA0}, 3898d78602aSSrinivas Kandagatla {WCD938X_HPH_SURGE_HPHLR_SURGE_STATUS, 0x00}, 3908d78602aSSrinivas Kandagatla {WCD938X_EAR_EAR_EN_REG, 0x22}, 3918d78602aSSrinivas Kandagatla {WCD938X_EAR_EAR_PA_CON, 0x44}, 3928d78602aSSrinivas Kandagatla {WCD938X_EAR_EAR_SP_CON, 0xDB}, 3938d78602aSSrinivas Kandagatla {WCD938X_EAR_EAR_DAC_CON, 0x80}, 3948d78602aSSrinivas Kandagatla {WCD938X_EAR_EAR_CNP_FSM_CON, 0xB2}, 3958d78602aSSrinivas Kandagatla {WCD938X_EAR_TEST_CTL, 0x00}, 3968d78602aSSrinivas Kandagatla {WCD938X_EAR_STATUS_REG_1, 0x00}, 3978d78602aSSrinivas Kandagatla {WCD938X_EAR_STATUS_REG_2, 0x08}, 3988d78602aSSrinivas Kandagatla {WCD938X_ANA_NEW_PAGE_REGISTER, 0x00}, 3998d78602aSSrinivas Kandagatla {WCD938X_HPH_NEW_ANA_HPH2, 0x00}, 4008d78602aSSrinivas Kandagatla {WCD938X_HPH_NEW_ANA_HPH3, 0x00}, 4018d78602aSSrinivas Kandagatla {WCD938X_SLEEP_CTL, 0x16}, 4028d78602aSSrinivas Kandagatla {WCD938X_SLEEP_WATCHDOG_CTL, 0x00}, 4038d78602aSSrinivas Kandagatla {WCD938X_MBHC_NEW_ELECT_REM_CLAMP_CTL, 0x00}, 4048d78602aSSrinivas Kandagatla {WCD938X_MBHC_NEW_CTL_1, 0x02}, 4058d78602aSSrinivas Kandagatla {WCD938X_MBHC_NEW_CTL_2, 0x05}, 4068d78602aSSrinivas Kandagatla {WCD938X_MBHC_NEW_PLUG_DETECT_CTL, 0xE9}, 4078d78602aSSrinivas Kandagatla {WCD938X_MBHC_NEW_ZDET_ANA_CTL, 0x0F}, 4088d78602aSSrinivas Kandagatla {WCD938X_MBHC_NEW_ZDET_RAMP_CTL, 0x00}, 4098d78602aSSrinivas Kandagatla {WCD938X_MBHC_NEW_FSM_STATUS, 0x00}, 4108d78602aSSrinivas Kandagatla {WCD938X_MBHC_NEW_ADC_RESULT, 0x00}, 4118d78602aSSrinivas Kandagatla {WCD938X_TX_NEW_AMIC_MUX_CFG, 0x00}, 4128d78602aSSrinivas Kandagatla {WCD938X_AUX_AUXPA, 0x00}, 4138d78602aSSrinivas Kandagatla {WCD938X_LDORXTX_MODE, 0x0C}, 4148d78602aSSrinivas Kandagatla {WCD938X_LDORXTX_CONFIG, 0x10}, 4158d78602aSSrinivas Kandagatla {WCD938X_DIE_CRACK_DIE_CRK_DET_EN, 0x00}, 4168d78602aSSrinivas Kandagatla {WCD938X_DIE_CRACK_DIE_CRK_DET_OUT, 0x00}, 4178d78602aSSrinivas Kandagatla {WCD938X_HPH_NEW_INT_RDAC_GAIN_CTL, 0x40}, 4188d78602aSSrinivas Kandagatla {WCD938X_HPH_NEW_INT_RDAC_HD2_CTL_L, 0x81}, 4198d78602aSSrinivas Kandagatla {WCD938X_HPH_NEW_INT_RDAC_VREF_CTL, 0x10}, 4208d78602aSSrinivas Kandagatla {WCD938X_HPH_NEW_INT_RDAC_OVERRIDE_CTL, 0x00}, 4218d78602aSSrinivas Kandagatla {WCD938X_HPH_NEW_INT_RDAC_HD2_CTL_R, 0x81}, 4228d78602aSSrinivas Kandagatla {WCD938X_HPH_NEW_INT_PA_MISC1, 0x22}, 4238d78602aSSrinivas Kandagatla {WCD938X_HPH_NEW_INT_PA_MISC2, 0x00}, 4248d78602aSSrinivas Kandagatla {WCD938X_HPH_NEW_INT_PA_RDAC_MISC, 0x00}, 4258d78602aSSrinivas Kandagatla {WCD938X_HPH_NEW_INT_HPH_TIMER1, 0xFE}, 4268d78602aSSrinivas Kandagatla {WCD938X_HPH_NEW_INT_HPH_TIMER2, 0x02}, 4278d78602aSSrinivas Kandagatla {WCD938X_HPH_NEW_INT_HPH_TIMER3, 0x4E}, 4288d78602aSSrinivas Kandagatla {WCD938X_HPH_NEW_INT_HPH_TIMER4, 0x54}, 4298d78602aSSrinivas Kandagatla {WCD938X_HPH_NEW_INT_PA_RDAC_MISC2, 0x00}, 4308d78602aSSrinivas Kandagatla {WCD938X_HPH_NEW_INT_PA_RDAC_MISC3, 0x00}, 4318d78602aSSrinivas Kandagatla {WCD938X_HPH_NEW_INT_RDAC_HD2_CTL_L_NEW, 0x90}, 4328d78602aSSrinivas Kandagatla {WCD938X_HPH_NEW_INT_RDAC_HD2_CTL_R_NEW, 0x90}, 4338d78602aSSrinivas Kandagatla {WCD938X_RX_NEW_INT_HPH_RDAC_BIAS_LOHIFI, 0x62}, 4348d78602aSSrinivas Kandagatla {WCD938X_RX_NEW_INT_HPH_RDAC_BIAS_ULP, 0x01}, 4358d78602aSSrinivas Kandagatla {WCD938X_RX_NEW_INT_HPH_RDAC_LDO_LP, 0x11}, 4368d78602aSSrinivas Kandagatla {WCD938X_MBHC_NEW_INT_MOISTURE_DET_DC_CTRL, 0x57}, 4378d78602aSSrinivas Kandagatla {WCD938X_MBHC_NEW_INT_MOISTURE_DET_POLLING_CTRL, 0x01}, 4388d78602aSSrinivas Kandagatla {WCD938X_MBHC_NEW_INT_MECH_DET_CURRENT, 0x00}, 4398d78602aSSrinivas Kandagatla {WCD938X_MBHC_NEW_INT_SPARE_2, 0x00}, 4408d78602aSSrinivas Kandagatla {WCD938X_EAR_INT_NEW_EAR_CHOPPER_CON, 0xA8}, 4418d78602aSSrinivas Kandagatla {WCD938X_EAR_INT_NEW_CNP_VCM_CON1, 0x42}, 4428d78602aSSrinivas Kandagatla {WCD938X_EAR_INT_NEW_CNP_VCM_CON2, 0x22}, 4438d78602aSSrinivas Kandagatla {WCD938X_EAR_INT_NEW_EAR_DYNAMIC_BIAS, 0x00}, 4448d78602aSSrinivas Kandagatla {WCD938X_AUX_INT_EN_REG, 0x00}, 4458d78602aSSrinivas Kandagatla {WCD938X_AUX_INT_PA_CTRL, 0x06}, 4468d78602aSSrinivas Kandagatla {WCD938X_AUX_INT_SP_CTRL, 0xD2}, 4478d78602aSSrinivas Kandagatla {WCD938X_AUX_INT_DAC_CTRL, 0x80}, 4488d78602aSSrinivas Kandagatla {WCD938X_AUX_INT_CLK_CTRL, 0x50}, 4498d78602aSSrinivas Kandagatla {WCD938X_AUX_INT_TEST_CTRL, 0x00}, 4508d78602aSSrinivas Kandagatla {WCD938X_AUX_INT_STATUS_REG, 0x00}, 4518d78602aSSrinivas Kandagatla {WCD938X_AUX_INT_MISC, 0x00}, 4528d78602aSSrinivas Kandagatla {WCD938X_LDORXTX_INT_BIAS, 0x6E}, 4538d78602aSSrinivas Kandagatla {WCD938X_LDORXTX_INT_STB_LOADS_DTEST, 0x50}, 4548d78602aSSrinivas Kandagatla {WCD938X_LDORXTX_INT_TEST0, 0x1C}, 4558d78602aSSrinivas Kandagatla {WCD938X_LDORXTX_INT_STARTUP_TIMER, 0xFF}, 4568d78602aSSrinivas Kandagatla {WCD938X_LDORXTX_INT_TEST1, 0x1F}, 4578d78602aSSrinivas Kandagatla {WCD938X_LDORXTX_INT_STATUS, 0x00}, 4588d78602aSSrinivas Kandagatla {WCD938X_SLEEP_INT_WATCHDOG_CTL_1, 0x0A}, 4598d78602aSSrinivas Kandagatla {WCD938X_SLEEP_INT_WATCHDOG_CTL_2, 0x0A}, 4608d78602aSSrinivas Kandagatla {WCD938X_DIE_CRACK_INT_DIE_CRK_DET_INT1, 0x02}, 4618d78602aSSrinivas Kandagatla {WCD938X_DIE_CRACK_INT_DIE_CRK_DET_INT2, 0x60}, 4628d78602aSSrinivas Kandagatla {WCD938X_TX_COM_NEW_INT_TXFE_DIVSTOP_L2, 0xFF}, 4638d78602aSSrinivas Kandagatla {WCD938X_TX_COM_NEW_INT_TXFE_DIVSTOP_L1, 0x7F}, 4648d78602aSSrinivas Kandagatla {WCD938X_TX_COM_NEW_INT_TXFE_DIVSTOP_L0, 0x3F}, 4658d78602aSSrinivas Kandagatla {WCD938X_TX_COM_NEW_INT_TXFE_DIVSTOP_ULP1P2M, 0x1F}, 4668d78602aSSrinivas Kandagatla {WCD938X_TX_COM_NEW_INT_TXFE_DIVSTOP_ULP0P6M, 0x0F}, 4678d78602aSSrinivas Kandagatla {WCD938X_TX_COM_NEW_INT_TXFE_ICTRL_STG1_L2L1, 0xD7}, 4688d78602aSSrinivas Kandagatla {WCD938X_TX_COM_NEW_INT_TXFE_ICTRL_STG1_L0, 0xC8}, 4698d78602aSSrinivas Kandagatla {WCD938X_TX_COM_NEW_INT_TXFE_ICTRL_STG1_ULP, 0xC6}, 4708d78602aSSrinivas Kandagatla {WCD938X_TX_COM_NEW_INT_TXFE_ICTRL_STG2MAIN_L2L1, 0xD5}, 4718d78602aSSrinivas Kandagatla {WCD938X_TX_COM_NEW_INT_TXFE_ICTRL_STG2MAIN_L0, 0xCA}, 4728d78602aSSrinivas Kandagatla {WCD938X_TX_COM_NEW_INT_TXFE_ICTRL_STG2MAIN_ULP, 0x05}, 4738d78602aSSrinivas Kandagatla {WCD938X_TX_COM_NEW_INT_TXFE_ICTRL_STG2CASC_L2L1L0, 0xA5}, 4748d78602aSSrinivas Kandagatla {WCD938X_TX_COM_NEW_INT_TXFE_ICTRL_STG2CASC_ULP, 0x13}, 4758d78602aSSrinivas Kandagatla {WCD938X_TX_COM_NEW_INT_TXADC_SCBIAS_L2L1, 0x88}, 4768d78602aSSrinivas Kandagatla {WCD938X_TX_COM_NEW_INT_TXADC_SCBIAS_L0ULP, 0x42}, 4778d78602aSSrinivas Kandagatla {WCD938X_TX_COM_NEW_INT_TXADC_INT_L2, 0xFF}, 4788d78602aSSrinivas Kandagatla {WCD938X_TX_COM_NEW_INT_TXADC_INT_L1, 0x64}, 4798d78602aSSrinivas Kandagatla {WCD938X_TX_COM_NEW_INT_TXADC_INT_L0, 0x64}, 4808d78602aSSrinivas Kandagatla {WCD938X_TX_COM_NEW_INT_TXADC_INT_ULP, 0x77}, 4818d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_PAGE_REGISTER, 0x00}, 4828d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_CHIP_ID0, 0x00}, 4838d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_CHIP_ID1, 0x00}, 4848d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_CHIP_ID2, 0x0D}, 4858d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_CHIP_ID3, 0x01}, 4868d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_SWR_TX_CLK_RATE, 0x00}, 4878d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_CDC_RST_CTL, 0x03}, 4888d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_TOP_CLK_CFG, 0x00}, 4898d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_CDC_ANA_CLK_CTL, 0x00}, 4908d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_CDC_DIG_CLK_CTL, 0xF0}, 4918d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_SWR_RST_EN, 0x00}, 4928d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_CDC_PATH_MODE, 0x55}, 4938d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_CDC_RX_RST, 0x00}, 4948d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_CDC_RX0_CTL, 0xFC}, 4958d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_CDC_RX1_CTL, 0xFC}, 4968d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_CDC_RX2_CTL, 0xFC}, 4978d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_CDC_TX_ANA_MODE_0_1, 0x00}, 4988d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_CDC_TX_ANA_MODE_2_3, 0x00}, 4998d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_CDC_COMP_CTL_0, 0x00}, 5008d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_CDC_ANA_TX_CLK_CTL, 0x1E}, 5018d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_CDC_HPH_DSM_A1_0, 0x00}, 5028d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_CDC_HPH_DSM_A1_1, 0x01}, 5038d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_CDC_HPH_DSM_A2_0, 0x63}, 5048d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_CDC_HPH_DSM_A2_1, 0x04}, 5058d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_CDC_HPH_DSM_A3_0, 0xAC}, 5068d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_CDC_HPH_DSM_A3_1, 0x04}, 5078d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_CDC_HPH_DSM_A4_0, 0x1A}, 5088d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_CDC_HPH_DSM_A4_1, 0x03}, 5098d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_CDC_HPH_DSM_A5_0, 0xBC}, 5108d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_CDC_HPH_DSM_A5_1, 0x02}, 5118d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_CDC_HPH_DSM_A6_0, 0xC7}, 5128d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_CDC_HPH_DSM_A7_0, 0xF8}, 5138d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_CDC_HPH_DSM_C_0, 0x47}, 5148d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_CDC_HPH_DSM_C_1, 0x43}, 5158d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_CDC_HPH_DSM_C_2, 0xB1}, 5168d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_CDC_HPH_DSM_C_3, 0x17}, 5178d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_CDC_HPH_DSM_R1, 0x4D}, 5188d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_CDC_HPH_DSM_R2, 0x29}, 5198d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_CDC_HPH_DSM_R3, 0x34}, 5208d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_CDC_HPH_DSM_R4, 0x59}, 5218d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_CDC_HPH_DSM_R5, 0x66}, 5228d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_CDC_HPH_DSM_R6, 0x87}, 5238d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_CDC_HPH_DSM_R7, 0x64}, 5248d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_CDC_AUX_DSM_A1_0, 0x00}, 5258d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_CDC_AUX_DSM_A1_1, 0x01}, 5268d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_CDC_AUX_DSM_A2_0, 0x96}, 5278d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_CDC_AUX_DSM_A2_1, 0x09}, 5288d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_CDC_AUX_DSM_A3_0, 0xAB}, 5298d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_CDC_AUX_DSM_A3_1, 0x05}, 5308d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_CDC_AUX_DSM_A4_0, 0x1C}, 5318d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_CDC_AUX_DSM_A4_1, 0x02}, 5328d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_CDC_AUX_DSM_A5_0, 0x17}, 5338d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_CDC_AUX_DSM_A5_1, 0x02}, 5348d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_CDC_AUX_DSM_A6_0, 0xAA}, 5358d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_CDC_AUX_DSM_A7_0, 0xE3}, 5368d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_CDC_AUX_DSM_C_0, 0x69}, 5378d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_CDC_AUX_DSM_C_1, 0x54}, 5388d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_CDC_AUX_DSM_C_2, 0x02}, 5398d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_CDC_AUX_DSM_C_3, 0x15}, 5408d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_CDC_AUX_DSM_R1, 0xA4}, 5418d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_CDC_AUX_DSM_R2, 0xB5}, 5428d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_CDC_AUX_DSM_R3, 0x86}, 5438d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_CDC_AUX_DSM_R4, 0x85}, 5448d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_CDC_AUX_DSM_R5, 0xAA}, 5458d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_CDC_AUX_DSM_R6, 0xE2}, 5468d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_CDC_AUX_DSM_R7, 0x62}, 5478d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_CDC_HPH_GAIN_RX_0, 0x55}, 5488d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_CDC_HPH_GAIN_RX_1, 0xA9}, 5498d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_CDC_HPH_GAIN_DSD_0, 0x3D}, 5508d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_CDC_HPH_GAIN_DSD_1, 0x2E}, 5518d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_CDC_HPH_GAIN_DSD_2, 0x01}, 5528d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_CDC_AUX_GAIN_DSD_0, 0x00}, 5538d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_CDC_AUX_GAIN_DSD_1, 0xFC}, 5548d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_CDC_AUX_GAIN_DSD_2, 0x01}, 5558d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_CDC_HPH_GAIN_CTL, 0x00}, 5568d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_CDC_AUX_GAIN_CTL, 0x00}, 5578d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_CDC_EAR_PATH_CTL, 0x00}, 5588d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_CDC_SWR_CLH, 0x00}, 5598d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_SWR_CLH_BYP, 0x00}, 5608d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_CDC_TX0_CTL, 0x68}, 5618d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_CDC_TX1_CTL, 0x68}, 5628d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_CDC_TX2_CTL, 0x68}, 5638d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_CDC_TX_RST, 0x00}, 5648d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_CDC_REQ_CTL, 0x01}, 5658d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_CDC_RST, 0x00}, 5668d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_CDC_AMIC_CTL, 0x0F}, 5678d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_CDC_DMIC_CTL, 0x04}, 5688d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_CDC_DMIC1_CTL, 0x01}, 5698d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_CDC_DMIC2_CTL, 0x01}, 5708d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_CDC_DMIC3_CTL, 0x01}, 5718d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_CDC_DMIC4_CTL, 0x01}, 5728d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_EFUSE_PRG_CTL, 0x00}, 5738d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_EFUSE_CTL, 0x2B}, 5748d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_CDC_DMIC_RATE_1_2, 0x11}, 5758d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_CDC_DMIC_RATE_3_4, 0x11}, 5768d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_PDM_WD_CTL0, 0x00}, 5778d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_PDM_WD_CTL1, 0x00}, 5788d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_PDM_WD_CTL2, 0x00}, 5798d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_INTR_MODE, 0x00}, 5808d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_INTR_MASK_0, 0xFF}, 5818d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_INTR_MASK_1, 0xFF}, 5828d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_INTR_MASK_2, 0x3F}, 5838d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_INTR_STATUS_0, 0x00}, 5848d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_INTR_STATUS_1, 0x00}, 5858d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_INTR_STATUS_2, 0x00}, 5868d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_INTR_CLEAR_0, 0x00}, 5878d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_INTR_CLEAR_1, 0x00}, 5888d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_INTR_CLEAR_2, 0x00}, 5898d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_INTR_LEVEL_0, 0x00}, 5908d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_INTR_LEVEL_1, 0x00}, 5918d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_INTR_LEVEL_2, 0x00}, 5928d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_INTR_SET_0, 0x00}, 5938d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_INTR_SET_1, 0x00}, 5948d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_INTR_SET_2, 0x00}, 5958d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_INTR_TEST_0, 0x00}, 5968d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_INTR_TEST_1, 0x00}, 5978d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_INTR_TEST_2, 0x00}, 5988d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_TX_MODE_DBG_EN, 0x00}, 5998d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_TX_MODE_DBG_0_1, 0x00}, 6008d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_TX_MODE_DBG_2_3, 0x00}, 6018d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_LB_IN_SEL_CTL, 0x00}, 6028d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_LOOP_BACK_MODE, 0x00}, 6038d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_SWR_DAC_TEST, 0x00}, 6048d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_SWR_HM_TEST_RX_0, 0x40}, 6058d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_SWR_HM_TEST_TX_0, 0x40}, 6068d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_SWR_HM_TEST_RX_1, 0x00}, 6078d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_SWR_HM_TEST_TX_1, 0x00}, 6088d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_SWR_HM_TEST_TX_2, 0x00}, 6098d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_SWR_HM_TEST_0, 0x00}, 6108d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_SWR_HM_TEST_1, 0x00}, 6118d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_PAD_CTL_SWR_0, 0x8F}, 6128d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_PAD_CTL_SWR_1, 0x06}, 6138d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_I2C_CTL, 0x00}, 6148d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_CDC_TX_TANGGU_SW_MODE, 0x00}, 6158d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_EFUSE_TEST_CTL_0, 0x00}, 6168d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_EFUSE_TEST_CTL_1, 0x00}, 6178d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_EFUSE_T_DATA_0, 0x00}, 6188d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_EFUSE_T_DATA_1, 0x00}, 6198d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_PAD_CTL_PDM_RX0, 0xF1}, 6208d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_PAD_CTL_PDM_RX1, 0xF1}, 6218d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_PAD_CTL_PDM_TX0, 0xF1}, 6228d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_PAD_CTL_PDM_TX1, 0xF1}, 6238d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_PAD_CTL_PDM_TX2, 0xF1}, 6248d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_PAD_INP_DIS_0, 0x00}, 6258d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_PAD_INP_DIS_1, 0x00}, 6268d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_DRIVE_STRENGTH_0, 0x00}, 6278d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_DRIVE_STRENGTH_1, 0x00}, 6288d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_DRIVE_STRENGTH_2, 0x00}, 6298d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_RX_DATA_EDGE_CTL, 0x1F}, 6308d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_TX_DATA_EDGE_CTL, 0x80}, 6318d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_GPIO_MODE, 0x00}, 6328d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_PIN_CTL_OE, 0x00}, 6338d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_PIN_CTL_DATA_0, 0x00}, 6348d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_PIN_CTL_DATA_1, 0x00}, 6358d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_PIN_STATUS_0, 0x00}, 6368d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_PIN_STATUS_1, 0x00}, 6378d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_DIG_DEBUG_CTL, 0x00}, 6388d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_DIG_DEBUG_EN, 0x00}, 6398d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_ANA_CSR_DBG_ADD, 0x00}, 6408d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_ANA_CSR_DBG_CTL, 0x48}, 6418d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_SSP_DBG, 0x00}, 6428d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_MODE_STATUS_0, 0x00}, 6438d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_MODE_STATUS_1, 0x00}, 6448d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_SPARE_0, 0x00}, 6458d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_SPARE_1, 0x00}, 6468d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_SPARE_2, 0x00}, 6478d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_EFUSE_REG_0, 0x00}, 6488d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_EFUSE_REG_1, 0xFF}, 6498d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_EFUSE_REG_2, 0xFF}, 6508d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_EFUSE_REG_3, 0xFF}, 6518d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_EFUSE_REG_4, 0xFF}, 6528d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_EFUSE_REG_5, 0xFF}, 6538d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_EFUSE_REG_6, 0xFF}, 6548d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_EFUSE_REG_7, 0xFF}, 6558d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_EFUSE_REG_8, 0xFF}, 6568d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_EFUSE_REG_9, 0xFF}, 6578d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_EFUSE_REG_10, 0xFF}, 6588d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_EFUSE_REG_11, 0xFF}, 6598d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_EFUSE_REG_12, 0xFF}, 6608d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_EFUSE_REG_13, 0xFF}, 6618d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_EFUSE_REG_14, 0xFF}, 6628d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_EFUSE_REG_15, 0xFF}, 6638d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_EFUSE_REG_16, 0xFF}, 6648d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_EFUSE_REG_17, 0xFF}, 6658d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_EFUSE_REG_18, 0xFF}, 6668d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_EFUSE_REG_19, 0xFF}, 6678d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_EFUSE_REG_20, 0x0E}, 6688d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_EFUSE_REG_21, 0x00}, 6698d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_EFUSE_REG_22, 0x00}, 6708d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_EFUSE_REG_23, 0xF8}, 6718d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_EFUSE_REG_24, 0x16}, 6728d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_EFUSE_REG_25, 0x00}, 6738d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_EFUSE_REG_26, 0x00}, 6748d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_EFUSE_REG_27, 0x00}, 6758d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_EFUSE_REG_28, 0x00}, 6768d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_EFUSE_REG_29, 0x00}, 6778d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_EFUSE_REG_30, 0x00}, 6788d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_EFUSE_REG_31, 0x00}, 6798d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_TX_REQ_FB_CTL_0, 0x88}, 6808d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_TX_REQ_FB_CTL_1, 0x88}, 6818d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_TX_REQ_FB_CTL_2, 0x88}, 6828d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_TX_REQ_FB_CTL_3, 0x88}, 6838d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_TX_REQ_FB_CTL_4, 0x88}, 6848d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_DEM_BYPASS_DATA0, 0x55}, 6858d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_DEM_BYPASS_DATA1, 0x55}, 6868d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_DEM_BYPASS_DATA2, 0x55}, 6878d78602aSSrinivas Kandagatla {WCD938X_DIGITAL_DEM_BYPASS_DATA3, 0x01}, 6888d78602aSSrinivas Kandagatla }; 6898d78602aSSrinivas Kandagatla 6908d78602aSSrinivas Kandagatla static bool wcd938x_rdwr_register(struct device *dev, unsigned int reg) 6918d78602aSSrinivas Kandagatla { 6928d78602aSSrinivas Kandagatla switch (reg) { 6938d78602aSSrinivas Kandagatla case WCD938X_ANA_PAGE_REGISTER: 6948d78602aSSrinivas Kandagatla case WCD938X_ANA_BIAS: 6958d78602aSSrinivas Kandagatla case WCD938X_ANA_RX_SUPPLIES: 6968d78602aSSrinivas Kandagatla case WCD938X_ANA_HPH: 6978d78602aSSrinivas Kandagatla case WCD938X_ANA_EAR: 6988d78602aSSrinivas Kandagatla case WCD938X_ANA_EAR_COMPANDER_CTL: 6998d78602aSSrinivas Kandagatla case WCD938X_ANA_TX_CH1: 7008d78602aSSrinivas Kandagatla case WCD938X_ANA_TX_CH2: 7018d78602aSSrinivas Kandagatla case WCD938X_ANA_TX_CH3: 7028d78602aSSrinivas Kandagatla case WCD938X_ANA_TX_CH4: 7038d78602aSSrinivas Kandagatla case WCD938X_ANA_MICB1_MICB2_DSP_EN_LOGIC: 7048d78602aSSrinivas Kandagatla case WCD938X_ANA_MICB3_DSP_EN_LOGIC: 7058d78602aSSrinivas Kandagatla case WCD938X_ANA_MBHC_MECH: 7068d78602aSSrinivas Kandagatla case WCD938X_ANA_MBHC_ELECT: 7078d78602aSSrinivas Kandagatla case WCD938X_ANA_MBHC_ZDET: 7088d78602aSSrinivas Kandagatla case WCD938X_ANA_MBHC_BTN0: 7098d78602aSSrinivas Kandagatla case WCD938X_ANA_MBHC_BTN1: 7108d78602aSSrinivas Kandagatla case WCD938X_ANA_MBHC_BTN2: 7118d78602aSSrinivas Kandagatla case WCD938X_ANA_MBHC_BTN3: 7128d78602aSSrinivas Kandagatla case WCD938X_ANA_MBHC_BTN4: 7138d78602aSSrinivas Kandagatla case WCD938X_ANA_MBHC_BTN5: 7148d78602aSSrinivas Kandagatla case WCD938X_ANA_MBHC_BTN6: 7158d78602aSSrinivas Kandagatla case WCD938X_ANA_MBHC_BTN7: 7168d78602aSSrinivas Kandagatla case WCD938X_ANA_MICB1: 7178d78602aSSrinivas Kandagatla case WCD938X_ANA_MICB2: 7188d78602aSSrinivas Kandagatla case WCD938X_ANA_MICB2_RAMP: 7198d78602aSSrinivas Kandagatla case WCD938X_ANA_MICB3: 7208d78602aSSrinivas Kandagatla case WCD938X_ANA_MICB4: 7218d78602aSSrinivas Kandagatla case WCD938X_BIAS_CTL: 7228d78602aSSrinivas Kandagatla case WCD938X_BIAS_VBG_FINE_ADJ: 7238d78602aSSrinivas Kandagatla case WCD938X_LDOL_VDDCX_ADJUST: 7248d78602aSSrinivas Kandagatla case WCD938X_LDOL_DISABLE_LDOL: 7258d78602aSSrinivas Kandagatla case WCD938X_MBHC_CTL_CLK: 7268d78602aSSrinivas Kandagatla case WCD938X_MBHC_CTL_ANA: 7278d78602aSSrinivas Kandagatla case WCD938X_MBHC_CTL_SPARE_1: 7288d78602aSSrinivas Kandagatla case WCD938X_MBHC_CTL_SPARE_2: 7298d78602aSSrinivas Kandagatla case WCD938X_MBHC_CTL_BCS: 7308d78602aSSrinivas Kandagatla case WCD938X_MBHC_TEST_CTL: 7318d78602aSSrinivas Kandagatla case WCD938X_LDOH_MODE: 7328d78602aSSrinivas Kandagatla case WCD938X_LDOH_BIAS: 7338d78602aSSrinivas Kandagatla case WCD938X_LDOH_STB_LOADS: 7348d78602aSSrinivas Kandagatla case WCD938X_LDOH_SLOWRAMP: 7358d78602aSSrinivas Kandagatla case WCD938X_MICB1_TEST_CTL_1: 7368d78602aSSrinivas Kandagatla case WCD938X_MICB1_TEST_CTL_2: 7378d78602aSSrinivas Kandagatla case WCD938X_MICB1_TEST_CTL_3: 7388d78602aSSrinivas Kandagatla case WCD938X_MICB2_TEST_CTL_1: 7398d78602aSSrinivas Kandagatla case WCD938X_MICB2_TEST_CTL_2: 7408d78602aSSrinivas Kandagatla case WCD938X_MICB2_TEST_CTL_3: 7418d78602aSSrinivas Kandagatla case WCD938X_MICB3_TEST_CTL_1: 7428d78602aSSrinivas Kandagatla case WCD938X_MICB3_TEST_CTL_2: 7438d78602aSSrinivas Kandagatla case WCD938X_MICB3_TEST_CTL_3: 7448d78602aSSrinivas Kandagatla case WCD938X_MICB4_TEST_CTL_1: 7458d78602aSSrinivas Kandagatla case WCD938X_MICB4_TEST_CTL_2: 7468d78602aSSrinivas Kandagatla case WCD938X_MICB4_TEST_CTL_3: 7478d78602aSSrinivas Kandagatla case WCD938X_TX_COM_ADC_VCM: 7488d78602aSSrinivas Kandagatla case WCD938X_TX_COM_BIAS_ATEST: 7498d78602aSSrinivas Kandagatla case WCD938X_TX_COM_SPARE1: 7508d78602aSSrinivas Kandagatla case WCD938X_TX_COM_SPARE2: 7518d78602aSSrinivas Kandagatla case WCD938X_TX_COM_TXFE_DIV_CTL: 7528d78602aSSrinivas Kandagatla case WCD938X_TX_COM_TXFE_DIV_START: 7538d78602aSSrinivas Kandagatla case WCD938X_TX_COM_SPARE3: 7548d78602aSSrinivas Kandagatla case WCD938X_TX_COM_SPARE4: 7558d78602aSSrinivas Kandagatla case WCD938X_TX_1_2_TEST_EN: 7568d78602aSSrinivas Kandagatla case WCD938X_TX_1_2_ADC_IB: 7578d78602aSSrinivas Kandagatla case WCD938X_TX_1_2_ATEST_REFCTL: 7588d78602aSSrinivas Kandagatla case WCD938X_TX_1_2_TEST_CTL: 7598d78602aSSrinivas Kandagatla case WCD938X_TX_1_2_TEST_BLK_EN1: 7608d78602aSSrinivas Kandagatla case WCD938X_TX_1_2_TXFE1_CLKDIV: 7618d78602aSSrinivas Kandagatla case WCD938X_TX_3_4_TEST_EN: 7628d78602aSSrinivas Kandagatla case WCD938X_TX_3_4_ADC_IB: 7638d78602aSSrinivas Kandagatla case WCD938X_TX_3_4_ATEST_REFCTL: 7648d78602aSSrinivas Kandagatla case WCD938X_TX_3_4_TEST_CTL: 7658d78602aSSrinivas Kandagatla case WCD938X_TX_3_4_TEST_BLK_EN3: 7668d78602aSSrinivas Kandagatla case WCD938X_TX_3_4_TXFE3_CLKDIV: 7678d78602aSSrinivas Kandagatla case WCD938X_TX_3_4_TEST_BLK_EN2: 7688d78602aSSrinivas Kandagatla case WCD938X_TX_3_4_TXFE2_CLKDIV: 7698d78602aSSrinivas Kandagatla case WCD938X_TX_3_4_SPARE1: 7708d78602aSSrinivas Kandagatla case WCD938X_TX_3_4_TEST_BLK_EN4: 7718d78602aSSrinivas Kandagatla case WCD938X_TX_3_4_TXFE4_CLKDIV: 7728d78602aSSrinivas Kandagatla case WCD938X_TX_3_4_SPARE2: 7738d78602aSSrinivas Kandagatla case WCD938X_CLASSH_MODE_1: 7748d78602aSSrinivas Kandagatla case WCD938X_CLASSH_MODE_2: 7758d78602aSSrinivas Kandagatla case WCD938X_CLASSH_MODE_3: 7768d78602aSSrinivas Kandagatla case WCD938X_CLASSH_CTRL_VCL_1: 7778d78602aSSrinivas Kandagatla case WCD938X_CLASSH_CTRL_VCL_2: 7788d78602aSSrinivas Kandagatla case WCD938X_CLASSH_CTRL_CCL_1: 7798d78602aSSrinivas Kandagatla case WCD938X_CLASSH_CTRL_CCL_2: 7808d78602aSSrinivas Kandagatla case WCD938X_CLASSH_CTRL_CCL_3: 7818d78602aSSrinivas Kandagatla case WCD938X_CLASSH_CTRL_CCL_4: 7828d78602aSSrinivas Kandagatla case WCD938X_CLASSH_CTRL_CCL_5: 7838d78602aSSrinivas Kandagatla case WCD938X_CLASSH_BUCK_TMUX_A_D: 7848d78602aSSrinivas Kandagatla case WCD938X_CLASSH_BUCK_SW_DRV_CNTL: 7858d78602aSSrinivas Kandagatla case WCD938X_CLASSH_SPARE: 7868d78602aSSrinivas Kandagatla case WCD938X_FLYBACK_EN: 7878d78602aSSrinivas Kandagatla case WCD938X_FLYBACK_VNEG_CTRL_1: 7888d78602aSSrinivas Kandagatla case WCD938X_FLYBACK_VNEG_CTRL_2: 7898d78602aSSrinivas Kandagatla case WCD938X_FLYBACK_VNEG_CTRL_3: 7908d78602aSSrinivas Kandagatla case WCD938X_FLYBACK_VNEG_CTRL_4: 7918d78602aSSrinivas Kandagatla case WCD938X_FLYBACK_VNEG_CTRL_5: 7928d78602aSSrinivas Kandagatla case WCD938X_FLYBACK_VNEG_CTRL_6: 7938d78602aSSrinivas Kandagatla case WCD938X_FLYBACK_VNEG_CTRL_7: 7948d78602aSSrinivas Kandagatla case WCD938X_FLYBACK_VNEG_CTRL_8: 7958d78602aSSrinivas Kandagatla case WCD938X_FLYBACK_VNEG_CTRL_9: 7968d78602aSSrinivas Kandagatla case WCD938X_FLYBACK_VNEGDAC_CTRL_1: 7978d78602aSSrinivas Kandagatla case WCD938X_FLYBACK_VNEGDAC_CTRL_2: 7988d78602aSSrinivas Kandagatla case WCD938X_FLYBACK_VNEGDAC_CTRL_3: 7998d78602aSSrinivas Kandagatla case WCD938X_FLYBACK_CTRL_1: 8008d78602aSSrinivas Kandagatla case WCD938X_FLYBACK_TEST_CTL: 8018d78602aSSrinivas Kandagatla case WCD938X_RX_AUX_SW_CTL: 8028d78602aSSrinivas Kandagatla case WCD938X_RX_PA_AUX_IN_CONN: 8038d78602aSSrinivas Kandagatla case WCD938X_RX_TIMER_DIV: 8048d78602aSSrinivas Kandagatla case WCD938X_RX_OCP_CTL: 8058d78602aSSrinivas Kandagatla case WCD938X_RX_OCP_COUNT: 8068d78602aSSrinivas Kandagatla case WCD938X_RX_BIAS_EAR_DAC: 8078d78602aSSrinivas Kandagatla case WCD938X_RX_BIAS_EAR_AMP: 8088d78602aSSrinivas Kandagatla case WCD938X_RX_BIAS_HPH_LDO: 8098d78602aSSrinivas Kandagatla case WCD938X_RX_BIAS_HPH_PA: 8108d78602aSSrinivas Kandagatla case WCD938X_RX_BIAS_HPH_RDACBUFF_CNP2: 8118d78602aSSrinivas Kandagatla case WCD938X_RX_BIAS_HPH_RDAC_LDO: 8128d78602aSSrinivas Kandagatla case WCD938X_RX_BIAS_HPH_CNP1: 8138d78602aSSrinivas Kandagatla case WCD938X_RX_BIAS_HPH_LOWPOWER: 8148d78602aSSrinivas Kandagatla case WCD938X_RX_BIAS_AUX_DAC: 8158d78602aSSrinivas Kandagatla case WCD938X_RX_BIAS_AUX_AMP: 8168d78602aSSrinivas Kandagatla case WCD938X_RX_BIAS_VNEGDAC_BLEEDER: 8178d78602aSSrinivas Kandagatla case WCD938X_RX_BIAS_MISC: 8188d78602aSSrinivas Kandagatla case WCD938X_RX_BIAS_BUCK_RST: 8198d78602aSSrinivas Kandagatla case WCD938X_RX_BIAS_BUCK_VREF_ERRAMP: 8208d78602aSSrinivas Kandagatla case WCD938X_RX_BIAS_FLYB_ERRAMP: 8218d78602aSSrinivas Kandagatla case WCD938X_RX_BIAS_FLYB_BUFF: 8228d78602aSSrinivas Kandagatla case WCD938X_RX_BIAS_FLYB_MID_RST: 8238d78602aSSrinivas Kandagatla case WCD938X_HPH_CNP_EN: 8248d78602aSSrinivas Kandagatla case WCD938X_HPH_CNP_WG_CTL: 8258d78602aSSrinivas Kandagatla case WCD938X_HPH_CNP_WG_TIME: 8268d78602aSSrinivas Kandagatla case WCD938X_HPH_OCP_CTL: 8278d78602aSSrinivas Kandagatla case WCD938X_HPH_AUTO_CHOP: 8288d78602aSSrinivas Kandagatla case WCD938X_HPH_CHOP_CTL: 8298d78602aSSrinivas Kandagatla case WCD938X_HPH_PA_CTL1: 8308d78602aSSrinivas Kandagatla case WCD938X_HPH_PA_CTL2: 8318d78602aSSrinivas Kandagatla case WCD938X_HPH_L_EN: 8328d78602aSSrinivas Kandagatla case WCD938X_HPH_L_TEST: 8338d78602aSSrinivas Kandagatla case WCD938X_HPH_L_ATEST: 8348d78602aSSrinivas Kandagatla case WCD938X_HPH_R_EN: 8358d78602aSSrinivas Kandagatla case WCD938X_HPH_R_TEST: 8368d78602aSSrinivas Kandagatla case WCD938X_HPH_R_ATEST: 8378d78602aSSrinivas Kandagatla case WCD938X_HPH_RDAC_CLK_CTL1: 8388d78602aSSrinivas Kandagatla case WCD938X_HPH_RDAC_CLK_CTL2: 8398d78602aSSrinivas Kandagatla case WCD938X_HPH_RDAC_LDO_CTL: 8408d78602aSSrinivas Kandagatla case WCD938X_HPH_RDAC_CHOP_CLK_LP_CTL: 8418d78602aSSrinivas Kandagatla case WCD938X_HPH_REFBUFF_UHQA_CTL: 8428d78602aSSrinivas Kandagatla case WCD938X_HPH_REFBUFF_LP_CTL: 8438d78602aSSrinivas Kandagatla case WCD938X_HPH_L_DAC_CTL: 8448d78602aSSrinivas Kandagatla case WCD938X_HPH_R_DAC_CTL: 8458d78602aSSrinivas Kandagatla case WCD938X_HPH_SURGE_HPHLR_SURGE_COMP_SEL: 8468d78602aSSrinivas Kandagatla case WCD938X_HPH_SURGE_HPHLR_SURGE_EN: 8478d78602aSSrinivas Kandagatla case WCD938X_HPH_SURGE_HPHLR_SURGE_MISC1: 8488d78602aSSrinivas Kandagatla case WCD938X_EAR_EAR_EN_REG: 8498d78602aSSrinivas Kandagatla case WCD938X_EAR_EAR_PA_CON: 8508d78602aSSrinivas Kandagatla case WCD938X_EAR_EAR_SP_CON: 8518d78602aSSrinivas Kandagatla case WCD938X_EAR_EAR_DAC_CON: 8528d78602aSSrinivas Kandagatla case WCD938X_EAR_EAR_CNP_FSM_CON: 8538d78602aSSrinivas Kandagatla case WCD938X_EAR_TEST_CTL: 8548d78602aSSrinivas Kandagatla case WCD938X_ANA_NEW_PAGE_REGISTER: 8558d78602aSSrinivas Kandagatla case WCD938X_HPH_NEW_ANA_HPH2: 8568d78602aSSrinivas Kandagatla case WCD938X_HPH_NEW_ANA_HPH3: 8578d78602aSSrinivas Kandagatla case WCD938X_SLEEP_CTL: 8588d78602aSSrinivas Kandagatla case WCD938X_SLEEP_WATCHDOG_CTL: 8598d78602aSSrinivas Kandagatla case WCD938X_MBHC_NEW_ELECT_REM_CLAMP_CTL: 8608d78602aSSrinivas Kandagatla case WCD938X_MBHC_NEW_CTL_1: 8618d78602aSSrinivas Kandagatla case WCD938X_MBHC_NEW_CTL_2: 8628d78602aSSrinivas Kandagatla case WCD938X_MBHC_NEW_PLUG_DETECT_CTL: 8638d78602aSSrinivas Kandagatla case WCD938X_MBHC_NEW_ZDET_ANA_CTL: 8648d78602aSSrinivas Kandagatla case WCD938X_MBHC_NEW_ZDET_RAMP_CTL: 8658d78602aSSrinivas Kandagatla case WCD938X_TX_NEW_AMIC_MUX_CFG: 8668d78602aSSrinivas Kandagatla case WCD938X_AUX_AUXPA: 8678d78602aSSrinivas Kandagatla case WCD938X_LDORXTX_MODE: 8688d78602aSSrinivas Kandagatla case WCD938X_LDORXTX_CONFIG: 8698d78602aSSrinivas Kandagatla case WCD938X_DIE_CRACK_DIE_CRK_DET_EN: 8708d78602aSSrinivas Kandagatla case WCD938X_HPH_NEW_INT_RDAC_GAIN_CTL: 8718d78602aSSrinivas Kandagatla case WCD938X_HPH_NEW_INT_RDAC_HD2_CTL_L: 8728d78602aSSrinivas Kandagatla case WCD938X_HPH_NEW_INT_RDAC_VREF_CTL: 8738d78602aSSrinivas Kandagatla case WCD938X_HPH_NEW_INT_RDAC_OVERRIDE_CTL: 8748d78602aSSrinivas Kandagatla case WCD938X_HPH_NEW_INT_RDAC_HD2_CTL_R: 8758d78602aSSrinivas Kandagatla case WCD938X_HPH_NEW_INT_PA_MISC1: 8768d78602aSSrinivas Kandagatla case WCD938X_HPH_NEW_INT_PA_MISC2: 8778d78602aSSrinivas Kandagatla case WCD938X_HPH_NEW_INT_PA_RDAC_MISC: 8788d78602aSSrinivas Kandagatla case WCD938X_HPH_NEW_INT_HPH_TIMER1: 8798d78602aSSrinivas Kandagatla case WCD938X_HPH_NEW_INT_HPH_TIMER2: 8808d78602aSSrinivas Kandagatla case WCD938X_HPH_NEW_INT_HPH_TIMER3: 8818d78602aSSrinivas Kandagatla case WCD938X_HPH_NEW_INT_HPH_TIMER4: 8828d78602aSSrinivas Kandagatla case WCD938X_HPH_NEW_INT_PA_RDAC_MISC2: 8838d78602aSSrinivas Kandagatla case WCD938X_HPH_NEW_INT_PA_RDAC_MISC3: 8848d78602aSSrinivas Kandagatla case WCD938X_HPH_NEW_INT_RDAC_HD2_CTL_L_NEW: 8858d78602aSSrinivas Kandagatla case WCD938X_HPH_NEW_INT_RDAC_HD2_CTL_R_NEW: 8868d78602aSSrinivas Kandagatla case WCD938X_RX_NEW_INT_HPH_RDAC_BIAS_LOHIFI: 8878d78602aSSrinivas Kandagatla case WCD938X_RX_NEW_INT_HPH_RDAC_BIAS_ULP: 8888d78602aSSrinivas Kandagatla case WCD938X_RX_NEW_INT_HPH_RDAC_LDO_LP: 8898d78602aSSrinivas Kandagatla case WCD938X_MBHC_NEW_INT_MOISTURE_DET_DC_CTRL: 8908d78602aSSrinivas Kandagatla case WCD938X_MBHC_NEW_INT_MOISTURE_DET_POLLING_CTRL: 8918d78602aSSrinivas Kandagatla case WCD938X_MBHC_NEW_INT_MECH_DET_CURRENT: 8928d78602aSSrinivas Kandagatla case WCD938X_MBHC_NEW_INT_SPARE_2: 8938d78602aSSrinivas Kandagatla case WCD938X_EAR_INT_NEW_EAR_CHOPPER_CON: 8948d78602aSSrinivas Kandagatla case WCD938X_EAR_INT_NEW_CNP_VCM_CON1: 8958d78602aSSrinivas Kandagatla case WCD938X_EAR_INT_NEW_CNP_VCM_CON2: 8968d78602aSSrinivas Kandagatla case WCD938X_EAR_INT_NEW_EAR_DYNAMIC_BIAS: 8978d78602aSSrinivas Kandagatla case WCD938X_AUX_INT_EN_REG: 8988d78602aSSrinivas Kandagatla case WCD938X_AUX_INT_PA_CTRL: 8998d78602aSSrinivas Kandagatla case WCD938X_AUX_INT_SP_CTRL: 9008d78602aSSrinivas Kandagatla case WCD938X_AUX_INT_DAC_CTRL: 9018d78602aSSrinivas Kandagatla case WCD938X_AUX_INT_CLK_CTRL: 9028d78602aSSrinivas Kandagatla case WCD938X_AUX_INT_TEST_CTRL: 9038d78602aSSrinivas Kandagatla case WCD938X_AUX_INT_MISC: 9048d78602aSSrinivas Kandagatla case WCD938X_LDORXTX_INT_BIAS: 9058d78602aSSrinivas Kandagatla case WCD938X_LDORXTX_INT_STB_LOADS_DTEST: 9068d78602aSSrinivas Kandagatla case WCD938X_LDORXTX_INT_TEST0: 9078d78602aSSrinivas Kandagatla case WCD938X_LDORXTX_INT_STARTUP_TIMER: 9088d78602aSSrinivas Kandagatla case WCD938X_LDORXTX_INT_TEST1: 9098d78602aSSrinivas Kandagatla case WCD938X_SLEEP_INT_WATCHDOG_CTL_1: 9108d78602aSSrinivas Kandagatla case WCD938X_SLEEP_INT_WATCHDOG_CTL_2: 9118d78602aSSrinivas Kandagatla case WCD938X_DIE_CRACK_INT_DIE_CRK_DET_INT1: 9128d78602aSSrinivas Kandagatla case WCD938X_DIE_CRACK_INT_DIE_CRK_DET_INT2: 9138d78602aSSrinivas Kandagatla case WCD938X_TX_COM_NEW_INT_TXFE_DIVSTOP_L2: 9148d78602aSSrinivas Kandagatla case WCD938X_TX_COM_NEW_INT_TXFE_DIVSTOP_L1: 9158d78602aSSrinivas Kandagatla case WCD938X_TX_COM_NEW_INT_TXFE_DIVSTOP_L0: 9168d78602aSSrinivas Kandagatla case WCD938X_TX_COM_NEW_INT_TXFE_DIVSTOP_ULP1P2M: 9178d78602aSSrinivas Kandagatla case WCD938X_TX_COM_NEW_INT_TXFE_DIVSTOP_ULP0P6M: 9188d78602aSSrinivas Kandagatla case WCD938X_TX_COM_NEW_INT_TXFE_ICTRL_STG1_L2L1: 9198d78602aSSrinivas Kandagatla case WCD938X_TX_COM_NEW_INT_TXFE_ICTRL_STG1_L0: 9208d78602aSSrinivas Kandagatla case WCD938X_TX_COM_NEW_INT_TXFE_ICTRL_STG1_ULP: 9218d78602aSSrinivas Kandagatla case WCD938X_TX_COM_NEW_INT_TXFE_ICTRL_STG2MAIN_L2L1: 9228d78602aSSrinivas Kandagatla case WCD938X_TX_COM_NEW_INT_TXFE_ICTRL_STG2MAIN_L0: 9238d78602aSSrinivas Kandagatla case WCD938X_TX_COM_NEW_INT_TXFE_ICTRL_STG2MAIN_ULP: 9248d78602aSSrinivas Kandagatla case WCD938X_TX_COM_NEW_INT_TXFE_ICTRL_STG2CASC_L2L1L0: 9258d78602aSSrinivas Kandagatla case WCD938X_TX_COM_NEW_INT_TXFE_ICTRL_STG2CASC_ULP: 9268d78602aSSrinivas Kandagatla case WCD938X_TX_COM_NEW_INT_TXADC_SCBIAS_L2L1: 9278d78602aSSrinivas Kandagatla case WCD938X_TX_COM_NEW_INT_TXADC_SCBIAS_L0ULP: 9288d78602aSSrinivas Kandagatla case WCD938X_TX_COM_NEW_INT_TXADC_INT_L2: 9298d78602aSSrinivas Kandagatla case WCD938X_TX_COM_NEW_INT_TXADC_INT_L1: 9308d78602aSSrinivas Kandagatla case WCD938X_TX_COM_NEW_INT_TXADC_INT_L0: 9318d78602aSSrinivas Kandagatla case WCD938X_TX_COM_NEW_INT_TXADC_INT_ULP: 9328d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_PAGE_REGISTER: 9338d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_SWR_TX_CLK_RATE: 9348d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_CDC_RST_CTL: 9358d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_TOP_CLK_CFG: 9368d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_CDC_ANA_CLK_CTL: 9378d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_CDC_DIG_CLK_CTL: 9388d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_SWR_RST_EN: 9398d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_CDC_PATH_MODE: 9408d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_CDC_RX_RST: 9418d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_CDC_RX0_CTL: 9428d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_CDC_RX1_CTL: 9438d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_CDC_RX2_CTL: 9448d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_CDC_TX_ANA_MODE_0_1: 9458d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_CDC_TX_ANA_MODE_2_3: 9468d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_CDC_COMP_CTL_0: 9478d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_CDC_ANA_TX_CLK_CTL: 9488d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_CDC_HPH_DSM_A1_0: 9498d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_CDC_HPH_DSM_A1_1: 9508d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_CDC_HPH_DSM_A2_0: 9518d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_CDC_HPH_DSM_A2_1: 9528d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_CDC_HPH_DSM_A3_0: 9538d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_CDC_HPH_DSM_A3_1: 9548d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_CDC_HPH_DSM_A4_0: 9558d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_CDC_HPH_DSM_A4_1: 9568d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_CDC_HPH_DSM_A5_0: 9578d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_CDC_HPH_DSM_A5_1: 9588d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_CDC_HPH_DSM_A6_0: 9598d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_CDC_HPH_DSM_A7_0: 9608d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_CDC_HPH_DSM_C_0: 9618d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_CDC_HPH_DSM_C_1: 9628d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_CDC_HPH_DSM_C_2: 9638d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_CDC_HPH_DSM_C_3: 9648d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_CDC_HPH_DSM_R1: 9658d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_CDC_HPH_DSM_R2: 9668d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_CDC_HPH_DSM_R3: 9678d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_CDC_HPH_DSM_R4: 9688d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_CDC_HPH_DSM_R5: 9698d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_CDC_HPH_DSM_R6: 9708d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_CDC_HPH_DSM_R7: 9718d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_CDC_AUX_DSM_A1_0: 9728d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_CDC_AUX_DSM_A1_1: 9738d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_CDC_AUX_DSM_A2_0: 9748d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_CDC_AUX_DSM_A2_1: 9758d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_CDC_AUX_DSM_A3_0: 9768d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_CDC_AUX_DSM_A3_1: 9778d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_CDC_AUX_DSM_A4_0: 9788d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_CDC_AUX_DSM_A4_1: 9798d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_CDC_AUX_DSM_A5_0: 9808d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_CDC_AUX_DSM_A5_1: 9818d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_CDC_AUX_DSM_A6_0: 9828d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_CDC_AUX_DSM_A7_0: 9838d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_CDC_AUX_DSM_C_0: 9848d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_CDC_AUX_DSM_C_1: 9858d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_CDC_AUX_DSM_C_2: 9868d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_CDC_AUX_DSM_C_3: 9878d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_CDC_AUX_DSM_R1: 9888d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_CDC_AUX_DSM_R2: 9898d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_CDC_AUX_DSM_R3: 9908d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_CDC_AUX_DSM_R4: 9918d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_CDC_AUX_DSM_R5: 9928d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_CDC_AUX_DSM_R6: 9938d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_CDC_AUX_DSM_R7: 9948d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_CDC_HPH_GAIN_RX_0: 9958d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_CDC_HPH_GAIN_RX_1: 9968d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_CDC_HPH_GAIN_DSD_0: 9978d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_CDC_HPH_GAIN_DSD_1: 9988d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_CDC_HPH_GAIN_DSD_2: 9998d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_CDC_AUX_GAIN_DSD_0: 10008d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_CDC_AUX_GAIN_DSD_1: 10018d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_CDC_AUX_GAIN_DSD_2: 10028d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_CDC_HPH_GAIN_CTL: 10038d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_CDC_AUX_GAIN_CTL: 10048d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_CDC_EAR_PATH_CTL: 10058d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_CDC_SWR_CLH: 10068d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_SWR_CLH_BYP: 10078d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_CDC_TX0_CTL: 10088d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_CDC_TX1_CTL: 10098d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_CDC_TX2_CTL: 10108d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_CDC_TX_RST: 10118d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_CDC_REQ_CTL: 10128d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_CDC_RST: 10138d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_CDC_AMIC_CTL: 10148d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_CDC_DMIC_CTL: 10158d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_CDC_DMIC1_CTL: 10168d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_CDC_DMIC2_CTL: 10178d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_CDC_DMIC3_CTL: 10188d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_CDC_DMIC4_CTL: 10198d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_EFUSE_PRG_CTL: 10208d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_EFUSE_CTL: 10218d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_CDC_DMIC_RATE_1_2: 10228d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_CDC_DMIC_RATE_3_4: 10238d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_PDM_WD_CTL0: 10248d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_PDM_WD_CTL1: 10258d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_PDM_WD_CTL2: 10268d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_INTR_MODE: 10278d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_INTR_MASK_0: 10288d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_INTR_MASK_1: 10298d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_INTR_MASK_2: 10308d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_INTR_CLEAR_0: 10318d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_INTR_CLEAR_1: 10328d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_INTR_CLEAR_2: 10338d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_INTR_LEVEL_0: 10348d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_INTR_LEVEL_1: 10358d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_INTR_LEVEL_2: 10368d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_INTR_SET_0: 10378d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_INTR_SET_1: 10388d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_INTR_SET_2: 10398d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_INTR_TEST_0: 10408d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_INTR_TEST_1: 10418d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_INTR_TEST_2: 10428d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_TX_MODE_DBG_EN: 10438d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_TX_MODE_DBG_0_1: 10448d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_TX_MODE_DBG_2_3: 10458d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_LB_IN_SEL_CTL: 10468d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_LOOP_BACK_MODE: 10478d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_SWR_DAC_TEST: 10488d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_SWR_HM_TEST_RX_0: 10498d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_SWR_HM_TEST_TX_0: 10508d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_SWR_HM_TEST_RX_1: 10518d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_SWR_HM_TEST_TX_1: 10528d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_SWR_HM_TEST_TX_2: 10538d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_PAD_CTL_SWR_0: 10548d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_PAD_CTL_SWR_1: 10558d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_I2C_CTL: 10568d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_CDC_TX_TANGGU_SW_MODE: 10578d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_EFUSE_TEST_CTL_0: 10588d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_EFUSE_TEST_CTL_1: 10598d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_PAD_CTL_PDM_RX0: 10608d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_PAD_CTL_PDM_RX1: 10618d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_PAD_CTL_PDM_TX0: 10628d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_PAD_CTL_PDM_TX1: 10638d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_PAD_CTL_PDM_TX2: 10648d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_PAD_INP_DIS_0: 10658d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_PAD_INP_DIS_1: 10668d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_DRIVE_STRENGTH_0: 10678d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_DRIVE_STRENGTH_1: 10688d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_DRIVE_STRENGTH_2: 10698d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_RX_DATA_EDGE_CTL: 10708d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_TX_DATA_EDGE_CTL: 10718d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_GPIO_MODE: 10728d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_PIN_CTL_OE: 10738d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_PIN_CTL_DATA_0: 10748d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_PIN_CTL_DATA_1: 10758d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_DIG_DEBUG_CTL: 10768d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_DIG_DEBUG_EN: 10778d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_ANA_CSR_DBG_ADD: 10788d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_ANA_CSR_DBG_CTL: 10798d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_SSP_DBG: 10808d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_SPARE_0: 10818d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_SPARE_1: 10828d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_SPARE_2: 10838d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_TX_REQ_FB_CTL_0: 10848d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_TX_REQ_FB_CTL_1: 10858d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_TX_REQ_FB_CTL_2: 10868d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_TX_REQ_FB_CTL_3: 10878d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_TX_REQ_FB_CTL_4: 10888d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_DEM_BYPASS_DATA0: 10898d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_DEM_BYPASS_DATA1: 10908d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_DEM_BYPASS_DATA2: 10918d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_DEM_BYPASS_DATA3: 10928d78602aSSrinivas Kandagatla return true; 10938d78602aSSrinivas Kandagatla } 10948d78602aSSrinivas Kandagatla 10958d78602aSSrinivas Kandagatla return false; 10968d78602aSSrinivas Kandagatla } 10978d78602aSSrinivas Kandagatla 10988d78602aSSrinivas Kandagatla static bool wcd938x_readonly_register(struct device *dev, unsigned int reg) 10998d78602aSSrinivas Kandagatla { 11008d78602aSSrinivas Kandagatla switch (reg) { 11018d78602aSSrinivas Kandagatla case WCD938X_ANA_MBHC_RESULT_1: 11028d78602aSSrinivas Kandagatla case WCD938X_ANA_MBHC_RESULT_2: 11038d78602aSSrinivas Kandagatla case WCD938X_ANA_MBHC_RESULT_3: 11048d78602aSSrinivas Kandagatla case WCD938X_MBHC_MOISTURE_DET_FSM_STATUS: 11058d78602aSSrinivas Kandagatla case WCD938X_TX_1_2_SAR2_ERR: 11068d78602aSSrinivas Kandagatla case WCD938X_TX_1_2_SAR1_ERR: 11078d78602aSSrinivas Kandagatla case WCD938X_TX_3_4_SAR4_ERR: 11088d78602aSSrinivas Kandagatla case WCD938X_TX_3_4_SAR3_ERR: 11098d78602aSSrinivas Kandagatla case WCD938X_HPH_L_STATUS: 11108d78602aSSrinivas Kandagatla case WCD938X_HPH_R_STATUS: 11118d78602aSSrinivas Kandagatla case WCD938X_HPH_SURGE_HPHLR_SURGE_STATUS: 11128d78602aSSrinivas Kandagatla case WCD938X_EAR_STATUS_REG_1: 11138d78602aSSrinivas Kandagatla case WCD938X_EAR_STATUS_REG_2: 11148d78602aSSrinivas Kandagatla case WCD938X_MBHC_NEW_FSM_STATUS: 11158d78602aSSrinivas Kandagatla case WCD938X_MBHC_NEW_ADC_RESULT: 11168d78602aSSrinivas Kandagatla case WCD938X_DIE_CRACK_DIE_CRK_DET_OUT: 11178d78602aSSrinivas Kandagatla case WCD938X_AUX_INT_STATUS_REG: 11188d78602aSSrinivas Kandagatla case WCD938X_LDORXTX_INT_STATUS: 11198d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_CHIP_ID0: 11208d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_CHIP_ID1: 11218d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_CHIP_ID2: 11228d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_CHIP_ID3: 11238d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_INTR_STATUS_0: 11248d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_INTR_STATUS_1: 11258d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_INTR_STATUS_2: 11268d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_SWR_HM_TEST_0: 11278d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_SWR_HM_TEST_1: 11288d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_EFUSE_T_DATA_0: 11298d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_EFUSE_T_DATA_1: 11308d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_PIN_STATUS_0: 11318d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_PIN_STATUS_1: 11328d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_MODE_STATUS_0: 11338d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_MODE_STATUS_1: 11348d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_EFUSE_REG_0: 11358d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_EFUSE_REG_1: 11368d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_EFUSE_REG_2: 11378d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_EFUSE_REG_3: 11388d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_EFUSE_REG_4: 11398d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_EFUSE_REG_5: 11408d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_EFUSE_REG_6: 11418d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_EFUSE_REG_7: 11428d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_EFUSE_REG_8: 11438d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_EFUSE_REG_9: 11448d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_EFUSE_REG_10: 11458d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_EFUSE_REG_11: 11468d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_EFUSE_REG_12: 11478d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_EFUSE_REG_13: 11488d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_EFUSE_REG_14: 11498d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_EFUSE_REG_15: 11508d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_EFUSE_REG_16: 11518d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_EFUSE_REG_17: 11528d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_EFUSE_REG_18: 11538d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_EFUSE_REG_19: 11548d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_EFUSE_REG_20: 11558d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_EFUSE_REG_21: 11568d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_EFUSE_REG_22: 11578d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_EFUSE_REG_23: 11588d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_EFUSE_REG_24: 11598d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_EFUSE_REG_25: 11608d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_EFUSE_REG_26: 11618d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_EFUSE_REG_27: 11628d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_EFUSE_REG_28: 11638d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_EFUSE_REG_29: 11648d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_EFUSE_REG_30: 11658d78602aSSrinivas Kandagatla case WCD938X_DIGITAL_EFUSE_REG_31: 11668d78602aSSrinivas Kandagatla return true; 11678d78602aSSrinivas Kandagatla } 11688d78602aSSrinivas Kandagatla return false; 11698d78602aSSrinivas Kandagatla } 11708d78602aSSrinivas Kandagatla 11718d78602aSSrinivas Kandagatla static bool wcd938x_readable_register(struct device *dev, unsigned int reg) 11728d78602aSSrinivas Kandagatla { 11738d78602aSSrinivas Kandagatla bool ret; 11748d78602aSSrinivas Kandagatla 11758d78602aSSrinivas Kandagatla ret = wcd938x_readonly_register(dev, reg); 11768d78602aSSrinivas Kandagatla if (!ret) 11778d78602aSSrinivas Kandagatla return wcd938x_rdwr_register(dev, reg); 11788d78602aSSrinivas Kandagatla 11798d78602aSSrinivas Kandagatla return ret; 11808d78602aSSrinivas Kandagatla } 11818d78602aSSrinivas Kandagatla 11828d78602aSSrinivas Kandagatla static bool wcd938x_writeable_register(struct device *dev, unsigned int reg) 11838d78602aSSrinivas Kandagatla { 11848d78602aSSrinivas Kandagatla return wcd938x_rdwr_register(dev, reg); 11858d78602aSSrinivas Kandagatla } 11868d78602aSSrinivas Kandagatla 11878d78602aSSrinivas Kandagatla static bool wcd938x_volatile_register(struct device *dev, unsigned int reg) 11888d78602aSSrinivas Kandagatla { 11898d78602aSSrinivas Kandagatla if (reg <= WCD938X_BASE_ADDRESS) 11908d78602aSSrinivas Kandagatla return 0; 11918d78602aSSrinivas Kandagatla 11928d78602aSSrinivas Kandagatla if (reg == WCD938X_DIGITAL_SWR_TX_CLK_RATE) 11938d78602aSSrinivas Kandagatla return true; 11948d78602aSSrinivas Kandagatla 11958d78602aSSrinivas Kandagatla if (wcd938x_readonly_register(dev, reg)) 11968d78602aSSrinivas Kandagatla return true; 11978d78602aSSrinivas Kandagatla 11988d78602aSSrinivas Kandagatla return false; 11998d78602aSSrinivas Kandagatla } 12008d78602aSSrinivas Kandagatla 1201*b90d9398SSrinivas Kandagatla static struct regmap_config wcd938x_regmap_config = { 12028d78602aSSrinivas Kandagatla .name = "wcd938x_csr", 12038d78602aSSrinivas Kandagatla .reg_bits = 32, 12048d78602aSSrinivas Kandagatla .val_bits = 8, 12058d78602aSSrinivas Kandagatla .cache_type = REGCACHE_RBTREE, 12068d78602aSSrinivas Kandagatla .reg_defaults = wcd938x_defaults, 12078d78602aSSrinivas Kandagatla .num_reg_defaults = ARRAY_SIZE(wcd938x_defaults), 12088d78602aSSrinivas Kandagatla .max_register = WCD938X_MAX_REGISTER, 12098d78602aSSrinivas Kandagatla .readable_reg = wcd938x_readable_register, 12108d78602aSSrinivas Kandagatla .writeable_reg = wcd938x_writeable_register, 12118d78602aSSrinivas Kandagatla .volatile_reg = wcd938x_volatile_register, 12128d78602aSSrinivas Kandagatla .can_multi_write = true, 12138d78602aSSrinivas Kandagatla }; 12148d78602aSSrinivas Kandagatla 12158d78602aSSrinivas Kandagatla static const struct regmap_irq wcd938x_irqs[WCD938X_NUM_IRQS] = { 12168d78602aSSrinivas Kandagatla REGMAP_IRQ_REG(WCD938X_IRQ_MBHC_BUTTON_PRESS_DET, 0, 0x01), 12178d78602aSSrinivas Kandagatla REGMAP_IRQ_REG(WCD938X_IRQ_MBHC_BUTTON_RELEASE_DET, 0, 0x02), 12188d78602aSSrinivas Kandagatla REGMAP_IRQ_REG(WCD938X_IRQ_MBHC_ELECT_INS_REM_DET, 0, 0x04), 12198d78602aSSrinivas Kandagatla REGMAP_IRQ_REG(WCD938X_IRQ_MBHC_ELECT_INS_REM_LEG_DET, 0, 0x08), 12208d78602aSSrinivas Kandagatla REGMAP_IRQ_REG(WCD938X_IRQ_MBHC_SW_DET, 0, 0x10), 12218d78602aSSrinivas Kandagatla REGMAP_IRQ_REG(WCD938X_IRQ_HPHR_OCP_INT, 0, 0x20), 12228d78602aSSrinivas Kandagatla REGMAP_IRQ_REG(WCD938X_IRQ_HPHR_CNP_INT, 0, 0x40), 12238d78602aSSrinivas Kandagatla REGMAP_IRQ_REG(WCD938X_IRQ_HPHL_OCP_INT, 0, 0x80), 12248d78602aSSrinivas Kandagatla REGMAP_IRQ_REG(WCD938X_IRQ_HPHL_CNP_INT, 1, 0x01), 12258d78602aSSrinivas Kandagatla REGMAP_IRQ_REG(WCD938X_IRQ_EAR_CNP_INT, 1, 0x02), 12268d78602aSSrinivas Kandagatla REGMAP_IRQ_REG(WCD938X_IRQ_EAR_SCD_INT, 1, 0x04), 12278d78602aSSrinivas Kandagatla REGMAP_IRQ_REG(WCD938X_IRQ_AUX_CNP_INT, 1, 0x08), 12288d78602aSSrinivas Kandagatla REGMAP_IRQ_REG(WCD938X_IRQ_AUX_SCD_INT, 1, 0x10), 12298d78602aSSrinivas Kandagatla REGMAP_IRQ_REG(WCD938X_IRQ_HPHL_PDM_WD_INT, 1, 0x20), 12308d78602aSSrinivas Kandagatla REGMAP_IRQ_REG(WCD938X_IRQ_HPHR_PDM_WD_INT, 1, 0x40), 12318d78602aSSrinivas Kandagatla REGMAP_IRQ_REG(WCD938X_IRQ_AUX_PDM_WD_INT, 1, 0x80), 12328d78602aSSrinivas Kandagatla REGMAP_IRQ_REG(WCD938X_IRQ_LDORT_SCD_INT, 2, 0x01), 12338d78602aSSrinivas Kandagatla REGMAP_IRQ_REG(WCD938X_IRQ_MBHC_MOISTURE_INT, 2, 0x02), 12348d78602aSSrinivas Kandagatla REGMAP_IRQ_REG(WCD938X_IRQ_HPHL_SURGE_DET_INT, 2, 0x04), 12358d78602aSSrinivas Kandagatla REGMAP_IRQ_REG(WCD938X_IRQ_HPHR_SURGE_DET_INT, 2, 0x08), 12368d78602aSSrinivas Kandagatla }; 12378d78602aSSrinivas Kandagatla 12388d78602aSSrinivas Kandagatla static struct regmap_irq_chip wcd938x_regmap_irq_chip = { 12398d78602aSSrinivas Kandagatla .name = "wcd938x", 12408d78602aSSrinivas Kandagatla .irqs = wcd938x_irqs, 12418d78602aSSrinivas Kandagatla .num_irqs = ARRAY_SIZE(wcd938x_irqs), 12428d78602aSSrinivas Kandagatla .num_regs = 3, 12438d78602aSSrinivas Kandagatla .status_base = WCD938X_DIGITAL_INTR_STATUS_0, 12448d78602aSSrinivas Kandagatla .mask_base = WCD938X_DIGITAL_INTR_MASK_0, 12458d78602aSSrinivas Kandagatla .type_base = WCD938X_DIGITAL_INTR_LEVEL_0, 12468d78602aSSrinivas Kandagatla .ack_base = WCD938X_DIGITAL_INTR_CLEAR_0, 12478d78602aSSrinivas Kandagatla .use_ack = 1, 12488d78602aSSrinivas Kandagatla .runtime_pm = true, 12498d78602aSSrinivas Kandagatla .irq_drv_data = NULL, 12508d78602aSSrinivas Kandagatla }; 12518d78602aSSrinivas Kandagatla 1252d5add08fSSrinivas Kandagatla static int wcd938x_get_clk_rate(int mode) 1253d5add08fSSrinivas Kandagatla { 1254d5add08fSSrinivas Kandagatla int rate; 1255d5add08fSSrinivas Kandagatla 1256d5add08fSSrinivas Kandagatla switch (mode) { 1257d5add08fSSrinivas Kandagatla case ADC_MODE_ULP2: 1258d5add08fSSrinivas Kandagatla rate = SWR_CLK_RATE_0P6MHZ; 1259d5add08fSSrinivas Kandagatla break; 1260d5add08fSSrinivas Kandagatla case ADC_MODE_ULP1: 1261d5add08fSSrinivas Kandagatla rate = SWR_CLK_RATE_1P2MHZ; 1262d5add08fSSrinivas Kandagatla break; 1263d5add08fSSrinivas Kandagatla case ADC_MODE_LP: 1264d5add08fSSrinivas Kandagatla rate = SWR_CLK_RATE_4P8MHZ; 1265d5add08fSSrinivas Kandagatla break; 1266d5add08fSSrinivas Kandagatla case ADC_MODE_NORMAL: 1267d5add08fSSrinivas Kandagatla case ADC_MODE_LO_HIF: 1268d5add08fSSrinivas Kandagatla case ADC_MODE_HIFI: 1269d5add08fSSrinivas Kandagatla case ADC_MODE_INVALID: 1270d5add08fSSrinivas Kandagatla default: 1271d5add08fSSrinivas Kandagatla rate = SWR_CLK_RATE_9P6MHZ; 1272d5add08fSSrinivas Kandagatla break; 1273d5add08fSSrinivas Kandagatla } 1274d5add08fSSrinivas Kandagatla 1275d5add08fSSrinivas Kandagatla return rate; 1276d5add08fSSrinivas Kandagatla } 1277d5add08fSSrinivas Kandagatla 1278d5add08fSSrinivas Kandagatla static int wcd938x_set_swr_clk_rate(struct snd_soc_component *component, int rate, int bank) 1279d5add08fSSrinivas Kandagatla { 1280d5add08fSSrinivas Kandagatla u8 mask = (bank ? 0xF0 : 0x0F); 1281d5add08fSSrinivas Kandagatla u8 val = 0; 1282d5add08fSSrinivas Kandagatla 1283d5add08fSSrinivas Kandagatla switch (rate) { 1284d5add08fSSrinivas Kandagatla case SWR_CLK_RATE_0P6MHZ: 1285d5add08fSSrinivas Kandagatla val = (bank ? 0x60 : 0x06); 1286d5add08fSSrinivas Kandagatla break; 1287d5add08fSSrinivas Kandagatla case SWR_CLK_RATE_1P2MHZ: 1288d5add08fSSrinivas Kandagatla val = (bank ? 0x50 : 0x05); 1289d5add08fSSrinivas Kandagatla break; 1290d5add08fSSrinivas Kandagatla case SWR_CLK_RATE_2P4MHZ: 1291d5add08fSSrinivas Kandagatla val = (bank ? 0x30 : 0x03); 1292d5add08fSSrinivas Kandagatla break; 1293d5add08fSSrinivas Kandagatla case SWR_CLK_RATE_4P8MHZ: 1294d5add08fSSrinivas Kandagatla val = (bank ? 0x10 : 0x01); 1295d5add08fSSrinivas Kandagatla break; 1296d5add08fSSrinivas Kandagatla case SWR_CLK_RATE_9P6MHZ: 1297d5add08fSSrinivas Kandagatla default: 1298d5add08fSSrinivas Kandagatla val = 0x00; 1299d5add08fSSrinivas Kandagatla break; 1300d5add08fSSrinivas Kandagatla } 1301d5add08fSSrinivas Kandagatla snd_soc_component_update_bits(component, WCD938X_DIGITAL_SWR_TX_CLK_RATE, 1302d5add08fSSrinivas Kandagatla mask, val); 1303d5add08fSSrinivas Kandagatla 1304d5add08fSSrinivas Kandagatla return 0; 1305d5add08fSSrinivas Kandagatla } 1306d5add08fSSrinivas Kandagatla 13078d78602aSSrinivas Kandagatla static int wcd938x_io_init(struct wcd938x_priv *wcd938x) 13088d78602aSSrinivas Kandagatla { 13098d78602aSSrinivas Kandagatla struct regmap *rm = wcd938x->regmap; 13108d78602aSSrinivas Kandagatla 13118d78602aSSrinivas Kandagatla regmap_update_bits(rm, WCD938X_SLEEP_CTL, 0x0E, 0x0E); 13128d78602aSSrinivas Kandagatla regmap_update_bits(rm, WCD938X_SLEEP_CTL, 0x80, 0x80); 13138d78602aSSrinivas Kandagatla /* 1 msec delay as per HW requirement */ 13148d78602aSSrinivas Kandagatla usleep_range(1000, 1010); 13158d78602aSSrinivas Kandagatla regmap_update_bits(rm, WCD938X_SLEEP_CTL, 0x40, 0x40); 13168d78602aSSrinivas Kandagatla /* 1 msec delay as per HW requirement */ 13178d78602aSSrinivas Kandagatla usleep_range(1000, 1010); 13188d78602aSSrinivas Kandagatla regmap_update_bits(rm, WCD938X_LDORXTX_CONFIG, 0x10, 0x00); 13198d78602aSSrinivas Kandagatla regmap_update_bits(rm, WCD938X_BIAS_VBG_FINE_ADJ, 13208d78602aSSrinivas Kandagatla 0xF0, 0x80); 13218d78602aSSrinivas Kandagatla regmap_update_bits(rm, WCD938X_ANA_BIAS, 0x80, 0x80); 13228d78602aSSrinivas Kandagatla regmap_update_bits(rm, WCD938X_ANA_BIAS, 0x40, 0x40); 13238d78602aSSrinivas Kandagatla /* 10 msec delay as per HW requirement */ 13248d78602aSSrinivas Kandagatla usleep_range(10000, 10010); 13258d78602aSSrinivas Kandagatla 13268d78602aSSrinivas Kandagatla regmap_update_bits(rm, WCD938X_ANA_BIAS, 0x40, 0x00); 13278d78602aSSrinivas Kandagatla regmap_update_bits(rm, WCD938X_HPH_NEW_INT_RDAC_GAIN_CTL, 13288d78602aSSrinivas Kandagatla 0xF0, 0x00); 13298d78602aSSrinivas Kandagatla regmap_update_bits(rm, WCD938X_HPH_NEW_INT_RDAC_HD2_CTL_L_NEW, 13308d78602aSSrinivas Kandagatla 0x1F, 0x15); 13318d78602aSSrinivas Kandagatla regmap_update_bits(rm, WCD938X_HPH_NEW_INT_RDAC_HD2_CTL_R_NEW, 13328d78602aSSrinivas Kandagatla 0x1F, 0x15); 13338d78602aSSrinivas Kandagatla regmap_update_bits(rm, WCD938X_HPH_REFBUFF_UHQA_CTL, 13348d78602aSSrinivas Kandagatla 0xC0, 0x80); 13358d78602aSSrinivas Kandagatla regmap_update_bits(rm, WCD938X_DIGITAL_CDC_DMIC_CTL, 13368d78602aSSrinivas Kandagatla 0x02, 0x02); 13378d78602aSSrinivas Kandagatla 13388d78602aSSrinivas Kandagatla regmap_update_bits(rm, WCD938X_TX_COM_NEW_INT_TXFE_ICTRL_STG2CASC_ULP, 13398d78602aSSrinivas Kandagatla 0xFF, 0x14); 13408d78602aSSrinivas Kandagatla regmap_update_bits(rm, WCD938X_TX_COM_NEW_INT_TXFE_ICTRL_STG2MAIN_ULP, 13418d78602aSSrinivas Kandagatla 0x1F, 0x08); 13428d78602aSSrinivas Kandagatla 13438d78602aSSrinivas Kandagatla regmap_update_bits(rm, WCD938X_DIGITAL_TX_REQ_FB_CTL_0, 0xFF, 0x55); 13448d78602aSSrinivas Kandagatla regmap_update_bits(rm, WCD938X_DIGITAL_TX_REQ_FB_CTL_1, 0xFF, 0x44); 13458d78602aSSrinivas Kandagatla regmap_update_bits(rm, WCD938X_DIGITAL_TX_REQ_FB_CTL_2, 0xFF, 0x11); 13468d78602aSSrinivas Kandagatla regmap_update_bits(rm, WCD938X_DIGITAL_TX_REQ_FB_CTL_3, 0xFF, 0x00); 13478d78602aSSrinivas Kandagatla regmap_update_bits(rm, WCD938X_DIGITAL_TX_REQ_FB_CTL_4, 0xFF, 0x00); 13488d78602aSSrinivas Kandagatla 13498d78602aSSrinivas Kandagatla /* Set Noise Filter Resistor value */ 13508d78602aSSrinivas Kandagatla regmap_update_bits(rm, WCD938X_MICB1_TEST_CTL_1, 0xE0, 0xE0); 13518d78602aSSrinivas Kandagatla regmap_update_bits(rm, WCD938X_MICB2_TEST_CTL_1, 0xE0, 0xE0); 13528d78602aSSrinivas Kandagatla regmap_update_bits(rm, WCD938X_MICB3_TEST_CTL_1, 0xE0, 0xE0); 13538d78602aSSrinivas Kandagatla regmap_update_bits(rm, WCD938X_MICB4_TEST_CTL_1, 0xE0, 0xE0); 13548d78602aSSrinivas Kandagatla 13558d78602aSSrinivas Kandagatla regmap_update_bits(rm, WCD938X_TX_3_4_TEST_BLK_EN2, 0x01, 0x00); 13568d78602aSSrinivas Kandagatla regmap_update_bits(rm, WCD938X_HPH_SURGE_HPHLR_SURGE_EN, 0xC0, 0xC0); 13578d78602aSSrinivas Kandagatla 13588d78602aSSrinivas Kandagatla return 0; 13598d78602aSSrinivas Kandagatla 13608d78602aSSrinivas Kandagatla } 13618d78602aSSrinivas Kandagatla 1362e8ba1e05SSrinivas Kandagatla static int wcd938x_sdw_connect_port(struct wcd938x_sdw_ch_info *ch_info, 1363e8ba1e05SSrinivas Kandagatla struct sdw_port_config *port_config, 1364e8ba1e05SSrinivas Kandagatla u32 mstr_port_num, 1365e8ba1e05SSrinivas Kandagatla u8 enable) 1366e8ba1e05SSrinivas Kandagatla { 1367e8ba1e05SSrinivas Kandagatla u8 ch_mask, port_num; 1368e8ba1e05SSrinivas Kandagatla 1369e8ba1e05SSrinivas Kandagatla port_num = ch_info->port_num; 1370e8ba1e05SSrinivas Kandagatla ch_mask = ch_info->ch_mask; 1371e8ba1e05SSrinivas Kandagatla 1372e8ba1e05SSrinivas Kandagatla port_config->num = port_num; 1373e8ba1e05SSrinivas Kandagatla 1374e8ba1e05SSrinivas Kandagatla if (enable) 1375e8ba1e05SSrinivas Kandagatla port_config->ch_mask |= ch_mask; 1376e8ba1e05SSrinivas Kandagatla else 1377e8ba1e05SSrinivas Kandagatla port_config->ch_mask &= ~ch_mask; 1378e8ba1e05SSrinivas Kandagatla 1379e8ba1e05SSrinivas Kandagatla return 0; 1380e8ba1e05SSrinivas Kandagatla } 1381e8ba1e05SSrinivas Kandagatla 1382e8ba1e05SSrinivas Kandagatla static int wcd938x_connect_port(struct wcd938x_sdw_priv *wcd, u8 ch_id, u8 enable) 1383e8ba1e05SSrinivas Kandagatla { 1384e8ba1e05SSrinivas Kandagatla u8 port_num, mstr_port_num; 1385e8ba1e05SSrinivas Kandagatla 1386e8ba1e05SSrinivas Kandagatla port_num = wcd->ch_info[ch_id].port_num; 1387e8ba1e05SSrinivas Kandagatla mstr_port_num = wcd->port_map[port_num - 1]; 1388e8ba1e05SSrinivas Kandagatla 1389e8ba1e05SSrinivas Kandagatla return wcd938x_sdw_connect_port(&wcd->ch_info[ch_id], 1390e8ba1e05SSrinivas Kandagatla &wcd->port_config[port_num], 1391e8ba1e05SSrinivas Kandagatla mstr_port_num, 1392e8ba1e05SSrinivas Kandagatla enable); 1393e8ba1e05SSrinivas Kandagatla } 1394e8ba1e05SSrinivas Kandagatla 13958da9db0cSSrinivas Kandagatla static int wcd938x_codec_enable_rxclk(struct snd_soc_dapm_widget *w, 13968da9db0cSSrinivas Kandagatla struct snd_kcontrol *kcontrol, 13978da9db0cSSrinivas Kandagatla int event) 13988da9db0cSSrinivas Kandagatla { 13998da9db0cSSrinivas Kandagatla struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); 14008da9db0cSSrinivas Kandagatla 14018da9db0cSSrinivas Kandagatla switch (event) { 14028da9db0cSSrinivas Kandagatla case SND_SOC_DAPM_PRE_PMU: 14038da9db0cSSrinivas Kandagatla snd_soc_component_write_field(component, WCD938X_DIGITAL_CDC_ANA_CLK_CTL, 14048da9db0cSSrinivas Kandagatla WCD938X_ANA_RX_CLK_EN_MASK, 1); 14058da9db0cSSrinivas Kandagatla snd_soc_component_write_field(component, WCD938X_ANA_RX_SUPPLIES, 14068da9db0cSSrinivas Kandagatla WCD938X_RX_BIAS_EN_MASK, 1); 14078da9db0cSSrinivas Kandagatla snd_soc_component_write_field(component, WCD938X_DIGITAL_CDC_RX0_CTL, 14088da9db0cSSrinivas Kandagatla WCD938X_DEM_DITHER_ENABLE_MASK, 0); 14098da9db0cSSrinivas Kandagatla snd_soc_component_write_field(component, WCD938X_DIGITAL_CDC_RX1_CTL, 14108da9db0cSSrinivas Kandagatla WCD938X_DEM_DITHER_ENABLE_MASK, 0); 14118da9db0cSSrinivas Kandagatla snd_soc_component_write_field(component, WCD938X_DIGITAL_CDC_RX2_CTL, 14128da9db0cSSrinivas Kandagatla WCD938X_DEM_DITHER_ENABLE_MASK, 0); 14138da9db0cSSrinivas Kandagatla snd_soc_component_write_field(component, WCD938X_DIGITAL_CDC_ANA_CLK_CTL, 14148da9db0cSSrinivas Kandagatla WCD938X_ANA_RX_DIV2_CLK_EN_MASK, 1); 14158da9db0cSSrinivas Kandagatla snd_soc_component_write_field(component, WCD938X_AUX_AUXPA, 14168da9db0cSSrinivas Kandagatla WCD938X_AUXPA_CLK_EN_MASK, 1); 14178da9db0cSSrinivas Kandagatla break; 14188da9db0cSSrinivas Kandagatla case SND_SOC_DAPM_POST_PMD: 14198da9db0cSSrinivas Kandagatla snd_soc_component_write_field(component, WCD938X_ANA_RX_SUPPLIES, 14208da9db0cSSrinivas Kandagatla WCD938X_VNEG_EN_MASK, 0); 14218da9db0cSSrinivas Kandagatla snd_soc_component_write_field(component, WCD938X_ANA_RX_SUPPLIES, 14228da9db0cSSrinivas Kandagatla WCD938X_VPOS_EN_MASK, 0); 14238da9db0cSSrinivas Kandagatla snd_soc_component_write_field(component, WCD938X_ANA_RX_SUPPLIES, 14248da9db0cSSrinivas Kandagatla WCD938X_RX_BIAS_EN_MASK, 0); 14258da9db0cSSrinivas Kandagatla snd_soc_component_write_field(component, WCD938X_DIGITAL_CDC_ANA_CLK_CTL, 14268da9db0cSSrinivas Kandagatla WCD938X_ANA_RX_DIV2_CLK_EN_MASK, 0); 14278da9db0cSSrinivas Kandagatla snd_soc_component_write_field(component, WCD938X_DIGITAL_CDC_ANA_CLK_CTL, 14288da9db0cSSrinivas Kandagatla WCD938X_ANA_RX_CLK_EN_MASK, 0); 14298da9db0cSSrinivas Kandagatla break; 14308da9db0cSSrinivas Kandagatla } 14318da9db0cSSrinivas Kandagatla return 0; 14328da9db0cSSrinivas Kandagatla } 14338da9db0cSSrinivas Kandagatla 14348da9db0cSSrinivas Kandagatla static int wcd938x_codec_hphl_dac_event(struct snd_soc_dapm_widget *w, 14358da9db0cSSrinivas Kandagatla struct snd_kcontrol *kcontrol, 14368da9db0cSSrinivas Kandagatla int event) 14378da9db0cSSrinivas Kandagatla { 14388da9db0cSSrinivas Kandagatla struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); 14398da9db0cSSrinivas Kandagatla struct wcd938x_priv *wcd938x = snd_soc_component_get_drvdata(component); 14408da9db0cSSrinivas Kandagatla 14418da9db0cSSrinivas Kandagatla switch (event) { 14428da9db0cSSrinivas Kandagatla case SND_SOC_DAPM_PRE_PMU: 14438da9db0cSSrinivas Kandagatla snd_soc_component_write_field(component, 14448da9db0cSSrinivas Kandagatla WCD938X_DIGITAL_CDC_DIG_CLK_CTL, 14458da9db0cSSrinivas Kandagatla WCD938X_RXD0_CLK_EN_MASK, 0x01); 14468da9db0cSSrinivas Kandagatla snd_soc_component_write_field(component, 14478da9db0cSSrinivas Kandagatla WCD938X_DIGITAL_CDC_HPH_GAIN_CTL, 14488da9db0cSSrinivas Kandagatla WCD938X_HPHL_RX_EN_MASK, 1); 14498da9db0cSSrinivas Kandagatla snd_soc_component_write_field(component, 14508da9db0cSSrinivas Kandagatla WCD938X_HPH_RDAC_CLK_CTL1, 14518da9db0cSSrinivas Kandagatla WCD938X_CHOP_CLK_EN_MASK, 0); 14528da9db0cSSrinivas Kandagatla break; 14538da9db0cSSrinivas Kandagatla case SND_SOC_DAPM_POST_PMU: 14548da9db0cSSrinivas Kandagatla snd_soc_component_write_field(component, 14558da9db0cSSrinivas Kandagatla WCD938X_HPH_NEW_INT_RDAC_HD2_CTL_L, 14568da9db0cSSrinivas Kandagatla WCD938X_HPH_RES_DIV_MASK, 0x02); 14578da9db0cSSrinivas Kandagatla if (wcd938x->comp1_enable) { 14588da9db0cSSrinivas Kandagatla snd_soc_component_write_field(component, 14598da9db0cSSrinivas Kandagatla WCD938X_DIGITAL_CDC_COMP_CTL_0, 14608da9db0cSSrinivas Kandagatla WCD938X_HPHL_COMP_EN_MASK, 1); 14618da9db0cSSrinivas Kandagatla /* 5msec compander delay as per HW requirement */ 14628da9db0cSSrinivas Kandagatla if (!wcd938x->comp2_enable || (snd_soc_component_read(component, 14638da9db0cSSrinivas Kandagatla WCD938X_DIGITAL_CDC_COMP_CTL_0) & 0x01)) 14648da9db0cSSrinivas Kandagatla usleep_range(5000, 5010); 14658da9db0cSSrinivas Kandagatla snd_soc_component_write_field(component, WCD938X_HPH_NEW_INT_HPH_TIMER1, 14668da9db0cSSrinivas Kandagatla WCD938X_AUTOCHOP_TIMER_EN, 0); 14678da9db0cSSrinivas Kandagatla } else { 14688da9db0cSSrinivas Kandagatla snd_soc_component_write_field(component, 14698da9db0cSSrinivas Kandagatla WCD938X_DIGITAL_CDC_COMP_CTL_0, 14708da9db0cSSrinivas Kandagatla WCD938X_HPHL_COMP_EN_MASK, 0); 14718da9db0cSSrinivas Kandagatla snd_soc_component_write_field(component, 14728da9db0cSSrinivas Kandagatla WCD938X_HPH_L_EN, 14738da9db0cSSrinivas Kandagatla WCD938X_GAIN_SRC_SEL_MASK, 14748da9db0cSSrinivas Kandagatla WCD938X_GAIN_SRC_SEL_REGISTER); 14758da9db0cSSrinivas Kandagatla 14768da9db0cSSrinivas Kandagatla } 14778da9db0cSSrinivas Kandagatla break; 14788da9db0cSSrinivas Kandagatla case SND_SOC_DAPM_POST_PMD: 14798da9db0cSSrinivas Kandagatla snd_soc_component_write_field(component, 14808da9db0cSSrinivas Kandagatla WCD938X_HPH_NEW_INT_RDAC_HD2_CTL_R, 14818da9db0cSSrinivas Kandagatla WCD938X_HPH_RES_DIV_MASK, 0x1); 14828da9db0cSSrinivas Kandagatla break; 14838da9db0cSSrinivas Kandagatla } 14848da9db0cSSrinivas Kandagatla 14858da9db0cSSrinivas Kandagatla return 0; 14868da9db0cSSrinivas Kandagatla } 14878da9db0cSSrinivas Kandagatla 14888da9db0cSSrinivas Kandagatla static int wcd938x_codec_hphr_dac_event(struct snd_soc_dapm_widget *w, 14898da9db0cSSrinivas Kandagatla struct snd_kcontrol *kcontrol, 14908da9db0cSSrinivas Kandagatla int event) 14918da9db0cSSrinivas Kandagatla { 14928da9db0cSSrinivas Kandagatla struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); 14938da9db0cSSrinivas Kandagatla struct wcd938x_priv *wcd938x = snd_soc_component_get_drvdata(component); 14948da9db0cSSrinivas Kandagatla 14958da9db0cSSrinivas Kandagatla switch (event) { 14968da9db0cSSrinivas Kandagatla case SND_SOC_DAPM_PRE_PMU: 14978da9db0cSSrinivas Kandagatla snd_soc_component_write_field(component, 14988da9db0cSSrinivas Kandagatla WCD938X_DIGITAL_CDC_DIG_CLK_CTL, 14998da9db0cSSrinivas Kandagatla WCD938X_RXD1_CLK_EN_MASK, 1); 15008da9db0cSSrinivas Kandagatla snd_soc_component_write_field(component, 15018da9db0cSSrinivas Kandagatla WCD938X_DIGITAL_CDC_HPH_GAIN_CTL, 15028da9db0cSSrinivas Kandagatla WCD938X_HPHR_RX_EN_MASK, 1); 15038da9db0cSSrinivas Kandagatla snd_soc_component_write_field(component, 15048da9db0cSSrinivas Kandagatla WCD938X_HPH_RDAC_CLK_CTL1, 15058da9db0cSSrinivas Kandagatla WCD938X_CHOP_CLK_EN_MASK, 0); 15068da9db0cSSrinivas Kandagatla break; 15078da9db0cSSrinivas Kandagatla case SND_SOC_DAPM_POST_PMU: 15088da9db0cSSrinivas Kandagatla snd_soc_component_write_field(component, 15098da9db0cSSrinivas Kandagatla WCD938X_HPH_NEW_INT_RDAC_HD2_CTL_R, 15108da9db0cSSrinivas Kandagatla WCD938X_HPH_RES_DIV_MASK, 0x02); 15118da9db0cSSrinivas Kandagatla if (wcd938x->comp2_enable) { 15128da9db0cSSrinivas Kandagatla snd_soc_component_write_field(component, 15138da9db0cSSrinivas Kandagatla WCD938X_DIGITAL_CDC_COMP_CTL_0, 15148da9db0cSSrinivas Kandagatla WCD938X_HPHR_COMP_EN_MASK, 1); 15158da9db0cSSrinivas Kandagatla /* 5msec compander delay as per HW requirement */ 15168da9db0cSSrinivas Kandagatla if (!wcd938x->comp1_enable || 15178da9db0cSSrinivas Kandagatla (snd_soc_component_read(component, 15188da9db0cSSrinivas Kandagatla WCD938X_DIGITAL_CDC_COMP_CTL_0) & 0x02)) 15198da9db0cSSrinivas Kandagatla usleep_range(5000, 5010); 15208da9db0cSSrinivas Kandagatla snd_soc_component_write_field(component, WCD938X_HPH_NEW_INT_HPH_TIMER1, 15218da9db0cSSrinivas Kandagatla WCD938X_AUTOCHOP_TIMER_EN, 0); 15228da9db0cSSrinivas Kandagatla } else { 15238da9db0cSSrinivas Kandagatla snd_soc_component_write_field(component, 15248da9db0cSSrinivas Kandagatla WCD938X_DIGITAL_CDC_COMP_CTL_0, 15258da9db0cSSrinivas Kandagatla WCD938X_HPHR_COMP_EN_MASK, 0); 15268da9db0cSSrinivas Kandagatla snd_soc_component_write_field(component, 15278da9db0cSSrinivas Kandagatla WCD938X_HPH_R_EN, 15288da9db0cSSrinivas Kandagatla WCD938X_GAIN_SRC_SEL_MASK, 15298da9db0cSSrinivas Kandagatla WCD938X_GAIN_SRC_SEL_REGISTER); 15308da9db0cSSrinivas Kandagatla } 15318da9db0cSSrinivas Kandagatla break; 15328da9db0cSSrinivas Kandagatla case SND_SOC_DAPM_POST_PMD: 15338da9db0cSSrinivas Kandagatla snd_soc_component_write_field(component, 15348da9db0cSSrinivas Kandagatla WCD938X_HPH_NEW_INT_RDAC_HD2_CTL_R, 15358da9db0cSSrinivas Kandagatla WCD938X_HPH_RES_DIV_MASK, 0x01); 15368da9db0cSSrinivas Kandagatla break; 15378da9db0cSSrinivas Kandagatla } 15388da9db0cSSrinivas Kandagatla 15398da9db0cSSrinivas Kandagatla return 0; 15408da9db0cSSrinivas Kandagatla } 15418da9db0cSSrinivas Kandagatla 15428da9db0cSSrinivas Kandagatla static int wcd938x_codec_ear_dac_event(struct snd_soc_dapm_widget *w, 15438da9db0cSSrinivas Kandagatla struct snd_kcontrol *kcontrol, 15448da9db0cSSrinivas Kandagatla int event) 15458da9db0cSSrinivas Kandagatla { 15468da9db0cSSrinivas Kandagatla struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); 15478da9db0cSSrinivas Kandagatla struct wcd938x_priv *wcd938x = snd_soc_component_get_drvdata(component); 15488da9db0cSSrinivas Kandagatla 15498da9db0cSSrinivas Kandagatla switch (event) { 15508da9db0cSSrinivas Kandagatla case SND_SOC_DAPM_PRE_PMU: 15518da9db0cSSrinivas Kandagatla wcd938x->ear_rx_path = 15528da9db0cSSrinivas Kandagatla snd_soc_component_read( 15538da9db0cSSrinivas Kandagatla component, WCD938X_DIGITAL_CDC_EAR_PATH_CTL); 15548da9db0cSSrinivas Kandagatla if (wcd938x->ear_rx_path & EAR_RX_PATH_AUX) { 15558da9db0cSSrinivas Kandagatla snd_soc_component_write_field(component, 15568da9db0cSSrinivas Kandagatla WCD938X_EAR_EAR_DAC_CON, 15578da9db0cSSrinivas Kandagatla WCD938X_DAC_SAMPLE_EDGE_SEL_MASK, 0); 15588da9db0cSSrinivas Kandagatla snd_soc_component_write_field(component, 15598da9db0cSSrinivas Kandagatla WCD938X_DIGITAL_CDC_AUX_GAIN_CTL, 15608da9db0cSSrinivas Kandagatla WCD938X_AUX_EN_MASK, 1); 15618da9db0cSSrinivas Kandagatla snd_soc_component_write_field(component, 15628da9db0cSSrinivas Kandagatla WCD938X_DIGITAL_CDC_DIG_CLK_CTL, 15638da9db0cSSrinivas Kandagatla WCD938X_RXD2_CLK_EN_MASK, 1); 15648da9db0cSSrinivas Kandagatla snd_soc_component_write_field(component, 15658da9db0cSSrinivas Kandagatla WCD938X_ANA_EAR_COMPANDER_CTL, 15668da9db0cSSrinivas Kandagatla WCD938X_GAIN_OVRD_REG_MASK, 1); 15678da9db0cSSrinivas Kandagatla } else { 15688da9db0cSSrinivas Kandagatla snd_soc_component_write_field(component, 15698da9db0cSSrinivas Kandagatla WCD938X_DIGITAL_CDC_HPH_GAIN_CTL, 15708da9db0cSSrinivas Kandagatla WCD938X_HPHL_RX_EN_MASK, 1); 15718da9db0cSSrinivas Kandagatla snd_soc_component_write_field(component, 15728da9db0cSSrinivas Kandagatla WCD938X_DIGITAL_CDC_DIG_CLK_CTL, 15738da9db0cSSrinivas Kandagatla WCD938X_RXD0_CLK_EN_MASK, 1); 15748da9db0cSSrinivas Kandagatla if (wcd938x->comp1_enable) 15758da9db0cSSrinivas Kandagatla snd_soc_component_write_field(component, 15768da9db0cSSrinivas Kandagatla WCD938X_DIGITAL_CDC_COMP_CTL_0, 15778da9db0cSSrinivas Kandagatla WCD938X_HPHL_COMP_EN_MASK, 1); 15788da9db0cSSrinivas Kandagatla } 15798da9db0cSSrinivas Kandagatla /* 5 msec delay as per HW requirement */ 15808da9db0cSSrinivas Kandagatla usleep_range(5000, 5010); 15818da9db0cSSrinivas Kandagatla if (wcd938x->flyback_cur_det_disable == 0) 15828da9db0cSSrinivas Kandagatla snd_soc_component_write_field(component, WCD938X_FLYBACK_EN, 15838da9db0cSSrinivas Kandagatla WCD938X_EN_CUR_DET_MASK, 0); 15848da9db0cSSrinivas Kandagatla wcd938x->flyback_cur_det_disable++; 15858da9db0cSSrinivas Kandagatla wcd_clsh_ctrl_set_state(wcd938x->clsh_info, 15868da9db0cSSrinivas Kandagatla WCD_CLSH_EVENT_PRE_DAC, 15878da9db0cSSrinivas Kandagatla WCD_CLSH_STATE_EAR, 15888da9db0cSSrinivas Kandagatla wcd938x->hph_mode); 15898da9db0cSSrinivas Kandagatla break; 15908da9db0cSSrinivas Kandagatla case SND_SOC_DAPM_POST_PMD: 15918da9db0cSSrinivas Kandagatla if (wcd938x->ear_rx_path & EAR_RX_PATH_AUX) { 15928da9db0cSSrinivas Kandagatla snd_soc_component_write_field(component, 15938da9db0cSSrinivas Kandagatla WCD938X_DIGITAL_CDC_AUX_GAIN_CTL, 15948da9db0cSSrinivas Kandagatla WCD938X_AUX_EN_MASK, 0); 15958da9db0cSSrinivas Kandagatla snd_soc_component_write_field(component, 15968da9db0cSSrinivas Kandagatla WCD938X_DIGITAL_CDC_DIG_CLK_CTL, 15978da9db0cSSrinivas Kandagatla WCD938X_RXD2_CLK_EN_MASK, 0); 15988da9db0cSSrinivas Kandagatla } else { 15998da9db0cSSrinivas Kandagatla snd_soc_component_write_field(component, 16008da9db0cSSrinivas Kandagatla WCD938X_DIGITAL_CDC_HPH_GAIN_CTL, 16018da9db0cSSrinivas Kandagatla WCD938X_HPHL_RX_EN_MASK, 0); 16028da9db0cSSrinivas Kandagatla snd_soc_component_write_field(component, 16038da9db0cSSrinivas Kandagatla WCD938X_DIGITAL_CDC_DIG_CLK_CTL, 16048da9db0cSSrinivas Kandagatla WCD938X_RXD0_CLK_EN_MASK, 0); 16058da9db0cSSrinivas Kandagatla if (wcd938x->comp1_enable) 16068da9db0cSSrinivas Kandagatla snd_soc_component_write_field(component, 16078da9db0cSSrinivas Kandagatla WCD938X_DIGITAL_CDC_COMP_CTL_0, 16088da9db0cSSrinivas Kandagatla WCD938X_HPHL_COMP_EN_MASK, 0); 16098da9db0cSSrinivas Kandagatla } 16108da9db0cSSrinivas Kandagatla snd_soc_component_write_field(component, WCD938X_ANA_EAR_COMPANDER_CTL, 16118da9db0cSSrinivas Kandagatla WCD938X_GAIN_OVRD_REG_MASK, 0); 16128da9db0cSSrinivas Kandagatla snd_soc_component_write_field(component, 16138da9db0cSSrinivas Kandagatla WCD938X_EAR_EAR_DAC_CON, 16148da9db0cSSrinivas Kandagatla WCD938X_DAC_SAMPLE_EDGE_SEL_MASK, 1); 16158da9db0cSSrinivas Kandagatla break; 16168da9db0cSSrinivas Kandagatla } 16178da9db0cSSrinivas Kandagatla return 0; 16188da9db0cSSrinivas Kandagatla 16198da9db0cSSrinivas Kandagatla } 16208da9db0cSSrinivas Kandagatla 16218da9db0cSSrinivas Kandagatla static int wcd938x_codec_aux_dac_event(struct snd_soc_dapm_widget *w, 16228da9db0cSSrinivas Kandagatla struct snd_kcontrol *kcontrol, 16238da9db0cSSrinivas Kandagatla int event) 16248da9db0cSSrinivas Kandagatla { 16258da9db0cSSrinivas Kandagatla struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); 16268da9db0cSSrinivas Kandagatla struct wcd938x_priv *wcd938x = snd_soc_component_get_drvdata(component); 16278da9db0cSSrinivas Kandagatla int ret = 0; 16288da9db0cSSrinivas Kandagatla 16298da9db0cSSrinivas Kandagatla switch (event) { 16308da9db0cSSrinivas Kandagatla case SND_SOC_DAPM_PRE_PMU: 16318da9db0cSSrinivas Kandagatla snd_soc_component_write_field(component, 16328da9db0cSSrinivas Kandagatla WCD938X_DIGITAL_CDC_ANA_CLK_CTL, 16338da9db0cSSrinivas Kandagatla WCD938X_ANA_RX_DIV4_CLK_EN_MASK, 1); 16348da9db0cSSrinivas Kandagatla snd_soc_component_write_field(component, 16358da9db0cSSrinivas Kandagatla WCD938X_DIGITAL_CDC_DIG_CLK_CTL, 16368da9db0cSSrinivas Kandagatla WCD938X_RXD2_CLK_EN_MASK, 1); 16378da9db0cSSrinivas Kandagatla snd_soc_component_write_field(component, 16388da9db0cSSrinivas Kandagatla WCD938X_DIGITAL_CDC_AUX_GAIN_CTL, 16398da9db0cSSrinivas Kandagatla WCD938X_AUX_EN_MASK, 1); 16408da9db0cSSrinivas Kandagatla if (wcd938x->flyback_cur_det_disable == 0) 16418da9db0cSSrinivas Kandagatla snd_soc_component_write_field(component, WCD938X_FLYBACK_EN, 16428da9db0cSSrinivas Kandagatla WCD938X_EN_CUR_DET_MASK, 0); 16438da9db0cSSrinivas Kandagatla wcd938x->flyback_cur_det_disable++; 16448da9db0cSSrinivas Kandagatla wcd_clsh_ctrl_set_state(wcd938x->clsh_info, 16458da9db0cSSrinivas Kandagatla WCD_CLSH_EVENT_PRE_DAC, 16468da9db0cSSrinivas Kandagatla WCD_CLSH_STATE_AUX, 16478da9db0cSSrinivas Kandagatla wcd938x->hph_mode); 16488da9db0cSSrinivas Kandagatla break; 16498da9db0cSSrinivas Kandagatla case SND_SOC_DAPM_POST_PMD: 16508da9db0cSSrinivas Kandagatla snd_soc_component_write_field(component, 16518da9db0cSSrinivas Kandagatla WCD938X_DIGITAL_CDC_ANA_CLK_CTL, 16528da9db0cSSrinivas Kandagatla WCD938X_ANA_RX_DIV4_CLK_EN_MASK, 0); 16538da9db0cSSrinivas Kandagatla break; 16548da9db0cSSrinivas Kandagatla } 16558da9db0cSSrinivas Kandagatla return ret; 16568da9db0cSSrinivas Kandagatla 16578da9db0cSSrinivas Kandagatla } 16588da9db0cSSrinivas Kandagatla 16598da9db0cSSrinivas Kandagatla static int wcd938x_codec_enable_hphr_pa(struct snd_soc_dapm_widget *w, 16608da9db0cSSrinivas Kandagatla struct snd_kcontrol *kcontrol, int event) 16618da9db0cSSrinivas Kandagatla { 16628da9db0cSSrinivas Kandagatla struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); 16638da9db0cSSrinivas Kandagatla struct wcd938x_priv *wcd938x = snd_soc_component_get_drvdata(component); 16648da9db0cSSrinivas Kandagatla int hph_mode = wcd938x->hph_mode; 16658da9db0cSSrinivas Kandagatla 16668da9db0cSSrinivas Kandagatla switch (event) { 16678da9db0cSSrinivas Kandagatla case SND_SOC_DAPM_PRE_PMU: 16688da9db0cSSrinivas Kandagatla if (wcd938x->ldoh) 16698da9db0cSSrinivas Kandagatla snd_soc_component_write_field(component, WCD938X_LDOH_MODE, 16708da9db0cSSrinivas Kandagatla WCD938X_LDOH_EN_MASK, 1); 16718da9db0cSSrinivas Kandagatla wcd_clsh_ctrl_set_state(wcd938x->clsh_info, WCD_CLSH_EVENT_PRE_DAC, 16728da9db0cSSrinivas Kandagatla WCD_CLSH_STATE_HPHR, hph_mode); 16738da9db0cSSrinivas Kandagatla wcd_clsh_set_hph_mode(wcd938x->clsh_info, CLS_H_HIFI); 16748da9db0cSSrinivas Kandagatla 16758da9db0cSSrinivas Kandagatla if (hph_mode == CLS_H_LP || hph_mode == CLS_H_LOHIFI || 16768da9db0cSSrinivas Kandagatla hph_mode == CLS_H_ULP) { 16778da9db0cSSrinivas Kandagatla snd_soc_component_write_field(component, 16788da9db0cSSrinivas Kandagatla WCD938X_HPH_REFBUFF_LP_CTL, 16798da9db0cSSrinivas Kandagatla WCD938X_PREREF_FLIT_BYPASS_MASK, 1); 16808da9db0cSSrinivas Kandagatla } 16818da9db0cSSrinivas Kandagatla snd_soc_component_write_field(component, WCD938X_ANA_HPH, 16828da9db0cSSrinivas Kandagatla WCD938X_HPHR_REF_EN_MASK, 1); 16838da9db0cSSrinivas Kandagatla wcd_clsh_set_hph_mode(wcd938x->clsh_info, hph_mode); 16848da9db0cSSrinivas Kandagatla /* 100 usec delay as per HW requirement */ 16858da9db0cSSrinivas Kandagatla usleep_range(100, 110); 16868da9db0cSSrinivas Kandagatla set_bit(HPH_PA_DELAY, &wcd938x->status_mask); 16878da9db0cSSrinivas Kandagatla snd_soc_component_write_field(component, 16888da9db0cSSrinivas Kandagatla WCD938X_DIGITAL_PDM_WD_CTL1, 16898da9db0cSSrinivas Kandagatla WCD938X_PDM_WD_EN_MASK, 0x3); 16908da9db0cSSrinivas Kandagatla break; 16918da9db0cSSrinivas Kandagatla case SND_SOC_DAPM_POST_PMU: 16928da9db0cSSrinivas Kandagatla /* 16938da9db0cSSrinivas Kandagatla * 7ms sleep is required if compander is enabled as per 16948da9db0cSSrinivas Kandagatla * HW requirement. If compander is disabled, then 16958da9db0cSSrinivas Kandagatla * 20ms delay is required. 16968da9db0cSSrinivas Kandagatla */ 16978da9db0cSSrinivas Kandagatla if (test_bit(HPH_PA_DELAY, &wcd938x->status_mask)) { 16988da9db0cSSrinivas Kandagatla if (!wcd938x->comp2_enable) 16998da9db0cSSrinivas Kandagatla usleep_range(20000, 20100); 17008da9db0cSSrinivas Kandagatla else 17018da9db0cSSrinivas Kandagatla usleep_range(7000, 7100); 17028da9db0cSSrinivas Kandagatla 17038da9db0cSSrinivas Kandagatla if (hph_mode == CLS_H_LP || hph_mode == CLS_H_LOHIFI || 17048da9db0cSSrinivas Kandagatla hph_mode == CLS_H_ULP) 17058da9db0cSSrinivas Kandagatla snd_soc_component_write_field(component, 17068da9db0cSSrinivas Kandagatla WCD938X_HPH_REFBUFF_LP_CTL, 17078da9db0cSSrinivas Kandagatla WCD938X_PREREF_FLIT_BYPASS_MASK, 0); 17088da9db0cSSrinivas Kandagatla clear_bit(HPH_PA_DELAY, &wcd938x->status_mask); 17098da9db0cSSrinivas Kandagatla } 17108da9db0cSSrinivas Kandagatla snd_soc_component_write_field(component, WCD938X_HPH_NEW_INT_HPH_TIMER1, 17118da9db0cSSrinivas Kandagatla WCD938X_AUTOCHOP_TIMER_EN, 1); 17128da9db0cSSrinivas Kandagatla if (hph_mode == CLS_AB || hph_mode == CLS_AB_HIFI || 17138da9db0cSSrinivas Kandagatla hph_mode == CLS_AB_LP || hph_mode == CLS_AB_LOHIFI) 17148da9db0cSSrinivas Kandagatla snd_soc_component_write_field(component, WCD938X_ANA_RX_SUPPLIES, 17158da9db0cSSrinivas Kandagatla WCD938X_REGULATOR_MODE_MASK, 17168da9db0cSSrinivas Kandagatla WCD938X_REGULATOR_MODE_CLASS_AB); 17178da9db0cSSrinivas Kandagatla enable_irq(wcd938x->hphr_pdm_wd_int); 17188da9db0cSSrinivas Kandagatla break; 17198da9db0cSSrinivas Kandagatla case SND_SOC_DAPM_PRE_PMD: 17208da9db0cSSrinivas Kandagatla disable_irq_nosync(wcd938x->hphr_pdm_wd_int); 17218da9db0cSSrinivas Kandagatla /* 17228da9db0cSSrinivas Kandagatla * 7ms sleep is required if compander is enabled as per 17238da9db0cSSrinivas Kandagatla * HW requirement. If compander is disabled, then 17248da9db0cSSrinivas Kandagatla * 20ms delay is required. 17258da9db0cSSrinivas Kandagatla */ 17268da9db0cSSrinivas Kandagatla if (!wcd938x->comp2_enable) 17278da9db0cSSrinivas Kandagatla usleep_range(20000, 20100); 17288da9db0cSSrinivas Kandagatla else 17298da9db0cSSrinivas Kandagatla usleep_range(7000, 7100); 17308da9db0cSSrinivas Kandagatla snd_soc_component_write_field(component, WCD938X_ANA_HPH, 17318da9db0cSSrinivas Kandagatla WCD938X_HPHR_EN_MASK, 0); 17328da9db0cSSrinivas Kandagatla set_bit(HPH_PA_DELAY, &wcd938x->status_mask); 17338da9db0cSSrinivas Kandagatla break; 17348da9db0cSSrinivas Kandagatla case SND_SOC_DAPM_POST_PMD: 17358da9db0cSSrinivas Kandagatla /* 17368da9db0cSSrinivas Kandagatla * 7ms sleep is required if compander is enabled as per 17378da9db0cSSrinivas Kandagatla * HW requirement. If compander is disabled, then 17388da9db0cSSrinivas Kandagatla * 20ms delay is required. 17398da9db0cSSrinivas Kandagatla */ 17408da9db0cSSrinivas Kandagatla if (test_bit(HPH_PA_DELAY, &wcd938x->status_mask)) { 17418da9db0cSSrinivas Kandagatla if (!wcd938x->comp2_enable) 17428da9db0cSSrinivas Kandagatla usleep_range(20000, 20100); 17438da9db0cSSrinivas Kandagatla else 17448da9db0cSSrinivas Kandagatla usleep_range(7000, 7100); 17458da9db0cSSrinivas Kandagatla clear_bit(HPH_PA_DELAY, &wcd938x->status_mask); 17468da9db0cSSrinivas Kandagatla } 17478da9db0cSSrinivas Kandagatla snd_soc_component_write_field(component, WCD938X_ANA_HPH, 17488da9db0cSSrinivas Kandagatla WCD938X_HPHR_REF_EN_MASK, 0); 17498da9db0cSSrinivas Kandagatla snd_soc_component_write_field(component, WCD938X_DIGITAL_PDM_WD_CTL1, 17508da9db0cSSrinivas Kandagatla WCD938X_PDM_WD_EN_MASK, 0); 17518da9db0cSSrinivas Kandagatla wcd_clsh_ctrl_set_state(wcd938x->clsh_info, WCD_CLSH_EVENT_POST_PA, 17528da9db0cSSrinivas Kandagatla WCD_CLSH_STATE_HPHR, hph_mode); 17538da9db0cSSrinivas Kandagatla if (wcd938x->ldoh) 17548da9db0cSSrinivas Kandagatla snd_soc_component_write_field(component, WCD938X_LDOH_MODE, 17558da9db0cSSrinivas Kandagatla WCD938X_LDOH_EN_MASK, 0); 17568da9db0cSSrinivas Kandagatla break; 17578da9db0cSSrinivas Kandagatla } 17588da9db0cSSrinivas Kandagatla 17598da9db0cSSrinivas Kandagatla return 0; 17608da9db0cSSrinivas Kandagatla } 17618da9db0cSSrinivas Kandagatla 17628da9db0cSSrinivas Kandagatla static int wcd938x_codec_enable_hphl_pa(struct snd_soc_dapm_widget *w, 17638da9db0cSSrinivas Kandagatla struct snd_kcontrol *kcontrol, int event) 17648da9db0cSSrinivas Kandagatla { 17658da9db0cSSrinivas Kandagatla struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); 17668da9db0cSSrinivas Kandagatla struct wcd938x_priv *wcd938x = snd_soc_component_get_drvdata(component); 17678da9db0cSSrinivas Kandagatla int hph_mode = wcd938x->hph_mode; 17688da9db0cSSrinivas Kandagatla 17698da9db0cSSrinivas Kandagatla switch (event) { 17708da9db0cSSrinivas Kandagatla case SND_SOC_DAPM_PRE_PMU: 17718da9db0cSSrinivas Kandagatla if (wcd938x->ldoh) 17728da9db0cSSrinivas Kandagatla snd_soc_component_write_field(component, WCD938X_LDOH_MODE, 17738da9db0cSSrinivas Kandagatla WCD938X_LDOH_EN_MASK, 1); 17748da9db0cSSrinivas Kandagatla wcd_clsh_ctrl_set_state(wcd938x->clsh_info, WCD_CLSH_EVENT_PRE_DAC, 17758da9db0cSSrinivas Kandagatla WCD_CLSH_STATE_HPHL, hph_mode); 17768da9db0cSSrinivas Kandagatla wcd_clsh_set_hph_mode(wcd938x->clsh_info, CLS_H_HIFI); 17778da9db0cSSrinivas Kandagatla if (hph_mode == CLS_H_LP || hph_mode == CLS_H_LOHIFI || 17788da9db0cSSrinivas Kandagatla hph_mode == CLS_H_ULP) { 17798da9db0cSSrinivas Kandagatla snd_soc_component_write_field(component, 17808da9db0cSSrinivas Kandagatla WCD938X_HPH_REFBUFF_LP_CTL, 17818da9db0cSSrinivas Kandagatla WCD938X_PREREF_FLIT_BYPASS_MASK, 1); 17828da9db0cSSrinivas Kandagatla } 17838da9db0cSSrinivas Kandagatla snd_soc_component_write_field(component, WCD938X_ANA_HPH, 17848da9db0cSSrinivas Kandagatla WCD938X_HPHL_REF_EN_MASK, 1); 17858da9db0cSSrinivas Kandagatla wcd_clsh_set_hph_mode(wcd938x->clsh_info, hph_mode); 17868da9db0cSSrinivas Kandagatla /* 100 usec delay as per HW requirement */ 17878da9db0cSSrinivas Kandagatla usleep_range(100, 110); 17888da9db0cSSrinivas Kandagatla set_bit(HPH_PA_DELAY, &wcd938x->status_mask); 17898da9db0cSSrinivas Kandagatla snd_soc_component_write_field(component, 17908da9db0cSSrinivas Kandagatla WCD938X_DIGITAL_PDM_WD_CTL0, 17918da9db0cSSrinivas Kandagatla WCD938X_PDM_WD_EN_MASK, 0x3); 17928da9db0cSSrinivas Kandagatla break; 17938da9db0cSSrinivas Kandagatla case SND_SOC_DAPM_POST_PMU: 17948da9db0cSSrinivas Kandagatla /* 17958da9db0cSSrinivas Kandagatla * 7ms sleep is required if compander is enabled as per 17968da9db0cSSrinivas Kandagatla * HW requirement. If compander is disabled, then 17978da9db0cSSrinivas Kandagatla * 20ms delay is required. 17988da9db0cSSrinivas Kandagatla */ 17998da9db0cSSrinivas Kandagatla if (test_bit(HPH_PA_DELAY, &wcd938x->status_mask)) { 18008da9db0cSSrinivas Kandagatla if (!wcd938x->comp1_enable) 18018da9db0cSSrinivas Kandagatla usleep_range(20000, 20100); 18028da9db0cSSrinivas Kandagatla else 18038da9db0cSSrinivas Kandagatla usleep_range(7000, 7100); 18048da9db0cSSrinivas Kandagatla if (hph_mode == CLS_H_LP || hph_mode == CLS_H_LOHIFI || 18058da9db0cSSrinivas Kandagatla hph_mode == CLS_H_ULP) 18068da9db0cSSrinivas Kandagatla snd_soc_component_write_field(component, 18078da9db0cSSrinivas Kandagatla WCD938X_HPH_REFBUFF_LP_CTL, 18088da9db0cSSrinivas Kandagatla WCD938X_PREREF_FLIT_BYPASS_MASK, 0); 18098da9db0cSSrinivas Kandagatla clear_bit(HPH_PA_DELAY, &wcd938x->status_mask); 18108da9db0cSSrinivas Kandagatla } 18118da9db0cSSrinivas Kandagatla 18128da9db0cSSrinivas Kandagatla snd_soc_component_write_field(component, WCD938X_HPH_NEW_INT_HPH_TIMER1, 18138da9db0cSSrinivas Kandagatla WCD938X_AUTOCHOP_TIMER_EN, 1); 18148da9db0cSSrinivas Kandagatla if (hph_mode == CLS_AB || hph_mode == CLS_AB_HIFI || 18158da9db0cSSrinivas Kandagatla hph_mode == CLS_AB_LP || hph_mode == CLS_AB_LOHIFI) 18168da9db0cSSrinivas Kandagatla snd_soc_component_write_field(component, WCD938X_ANA_RX_SUPPLIES, 18178da9db0cSSrinivas Kandagatla WCD938X_REGULATOR_MODE_MASK, 18188da9db0cSSrinivas Kandagatla WCD938X_REGULATOR_MODE_CLASS_AB); 18198da9db0cSSrinivas Kandagatla enable_irq(wcd938x->hphl_pdm_wd_int); 18208da9db0cSSrinivas Kandagatla break; 18218da9db0cSSrinivas Kandagatla case SND_SOC_DAPM_PRE_PMD: 18228da9db0cSSrinivas Kandagatla disable_irq_nosync(wcd938x->hphl_pdm_wd_int); 18238da9db0cSSrinivas Kandagatla /* 18248da9db0cSSrinivas Kandagatla * 7ms sleep is required if compander is enabled as per 18258da9db0cSSrinivas Kandagatla * HW requirement. If compander is disabled, then 18268da9db0cSSrinivas Kandagatla * 20ms delay is required. 18278da9db0cSSrinivas Kandagatla */ 18288da9db0cSSrinivas Kandagatla if (!wcd938x->comp1_enable) 18298da9db0cSSrinivas Kandagatla usleep_range(20000, 20100); 18308da9db0cSSrinivas Kandagatla else 18318da9db0cSSrinivas Kandagatla usleep_range(7000, 7100); 18328da9db0cSSrinivas Kandagatla snd_soc_component_write_field(component, WCD938X_ANA_HPH, 18338da9db0cSSrinivas Kandagatla WCD938X_HPHL_EN_MASK, 0); 18348da9db0cSSrinivas Kandagatla set_bit(HPH_PA_DELAY, &wcd938x->status_mask); 18358da9db0cSSrinivas Kandagatla break; 18368da9db0cSSrinivas Kandagatla case SND_SOC_DAPM_POST_PMD: 18378da9db0cSSrinivas Kandagatla /* 18388da9db0cSSrinivas Kandagatla * 7ms sleep is required if compander is enabled as per 18398da9db0cSSrinivas Kandagatla * HW requirement. If compander is disabled, then 18408da9db0cSSrinivas Kandagatla * 20ms delay is required. 18418da9db0cSSrinivas Kandagatla */ 18428da9db0cSSrinivas Kandagatla if (test_bit(HPH_PA_DELAY, &wcd938x->status_mask)) { 18438da9db0cSSrinivas Kandagatla if (!wcd938x->comp1_enable) 18448da9db0cSSrinivas Kandagatla usleep_range(21000, 21100); 18458da9db0cSSrinivas Kandagatla else 18468da9db0cSSrinivas Kandagatla usleep_range(7000, 7100); 18478da9db0cSSrinivas Kandagatla clear_bit(HPH_PA_DELAY, &wcd938x->status_mask); 18488da9db0cSSrinivas Kandagatla } 18498da9db0cSSrinivas Kandagatla snd_soc_component_write_field(component, WCD938X_ANA_HPH, 18508da9db0cSSrinivas Kandagatla WCD938X_HPHL_REF_EN_MASK, 0); 18518da9db0cSSrinivas Kandagatla snd_soc_component_write_field(component, WCD938X_DIGITAL_PDM_WD_CTL0, 18528da9db0cSSrinivas Kandagatla WCD938X_PDM_WD_EN_MASK, 0); 18538da9db0cSSrinivas Kandagatla wcd_clsh_ctrl_set_state(wcd938x->clsh_info, WCD_CLSH_EVENT_POST_PA, 18548da9db0cSSrinivas Kandagatla WCD_CLSH_STATE_HPHL, hph_mode); 18558da9db0cSSrinivas Kandagatla if (wcd938x->ldoh) 18568da9db0cSSrinivas Kandagatla snd_soc_component_write_field(component, WCD938X_LDOH_MODE, 18578da9db0cSSrinivas Kandagatla WCD938X_LDOH_EN_MASK, 0); 18588da9db0cSSrinivas Kandagatla break; 18598da9db0cSSrinivas Kandagatla } 18608da9db0cSSrinivas Kandagatla 18618da9db0cSSrinivas Kandagatla return 0; 18628da9db0cSSrinivas Kandagatla } 18638da9db0cSSrinivas Kandagatla 18648da9db0cSSrinivas Kandagatla static int wcd938x_codec_enable_aux_pa(struct snd_soc_dapm_widget *w, 18658da9db0cSSrinivas Kandagatla struct snd_kcontrol *kcontrol, int event) 18668da9db0cSSrinivas Kandagatla { 18678da9db0cSSrinivas Kandagatla struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); 18688da9db0cSSrinivas Kandagatla struct wcd938x_priv *wcd938x = snd_soc_component_get_drvdata(component); 18698da9db0cSSrinivas Kandagatla int hph_mode = wcd938x->hph_mode; 18708da9db0cSSrinivas Kandagatla int ret = 0; 18718da9db0cSSrinivas Kandagatla 18728da9db0cSSrinivas Kandagatla switch (event) { 18738da9db0cSSrinivas Kandagatla case SND_SOC_DAPM_PRE_PMU: 18748da9db0cSSrinivas Kandagatla snd_soc_component_write_field(component, WCD938X_DIGITAL_PDM_WD_CTL2, 18758da9db0cSSrinivas Kandagatla WCD938X_AUX_PDM_WD_EN_MASK, 1); 18768da9db0cSSrinivas Kandagatla break; 18778da9db0cSSrinivas Kandagatla case SND_SOC_DAPM_POST_PMU: 18788da9db0cSSrinivas Kandagatla /* 1 msec delay as per HW requirement */ 18798da9db0cSSrinivas Kandagatla usleep_range(1000, 1010); 18808da9db0cSSrinivas Kandagatla if (hph_mode == CLS_AB || hph_mode == CLS_AB_HIFI || 18818da9db0cSSrinivas Kandagatla hph_mode == CLS_AB_LP || hph_mode == CLS_AB_LOHIFI) 18828da9db0cSSrinivas Kandagatla snd_soc_component_write_field(component, WCD938X_ANA_RX_SUPPLIES, 18838da9db0cSSrinivas Kandagatla WCD938X_REGULATOR_MODE_MASK, 18848da9db0cSSrinivas Kandagatla WCD938X_REGULATOR_MODE_CLASS_AB); 18858da9db0cSSrinivas Kandagatla enable_irq(wcd938x->aux_pdm_wd_int); 18868da9db0cSSrinivas Kandagatla break; 18878da9db0cSSrinivas Kandagatla case SND_SOC_DAPM_PRE_PMD: 18888da9db0cSSrinivas Kandagatla disable_irq_nosync(wcd938x->aux_pdm_wd_int); 18898da9db0cSSrinivas Kandagatla break; 18908da9db0cSSrinivas Kandagatla case SND_SOC_DAPM_POST_PMD: 18918da9db0cSSrinivas Kandagatla /* 1 msec delay as per HW requirement */ 18928da9db0cSSrinivas Kandagatla usleep_range(1000, 1010); 18938da9db0cSSrinivas Kandagatla snd_soc_component_write_field(component, WCD938X_DIGITAL_PDM_WD_CTL2, 18948da9db0cSSrinivas Kandagatla WCD938X_AUX_PDM_WD_EN_MASK, 0); 18958da9db0cSSrinivas Kandagatla wcd_clsh_ctrl_set_state(wcd938x->clsh_info, 18968da9db0cSSrinivas Kandagatla WCD_CLSH_EVENT_POST_PA, 18978da9db0cSSrinivas Kandagatla WCD_CLSH_STATE_AUX, 18988da9db0cSSrinivas Kandagatla hph_mode); 18998da9db0cSSrinivas Kandagatla 19008da9db0cSSrinivas Kandagatla wcd938x->flyback_cur_det_disable--; 19018da9db0cSSrinivas Kandagatla if (wcd938x->flyback_cur_det_disable == 0) 19028da9db0cSSrinivas Kandagatla snd_soc_component_write_field(component, WCD938X_FLYBACK_EN, 19038da9db0cSSrinivas Kandagatla WCD938X_EN_CUR_DET_MASK, 1); 19048da9db0cSSrinivas Kandagatla break; 19058da9db0cSSrinivas Kandagatla } 19068da9db0cSSrinivas Kandagatla return ret; 19078da9db0cSSrinivas Kandagatla } 19088da9db0cSSrinivas Kandagatla 19098da9db0cSSrinivas Kandagatla static int wcd938x_codec_enable_ear_pa(struct snd_soc_dapm_widget *w, 19108da9db0cSSrinivas Kandagatla struct snd_kcontrol *kcontrol, int event) 19118da9db0cSSrinivas Kandagatla { 19128da9db0cSSrinivas Kandagatla struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); 19138da9db0cSSrinivas Kandagatla struct wcd938x_priv *wcd938x = snd_soc_component_get_drvdata(component); 19148da9db0cSSrinivas Kandagatla int hph_mode = wcd938x->hph_mode; 19158da9db0cSSrinivas Kandagatla 19168da9db0cSSrinivas Kandagatla switch (event) { 19178da9db0cSSrinivas Kandagatla case SND_SOC_DAPM_PRE_PMU: 19188da9db0cSSrinivas Kandagatla /* 19198da9db0cSSrinivas Kandagatla * Enable watchdog interrupt for HPHL or AUX 19208da9db0cSSrinivas Kandagatla * depending on mux value 19218da9db0cSSrinivas Kandagatla */ 19228da9db0cSSrinivas Kandagatla wcd938x->ear_rx_path = snd_soc_component_read(component, 19238da9db0cSSrinivas Kandagatla WCD938X_DIGITAL_CDC_EAR_PATH_CTL); 19248da9db0cSSrinivas Kandagatla if (wcd938x->ear_rx_path & EAR_RX_PATH_AUX) 19258da9db0cSSrinivas Kandagatla snd_soc_component_write_field(component, WCD938X_DIGITAL_PDM_WD_CTL2, 19268da9db0cSSrinivas Kandagatla WCD938X_AUX_PDM_WD_EN_MASK, 1); 19278da9db0cSSrinivas Kandagatla else 19288da9db0cSSrinivas Kandagatla snd_soc_component_write_field(component, 19298da9db0cSSrinivas Kandagatla WCD938X_DIGITAL_PDM_WD_CTL0, 19308da9db0cSSrinivas Kandagatla WCD938X_PDM_WD_EN_MASK, 0x3); 19318da9db0cSSrinivas Kandagatla if (!wcd938x->comp1_enable) 19328da9db0cSSrinivas Kandagatla snd_soc_component_write_field(component, 19338da9db0cSSrinivas Kandagatla WCD938X_ANA_EAR_COMPANDER_CTL, 19348da9db0cSSrinivas Kandagatla WCD938X_GAIN_OVRD_REG_MASK, 1); 19358da9db0cSSrinivas Kandagatla 19368da9db0cSSrinivas Kandagatla break; 19378da9db0cSSrinivas Kandagatla case SND_SOC_DAPM_POST_PMU: 19388da9db0cSSrinivas Kandagatla /* 6 msec delay as per HW requirement */ 19398da9db0cSSrinivas Kandagatla usleep_range(6000, 6010); 19408da9db0cSSrinivas Kandagatla if (hph_mode == CLS_AB || hph_mode == CLS_AB_HIFI || 19418da9db0cSSrinivas Kandagatla hph_mode == CLS_AB_LP || hph_mode == CLS_AB_LOHIFI) 19428da9db0cSSrinivas Kandagatla snd_soc_component_write_field(component, WCD938X_ANA_RX_SUPPLIES, 19438da9db0cSSrinivas Kandagatla WCD938X_REGULATOR_MODE_MASK, 19448da9db0cSSrinivas Kandagatla WCD938X_REGULATOR_MODE_CLASS_AB); 19458da9db0cSSrinivas Kandagatla if (wcd938x->ear_rx_path & EAR_RX_PATH_AUX) 19468da9db0cSSrinivas Kandagatla enable_irq(wcd938x->aux_pdm_wd_int); 19478da9db0cSSrinivas Kandagatla else 19488da9db0cSSrinivas Kandagatla enable_irq(wcd938x->hphl_pdm_wd_int); 19498da9db0cSSrinivas Kandagatla break; 19508da9db0cSSrinivas Kandagatla case SND_SOC_DAPM_PRE_PMD: 19518da9db0cSSrinivas Kandagatla if (wcd938x->ear_rx_path & EAR_RX_PATH_AUX) 19528da9db0cSSrinivas Kandagatla disable_irq_nosync(wcd938x->aux_pdm_wd_int); 19538da9db0cSSrinivas Kandagatla else 19548da9db0cSSrinivas Kandagatla disable_irq_nosync(wcd938x->hphl_pdm_wd_int); 19558da9db0cSSrinivas Kandagatla break; 19568da9db0cSSrinivas Kandagatla case SND_SOC_DAPM_POST_PMD: 19578da9db0cSSrinivas Kandagatla if (!wcd938x->comp1_enable) 19588da9db0cSSrinivas Kandagatla snd_soc_component_write_field(component, WCD938X_ANA_EAR_COMPANDER_CTL, 19598da9db0cSSrinivas Kandagatla WCD938X_GAIN_OVRD_REG_MASK, 0); 19608da9db0cSSrinivas Kandagatla /* 7 msec delay as per HW requirement */ 19618da9db0cSSrinivas Kandagatla usleep_range(7000, 7010); 19628da9db0cSSrinivas Kandagatla if (wcd938x->ear_rx_path & EAR_RX_PATH_AUX) 19638da9db0cSSrinivas Kandagatla snd_soc_component_write_field(component, WCD938X_DIGITAL_PDM_WD_CTL2, 19648da9db0cSSrinivas Kandagatla WCD938X_AUX_PDM_WD_EN_MASK, 0); 19658da9db0cSSrinivas Kandagatla else 19668da9db0cSSrinivas Kandagatla snd_soc_component_write_field(component, WCD938X_DIGITAL_PDM_WD_CTL0, 19678da9db0cSSrinivas Kandagatla WCD938X_PDM_WD_EN_MASK, 0); 19688da9db0cSSrinivas Kandagatla 19698da9db0cSSrinivas Kandagatla wcd_clsh_ctrl_set_state(wcd938x->clsh_info, WCD_CLSH_EVENT_POST_PA, 19708da9db0cSSrinivas Kandagatla WCD_CLSH_STATE_EAR, hph_mode); 19718da9db0cSSrinivas Kandagatla 19728da9db0cSSrinivas Kandagatla wcd938x->flyback_cur_det_disable--; 19738da9db0cSSrinivas Kandagatla if (wcd938x->flyback_cur_det_disable == 0) 19748da9db0cSSrinivas Kandagatla snd_soc_component_write_field(component, WCD938X_FLYBACK_EN, 19758da9db0cSSrinivas Kandagatla WCD938X_EN_CUR_DET_MASK, 1); 19768da9db0cSSrinivas Kandagatla break; 19778da9db0cSSrinivas Kandagatla } 19788da9db0cSSrinivas Kandagatla 19798da9db0cSSrinivas Kandagatla return 0; 19808da9db0cSSrinivas Kandagatla } 19818da9db0cSSrinivas Kandagatla 1982d5add08fSSrinivas Kandagatla static int wcd938x_codec_enable_dmic(struct snd_soc_dapm_widget *w, 1983d5add08fSSrinivas Kandagatla struct snd_kcontrol *kcontrol, 1984d5add08fSSrinivas Kandagatla int event) 1985d5add08fSSrinivas Kandagatla { 1986d5add08fSSrinivas Kandagatla struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); 1987d5add08fSSrinivas Kandagatla u16 dmic_clk_reg, dmic_clk_en_reg; 1988d5add08fSSrinivas Kandagatla u8 dmic_sel_mask, dmic_clk_mask; 1989d5add08fSSrinivas Kandagatla 1990d5add08fSSrinivas Kandagatla switch (w->shift) { 1991d5add08fSSrinivas Kandagatla case 0: 1992d5add08fSSrinivas Kandagatla case 1: 1993d5add08fSSrinivas Kandagatla dmic_clk_reg = WCD938X_DIGITAL_CDC_DMIC_RATE_1_2; 1994d5add08fSSrinivas Kandagatla dmic_clk_en_reg = WCD938X_DIGITAL_CDC_DMIC1_CTL; 1995d5add08fSSrinivas Kandagatla dmic_clk_mask = WCD938X_DMIC1_RATE_MASK; 1996d5add08fSSrinivas Kandagatla dmic_sel_mask = WCD938X_AMIC1_IN_SEL_MASK; 1997d5add08fSSrinivas Kandagatla break; 1998d5add08fSSrinivas Kandagatla case 2: 1999d5add08fSSrinivas Kandagatla case 3: 2000d5add08fSSrinivas Kandagatla dmic_clk_reg = WCD938X_DIGITAL_CDC_DMIC_RATE_1_2; 2001d5add08fSSrinivas Kandagatla dmic_clk_en_reg = WCD938X_DIGITAL_CDC_DMIC2_CTL; 2002d5add08fSSrinivas Kandagatla dmic_clk_mask = WCD938X_DMIC2_RATE_MASK; 2003d5add08fSSrinivas Kandagatla dmic_sel_mask = WCD938X_AMIC3_IN_SEL_MASK; 2004d5add08fSSrinivas Kandagatla break; 2005d5add08fSSrinivas Kandagatla case 4: 2006d5add08fSSrinivas Kandagatla case 5: 2007d5add08fSSrinivas Kandagatla dmic_clk_reg = WCD938X_DIGITAL_CDC_DMIC_RATE_3_4; 2008d5add08fSSrinivas Kandagatla dmic_clk_en_reg = WCD938X_DIGITAL_CDC_DMIC3_CTL; 2009d5add08fSSrinivas Kandagatla dmic_clk_mask = WCD938X_DMIC3_RATE_MASK; 2010d5add08fSSrinivas Kandagatla dmic_sel_mask = WCD938X_AMIC4_IN_SEL_MASK; 2011d5add08fSSrinivas Kandagatla break; 2012d5add08fSSrinivas Kandagatla case 6: 2013d5add08fSSrinivas Kandagatla case 7: 2014d5add08fSSrinivas Kandagatla dmic_clk_reg = WCD938X_DIGITAL_CDC_DMIC_RATE_3_4; 2015d5add08fSSrinivas Kandagatla dmic_clk_en_reg = WCD938X_DIGITAL_CDC_DMIC4_CTL; 2016d5add08fSSrinivas Kandagatla dmic_clk_mask = WCD938X_DMIC4_RATE_MASK; 2017d5add08fSSrinivas Kandagatla dmic_sel_mask = WCD938X_AMIC5_IN_SEL_MASK; 2018d5add08fSSrinivas Kandagatla break; 2019d5add08fSSrinivas Kandagatla default: 2020d5add08fSSrinivas Kandagatla dev_err(component->dev, "%s: Invalid DMIC Selection\n", 2021d5add08fSSrinivas Kandagatla __func__); 2022d5add08fSSrinivas Kandagatla return -EINVAL; 2023d5add08fSSrinivas Kandagatla } 2024d5add08fSSrinivas Kandagatla 2025d5add08fSSrinivas Kandagatla switch (event) { 2026d5add08fSSrinivas Kandagatla case SND_SOC_DAPM_PRE_PMU: 2027d5add08fSSrinivas Kandagatla snd_soc_component_write_field(component, 2028d5add08fSSrinivas Kandagatla WCD938X_DIGITAL_CDC_AMIC_CTL, 2029d5add08fSSrinivas Kandagatla dmic_sel_mask, 2030d5add08fSSrinivas Kandagatla WCD938X_AMIC1_IN_SEL_DMIC); 2031d5add08fSSrinivas Kandagatla /* 250us sleep as per HW requirement */ 2032d5add08fSSrinivas Kandagatla usleep_range(250, 260); 2033d5add08fSSrinivas Kandagatla /* Setting DMIC clock rate to 2.4MHz */ 2034d5add08fSSrinivas Kandagatla snd_soc_component_write_field(component, dmic_clk_reg, 2035d5add08fSSrinivas Kandagatla dmic_clk_mask, 2036d5add08fSSrinivas Kandagatla WCD938X_DMIC4_RATE_2P4MHZ); 2037d5add08fSSrinivas Kandagatla snd_soc_component_write_field(component, dmic_clk_en_reg, 2038d5add08fSSrinivas Kandagatla WCD938X_DMIC_CLK_EN_MASK, 1); 2039d5add08fSSrinivas Kandagatla /* enable clock scaling */ 2040d5add08fSSrinivas Kandagatla snd_soc_component_write_field(component, WCD938X_DIGITAL_CDC_DMIC_CTL, 2041d5add08fSSrinivas Kandagatla WCD938X_DMIC_CLK_SCALING_EN_MASK, 0x3); 2042d5add08fSSrinivas Kandagatla break; 2043d5add08fSSrinivas Kandagatla case SND_SOC_DAPM_POST_PMD: 2044d5add08fSSrinivas Kandagatla snd_soc_component_write_field(component, 2045d5add08fSSrinivas Kandagatla WCD938X_DIGITAL_CDC_AMIC_CTL, 2046d5add08fSSrinivas Kandagatla dmic_sel_mask, WCD938X_AMIC1_IN_SEL_AMIC); 2047d5add08fSSrinivas Kandagatla snd_soc_component_write_field(component, dmic_clk_en_reg, 2048d5add08fSSrinivas Kandagatla WCD938X_DMIC_CLK_EN_MASK, 0); 2049d5add08fSSrinivas Kandagatla break; 2050d5add08fSSrinivas Kandagatla } 2051d5add08fSSrinivas Kandagatla return 0; 2052d5add08fSSrinivas Kandagatla } 2053d5add08fSSrinivas Kandagatla 2054d5add08fSSrinivas Kandagatla static int wcd938x_tx_swr_ctrl(struct snd_soc_dapm_widget *w, 2055d5add08fSSrinivas Kandagatla struct snd_kcontrol *kcontrol, int event) 2056d5add08fSSrinivas Kandagatla { 2057d5add08fSSrinivas Kandagatla struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); 2058d5add08fSSrinivas Kandagatla struct wcd938x_priv *wcd938x = snd_soc_component_get_drvdata(component); 2059d5add08fSSrinivas Kandagatla int bank; 2060d5add08fSSrinivas Kandagatla int rate; 2061d5add08fSSrinivas Kandagatla 2062d5add08fSSrinivas Kandagatla bank = (wcd938x_swr_get_current_bank(wcd938x->sdw_priv[AIF1_CAP]->sdev)) ? 0 : 1; 2063d5add08fSSrinivas Kandagatla bank = bank ? 0 : 1; 2064d5add08fSSrinivas Kandagatla 2065d5add08fSSrinivas Kandagatla switch (event) { 2066d5add08fSSrinivas Kandagatla case SND_SOC_DAPM_PRE_PMU: 2067d5add08fSSrinivas Kandagatla if (strnstr(w->name, "ADC", sizeof("ADC"))) { 2068d5add08fSSrinivas Kandagatla int i = 0, mode = 0; 2069d5add08fSSrinivas Kandagatla 2070d5add08fSSrinivas Kandagatla if (test_bit(WCD_ADC1, &wcd938x->status_mask)) 2071d5add08fSSrinivas Kandagatla mode |= tx_mode_bit[wcd938x->tx_mode[WCD_ADC1]]; 2072d5add08fSSrinivas Kandagatla if (test_bit(WCD_ADC2, &wcd938x->status_mask)) 2073d5add08fSSrinivas Kandagatla mode |= tx_mode_bit[wcd938x->tx_mode[WCD_ADC2]]; 2074d5add08fSSrinivas Kandagatla if (test_bit(WCD_ADC3, &wcd938x->status_mask)) 2075d5add08fSSrinivas Kandagatla mode |= tx_mode_bit[wcd938x->tx_mode[WCD_ADC3]]; 2076d5add08fSSrinivas Kandagatla if (test_bit(WCD_ADC4, &wcd938x->status_mask)) 2077d5add08fSSrinivas Kandagatla mode |= tx_mode_bit[wcd938x->tx_mode[WCD_ADC4]]; 2078d5add08fSSrinivas Kandagatla 2079d5add08fSSrinivas Kandagatla if (mode != 0) { 2080d5add08fSSrinivas Kandagatla for (i = 0; i < ADC_MODE_ULP2; i++) { 2081d5add08fSSrinivas Kandagatla if (mode & (1 << i)) { 2082d5add08fSSrinivas Kandagatla i++; 2083d5add08fSSrinivas Kandagatla break; 2084d5add08fSSrinivas Kandagatla } 2085d5add08fSSrinivas Kandagatla } 2086d5add08fSSrinivas Kandagatla } 2087d5add08fSSrinivas Kandagatla rate = wcd938x_get_clk_rate(i); 2088d5add08fSSrinivas Kandagatla wcd938x_set_swr_clk_rate(component, rate, bank); 2089d5add08fSSrinivas Kandagatla } 2090d5add08fSSrinivas Kandagatla 2091d5add08fSSrinivas Kandagatla if (strnstr(w->name, "ADC", sizeof("ADC"))) 2092d5add08fSSrinivas Kandagatla /* Copy clk settings to active bank */ 2093d5add08fSSrinivas Kandagatla wcd938x_set_swr_clk_rate(component, rate, !bank); 2094d5add08fSSrinivas Kandagatla break; 2095d5add08fSSrinivas Kandagatla case SND_SOC_DAPM_POST_PMD: 2096d5add08fSSrinivas Kandagatla if (strnstr(w->name, "ADC", sizeof("ADC"))) { 2097d5add08fSSrinivas Kandagatla rate = wcd938x_get_clk_rate(ADC_MODE_INVALID); 2098d5add08fSSrinivas Kandagatla wcd938x_set_swr_clk_rate(component, rate, !bank); 2099d5add08fSSrinivas Kandagatla wcd938x_set_swr_clk_rate(component, rate, bank); 2100d5add08fSSrinivas Kandagatla } 2101d5add08fSSrinivas Kandagatla break; 2102d5add08fSSrinivas Kandagatla } 2103d5add08fSSrinivas Kandagatla 2104d5add08fSSrinivas Kandagatla return 0; 2105d5add08fSSrinivas Kandagatla } 2106d5add08fSSrinivas Kandagatla 2107d5add08fSSrinivas Kandagatla static int wcd938x_get_adc_mode(int val) 2108d5add08fSSrinivas Kandagatla { 2109d5add08fSSrinivas Kandagatla int ret = 0; 2110d5add08fSSrinivas Kandagatla 2111d5add08fSSrinivas Kandagatla switch (val) { 2112d5add08fSSrinivas Kandagatla case ADC_MODE_INVALID: 2113d5add08fSSrinivas Kandagatla ret = ADC_MODE_VAL_NORMAL; 2114d5add08fSSrinivas Kandagatla break; 2115d5add08fSSrinivas Kandagatla case ADC_MODE_HIFI: 2116d5add08fSSrinivas Kandagatla ret = ADC_MODE_VAL_HIFI; 2117d5add08fSSrinivas Kandagatla break; 2118d5add08fSSrinivas Kandagatla case ADC_MODE_LO_HIF: 2119d5add08fSSrinivas Kandagatla ret = ADC_MODE_VAL_LO_HIF; 2120d5add08fSSrinivas Kandagatla break; 2121d5add08fSSrinivas Kandagatla case ADC_MODE_NORMAL: 2122d5add08fSSrinivas Kandagatla ret = ADC_MODE_VAL_NORMAL; 2123d5add08fSSrinivas Kandagatla break; 2124d5add08fSSrinivas Kandagatla case ADC_MODE_LP: 2125d5add08fSSrinivas Kandagatla ret = ADC_MODE_VAL_LP; 2126d5add08fSSrinivas Kandagatla break; 2127d5add08fSSrinivas Kandagatla case ADC_MODE_ULP1: 2128d5add08fSSrinivas Kandagatla ret = ADC_MODE_VAL_ULP1; 2129d5add08fSSrinivas Kandagatla break; 2130d5add08fSSrinivas Kandagatla case ADC_MODE_ULP2: 2131d5add08fSSrinivas Kandagatla ret = ADC_MODE_VAL_ULP2; 2132d5add08fSSrinivas Kandagatla break; 2133d5add08fSSrinivas Kandagatla default: 2134d5add08fSSrinivas Kandagatla ret = -EINVAL; 2135d5add08fSSrinivas Kandagatla break; 2136d5add08fSSrinivas Kandagatla } 2137d5add08fSSrinivas Kandagatla return ret; 2138d5add08fSSrinivas Kandagatla } 2139d5add08fSSrinivas Kandagatla 2140d5add08fSSrinivas Kandagatla static int wcd938x_codec_enable_adc(struct snd_soc_dapm_widget *w, 2141d5add08fSSrinivas Kandagatla struct snd_kcontrol *kcontrol, int event) 2142d5add08fSSrinivas Kandagatla { 2143d5add08fSSrinivas Kandagatla struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); 2144d5add08fSSrinivas Kandagatla struct wcd938x_priv *wcd938x = snd_soc_component_get_drvdata(component); 2145d5add08fSSrinivas Kandagatla 2146d5add08fSSrinivas Kandagatla switch (event) { 2147d5add08fSSrinivas Kandagatla case SND_SOC_DAPM_PRE_PMU: 2148d5add08fSSrinivas Kandagatla snd_soc_component_write_field(component, 2149d5add08fSSrinivas Kandagatla WCD938X_DIGITAL_CDC_ANA_CLK_CTL, 2150d5add08fSSrinivas Kandagatla WCD938X_ANA_TX_CLK_EN_MASK, 1); 2151d5add08fSSrinivas Kandagatla snd_soc_component_write_field(component, 2152d5add08fSSrinivas Kandagatla WCD938X_DIGITAL_CDC_ANA_CLK_CTL, 2153d5add08fSSrinivas Kandagatla WCD938X_ANA_TX_DIV2_CLK_EN_MASK, 1); 2154d5add08fSSrinivas Kandagatla set_bit(w->shift, &wcd938x->status_mask); 2155d5add08fSSrinivas Kandagatla break; 2156d5add08fSSrinivas Kandagatla case SND_SOC_DAPM_POST_PMD: 2157d5add08fSSrinivas Kandagatla snd_soc_component_write_field(component, WCD938X_DIGITAL_CDC_ANA_CLK_CTL, 2158d5add08fSSrinivas Kandagatla WCD938X_ANA_TX_CLK_EN_MASK, 0); 2159d5add08fSSrinivas Kandagatla clear_bit(w->shift, &wcd938x->status_mask); 2160d5add08fSSrinivas Kandagatla break; 2161d5add08fSSrinivas Kandagatla } 2162d5add08fSSrinivas Kandagatla 2163d5add08fSSrinivas Kandagatla return 0; 2164d5add08fSSrinivas Kandagatla } 2165d5add08fSSrinivas Kandagatla 2166d5add08fSSrinivas Kandagatla static void wcd938x_tx_channel_config(struct snd_soc_component *component, 2167d5add08fSSrinivas Kandagatla int channel, int mode) 2168d5add08fSSrinivas Kandagatla { 2169d5add08fSSrinivas Kandagatla int reg, mask; 2170d5add08fSSrinivas Kandagatla 2171d5add08fSSrinivas Kandagatla switch (channel) { 2172d5add08fSSrinivas Kandagatla case 0: 2173d5add08fSSrinivas Kandagatla reg = WCD938X_ANA_TX_CH2; 2174d5add08fSSrinivas Kandagatla mask = WCD938X_HPF1_INIT_MASK; 2175d5add08fSSrinivas Kandagatla break; 2176d5add08fSSrinivas Kandagatla case 1: 2177d5add08fSSrinivas Kandagatla reg = WCD938X_ANA_TX_CH2; 2178d5add08fSSrinivas Kandagatla mask = WCD938X_HPF2_INIT_MASK; 2179d5add08fSSrinivas Kandagatla break; 2180d5add08fSSrinivas Kandagatla case 2: 2181d5add08fSSrinivas Kandagatla reg = WCD938X_ANA_TX_CH4; 2182d5add08fSSrinivas Kandagatla mask = WCD938X_HPF3_INIT_MASK; 2183d5add08fSSrinivas Kandagatla break; 2184d5add08fSSrinivas Kandagatla case 3: 2185d5add08fSSrinivas Kandagatla reg = WCD938X_ANA_TX_CH4; 2186d5add08fSSrinivas Kandagatla mask = WCD938X_HPF4_INIT_MASK; 2187d5add08fSSrinivas Kandagatla break; 2188d5add08fSSrinivas Kandagatla } 2189d5add08fSSrinivas Kandagatla 2190d5add08fSSrinivas Kandagatla snd_soc_component_write_field(component, reg, mask, mode); 2191d5add08fSSrinivas Kandagatla } 2192d5add08fSSrinivas Kandagatla 2193d5add08fSSrinivas Kandagatla static int wcd938x_adc_enable_req(struct snd_soc_dapm_widget *w, 2194d5add08fSSrinivas Kandagatla struct snd_kcontrol *kcontrol, int event) 2195d5add08fSSrinivas Kandagatla { 2196d5add08fSSrinivas Kandagatla struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); 2197d5add08fSSrinivas Kandagatla struct wcd938x_priv *wcd938x = snd_soc_component_get_drvdata(component); 2198d5add08fSSrinivas Kandagatla int mode; 2199d5add08fSSrinivas Kandagatla 2200d5add08fSSrinivas Kandagatla switch (event) { 2201d5add08fSSrinivas Kandagatla case SND_SOC_DAPM_PRE_PMU: 2202d5add08fSSrinivas Kandagatla snd_soc_component_write_field(component, 2203d5add08fSSrinivas Kandagatla WCD938X_DIGITAL_CDC_REQ_CTL, 2204d5add08fSSrinivas Kandagatla WCD938X_FS_RATE_4P8_MASK, 1); 2205d5add08fSSrinivas Kandagatla snd_soc_component_write_field(component, 2206d5add08fSSrinivas Kandagatla WCD938X_DIGITAL_CDC_REQ_CTL, 2207d5add08fSSrinivas Kandagatla WCD938X_NO_NOTCH_MASK, 0); 2208d5add08fSSrinivas Kandagatla wcd938x_tx_channel_config(component, w->shift, 1); 2209d5add08fSSrinivas Kandagatla mode = wcd938x_get_adc_mode(wcd938x->tx_mode[w->shift]); 2210d5add08fSSrinivas Kandagatla if (mode < 0) { 2211d5add08fSSrinivas Kandagatla dev_info(component->dev, "Invalid ADC mode\n"); 2212d5add08fSSrinivas Kandagatla return -EINVAL; 2213d5add08fSSrinivas Kandagatla } 2214d5add08fSSrinivas Kandagatla switch (w->shift) { 2215d5add08fSSrinivas Kandagatla case 0: 2216d5add08fSSrinivas Kandagatla snd_soc_component_write_field(component, 2217d5add08fSSrinivas Kandagatla WCD938X_DIGITAL_CDC_TX_ANA_MODE_0_1, 2218d5add08fSSrinivas Kandagatla WCD938X_TXD0_MODE_MASK, mode); 2219d5add08fSSrinivas Kandagatla snd_soc_component_write_field(component, 2220d5add08fSSrinivas Kandagatla WCD938X_DIGITAL_CDC_DIG_CLK_CTL, 2221d5add08fSSrinivas Kandagatla WCD938X_TXD0_CLK_EN_MASK, 1); 2222d5add08fSSrinivas Kandagatla break; 2223d5add08fSSrinivas Kandagatla case 1: 2224d5add08fSSrinivas Kandagatla snd_soc_component_write_field(component, 2225d5add08fSSrinivas Kandagatla WCD938X_DIGITAL_CDC_TX_ANA_MODE_0_1, 2226d5add08fSSrinivas Kandagatla WCD938X_TXD1_MODE_MASK, mode); 2227d5add08fSSrinivas Kandagatla snd_soc_component_write_field(component, 2228d5add08fSSrinivas Kandagatla WCD938X_DIGITAL_CDC_DIG_CLK_CTL, 2229d5add08fSSrinivas Kandagatla WCD938X_TXD1_CLK_EN_MASK, 1); 2230d5add08fSSrinivas Kandagatla break; 2231d5add08fSSrinivas Kandagatla case 2: 2232d5add08fSSrinivas Kandagatla snd_soc_component_write_field(component, 2233d5add08fSSrinivas Kandagatla WCD938X_DIGITAL_CDC_TX_ANA_MODE_2_3, 2234d5add08fSSrinivas Kandagatla WCD938X_TXD2_MODE_MASK, mode); 2235d5add08fSSrinivas Kandagatla snd_soc_component_write_field(component, 2236d5add08fSSrinivas Kandagatla WCD938X_DIGITAL_CDC_DIG_CLK_CTL, 2237d5add08fSSrinivas Kandagatla WCD938X_TXD2_CLK_EN_MASK, 1); 2238d5add08fSSrinivas Kandagatla break; 2239d5add08fSSrinivas Kandagatla case 3: 2240d5add08fSSrinivas Kandagatla snd_soc_component_write_field(component, 2241d5add08fSSrinivas Kandagatla WCD938X_DIGITAL_CDC_TX_ANA_MODE_2_3, 2242d5add08fSSrinivas Kandagatla WCD938X_TXD3_MODE_MASK, mode); 2243d5add08fSSrinivas Kandagatla snd_soc_component_write_field(component, 2244d5add08fSSrinivas Kandagatla WCD938X_DIGITAL_CDC_DIG_CLK_CTL, 2245d5add08fSSrinivas Kandagatla WCD938X_TXD3_CLK_EN_MASK, 1); 2246d5add08fSSrinivas Kandagatla break; 2247d5add08fSSrinivas Kandagatla default: 2248d5add08fSSrinivas Kandagatla break; 2249d5add08fSSrinivas Kandagatla } 2250d5add08fSSrinivas Kandagatla 2251d5add08fSSrinivas Kandagatla wcd938x_tx_channel_config(component, w->shift, 0); 2252d5add08fSSrinivas Kandagatla break; 2253d5add08fSSrinivas Kandagatla case SND_SOC_DAPM_POST_PMD: 2254d5add08fSSrinivas Kandagatla switch (w->shift) { 2255d5add08fSSrinivas Kandagatla case 0: 2256d5add08fSSrinivas Kandagatla snd_soc_component_write_field(component, 2257d5add08fSSrinivas Kandagatla WCD938X_DIGITAL_CDC_TX_ANA_MODE_0_1, 2258d5add08fSSrinivas Kandagatla WCD938X_TXD0_MODE_MASK, 0); 2259d5add08fSSrinivas Kandagatla snd_soc_component_write_field(component, 2260d5add08fSSrinivas Kandagatla WCD938X_DIGITAL_CDC_DIG_CLK_CTL, 2261d5add08fSSrinivas Kandagatla WCD938X_TXD0_CLK_EN_MASK, 0); 2262d5add08fSSrinivas Kandagatla break; 2263d5add08fSSrinivas Kandagatla case 1: 2264d5add08fSSrinivas Kandagatla snd_soc_component_write_field(component, 2265d5add08fSSrinivas Kandagatla WCD938X_DIGITAL_CDC_TX_ANA_MODE_0_1, 2266d5add08fSSrinivas Kandagatla WCD938X_TXD1_MODE_MASK, 0); 2267d5add08fSSrinivas Kandagatla snd_soc_component_write_field(component, 2268d5add08fSSrinivas Kandagatla WCD938X_DIGITAL_CDC_DIG_CLK_CTL, 2269d5add08fSSrinivas Kandagatla WCD938X_TXD1_CLK_EN_MASK, 0); 2270d5add08fSSrinivas Kandagatla break; 2271d5add08fSSrinivas Kandagatla case 2: 2272d5add08fSSrinivas Kandagatla snd_soc_component_write_field(component, 2273d5add08fSSrinivas Kandagatla WCD938X_DIGITAL_CDC_TX_ANA_MODE_2_3, 2274d5add08fSSrinivas Kandagatla WCD938X_TXD2_MODE_MASK, 0); 2275d5add08fSSrinivas Kandagatla snd_soc_component_write_field(component, 2276d5add08fSSrinivas Kandagatla WCD938X_DIGITAL_CDC_DIG_CLK_CTL, 2277d5add08fSSrinivas Kandagatla WCD938X_TXD2_CLK_EN_MASK, 0); 2278d5add08fSSrinivas Kandagatla break; 2279d5add08fSSrinivas Kandagatla case 3: 2280d5add08fSSrinivas Kandagatla snd_soc_component_write_field(component, 2281d5add08fSSrinivas Kandagatla WCD938X_DIGITAL_CDC_TX_ANA_MODE_2_3, 2282d5add08fSSrinivas Kandagatla WCD938X_TXD3_MODE_MASK, 0); 2283d5add08fSSrinivas Kandagatla snd_soc_component_write_field(component, 2284d5add08fSSrinivas Kandagatla WCD938X_DIGITAL_CDC_DIG_CLK_CTL, 2285d5add08fSSrinivas Kandagatla WCD938X_TXD3_CLK_EN_MASK, 0); 2286d5add08fSSrinivas Kandagatla break; 2287d5add08fSSrinivas Kandagatla default: 2288d5add08fSSrinivas Kandagatla break; 2289d5add08fSSrinivas Kandagatla } 2290d5add08fSSrinivas Kandagatla snd_soc_component_write_field(component, 2291d5add08fSSrinivas Kandagatla WCD938X_DIGITAL_CDC_ANA_CLK_CTL, 2292d5add08fSSrinivas Kandagatla WCD938X_ANA_TX_DIV2_CLK_EN_MASK, 0); 2293d5add08fSSrinivas Kandagatla break; 2294d5add08fSSrinivas Kandagatla } 2295d5add08fSSrinivas Kandagatla 2296d5add08fSSrinivas Kandagatla return 0; 2297d5add08fSSrinivas Kandagatla } 2298d5add08fSSrinivas Kandagatla 2299d5add08fSSrinivas Kandagatla static int wcd938x_micbias_control(struct snd_soc_component *component, 2300d5add08fSSrinivas Kandagatla int micb_num, int req, bool is_dapm) 2301d5add08fSSrinivas Kandagatla { 2302d5add08fSSrinivas Kandagatla struct wcd938x_priv *wcd938x = snd_soc_component_get_drvdata(component); 2303d5add08fSSrinivas Kandagatla int micb_index = micb_num - 1; 2304d5add08fSSrinivas Kandagatla u16 micb_reg; 2305d5add08fSSrinivas Kandagatla 2306d5add08fSSrinivas Kandagatla switch (micb_num) { 2307d5add08fSSrinivas Kandagatla case MIC_BIAS_1: 2308d5add08fSSrinivas Kandagatla micb_reg = WCD938X_ANA_MICB1; 2309d5add08fSSrinivas Kandagatla break; 2310d5add08fSSrinivas Kandagatla case MIC_BIAS_2: 2311d5add08fSSrinivas Kandagatla micb_reg = WCD938X_ANA_MICB2; 2312d5add08fSSrinivas Kandagatla break; 2313d5add08fSSrinivas Kandagatla case MIC_BIAS_3: 2314d5add08fSSrinivas Kandagatla micb_reg = WCD938X_ANA_MICB3; 2315d5add08fSSrinivas Kandagatla break; 2316d5add08fSSrinivas Kandagatla case MIC_BIAS_4: 2317d5add08fSSrinivas Kandagatla micb_reg = WCD938X_ANA_MICB4; 2318d5add08fSSrinivas Kandagatla break; 2319d5add08fSSrinivas Kandagatla default: 2320d5add08fSSrinivas Kandagatla dev_err(component->dev, "%s: Invalid micbias number: %d\n", 2321d5add08fSSrinivas Kandagatla __func__, micb_num); 2322d5add08fSSrinivas Kandagatla return -EINVAL; 2323d5add08fSSrinivas Kandagatla } 2324d5add08fSSrinivas Kandagatla 2325d5add08fSSrinivas Kandagatla switch (req) { 2326d5add08fSSrinivas Kandagatla case MICB_PULLUP_ENABLE: 2327d5add08fSSrinivas Kandagatla wcd938x->pullup_ref[micb_index]++; 2328d5add08fSSrinivas Kandagatla if ((wcd938x->pullup_ref[micb_index] == 1) && 2329d5add08fSSrinivas Kandagatla (wcd938x->micb_ref[micb_index] == 0)) 2330d5add08fSSrinivas Kandagatla snd_soc_component_write_field(component, micb_reg, 2331d5add08fSSrinivas Kandagatla WCD938X_MICB_EN_MASK, 2332d5add08fSSrinivas Kandagatla WCD938X_MICB_PULL_UP); 2333d5add08fSSrinivas Kandagatla break; 2334d5add08fSSrinivas Kandagatla case MICB_PULLUP_DISABLE: 2335d5add08fSSrinivas Kandagatla if (wcd938x->pullup_ref[micb_index] > 0) 2336d5add08fSSrinivas Kandagatla wcd938x->pullup_ref[micb_index]--; 2337d5add08fSSrinivas Kandagatla 2338d5add08fSSrinivas Kandagatla if ((wcd938x->pullup_ref[micb_index] == 0) && 2339d5add08fSSrinivas Kandagatla (wcd938x->micb_ref[micb_index] == 0)) 2340d5add08fSSrinivas Kandagatla snd_soc_component_write_field(component, micb_reg, 2341d5add08fSSrinivas Kandagatla WCD938X_MICB_EN_MASK, 0); 2342d5add08fSSrinivas Kandagatla break; 2343d5add08fSSrinivas Kandagatla case MICB_ENABLE: 2344d5add08fSSrinivas Kandagatla wcd938x->micb_ref[micb_index]++; 2345d5add08fSSrinivas Kandagatla if (wcd938x->micb_ref[micb_index] == 1) { 2346d5add08fSSrinivas Kandagatla snd_soc_component_write_field(component, 2347d5add08fSSrinivas Kandagatla WCD938X_DIGITAL_CDC_DIG_CLK_CTL, 2348d5add08fSSrinivas Kandagatla WCD938X_TX_CLK_EN_MASK, 0xF); 2349d5add08fSSrinivas Kandagatla snd_soc_component_write_field(component, 2350d5add08fSSrinivas Kandagatla WCD938X_DIGITAL_CDC_ANA_CLK_CTL, 2351d5add08fSSrinivas Kandagatla WCD938X_ANA_TX_DIV2_CLK_EN_MASK, 1); 2352d5add08fSSrinivas Kandagatla snd_soc_component_write_field(component, 2353d5add08fSSrinivas Kandagatla WCD938X_DIGITAL_CDC_ANA_TX_CLK_CTL, 2354d5add08fSSrinivas Kandagatla WCD938X_TX_SC_CLK_EN_MASK, 1); 2355d5add08fSSrinivas Kandagatla 2356d5add08fSSrinivas Kandagatla snd_soc_component_write_field(component, micb_reg, 2357d5add08fSSrinivas Kandagatla WCD938X_MICB_EN_MASK, 2358d5add08fSSrinivas Kandagatla WCD938X_MICB_ENABLE); 2359d5add08fSSrinivas Kandagatla } 2360d5add08fSSrinivas Kandagatla 2361d5add08fSSrinivas Kandagatla break; 2362d5add08fSSrinivas Kandagatla case MICB_DISABLE: 2363d5add08fSSrinivas Kandagatla if (wcd938x->micb_ref[micb_index] > 0) 2364d5add08fSSrinivas Kandagatla wcd938x->micb_ref[micb_index]--; 2365d5add08fSSrinivas Kandagatla 2366d5add08fSSrinivas Kandagatla if ((wcd938x->micb_ref[micb_index] == 0) && 2367d5add08fSSrinivas Kandagatla (wcd938x->pullup_ref[micb_index] > 0)) 2368d5add08fSSrinivas Kandagatla snd_soc_component_write_field(component, micb_reg, 2369d5add08fSSrinivas Kandagatla WCD938X_MICB_EN_MASK, 2370d5add08fSSrinivas Kandagatla WCD938X_MICB_PULL_UP); 2371d5add08fSSrinivas Kandagatla else if ((wcd938x->micb_ref[micb_index] == 0) && 2372d5add08fSSrinivas Kandagatla (wcd938x->pullup_ref[micb_index] == 0)) { 2373d5add08fSSrinivas Kandagatla 2374d5add08fSSrinivas Kandagatla snd_soc_component_write_field(component, micb_reg, 2375d5add08fSSrinivas Kandagatla WCD938X_MICB_EN_MASK, 0); 2376d5add08fSSrinivas Kandagatla } 2377d5add08fSSrinivas Kandagatla break; 2378d5add08fSSrinivas Kandagatla } 2379d5add08fSSrinivas Kandagatla 2380d5add08fSSrinivas Kandagatla return 0; 2381d5add08fSSrinivas Kandagatla } 2382d5add08fSSrinivas Kandagatla 2383d5add08fSSrinivas Kandagatla static int wcd938x_codec_enable_micbias(struct snd_soc_dapm_widget *w, 2384d5add08fSSrinivas Kandagatla struct snd_kcontrol *kcontrol, 2385d5add08fSSrinivas Kandagatla int event) 2386d5add08fSSrinivas Kandagatla { 2387d5add08fSSrinivas Kandagatla struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); 2388d5add08fSSrinivas Kandagatla int micb_num = w->shift; 2389d5add08fSSrinivas Kandagatla 2390d5add08fSSrinivas Kandagatla switch (event) { 2391d5add08fSSrinivas Kandagatla case SND_SOC_DAPM_PRE_PMU: 2392d5add08fSSrinivas Kandagatla wcd938x_micbias_control(component, micb_num, MICB_ENABLE, true); 2393d5add08fSSrinivas Kandagatla break; 2394d5add08fSSrinivas Kandagatla case SND_SOC_DAPM_POST_PMU: 2395d5add08fSSrinivas Kandagatla /* 1 msec delay as per HW requirement */ 2396d5add08fSSrinivas Kandagatla usleep_range(1000, 1100); 2397d5add08fSSrinivas Kandagatla break; 2398d5add08fSSrinivas Kandagatla case SND_SOC_DAPM_POST_PMD: 2399d5add08fSSrinivas Kandagatla wcd938x_micbias_control(component, micb_num, MICB_DISABLE, true); 2400d5add08fSSrinivas Kandagatla break; 2401d5add08fSSrinivas Kandagatla } 2402d5add08fSSrinivas Kandagatla 2403d5add08fSSrinivas Kandagatla return 0; 2404d5add08fSSrinivas Kandagatla } 2405d5add08fSSrinivas Kandagatla 2406d5add08fSSrinivas Kandagatla static int wcd938x_codec_enable_micbias_pullup(struct snd_soc_dapm_widget *w, 2407d5add08fSSrinivas Kandagatla struct snd_kcontrol *kcontrol, 2408d5add08fSSrinivas Kandagatla int event) 2409d5add08fSSrinivas Kandagatla { 2410d5add08fSSrinivas Kandagatla struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); 2411d5add08fSSrinivas Kandagatla int micb_num = w->shift; 2412d5add08fSSrinivas Kandagatla 2413d5add08fSSrinivas Kandagatla switch (event) { 2414d5add08fSSrinivas Kandagatla case SND_SOC_DAPM_PRE_PMU: 2415d5add08fSSrinivas Kandagatla wcd938x_micbias_control(component, micb_num, 2416d5add08fSSrinivas Kandagatla MICB_PULLUP_ENABLE, true); 2417d5add08fSSrinivas Kandagatla break; 2418d5add08fSSrinivas Kandagatla case SND_SOC_DAPM_POST_PMU: 2419d5add08fSSrinivas Kandagatla /* 1 msec delay as per HW requirement */ 2420d5add08fSSrinivas Kandagatla usleep_range(1000, 1100); 2421d5add08fSSrinivas Kandagatla break; 2422d5add08fSSrinivas Kandagatla case SND_SOC_DAPM_POST_PMD: 2423d5add08fSSrinivas Kandagatla wcd938x_micbias_control(component, micb_num, 2424d5add08fSSrinivas Kandagatla MICB_PULLUP_DISABLE, true); 2425d5add08fSSrinivas Kandagatla break; 2426d5add08fSSrinivas Kandagatla } 2427d5add08fSSrinivas Kandagatla 2428d5add08fSSrinivas Kandagatla return 0; 2429d5add08fSSrinivas Kandagatla } 2430d5add08fSSrinivas Kandagatla 2431e8ba1e05SSrinivas Kandagatla static int wcd938x_tx_mode_get(struct snd_kcontrol *kcontrol, 2432e8ba1e05SSrinivas Kandagatla struct snd_ctl_elem_value *ucontrol) 2433e8ba1e05SSrinivas Kandagatla { 2434e8ba1e05SSrinivas Kandagatla struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); 2435e8ba1e05SSrinivas Kandagatla struct wcd938x_priv *wcd938x = snd_soc_component_get_drvdata(component); 2436e8ba1e05SSrinivas Kandagatla struct soc_enum *e = (struct soc_enum *)kcontrol->private_value; 2437e8ba1e05SSrinivas Kandagatla int path = e->shift_l; 2438e8ba1e05SSrinivas Kandagatla 2439e8ba1e05SSrinivas Kandagatla ucontrol->value.integer.value[0] = wcd938x->tx_mode[path]; 2440e8ba1e05SSrinivas Kandagatla 2441e8ba1e05SSrinivas Kandagatla return 0; 2442e8ba1e05SSrinivas Kandagatla } 2443e8ba1e05SSrinivas Kandagatla 2444e8ba1e05SSrinivas Kandagatla static int wcd938x_tx_mode_put(struct snd_kcontrol *kcontrol, 2445e8ba1e05SSrinivas Kandagatla struct snd_ctl_elem_value *ucontrol) 2446e8ba1e05SSrinivas Kandagatla { 2447e8ba1e05SSrinivas Kandagatla struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); 2448e8ba1e05SSrinivas Kandagatla struct wcd938x_priv *wcd938x = snd_soc_component_get_drvdata(component); 2449e8ba1e05SSrinivas Kandagatla struct soc_enum *e = (struct soc_enum *)kcontrol->private_value; 2450e8ba1e05SSrinivas Kandagatla int path = e->shift_l; 2451e8ba1e05SSrinivas Kandagatla 2452e8ba1e05SSrinivas Kandagatla wcd938x->tx_mode[path] = ucontrol->value.enumerated.item[0]; 2453e8ba1e05SSrinivas Kandagatla 2454e8ba1e05SSrinivas Kandagatla return 1; 2455e8ba1e05SSrinivas Kandagatla } 2456e8ba1e05SSrinivas Kandagatla 2457e8ba1e05SSrinivas Kandagatla static int wcd938x_rx_hph_mode_get(struct snd_kcontrol *kcontrol, 2458e8ba1e05SSrinivas Kandagatla struct snd_ctl_elem_value *ucontrol) 2459e8ba1e05SSrinivas Kandagatla { 2460e8ba1e05SSrinivas Kandagatla struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); 2461e8ba1e05SSrinivas Kandagatla struct wcd938x_priv *wcd938x = snd_soc_component_get_drvdata(component); 2462e8ba1e05SSrinivas Kandagatla 2463e8ba1e05SSrinivas Kandagatla ucontrol->value.integer.value[0] = wcd938x->hph_mode; 2464e8ba1e05SSrinivas Kandagatla 2465e8ba1e05SSrinivas Kandagatla return 0; 2466e8ba1e05SSrinivas Kandagatla } 2467e8ba1e05SSrinivas Kandagatla 2468e8ba1e05SSrinivas Kandagatla static int wcd938x_rx_hph_mode_put(struct snd_kcontrol *kcontrol, 2469e8ba1e05SSrinivas Kandagatla struct snd_ctl_elem_value *ucontrol) 2470e8ba1e05SSrinivas Kandagatla { 2471e8ba1e05SSrinivas Kandagatla struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); 2472e8ba1e05SSrinivas Kandagatla struct wcd938x_priv *wcd938x = snd_soc_component_get_drvdata(component); 2473e8ba1e05SSrinivas Kandagatla 2474e8ba1e05SSrinivas Kandagatla wcd938x->hph_mode = ucontrol->value.enumerated.item[0]; 2475e8ba1e05SSrinivas Kandagatla 2476e8ba1e05SSrinivas Kandagatla return 1; 2477e8ba1e05SSrinivas Kandagatla } 2478e8ba1e05SSrinivas Kandagatla 2479e8ba1e05SSrinivas Kandagatla static int wcd938x_ear_pa_put_gain(struct snd_kcontrol *kcontrol, 2480e8ba1e05SSrinivas Kandagatla struct snd_ctl_elem_value *ucontrol) 2481e8ba1e05SSrinivas Kandagatla { 2482e8ba1e05SSrinivas Kandagatla struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); 2483e8ba1e05SSrinivas Kandagatla struct wcd938x_priv *wcd938x = snd_soc_component_get_drvdata(component); 2484e8ba1e05SSrinivas Kandagatla 2485e8ba1e05SSrinivas Kandagatla if (wcd938x->comp1_enable) { 2486e8ba1e05SSrinivas Kandagatla dev_err(component->dev, "Can not set EAR PA Gain, compander1 is enabled\n"); 2487e8ba1e05SSrinivas Kandagatla return -EINVAL; 2488e8ba1e05SSrinivas Kandagatla } 2489e8ba1e05SSrinivas Kandagatla 2490e8ba1e05SSrinivas Kandagatla snd_soc_component_write_field(component, WCD938X_ANA_EAR_COMPANDER_CTL, 2491e8ba1e05SSrinivas Kandagatla WCD938X_EAR_GAIN_MASK, 2492e8ba1e05SSrinivas Kandagatla ucontrol->value.integer.value[0]); 2493e8ba1e05SSrinivas Kandagatla 2494e8ba1e05SSrinivas Kandagatla return 0; 2495e8ba1e05SSrinivas Kandagatla } 2496e8ba1e05SSrinivas Kandagatla 2497e8ba1e05SSrinivas Kandagatla static int wcd938x_get_compander(struct snd_kcontrol *kcontrol, 2498e8ba1e05SSrinivas Kandagatla struct snd_ctl_elem_value *ucontrol) 2499e8ba1e05SSrinivas Kandagatla { 2500e8ba1e05SSrinivas Kandagatla 2501e8ba1e05SSrinivas Kandagatla struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); 2502e8ba1e05SSrinivas Kandagatla struct wcd938x_priv *wcd938x = snd_soc_component_get_drvdata(component); 2503e8ba1e05SSrinivas Kandagatla struct soc_mixer_control *mc; 2504e8ba1e05SSrinivas Kandagatla bool hphr; 2505e8ba1e05SSrinivas Kandagatla 2506e8ba1e05SSrinivas Kandagatla mc = (struct soc_mixer_control *)(kcontrol->private_value); 2507e8ba1e05SSrinivas Kandagatla hphr = mc->shift; 2508e8ba1e05SSrinivas Kandagatla 2509e8ba1e05SSrinivas Kandagatla if (hphr) 2510e8ba1e05SSrinivas Kandagatla ucontrol->value.integer.value[0] = wcd938x->comp2_enable; 2511e8ba1e05SSrinivas Kandagatla else 2512e8ba1e05SSrinivas Kandagatla ucontrol->value.integer.value[0] = wcd938x->comp1_enable; 2513e8ba1e05SSrinivas Kandagatla 2514e8ba1e05SSrinivas Kandagatla return 0; 2515e8ba1e05SSrinivas Kandagatla } 2516e8ba1e05SSrinivas Kandagatla 2517e8ba1e05SSrinivas Kandagatla static int wcd938x_set_compander(struct snd_kcontrol *kcontrol, 2518e8ba1e05SSrinivas Kandagatla struct snd_ctl_elem_value *ucontrol) 2519e8ba1e05SSrinivas Kandagatla { 2520e8ba1e05SSrinivas Kandagatla struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); 2521e8ba1e05SSrinivas Kandagatla struct wcd938x_priv *wcd938x = snd_soc_component_get_drvdata(component); 2522e8ba1e05SSrinivas Kandagatla struct wcd938x_sdw_priv *wcd; 2523e8ba1e05SSrinivas Kandagatla int value = ucontrol->value.integer.value[0]; 2524e8ba1e05SSrinivas Kandagatla struct soc_mixer_control *mc; 2525e8ba1e05SSrinivas Kandagatla bool hphr; 2526e8ba1e05SSrinivas Kandagatla 2527e8ba1e05SSrinivas Kandagatla mc = (struct soc_mixer_control *)(kcontrol->private_value); 2528e8ba1e05SSrinivas Kandagatla hphr = mc->shift; 2529e8ba1e05SSrinivas Kandagatla 2530e8ba1e05SSrinivas Kandagatla wcd = wcd938x->sdw_priv[AIF1_PB]; 2531e8ba1e05SSrinivas Kandagatla 2532e8ba1e05SSrinivas Kandagatla if (hphr) 2533e8ba1e05SSrinivas Kandagatla wcd938x->comp2_enable = value; 2534e8ba1e05SSrinivas Kandagatla else 2535e8ba1e05SSrinivas Kandagatla wcd938x->comp1_enable = value; 2536e8ba1e05SSrinivas Kandagatla 2537e8ba1e05SSrinivas Kandagatla if (value) 2538e8ba1e05SSrinivas Kandagatla wcd938x_connect_port(wcd, mc->reg, true); 2539e8ba1e05SSrinivas Kandagatla else 2540e8ba1e05SSrinivas Kandagatla wcd938x_connect_port(wcd, mc->reg, false); 2541e8ba1e05SSrinivas Kandagatla 2542e8ba1e05SSrinivas Kandagatla return 0; 2543e8ba1e05SSrinivas Kandagatla } 2544e8ba1e05SSrinivas Kandagatla 2545e8ba1e05SSrinivas Kandagatla static int wcd938x_ldoh_get(struct snd_kcontrol *kcontrol, 2546e8ba1e05SSrinivas Kandagatla struct snd_ctl_elem_value *ucontrol) 2547e8ba1e05SSrinivas Kandagatla { 2548e8ba1e05SSrinivas Kandagatla struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); 2549e8ba1e05SSrinivas Kandagatla struct wcd938x_priv *wcd938x = snd_soc_component_get_drvdata(component); 2550e8ba1e05SSrinivas Kandagatla 2551e8ba1e05SSrinivas Kandagatla ucontrol->value.integer.value[0] = wcd938x->ldoh; 2552e8ba1e05SSrinivas Kandagatla 2553e8ba1e05SSrinivas Kandagatla return 0; 2554e8ba1e05SSrinivas Kandagatla } 2555e8ba1e05SSrinivas Kandagatla 2556e8ba1e05SSrinivas Kandagatla static int wcd938x_ldoh_put(struct snd_kcontrol *kcontrol, 2557e8ba1e05SSrinivas Kandagatla struct snd_ctl_elem_value *ucontrol) 2558e8ba1e05SSrinivas Kandagatla { 2559e8ba1e05SSrinivas Kandagatla struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); 2560e8ba1e05SSrinivas Kandagatla struct wcd938x_priv *wcd938x = snd_soc_component_get_drvdata(component); 2561e8ba1e05SSrinivas Kandagatla 2562e8ba1e05SSrinivas Kandagatla wcd938x->ldoh = ucontrol->value.integer.value[0]; 2563e8ba1e05SSrinivas Kandagatla 2564e8ba1e05SSrinivas Kandagatla return 1; 2565e8ba1e05SSrinivas Kandagatla } 2566e8ba1e05SSrinivas Kandagatla 2567e8ba1e05SSrinivas Kandagatla static int wcd938x_bcs_get(struct snd_kcontrol *kcontrol, 2568e8ba1e05SSrinivas Kandagatla struct snd_ctl_elem_value *ucontrol) 2569e8ba1e05SSrinivas Kandagatla { 2570e8ba1e05SSrinivas Kandagatla struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); 2571e8ba1e05SSrinivas Kandagatla struct wcd938x_priv *wcd938x = snd_soc_component_get_drvdata(component); 2572e8ba1e05SSrinivas Kandagatla 2573e8ba1e05SSrinivas Kandagatla ucontrol->value.integer.value[0] = wcd938x->bcs_dis; 2574e8ba1e05SSrinivas Kandagatla 2575e8ba1e05SSrinivas Kandagatla return 0; 2576e8ba1e05SSrinivas Kandagatla } 2577e8ba1e05SSrinivas Kandagatla 2578e8ba1e05SSrinivas Kandagatla static int wcd938x_bcs_put(struct snd_kcontrol *kcontrol, 2579e8ba1e05SSrinivas Kandagatla struct snd_ctl_elem_value *ucontrol) 2580e8ba1e05SSrinivas Kandagatla { 2581e8ba1e05SSrinivas Kandagatla struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); 2582e8ba1e05SSrinivas Kandagatla struct wcd938x_priv *wcd938x = snd_soc_component_get_drvdata(component); 2583e8ba1e05SSrinivas Kandagatla 2584e8ba1e05SSrinivas Kandagatla wcd938x->bcs_dis = ucontrol->value.integer.value[0]; 2585e8ba1e05SSrinivas Kandagatla 2586e8ba1e05SSrinivas Kandagatla return 1; 2587e8ba1e05SSrinivas Kandagatla } 2588e8ba1e05SSrinivas Kandagatla 2589e8ba1e05SSrinivas Kandagatla static const char * const tx_mode_mux_text_wcd9380[] = { 2590e8ba1e05SSrinivas Kandagatla "ADC_INVALID", "ADC_HIFI", "ADC_LO_HIF", "ADC_NORMAL", "ADC_LP", 2591e8ba1e05SSrinivas Kandagatla }; 2592e8ba1e05SSrinivas Kandagatla 2593e8ba1e05SSrinivas Kandagatla static const char * const tx_mode_mux_text[] = { 2594e8ba1e05SSrinivas Kandagatla "ADC_INVALID", "ADC_HIFI", "ADC_LO_HIF", "ADC_NORMAL", "ADC_LP", 2595e8ba1e05SSrinivas Kandagatla "ADC_ULP1", "ADC_ULP2", 2596e8ba1e05SSrinivas Kandagatla }; 2597e8ba1e05SSrinivas Kandagatla 2598e8ba1e05SSrinivas Kandagatla static const char * const rx_hph_mode_mux_text_wcd9380[] = { 2599e8ba1e05SSrinivas Kandagatla "CLS_H_INVALID", "CLS_H_INVALID_1", "CLS_H_LP", "CLS_AB", 2600e8ba1e05SSrinivas Kandagatla "CLS_H_LOHIFI", "CLS_H_ULP", "CLS_H_INVALID_2", "CLS_AB_LP", 2601e8ba1e05SSrinivas Kandagatla "CLS_AB_LOHIFI", 2602e8ba1e05SSrinivas Kandagatla }; 2603e8ba1e05SSrinivas Kandagatla 2604e8ba1e05SSrinivas Kandagatla static const char * const rx_hph_mode_mux_text[] = { 2605e8ba1e05SSrinivas Kandagatla "CLS_H_INVALID", "CLS_H_HIFI", "CLS_H_LP", "CLS_AB", "CLS_H_LOHIFI", 2606e8ba1e05SSrinivas Kandagatla "CLS_H_ULP", "CLS_AB_HIFI", "CLS_AB_LP", "CLS_AB_LOHIFI", 2607e8ba1e05SSrinivas Kandagatla }; 2608e8ba1e05SSrinivas Kandagatla 26098da9db0cSSrinivas Kandagatla static const char * const adc2_mux_text[] = { 26108da9db0cSSrinivas Kandagatla "INP2", "INP3" 26118da9db0cSSrinivas Kandagatla }; 26128da9db0cSSrinivas Kandagatla 26138da9db0cSSrinivas Kandagatla static const char * const adc3_mux_text[] = { 26148da9db0cSSrinivas Kandagatla "INP4", "INP6" 26158da9db0cSSrinivas Kandagatla }; 26168da9db0cSSrinivas Kandagatla 26178da9db0cSSrinivas Kandagatla static const char * const adc4_mux_text[] = { 26188da9db0cSSrinivas Kandagatla "INP5", "INP7" 26198da9db0cSSrinivas Kandagatla }; 26208da9db0cSSrinivas Kandagatla 26218da9db0cSSrinivas Kandagatla static const char * const rdac3_mux_text[] = { 26228da9db0cSSrinivas Kandagatla "RX1", "RX3" 26238da9db0cSSrinivas Kandagatla }; 26248da9db0cSSrinivas Kandagatla 26258da9db0cSSrinivas Kandagatla static const char * const hdr12_mux_text[] = { 26268da9db0cSSrinivas Kandagatla "NO_HDR12", "HDR12" 26278da9db0cSSrinivas Kandagatla }; 26288da9db0cSSrinivas Kandagatla 26298da9db0cSSrinivas Kandagatla static const char * const hdr34_mux_text[] = { 26308da9db0cSSrinivas Kandagatla "NO_HDR34", "HDR34" 26318da9db0cSSrinivas Kandagatla }; 26328da9db0cSSrinivas Kandagatla 2633e8ba1e05SSrinivas Kandagatla static const struct soc_enum tx0_mode_enum_wcd9380 = 2634e8ba1e05SSrinivas Kandagatla SOC_ENUM_SINGLE(SND_SOC_NOPM, 0, ARRAY_SIZE(tx_mode_mux_text_wcd9380), 2635e8ba1e05SSrinivas Kandagatla tx_mode_mux_text_wcd9380); 2636e8ba1e05SSrinivas Kandagatla 2637e8ba1e05SSrinivas Kandagatla static const struct soc_enum tx1_mode_enum_wcd9380 = 2638e8ba1e05SSrinivas Kandagatla SOC_ENUM_SINGLE(SND_SOC_NOPM, 1, ARRAY_SIZE(tx_mode_mux_text_wcd9380), 2639e8ba1e05SSrinivas Kandagatla tx_mode_mux_text_wcd9380); 2640e8ba1e05SSrinivas Kandagatla 2641e8ba1e05SSrinivas Kandagatla static const struct soc_enum tx2_mode_enum_wcd9380 = 2642e8ba1e05SSrinivas Kandagatla SOC_ENUM_SINGLE(SND_SOC_NOPM, 2, ARRAY_SIZE(tx_mode_mux_text_wcd9380), 2643e8ba1e05SSrinivas Kandagatla tx_mode_mux_text_wcd9380); 2644e8ba1e05SSrinivas Kandagatla 2645e8ba1e05SSrinivas Kandagatla static const struct soc_enum tx3_mode_enum_wcd9380 = 2646e8ba1e05SSrinivas Kandagatla SOC_ENUM_SINGLE(SND_SOC_NOPM, 3, ARRAY_SIZE(tx_mode_mux_text_wcd9380), 2647e8ba1e05SSrinivas Kandagatla tx_mode_mux_text_wcd9380); 2648e8ba1e05SSrinivas Kandagatla 2649e8ba1e05SSrinivas Kandagatla static const struct soc_enum tx0_mode_enum_wcd9385 = 2650e8ba1e05SSrinivas Kandagatla SOC_ENUM_SINGLE(SND_SOC_NOPM, 0, ARRAY_SIZE(tx_mode_mux_text), 2651e8ba1e05SSrinivas Kandagatla tx_mode_mux_text); 2652e8ba1e05SSrinivas Kandagatla 2653e8ba1e05SSrinivas Kandagatla static const struct soc_enum tx1_mode_enum_wcd9385 = 2654e8ba1e05SSrinivas Kandagatla SOC_ENUM_SINGLE(SND_SOC_NOPM, 1, ARRAY_SIZE(tx_mode_mux_text), 2655e8ba1e05SSrinivas Kandagatla tx_mode_mux_text); 2656e8ba1e05SSrinivas Kandagatla 2657e8ba1e05SSrinivas Kandagatla static const struct soc_enum tx2_mode_enum_wcd9385 = 2658e8ba1e05SSrinivas Kandagatla SOC_ENUM_SINGLE(SND_SOC_NOPM, 2, ARRAY_SIZE(tx_mode_mux_text), 2659e8ba1e05SSrinivas Kandagatla tx_mode_mux_text); 2660e8ba1e05SSrinivas Kandagatla 2661e8ba1e05SSrinivas Kandagatla static const struct soc_enum tx3_mode_enum_wcd9385 = 2662e8ba1e05SSrinivas Kandagatla SOC_ENUM_SINGLE(SND_SOC_NOPM, 3, ARRAY_SIZE(tx_mode_mux_text), 2663e8ba1e05SSrinivas Kandagatla tx_mode_mux_text); 2664e8ba1e05SSrinivas Kandagatla 2665e8ba1e05SSrinivas Kandagatla static const struct soc_enum rx_hph_mode_mux_enum_wcd9380 = 2666e8ba1e05SSrinivas Kandagatla SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(rx_hph_mode_mux_text_wcd9380), 2667e8ba1e05SSrinivas Kandagatla rx_hph_mode_mux_text_wcd9380); 2668e8ba1e05SSrinivas Kandagatla 2669e8ba1e05SSrinivas Kandagatla static const struct soc_enum rx_hph_mode_mux_enum = 2670e8ba1e05SSrinivas Kandagatla SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(rx_hph_mode_mux_text), 2671e8ba1e05SSrinivas Kandagatla rx_hph_mode_mux_text); 2672e8ba1e05SSrinivas Kandagatla 2673d5add08fSSrinivas Kandagatla static const struct soc_enum adc2_enum = 2674d5add08fSSrinivas Kandagatla SOC_ENUM_SINGLE(WCD938X_TX_NEW_AMIC_MUX_CFG, 7, 2675d5add08fSSrinivas Kandagatla ARRAY_SIZE(adc2_mux_text), adc2_mux_text); 2676d5add08fSSrinivas Kandagatla 2677d5add08fSSrinivas Kandagatla static const struct soc_enum adc3_enum = 2678d5add08fSSrinivas Kandagatla SOC_ENUM_SINGLE(WCD938X_TX_NEW_AMIC_MUX_CFG, 6, 2679d5add08fSSrinivas Kandagatla ARRAY_SIZE(adc3_mux_text), adc3_mux_text); 2680d5add08fSSrinivas Kandagatla 2681d5add08fSSrinivas Kandagatla static const struct soc_enum adc4_enum = 2682d5add08fSSrinivas Kandagatla SOC_ENUM_SINGLE(WCD938X_TX_NEW_AMIC_MUX_CFG, 5, 2683d5add08fSSrinivas Kandagatla ARRAY_SIZE(adc4_mux_text), adc4_mux_text); 2684d5add08fSSrinivas Kandagatla 2685d5add08fSSrinivas Kandagatla static const struct soc_enum hdr12_enum = 2686d5add08fSSrinivas Kandagatla SOC_ENUM_SINGLE(WCD938X_TX_NEW_AMIC_MUX_CFG, 4, 2687d5add08fSSrinivas Kandagatla ARRAY_SIZE(hdr12_mux_text), hdr12_mux_text); 2688d5add08fSSrinivas Kandagatla 2689d5add08fSSrinivas Kandagatla static const struct soc_enum hdr34_enum = 2690d5add08fSSrinivas Kandagatla SOC_ENUM_SINGLE(WCD938X_TX_NEW_AMIC_MUX_CFG, 3, 2691d5add08fSSrinivas Kandagatla ARRAY_SIZE(hdr34_mux_text), hdr34_mux_text); 2692d5add08fSSrinivas Kandagatla 26938da9db0cSSrinivas Kandagatla static const struct soc_enum rdac3_enum = 26948da9db0cSSrinivas Kandagatla SOC_ENUM_SINGLE(WCD938X_DIGITAL_CDC_EAR_PATH_CTL, 0, 26958da9db0cSSrinivas Kandagatla ARRAY_SIZE(rdac3_mux_text), rdac3_mux_text); 26968da9db0cSSrinivas Kandagatla 2697d5add08fSSrinivas Kandagatla static const struct snd_kcontrol_new adc1_switch[] = { 2698d5add08fSSrinivas Kandagatla SOC_DAPM_SINGLE("Switch", SND_SOC_NOPM, 0, 1, 0) 2699d5add08fSSrinivas Kandagatla }; 2700d5add08fSSrinivas Kandagatla 2701d5add08fSSrinivas Kandagatla static const struct snd_kcontrol_new adc2_switch[] = { 2702d5add08fSSrinivas Kandagatla SOC_DAPM_SINGLE("Switch", SND_SOC_NOPM, 0, 1, 0) 2703d5add08fSSrinivas Kandagatla }; 2704d5add08fSSrinivas Kandagatla 2705d5add08fSSrinivas Kandagatla static const struct snd_kcontrol_new adc3_switch[] = { 2706d5add08fSSrinivas Kandagatla SOC_DAPM_SINGLE("Switch", SND_SOC_NOPM, 0, 1, 0) 2707d5add08fSSrinivas Kandagatla }; 2708d5add08fSSrinivas Kandagatla 2709d5add08fSSrinivas Kandagatla static const struct snd_kcontrol_new adc4_switch[] = { 2710d5add08fSSrinivas Kandagatla SOC_DAPM_SINGLE("Switch", SND_SOC_NOPM, 0, 1, 0) 2711d5add08fSSrinivas Kandagatla }; 2712d5add08fSSrinivas Kandagatla 2713d5add08fSSrinivas Kandagatla static const struct snd_kcontrol_new dmic1_switch[] = { 2714d5add08fSSrinivas Kandagatla SOC_DAPM_SINGLE("Switch", SND_SOC_NOPM, 0, 1, 0) 2715d5add08fSSrinivas Kandagatla }; 2716d5add08fSSrinivas Kandagatla 2717d5add08fSSrinivas Kandagatla static const struct snd_kcontrol_new dmic2_switch[] = { 2718d5add08fSSrinivas Kandagatla SOC_DAPM_SINGLE("Switch", SND_SOC_NOPM, 0, 1, 0) 2719d5add08fSSrinivas Kandagatla }; 2720d5add08fSSrinivas Kandagatla 2721d5add08fSSrinivas Kandagatla static const struct snd_kcontrol_new dmic3_switch[] = { 2722d5add08fSSrinivas Kandagatla SOC_DAPM_SINGLE("Switch", SND_SOC_NOPM, 0, 1, 0) 2723d5add08fSSrinivas Kandagatla }; 2724d5add08fSSrinivas Kandagatla 2725d5add08fSSrinivas Kandagatla static const struct snd_kcontrol_new dmic4_switch[] = { 2726d5add08fSSrinivas Kandagatla SOC_DAPM_SINGLE("Switch", SND_SOC_NOPM, 0, 1, 0) 2727d5add08fSSrinivas Kandagatla }; 2728d5add08fSSrinivas Kandagatla 2729d5add08fSSrinivas Kandagatla static const struct snd_kcontrol_new dmic5_switch[] = { 2730d5add08fSSrinivas Kandagatla SOC_DAPM_SINGLE("Switch", SND_SOC_NOPM, 0, 1, 0) 2731d5add08fSSrinivas Kandagatla }; 2732d5add08fSSrinivas Kandagatla 2733d5add08fSSrinivas Kandagatla static const struct snd_kcontrol_new dmic6_switch[] = { 2734d5add08fSSrinivas Kandagatla SOC_DAPM_SINGLE("Switch", SND_SOC_NOPM, 0, 1, 0) 2735d5add08fSSrinivas Kandagatla }; 2736d5add08fSSrinivas Kandagatla 2737d5add08fSSrinivas Kandagatla static const struct snd_kcontrol_new dmic7_switch[] = { 2738d5add08fSSrinivas Kandagatla SOC_DAPM_SINGLE("Switch", SND_SOC_NOPM, 0, 1, 0) 2739d5add08fSSrinivas Kandagatla }; 2740d5add08fSSrinivas Kandagatla 2741d5add08fSSrinivas Kandagatla static const struct snd_kcontrol_new dmic8_switch[] = { 2742d5add08fSSrinivas Kandagatla SOC_DAPM_SINGLE("Switch", SND_SOC_NOPM, 0, 1, 0) 2743d5add08fSSrinivas Kandagatla }; 2744d5add08fSSrinivas Kandagatla 27458da9db0cSSrinivas Kandagatla static const struct snd_kcontrol_new ear_rdac_switch[] = { 27468da9db0cSSrinivas Kandagatla SOC_DAPM_SINGLE("Switch", SND_SOC_NOPM, 0, 1, 0) 27478da9db0cSSrinivas Kandagatla }; 27488da9db0cSSrinivas Kandagatla 27498da9db0cSSrinivas Kandagatla static const struct snd_kcontrol_new aux_rdac_switch[] = { 27508da9db0cSSrinivas Kandagatla SOC_DAPM_SINGLE("Switch", SND_SOC_NOPM, 0, 1, 0) 27518da9db0cSSrinivas Kandagatla }; 27528da9db0cSSrinivas Kandagatla 27538da9db0cSSrinivas Kandagatla static const struct snd_kcontrol_new hphl_rdac_switch[] = { 27548da9db0cSSrinivas Kandagatla SOC_DAPM_SINGLE("Switch", SND_SOC_NOPM, 0, 1, 0) 27558da9db0cSSrinivas Kandagatla }; 27568da9db0cSSrinivas Kandagatla 27578da9db0cSSrinivas Kandagatla static const struct snd_kcontrol_new hphr_rdac_switch[] = { 27588da9db0cSSrinivas Kandagatla SOC_DAPM_SINGLE("Switch", SND_SOC_NOPM, 0, 1, 0) 27598da9db0cSSrinivas Kandagatla }; 27608da9db0cSSrinivas Kandagatla 2761d5add08fSSrinivas Kandagatla static const struct snd_kcontrol_new tx_adc2_mux = 2762d5add08fSSrinivas Kandagatla SOC_DAPM_ENUM("ADC2 MUX Mux", adc2_enum); 2763d5add08fSSrinivas Kandagatla 2764d5add08fSSrinivas Kandagatla static const struct snd_kcontrol_new tx_adc3_mux = 2765d5add08fSSrinivas Kandagatla SOC_DAPM_ENUM("ADC3 MUX Mux", adc3_enum); 2766d5add08fSSrinivas Kandagatla 2767d5add08fSSrinivas Kandagatla static const struct snd_kcontrol_new tx_adc4_mux = 2768d5add08fSSrinivas Kandagatla SOC_DAPM_ENUM("ADC4 MUX Mux", adc4_enum); 2769d5add08fSSrinivas Kandagatla 2770d5add08fSSrinivas Kandagatla static const struct snd_kcontrol_new tx_hdr12_mux = 2771d5add08fSSrinivas Kandagatla SOC_DAPM_ENUM("HDR12 MUX Mux", hdr12_enum); 2772d5add08fSSrinivas Kandagatla 2773d5add08fSSrinivas Kandagatla static const struct snd_kcontrol_new tx_hdr34_mux = 2774d5add08fSSrinivas Kandagatla SOC_DAPM_ENUM("HDR34 MUX Mux", hdr34_enum); 2775d5add08fSSrinivas Kandagatla 27768da9db0cSSrinivas Kandagatla static const struct snd_kcontrol_new rx_rdac3_mux = 27778da9db0cSSrinivas Kandagatla SOC_DAPM_ENUM("RDAC3_MUX Mux", rdac3_enum); 27788da9db0cSSrinivas Kandagatla 2779e8ba1e05SSrinivas Kandagatla static const struct snd_kcontrol_new wcd9380_snd_controls[] = { 2780e8ba1e05SSrinivas Kandagatla SOC_ENUM_EXT("RX HPH Mode", rx_hph_mode_mux_enum_wcd9380, 2781e8ba1e05SSrinivas Kandagatla wcd938x_rx_hph_mode_get, wcd938x_rx_hph_mode_put), 2782e8ba1e05SSrinivas Kandagatla SOC_ENUM_EXT("TX0 MODE", tx0_mode_enum_wcd9380, 2783e8ba1e05SSrinivas Kandagatla wcd938x_tx_mode_get, wcd938x_tx_mode_put), 2784e8ba1e05SSrinivas Kandagatla SOC_ENUM_EXT("TX1 MODE", tx1_mode_enum_wcd9380, 2785e8ba1e05SSrinivas Kandagatla wcd938x_tx_mode_get, wcd938x_tx_mode_put), 2786e8ba1e05SSrinivas Kandagatla SOC_ENUM_EXT("TX2 MODE", tx2_mode_enum_wcd9380, 2787e8ba1e05SSrinivas Kandagatla wcd938x_tx_mode_get, wcd938x_tx_mode_put), 2788e8ba1e05SSrinivas Kandagatla SOC_ENUM_EXT("TX3 MODE", tx3_mode_enum_wcd9380, 2789e8ba1e05SSrinivas Kandagatla wcd938x_tx_mode_get, wcd938x_tx_mode_put), 2790e8ba1e05SSrinivas Kandagatla }; 2791e8ba1e05SSrinivas Kandagatla 2792e8ba1e05SSrinivas Kandagatla static const struct snd_kcontrol_new wcd9385_snd_controls[] = { 2793e8ba1e05SSrinivas Kandagatla SOC_ENUM_EXT("RX HPH Mode", rx_hph_mode_mux_enum, 2794e8ba1e05SSrinivas Kandagatla wcd938x_rx_hph_mode_get, wcd938x_rx_hph_mode_put), 2795e8ba1e05SSrinivas Kandagatla SOC_ENUM_EXT("TX0 MODE", tx0_mode_enum_wcd9385, 2796e8ba1e05SSrinivas Kandagatla wcd938x_tx_mode_get, wcd938x_tx_mode_put), 2797e8ba1e05SSrinivas Kandagatla SOC_ENUM_EXT("TX1 MODE", tx1_mode_enum_wcd9385, 2798e8ba1e05SSrinivas Kandagatla wcd938x_tx_mode_get, wcd938x_tx_mode_put), 2799e8ba1e05SSrinivas Kandagatla SOC_ENUM_EXT("TX2 MODE", tx2_mode_enum_wcd9385, 2800e8ba1e05SSrinivas Kandagatla wcd938x_tx_mode_get, wcd938x_tx_mode_put), 2801e8ba1e05SSrinivas Kandagatla SOC_ENUM_EXT("TX3 MODE", tx3_mode_enum_wcd9385, 2802e8ba1e05SSrinivas Kandagatla wcd938x_tx_mode_get, wcd938x_tx_mode_put), 2803e8ba1e05SSrinivas Kandagatla }; 2804e8ba1e05SSrinivas Kandagatla 2805e8ba1e05SSrinivas Kandagatla static int wcd938x_get_swr_port(struct snd_kcontrol *kcontrol, 2806e8ba1e05SSrinivas Kandagatla struct snd_ctl_elem_value *ucontrol) 2807e8ba1e05SSrinivas Kandagatla { 2808e8ba1e05SSrinivas Kandagatla struct snd_soc_component *comp = snd_soc_kcontrol_component(kcontrol); 2809e8ba1e05SSrinivas Kandagatla struct wcd938x_priv *wcd938x = snd_soc_component_get_drvdata(comp); 2810e8ba1e05SSrinivas Kandagatla struct wcd938x_sdw_priv *wcd; 2811e8ba1e05SSrinivas Kandagatla struct soc_mixer_control *mixer = (struct soc_mixer_control *)kcontrol->private_value; 2812e8ba1e05SSrinivas Kandagatla int dai_id = mixer->shift; 2813e8ba1e05SSrinivas Kandagatla int portidx = mixer->reg; 2814e8ba1e05SSrinivas Kandagatla 2815e8ba1e05SSrinivas Kandagatla wcd = wcd938x->sdw_priv[dai_id]; 2816e8ba1e05SSrinivas Kandagatla 2817e8ba1e05SSrinivas Kandagatla ucontrol->value.integer.value[0] = wcd->port_enable[portidx]; 2818e8ba1e05SSrinivas Kandagatla 2819e8ba1e05SSrinivas Kandagatla return 0; 2820e8ba1e05SSrinivas Kandagatla } 2821e8ba1e05SSrinivas Kandagatla 2822e8ba1e05SSrinivas Kandagatla static int wcd938x_set_swr_port(struct snd_kcontrol *kcontrol, 2823e8ba1e05SSrinivas Kandagatla struct snd_ctl_elem_value *ucontrol) 2824e8ba1e05SSrinivas Kandagatla { 2825e8ba1e05SSrinivas Kandagatla struct snd_soc_component *comp = snd_soc_kcontrol_component(kcontrol); 2826e8ba1e05SSrinivas Kandagatla struct wcd938x_priv *wcd938x = snd_soc_component_get_drvdata(comp); 2827e8ba1e05SSrinivas Kandagatla struct wcd938x_sdw_priv *wcd; 2828e8ba1e05SSrinivas Kandagatla struct soc_mixer_control *mixer = 2829e8ba1e05SSrinivas Kandagatla (struct soc_mixer_control *)kcontrol->private_value; 2830e8ba1e05SSrinivas Kandagatla int portidx = mixer->reg; 2831e8ba1e05SSrinivas Kandagatla int dai_id = mixer->shift; 2832e8ba1e05SSrinivas Kandagatla bool enable; 2833e8ba1e05SSrinivas Kandagatla 2834e8ba1e05SSrinivas Kandagatla wcd = wcd938x->sdw_priv[dai_id]; 2835e8ba1e05SSrinivas Kandagatla 2836e8ba1e05SSrinivas Kandagatla if (ucontrol->value.integer.value[0]) 2837e8ba1e05SSrinivas Kandagatla enable = true; 2838e8ba1e05SSrinivas Kandagatla else 2839e8ba1e05SSrinivas Kandagatla enable = false; 2840e8ba1e05SSrinivas Kandagatla 2841e8ba1e05SSrinivas Kandagatla wcd->port_enable[portidx] = enable; 2842e8ba1e05SSrinivas Kandagatla 2843e8ba1e05SSrinivas Kandagatla wcd938x_connect_port(wcd, portidx, enable); 2844e8ba1e05SSrinivas Kandagatla 2845e8ba1e05SSrinivas Kandagatla return 0; 2846e8ba1e05SSrinivas Kandagatla 2847e8ba1e05SSrinivas Kandagatla } 2848e8ba1e05SSrinivas Kandagatla 2849e8ba1e05SSrinivas Kandagatla static const struct snd_kcontrol_new wcd938x_snd_controls[] = { 2850e8ba1e05SSrinivas Kandagatla SOC_SINGLE_EXT("HPHL_COMP Switch", WCD938X_COMP_L, 0, 1, 0, 2851e8ba1e05SSrinivas Kandagatla wcd938x_get_compander, wcd938x_set_compander), 2852e8ba1e05SSrinivas Kandagatla SOC_SINGLE_EXT("HPHR_COMP Switch", WCD938X_COMP_R, 1, 1, 0, 2853e8ba1e05SSrinivas Kandagatla wcd938x_get_compander, wcd938x_set_compander), 2854e8ba1e05SSrinivas Kandagatla SOC_SINGLE_EXT("HPHL Switch", WCD938X_HPH_L, 0, 1, 0, 2855e8ba1e05SSrinivas Kandagatla wcd938x_get_swr_port, wcd938x_set_swr_port), 2856e8ba1e05SSrinivas Kandagatla SOC_SINGLE_EXT("HPHR Switch", WCD938X_HPH_R, 0, 1, 0, 2857e8ba1e05SSrinivas Kandagatla wcd938x_get_swr_port, wcd938x_set_swr_port), 2858e8ba1e05SSrinivas Kandagatla SOC_SINGLE_EXT("CLSH Switch", WCD938X_CLSH, 0, 1, 0, 2859e8ba1e05SSrinivas Kandagatla wcd938x_get_swr_port, wcd938x_set_swr_port), 2860e8ba1e05SSrinivas Kandagatla SOC_SINGLE_EXT("LO Switch", WCD938X_LO, 0, 1, 0, 2861e8ba1e05SSrinivas Kandagatla wcd938x_get_swr_port, wcd938x_set_swr_port), 2862e8ba1e05SSrinivas Kandagatla SOC_SINGLE_EXT("DSD_L Switch", WCD938X_DSD_L, 0, 1, 0, 2863e8ba1e05SSrinivas Kandagatla wcd938x_get_swr_port, wcd938x_set_swr_port), 2864e8ba1e05SSrinivas Kandagatla SOC_SINGLE_EXT("DSD_R Switch", WCD938X_DSD_R, 0, 1, 0, 2865e8ba1e05SSrinivas Kandagatla wcd938x_get_swr_port, wcd938x_set_swr_port), 2866e8ba1e05SSrinivas Kandagatla SOC_SINGLE_TLV("HPHL Volume", WCD938X_HPH_L_EN, 0, 0x18, 0, line_gain), 2867e8ba1e05SSrinivas Kandagatla SOC_SINGLE_TLV("HPHR Volume", WCD938X_HPH_R_EN, 0, 0x18, 0, line_gain), 2868e8ba1e05SSrinivas Kandagatla WCD938X_EAR_PA_GAIN_TLV("EAR_PA Volume", WCD938X_ANA_EAR_COMPANDER_CTL, 2869e8ba1e05SSrinivas Kandagatla 2, 0x10, 0, ear_pa_gain), 2870e8ba1e05SSrinivas Kandagatla SOC_SINGLE_EXT("ADC1 Switch", WCD938X_ADC1, 1, 1, 0, 2871e8ba1e05SSrinivas Kandagatla wcd938x_get_swr_port, wcd938x_set_swr_port), 2872e8ba1e05SSrinivas Kandagatla SOC_SINGLE_EXT("ADC2 Switch", WCD938X_ADC2, 1, 1, 0, 2873e8ba1e05SSrinivas Kandagatla wcd938x_get_swr_port, wcd938x_set_swr_port), 2874e8ba1e05SSrinivas Kandagatla SOC_SINGLE_EXT("ADC3 Switch", WCD938X_ADC3, 1, 1, 0, 2875e8ba1e05SSrinivas Kandagatla wcd938x_get_swr_port, wcd938x_set_swr_port), 2876e8ba1e05SSrinivas Kandagatla SOC_SINGLE_EXT("ADC4 Switch", WCD938X_ADC4, 1, 1, 0, 2877e8ba1e05SSrinivas Kandagatla wcd938x_get_swr_port, wcd938x_set_swr_port), 2878e8ba1e05SSrinivas Kandagatla SOC_SINGLE_EXT("DMIC0 Switch", WCD938X_DMIC0, 1, 1, 0, 2879e8ba1e05SSrinivas Kandagatla wcd938x_get_swr_port, wcd938x_set_swr_port), 2880e8ba1e05SSrinivas Kandagatla SOC_SINGLE_EXT("DMIC1 Switch", WCD938X_DMIC1, 1, 1, 0, 2881e8ba1e05SSrinivas Kandagatla wcd938x_get_swr_port, wcd938x_set_swr_port), 2882e8ba1e05SSrinivas Kandagatla SOC_SINGLE_EXT("MBHC Switch", WCD938X_MBHC, 1, 1, 0, 2883e8ba1e05SSrinivas Kandagatla wcd938x_get_swr_port, wcd938x_set_swr_port), 2884e8ba1e05SSrinivas Kandagatla SOC_SINGLE_EXT("DMIC2 Switch", WCD938X_DMIC2, 1, 1, 0, 2885e8ba1e05SSrinivas Kandagatla wcd938x_get_swr_port, wcd938x_set_swr_port), 2886e8ba1e05SSrinivas Kandagatla SOC_SINGLE_EXT("DMIC3 Switch", WCD938X_DMIC3, 1, 1, 0, 2887e8ba1e05SSrinivas Kandagatla wcd938x_get_swr_port, wcd938x_set_swr_port), 2888e8ba1e05SSrinivas Kandagatla SOC_SINGLE_EXT("DMIC4 Switch", WCD938X_DMIC4, 1, 1, 0, 2889e8ba1e05SSrinivas Kandagatla wcd938x_get_swr_port, wcd938x_set_swr_port), 2890e8ba1e05SSrinivas Kandagatla SOC_SINGLE_EXT("DMIC5 Switch", WCD938X_DMIC5, 1, 1, 0, 2891e8ba1e05SSrinivas Kandagatla wcd938x_get_swr_port, wcd938x_set_swr_port), 2892e8ba1e05SSrinivas Kandagatla SOC_SINGLE_EXT("DMIC6 Switch", WCD938X_DMIC6, 1, 1, 0, 2893e8ba1e05SSrinivas Kandagatla wcd938x_get_swr_port, wcd938x_set_swr_port), 2894e8ba1e05SSrinivas Kandagatla SOC_SINGLE_EXT("DMIC7 Switch", WCD938X_DMIC7, 1, 1, 0, 2895e8ba1e05SSrinivas Kandagatla wcd938x_get_swr_port, wcd938x_set_swr_port), 2896e8ba1e05SSrinivas Kandagatla SOC_SINGLE_EXT("LDOH Enable Switch", SND_SOC_NOPM, 0, 1, 0, 2897e8ba1e05SSrinivas Kandagatla wcd938x_ldoh_get, wcd938x_ldoh_put), 2898e8ba1e05SSrinivas Kandagatla SOC_SINGLE_EXT("ADC2_BCS Disable Switch", SND_SOC_NOPM, 0, 1, 0, 2899e8ba1e05SSrinivas Kandagatla wcd938x_bcs_get, wcd938x_bcs_put), 2900e8ba1e05SSrinivas Kandagatla 2901e8ba1e05SSrinivas Kandagatla SOC_SINGLE_TLV("ADC1 Volume", WCD938X_ANA_TX_CH1, 0, 20, 0, analog_gain), 2902e8ba1e05SSrinivas Kandagatla SOC_SINGLE_TLV("ADC2 Volume", WCD938X_ANA_TX_CH2, 0, 20, 0, analog_gain), 2903e8ba1e05SSrinivas Kandagatla SOC_SINGLE_TLV("ADC3 Volume", WCD938X_ANA_TX_CH3, 0, 20, 0, analog_gain), 2904e8ba1e05SSrinivas Kandagatla SOC_SINGLE_TLV("ADC4 Volume", WCD938X_ANA_TX_CH4, 0, 20, 0, analog_gain), 2905e8ba1e05SSrinivas Kandagatla }; 2906e8ba1e05SSrinivas Kandagatla 29078da9db0cSSrinivas Kandagatla static const struct snd_soc_dapm_widget wcd938x_dapm_widgets[] = { 2908d5add08fSSrinivas Kandagatla 2909d5add08fSSrinivas Kandagatla /*input widgets*/ 2910d5add08fSSrinivas Kandagatla SND_SOC_DAPM_INPUT("AMIC1"), 2911d5add08fSSrinivas Kandagatla SND_SOC_DAPM_INPUT("AMIC2"), 2912d5add08fSSrinivas Kandagatla SND_SOC_DAPM_INPUT("AMIC3"), 2913d5add08fSSrinivas Kandagatla SND_SOC_DAPM_INPUT("AMIC4"), 2914d5add08fSSrinivas Kandagatla SND_SOC_DAPM_INPUT("AMIC5"), 2915d5add08fSSrinivas Kandagatla SND_SOC_DAPM_INPUT("AMIC6"), 2916d5add08fSSrinivas Kandagatla SND_SOC_DAPM_INPUT("AMIC7"), 2917d5add08fSSrinivas Kandagatla SND_SOC_DAPM_MIC("Analog Mic1", NULL), 2918d5add08fSSrinivas Kandagatla SND_SOC_DAPM_MIC("Analog Mic2", NULL), 2919d5add08fSSrinivas Kandagatla SND_SOC_DAPM_MIC("Analog Mic3", NULL), 2920d5add08fSSrinivas Kandagatla SND_SOC_DAPM_MIC("Analog Mic4", NULL), 2921d5add08fSSrinivas Kandagatla SND_SOC_DAPM_MIC("Analog Mic5", NULL), 2922d5add08fSSrinivas Kandagatla 2923d5add08fSSrinivas Kandagatla /*tx widgets*/ 2924d5add08fSSrinivas Kandagatla SND_SOC_DAPM_ADC_E("ADC1", NULL, SND_SOC_NOPM, 0, 0, 2925d5add08fSSrinivas Kandagatla wcd938x_codec_enable_adc, 2926d5add08fSSrinivas Kandagatla SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD), 2927d5add08fSSrinivas Kandagatla SND_SOC_DAPM_ADC_E("ADC2", NULL, SND_SOC_NOPM, 1, 0, 2928d5add08fSSrinivas Kandagatla wcd938x_codec_enable_adc, 2929d5add08fSSrinivas Kandagatla SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD), 2930d5add08fSSrinivas Kandagatla SND_SOC_DAPM_ADC_E("ADC3", NULL, SND_SOC_NOPM, 2, 0, 2931d5add08fSSrinivas Kandagatla wcd938x_codec_enable_adc, 2932d5add08fSSrinivas Kandagatla SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD), 2933d5add08fSSrinivas Kandagatla SND_SOC_DAPM_ADC_E("ADC4", NULL, SND_SOC_NOPM, 3, 0, 2934d5add08fSSrinivas Kandagatla wcd938x_codec_enable_adc, 2935d5add08fSSrinivas Kandagatla SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD), 2936d5add08fSSrinivas Kandagatla SND_SOC_DAPM_ADC_E("DMIC1", NULL, SND_SOC_NOPM, 0, 0, 2937d5add08fSSrinivas Kandagatla wcd938x_codec_enable_dmic, 2938d5add08fSSrinivas Kandagatla SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD), 2939d5add08fSSrinivas Kandagatla SND_SOC_DAPM_ADC_E("DMIC2", NULL, SND_SOC_NOPM, 1, 0, 2940d5add08fSSrinivas Kandagatla wcd938x_codec_enable_dmic, 2941d5add08fSSrinivas Kandagatla SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD), 2942d5add08fSSrinivas Kandagatla SND_SOC_DAPM_ADC_E("DMIC3", NULL, SND_SOC_NOPM, 2, 0, 2943d5add08fSSrinivas Kandagatla wcd938x_codec_enable_dmic, 2944d5add08fSSrinivas Kandagatla SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD), 2945d5add08fSSrinivas Kandagatla SND_SOC_DAPM_ADC_E("DMIC4", NULL, SND_SOC_NOPM, 3, 0, 2946d5add08fSSrinivas Kandagatla wcd938x_codec_enable_dmic, 2947d5add08fSSrinivas Kandagatla SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD), 2948d5add08fSSrinivas Kandagatla SND_SOC_DAPM_ADC_E("DMIC5", NULL, SND_SOC_NOPM, 4, 0, 2949d5add08fSSrinivas Kandagatla wcd938x_codec_enable_dmic, 2950d5add08fSSrinivas Kandagatla SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD), 2951d5add08fSSrinivas Kandagatla SND_SOC_DAPM_ADC_E("DMIC6", NULL, SND_SOC_NOPM, 5, 0, 2952d5add08fSSrinivas Kandagatla wcd938x_codec_enable_dmic, 2953d5add08fSSrinivas Kandagatla SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD), 2954d5add08fSSrinivas Kandagatla SND_SOC_DAPM_ADC_E("DMIC7", NULL, SND_SOC_NOPM, 6, 0, 2955d5add08fSSrinivas Kandagatla wcd938x_codec_enable_dmic, 2956d5add08fSSrinivas Kandagatla SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD), 2957d5add08fSSrinivas Kandagatla SND_SOC_DAPM_ADC_E("DMIC8", NULL, SND_SOC_NOPM, 7, 0, 2958d5add08fSSrinivas Kandagatla wcd938x_codec_enable_dmic, 2959d5add08fSSrinivas Kandagatla SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD), 2960d5add08fSSrinivas Kandagatla 2961d5add08fSSrinivas Kandagatla SND_SOC_DAPM_MIXER_E("ADC1 REQ", SND_SOC_NOPM, 0, 0, 2962d5add08fSSrinivas Kandagatla NULL, 0, wcd938x_adc_enable_req, 2963d5add08fSSrinivas Kandagatla SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD), 2964d5add08fSSrinivas Kandagatla SND_SOC_DAPM_MIXER_E("ADC2 REQ", SND_SOC_NOPM, 1, 0, 2965d5add08fSSrinivas Kandagatla NULL, 0, wcd938x_adc_enable_req, 2966d5add08fSSrinivas Kandagatla SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD), 2967d5add08fSSrinivas Kandagatla SND_SOC_DAPM_MIXER_E("ADC3 REQ", SND_SOC_NOPM, 2, 0, 2968d5add08fSSrinivas Kandagatla NULL, 0, wcd938x_adc_enable_req, 2969d5add08fSSrinivas Kandagatla SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD), 2970d5add08fSSrinivas Kandagatla SND_SOC_DAPM_MIXER_E("ADC4 REQ", SND_SOC_NOPM, 3, 0, NULL, 0, 2971d5add08fSSrinivas Kandagatla wcd938x_adc_enable_req, 2972d5add08fSSrinivas Kandagatla SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD), 2973d5add08fSSrinivas Kandagatla 2974d5add08fSSrinivas Kandagatla SND_SOC_DAPM_MUX("ADC2 MUX", SND_SOC_NOPM, 0, 0, &tx_adc2_mux), 2975d5add08fSSrinivas Kandagatla SND_SOC_DAPM_MUX("ADC3 MUX", SND_SOC_NOPM, 0, 0, &tx_adc3_mux), 2976d5add08fSSrinivas Kandagatla SND_SOC_DAPM_MUX("ADC4 MUX", SND_SOC_NOPM, 0, 0, &tx_adc4_mux), 2977d5add08fSSrinivas Kandagatla SND_SOC_DAPM_MUX("HDR12 MUX", SND_SOC_NOPM, 0, 0, &tx_hdr12_mux), 2978d5add08fSSrinivas Kandagatla SND_SOC_DAPM_MUX("HDR34 MUX", SND_SOC_NOPM, 0, 0, &tx_hdr34_mux), 2979d5add08fSSrinivas Kandagatla 2980d5add08fSSrinivas Kandagatla /*tx mixers*/ 2981d5add08fSSrinivas Kandagatla SND_SOC_DAPM_MIXER_E("ADC1_MIXER", SND_SOC_NOPM, 0, 0, adc1_switch, 2982d5add08fSSrinivas Kandagatla ARRAY_SIZE(adc1_switch), wcd938x_tx_swr_ctrl, 2983d5add08fSSrinivas Kandagatla SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD), 2984d5add08fSSrinivas Kandagatla SND_SOC_DAPM_MIXER_E("ADC2_MIXER", SND_SOC_NOPM, 0, 0, adc2_switch, 2985d5add08fSSrinivas Kandagatla ARRAY_SIZE(adc2_switch), wcd938x_tx_swr_ctrl, 2986d5add08fSSrinivas Kandagatla SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD), 2987d5add08fSSrinivas Kandagatla SND_SOC_DAPM_MIXER_E("ADC3_MIXER", SND_SOC_NOPM, 0, 0, adc3_switch, 2988d5add08fSSrinivas Kandagatla ARRAY_SIZE(adc3_switch), wcd938x_tx_swr_ctrl, 2989d5add08fSSrinivas Kandagatla SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD), 2990d5add08fSSrinivas Kandagatla SND_SOC_DAPM_MIXER_E("ADC4_MIXER", SND_SOC_NOPM, 0, 0, adc4_switch, 2991d5add08fSSrinivas Kandagatla ARRAY_SIZE(adc4_switch), wcd938x_tx_swr_ctrl, 2992d5add08fSSrinivas Kandagatla SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD), 2993d5add08fSSrinivas Kandagatla SND_SOC_DAPM_MIXER_E("DMIC1_MIXER", SND_SOC_NOPM, 0, 0, dmic1_switch, 2994d5add08fSSrinivas Kandagatla ARRAY_SIZE(dmic1_switch), wcd938x_tx_swr_ctrl, 2995d5add08fSSrinivas Kandagatla SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD), 2996d5add08fSSrinivas Kandagatla SND_SOC_DAPM_MIXER_E("DMIC2_MIXER", SND_SOC_NOPM, 0, 0, dmic2_switch, 2997d5add08fSSrinivas Kandagatla ARRAY_SIZE(dmic2_switch), wcd938x_tx_swr_ctrl, 2998d5add08fSSrinivas Kandagatla SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD), 2999d5add08fSSrinivas Kandagatla SND_SOC_DAPM_MIXER_E("DMIC3_MIXER", SND_SOC_NOPM, 0, 0, dmic3_switch, 3000d5add08fSSrinivas Kandagatla ARRAY_SIZE(dmic3_switch), wcd938x_tx_swr_ctrl, 3001d5add08fSSrinivas Kandagatla SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD), 3002d5add08fSSrinivas Kandagatla SND_SOC_DAPM_MIXER_E("DMIC4_MIXER", SND_SOC_NOPM, 0, 0, dmic4_switch, 3003d5add08fSSrinivas Kandagatla ARRAY_SIZE(dmic4_switch), wcd938x_tx_swr_ctrl, 3004d5add08fSSrinivas Kandagatla SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD), 3005d5add08fSSrinivas Kandagatla SND_SOC_DAPM_MIXER_E("DMIC5_MIXER", SND_SOC_NOPM, 0, 0, dmic5_switch, 3006d5add08fSSrinivas Kandagatla ARRAY_SIZE(dmic5_switch), wcd938x_tx_swr_ctrl, 3007d5add08fSSrinivas Kandagatla SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD), 3008d5add08fSSrinivas Kandagatla SND_SOC_DAPM_MIXER_E("DMIC6_MIXER", SND_SOC_NOPM, 0, 0, dmic6_switch, 3009d5add08fSSrinivas Kandagatla ARRAY_SIZE(dmic6_switch), wcd938x_tx_swr_ctrl, 3010d5add08fSSrinivas Kandagatla SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD), 3011d5add08fSSrinivas Kandagatla SND_SOC_DAPM_MIXER_E("DMIC7_MIXER", SND_SOC_NOPM, 0, 0, dmic7_switch, 3012d5add08fSSrinivas Kandagatla ARRAY_SIZE(dmic7_switch), wcd938x_tx_swr_ctrl, 3013d5add08fSSrinivas Kandagatla SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD), 3014d5add08fSSrinivas Kandagatla SND_SOC_DAPM_MIXER_E("DMIC8_MIXER", SND_SOC_NOPM, 0, 0, dmic8_switch, 3015d5add08fSSrinivas Kandagatla ARRAY_SIZE(dmic8_switch), wcd938x_tx_swr_ctrl, 3016d5add08fSSrinivas Kandagatla SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD), 3017d5add08fSSrinivas Kandagatla /* micbias widgets*/ 3018d5add08fSSrinivas Kandagatla SND_SOC_DAPM_SUPPLY("MIC BIAS1", SND_SOC_NOPM, MIC_BIAS_1, 0, 3019d5add08fSSrinivas Kandagatla wcd938x_codec_enable_micbias, 3020d5add08fSSrinivas Kandagatla SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU | 3021d5add08fSSrinivas Kandagatla SND_SOC_DAPM_POST_PMD), 3022d5add08fSSrinivas Kandagatla SND_SOC_DAPM_SUPPLY("MIC BIAS2", SND_SOC_NOPM, MIC_BIAS_2, 0, 3023d5add08fSSrinivas Kandagatla wcd938x_codec_enable_micbias, 3024d5add08fSSrinivas Kandagatla SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU | 3025d5add08fSSrinivas Kandagatla SND_SOC_DAPM_POST_PMD), 3026d5add08fSSrinivas Kandagatla SND_SOC_DAPM_SUPPLY("MIC BIAS3", SND_SOC_NOPM, MIC_BIAS_3, 0, 3027d5add08fSSrinivas Kandagatla wcd938x_codec_enable_micbias, 3028d5add08fSSrinivas Kandagatla SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU | 3029d5add08fSSrinivas Kandagatla SND_SOC_DAPM_POST_PMD), 3030d5add08fSSrinivas Kandagatla SND_SOC_DAPM_SUPPLY("MIC BIAS4", SND_SOC_NOPM, MIC_BIAS_4, 0, 3031d5add08fSSrinivas Kandagatla wcd938x_codec_enable_micbias, 3032d5add08fSSrinivas Kandagatla SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU | 3033d5add08fSSrinivas Kandagatla SND_SOC_DAPM_POST_PMD), 3034d5add08fSSrinivas Kandagatla 3035d5add08fSSrinivas Kandagatla /* micbias pull up widgets*/ 3036d5add08fSSrinivas Kandagatla SND_SOC_DAPM_SUPPLY("VA MIC BIAS1", SND_SOC_NOPM, MIC_BIAS_1, 0, 3037d5add08fSSrinivas Kandagatla wcd938x_codec_enable_micbias_pullup, 3038d5add08fSSrinivas Kandagatla SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU | 3039d5add08fSSrinivas Kandagatla SND_SOC_DAPM_POST_PMD), 3040d5add08fSSrinivas Kandagatla SND_SOC_DAPM_SUPPLY("VA MIC BIAS2", SND_SOC_NOPM, MIC_BIAS_2, 0, 3041d5add08fSSrinivas Kandagatla wcd938x_codec_enable_micbias_pullup, 3042d5add08fSSrinivas Kandagatla SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU | 3043d5add08fSSrinivas Kandagatla SND_SOC_DAPM_POST_PMD), 3044d5add08fSSrinivas Kandagatla SND_SOC_DAPM_SUPPLY("VA MIC BIAS3", SND_SOC_NOPM, MIC_BIAS_3, 0, 3045d5add08fSSrinivas Kandagatla wcd938x_codec_enable_micbias_pullup, 3046d5add08fSSrinivas Kandagatla SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU | 3047d5add08fSSrinivas Kandagatla SND_SOC_DAPM_POST_PMD), 3048d5add08fSSrinivas Kandagatla SND_SOC_DAPM_SUPPLY("VA MIC BIAS4", SND_SOC_NOPM, MIC_BIAS_4, 0, 3049d5add08fSSrinivas Kandagatla wcd938x_codec_enable_micbias_pullup, 3050d5add08fSSrinivas Kandagatla SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU | 3051d5add08fSSrinivas Kandagatla SND_SOC_DAPM_POST_PMD), 3052d5add08fSSrinivas Kandagatla 3053d5add08fSSrinivas Kandagatla /*output widgets tx*/ 3054d5add08fSSrinivas Kandagatla SND_SOC_DAPM_OUTPUT("ADC1_OUTPUT"), 3055d5add08fSSrinivas Kandagatla SND_SOC_DAPM_OUTPUT("ADC2_OUTPUT"), 3056d5add08fSSrinivas Kandagatla SND_SOC_DAPM_OUTPUT("ADC3_OUTPUT"), 3057d5add08fSSrinivas Kandagatla SND_SOC_DAPM_OUTPUT("ADC4_OUTPUT"), 3058d5add08fSSrinivas Kandagatla SND_SOC_DAPM_OUTPUT("DMIC1_OUTPUT"), 3059d5add08fSSrinivas Kandagatla SND_SOC_DAPM_OUTPUT("DMIC2_OUTPUT"), 3060d5add08fSSrinivas Kandagatla SND_SOC_DAPM_OUTPUT("DMIC3_OUTPUT"), 3061d5add08fSSrinivas Kandagatla SND_SOC_DAPM_OUTPUT("DMIC4_OUTPUT"), 3062d5add08fSSrinivas Kandagatla SND_SOC_DAPM_OUTPUT("DMIC5_OUTPUT"), 3063d5add08fSSrinivas Kandagatla SND_SOC_DAPM_OUTPUT("DMIC6_OUTPUT"), 3064d5add08fSSrinivas Kandagatla SND_SOC_DAPM_OUTPUT("DMIC7_OUTPUT"), 3065d5add08fSSrinivas Kandagatla SND_SOC_DAPM_OUTPUT("DMIC8_OUTPUT"), 3066d5add08fSSrinivas Kandagatla 30678da9db0cSSrinivas Kandagatla SND_SOC_DAPM_INPUT("IN1_HPHL"), 30688da9db0cSSrinivas Kandagatla SND_SOC_DAPM_INPUT("IN2_HPHR"), 30698da9db0cSSrinivas Kandagatla SND_SOC_DAPM_INPUT("IN3_AUX"), 30708da9db0cSSrinivas Kandagatla 30718da9db0cSSrinivas Kandagatla /*rx widgets*/ 30728da9db0cSSrinivas Kandagatla SND_SOC_DAPM_PGA_E("EAR PGA", WCD938X_ANA_EAR, 7, 0, NULL, 0, 30738da9db0cSSrinivas Kandagatla wcd938x_codec_enable_ear_pa, 30748da9db0cSSrinivas Kandagatla SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU | 30758da9db0cSSrinivas Kandagatla SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD), 30768da9db0cSSrinivas Kandagatla SND_SOC_DAPM_PGA_E("AUX PGA", WCD938X_AUX_AUXPA, 7, 0, NULL, 0, 30778da9db0cSSrinivas Kandagatla wcd938x_codec_enable_aux_pa, 30788da9db0cSSrinivas Kandagatla SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU | 30798da9db0cSSrinivas Kandagatla SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD), 30808da9db0cSSrinivas Kandagatla SND_SOC_DAPM_PGA_E("HPHL PGA", WCD938X_ANA_HPH, 7, 0, NULL, 0, 30818da9db0cSSrinivas Kandagatla wcd938x_codec_enable_hphl_pa, 30828da9db0cSSrinivas Kandagatla SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU | 30838da9db0cSSrinivas Kandagatla SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD), 30848da9db0cSSrinivas Kandagatla SND_SOC_DAPM_PGA_E("HPHR PGA", WCD938X_ANA_HPH, 6, 0, NULL, 0, 30858da9db0cSSrinivas Kandagatla wcd938x_codec_enable_hphr_pa, 30868da9db0cSSrinivas Kandagatla SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU | 30878da9db0cSSrinivas Kandagatla SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD), 30888da9db0cSSrinivas Kandagatla 30898da9db0cSSrinivas Kandagatla SND_SOC_DAPM_DAC_E("RDAC1", NULL, SND_SOC_NOPM, 0, 0, 30908da9db0cSSrinivas Kandagatla wcd938x_codec_hphl_dac_event, 30918da9db0cSSrinivas Kandagatla SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU | 30928da9db0cSSrinivas Kandagatla SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD), 30938da9db0cSSrinivas Kandagatla SND_SOC_DAPM_DAC_E("RDAC2", NULL, SND_SOC_NOPM, 0, 0, 30948da9db0cSSrinivas Kandagatla wcd938x_codec_hphr_dac_event, 30958da9db0cSSrinivas Kandagatla SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU | 30968da9db0cSSrinivas Kandagatla SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD), 30978da9db0cSSrinivas Kandagatla SND_SOC_DAPM_DAC_E("RDAC3", NULL, SND_SOC_NOPM, 0, 0, 30988da9db0cSSrinivas Kandagatla wcd938x_codec_ear_dac_event, 30998da9db0cSSrinivas Kandagatla SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU | 31008da9db0cSSrinivas Kandagatla SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD), 31018da9db0cSSrinivas Kandagatla SND_SOC_DAPM_DAC_E("RDAC4", NULL, SND_SOC_NOPM, 0, 0, 31028da9db0cSSrinivas Kandagatla wcd938x_codec_aux_dac_event, 31038da9db0cSSrinivas Kandagatla SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU | 31048da9db0cSSrinivas Kandagatla SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD), 31058da9db0cSSrinivas Kandagatla 31068da9db0cSSrinivas Kandagatla SND_SOC_DAPM_MUX("RDAC3_MUX", SND_SOC_NOPM, 0, 0, &rx_rdac3_mux), 31078da9db0cSSrinivas Kandagatla 31088da9db0cSSrinivas Kandagatla SND_SOC_DAPM_SUPPLY("VDD_BUCK", SND_SOC_NOPM, 0, 0, NULL, 0), 31098da9db0cSSrinivas Kandagatla SND_SOC_DAPM_SUPPLY("RXCLK", SND_SOC_NOPM, 0, 0, 31108da9db0cSSrinivas Kandagatla wcd938x_codec_enable_rxclk, 31118da9db0cSSrinivas Kandagatla SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU | 31128da9db0cSSrinivas Kandagatla SND_SOC_DAPM_POST_PMD), 31138da9db0cSSrinivas Kandagatla 31148da9db0cSSrinivas Kandagatla SND_SOC_DAPM_SUPPLY_S("CLS_H_PORT", 1, SND_SOC_NOPM, 0, 0, NULL, 0), 31158da9db0cSSrinivas Kandagatla 31168da9db0cSSrinivas Kandagatla SND_SOC_DAPM_MIXER_E("RX1", SND_SOC_NOPM, 0, 0, NULL, 0, NULL, 0), 31178da9db0cSSrinivas Kandagatla SND_SOC_DAPM_MIXER_E("RX2", SND_SOC_NOPM, 0, 0, NULL, 0, NULL, 0), 31188da9db0cSSrinivas Kandagatla SND_SOC_DAPM_MIXER_E("RX3", SND_SOC_NOPM, 0, 0, NULL, 0, NULL, 0), 31198da9db0cSSrinivas Kandagatla 31208da9db0cSSrinivas Kandagatla /* rx mixer widgets*/ 31218da9db0cSSrinivas Kandagatla SND_SOC_DAPM_MIXER("EAR_RDAC", SND_SOC_NOPM, 0, 0, 31228da9db0cSSrinivas Kandagatla ear_rdac_switch, ARRAY_SIZE(ear_rdac_switch)), 31238da9db0cSSrinivas Kandagatla SND_SOC_DAPM_MIXER("AUX_RDAC", SND_SOC_NOPM, 0, 0, 31248da9db0cSSrinivas Kandagatla aux_rdac_switch, ARRAY_SIZE(aux_rdac_switch)), 31258da9db0cSSrinivas Kandagatla SND_SOC_DAPM_MIXER("HPHL_RDAC", SND_SOC_NOPM, 0, 0, 31268da9db0cSSrinivas Kandagatla hphl_rdac_switch, ARRAY_SIZE(hphl_rdac_switch)), 31278da9db0cSSrinivas Kandagatla SND_SOC_DAPM_MIXER("HPHR_RDAC", SND_SOC_NOPM, 0, 0, 31288da9db0cSSrinivas Kandagatla hphr_rdac_switch, ARRAY_SIZE(hphr_rdac_switch)), 31298da9db0cSSrinivas Kandagatla 31308da9db0cSSrinivas Kandagatla /*output widgets rx*/ 31318da9db0cSSrinivas Kandagatla SND_SOC_DAPM_OUTPUT("EAR"), 31328da9db0cSSrinivas Kandagatla SND_SOC_DAPM_OUTPUT("AUX"), 31338da9db0cSSrinivas Kandagatla SND_SOC_DAPM_OUTPUT("HPHL"), 31348da9db0cSSrinivas Kandagatla SND_SOC_DAPM_OUTPUT("HPHR"), 313504544222SSrinivas Kandagatla 313604544222SSrinivas Kandagatla }; 313704544222SSrinivas Kandagatla 313804544222SSrinivas Kandagatla static const struct snd_soc_dapm_route wcd938x_audio_map[] = { 313904544222SSrinivas Kandagatla {"ADC1_OUTPUT", NULL, "ADC1_MIXER"}, 314004544222SSrinivas Kandagatla {"ADC1_MIXER", "Switch", "ADC1 REQ"}, 314104544222SSrinivas Kandagatla {"ADC1 REQ", NULL, "ADC1"}, 314204544222SSrinivas Kandagatla {"ADC1", NULL, "AMIC1"}, 314304544222SSrinivas Kandagatla 314404544222SSrinivas Kandagatla {"ADC2_OUTPUT", NULL, "ADC2_MIXER"}, 314504544222SSrinivas Kandagatla {"ADC2_MIXER", "Switch", "ADC2 REQ"}, 314604544222SSrinivas Kandagatla {"ADC2 REQ", NULL, "ADC2"}, 314704544222SSrinivas Kandagatla {"ADC2", NULL, "HDR12 MUX"}, 314804544222SSrinivas Kandagatla {"HDR12 MUX", "NO_HDR12", "ADC2 MUX"}, 314904544222SSrinivas Kandagatla {"HDR12 MUX", "HDR12", "AMIC1"}, 315004544222SSrinivas Kandagatla {"ADC2 MUX", "INP3", "AMIC3"}, 315104544222SSrinivas Kandagatla {"ADC2 MUX", "INP2", "AMIC2"}, 315204544222SSrinivas Kandagatla 315304544222SSrinivas Kandagatla {"ADC3_OUTPUT", NULL, "ADC3_MIXER"}, 315404544222SSrinivas Kandagatla {"ADC3_MIXER", "Switch", "ADC3 REQ"}, 315504544222SSrinivas Kandagatla {"ADC3 REQ", NULL, "ADC3"}, 315604544222SSrinivas Kandagatla {"ADC3", NULL, "HDR34 MUX"}, 315704544222SSrinivas Kandagatla {"HDR34 MUX", "NO_HDR34", "ADC3 MUX"}, 315804544222SSrinivas Kandagatla {"HDR34 MUX", "HDR34", "AMIC5"}, 315904544222SSrinivas Kandagatla {"ADC3 MUX", "INP4", "AMIC4"}, 316004544222SSrinivas Kandagatla {"ADC3 MUX", "INP6", "AMIC6"}, 316104544222SSrinivas Kandagatla 316204544222SSrinivas Kandagatla {"ADC4_OUTPUT", NULL, "ADC4_MIXER"}, 316304544222SSrinivas Kandagatla {"ADC4_MIXER", "Switch", "ADC4 REQ"}, 316404544222SSrinivas Kandagatla {"ADC4 REQ", NULL, "ADC4"}, 316504544222SSrinivas Kandagatla {"ADC4", NULL, "ADC4 MUX"}, 316604544222SSrinivas Kandagatla {"ADC4 MUX", "INP5", "AMIC5"}, 316704544222SSrinivas Kandagatla {"ADC4 MUX", "INP7", "AMIC7"}, 316804544222SSrinivas Kandagatla 316904544222SSrinivas Kandagatla {"DMIC1_OUTPUT", NULL, "DMIC1_MIXER"}, 317004544222SSrinivas Kandagatla {"DMIC1_MIXER", "Switch", "DMIC1"}, 317104544222SSrinivas Kandagatla 317204544222SSrinivas Kandagatla {"DMIC2_OUTPUT", NULL, "DMIC2_MIXER"}, 317304544222SSrinivas Kandagatla {"DMIC2_MIXER", "Switch", "DMIC2"}, 317404544222SSrinivas Kandagatla 317504544222SSrinivas Kandagatla {"DMIC3_OUTPUT", NULL, "DMIC3_MIXER"}, 317604544222SSrinivas Kandagatla {"DMIC3_MIXER", "Switch", "DMIC3"}, 317704544222SSrinivas Kandagatla 317804544222SSrinivas Kandagatla {"DMIC4_OUTPUT", NULL, "DMIC4_MIXER"}, 317904544222SSrinivas Kandagatla {"DMIC4_MIXER", "Switch", "DMIC4"}, 318004544222SSrinivas Kandagatla 318104544222SSrinivas Kandagatla {"DMIC5_OUTPUT", NULL, "DMIC5_MIXER"}, 318204544222SSrinivas Kandagatla {"DMIC5_MIXER", "Switch", "DMIC5"}, 318304544222SSrinivas Kandagatla 318404544222SSrinivas Kandagatla {"DMIC6_OUTPUT", NULL, "DMIC6_MIXER"}, 318504544222SSrinivas Kandagatla {"DMIC6_MIXER", "Switch", "DMIC6"}, 318604544222SSrinivas Kandagatla 318704544222SSrinivas Kandagatla {"DMIC7_OUTPUT", NULL, "DMIC7_MIXER"}, 318804544222SSrinivas Kandagatla {"DMIC7_MIXER", "Switch", "DMIC7"}, 318904544222SSrinivas Kandagatla 319004544222SSrinivas Kandagatla {"DMIC8_OUTPUT", NULL, "DMIC8_MIXER"}, 319104544222SSrinivas Kandagatla {"DMIC8_MIXER", "Switch", "DMIC8"}, 319204544222SSrinivas Kandagatla 319304544222SSrinivas Kandagatla {"IN1_HPHL", NULL, "VDD_BUCK"}, 319404544222SSrinivas Kandagatla {"IN1_HPHL", NULL, "CLS_H_PORT"}, 319504544222SSrinivas Kandagatla 319604544222SSrinivas Kandagatla {"RX1", NULL, "IN1_HPHL"}, 319704544222SSrinivas Kandagatla {"RX1", NULL, "RXCLK"}, 319804544222SSrinivas Kandagatla {"RDAC1", NULL, "RX1"}, 319904544222SSrinivas Kandagatla {"HPHL_RDAC", "Switch", "RDAC1"}, 320004544222SSrinivas Kandagatla {"HPHL PGA", NULL, "HPHL_RDAC"}, 320104544222SSrinivas Kandagatla {"HPHL", NULL, "HPHL PGA"}, 320204544222SSrinivas Kandagatla 320304544222SSrinivas Kandagatla {"IN2_HPHR", NULL, "VDD_BUCK"}, 320404544222SSrinivas Kandagatla {"IN2_HPHR", NULL, "CLS_H_PORT"}, 320504544222SSrinivas Kandagatla {"RX2", NULL, "IN2_HPHR"}, 320604544222SSrinivas Kandagatla {"RDAC2", NULL, "RX2"}, 320704544222SSrinivas Kandagatla {"RX2", NULL, "RXCLK"}, 320804544222SSrinivas Kandagatla {"HPHR_RDAC", "Switch", "RDAC2"}, 320904544222SSrinivas Kandagatla {"HPHR PGA", NULL, "HPHR_RDAC"}, 321004544222SSrinivas Kandagatla {"HPHR", NULL, "HPHR PGA"}, 321104544222SSrinivas Kandagatla 321204544222SSrinivas Kandagatla {"IN3_AUX", NULL, "VDD_BUCK"}, 321304544222SSrinivas Kandagatla {"IN3_AUX", NULL, "CLS_H_PORT"}, 321404544222SSrinivas Kandagatla {"RX3", NULL, "IN3_AUX"}, 321504544222SSrinivas Kandagatla {"RDAC4", NULL, "RX3"}, 321604544222SSrinivas Kandagatla {"RX3", NULL, "RXCLK"}, 321704544222SSrinivas Kandagatla {"AUX_RDAC", "Switch", "RDAC4"}, 321804544222SSrinivas Kandagatla {"AUX PGA", NULL, "AUX_RDAC"}, 321904544222SSrinivas Kandagatla {"AUX", NULL, "AUX PGA"}, 322004544222SSrinivas Kandagatla 322104544222SSrinivas Kandagatla {"RDAC3_MUX", "RX3", "RX3"}, 322204544222SSrinivas Kandagatla {"RDAC3_MUX", "RX1", "RX1"}, 322304544222SSrinivas Kandagatla {"RDAC3", NULL, "RDAC3_MUX"}, 322404544222SSrinivas Kandagatla {"EAR_RDAC", "Switch", "RDAC3"}, 322504544222SSrinivas Kandagatla {"EAR PGA", NULL, "EAR_RDAC"}, 322604544222SSrinivas Kandagatla {"EAR", NULL, "EAR PGA"}, 32278da9db0cSSrinivas Kandagatla }; 32288da9db0cSSrinivas Kandagatla 32298d78602aSSrinivas Kandagatla static int wcd938x_get_micb_vout_ctl_val(u32 micb_mv) 32308d78602aSSrinivas Kandagatla { 32318d78602aSSrinivas Kandagatla /* min micbias voltage is 1V and maximum is 2.85V */ 32328d78602aSSrinivas Kandagatla if (micb_mv < 1000 || micb_mv > 2850) 32338d78602aSSrinivas Kandagatla return -EINVAL; 32348d78602aSSrinivas Kandagatla 32358d78602aSSrinivas Kandagatla return (micb_mv - 1000) / 50; 32368d78602aSSrinivas Kandagatla } 32378d78602aSSrinivas Kandagatla 32388d78602aSSrinivas Kandagatla static int wcd938x_set_micbias_data(struct wcd938x_priv *wcd938x) 32398d78602aSSrinivas Kandagatla { 32408d78602aSSrinivas Kandagatla int vout_ctl_1, vout_ctl_2, vout_ctl_3, vout_ctl_4; 32418d78602aSSrinivas Kandagatla 32428d78602aSSrinivas Kandagatla /* set micbias voltage */ 32438d78602aSSrinivas Kandagatla vout_ctl_1 = wcd938x_get_micb_vout_ctl_val(wcd938x->micb1_mv); 32448d78602aSSrinivas Kandagatla vout_ctl_2 = wcd938x_get_micb_vout_ctl_val(wcd938x->micb2_mv); 32458d78602aSSrinivas Kandagatla vout_ctl_3 = wcd938x_get_micb_vout_ctl_val(wcd938x->micb3_mv); 32468d78602aSSrinivas Kandagatla vout_ctl_4 = wcd938x_get_micb_vout_ctl_val(wcd938x->micb4_mv); 32478d78602aSSrinivas Kandagatla if (vout_ctl_1 < 0 || vout_ctl_2 < 0 || vout_ctl_3 < 0 || vout_ctl_4 < 0) 32488d78602aSSrinivas Kandagatla return -EINVAL; 32498d78602aSSrinivas Kandagatla 32508d78602aSSrinivas Kandagatla regmap_update_bits(wcd938x->regmap, WCD938X_ANA_MICB1, 32518d78602aSSrinivas Kandagatla WCD938X_MICB_VOUT_MASK, vout_ctl_1); 32528d78602aSSrinivas Kandagatla regmap_update_bits(wcd938x->regmap, WCD938X_ANA_MICB2, 32538d78602aSSrinivas Kandagatla WCD938X_MICB_VOUT_MASK, vout_ctl_2); 32548d78602aSSrinivas Kandagatla regmap_update_bits(wcd938x->regmap, WCD938X_ANA_MICB3, 32558d78602aSSrinivas Kandagatla WCD938X_MICB_VOUT_MASK, vout_ctl_3); 32568d78602aSSrinivas Kandagatla regmap_update_bits(wcd938x->regmap, WCD938X_ANA_MICB4, 32578d78602aSSrinivas Kandagatla WCD938X_MICB_VOUT_MASK, vout_ctl_4); 32588d78602aSSrinivas Kandagatla 32598d78602aSSrinivas Kandagatla return 0; 32608d78602aSSrinivas Kandagatla } 32618d78602aSSrinivas Kandagatla 32628d78602aSSrinivas Kandagatla static irqreturn_t wcd938x_wd_handle_irq(int irq, void *data) 32638d78602aSSrinivas Kandagatla { 32648d78602aSSrinivas Kandagatla return IRQ_HANDLED; 32658d78602aSSrinivas Kandagatla } 32668d78602aSSrinivas Kandagatla 32678d78602aSSrinivas Kandagatla static struct irq_chip wcd_irq_chip = { 32688d78602aSSrinivas Kandagatla .name = "WCD938x", 32698d78602aSSrinivas Kandagatla }; 32708d78602aSSrinivas Kandagatla 32718d78602aSSrinivas Kandagatla static int wcd_irq_chip_map(struct irq_domain *irqd, unsigned int virq, 32728d78602aSSrinivas Kandagatla irq_hw_number_t hw) 32738d78602aSSrinivas Kandagatla { 32748d78602aSSrinivas Kandagatla irq_set_chip_and_handler(virq, &wcd_irq_chip, handle_simple_irq); 32758d78602aSSrinivas Kandagatla irq_set_nested_thread(virq, 1); 32768d78602aSSrinivas Kandagatla irq_set_noprobe(virq); 32778d78602aSSrinivas Kandagatla 32788d78602aSSrinivas Kandagatla return 0; 32798d78602aSSrinivas Kandagatla } 32808d78602aSSrinivas Kandagatla 32818d78602aSSrinivas Kandagatla static const struct irq_domain_ops wcd_domain_ops = { 32828d78602aSSrinivas Kandagatla .map = wcd_irq_chip_map, 32838d78602aSSrinivas Kandagatla }; 32848d78602aSSrinivas Kandagatla 32858d78602aSSrinivas Kandagatla static int wcd938x_irq_init(struct wcd938x_priv *wcd, struct device *dev) 32868d78602aSSrinivas Kandagatla { 32878d78602aSSrinivas Kandagatla 32888d78602aSSrinivas Kandagatla wcd->virq = irq_domain_add_linear(NULL, 1, &wcd_domain_ops, NULL); 32898d78602aSSrinivas Kandagatla if (!(wcd->virq)) { 32908d78602aSSrinivas Kandagatla dev_err(dev, "%s: Failed to add IRQ domain\n", __func__); 32918d78602aSSrinivas Kandagatla return -EINVAL; 32928d78602aSSrinivas Kandagatla } 32938d78602aSSrinivas Kandagatla 32948d78602aSSrinivas Kandagatla return devm_regmap_add_irq_chip(dev, wcd->regmap, 32958d78602aSSrinivas Kandagatla irq_create_mapping(wcd->virq, 0), 32968d78602aSSrinivas Kandagatla IRQF_ONESHOT, 0, &wcd938x_regmap_irq_chip, 32978d78602aSSrinivas Kandagatla &wcd->irq_chip); 32988d78602aSSrinivas Kandagatla } 32998d78602aSSrinivas Kandagatla 33008d78602aSSrinivas Kandagatla static int wcd938x_soc_codec_probe(struct snd_soc_component *component) 33018d78602aSSrinivas Kandagatla { 33028d78602aSSrinivas Kandagatla struct wcd938x_priv *wcd938x = snd_soc_component_get_drvdata(component); 33038d78602aSSrinivas Kandagatla struct device *dev = component->dev; 33048d78602aSSrinivas Kandagatla int ret, i; 33058d78602aSSrinivas Kandagatla 33068d78602aSSrinivas Kandagatla snd_soc_component_init_regmap(component, wcd938x->regmap); 33078d78602aSSrinivas Kandagatla 33088d78602aSSrinivas Kandagatla wcd938x->variant = snd_soc_component_read_field(component, 33098d78602aSSrinivas Kandagatla WCD938X_DIGITAL_EFUSE_REG_0, 33108d78602aSSrinivas Kandagatla WCD938X_ID_MASK); 33118d78602aSSrinivas Kandagatla 33128d78602aSSrinivas Kandagatla wcd938x->clsh_info = wcd_clsh_ctrl_alloc(component, WCD938X); 33138d78602aSSrinivas Kandagatla 33148d78602aSSrinivas Kandagatla wcd938x_io_init(wcd938x); 33158d78602aSSrinivas Kandagatla /* Set all interrupts as edge triggered */ 33168d78602aSSrinivas Kandagatla for (i = 0; i < wcd938x_regmap_irq_chip.num_regs; i++) { 33178d78602aSSrinivas Kandagatla regmap_write(wcd938x->regmap, 33188d78602aSSrinivas Kandagatla (WCD938X_DIGITAL_INTR_LEVEL_0 + i), 0); 33198d78602aSSrinivas Kandagatla } 33208d78602aSSrinivas Kandagatla 33218d78602aSSrinivas Kandagatla ret = wcd938x_irq_init(wcd938x, component->dev); 33228d78602aSSrinivas Kandagatla if (ret) { 33238d78602aSSrinivas Kandagatla dev_err(component->dev, "%s: IRQ init failed: %d\n", 33248d78602aSSrinivas Kandagatla __func__, ret); 33258d78602aSSrinivas Kandagatla return ret; 33268d78602aSSrinivas Kandagatla } 33278d78602aSSrinivas Kandagatla 33288d78602aSSrinivas Kandagatla wcd938x->hphr_pdm_wd_int = regmap_irq_get_virq(wcd938x->irq_chip, 33298d78602aSSrinivas Kandagatla WCD938X_IRQ_HPHR_PDM_WD_INT); 33308d78602aSSrinivas Kandagatla wcd938x->hphl_pdm_wd_int = regmap_irq_get_virq(wcd938x->irq_chip, 33318d78602aSSrinivas Kandagatla WCD938X_IRQ_HPHL_PDM_WD_INT); 33328d78602aSSrinivas Kandagatla wcd938x->aux_pdm_wd_int = regmap_irq_get_virq(wcd938x->irq_chip, 33338d78602aSSrinivas Kandagatla WCD938X_IRQ_AUX_PDM_WD_INT); 33348d78602aSSrinivas Kandagatla 33358d78602aSSrinivas Kandagatla /* Request for watchdog interrupt */ 33368d78602aSSrinivas Kandagatla ret = request_threaded_irq(wcd938x->hphr_pdm_wd_int, NULL, wcd938x_wd_handle_irq, 33378d78602aSSrinivas Kandagatla IRQF_ONESHOT | IRQF_TRIGGER_RISING, 33388d78602aSSrinivas Kandagatla "HPHR PDM WD INT", wcd938x); 33398d78602aSSrinivas Kandagatla if (ret) 33408d78602aSSrinivas Kandagatla dev_err(dev, "Failed to request HPHR WD interrupt (%d)\n", ret); 33418d78602aSSrinivas Kandagatla 33428d78602aSSrinivas Kandagatla ret = request_threaded_irq(wcd938x->hphl_pdm_wd_int, NULL, wcd938x_wd_handle_irq, 33438d78602aSSrinivas Kandagatla IRQF_ONESHOT | IRQF_TRIGGER_RISING, 33448d78602aSSrinivas Kandagatla "HPHL PDM WD INT", wcd938x); 33458d78602aSSrinivas Kandagatla if (ret) 33468d78602aSSrinivas Kandagatla dev_err(dev, "Failed to request HPHL WD interrupt (%d)\n", ret); 33478d78602aSSrinivas Kandagatla 33488d78602aSSrinivas Kandagatla ret = request_threaded_irq(wcd938x->aux_pdm_wd_int, NULL, wcd938x_wd_handle_irq, 33498d78602aSSrinivas Kandagatla IRQF_ONESHOT | IRQF_TRIGGER_RISING, 33508d78602aSSrinivas Kandagatla "AUX PDM WD INT", wcd938x); 33518d78602aSSrinivas Kandagatla if (ret) 33528d78602aSSrinivas Kandagatla dev_err(dev, "Failed to request Aux WD interrupt (%d)\n", ret); 33538d78602aSSrinivas Kandagatla 33548d78602aSSrinivas Kandagatla /* Disable watchdog interrupt for HPH and AUX */ 33558d78602aSSrinivas Kandagatla disable_irq_nosync(wcd938x->hphr_pdm_wd_int); 33568d78602aSSrinivas Kandagatla disable_irq_nosync(wcd938x->hphl_pdm_wd_int); 33578d78602aSSrinivas Kandagatla disable_irq_nosync(wcd938x->aux_pdm_wd_int); 33588d78602aSSrinivas Kandagatla 3359e8ba1e05SSrinivas Kandagatla switch (wcd938x->variant) { 3360e8ba1e05SSrinivas Kandagatla case WCD9380: 3361e8ba1e05SSrinivas Kandagatla ret = snd_soc_add_component_controls(component, wcd9380_snd_controls, 3362e8ba1e05SSrinivas Kandagatla ARRAY_SIZE(wcd9380_snd_controls)); 3363e8ba1e05SSrinivas Kandagatla if (ret < 0) { 3364e8ba1e05SSrinivas Kandagatla dev_err(component->dev, 3365e8ba1e05SSrinivas Kandagatla "%s: Failed to add snd ctrls for variant: %d\n", 3366e8ba1e05SSrinivas Kandagatla __func__, wcd938x->variant); 3367e8ba1e05SSrinivas Kandagatla goto err; 3368e8ba1e05SSrinivas Kandagatla } 3369e8ba1e05SSrinivas Kandagatla break; 3370e8ba1e05SSrinivas Kandagatla case WCD9385: 3371e8ba1e05SSrinivas Kandagatla ret = snd_soc_add_component_controls(component, wcd9385_snd_controls, 3372e8ba1e05SSrinivas Kandagatla ARRAY_SIZE(wcd9385_snd_controls)); 3373e8ba1e05SSrinivas Kandagatla if (ret < 0) { 3374e8ba1e05SSrinivas Kandagatla dev_err(component->dev, 3375e8ba1e05SSrinivas Kandagatla "%s: Failed to add snd ctrls for variant: %d\n", 3376e8ba1e05SSrinivas Kandagatla __func__, wcd938x->variant); 3377e8ba1e05SSrinivas Kandagatla goto err; 3378e8ba1e05SSrinivas Kandagatla } 3379e8ba1e05SSrinivas Kandagatla break; 3380e8ba1e05SSrinivas Kandagatla default: 3381e8ba1e05SSrinivas Kandagatla break; 3382e8ba1e05SSrinivas Kandagatla } 3383e8ba1e05SSrinivas Kandagatla err: 33848d78602aSSrinivas Kandagatla return ret; 33858d78602aSSrinivas Kandagatla } 33868d78602aSSrinivas Kandagatla 33878d78602aSSrinivas Kandagatla static const struct snd_soc_component_driver soc_codec_dev_wcd938x = { 33888d78602aSSrinivas Kandagatla .name = "wcd938x_codec", 33898d78602aSSrinivas Kandagatla .probe = wcd938x_soc_codec_probe, 3390e8ba1e05SSrinivas Kandagatla .controls = wcd938x_snd_controls, 3391e8ba1e05SSrinivas Kandagatla .num_controls = ARRAY_SIZE(wcd938x_snd_controls), 33928da9db0cSSrinivas Kandagatla .dapm_widgets = wcd938x_dapm_widgets, 33938da9db0cSSrinivas Kandagatla .num_dapm_widgets = ARRAY_SIZE(wcd938x_dapm_widgets), 339404544222SSrinivas Kandagatla .dapm_routes = wcd938x_audio_map, 339504544222SSrinivas Kandagatla .num_dapm_routes = ARRAY_SIZE(wcd938x_audio_map), 33968d78602aSSrinivas Kandagatla }; 33978d78602aSSrinivas Kandagatla 33988d78602aSSrinivas Kandagatla static void wcd938x_dt_parse_micbias_info(struct device *dev, struct wcd938x_priv *wcd) 33998d78602aSSrinivas Kandagatla { 34008d78602aSSrinivas Kandagatla struct device_node *np = dev->of_node; 34018d78602aSSrinivas Kandagatla u32 prop_val = 0; 34028d78602aSSrinivas Kandagatla int rc = 0; 34038d78602aSSrinivas Kandagatla 34048d78602aSSrinivas Kandagatla rc = of_property_read_u32(np, "qcom,micbias1-microvolt", &prop_val); 34058d78602aSSrinivas Kandagatla if (!rc) 34068d78602aSSrinivas Kandagatla wcd->micb1_mv = prop_val/1000; 34078d78602aSSrinivas Kandagatla else 34088d78602aSSrinivas Kandagatla dev_info(dev, "%s: Micbias1 DT property not found\n", __func__); 34098d78602aSSrinivas Kandagatla 34108d78602aSSrinivas Kandagatla rc = of_property_read_u32(np, "qcom,micbias2-microvolt", &prop_val); 34118d78602aSSrinivas Kandagatla if (!rc) 34128d78602aSSrinivas Kandagatla wcd->micb2_mv = prop_val/1000; 34138d78602aSSrinivas Kandagatla else 34148d78602aSSrinivas Kandagatla dev_info(dev, "%s: Micbias2 DT property not found\n", __func__); 34158d78602aSSrinivas Kandagatla 34168d78602aSSrinivas Kandagatla rc = of_property_read_u32(np, "qcom,micbias3-microvolt", &prop_val); 34178d78602aSSrinivas Kandagatla if (!rc) 34188d78602aSSrinivas Kandagatla wcd->micb3_mv = prop_val/1000; 34198d78602aSSrinivas Kandagatla else 34208d78602aSSrinivas Kandagatla dev_info(dev, "%s: Micbias3 DT property not found\n", __func__); 34218d78602aSSrinivas Kandagatla 34228d78602aSSrinivas Kandagatla rc = of_property_read_u32(np, "qcom,micbias4-microvolt", &prop_val); 34238d78602aSSrinivas Kandagatla if (!rc) 34248d78602aSSrinivas Kandagatla wcd->micb4_mv = prop_val/1000; 34258d78602aSSrinivas Kandagatla else 34268d78602aSSrinivas Kandagatla dev_info(dev, "%s: Micbias4 DT property not found\n", __func__); 34278d78602aSSrinivas Kandagatla } 34288d78602aSSrinivas Kandagatla 34298d78602aSSrinivas Kandagatla static int wcd938x_populate_dt_data(struct wcd938x_priv *wcd938x, struct device *dev) 34308d78602aSSrinivas Kandagatla { 34318d78602aSSrinivas Kandagatla int ret; 34328d78602aSSrinivas Kandagatla 34338d78602aSSrinivas Kandagatla wcd938x->reset_gpio = of_get_named_gpio(dev->of_node, "reset-gpios", 0); 34348d78602aSSrinivas Kandagatla if (wcd938x->reset_gpio < 0) { 34358d78602aSSrinivas Kandagatla dev_err(dev, "Failed to get reset gpio: err = %d\n", 34368d78602aSSrinivas Kandagatla wcd938x->reset_gpio); 34378d78602aSSrinivas Kandagatla return wcd938x->reset_gpio; 34388d78602aSSrinivas Kandagatla } 34398d78602aSSrinivas Kandagatla 34408d78602aSSrinivas Kandagatla wcd938x->supplies[0].supply = "vdd-rxtx"; 34418d78602aSSrinivas Kandagatla wcd938x->supplies[1].supply = "vdd-io"; 34428d78602aSSrinivas Kandagatla wcd938x->supplies[2].supply = "vdd-buck"; 34438d78602aSSrinivas Kandagatla wcd938x->supplies[3].supply = "vdd-mic-bias"; 34448d78602aSSrinivas Kandagatla 34458d78602aSSrinivas Kandagatla ret = regulator_bulk_get(dev, WCD938X_MAX_SUPPLY, wcd938x->supplies); 34468d78602aSSrinivas Kandagatla if (ret) { 34478d78602aSSrinivas Kandagatla dev_err(dev, "Failed to get supplies: err = %d\n", ret); 34488d78602aSSrinivas Kandagatla return ret; 34498d78602aSSrinivas Kandagatla } 34508d78602aSSrinivas Kandagatla 34518d78602aSSrinivas Kandagatla ret = regulator_bulk_enable(WCD938X_MAX_SUPPLY, wcd938x->supplies); 34528d78602aSSrinivas Kandagatla if (ret) { 34538d78602aSSrinivas Kandagatla dev_err(dev, "Failed to enable supplies: err = %d\n", ret); 34548d78602aSSrinivas Kandagatla return ret; 34558d78602aSSrinivas Kandagatla } 34568d78602aSSrinivas Kandagatla 34578d78602aSSrinivas Kandagatla wcd938x_dt_parse_micbias_info(dev, wcd938x); 34588d78602aSSrinivas Kandagatla 34598d78602aSSrinivas Kandagatla return 0; 34608d78602aSSrinivas Kandagatla } 34618d78602aSSrinivas Kandagatla 34628d78602aSSrinivas Kandagatla static int wcd938x_reset(struct wcd938x_priv *wcd938x) 34638d78602aSSrinivas Kandagatla { 34648d78602aSSrinivas Kandagatla gpio_direction_output(wcd938x->reset_gpio, 0); 34658d78602aSSrinivas Kandagatla /* 20us sleep required after pulling the reset gpio to LOW */ 34668d78602aSSrinivas Kandagatla usleep_range(20, 30); 34678d78602aSSrinivas Kandagatla gpio_set_value(wcd938x->reset_gpio, 1); 34688d78602aSSrinivas Kandagatla /* 20us sleep required after pulling the reset gpio to HIGH */ 34698d78602aSSrinivas Kandagatla usleep_range(20, 30); 34708d78602aSSrinivas Kandagatla 34718d78602aSSrinivas Kandagatla return 0; 34728d78602aSSrinivas Kandagatla } 34738d78602aSSrinivas Kandagatla 347416572522SSrinivas Kandagatla static int wcd938x_codec_hw_params(struct snd_pcm_substream *substream, 347516572522SSrinivas Kandagatla struct snd_pcm_hw_params *params, 347616572522SSrinivas Kandagatla struct snd_soc_dai *dai) 347716572522SSrinivas Kandagatla { 347816572522SSrinivas Kandagatla struct wcd938x_priv *wcd938x = dev_get_drvdata(dai->dev); 347916572522SSrinivas Kandagatla struct wcd938x_sdw_priv *wcd = wcd938x->sdw_priv[dai->id]; 348016572522SSrinivas Kandagatla 348116572522SSrinivas Kandagatla return wcd938x_sdw_hw_params(wcd, substream, params, dai); 348216572522SSrinivas Kandagatla } 348316572522SSrinivas Kandagatla 348416572522SSrinivas Kandagatla static int wcd938x_codec_free(struct snd_pcm_substream *substream, 348516572522SSrinivas Kandagatla struct snd_soc_dai *dai) 348616572522SSrinivas Kandagatla { 348716572522SSrinivas Kandagatla struct wcd938x_priv *wcd938x = dev_get_drvdata(dai->dev); 348816572522SSrinivas Kandagatla struct wcd938x_sdw_priv *wcd = wcd938x->sdw_priv[dai->id]; 348916572522SSrinivas Kandagatla 349016572522SSrinivas Kandagatla return wcd938x_sdw_free(wcd, substream, dai); 349116572522SSrinivas Kandagatla } 349216572522SSrinivas Kandagatla 349316572522SSrinivas Kandagatla static int wcd938x_codec_set_sdw_stream(struct snd_soc_dai *dai, 349416572522SSrinivas Kandagatla void *stream, int direction) 349516572522SSrinivas Kandagatla { 349616572522SSrinivas Kandagatla struct wcd938x_priv *wcd938x = dev_get_drvdata(dai->dev); 349716572522SSrinivas Kandagatla struct wcd938x_sdw_priv *wcd = wcd938x->sdw_priv[dai->id]; 349816572522SSrinivas Kandagatla 349916572522SSrinivas Kandagatla return wcd938x_sdw_set_sdw_stream(wcd, dai, stream, direction); 350016572522SSrinivas Kandagatla 350116572522SSrinivas Kandagatla } 350216572522SSrinivas Kandagatla 3503355af6c0SPu Lehui static const struct snd_soc_dai_ops wcd938x_sdw_dai_ops = { 350416572522SSrinivas Kandagatla .hw_params = wcd938x_codec_hw_params, 350516572522SSrinivas Kandagatla .hw_free = wcd938x_codec_free, 350616572522SSrinivas Kandagatla .set_sdw_stream = wcd938x_codec_set_sdw_stream, 35078d78602aSSrinivas Kandagatla }; 35088d78602aSSrinivas Kandagatla 35098d78602aSSrinivas Kandagatla static struct snd_soc_dai_driver wcd938x_dais[] = { 35108d78602aSSrinivas Kandagatla [0] = { 35118d78602aSSrinivas Kandagatla .name = "wcd938x-sdw-rx", 35128d78602aSSrinivas Kandagatla .playback = { 35138d78602aSSrinivas Kandagatla .stream_name = "WCD AIF1 Playback", 35148d78602aSSrinivas Kandagatla .rates = WCD938X_RATES_MASK | WCD938X_FRAC_RATES_MASK, 35158d78602aSSrinivas Kandagatla .formats = WCD938X_FORMATS_S16_S24_LE, 35168d78602aSSrinivas Kandagatla .rate_max = 192000, 35178d78602aSSrinivas Kandagatla .rate_min = 8000, 35188d78602aSSrinivas Kandagatla .channels_min = 1, 35198d78602aSSrinivas Kandagatla .channels_max = 2, 35208d78602aSSrinivas Kandagatla }, 35218d78602aSSrinivas Kandagatla .ops = &wcd938x_sdw_dai_ops, 35228d78602aSSrinivas Kandagatla }, 35238d78602aSSrinivas Kandagatla [1] = { 35248d78602aSSrinivas Kandagatla .name = "wcd938x-sdw-tx", 35258d78602aSSrinivas Kandagatla .capture = { 35268d78602aSSrinivas Kandagatla .stream_name = "WCD AIF1 Capture", 35278d78602aSSrinivas Kandagatla .rates = WCD938X_RATES_MASK, 35288d78602aSSrinivas Kandagatla .formats = SNDRV_PCM_FMTBIT_S16_LE, 35298d78602aSSrinivas Kandagatla .rate_min = 8000, 35308d78602aSSrinivas Kandagatla .rate_max = 192000, 35318d78602aSSrinivas Kandagatla .channels_min = 1, 35328d78602aSSrinivas Kandagatla .channels_max = 4, 35338d78602aSSrinivas Kandagatla }, 35348d78602aSSrinivas Kandagatla .ops = &wcd938x_sdw_dai_ops, 35358d78602aSSrinivas Kandagatla }, 35368d78602aSSrinivas Kandagatla }; 35378d78602aSSrinivas Kandagatla 35388d78602aSSrinivas Kandagatla static int wcd938x_bind(struct device *dev) 35398d78602aSSrinivas Kandagatla { 35408d78602aSSrinivas Kandagatla struct wcd938x_priv *wcd938x = dev_get_drvdata(dev); 35418d78602aSSrinivas Kandagatla int ret; 35428d78602aSSrinivas Kandagatla 35438d78602aSSrinivas Kandagatla ret = component_bind_all(dev, wcd938x); 35448d78602aSSrinivas Kandagatla if (ret) { 35458d78602aSSrinivas Kandagatla dev_err(dev, "%s: Slave bind failed, ret = %d\n", 35468d78602aSSrinivas Kandagatla __func__, ret); 35478d78602aSSrinivas Kandagatla return ret; 35488d78602aSSrinivas Kandagatla } 35498d78602aSSrinivas Kandagatla 355016572522SSrinivas Kandagatla wcd938x->rxdev = wcd938x_sdw_device_get(wcd938x->rxnode); 355116572522SSrinivas Kandagatla if (!wcd938x->rxdev) { 355216572522SSrinivas Kandagatla dev_err(dev, "could not find slave with matching of node\n"); 355316572522SSrinivas Kandagatla return -EINVAL; 355416572522SSrinivas Kandagatla } 355516572522SSrinivas Kandagatla wcd938x->sdw_priv[AIF1_PB] = dev_get_drvdata(wcd938x->rxdev); 355616572522SSrinivas Kandagatla wcd938x->sdw_priv[AIF1_PB]->wcd938x = wcd938x; 3557*b90d9398SSrinivas Kandagatla wcd938x->sdw_priv[AIF1_PB]->slave_irq = wcd938x->virq; 355816572522SSrinivas Kandagatla 355916572522SSrinivas Kandagatla wcd938x->txdev = wcd938x_sdw_device_get(wcd938x->txnode); 356016572522SSrinivas Kandagatla if (!wcd938x->txdev) { 356116572522SSrinivas Kandagatla dev_err(dev, "could not find txslave with matching of node\n"); 356216572522SSrinivas Kandagatla return -EINVAL; 356316572522SSrinivas Kandagatla } 356416572522SSrinivas Kandagatla wcd938x->sdw_priv[AIF1_CAP] = dev_get_drvdata(wcd938x->txdev); 356516572522SSrinivas Kandagatla wcd938x->sdw_priv[AIF1_CAP]->wcd938x = wcd938x; 3566*b90d9398SSrinivas Kandagatla wcd938x->sdw_priv[AIF1_CAP]->slave_irq = wcd938x->virq; 356716572522SSrinivas Kandagatla wcd938x->tx_sdw_dev = dev_to_sdw_dev(wcd938x->txdev); 356816572522SSrinivas Kandagatla if (!wcd938x->tx_sdw_dev) { 356916572522SSrinivas Kandagatla dev_err(dev, "could not get txslave with matching of dev\n"); 357016572522SSrinivas Kandagatla return -EINVAL; 357116572522SSrinivas Kandagatla } 357216572522SSrinivas Kandagatla 357316572522SSrinivas Kandagatla /* As TX is main CSR reg interface, which should not be suspended first. 357416572522SSrinivas Kandagatla * expicilty add the dependency link */ 357516572522SSrinivas Kandagatla if (!device_link_add(wcd938x->rxdev, wcd938x->txdev, DL_FLAG_STATELESS | 357616572522SSrinivas Kandagatla DL_FLAG_PM_RUNTIME)) { 357716572522SSrinivas Kandagatla dev_err(dev, "could not devlink tx and rx\n"); 357816572522SSrinivas Kandagatla return -EINVAL; 357916572522SSrinivas Kandagatla } 358016572522SSrinivas Kandagatla 358116572522SSrinivas Kandagatla if (!device_link_add(dev, wcd938x->txdev, DL_FLAG_STATELESS | 358216572522SSrinivas Kandagatla DL_FLAG_PM_RUNTIME)) { 358316572522SSrinivas Kandagatla dev_err(dev, "could not devlink wcd and tx\n"); 358416572522SSrinivas Kandagatla return -EINVAL; 358516572522SSrinivas Kandagatla } 358616572522SSrinivas Kandagatla 358716572522SSrinivas Kandagatla if (!device_link_add(dev, wcd938x->rxdev, DL_FLAG_STATELESS | 358816572522SSrinivas Kandagatla DL_FLAG_PM_RUNTIME)) { 358916572522SSrinivas Kandagatla dev_err(dev, "could not devlink wcd and rx\n"); 359016572522SSrinivas Kandagatla return -EINVAL; 359116572522SSrinivas Kandagatla } 359216572522SSrinivas Kandagatla 3593*b90d9398SSrinivas Kandagatla wcd938x->regmap = devm_regmap_init_sdw(wcd938x->tx_sdw_dev, &wcd938x_regmap_config); 3594*b90d9398SSrinivas Kandagatla if (IS_ERR(wcd938x->regmap)) { 359516572522SSrinivas Kandagatla dev_err(dev, "%s: tx csr regmap not found\n", __func__); 359616572522SSrinivas Kandagatla return PTR_ERR(wcd938x->regmap); 359716572522SSrinivas Kandagatla } 359816572522SSrinivas Kandagatla 35998d78602aSSrinivas Kandagatla ret = wcd938x_set_micbias_data(wcd938x); 36008d78602aSSrinivas Kandagatla if (ret < 0) { 36018d78602aSSrinivas Kandagatla dev_err(dev, "%s: bad micbias pdata\n", __func__); 36028d78602aSSrinivas Kandagatla return ret; 36038d78602aSSrinivas Kandagatla } 36048d78602aSSrinivas Kandagatla 36058d78602aSSrinivas Kandagatla ret = snd_soc_register_component(dev, &soc_codec_dev_wcd938x, 36068d78602aSSrinivas Kandagatla wcd938x_dais, ARRAY_SIZE(wcd938x_dais)); 36078d78602aSSrinivas Kandagatla if (ret) 36088d78602aSSrinivas Kandagatla dev_err(dev, "%s: Codec registration failed\n", 36098d78602aSSrinivas Kandagatla __func__); 36108d78602aSSrinivas Kandagatla 36118d78602aSSrinivas Kandagatla return ret; 36128d78602aSSrinivas Kandagatla 36138d78602aSSrinivas Kandagatla } 36148d78602aSSrinivas Kandagatla 36158d78602aSSrinivas Kandagatla static void wcd938x_unbind(struct device *dev) 36168d78602aSSrinivas Kandagatla { 36178d78602aSSrinivas Kandagatla struct wcd938x_priv *wcd938x = dev_get_drvdata(dev); 36188d78602aSSrinivas Kandagatla 361916572522SSrinivas Kandagatla device_link_remove(dev, wcd938x->txdev); 362016572522SSrinivas Kandagatla device_link_remove(dev, wcd938x->rxdev); 362116572522SSrinivas Kandagatla device_link_remove(wcd938x->rxdev, wcd938x->txdev); 36228d78602aSSrinivas Kandagatla snd_soc_unregister_component(dev); 36238d78602aSSrinivas Kandagatla component_unbind_all(dev, wcd938x); 36248d78602aSSrinivas Kandagatla } 36258d78602aSSrinivas Kandagatla 36268d78602aSSrinivas Kandagatla static const struct component_master_ops wcd938x_comp_ops = { 36278d78602aSSrinivas Kandagatla .bind = wcd938x_bind, 36288d78602aSSrinivas Kandagatla .unbind = wcd938x_unbind, 36298d78602aSSrinivas Kandagatla }; 36308d78602aSSrinivas Kandagatla 36318d78602aSSrinivas Kandagatla static int wcd938x_compare_of(struct device *dev, void *data) 36328d78602aSSrinivas Kandagatla { 36338d78602aSSrinivas Kandagatla return dev->of_node == data; 36348d78602aSSrinivas Kandagatla } 36358d78602aSSrinivas Kandagatla 36368d78602aSSrinivas Kandagatla static void wcd938x_release_of(struct device *dev, void *data) 36378d78602aSSrinivas Kandagatla { 36388d78602aSSrinivas Kandagatla of_node_put(data); 36398d78602aSSrinivas Kandagatla } 36408d78602aSSrinivas Kandagatla 36418d78602aSSrinivas Kandagatla static int wcd938x_add_slave_components(struct wcd938x_priv *wcd938x, 36428d78602aSSrinivas Kandagatla struct device *dev, 36438d78602aSSrinivas Kandagatla struct component_match **matchptr) 36448d78602aSSrinivas Kandagatla { 36458d78602aSSrinivas Kandagatla struct device_node *np; 36468d78602aSSrinivas Kandagatla 36478d78602aSSrinivas Kandagatla np = dev->of_node; 36488d78602aSSrinivas Kandagatla 36498d78602aSSrinivas Kandagatla wcd938x->rxnode = of_parse_phandle(np, "qcom,rx-device", 0); 36508d78602aSSrinivas Kandagatla if (!wcd938x->rxnode) { 36518d78602aSSrinivas Kandagatla dev_err(dev, "%s: Rx-device node not defined\n", __func__); 36528d78602aSSrinivas Kandagatla return -ENODEV; 36538d78602aSSrinivas Kandagatla } 36548d78602aSSrinivas Kandagatla 36558d78602aSSrinivas Kandagatla of_node_get(wcd938x->rxnode); 36568d78602aSSrinivas Kandagatla component_match_add_release(dev, matchptr, wcd938x_release_of, 36578d78602aSSrinivas Kandagatla wcd938x_compare_of, wcd938x->rxnode); 36588d78602aSSrinivas Kandagatla 36598d78602aSSrinivas Kandagatla wcd938x->txnode = of_parse_phandle(np, "qcom,tx-device", 0); 36608d78602aSSrinivas Kandagatla if (!wcd938x->txnode) { 36618d78602aSSrinivas Kandagatla dev_err(dev, "%s: Tx-device node not defined\n", __func__); 36628d78602aSSrinivas Kandagatla return -ENODEV; 36638d78602aSSrinivas Kandagatla } 36648d78602aSSrinivas Kandagatla of_node_get(wcd938x->txnode); 36658d78602aSSrinivas Kandagatla component_match_add_release(dev, matchptr, wcd938x_release_of, 36668d78602aSSrinivas Kandagatla wcd938x_compare_of, wcd938x->txnode); 36678d78602aSSrinivas Kandagatla return 0; 36688d78602aSSrinivas Kandagatla } 36698d78602aSSrinivas Kandagatla 36708d78602aSSrinivas Kandagatla static int wcd938x_probe(struct platform_device *pdev) 36718d78602aSSrinivas Kandagatla { 36728d78602aSSrinivas Kandagatla struct component_match *match = NULL; 36738d78602aSSrinivas Kandagatla struct wcd938x_priv *wcd938x = NULL; 36748d78602aSSrinivas Kandagatla struct device *dev = &pdev->dev; 36758d78602aSSrinivas Kandagatla int ret; 36768d78602aSSrinivas Kandagatla 36778d78602aSSrinivas Kandagatla wcd938x = devm_kzalloc(dev, sizeof(struct wcd938x_priv), 36788d78602aSSrinivas Kandagatla GFP_KERNEL); 36798d78602aSSrinivas Kandagatla if (!wcd938x) 36808d78602aSSrinivas Kandagatla return -ENOMEM; 36818d78602aSSrinivas Kandagatla 36828d78602aSSrinivas Kandagatla dev_set_drvdata(dev, wcd938x); 36838d78602aSSrinivas Kandagatla 36848d78602aSSrinivas Kandagatla ret = wcd938x_populate_dt_data(wcd938x, dev); 36858d78602aSSrinivas Kandagatla if (ret) { 36868d78602aSSrinivas Kandagatla dev_err(dev, "%s: Fail to obtain platform data\n", __func__); 36878d78602aSSrinivas Kandagatla return -EINVAL; 36888d78602aSSrinivas Kandagatla } 36898d78602aSSrinivas Kandagatla 36908d78602aSSrinivas Kandagatla ret = wcd938x_add_slave_components(wcd938x, dev, &match); 36918d78602aSSrinivas Kandagatla if (ret) 36928d78602aSSrinivas Kandagatla return ret; 36938d78602aSSrinivas Kandagatla 36948d78602aSSrinivas Kandagatla wcd938x_reset(wcd938x); 36958d78602aSSrinivas Kandagatla 36968d78602aSSrinivas Kandagatla ret = component_master_add_with_match(dev, &wcd938x_comp_ops, match); 36978d78602aSSrinivas Kandagatla if (ret) 36988d78602aSSrinivas Kandagatla return ret; 36998d78602aSSrinivas Kandagatla 37008d78602aSSrinivas Kandagatla pm_runtime_set_autosuspend_delay(dev, 1000); 37018d78602aSSrinivas Kandagatla pm_runtime_use_autosuspend(dev); 37028d78602aSSrinivas Kandagatla pm_runtime_mark_last_busy(dev); 37038d78602aSSrinivas Kandagatla pm_runtime_set_active(dev); 37048d78602aSSrinivas Kandagatla pm_runtime_enable(dev); 37058d78602aSSrinivas Kandagatla pm_runtime_idle(dev); 37068d78602aSSrinivas Kandagatla 37078d78602aSSrinivas Kandagatla return ret; 37088d78602aSSrinivas Kandagatla } 37098d78602aSSrinivas Kandagatla 37108d78602aSSrinivas Kandagatla static int wcd938x_remove(struct platform_device *pdev) 37118d78602aSSrinivas Kandagatla { 37128d78602aSSrinivas Kandagatla component_master_del(&pdev->dev, &wcd938x_comp_ops); 37138d78602aSSrinivas Kandagatla 37148d78602aSSrinivas Kandagatla return 0; 37158d78602aSSrinivas Kandagatla } 37168d78602aSSrinivas Kandagatla 37178d78602aSSrinivas Kandagatla static const struct of_device_id wcd938x_dt_match[] = { 37188d78602aSSrinivas Kandagatla { .compatible = "qcom,wcd9380-codec" }, 37198d78602aSSrinivas Kandagatla { .compatible = "qcom,wcd9385-codec" }, 37208d78602aSSrinivas Kandagatla {} 37218d78602aSSrinivas Kandagatla }; 37228d78602aSSrinivas Kandagatla MODULE_DEVICE_TABLE(of, wcd938x_dt_match); 37238d78602aSSrinivas Kandagatla 37248d78602aSSrinivas Kandagatla static struct platform_driver wcd938x_codec_driver = { 37258d78602aSSrinivas Kandagatla .probe = wcd938x_probe, 37268d78602aSSrinivas Kandagatla .remove = wcd938x_remove, 37278d78602aSSrinivas Kandagatla .driver = { 37288d78602aSSrinivas Kandagatla .name = "wcd938x_codec", 37298d78602aSSrinivas Kandagatla .of_match_table = of_match_ptr(wcd938x_dt_match), 37308d78602aSSrinivas Kandagatla .suppress_bind_attrs = true, 37318d78602aSSrinivas Kandagatla }, 37328d78602aSSrinivas Kandagatla }; 37338d78602aSSrinivas Kandagatla 37348d78602aSSrinivas Kandagatla module_platform_driver(wcd938x_codec_driver); 37358d78602aSSrinivas Kandagatla MODULE_DESCRIPTION("WCD938X Codec driver"); 37368d78602aSSrinivas Kandagatla MODULE_LICENSE("GPL"); 3737