1*d2912cb1SThomas Gleixner /* SPDX-License-Identifier: GPL-2.0-only */ 229bc643dSShuming Fan /* 329bc643dSShuming Fan * RT1305.h -- RT1305 ALSA SoC amplifier component driver 429bc643dSShuming Fan * 529bc643dSShuming Fan * Copyright 2018 Realtek Semiconductor Corp. 629bc643dSShuming Fan * Author: Shuming Fan <shumingf@realtek.com> 729bc643dSShuming Fan */ 829bc643dSShuming Fan 929bc643dSShuming Fan #ifndef _RT1305_H_ 1029bc643dSShuming Fan #define _RT1305_H_ 1129bc643dSShuming Fan 1229bc643dSShuming Fan #define RT1305_DEVICE_ID_NUM 0x6251 1329bc643dSShuming Fan 1429bc643dSShuming Fan #define RT1305_RESET 0x00 1529bc643dSShuming Fan #define RT1305_CLK_1 0x04 1629bc643dSShuming Fan #define RT1305_CLK_2 0x05 1729bc643dSShuming Fan #define RT1305_CLK_3 0x06 1829bc643dSShuming Fan #define RT1305_DFLL_REG 0x07 1929bc643dSShuming Fan #define RT1305_CAL_EFUSE_CLOCK 0x08 2029bc643dSShuming Fan #define RT1305_PLL0_1 0x0a 2129bc643dSShuming Fan #define RT1305_PLL0_2 0x0b 2229bc643dSShuming Fan #define RT1305_PLL1_1 0x0c 2329bc643dSShuming Fan #define RT1305_PLL1_2 0x0d 2429bc643dSShuming Fan #define RT1305_MIXER_CTRL_1 0x10 2529bc643dSShuming Fan #define RT1305_MIXER_CTRL_2 0x11 2629bc643dSShuming Fan #define RT1305_DAC_SET_1 0x12 2729bc643dSShuming Fan #define RT1305_DAC_SET_2 0x14 2829bc643dSShuming Fan #define RT1305_ADC_SET_1 0x16 2929bc643dSShuming Fan #define RT1305_ADC_SET_2 0x17 3029bc643dSShuming Fan #define RT1305_ADC_SET_3 0x18 3129bc643dSShuming Fan #define RT1305_PATH_SET 0x20 3229bc643dSShuming Fan #define RT1305_SPDIF_IN_SET_1 0x22 3329bc643dSShuming Fan #define RT1305_SPDIF_IN_SET_2 0x24 3429bc643dSShuming Fan #define RT1305_SPDIF_IN_SET_3 0x26 3529bc643dSShuming Fan #define RT1305_SPDIF_OUT_SET_1 0x28 3629bc643dSShuming Fan #define RT1305_SPDIF_OUT_SET_2 0x2a 3729bc643dSShuming Fan #define RT1305_SPDIF_OUT_SET_3 0x2b 3829bc643dSShuming Fan #define RT1305_I2S_SET_1 0x2d 3929bc643dSShuming Fan #define RT1305_I2S_SET_2 0x2e 4029bc643dSShuming Fan #define RT1305_PBTL_MONO_MODE_SRC 0x2f 4129bc643dSShuming Fan #define RT1305_MANUALLY_I2C_DEVICE 0x32 4229bc643dSShuming Fan #define RT1305_POWER_STATUS 0x39 4329bc643dSShuming Fan #define RT1305_POWER_CTRL_1 0x3a 4429bc643dSShuming Fan #define RT1305_POWER_CTRL_2 0x3b 4529bc643dSShuming Fan #define RT1305_POWER_CTRL_3 0x3c 4629bc643dSShuming Fan #define RT1305_POWER_CTRL_4 0x3d 4729bc643dSShuming Fan #define RT1305_POWER_CTRL_5 0x3e 4829bc643dSShuming Fan #define RT1305_CLOCK_DETECT 0x3f 4929bc643dSShuming Fan #define RT1305_BIQUAD_SET_1 0x40 5029bc643dSShuming Fan #define RT1305_BIQUAD_SET_2 0x42 5129bc643dSShuming Fan #define RT1305_ADJUSTED_HPF_1 0x46 5229bc643dSShuming Fan #define RT1305_ADJUSTED_HPF_2 0x47 5329bc643dSShuming Fan #define RT1305_EQ_SET_1 0x4b 5429bc643dSShuming Fan #define RT1305_EQ_SET_2 0x4c 5529bc643dSShuming Fan #define RT1305_SPK_TEMP_PROTECTION_0 0x4f 5629bc643dSShuming Fan #define RT1305_SPK_TEMP_PROTECTION_1 0x50 5729bc643dSShuming Fan #define RT1305_SPK_TEMP_PROTECTION_2 0x51 5829bc643dSShuming Fan #define RT1305_SPK_TEMP_PROTECTION_3 0x52 5929bc643dSShuming Fan #define RT1305_SPK_DC_DETECT_1 0x53 6029bc643dSShuming Fan #define RT1305_SPK_DC_DETECT_2 0x54 6129bc643dSShuming Fan #define RT1305_LOUDNESS 0x58 6229bc643dSShuming Fan #define RT1305_THERMAL_FOLD_BACK_1 0x5e 6329bc643dSShuming Fan #define RT1305_THERMAL_FOLD_BACK_2 0x5f 6429bc643dSShuming Fan #define RT1305_SILENCE_DETECT 0x60 6529bc643dSShuming Fan #define RT1305_ALC_DRC_1 0x62 6629bc643dSShuming Fan #define RT1305_ALC_DRC_2 0x63 6729bc643dSShuming Fan #define RT1305_ALC_DRC_3 0x64 6829bc643dSShuming Fan #define RT1305_ALC_DRC_4 0x65 6929bc643dSShuming Fan #define RT1305_PRIV_INDEX 0x6a 7029bc643dSShuming Fan #define RT1305_PRIV_DATA 0x6c 7129bc643dSShuming Fan #define RT1305_SPK_EXCURSION_LIMITER_7 0x76 7229bc643dSShuming Fan #define RT1305_VERSION_ID 0x7a 7329bc643dSShuming Fan #define RT1305_VENDOR_ID 0x7c 7429bc643dSShuming Fan #define RT1305_DEVICE_ID 0x7e 7529bc643dSShuming Fan #define RT1305_EFUSE_1 0x80 7629bc643dSShuming Fan #define RT1305_EFUSE_2 0x81 7729bc643dSShuming Fan #define RT1305_EFUSE_3 0x82 7829bc643dSShuming Fan #define RT1305_DC_CALIB_1 0x90 7929bc643dSShuming Fan #define RT1305_DC_CALIB_2 0x91 8029bc643dSShuming Fan #define RT1305_DC_CALIB_3 0x92 8129bc643dSShuming Fan #define RT1305_DAC_OFFSET_1 0x93 8229bc643dSShuming Fan #define RT1305_DAC_OFFSET_2 0x94 8329bc643dSShuming Fan #define RT1305_DAC_OFFSET_3 0x95 8429bc643dSShuming Fan #define RT1305_DAC_OFFSET_4 0x96 8529bc643dSShuming Fan #define RT1305_DAC_OFFSET_5 0x97 8629bc643dSShuming Fan #define RT1305_DAC_OFFSET_6 0x98 8729bc643dSShuming Fan #define RT1305_DAC_OFFSET_7 0x99 8829bc643dSShuming Fan #define RT1305_DAC_OFFSET_8 0x9a 8929bc643dSShuming Fan #define RT1305_DAC_OFFSET_9 0x9b 9029bc643dSShuming Fan #define RT1305_DAC_OFFSET_10 0x9c 9129bc643dSShuming Fan #define RT1305_DAC_OFFSET_11 0x9d 9229bc643dSShuming Fan #define RT1305_DAC_OFFSET_12 0x9e 9329bc643dSShuming Fan #define RT1305_DAC_OFFSET_13 0x9f 9429bc643dSShuming Fan #define RT1305_DAC_OFFSET_14 0xa0 9529bc643dSShuming Fan #define RT1305_TRIM_1 0xb0 9629bc643dSShuming Fan #define RT1305_TRIM_2 0xb1 9729bc643dSShuming Fan #define RT1305_TUNE_INTERNAL_OSC 0xb2 9829bc643dSShuming Fan #define RT1305_BIQUAD1_H0_L_28_16 0xc0 9929bc643dSShuming Fan #define RT1305_BIQUAD3_A2_R_15_0 0xfb 10029bc643dSShuming Fan #define RT1305_MAX_REG 0xff 10129bc643dSShuming Fan 10229bc643dSShuming Fan /* CLOCK-1 (0x04) */ 10329bc643dSShuming Fan #define RT1305_SEL_PLL_SRC_2_MASK (0x1 << 15) 10429bc643dSShuming Fan #define RT1305_SEL_PLL_SRC_2_SFT 15 10529bc643dSShuming Fan #define RT1305_SEL_PLL_SRC_2_MCLK (0x0 << 15) 10629bc643dSShuming Fan #define RT1305_SEL_PLL_SRC_2_RCCLK (0x1 << 15) 10729bc643dSShuming Fan #define RT1305_DIV_PLL_SRC_2_MASK (0x3 << 13) 10829bc643dSShuming Fan #define RT1305_DIV_PLL_SRC_2_SFT 13 10929bc643dSShuming Fan #define RT1305_SEL_PLL_SRC_1_MASK (0x3 << 10) 11029bc643dSShuming Fan #define RT1305_SEL_PLL_SRC_1_SFT 10 11129bc643dSShuming Fan #define RT1305_SEL_PLL_SRC_1_PLL2 (0x0 << 10) 11229bc643dSShuming Fan #define RT1305_SEL_PLL_SRC_1_BCLK (0x1 << 10) 11329bc643dSShuming Fan #define RT1305_SEL_PLL_SRC_1_DFLL (0x2 << 10) 11429bc643dSShuming Fan #define RT1305_SEL_FS_SYS_PRE_MASK (0x3 << 8) 11529bc643dSShuming Fan #define RT1305_SEL_FS_SYS_PRE_SFT 8 11629bc643dSShuming Fan #define RT1305_SEL_FS_SYS_PRE_MCLK (0x0 << 8) 11729bc643dSShuming Fan #define RT1305_SEL_FS_SYS_PRE_PLL (0x1 << 8) 11829bc643dSShuming Fan #define RT1305_SEL_FS_SYS_PRE_RCCLK (0x2 << 8) 11929bc643dSShuming Fan #define RT1305_DIV_FS_SYS_MASK (0x7 << 4) 12029bc643dSShuming Fan #define RT1305_DIV_FS_SYS_SFT 4 12129bc643dSShuming Fan 12229bc643dSShuming Fan /* PLL1M/N/K Code-1 (0x0c) */ 12329bc643dSShuming Fan #define RT1305_PLL_1_M_SFT 12 12429bc643dSShuming Fan #define RT1305_PLL_1_M_BYPASS_MASK (0x1 << 11) 12529bc643dSShuming Fan #define RT1305_PLL_1_M_BYPASS_SFT 11 12629bc643dSShuming Fan #define RT1305_PLL_1_M_BYPASS (0x1 << 11) 12729bc643dSShuming Fan #define RT1305_PLL_1_N_MASK (0x1ff << 0) 12829bc643dSShuming Fan 12929bc643dSShuming Fan /* DAC Setting (0x14) */ 13029bc643dSShuming Fan #define RT1305_DVOL_MUTE_L_EN_SFT 15 13129bc643dSShuming Fan #define RT1305_DVOL_MUTE_R_EN_SFT 14 13229bc643dSShuming Fan 13329bc643dSShuming Fan /* I2S Setting-1 (0x2d) */ 13429bc643dSShuming Fan #define RT1305_SEL_I2S_OUT_MODE_MASK (0x1 << 15) 13529bc643dSShuming Fan #define RT1305_SEL_I2S_OUT_MODE_SFT 15 13629bc643dSShuming Fan #define RT1305_SEL_I2S_OUT_MODE_S (0x0 << 15) 13729bc643dSShuming Fan #define RT1305_SEL_I2S_OUT_MODE_M (0x1 << 15) 13829bc643dSShuming Fan 13929bc643dSShuming Fan /* I2S Setting-2 (0x2e) */ 14029bc643dSShuming Fan #define RT1305_I2S_DF_SEL_MASK (0x3 << 12) 14129bc643dSShuming Fan #define RT1305_I2S_DF_SEL_SFT 12 14229bc643dSShuming Fan #define RT1305_I2S_DF_SEL_I2S (0x0 << 12) 14329bc643dSShuming Fan #define RT1305_I2S_DF_SEL_LEFT (0x1 << 12) 14429bc643dSShuming Fan #define RT1305_I2S_DF_SEL_PCM_A (0x2 << 12) 14529bc643dSShuming Fan #define RT1305_I2S_DF_SEL_PCM_B (0x3 << 12) 14629bc643dSShuming Fan #define RT1305_I2S_DL_SEL_MASK (0x3 << 10) 14729bc643dSShuming Fan #define RT1305_I2S_DL_SEL_SFT 10 14829bc643dSShuming Fan #define RT1305_I2S_DL_SEL_16B (0x0 << 10) 14929bc643dSShuming Fan #define RT1305_I2S_DL_SEL_20B (0x1 << 10) 15029bc643dSShuming Fan #define RT1305_I2S_DL_SEL_24B (0x2 << 10) 15129bc643dSShuming Fan #define RT1305_I2S_DL_SEL_8B (0x3 << 10) 15229bc643dSShuming Fan #define RT1305_I2S_BCLK_MASK (0x1 << 9) 15329bc643dSShuming Fan #define RT1305_I2S_BCLK_SFT 9 15429bc643dSShuming Fan #define RT1305_I2S_BCLK_NORMAL (0x0 << 9) 15529bc643dSShuming Fan #define RT1305_I2S_BCLK_INV (0x1 << 9) 15629bc643dSShuming Fan 15729bc643dSShuming Fan /* Power Control-1 (0x3a) */ 15829bc643dSShuming Fan #define RT1305_POW_PDB_JD_MASK (0x1 << 12) 15929bc643dSShuming Fan #define RT1305_POW_PDB_JD (0x1 << 12) 16029bc643dSShuming Fan #define RT1305_POW_PDB_JD_BIT 12 16129bc643dSShuming Fan #define RT1305_POW_PLL0_EN (0x1 << 11) 16229bc643dSShuming Fan #define RT1305_POW_PLL0_EN_BIT 11 16329bc643dSShuming Fan #define RT1305_POW_PLL1_EN (0x1 << 10) 16429bc643dSShuming Fan #define RT1305_POW_PLL1_EN_BIT 10 16529bc643dSShuming Fan #define RT1305_POW_PDB_JD_POLARITY (0x1 << 9) 16629bc643dSShuming Fan #define RT1305_POW_PDB_JD_POLARITY_BIT 9 16729bc643dSShuming Fan #define RT1305_POW_MBIAS_LV (0x1 << 8) 16829bc643dSShuming Fan #define RT1305_POW_MBIAS_LV_BIT 8 16929bc643dSShuming Fan #define RT1305_POW_BG_MBIAS_LV (0x1 << 7) 17029bc643dSShuming Fan #define RT1305_POW_BG_MBIAS_LV_BIT 7 17129bc643dSShuming Fan #define RT1305_POW_LDO2 (0x1 << 6) 17229bc643dSShuming Fan #define RT1305_POW_LDO2_BIT 6 17329bc643dSShuming Fan #define RT1305_POW_BG2 (0x1 << 5) 17429bc643dSShuming Fan #define RT1305_POW_BG2_BIT 5 17529bc643dSShuming Fan #define RT1305_POW_LDO2_IB2 (0x1 << 4) 17629bc643dSShuming Fan #define RT1305_POW_LDO2_IB2_BIT 4 17729bc643dSShuming Fan #define RT1305_POW_VREF (0x1 << 3) 17829bc643dSShuming Fan #define RT1305_POW_VREF_BIT 3 17929bc643dSShuming Fan #define RT1305_POW_VREF1 (0x1 << 2) 18029bc643dSShuming Fan #define RT1305_POW_VREF1_BIT 2 18129bc643dSShuming Fan #define RT1305_POW_VREF2 (0x1 << 1) 18229bc643dSShuming Fan #define RT1305_POW_VREF2_BIT 1 18329bc643dSShuming Fan 18429bc643dSShuming Fan /* Power Control-2 (0x3b) */ 18529bc643dSShuming Fan #define RT1305_POW_DISC_VREF (1 << 15) 18629bc643dSShuming Fan #define RT1305_POW_DISC_VREF_BIT 15 18729bc643dSShuming Fan #define RT1305_POW_FASTB_VREF (1 << 14) 18829bc643dSShuming Fan #define RT1305_POW_FASTB_VREF_BIT 14 18929bc643dSShuming Fan #define RT1305_POW_ULTRA_FAST_VREF (1 << 13) 19029bc643dSShuming Fan #define RT1305_POW_ULTRA_FAST_VREF_BIT 13 19129bc643dSShuming Fan #define RT1305_POW_CKXEN_DAC (1 << 12) 19229bc643dSShuming Fan #define RT1305_POW_CKXEN_DAC_BIT 12 19329bc643dSShuming Fan #define RT1305_POW_EN_CKGEN_DAC (1 << 11) 19429bc643dSShuming Fan #define RT1305_POW_EN_CKGEN_DAC_BIT 11 19529bc643dSShuming Fan #define RT1305_POW_DAC1_L (1 << 10) 19629bc643dSShuming Fan #define RT1305_POW_DAC1_L_BIT 10 19729bc643dSShuming Fan #define RT1305_POW_DAC1_R (1 << 9) 19829bc643dSShuming Fan #define RT1305_POW_DAC1_R_BIT 9 19929bc643dSShuming Fan #define RT1305_POW_CLAMP (1 << 8) 20029bc643dSShuming Fan #define RT1305_POW_CLAMP_BIT 8 20129bc643dSShuming Fan #define RT1305_POW_BUFL (1 << 7) 20229bc643dSShuming Fan #define RT1305_POW_BUFL_BIT 7 20329bc643dSShuming Fan #define RT1305_POW_BUFR (1 << 6) 20429bc643dSShuming Fan #define RT1305_POW_BUFR_BIT 6 20529bc643dSShuming Fan #define RT1305_POW_EN_CKGEN_ADC (1 << 5) 20629bc643dSShuming Fan #define RT1305_POW_EN_CKGEN_ADC_BIT 5 20729bc643dSShuming Fan #define RT1305_POW_ADC3_L (1 << 4) 20829bc643dSShuming Fan #define RT1305_POW_ADC3_L_BIT 4 20929bc643dSShuming Fan #define RT1305_POW_ADC3_R (1 << 3) 21029bc643dSShuming Fan #define RT1305_POW_ADC3_R_BIT 3 21129bc643dSShuming Fan #define RT1305_POW_TRIOSC (1 << 2) 21229bc643dSShuming Fan #define RT1305_POW_TRIOSC_BIT 2 21329bc643dSShuming Fan #define RT1305_POR_AVDD1 (1 << 1) 21429bc643dSShuming Fan #define RT1305_POR_AVDD1_BIT 1 21529bc643dSShuming Fan #define RT1305_POR_AVDD2 (1 << 0) 21629bc643dSShuming Fan #define RT1305_POR_AVDD2_BIT 0 21729bc643dSShuming Fan 21829bc643dSShuming Fan /* Power Control-3 (0x3c) */ 21929bc643dSShuming Fan #define RT1305_POW_VSENSE_RCH (1 << 15) 22029bc643dSShuming Fan #define RT1305_POW_VSENSE_RCH_BIT 15 22129bc643dSShuming Fan #define RT1305_POW_VSENSE_LCH (1 << 14) 22229bc643dSShuming Fan #define RT1305_POW_VSENSE_LCH_BIT 14 22329bc643dSShuming Fan #define RT1305_POW_ISENSE_RCH (1 << 13) 22429bc643dSShuming Fan #define RT1305_POW_ISENSE_RCH_BIT 13 22529bc643dSShuming Fan #define RT1305_POW_ISENSE_LCH (1 << 12) 22629bc643dSShuming Fan #define RT1305_POW_ISENSE_LCH_BIT 12 22729bc643dSShuming Fan #define RT1305_POW_POR_AVDD1 (1 << 11) 22829bc643dSShuming Fan #define RT1305_POW_POR_AVDD1_BIT 11 22929bc643dSShuming Fan #define RT1305_POW_POR_AVDD2 (1 << 10) 23029bc643dSShuming Fan #define RT1305_POW_POR_AVDD2_BIT 10 23129bc643dSShuming Fan #define RT1305_EN_K_HV (1 << 9) 23229bc643dSShuming Fan #define RT1305_EN_K_HV_BIT 9 23329bc643dSShuming Fan #define RT1305_EN_PRE_K_HV (1 << 8) 23429bc643dSShuming Fan #define RT1305_EN_PRE_K_HV_BIT 8 23529bc643dSShuming Fan #define RT1305_EN_EFUSE_1P8V (1 << 7) 23629bc643dSShuming Fan #define RT1305_EN_EFUSE_1P8V_BIT 7 23729bc643dSShuming Fan #define RT1305_EN_EFUSE_5V (1 << 6) 23829bc643dSShuming Fan #define RT1305_EN_EFUSE_5V_BIT 6 23929bc643dSShuming Fan #define RT1305_EN_VCM_6172 (1 << 5) 24029bc643dSShuming Fan #define RT1305_EN_VCM_6172_BIT 5 24129bc643dSShuming Fan #define RT1305_POR_EFUSE (1 << 4) 24229bc643dSShuming Fan #define RT1305_POR_EFUSE_BIT 4 24329bc643dSShuming Fan 24429bc643dSShuming Fan /* Clock Detect (0x3f) */ 24529bc643dSShuming Fan #define RT1305_SEL_CLK_DET_SRC_MASK (0x1 << 12) 24629bc643dSShuming Fan #define RT1305_SEL_CLK_DET_SRC_SFT 12 24729bc643dSShuming Fan #define RT1305_SEL_CLK_DET_SRC_MCLK (0x0 << 12) 24829bc643dSShuming Fan #define RT1305_SEL_CLK_DET_SRC_BCLK (0x1 << 12) 24929bc643dSShuming Fan 25029bc643dSShuming Fan 25129bc643dSShuming Fan /* System Clock Source */ 25229bc643dSShuming Fan enum { 25329bc643dSShuming Fan RT1305_FS_SYS_PRE_S_MCLK, 25429bc643dSShuming Fan RT1305_FS_SYS_PRE_S_PLL1, 25529bc643dSShuming Fan RT1305_FS_SYS_PRE_S_RCCLK, /* 98.304M Hz */ 25629bc643dSShuming Fan }; 25729bc643dSShuming Fan 25829bc643dSShuming Fan /* PLL Source 1/2 */ 25929bc643dSShuming Fan enum { 26029bc643dSShuming Fan RT1305_PLL1_S_BCLK, 26129bc643dSShuming Fan RT1305_PLL2_S_MCLK, 26229bc643dSShuming Fan RT1305_PLL2_S_RCCLK, /* 98.304M Hz */ 26329bc643dSShuming Fan }; 26429bc643dSShuming Fan 26529bc643dSShuming Fan enum { 26629bc643dSShuming Fan RT1305_AIF1, 26729bc643dSShuming Fan RT1305_AIFS 26829bc643dSShuming Fan }; 26929bc643dSShuming Fan 27029bc643dSShuming Fan #define R0_UPPER 0x2E8BA2 //5.5 ohm 27129bc643dSShuming Fan #define R0_LOWER 0x666666 //2.5 ohm 27229bc643dSShuming Fan 27329bc643dSShuming Fan #endif /* end of _RT1305_H_ */ 274