1*29bc643dSShuming Fan /* 2*29bc643dSShuming Fan * RT1305.h -- RT1305 ALSA SoC amplifier component driver 3*29bc643dSShuming Fan * 4*29bc643dSShuming Fan * Copyright 2018 Realtek Semiconductor Corp. 5*29bc643dSShuming Fan * Author: Shuming Fan <shumingf@realtek.com> 6*29bc643dSShuming Fan * 7*29bc643dSShuming Fan * This program is free software; you can redistribute it and/or modify 8*29bc643dSShuming Fan * it under the terms of the GNU General Public License version 2 as 9*29bc643dSShuming Fan * published by the Free Software Foundation. 10*29bc643dSShuming Fan */ 11*29bc643dSShuming Fan 12*29bc643dSShuming Fan #ifndef _RT1305_H_ 13*29bc643dSShuming Fan #define _RT1305_H_ 14*29bc643dSShuming Fan 15*29bc643dSShuming Fan #define RT1305_DEVICE_ID_NUM 0x6251 16*29bc643dSShuming Fan 17*29bc643dSShuming Fan #define RT1305_RESET 0x00 18*29bc643dSShuming Fan #define RT1305_CLK_1 0x04 19*29bc643dSShuming Fan #define RT1305_CLK_2 0x05 20*29bc643dSShuming Fan #define RT1305_CLK_3 0x06 21*29bc643dSShuming Fan #define RT1305_DFLL_REG 0x07 22*29bc643dSShuming Fan #define RT1305_CAL_EFUSE_CLOCK 0x08 23*29bc643dSShuming Fan #define RT1305_PLL0_1 0x0a 24*29bc643dSShuming Fan #define RT1305_PLL0_2 0x0b 25*29bc643dSShuming Fan #define RT1305_PLL1_1 0x0c 26*29bc643dSShuming Fan #define RT1305_PLL1_2 0x0d 27*29bc643dSShuming Fan #define RT1305_MIXER_CTRL_1 0x10 28*29bc643dSShuming Fan #define RT1305_MIXER_CTRL_2 0x11 29*29bc643dSShuming Fan #define RT1305_DAC_SET_1 0x12 30*29bc643dSShuming Fan #define RT1305_DAC_SET_2 0x14 31*29bc643dSShuming Fan #define RT1305_ADC_SET_1 0x16 32*29bc643dSShuming Fan #define RT1305_ADC_SET_2 0x17 33*29bc643dSShuming Fan #define RT1305_ADC_SET_3 0x18 34*29bc643dSShuming Fan #define RT1305_PATH_SET 0x20 35*29bc643dSShuming Fan #define RT1305_SPDIF_IN_SET_1 0x22 36*29bc643dSShuming Fan #define RT1305_SPDIF_IN_SET_2 0x24 37*29bc643dSShuming Fan #define RT1305_SPDIF_IN_SET_3 0x26 38*29bc643dSShuming Fan #define RT1305_SPDIF_OUT_SET_1 0x28 39*29bc643dSShuming Fan #define RT1305_SPDIF_OUT_SET_2 0x2a 40*29bc643dSShuming Fan #define RT1305_SPDIF_OUT_SET_3 0x2b 41*29bc643dSShuming Fan #define RT1305_I2S_SET_1 0x2d 42*29bc643dSShuming Fan #define RT1305_I2S_SET_2 0x2e 43*29bc643dSShuming Fan #define RT1305_PBTL_MONO_MODE_SRC 0x2f 44*29bc643dSShuming Fan #define RT1305_MANUALLY_I2C_DEVICE 0x32 45*29bc643dSShuming Fan #define RT1305_POWER_STATUS 0x39 46*29bc643dSShuming Fan #define RT1305_POWER_CTRL_1 0x3a 47*29bc643dSShuming Fan #define RT1305_POWER_CTRL_2 0x3b 48*29bc643dSShuming Fan #define RT1305_POWER_CTRL_3 0x3c 49*29bc643dSShuming Fan #define RT1305_POWER_CTRL_4 0x3d 50*29bc643dSShuming Fan #define RT1305_POWER_CTRL_5 0x3e 51*29bc643dSShuming Fan #define RT1305_CLOCK_DETECT 0x3f 52*29bc643dSShuming Fan #define RT1305_BIQUAD_SET_1 0x40 53*29bc643dSShuming Fan #define RT1305_BIQUAD_SET_2 0x42 54*29bc643dSShuming Fan #define RT1305_ADJUSTED_HPF_1 0x46 55*29bc643dSShuming Fan #define RT1305_ADJUSTED_HPF_2 0x47 56*29bc643dSShuming Fan #define RT1305_EQ_SET_1 0x4b 57*29bc643dSShuming Fan #define RT1305_EQ_SET_2 0x4c 58*29bc643dSShuming Fan #define RT1305_SPK_TEMP_PROTECTION_0 0x4f 59*29bc643dSShuming Fan #define RT1305_SPK_TEMP_PROTECTION_1 0x50 60*29bc643dSShuming Fan #define RT1305_SPK_TEMP_PROTECTION_2 0x51 61*29bc643dSShuming Fan #define RT1305_SPK_TEMP_PROTECTION_3 0x52 62*29bc643dSShuming Fan #define RT1305_SPK_DC_DETECT_1 0x53 63*29bc643dSShuming Fan #define RT1305_SPK_DC_DETECT_2 0x54 64*29bc643dSShuming Fan #define RT1305_LOUDNESS 0x58 65*29bc643dSShuming Fan #define RT1305_THERMAL_FOLD_BACK_1 0x5e 66*29bc643dSShuming Fan #define RT1305_THERMAL_FOLD_BACK_2 0x5f 67*29bc643dSShuming Fan #define RT1305_SILENCE_DETECT 0x60 68*29bc643dSShuming Fan #define RT1305_ALC_DRC_1 0x62 69*29bc643dSShuming Fan #define RT1305_ALC_DRC_2 0x63 70*29bc643dSShuming Fan #define RT1305_ALC_DRC_3 0x64 71*29bc643dSShuming Fan #define RT1305_ALC_DRC_4 0x65 72*29bc643dSShuming Fan #define RT1305_PRIV_INDEX 0x6a 73*29bc643dSShuming Fan #define RT1305_PRIV_DATA 0x6c 74*29bc643dSShuming Fan #define RT1305_SPK_EXCURSION_LIMITER_7 0x76 75*29bc643dSShuming Fan #define RT1305_VERSION_ID 0x7a 76*29bc643dSShuming Fan #define RT1305_VENDOR_ID 0x7c 77*29bc643dSShuming Fan #define RT1305_DEVICE_ID 0x7e 78*29bc643dSShuming Fan #define RT1305_EFUSE_1 0x80 79*29bc643dSShuming Fan #define RT1305_EFUSE_2 0x81 80*29bc643dSShuming Fan #define RT1305_EFUSE_3 0x82 81*29bc643dSShuming Fan #define RT1305_DC_CALIB_1 0x90 82*29bc643dSShuming Fan #define RT1305_DC_CALIB_2 0x91 83*29bc643dSShuming Fan #define RT1305_DC_CALIB_3 0x92 84*29bc643dSShuming Fan #define RT1305_DAC_OFFSET_1 0x93 85*29bc643dSShuming Fan #define RT1305_DAC_OFFSET_2 0x94 86*29bc643dSShuming Fan #define RT1305_DAC_OFFSET_3 0x95 87*29bc643dSShuming Fan #define RT1305_DAC_OFFSET_4 0x96 88*29bc643dSShuming Fan #define RT1305_DAC_OFFSET_5 0x97 89*29bc643dSShuming Fan #define RT1305_DAC_OFFSET_6 0x98 90*29bc643dSShuming Fan #define RT1305_DAC_OFFSET_7 0x99 91*29bc643dSShuming Fan #define RT1305_DAC_OFFSET_8 0x9a 92*29bc643dSShuming Fan #define RT1305_DAC_OFFSET_9 0x9b 93*29bc643dSShuming Fan #define RT1305_DAC_OFFSET_10 0x9c 94*29bc643dSShuming Fan #define RT1305_DAC_OFFSET_11 0x9d 95*29bc643dSShuming Fan #define RT1305_DAC_OFFSET_12 0x9e 96*29bc643dSShuming Fan #define RT1305_DAC_OFFSET_13 0x9f 97*29bc643dSShuming Fan #define RT1305_DAC_OFFSET_14 0xa0 98*29bc643dSShuming Fan #define RT1305_TRIM_1 0xb0 99*29bc643dSShuming Fan #define RT1305_TRIM_2 0xb1 100*29bc643dSShuming Fan #define RT1305_TUNE_INTERNAL_OSC 0xb2 101*29bc643dSShuming Fan #define RT1305_BIQUAD1_H0_L_28_16 0xc0 102*29bc643dSShuming Fan #define RT1305_BIQUAD3_A2_R_15_0 0xfb 103*29bc643dSShuming Fan #define RT1305_MAX_REG 0xff 104*29bc643dSShuming Fan 105*29bc643dSShuming Fan /* CLOCK-1 (0x04) */ 106*29bc643dSShuming Fan #define RT1305_SEL_PLL_SRC_2_MASK (0x1 << 15) 107*29bc643dSShuming Fan #define RT1305_SEL_PLL_SRC_2_SFT 15 108*29bc643dSShuming Fan #define RT1305_SEL_PLL_SRC_2_MCLK (0x0 << 15) 109*29bc643dSShuming Fan #define RT1305_SEL_PLL_SRC_2_RCCLK (0x1 << 15) 110*29bc643dSShuming Fan #define RT1305_DIV_PLL_SRC_2_MASK (0x3 << 13) 111*29bc643dSShuming Fan #define RT1305_DIV_PLL_SRC_2_SFT 13 112*29bc643dSShuming Fan #define RT1305_SEL_PLL_SRC_1_MASK (0x3 << 10) 113*29bc643dSShuming Fan #define RT1305_SEL_PLL_SRC_1_SFT 10 114*29bc643dSShuming Fan #define RT1305_SEL_PLL_SRC_1_PLL2 (0x0 << 10) 115*29bc643dSShuming Fan #define RT1305_SEL_PLL_SRC_1_BCLK (0x1 << 10) 116*29bc643dSShuming Fan #define RT1305_SEL_PLL_SRC_1_DFLL (0x2 << 10) 117*29bc643dSShuming Fan #define RT1305_SEL_FS_SYS_PRE_MASK (0x3 << 8) 118*29bc643dSShuming Fan #define RT1305_SEL_FS_SYS_PRE_SFT 8 119*29bc643dSShuming Fan #define RT1305_SEL_FS_SYS_PRE_MCLK (0x0 << 8) 120*29bc643dSShuming Fan #define RT1305_SEL_FS_SYS_PRE_PLL (0x1 << 8) 121*29bc643dSShuming Fan #define RT1305_SEL_FS_SYS_PRE_RCCLK (0x2 << 8) 122*29bc643dSShuming Fan #define RT1305_DIV_FS_SYS_MASK (0x7 << 4) 123*29bc643dSShuming Fan #define RT1305_DIV_FS_SYS_SFT 4 124*29bc643dSShuming Fan 125*29bc643dSShuming Fan /* PLL1M/N/K Code-1 (0x0c) */ 126*29bc643dSShuming Fan #define RT1305_PLL_1_M_SFT 12 127*29bc643dSShuming Fan #define RT1305_PLL_1_M_BYPASS_MASK (0x1 << 11) 128*29bc643dSShuming Fan #define RT1305_PLL_1_M_BYPASS_SFT 11 129*29bc643dSShuming Fan #define RT1305_PLL_1_M_BYPASS (0x1 << 11) 130*29bc643dSShuming Fan #define RT1305_PLL_1_N_MASK (0x1ff << 0) 131*29bc643dSShuming Fan 132*29bc643dSShuming Fan /* DAC Setting (0x14) */ 133*29bc643dSShuming Fan #define RT1305_DVOL_MUTE_L_EN_SFT 15 134*29bc643dSShuming Fan #define RT1305_DVOL_MUTE_R_EN_SFT 14 135*29bc643dSShuming Fan 136*29bc643dSShuming Fan /* I2S Setting-1 (0x2d) */ 137*29bc643dSShuming Fan #define RT1305_SEL_I2S_OUT_MODE_MASK (0x1 << 15) 138*29bc643dSShuming Fan #define RT1305_SEL_I2S_OUT_MODE_SFT 15 139*29bc643dSShuming Fan #define RT1305_SEL_I2S_OUT_MODE_S (0x0 << 15) 140*29bc643dSShuming Fan #define RT1305_SEL_I2S_OUT_MODE_M (0x1 << 15) 141*29bc643dSShuming Fan 142*29bc643dSShuming Fan /* I2S Setting-2 (0x2e) */ 143*29bc643dSShuming Fan #define RT1305_I2S_DF_SEL_MASK (0x3 << 12) 144*29bc643dSShuming Fan #define RT1305_I2S_DF_SEL_SFT 12 145*29bc643dSShuming Fan #define RT1305_I2S_DF_SEL_I2S (0x0 << 12) 146*29bc643dSShuming Fan #define RT1305_I2S_DF_SEL_LEFT (0x1 << 12) 147*29bc643dSShuming Fan #define RT1305_I2S_DF_SEL_PCM_A (0x2 << 12) 148*29bc643dSShuming Fan #define RT1305_I2S_DF_SEL_PCM_B (0x3 << 12) 149*29bc643dSShuming Fan #define RT1305_I2S_DL_SEL_MASK (0x3 << 10) 150*29bc643dSShuming Fan #define RT1305_I2S_DL_SEL_SFT 10 151*29bc643dSShuming Fan #define RT1305_I2S_DL_SEL_16B (0x0 << 10) 152*29bc643dSShuming Fan #define RT1305_I2S_DL_SEL_20B (0x1 << 10) 153*29bc643dSShuming Fan #define RT1305_I2S_DL_SEL_24B (0x2 << 10) 154*29bc643dSShuming Fan #define RT1305_I2S_DL_SEL_8B (0x3 << 10) 155*29bc643dSShuming Fan #define RT1305_I2S_BCLK_MASK (0x1 << 9) 156*29bc643dSShuming Fan #define RT1305_I2S_BCLK_SFT 9 157*29bc643dSShuming Fan #define RT1305_I2S_BCLK_NORMAL (0x0 << 9) 158*29bc643dSShuming Fan #define RT1305_I2S_BCLK_INV (0x1 << 9) 159*29bc643dSShuming Fan 160*29bc643dSShuming Fan /* Power Control-1 (0x3a) */ 161*29bc643dSShuming Fan #define RT1305_POW_PDB_JD_MASK (0x1 << 12) 162*29bc643dSShuming Fan #define RT1305_POW_PDB_JD (0x1 << 12) 163*29bc643dSShuming Fan #define RT1305_POW_PDB_JD_BIT 12 164*29bc643dSShuming Fan #define RT1305_POW_PLL0_EN (0x1 << 11) 165*29bc643dSShuming Fan #define RT1305_POW_PLL0_EN_BIT 11 166*29bc643dSShuming Fan #define RT1305_POW_PLL1_EN (0x1 << 10) 167*29bc643dSShuming Fan #define RT1305_POW_PLL1_EN_BIT 10 168*29bc643dSShuming Fan #define RT1305_POW_PDB_JD_POLARITY (0x1 << 9) 169*29bc643dSShuming Fan #define RT1305_POW_PDB_JD_POLARITY_BIT 9 170*29bc643dSShuming Fan #define RT1305_POW_MBIAS_LV (0x1 << 8) 171*29bc643dSShuming Fan #define RT1305_POW_MBIAS_LV_BIT 8 172*29bc643dSShuming Fan #define RT1305_POW_BG_MBIAS_LV (0x1 << 7) 173*29bc643dSShuming Fan #define RT1305_POW_BG_MBIAS_LV_BIT 7 174*29bc643dSShuming Fan #define RT1305_POW_LDO2 (0x1 << 6) 175*29bc643dSShuming Fan #define RT1305_POW_LDO2_BIT 6 176*29bc643dSShuming Fan #define RT1305_POW_BG2 (0x1 << 5) 177*29bc643dSShuming Fan #define RT1305_POW_BG2_BIT 5 178*29bc643dSShuming Fan #define RT1305_POW_LDO2_IB2 (0x1 << 4) 179*29bc643dSShuming Fan #define RT1305_POW_LDO2_IB2_BIT 4 180*29bc643dSShuming Fan #define RT1305_POW_VREF (0x1 << 3) 181*29bc643dSShuming Fan #define RT1305_POW_VREF_BIT 3 182*29bc643dSShuming Fan #define RT1305_POW_VREF1 (0x1 << 2) 183*29bc643dSShuming Fan #define RT1305_POW_VREF1_BIT 2 184*29bc643dSShuming Fan #define RT1305_POW_VREF2 (0x1 << 1) 185*29bc643dSShuming Fan #define RT1305_POW_VREF2_BIT 1 186*29bc643dSShuming Fan 187*29bc643dSShuming Fan /* Power Control-2 (0x3b) */ 188*29bc643dSShuming Fan #define RT1305_POW_DISC_VREF (1 << 15) 189*29bc643dSShuming Fan #define RT1305_POW_DISC_VREF_BIT 15 190*29bc643dSShuming Fan #define RT1305_POW_FASTB_VREF (1 << 14) 191*29bc643dSShuming Fan #define RT1305_POW_FASTB_VREF_BIT 14 192*29bc643dSShuming Fan #define RT1305_POW_ULTRA_FAST_VREF (1 << 13) 193*29bc643dSShuming Fan #define RT1305_POW_ULTRA_FAST_VREF_BIT 13 194*29bc643dSShuming Fan #define RT1305_POW_CKXEN_DAC (1 << 12) 195*29bc643dSShuming Fan #define RT1305_POW_CKXEN_DAC_BIT 12 196*29bc643dSShuming Fan #define RT1305_POW_EN_CKGEN_DAC (1 << 11) 197*29bc643dSShuming Fan #define RT1305_POW_EN_CKGEN_DAC_BIT 11 198*29bc643dSShuming Fan #define RT1305_POW_DAC1_L (1 << 10) 199*29bc643dSShuming Fan #define RT1305_POW_DAC1_L_BIT 10 200*29bc643dSShuming Fan #define RT1305_POW_DAC1_R (1 << 9) 201*29bc643dSShuming Fan #define RT1305_POW_DAC1_R_BIT 9 202*29bc643dSShuming Fan #define RT1305_POW_CLAMP (1 << 8) 203*29bc643dSShuming Fan #define RT1305_POW_CLAMP_BIT 8 204*29bc643dSShuming Fan #define RT1305_POW_BUFL (1 << 7) 205*29bc643dSShuming Fan #define RT1305_POW_BUFL_BIT 7 206*29bc643dSShuming Fan #define RT1305_POW_BUFR (1 << 6) 207*29bc643dSShuming Fan #define RT1305_POW_BUFR_BIT 6 208*29bc643dSShuming Fan #define RT1305_POW_EN_CKGEN_ADC (1 << 5) 209*29bc643dSShuming Fan #define RT1305_POW_EN_CKGEN_ADC_BIT 5 210*29bc643dSShuming Fan #define RT1305_POW_ADC3_L (1 << 4) 211*29bc643dSShuming Fan #define RT1305_POW_ADC3_L_BIT 4 212*29bc643dSShuming Fan #define RT1305_POW_ADC3_R (1 << 3) 213*29bc643dSShuming Fan #define RT1305_POW_ADC3_R_BIT 3 214*29bc643dSShuming Fan #define RT1305_POW_TRIOSC (1 << 2) 215*29bc643dSShuming Fan #define RT1305_POW_TRIOSC_BIT 2 216*29bc643dSShuming Fan #define RT1305_POR_AVDD1 (1 << 1) 217*29bc643dSShuming Fan #define RT1305_POR_AVDD1_BIT 1 218*29bc643dSShuming Fan #define RT1305_POR_AVDD2 (1 << 0) 219*29bc643dSShuming Fan #define RT1305_POR_AVDD2_BIT 0 220*29bc643dSShuming Fan 221*29bc643dSShuming Fan /* Power Control-3 (0x3c) */ 222*29bc643dSShuming Fan #define RT1305_POW_VSENSE_RCH (1 << 15) 223*29bc643dSShuming Fan #define RT1305_POW_VSENSE_RCH_BIT 15 224*29bc643dSShuming Fan #define RT1305_POW_VSENSE_LCH (1 << 14) 225*29bc643dSShuming Fan #define RT1305_POW_VSENSE_LCH_BIT 14 226*29bc643dSShuming Fan #define RT1305_POW_ISENSE_RCH (1 << 13) 227*29bc643dSShuming Fan #define RT1305_POW_ISENSE_RCH_BIT 13 228*29bc643dSShuming Fan #define RT1305_POW_ISENSE_LCH (1 << 12) 229*29bc643dSShuming Fan #define RT1305_POW_ISENSE_LCH_BIT 12 230*29bc643dSShuming Fan #define RT1305_POW_POR_AVDD1 (1 << 11) 231*29bc643dSShuming Fan #define RT1305_POW_POR_AVDD1_BIT 11 232*29bc643dSShuming Fan #define RT1305_POW_POR_AVDD2 (1 << 10) 233*29bc643dSShuming Fan #define RT1305_POW_POR_AVDD2_BIT 10 234*29bc643dSShuming Fan #define RT1305_EN_K_HV (1 << 9) 235*29bc643dSShuming Fan #define RT1305_EN_K_HV_BIT 9 236*29bc643dSShuming Fan #define RT1305_EN_PRE_K_HV (1 << 8) 237*29bc643dSShuming Fan #define RT1305_EN_PRE_K_HV_BIT 8 238*29bc643dSShuming Fan #define RT1305_EN_EFUSE_1P8V (1 << 7) 239*29bc643dSShuming Fan #define RT1305_EN_EFUSE_1P8V_BIT 7 240*29bc643dSShuming Fan #define RT1305_EN_EFUSE_5V (1 << 6) 241*29bc643dSShuming Fan #define RT1305_EN_EFUSE_5V_BIT 6 242*29bc643dSShuming Fan #define RT1305_EN_VCM_6172 (1 << 5) 243*29bc643dSShuming Fan #define RT1305_EN_VCM_6172_BIT 5 244*29bc643dSShuming Fan #define RT1305_POR_EFUSE (1 << 4) 245*29bc643dSShuming Fan #define RT1305_POR_EFUSE_BIT 4 246*29bc643dSShuming Fan 247*29bc643dSShuming Fan /* Clock Detect (0x3f) */ 248*29bc643dSShuming Fan #define RT1305_SEL_CLK_DET_SRC_MASK (0x1 << 12) 249*29bc643dSShuming Fan #define RT1305_SEL_CLK_DET_SRC_SFT 12 250*29bc643dSShuming Fan #define RT1305_SEL_CLK_DET_SRC_MCLK (0x0 << 12) 251*29bc643dSShuming Fan #define RT1305_SEL_CLK_DET_SRC_BCLK (0x1 << 12) 252*29bc643dSShuming Fan 253*29bc643dSShuming Fan 254*29bc643dSShuming Fan /* System Clock Source */ 255*29bc643dSShuming Fan enum { 256*29bc643dSShuming Fan RT1305_FS_SYS_PRE_S_MCLK, 257*29bc643dSShuming Fan RT1305_FS_SYS_PRE_S_PLL1, 258*29bc643dSShuming Fan RT1305_FS_SYS_PRE_S_RCCLK, /* 98.304M Hz */ 259*29bc643dSShuming Fan }; 260*29bc643dSShuming Fan 261*29bc643dSShuming Fan /* PLL Source 1/2 */ 262*29bc643dSShuming Fan enum { 263*29bc643dSShuming Fan RT1305_PLL1_S_BCLK, 264*29bc643dSShuming Fan RT1305_PLL2_S_MCLK, 265*29bc643dSShuming Fan RT1305_PLL2_S_RCCLK, /* 98.304M Hz */ 266*29bc643dSShuming Fan }; 267*29bc643dSShuming Fan 268*29bc643dSShuming Fan enum { 269*29bc643dSShuming Fan RT1305_AIF1, 270*29bc643dSShuming Fan RT1305_AIFS 271*29bc643dSShuming Fan }; 272*29bc643dSShuming Fan 273*29bc643dSShuming Fan #define R0_UPPER 0x2E8BA2 //5.5 ohm 274*29bc643dSShuming Fan #define R0_LOWER 0x666666 //2.5 ohm 275*29bc643dSShuming Fan 276*29bc643dSShuming Fan #endif /* end of _RT1305_H_ */ 277