1 // SPDX-License-Identifier: GPL-2.0-only
2 /*
3  * soc-acpi-intel-cht-match.c - tables and support for CHT ACPI enumeration.
4  *
5  * Copyright (c) 2017, Intel Corporation.
6  */
7 
8 #include <linux/dmi.h>
9 #include <sound/soc-acpi.h>
10 #include <sound/soc-acpi-intel-match.h>
11 
12 static unsigned long cht_machine_id;
13 
14 #define CHT_SURFACE_MACH 1
15 
16 static int cht_surface_quirk_cb(const struct dmi_system_id *id)
17 {
18 	cht_machine_id = CHT_SURFACE_MACH;
19 	return 1;
20 }
21 
22 static const struct dmi_system_id cht_table[] = {
23 	{
24 		.callback = cht_surface_quirk_cb,
25 		.matches = {
26 			DMI_MATCH(DMI_SYS_VENDOR, "Microsoft Corporation"),
27 			DMI_MATCH(DMI_PRODUCT_NAME, "Surface 3"),
28 		},
29 	},
30 	{ }
31 };
32 
33 static struct snd_soc_acpi_mach cht_surface_mach = {
34 	.id = "10EC5640",
35 	.drv_name = "cht-bsw-rt5645",
36 	.fw_filename = "intel/fw_sst_22a8.bin",
37 	.board = "cht-bsw",
38 	.sof_fw_filename = "sof-cht.ri",
39 	.sof_tplg_filename = "sof-cht-rt5645.tplg",
40 };
41 
42 static struct snd_soc_acpi_mach *cht_quirk(void *arg)
43 {
44 	struct snd_soc_acpi_mach *mach = arg;
45 
46 	dmi_check_system(cht_table);
47 
48 	if (cht_machine_id == CHT_SURFACE_MACH)
49 		return &cht_surface_mach;
50 	else
51 		return mach;
52 }
53 
54 static const struct snd_soc_acpi_codecs rt5640_comp_ids = {
55 	.num_codecs = 2,
56 	.codecs = { "10EC5640", "10EC3276" },
57 };
58 
59 static const struct snd_soc_acpi_codecs rt5670_comp_ids = {
60 	.num_codecs = 2,
61 	.codecs = { "10EC5670", "10EC5672" },
62 };
63 
64 static const struct snd_soc_acpi_codecs rt5645_comp_ids = {
65 	.num_codecs = 3,
66 	.codecs = { "10EC5645", "10EC5650", "10EC3270" },
67 };
68 
69 static const struct snd_soc_acpi_codecs da7213_comp_ids = {
70 	.num_codecs = 2,
71 	.codecs = { "DGLS7212", "DGLS7213"},
72 
73 };
74 
75 /* Cherryview-based platforms: CherryTrail and Braswell */
76 struct snd_soc_acpi_mach  snd_soc_acpi_intel_cherrytrail_machines[] = {
77 	{
78 		.comp_ids = &rt5670_comp_ids,
79 		.drv_name = "cht-bsw-rt5672",
80 		.fw_filename = "intel/fw_sst_22a8.bin",
81 		.board = "cht-bsw",
82 		.sof_fw_filename = "sof-cht.ri",
83 		.sof_tplg_filename = "sof-cht-rt5670.tplg",
84 	},
85 	{
86 		.comp_ids = &rt5645_comp_ids,
87 		.drv_name = "cht-bsw-rt5645",
88 		.fw_filename = "intel/fw_sst_22a8.bin",
89 		.board = "cht-bsw",
90 		.sof_fw_filename = "sof-cht.ri",
91 		.sof_tplg_filename = "sof-cht-rt5645.tplg",
92 	},
93 	{
94 		.id = "193C9890",
95 		.drv_name = "cht-bsw-max98090",
96 		.fw_filename = "intel/fw_sst_22a8.bin",
97 		.board = "cht-bsw",
98 		.sof_fw_filename = "sof-cht.ri",
99 		.sof_tplg_filename = "sof-cht-max98090.tplg",
100 	},
101 	{
102 		.id = "10508824",
103 		.drv_name = "cht-bsw-nau8824",
104 		.fw_filename = "intel/fw_sst_22a8.bin",
105 		.board = "cht-bsw",
106 		.sof_fw_filename = "sof-cht.ri",
107 		.sof_tplg_filename = "sof-cht-nau8824.tplg",
108 	},
109 	{
110 		.comp_ids = &da7213_comp_ids,
111 		.drv_name = "bytcht_da7213",
112 		.fw_filename = "intel/fw_sst_22a8.bin",
113 		.board = "bytcht_da7213",
114 		.sof_fw_filename = "sof-cht.ri",
115 		.sof_tplg_filename = "sof-cht-da7213.tplg",
116 	},
117 	{
118 		.id = "ESSX8316",
119 		.drv_name = "bytcht_es8316",
120 		.fw_filename = "intel/fw_sst_22a8.bin",
121 		.board = "bytcht_es8316",
122 		.sof_fw_filename = "sof-cht.ri",
123 		.sof_tplg_filename = "sof-cht-es8316.tplg",
124 	},
125 	/* some CHT-T platforms rely on RT5640, use Baytrail machine driver */
126 	{
127 		.comp_ids = &rt5640_comp_ids,
128 		.drv_name = "bytcr_rt5640",
129 		.fw_filename = "intel/fw_sst_22a8.bin",
130 		.board = "bytcr_rt5640",
131 		.machine_quirk = cht_quirk,
132 		.sof_fw_filename = "sof-cht.ri",
133 		.sof_tplg_filename = "sof-cht-rt5640.tplg",
134 	},
135 	{
136 		.id = "10EC5682",
137 		.drv_name = "sof_rt5682",
138 		.sof_fw_filename = "sof-cht.ri",
139 		.sof_tplg_filename = "sof-cht-rt5682.tplg",
140 	},
141 	/* some CHT-T platforms rely on RT5651, use Baytrail machine driver */
142 	{
143 		.id = "10EC5651",
144 		.drv_name = "bytcr_rt5651",
145 		.fw_filename = "intel/fw_sst_22a8.bin",
146 		.board = "bytcr_rt5651",
147 		.sof_fw_filename = "sof-cht.ri",
148 		.sof_tplg_filename = "sof-cht-rt5651.tplg",
149 	},
150 	{
151 		.id = "14F10720",
152 		.drv_name = "bytcht_cx2072x",
153 		.fw_filename = "intel/fw_sst_22a8.bin",
154 		.board = "bytcht_cx2072x",
155 		.sof_fw_filename = "sof-cht.ri",
156 		.sof_tplg_filename = "sof-cht-cx2072x.tplg",
157 	},
158 	{
159 		.id = "104C5122",
160 		.drv_name = "sof_pcm512x",
161 		.sof_fw_filename = "sof-cht.ri",
162 		.sof_tplg_filename = "sof-cht-src-50khz-pcm512x.tplg",
163 	},
164 
165 #if IS_ENABLED(CONFIG_SND_SOC_INTEL_BYT_CHT_NOCODEC_MACH)
166 	/*
167 	 * This is always last in the table so that it is selected only when
168 	 * enabled explicitly and there is no codec-related information in SSDT
169 	 */
170 	{
171 		.id = "808622A8",
172 		.drv_name = "bytcht_nocodec",
173 		.fw_filename = "intel/fw_sst_22a8.bin",
174 		.board = "bytcht_nocodec",
175 	},
176 #endif
177 	{},
178 };
179 EXPORT_SYMBOL_GPL(snd_soc_acpi_intel_cherrytrail_machines);
180