0001
0002
0003
0004
0005
0006
0007
0008 #ifndef __RT715_H__
0009 #define __RT715_H__
0010
0011 #include <linux/regulator/consumer.h>
0012
0013 struct rt715_priv {
0014 struct regmap *regmap;
0015 struct regmap *sdw_regmap;
0016 struct snd_soc_codec *codec;
0017 struct sdw_slave *slave;
0018 int dbg_nid;
0019 int dbg_vid;
0020 int dbg_payload;
0021 enum sdw_slave_status status;
0022 struct sdw_bus_params params;
0023 bool hw_init;
0024 bool first_hw_init;
0025 unsigned int kctl_2ch_vol_ori[2];
0026 unsigned int kctl_8ch_switch_ori[8];
0027 unsigned int kctl_8ch_vol_ori[8];
0028 };
0029
0030 struct sdw_stream_data {
0031 struct sdw_stream_runtime *sdw_stream;
0032 };
0033
0034
0035 #define RT715_AUDIO_FUNCTION_GROUP 0x01
0036 #define RT715_MIC_ADC 0x07
0037 #define RT715_LINE_ADC 0x08
0038 #define RT715_MIX_ADC 0x09
0039 #define RT715_DMIC1 0x12
0040 #define RT715_DMIC2 0x13
0041 #define RT715_MIC1 0x18
0042 #define RT715_MIC2 0x19
0043 #define RT715_LINE1 0x1a
0044 #define RT715_LINE2 0x1b
0045 #define RT715_DMIC3 0x1d
0046 #define RT715_DMIC4 0x29
0047 #define RT715_VENDOR_REGISTERS 0x20
0048 #define RT715_MUX_IN1 0x22
0049 #define RT715_MUX_IN2 0x23
0050 #define RT715_MUX_IN3 0x24
0051 #define RT715_MUX_IN4 0x25
0052 #define RT715_MIX_ADC2 0x27
0053 #define RT715_INLINE_CMD 0x55
0054
0055
0056 #define RT715_SDW_INPUT_SEL 0x39
0057 #define RT715_EXT_DMIC_CLK_CTRL2 0x54
0058
0059
0060 #define RT715_VERB_SET_CONNECT_SEL 0x3100
0061 #define RT715_VERB_GET_CONNECT_SEL 0xb100
0062 #define RT715_VERB_SET_EAPD_BTLENABLE 0x3c00
0063 #define RT715_VERB_SET_POWER_STATE 0x3500
0064 #define RT715_VERB_SET_CHANNEL_STREAMID 0x3600
0065 #define RT715_VERB_SET_PIN_WIDGET_CONTROL 0x3700
0066 #define RT715_VERB_SET_CONFIG_DEFAULT1 0x4c00
0067 #define RT715_VERB_SET_CONFIG_DEFAULT2 0x4d00
0068 #define RT715_VERB_SET_CONFIG_DEFAULT3 0x4e00
0069 #define RT715_VERB_SET_CONFIG_DEFAULT4 0x4f00
0070 #define RT715_VERB_SET_UNSOLICITED_ENABLE 0x3800
0071 #define RT715_SET_AMP_GAIN_MUTE_H 0x7300
0072 #define RT715_SET_AMP_GAIN_MUTE_L 0x8380
0073 #define RT715_READ_HDA_3 0x2012
0074 #define RT715_READ_HDA_2 0x2013
0075 #define RT715_READ_HDA_1 0x2014
0076 #define RT715_READ_HDA_0 0x2015
0077 #define RT715_PRIV_INDEX_W_H 0x7520
0078 #define RT715_PRIV_INDEX_W_L 0x85a0
0079 #define RT715_PRIV_DATA_W_H 0x7420
0080 #define RT715_PRIV_DATA_W_L 0x84a0
0081 #define RT715_PRIV_INDEX_R_H 0x9d20
0082 #define RT715_PRIV_INDEX_R_L 0xada0
0083 #define RT715_PRIV_DATA_R_H 0x9c20
0084 #define RT715_PRIV_DATA_R_L 0xaca0
0085 #define RT715_MIC_ADC_FORMAT_H 0x7207
0086 #define RT715_MIC_ADC_FORMAT_L 0x8287
0087 #define RT715_MIC_LINE_FORMAT_H 0x7208
0088 #define RT715_MIC_LINE_FORMAT_L 0x8288
0089 #define RT715_MIX_ADC_FORMAT_H 0x7209
0090 #define RT715_MIX_ADC_FORMAT_L 0x8289
0091 #define RT715_MIX_ADC2_FORMAT_H 0x7227
0092 #define RT715_MIX_ADC2_FORMAT_L 0x82a7
0093 #define RT715_FUNC_RESET 0xff01
0094
0095 #define RT715_SET_AUDIO_POWER_STATE\
0096 (RT715_VERB_SET_POWER_STATE | RT715_AUDIO_FUNCTION_GROUP)
0097 #define RT715_SET_PIN_DMIC1\
0098 (RT715_VERB_SET_PIN_WIDGET_CONTROL | RT715_DMIC1)
0099 #define RT715_SET_PIN_DMIC2\
0100 (RT715_VERB_SET_PIN_WIDGET_CONTROL | RT715_DMIC2)
0101 #define RT715_SET_PIN_DMIC3\
0102 (RT715_VERB_SET_PIN_WIDGET_CONTROL | RT715_DMIC3)
0103 #define RT715_SET_PIN_DMIC4\
0104 (RT715_VERB_SET_PIN_WIDGET_CONTROL | RT715_DMIC4)
0105 #define RT715_SET_PIN_MIC1\
0106 (RT715_VERB_SET_PIN_WIDGET_CONTROL | RT715_MIC1)
0107 #define RT715_SET_PIN_MIC2\
0108 (RT715_VERB_SET_PIN_WIDGET_CONTROL | RT715_MIC2)
0109 #define RT715_SET_PIN_LINE1\
0110 (RT715_VERB_SET_PIN_WIDGET_CONTROL | RT715_LINE1)
0111 #define RT715_SET_PIN_LINE2\
0112 (RT715_VERB_SET_PIN_WIDGET_CONTROL | RT715_LINE2)
0113 #define RT715_SET_MIC1_UNSOLICITED_ENABLE\
0114 (RT715_VERB_SET_UNSOLICITED_ENABLE | RT715_MIC1)
0115 #define RT715_SET_MIC2_UNSOLICITED_ENABLE\
0116 (RT715_VERB_SET_UNSOLICITED_ENABLE | RT715_MIC2)
0117 #define RT715_SET_STREAMID_MIC_ADC\
0118 (RT715_VERB_SET_CHANNEL_STREAMID | RT715_MIC_ADC)
0119 #define RT715_SET_STREAMID_LINE_ADC\
0120 (RT715_VERB_SET_CHANNEL_STREAMID | RT715_LINE_ADC)
0121 #define RT715_SET_STREAMID_MIX_ADC\
0122 (RT715_VERB_SET_CHANNEL_STREAMID | RT715_MIX_ADC)
0123 #define RT715_SET_STREAMID_MIX_ADC2\
0124 (RT715_VERB_SET_CHANNEL_STREAMID | RT715_MIX_ADC2)
0125 #define RT715_SET_GAIN_MIC_ADC_L\
0126 (RT715_SET_AMP_GAIN_MUTE_L | RT715_MIC_ADC)
0127 #define RT715_SET_GAIN_MIC_ADC_H\
0128 (RT715_SET_AMP_GAIN_MUTE_H | RT715_MIC_ADC)
0129 #define RT715_SET_GAIN_LINE_ADC_L\
0130 (RT715_SET_AMP_GAIN_MUTE_L | RT715_LINE_ADC)
0131 #define RT715_SET_GAIN_LINE_ADC_H\
0132 (RT715_SET_AMP_GAIN_MUTE_H | RT715_LINE_ADC)
0133 #define RT715_SET_GAIN_MIX_ADC_L\
0134 (RT715_SET_AMP_GAIN_MUTE_L | RT715_MIX_ADC)
0135 #define RT715_SET_GAIN_MIX_ADC_H\
0136 (RT715_SET_AMP_GAIN_MUTE_H | RT715_MIX_ADC)
0137 #define RT715_SET_GAIN_MIX_ADC2_L\
0138 (RT715_SET_AMP_GAIN_MUTE_L | RT715_MIX_ADC2)
0139 #define RT715_SET_GAIN_MIX_ADC2_H\
0140 (RT715_SET_AMP_GAIN_MUTE_H | RT715_MIX_ADC2)
0141 #define RT715_SET_GAIN_DMIC1_L\
0142 (RT715_SET_AMP_GAIN_MUTE_L | RT715_DMIC1)
0143 #define RT715_SET_GAIN_DMIC1_H\
0144 (RT715_SET_AMP_GAIN_MUTE_H | RT715_DMIC1)
0145 #define RT715_SET_GAIN_DMIC2_L\
0146 (RT715_SET_AMP_GAIN_MUTE_L | RT715_DMIC2)
0147 #define RT715_SET_GAIN_DMIC2_H\
0148 (RT715_SET_AMP_GAIN_MUTE_H | RT715_DMIC2)
0149 #define RT715_SET_GAIN_DMIC3_L\
0150 (RT715_SET_AMP_GAIN_MUTE_L | RT715_DMIC3)
0151 #define RT715_SET_GAIN_DMIC3_H\
0152 (RT715_SET_AMP_GAIN_MUTE_H | RT715_DMIC3)
0153 #define RT715_SET_GAIN_DMIC4_L\
0154 (RT715_SET_AMP_GAIN_MUTE_L | RT715_DMIC4)
0155 #define RT715_SET_GAIN_DMIC4_H\
0156 (RT715_SET_AMP_GAIN_MUTE_H | RT715_DMIC4)
0157 #define RT715_SET_GAIN_MIC1_L\
0158 (RT715_SET_AMP_GAIN_MUTE_L | RT715_MIC1)
0159 #define RT715_SET_GAIN_MIC1_H\
0160 (RT715_SET_AMP_GAIN_MUTE_H | RT715_MIC1)
0161 #define RT715_SET_GAIN_MIC2_L\
0162 (RT715_SET_AMP_GAIN_MUTE_L | RT715_MIC2)
0163 #define RT715_SET_GAIN_MIC2_H\
0164 (RT715_SET_AMP_GAIN_MUTE_H | RT715_MIC2)
0165 #define RT715_SET_GAIN_LINE1_L\
0166 (RT715_SET_AMP_GAIN_MUTE_L | RT715_LINE1)
0167 #define RT715_SET_GAIN_LINE1_H\
0168 (RT715_SET_AMP_GAIN_MUTE_H | RT715_LINE1)
0169 #define RT715_SET_GAIN_LINE2_L\
0170 (RT715_SET_AMP_GAIN_MUTE_L | RT715_LINE2)
0171 #define RT715_SET_GAIN_LINE2_H\
0172 (RT715_SET_AMP_GAIN_MUTE_H | RT715_LINE2)
0173 #define RT715_SET_DMIC1_CONFIG_DEFAULT1\
0174 (RT715_VERB_SET_CONFIG_DEFAULT1 | RT715_DMIC1)
0175 #define RT715_SET_DMIC2_CONFIG_DEFAULT1\
0176 (RT715_VERB_SET_CONFIG_DEFAULT1 | RT715_DMIC2)
0177 #define RT715_SET_DMIC1_CONFIG_DEFAULT2\
0178 (RT715_VERB_SET_CONFIG_DEFAULT2 | RT715_DMIC1)
0179 #define RT715_SET_DMIC2_CONFIG_DEFAULT2\
0180 (RT715_VERB_SET_CONFIG_DEFAULT2 | RT715_DMIC2)
0181 #define RT715_SET_DMIC1_CONFIG_DEFAULT3\
0182 (RT715_VERB_SET_CONFIG_DEFAULT3 | RT715_DMIC1)
0183 #define RT715_SET_DMIC2_CONFIG_DEFAULT3\
0184 (RT715_VERB_SET_CONFIG_DEFAULT3 | RT715_DMIC2)
0185 #define RT715_SET_DMIC1_CONFIG_DEFAULT4\
0186 (RT715_VERB_SET_CONFIG_DEFAULT4 | RT715_DMIC1)
0187 #define RT715_SET_DMIC2_CONFIG_DEFAULT4\
0188 (RT715_VERB_SET_CONFIG_DEFAULT4 | RT715_DMIC2)
0189 #define RT715_SET_DMIC3_CONFIG_DEFAULT1\
0190 (RT715_VERB_SET_CONFIG_DEFAULT1 | RT715_DMIC3)
0191 #define RT715_SET_DMIC4_CONFIG_DEFAULT1\
0192 (RT715_VERB_SET_CONFIG_DEFAULT1 | RT715_DMIC4)
0193 #define RT715_SET_DMIC3_CONFIG_DEFAULT2\
0194 (RT715_VERB_SET_CONFIG_DEFAULT2 | RT715_DMIC3)
0195 #define RT715_SET_DMIC4_CONFIG_DEFAULT2\
0196 (RT715_VERB_SET_CONFIG_DEFAULT2 | RT715_DMIC4)
0197 #define RT715_SET_DMIC3_CONFIG_DEFAULT3\
0198 (RT715_VERB_SET_CONFIG_DEFAULT3 | RT715_DMIC3)
0199 #define RT715_SET_DMIC4_CONFIG_DEFAULT3\
0200 (RT715_VERB_SET_CONFIG_DEFAULT3 | RT715_DMIC4)
0201 #define RT715_SET_DMIC3_CONFIG_DEFAULT4\
0202 (RT715_VERB_SET_CONFIG_DEFAULT4 | RT715_DMIC3)
0203 #define RT715_SET_DMIC4_CONFIG_DEFAULT4\
0204 (RT715_VERB_SET_CONFIG_DEFAULT4 | RT715_DMIC4)
0205
0206 #define RT715_MUTE_SFT 7
0207 #define RT715_DIR_IN_SFT 6
0208 #define RT715_DIR_OUT_SFT 7
0209
0210 enum {
0211 RT715_AIF1,
0212 RT715_AIF2,
0213 };
0214
0215 #define RT715_POWER_UP_DELAY_MS 400
0216
0217 int rt715_io_init(struct device *dev, struct sdw_slave *slave);
0218 int rt715_init(struct device *dev, struct regmap *sdw_regmap,
0219 struct regmap *regmap, struct sdw_slave *slave);
0220
0221 int hda_to_sdw(unsigned int nid, unsigned int verb, unsigned int payload,
0222 unsigned int *sdw_addr_h, unsigned int *sdw_data_h,
0223 unsigned int *sdw_addr_l, unsigned int *sdw_data_l);
0224 int rt715_clock_config(struct device *dev);
0225 #endif