1 // SPDX-License-Identifier: GPL-2.0-only 2 // Copyright (c) 2018-2020, The Linux Foundation. All rights reserved. 3 4 #include <linux/cleanup.h> 5 #include <linux/module.h> 6 #include <linux/init.h> 7 #include <linux/io.h> 8 #include <linux/platform_device.h> 9 #include <linux/pm_runtime.h> 10 #include <linux/clk.h> 11 #include <sound/soc.h> 12 #include <sound/pcm.h> 13 #include <sound/pcm_params.h> 14 #include <sound/soc-dapm.h> 15 #include <sound/tlv.h> 16 #include <linux/of_clk.h> 17 #include <linux/clk-provider.h> 18 19 #include "lpass-macro-common.h" 20 21 #define CDC_RX_TOP_TOP_CFG0 (0x0000) 22 #define CDC_RX_TOP_SWR_CTRL (0x0008) 23 #define CDC_RX_TOP_DEBUG (0x000C) 24 #define CDC_RX_TOP_DEBUG_BUS (0x0010) 25 #define CDC_RX_TOP_DEBUG_EN0 (0x0014) 26 #define CDC_RX_TOP_DEBUG_EN1 (0x0018) 27 #define CDC_RX_TOP_DEBUG_EN2 (0x001C) 28 #define CDC_RX_TOP_HPHL_COMP_WR_LSB (0x0020) 29 #define CDC_RX_TOP_HPHL_COMP_WR_MSB (0x0024) 30 #define CDC_RX_TOP_HPHL_COMP_LUT (0x0028) 31 #define CDC_RX_TOP_HPH_LUT_BYPASS_MASK BIT(7) 32 #define CDC_RX_TOP_HPHL_COMP_RD_LSB (0x002C) 33 #define CDC_RX_TOP_HPHL_COMP_RD_MSB (0x0030) 34 #define CDC_RX_TOP_HPHR_COMP_WR_LSB (0x0034) 35 #define CDC_RX_TOP_HPHR_COMP_WR_MSB (0x0038) 36 #define CDC_RX_TOP_HPHR_COMP_LUT (0x003C) 37 #define CDC_RX_TOP_HPHR_COMP_RD_LSB (0x0040) 38 #define CDC_RX_TOP_HPHR_COMP_RD_MSB (0x0044) 39 #define CDC_RX_TOP_DSD0_DEBUG_CFG0 (0x0070) 40 #define CDC_RX_TOP_DSD0_DEBUG_CFG1 (0x0074) 41 #define CDC_RX_TOP_DSD0_DEBUG_CFG2 (0x0078) 42 #define CDC_RX_TOP_DSD0_DEBUG_CFG3 (0x007C) 43 #define CDC_RX_TOP_DSD1_DEBUG_CFG0 (0x0080) 44 #define CDC_RX_TOP_DSD1_DEBUG_CFG1 (0x0084) 45 #define CDC_RX_TOP_DSD1_DEBUG_CFG2 (0x0088) 46 #define CDC_RX_TOP_DSD1_DEBUG_CFG3 (0x008C) 47 #define CDC_RX_TOP_RX_I2S_CTL (0x0090) 48 #define CDC_RX_TOP_TX_I2S2_CTL (0x0094) 49 #define CDC_RX_TOP_I2S_CLK (0x0098) 50 #define CDC_RX_TOP_I2S_RESET (0x009C) 51 #define CDC_RX_TOP_I2S_MUX (0x00A0) 52 #define CDC_RX_CLK_RST_CTRL_MCLK_CONTROL (0x0100) 53 #define CDC_RX_CLK_MCLK_EN_MASK BIT(0) 54 #define CDC_RX_CLK_MCLK_ENABLE BIT(0) 55 #define CDC_RX_CLK_MCLK2_EN_MASK BIT(1) 56 #define CDC_RX_CLK_MCLK2_ENABLE BIT(1) 57 #define CDC_RX_CLK_RST_CTRL_FS_CNT_CONTROL (0x0104) 58 #define CDC_RX_FS_MCLK_CNT_EN_MASK BIT(0) 59 #define CDC_RX_FS_MCLK_CNT_ENABLE BIT(0) 60 #define CDC_RX_FS_MCLK_CNT_CLR_MASK BIT(1) 61 #define CDC_RX_FS_MCLK_CNT_CLR BIT(1) 62 #define CDC_RX_CLK_RST_CTRL_SWR_CONTROL (0x0108) 63 #define CDC_RX_SWR_CLK_EN_MASK BIT(0) 64 #define CDC_RX_SWR_RESET_MASK BIT(1) 65 #define CDC_RX_SWR_RESET BIT(1) 66 #define CDC_RX_CLK_RST_CTRL_DSD_CONTROL (0x010C) 67 #define CDC_RX_CLK_RST_CTRL_ASRC_SHARE_CONTROL (0x0110) 68 #define CDC_RX_SOFTCLIP_CRC (0x0140) 69 #define CDC_RX_SOFTCLIP_CLK_EN_MASK BIT(0) 70 #define CDC_RX_SOFTCLIP_SOFTCLIP_CTRL (0x0144) 71 #define CDC_RX_SOFTCLIP_EN_MASK BIT(0) 72 #define CDC_RX_INP_MUX_RX_INT0_CFG0 (0x0180) 73 #define CDC_RX_INTX_1_MIX_INP0_SEL_MASK GENMASK(3, 0) 74 #define CDC_RX_INTX_1_MIX_INP1_SEL_MASK GENMASK(7, 4) 75 #define CDC_RX_INP_MUX_RX_INT0_CFG1 (0x0184) 76 #define CDC_RX_INTX_2_SEL_MASK GENMASK(3, 0) 77 #define CDC_RX_INTX_1_MIX_INP2_SEL_MASK GENMASK(7, 4) 78 #define CDC_RX_INP_MUX_RX_INT1_CFG0 (0x0188) 79 #define CDC_RX_INP_MUX_RX_INT1_CFG1 (0x018C) 80 #define CDC_RX_INP_MUX_RX_INT2_CFG0 (0x0190) 81 #define CDC_RX_INP_MUX_RX_INT2_CFG1 (0x0194) 82 #define CDC_RX_INP_MUX_RX_MIX_CFG4 (0x0198) 83 #define CDC_RX_INP_MUX_RX_MIX_CFG5 (0x019C) 84 #define CDC_RX_INP_MUX_SIDETONE_SRC_CFG0 (0x01A0) 85 #define CDC_RX_CLSH_CRC (0x0200) 86 #define CDC_RX_CLSH_CLK_EN_MASK BIT(0) 87 #define CDC_RX_CLSH_DLY_CTRL (0x0204) 88 #define CDC_RX_CLSH_DECAY_CTRL (0x0208) 89 #define CDC_RX_CLSH_DECAY_RATE_MASK GENMASK(2, 0) 90 #define CDC_RX_CLSH_HPH_V_PA (0x020C) 91 #define CDC_RX_CLSH_HPH_V_PA_MIN_MASK GENMASK(5, 0) 92 #define CDC_RX_CLSH_EAR_V_PA (0x0210) 93 #define CDC_RX_CLSH_HPH_V_HD (0x0214) 94 #define CDC_RX_CLSH_EAR_V_HD (0x0218) 95 #define CDC_RX_CLSH_K1_MSB (0x021C) 96 #define CDC_RX_CLSH_K1_MSB_COEFF_MASK GENMASK(3, 0) 97 #define CDC_RX_CLSH_K1_LSB (0x0220) 98 #define CDC_RX_CLSH_K2_MSB (0x0224) 99 #define CDC_RX_CLSH_K2_LSB (0x0228) 100 #define CDC_RX_CLSH_IDLE_CTRL (0x022C) 101 #define CDC_RX_CLSH_IDLE_HPH (0x0230) 102 #define CDC_RX_CLSH_IDLE_EAR (0x0234) 103 #define CDC_RX_CLSH_TEST0 (0x0238) 104 #define CDC_RX_CLSH_TEST1 (0x023C) 105 #define CDC_RX_CLSH_OVR_VREF (0x0240) 106 #define CDC_RX_CLSH_CLSG_CTL (0x0244) 107 #define CDC_RX_CLSH_CLSG_CFG1 (0x0248) 108 #define CDC_RX_CLSH_CLSG_CFG2 (0x024C) 109 #define CDC_RX_BCL_VBAT_PATH_CTL (0x0280) 110 #define CDC_RX_BCL_VBAT_CFG (0x0284) 111 #define CDC_RX_BCL_VBAT_ADC_CAL1 (0x0288) 112 #define CDC_RX_BCL_VBAT_ADC_CAL2 (0x028C) 113 #define CDC_RX_BCL_VBAT_ADC_CAL3 (0x0290) 114 #define CDC_RX_BCL_VBAT_PK_EST1 (0x0294) 115 #define CDC_RX_BCL_VBAT_PK_EST2 (0x0298) 116 #define CDC_RX_BCL_VBAT_PK_EST3 (0x029C) 117 #define CDC_RX_BCL_VBAT_RF_PROC1 (0x02A0) 118 #define CDC_RX_BCL_VBAT_RF_PROC2 (0x02A4) 119 #define CDC_RX_BCL_VBAT_TAC1 (0x02A8) 120 #define CDC_RX_BCL_VBAT_TAC2 (0x02AC) 121 #define CDC_RX_BCL_VBAT_TAC3 (0x02B0) 122 #define CDC_RX_BCL_VBAT_TAC4 (0x02B4) 123 #define CDC_RX_BCL_VBAT_GAIN_UPD1 (0x02B8) 124 #define CDC_RX_BCL_VBAT_GAIN_UPD2 (0x02BC) 125 #define CDC_RX_BCL_VBAT_GAIN_UPD3 (0x02C0) 126 #define CDC_RX_BCL_VBAT_GAIN_UPD4 (0x02C4) 127 #define CDC_RX_BCL_VBAT_GAIN_UPD5 (0x02C8) 128 #define CDC_RX_BCL_VBAT_DEBUG1 (0x02CC) 129 #define CDC_RX_BCL_VBAT_GAIN_UPD_MON (0x02D0) 130 #define CDC_RX_BCL_VBAT_GAIN_MON_VAL (0x02D4) 131 #define CDC_RX_BCL_VBAT_BAN (0x02D8) 132 #define CDC_RX_BCL_VBAT_BCL_GAIN_UPD1 (0x02DC) 133 #define CDC_RX_BCL_VBAT_BCL_GAIN_UPD2 (0x02E0) 134 #define CDC_RX_BCL_VBAT_BCL_GAIN_UPD3 (0x02E4) 135 #define CDC_RX_BCL_VBAT_BCL_GAIN_UPD4 (0x02E8) 136 #define CDC_RX_BCL_VBAT_BCL_GAIN_UPD5 (0x02EC) 137 #define CDC_RX_BCL_VBAT_BCL_GAIN_UPD6 (0x02F0) 138 #define CDC_RX_BCL_VBAT_BCL_GAIN_UPD7 (0x02F4) 139 #define CDC_RX_BCL_VBAT_BCL_GAIN_UPD8 (0x02F8) 140 #define CDC_RX_BCL_VBAT_BCL_GAIN_UPD9 (0x02FC) 141 #define CDC_RX_BCL_VBAT_ATTN1 (0x0300) 142 #define CDC_RX_BCL_VBAT_ATTN2 (0x0304) 143 #define CDC_RX_BCL_VBAT_ATTN3 (0x0308) 144 #define CDC_RX_BCL_VBAT_DECODE_CTL1 (0x030C) 145 #define CDC_RX_BCL_VBAT_DECODE_CTL2 (0x0310) 146 #define CDC_RX_BCL_VBAT_DECODE_CFG1 (0x0314) 147 #define CDC_RX_BCL_VBAT_DECODE_CFG2 (0x0318) 148 #define CDC_RX_BCL_VBAT_DECODE_CFG3 (0x031C) 149 #define CDC_RX_BCL_VBAT_DECODE_CFG4 (0x0320) 150 #define CDC_RX_BCL_VBAT_DECODE_ST (0x0324) 151 #define CDC_RX_INTR_CTRL_CFG (0x0340) 152 #define CDC_RX_INTR_CTRL_CLR_COMMIT (0x0344) 153 #define CDC_RX_INTR_CTRL_PIN1_MASK0 (0x0360) 154 #define CDC_RX_INTR_CTRL_PIN1_STATUS0 (0x0368) 155 #define CDC_RX_INTR_CTRL_PIN1_CLEAR0 (0x0370) 156 #define CDC_RX_INTR_CTRL_PIN2_MASK0 (0x0380) 157 #define CDC_RX_INTR_CTRL_PIN2_STATUS0 (0x0388) 158 #define CDC_RX_INTR_CTRL_PIN2_CLEAR0 (0x0390) 159 #define CDC_RX_INTR_CTRL_LEVEL0 (0x03C0) 160 #define CDC_RX_INTR_CTRL_BYPASS0 (0x03C8) 161 #define CDC_RX_INTR_CTRL_SET0 (0x03D0) 162 #define CDC_RX_RXn_RX_PATH_CTL(rx, n) (0x0400 + rx->rxn_reg_stride * n) 163 #define CDC_RX_RX0_RX_PATH_CTL (0x0400) 164 #define CDC_RX_PATH_RESET_EN_MASK BIT(6) 165 #define CDC_RX_PATH_CLK_EN_MASK BIT(5) 166 #define CDC_RX_PATH_CLK_ENABLE BIT(5) 167 #define CDC_RX_PATH_PGA_MUTE_MASK BIT(4) 168 #define CDC_RX_PATH_PGA_MUTE_ENABLE BIT(4) 169 #define CDC_RX_PATH_PCM_RATE_MASK GENMASK(3, 0) 170 #define CDC_RX_RXn_RX_PATH_CFG0(rx, n) (0x0404 + rx->rxn_reg_stride * n) 171 #define CDC_RX_RXn_COMP_EN_MASK BIT(1) 172 #define CDC_RX_RX0_RX_PATH_CFG0 (0x0404) 173 #define CDC_RX_RXn_CLSH_EN_MASK BIT(6) 174 #define CDC_RX_DLY_ZN_EN_MASK BIT(3) 175 #define CDC_RX_DLY_ZN_ENABLE BIT(3) 176 #define CDC_RX_RXn_HD2_EN_MASK BIT(2) 177 #define CDC_RX_RXn_RX_PATH_CFG1(rx, n) (0x0408 + rx->rxn_reg_stride * n) 178 #define CDC_RX_RXn_SIDETONE_EN_MASK BIT(4) 179 #define CDC_RX_RX0_RX_PATH_CFG1 (0x0408) 180 #define CDC_RX_RX0_HPH_L_EAR_SEL_MASK BIT(1) 181 #define CDC_RX_RXn_RX_PATH_CFG2(rx, n) (0x040C + rx->rxn_reg_stride * n) 182 #define CDC_RX_RXn_HPF_CUT_FREQ_MASK GENMASK(1, 0) 183 #define CDC_RX_RX0_RX_PATH_CFG2 (0x040C) 184 #define CDC_RX_RXn_RX_PATH_CFG3(rx, n) (0x0410 + rx->rxn_reg_stride * n) 185 #define CDC_RX_RX0_RX_PATH_CFG3 (0x0410) 186 #define CDC_RX_DC_COEFF_SEL_MASK GENMASK(1, 0) 187 #define CDC_RX_DC_COEFF_SEL_TWO 0x2 188 #define CDC_RX_RXn_RX_VOL_CTL(rx, n) (0x0414 + rx->rxn_reg_stride * n) 189 #define CDC_RX_RX0_RX_VOL_CTL (0x0414) 190 #define CDC_RX_RXn_RX_PATH_MIX_CTL(rx, n) (0x0418 + rx->rxn_reg_stride * n) 191 #define CDC_RX_RXn_MIX_PCM_RATE_MASK GENMASK(3, 0) 192 #define CDC_RX_RXn_MIX_RESET_MASK BIT(6) 193 #define CDC_RX_RXn_MIX_RESET BIT(6) 194 #define CDC_RX_RXn_MIX_CLK_EN_MASK BIT(5) 195 #define CDC_RX_RX0_RX_PATH_MIX_CTL (0x0418) 196 #define CDC_RX_RX0_RX_PATH_MIX_CFG (0x041C) 197 #define CDC_RX_RXn_RX_VOL_MIX_CTL(rx, n) (0x0420 + rx->rxn_reg_stride * n) 198 #define CDC_RX_RX0_RX_VOL_MIX_CTL (0x0420) 199 #define CDC_RX_RX0_RX_PATH_SEC1 (0x0424) 200 #define CDC_RX_RX0_RX_PATH_SEC2 (0x0428) 201 #define CDC_RX_RX0_RX_PATH_SEC3 (0x042C) 202 #define CDC_RX_RXn_RX_PATH_SEC3(rx, n) (0x042c + rx->rxn_reg_stride * n) 203 #define CDC_RX_RX0_RX_PATH_SEC4 (0x0430) 204 #define CDC_RX_RX0_RX_PATH_SEC7 (0x0434) 205 #define CDC_RX_RXn_RX_PATH_SEC7(rx, n) (0x0434 + rx->rxn_reg_stride * n) 206 #define CDC_RX_DSM_OUT_DELAY_SEL_MASK GENMASK(2, 0) 207 #define CDC_RX_DSM_OUT_DELAY_TWO_SAMPLE 0x2 208 #define CDC_RX_RX0_RX_PATH_MIX_SEC0 (0x0438) 209 #define CDC_RX_RX0_RX_PATH_MIX_SEC1 (0x043C) 210 #define CDC_RX_RXn_RX_PATH_DSM_CTL(rx, n) (0x0440 + rx->rxn_reg_stride * n) 211 #define CDC_RX_RXn_DSM_CLK_EN_MASK BIT(0) 212 #define CDC_RX_RX0_RX_PATH_DSM_CTL (0x0440) 213 #define CDC_RX_RX0_RX_PATH_DSM_DATA1 (0x0444) 214 #define CDC_RX_RX0_RX_PATH_DSM_DATA2 (0x0448) 215 #define CDC_RX_RX0_RX_PATH_DSM_DATA3 (0x044C) 216 #define CDC_RX_RX0_RX_PATH_DSM_DATA4 (0x0450) 217 #define CDC_RX_RX0_RX_PATH_DSM_DATA5 (0x0454) 218 #define CDC_RX_RX0_RX_PATH_DSM_DATA6 (0x0458) 219 /* RX offsets prior to 2.5 codec version */ 220 #define CDC_RX_RX1_RX_PATH_CTL (0x0480) 221 #define CDC_RX_RX1_RX_PATH_CFG0 (0x0484) 222 #define CDC_RX_RX1_RX_PATH_CFG1 (0x0488) 223 #define CDC_RX_RX1_RX_PATH_CFG2 (0x048C) 224 #define CDC_RX_RX1_RX_PATH_CFG3 (0x0490) 225 #define CDC_RX_RX1_RX_VOL_CTL (0x0494) 226 #define CDC_RX_RX1_RX_PATH_MIX_CTL (0x0498) 227 #define CDC_RX_RX1_RX_PATH_MIX_CFG (0x049C) 228 #define CDC_RX_RX1_RX_VOL_MIX_CTL (0x04A0) 229 #define CDC_RX_RX1_RX_PATH_SEC1 (0x04A4) 230 #define CDC_RX_RX1_RX_PATH_SEC2 (0x04A8) 231 #define CDC_RX_RX1_RX_PATH_SEC3 (0x04AC) 232 #define CDC_RX_RXn_HD2_ALPHA_MASK GENMASK(5, 2) 233 #define CDC_RX_RX1_RX_PATH_SEC4 (0x04B0) 234 #define CDC_RX_RX1_RX_PATH_SEC7 (0x04B4) 235 #define CDC_RX_RX1_RX_PATH_MIX_SEC0 (0x04B8) 236 #define CDC_RX_RX1_RX_PATH_MIX_SEC1 (0x04BC) 237 #define CDC_RX_RX1_RX_PATH_DSM_CTL (0x04C0) 238 #define CDC_RX_RX1_RX_PATH_DSM_DATA1 (0x04C4) 239 #define CDC_RX_RX1_RX_PATH_DSM_DATA2 (0x04C8) 240 #define CDC_RX_RX1_RX_PATH_DSM_DATA3 (0x04CC) 241 #define CDC_RX_RX1_RX_PATH_DSM_DATA4 (0x04D0) 242 #define CDC_RX_RX1_RX_PATH_DSM_DATA5 (0x04D4) 243 #define CDC_RX_RX1_RX_PATH_DSM_DATA6 (0x04D8) 244 #define CDC_RX_RX2_RX_PATH_CTL (0x0500) 245 #define CDC_RX_RX2_RX_PATH_CFG0 (0x0504) 246 #define CDC_RX_RX2_CLSH_EN_MASK BIT(4) 247 #define CDC_RX_RX2_DLY_Z_EN_MASK BIT(3) 248 #define CDC_RX_RX2_RX_PATH_CFG1 (0x0508) 249 #define CDC_RX_RX2_RX_PATH_CFG2 (0x050C) 250 #define CDC_RX_RX2_RX_PATH_CFG3 (0x0510) 251 #define CDC_RX_RX2_RX_VOL_CTL (0x0514) 252 #define CDC_RX_RX2_RX_PATH_MIX_CTL (0x0518) 253 #define CDC_RX_RX2_RX_PATH_MIX_CFG (0x051C) 254 #define CDC_RX_RX2_RX_VOL_MIX_CTL (0x0520) 255 #define CDC_RX_RX2_RX_PATH_SEC0 (0x0524) 256 #define CDC_RX_RX2_RX_PATH_SEC1 (0x0528) 257 #define CDC_RX_RX2_RX_PATH_SEC2 (0x052C) 258 #define CDC_RX_RX2_RX_PATH_SEC3 (0x0530) 259 #define CDC_RX_RX2_RX_PATH_SEC4 (0x0534) 260 #define CDC_RX_RX2_RX_PATH_SEC5 (0x0538) 261 #define CDC_RX_RX2_RX_PATH_SEC6 (0x053C) 262 #define CDC_RX_RX2_RX_PATH_SEC7 (0x0540) 263 #define CDC_RX_RX2_RX_PATH_MIX_SEC0 (0x0544) 264 #define CDC_RX_RX2_RX_PATH_MIX_SEC1 (0x0548) 265 #define CDC_RX_RX2_RX_PATH_DSM_CTL (0x054C) 266 267 /* LPASS CODEC version 2.5 rx reg offsets */ 268 #define CDC_2_5_RX_RX1_RX_PATH_CTL (0x04c0) 269 #define CDC_2_5_RX_RX1_RX_PATH_CFG0 (0x04c4) 270 #define CDC_2_5_RX_RX1_RX_PATH_CFG1 (0x04c8) 271 #define CDC_2_5_RX_RX1_RX_PATH_CFG2 (0x04cC) 272 #define CDC_2_5_RX_RX1_RX_PATH_CFG3 (0x04d0) 273 #define CDC_2_5_RX_RX1_RX_VOL_CTL (0x04d4) 274 #define CDC_2_5_RX_RX1_RX_PATH_MIX_CTL (0x04d8) 275 #define CDC_2_5_RX_RX1_RX_PATH_MIX_CFG (0x04dC) 276 #define CDC_2_5_RX_RX1_RX_VOL_MIX_CTL (0x04e0) 277 #define CDC_2_5_RX_RX1_RX_PATH_SEC1 (0x04e4) 278 #define CDC_2_5_RX_RX1_RX_PATH_SEC2 (0x04e8) 279 #define CDC_2_5_RX_RX1_RX_PATH_SEC3 (0x04eC) 280 #define CDC_2_5_RX_RX1_RX_PATH_SEC4 (0x04f0) 281 #define CDC_2_5_RX_RX1_RX_PATH_SEC7 (0x04f4) 282 #define CDC_2_5_RX_RX1_RX_PATH_MIX_SEC0 (0x04f8) 283 #define CDC_2_5_RX_RX1_RX_PATH_MIX_SEC1 (0x04fC) 284 #define CDC_2_5_RX_RX1_RX_PATH_DSM_CTL (0x0500) 285 #define CDC_2_5_RX_RX1_RX_PATH_DSM_DATA1 (0x0504) 286 #define CDC_2_5_RX_RX1_RX_PATH_DSM_DATA2 (0x0508) 287 #define CDC_2_5_RX_RX1_RX_PATH_DSM_DATA3 (0x050C) 288 #define CDC_2_5_RX_RX1_RX_PATH_DSM_DATA4 (0x0510) 289 #define CDC_2_5_RX_RX1_RX_PATH_DSM_DATA5 (0x0514) 290 #define CDC_2_5_RX_RX1_RX_PATH_DSM_DATA6 (0x0518) 291 292 #define CDC_2_5_RX_RX2_RX_PATH_CTL (0x0580) 293 #define CDC_2_5_RX_RX2_RX_PATH_CFG0 (0x0584) 294 #define CDC_2_5_RX_RX2_RX_PATH_CFG1 (0x0588) 295 #define CDC_2_5_RX_RX2_RX_PATH_CFG2 (0x058C) 296 #define CDC_2_5_RX_RX2_RX_PATH_CFG3 (0x0590) 297 #define CDC_2_5_RX_RX2_RX_VOL_CTL (0x0594) 298 #define CDC_2_5_RX_RX2_RX_PATH_MIX_CTL (0x0598) 299 #define CDC_2_5_RX_RX2_RX_PATH_MIX_CFG (0x059C) 300 #define CDC_2_5_RX_RX2_RX_VOL_MIX_CTL (0x05a0) 301 #define CDC_2_5_RX_RX2_RX_PATH_SEC0 (0x05a4) 302 #define CDC_2_5_RX_RX2_RX_PATH_SEC1 (0x05a8) 303 #define CDC_2_5_RX_RX2_RX_PATH_SEC2 (0x05aC) 304 #define CDC_2_5_RX_RX2_RX_PATH_SEC3 (0x05b0) 305 #define CDC_2_5_RX_RX2_RX_PATH_SEC4 (0x05b4) 306 #define CDC_2_5_RX_RX2_RX_PATH_SEC5 (0x05b8) 307 #define CDC_2_5_RX_RX2_RX_PATH_SEC6 (0x05bC) 308 #define CDC_2_5_RX_RX2_RX_PATH_SEC7 (0x05c0) 309 #define CDC_2_5_RX_RX2_RX_PATH_MIX_SEC0 (0x05c4) 310 #define CDC_2_5_RX_RX2_RX_PATH_MIX_SEC1 (0x05c8) 311 #define CDC_2_5_RX_RX2_RX_PATH_DSM_CTL (0x05cC) 312 313 #define CDC_RX_IDLE_DETECT_PATH_CTL (0x0780) 314 #define CDC_RX_IDLE_DETECT_CFG0 (0x0784) 315 #define CDC_RX_IDLE_DETECT_CFG1 (0x0788) 316 #define CDC_RX_IDLE_DETECT_CFG2 (0x078C) 317 #define CDC_RX_IDLE_DETECT_CFG3 (0x0790) 318 #define CDC_RX_COMPANDERn_CTL0(n) (0x0800 + 0x40 * n) 319 #define CDC_RX_COMPANDERn_CLK_EN_MASK BIT(0) 320 #define CDC_RX_COMPANDERn_SOFT_RST_MASK BIT(1) 321 #define CDC_RX_COMPANDERn_HALT_MASK BIT(2) 322 #define CDC_RX_COMPANDER0_CTL0 (0x0800) 323 #define CDC_RX_COMPANDER0_CTL1 (0x0804) 324 #define CDC_RX_COMPANDER0_CTL2 (0x0808) 325 #define CDC_RX_COMPANDER0_CTL3 (0x080C) 326 #define CDC_RX_COMPANDER0_CTL4 (0x0810) 327 #define CDC_RX_COMPANDER0_CTL5 (0x0814) 328 #define CDC_RX_COMPANDER0_CTL6 (0x0818) 329 #define CDC_RX_COMPANDER0_CTL7 (0x081C) 330 #define CDC_RX_COMPANDER1_CTL0 (0x0840) 331 #define CDC_RX_COMPANDER1_CTL1 (0x0844) 332 #define CDC_RX_COMPANDER1_CTL2 (0x0848) 333 #define CDC_RX_COMPANDER1_CTL3 (0x084C) 334 #define CDC_RX_COMPANDER1_CTL4 (0x0850) 335 #define CDC_RX_COMPANDER1_CTL5 (0x0854) 336 #define CDC_RX_COMPANDER1_CTL6 (0x0858) 337 #define CDC_RX_COMPANDER1_CTL7 (0x085C) 338 #define CDC_RX_COMPANDER1_HPH_LOW_PWR_MODE_MASK BIT(5) 339 #define CDC_RX_SIDETONE_IIR0_IIR_PATH_CTL (0x0A00) 340 #define CDC_RX_SIDETONE_IIR0_IIR_GAIN_B1_CTL (0x0A04) 341 #define CDC_RX_SIDETONE_IIR0_IIR_GAIN_B2_CTL (0x0A08) 342 #define CDC_RX_SIDETONE_IIR0_IIR_GAIN_B3_CTL (0x0A0C) 343 #define CDC_RX_SIDETONE_IIR0_IIR_GAIN_B4_CTL (0x0A10) 344 #define CDC_RX_SIDETONE_IIR0_IIR_GAIN_B5_CTL (0x0A14) 345 #define CDC_RX_SIDETONE_IIR0_IIR_GAIN_B6_CTL (0x0A18) 346 #define CDC_RX_SIDETONE_IIR0_IIR_GAIN_B7_CTL (0x0A1C) 347 #define CDC_RX_SIDETONE_IIR0_IIR_GAIN_B8_CTL (0x0A20) 348 #define CDC_RX_SIDETONE_IIR0_IIR_CTL (0x0A24) 349 #define CDC_RX_SIDETONE_IIR0_IIR_GAIN_TIMER_CTL (0x0A28) 350 #define CDC_RX_SIDETONE_IIR0_IIR_COEF_B1_CTL (0x0A2C) 351 #define CDC_RX_SIDETONE_IIR0_IIR_COEF_B2_CTL (0x0A30) 352 #define CDC_RX_SIDETONE_IIR1_IIR_PATH_CTL (0x0A80) 353 #define CDC_RX_SIDETONE_IIR1_IIR_GAIN_B1_CTL (0x0A84) 354 #define CDC_RX_SIDETONE_IIR1_IIR_GAIN_B2_CTL (0x0A88) 355 #define CDC_RX_SIDETONE_IIR1_IIR_GAIN_B3_CTL (0x0A8C) 356 #define CDC_RX_SIDETONE_IIR1_IIR_GAIN_B4_CTL (0x0A90) 357 #define CDC_RX_SIDETONE_IIR1_IIR_GAIN_B5_CTL (0x0A94) 358 #define CDC_RX_SIDETONE_IIR1_IIR_GAIN_B6_CTL (0x0A98) 359 #define CDC_RX_SIDETONE_IIR1_IIR_GAIN_B7_CTL (0x0A9C) 360 #define CDC_RX_SIDETONE_IIR1_IIR_GAIN_B8_CTL (0x0AA0) 361 #define CDC_RX_SIDETONE_IIR1_IIR_CTL (0x0AA4) 362 #define CDC_RX_SIDETONE_IIR1_IIR_GAIN_TIMER_CTL (0x0AA8) 363 #define CDC_RX_SIDETONE_IIR1_IIR_COEF_B1_CTL (0x0AAC) 364 #define CDC_RX_SIDETONE_IIR1_IIR_COEF_B2_CTL (0x0AB0) 365 #define CDC_RX_IIR_INP_MUX_IIR0_MIX_CFG0 (0x0B00) 366 #define CDC_RX_IIR_INP_MUX_IIR0_MIX_CFG1 (0x0B04) 367 #define CDC_RX_IIR_INP_MUX_IIR0_MIX_CFG2 (0x0B08) 368 #define CDC_RX_IIR_INP_MUX_IIR0_MIX_CFG3 (0x0B0C) 369 #define CDC_RX_IIR_INP_MUX_IIR1_MIX_CFG0 (0x0B10) 370 #define CDC_RX_IIR_INP_MUX_IIR1_MIX_CFG1 (0x0B14) 371 #define CDC_RX_IIR_INP_MUX_IIR1_MIX_CFG2 (0x0B18) 372 #define CDC_RX_IIR_INP_MUX_IIR1_MIX_CFG3 (0x0B1C) 373 #define CDC_RX_SIDETONE_SRC0_ST_SRC_PATH_CTL (0x0B40) 374 #define CDC_RX_SIDETONE_SRC0_ST_SRC_PATH_CFG1 (0x0B44) 375 #define CDC_RX_SIDETONE_SRC1_ST_SRC_PATH_CTL (0x0B50) 376 #define CDC_RX_SIDETONE_SRC1_ST_SRC_PATH_CFG1 (0x0B54) 377 #define CDC_RX_EC_REF_HQ0_EC_REF_HQ_PATH_CTL (0x0C00) 378 #define CDC_RX_EC_REF_HQ0_EC_REF_HQ_CFG0 (0x0C04) 379 #define CDC_RX_EC_REF_HQ1_EC_REF_HQ_PATH_CTL (0x0C40) 380 #define CDC_RX_EC_REF_HQ1_EC_REF_HQ_CFG0 (0x0C44) 381 #define CDC_RX_EC_REF_HQ2_EC_REF_HQ_PATH_CTL (0x0C80) 382 #define CDC_RX_EC_REF_HQ2_EC_REF_HQ_CFG0 (0x0C84) 383 #define CDC_RX_EC_ASRC0_CLK_RST_CTL (0x0D00) 384 #define CDC_RX_EC_ASRC0_CTL0 (0x0D04) 385 #define CDC_RX_EC_ASRC0_CTL1 (0x0D08) 386 #define CDC_RX_EC_ASRC0_FIFO_CTL (0x0D0C) 387 #define CDC_RX_EC_ASRC0_STATUS_FMIN_CNTR_LSB (0x0D10) 388 #define CDC_RX_EC_ASRC0_STATUS_FMIN_CNTR_MSB (0x0D14) 389 #define CDC_RX_EC_ASRC0_STATUS_FMAX_CNTR_LSB (0x0D18) 390 #define CDC_RX_EC_ASRC0_STATUS_FMAX_CNTR_MSB (0x0D1C) 391 #define CDC_RX_EC_ASRC0_STATUS_FIFO (0x0D20) 392 #define CDC_RX_EC_ASRC1_CLK_RST_CTL (0x0D40) 393 #define CDC_RX_EC_ASRC1_CTL0 (0x0D44) 394 #define CDC_RX_EC_ASRC1_CTL1 (0x0D48) 395 #define CDC_RX_EC_ASRC1_FIFO_CTL (0x0D4C) 396 #define CDC_RX_EC_ASRC1_STATUS_FMIN_CNTR_LSB (0x0D50) 397 #define CDC_RX_EC_ASRC1_STATUS_FMIN_CNTR_MSB (0x0D54) 398 #define CDC_RX_EC_ASRC1_STATUS_FMAX_CNTR_LSB (0x0D58) 399 #define CDC_RX_EC_ASRC1_STATUS_FMAX_CNTR_MSB (0x0D5C) 400 #define CDC_RX_EC_ASRC1_STATUS_FIFO (0x0D60) 401 #define CDC_RX_EC_ASRC2_CLK_RST_CTL (0x0D80) 402 #define CDC_RX_EC_ASRC2_CTL0 (0x0D84) 403 #define CDC_RX_EC_ASRC2_CTL1 (0x0D88) 404 #define CDC_RX_EC_ASRC2_FIFO_CTL (0x0D8C) 405 #define CDC_RX_EC_ASRC2_STATUS_FMIN_CNTR_LSB (0x0D90) 406 #define CDC_RX_EC_ASRC2_STATUS_FMIN_CNTR_MSB (0x0D94) 407 #define CDC_RX_EC_ASRC2_STATUS_FMAX_CNTR_LSB (0x0D98) 408 #define CDC_RX_EC_ASRC2_STATUS_FMAX_CNTR_MSB (0x0D9C) 409 #define CDC_RX_EC_ASRC2_STATUS_FIFO (0x0DA0) 410 #define CDC_RX_DSD0_PATH_CTL (0x0F00) 411 #define CDC_RX_DSD0_CFG0 (0x0F04) 412 #define CDC_RX_DSD0_CFG1 (0x0F08) 413 #define CDC_RX_DSD0_CFG2 (0x0F0C) 414 #define CDC_RX_DSD1_PATH_CTL (0x0F80) 415 #define CDC_RX_DSD1_CFG0 (0x0F84) 416 #define CDC_RX_DSD1_CFG1 (0x0F88) 417 #define CDC_RX_DSD1_CFG2 (0x0F8C) 418 #define RX_MAX_OFFSET (0x0F8C) 419 420 #define MCLK_FREQ 19200000 421 422 #define RX_MACRO_RATES (SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |\ 423 SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |\ 424 SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_192000 |\ 425 SNDRV_PCM_RATE_384000) 426 /* Fractional Rates */ 427 #define RX_MACRO_FRAC_RATES (SNDRV_PCM_RATE_44100 | SNDRV_PCM_RATE_88200 |\ 428 SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800) 429 430 #define RX_MACRO_FORMATS (SNDRV_PCM_FMTBIT_S16_LE |\ 431 SNDRV_PCM_FMTBIT_S24_LE |\ 432 SNDRV_PCM_FMTBIT_S24_3LE | SNDRV_PCM_FMTBIT_S32_LE) 433 434 #define RX_MACRO_ECHO_RATES (SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |\ 435 SNDRV_PCM_RATE_48000) 436 #define RX_MACRO_ECHO_FORMATS (SNDRV_PCM_FMTBIT_S16_LE |\ 437 SNDRV_PCM_FMTBIT_S24_LE |\ 438 SNDRV_PCM_FMTBIT_S24_3LE) 439 440 #define RX_MACRO_MAX_DMA_CH_PER_PORT 2 441 442 #define RX_MACRO_EC_MIX_TX0_MASK 0xf0 443 #define RX_MACRO_EC_MIX_TX1_MASK 0x0f 444 #define RX_MACRO_EC_MIX_TX2_MASK 0x0f 445 446 #define COMP_MAX_COEFF 25 447 #define RX_NUM_CLKS_MAX 5 448 449 struct comp_coeff_val { 450 u8 lsb; 451 u8 msb; 452 }; 453 454 enum { 455 HPH_ULP, 456 HPH_LOHIFI, 457 HPH_MODE_MAX, 458 }; 459 460 static const struct comp_coeff_val comp_coeff_table[HPH_MODE_MAX][COMP_MAX_COEFF] = { 461 { 462 {0x40, 0x00}, 463 {0x4C, 0x00}, 464 {0x5A, 0x00}, 465 {0x6B, 0x00}, 466 {0x7F, 0x00}, 467 {0x97, 0x00}, 468 {0xB3, 0x00}, 469 {0xD5, 0x00}, 470 {0xFD, 0x00}, 471 {0x2D, 0x01}, 472 {0x66, 0x01}, 473 {0xA7, 0x01}, 474 {0xF8, 0x01}, 475 {0x57, 0x02}, 476 {0xC7, 0x02}, 477 {0x4B, 0x03}, 478 {0xE9, 0x03}, 479 {0xA3, 0x04}, 480 {0x7D, 0x05}, 481 {0x90, 0x06}, 482 {0xD1, 0x07}, 483 {0x49, 0x09}, 484 {0x00, 0x0B}, 485 {0x01, 0x0D}, 486 {0x59, 0x0F}, 487 }, 488 { 489 {0x40, 0x00}, 490 {0x4C, 0x00}, 491 {0x5A, 0x00}, 492 {0x6B, 0x00}, 493 {0x80, 0x00}, 494 {0x98, 0x00}, 495 {0xB4, 0x00}, 496 {0xD5, 0x00}, 497 {0xFE, 0x00}, 498 {0x2E, 0x01}, 499 {0x66, 0x01}, 500 {0xA9, 0x01}, 501 {0xF8, 0x01}, 502 {0x56, 0x02}, 503 {0xC4, 0x02}, 504 {0x4F, 0x03}, 505 {0xF0, 0x03}, 506 {0xAE, 0x04}, 507 {0x8B, 0x05}, 508 {0x8E, 0x06}, 509 {0xBC, 0x07}, 510 {0x56, 0x09}, 511 {0x0F, 0x0B}, 512 {0x13, 0x0D}, 513 {0x6F, 0x0F}, 514 }, 515 }; 516 517 enum { 518 INTERP_HPHL, 519 INTERP_HPHR, 520 INTERP_AUX, 521 INTERP_MAX 522 }; 523 524 enum { 525 RX_MACRO_RX0, 526 RX_MACRO_RX1, 527 RX_MACRO_RX2, 528 RX_MACRO_RX3, 529 RX_MACRO_RX4, 530 RX_MACRO_RX5, 531 RX_MACRO_PORTS_MAX 532 }; 533 534 enum { 535 RX_MACRO_COMP1, /* HPH_L */ 536 RX_MACRO_COMP2, /* HPH_R */ 537 RX_MACRO_COMP_MAX 538 }; 539 540 enum { 541 RX_MACRO_EC0_MUX = 0, 542 RX_MACRO_EC1_MUX, 543 RX_MACRO_EC2_MUX, 544 RX_MACRO_EC_MUX_MAX, 545 }; 546 547 enum { 548 INTn_1_INP_SEL_ZERO = 0, 549 INTn_1_INP_SEL_DEC0, 550 INTn_1_INP_SEL_DEC1, 551 INTn_1_INP_SEL_IIR0, 552 INTn_1_INP_SEL_IIR1, 553 INTn_1_INP_SEL_RX0, 554 INTn_1_INP_SEL_RX1, 555 INTn_1_INP_SEL_RX2, 556 INTn_1_INP_SEL_RX3, 557 INTn_1_INP_SEL_RX4, 558 INTn_1_INP_SEL_RX5, 559 }; 560 561 enum { 562 INTn_2_INP_SEL_ZERO = 0, 563 INTn_2_INP_SEL_RX0, 564 INTn_2_INP_SEL_RX1, 565 INTn_2_INP_SEL_RX2, 566 INTn_2_INP_SEL_RX3, 567 INTn_2_INP_SEL_RX4, 568 INTn_2_INP_SEL_RX5, 569 }; 570 571 enum { 572 INTERP_MAIN_PATH, 573 INTERP_MIX_PATH, 574 }; 575 576 /* Codec supports 2 IIR filters */ 577 enum { 578 IIR0 = 0, 579 IIR1, 580 IIR_MAX, 581 }; 582 583 /* Each IIR has 5 Filter Stages */ 584 enum { 585 BAND1 = 0, 586 BAND2, 587 BAND3, 588 BAND4, 589 BAND5, 590 BAND_MAX, 591 }; 592 593 #define RX_MACRO_IIR_FILTER_SIZE (sizeof(u32) * BAND_MAX) 594 595 #define RX_MACRO_IIR_FILTER_CTL(xname, iidx, bidx) \ 596 { \ 597 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \ 598 .info = rx_macro_iir_filter_info, \ 599 .get = rx_macro_get_iir_band_audio_mixer, \ 600 .put = rx_macro_put_iir_band_audio_mixer, \ 601 .private_value = (unsigned long)&(struct wcd_iir_filter_ctl) { \ 602 .iir_idx = iidx, \ 603 .band_idx = bidx, \ 604 .bytes_ext = {.max = RX_MACRO_IIR_FILTER_SIZE, }, \ 605 } \ 606 } 607 608 struct interp_sample_rate { 609 int sample_rate; 610 int rate_val; 611 }; 612 613 static struct interp_sample_rate sr_val_tbl[] = { 614 {8000, 0x0}, {16000, 0x1}, {32000, 0x3}, {48000, 0x4}, {96000, 0x5}, 615 {192000, 0x6}, {384000, 0x7}, {44100, 0x9}, {88200, 0xA}, 616 {176400, 0xB}, {352800, 0xC}, 617 }; 618 619 enum { 620 RX_MACRO_AIF_INVALID = 0, 621 RX_MACRO_AIF1_PB, 622 RX_MACRO_AIF2_PB, 623 RX_MACRO_AIF3_PB, 624 RX_MACRO_AIF4_PB, 625 RX_MACRO_AIF_ECHO, 626 RX_MACRO_MAX_DAIS, 627 }; 628 629 enum { 630 RX_MACRO_AIF1_CAP = 0, 631 RX_MACRO_AIF2_CAP, 632 RX_MACRO_AIF3_CAP, 633 RX_MACRO_MAX_AIF_CAP_DAIS 634 }; 635 636 struct rx_macro { 637 struct device *dev; 638 int comp_enabled[RX_MACRO_COMP_MAX]; 639 /* Main path clock users count */ 640 int main_clk_users[INTERP_MAX]; 641 int rx_port_value[RX_MACRO_PORTS_MAX]; 642 u16 prim_int_users[INTERP_MAX]; 643 int rx_mclk_users; 644 int clsh_users; 645 int rx_mclk_cnt; 646 enum lpass_codec_version codec_version; 647 int rxn_reg_stride; 648 bool is_ear_mode_on; 649 bool hph_pwr_mode; 650 bool hph_hd2_mode; 651 struct snd_soc_component *component; 652 unsigned long active_ch_mask[RX_MACRO_MAX_DAIS]; 653 unsigned long active_ch_cnt[RX_MACRO_MAX_DAIS]; 654 u16 bit_width[RX_MACRO_MAX_DAIS]; 655 int is_softclip_on; 656 int is_aux_hpf_on; 657 int softclip_clk_users; 658 struct lpass_macro *pds; 659 struct regmap *regmap; 660 struct clk *mclk; 661 struct clk *npl; 662 struct clk *macro; 663 struct clk *dcodec; 664 struct clk *fsgen; 665 struct clk_hw hw; 666 }; 667 #define to_rx_macro(_hw) container_of(_hw, struct rx_macro, hw) 668 669 struct wcd_iir_filter_ctl { 670 unsigned int iir_idx; 671 unsigned int band_idx; 672 struct soc_bytes_ext bytes_ext; 673 }; 674 675 static const DECLARE_TLV_DB_SCALE(digital_gain, -8400, 100, -8400); 676 677 static const char * const rx_int_mix_mux_text[] = { 678 "ZERO", "RX0", "RX1", "RX2", "RX3", "RX4", "RX5" 679 }; 680 681 static const char * const rx_prim_mix_text[] = { 682 "ZERO", "DEC0", "DEC1", "IIR0", "IIR1", "RX0", "RX1", "RX2", 683 "RX3", "RX4", "RX5" 684 }; 685 686 static const char * const rx_sidetone_mix_text[] = { 687 "ZERO", "SRC0", "SRC1", "SRC_SUM" 688 }; 689 690 static const char * const iir_inp_mux_text[] = { 691 "ZERO", "DEC0", "DEC1", "DEC2", "DEC3", 692 "RX0", "RX1", "RX2", "RX3", "RX4", "RX5" 693 }; 694 695 static const char * const rx_int_dem_inp_mux_text[] = { 696 "NORMAL_DSM_OUT", "CLSH_DSM_OUT", 697 }; 698 699 static const char * const rx_int0_1_interp_mux_text[] = { 700 "ZERO", "RX INT0_1 MIX1", 701 }; 702 703 static const char * const rx_int1_1_interp_mux_text[] = { 704 "ZERO", "RX INT1_1 MIX1", 705 }; 706 707 static const char * const rx_int2_1_interp_mux_text[] = { 708 "ZERO", "RX INT2_1 MIX1", 709 }; 710 711 static const char * const rx_int0_2_interp_mux_text[] = { 712 "ZERO", "RX INT0_2 MUX", 713 }; 714 715 static const char * const rx_int1_2_interp_mux_text[] = { 716 "ZERO", "RX INT1_2 MUX", 717 }; 718 719 static const char * const rx_int2_2_interp_mux_text[] = { 720 "ZERO", "RX INT2_2 MUX", 721 }; 722 723 static const char *const rx_macro_mux_text[] = { 724 "ZERO", "AIF1_PB", "AIF2_PB", "AIF3_PB", "AIF4_PB" 725 }; 726 727 static const char *const rx_macro_hph_pwr_mode_text[] = { 728 "ULP", "LOHIFI" 729 }; 730 731 static const char * const rx_echo_mux_text[] = { 732 "ZERO", "RX_MIX0", "RX_MIX1", "RX_MIX2" 733 }; 734 735 static const struct soc_enum rx_macro_hph_pwr_mode_enum = 736 SOC_ENUM_SINGLE_EXT(2, rx_macro_hph_pwr_mode_text); 737 static const struct soc_enum rx_mix_tx2_mux_enum = 738 SOC_ENUM_SINGLE(CDC_RX_INP_MUX_RX_MIX_CFG5, 0, 4, rx_echo_mux_text); 739 static const struct soc_enum rx_mix_tx1_mux_enum = 740 SOC_ENUM_SINGLE(CDC_RX_INP_MUX_RX_MIX_CFG4, 0, 4, rx_echo_mux_text); 741 static const struct soc_enum rx_mix_tx0_mux_enum = 742 SOC_ENUM_SINGLE(CDC_RX_INP_MUX_RX_MIX_CFG4, 4, 4, rx_echo_mux_text); 743 744 static SOC_ENUM_SINGLE_DECL(rx_int0_2_enum, CDC_RX_INP_MUX_RX_INT0_CFG1, 0, 745 rx_int_mix_mux_text); 746 static SOC_ENUM_SINGLE_DECL(rx_int1_2_enum, CDC_RX_INP_MUX_RX_INT1_CFG1, 0, 747 rx_int_mix_mux_text); 748 static SOC_ENUM_SINGLE_DECL(rx_int2_2_enum, CDC_RX_INP_MUX_RX_INT2_CFG1, 0, 749 rx_int_mix_mux_text); 750 751 static SOC_ENUM_SINGLE_DECL(rx_int0_1_mix_inp0_enum, CDC_RX_INP_MUX_RX_INT0_CFG0, 0, 752 rx_prim_mix_text); 753 static SOC_ENUM_SINGLE_DECL(rx_int0_1_mix_inp1_enum, CDC_RX_INP_MUX_RX_INT0_CFG0, 4, 754 rx_prim_mix_text); 755 static SOC_ENUM_SINGLE_DECL(rx_int0_1_mix_inp2_enum, CDC_RX_INP_MUX_RX_INT0_CFG1, 4, 756 rx_prim_mix_text); 757 static SOC_ENUM_SINGLE_DECL(rx_int1_1_mix_inp0_enum, CDC_RX_INP_MUX_RX_INT1_CFG0, 0, 758 rx_prim_mix_text); 759 static SOC_ENUM_SINGLE_DECL(rx_int1_1_mix_inp1_enum, CDC_RX_INP_MUX_RX_INT1_CFG0, 4, 760 rx_prim_mix_text); 761 static SOC_ENUM_SINGLE_DECL(rx_int1_1_mix_inp2_enum, CDC_RX_INP_MUX_RX_INT1_CFG1, 4, 762 rx_prim_mix_text); 763 static SOC_ENUM_SINGLE_DECL(rx_int2_1_mix_inp0_enum, CDC_RX_INP_MUX_RX_INT2_CFG0, 0, 764 rx_prim_mix_text); 765 static SOC_ENUM_SINGLE_DECL(rx_int2_1_mix_inp1_enum, CDC_RX_INP_MUX_RX_INT2_CFG0, 4, 766 rx_prim_mix_text); 767 static SOC_ENUM_SINGLE_DECL(rx_int2_1_mix_inp2_enum, CDC_RX_INP_MUX_RX_INT2_CFG1, 4, 768 rx_prim_mix_text); 769 770 static SOC_ENUM_SINGLE_DECL(rx_int0_mix2_inp_enum, CDC_RX_INP_MUX_SIDETONE_SRC_CFG0, 2, 771 rx_sidetone_mix_text); 772 static SOC_ENUM_SINGLE_DECL(rx_int1_mix2_inp_enum, CDC_RX_INP_MUX_SIDETONE_SRC_CFG0, 4, 773 rx_sidetone_mix_text); 774 static SOC_ENUM_SINGLE_DECL(rx_int2_mix2_inp_enum, CDC_RX_INP_MUX_SIDETONE_SRC_CFG0, 6, 775 rx_sidetone_mix_text); 776 static SOC_ENUM_SINGLE_DECL(iir0_inp0_enum, CDC_RX_IIR_INP_MUX_IIR0_MIX_CFG0, 0, 777 iir_inp_mux_text); 778 static SOC_ENUM_SINGLE_DECL(iir0_inp1_enum, CDC_RX_IIR_INP_MUX_IIR0_MIX_CFG1, 0, 779 iir_inp_mux_text); 780 static SOC_ENUM_SINGLE_DECL(iir0_inp2_enum, CDC_RX_IIR_INP_MUX_IIR0_MIX_CFG2, 0, 781 iir_inp_mux_text); 782 static SOC_ENUM_SINGLE_DECL(iir0_inp3_enum, CDC_RX_IIR_INP_MUX_IIR0_MIX_CFG3, 0, 783 iir_inp_mux_text); 784 static SOC_ENUM_SINGLE_DECL(iir1_inp0_enum, CDC_RX_IIR_INP_MUX_IIR1_MIX_CFG0, 0, 785 iir_inp_mux_text); 786 static SOC_ENUM_SINGLE_DECL(iir1_inp1_enum, CDC_RX_IIR_INP_MUX_IIR1_MIX_CFG1, 0, 787 iir_inp_mux_text); 788 static SOC_ENUM_SINGLE_DECL(iir1_inp2_enum, CDC_RX_IIR_INP_MUX_IIR1_MIX_CFG2, 0, 789 iir_inp_mux_text); 790 static SOC_ENUM_SINGLE_DECL(iir1_inp3_enum, CDC_RX_IIR_INP_MUX_IIR1_MIX_CFG3, 0, 791 iir_inp_mux_text); 792 793 static SOC_ENUM_SINGLE_DECL(rx_int0_1_interp_enum, SND_SOC_NOPM, 0, 794 rx_int0_1_interp_mux_text); 795 static SOC_ENUM_SINGLE_DECL(rx_int1_1_interp_enum, SND_SOC_NOPM, 0, 796 rx_int1_1_interp_mux_text); 797 static SOC_ENUM_SINGLE_DECL(rx_int2_1_interp_enum, SND_SOC_NOPM, 0, 798 rx_int2_1_interp_mux_text); 799 static SOC_ENUM_SINGLE_DECL(rx_int0_2_interp_enum, SND_SOC_NOPM, 0, 800 rx_int0_2_interp_mux_text); 801 static SOC_ENUM_SINGLE_DECL(rx_int1_2_interp_enum, SND_SOC_NOPM, 0, 802 rx_int1_2_interp_mux_text); 803 static SOC_ENUM_SINGLE_DECL(rx_int2_2_interp_enum, SND_SOC_NOPM, 0, 804 rx_int2_2_interp_mux_text); 805 static SOC_ENUM_SINGLE_DECL(rx_int0_dem_inp_enum, CDC_RX_RX0_RX_PATH_CFG1, 0, 806 rx_int_dem_inp_mux_text); 807 static SOC_ENUM_SINGLE_DECL(rx_int1_dem_inp_enum, CDC_RX_RX1_RX_PATH_CFG1, 0, 808 rx_int_dem_inp_mux_text); 809 static SOC_ENUM_SINGLE_DECL(rx_2_5_int1_dem_inp_enum, CDC_2_5_RX_RX1_RX_PATH_CFG1, 0, 810 rx_int_dem_inp_mux_text); 811 812 static SOC_ENUM_SINGLE_DECL(rx_macro_rx0_enum, SND_SOC_NOPM, 0, rx_macro_mux_text); 813 static SOC_ENUM_SINGLE_DECL(rx_macro_rx1_enum, SND_SOC_NOPM, 0, rx_macro_mux_text); 814 static SOC_ENUM_SINGLE_DECL(rx_macro_rx2_enum, SND_SOC_NOPM, 0, rx_macro_mux_text); 815 static SOC_ENUM_SINGLE_DECL(rx_macro_rx3_enum, SND_SOC_NOPM, 0, rx_macro_mux_text); 816 static SOC_ENUM_SINGLE_DECL(rx_macro_rx4_enum, SND_SOC_NOPM, 0, rx_macro_mux_text); 817 static SOC_ENUM_SINGLE_DECL(rx_macro_rx5_enum, SND_SOC_NOPM, 0, rx_macro_mux_text); 818 819 static const struct snd_kcontrol_new rx_mix_tx1_mux = 820 SOC_DAPM_ENUM("RX MIX TX1_MUX Mux", rx_mix_tx1_mux_enum); 821 static const struct snd_kcontrol_new rx_mix_tx2_mux = 822 SOC_DAPM_ENUM("RX MIX TX2_MUX Mux", rx_mix_tx2_mux_enum); 823 static const struct snd_kcontrol_new rx_int0_2_mux = 824 SOC_DAPM_ENUM("rx_int0_2", rx_int0_2_enum); 825 static const struct snd_kcontrol_new rx_int1_2_mux = 826 SOC_DAPM_ENUM("rx_int1_2", rx_int1_2_enum); 827 static const struct snd_kcontrol_new rx_int2_2_mux = 828 SOC_DAPM_ENUM("rx_int2_2", rx_int2_2_enum); 829 static const struct snd_kcontrol_new rx_int0_1_mix_inp0_mux = 830 SOC_DAPM_ENUM("rx_int0_1_mix_inp0", rx_int0_1_mix_inp0_enum); 831 static const struct snd_kcontrol_new rx_int0_1_mix_inp1_mux = 832 SOC_DAPM_ENUM("rx_int0_1_mix_inp1", rx_int0_1_mix_inp1_enum); 833 static const struct snd_kcontrol_new rx_int0_1_mix_inp2_mux = 834 SOC_DAPM_ENUM("rx_int0_1_mix_inp2", rx_int0_1_mix_inp2_enum); 835 static const struct snd_kcontrol_new rx_int1_1_mix_inp0_mux = 836 SOC_DAPM_ENUM("rx_int1_1_mix_inp0", rx_int1_1_mix_inp0_enum); 837 static const struct snd_kcontrol_new rx_int1_1_mix_inp1_mux = 838 SOC_DAPM_ENUM("rx_int1_1_mix_inp1", rx_int1_1_mix_inp1_enum); 839 static const struct snd_kcontrol_new rx_int1_1_mix_inp2_mux = 840 SOC_DAPM_ENUM("rx_int1_1_mix_inp2", rx_int1_1_mix_inp2_enum); 841 static const struct snd_kcontrol_new rx_int2_1_mix_inp0_mux = 842 SOC_DAPM_ENUM("rx_int2_1_mix_inp0", rx_int2_1_mix_inp0_enum); 843 static const struct snd_kcontrol_new rx_int2_1_mix_inp1_mux = 844 SOC_DAPM_ENUM("rx_int2_1_mix_inp1", rx_int2_1_mix_inp1_enum); 845 static const struct snd_kcontrol_new rx_int2_1_mix_inp2_mux = 846 SOC_DAPM_ENUM("rx_int2_1_mix_inp2", rx_int2_1_mix_inp2_enum); 847 static const struct snd_kcontrol_new rx_int0_mix2_inp_mux = 848 SOC_DAPM_ENUM("rx_int0_mix2_inp", rx_int0_mix2_inp_enum); 849 static const struct snd_kcontrol_new rx_int1_mix2_inp_mux = 850 SOC_DAPM_ENUM("rx_int1_mix2_inp", rx_int1_mix2_inp_enum); 851 static const struct snd_kcontrol_new rx_int2_mix2_inp_mux = 852 SOC_DAPM_ENUM("rx_int2_mix2_inp", rx_int2_mix2_inp_enum); 853 static const struct snd_kcontrol_new iir0_inp0_mux = 854 SOC_DAPM_ENUM("iir0_inp0", iir0_inp0_enum); 855 static const struct snd_kcontrol_new iir0_inp1_mux = 856 SOC_DAPM_ENUM("iir0_inp1", iir0_inp1_enum); 857 static const struct snd_kcontrol_new iir0_inp2_mux = 858 SOC_DAPM_ENUM("iir0_inp2", iir0_inp2_enum); 859 static const struct snd_kcontrol_new iir0_inp3_mux = 860 SOC_DAPM_ENUM("iir0_inp3", iir0_inp3_enum); 861 static const struct snd_kcontrol_new iir1_inp0_mux = 862 SOC_DAPM_ENUM("iir1_inp0", iir1_inp0_enum); 863 static const struct snd_kcontrol_new iir1_inp1_mux = 864 SOC_DAPM_ENUM("iir1_inp1", iir1_inp1_enum); 865 static const struct snd_kcontrol_new iir1_inp2_mux = 866 SOC_DAPM_ENUM("iir1_inp2", iir1_inp2_enum); 867 static const struct snd_kcontrol_new iir1_inp3_mux = 868 SOC_DAPM_ENUM("iir1_inp3", iir1_inp3_enum); 869 static const struct snd_kcontrol_new rx_int0_1_interp_mux = 870 SOC_DAPM_ENUM("rx_int0_1_interp", rx_int0_1_interp_enum); 871 static const struct snd_kcontrol_new rx_int1_1_interp_mux = 872 SOC_DAPM_ENUM("rx_int1_1_interp", rx_int1_1_interp_enum); 873 static const struct snd_kcontrol_new rx_int2_1_interp_mux = 874 SOC_DAPM_ENUM("rx_int2_1_interp", rx_int2_1_interp_enum); 875 static const struct snd_kcontrol_new rx_int0_2_interp_mux = 876 SOC_DAPM_ENUM("rx_int0_2_interp", rx_int0_2_interp_enum); 877 static const struct snd_kcontrol_new rx_int1_2_interp_mux = 878 SOC_DAPM_ENUM("rx_int1_2_interp", rx_int1_2_interp_enum); 879 static const struct snd_kcontrol_new rx_int2_2_interp_mux = 880 SOC_DAPM_ENUM("rx_int2_2_interp", rx_int2_2_interp_enum); 881 static const struct snd_kcontrol_new rx_mix_tx0_mux = 882 SOC_DAPM_ENUM("RX MIX TX0_MUX Mux", rx_mix_tx0_mux_enum); 883 884 static const struct reg_default rx_defaults[] = { 885 /* RX Macro */ 886 { CDC_RX_TOP_TOP_CFG0, 0x00 }, 887 { CDC_RX_TOP_SWR_CTRL, 0x00 }, 888 { CDC_RX_TOP_DEBUG, 0x00 }, 889 { CDC_RX_TOP_DEBUG_BUS, 0x00 }, 890 { CDC_RX_TOP_DEBUG_EN0, 0x00 }, 891 { CDC_RX_TOP_DEBUG_EN1, 0x00 }, 892 { CDC_RX_TOP_DEBUG_EN2, 0x00 }, 893 { CDC_RX_TOP_HPHL_COMP_WR_LSB, 0x00 }, 894 { CDC_RX_TOP_HPHL_COMP_WR_MSB, 0x00 }, 895 { CDC_RX_TOP_HPHL_COMP_LUT, 0x00 }, 896 { CDC_RX_TOP_HPHL_COMP_RD_LSB, 0x00 }, 897 { CDC_RX_TOP_HPHL_COMP_RD_MSB, 0x00 }, 898 { CDC_RX_TOP_HPHR_COMP_WR_LSB, 0x00 }, 899 { CDC_RX_TOP_HPHR_COMP_WR_MSB, 0x00 }, 900 { CDC_RX_TOP_HPHR_COMP_LUT, 0x00 }, 901 { CDC_RX_TOP_HPHR_COMP_RD_LSB, 0x00 }, 902 { CDC_RX_TOP_HPHR_COMP_RD_MSB, 0x00 }, 903 { CDC_RX_TOP_DSD0_DEBUG_CFG0, 0x11 }, 904 { CDC_RX_TOP_DSD0_DEBUG_CFG1, 0x20 }, 905 { CDC_RX_TOP_DSD0_DEBUG_CFG2, 0x00 }, 906 { CDC_RX_TOP_DSD0_DEBUG_CFG3, 0x00 }, 907 { CDC_RX_TOP_DSD1_DEBUG_CFG0, 0x11 }, 908 { CDC_RX_TOP_DSD1_DEBUG_CFG1, 0x20 }, 909 { CDC_RX_TOP_DSD1_DEBUG_CFG2, 0x00 }, 910 { CDC_RX_TOP_DSD1_DEBUG_CFG3, 0x00 }, 911 { CDC_RX_TOP_RX_I2S_CTL, 0x0C }, 912 { CDC_RX_TOP_TX_I2S2_CTL, 0x0C }, 913 { CDC_RX_TOP_I2S_CLK, 0x0C }, 914 { CDC_RX_TOP_I2S_RESET, 0x00 }, 915 { CDC_RX_TOP_I2S_MUX, 0x00 }, 916 { CDC_RX_CLK_RST_CTRL_MCLK_CONTROL, 0x00 }, 917 { CDC_RX_CLK_RST_CTRL_FS_CNT_CONTROL, 0x00 }, 918 { CDC_RX_CLK_RST_CTRL_SWR_CONTROL, 0x00 }, 919 { CDC_RX_CLK_RST_CTRL_DSD_CONTROL, 0x00 }, 920 { CDC_RX_CLK_RST_CTRL_ASRC_SHARE_CONTROL, 0x08 }, 921 { CDC_RX_SOFTCLIP_CRC, 0x00 }, 922 { CDC_RX_SOFTCLIP_SOFTCLIP_CTRL, 0x38 }, 923 { CDC_RX_INP_MUX_RX_INT0_CFG0, 0x00 }, 924 { CDC_RX_INP_MUX_RX_INT0_CFG1, 0x00 }, 925 { CDC_RX_INP_MUX_RX_INT1_CFG0, 0x00 }, 926 { CDC_RX_INP_MUX_RX_INT1_CFG1, 0x00 }, 927 { CDC_RX_INP_MUX_RX_INT2_CFG0, 0x00 }, 928 { CDC_RX_INP_MUX_RX_INT2_CFG1, 0x00 }, 929 { CDC_RX_INP_MUX_RX_MIX_CFG4, 0x00 }, 930 { CDC_RX_INP_MUX_RX_MIX_CFG5, 0x00 }, 931 { CDC_RX_INP_MUX_SIDETONE_SRC_CFG0, 0x00 }, 932 { CDC_RX_CLSH_CRC, 0x00 }, 933 { CDC_RX_CLSH_DLY_CTRL, 0x03 }, 934 { CDC_RX_CLSH_DECAY_CTRL, 0x02 }, 935 { CDC_RX_CLSH_HPH_V_PA, 0x1C }, 936 { CDC_RX_CLSH_EAR_V_PA, 0x39 }, 937 { CDC_RX_CLSH_HPH_V_HD, 0x0C }, 938 { CDC_RX_CLSH_EAR_V_HD, 0x0C }, 939 { CDC_RX_CLSH_K1_MSB, 0x01 }, 940 { CDC_RX_CLSH_K1_LSB, 0x00 }, 941 { CDC_RX_CLSH_K2_MSB, 0x00 }, 942 { CDC_RX_CLSH_K2_LSB, 0x80 }, 943 { CDC_RX_CLSH_IDLE_CTRL, 0x00 }, 944 { CDC_RX_CLSH_IDLE_HPH, 0x00 }, 945 { CDC_RX_CLSH_IDLE_EAR, 0x00 }, 946 { CDC_RX_CLSH_TEST0, 0x07 }, 947 { CDC_RX_CLSH_TEST1, 0x00 }, 948 { CDC_RX_CLSH_OVR_VREF, 0x00 }, 949 { CDC_RX_CLSH_CLSG_CTL, 0x02 }, 950 { CDC_RX_CLSH_CLSG_CFG1, 0x9A }, 951 { CDC_RX_CLSH_CLSG_CFG2, 0x10 }, 952 { CDC_RX_BCL_VBAT_PATH_CTL, 0x00 }, 953 { CDC_RX_BCL_VBAT_CFG, 0x10 }, 954 { CDC_RX_BCL_VBAT_ADC_CAL1, 0x00 }, 955 { CDC_RX_BCL_VBAT_ADC_CAL2, 0x00 }, 956 { CDC_RX_BCL_VBAT_ADC_CAL3, 0x04 }, 957 { CDC_RX_BCL_VBAT_PK_EST1, 0xE0 }, 958 { CDC_RX_BCL_VBAT_PK_EST2, 0x01 }, 959 { CDC_RX_BCL_VBAT_PK_EST3, 0x40 }, 960 { CDC_RX_BCL_VBAT_RF_PROC1, 0x2A }, 961 { CDC_RX_BCL_VBAT_RF_PROC1, 0x00 }, 962 { CDC_RX_BCL_VBAT_TAC1, 0x00 }, 963 { CDC_RX_BCL_VBAT_TAC2, 0x18 }, 964 { CDC_RX_BCL_VBAT_TAC3, 0x18 }, 965 { CDC_RX_BCL_VBAT_TAC4, 0x03 }, 966 { CDC_RX_BCL_VBAT_GAIN_UPD1, 0x01 }, 967 { CDC_RX_BCL_VBAT_GAIN_UPD2, 0x00 }, 968 { CDC_RX_BCL_VBAT_GAIN_UPD3, 0x00 }, 969 { CDC_RX_BCL_VBAT_GAIN_UPD4, 0x64 }, 970 { CDC_RX_BCL_VBAT_GAIN_UPD5, 0x01 }, 971 { CDC_RX_BCL_VBAT_DEBUG1, 0x00 }, 972 { CDC_RX_BCL_VBAT_GAIN_UPD_MON, 0x00 }, 973 { CDC_RX_BCL_VBAT_GAIN_MON_VAL, 0x00 }, 974 { CDC_RX_BCL_VBAT_BAN, 0x0C }, 975 { CDC_RX_BCL_VBAT_BCL_GAIN_UPD1, 0x00 }, 976 { CDC_RX_BCL_VBAT_BCL_GAIN_UPD2, 0x77 }, 977 { CDC_RX_BCL_VBAT_BCL_GAIN_UPD3, 0x01 }, 978 { CDC_RX_BCL_VBAT_BCL_GAIN_UPD4, 0x00 }, 979 { CDC_RX_BCL_VBAT_BCL_GAIN_UPD5, 0x4B }, 980 { CDC_RX_BCL_VBAT_BCL_GAIN_UPD6, 0x00 }, 981 { CDC_RX_BCL_VBAT_BCL_GAIN_UPD7, 0x01 }, 982 { CDC_RX_BCL_VBAT_BCL_GAIN_UPD8, 0x00 }, 983 { CDC_RX_BCL_VBAT_BCL_GAIN_UPD9, 0x00 }, 984 { CDC_RX_BCL_VBAT_ATTN1, 0x04 }, 985 { CDC_RX_BCL_VBAT_ATTN2, 0x08 }, 986 { CDC_RX_BCL_VBAT_ATTN3, 0x0C }, 987 { CDC_RX_BCL_VBAT_DECODE_CTL1, 0xE0 }, 988 { CDC_RX_BCL_VBAT_DECODE_CTL2, 0x00 }, 989 { CDC_RX_BCL_VBAT_DECODE_CFG1, 0x00 }, 990 { CDC_RX_BCL_VBAT_DECODE_CFG2, 0x00 }, 991 { CDC_RX_BCL_VBAT_DECODE_CFG3, 0x00 }, 992 { CDC_RX_BCL_VBAT_DECODE_CFG4, 0x00 }, 993 { CDC_RX_BCL_VBAT_DECODE_ST, 0x00 }, 994 { CDC_RX_INTR_CTRL_CFG, 0x00 }, 995 { CDC_RX_INTR_CTRL_CLR_COMMIT, 0x00 }, 996 { CDC_RX_INTR_CTRL_PIN1_MASK0, 0xFF }, 997 { CDC_RX_INTR_CTRL_PIN1_STATUS0, 0x00 }, 998 { CDC_RX_INTR_CTRL_PIN1_CLEAR0, 0x00 }, 999 { CDC_RX_INTR_CTRL_PIN2_MASK0, 0xFF }, 1000 { CDC_RX_INTR_CTRL_PIN2_STATUS0, 0x00 }, 1001 { CDC_RX_INTR_CTRL_PIN2_CLEAR0, 0x00 }, 1002 { CDC_RX_INTR_CTRL_LEVEL0, 0x00 }, 1003 { CDC_RX_INTR_CTRL_BYPASS0, 0x00 }, 1004 { CDC_RX_INTR_CTRL_SET0, 0x00 }, 1005 { CDC_RX_RX0_RX_PATH_CTL, 0x04 }, 1006 { CDC_RX_RX0_RX_PATH_CFG0, 0x00 }, 1007 { CDC_RX_RX0_RX_PATH_CFG1, 0x64 }, 1008 { CDC_RX_RX0_RX_PATH_CFG2, 0x8F }, 1009 { CDC_RX_RX0_RX_PATH_CFG3, 0x00 }, 1010 { CDC_RX_RX0_RX_VOL_CTL, 0x00 }, 1011 { CDC_RX_RX0_RX_PATH_MIX_CTL, 0x04 }, 1012 { CDC_RX_RX0_RX_PATH_MIX_CFG, 0x7E }, 1013 { CDC_RX_RX0_RX_VOL_MIX_CTL, 0x00 }, 1014 { CDC_RX_RX0_RX_PATH_SEC1, 0x08 }, 1015 { CDC_RX_RX0_RX_PATH_SEC2, 0x00 }, 1016 { CDC_RX_RX0_RX_PATH_SEC3, 0x00 }, 1017 { CDC_RX_RX0_RX_PATH_SEC4, 0x00 }, 1018 { CDC_RX_RX0_RX_PATH_SEC7, 0x00 }, 1019 { CDC_RX_RX0_RX_PATH_MIX_SEC0, 0x08 }, 1020 { CDC_RX_RX0_RX_PATH_MIX_SEC1, 0x00 }, 1021 { CDC_RX_RX0_RX_PATH_DSM_CTL, 0x08 }, 1022 { CDC_RX_RX0_RX_PATH_DSM_DATA1, 0x00 }, 1023 { CDC_RX_RX0_RX_PATH_DSM_DATA2, 0x00 }, 1024 { CDC_RX_RX0_RX_PATH_DSM_DATA3, 0x00 }, 1025 { CDC_RX_RX0_RX_PATH_DSM_DATA4, 0x55 }, 1026 { CDC_RX_RX0_RX_PATH_DSM_DATA5, 0x55 }, 1027 { CDC_RX_RX0_RX_PATH_DSM_DATA6, 0x55 }, 1028 { CDC_RX_IDLE_DETECT_PATH_CTL, 0x00 }, 1029 { CDC_RX_IDLE_DETECT_CFG0, 0x07 }, 1030 { CDC_RX_IDLE_DETECT_CFG1, 0x3C }, 1031 { CDC_RX_IDLE_DETECT_CFG2, 0x00 }, 1032 { CDC_RX_IDLE_DETECT_CFG3, 0x00 }, 1033 { CDC_RX_COMPANDER0_CTL0, 0x60 }, 1034 { CDC_RX_COMPANDER0_CTL1, 0xDB }, 1035 { CDC_RX_COMPANDER0_CTL2, 0xFF }, 1036 { CDC_RX_COMPANDER0_CTL3, 0x35 }, 1037 { CDC_RX_COMPANDER0_CTL4, 0xFF }, 1038 { CDC_RX_COMPANDER0_CTL5, 0x00 }, 1039 { CDC_RX_COMPANDER0_CTL6, 0x01 }, 1040 { CDC_RX_COMPANDER0_CTL7, 0x28 }, 1041 { CDC_RX_COMPANDER1_CTL0, 0x60 }, 1042 { CDC_RX_COMPANDER1_CTL1, 0xDB }, 1043 { CDC_RX_COMPANDER1_CTL2, 0xFF }, 1044 { CDC_RX_COMPANDER1_CTL3, 0x35 }, 1045 { CDC_RX_COMPANDER1_CTL4, 0xFF }, 1046 { CDC_RX_COMPANDER1_CTL5, 0x00 }, 1047 { CDC_RX_COMPANDER1_CTL6, 0x01 }, 1048 { CDC_RX_COMPANDER1_CTL7, 0x28 }, 1049 { CDC_RX_SIDETONE_IIR0_IIR_PATH_CTL, 0x00 }, 1050 { CDC_RX_SIDETONE_IIR0_IIR_GAIN_B1_CTL, 0x00 }, 1051 { CDC_RX_SIDETONE_IIR0_IIR_GAIN_B2_CTL, 0x00 }, 1052 { CDC_RX_SIDETONE_IIR0_IIR_GAIN_B3_CTL, 0x00 }, 1053 { CDC_RX_SIDETONE_IIR0_IIR_GAIN_B4_CTL, 0x00 }, 1054 { CDC_RX_SIDETONE_IIR0_IIR_GAIN_B5_CTL, 0x00 }, 1055 { CDC_RX_SIDETONE_IIR0_IIR_GAIN_B6_CTL, 0x00 }, 1056 { CDC_RX_SIDETONE_IIR0_IIR_GAIN_B7_CTL, 0x00 }, 1057 { CDC_RX_SIDETONE_IIR0_IIR_GAIN_B8_CTL, 0x00 }, 1058 { CDC_RX_SIDETONE_IIR0_IIR_CTL, 0x40 }, 1059 { CDC_RX_SIDETONE_IIR0_IIR_GAIN_TIMER_CTL, 0x00 }, 1060 { CDC_RX_SIDETONE_IIR0_IIR_COEF_B1_CTL, 0x00 }, 1061 { CDC_RX_SIDETONE_IIR0_IIR_COEF_B2_CTL, 0x00 }, 1062 { CDC_RX_SIDETONE_IIR1_IIR_PATH_CTL, 0x00 }, 1063 { CDC_RX_SIDETONE_IIR1_IIR_GAIN_B1_CTL, 0x00 }, 1064 { CDC_RX_SIDETONE_IIR1_IIR_GAIN_B2_CTL, 0x00 }, 1065 { CDC_RX_SIDETONE_IIR1_IIR_GAIN_B3_CTL, 0x00 }, 1066 { CDC_RX_SIDETONE_IIR1_IIR_GAIN_B4_CTL, 0x00 }, 1067 { CDC_RX_SIDETONE_IIR1_IIR_GAIN_B5_CTL, 0x00 }, 1068 { CDC_RX_SIDETONE_IIR1_IIR_GAIN_B6_CTL, 0x00 }, 1069 { CDC_RX_SIDETONE_IIR1_IIR_GAIN_B7_CTL, 0x00 }, 1070 { CDC_RX_SIDETONE_IIR1_IIR_GAIN_B8_CTL, 0x00 }, 1071 { CDC_RX_SIDETONE_IIR1_IIR_CTL, 0x40 }, 1072 { CDC_RX_SIDETONE_IIR1_IIR_GAIN_TIMER_CTL, 0x00 }, 1073 { CDC_RX_SIDETONE_IIR1_IIR_COEF_B1_CTL, 0x00 }, 1074 { CDC_RX_SIDETONE_IIR1_IIR_COEF_B2_CTL, 0x00 }, 1075 { CDC_RX_IIR_INP_MUX_IIR0_MIX_CFG0, 0x00 }, 1076 { CDC_RX_IIR_INP_MUX_IIR0_MIX_CFG1, 0x00 }, 1077 { CDC_RX_IIR_INP_MUX_IIR0_MIX_CFG2, 0x00 }, 1078 { CDC_RX_IIR_INP_MUX_IIR0_MIX_CFG3, 0x00 }, 1079 { CDC_RX_IIR_INP_MUX_IIR1_MIX_CFG0, 0x00 }, 1080 { CDC_RX_IIR_INP_MUX_IIR1_MIX_CFG1, 0x00 }, 1081 { CDC_RX_IIR_INP_MUX_IIR1_MIX_CFG2, 0x00 }, 1082 { CDC_RX_IIR_INP_MUX_IIR1_MIX_CFG3, 0x00 }, 1083 { CDC_RX_SIDETONE_SRC0_ST_SRC_PATH_CTL, 0x04 }, 1084 { CDC_RX_SIDETONE_SRC0_ST_SRC_PATH_CFG1, 0x00 }, 1085 { CDC_RX_SIDETONE_SRC1_ST_SRC_PATH_CTL, 0x04 }, 1086 { CDC_RX_SIDETONE_SRC1_ST_SRC_PATH_CFG1, 0x00 }, 1087 { CDC_RX_EC_REF_HQ0_EC_REF_HQ_PATH_CTL, 0x00 }, 1088 { CDC_RX_EC_REF_HQ0_EC_REF_HQ_CFG0, 0x01 }, 1089 { CDC_RX_EC_REF_HQ1_EC_REF_HQ_PATH_CTL, 0x00 }, 1090 { CDC_RX_EC_REF_HQ1_EC_REF_HQ_CFG0, 0x01 }, 1091 { CDC_RX_EC_REF_HQ2_EC_REF_HQ_PATH_CTL, 0x00 }, 1092 { CDC_RX_EC_REF_HQ2_EC_REF_HQ_CFG0, 0x01 }, 1093 { CDC_RX_EC_ASRC0_CLK_RST_CTL, 0x00 }, 1094 { CDC_RX_EC_ASRC0_CTL0, 0x00 }, 1095 { CDC_RX_EC_ASRC0_CTL1, 0x00 }, 1096 { CDC_RX_EC_ASRC0_FIFO_CTL, 0xA8 }, 1097 { CDC_RX_EC_ASRC0_STATUS_FMIN_CNTR_LSB, 0x00 }, 1098 { CDC_RX_EC_ASRC0_STATUS_FMIN_CNTR_MSB, 0x00 }, 1099 { CDC_RX_EC_ASRC0_STATUS_FMAX_CNTR_LSB, 0x00 }, 1100 { CDC_RX_EC_ASRC0_STATUS_FMAX_CNTR_MSB, 0x00 }, 1101 { CDC_RX_EC_ASRC0_STATUS_FIFO, 0x00 }, 1102 { CDC_RX_EC_ASRC1_CLK_RST_CTL, 0x00 }, 1103 { CDC_RX_EC_ASRC1_CTL0, 0x00 }, 1104 { CDC_RX_EC_ASRC1_CTL1, 0x00 }, 1105 { CDC_RX_EC_ASRC1_FIFO_CTL, 0xA8 }, 1106 { CDC_RX_EC_ASRC1_STATUS_FMIN_CNTR_LSB, 0x00 }, 1107 { CDC_RX_EC_ASRC1_STATUS_FMIN_CNTR_MSB, 0x00 }, 1108 { CDC_RX_EC_ASRC1_STATUS_FMAX_CNTR_LSB, 0x00 }, 1109 { CDC_RX_EC_ASRC1_STATUS_FMAX_CNTR_MSB, 0x00 }, 1110 { CDC_RX_EC_ASRC1_STATUS_FIFO, 0x00 }, 1111 { CDC_RX_EC_ASRC2_CLK_RST_CTL, 0x00 }, 1112 { CDC_RX_EC_ASRC2_CTL0, 0x00 }, 1113 { CDC_RX_EC_ASRC2_CTL1, 0x00 }, 1114 { CDC_RX_EC_ASRC2_FIFO_CTL, 0xA8 }, 1115 { CDC_RX_EC_ASRC2_STATUS_FMIN_CNTR_LSB, 0x00 }, 1116 { CDC_RX_EC_ASRC2_STATUS_FMIN_CNTR_MSB, 0x00 }, 1117 { CDC_RX_EC_ASRC2_STATUS_FMAX_CNTR_LSB, 0x00 }, 1118 { CDC_RX_EC_ASRC2_STATUS_FMAX_CNTR_MSB, 0x00 }, 1119 { CDC_RX_EC_ASRC2_STATUS_FIFO, 0x00 }, 1120 { CDC_RX_DSD0_PATH_CTL, 0x00 }, 1121 { CDC_RX_DSD0_CFG0, 0x00 }, 1122 { CDC_RX_DSD0_CFG1, 0x62 }, 1123 { CDC_RX_DSD0_CFG2, 0x96 }, 1124 { CDC_RX_DSD1_PATH_CTL, 0x00 }, 1125 { CDC_RX_DSD1_CFG0, 0x00 }, 1126 { CDC_RX_DSD1_CFG1, 0x62 }, 1127 { CDC_RX_DSD1_CFG2, 0x96 }, 1128 }; 1129 1130 static const struct reg_default rx_2_5_defaults[] = { 1131 { CDC_2_5_RX_RX1_RX_PATH_CTL, 0x04 }, 1132 { CDC_2_5_RX_RX1_RX_PATH_CFG0, 0x00 }, 1133 { CDC_2_5_RX_RX1_RX_PATH_CFG1, 0x64 }, 1134 { CDC_2_5_RX_RX1_RX_PATH_CFG2, 0x8F }, 1135 { CDC_2_5_RX_RX1_RX_PATH_CFG3, 0x00 }, 1136 { CDC_2_5_RX_RX1_RX_VOL_CTL, 0x00 }, 1137 { CDC_2_5_RX_RX1_RX_PATH_MIX_CTL, 0x04 }, 1138 { CDC_2_5_RX_RX1_RX_PATH_MIX_CFG, 0x7E }, 1139 { CDC_2_5_RX_RX1_RX_VOL_MIX_CTL, 0x00 }, 1140 { CDC_2_5_RX_RX1_RX_PATH_SEC1, 0x08 }, 1141 { CDC_2_5_RX_RX1_RX_PATH_SEC2, 0x00 }, 1142 { CDC_2_5_RX_RX1_RX_PATH_SEC3, 0x00 }, 1143 { CDC_2_5_RX_RX1_RX_PATH_SEC4, 0x00 }, 1144 { CDC_2_5_RX_RX1_RX_PATH_SEC7, 0x00 }, 1145 { CDC_2_5_RX_RX1_RX_PATH_MIX_SEC0, 0x08 }, 1146 { CDC_2_5_RX_RX1_RX_PATH_MIX_SEC1, 0x00 }, 1147 { CDC_2_5_RX_RX1_RX_PATH_DSM_CTL, 0x08 }, 1148 { CDC_2_5_RX_RX1_RX_PATH_DSM_DATA1, 0x00 }, 1149 { CDC_2_5_RX_RX1_RX_PATH_DSM_DATA2, 0x00 }, 1150 { CDC_2_5_RX_RX1_RX_PATH_DSM_DATA3, 0x00 }, 1151 { CDC_2_5_RX_RX1_RX_PATH_DSM_DATA4, 0x55 }, 1152 { CDC_2_5_RX_RX1_RX_PATH_DSM_DATA5, 0x55 }, 1153 { CDC_2_5_RX_RX1_RX_PATH_DSM_DATA6, 0x55 }, 1154 { CDC_2_5_RX_RX2_RX_PATH_CTL, 0x04 }, 1155 { CDC_2_5_RX_RX2_RX_PATH_CFG0, 0x00 }, 1156 { CDC_2_5_RX_RX2_RX_PATH_CFG1, 0x64 }, 1157 { CDC_2_5_RX_RX2_RX_PATH_CFG2, 0x8F }, 1158 { CDC_2_5_RX_RX2_RX_PATH_CFG3, 0x00 }, 1159 { CDC_2_5_RX_RX2_RX_VOL_CTL, 0x00 }, 1160 { CDC_2_5_RX_RX2_RX_PATH_MIX_CTL, 0x04 }, 1161 { CDC_2_5_RX_RX2_RX_PATH_MIX_CFG, 0x7E }, 1162 { CDC_2_5_RX_RX2_RX_VOL_MIX_CTL, 0x00 }, 1163 { CDC_2_5_RX_RX2_RX_PATH_SEC0, 0x04 }, 1164 { CDC_2_5_RX_RX2_RX_PATH_SEC1, 0x08 }, 1165 { CDC_2_5_RX_RX2_RX_PATH_SEC2, 0x00 }, 1166 { CDC_2_5_RX_RX2_RX_PATH_SEC3, 0x00 }, 1167 { CDC_2_5_RX_RX2_RX_PATH_SEC4, 0x00 }, 1168 { CDC_2_5_RX_RX2_RX_PATH_SEC5, 0x00 }, 1169 { CDC_2_5_RX_RX2_RX_PATH_SEC6, 0x00 }, 1170 { CDC_2_5_RX_RX2_RX_PATH_SEC7, 0x00 }, 1171 { CDC_2_5_RX_RX2_RX_PATH_MIX_SEC0, 0x08 }, 1172 { CDC_2_5_RX_RX2_RX_PATH_MIX_SEC1, 0x00 }, 1173 { CDC_2_5_RX_RX2_RX_PATH_DSM_CTL, 0x00 }, 1174 }; 1175 1176 static const struct reg_default rx_pre_2_5_defaults[] = { 1177 { CDC_RX_RX1_RX_PATH_CTL, 0x04 }, 1178 { CDC_RX_RX1_RX_PATH_CFG0, 0x00 }, 1179 { CDC_RX_RX1_RX_PATH_CFG1, 0x64 }, 1180 { CDC_RX_RX1_RX_PATH_CFG2, 0x8F }, 1181 { CDC_RX_RX1_RX_PATH_CFG3, 0x00 }, 1182 { CDC_RX_RX1_RX_VOL_CTL, 0x00 }, 1183 { CDC_RX_RX1_RX_PATH_MIX_CTL, 0x04 }, 1184 { CDC_RX_RX1_RX_PATH_MIX_CFG, 0x7E }, 1185 { CDC_RX_RX1_RX_VOL_MIX_CTL, 0x00 }, 1186 { CDC_RX_RX1_RX_PATH_SEC1, 0x08 }, 1187 { CDC_RX_RX1_RX_PATH_SEC2, 0x00 }, 1188 { CDC_RX_RX1_RX_PATH_SEC3, 0x00 }, 1189 { CDC_RX_RX1_RX_PATH_SEC4, 0x00 }, 1190 { CDC_RX_RX1_RX_PATH_SEC7, 0x00 }, 1191 { CDC_RX_RX1_RX_PATH_MIX_SEC0, 0x08 }, 1192 { CDC_RX_RX1_RX_PATH_MIX_SEC1, 0x00 }, 1193 { CDC_RX_RX1_RX_PATH_DSM_CTL, 0x08 }, 1194 { CDC_RX_RX1_RX_PATH_DSM_DATA1, 0x00 }, 1195 { CDC_RX_RX1_RX_PATH_DSM_DATA2, 0x00 }, 1196 { CDC_RX_RX1_RX_PATH_DSM_DATA3, 0x00 }, 1197 { CDC_RX_RX1_RX_PATH_DSM_DATA4, 0x55 }, 1198 { CDC_RX_RX1_RX_PATH_DSM_DATA5, 0x55 }, 1199 { CDC_RX_RX1_RX_PATH_DSM_DATA6, 0x55 }, 1200 { CDC_RX_RX2_RX_PATH_CTL, 0x04 }, 1201 { CDC_RX_RX2_RX_PATH_CFG0, 0x00 }, 1202 { CDC_RX_RX2_RX_PATH_CFG1, 0x64 }, 1203 { CDC_RX_RX2_RX_PATH_CFG2, 0x8F }, 1204 { CDC_RX_RX2_RX_PATH_CFG3, 0x00 }, 1205 { CDC_RX_RX2_RX_VOL_CTL, 0x00 }, 1206 { CDC_RX_RX2_RX_PATH_MIX_CTL, 0x04 }, 1207 { CDC_RX_RX2_RX_PATH_MIX_CFG, 0x7E }, 1208 { CDC_RX_RX2_RX_VOL_MIX_CTL, 0x00 }, 1209 { CDC_RX_RX2_RX_PATH_SEC0, 0x04 }, 1210 { CDC_RX_RX2_RX_PATH_SEC1, 0x08 }, 1211 { CDC_RX_RX2_RX_PATH_SEC2, 0x00 }, 1212 { CDC_RX_RX2_RX_PATH_SEC3, 0x00 }, 1213 { CDC_RX_RX2_RX_PATH_SEC4, 0x00 }, 1214 { CDC_RX_RX2_RX_PATH_SEC5, 0x00 }, 1215 { CDC_RX_RX2_RX_PATH_SEC6, 0x00 }, 1216 { CDC_RX_RX2_RX_PATH_SEC7, 0x00 }, 1217 { CDC_RX_RX2_RX_PATH_MIX_SEC0, 0x08 }, 1218 { CDC_RX_RX2_RX_PATH_MIX_SEC1, 0x00 }, 1219 { CDC_RX_RX2_RX_PATH_DSM_CTL, 0x00 }, 1220 1221 }; 1222 1223 static bool rx_is_wronly_register(struct device *dev, 1224 unsigned int reg) 1225 { 1226 switch (reg) { 1227 case CDC_RX_BCL_VBAT_GAIN_UPD_MON: 1228 case CDC_RX_INTR_CTRL_CLR_COMMIT: 1229 case CDC_RX_INTR_CTRL_PIN1_CLEAR0: 1230 case CDC_RX_INTR_CTRL_PIN2_CLEAR0: 1231 return true; 1232 } 1233 1234 return false; 1235 } 1236 1237 static bool rx_is_volatile_register(struct device *dev, unsigned int reg) 1238 { 1239 /* Update volatile list for rx/tx macros */ 1240 switch (reg) { 1241 case CDC_RX_TOP_HPHL_COMP_RD_LSB: 1242 case CDC_RX_TOP_HPHL_COMP_WR_LSB: 1243 case CDC_RX_TOP_HPHL_COMP_RD_MSB: 1244 case CDC_RX_TOP_HPHL_COMP_WR_MSB: 1245 case CDC_RX_TOP_HPHR_COMP_RD_LSB: 1246 case CDC_RX_TOP_HPHR_COMP_WR_LSB: 1247 case CDC_RX_TOP_HPHR_COMP_RD_MSB: 1248 case CDC_RX_TOP_HPHR_COMP_WR_MSB: 1249 case CDC_RX_TOP_DSD0_DEBUG_CFG2: 1250 case CDC_RX_TOP_DSD1_DEBUG_CFG2: 1251 case CDC_RX_BCL_VBAT_GAIN_MON_VAL: 1252 case CDC_RX_BCL_VBAT_DECODE_ST: 1253 case CDC_RX_INTR_CTRL_PIN1_STATUS0: 1254 case CDC_RX_INTR_CTRL_PIN2_STATUS0: 1255 case CDC_RX_COMPANDER0_CTL6: 1256 case CDC_RX_COMPANDER1_CTL6: 1257 case CDC_RX_EC_ASRC0_STATUS_FMIN_CNTR_LSB: 1258 case CDC_RX_EC_ASRC0_STATUS_FMIN_CNTR_MSB: 1259 case CDC_RX_EC_ASRC0_STATUS_FMAX_CNTR_LSB: 1260 case CDC_RX_EC_ASRC0_STATUS_FMAX_CNTR_MSB: 1261 case CDC_RX_EC_ASRC0_STATUS_FIFO: 1262 case CDC_RX_EC_ASRC1_STATUS_FMIN_CNTR_LSB: 1263 case CDC_RX_EC_ASRC1_STATUS_FMIN_CNTR_MSB: 1264 case CDC_RX_EC_ASRC1_STATUS_FMAX_CNTR_LSB: 1265 case CDC_RX_EC_ASRC1_STATUS_FMAX_CNTR_MSB: 1266 case CDC_RX_EC_ASRC1_STATUS_FIFO: 1267 case CDC_RX_EC_ASRC2_STATUS_FMIN_CNTR_LSB: 1268 case CDC_RX_EC_ASRC2_STATUS_FMIN_CNTR_MSB: 1269 case CDC_RX_EC_ASRC2_STATUS_FMAX_CNTR_LSB: 1270 case CDC_RX_EC_ASRC2_STATUS_FMAX_CNTR_MSB: 1271 case CDC_RX_EC_ASRC2_STATUS_FIFO: 1272 return true; 1273 } 1274 return false; 1275 } 1276 1277 static bool rx_pre_2_5_is_rw_register(struct device *dev, unsigned int reg) 1278 { 1279 switch (reg) { 1280 case CDC_RX_RX1_RX_PATH_CTL: 1281 case CDC_RX_RX1_RX_PATH_CFG0: 1282 case CDC_RX_RX1_RX_PATH_CFG1: 1283 case CDC_RX_RX1_RX_PATH_CFG2: 1284 case CDC_RX_RX1_RX_PATH_CFG3: 1285 case CDC_RX_RX1_RX_VOL_CTL: 1286 case CDC_RX_RX1_RX_PATH_MIX_CTL: 1287 case CDC_RX_RX1_RX_PATH_MIX_CFG: 1288 case CDC_RX_RX1_RX_VOL_MIX_CTL: 1289 case CDC_RX_RX1_RX_PATH_SEC1: 1290 case CDC_RX_RX1_RX_PATH_SEC2: 1291 case CDC_RX_RX1_RX_PATH_SEC3: 1292 case CDC_RX_RX1_RX_PATH_SEC4: 1293 case CDC_RX_RX1_RX_PATH_SEC7: 1294 case CDC_RX_RX1_RX_PATH_MIX_SEC0: 1295 case CDC_RX_RX1_RX_PATH_MIX_SEC1: 1296 case CDC_RX_RX1_RX_PATH_DSM_CTL: 1297 case CDC_RX_RX1_RX_PATH_DSM_DATA1: 1298 case CDC_RX_RX1_RX_PATH_DSM_DATA2: 1299 case CDC_RX_RX1_RX_PATH_DSM_DATA3: 1300 case CDC_RX_RX1_RX_PATH_DSM_DATA4: 1301 case CDC_RX_RX1_RX_PATH_DSM_DATA5: 1302 case CDC_RX_RX1_RX_PATH_DSM_DATA6: 1303 case CDC_RX_RX2_RX_PATH_CTL: 1304 case CDC_RX_RX2_RX_PATH_CFG0: 1305 case CDC_RX_RX2_RX_PATH_CFG1: 1306 case CDC_RX_RX2_RX_PATH_CFG2: 1307 case CDC_RX_RX2_RX_PATH_CFG3: 1308 case CDC_RX_RX2_RX_VOL_CTL: 1309 case CDC_RX_RX2_RX_PATH_MIX_CTL: 1310 case CDC_RX_RX2_RX_PATH_MIX_CFG: 1311 case CDC_RX_RX2_RX_VOL_MIX_CTL: 1312 case CDC_RX_RX2_RX_PATH_SEC0: 1313 case CDC_RX_RX2_RX_PATH_SEC1: 1314 case CDC_RX_RX2_RX_PATH_SEC2: 1315 case CDC_RX_RX2_RX_PATH_SEC3: 1316 case CDC_RX_RX2_RX_PATH_SEC4: 1317 case CDC_RX_RX2_RX_PATH_SEC5: 1318 case CDC_RX_RX2_RX_PATH_SEC6: 1319 case CDC_RX_RX2_RX_PATH_SEC7: 1320 case CDC_RX_RX2_RX_PATH_MIX_SEC0: 1321 case CDC_RX_RX2_RX_PATH_MIX_SEC1: 1322 case CDC_RX_RX2_RX_PATH_DSM_CTL: 1323 return true; 1324 } 1325 1326 return false; 1327 } 1328 1329 static bool rx_2_5_is_rw_register(struct device *dev, unsigned int reg) 1330 { 1331 switch (reg) { 1332 case CDC_2_5_RX_RX1_RX_PATH_CTL: 1333 case CDC_2_5_RX_RX1_RX_PATH_CFG0: 1334 case CDC_2_5_RX_RX1_RX_PATH_CFG1: 1335 case CDC_2_5_RX_RX1_RX_PATH_CFG2: 1336 case CDC_2_5_RX_RX1_RX_PATH_CFG3: 1337 case CDC_2_5_RX_RX1_RX_VOL_CTL: 1338 case CDC_2_5_RX_RX1_RX_PATH_MIX_CTL: 1339 case CDC_2_5_RX_RX1_RX_PATH_MIX_CFG: 1340 case CDC_2_5_RX_RX1_RX_VOL_MIX_CTL: 1341 case CDC_2_5_RX_RX1_RX_PATH_SEC1: 1342 case CDC_2_5_RX_RX1_RX_PATH_SEC2: 1343 case CDC_2_5_RX_RX1_RX_PATH_SEC3: 1344 case CDC_2_5_RX_RX1_RX_PATH_SEC4: 1345 case CDC_2_5_RX_RX1_RX_PATH_SEC7: 1346 case CDC_2_5_RX_RX1_RX_PATH_MIX_SEC0: 1347 case CDC_2_5_RX_RX1_RX_PATH_MIX_SEC1: 1348 case CDC_2_5_RX_RX1_RX_PATH_DSM_CTL: 1349 case CDC_2_5_RX_RX1_RX_PATH_DSM_DATA1: 1350 case CDC_2_5_RX_RX1_RX_PATH_DSM_DATA2: 1351 case CDC_2_5_RX_RX1_RX_PATH_DSM_DATA3: 1352 case CDC_2_5_RX_RX1_RX_PATH_DSM_DATA4: 1353 case CDC_2_5_RX_RX1_RX_PATH_DSM_DATA5: 1354 case CDC_2_5_RX_RX1_RX_PATH_DSM_DATA6: 1355 case CDC_2_5_RX_RX2_RX_PATH_CTL: 1356 case CDC_2_5_RX_RX2_RX_PATH_CFG0: 1357 case CDC_2_5_RX_RX2_RX_PATH_CFG1: 1358 case CDC_2_5_RX_RX2_RX_PATH_CFG2: 1359 case CDC_2_5_RX_RX2_RX_PATH_CFG3: 1360 case CDC_2_5_RX_RX2_RX_VOL_CTL: 1361 case CDC_2_5_RX_RX2_RX_PATH_MIX_CTL: 1362 case CDC_2_5_RX_RX2_RX_PATH_MIX_CFG: 1363 case CDC_2_5_RX_RX2_RX_VOL_MIX_CTL: 1364 case CDC_2_5_RX_RX2_RX_PATH_SEC0: 1365 case CDC_2_5_RX_RX2_RX_PATH_SEC1: 1366 case CDC_2_5_RX_RX2_RX_PATH_SEC2: 1367 case CDC_2_5_RX_RX2_RX_PATH_SEC3: 1368 case CDC_2_5_RX_RX2_RX_PATH_SEC4: 1369 case CDC_2_5_RX_RX2_RX_PATH_SEC5: 1370 case CDC_2_5_RX_RX2_RX_PATH_SEC6: 1371 case CDC_2_5_RX_RX2_RX_PATH_SEC7: 1372 case CDC_2_5_RX_RX2_RX_PATH_MIX_SEC0: 1373 case CDC_2_5_RX_RX2_RX_PATH_MIX_SEC1: 1374 case CDC_2_5_RX_RX2_RX_PATH_DSM_CTL: 1375 return true; 1376 } 1377 1378 return false; 1379 } 1380 1381 static bool rx_is_rw_register(struct device *dev, unsigned int reg) 1382 { 1383 struct rx_macro *rx = dev_get_drvdata(dev); 1384 1385 switch (reg) { 1386 case CDC_RX_TOP_TOP_CFG0: 1387 case CDC_RX_TOP_SWR_CTRL: 1388 case CDC_RX_TOP_DEBUG: 1389 case CDC_RX_TOP_DEBUG_BUS: 1390 case CDC_RX_TOP_DEBUG_EN0: 1391 case CDC_RX_TOP_DEBUG_EN1: 1392 case CDC_RX_TOP_DEBUG_EN2: 1393 case CDC_RX_TOP_HPHL_COMP_WR_LSB: 1394 case CDC_RX_TOP_HPHL_COMP_WR_MSB: 1395 case CDC_RX_TOP_HPHL_COMP_LUT: 1396 case CDC_RX_TOP_HPHR_COMP_WR_LSB: 1397 case CDC_RX_TOP_HPHR_COMP_WR_MSB: 1398 case CDC_RX_TOP_HPHR_COMP_LUT: 1399 case CDC_RX_TOP_DSD0_DEBUG_CFG0: 1400 case CDC_RX_TOP_DSD0_DEBUG_CFG1: 1401 case CDC_RX_TOP_DSD0_DEBUG_CFG3: 1402 case CDC_RX_TOP_DSD1_DEBUG_CFG0: 1403 case CDC_RX_TOP_DSD1_DEBUG_CFG1: 1404 case CDC_RX_TOP_DSD1_DEBUG_CFG3: 1405 case CDC_RX_TOP_RX_I2S_CTL: 1406 case CDC_RX_TOP_TX_I2S2_CTL: 1407 case CDC_RX_TOP_I2S_CLK: 1408 case CDC_RX_TOP_I2S_RESET: 1409 case CDC_RX_TOP_I2S_MUX: 1410 case CDC_RX_CLK_RST_CTRL_MCLK_CONTROL: 1411 case CDC_RX_CLK_RST_CTRL_FS_CNT_CONTROL: 1412 case CDC_RX_CLK_RST_CTRL_SWR_CONTROL: 1413 case CDC_RX_CLK_RST_CTRL_DSD_CONTROL: 1414 case CDC_RX_CLK_RST_CTRL_ASRC_SHARE_CONTROL: 1415 case CDC_RX_SOFTCLIP_CRC: 1416 case CDC_RX_SOFTCLIP_SOFTCLIP_CTRL: 1417 case CDC_RX_INP_MUX_RX_INT0_CFG0: 1418 case CDC_RX_INP_MUX_RX_INT0_CFG1: 1419 case CDC_RX_INP_MUX_RX_INT1_CFG0: 1420 case CDC_RX_INP_MUX_RX_INT1_CFG1: 1421 case CDC_RX_INP_MUX_RX_INT2_CFG0: 1422 case CDC_RX_INP_MUX_RX_INT2_CFG1: 1423 case CDC_RX_INP_MUX_RX_MIX_CFG4: 1424 case CDC_RX_INP_MUX_RX_MIX_CFG5: 1425 case CDC_RX_INP_MUX_SIDETONE_SRC_CFG0: 1426 case CDC_RX_CLSH_CRC: 1427 case CDC_RX_CLSH_DLY_CTRL: 1428 case CDC_RX_CLSH_DECAY_CTRL: 1429 case CDC_RX_CLSH_HPH_V_PA: 1430 case CDC_RX_CLSH_EAR_V_PA: 1431 case CDC_RX_CLSH_HPH_V_HD: 1432 case CDC_RX_CLSH_EAR_V_HD: 1433 case CDC_RX_CLSH_K1_MSB: 1434 case CDC_RX_CLSH_K1_LSB: 1435 case CDC_RX_CLSH_K2_MSB: 1436 case CDC_RX_CLSH_K2_LSB: 1437 case CDC_RX_CLSH_IDLE_CTRL: 1438 case CDC_RX_CLSH_IDLE_HPH: 1439 case CDC_RX_CLSH_IDLE_EAR: 1440 case CDC_RX_CLSH_TEST0: 1441 case CDC_RX_CLSH_TEST1: 1442 case CDC_RX_CLSH_OVR_VREF: 1443 case CDC_RX_CLSH_CLSG_CTL: 1444 case CDC_RX_CLSH_CLSG_CFG1: 1445 case CDC_RX_CLSH_CLSG_CFG2: 1446 case CDC_RX_BCL_VBAT_PATH_CTL: 1447 case CDC_RX_BCL_VBAT_CFG: 1448 case CDC_RX_BCL_VBAT_ADC_CAL1: 1449 case CDC_RX_BCL_VBAT_ADC_CAL2: 1450 case CDC_RX_BCL_VBAT_ADC_CAL3: 1451 case CDC_RX_BCL_VBAT_PK_EST1: 1452 case CDC_RX_BCL_VBAT_PK_EST2: 1453 case CDC_RX_BCL_VBAT_PK_EST3: 1454 case CDC_RX_BCL_VBAT_RF_PROC1: 1455 case CDC_RX_BCL_VBAT_RF_PROC2: 1456 case CDC_RX_BCL_VBAT_TAC1: 1457 case CDC_RX_BCL_VBAT_TAC2: 1458 case CDC_RX_BCL_VBAT_TAC3: 1459 case CDC_RX_BCL_VBAT_TAC4: 1460 case CDC_RX_BCL_VBAT_GAIN_UPD1: 1461 case CDC_RX_BCL_VBAT_GAIN_UPD2: 1462 case CDC_RX_BCL_VBAT_GAIN_UPD3: 1463 case CDC_RX_BCL_VBAT_GAIN_UPD4: 1464 case CDC_RX_BCL_VBAT_GAIN_UPD5: 1465 case CDC_RX_BCL_VBAT_DEBUG1: 1466 case CDC_RX_BCL_VBAT_BAN: 1467 case CDC_RX_BCL_VBAT_BCL_GAIN_UPD1: 1468 case CDC_RX_BCL_VBAT_BCL_GAIN_UPD2: 1469 case CDC_RX_BCL_VBAT_BCL_GAIN_UPD3: 1470 case CDC_RX_BCL_VBAT_BCL_GAIN_UPD4: 1471 case CDC_RX_BCL_VBAT_BCL_GAIN_UPD5: 1472 case CDC_RX_BCL_VBAT_BCL_GAIN_UPD6: 1473 case CDC_RX_BCL_VBAT_BCL_GAIN_UPD7: 1474 case CDC_RX_BCL_VBAT_BCL_GAIN_UPD8: 1475 case CDC_RX_BCL_VBAT_BCL_GAIN_UPD9: 1476 case CDC_RX_BCL_VBAT_ATTN1: 1477 case CDC_RX_BCL_VBAT_ATTN2: 1478 case CDC_RX_BCL_VBAT_ATTN3: 1479 case CDC_RX_BCL_VBAT_DECODE_CTL1: 1480 case CDC_RX_BCL_VBAT_DECODE_CTL2: 1481 case CDC_RX_BCL_VBAT_DECODE_CFG1: 1482 case CDC_RX_BCL_VBAT_DECODE_CFG2: 1483 case CDC_RX_BCL_VBAT_DECODE_CFG3: 1484 case CDC_RX_BCL_VBAT_DECODE_CFG4: 1485 case CDC_RX_INTR_CTRL_CFG: 1486 case CDC_RX_INTR_CTRL_PIN1_MASK0: 1487 case CDC_RX_INTR_CTRL_PIN2_MASK0: 1488 case CDC_RX_INTR_CTRL_LEVEL0: 1489 case CDC_RX_INTR_CTRL_BYPASS0: 1490 case CDC_RX_INTR_CTRL_SET0: 1491 case CDC_RX_RX0_RX_PATH_CTL: 1492 case CDC_RX_RX0_RX_PATH_CFG0: 1493 case CDC_RX_RX0_RX_PATH_CFG1: 1494 case CDC_RX_RX0_RX_PATH_CFG2: 1495 case CDC_RX_RX0_RX_PATH_CFG3: 1496 case CDC_RX_RX0_RX_VOL_CTL: 1497 case CDC_RX_RX0_RX_PATH_MIX_CTL: 1498 case CDC_RX_RX0_RX_PATH_MIX_CFG: 1499 case CDC_RX_RX0_RX_VOL_MIX_CTL: 1500 case CDC_RX_RX0_RX_PATH_SEC1: 1501 case CDC_RX_RX0_RX_PATH_SEC2: 1502 case CDC_RX_RX0_RX_PATH_SEC3: 1503 case CDC_RX_RX0_RX_PATH_SEC4: 1504 case CDC_RX_RX0_RX_PATH_SEC7: 1505 case CDC_RX_RX0_RX_PATH_MIX_SEC0: 1506 case CDC_RX_RX0_RX_PATH_MIX_SEC1: 1507 case CDC_RX_RX0_RX_PATH_DSM_CTL: 1508 case CDC_RX_RX0_RX_PATH_DSM_DATA1: 1509 case CDC_RX_RX0_RX_PATH_DSM_DATA2: 1510 case CDC_RX_RX0_RX_PATH_DSM_DATA3: 1511 case CDC_RX_RX0_RX_PATH_DSM_DATA4: 1512 case CDC_RX_RX0_RX_PATH_DSM_DATA5: 1513 case CDC_RX_RX0_RX_PATH_DSM_DATA6: 1514 case CDC_RX_IDLE_DETECT_PATH_CTL: 1515 case CDC_RX_IDLE_DETECT_CFG0: 1516 case CDC_RX_IDLE_DETECT_CFG1: 1517 case CDC_RX_IDLE_DETECT_CFG2: 1518 case CDC_RX_IDLE_DETECT_CFG3: 1519 case CDC_RX_COMPANDER0_CTL0: 1520 case CDC_RX_COMPANDER0_CTL1: 1521 case CDC_RX_COMPANDER0_CTL2: 1522 case CDC_RX_COMPANDER0_CTL3: 1523 case CDC_RX_COMPANDER0_CTL4: 1524 case CDC_RX_COMPANDER0_CTL5: 1525 case CDC_RX_COMPANDER0_CTL7: 1526 case CDC_RX_COMPANDER1_CTL0: 1527 case CDC_RX_COMPANDER1_CTL1: 1528 case CDC_RX_COMPANDER1_CTL2: 1529 case CDC_RX_COMPANDER1_CTL3: 1530 case CDC_RX_COMPANDER1_CTL4: 1531 case CDC_RX_COMPANDER1_CTL5: 1532 case CDC_RX_COMPANDER1_CTL7: 1533 case CDC_RX_SIDETONE_IIR0_IIR_PATH_CTL: 1534 case CDC_RX_SIDETONE_IIR0_IIR_GAIN_B1_CTL: 1535 case CDC_RX_SIDETONE_IIR0_IIR_GAIN_B2_CTL: 1536 case CDC_RX_SIDETONE_IIR0_IIR_GAIN_B3_CTL: 1537 case CDC_RX_SIDETONE_IIR0_IIR_GAIN_B4_CTL: 1538 case CDC_RX_SIDETONE_IIR0_IIR_GAIN_B5_CTL: 1539 case CDC_RX_SIDETONE_IIR0_IIR_GAIN_B6_CTL: 1540 case CDC_RX_SIDETONE_IIR0_IIR_GAIN_B7_CTL: 1541 case CDC_RX_SIDETONE_IIR0_IIR_GAIN_B8_CTL: 1542 case CDC_RX_SIDETONE_IIR0_IIR_CTL: 1543 case CDC_RX_SIDETONE_IIR0_IIR_GAIN_TIMER_CTL: 1544 case CDC_RX_SIDETONE_IIR0_IIR_COEF_B1_CTL: 1545 case CDC_RX_SIDETONE_IIR0_IIR_COEF_B2_CTL: 1546 case CDC_RX_SIDETONE_IIR1_IIR_PATH_CTL: 1547 case CDC_RX_SIDETONE_IIR1_IIR_GAIN_B1_CTL: 1548 case CDC_RX_SIDETONE_IIR1_IIR_GAIN_B2_CTL: 1549 case CDC_RX_SIDETONE_IIR1_IIR_GAIN_B3_CTL: 1550 case CDC_RX_SIDETONE_IIR1_IIR_GAIN_B4_CTL: 1551 case CDC_RX_SIDETONE_IIR1_IIR_GAIN_B5_CTL: 1552 case CDC_RX_SIDETONE_IIR1_IIR_GAIN_B6_CTL: 1553 case CDC_RX_SIDETONE_IIR1_IIR_GAIN_B7_CTL: 1554 case CDC_RX_SIDETONE_IIR1_IIR_GAIN_B8_CTL: 1555 case CDC_RX_SIDETONE_IIR1_IIR_CTL: 1556 case CDC_RX_SIDETONE_IIR1_IIR_GAIN_TIMER_CTL: 1557 case CDC_RX_SIDETONE_IIR1_IIR_COEF_B1_CTL: 1558 case CDC_RX_SIDETONE_IIR1_IIR_COEF_B2_CTL: 1559 case CDC_RX_IIR_INP_MUX_IIR0_MIX_CFG0: 1560 case CDC_RX_IIR_INP_MUX_IIR0_MIX_CFG1: 1561 case CDC_RX_IIR_INP_MUX_IIR0_MIX_CFG2: 1562 case CDC_RX_IIR_INP_MUX_IIR0_MIX_CFG3: 1563 case CDC_RX_IIR_INP_MUX_IIR1_MIX_CFG0: 1564 case CDC_RX_IIR_INP_MUX_IIR1_MIX_CFG1: 1565 case CDC_RX_IIR_INP_MUX_IIR1_MIX_CFG2: 1566 case CDC_RX_IIR_INP_MUX_IIR1_MIX_CFG3: 1567 case CDC_RX_SIDETONE_SRC0_ST_SRC_PATH_CTL: 1568 case CDC_RX_SIDETONE_SRC0_ST_SRC_PATH_CFG1: 1569 case CDC_RX_SIDETONE_SRC1_ST_SRC_PATH_CTL: 1570 case CDC_RX_SIDETONE_SRC1_ST_SRC_PATH_CFG1: 1571 case CDC_RX_EC_REF_HQ0_EC_REF_HQ_PATH_CTL: 1572 case CDC_RX_EC_REF_HQ0_EC_REF_HQ_CFG0: 1573 case CDC_RX_EC_REF_HQ1_EC_REF_HQ_PATH_CTL: 1574 case CDC_RX_EC_REF_HQ1_EC_REF_HQ_CFG0: 1575 case CDC_RX_EC_REF_HQ2_EC_REF_HQ_PATH_CTL: 1576 case CDC_RX_EC_REF_HQ2_EC_REF_HQ_CFG0: 1577 case CDC_RX_EC_ASRC0_CLK_RST_CTL: 1578 case CDC_RX_EC_ASRC0_CTL0: 1579 case CDC_RX_EC_ASRC0_CTL1: 1580 case CDC_RX_EC_ASRC0_FIFO_CTL: 1581 case CDC_RX_EC_ASRC1_CLK_RST_CTL: 1582 case CDC_RX_EC_ASRC1_CTL0: 1583 case CDC_RX_EC_ASRC1_CTL1: 1584 case CDC_RX_EC_ASRC1_FIFO_CTL: 1585 case CDC_RX_EC_ASRC2_CLK_RST_CTL: 1586 case CDC_RX_EC_ASRC2_CTL0: 1587 case CDC_RX_EC_ASRC2_CTL1: 1588 case CDC_RX_EC_ASRC2_FIFO_CTL: 1589 case CDC_RX_DSD0_PATH_CTL: 1590 case CDC_RX_DSD0_CFG0: 1591 case CDC_RX_DSD0_CFG1: 1592 case CDC_RX_DSD0_CFG2: 1593 case CDC_RX_DSD1_PATH_CTL: 1594 case CDC_RX_DSD1_CFG0: 1595 case CDC_RX_DSD1_CFG1: 1596 case CDC_RX_DSD1_CFG2: 1597 return true; 1598 } 1599 1600 switch (rx->codec_version) { 1601 case LPASS_CODEC_VERSION_1_0: 1602 case LPASS_CODEC_VERSION_1_1: 1603 case LPASS_CODEC_VERSION_1_2: 1604 case LPASS_CODEC_VERSION_2_0: 1605 case LPASS_CODEC_VERSION_2_1: 1606 return rx_pre_2_5_is_rw_register(dev, reg); 1607 case LPASS_CODEC_VERSION_2_5: 1608 case LPASS_CODEC_VERSION_2_6: 1609 case LPASS_CODEC_VERSION_2_7: 1610 case LPASS_CODEC_VERSION_2_8: 1611 return rx_2_5_is_rw_register(dev, reg); 1612 default: 1613 break; 1614 } 1615 1616 return false; 1617 } 1618 1619 static bool rx_is_writeable_register(struct device *dev, unsigned int reg) 1620 { 1621 bool ret; 1622 1623 ret = rx_is_rw_register(dev, reg); 1624 if (!ret) 1625 return rx_is_wronly_register(dev, reg); 1626 1627 return ret; 1628 } 1629 1630 static bool rx_is_readable_register(struct device *dev, unsigned int reg) 1631 { 1632 switch (reg) { 1633 case CDC_RX_TOP_HPHL_COMP_RD_LSB: 1634 case CDC_RX_TOP_HPHL_COMP_RD_MSB: 1635 case CDC_RX_TOP_HPHR_COMP_RD_LSB: 1636 case CDC_RX_TOP_HPHR_COMP_RD_MSB: 1637 case CDC_RX_TOP_DSD0_DEBUG_CFG2: 1638 case CDC_RX_TOP_DSD1_DEBUG_CFG2: 1639 case CDC_RX_BCL_VBAT_GAIN_MON_VAL: 1640 case CDC_RX_BCL_VBAT_DECODE_ST: 1641 case CDC_RX_INTR_CTRL_PIN1_STATUS0: 1642 case CDC_RX_INTR_CTRL_PIN2_STATUS0: 1643 case CDC_RX_COMPANDER0_CTL6: 1644 case CDC_RX_COMPANDER1_CTL6: 1645 case CDC_RX_EC_ASRC0_STATUS_FMIN_CNTR_LSB: 1646 case CDC_RX_EC_ASRC0_STATUS_FMIN_CNTR_MSB: 1647 case CDC_RX_EC_ASRC0_STATUS_FMAX_CNTR_LSB: 1648 case CDC_RX_EC_ASRC0_STATUS_FMAX_CNTR_MSB: 1649 case CDC_RX_EC_ASRC0_STATUS_FIFO: 1650 case CDC_RX_EC_ASRC1_STATUS_FMIN_CNTR_LSB: 1651 case CDC_RX_EC_ASRC1_STATUS_FMIN_CNTR_MSB: 1652 case CDC_RX_EC_ASRC1_STATUS_FMAX_CNTR_LSB: 1653 case CDC_RX_EC_ASRC1_STATUS_FMAX_CNTR_MSB: 1654 case CDC_RX_EC_ASRC1_STATUS_FIFO: 1655 case CDC_RX_EC_ASRC2_STATUS_FMIN_CNTR_LSB: 1656 case CDC_RX_EC_ASRC2_STATUS_FMIN_CNTR_MSB: 1657 case CDC_RX_EC_ASRC2_STATUS_FMAX_CNTR_LSB: 1658 case CDC_RX_EC_ASRC2_STATUS_FMAX_CNTR_MSB: 1659 case CDC_RX_EC_ASRC2_STATUS_FIFO: 1660 return true; 1661 } 1662 1663 return rx_is_rw_register(dev, reg); 1664 } 1665 1666 static const struct regmap_config rx_regmap_config = { 1667 .name = "rx_macro", 1668 .reg_bits = 16, 1669 .val_bits = 32, /* 8 but with 32 bit read/write */ 1670 .reg_stride = 4, 1671 .cache_type = REGCACHE_FLAT, 1672 .max_register = RX_MAX_OFFSET, 1673 .writeable_reg = rx_is_writeable_register, 1674 .volatile_reg = rx_is_volatile_register, 1675 .readable_reg = rx_is_readable_register, 1676 }; 1677 1678 static int rx_macro_int_dem_inp_mux_put(struct snd_kcontrol *kcontrol, 1679 struct snd_ctl_elem_value *ucontrol) 1680 { 1681 struct snd_soc_dapm_widget *widget = snd_soc_dapm_kcontrol_widget(kcontrol); 1682 struct snd_soc_component *component = snd_soc_dapm_to_component(widget->dapm); 1683 struct rx_macro *rx = snd_soc_component_get_drvdata(component); 1684 struct soc_enum *e = (struct soc_enum *)kcontrol->private_value; 1685 unsigned short look_ahead_dly_reg; 1686 unsigned int val; 1687 1688 val = ucontrol->value.enumerated.item[0]; 1689 1690 if (e->reg == CDC_RX_RXn_RX_PATH_CFG1(rx, 0)) 1691 look_ahead_dly_reg = CDC_RX_RXn_RX_PATH_CFG0(rx, 0); 1692 else if (e->reg == CDC_RX_RXn_RX_PATH_CFG1(rx, 1)) 1693 look_ahead_dly_reg = CDC_RX_RXn_RX_PATH_CFG0(rx, 1); 1694 1695 /* Set Look Ahead Delay */ 1696 if (val) 1697 snd_soc_component_update_bits(component, look_ahead_dly_reg, 1698 CDC_RX_DLY_ZN_EN_MASK, 1699 CDC_RX_DLY_ZN_ENABLE); 1700 else 1701 snd_soc_component_update_bits(component, look_ahead_dly_reg, 1702 CDC_RX_DLY_ZN_EN_MASK, 0); 1703 /* Set DEM INP Select */ 1704 return snd_soc_dapm_put_enum_double(kcontrol, ucontrol); 1705 } 1706 1707 static const struct snd_kcontrol_new rx_int0_dem_inp_mux = 1708 SOC_DAPM_ENUM_EXT("rx_int0_dem_inp", rx_int0_dem_inp_enum, 1709 snd_soc_dapm_get_enum_double, rx_macro_int_dem_inp_mux_put); 1710 static const struct snd_kcontrol_new rx_int1_dem_inp_mux = 1711 SOC_DAPM_ENUM_EXT("rx_int1_dem_inp", rx_int1_dem_inp_enum, 1712 snd_soc_dapm_get_enum_double, rx_macro_int_dem_inp_mux_put); 1713 1714 static const struct snd_kcontrol_new rx_2_5_int1_dem_inp_mux = 1715 SOC_DAPM_ENUM_EXT("rx_int1_dem_inp", rx_2_5_int1_dem_inp_enum, 1716 snd_soc_dapm_get_enum_double, rx_macro_int_dem_inp_mux_put); 1717 1718 static int rx_macro_set_prim_interpolator_rate(struct snd_soc_dai *dai, 1719 int rate_reg_val, u32 sample_rate) 1720 { 1721 1722 u8 int_1_mix1_inp; 1723 u32 j, port; 1724 u16 int_mux_cfg0, int_mux_cfg1; 1725 u16 int_fs_reg; 1726 u8 inp0_sel, inp1_sel, inp2_sel; 1727 struct snd_soc_component *component = dai->component; 1728 struct rx_macro *rx = snd_soc_component_get_drvdata(component); 1729 1730 for_each_set_bit(port, &rx->active_ch_mask[dai->id], RX_MACRO_PORTS_MAX) { 1731 int_1_mix1_inp = port; 1732 int_mux_cfg0 = CDC_RX_INP_MUX_RX_INT0_CFG0; 1733 /* 1734 * Loop through all interpolator MUX inputs and find out 1735 * to which interpolator input, the rx port 1736 * is connected 1737 */ 1738 for (j = 0; j < INTERP_MAX; j++) { 1739 int_mux_cfg1 = int_mux_cfg0 + 4; 1740 1741 inp0_sel = snd_soc_component_read_field(component, int_mux_cfg0, 1742 CDC_RX_INTX_1_MIX_INP0_SEL_MASK); 1743 inp1_sel = snd_soc_component_read_field(component, int_mux_cfg0, 1744 CDC_RX_INTX_1_MIX_INP1_SEL_MASK); 1745 inp2_sel = snd_soc_component_read_field(component, int_mux_cfg1, 1746 CDC_RX_INTX_1_MIX_INP2_SEL_MASK); 1747 1748 if ((inp0_sel == int_1_mix1_inp + INTn_1_INP_SEL_RX0) || 1749 (inp1_sel == int_1_mix1_inp + INTn_1_INP_SEL_RX0) || 1750 (inp2_sel == int_1_mix1_inp + INTn_1_INP_SEL_RX0)) { 1751 int_fs_reg = CDC_RX_RXn_RX_PATH_CTL(rx, j); 1752 /* sample_rate is in Hz */ 1753 snd_soc_component_update_bits(component, int_fs_reg, 1754 CDC_RX_PATH_PCM_RATE_MASK, 1755 rate_reg_val); 1756 } 1757 int_mux_cfg0 += 8; 1758 } 1759 } 1760 1761 return 0; 1762 } 1763 1764 static int rx_macro_set_mix_interpolator_rate(struct snd_soc_dai *dai, 1765 int rate_reg_val, u32 sample_rate) 1766 { 1767 1768 u8 int_2_inp; 1769 u32 j, port; 1770 u16 int_mux_cfg1, int_fs_reg; 1771 u8 int_mux_cfg1_val; 1772 struct snd_soc_component *component = dai->component; 1773 struct rx_macro *rx = snd_soc_component_get_drvdata(component); 1774 1775 for_each_set_bit(port, &rx->active_ch_mask[dai->id], RX_MACRO_PORTS_MAX) { 1776 int_2_inp = port; 1777 1778 int_mux_cfg1 = CDC_RX_INP_MUX_RX_INT0_CFG1; 1779 for (j = 0; j < INTERP_MAX; j++) { 1780 int_mux_cfg1_val = snd_soc_component_read_field(component, int_mux_cfg1, 1781 CDC_RX_INTX_2_SEL_MASK); 1782 1783 if (int_mux_cfg1_val == int_2_inp + INTn_2_INP_SEL_RX0) { 1784 int_fs_reg = CDC_RX_RXn_RX_PATH_MIX_CTL(rx, j); 1785 snd_soc_component_update_bits(component, int_fs_reg, 1786 CDC_RX_RXn_MIX_PCM_RATE_MASK, 1787 rate_reg_val); 1788 } 1789 int_mux_cfg1 += 8; 1790 } 1791 } 1792 return 0; 1793 } 1794 1795 static int rx_macro_set_interpolator_rate(struct snd_soc_dai *dai, 1796 u32 sample_rate) 1797 { 1798 int rate_val = 0; 1799 int i, ret; 1800 1801 for (i = 0; i < ARRAY_SIZE(sr_val_tbl); i++) 1802 if (sample_rate == sr_val_tbl[i].sample_rate) 1803 rate_val = sr_val_tbl[i].rate_val; 1804 1805 ret = rx_macro_set_prim_interpolator_rate(dai, rate_val, sample_rate); 1806 if (ret) 1807 return ret; 1808 1809 ret = rx_macro_set_mix_interpolator_rate(dai, rate_val, sample_rate); 1810 1811 return ret; 1812 } 1813 1814 static int rx_macro_hw_params(struct snd_pcm_substream *substream, 1815 struct snd_pcm_hw_params *params, 1816 struct snd_soc_dai *dai) 1817 { 1818 struct snd_soc_component *component = dai->component; 1819 struct rx_macro *rx = snd_soc_component_get_drvdata(component); 1820 int ret; 1821 1822 switch (substream->stream) { 1823 case SNDRV_PCM_STREAM_PLAYBACK: 1824 ret = rx_macro_set_interpolator_rate(dai, params_rate(params)); 1825 if (ret) { 1826 dev_err(component->dev, "%s: cannot set sample rate: %u\n", 1827 __func__, params_rate(params)); 1828 return ret; 1829 } 1830 rx->bit_width[dai->id] = params_width(params); 1831 break; 1832 default: 1833 break; 1834 } 1835 return 0; 1836 } 1837 1838 static int rx_macro_get_channel_map(const struct snd_soc_dai *dai, 1839 unsigned int *tx_num, unsigned int *tx_slot, 1840 unsigned int *rx_num, unsigned int *rx_slot) 1841 { 1842 struct snd_soc_component *component = dai->component; 1843 struct rx_macro *rx = snd_soc_component_get_drvdata(component); 1844 u16 val, mask = 0, cnt = 0, temp; 1845 1846 switch (dai->id) { 1847 case RX_MACRO_AIF1_PB: 1848 case RX_MACRO_AIF2_PB: 1849 case RX_MACRO_AIF3_PB: 1850 case RX_MACRO_AIF4_PB: 1851 for_each_set_bit(temp, &rx->active_ch_mask[dai->id], 1852 RX_MACRO_PORTS_MAX) { 1853 mask |= (1 << temp); 1854 if (++cnt == RX_MACRO_MAX_DMA_CH_PER_PORT) 1855 break; 1856 } 1857 /* 1858 * CDC_DMA_RX_0 port drives RX0/RX1 -- ch_mask 0x1/0x2/0x3 1859 * CDC_DMA_RX_1 port drives RX2/RX3 -- ch_mask 0x1/0x2/0x3 1860 * CDC_DMA_RX_2 port drives RX4 -- ch_mask 0x1 1861 * CDC_DMA_RX_3 port drives RX5 -- ch_mask 0x1 1862 * AIFn can pair to any CDC_DMA_RX_n port. 1863 * In general, below convention is used:: 1864 * CDC_DMA_RX_0(AIF1)/CDC_DMA_RX_1(AIF2)/ 1865 * CDC_DMA_RX_2(AIF3)/CDC_DMA_RX_3(AIF4) 1866 */ 1867 if (mask & 0x0C) 1868 mask = mask >> 2; 1869 if ((mask & 0x10) || (mask & 0x20)) 1870 mask = 0x1; 1871 *rx_slot = mask; 1872 *rx_num = rx->active_ch_cnt[dai->id]; 1873 break; 1874 case RX_MACRO_AIF_ECHO: 1875 val = snd_soc_component_read(component, CDC_RX_INP_MUX_RX_MIX_CFG4); 1876 if (val & RX_MACRO_EC_MIX_TX0_MASK) { 1877 mask |= 0x1; 1878 cnt++; 1879 } 1880 if (val & RX_MACRO_EC_MIX_TX1_MASK) { 1881 mask |= 0x2; 1882 cnt++; 1883 } 1884 val = snd_soc_component_read(component, 1885 CDC_RX_INP_MUX_RX_MIX_CFG5); 1886 if (val & RX_MACRO_EC_MIX_TX2_MASK) { 1887 mask |= 0x4; 1888 cnt++; 1889 } 1890 *tx_slot = mask; 1891 *tx_num = cnt; 1892 break; 1893 default: 1894 dev_err(component->dev, "%s: Invalid AIF\n", __func__); 1895 break; 1896 } 1897 return 0; 1898 } 1899 1900 static int rx_macro_digital_mute(struct snd_soc_dai *dai, int mute, int stream) 1901 { 1902 struct snd_soc_component *component = dai->component; 1903 struct rx_macro *rx = snd_soc_component_get_drvdata(component); 1904 uint16_t j, reg, mix_reg, dsm_reg; 1905 u16 int_mux_cfg0, int_mux_cfg1; 1906 u8 int_mux_cfg0_val, int_mux_cfg1_val; 1907 1908 switch (dai->id) { 1909 case RX_MACRO_AIF1_PB: 1910 case RX_MACRO_AIF2_PB: 1911 case RX_MACRO_AIF3_PB: 1912 case RX_MACRO_AIF4_PB: 1913 for (j = 0; j < INTERP_MAX; j++) { 1914 reg = CDC_RX_RXn_RX_PATH_CTL(rx, j); 1915 mix_reg = CDC_RX_RXn_RX_PATH_MIX_CTL(rx, j); 1916 dsm_reg = CDC_RX_RXn_RX_PATH_DSM_CTL(rx, j); 1917 1918 if (mute) { 1919 snd_soc_component_update_bits(component, reg, 1920 CDC_RX_PATH_PGA_MUTE_MASK, 1921 CDC_RX_PATH_PGA_MUTE_ENABLE); 1922 snd_soc_component_update_bits(component, mix_reg, 1923 CDC_RX_PATH_PGA_MUTE_MASK, 1924 CDC_RX_PATH_PGA_MUTE_ENABLE); 1925 } else { 1926 snd_soc_component_update_bits(component, reg, 1927 CDC_RX_PATH_PGA_MUTE_MASK, 0x0); 1928 snd_soc_component_update_bits(component, mix_reg, 1929 CDC_RX_PATH_PGA_MUTE_MASK, 0x0); 1930 } 1931 1932 if (j == INTERP_AUX) 1933 dsm_reg = CDC_RX_RXn_RX_PATH_DSM_CTL(rx, 2); 1934 1935 int_mux_cfg0 = CDC_RX_INP_MUX_RX_INT0_CFG0 + j * 8; 1936 int_mux_cfg1 = int_mux_cfg0 + 4; 1937 int_mux_cfg0_val = snd_soc_component_read(component, int_mux_cfg0); 1938 int_mux_cfg1_val = snd_soc_component_read(component, int_mux_cfg1); 1939 1940 if (snd_soc_component_read(component, dsm_reg) & 0x01) { 1941 if (int_mux_cfg0_val || (int_mux_cfg1_val & 0xF0)) 1942 snd_soc_component_update_bits(component, reg, 0x20, 0x20); 1943 if (int_mux_cfg1_val & 0x0F) { 1944 snd_soc_component_update_bits(component, reg, 0x20, 0x20); 1945 snd_soc_component_update_bits(component, mix_reg, 0x20, 1946 0x20); 1947 } 1948 } 1949 } 1950 break; 1951 default: 1952 break; 1953 } 1954 return 0; 1955 } 1956 1957 static const struct snd_soc_dai_ops rx_macro_dai_ops = { 1958 .hw_params = rx_macro_hw_params, 1959 .get_channel_map = rx_macro_get_channel_map, 1960 .mute_stream = rx_macro_digital_mute, 1961 }; 1962 1963 static struct snd_soc_dai_driver rx_macro_dai[] = { 1964 { 1965 .name = "rx_macro_rx1", 1966 .id = RX_MACRO_AIF1_PB, 1967 .playback = { 1968 .stream_name = "RX_MACRO_AIF1 Playback", 1969 .rates = RX_MACRO_RATES | RX_MACRO_FRAC_RATES, 1970 .formats = RX_MACRO_FORMATS, 1971 .rate_max = 384000, 1972 .rate_min = 8000, 1973 .channels_min = 1, 1974 .channels_max = 2, 1975 }, 1976 .ops = &rx_macro_dai_ops, 1977 }, 1978 { 1979 .name = "rx_macro_rx2", 1980 .id = RX_MACRO_AIF2_PB, 1981 .playback = { 1982 .stream_name = "RX_MACRO_AIF2 Playback", 1983 .rates = RX_MACRO_RATES | RX_MACRO_FRAC_RATES, 1984 .formats = RX_MACRO_FORMATS, 1985 .rate_max = 384000, 1986 .rate_min = 8000, 1987 .channels_min = 1, 1988 .channels_max = 2, 1989 }, 1990 .ops = &rx_macro_dai_ops, 1991 }, 1992 { 1993 .name = "rx_macro_rx3", 1994 .id = RX_MACRO_AIF3_PB, 1995 .playback = { 1996 .stream_name = "RX_MACRO_AIF3 Playback", 1997 .rates = RX_MACRO_RATES | RX_MACRO_FRAC_RATES, 1998 .formats = RX_MACRO_FORMATS, 1999 .rate_max = 384000, 2000 .rate_min = 8000, 2001 .channels_min = 1, 2002 .channels_max = 2, 2003 }, 2004 .ops = &rx_macro_dai_ops, 2005 }, 2006 { 2007 .name = "rx_macro_rx4", 2008 .id = RX_MACRO_AIF4_PB, 2009 .playback = { 2010 .stream_name = "RX_MACRO_AIF4 Playback", 2011 .rates = RX_MACRO_RATES | RX_MACRO_FRAC_RATES, 2012 .formats = RX_MACRO_FORMATS, 2013 .rate_max = 384000, 2014 .rate_min = 8000, 2015 .channels_min = 1, 2016 .channels_max = 2, 2017 }, 2018 .ops = &rx_macro_dai_ops, 2019 }, 2020 { 2021 .name = "rx_macro_echo", 2022 .id = RX_MACRO_AIF_ECHO, 2023 .capture = { 2024 .stream_name = "RX_AIF_ECHO Capture", 2025 .rates = RX_MACRO_ECHO_RATES, 2026 .formats = RX_MACRO_ECHO_FORMATS, 2027 .rate_max = 48000, 2028 .rate_min = 8000, 2029 .channels_min = 1, 2030 .channels_max = 3, 2031 }, 2032 .ops = &rx_macro_dai_ops, 2033 }, 2034 }; 2035 2036 static void rx_macro_mclk_enable(struct rx_macro *rx, bool mclk_enable) 2037 { 2038 struct regmap *regmap = rx->regmap; 2039 2040 if (mclk_enable) { 2041 if (rx->rx_mclk_users == 0) { 2042 regmap_update_bits(regmap, CDC_RX_CLK_RST_CTRL_MCLK_CONTROL, 2043 CDC_RX_CLK_MCLK_EN_MASK | 2044 CDC_RX_CLK_MCLK2_EN_MASK, 2045 CDC_RX_CLK_MCLK_ENABLE | 2046 CDC_RX_CLK_MCLK2_ENABLE); 2047 regmap_update_bits(regmap, CDC_RX_CLK_RST_CTRL_FS_CNT_CONTROL, 2048 CDC_RX_FS_MCLK_CNT_CLR_MASK, 0x00); 2049 regmap_update_bits(regmap, CDC_RX_CLK_RST_CTRL_FS_CNT_CONTROL, 2050 CDC_RX_FS_MCLK_CNT_EN_MASK, 2051 CDC_RX_FS_MCLK_CNT_ENABLE); 2052 regcache_mark_dirty(regmap); 2053 regcache_sync(regmap); 2054 } 2055 rx->rx_mclk_users++; 2056 } else { 2057 if (rx->rx_mclk_users <= 0) { 2058 dev_err(rx->dev, "%s: clock already disabled\n", __func__); 2059 rx->rx_mclk_users = 0; 2060 return; 2061 } 2062 rx->rx_mclk_users--; 2063 if (rx->rx_mclk_users == 0) { 2064 regmap_update_bits(regmap, CDC_RX_CLK_RST_CTRL_FS_CNT_CONTROL, 2065 CDC_RX_FS_MCLK_CNT_EN_MASK, 0x0); 2066 regmap_update_bits(regmap, CDC_RX_CLK_RST_CTRL_FS_CNT_CONTROL, 2067 CDC_RX_FS_MCLK_CNT_CLR_MASK, 2068 CDC_RX_FS_MCLK_CNT_CLR); 2069 regmap_update_bits(regmap, CDC_RX_CLK_RST_CTRL_MCLK_CONTROL, 2070 CDC_RX_CLK_MCLK_EN_MASK | 2071 CDC_RX_CLK_MCLK2_EN_MASK, 0x0); 2072 } 2073 } 2074 } 2075 2076 static int rx_macro_mclk_event(struct snd_soc_dapm_widget *w, 2077 struct snd_kcontrol *kcontrol, int event) 2078 { 2079 struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); 2080 struct rx_macro *rx = snd_soc_component_get_drvdata(component); 2081 int ret = 0; 2082 2083 switch (event) { 2084 case SND_SOC_DAPM_PRE_PMU: 2085 rx_macro_mclk_enable(rx, true); 2086 break; 2087 case SND_SOC_DAPM_POST_PMD: 2088 rx_macro_mclk_enable(rx, false); 2089 break; 2090 default: 2091 dev_err(component->dev, "%s: invalid DAPM event %d\n", __func__, event); 2092 ret = -EINVAL; 2093 } 2094 return ret; 2095 } 2096 2097 static bool rx_macro_adie_lb(struct snd_soc_component *component, 2098 int interp_idx) 2099 { 2100 u16 int_mux_cfg0, int_mux_cfg1; 2101 u8 int_n_inp0, int_n_inp1, int_n_inp2; 2102 2103 int_mux_cfg0 = CDC_RX_INP_MUX_RX_INT0_CFG0 + interp_idx * 8; 2104 int_mux_cfg1 = int_mux_cfg0 + 4; 2105 2106 int_n_inp0 = snd_soc_component_read_field(component, int_mux_cfg0, 2107 CDC_RX_INTX_1_MIX_INP0_SEL_MASK); 2108 int_n_inp1 = snd_soc_component_read_field(component, int_mux_cfg0, 2109 CDC_RX_INTX_1_MIX_INP1_SEL_MASK); 2110 int_n_inp2 = snd_soc_component_read_field(component, int_mux_cfg1, 2111 CDC_RX_INTX_1_MIX_INP2_SEL_MASK); 2112 2113 if (int_n_inp0 == INTn_1_INP_SEL_DEC0 || 2114 int_n_inp0 == INTn_1_INP_SEL_DEC1 || 2115 int_n_inp0 == INTn_1_INP_SEL_IIR0 || 2116 int_n_inp0 == INTn_1_INP_SEL_IIR1) 2117 return true; 2118 2119 if (int_n_inp1 == INTn_1_INP_SEL_DEC0 || 2120 int_n_inp1 == INTn_1_INP_SEL_DEC1 || 2121 int_n_inp1 == INTn_1_INP_SEL_IIR0 || 2122 int_n_inp1 == INTn_1_INP_SEL_IIR1) 2123 return true; 2124 2125 if (int_n_inp2 == INTn_1_INP_SEL_DEC0 || 2126 int_n_inp2 == INTn_1_INP_SEL_DEC1 || 2127 int_n_inp2 == INTn_1_INP_SEL_IIR0 || 2128 int_n_inp2 == INTn_1_INP_SEL_IIR1) 2129 return true; 2130 2131 return false; 2132 } 2133 2134 static int rx_macro_enable_interp_clk(struct snd_soc_component *component, 2135 int event, int interp_idx); 2136 static int rx_macro_enable_main_path(struct snd_soc_dapm_widget *w, 2137 struct snd_kcontrol *kcontrol, 2138 int event) 2139 { 2140 struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); 2141 struct rx_macro *rx = snd_soc_component_get_drvdata(component); 2142 u16 gain_reg, reg; 2143 2144 reg = CDC_RX_RXn_RX_PATH_CTL(rx, w->shift); 2145 gain_reg = CDC_RX_RXn_RX_VOL_CTL(rx, w->shift); 2146 2147 switch (event) { 2148 case SND_SOC_DAPM_PRE_PMU: 2149 rx_macro_enable_interp_clk(component, event, w->shift); 2150 if (rx_macro_adie_lb(component, w->shift)) 2151 snd_soc_component_update_bits(component, reg, 2152 CDC_RX_PATH_CLK_EN_MASK, 2153 CDC_RX_PATH_CLK_ENABLE); 2154 break; 2155 case SND_SOC_DAPM_POST_PMU: 2156 snd_soc_component_write(component, gain_reg, 2157 snd_soc_component_read(component, gain_reg)); 2158 break; 2159 case SND_SOC_DAPM_POST_PMD: 2160 rx_macro_enable_interp_clk(component, event, w->shift); 2161 break; 2162 } 2163 2164 return 0; 2165 } 2166 2167 static int rx_macro_config_compander(struct snd_soc_component *component, 2168 struct rx_macro *rx, 2169 int comp, int event) 2170 { 2171 u8 pcm_rate, val; 2172 2173 /* AUX does not have compander */ 2174 if (comp == INTERP_AUX) 2175 return 0; 2176 2177 pcm_rate = snd_soc_component_read(component, CDC_RX_RXn_RX_PATH_CTL(rx, comp)) & 0x0F; 2178 if (pcm_rate < 0x06) 2179 val = 0x03; 2180 else if (pcm_rate < 0x08) 2181 val = 0x01; 2182 else if (pcm_rate < 0x0B) 2183 val = 0x02; 2184 else 2185 val = 0x00; 2186 2187 if (SND_SOC_DAPM_EVENT_ON(event)) 2188 snd_soc_component_update_bits(component, CDC_RX_RXn_RX_PATH_CFG3(rx, comp), 2189 CDC_RX_DC_COEFF_SEL_MASK, val); 2190 2191 if (SND_SOC_DAPM_EVENT_OFF(event)) 2192 snd_soc_component_update_bits(component, CDC_RX_RXn_RX_PATH_CFG3(rx, comp), 2193 CDC_RX_DC_COEFF_SEL_MASK, 0x3); 2194 if (!rx->comp_enabled[comp]) 2195 return 0; 2196 2197 if (SND_SOC_DAPM_EVENT_ON(event)) { 2198 /* Enable Compander Clock */ 2199 snd_soc_component_write_field(component, CDC_RX_COMPANDERn_CTL0(comp), 2200 CDC_RX_COMPANDERn_CLK_EN_MASK, 0x1); 2201 snd_soc_component_write_field(component, CDC_RX_COMPANDERn_CTL0(comp), 2202 CDC_RX_COMPANDERn_SOFT_RST_MASK, 0x1); 2203 snd_soc_component_write_field(component, CDC_RX_COMPANDERn_CTL0(comp), 2204 CDC_RX_COMPANDERn_SOFT_RST_MASK, 0x0); 2205 snd_soc_component_write_field(component, CDC_RX_RXn_RX_PATH_CFG0(rx, comp), 2206 CDC_RX_RXn_COMP_EN_MASK, 0x1); 2207 } 2208 2209 if (SND_SOC_DAPM_EVENT_OFF(event)) { 2210 snd_soc_component_write_field(component, CDC_RX_COMPANDERn_CTL0(comp), 2211 CDC_RX_COMPANDERn_HALT_MASK, 0x1); 2212 snd_soc_component_write_field(component, CDC_RX_RXn_RX_PATH_CFG0(rx, comp), 2213 CDC_RX_RXn_COMP_EN_MASK, 0x0); 2214 snd_soc_component_write_field(component, CDC_RX_COMPANDERn_CTL0(comp), 2215 CDC_RX_COMPANDERn_CLK_EN_MASK, 0x0); 2216 snd_soc_component_write_field(component, CDC_RX_COMPANDERn_CTL0(comp), 2217 CDC_RX_COMPANDERn_HALT_MASK, 0x0); 2218 } 2219 2220 return 0; 2221 } 2222 2223 static int rx_macro_load_compander_coeff(struct snd_soc_component *component, 2224 struct rx_macro *rx, 2225 int comp, int event) 2226 { 2227 u16 comp_coeff_lsb_reg, comp_coeff_msb_reg; 2228 int i; 2229 int hph_pwr_mode; 2230 2231 /* AUX does not have compander */ 2232 if (comp == INTERP_AUX) 2233 return 0; 2234 2235 if (!rx->comp_enabled[comp]) 2236 return 0; 2237 2238 if (comp == INTERP_HPHL) { 2239 comp_coeff_lsb_reg = CDC_RX_TOP_HPHL_COMP_WR_LSB; 2240 comp_coeff_msb_reg = CDC_RX_TOP_HPHL_COMP_WR_MSB; 2241 } else if (comp == INTERP_HPHR) { 2242 comp_coeff_lsb_reg = CDC_RX_TOP_HPHR_COMP_WR_LSB; 2243 comp_coeff_msb_reg = CDC_RX_TOP_HPHR_COMP_WR_MSB; 2244 } else { 2245 /* compander coefficients are loaded only for hph path */ 2246 return 0; 2247 } 2248 2249 hph_pwr_mode = rx->hph_pwr_mode; 2250 2251 if (SND_SOC_DAPM_EVENT_ON(event)) { 2252 /* Load Compander Coeff */ 2253 for (i = 0; i < COMP_MAX_COEFF; i++) { 2254 snd_soc_component_write(component, comp_coeff_lsb_reg, 2255 comp_coeff_table[hph_pwr_mode][i].lsb); 2256 snd_soc_component_write(component, comp_coeff_msb_reg, 2257 comp_coeff_table[hph_pwr_mode][i].msb); 2258 } 2259 } 2260 2261 return 0; 2262 } 2263 2264 static void rx_macro_enable_softclip_clk(struct snd_soc_component *component, 2265 struct rx_macro *rx, bool enable) 2266 { 2267 if (enable) { 2268 if (rx->softclip_clk_users == 0) 2269 snd_soc_component_write_field(component, CDC_RX_SOFTCLIP_CRC, 2270 CDC_RX_SOFTCLIP_CLK_EN_MASK, 1); 2271 rx->softclip_clk_users++; 2272 } else { 2273 rx->softclip_clk_users--; 2274 if (rx->softclip_clk_users == 0) 2275 snd_soc_component_write_field(component, CDC_RX_SOFTCLIP_CRC, 2276 CDC_RX_SOFTCLIP_CLK_EN_MASK, 0); 2277 } 2278 } 2279 2280 static int rx_macro_config_softclip(struct snd_soc_component *component, 2281 struct rx_macro *rx, int event) 2282 { 2283 2284 if (!rx->is_softclip_on) 2285 return 0; 2286 2287 if (SND_SOC_DAPM_EVENT_ON(event)) { 2288 /* Enable Softclip clock */ 2289 rx_macro_enable_softclip_clk(component, rx, true); 2290 /* Enable Softclip control */ 2291 snd_soc_component_write_field(component, CDC_RX_SOFTCLIP_SOFTCLIP_CTRL, 2292 CDC_RX_SOFTCLIP_EN_MASK, 0x01); 2293 } 2294 2295 if (SND_SOC_DAPM_EVENT_OFF(event)) { 2296 snd_soc_component_write_field(component, CDC_RX_SOFTCLIP_SOFTCLIP_CTRL, 2297 CDC_RX_SOFTCLIP_EN_MASK, 0x0); 2298 rx_macro_enable_softclip_clk(component, rx, false); 2299 } 2300 2301 return 0; 2302 } 2303 2304 static int rx_macro_config_aux_hpf(struct snd_soc_component *component, 2305 struct rx_macro *rx, int event) 2306 { 2307 if (SND_SOC_DAPM_EVENT_ON(event)) { 2308 /* Update Aux HPF control */ 2309 if (!rx->is_aux_hpf_on) 2310 snd_soc_component_update_bits(component, 2311 CDC_RX_RXn_RX_PATH_CFG1(rx, 2), 0x04, 0x00); 2312 } 2313 2314 if (SND_SOC_DAPM_EVENT_OFF(event)) { 2315 /* Reset to default (HPF=ON) */ 2316 snd_soc_component_update_bits(component, 2317 CDC_RX_RXn_RX_PATH_CFG1(rx, 2), 0x04, 0x04); 2318 } 2319 2320 return 0; 2321 } 2322 2323 static inline void rx_macro_enable_clsh_block(struct rx_macro *rx, bool enable) 2324 { 2325 if ((enable && ++rx->clsh_users == 1) || (!enable && --rx->clsh_users == 0)) 2326 snd_soc_component_update_bits(rx->component, CDC_RX_CLSH_CRC, 2327 CDC_RX_CLSH_CLK_EN_MASK, enable); 2328 if (rx->clsh_users < 0) 2329 rx->clsh_users = 0; 2330 } 2331 2332 static int rx_macro_config_classh(struct snd_soc_component *component, 2333 struct rx_macro *rx, 2334 int interp_n, int event) 2335 { 2336 if (SND_SOC_DAPM_EVENT_OFF(event)) { 2337 rx_macro_enable_clsh_block(rx, false); 2338 return 0; 2339 } 2340 2341 if (!SND_SOC_DAPM_EVENT_ON(event)) 2342 return 0; 2343 2344 rx_macro_enable_clsh_block(rx, true); 2345 if (interp_n == INTERP_HPHL || 2346 interp_n == INTERP_HPHR) { 2347 /* 2348 * These K1 values depend on the Headphone Impedance 2349 * For now it is assumed to be 16 ohm 2350 */ 2351 snd_soc_component_write(component, CDC_RX_CLSH_K1_LSB, 0xc0); 2352 snd_soc_component_write_field(component, CDC_RX_CLSH_K1_MSB, 2353 CDC_RX_CLSH_K1_MSB_COEFF_MASK, 0); 2354 } 2355 switch (interp_n) { 2356 case INTERP_HPHL: 2357 if (rx->is_ear_mode_on) 2358 snd_soc_component_update_bits(component, 2359 CDC_RX_CLSH_HPH_V_PA, 2360 CDC_RX_CLSH_HPH_V_PA_MIN_MASK, 0x39); 2361 else 2362 snd_soc_component_update_bits(component, 2363 CDC_RX_CLSH_HPH_V_PA, 2364 CDC_RX_CLSH_HPH_V_PA_MIN_MASK, 0x1c); 2365 snd_soc_component_update_bits(component, 2366 CDC_RX_CLSH_DECAY_CTRL, 2367 CDC_RX_CLSH_DECAY_RATE_MASK, 0x0); 2368 snd_soc_component_write_field(component, 2369 CDC_RX_RXn_RX_PATH_CFG0(rx, 0), 2370 CDC_RX_RXn_CLSH_EN_MASK, 0x1); 2371 break; 2372 case INTERP_HPHR: 2373 if (rx->is_ear_mode_on) 2374 snd_soc_component_update_bits(component, 2375 CDC_RX_CLSH_HPH_V_PA, 2376 CDC_RX_CLSH_HPH_V_PA_MIN_MASK, 0x39); 2377 else 2378 snd_soc_component_update_bits(component, 2379 CDC_RX_CLSH_HPH_V_PA, 2380 CDC_RX_CLSH_HPH_V_PA_MIN_MASK, 0x1c); 2381 snd_soc_component_update_bits(component, 2382 CDC_RX_CLSH_DECAY_CTRL, 2383 CDC_RX_CLSH_DECAY_RATE_MASK, 0x0); 2384 snd_soc_component_write_field(component, 2385 CDC_RX_RXn_RX_PATH_CFG0(rx, 1), 2386 CDC_RX_RXn_CLSH_EN_MASK, 0x1); 2387 break; 2388 case INTERP_AUX: 2389 snd_soc_component_update_bits(component, 2390 CDC_RX_RXn_RX_PATH_CFG0(rx, 2), 2391 CDC_RX_RX2_DLY_Z_EN_MASK, 1); 2392 snd_soc_component_write_field(component, 2393 CDC_RX_RXn_RX_PATH_CFG0(rx, 2), 2394 CDC_RX_RX2_CLSH_EN_MASK, 1); 2395 break; 2396 } 2397 2398 return 0; 2399 } 2400 2401 static void rx_macro_hd2_control(struct snd_soc_component *component, 2402 u16 interp_idx, int event) 2403 { 2404 struct rx_macro *rx = snd_soc_component_get_drvdata(component); 2405 u16 hd2_scale_reg, hd2_enable_reg; 2406 2407 switch (interp_idx) { 2408 case INTERP_HPHL: 2409 hd2_scale_reg = CDC_RX_RXn_RX_PATH_SEC3(rx, 0); 2410 hd2_enable_reg = CDC_RX_RXn_RX_PATH_CFG0(rx, 0); 2411 break; 2412 case INTERP_HPHR: 2413 hd2_scale_reg = CDC_RX_RXn_RX_PATH_SEC3(rx, 1); 2414 hd2_enable_reg = CDC_RX_RXn_RX_PATH_CFG0(rx, 1); 2415 break; 2416 } 2417 2418 if (hd2_enable_reg && SND_SOC_DAPM_EVENT_ON(event)) { 2419 snd_soc_component_update_bits(component, hd2_scale_reg, 2420 CDC_RX_RXn_HD2_ALPHA_MASK, 0x14); 2421 snd_soc_component_write_field(component, hd2_enable_reg, 2422 CDC_RX_RXn_HD2_EN_MASK, 1); 2423 } 2424 2425 if (hd2_enable_reg && SND_SOC_DAPM_EVENT_OFF(event)) { 2426 snd_soc_component_write_field(component, hd2_enable_reg, 2427 CDC_RX_RXn_HD2_EN_MASK, 0); 2428 snd_soc_component_update_bits(component, hd2_scale_reg, 2429 CDC_RX_RXn_HD2_ALPHA_MASK, 0x0); 2430 } 2431 } 2432 2433 static int rx_macro_get_compander(struct snd_kcontrol *kcontrol, 2434 struct snd_ctl_elem_value *ucontrol) 2435 { 2436 struct snd_soc_component *component = 2437 snd_soc_kcontrol_component(kcontrol); 2438 int comp = ((struct soc_mixer_control *) kcontrol->private_value)->shift; 2439 struct rx_macro *rx = snd_soc_component_get_drvdata(component); 2440 2441 ucontrol->value.integer.value[0] = rx->comp_enabled[comp]; 2442 return 0; 2443 } 2444 2445 static int rx_macro_set_compander(struct snd_kcontrol *kcontrol, 2446 struct snd_ctl_elem_value *ucontrol) 2447 { 2448 struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); 2449 int comp = ((struct soc_mixer_control *) kcontrol->private_value)->shift; 2450 int value = ucontrol->value.integer.value[0]; 2451 struct rx_macro *rx = snd_soc_component_get_drvdata(component); 2452 2453 rx->comp_enabled[comp] = value; 2454 2455 return 0; 2456 } 2457 2458 static int rx_macro_mux_get(struct snd_kcontrol *kcontrol, 2459 struct snd_ctl_elem_value *ucontrol) 2460 { 2461 struct snd_soc_dapm_widget *widget = snd_soc_dapm_kcontrol_widget(kcontrol); 2462 struct snd_soc_component *component = snd_soc_dapm_to_component(widget->dapm); 2463 struct rx_macro *rx = snd_soc_component_get_drvdata(component); 2464 2465 ucontrol->value.enumerated.item[0] = 2466 rx->rx_port_value[widget->shift]; 2467 return 0; 2468 } 2469 2470 static int rx_macro_mux_put(struct snd_kcontrol *kcontrol, 2471 struct snd_ctl_elem_value *ucontrol) 2472 { 2473 struct snd_soc_dapm_widget *widget = snd_soc_dapm_kcontrol_widget(kcontrol); 2474 struct snd_soc_component *component = snd_soc_dapm_to_component(widget->dapm); 2475 struct soc_enum *e = (struct soc_enum *)kcontrol->private_value; 2476 struct snd_soc_dapm_update *update = NULL; 2477 u32 rx_port_value = ucontrol->value.enumerated.item[0]; 2478 u32 aif_rst; 2479 struct rx_macro *rx = snd_soc_component_get_drvdata(component); 2480 2481 aif_rst = rx->rx_port_value[widget->shift]; 2482 if (!rx_port_value) { 2483 if (aif_rst == 0) 2484 return 0; 2485 if (aif_rst > RX_MACRO_AIF4_PB) { 2486 dev_err(component->dev, "%s: Invalid AIF reset\n", __func__); 2487 return 0; 2488 } 2489 } 2490 rx->rx_port_value[widget->shift] = rx_port_value; 2491 2492 switch (rx_port_value) { 2493 case 0: 2494 if (rx->active_ch_cnt[aif_rst]) { 2495 clear_bit(widget->shift, 2496 &rx->active_ch_mask[aif_rst]); 2497 rx->active_ch_cnt[aif_rst]--; 2498 } 2499 break; 2500 case 1: 2501 case 2: 2502 case 3: 2503 case 4: 2504 set_bit(widget->shift, 2505 &rx->active_ch_mask[rx_port_value]); 2506 rx->active_ch_cnt[rx_port_value]++; 2507 break; 2508 default: 2509 dev_err(component->dev, 2510 "%s:Invalid AIF_ID for RX_MACRO MUX %d\n", 2511 __func__, rx_port_value); 2512 goto err; 2513 } 2514 2515 snd_soc_dapm_mux_update_power(widget->dapm, kcontrol, 2516 rx_port_value, e, update); 2517 return 0; 2518 err: 2519 return -EINVAL; 2520 } 2521 2522 static const struct snd_kcontrol_new rx_macro_rx0_mux = 2523 SOC_DAPM_ENUM_EXT("rx_macro_rx0", rx_macro_rx0_enum, 2524 rx_macro_mux_get, rx_macro_mux_put); 2525 static const struct snd_kcontrol_new rx_macro_rx1_mux = 2526 SOC_DAPM_ENUM_EXT("rx_macro_rx1", rx_macro_rx1_enum, 2527 rx_macro_mux_get, rx_macro_mux_put); 2528 static const struct snd_kcontrol_new rx_macro_rx2_mux = 2529 SOC_DAPM_ENUM_EXT("rx_macro_rx2", rx_macro_rx2_enum, 2530 rx_macro_mux_get, rx_macro_mux_put); 2531 static const struct snd_kcontrol_new rx_macro_rx3_mux = 2532 SOC_DAPM_ENUM_EXT("rx_macro_rx3", rx_macro_rx3_enum, 2533 rx_macro_mux_get, rx_macro_mux_put); 2534 static const struct snd_kcontrol_new rx_macro_rx4_mux = 2535 SOC_DAPM_ENUM_EXT("rx_macro_rx4", rx_macro_rx4_enum, 2536 rx_macro_mux_get, rx_macro_mux_put); 2537 static const struct snd_kcontrol_new rx_macro_rx5_mux = 2538 SOC_DAPM_ENUM_EXT("rx_macro_rx5", rx_macro_rx5_enum, 2539 rx_macro_mux_get, rx_macro_mux_put); 2540 2541 static int rx_macro_get_ear_mode(struct snd_kcontrol *kcontrol, 2542 struct snd_ctl_elem_value *ucontrol) 2543 { 2544 struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); 2545 struct rx_macro *rx = snd_soc_component_get_drvdata(component); 2546 2547 ucontrol->value.integer.value[0] = rx->is_ear_mode_on; 2548 return 0; 2549 } 2550 2551 static int rx_macro_put_ear_mode(struct snd_kcontrol *kcontrol, 2552 struct snd_ctl_elem_value *ucontrol) 2553 { 2554 struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); 2555 struct rx_macro *rx = snd_soc_component_get_drvdata(component); 2556 2557 rx->is_ear_mode_on = (!ucontrol->value.integer.value[0] ? false : true); 2558 return 0; 2559 } 2560 2561 static int rx_macro_get_hph_hd2_mode(struct snd_kcontrol *kcontrol, 2562 struct snd_ctl_elem_value *ucontrol) 2563 { 2564 struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); 2565 struct rx_macro *rx = snd_soc_component_get_drvdata(component); 2566 2567 ucontrol->value.integer.value[0] = rx->hph_hd2_mode; 2568 return 0; 2569 } 2570 2571 static int rx_macro_put_hph_hd2_mode(struct snd_kcontrol *kcontrol, 2572 struct snd_ctl_elem_value *ucontrol) 2573 { 2574 struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); 2575 struct rx_macro *rx = snd_soc_component_get_drvdata(component); 2576 2577 rx->hph_hd2_mode = ucontrol->value.integer.value[0]; 2578 return 0; 2579 } 2580 2581 static int rx_macro_get_hph_pwr_mode(struct snd_kcontrol *kcontrol, 2582 struct snd_ctl_elem_value *ucontrol) 2583 { 2584 struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); 2585 struct rx_macro *rx = snd_soc_component_get_drvdata(component); 2586 2587 ucontrol->value.enumerated.item[0] = rx->hph_pwr_mode; 2588 return 0; 2589 } 2590 2591 static int rx_macro_put_hph_pwr_mode(struct snd_kcontrol *kcontrol, 2592 struct snd_ctl_elem_value *ucontrol) 2593 { 2594 struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); 2595 struct rx_macro *rx = snd_soc_component_get_drvdata(component); 2596 2597 rx->hph_pwr_mode = ucontrol->value.enumerated.item[0]; 2598 return 0; 2599 } 2600 2601 static int rx_macro_soft_clip_enable_get(struct snd_kcontrol *kcontrol, 2602 struct snd_ctl_elem_value *ucontrol) 2603 { 2604 struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); 2605 struct rx_macro *rx = snd_soc_component_get_drvdata(component); 2606 2607 ucontrol->value.integer.value[0] = rx->is_softclip_on; 2608 2609 return 0; 2610 } 2611 2612 static int rx_macro_soft_clip_enable_put(struct snd_kcontrol *kcontrol, 2613 struct snd_ctl_elem_value *ucontrol) 2614 { 2615 struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); 2616 struct rx_macro *rx = snd_soc_component_get_drvdata(component); 2617 2618 rx->is_softclip_on = ucontrol->value.integer.value[0]; 2619 2620 return 0; 2621 } 2622 2623 static int rx_macro_aux_hpf_mode_get(struct snd_kcontrol *kcontrol, 2624 struct snd_ctl_elem_value *ucontrol) 2625 { 2626 struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); 2627 struct rx_macro *rx = snd_soc_component_get_drvdata(component); 2628 2629 ucontrol->value.integer.value[0] = rx->is_aux_hpf_on; 2630 2631 return 0; 2632 } 2633 2634 static int rx_macro_aux_hpf_mode_put(struct snd_kcontrol *kcontrol, 2635 struct snd_ctl_elem_value *ucontrol) 2636 { 2637 struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); 2638 struct rx_macro *rx = snd_soc_component_get_drvdata(component); 2639 2640 rx->is_aux_hpf_on = ucontrol->value.integer.value[0]; 2641 2642 return 0; 2643 } 2644 2645 static int rx_macro_hphdelay_lutbypass(struct snd_soc_component *component, 2646 struct rx_macro *rx, 2647 u16 interp_idx, int event) 2648 { 2649 u16 hph_lut_bypass_reg; 2650 u16 hph_comp_ctrl7; 2651 2652 switch (interp_idx) { 2653 case INTERP_HPHL: 2654 hph_lut_bypass_reg = CDC_RX_TOP_HPHL_COMP_LUT; 2655 hph_comp_ctrl7 = CDC_RX_COMPANDER0_CTL7; 2656 break; 2657 case INTERP_HPHR: 2658 hph_lut_bypass_reg = CDC_RX_TOP_HPHR_COMP_LUT; 2659 hph_comp_ctrl7 = CDC_RX_COMPANDER1_CTL7; 2660 break; 2661 default: 2662 return -EINVAL; 2663 } 2664 2665 if (hph_lut_bypass_reg && SND_SOC_DAPM_EVENT_ON(event)) { 2666 if (interp_idx == INTERP_HPHL) { 2667 if (rx->is_ear_mode_on) 2668 snd_soc_component_write_field(component, 2669 CDC_RX_RXn_RX_PATH_CFG1(rx, 0), 2670 CDC_RX_RX0_HPH_L_EAR_SEL_MASK, 0x1); 2671 else 2672 snd_soc_component_write_field(component, 2673 hph_lut_bypass_reg, 2674 CDC_RX_TOP_HPH_LUT_BYPASS_MASK, 1); 2675 } else { 2676 snd_soc_component_write_field(component, hph_lut_bypass_reg, 2677 CDC_RX_TOP_HPH_LUT_BYPASS_MASK, 1); 2678 } 2679 if (rx->hph_pwr_mode) 2680 snd_soc_component_write_field(component, hph_comp_ctrl7, 2681 CDC_RX_COMPANDER1_HPH_LOW_PWR_MODE_MASK, 0x0); 2682 } 2683 2684 if (hph_lut_bypass_reg && SND_SOC_DAPM_EVENT_OFF(event)) { 2685 snd_soc_component_write_field(component, 2686 CDC_RX_RXn_RX_PATH_CFG1(rx, 0), 2687 CDC_RX_RX0_HPH_L_EAR_SEL_MASK, 0x0); 2688 snd_soc_component_update_bits(component, hph_lut_bypass_reg, 2689 CDC_RX_TOP_HPH_LUT_BYPASS_MASK, 0); 2690 snd_soc_component_write_field(component, hph_comp_ctrl7, 2691 CDC_RX_COMPANDER1_HPH_LOW_PWR_MODE_MASK, 0x1); 2692 } 2693 2694 return 0; 2695 } 2696 2697 static int rx_macro_enable_interp_clk(struct snd_soc_component *component, 2698 int event, int interp_idx) 2699 { 2700 u16 main_reg, dsm_reg, rx_cfg2_reg; 2701 struct rx_macro *rx = snd_soc_component_get_drvdata(component); 2702 2703 main_reg = CDC_RX_RXn_RX_PATH_CTL(rx, interp_idx); 2704 dsm_reg = CDC_RX_RXn_RX_PATH_DSM_CTL(rx, interp_idx); 2705 if (interp_idx == INTERP_AUX) 2706 dsm_reg = CDC_RX_RXn_RX_PATH_DSM_CTL(rx, 2); 2707 2708 rx_cfg2_reg = CDC_RX_RXn_RX_PATH_CFG2(rx, interp_idx); 2709 2710 if (SND_SOC_DAPM_EVENT_ON(event)) { 2711 if (rx->main_clk_users[interp_idx] == 0) { 2712 /* Main path PGA mute enable */ 2713 snd_soc_component_write_field(component, main_reg, 2714 CDC_RX_PATH_PGA_MUTE_MASK, 0x1); 2715 snd_soc_component_write_field(component, dsm_reg, 2716 CDC_RX_RXn_DSM_CLK_EN_MASK, 0x1); 2717 snd_soc_component_update_bits(component, rx_cfg2_reg, 2718 CDC_RX_RXn_HPF_CUT_FREQ_MASK, 0x03); 2719 rx_macro_load_compander_coeff(component, rx, interp_idx, event); 2720 if (rx->hph_hd2_mode) 2721 rx_macro_hd2_control(component, interp_idx, event); 2722 rx_macro_hphdelay_lutbypass(component, rx, interp_idx, event); 2723 rx_macro_config_compander(component, rx, interp_idx, event); 2724 if (interp_idx == INTERP_AUX) { 2725 rx_macro_config_softclip(component, rx, event); 2726 rx_macro_config_aux_hpf(component, rx, event); 2727 } 2728 rx_macro_config_classh(component, rx, interp_idx, event); 2729 } 2730 rx->main_clk_users[interp_idx]++; 2731 } 2732 2733 if (SND_SOC_DAPM_EVENT_OFF(event)) { 2734 rx->main_clk_users[interp_idx]--; 2735 if (rx->main_clk_users[interp_idx] <= 0) { 2736 rx->main_clk_users[interp_idx] = 0; 2737 /* Main path PGA mute enable */ 2738 snd_soc_component_write_field(component, main_reg, 2739 CDC_RX_PATH_PGA_MUTE_MASK, 0x1); 2740 /* Clk Disable */ 2741 snd_soc_component_write_field(component, dsm_reg, 2742 CDC_RX_RXn_DSM_CLK_EN_MASK, 0); 2743 snd_soc_component_write_field(component, main_reg, 2744 CDC_RX_PATH_CLK_EN_MASK, 0); 2745 /* Reset enable and disable */ 2746 snd_soc_component_write_field(component, main_reg, 2747 CDC_RX_PATH_RESET_EN_MASK, 1); 2748 snd_soc_component_write_field(component, main_reg, 2749 CDC_RX_PATH_RESET_EN_MASK, 0); 2750 /* Reset rate to 48K*/ 2751 snd_soc_component_update_bits(component, main_reg, 2752 CDC_RX_PATH_PCM_RATE_MASK, 2753 0x04); 2754 snd_soc_component_update_bits(component, rx_cfg2_reg, 2755 CDC_RX_RXn_HPF_CUT_FREQ_MASK, 0x00); 2756 rx_macro_config_classh(component, rx, interp_idx, event); 2757 rx_macro_config_compander(component, rx, interp_idx, event); 2758 if (interp_idx == INTERP_AUX) { 2759 rx_macro_config_softclip(component, rx, event); 2760 rx_macro_config_aux_hpf(component, rx, event); 2761 } 2762 rx_macro_hphdelay_lutbypass(component, rx, interp_idx, event); 2763 if (rx->hph_hd2_mode) 2764 rx_macro_hd2_control(component, interp_idx, event); 2765 } 2766 } 2767 2768 return rx->main_clk_users[interp_idx]; 2769 } 2770 2771 static int rx_macro_enable_mix_path(struct snd_soc_dapm_widget *w, 2772 struct snd_kcontrol *kcontrol, int event) 2773 { 2774 struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); 2775 struct rx_macro *rx = snd_soc_component_get_drvdata(component); 2776 u16 gain_reg, mix_reg; 2777 2778 gain_reg = CDC_RX_RXn_RX_VOL_MIX_CTL(rx, w->shift); 2779 mix_reg = CDC_RX_RXn_RX_PATH_MIX_CTL(rx, w->shift); 2780 2781 switch (event) { 2782 case SND_SOC_DAPM_PRE_PMU: 2783 rx_macro_enable_interp_clk(component, event, w->shift); 2784 break; 2785 case SND_SOC_DAPM_POST_PMU: 2786 snd_soc_component_write(component, gain_reg, 2787 snd_soc_component_read(component, gain_reg)); 2788 break; 2789 case SND_SOC_DAPM_POST_PMD: 2790 /* Clk Disable */ 2791 snd_soc_component_update_bits(component, mix_reg, 2792 CDC_RX_RXn_MIX_CLK_EN_MASK, 0x00); 2793 rx_macro_enable_interp_clk(component, event, w->shift); 2794 /* Reset enable and disable */ 2795 snd_soc_component_update_bits(component, mix_reg, 2796 CDC_RX_RXn_MIX_RESET_MASK, 2797 CDC_RX_RXn_MIX_RESET); 2798 snd_soc_component_update_bits(component, mix_reg, 2799 CDC_RX_RXn_MIX_RESET_MASK, 0x00); 2800 break; 2801 } 2802 2803 return 0; 2804 } 2805 2806 static int rx_macro_enable_rx_path_clk(struct snd_soc_dapm_widget *w, 2807 struct snd_kcontrol *kcontrol, int event) 2808 { 2809 struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); 2810 struct rx_macro *rx = snd_soc_component_get_drvdata(component); 2811 2812 switch (event) { 2813 case SND_SOC_DAPM_PRE_PMU: 2814 rx_macro_enable_interp_clk(component, event, w->shift); 2815 snd_soc_component_write_field(component, CDC_RX_RXn_RX_PATH_CFG1(rx, w->shift), 2816 CDC_RX_RXn_SIDETONE_EN_MASK, 1); 2817 snd_soc_component_write_field(component, CDC_RX_RXn_RX_PATH_CTL(rx, w->shift), 2818 CDC_RX_PATH_CLK_EN_MASK, 1); 2819 break; 2820 case SND_SOC_DAPM_POST_PMD: 2821 snd_soc_component_write_field(component, CDC_RX_RXn_RX_PATH_CFG1(rx, w->shift), 2822 CDC_RX_RXn_SIDETONE_EN_MASK, 0); 2823 rx_macro_enable_interp_clk(component, event, w->shift); 2824 break; 2825 default: 2826 break; 2827 } 2828 return 0; 2829 } 2830 2831 static int rx_macro_set_iir_gain(struct snd_soc_dapm_widget *w, 2832 struct snd_kcontrol *kcontrol, int event) 2833 { 2834 struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); 2835 2836 switch (event) { 2837 case SND_SOC_DAPM_POST_PMU: /* fall through */ 2838 case SND_SOC_DAPM_PRE_PMD: 2839 if (strnstr(w->name, "IIR0", sizeof("IIR0"))) { 2840 snd_soc_component_write(component, 2841 CDC_RX_SIDETONE_IIR0_IIR_GAIN_B1_CTL, 2842 snd_soc_component_read(component, 2843 CDC_RX_SIDETONE_IIR0_IIR_GAIN_B1_CTL)); 2844 snd_soc_component_write(component, 2845 CDC_RX_SIDETONE_IIR0_IIR_GAIN_B2_CTL, 2846 snd_soc_component_read(component, 2847 CDC_RX_SIDETONE_IIR0_IIR_GAIN_B2_CTL)); 2848 snd_soc_component_write(component, 2849 CDC_RX_SIDETONE_IIR0_IIR_GAIN_B3_CTL, 2850 snd_soc_component_read(component, 2851 CDC_RX_SIDETONE_IIR0_IIR_GAIN_B3_CTL)); 2852 snd_soc_component_write(component, 2853 CDC_RX_SIDETONE_IIR0_IIR_GAIN_B4_CTL, 2854 snd_soc_component_read(component, 2855 CDC_RX_SIDETONE_IIR0_IIR_GAIN_B4_CTL)); 2856 } else { 2857 snd_soc_component_write(component, 2858 CDC_RX_SIDETONE_IIR1_IIR_GAIN_B1_CTL, 2859 snd_soc_component_read(component, 2860 CDC_RX_SIDETONE_IIR1_IIR_GAIN_B1_CTL)); 2861 snd_soc_component_write(component, 2862 CDC_RX_SIDETONE_IIR1_IIR_GAIN_B2_CTL, 2863 snd_soc_component_read(component, 2864 CDC_RX_SIDETONE_IIR1_IIR_GAIN_B2_CTL)); 2865 snd_soc_component_write(component, 2866 CDC_RX_SIDETONE_IIR1_IIR_GAIN_B3_CTL, 2867 snd_soc_component_read(component, 2868 CDC_RX_SIDETONE_IIR1_IIR_GAIN_B3_CTL)); 2869 snd_soc_component_write(component, 2870 CDC_RX_SIDETONE_IIR1_IIR_GAIN_B4_CTL, 2871 snd_soc_component_read(component, 2872 CDC_RX_SIDETONE_IIR1_IIR_GAIN_B4_CTL)); 2873 } 2874 break; 2875 } 2876 return 0; 2877 } 2878 2879 static uint32_t get_iir_band_coeff(struct snd_soc_component *component, 2880 int iir_idx, int band_idx, int coeff_idx) 2881 { 2882 u32 value; 2883 int reg, b2_reg; 2884 2885 /* Address does not automatically update if reading */ 2886 reg = CDC_RX_SIDETONE_IIR0_IIR_COEF_B1_CTL + 0x80 * iir_idx; 2887 b2_reg = CDC_RX_SIDETONE_IIR0_IIR_COEF_B2_CTL + 0x80 * iir_idx; 2888 2889 snd_soc_component_write(component, reg, 2890 ((band_idx * BAND_MAX + coeff_idx) * 2891 sizeof(uint32_t)) & 0x7F); 2892 2893 value = snd_soc_component_read(component, b2_reg); 2894 snd_soc_component_write(component, reg, 2895 ((band_idx * BAND_MAX + coeff_idx) 2896 * sizeof(uint32_t) + 1) & 0x7F); 2897 2898 value |= (snd_soc_component_read(component, b2_reg) << 8); 2899 snd_soc_component_write(component, reg, 2900 ((band_idx * BAND_MAX + coeff_idx) 2901 * sizeof(uint32_t) + 2) & 0x7F); 2902 2903 value |= (snd_soc_component_read(component, b2_reg) << 16); 2904 snd_soc_component_write(component, reg, 2905 ((band_idx * BAND_MAX + coeff_idx) 2906 * sizeof(uint32_t) + 3) & 0x7F); 2907 2908 /* Mask bits top 2 bits since they are reserved */ 2909 value |= (snd_soc_component_read(component, b2_reg) << 24); 2910 return value; 2911 } 2912 2913 static void set_iir_band_coeff(struct snd_soc_component *component, 2914 int iir_idx, int band_idx, uint32_t value) 2915 { 2916 int reg = CDC_RX_SIDETONE_IIR0_IIR_COEF_B2_CTL + 0x80 * iir_idx; 2917 2918 snd_soc_component_write(component, reg, (value & 0xFF)); 2919 snd_soc_component_write(component, reg, (value >> 8) & 0xFF); 2920 snd_soc_component_write(component, reg, (value >> 16) & 0xFF); 2921 /* Mask top 2 bits, 7-8 are reserved */ 2922 snd_soc_component_write(component, reg, (value >> 24) & 0x3F); 2923 } 2924 2925 static int rx_macro_put_iir_band_audio_mixer( 2926 struct snd_kcontrol *kcontrol, 2927 struct snd_ctl_elem_value *ucontrol) 2928 { 2929 struct snd_soc_component *component = 2930 snd_soc_kcontrol_component(kcontrol); 2931 struct wcd_iir_filter_ctl *ctl = 2932 (struct wcd_iir_filter_ctl *)kcontrol->private_value; 2933 struct soc_bytes_ext *params = &ctl->bytes_ext; 2934 int iir_idx = ctl->iir_idx; 2935 int band_idx = ctl->band_idx; 2936 u32 coeff[BAND_MAX]; 2937 int reg = CDC_RX_SIDETONE_IIR0_IIR_COEF_B1_CTL + 0x80 * iir_idx; 2938 2939 memcpy(&coeff[0], ucontrol->value.bytes.data, params->max); 2940 2941 /* Mask top bit it is reserved */ 2942 /* Updates addr automatically for each B2 write */ 2943 snd_soc_component_write(component, reg, (band_idx * BAND_MAX * 2944 sizeof(uint32_t)) & 0x7F); 2945 2946 set_iir_band_coeff(component, iir_idx, band_idx, coeff[0]); 2947 set_iir_band_coeff(component, iir_idx, band_idx, coeff[1]); 2948 set_iir_band_coeff(component, iir_idx, band_idx, coeff[2]); 2949 set_iir_band_coeff(component, iir_idx, band_idx, coeff[3]); 2950 set_iir_band_coeff(component, iir_idx, band_idx, coeff[4]); 2951 2952 return 0; 2953 } 2954 2955 static int rx_macro_get_iir_band_audio_mixer(struct snd_kcontrol *kcontrol, 2956 struct snd_ctl_elem_value *ucontrol) 2957 { 2958 struct snd_soc_component *component = 2959 snd_soc_kcontrol_component(kcontrol); 2960 struct wcd_iir_filter_ctl *ctl = 2961 (struct wcd_iir_filter_ctl *)kcontrol->private_value; 2962 struct soc_bytes_ext *params = &ctl->bytes_ext; 2963 int iir_idx = ctl->iir_idx; 2964 int band_idx = ctl->band_idx; 2965 u32 coeff[BAND_MAX]; 2966 2967 coeff[0] = get_iir_band_coeff(component, iir_idx, band_idx, 0); 2968 coeff[1] = get_iir_band_coeff(component, iir_idx, band_idx, 1); 2969 coeff[2] = get_iir_band_coeff(component, iir_idx, band_idx, 2); 2970 coeff[3] = get_iir_band_coeff(component, iir_idx, band_idx, 3); 2971 coeff[4] = get_iir_band_coeff(component, iir_idx, band_idx, 4); 2972 2973 memcpy(ucontrol->value.bytes.data, &coeff[0], params->max); 2974 2975 return 0; 2976 } 2977 2978 static int rx_macro_iir_filter_info(struct snd_kcontrol *kcontrol, 2979 struct snd_ctl_elem_info *ucontrol) 2980 { 2981 struct wcd_iir_filter_ctl *ctl = 2982 (struct wcd_iir_filter_ctl *)kcontrol->private_value; 2983 struct soc_bytes_ext *params = &ctl->bytes_ext; 2984 2985 ucontrol->type = SNDRV_CTL_ELEM_TYPE_BYTES; 2986 ucontrol->count = params->max; 2987 2988 return 0; 2989 } 2990 2991 static const struct snd_kcontrol_new rx_macro_def_snd_controls[] = { 2992 SOC_SINGLE_S8_TLV("RX_RX1 Digital Volume", CDC_RX_RX1_RX_VOL_CTL, 2993 -84, 40, digital_gain), 2994 SOC_SINGLE_S8_TLV("RX_RX2 Digital Volume", CDC_RX_RX2_RX_VOL_CTL, 2995 -84, 40, digital_gain), 2996 SOC_SINGLE_S8_TLV("RX_RX1 Mix Digital Volume", CDC_RX_RX1_RX_VOL_MIX_CTL, 2997 -84, 40, digital_gain), 2998 SOC_SINGLE_S8_TLV("RX_RX2 Mix Digital Volume", CDC_RX_RX2_RX_VOL_MIX_CTL, 2999 -84, 40, digital_gain), 3000 }; 3001 3002 static const struct snd_kcontrol_new rx_macro_2_5_snd_controls[] = { 3003 3004 SOC_SINGLE_S8_TLV("RX_RX1 Digital Volume", CDC_2_5_RX_RX1_RX_VOL_CTL, 3005 -84, 40, digital_gain), 3006 SOC_SINGLE_S8_TLV("RX_RX2 Digital Volume", CDC_2_5_RX_RX2_RX_VOL_CTL, 3007 -84, 40, digital_gain), 3008 SOC_SINGLE_S8_TLV("RX_RX1 Mix Digital Volume", CDC_2_5_RX_RX1_RX_VOL_MIX_CTL, 3009 -84, 40, digital_gain), 3010 SOC_SINGLE_S8_TLV("RX_RX2 Mix Digital Volume", CDC_2_5_RX_RX2_RX_VOL_MIX_CTL, 3011 -84, 40, digital_gain), 3012 }; 3013 3014 static const struct snd_kcontrol_new rx_macro_snd_controls[] = { 3015 SOC_SINGLE_S8_TLV("RX_RX0 Digital Volume", CDC_RX_RX0_RX_VOL_CTL, 3016 -84, 40, digital_gain), 3017 SOC_SINGLE_S8_TLV("RX_RX0 Mix Digital Volume", CDC_RX_RX0_RX_VOL_MIX_CTL, 3018 -84, 40, digital_gain), 3019 SOC_SINGLE_EXT("RX_COMP1 Switch", SND_SOC_NOPM, RX_MACRO_COMP1, 1, 0, 3020 rx_macro_get_compander, rx_macro_set_compander), 3021 SOC_SINGLE_EXT("RX_COMP2 Switch", SND_SOC_NOPM, RX_MACRO_COMP2, 1, 0, 3022 rx_macro_get_compander, rx_macro_set_compander), 3023 3024 SOC_SINGLE_EXT("RX_EAR Mode Switch", SND_SOC_NOPM, 0, 1, 0, 3025 rx_macro_get_ear_mode, rx_macro_put_ear_mode), 3026 3027 SOC_SINGLE_EXT("RX_HPH HD2 Mode Switch", SND_SOC_NOPM, 0, 1, 0, 3028 rx_macro_get_hph_hd2_mode, rx_macro_put_hph_hd2_mode), 3029 3030 SOC_ENUM_EXT("RX_HPH PWR Mode", rx_macro_hph_pwr_mode_enum, 3031 rx_macro_get_hph_pwr_mode, rx_macro_put_hph_pwr_mode), 3032 3033 SOC_SINGLE_EXT("RX_Softclip Switch", SND_SOC_NOPM, 0, 1, 0, 3034 rx_macro_soft_clip_enable_get, 3035 rx_macro_soft_clip_enable_put), 3036 SOC_SINGLE_EXT("AUX_HPF Switch", SND_SOC_NOPM, 0, 1, 0, 3037 rx_macro_aux_hpf_mode_get, 3038 rx_macro_aux_hpf_mode_put), 3039 3040 SOC_SINGLE_S8_TLV("IIR0 INP0 Volume", 3041 CDC_RX_SIDETONE_IIR0_IIR_GAIN_B1_CTL, -84, 40, 3042 digital_gain), 3043 SOC_SINGLE_S8_TLV("IIR0 INP1 Volume", 3044 CDC_RX_SIDETONE_IIR0_IIR_GAIN_B2_CTL, -84, 40, 3045 digital_gain), 3046 SOC_SINGLE_S8_TLV("IIR0 INP2 Volume", 3047 CDC_RX_SIDETONE_IIR0_IIR_GAIN_B3_CTL, -84, 40, 3048 digital_gain), 3049 SOC_SINGLE_S8_TLV("IIR0 INP3 Volume", 3050 CDC_RX_SIDETONE_IIR0_IIR_GAIN_B4_CTL, -84, 40, 3051 digital_gain), 3052 SOC_SINGLE_S8_TLV("IIR1 INP0 Volume", 3053 CDC_RX_SIDETONE_IIR1_IIR_GAIN_B1_CTL, -84, 40, 3054 digital_gain), 3055 SOC_SINGLE_S8_TLV("IIR1 INP1 Volume", 3056 CDC_RX_SIDETONE_IIR1_IIR_GAIN_B2_CTL, -84, 40, 3057 digital_gain), 3058 SOC_SINGLE_S8_TLV("IIR1 INP2 Volume", 3059 CDC_RX_SIDETONE_IIR1_IIR_GAIN_B3_CTL, -84, 40, 3060 digital_gain), 3061 SOC_SINGLE_S8_TLV("IIR1 INP3 Volume", 3062 CDC_RX_SIDETONE_IIR1_IIR_GAIN_B4_CTL, -84, 40, 3063 digital_gain), 3064 3065 SOC_SINGLE("IIR1 Band1 Switch", CDC_RX_SIDETONE_IIR0_IIR_CTL, 3066 0, 1, 0), 3067 SOC_SINGLE("IIR1 Band2 Switch", CDC_RX_SIDETONE_IIR0_IIR_CTL, 3068 1, 1, 0), 3069 SOC_SINGLE("IIR1 Band3 Switch", CDC_RX_SIDETONE_IIR0_IIR_CTL, 3070 2, 1, 0), 3071 SOC_SINGLE("IIR1 Band4 Switch", CDC_RX_SIDETONE_IIR0_IIR_CTL, 3072 3, 1, 0), 3073 SOC_SINGLE("IIR1 Band5 Switch", CDC_RX_SIDETONE_IIR0_IIR_CTL, 3074 4, 1, 0), 3075 SOC_SINGLE("IIR2 Band1 Switch", CDC_RX_SIDETONE_IIR1_IIR_CTL, 3076 0, 1, 0), 3077 SOC_SINGLE("IIR2 Band2 Switch", CDC_RX_SIDETONE_IIR1_IIR_CTL, 3078 1, 1, 0), 3079 SOC_SINGLE("IIR2 Band3 Switch", CDC_RX_SIDETONE_IIR1_IIR_CTL, 3080 2, 1, 0), 3081 SOC_SINGLE("IIR2 Band4 Switch", CDC_RX_SIDETONE_IIR1_IIR_CTL, 3082 3, 1, 0), 3083 SOC_SINGLE("IIR2 Band5 Switch", CDC_RX_SIDETONE_IIR1_IIR_CTL, 3084 4, 1, 0), 3085 3086 RX_MACRO_IIR_FILTER_CTL("IIR0 Band1", IIR0, BAND1), 3087 RX_MACRO_IIR_FILTER_CTL("IIR0 Band2", IIR0, BAND2), 3088 RX_MACRO_IIR_FILTER_CTL("IIR0 Band3", IIR0, BAND3), 3089 RX_MACRO_IIR_FILTER_CTL("IIR0 Band4", IIR0, BAND4), 3090 RX_MACRO_IIR_FILTER_CTL("IIR0 Band5", IIR0, BAND5), 3091 3092 RX_MACRO_IIR_FILTER_CTL("IIR1 Band1", IIR1, BAND1), 3093 RX_MACRO_IIR_FILTER_CTL("IIR1 Band2", IIR1, BAND2), 3094 RX_MACRO_IIR_FILTER_CTL("IIR1 Band3", IIR1, BAND3), 3095 RX_MACRO_IIR_FILTER_CTL("IIR1 Band4", IIR1, BAND4), 3096 RX_MACRO_IIR_FILTER_CTL("IIR1 Band5", IIR1, BAND5), 3097 3098 }; 3099 3100 static int rx_macro_enable_echo(struct snd_soc_dapm_widget *w, 3101 struct snd_kcontrol *kcontrol, 3102 int event) 3103 { 3104 struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); 3105 u16 val, ec_hq_reg; 3106 int ec_tx = -1; 3107 3108 val = snd_soc_component_read(component, 3109 CDC_RX_INP_MUX_RX_MIX_CFG4); 3110 if (!(snd_soc_dapm_widget_name_cmp(w, "RX MIX TX0 MUX"))) 3111 ec_tx = ((val & 0xf0) >> 0x4) - 1; 3112 else if (!(snd_soc_dapm_widget_name_cmp(w, "RX MIX TX1 MUX"))) 3113 ec_tx = (val & 0x0f) - 1; 3114 3115 val = snd_soc_component_read(component, 3116 CDC_RX_INP_MUX_RX_MIX_CFG5); 3117 if (!(snd_soc_dapm_widget_name_cmp(w, "RX MIX TX2 MUX"))) 3118 ec_tx = (val & 0x0f) - 1; 3119 3120 if (ec_tx < 0 || (ec_tx >= RX_MACRO_EC_MUX_MAX)) { 3121 dev_err(component->dev, "%s: EC mix control not set correctly\n", 3122 __func__); 3123 return -EINVAL; 3124 } 3125 ec_hq_reg = CDC_RX_EC_REF_HQ0_EC_REF_HQ_PATH_CTL + 3126 0x40 * ec_tx; 3127 snd_soc_component_update_bits(component, ec_hq_reg, 0x01, 0x01); 3128 ec_hq_reg = CDC_RX_EC_REF_HQ0_EC_REF_HQ_CFG0 + 3129 0x40 * ec_tx; 3130 /* default set to 48k */ 3131 snd_soc_component_update_bits(component, ec_hq_reg, 0x1E, 0x08); 3132 3133 return 0; 3134 } 3135 3136 static const struct snd_soc_dapm_widget rx_macro_2_5_dapm_widgets[] = { 3137 SND_SOC_DAPM_MUX("RX INT1 DEM MUX", SND_SOC_NOPM, 0, 0, 3138 &rx_2_5_int1_dem_inp_mux), 3139 }; 3140 3141 static const struct snd_soc_dapm_widget rx_macro_def_dapm_widgets[] = { 3142 SND_SOC_DAPM_MUX("RX INT1 DEM MUX", SND_SOC_NOPM, 0, 0, 3143 &rx_int1_dem_inp_mux), 3144 }; 3145 3146 static const struct snd_soc_dapm_widget rx_macro_dapm_widgets[] = { 3147 SND_SOC_DAPM_AIF_IN("RX AIF1 PB", "RX_MACRO_AIF1 Playback", 0, 3148 SND_SOC_NOPM, 0, 0), 3149 3150 SND_SOC_DAPM_AIF_IN("RX AIF2 PB", "RX_MACRO_AIF2 Playback", 0, 3151 SND_SOC_NOPM, 0, 0), 3152 3153 SND_SOC_DAPM_AIF_IN("RX AIF3 PB", "RX_MACRO_AIF3 Playback", 0, 3154 SND_SOC_NOPM, 0, 0), 3155 3156 SND_SOC_DAPM_AIF_IN("RX AIF4 PB", "RX_MACRO_AIF4 Playback", 0, 3157 SND_SOC_NOPM, 0, 0), 3158 3159 SND_SOC_DAPM_AIF_OUT("RX AIF_ECHO", "RX_AIF_ECHO Capture", 0, 3160 SND_SOC_NOPM, 0, 0), 3161 3162 SND_SOC_DAPM_MUX("RX_MACRO RX0 MUX", SND_SOC_NOPM, RX_MACRO_RX0, 0, 3163 &rx_macro_rx0_mux), 3164 SND_SOC_DAPM_MUX("RX_MACRO RX1 MUX", SND_SOC_NOPM, RX_MACRO_RX1, 0, 3165 &rx_macro_rx1_mux), 3166 SND_SOC_DAPM_MUX("RX_MACRO RX2 MUX", SND_SOC_NOPM, RX_MACRO_RX2, 0, 3167 &rx_macro_rx2_mux), 3168 SND_SOC_DAPM_MUX("RX_MACRO RX3 MUX", SND_SOC_NOPM, RX_MACRO_RX3, 0, 3169 &rx_macro_rx3_mux), 3170 SND_SOC_DAPM_MUX("RX_MACRO RX4 MUX", SND_SOC_NOPM, RX_MACRO_RX4, 0, 3171 &rx_macro_rx4_mux), 3172 SND_SOC_DAPM_MUX("RX_MACRO RX5 MUX", SND_SOC_NOPM, RX_MACRO_RX5, 0, 3173 &rx_macro_rx5_mux), 3174 3175 SND_SOC_DAPM_MIXER("RX_RX0", SND_SOC_NOPM, 0, 0, NULL, 0), 3176 SND_SOC_DAPM_MIXER("RX_RX1", SND_SOC_NOPM, 0, 0, NULL, 0), 3177 SND_SOC_DAPM_MIXER("RX_RX2", SND_SOC_NOPM, 0, 0, NULL, 0), 3178 SND_SOC_DAPM_MIXER("RX_RX3", SND_SOC_NOPM, 0, 0, NULL, 0), 3179 SND_SOC_DAPM_MIXER("RX_RX4", SND_SOC_NOPM, 0, 0, NULL, 0), 3180 SND_SOC_DAPM_MIXER("RX_RX5", SND_SOC_NOPM, 0, 0, NULL, 0), 3181 3182 SND_SOC_DAPM_MUX("IIR0 INP0 MUX", SND_SOC_NOPM, 0, 0, &iir0_inp0_mux), 3183 SND_SOC_DAPM_MUX("IIR0 INP1 MUX", SND_SOC_NOPM, 0, 0, &iir0_inp1_mux), 3184 SND_SOC_DAPM_MUX("IIR0 INP2 MUX", SND_SOC_NOPM, 0, 0, &iir0_inp2_mux), 3185 SND_SOC_DAPM_MUX("IIR0 INP3 MUX", SND_SOC_NOPM, 0, 0, &iir0_inp3_mux), 3186 SND_SOC_DAPM_MUX("IIR1 INP0 MUX", SND_SOC_NOPM, 0, 0, &iir1_inp0_mux), 3187 SND_SOC_DAPM_MUX("IIR1 INP1 MUX", SND_SOC_NOPM, 0, 0, &iir1_inp1_mux), 3188 SND_SOC_DAPM_MUX("IIR1 INP2 MUX", SND_SOC_NOPM, 0, 0, &iir1_inp2_mux), 3189 SND_SOC_DAPM_MUX("IIR1 INP3 MUX", SND_SOC_NOPM, 0, 0, &iir1_inp3_mux), 3190 3191 SND_SOC_DAPM_MUX_E("RX MIX TX0 MUX", SND_SOC_NOPM, 3192 RX_MACRO_EC0_MUX, 0, 3193 &rx_mix_tx0_mux, rx_macro_enable_echo, 3194 SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD), 3195 SND_SOC_DAPM_MUX_E("RX MIX TX1 MUX", SND_SOC_NOPM, 3196 RX_MACRO_EC1_MUX, 0, 3197 &rx_mix_tx1_mux, rx_macro_enable_echo, 3198 SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD), 3199 SND_SOC_DAPM_MUX_E("RX MIX TX2 MUX", SND_SOC_NOPM, 3200 RX_MACRO_EC2_MUX, 0, 3201 &rx_mix_tx2_mux, rx_macro_enable_echo, 3202 SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD), 3203 3204 SND_SOC_DAPM_MIXER_E("IIR0", CDC_RX_SIDETONE_IIR0_IIR_PATH_CTL, 3205 4, 0, NULL, 0, rx_macro_set_iir_gain, 3206 SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_PRE_PMD), 3207 SND_SOC_DAPM_MIXER_E("IIR1", CDC_RX_SIDETONE_IIR1_IIR_PATH_CTL, 3208 4, 0, NULL, 0, rx_macro_set_iir_gain, 3209 SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_PRE_PMD), 3210 SND_SOC_DAPM_MIXER("SRC0", CDC_RX_SIDETONE_SRC0_ST_SRC_PATH_CTL, 3211 4, 0, NULL, 0), 3212 SND_SOC_DAPM_MIXER("SRC1", CDC_RX_SIDETONE_SRC1_ST_SRC_PATH_CTL, 3213 4, 0, NULL, 0), 3214 3215 SND_SOC_DAPM_MUX("RX INT0 DEM MUX", SND_SOC_NOPM, 0, 0, 3216 &rx_int0_dem_inp_mux), 3217 3218 SND_SOC_DAPM_MUX_E("RX INT0_2 MUX", SND_SOC_NOPM, INTERP_HPHL, 0, 3219 &rx_int0_2_mux, rx_macro_enable_mix_path, 3220 SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU | 3221 SND_SOC_DAPM_POST_PMD), 3222 SND_SOC_DAPM_MUX_E("RX INT1_2 MUX", SND_SOC_NOPM, INTERP_HPHR, 0, 3223 &rx_int1_2_mux, rx_macro_enable_mix_path, 3224 SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU | 3225 SND_SOC_DAPM_POST_PMD), 3226 SND_SOC_DAPM_MUX_E("RX INT2_2 MUX", SND_SOC_NOPM, INTERP_AUX, 0, 3227 &rx_int2_2_mux, rx_macro_enable_mix_path, 3228 SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU | 3229 SND_SOC_DAPM_POST_PMD), 3230 3231 SND_SOC_DAPM_MUX("RX INT0_1 MIX1 INP0", SND_SOC_NOPM, 0, 0, &rx_int0_1_mix_inp0_mux), 3232 SND_SOC_DAPM_MUX("RX INT0_1 MIX1 INP1", SND_SOC_NOPM, 0, 0, &rx_int0_1_mix_inp1_mux), 3233 SND_SOC_DAPM_MUX("RX INT0_1 MIX1 INP2", SND_SOC_NOPM, 0, 0, &rx_int0_1_mix_inp2_mux), 3234 SND_SOC_DAPM_MUX("RX INT1_1 MIX1 INP0", SND_SOC_NOPM, 0, 0, &rx_int1_1_mix_inp0_mux), 3235 SND_SOC_DAPM_MUX("RX INT1_1 MIX1 INP1", SND_SOC_NOPM, 0, 0, &rx_int1_1_mix_inp1_mux), 3236 SND_SOC_DAPM_MUX("RX INT1_1 MIX1 INP2", SND_SOC_NOPM, 0, 0, &rx_int1_1_mix_inp2_mux), 3237 SND_SOC_DAPM_MUX("RX INT2_1 MIX1 INP0", SND_SOC_NOPM, 0, 0, &rx_int2_1_mix_inp0_mux), 3238 SND_SOC_DAPM_MUX("RX INT2_1 MIX1 INP1", SND_SOC_NOPM, 0, 0, &rx_int2_1_mix_inp1_mux), 3239 SND_SOC_DAPM_MUX("RX INT2_1 MIX1 INP2", SND_SOC_NOPM, 0, 0, &rx_int2_1_mix_inp2_mux), 3240 3241 SND_SOC_DAPM_MUX_E("RX INT0_1 INTERP", SND_SOC_NOPM, INTERP_HPHL, 0, 3242 &rx_int0_1_interp_mux, rx_macro_enable_main_path, 3243 SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU | 3244 SND_SOC_DAPM_POST_PMD), 3245 SND_SOC_DAPM_MUX_E("RX INT1_1 INTERP", SND_SOC_NOPM, INTERP_HPHR, 0, 3246 &rx_int1_1_interp_mux, rx_macro_enable_main_path, 3247 SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU | 3248 SND_SOC_DAPM_POST_PMD), 3249 SND_SOC_DAPM_MUX_E("RX INT2_1 INTERP", SND_SOC_NOPM, INTERP_AUX, 0, 3250 &rx_int2_1_interp_mux, rx_macro_enable_main_path, 3251 SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU | 3252 SND_SOC_DAPM_POST_PMD), 3253 3254 SND_SOC_DAPM_MUX("RX INT0_2 INTERP", SND_SOC_NOPM, 0, 0, 3255 &rx_int0_2_interp_mux), 3256 SND_SOC_DAPM_MUX("RX INT1_2 INTERP", SND_SOC_NOPM, 0, 0, 3257 &rx_int1_2_interp_mux), 3258 SND_SOC_DAPM_MUX("RX INT2_2 INTERP", SND_SOC_NOPM, 0, 0, 3259 &rx_int2_2_interp_mux), 3260 3261 SND_SOC_DAPM_MIXER("RX INT0_1 MIX1", SND_SOC_NOPM, 0, 0, NULL, 0), 3262 SND_SOC_DAPM_MIXER("RX INT0 SEC MIX", SND_SOC_NOPM, 0, 0, NULL, 0), 3263 SND_SOC_DAPM_MIXER("RX INT1_1 MIX1", SND_SOC_NOPM, 0, 0, NULL, 0), 3264 SND_SOC_DAPM_MIXER("RX INT1 SEC MIX", SND_SOC_NOPM, 0, 0, NULL, 0), 3265 SND_SOC_DAPM_MIXER("RX INT2_1 MIX1", SND_SOC_NOPM, 0, 0, NULL, 0), 3266 SND_SOC_DAPM_MIXER("RX INT2 SEC MIX", SND_SOC_NOPM, 0, 0, NULL, 0), 3267 3268 SND_SOC_DAPM_MUX_E("RX INT0 MIX2 INP", SND_SOC_NOPM, INTERP_HPHL, 3269 0, &rx_int0_mix2_inp_mux, rx_macro_enable_rx_path_clk, 3270 SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD), 3271 SND_SOC_DAPM_MUX_E("RX INT1 MIX2 INP", SND_SOC_NOPM, INTERP_HPHR, 3272 0, &rx_int1_mix2_inp_mux, rx_macro_enable_rx_path_clk, 3273 SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD), 3274 SND_SOC_DAPM_MUX_E("RX INT2 MIX2 INP", SND_SOC_NOPM, INTERP_AUX, 3275 0, &rx_int2_mix2_inp_mux, rx_macro_enable_rx_path_clk, 3276 SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD), 3277 3278 SND_SOC_DAPM_MIXER("RX INT0 MIX2", SND_SOC_NOPM, 0, 0, NULL, 0), 3279 SND_SOC_DAPM_MIXER("RX INT1 MIX2", SND_SOC_NOPM, 0, 0, NULL, 0), 3280 SND_SOC_DAPM_MIXER("RX INT2 MIX2", SND_SOC_NOPM, 0, 0, NULL, 0), 3281 3282 SND_SOC_DAPM_OUTPUT("HPHL_OUT"), 3283 SND_SOC_DAPM_OUTPUT("HPHR_OUT"), 3284 SND_SOC_DAPM_OUTPUT("AUX_OUT"), 3285 3286 SND_SOC_DAPM_INPUT("RX_TX DEC0_INP"), 3287 SND_SOC_DAPM_INPUT("RX_TX DEC1_INP"), 3288 SND_SOC_DAPM_INPUT("RX_TX DEC2_INP"), 3289 SND_SOC_DAPM_INPUT("RX_TX DEC3_INP"), 3290 3291 SND_SOC_DAPM_SUPPLY_S("RX_MCLK", 0, SND_SOC_NOPM, 0, 0, 3292 rx_macro_mclk_event, SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD), 3293 }; 3294 3295 static const struct snd_soc_dapm_route rx_audio_map[] = { 3296 {"RX AIF1 PB", NULL, "RX_MCLK"}, 3297 {"RX AIF2 PB", NULL, "RX_MCLK"}, 3298 {"RX AIF3 PB", NULL, "RX_MCLK"}, 3299 {"RX AIF4 PB", NULL, "RX_MCLK"}, 3300 3301 {"RX_MACRO RX0 MUX", "AIF1_PB", "RX AIF1 PB"}, 3302 {"RX_MACRO RX1 MUX", "AIF1_PB", "RX AIF1 PB"}, 3303 {"RX_MACRO RX2 MUX", "AIF1_PB", "RX AIF1 PB"}, 3304 {"RX_MACRO RX3 MUX", "AIF1_PB", "RX AIF1 PB"}, 3305 {"RX_MACRO RX4 MUX", "AIF1_PB", "RX AIF1 PB"}, 3306 {"RX_MACRO RX5 MUX", "AIF1_PB", "RX AIF1 PB"}, 3307 3308 {"RX_MACRO RX0 MUX", "AIF2_PB", "RX AIF2 PB"}, 3309 {"RX_MACRO RX1 MUX", "AIF2_PB", "RX AIF2 PB"}, 3310 {"RX_MACRO RX2 MUX", "AIF2_PB", "RX AIF2 PB"}, 3311 {"RX_MACRO RX3 MUX", "AIF2_PB", "RX AIF2 PB"}, 3312 {"RX_MACRO RX4 MUX", "AIF2_PB", "RX AIF2 PB"}, 3313 {"RX_MACRO RX5 MUX", "AIF2_PB", "RX AIF2 PB"}, 3314 3315 {"RX_MACRO RX0 MUX", "AIF3_PB", "RX AIF3 PB"}, 3316 {"RX_MACRO RX1 MUX", "AIF3_PB", "RX AIF3 PB"}, 3317 {"RX_MACRO RX2 MUX", "AIF3_PB", "RX AIF3 PB"}, 3318 {"RX_MACRO RX3 MUX", "AIF3_PB", "RX AIF3 PB"}, 3319 {"RX_MACRO RX4 MUX", "AIF3_PB", "RX AIF3 PB"}, 3320 {"RX_MACRO RX5 MUX", "AIF3_PB", "RX AIF3 PB"}, 3321 3322 {"RX_MACRO RX0 MUX", "AIF4_PB", "RX AIF4 PB"}, 3323 {"RX_MACRO RX1 MUX", "AIF4_PB", "RX AIF4 PB"}, 3324 {"RX_MACRO RX2 MUX", "AIF4_PB", "RX AIF4 PB"}, 3325 {"RX_MACRO RX3 MUX", "AIF4_PB", "RX AIF4 PB"}, 3326 {"RX_MACRO RX4 MUX", "AIF4_PB", "RX AIF4 PB"}, 3327 {"RX_MACRO RX5 MUX", "AIF4_PB", "RX AIF4 PB"}, 3328 3329 {"RX_RX0", NULL, "RX_MACRO RX0 MUX"}, 3330 {"RX_RX1", NULL, "RX_MACRO RX1 MUX"}, 3331 {"RX_RX2", NULL, "RX_MACRO RX2 MUX"}, 3332 {"RX_RX3", NULL, "RX_MACRO RX3 MUX"}, 3333 {"RX_RX4", NULL, "RX_MACRO RX4 MUX"}, 3334 {"RX_RX5", NULL, "RX_MACRO RX5 MUX"}, 3335 3336 {"RX INT0_1 MIX1 INP0", "RX0", "RX_RX0"}, 3337 {"RX INT0_1 MIX1 INP0", "RX1", "RX_RX1"}, 3338 {"RX INT0_1 MIX1 INP0", "RX2", "RX_RX2"}, 3339 {"RX INT0_1 MIX1 INP0", "RX3", "RX_RX3"}, 3340 {"RX INT0_1 MIX1 INP0", "RX4", "RX_RX4"}, 3341 {"RX INT0_1 MIX1 INP0", "RX5", "RX_RX5"}, 3342 {"RX INT0_1 MIX1 INP0", "IIR0", "IIR0"}, 3343 {"RX INT0_1 MIX1 INP0", "IIR1", "IIR1"}, 3344 {"RX INT0_1 MIX1 INP0", "DEC0", "RX_TX DEC0_INP"}, 3345 {"RX INT0_1 MIX1 INP0", "DEC1", "RX_TX DEC1_INP"}, 3346 {"RX INT0_1 MIX1 INP1", "RX0", "RX_RX0"}, 3347 {"RX INT0_1 MIX1 INP1", "RX1", "RX_RX1"}, 3348 {"RX INT0_1 MIX1 INP1", "RX2", "RX_RX2"}, 3349 {"RX INT0_1 MIX1 INP1", "RX3", "RX_RX3"}, 3350 {"RX INT0_1 MIX1 INP1", "RX4", "RX_RX4"}, 3351 {"RX INT0_1 MIX1 INP1", "RX5", "RX_RX5"}, 3352 {"RX INT0_1 MIX1 INP1", "IIR0", "IIR0"}, 3353 {"RX INT0_1 MIX1 INP1", "IIR1", "IIR1"}, 3354 {"RX INT0_1 MIX1 INP1", "DEC0", "RX_TX DEC0_INP"}, 3355 {"RX INT0_1 MIX1 INP1", "DEC1", "RX_TX DEC1_INP"}, 3356 {"RX INT0_1 MIX1 INP2", "RX0", "RX_RX0"}, 3357 {"RX INT0_1 MIX1 INP2", "RX1", "RX_RX1"}, 3358 {"RX INT0_1 MIX1 INP2", "RX2", "RX_RX2"}, 3359 {"RX INT0_1 MIX1 INP2", "RX3", "RX_RX3"}, 3360 {"RX INT0_1 MIX1 INP2", "RX4", "RX_RX4"}, 3361 {"RX INT0_1 MIX1 INP2", "RX5", "RX_RX5"}, 3362 {"RX INT0_1 MIX1 INP2", "IIR0", "IIR0"}, 3363 {"RX INT0_1 MIX1 INP2", "IIR1", "IIR1"}, 3364 {"RX INT0_1 MIX1 INP2", "DEC0", "RX_TX DEC0_INP"}, 3365 {"RX INT0_1 MIX1 INP2", "DEC1", "RX_TX DEC1_INP"}, 3366 3367 {"RX INT1_1 MIX1 INP0", "RX0", "RX_RX0"}, 3368 {"RX INT1_1 MIX1 INP0", "RX1", "RX_RX1"}, 3369 {"RX INT1_1 MIX1 INP0", "RX2", "RX_RX2"}, 3370 {"RX INT1_1 MIX1 INP0", "RX3", "RX_RX3"}, 3371 {"RX INT1_1 MIX1 INP0", "RX4", "RX_RX4"}, 3372 {"RX INT1_1 MIX1 INP0", "RX5", "RX_RX5"}, 3373 {"RX INT1_1 MIX1 INP0", "IIR0", "IIR0"}, 3374 {"RX INT1_1 MIX1 INP0", "IIR1", "IIR1"}, 3375 {"RX INT1_1 MIX1 INP0", "DEC0", "RX_TX DEC0_INP"}, 3376 {"RX INT1_1 MIX1 INP0", "DEC1", "RX_TX DEC1_INP"}, 3377 {"RX INT1_1 MIX1 INP1", "RX0", "RX_RX0"}, 3378 {"RX INT1_1 MIX1 INP1", "RX1", "RX_RX1"}, 3379 {"RX INT1_1 MIX1 INP1", "RX2", "RX_RX2"}, 3380 {"RX INT1_1 MIX1 INP1", "RX3", "RX_RX3"}, 3381 {"RX INT1_1 MIX1 INP1", "RX4", "RX_RX4"}, 3382 {"RX INT1_1 MIX1 INP1", "RX5", "RX_RX5"}, 3383 {"RX INT1_1 MIX1 INP1", "IIR0", "IIR0"}, 3384 {"RX INT1_1 MIX1 INP1", "IIR1", "IIR1"}, 3385 {"RX INT1_1 MIX1 INP1", "DEC0", "RX_TX DEC0_INP"}, 3386 {"RX INT1_1 MIX1 INP1", "DEC1", "RX_TX DEC1_INP"}, 3387 {"RX INT1_1 MIX1 INP2", "RX0", "RX_RX0"}, 3388 {"RX INT1_1 MIX1 INP2", "RX1", "RX_RX1"}, 3389 {"RX INT1_1 MIX1 INP2", "RX2", "RX_RX2"}, 3390 {"RX INT1_1 MIX1 INP2", "RX3", "RX_RX3"}, 3391 {"RX INT1_1 MIX1 INP2", "RX4", "RX_RX4"}, 3392 {"RX INT1_1 MIX1 INP2", "RX5", "RX_RX5"}, 3393 {"RX INT1_1 MIX1 INP2", "IIR0", "IIR0"}, 3394 {"RX INT1_1 MIX1 INP2", "IIR1", "IIR1"}, 3395 {"RX INT1_1 MIX1 INP2", "DEC0", "RX_TX DEC0_INP"}, 3396 {"RX INT1_1 MIX1 INP2", "DEC1", "RX_TX DEC1_INP"}, 3397 3398 {"RX INT2_1 MIX1 INP0", "RX0", "RX_RX0"}, 3399 {"RX INT2_1 MIX1 INP0", "RX1", "RX_RX1"}, 3400 {"RX INT2_1 MIX1 INP0", "RX2", "RX_RX2"}, 3401 {"RX INT2_1 MIX1 INP0", "RX3", "RX_RX3"}, 3402 {"RX INT2_1 MIX1 INP0", "RX4", "RX_RX4"}, 3403 {"RX INT2_1 MIX1 INP0", "RX5", "RX_RX5"}, 3404 {"RX INT2_1 MIX1 INP0", "IIR0", "IIR0"}, 3405 {"RX INT2_1 MIX1 INP0", "IIR1", "IIR1"}, 3406 {"RX INT2_1 MIX1 INP0", "DEC0", "RX_TX DEC0_INP"}, 3407 {"RX INT2_1 MIX1 INP0", "DEC1", "RX_TX DEC1_INP"}, 3408 {"RX INT2_1 MIX1 INP1", "RX0", "RX_RX0"}, 3409 {"RX INT2_1 MIX1 INP1", "RX1", "RX_RX1"}, 3410 {"RX INT2_1 MIX1 INP1", "RX2", "RX_RX2"}, 3411 {"RX INT2_1 MIX1 INP1", "RX3", "RX_RX3"}, 3412 {"RX INT2_1 MIX1 INP1", "RX4", "RX_RX4"}, 3413 {"RX INT2_1 MIX1 INP1", "RX5", "RX_RX5"}, 3414 {"RX INT2_1 MIX1 INP1", "IIR0", "IIR0"}, 3415 {"RX INT2_1 MIX1 INP1", "IIR1", "IIR1"}, 3416 {"RX INT2_1 MIX1 INP1", "DEC0", "RX_TX DEC0_INP"}, 3417 {"RX INT2_1 MIX1 INP1", "DEC1", "RX_TX DEC1_INP"}, 3418 {"RX INT2_1 MIX1 INP2", "RX0", "RX_RX0"}, 3419 {"RX INT2_1 MIX1 INP2", "RX1", "RX_RX1"}, 3420 {"RX INT2_1 MIX1 INP2", "RX2", "RX_RX2"}, 3421 {"RX INT2_1 MIX1 INP2", "RX3", "RX_RX3"}, 3422 {"RX INT2_1 MIX1 INP2", "RX4", "RX_RX4"}, 3423 {"RX INT2_1 MIX1 INP2", "RX5", "RX_RX5"}, 3424 {"RX INT2_1 MIX1 INP2", "IIR0", "IIR0"}, 3425 {"RX INT2_1 MIX1 INP2", "IIR1", "IIR1"}, 3426 {"RX INT2_1 MIX1 INP2", "DEC0", "RX_TX DEC0_INP"}, 3427 {"RX INT2_1 MIX1 INP2", "DEC1", "RX_TX DEC1_INP"}, 3428 3429 {"RX INT0_1 MIX1", NULL, "RX INT0_1 MIX1 INP0"}, 3430 {"RX INT0_1 MIX1", NULL, "RX INT0_1 MIX1 INP1"}, 3431 {"RX INT0_1 MIX1", NULL, "RX INT0_1 MIX1 INP2"}, 3432 {"RX INT1_1 MIX1", NULL, "RX INT1_1 MIX1 INP0"}, 3433 {"RX INT1_1 MIX1", NULL, "RX INT1_1 MIX1 INP1"}, 3434 {"RX INT1_1 MIX1", NULL, "RX INT1_1 MIX1 INP2"}, 3435 {"RX INT2_1 MIX1", NULL, "RX INT2_1 MIX1 INP0"}, 3436 {"RX INT2_1 MIX1", NULL, "RX INT2_1 MIX1 INP1"}, 3437 {"RX INT2_1 MIX1", NULL, "RX INT2_1 MIX1 INP2"}, 3438 3439 {"RX MIX TX0 MUX", "RX_MIX0", "RX INT0 SEC MIX"}, 3440 {"RX MIX TX0 MUX", "RX_MIX1", "RX INT1 SEC MIX"}, 3441 {"RX MIX TX0 MUX", "RX_MIX2", "RX INT2 SEC MIX"}, 3442 {"RX MIX TX1 MUX", "RX_MIX0", "RX INT0 SEC MIX"}, 3443 {"RX MIX TX1 MUX", "RX_MIX1", "RX INT1 SEC MIX"}, 3444 {"RX MIX TX1 MUX", "RX_MIX2", "RX INT2 SEC MIX"}, 3445 {"RX MIX TX2 MUX", "RX_MIX0", "RX INT0 SEC MIX"}, 3446 {"RX MIX TX2 MUX", "RX_MIX1", "RX INT1 SEC MIX"}, 3447 {"RX MIX TX2 MUX", "RX_MIX2", "RX INT2 SEC MIX"}, 3448 {"RX AIF_ECHO", NULL, "RX MIX TX0 MUX"}, 3449 {"RX AIF_ECHO", NULL, "RX MIX TX1 MUX"}, 3450 {"RX AIF_ECHO", NULL, "RX MIX TX2 MUX"}, 3451 {"RX AIF_ECHO", NULL, "RX_MCLK"}, 3452 3453 /* Mixing path INT0 */ 3454 {"RX INT0_2 MUX", "RX0", "RX_RX0"}, 3455 {"RX INT0_2 MUX", "RX1", "RX_RX1"}, 3456 {"RX INT0_2 MUX", "RX2", "RX_RX2"}, 3457 {"RX INT0_2 MUX", "RX3", "RX_RX3"}, 3458 {"RX INT0_2 MUX", "RX4", "RX_RX4"}, 3459 {"RX INT0_2 MUX", "RX5", "RX_RX5"}, 3460 {"RX INT0_2 INTERP", NULL, "RX INT0_2 MUX"}, 3461 {"RX INT0 SEC MIX", NULL, "RX INT0_2 INTERP"}, 3462 3463 /* Mixing path INT1 */ 3464 {"RX INT1_2 MUX", "RX0", "RX_RX0"}, 3465 {"RX INT1_2 MUX", "RX1", "RX_RX1"}, 3466 {"RX INT1_2 MUX", "RX2", "RX_RX2"}, 3467 {"RX INT1_2 MUX", "RX3", "RX_RX3"}, 3468 {"RX INT1_2 MUX", "RX4", "RX_RX4"}, 3469 {"RX INT1_2 MUX", "RX5", "RX_RX5"}, 3470 {"RX INT1_2 INTERP", NULL, "RX INT1_2 MUX"}, 3471 {"RX INT1 SEC MIX", NULL, "RX INT1_2 INTERP"}, 3472 3473 /* Mixing path INT2 */ 3474 {"RX INT2_2 MUX", "RX0", "RX_RX0"}, 3475 {"RX INT2_2 MUX", "RX1", "RX_RX1"}, 3476 {"RX INT2_2 MUX", "RX2", "RX_RX2"}, 3477 {"RX INT2_2 MUX", "RX3", "RX_RX3"}, 3478 {"RX INT2_2 MUX", "RX4", "RX_RX4"}, 3479 {"RX INT2_2 MUX", "RX5", "RX_RX5"}, 3480 {"RX INT2_2 INTERP", NULL, "RX INT2_2 MUX"}, 3481 {"RX INT2 SEC MIX", NULL, "RX INT2_2 INTERP"}, 3482 3483 {"RX INT0_1 INTERP", NULL, "RX INT0_1 MIX1"}, 3484 {"RX INT0 SEC MIX", NULL, "RX INT0_1 INTERP"}, 3485 {"RX INT0 MIX2", NULL, "RX INT0 SEC MIX"}, 3486 {"RX INT0 MIX2", NULL, "RX INT0 MIX2 INP"}, 3487 {"RX INT0 DEM MUX", "CLSH_DSM_OUT", "RX INT0 MIX2"}, 3488 {"HPHL_OUT", NULL, "RX INT0 DEM MUX"}, 3489 {"HPHL_OUT", NULL, "RX_MCLK"}, 3490 3491 {"RX INT1_1 INTERP", NULL, "RX INT1_1 MIX1"}, 3492 {"RX INT1 SEC MIX", NULL, "RX INT1_1 INTERP"}, 3493 {"RX INT1 MIX2", NULL, "RX INT1 SEC MIX"}, 3494 {"RX INT1 MIX2", NULL, "RX INT1 MIX2 INP"}, 3495 {"RX INT1 DEM MUX", "CLSH_DSM_OUT", "RX INT1 MIX2"}, 3496 {"HPHR_OUT", NULL, "RX INT1 DEM MUX"}, 3497 {"HPHR_OUT", NULL, "RX_MCLK"}, 3498 3499 {"RX INT2_1 INTERP", NULL, "RX INT2_1 MIX1"}, 3500 3501 {"RX INT2 SEC MIX", NULL, "RX INT2_1 INTERP"}, 3502 {"RX INT2 MIX2", NULL, "RX INT2 SEC MIX"}, 3503 {"RX INT2 MIX2", NULL, "RX INT2 MIX2 INP"}, 3504 {"AUX_OUT", NULL, "RX INT2 MIX2"}, 3505 {"AUX_OUT", NULL, "RX_MCLK"}, 3506 3507 {"IIR0", NULL, "RX_MCLK"}, 3508 {"IIR0", NULL, "IIR0 INP0 MUX"}, 3509 {"IIR0 INP0 MUX", "DEC0", "RX_TX DEC0_INP"}, 3510 {"IIR0 INP0 MUX", "DEC1", "RX_TX DEC1_INP"}, 3511 {"IIR0 INP0 MUX", "DEC2", "RX_TX DEC2_INP"}, 3512 {"IIR0 INP0 MUX", "DEC3", "RX_TX DEC3_INP"}, 3513 {"IIR0 INP0 MUX", "RX0", "RX_RX0"}, 3514 {"IIR0 INP0 MUX", "RX1", "RX_RX1"}, 3515 {"IIR0 INP0 MUX", "RX2", "RX_RX2"}, 3516 {"IIR0 INP0 MUX", "RX3", "RX_RX3"}, 3517 {"IIR0 INP0 MUX", "RX4", "RX_RX4"}, 3518 {"IIR0 INP0 MUX", "RX5", "RX_RX5"}, 3519 {"IIR0", NULL, "IIR0 INP1 MUX"}, 3520 {"IIR0 INP1 MUX", "DEC0", "RX_TX DEC0_INP"}, 3521 {"IIR0 INP1 MUX", "DEC1", "RX_TX DEC1_INP"}, 3522 {"IIR0 INP1 MUX", "DEC2", "RX_TX DEC2_INP"}, 3523 {"IIR0 INP1 MUX", "DEC3", "RX_TX DEC3_INP"}, 3524 {"IIR0 INP1 MUX", "RX0", "RX_RX0"}, 3525 {"IIR0 INP1 MUX", "RX1", "RX_RX1"}, 3526 {"IIR0 INP1 MUX", "RX2", "RX_RX2"}, 3527 {"IIR0 INP1 MUX", "RX3", "RX_RX3"}, 3528 {"IIR0 INP1 MUX", "RX4", "RX_RX4"}, 3529 {"IIR0 INP1 MUX", "RX5", "RX_RX5"}, 3530 {"IIR0", NULL, "IIR0 INP2 MUX"}, 3531 {"IIR0 INP2 MUX", "DEC0", "RX_TX DEC0_INP"}, 3532 {"IIR0 INP2 MUX", "DEC1", "RX_TX DEC1_INP"}, 3533 {"IIR0 INP2 MUX", "DEC2", "RX_TX DEC2_INP"}, 3534 {"IIR0 INP2 MUX", "DEC3", "RX_TX DEC3_INP"}, 3535 {"IIR0 INP2 MUX", "RX0", "RX_RX0"}, 3536 {"IIR0 INP2 MUX", "RX1", "RX_RX1"}, 3537 {"IIR0 INP2 MUX", "RX2", "RX_RX2"}, 3538 {"IIR0 INP2 MUX", "RX3", "RX_RX3"}, 3539 {"IIR0 INP2 MUX", "RX4", "RX_RX4"}, 3540 {"IIR0 INP2 MUX", "RX5", "RX_RX5"}, 3541 {"IIR0", NULL, "IIR0 INP3 MUX"}, 3542 {"IIR0 INP3 MUX", "DEC0", "RX_TX DEC0_INP"}, 3543 {"IIR0 INP3 MUX", "DEC1", "RX_TX DEC1_INP"}, 3544 {"IIR0 INP3 MUX", "DEC2", "RX_TX DEC2_INP"}, 3545 {"IIR0 INP3 MUX", "DEC3", "RX_TX DEC3_INP"}, 3546 {"IIR0 INP3 MUX", "RX0", "RX_RX0"}, 3547 {"IIR0 INP3 MUX", "RX1", "RX_RX1"}, 3548 {"IIR0 INP3 MUX", "RX2", "RX_RX2"}, 3549 {"IIR0 INP3 MUX", "RX3", "RX_RX3"}, 3550 {"IIR0 INP3 MUX", "RX4", "RX_RX4"}, 3551 {"IIR0 INP3 MUX", "RX5", "RX_RX5"}, 3552 3553 {"IIR1", NULL, "RX_MCLK"}, 3554 {"IIR1", NULL, "IIR1 INP0 MUX"}, 3555 {"IIR1 INP0 MUX", "DEC0", "RX_TX DEC0_INP"}, 3556 {"IIR1 INP0 MUX", "DEC1", "RX_TX DEC1_INP"}, 3557 {"IIR1 INP0 MUX", "DEC2", "RX_TX DEC2_INP"}, 3558 {"IIR1 INP0 MUX", "DEC3", "RX_TX DEC3_INP"}, 3559 {"IIR1 INP0 MUX", "RX0", "RX_RX0"}, 3560 {"IIR1 INP0 MUX", "RX1", "RX_RX1"}, 3561 {"IIR1 INP0 MUX", "RX2", "RX_RX2"}, 3562 {"IIR1 INP0 MUX", "RX3", "RX_RX3"}, 3563 {"IIR1 INP0 MUX", "RX4", "RX_RX4"}, 3564 {"IIR1 INP0 MUX", "RX5", "RX_RX5"}, 3565 {"IIR1", NULL, "IIR1 INP1 MUX"}, 3566 {"IIR1 INP1 MUX", "DEC0", "RX_TX DEC0_INP"}, 3567 {"IIR1 INP1 MUX", "DEC1", "RX_TX DEC1_INP"}, 3568 {"IIR1 INP1 MUX", "DEC2", "RX_TX DEC2_INP"}, 3569 {"IIR1 INP1 MUX", "DEC3", "RX_TX DEC3_INP"}, 3570 {"IIR1 INP1 MUX", "RX0", "RX_RX0"}, 3571 {"IIR1 INP1 MUX", "RX1", "RX_RX1"}, 3572 {"IIR1 INP1 MUX", "RX2", "RX_RX2"}, 3573 {"IIR1 INP1 MUX", "RX3", "RX_RX3"}, 3574 {"IIR1 INP1 MUX", "RX4", "RX_RX4"}, 3575 {"IIR1 INP1 MUX", "RX5", "RX_RX5"}, 3576 {"IIR1", NULL, "IIR1 INP2 MUX"}, 3577 {"IIR1 INP2 MUX", "DEC0", "RX_TX DEC0_INP"}, 3578 {"IIR1 INP2 MUX", "DEC1", "RX_TX DEC1_INP"}, 3579 {"IIR1 INP2 MUX", "DEC2", "RX_TX DEC2_INP"}, 3580 {"IIR1 INP2 MUX", "DEC3", "RX_TX DEC3_INP"}, 3581 {"IIR1 INP2 MUX", "RX0", "RX_RX0"}, 3582 {"IIR1 INP2 MUX", "RX1", "RX_RX1"}, 3583 {"IIR1 INP2 MUX", "RX2", "RX_RX2"}, 3584 {"IIR1 INP2 MUX", "RX3", "RX_RX3"}, 3585 {"IIR1 INP2 MUX", "RX4", "RX_RX4"}, 3586 {"IIR1 INP2 MUX", "RX5", "RX_RX5"}, 3587 {"IIR1", NULL, "IIR1 INP3 MUX"}, 3588 {"IIR1 INP3 MUX", "DEC0", "RX_TX DEC0_INP"}, 3589 {"IIR1 INP3 MUX", "DEC1", "RX_TX DEC1_INP"}, 3590 {"IIR1 INP3 MUX", "DEC2", "RX_TX DEC2_INP"}, 3591 {"IIR1 INP3 MUX", "DEC3", "RX_TX DEC3_INP"}, 3592 {"IIR1 INP3 MUX", "RX0", "RX_RX0"}, 3593 {"IIR1 INP3 MUX", "RX1", "RX_RX1"}, 3594 {"IIR1 INP3 MUX", "RX2", "RX_RX2"}, 3595 {"IIR1 INP3 MUX", "RX3", "RX_RX3"}, 3596 {"IIR1 INP3 MUX", "RX4", "RX_RX4"}, 3597 {"IIR1 INP3 MUX", "RX5", "RX_RX5"}, 3598 3599 {"SRC0", NULL, "IIR0"}, 3600 {"SRC1", NULL, "IIR1"}, 3601 {"RX INT0 MIX2 INP", "SRC0", "SRC0"}, 3602 {"RX INT0 MIX2 INP", "SRC1", "SRC1"}, 3603 {"RX INT1 MIX2 INP", "SRC0", "SRC0"}, 3604 {"RX INT1 MIX2 INP", "SRC1", "SRC1"}, 3605 {"RX INT2 MIX2 INP", "SRC0", "SRC0"}, 3606 {"RX INT2 MIX2 INP", "SRC1", "SRC1"}, 3607 }; 3608 3609 static int rx_macro_component_probe(struct snd_soc_component *component) 3610 { 3611 struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); 3612 struct rx_macro *rx = snd_soc_component_get_drvdata(component); 3613 const struct snd_soc_dapm_widget *widgets; 3614 const struct snd_kcontrol_new *controls; 3615 unsigned int num_controls, num_widgets; 3616 int ret; 3617 3618 snd_soc_component_init_regmap(component, rx->regmap); 3619 3620 snd_soc_component_update_bits(component, CDC_RX_RXn_RX_PATH_SEC7(rx, 0), 3621 CDC_RX_DSM_OUT_DELAY_SEL_MASK, 3622 CDC_RX_DSM_OUT_DELAY_TWO_SAMPLE); 3623 snd_soc_component_update_bits(component, CDC_RX_RXn_RX_PATH_SEC7(rx, 1), 3624 CDC_RX_DSM_OUT_DELAY_SEL_MASK, 3625 CDC_RX_DSM_OUT_DELAY_TWO_SAMPLE); 3626 snd_soc_component_update_bits(component, CDC_RX_RXn_RX_PATH_SEC7(rx, 2), 3627 CDC_RX_DSM_OUT_DELAY_SEL_MASK, 3628 CDC_RX_DSM_OUT_DELAY_TWO_SAMPLE); 3629 snd_soc_component_update_bits(component, CDC_RX_RXn_RX_PATH_CFG3(rx, 0), 3630 CDC_RX_DC_COEFF_SEL_MASK, 3631 CDC_RX_DC_COEFF_SEL_TWO); 3632 snd_soc_component_update_bits(component, CDC_RX_RXn_RX_PATH_CFG3(rx, 1), 3633 CDC_RX_DC_COEFF_SEL_MASK, 3634 CDC_RX_DC_COEFF_SEL_TWO); 3635 snd_soc_component_update_bits(component, CDC_RX_RXn_RX_PATH_CFG3(rx, 2), 3636 CDC_RX_DC_COEFF_SEL_MASK, 3637 CDC_RX_DC_COEFF_SEL_TWO); 3638 3639 switch (rx->codec_version) { 3640 case LPASS_CODEC_VERSION_1_0: 3641 case LPASS_CODEC_VERSION_1_1: 3642 case LPASS_CODEC_VERSION_1_2: 3643 case LPASS_CODEC_VERSION_2_0: 3644 case LPASS_CODEC_VERSION_2_1: 3645 controls = rx_macro_def_snd_controls; 3646 num_controls = ARRAY_SIZE(rx_macro_def_snd_controls); 3647 widgets = rx_macro_def_dapm_widgets; 3648 num_widgets = ARRAY_SIZE(rx_macro_def_dapm_widgets); 3649 break; 3650 case LPASS_CODEC_VERSION_2_5: 3651 case LPASS_CODEC_VERSION_2_6: 3652 case LPASS_CODEC_VERSION_2_7: 3653 case LPASS_CODEC_VERSION_2_8: 3654 controls = rx_macro_2_5_snd_controls; 3655 num_controls = ARRAY_SIZE(rx_macro_2_5_snd_controls); 3656 widgets = rx_macro_2_5_dapm_widgets; 3657 num_widgets = ARRAY_SIZE(rx_macro_2_5_dapm_widgets); 3658 break; 3659 default: 3660 return -EINVAL; 3661 } 3662 3663 rx->component = component; 3664 3665 ret = snd_soc_add_component_controls(component, controls, num_controls); 3666 if (ret) 3667 return ret; 3668 3669 return snd_soc_dapm_new_controls(dapm, widgets, num_widgets); 3670 } 3671 3672 static int swclk_gate_enable(struct clk_hw *hw) 3673 { 3674 struct rx_macro *rx = to_rx_macro(hw); 3675 int ret; 3676 3677 ret = clk_prepare_enable(rx->mclk); 3678 if (ret) { 3679 dev_err(rx->dev, "unable to prepare mclk\n"); 3680 return ret; 3681 } 3682 3683 rx_macro_mclk_enable(rx, true); 3684 3685 regmap_update_bits(rx->regmap, CDC_RX_CLK_RST_CTRL_SWR_CONTROL, 3686 CDC_RX_SWR_CLK_EN_MASK, 1); 3687 3688 return 0; 3689 } 3690 3691 static void swclk_gate_disable(struct clk_hw *hw) 3692 { 3693 struct rx_macro *rx = to_rx_macro(hw); 3694 3695 regmap_update_bits(rx->regmap, CDC_RX_CLK_RST_CTRL_SWR_CONTROL, 3696 CDC_RX_SWR_CLK_EN_MASK, 0); 3697 3698 rx_macro_mclk_enable(rx, false); 3699 clk_disable_unprepare(rx->mclk); 3700 } 3701 3702 static int swclk_gate_is_enabled(struct clk_hw *hw) 3703 { 3704 struct rx_macro *rx = to_rx_macro(hw); 3705 int ret, val; 3706 3707 regmap_read(rx->regmap, CDC_RX_CLK_RST_CTRL_SWR_CONTROL, &val); 3708 ret = val & BIT(0); 3709 3710 return ret; 3711 } 3712 3713 static unsigned long swclk_recalc_rate(struct clk_hw *hw, 3714 unsigned long parent_rate) 3715 { 3716 return parent_rate / 2; 3717 } 3718 3719 static const struct clk_ops swclk_gate_ops = { 3720 .prepare = swclk_gate_enable, 3721 .unprepare = swclk_gate_disable, 3722 .is_enabled = swclk_gate_is_enabled, 3723 .recalc_rate = swclk_recalc_rate, 3724 3725 }; 3726 3727 static int rx_macro_register_mclk_output(struct rx_macro *rx) 3728 { 3729 struct device *dev = rx->dev; 3730 const char *parent_clk_name = NULL; 3731 const char *clk_name = "lpass-rx-mclk"; 3732 struct clk_hw *hw; 3733 struct clk_init_data init; 3734 int ret; 3735 3736 if (rx->npl) 3737 parent_clk_name = __clk_get_name(rx->npl); 3738 else 3739 parent_clk_name = __clk_get_name(rx->mclk); 3740 3741 init.name = clk_name; 3742 init.ops = &swclk_gate_ops; 3743 init.flags = 0; 3744 init.parent_names = &parent_clk_name; 3745 init.num_parents = 1; 3746 rx->hw.init = &init; 3747 hw = &rx->hw; 3748 ret = devm_clk_hw_register(rx->dev, hw); 3749 if (ret) 3750 return ret; 3751 3752 return devm_of_clk_add_hw_provider(dev, of_clk_hw_simple_get, hw); 3753 } 3754 3755 static const struct snd_soc_component_driver rx_macro_component_drv = { 3756 .name = "RX-MACRO", 3757 .probe = rx_macro_component_probe, 3758 .controls = rx_macro_snd_controls, 3759 .num_controls = ARRAY_SIZE(rx_macro_snd_controls), 3760 .dapm_widgets = rx_macro_dapm_widgets, 3761 .num_dapm_widgets = ARRAY_SIZE(rx_macro_dapm_widgets), 3762 .dapm_routes = rx_audio_map, 3763 .num_dapm_routes = ARRAY_SIZE(rx_audio_map), 3764 }; 3765 3766 static int rx_macro_probe(struct platform_device *pdev) 3767 { 3768 struct device *dev = &pdev->dev; 3769 kernel_ulong_t flags; 3770 struct rx_macro *rx; 3771 void __iomem *base; 3772 int ret, def_count; 3773 3774 flags = (kernel_ulong_t)device_get_match_data(dev); 3775 3776 rx = devm_kzalloc(dev, sizeof(*rx), GFP_KERNEL); 3777 if (!rx) 3778 return -ENOMEM; 3779 3780 rx->macro = devm_clk_get_optional(dev, "macro"); 3781 if (IS_ERR(rx->macro)) 3782 return dev_err_probe(dev, PTR_ERR(rx->macro), "unable to get macro clock\n"); 3783 3784 rx->dcodec = devm_clk_get_optional(dev, "dcodec"); 3785 if (IS_ERR(rx->dcodec)) 3786 return dev_err_probe(dev, PTR_ERR(rx->dcodec), "unable to get dcodec clock\n"); 3787 3788 rx->mclk = devm_clk_get(dev, "mclk"); 3789 if (IS_ERR(rx->mclk)) 3790 return dev_err_probe(dev, PTR_ERR(rx->mclk), "unable to get mclk clock\n"); 3791 3792 if (flags & LPASS_MACRO_FLAG_HAS_NPL_CLOCK) { 3793 rx->npl = devm_clk_get(dev, "npl"); 3794 if (IS_ERR(rx->npl)) 3795 return dev_err_probe(dev, PTR_ERR(rx->npl), "unable to get npl clock\n"); 3796 } 3797 3798 rx->fsgen = devm_clk_get(dev, "fsgen"); 3799 if (IS_ERR(rx->fsgen)) 3800 return dev_err_probe(dev, PTR_ERR(rx->fsgen), "unable to get fsgen clock\n"); 3801 3802 rx->pds = lpass_macro_pds_init(dev); 3803 if (IS_ERR(rx->pds)) 3804 return PTR_ERR(rx->pds); 3805 3806 ret = devm_add_action_or_reset(dev, lpass_macro_pds_exit_action, rx->pds); 3807 if (ret) 3808 return ret; 3809 3810 base = devm_platform_ioremap_resource(pdev, 0); 3811 if (IS_ERR(base)) 3812 return PTR_ERR(base); 3813 3814 rx->codec_version = lpass_macro_get_codec_version(); 3815 struct reg_default *reg_defaults __free(kfree) = NULL; 3816 3817 switch (rx->codec_version) { 3818 case LPASS_CODEC_VERSION_1_0: 3819 case LPASS_CODEC_VERSION_1_1: 3820 case LPASS_CODEC_VERSION_1_2: 3821 case LPASS_CODEC_VERSION_2_0: 3822 case LPASS_CODEC_VERSION_2_1: 3823 rx->rxn_reg_stride = 0x80; 3824 def_count = ARRAY_SIZE(rx_defaults) + ARRAY_SIZE(rx_pre_2_5_defaults); 3825 reg_defaults = kmalloc_array(def_count, sizeof(struct reg_default), GFP_KERNEL); 3826 if (!reg_defaults) 3827 return -ENOMEM; 3828 memcpy(®_defaults[0], rx_defaults, sizeof(rx_defaults)); 3829 memcpy(®_defaults[ARRAY_SIZE(rx_defaults)], 3830 rx_pre_2_5_defaults, sizeof(rx_pre_2_5_defaults)); 3831 break; 3832 case LPASS_CODEC_VERSION_2_5: 3833 case LPASS_CODEC_VERSION_2_6: 3834 case LPASS_CODEC_VERSION_2_7: 3835 case LPASS_CODEC_VERSION_2_8: 3836 rx->rxn_reg_stride = 0xc0; 3837 def_count = ARRAY_SIZE(rx_defaults) + ARRAY_SIZE(rx_2_5_defaults); 3838 reg_defaults = kmalloc_array(def_count, sizeof(struct reg_default), GFP_KERNEL); 3839 if (!reg_defaults) 3840 return -ENOMEM; 3841 memcpy(®_defaults[0], rx_defaults, sizeof(rx_defaults)); 3842 memcpy(®_defaults[ARRAY_SIZE(rx_defaults)], 3843 rx_2_5_defaults, sizeof(rx_2_5_defaults)); 3844 break; 3845 default: 3846 dev_err(dev, "Unsupported Codec version (%d)\n", rx->codec_version); 3847 return -EINVAL; 3848 } 3849 3850 struct regmap_config *reg_config __free(kfree) = kmemdup(&rx_regmap_config, 3851 sizeof(*reg_config), 3852 GFP_KERNEL); 3853 if (!reg_config) 3854 return -ENOMEM; 3855 3856 reg_config->reg_defaults = reg_defaults; 3857 reg_config->num_reg_defaults = def_count; 3858 3859 rx->regmap = devm_regmap_init_mmio(dev, base, reg_config); 3860 if (IS_ERR(rx->regmap)) 3861 return PTR_ERR(rx->regmap); 3862 3863 dev_set_drvdata(dev, rx); 3864 3865 rx->dev = dev; 3866 3867 /* set MCLK and NPL rates */ 3868 clk_set_rate(rx->mclk, MCLK_FREQ); 3869 clk_set_rate(rx->npl, MCLK_FREQ); 3870 3871 ret = clk_prepare_enable(rx->macro); 3872 if (ret) 3873 return ret; 3874 3875 ret = clk_prepare_enable(rx->dcodec); 3876 if (ret) 3877 goto err_dcodec; 3878 3879 ret = clk_prepare_enable(rx->mclk); 3880 if (ret) 3881 goto err_mclk; 3882 3883 ret = clk_prepare_enable(rx->npl); 3884 if (ret) 3885 goto err_npl; 3886 3887 ret = clk_prepare_enable(rx->fsgen); 3888 if (ret) 3889 goto err_fsgen; 3890 3891 /* reset swr block */ 3892 regmap_update_bits(rx->regmap, CDC_RX_CLK_RST_CTRL_SWR_CONTROL, 3893 CDC_RX_SWR_RESET_MASK, 3894 CDC_RX_SWR_RESET); 3895 3896 regmap_update_bits(rx->regmap, CDC_RX_CLK_RST_CTRL_SWR_CONTROL, 3897 CDC_RX_SWR_CLK_EN_MASK, 1); 3898 3899 regmap_update_bits(rx->regmap, CDC_RX_CLK_RST_CTRL_SWR_CONTROL, 3900 CDC_RX_SWR_RESET_MASK, 0); 3901 3902 ret = devm_snd_soc_register_component(dev, &rx_macro_component_drv, 3903 rx_macro_dai, 3904 ARRAY_SIZE(rx_macro_dai)); 3905 if (ret) 3906 goto err_clkout; 3907 3908 3909 pm_runtime_set_autosuspend_delay(dev, 3000); 3910 pm_runtime_use_autosuspend(dev); 3911 pm_runtime_mark_last_busy(dev); 3912 pm_runtime_set_active(dev); 3913 pm_runtime_enable(dev); 3914 3915 ret = rx_macro_register_mclk_output(rx); 3916 if (ret) 3917 goto err_clkout; 3918 3919 return 0; 3920 3921 err_clkout: 3922 clk_disable_unprepare(rx->fsgen); 3923 err_fsgen: 3924 clk_disable_unprepare(rx->npl); 3925 err_npl: 3926 clk_disable_unprepare(rx->mclk); 3927 err_mclk: 3928 clk_disable_unprepare(rx->dcodec); 3929 err_dcodec: 3930 clk_disable_unprepare(rx->macro); 3931 3932 return ret; 3933 } 3934 3935 static void rx_macro_remove(struct platform_device *pdev) 3936 { 3937 struct rx_macro *rx = dev_get_drvdata(&pdev->dev); 3938 3939 clk_disable_unprepare(rx->mclk); 3940 clk_disable_unprepare(rx->npl); 3941 clk_disable_unprepare(rx->fsgen); 3942 clk_disable_unprepare(rx->macro); 3943 clk_disable_unprepare(rx->dcodec); 3944 } 3945 3946 static const struct of_device_id rx_macro_dt_match[] = { 3947 { 3948 .compatible = "qcom,sc7280-lpass-rx-macro", 3949 .data = (void *)LPASS_MACRO_FLAG_HAS_NPL_CLOCK, 3950 3951 }, { 3952 .compatible = "qcom,sm8250-lpass-rx-macro", 3953 .data = (void *)LPASS_MACRO_FLAG_HAS_NPL_CLOCK, 3954 }, { 3955 .compatible = "qcom,sm8450-lpass-rx-macro", 3956 .data = (void *)LPASS_MACRO_FLAG_HAS_NPL_CLOCK, 3957 }, { 3958 .compatible = "qcom,sm8550-lpass-rx-macro", 3959 }, { 3960 .compatible = "qcom,sc8280xp-lpass-rx-macro", 3961 .data = (void *)LPASS_MACRO_FLAG_HAS_NPL_CLOCK, 3962 }, 3963 { } 3964 }; 3965 MODULE_DEVICE_TABLE(of, rx_macro_dt_match); 3966 3967 static int __maybe_unused rx_macro_runtime_suspend(struct device *dev) 3968 { 3969 struct rx_macro *rx = dev_get_drvdata(dev); 3970 3971 regcache_cache_only(rx->regmap, true); 3972 regcache_mark_dirty(rx->regmap); 3973 3974 clk_disable_unprepare(rx->fsgen); 3975 clk_disable_unprepare(rx->npl); 3976 clk_disable_unprepare(rx->mclk); 3977 3978 return 0; 3979 } 3980 3981 static int __maybe_unused rx_macro_runtime_resume(struct device *dev) 3982 { 3983 struct rx_macro *rx = dev_get_drvdata(dev); 3984 int ret; 3985 3986 ret = clk_prepare_enable(rx->mclk); 3987 if (ret) { 3988 dev_err(dev, "unable to prepare mclk\n"); 3989 return ret; 3990 } 3991 3992 ret = clk_prepare_enable(rx->npl); 3993 if (ret) { 3994 dev_err(dev, "unable to prepare mclkx2\n"); 3995 goto err_npl; 3996 } 3997 3998 ret = clk_prepare_enable(rx->fsgen); 3999 if (ret) { 4000 dev_err(dev, "unable to prepare fsgen\n"); 4001 goto err_fsgen; 4002 } 4003 regcache_cache_only(rx->regmap, false); 4004 regcache_sync(rx->regmap); 4005 4006 return 0; 4007 err_fsgen: 4008 clk_disable_unprepare(rx->npl); 4009 err_npl: 4010 clk_disable_unprepare(rx->mclk); 4011 4012 return ret; 4013 } 4014 4015 static const struct dev_pm_ops rx_macro_pm_ops = { 4016 SET_RUNTIME_PM_OPS(rx_macro_runtime_suspend, rx_macro_runtime_resume, NULL) 4017 }; 4018 4019 static struct platform_driver rx_macro_driver = { 4020 .driver = { 4021 .name = "rx_macro", 4022 .of_match_table = rx_macro_dt_match, 4023 .suppress_bind_attrs = true, 4024 .pm = &rx_macro_pm_ops, 4025 }, 4026 .probe = rx_macro_probe, 4027 .remove_new = rx_macro_remove, 4028 }; 4029 4030 module_platform_driver(rx_macro_driver); 4031 4032 MODULE_DESCRIPTION("RX macro driver"); 4033 MODULE_LICENSE("GPL"); 4034