1 /* SPDX-License-Identifier: GPL-2.0-only */
3 * rt1017-sdca-sdw.h -- RT1017 SDCA ALSA SoC audio driver header
5 * Copyright(c) 2023 Realtek Semiconductor Corp.
8 #ifndef __RT1017_SDW_H__
9 #define __RT1017_SDW_H__
11 #include <linux/regmap.h>
12 #include <linux/soundwire/sdw.h>
13 #include <linux/soundwire/sdw_type.h>
14 #include <linux/soundwire/sdw_registers.h>
15 #include <sound/soc.h>
17 /* RT1017 SDCA Control - function number */
18 #define FUNC_NUM_SMART_AMP 0x04
20 /* RT1017 SDCA entity */
21 #define RT1017_SDCA_ENT_PDE23 0x31
22 #define RT1017_SDCA_ENT_PDE22 0x33
23 #define RT1017_SDCA_ENT_CS21 0x21
24 #define RT1017_SDCA_ENT_SAPU29 0x29
25 #define RT1017_SDCA_ENT_XU22 0x22
26 #define RT1017_SDCA_ENT_FU 0x03
27 #define RT1017_SDCA_ENT_UDMPU21 0x02
29 /* RT1017 SDCA control */
30 #define RT1017_SDCA_CTL_FS_INDEX 0x10
31 #define RT1017_SDCA_CTL_REQ_POWER_STATE 0x01
32 #define RT1017_SDCA_CTL_PROT_STAT 0x11
33 #define RT1017_SDCA_CTL_BYPASS 0x01
34 #define RT1017_SDCA_CTL_FU_MUTE 0x01
35 #define RT1017_SDCA_CTL_FU_VOLUME 0x02
36 #define RT1017_SDCA_CTL_UDMPU_CLUSTER 0x10
39 #define RT1017_CLASSD_INT_1 0xd300
40 #define RT1017_PWM_TRIM_1 0xd370
43 #define RT1017_PWM_FREQ_CTL_SRC_SEL_MASK (0x3 << 2)
44 #define RT1017_PWM_FREQ_CTL_SRC_SEL_EFUSE (0x2 << 2)
45 #define RT1017_PWM_FREQ_CTL_SRC_SEL_REG (0x0 << 2)
48 RT1017_SDCA_RATE_44100HZ = 0x8,
49 RT1017_SDCA_RATE_48000HZ = 0x9,
50 RT1017_SDCA_RATE_96000HZ = 0xb,
51 RT1017_SDCA_RATE_192000HZ = 0xd,
54 struct rt1017_sdca_priv {
55 struct snd_soc_component *component;
56 struct regmap *regmap;
57 struct sdw_slave *sdw_slave;
58 struct sdw_bus_params params;
63 static const struct reg_default rt1017_sdca_reg_defaults[] = {
169 { SDW_SDCA_CTL(FUNC_NUM_SMART_AMP, RT1017_SDCA_ENT_UDMPU21,
170 RT1017_SDCA_CTL_UDMPU_CLUSTER, 0), 0x00 },
171 { SDW_SDCA_CTL(FUNC_NUM_SMART_AMP, RT1017_SDCA_ENT_FU,
172 RT1017_SDCA_CTL_FU_MUTE, 0x01), 0x01 },
173 { SDW_SDCA_CTL(FUNC_NUM_SMART_AMP, RT1017_SDCA_ENT_XU22,
174 RT1017_SDCA_CTL_BYPASS, 0), 0x01 },
175 { SDW_SDCA_CTL(FUNC_NUM_SMART_AMP, RT1017_SDCA_ENT_CS21,
176 RT1017_SDCA_CTL_FS_INDEX, 0), 0x09 },
177 { SDW_SDCA_CTL(FUNC_NUM_SMART_AMP, RT1017_SDCA_ENT_PDE23,
178 RT1017_SDCA_CTL_REQ_POWER_STATE, 0), 0x03 },
179 { SDW_SDCA_CTL(FUNC_NUM_SMART_AMP, RT1017_SDCA_ENT_PDE22,
180 RT1017_SDCA_CTL_REQ_POWER_STATE, 0), 0x03 },
183 #endif /* __RT1017_SDW_H__ */