111fe58c4SBard Liao // SPDX-License-Identifier: GPL-2.0-only
211fe58c4SBard Liao /*
311fe58c4SBard Liao  * soc-acpi-intel-mtl-match.c - tables and support for MTL ACPI enumeration.
411fe58c4SBard Liao  *
511fe58c4SBard Liao  * Copyright (c) 2022, Intel Corporation.
611fe58c4SBard Liao  *
711fe58c4SBard Liao  */
811fe58c4SBard Liao 
911fe58c4SBard Liao #include <sound/soc-acpi.h>
1011fe58c4SBard Liao #include <sound/soc-acpi-intel-match.h>
1111fe58c4SBard Liao #include "soc-acpi-intel-sdw-mockup-match.h"
1211fe58c4SBard Liao 
131f6645b1SYong Zhi static const struct snd_soc_acpi_codecs mtl_max98357a_amp = {
141f6645b1SYong Zhi 	.num_codecs = 1,
151f6645b1SYong Zhi 	.codecs = {"MX98357A"}
161f6645b1SYong Zhi };
171f6645b1SYong Zhi 
18*7e43b75dSDharageswari.R static const struct snd_soc_acpi_codecs mtl_max98360a_amp = {
19*7e43b75dSDharageswari.R 	.num_codecs = 1,
20*7e43b75dSDharageswari.R 	.codecs = {"MX98360A"}
21*7e43b75dSDharageswari.R };
22*7e43b75dSDharageswari.R 
231f6645b1SYong Zhi static const struct snd_soc_acpi_codecs mtl_rt5682_rt5682s_hp = {
241f6645b1SYong Zhi 	.num_codecs = 2,
251f6645b1SYong Zhi 	.codecs = {"10EC5682", "RTL5682"},
261f6645b1SYong Zhi };
271f6645b1SYong Zhi 
2811fe58c4SBard Liao struct snd_soc_acpi_mach snd_soc_acpi_intel_mtl_machines[] = {
291f6645b1SYong Zhi 	{
301f6645b1SYong Zhi 		.comp_ids = &mtl_rt5682_rt5682s_hp,
311f6645b1SYong Zhi 		.drv_name = "mtl_mx98357_rt5682",
321f6645b1SYong Zhi 		.machine_quirk = snd_soc_acpi_codec_list,
331f6645b1SYong Zhi 		.quirk_data = &mtl_max98357a_amp,
341f6645b1SYong Zhi 		.sof_tplg_filename = "sof-mtl-max98357a-rt5682.tplg",
351f6645b1SYong Zhi 	},
36*7e43b75dSDharageswari.R 	{
37*7e43b75dSDharageswari.R 		.comp_ids = &mtl_rt5682_rt5682s_hp,
38*7e43b75dSDharageswari.R 		.drv_name = "mtl_mx98360_rt5682",
39*7e43b75dSDharageswari.R 		.machine_quirk = snd_soc_acpi_codec_list,
40*7e43b75dSDharageswari.R 		.quirk_data = &mtl_max98360a_amp,
41*7e43b75dSDharageswari.R 		.sof_tplg_filename = "sof-mtl-max98360a-rt5682.tplg",
42*7e43b75dSDharageswari.R 	},
4311fe58c4SBard Liao 	{},
4411fe58c4SBard Liao };
4511fe58c4SBard Liao EXPORT_SYMBOL_GPL(snd_soc_acpi_intel_mtl_machines);
4611fe58c4SBard Liao 
4718489174SYong Zhi static const struct snd_soc_acpi_endpoint single_endpoint = {
4818489174SYong Zhi 	.num = 0,
4918489174SYong Zhi 	.aggregated = 0,
5018489174SYong Zhi 	.group_position = 0,
5118489174SYong Zhi 	.group_id = 0,
5218489174SYong Zhi };
5318489174SYong Zhi 
548dcc2059SYong Zhi static const struct snd_soc_acpi_endpoint spk_l_endpoint = {
558dcc2059SYong Zhi 	.num = 0,
568dcc2059SYong Zhi 	.aggregated = 1,
578dcc2059SYong Zhi 	.group_position = 0,
588dcc2059SYong Zhi 	.group_id = 1,
598dcc2059SYong Zhi };
608dcc2059SYong Zhi 
618dcc2059SYong Zhi static const struct snd_soc_acpi_endpoint spk_r_endpoint = {
628dcc2059SYong Zhi 	.num = 0,
638dcc2059SYong Zhi 	.aggregated = 1,
648dcc2059SYong Zhi 	.group_position = 1,
658dcc2059SYong Zhi 	.group_id = 1,
668dcc2059SYong Zhi };
678dcc2059SYong Zhi 
6818489174SYong Zhi static const struct snd_soc_acpi_adr_device rt711_sdca_0_adr[] = {
6918489174SYong Zhi 	{
7018489174SYong Zhi 		.adr = 0x000030025D071101ull,
7118489174SYong Zhi 		.num_endpoints = 1,
7218489174SYong Zhi 		.endpoints = &single_endpoint,
7318489174SYong Zhi 		.name_prefix = "rt711"
7418489174SYong Zhi 	}
7518489174SYong Zhi };
7618489174SYong Zhi 
778dcc2059SYong Zhi static const struct snd_soc_acpi_adr_device mx8373_0_adr[] = {
788dcc2059SYong Zhi 	{
798dcc2059SYong Zhi 		.adr = 0x000023019F837300ull,
808dcc2059SYong Zhi 		.num_endpoints = 1,
818dcc2059SYong Zhi 		.endpoints = &spk_l_endpoint,
828dcc2059SYong Zhi 		.name_prefix = "Left"
838dcc2059SYong Zhi 	},
848dcc2059SYong Zhi 	{
858dcc2059SYong Zhi 		.adr = 0x000027019F837300ull,
868dcc2059SYong Zhi 		.num_endpoints = 1,
878dcc2059SYong Zhi 		.endpoints = &spk_r_endpoint,
888dcc2059SYong Zhi 		.name_prefix = "Right"
898dcc2059SYong Zhi 	}
908dcc2059SYong Zhi };
918dcc2059SYong Zhi 
928dcc2059SYong Zhi static const struct snd_soc_acpi_adr_device rt5682_2_adr[] = {
938dcc2059SYong Zhi 	{
948dcc2059SYong Zhi 		.adr = 0x000221025D568200ull,
958dcc2059SYong Zhi 		.num_endpoints = 1,
968dcc2059SYong Zhi 		.endpoints = &single_endpoint,
978dcc2059SYong Zhi 		.name_prefix = "rt5682"
988dcc2059SYong Zhi 	}
998dcc2059SYong Zhi };
1008dcc2059SYong Zhi 
1018dcc2059SYong Zhi static const struct snd_soc_acpi_link_adr rt5682_link2_max98373_link0[] = {
1028dcc2059SYong Zhi 	/* Expected order: jack -> amp */
1038dcc2059SYong Zhi 	{
1048dcc2059SYong Zhi 		.mask = BIT(2),
1058dcc2059SYong Zhi 		.num_adr = ARRAY_SIZE(rt5682_2_adr),
1068dcc2059SYong Zhi 		.adr_d = rt5682_2_adr,
1078dcc2059SYong Zhi 	},
1088dcc2059SYong Zhi 	{
1098dcc2059SYong Zhi 		.mask = BIT(0),
1108dcc2059SYong Zhi 		.num_adr = ARRAY_SIZE(mx8373_0_adr),
1118dcc2059SYong Zhi 		.adr_d = mx8373_0_adr,
1128dcc2059SYong Zhi 	},
1138dcc2059SYong Zhi 	{}
1148dcc2059SYong Zhi };
1158dcc2059SYong Zhi 
11618489174SYong Zhi static const struct snd_soc_acpi_link_adr mtl_rvp[] = {
11718489174SYong Zhi 	{
11818489174SYong Zhi 		.mask = BIT(0),
11918489174SYong Zhi 		.num_adr = ARRAY_SIZE(rt711_sdca_0_adr),
12018489174SYong Zhi 		.adr_d = rt711_sdca_0_adr,
12118489174SYong Zhi 	},
12218489174SYong Zhi 	{}
12318489174SYong Zhi };
12418489174SYong Zhi 
12511fe58c4SBard Liao /* this table is used when there is no I2S codec present */
12611fe58c4SBard Liao struct snd_soc_acpi_mach snd_soc_acpi_intel_mtl_sdw_machines[] = {
12711fe58c4SBard Liao 	/* mockup tests need to be first */
12811fe58c4SBard Liao 	{
12911fe58c4SBard Liao 		.link_mask = GENMASK(3, 0),
13011fe58c4SBard Liao 		.links = sdw_mockup_headset_2amps_mic,
13111fe58c4SBard Liao 		.drv_name = "sof_sdw",
13211fe58c4SBard Liao 		.sof_tplg_filename = "sof-mtl-rt711-rt1308-rt715.tplg",
13311fe58c4SBard Liao 	},
13411fe58c4SBard Liao 	{
13511fe58c4SBard Liao 		.link_mask = BIT(0) | BIT(1) | BIT(3),
13611fe58c4SBard Liao 		.links = sdw_mockup_headset_1amp_mic,
13711fe58c4SBard Liao 		.drv_name = "sof_sdw",
13811fe58c4SBard Liao 		.sof_tplg_filename = "sof-mtl-rt711-rt1308-mono-rt715.tplg",
13911fe58c4SBard Liao 	},
14011fe58c4SBard Liao 	{
14111fe58c4SBard Liao 		.link_mask = GENMASK(2, 0),
14211fe58c4SBard Liao 		.links = sdw_mockup_mic_headset_1amp,
14311fe58c4SBard Liao 		.drv_name = "sof_sdw",
14411fe58c4SBard Liao 		.sof_tplg_filename = "sof-mtl-rt715-rt711-rt1308-mono.tplg",
14511fe58c4SBard Liao 	},
14618489174SYong Zhi 	{
14718489174SYong Zhi 		.link_mask = BIT(0),
14818489174SYong Zhi 		.links = mtl_rvp,
14918489174SYong Zhi 		.drv_name = "sof_sdw",
15018489174SYong Zhi 		.sof_tplg_filename = "sof-mtl-rt711.tplg",
15118489174SYong Zhi 	},
1528dcc2059SYong Zhi 	{
1538dcc2059SYong Zhi 		.link_mask = BIT(0) | BIT(2),
1548dcc2059SYong Zhi 		.links = rt5682_link2_max98373_link0,
1558dcc2059SYong Zhi 		.drv_name = "sof_sdw",
1568dcc2059SYong Zhi 		.sof_tplg_filename = "sof-mtl-sdw-rt5682-l2-max98373-l0.tplg",
1578dcc2059SYong Zhi 	},
15811fe58c4SBard Liao 	{},
15911fe58c4SBard Liao };
16011fe58c4SBard Liao EXPORT_SYMBOL_GPL(snd_soc_acpi_intel_mtl_sdw_machines);
161