Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 */
0002 /*
0003  * sgtl5000.h - SGTL5000 audio codec interface
0004  *
0005  * Copyright 2010-2011 Freescale Semiconductor, Inc.
0006  */
0007 
0008 #ifndef _SGTL5000_H
0009 #define _SGTL5000_H
0010 
0011 /*
0012  * Registers addresses
0013  */
0014 #define SGTL5000_CHIP_ID            0x0000
0015 #define SGTL5000_CHIP_DIG_POWER         0x0002
0016 #define SGTL5000_CHIP_CLK_CTRL          0x0004
0017 #define SGTL5000_CHIP_I2S_CTRL          0x0006
0018 #define SGTL5000_CHIP_SSS_CTRL          0x000a
0019 #define SGTL5000_CHIP_ADCDAC_CTRL       0x000e
0020 #define SGTL5000_CHIP_DAC_VOL           0x0010
0021 #define SGTL5000_CHIP_PAD_STRENGTH      0x0014
0022 #define SGTL5000_CHIP_ANA_ADC_CTRL      0x0020
0023 #define SGTL5000_CHIP_ANA_HP_CTRL       0x0022
0024 #define SGTL5000_CHIP_ANA_CTRL          0x0024
0025 #define SGTL5000_CHIP_LINREG_CTRL       0x0026
0026 #define SGTL5000_CHIP_REF_CTRL          0x0028
0027 #define SGTL5000_CHIP_MIC_CTRL          0x002a
0028 #define SGTL5000_CHIP_LINE_OUT_CTRL     0x002c
0029 #define SGTL5000_CHIP_LINE_OUT_VOL      0x002e
0030 #define SGTL5000_CHIP_ANA_POWER         0x0030
0031 #define SGTL5000_CHIP_PLL_CTRL          0x0032
0032 #define SGTL5000_CHIP_CLK_TOP_CTRL      0x0034
0033 #define SGTL5000_CHIP_ANA_STATUS        0x0036
0034 #define SGTL5000_CHIP_SHORT_CTRL        0x003c
0035 #define SGTL5000_CHIP_ANA_TEST2         0x003a
0036 #define SGTL5000_DAP_CTRL           0x0100
0037 #define SGTL5000_DAP_PEQ            0x0102
0038 #define SGTL5000_DAP_BASS_ENHANCE       0x0104
0039 #define SGTL5000_DAP_BASS_ENHANCE_CTRL      0x0106
0040 #define SGTL5000_DAP_AUDIO_EQ           0x0108
0041 #define SGTL5000_DAP_SURROUND           0x010a
0042 #define SGTL5000_DAP_FLT_COEF_ACCESS        0x010c
0043 #define SGTL5000_DAP_COEF_WR_B0_MSB     0x010e
0044 #define SGTL5000_DAP_COEF_WR_B0_LSB     0x0110
0045 #define SGTL5000_DAP_EQ_BASS_BAND0      0x0116
0046 #define SGTL5000_DAP_EQ_BASS_BAND1      0x0118
0047 #define SGTL5000_DAP_EQ_BASS_BAND2      0x011a
0048 #define SGTL5000_DAP_EQ_BASS_BAND3      0x011c
0049 #define SGTL5000_DAP_EQ_BASS_BAND4      0x011e
0050 #define SGTL5000_DAP_MAIN_CHAN          0x0120
0051 #define SGTL5000_DAP_MIX_CHAN           0x0122
0052 #define SGTL5000_DAP_AVC_CTRL           0x0124
0053 #define SGTL5000_DAP_AVC_THRESHOLD      0x0126
0054 #define SGTL5000_DAP_AVC_ATTACK         0x0128
0055 #define SGTL5000_DAP_AVC_DECAY          0x012a
0056 #define SGTL5000_DAP_COEF_WR_B1_MSB     0x012c
0057 #define SGTL5000_DAP_COEF_WR_B1_LSB     0x012e
0058 #define SGTL5000_DAP_COEF_WR_B2_MSB     0x0130
0059 #define SGTL5000_DAP_COEF_WR_B2_LSB     0x0132
0060 #define SGTL5000_DAP_COEF_WR_A1_MSB     0x0134
0061 #define SGTL5000_DAP_COEF_WR_A1_LSB     0x0136
0062 #define SGTL5000_DAP_COEF_WR_A2_MSB     0x0138
0063 #define SGTL5000_DAP_COEF_WR_A2_LSB     0x013a
0064 
0065 /*
0066  * Field Definitions.
0067  */
0068 
0069 /*
0070  * SGTL5000_CHIP_ID
0071  */
0072 #define SGTL5000_PARTID_MASK            0xff00
0073 #define SGTL5000_PARTID_SHIFT           8
0074 #define SGTL5000_PARTID_WIDTH           8
0075 #define SGTL5000_PARTID_PART_ID         0xa0
0076 #define SGTL5000_REVID_MASK         0x00ff
0077 #define SGTL5000_REVID_SHIFT            0
0078 #define SGTL5000_REVID_WIDTH            8
0079 
0080 /*
0081  * SGTL5000_CHIP_DIG_POWER
0082  */
0083 #define SGTL5000_DIG_POWER_DEFAULT      0x0000
0084 #define SGTL5000_ADC_EN             0x0040
0085 #define SGTL5000_DAC_EN             0x0020
0086 #define SGTL5000_DAP_POWERUP            0x0010
0087 #define SGTL5000_I2S_OUT_POWERUP        0x0002
0088 #define SGTL5000_I2S_IN_POWERUP         0x0001
0089 
0090 /*
0091  * SGTL5000_CHIP_CLK_CTRL
0092  */
0093 #define SGTL5000_CHIP_CLK_CTRL_DEFAULT      0x0008
0094 #define SGTL5000_RATE_MODE_MASK         0x0030
0095 #define SGTL5000_RATE_MODE_SHIFT        4
0096 #define SGTL5000_RATE_MODE_WIDTH        2
0097 #define SGTL5000_RATE_MODE_DIV_1        0
0098 #define SGTL5000_RATE_MODE_DIV_2        1
0099 #define SGTL5000_RATE_MODE_DIV_4        2
0100 #define SGTL5000_RATE_MODE_DIV_6        3
0101 #define SGTL5000_SYS_FS_MASK            0x000c
0102 #define SGTL5000_SYS_FS_SHIFT           2
0103 #define SGTL5000_SYS_FS_WIDTH           2
0104 #define SGTL5000_SYS_FS_32k         0x0
0105 #define SGTL5000_SYS_FS_44_1k           0x1
0106 #define SGTL5000_SYS_FS_48k         0x2
0107 #define SGTL5000_SYS_FS_96k         0x3
0108 #define SGTL5000_MCLK_FREQ_MASK         0x0003
0109 #define SGTL5000_MCLK_FREQ_SHIFT        0
0110 #define SGTL5000_MCLK_FREQ_WIDTH        2
0111 #define SGTL5000_MCLK_FREQ_256FS        0x0
0112 #define SGTL5000_MCLK_FREQ_384FS        0x1
0113 #define SGTL5000_MCLK_FREQ_512FS        0x2
0114 #define SGTL5000_MCLK_FREQ_PLL          0x3
0115 
0116 /*
0117  * SGTL5000_CHIP_I2S_CTRL
0118  */
0119 #define SGTL5000_I2S_SCLKFREQ_MASK      0x0100
0120 #define SGTL5000_I2S_SCLKFREQ_SHIFT     8
0121 #define SGTL5000_I2S_SCLKFREQ_WIDTH     1
0122 #define SGTL5000_I2S_SCLKFREQ_64FS      0x0
0123 #define SGTL5000_I2S_SCLKFREQ_32FS      0x1 /* Not for RJ mode */
0124 #define SGTL5000_I2S_MASTER         0x0080
0125 #define SGTL5000_I2S_SCLK_INV           0x0040
0126 #define SGTL5000_I2S_DLEN_MASK          0x0030
0127 #define SGTL5000_I2S_DLEN_SHIFT         4
0128 #define SGTL5000_I2S_DLEN_WIDTH         2
0129 #define SGTL5000_I2S_DLEN_32            0x0
0130 #define SGTL5000_I2S_DLEN_24            0x1
0131 #define SGTL5000_I2S_DLEN_20            0x2
0132 #define SGTL5000_I2S_DLEN_16            0x3
0133 #define SGTL5000_I2S_MODE_MASK          0x000c
0134 #define SGTL5000_I2S_MODE_SHIFT         2
0135 #define SGTL5000_I2S_MODE_WIDTH         2
0136 #define SGTL5000_I2S_MODE_I2S_LJ        0x0
0137 #define SGTL5000_I2S_MODE_RJ            0x1
0138 #define SGTL5000_I2S_MODE_PCM           0x2
0139 #define SGTL5000_I2S_LRALIGN            0x0002
0140 #define SGTL5000_I2S_LRPOL          0x0001  /* set for which mode */
0141 
0142 /*
0143  * SGTL5000_CHIP_SSS_CTRL
0144  */
0145 #define SGTL5000_DAP_MIX_LRSWAP         0x4000
0146 #define SGTL5000_DAP_LRSWAP         0x2000
0147 #define SGTL5000_DAC_LRSWAP         0x1000
0148 #define SGTL5000_I2S_OUT_LRSWAP         0x0400
0149 #define SGTL5000_DAP_MIX_SEL_MASK       0x0300
0150 #define SGTL5000_DAP_MIX_SEL_SHIFT      8
0151 #define SGTL5000_DAP_MIX_SEL_WIDTH      2
0152 #define SGTL5000_DAP_MIX_SEL_ADC        0x0
0153 #define SGTL5000_DAP_MIX_SEL_I2S_IN     0x1
0154 #define SGTL5000_DAP_SEL_MASK           0x00c0
0155 #define SGTL5000_DAP_SEL_SHIFT          6
0156 #define SGTL5000_DAP_SEL_WIDTH          2
0157 #define SGTL5000_DAP_SEL_ADC            0x0
0158 #define SGTL5000_DAP_SEL_I2S_IN         0x1
0159 #define SGTL5000_DAC_SEL_MASK           0x0030
0160 #define SGTL5000_DAC_SEL_SHIFT          4
0161 #define SGTL5000_DAC_SEL_WIDTH          2
0162 #define SGTL5000_DAC_SEL_ADC            0x0
0163 #define SGTL5000_DAC_SEL_I2S_IN         0x1
0164 #define SGTL5000_DAC_SEL_DAP            0x3
0165 #define SGTL5000_I2S_OUT_SEL_MASK       0x0003
0166 #define SGTL5000_I2S_OUT_SEL_SHIFT      0
0167 #define SGTL5000_I2S_OUT_SEL_WIDTH      2
0168 #define SGTL5000_I2S_OUT_SEL_ADC        0x0
0169 #define SGTL5000_I2S_OUT_SEL_I2S_IN     0x1
0170 #define SGTL5000_I2S_OUT_SEL_DAP        0x3
0171 
0172 /*
0173  * SGTL5000_CHIP_ADCDAC_CTRL
0174  */
0175 #define SGTL5000_VOL_BUSY_DAC_RIGHT     0x2000
0176 #define SGTL5000_VOL_BUSY_DAC_LEFT      0x1000
0177 #define SGTL5000_DAC_VOL_RAMP_EN        0x0200
0178 #define SGTL5000_DAC_VOL_RAMP_EXPO      0x0100
0179 #define SGTL5000_DAC_MUTE_RIGHT         0x0008
0180 #define SGTL5000_DAC_MUTE_LEFT          0x0004
0181 #define SGTL5000_ADC_HPF_FREEZE         0x0002
0182 #define SGTL5000_ADC_HPF_BYPASS         0x0001
0183 
0184 /*
0185  * SGTL5000_CHIP_DAC_VOL
0186  */
0187 #define SGTL5000_DAC_VOL_RIGHT_MASK     0xff00
0188 #define SGTL5000_DAC_VOL_RIGHT_SHIFT        8
0189 #define SGTL5000_DAC_VOL_RIGHT_WIDTH        8
0190 #define SGTL5000_DAC_VOL_LEFT_MASK      0x00ff
0191 #define SGTL5000_DAC_VOL_LEFT_SHIFT     0
0192 #define SGTL5000_DAC_VOL_LEFT_WIDTH     8
0193 
0194 /*
0195  * SGTL5000_CHIP_PAD_STRENGTH
0196  */
0197 #define SGTL5000_PAD_I2S_LRCLK_MASK     0x0300
0198 #define SGTL5000_PAD_I2S_LRCLK_SHIFT        8
0199 #define SGTL5000_PAD_I2S_LRCLK_WIDTH        2
0200 #define SGTL5000_PAD_I2S_SCLK_MASK      0x00c0
0201 #define SGTL5000_PAD_I2S_SCLK_SHIFT     6
0202 #define SGTL5000_PAD_I2S_SCLK_WIDTH     2
0203 #define SGTL5000_PAD_I2S_DOUT_MASK      0x0030
0204 #define SGTL5000_PAD_I2S_DOUT_SHIFT     4
0205 #define SGTL5000_PAD_I2S_DOUT_WIDTH     2
0206 #define SGTL5000_PAD_I2C_SDA_MASK       0x000c
0207 #define SGTL5000_PAD_I2C_SDA_SHIFT      2
0208 #define SGTL5000_PAD_I2C_SDA_WIDTH      2
0209 #define SGTL5000_PAD_I2C_SCL_MASK       0x0003
0210 #define SGTL5000_PAD_I2C_SCL_SHIFT      0
0211 #define SGTL5000_PAD_I2C_SCL_WIDTH      2
0212 
0213 /*
0214  * SGTL5000_CHIP_ANA_ADC_CTRL
0215  */
0216 #define SGTL5000_ADC_VOL_M6DB           0x0100
0217 #define SGTL5000_ADC_VOL_RIGHT_MASK     0x00f0
0218 #define SGTL5000_ADC_VOL_RIGHT_SHIFT        4
0219 #define SGTL5000_ADC_VOL_RIGHT_WIDTH        4
0220 #define SGTL5000_ADC_VOL_LEFT_MASK      0x000f
0221 #define SGTL5000_ADC_VOL_LEFT_SHIFT     0
0222 #define SGTL5000_ADC_VOL_LEFT_WIDTH     4
0223 
0224 /*
0225  * SGTL5000_CHIP_ANA_HP_CTRL
0226  */
0227 #define SGTL5000_HP_VOL_RIGHT_MASK      0x7f00
0228 #define SGTL5000_HP_VOL_RIGHT_SHIFT     8
0229 #define SGTL5000_HP_VOL_RIGHT_WIDTH     7
0230 #define SGTL5000_HP_VOL_LEFT_MASK       0x007f
0231 #define SGTL5000_HP_VOL_LEFT_SHIFT      0
0232 #define SGTL5000_HP_VOL_LEFT_WIDTH      7
0233 
0234 /*
0235  * SGTL5000_CHIP_ANA_CTRL
0236  */
0237 #define SGTL5000_CHIP_ANA_CTRL_DEFAULT      0x0133
0238 #define SGTL5000_LINE_OUT_MUTE          0x0100
0239 #define SGTL5000_HP_SEL_MASK            0x0040
0240 #define SGTL5000_HP_SEL_SHIFT           6
0241 #define SGTL5000_HP_SEL_WIDTH           1
0242 #define SGTL5000_HP_SEL_DAC         0x0
0243 #define SGTL5000_HP_SEL_LINE_IN         0x1
0244 #define SGTL5000_HP_ZCD_EN          0x0020
0245 #define SGTL5000_HP_MUTE            0x0010
0246 #define SGTL5000_ADC_SEL_MASK           0x0004
0247 #define SGTL5000_ADC_SEL_SHIFT          2
0248 #define SGTL5000_ADC_SEL_WIDTH          1
0249 #define SGTL5000_ADC_SEL_MIC            0x0
0250 #define SGTL5000_ADC_SEL_LINE_IN        0x1
0251 #define SGTL5000_ADC_ZCD_EN         0x0002
0252 #define SGTL5000_ADC_MUTE           0x0001
0253 
0254 /*
0255  * SGTL5000_CHIP_LINREG_CTRL
0256  */
0257 #define SGTL5000_VDDC_MAN_ASSN_MASK     0x0040
0258 #define SGTL5000_VDDC_MAN_ASSN_SHIFT        6
0259 #define SGTL5000_VDDC_MAN_ASSN_WIDTH        1
0260 #define SGTL5000_VDDC_MAN_ASSN_VDDA     0x0
0261 #define SGTL5000_VDDC_MAN_ASSN_VDDIO        0x1
0262 #define SGTL5000_VDDC_ASSN_OVRD         0x0020
0263 #define SGTL5000_LINREG_VDDD_MASK       0x000f
0264 #define SGTL5000_LINREG_VDDD_SHIFT      0
0265 #define SGTL5000_LINREG_VDDD_WIDTH      4
0266 
0267 /*
0268  * SGTL5000_CHIP_REF_CTRL
0269  */
0270 #define SGTL5000_ANA_GND_MASK           0x01f0
0271 #define SGTL5000_ANA_GND_SHIFT          4
0272 #define SGTL5000_ANA_GND_WIDTH          5
0273 #define SGTL5000_ANA_GND_BASE           800 /* mv */
0274 #define SGTL5000_ANA_GND_STP            25  /*mv */
0275 #define SGTL5000_BIAS_CTRL_MASK         0x000e
0276 #define SGTL5000_BIAS_CTRL_SHIFT        1
0277 #define SGTL5000_BIAS_CTRL_WIDTH        3
0278 #define SGTL5000_SMALL_POP          0x0001
0279 
0280 /*
0281  * SGTL5000_CHIP_MIC_CTRL
0282  */
0283 #define SGTL5000_BIAS_R_MASK            0x0300
0284 #define SGTL5000_BIAS_R_SHIFT           8
0285 #define SGTL5000_BIAS_R_WIDTH           2
0286 #define SGTL5000_BIAS_R_off         0x0
0287 #define SGTL5000_BIAS_R_2K          0x1
0288 #define SGTL5000_BIAS_R_4k          0x2
0289 #define SGTL5000_BIAS_R_8k          0x3
0290 #define SGTL5000_BIAS_VOLT_MASK         0x0070
0291 #define SGTL5000_BIAS_VOLT_SHIFT        4
0292 #define SGTL5000_BIAS_VOLT_WIDTH        3
0293 #define SGTL5000_MIC_GAIN_MASK          0x0003
0294 #define SGTL5000_MIC_GAIN_SHIFT         0
0295 #define SGTL5000_MIC_GAIN_WIDTH         2
0296 
0297 /*
0298  * SGTL5000_CHIP_LINE_OUT_CTRL
0299  */
0300 #define SGTL5000_LINE_OUT_CURRENT_MASK      0x0f00
0301 #define SGTL5000_LINE_OUT_CURRENT_SHIFT     8
0302 #define SGTL5000_LINE_OUT_CURRENT_WIDTH     4
0303 #define SGTL5000_LINE_OUT_CURRENT_180u      0x0
0304 #define SGTL5000_LINE_OUT_CURRENT_270u      0x1
0305 #define SGTL5000_LINE_OUT_CURRENT_360u      0x3
0306 #define SGTL5000_LINE_OUT_CURRENT_450u      0x7
0307 #define SGTL5000_LINE_OUT_CURRENT_540u      0xf
0308 #define SGTL5000_LINE_OUT_GND_MASK      0x003f
0309 #define SGTL5000_LINE_OUT_GND_SHIFT     0
0310 #define SGTL5000_LINE_OUT_GND_WIDTH     6
0311 #define SGTL5000_LINE_OUT_GND_BASE      800 /* mv */
0312 #define SGTL5000_LINE_OUT_GND_STP       25
0313 #define SGTL5000_LINE_OUT_GND_MAX       0x23
0314 
0315 /*
0316  * SGTL5000_CHIP_LINE_OUT_VOL
0317  */
0318 #define SGTL5000_LINE_OUT_VOL_RIGHT_MASK    0x1f00
0319 #define SGTL5000_LINE_OUT_VOL_RIGHT_SHIFT   8
0320 #define SGTL5000_LINE_OUT_VOL_RIGHT_WIDTH   5
0321 #define SGTL5000_LINE_OUT_VOL_LEFT_MASK     0x001f
0322 #define SGTL5000_LINE_OUT_VOL_LEFT_SHIFT    0
0323 #define SGTL5000_LINE_OUT_VOL_LEFT_WIDTH    5
0324 
0325 /*
0326  * SGTL5000_CHIP_ANA_POWER
0327  */
0328 #define SGTL5000_ANA_POWER_DEFAULT      0x7060
0329 #define SGTL5000_DAC_STEREO         0x4000
0330 #define SGTL5000_LINREG_SIMPLE_POWERUP      0x2000
0331 #define SGTL5000_STARTUP_POWERUP        0x1000
0332 #define SGTL5000_VDDC_CHRGPMP_POWERUP       0x0800
0333 #define SGTL5000_PLL_POWERUP            0x0400
0334 #define SGTL5000_LINEREG_D_POWERUP      0x0200
0335 #define SGTL5000_VCOAMP_POWERUP         0x0100
0336 #define SGTL5000_VAG_POWERUP            0x0080
0337 #define SGTL5000_ADC_STEREO         0x0040
0338 #define SGTL5000_REFTOP_POWERUP         0x0020
0339 #define SGTL5000_HP_POWERUP         0x0010
0340 #define SGTL5000_DAC_POWERUP            0x0008
0341 #define SGTL5000_CAPLESS_HP_POWERUP     0x0004
0342 #define SGTL5000_ADC_POWERUP            0x0002
0343 #define SGTL5000_LINE_OUT_POWERUP       0x0001
0344 
0345 /*
0346  * SGTL5000_CHIP_PLL_CTRL
0347  */
0348 #define SGTL5000_PLL_INT_DIV_MASK       0xf800
0349 #define SGTL5000_PLL_INT_DIV_SHIFT      11
0350 #define SGTL5000_PLL_INT_DIV_WIDTH      5
0351 #define SGTL5000_PLL_FRAC_DIV_MASK      0x07ff
0352 #define SGTL5000_PLL_FRAC_DIV_SHIFT     0
0353 #define SGTL5000_PLL_FRAC_DIV_WIDTH     11
0354 
0355 /*
0356  * SGTL5000_CHIP_CLK_TOP_CTRL
0357  */
0358 #define SGTL5000_INT_OSC_EN         0x0800
0359 #define SGTL5000_INPUT_FREQ_DIV2        0x0008
0360 
0361 /*
0362  * SGTL5000_CHIP_ANA_STATUS
0363  */
0364 #define SGTL5000_HP_LRSHORT         0x0200
0365 #define SGTL5000_CAPLESS_SHORT          0x0100
0366 #define SGTL5000_PLL_LOCKED         0x0010
0367 
0368 /*
0369  * SGTL5000_CHIP_SHORT_CTRL
0370  */
0371 #define SGTL5000_LVLADJR_MASK           0x7000
0372 #define SGTL5000_LVLADJR_SHIFT          12
0373 #define SGTL5000_LVLADJR_WIDTH          3
0374 #define SGTL5000_LVLADJL_MASK           0x0700
0375 #define SGTL5000_LVLADJL_SHIFT          8
0376 #define SGTL5000_LVLADJL_WIDTH          3
0377 #define SGTL5000_LVLADJC_MASK           0x0070
0378 #define SGTL5000_LVLADJC_SHIFT          4
0379 #define SGTL5000_LVLADJC_WIDTH          3
0380 #define SGTL5000_LR_SHORT_MOD_MASK      0x000c
0381 #define SGTL5000_LR_SHORT_MOD_SHIFT     2
0382 #define SGTL5000_LR_SHORT_MOD_WIDTH     2
0383 #define SGTL5000_CM_SHORT_MOD_MASK      0x0003
0384 #define SGTL5000_CM_SHORT_MOD_SHIFT     0
0385 #define SGTL5000_CM_SHORT_MOD_WIDTH     2
0386 
0387 /*
0388  *SGTL5000_CHIP_ANA_TEST2
0389  */
0390 #define SGTL5000_MONO_DAC           0x1000
0391 
0392 /*
0393  * SGTL5000_DAP_CTRL
0394  */
0395 #define SGTL5000_DAP_MIX_EN         0x0010
0396 #define SGTL5000_DAP_EN             0x0001
0397 
0398 #define SGTL5000_SYSCLK             0x00
0399 #define SGTL5000_LRCLK              0x01
0400 
0401 /*
0402  * SGTL5000_DAP_AUDIO_EQ
0403  */
0404 #define SGTL5000_DAP_SEL_PEQ            1
0405 #define SGTL5000_DAP_SEL_TONE_CTRL      2
0406 #define SGTL5000_DAP_SEL_GEQ            3
0407 
0408 #endif