File Index
Files and directories
Sign in
FILE

rt721-sdca.h

File preview with syntax highlighting.

linux-6.19.14/sound/soc/codecs/rt721-sdca.h C
  1/* SPDX-License-Identifier: GPL-2.0-only */
  2/*
  3 * rt721-sdca.h -- RT721 SDCA ALSA SoC audio driver header
  4 *
  5 * Copyright(c) 2024 Realtek Semiconductor Corp.
  6 */
  7
  8#ifndef __RT721_H__
  9#define __RT721_H__
 10
 11#include <linux/pm.h>
 12#include <linux/regmap.h>
 13#include <linux/soundwire/sdw.h>
 14#include <linux/soundwire/sdw_type.h>
 15#include <sound/soc.h>
 16#include <linux/workqueue.h>
 17
 18struct  rt721_sdca_priv {
 19	struct regmap *regmap;
 20	struct regmap *mbq_regmap;
 21	struct snd_soc_component *component;
 22	struct sdw_slave *slave;
 23	struct sdw_bus_params params;
 24	bool hw_init;
 25	bool first_hw_init;
 26	struct mutex calibrate_mutex;
 27	struct mutex disable_irq_lock;
 28	bool disable_irq;
 29	/* For Headset jack & Headphone */
 30	unsigned int scp_sdca_stat1;
 31	unsigned int scp_sdca_stat2;
 32	struct snd_soc_jack *hs_jack;
 33	struct delayed_work jack_detect_work;
 34	struct delayed_work jack_btn_check_work;
 35	int jack_type;
 36	int jd_src;
 37	bool fu0f_dapm_mute;
 38	bool fu0f_mixer_l_mute;
 39	bool fu0f_mixer_r_mute;
 40	/* For DMIC */
 41	bool fu1e_dapm_mute;
 42	bool fu1e_mixer_mute[4];
 43};
 44
 45struct rt721_sdca_dmic_kctrl_priv {
 46	unsigned int reg_base;
 47	unsigned int count;
 48	unsigned int max;
 49	unsigned int invert;
 50};
 51
 52/* NID */
 53#define RT721_ANA_POW_PART			0x01
 54#define RT721_DAC_CTRL				0x04
 55#define RT721_JD_CTRL				0x09
 56#define RT721_CBJ_CTRL				0x0a
 57#define RT721_CAP_PORT_CTRL			0x0c
 58#define RT721_CLASD_AMP_CTRL			0x0d
 59#define RT721_BOOST_CTRL			0x0f
 60#define RT721_VENDOR_REG			0x20
 61#define RT721_RC_CALIB_CTRL			0x40
 62#define RT721_VENDOR_EQ_L			0x53
 63#define RT721_VENDOR_EQ_R			0x54
 64#define RT721_VENDOR_HP_CALI			0x56
 65#define RT721_VENDOR_CHARGE_PUMP		0x57
 66#define RT721_VENDOR_CLASD_CALI			0x58
 67#define RT721_VENDOR_IMS_DRE			0x5b
 68#define RT721_VENDOR_SPK_EFUSE			0x5c
 69#define RT721_VENDOR_LEVEL_CTRL			0x5d
 70#define RT721_VENDOR_ANA_CTL			0x5f
 71#define RT721_HDA_SDCA_FLOAT			0x61
 72
 73/* Index (NID:01h) */
 74#define RT721_MBIAS_LV_CTRL2			0x07
 75#define RT721_VREF1_HV_CTRL1			0x0a
 76#define RT721_VREF2_LV_CTRL1			0x0b
 77
 78/* Index (NID:04h) */
 79#define RT721_DAC_2CH_CTRL3			0x02
 80#define RT721_DAC_2CH_CTRL4			0x03
 81
 82/* Index (NID:09h) */
 83#define RT721_JD_1PIN_GAT_CTRL2			0x07
 84
 85/* Index (NID:0ah) */
 86#define RT721_CBJ_A0_GAT_CTRL1			0x04
 87#define RT721_CBJ_A0_GAT_CTRL2			0x05
 88
 89/* Index (NID:0Ch) */
 90#define RT721_HP_AMP_2CH_CAL1			0x05
 91#define RT721_HP_AMP_2CH_CAL4			0x08
 92#define RT721_HP_AMP_2CH_CAL18			0x1b
 93
 94/* Index (NID:0dh) */
 95#define RT721_CLASD_AMP_2CH_CAL			0x14
 96
 97/* Index (NID:0fh) */
 98#define RT721_BST_4CH_TOP_GATING_CTRL1		0x05
 99
100/* Index (NID:20h) */
101#define RT721_JD_PRODUCT_NUM			0x00
102#define RT721_ANALOG_BIAS_CTL3			0x04
103#define RT721_JD_CTRL1				0x09
104#define RT721_LDO2_3_CTL1			0x0e
105#define RT721_GPIO_PAD_CTRL5			0x13
106#define RT721_LDO1_CTL				0x1a
107#define RT721_HP_JD_CTRL			0x24
108#define RT721_VD_HIDDEN_CTRL			0x26
109#define RT721_CLSD_CTRL6			0x3c
110#define RT721_COMBO_JACK_AUTO_CTL1		0x45
111#define RT721_COMBO_JACK_AUTO_CTL2		0x46
112#define RT721_COMBO_JACK_AUTO_CTL3		0x47
113#define RT721_DIGITAL_MISC_CTRL4		0x4a
114#define RT721_VREFO_GAT				0x63
115#define RT721_FSM_CTL				0x67
116#define RT721_SDCA_INTR_REC			0x82
117#define RT721_SW_CONFIG1			0x8a
118#define RT721_SW_CONFIG2			0x8b
119
120/* Index (NID:40h) */
121#define RT721_RC_CALIB_CTRL0			0x00
122
123/* Index (NID:58h) */
124#define RT721_DAC_DC_CALI_CTL1			0x01
125#define RT721_DAC_DC_CALI_CTL2			0x02
126#define RT721_DAC_DC_CALI_CTL3			0x03
127
128/* Index (NID:5fh) */
129#define RT721_MISC_POWER_CTL0			0x00
130#define RT721_MISC_POWER_CTL31			0x31
131#define RT721_UAJ_TOP_TCON13			0x44
132#define RT721_UAJ_TOP_TCON14			0x45
133#define RT721_UAJ_TOP_TCON17			0x48
134
135/* Index (NID:61h) */
136#define RT721_HDA_LEGACY_MUX_CTL0		0x00
137#define RT721_HDA_LEGACY_UAJ_CTL		0x02
138#define RT721_HDA_LEGACY_CTL1			0x05
139#define RT721_HDA_LEGACY_RESET_CTL		0x06
140#define RT721_MISC_CTL				0x07
141#define RT721_XU_REL_CTRL			0x0c
142#define RT721_GE_REL_CTRL1			0x0d
143#define RT721_HDA_LEGACY_GPIO_WAKE_EN_CTL	0x0e
144#define RT721_GE_SDCA_RST_CTRL			0x10
145#define RT721_INT_RST_EN_CTRL			0x11
146#define RT721_XU_EVENT_EN			0x13
147#define RT721_INLINE_CTL2			0x17
148#define RT721_UMP_HID_CTRL1			0x18
149#define RT721_UMP_HID_CTRL2			0x19
150#define RT721_UMP_HID_CTRL3			0x1a
151#define RT721_UMP_HID_CTRL4			0x1b
152#define RT721_UMP_HID_CTRL5			0x1c
153#define RT721_FUNC_FLOAT_CTL0			0x22
154#define RT721_FUNC_FLOAT_CTL1			0x23
155#define RT721_FUNC_FLOAT_CTL2			0x24
156#define RT721_FUNC_FLOAT_CTL3			0x25
157#define RT721_ENT_FLOAT_CTL0			0x29
158#define RT721_ENT_FLOAT_CTL1			0x2c
159#define RT721_ENT_FLOAT_CTL2			0x2d
160#define RT721_ENT_FLOAT_CTL3			0x2e
161#define RT721_ENT_FLOAT_CTL4			0x2f
162#define RT721_CH_FLOAT_CTL1			0x45
163#define RT721_CH_FLOAT_CTL2			0x46
164#define RT721_ENT_FLOAT_CTL5			0x53
165#define RT721_ENT_FLOAT_CTL6			0x54
166#define RT721_ENT_FLOAT_CTL7			0x55
167#define RT721_ENT_FLOAT_CTL8			0x57
168#define RT721_ENT_FLOAT_CTL9			0x5a
169#define RT721_ENT_FLOAT_CTL10			0x5b
170#define RT721_CH_FLOAT_CTL3			0x6a
171#define RT721_CH_FLOAT_CTL4			0x6d
172#define RT721_CH_FLOAT_CTL5			0x70
173#define RT721_CH_FLOAT_CTL6			0x92
174
175/* Parameter & Verb control 01 (0x26)(NID:20h) */
176#define RT721_HIDDEN_REG_SW_RESET (0x1 << 14)
177
178/* Buffer address for HID */
179#define RT721_BUF_ADDR_HID1			0x44030000
180#define RT721_BUF_ADDR_HID2			0x44030020
181
182/* RT721 SDCA Control - function number */
183#define FUNC_NUM_JACK_CODEC			0x01
184#define FUNC_NUM_MIC_ARRAY			0x02
185#define FUNC_NUM_HID				0x03
186#define FUNC_NUM_AMP				0x04
187
188/* RT721 SDCA entity */
189#define RT721_SDCA_ENT_HID01			0x01
190#define RT721_SDCA_ENT_XUV			0x03
191#define RT721_SDCA_ENT_GE49			0x49
192#define RT721_SDCA_ENT_USER_FU05		0x05
193#define RT721_SDCA_ENT_USER_FU06		0x06
194#define RT721_SDCA_ENT_USER_FU0F		0x0f
195#define RT721_SDCA_ENT_USER_FU10		0x19
196#define RT721_SDCA_ENT_USER_FU1E		0x1e
197#define RT721_SDCA_ENT_FU15			0x15
198#define RT721_SDCA_ENT_PDE23			0x23
199#define RT721_SDCA_ENT_PDE40			0x40
200#define RT721_SDCA_ENT_PDE41			0x41
201#define RT721_SDCA_ENT_PDE11			0x11
202#define RT721_SDCA_ENT_PDE12			0x12
203#define RT721_SDCA_ENT_PDE2A			0x2a
204#define RT721_SDCA_ENT_CS01			0x01
205#define RT721_SDCA_ENT_CS11			0x11
206#define RT721_SDCA_ENT_CS1F			0x1f
207#define RT721_SDCA_ENT_CS1C			0x1c
208#define RT721_SDCA_ENT_CS31			0x31
209#define RT721_SDCA_ENT_OT23			0x42
210#define RT721_SDCA_ENT_IT26			0x26
211#define RT721_SDCA_ENT_IT09			0x09
212#define RT721_SDCA_ENT_PLATFORM_FU15		0x15
213#define RT721_SDCA_ENT_PLATFORM_FU44		0x44
214#define RT721_SDCA_ENT_XU03			0x03
215#define RT721_SDCA_ENT_XU0D			0x0d
216#define RT721_SDCA_ENT_FU55			0x55
217
218/* RT721 SDCA control */
219#define RT721_SDCA_CTL_SAMPLE_FREQ_INDEX		0x10
220#define RT721_SDCA_CTL_FU_MUTE				0x01
221#define RT721_SDCA_CTL_FU_VOLUME			0x02
222#define RT721_SDCA_CTL_HIDTX_CURRENT_OWNER		0x10
223#define RT721_SDCA_CTL_HIDTX_SET_OWNER_TO_DEVICE	0x11
224#define RT721_SDCA_CTL_HIDTX_MESSAGE_OFFSET		0x12
225#define RT721_SDCA_CTL_HIDTX_MESSAGE_LENGTH		0x13
226#define RT721_SDCA_CTL_SELECTED_MODE			0x01
227#define RT721_SDCA_CTL_DETECTED_MODE			0x02
228#define RT721_SDCA_CTL_REQ_POWER_STATE			0x01
229#define RT721_SDCA_CTL_VENDOR_DEF			0x30
230#define RT721_SDCA_CTL_XUV				0x34
231#define RT721_SDCA_CTL_FU_CH_GAIN			0x0b
232
233/* RT721 SDCA channel */
234#define CH_L	0x01
235#define CH_R	0x02
236#define CH_01	0x01
237#define CH_02	0x02
238#define CH_03	0x03
239#define CH_04	0x04
240#define CH_08	0x08
241#define CH_09	0x09
242#define CH_0A	0x0a
243
244/* sample frequency index */
245#define RT721_SDCA_RATE_8000HZ		0x01
246#define RT721_SDCA_RATE_11025HZ		0x02
247#define RT721_SDCA_RATE_12000HZ		0x03
248#define RT721_SDCA_RATE_16000HZ		0x04
249#define RT721_SDCA_RATE_22050HZ		0x05
250#define RT721_SDCA_RATE_24000HZ		0x06
251#define RT721_SDCA_RATE_32000HZ		0x07
252#define RT721_SDCA_RATE_44100HZ		0x08
253#define RT721_SDCA_RATE_48000HZ		0x09
254#define RT721_SDCA_RATE_88200HZ		0x0a
255#define RT721_SDCA_RATE_96000HZ		0x0b
256#define RT721_SDCA_RATE_176400HZ	0x0c
257#define RT721_SDCA_RATE_192000HZ	0x0d
258#define RT721_SDCA_RATE_384000HZ	0x0e
259#define RT721_SDCA_RATE_768000HZ	0x0f
260
261/* RT721 HID ID */
262#define RT721_SDCA_HID_ID		0x11
263
264enum {
265	RT721_AIF1, /* For headset mic and headphone */
266	RT721_AIF2, /* For speaker */
267	RT721_AIF3, /* For dmic */
268	RT721_AIFS,
269};
270
271int rt721_sdca_io_init(struct device *dev, struct sdw_slave *slave);
272int rt721_sdca_init(struct device *dev, struct regmap *regmap,
273			struct regmap *mbq_regmap, struct sdw_slave *slave);
274#endif /* __RT721_H__ */
~/ Read-only file preview.