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_3_group1_adr[] = {
69 	{
70 		.adr = 0x000330025D131601ull,
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 rt714_2_adr[] = {
78 	{
79 		.adr = 0x000230025D071401ull,
80 		.num_endpoints = 1,
81 		.endpoints = &single_endpoint,
82 		.name_prefix = "rt714"
83 	}
84 };
85 
86 static const struct snd_soc_acpi_link_adr rpl_sdca_3_in_1[] = {
87 	{
88 		.mask = BIT(0),
89 		.num_adr = ARRAY_SIZE(rt711_sdca_0_adr),
90 		.adr_d = rt711_sdca_0_adr,
91 	},
92 	{
93 		.mask = BIT(1),
94 		.num_adr = ARRAY_SIZE(rt1316_1_group1_adr),
95 		.adr_d = rt1316_1_group1_adr,
96 	},
97 	{
98 		.mask = BIT(2),
99 		.num_adr = ARRAY_SIZE(rt714_2_adr),
100 		.adr_d = rt714_2_adr,
101 	},
102 	{
103 		.mask = BIT(3),
104 		.num_adr = ARRAY_SIZE(rt1316_3_group1_adr),
105 		.adr_d = rt1316_3_group1_adr,
106 	},
107 	{}
108 };
109 
110 struct snd_soc_acpi_mach snd_soc_acpi_intel_rpl_machines[] = {
111 	{},
112 };
113 EXPORT_SYMBOL_GPL(snd_soc_acpi_intel_rpl_machines);
114 
115 /* this table is used when there is no I2S codec present */
116 struct snd_soc_acpi_mach snd_soc_acpi_intel_rpl_sdw_machines[] = {
117 	{
118 		.link_mask = 0xF, /* 4 active links required */
119 		.links = rpl_sdca_3_in_1,
120 		.drv_name = "sof_sdw",
121 		.sof_tplg_filename = "sof-rpl-rt711-l0-rt1316-l13-rt714-l2.tplg",
122 	},
123 	{
124 		.link_mask = 0x1, /* link0 required */
125 		.links = rpl_rvp,
126 		.drv_name = "sof_sdw",
127 		.sof_tplg_filename = "sof-rpl-rt711.tplg",
128 	},
129 	{},
130 };
131 EXPORT_SYMBOL_GPL(snd_soc_acpi_intel_rpl_sdw_machines);
132