1 // SPDX-License-Identifier: GPL-2.0-only
2 /*
3  * soc-apci-intel-rpl-match.c - tables and support for RPL ACPI enumeration.
4  *
5  * Copyright (c) 2022 Intel Corporation.
6  */
7 
8 #include <sound/soc-acpi.h>
9 #include <sound/soc-acpi-intel-match.h>
10 
11 static const struct snd_soc_acpi_endpoint single_endpoint = {
12 	.num = 0,
13 	.aggregated = 0,
14 	.group_position = 0,
15 	.group_id = 0,
16 };
17 
18 static const struct snd_soc_acpi_endpoint spk_l_endpoint = {
19 	.num = 0,
20 	.aggregated = 1,
21 	.group_position = 0,
22 	.group_id = 1,
23 };
24 
25 static const struct snd_soc_acpi_endpoint spk_r_endpoint = {
26 	.num = 0,
27 	.aggregated = 1,
28 	.group_position = 1,
29 	.group_id = 1,
30 };
31 
32 static const struct snd_soc_acpi_adr_device rt711_0_adr[] = {
33 	{
34 		.adr = 0x000020025D071100ull,
35 		.num_endpoints = 1,
36 		.endpoints = &single_endpoint,
37 		.name_prefix = "rt711"
38 	}
39 };
40 
41 static const struct snd_soc_acpi_link_adr rpl_rvp[] = {
42 	{
43 		.mask = BIT(0),
44 		.num_adr = ARRAY_SIZE(rt711_0_adr),
45 		.adr_d = rt711_0_adr,
46 	},
47 	{}
48 };
49 
50 static const struct snd_soc_acpi_adr_device rt711_sdca_0_adr[] = {
51 	{
52 		.adr = 0x000030025D071101ull,
53 		.num_endpoints = 1,
54 		.endpoints = &single_endpoint,
55 		.name_prefix = "rt711"
56 	}
57 };
58 
59 static const struct snd_soc_acpi_adr_device rt1316_1_group1_adr[] = {
60 	{
61 		.adr = 0x000131025D131601ull, /* unique ID is set for some reason */
62 		.num_endpoints = 1,
63 		.endpoints = &spk_l_endpoint,
64 		.name_prefix = "rt1316-1"
65 	}
66 };
67 
68 static const struct snd_soc_acpi_adr_device rt1316_2_group1_adr[] = {
69 	{
70 		.adr = 0x000230025D131601ull,
71 		.num_endpoints = 1,
72 		.endpoints = &spk_r_endpoint,
73 		.name_prefix = "rt1316-2"
74 	}
75 };
76 
77 static const struct snd_soc_acpi_adr_device rt1316_3_group1_adr[] = {
78 	{
79 		.adr = 0x000330025D131601ull,
80 		.num_endpoints = 1,
81 		.endpoints = &spk_r_endpoint,
82 		.name_prefix = "rt1316-2"
83 	}
84 };
85 
86 static const struct snd_soc_acpi_adr_device rt714_0_adr[] = {
87 	{
88 		.adr = 0x000030025D071401ull,
89 		.num_endpoints = 1,
90 		.endpoints = &single_endpoint,
91 		.name_prefix = "rt714"
92 	}
93 };
94 
95 static const struct snd_soc_acpi_adr_device rt714_2_adr[] = {
96 	{
97 		.adr = 0x000230025D071401ull,
98 		.num_endpoints = 1,
99 		.endpoints = &single_endpoint,
100 		.name_prefix = "rt714"
101 	}
102 };
103 
104 static const struct snd_soc_acpi_link_adr rpl_sdca_3_in_1[] = {
105 	{
106 		.mask = BIT(0),
107 		.num_adr = ARRAY_SIZE(rt711_sdca_0_adr),
108 		.adr_d = rt711_sdca_0_adr,
109 	},
110 	{
111 		.mask = BIT(1),
112 		.num_adr = ARRAY_SIZE(rt1316_1_group1_adr),
113 		.adr_d = rt1316_1_group1_adr,
114 	},
115 	{
116 		.mask = BIT(2),
117 		.num_adr = ARRAY_SIZE(rt714_2_adr),
118 		.adr_d = rt714_2_adr,
119 	},
120 	{
121 		.mask = BIT(3),
122 		.num_adr = ARRAY_SIZE(rt1316_3_group1_adr),
123 		.adr_d = rt1316_3_group1_adr,
124 	},
125 	{}
126 };
127 
128 static const struct snd_soc_acpi_link_adr rpl_sdw_rt1316_link12_rt714_link0[] = {
129 	{
130 		.mask = BIT(1),
131 		.num_adr = ARRAY_SIZE(rt1316_1_group1_adr),
132 		.adr_d = rt1316_1_group1_adr,
133 	},
134 	{
135 		.mask = BIT(2),
136 		.num_adr = ARRAY_SIZE(rt1316_2_group1_adr),
137 		.adr_d = rt1316_2_group1_adr,
138 	},
139 	{
140 		.mask = BIT(0),
141 		.num_adr = ARRAY_SIZE(rt714_0_adr),
142 		.adr_d = rt714_0_adr,
143 	},
144 	{}
145 };
146 
147 struct snd_soc_acpi_mach snd_soc_acpi_intel_rpl_machines[] = {
148 	{},
149 };
150 EXPORT_SYMBOL_GPL(snd_soc_acpi_intel_rpl_machines);
151 
152 /* this table is used when there is no I2S codec present */
153 struct snd_soc_acpi_mach snd_soc_acpi_intel_rpl_sdw_machines[] = {
154 	{
155 		.link_mask = 0xF, /* 4 active links required */
156 		.links = rpl_sdca_3_in_1,
157 		.drv_name = "sof_sdw",
158 		.sof_tplg_filename = "sof-rpl-rt711-l0-rt1316-l13-rt714-l2.tplg",
159 	},
160 	{
161 		.link_mask = 0x7, /* rt714 on link0 & two rt1316s on link1 and link2 */
162 		.links = rpl_sdw_rt1316_link12_rt714_link0,
163 		.drv_name = "sof_sdw",
164 		.sof_tplg_filename = "sof-rpl-rt1316-l12-rt714-l0.tplg",
165 	},
166 	{
167 		.link_mask = 0x1, /* link0 required */
168 		.links = rpl_rvp,
169 		.drv_name = "sof_sdw",
170 		.sof_tplg_filename = "sof-rpl-rt711.tplg",
171 	},
172 	{},
173 };
174 EXPORT_SYMBOL_GPL(snd_soc_acpi_intel_rpl_sdw_machines);
175