1 // SPDX-License-Identifier: GPL-2.0-only
2 /*
3  * soc-acpi-intel-mtl-match.c - tables and support for MTL ACPI enumeration.
4  *
5  * Copyright (c) 2022, Intel Corporation.
6  *
7  */
8 
9 #include <sound/soc-acpi.h>
10 #include <sound/soc-acpi-intel-match.h>
11 #include "soc-acpi-intel-sdw-mockup-match.h"
12 
13 static const struct snd_soc_acpi_codecs mtl_max98357a_amp = {
14 	.num_codecs = 1,
15 	.codecs = {"MX98357A"}
16 };
17 
18 static const struct snd_soc_acpi_codecs mtl_max98360a_amp = {
19 	.num_codecs = 1,
20 	.codecs = {"MX98360A"}
21 };
22 
23 static const struct snd_soc_acpi_codecs mtl_rt5682_rt5682s_hp = {
24 	.num_codecs = 2,
25 	.codecs = {"10EC5682", "RTL5682"},
26 };
27 
28 struct snd_soc_acpi_mach snd_soc_acpi_intel_mtl_machines[] = {
29 	{
30 		.comp_ids = &mtl_rt5682_rt5682s_hp,
31 		.drv_name = "mtl_mx98357_rt5682",
32 		.machine_quirk = snd_soc_acpi_codec_list,
33 		.quirk_data = &mtl_max98357a_amp,
34 		.sof_tplg_filename = "sof-mtl-max98357a-rt5682.tplg",
35 	},
36 	{
37 		.comp_ids = &mtl_rt5682_rt5682s_hp,
38 		.drv_name = "mtl_mx98360_rt5682",
39 		.machine_quirk = snd_soc_acpi_codec_list,
40 		.quirk_data = &mtl_max98360a_amp,
41 		.sof_tplg_filename = "sof-mtl-max98360a-rt5682.tplg",
42 	},
43 	{},
44 };
45 EXPORT_SYMBOL_GPL(snd_soc_acpi_intel_mtl_machines);
46 
47 static const struct snd_soc_acpi_endpoint single_endpoint = {
48 	.num = 0,
49 	.aggregated = 0,
50 	.group_position = 0,
51 	.group_id = 0,
52 };
53 
54 static const struct snd_soc_acpi_endpoint spk_l_endpoint = {
55 	.num = 0,
56 	.aggregated = 1,
57 	.group_position = 0,
58 	.group_id = 1,
59 };
60 
61 static const struct snd_soc_acpi_endpoint spk_r_endpoint = {
62 	.num = 0,
63 	.aggregated = 1,
64 	.group_position = 1,
65 	.group_id = 1,
66 };
67 
68 static const struct snd_soc_acpi_adr_device rt711_sdca_0_adr[] = {
69 	{
70 		.adr = 0x000030025D071101ull,
71 		.num_endpoints = 1,
72 		.endpoints = &single_endpoint,
73 		.name_prefix = "rt711"
74 	}
75 };
76 
77 static const struct snd_soc_acpi_adr_device mx8373_0_adr[] = {
78 	{
79 		.adr = 0x000023019F837300ull,
80 		.num_endpoints = 1,
81 		.endpoints = &spk_l_endpoint,
82 		.name_prefix = "Left"
83 	},
84 	{
85 		.adr = 0x000027019F837300ull,
86 		.num_endpoints = 1,
87 		.endpoints = &spk_r_endpoint,
88 		.name_prefix = "Right"
89 	}
90 };
91 
92 static const struct snd_soc_acpi_adr_device rt5682_2_adr[] = {
93 	{
94 		.adr = 0x000221025D568200ull,
95 		.num_endpoints = 1,
96 		.endpoints = &single_endpoint,
97 		.name_prefix = "rt5682"
98 	}
99 };
100 
101 static const struct snd_soc_acpi_adr_device rt1316_2_group1_adr[] = {
102 	{
103 		.adr = 0x000230025D131601ull,
104 		.num_endpoints = 1,
105 		.endpoints = &spk_l_endpoint,
106 		.name_prefix = "rt1316-1"
107 	}
108 };
109 
110 static const struct snd_soc_acpi_adr_device rt1316_3_group1_adr[] = {
111 	{
112 		.adr = 0x000331025D131601ull,
113 		.num_endpoints = 1,
114 		.endpoints = &spk_r_endpoint,
115 		.name_prefix = "rt1316-2"
116 	}
117 };
118 
119 static const struct snd_soc_acpi_adr_device rt714_1_adr[] = {
120 	{
121 		.adr = 0x000130025D071401ull,
122 		.num_endpoints = 1,
123 		.endpoints = &single_endpoint,
124 		.name_prefix = "rt714"
125 	}
126 };
127 
128 static const struct snd_soc_acpi_link_adr rt5682_link2_max98373_link0[] = {
129 	/* Expected order: jack -> amp */
130 	{
131 		.mask = BIT(2),
132 		.num_adr = ARRAY_SIZE(rt5682_2_adr),
133 		.adr_d = rt5682_2_adr,
134 	},
135 	{
136 		.mask = BIT(0),
137 		.num_adr = ARRAY_SIZE(mx8373_0_adr),
138 		.adr_d = mx8373_0_adr,
139 	},
140 	{}
141 };
142 
143 static const struct snd_soc_acpi_link_adr mtl_rvp[] = {
144 	{
145 		.mask = BIT(0),
146 		.num_adr = ARRAY_SIZE(rt711_sdca_0_adr),
147 		.adr_d = rt711_sdca_0_adr,
148 	},
149 	{}
150 };
151 
152 static const struct snd_soc_acpi_link_adr mtl_3_in_1_sdca[] = {
153 	{
154 		.mask = BIT(0),
155 		.num_adr = ARRAY_SIZE(rt711_sdca_0_adr),
156 		.adr_d = rt711_sdca_0_adr,
157 	},
158 	{
159 		.mask = BIT(2),
160 		.num_adr = ARRAY_SIZE(rt1316_2_group1_adr),
161 		.adr_d = rt1316_2_group1_adr,
162 	},
163 	{
164 		.mask = BIT(3),
165 		.num_adr = ARRAY_SIZE(rt1316_3_group1_adr),
166 		.adr_d = rt1316_3_group1_adr,
167 	},
168 	{
169 		.mask = BIT(1),
170 		.num_adr = ARRAY_SIZE(rt714_1_adr),
171 		.adr_d = rt714_1_adr,
172 	},
173 	{}
174 };
175 
176 /* this table is used when there is no I2S codec present */
177 struct snd_soc_acpi_mach snd_soc_acpi_intel_mtl_sdw_machines[] = {
178 	/* mockup tests need to be first */
179 	{
180 		.link_mask = GENMASK(3, 0),
181 		.links = sdw_mockup_headset_2amps_mic,
182 		.drv_name = "sof_sdw",
183 		.sof_tplg_filename = "sof-mtl-rt711-rt1308-rt715.tplg",
184 	},
185 	{
186 		.link_mask = BIT(0) | BIT(1) | BIT(3),
187 		.links = sdw_mockup_headset_1amp_mic,
188 		.drv_name = "sof_sdw",
189 		.sof_tplg_filename = "sof-mtl-rt711-rt1308-mono-rt715.tplg",
190 	},
191 	{
192 		.link_mask = GENMASK(2, 0),
193 		.links = sdw_mockup_mic_headset_1amp,
194 		.drv_name = "sof_sdw",
195 		.sof_tplg_filename = "sof-mtl-rt715-rt711-rt1308-mono.tplg",
196 	},
197 	{
198 		.link_mask = GENMASK(3, 0),
199 		.links = mtl_3_in_1_sdca,
200 		.drv_name = "sof_sdw",
201 		.sof_tplg_filename = "sof-mtl-rt711-l0-rt1316-l23-rt714-l1.tplg",
202 	},
203 	{
204 		.link_mask = BIT(0),
205 		.links = mtl_rvp,
206 		.drv_name = "sof_sdw",
207 		.sof_tplg_filename = "sof-mtl-rt711.tplg",
208 	},
209 	{
210 		.link_mask = BIT(0) | BIT(2),
211 		.links = rt5682_link2_max98373_link0,
212 		.drv_name = "sof_sdw",
213 		.sof_tplg_filename = "sof-mtl-sdw-rt5682-l2-max98373-l0.tplg",
214 	},
215 	{},
216 };
217 EXPORT_SYMBOL_GPL(snd_soc_acpi_intel_mtl_sdw_machines);
218