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_rt5682_rt5682s_hp = {
19 	.num_codecs = 2,
20 	.codecs = {"10EC5682", "RTL5682"},
21 };
22 
23 struct snd_soc_acpi_mach snd_soc_acpi_intel_mtl_machines[] = {
24 	{
25 		.comp_ids = &mtl_rt5682_rt5682s_hp,
26 		.drv_name = "mtl_mx98357_rt5682",
27 		.machine_quirk = snd_soc_acpi_codec_list,
28 		.quirk_data = &mtl_max98357a_amp,
29 		.sof_tplg_filename = "sof-mtl-max98357a-rt5682.tplg",
30 	},
31 	{},
32 };
33 EXPORT_SYMBOL_GPL(snd_soc_acpi_intel_mtl_machines);
34 
35 static const struct snd_soc_acpi_endpoint single_endpoint = {
36 	.num = 0,
37 	.aggregated = 0,
38 	.group_position = 0,
39 	.group_id = 0,
40 };
41 
42 static const struct snd_soc_acpi_endpoint spk_l_endpoint = {
43 	.num = 0,
44 	.aggregated = 1,
45 	.group_position = 0,
46 	.group_id = 1,
47 };
48 
49 static const struct snd_soc_acpi_endpoint spk_r_endpoint = {
50 	.num = 0,
51 	.aggregated = 1,
52 	.group_position = 1,
53 	.group_id = 1,
54 };
55 
56 static const struct snd_soc_acpi_adr_device rt711_sdca_0_adr[] = {
57 	{
58 		.adr = 0x000030025D071101ull,
59 		.num_endpoints = 1,
60 		.endpoints = &single_endpoint,
61 		.name_prefix = "rt711"
62 	}
63 };
64 
65 static const struct snd_soc_acpi_adr_device mx8373_0_adr[] = {
66 	{
67 		.adr = 0x000023019F837300ull,
68 		.num_endpoints = 1,
69 		.endpoints = &spk_l_endpoint,
70 		.name_prefix = "Left"
71 	},
72 	{
73 		.adr = 0x000027019F837300ull,
74 		.num_endpoints = 1,
75 		.endpoints = &spk_r_endpoint,
76 		.name_prefix = "Right"
77 	}
78 };
79 
80 static const struct snd_soc_acpi_adr_device rt5682_2_adr[] = {
81 	{
82 		.adr = 0x000221025D568200ull,
83 		.num_endpoints = 1,
84 		.endpoints = &single_endpoint,
85 		.name_prefix = "rt5682"
86 	}
87 };
88 
89 static const struct snd_soc_acpi_link_adr rt5682_link2_max98373_link0[] = {
90 	/* Expected order: jack -> amp */
91 	{
92 		.mask = BIT(2),
93 		.num_adr = ARRAY_SIZE(rt5682_2_adr),
94 		.adr_d = rt5682_2_adr,
95 	},
96 	{
97 		.mask = BIT(0),
98 		.num_adr = ARRAY_SIZE(mx8373_0_adr),
99 		.adr_d = mx8373_0_adr,
100 	},
101 	{}
102 };
103 
104 static const struct snd_soc_acpi_link_adr mtl_rvp[] = {
105 	{
106 		.mask = BIT(0),
107 		.num_adr = ARRAY_SIZE(rt711_sdca_0_adr),
108 		.adr_d = rt711_sdca_0_adr,
109 	},
110 	{}
111 };
112 
113 /* this table is used when there is no I2S codec present */
114 struct snd_soc_acpi_mach snd_soc_acpi_intel_mtl_sdw_machines[] = {
115 	/* mockup tests need to be first */
116 	{
117 		.link_mask = GENMASK(3, 0),
118 		.links = sdw_mockup_headset_2amps_mic,
119 		.drv_name = "sof_sdw",
120 		.sof_tplg_filename = "sof-mtl-rt711-rt1308-rt715.tplg",
121 	},
122 	{
123 		.link_mask = BIT(0) | BIT(1) | BIT(3),
124 		.links = sdw_mockup_headset_1amp_mic,
125 		.drv_name = "sof_sdw",
126 		.sof_tplg_filename = "sof-mtl-rt711-rt1308-mono-rt715.tplg",
127 	},
128 	{
129 		.link_mask = GENMASK(2, 0),
130 		.links = sdw_mockup_mic_headset_1amp,
131 		.drv_name = "sof_sdw",
132 		.sof_tplg_filename = "sof-mtl-rt715-rt711-rt1308-mono.tplg",
133 	},
134 	{
135 		.link_mask = BIT(0),
136 		.links = mtl_rvp,
137 		.drv_name = "sof_sdw",
138 		.sof_tplg_filename = "sof-mtl-rt711.tplg",
139 	},
140 	{
141 		.link_mask = BIT(0) | BIT(2),
142 		.links = rt5682_link2_max98373_link0,
143 		.drv_name = "sof_sdw",
144 		.sof_tplg_filename = "sof-mtl-sdw-rt5682-l2-max98373-l0.tplg",
145 	},
146 	{},
147 };
148 EXPORT_SYMBOL_GPL(snd_soc_acpi_intel_mtl_sdw_machines);
149