Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0-only */
0002 /*
0003  * rt274.h  --  RT274 ALSA SoC audio driver
0004  *
0005  * Copyright 2016 Realtek Microelectronics
0006  * Author: Bard Liao <bardliao@realtek.com>
0007  */
0008 
0009 #ifndef __RT274_H__
0010 #define __RT274_H__
0011 
0012 #define VERB_CMD(V, N, D) ((N << 20) | (V << 8) | D)
0013 
0014 #define RT274_AUDIO_FUNCTION_GROUP          0x01
0015 #define RT274_DAC_OUT0                  0x02
0016 #define RT274_DAC_OUT1                  0x03
0017 #define RT274_ADC_IN2                   0x08
0018 #define RT274_ADC_IN1                   0x09
0019 #define RT274_DIG_CVT                   0x0a
0020 #define RT274_DMIC1                 0x12
0021 #define RT274_DMIC2                 0x13
0022 #define RT274_MIC                   0x19
0023 #define RT274_LINE1                 0x1a
0024 #define RT274_LINE2                 0x1b
0025 #define RT274_LINE3                 0x16
0026 #define RT274_SPDIF                 0x1e
0027 #define RT274_VENDOR_REGISTERS              0x20
0028 #define RT274_HP_OUT                    0x21
0029 #define RT274_MIXER_IN1                 0x22
0030 #define RT274_MIXER_IN2                 0x23
0031 #define RT274_INLINE_CMD                0x55
0032 
0033 #define RT274_SET_PIN_SFT               6
0034 #define RT274_SET_PIN_ENABLE                0x40
0035 #define RT274_SET_PIN_DISABLE               0
0036 #define RT274_SET_EAPD_HIGH             0x2
0037 #define RT274_SET_EAPD_LOW              0
0038 
0039 #define RT274_MUTE_SFT                  7
0040 
0041 /* Verb commands */
0042 #define RT274_RESET\
0043     VERB_CMD(AC_VERB_SET_CODEC_RESET, RT274_AUDIO_FUNCTION_GROUP, 0)
0044 #define RT274_GET_PARAM(NID, PARAM) VERB_CMD(AC_VERB_PARAMETERS, NID, PARAM)
0045 #define RT274_SET_POWER(NID) VERB_CMD(AC_VERB_SET_POWER_STATE, NID, 0)
0046 #define RT274_SET_AUDIO_POWER RT274_SET_POWER(RT274_AUDIO_FUNCTION_GROUP)
0047 #define RT274_SET_HPO_POWER RT274_SET_POWER(RT274_HP_OUT)
0048 #define RT274_SET_DMIC1_POWER RT274_SET_POWER(RT274_DMIC1)
0049 #define RT274_LOUT_MUX\
0050     VERB_CMD(AC_VERB_SET_CONNECT_SEL, RT274_LINE3, 0)
0051 #define RT274_HPO_MUX\
0052     VERB_CMD(AC_VERB_SET_CONNECT_SEL, RT274_HP_OUT, 0)
0053 #define RT274_ADC0_MUX\
0054     VERB_CMD(AC_VERB_SET_CONNECT_SEL, RT274_MIXER_IN1, 0)
0055 #define RT274_ADC1_MUX\
0056     VERB_CMD(AC_VERB_SET_CONNECT_SEL, RT274_MIXER_IN2, 0)
0057 #define RT274_SET_MIC\
0058     VERB_CMD(AC_VERB_SET_PIN_WIDGET_CONTROL, RT274_MIC, 0)
0059 #define RT274_SET_PIN_LOUT3\
0060     VERB_CMD(AC_VERB_SET_PIN_WIDGET_CONTROL, RT274_LINE3, 0)
0061 #define RT274_SET_PIN_HPO\
0062     VERB_CMD(AC_VERB_SET_PIN_WIDGET_CONTROL, RT274_HP_OUT, 0)
0063 #define RT274_SET_PIN_DMIC1\
0064     VERB_CMD(AC_VERB_SET_PIN_WIDGET_CONTROL, RT274_DMIC1, 0)
0065 #define RT274_SET_PIN_SPDIF\
0066     VERB_CMD(AC_VERB_SET_PIN_WIDGET_CONTROL, RT274_SPDIF, 0)
0067 #define RT274_SET_PIN_DIG_CVT\
0068     VERB_CMD(AC_VERB_SET_DIGI_CONVERT_1, RT274_DIG_CVT, 0)
0069 #define RT274_SET_AMP_GAIN_HPO\
0070     VERB_CMD(AC_VERB_SET_AMP_GAIN_MUTE, RT274_HP_OUT, 0)
0071 #define RT274_SET_AMP_GAIN_ADC_IN1\
0072     VERB_CMD(AC_VERB_SET_AMP_GAIN_MUTE, RT274_ADC_IN1, 0)
0073 #define RT274_SET_AMP_GAIN_ADC_IN2\
0074     VERB_CMD(AC_VERB_SET_AMP_GAIN_MUTE, RT274_ADC_IN2, 0)
0075 #define RT274_GET_HP_SENSE\
0076     VERB_CMD(AC_VERB_GET_PIN_SENSE, RT274_HP_OUT, 0)
0077 #define RT274_GET_MIC_SENSE\
0078     VERB_CMD(AC_VERB_GET_PIN_SENSE, RT274_MIC, 0)
0079 #define RT274_SET_DMIC2_DEFAULT\
0080     VERB_CMD(AC_VERB_SET_CONFIG_DEFAULT_BYTES_3, RT274_DMIC2, 0)
0081 #define RT274_SET_SPDIF_DEFAULT\
0082     VERB_CMD(AC_VERB_SET_CONFIG_DEFAULT_BYTES_3, RT274_SPDIF, 0)
0083 #define RT274_DAC0L_GAIN\
0084     VERB_CMD(AC_VERB_SET_AMP_GAIN_MUTE, RT274_DAC_OUT0, 0xa000)
0085 #define RT274_DAC0R_GAIN\
0086     VERB_CMD(AC_VERB_SET_AMP_GAIN_MUTE, RT274_DAC_OUT0, 0x9000)
0087 #define RT274_DAC1L_GAIN\
0088     VERB_CMD(AC_VERB_SET_AMP_GAIN_MUTE, RT274_DAC_OUT1, 0xa000)
0089 #define RT274_DAC1R_GAIN\
0090     VERB_CMD(AC_VERB_SET_AMP_GAIN_MUTE, RT274_DAC_OUT1, 0x9000)
0091 #define RT274_ADCL_GAIN\
0092     VERB_CMD(AC_VERB_SET_AMP_GAIN_MUTE, RT274_ADC_IN1, 0x6000)
0093 #define RT274_ADCR_GAIN\
0094     VERB_CMD(AC_VERB_SET_AMP_GAIN_MUTE, RT274_ADC_IN1, 0x5000)
0095 #define RT274_MIC_GAIN\
0096     VERB_CMD(AC_VERB_SET_AMP_GAIN_MUTE, RT274_MIC, 0x7000)
0097 #define RT274_LOUTL_GAIN\
0098     VERB_CMD(AC_VERB_SET_AMP_GAIN_MUTE, RT274_LINE3, 0xa000)
0099 #define RT274_LOUTR_GAIN\
0100     VERB_CMD(AC_VERB_SET_AMP_GAIN_MUTE, RT274_LINE3, 0x9000)
0101 #define RT274_HPOL_GAIN\
0102     VERB_CMD(AC_VERB_SET_AMP_GAIN_MUTE, RT274_HP_OUT, 0xa000)
0103 #define RT274_HPOR_GAIN\
0104     VERB_CMD(AC_VERB_SET_AMP_GAIN_MUTE, RT274_HP_OUT, 0x9000)
0105 #define RT274_DAC_FORMAT\
0106     VERB_CMD(AC_VERB_SET_STREAM_FORMAT, RT274_DAC_OUT0, 0)
0107 #define RT274_ADC_FORMAT\
0108     VERB_CMD(AC_VERB_SET_STREAM_FORMAT, RT274_ADC_IN1, 0)
0109 #define RT274_COEF_INDEX\
0110     VERB_CMD(AC_VERB_SET_COEF_INDEX, RT274_VENDOR_REGISTERS, 0)
0111 #define RT274_PROC_COEF\
0112     VERB_CMD(AC_VERB_SET_PROC_COEF, RT274_VENDOR_REGISTERS, 0)
0113 #define RT274_UNSOLICITED_INLINE_CMD\
0114     VERB_CMD(AC_VERB_SET_UNSOLICITED_ENABLE, RT274_INLINE_CMD, 0)
0115 #define RT274_UNSOLICITED_HP_OUT\
0116     VERB_CMD(AC_VERB_SET_UNSOLICITED_ENABLE, RT274_HP_OUT, 0)
0117 #define RT274_UNSOLICITED_MIC\
0118     VERB_CMD(AC_VERB_SET_UNSOLICITED_ENABLE, RT274_MIC, 0)
0119 #define RT274_COEF58_INDEX\
0120     VERB_CMD(AC_VERB_SET_COEF_INDEX, 0x58, 0)
0121 #define RT274_COEF58_COEF\
0122     VERB_CMD(AC_VERB_SET_PROC_COEF, 0x58, 0)
0123 #define RT274_COEF5b_INDEX\
0124     VERB_CMD(AC_VERB_SET_COEF_INDEX, 0x5b, 0)
0125 #define RT274_COEF5b_COEF\
0126     VERB_CMD(AC_VERB_SET_PROC_COEF, 0x5b, 0)
0127 #define RT274_SET_STREAMID_DAC0\
0128     VERB_CMD(AC_VERB_SET_CHANNEL_STREAMID, RT274_DAC_OUT0, 0)
0129 #define RT274_SET_STREAMID_DAC1\
0130     VERB_CMD(AC_VERB_SET_CHANNEL_STREAMID, RT274_DAC_OUT1, 0)
0131 #define RT274_SET_STREAMID_ADC1\
0132     VERB_CMD(AC_VERB_SET_CHANNEL_STREAMID, RT274_ADC_IN1, 0)
0133 #define RT274_SET_STREAMID_ADC2\
0134     VERB_CMD(AC_VERB_SET_CHANNEL_STREAMID, RT274_ADC_IN2, 0)
0135 
0136 /* Index registers */
0137 #define RT274_EAPD_GPIO_IRQ_CTRL    0x10
0138 #define RT274_PAD_CTRL12        0x35
0139 #define RT274_I2S_CTRL1         0x63
0140 #define RT274_I2S_CTRL2         0x64
0141 #define RT274_MCLK_CTRL         0x71
0142 #define RT274_CLK_CTRL          0x72
0143 #define RT274_PLL2_CTRL         0x7b
0144 
0145 
0146 /* EAPD GPIO IRQ control (Index 0x10) */
0147 #define RT274_IRQ_DIS       (0x0 << 13)
0148 #define RT274_IRQ_EN        (0x1 << 13)
0149 #define RT274_IRQ_CLR       (0x1 << 12)
0150 #define RT274_GPI2_SEL_MASK (0x3 << 7)
0151 #define RT274_GPI2_SEL_GPIO2    (0x0 << 7)
0152 #define RT274_GPI2_SEL_I2S  (0x1 << 7)
0153 #define RT274_GPI2_SEL_DMIC_CLK (0x2 << 7)
0154 #define RT274_GPI2_SEL_CBJ  (0x3 << 7)
0155 
0156 /* Front I2S_Interface control 1 (Index 0x63) */
0157 #define RT274_I2S_MODE_MASK (0x1 << 11)
0158 #define RT274_I2S_MODE_S    (0x0 << 11)
0159 #define RT274_I2S_MODE_M    (0x1 << 11)
0160 #define RT274_TDM_DIS       (0x0 << 10)
0161 #define RT274_TDM_EN        (0x1 << 10)
0162 #define RT274_TDM_CH_NUM    (0x1 << 7)
0163 #define RT274_TDM_2CH       (0x0 << 7)
0164 #define RT274_TDM_4CH       (0x1 << 7)
0165 #define RT274_I2S_FMT_MASK  (0x3 << 8)
0166 #define RT274_I2S_FMT_I2S   (0x0 << 8)
0167 #define RT274_I2S_FMT_LJ    (0x1 << 8)
0168 #define RT274_I2S_FMT_PCMA  (0x2 << 8)
0169 #define RT274_I2S_FMT_PCMB  (0x3 << 8)
0170 
0171 /* MCLK clock domain control (Index 0x71) */
0172 #define RT274_MCLK_MODE_MASK    (0x1 << 14)
0173 #define RT274_MCLK_MODE_DIS (0x0 << 14)
0174 #define RT274_MCLK_MODE_EN  (0x1 << 14)
0175 
0176 /* Clock control (Index 0x72) */
0177 #define RT274_CLK_SRC_MASK  (0x7 << 3)
0178 #define RT274_CLK_SRC_MCLK  (0x0 << 3)
0179 #define RT274_CLK_SRC_PLL2  (0x3 << 3)
0180 
0181 /* PLL2 control (Index 0x7b) */
0182 #define RT274_PLL2_SRC_MASK (0x1 << 13)
0183 #define RT274_PLL2_SRC_MCLK (0x0 << 13)
0184 #define RT274_PLL2_SRC_BCLK (0x1 << 13)
0185 
0186 /* HP-OUT (0x21) */
0187 #define RT274_M_HP_MUX_SFT  14
0188 #define RT274_HP_SEL_MASK   0x1
0189 #define RT274_HP_SEL_SFT    0
0190 #define RT274_HP_SEL_F      0
0191 #define RT274_HP_SEL_S      1
0192 
0193 /* ADC (0x22) (0x23) */
0194 #define RT274_ADC_SEL_MASK  0x7
0195 #define RT274_ADC_SEL_SFT   0
0196 #define RT274_ADC_SEL_MIC   0
0197 #define RT274_ADC_SEL_LINE1 1
0198 #define RT274_ADC_SEL_LINE2 2
0199 #define RT274_ADC_SEL_DMIC  3
0200 
0201 #define RT274_SCLK_S_MCLK   0
0202 #define RT274_SCLK_S_PLL1   1
0203 #define RT274_SCLK_S_PLL2   2
0204 
0205 #define RT274_PLL2_S_MCLK   0
0206 #define RT274_PLL2_S_BCLK   1
0207 
0208 enum {
0209     RT274_AIF1,
0210     RT274_AIFS,
0211 };
0212 
0213 #endif /* __RT274_H__ */
0214