Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 */
0002 /*
0003  * rt1308.h  --  RT1308 ALSA SoC amplifier component driver
0004  *
0005  * Copyright 2019 Realtek Semiconductor Corp.
0006  * Author: Derek Fang <derek.fang@realtek.com>
0007  *
0008  */
0009 
0010 #ifndef _RT1308_H_
0011 #define _RT1308_H_
0012 
0013 #define RT1308_DEVICE_ID_NUM            0x10ec1300
0014 
0015 #define RT1308_RESET                0x00
0016 #define RT1308_RESET_N              0x01
0017 #define RT1308_CLK_GATING           0x02
0018 #define RT1308_PLL_1                0x03
0019 #define RT1308_PLL_2                0x04
0020 #define RT1308_PLL_INT              0x05
0021 #define RT1308_CLK_1                0x06
0022 #define RT1308_DATA_PATH            0x07
0023 #define RT1308_CLK_2                0x08
0024 #define RT1308_SIL_DET              0x09
0025 #define RT1308_CLK_DET              0x0a
0026 #define RT1308_DC_DET               0x0b
0027 #define RT1308_DC_DET_THRES         0x0c
0028 #define RT1308_DAC_SET              0x10
0029 #define RT1308_SRC_SET              0x11
0030 #define RT1308_DAC_BUF              0x12
0031 #define RT1308_ADC_SET              0x13
0032 #define RT1308_ADC_SET_INT          0x14
0033 #define RT1308_I2S_SET_1            0x15
0034 #define RT1308_I2S_SET_2            0x16
0035 #define RT1308_I2C_I2S_SDW_SET          0x17
0036 #define RT1308_SDW_REG_RW           0x18
0037 #define RT1308_SDW_REG_RDATA            0x19
0038 #define RT1308_IV_SENSE             0x1a
0039 #define RT1308_I2S_TX_DAC_SET           0x1b
0040 #define RT1308_AD_FILTER_SET            0x1c
0041 #define RT1308_DC_CAL_1             0x20
0042 #define RT1308_DC_CAL_2             0x21
0043 #define RT1308_DC_CAL_L_OFFSET          0x22
0044 #define RT1308_DC_CAL_R_OFFSET          0x23
0045 #define RT1308_PVDD_OFFSET_CTL          0x24
0046 #define RT1308_PVDD_OFFSET_L            0x25
0047 #define RT1308_PVDD_OFFSET_R            0x26
0048 #define RT1308_PVDD_OFFSET_PBTL         0x27
0049 #define RT1308_PVDD_OFFSET_PVDD         0x28
0050 #define RT1308_CAL_OFFSET_DAC_PBTL      0x29
0051 #define RT1308_CAL_OFFSET_DAC_L         0x2a
0052 #define RT1308_CAL_OFFSET_DAC_R         0x2b
0053 #define RT1308_CAL_OFFSET_PWM_L         0x2c
0054 #define RT1308_CAL_OFFSET_PWM_R         0x2d
0055 #define RT1308_CAL_PWM_VOS_ADC_L        0x2e
0056 #define RT1308_CAL_PWM_VOS_ADC_R        0x2f
0057 #define RT1308_CLASS_D_SET_1            0x30
0058 #define RT1308_CLASS_D_SET_2            0x31
0059 #define RT1308_POWER                0x32
0060 #define RT1308_LDO              0x33
0061 #define RT1308_VREF             0x34
0062 #define RT1308_MBIAS                0x35
0063 #define RT1308_POWER_STATUS         0x36
0064 #define RT1308_POWER_INT            0x37
0065 #define RT1308_SINE_TONE_GEN_1          0x50
0066 #define RT1308_SINE_TONE_GEN_2          0x51
0067 #define RT1308_BQ_SET               0x54
0068 #define RT1308_BQ_PARA_UPDATE           0x55
0069 #define RT1308_BQ_PRE_VOL_L         0x56
0070 #define RT1308_BQ_PRE_VOL_R         0x57
0071 #define RT1308_BQ_POST_VOL_L            0x58
0072 #define RT1308_BQ_POST_VOL_R            0x59
0073 #define RT1308_BQ1_L_H0             0x5b
0074 #define RT1308_BQ1_L_B1             0x5c
0075 #define RT1308_BQ1_L_B2             0x5d
0076 #define RT1308_BQ1_L_A1             0x5e
0077 #define RT1308_BQ1_L_A2             0x5f
0078 #define RT1308_BQ1_R_H0             0x60
0079 #define RT1308_BQ1_R_B1             0x61
0080 #define RT1308_BQ1_R_B2             0x62
0081 #define RT1308_BQ1_R_A1             0x63
0082 #define RT1308_BQ1_R_A2             0x64
0083 #define RT1308_BQ2_L_H0             0x65
0084 #define RT1308_BQ2_L_B1             0x66
0085 #define RT1308_BQ2_L_B2             0x67
0086 #define RT1308_BQ2_L_A1             0x68
0087 #define RT1308_BQ2_L_A2             0x69
0088 #define RT1308_BQ2_R_H0             0x6a
0089 #define RT1308_BQ2_R_B1             0x6b
0090 #define RT1308_BQ2_R_B2             0x6c
0091 #define RT1308_BQ2_R_A1             0x6d
0092 #define RT1308_BQ2_R_A2             0x6e
0093 #define RT1308_VEN_DEV_ID           0x70
0094 #define RT1308_VERSION_ID           0x71
0095 #define RT1308_SPK_BOUND            0x72
0096 #define RT1308_BQ1_EQ_L_1           0x73
0097 #define RT1308_BQ1_EQ_L_2           0x74
0098 #define RT1308_BQ1_EQ_L_3           0x75
0099 #define RT1308_BQ1_EQ_R_1           0x76
0100 #define RT1308_BQ1_EQ_R_2           0x77
0101 #define RT1308_BQ1_EQ_R_3           0x78
0102 #define RT1308_BQ2_EQ_L_1           0x79
0103 #define RT1308_BQ2_EQ_L_2           0x7a
0104 #define RT1308_BQ2_EQ_L_3           0x7b
0105 #define RT1308_BQ2_EQ_R_1           0x7c
0106 #define RT1308_BQ2_EQ_R_2           0x7d
0107 #define RT1308_BQ2_EQ_R_3           0x7e
0108 #define RT1308_EFUSE_1              0x7f
0109 #define RT1308_EFUSE_2              0x80
0110 #define RT1308_EFUSE_PROG_PVDD_L        0x81
0111 #define RT1308_EFUSE_PROG_PVDD_R        0x82
0112 #define RT1308_EFUSE_PROG_R0_L          0x83
0113 #define RT1308_EFUSE_PROG_R0_R          0x84
0114 #define RT1308_EFUSE_PROG_DEV           0x85
0115 #define RT1308_EFUSE_READ_PVDD_L        0x86
0116 #define RT1308_EFUSE_READ_PVDD_R        0x87
0117 #define RT1308_EFUSE_READ_PVDD_PTBL     0x88
0118 #define RT1308_EFUSE_READ_DEV           0x89
0119 #define RT1308_EFUSE_READ_R0            0x8a
0120 #define RT1308_EFUSE_READ_ADC_L         0x8b
0121 #define RT1308_EFUSE_READ_ADC_R         0x8c
0122 #define RT1308_EFUSE_READ_ADC_PBTL      0x8d
0123 #define RT1308_EFUSE_RESERVE            0x8e
0124 #define RT1308_PADS_1               0x90
0125 #define RT1308_PADS_2               0x91
0126 #define RT1308_TEST_MODE            0xa0
0127 #define RT1308_TEST_1               0xa1
0128 #define RT1308_TEST_2               0xa2
0129 #define RT1308_TEST_3               0xa3
0130 #define RT1308_TEST_4               0xa4
0131 #define RT1308_EFUSE_DATA_0_MSB         0xb0
0132 #define RT1308_EFUSE_DATA_0_LSB         0xb1
0133 #define RT1308_EFUSE_DATA_1_MSB         0xb2
0134 #define RT1308_EFUSE_DATA_1_LSB         0xb3
0135 #define RT1308_EFUSE_DATA_2_MSB         0xb4
0136 #define RT1308_EFUSE_DATA_2_LSB         0xb5
0137 #define RT1308_EFUSE_DATA_3_MSB         0xb6
0138 #define RT1308_EFUSE_DATA_3_LSB         0xb7
0139 #define RT1308_EFUSE_DATA_TEST_MSB      0xb8
0140 #define RT1308_EFUSE_DATA_TEST_LSB      0xb9
0141 #define RT1308_EFUSE_STATUS_1           0xba
0142 #define RT1308_EFUSE_STATUS_2           0xbb
0143 #define RT1308_TCON_1               0xc0
0144 #define RT1308_TCON_2               0xc1
0145 #define RT1308_DUMMY_REG            0xf0
0146 #define RT1308_MAX_REG              0xff
0147 
0148 /* PLL1 M/N/K Code-1 (0x03) */
0149 #define RT1308_PLL1_K_SFT           24
0150 #define RT1308_PLL1_K_MASK          (0x1f << 24)
0151 #define RT1308_PLL1_M_BYPASS_MASK       (0x1 << 23)
0152 #define RT1308_PLL1_M_BYPASS_SFT        23
0153 #define RT1308_PLL1_M_BYPASS            (0x1 << 23)
0154 #define RT1308_PLL1_M_MASK          (0x3f << 16)
0155 #define RT1308_PLL1_M_SFT           16
0156 #define RT1308_PLL1_N_MASK          (0x7f << 8)
0157 #define RT1308_PLL1_N_SFT           8
0158 
0159 /* CLOCK-1 (0x06) */
0160 #define RT1308_DIV_FS_SYS_MASK          (0xf << 28)
0161 #define RT1308_DIV_FS_SYS_SFT           28
0162 #define RT1308_SEL_FS_SYS_MASK          (0x7 << 24)
0163 #define RT1308_SEL_FS_SYS_SFT           24
0164 #define RT1308_SEL_FS_SYS_SRC_MCLK      (0x0 << 24)
0165 #define RT1308_SEL_FS_SYS_SRC_BCLK      (0x1 << 24)
0166 #define RT1308_SEL_FS_SYS_SRC_PLL       (0x2 << 24)
0167 #define RT1308_SEL_FS_SYS_SRC_RCCLK     (0x4 << 24)
0168 
0169 /* CLOCK-2 (0x08) */
0170 #define RT1308_DIV_PRE_PLL_MASK         (0xf << 28)
0171 #define RT1308_DIV_PRE_PLL_SFT          28
0172 #define RT1308_SEL_PLL_SRC_MASK         (0x7 << 24)
0173 #define RT1308_SEL_PLL_SRC_SFT          24
0174 #define RT1308_SEL_PLL_SRC_MCLK         (0x0 << 24)
0175 #define RT1308_SEL_PLL_SRC_BCLK         (0x1 << 24)
0176 #define RT1308_SEL_PLL_SRC_RCCLK        (0x4 << 24)
0177 
0178 /* Clock Detect (0x0a) */
0179 #define RT1308_MCLK_DET_EN_MASK         (0x1 << 25)
0180 #define RT1308_MCLK_DET_EN_SFT          25
0181 #define RT1308_MCLK_DET_EN          (0x1 << 25)
0182 #define RT1308_BCLK_DET_EN_MASK         (0x1 << 24)
0183 #define RT1308_BCLK_DET_EN_SFT          24
0184 #define RT1308_BCLK_DET_EN          (0x1 << 24)
0185 
0186 /* DAC Setting (0x10) */
0187 #define RT1308_DVOL_MUTE_R_EN_SFT       7
0188 #define RT1308_DVOL_MUTE_L_EN_SFT       6
0189 
0190 /* I2S Setting-1 (0x15) */
0191 #define RT1308_I2S_DF_SEL_MASK          (0x3 << 12)
0192 #define RT1308_I2S_DF_SEL_SFT           12
0193 #define RT1308_I2S_DF_SEL_I2S           (0x0 << 12)
0194 #define RT1308_I2S_DF_SEL_LEFT          (0x1 << 12)
0195 #define RT1308_I2S_DF_SEL_PCM_A         (0x2 << 12)
0196 #define RT1308_I2S_DF_SEL_PCM_B         (0x3 << 12)
0197 #define RT1308_I2S_DL_RX_SEL_MASK       (0x7 << 4)
0198 #define RT1308_I2S_DL_RX_SEL_SFT        4
0199 #define RT1308_I2S_DL_RX_SEL_16B        (0x0 << 4)
0200 #define RT1308_I2S_DL_RX_SEL_20B        (0x1 << 4)
0201 #define RT1308_I2S_DL_RX_SEL_24B        (0x2 << 4)
0202 #define RT1308_I2S_DL_RX_SEL_32B        (0x3 << 4)
0203 #define RT1308_I2S_DL_RX_SEL_8B         (0x4 << 4)
0204 #define RT1308_I2S_DL_TX_SEL_MASK       (0x7 << 0)
0205 #define RT1308_I2S_DL_TX_SEL_SFT        0
0206 #define RT1308_I2S_DL_TX_SEL_16B        (0x0 << 0)
0207 #define RT1308_I2S_DL_TX_SEL_20B        (0x1 << 0)
0208 #define RT1308_I2S_DL_TX_SEL_24B        (0x2 << 0)
0209 #define RT1308_I2S_DL_TX_SEL_32B        (0x3 << 0)
0210 #define RT1308_I2S_DL_TX_SEL_8B         (0x4 << 0)
0211 
0212 /* I2S Setting-2 (0x16) */
0213 #define RT1308_I2S_DL_SEL_MASK          (0x7 << 24)
0214 #define RT1308_I2S_DL_SEL_SFT           24
0215 #define RT1308_I2S_DL_SEL_16B           (0x0 << 24)
0216 #define RT1308_I2S_DL_SEL_20B           (0x1 << 24)
0217 #define RT1308_I2S_DL_SEL_24B           (0x2 << 24)
0218 #define RT1308_I2S_DL_SEL_32B           (0x3 << 24)
0219 #define RT1308_I2S_DL_SEL_8B            (0x4 << 24)
0220 #define RT1308_I2S_BCLK_MASK            (0x1 << 14)
0221 #define RT1308_I2S_BCLK_SFT         14
0222 #define RT1308_I2S_BCLK_NORMAL          (0x0 << 14)
0223 #define RT1308_I2S_BCLK_INV         (0x1 << 14)
0224 
0225 /* Power Control-1 (0x32) */
0226 #define RT1308_POW_MBIAS20U         (0x1 << 31)
0227 #define RT1308_POW_MBIAS20U_BIT         31
0228 #define RT1308_POW_ALDO             (0x1 << 30)
0229 #define RT1308_POW_ALDO_BIT         30
0230 #define RT1308_POW_DBG              (0x1 << 29)
0231 #define RT1308_POW_DBG_BIT          29
0232 #define RT1308_POW_DACL             (0x1 << 28)
0233 #define RT1308_POW_DACL_BIT         28
0234 #define RT1308_POW_DAC1             (0x1 << 27)
0235 #define RT1308_POW_DAC1_BIT         27
0236 #define RT1308_POW_CLK25M           (0x1 << 26)
0237 #define RT1308_POW_CLK25M_BIT           26
0238 #define RT1308_POW_ADC_R            (0x1 << 25)
0239 #define RT1308_POW_ADC_R_BIT            25
0240 #define RT1308_POW_ADC_L            (0x1 << 24)
0241 #define RT1308_POW_ADC_L_BIT            24
0242 #define RT1308_POW_DLDO             (0x1 << 21)
0243 #define RT1308_POW_DLDO_BIT         21
0244 #define RT1308_POW_VREF             (0x1 << 20)
0245 #define RT1308_POW_VREF_BIT         20
0246 #define RT1308_POW_MIXER_R          (0x1 << 18)
0247 #define RT1308_POW_MIXER_R_BIT          18
0248 #define RT1308_POW_MIXER_L          (0x1 << 17)
0249 #define RT1308_POW_MIXER_L_BIT          17
0250 #define RT1308_POW_MBIAS4U          (0x1 << 16)
0251 #define RT1308_POW_MBIAS4U_BIT          16
0252 #define RT1308_POW_PLL2_LDO_EN          (0x1 << 12)
0253 #define RT1308_POW_PLL2_LDO_EN_BIT      12
0254 #define RT1308_POW_PLL2B_EN         (0x1 << 11)
0255 #define RT1308_POW_PLL2B_EN_BIT         11
0256 #define RT1308_POW_PLL2F_EN         (0x1 << 10)
0257 #define RT1308_POW_PLL2F_EN_BIT         10
0258 #define RT1308_POW_PLL2F2_EN            (0x1 << 9)
0259 #define RT1308_POW_PLL2F2_EN_BIT        9
0260 #define RT1308_POW_PLL2B2_EN            (0x1 << 8)
0261 #define RT1308_POW_PLL2B2_EN_BIT        8
0262 
0263 /* Power Control-2 (0x36) */
0264 #define RT1308_POW_PDB_SRC_BIT          (0x1 << 27)
0265 #define RT1308_POW_PDB_MN_BIT           (0x1 << 25)
0266 #define RT1308_POW_PDB_REG_BIT          (0x1 << 24)
0267 
0268 
0269 /* System Clock Source */
0270 enum {
0271     RT1308_FS_SYS_S_MCLK,
0272     RT1308_FS_SYS_S_BCLK,
0273     RT1308_FS_SYS_S_PLL,
0274     RT1308_FS_SYS_S_RCCLK,  /* 25.0 MHz */
0275 };
0276 
0277 /* PLL Source */
0278 enum {
0279     RT1308_PLL_S_MCLK,
0280     RT1308_PLL_S_BCLK,
0281     RT1308_PLL_S_RCCLK,
0282 };
0283 
0284 enum {
0285     RT1308_AIF1,
0286     RT1308_AIFS
0287 };
0288 
0289 #endif      /* end of _RT1308_H_ */