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