1 /*
2  * soc-apci-intel-cht-match.c - tables and support for CHT ACPI enumeration.
3  *
4  * Copyright (c) 2017, Intel Corporation.
5  *
6  *
7  * This program is free software; you can redistribute it and/or modify it
8  * under the terms and conditions of the GNU General Public License,
9  * version 2, as published by the Free Software Foundation.
10  *
11  * This program is distributed in the hope it will be useful, but WITHOUT
12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
14  * more details.
15  */
16 
17 #include <linux/dmi.h>
18 #include <sound/soc-acpi.h>
19 #include <sound/soc-acpi-intel-match.h>
20 
21 static unsigned long cht_machine_id;
22 
23 #define CHT_SURFACE_MACH 1
24 
25 static int cht_surface_quirk_cb(const struct dmi_system_id *id)
26 {
27 	cht_machine_id = CHT_SURFACE_MACH;
28 	return 1;
29 }
30 
31 static const struct dmi_system_id cht_table[] = {
32 	{
33 		.callback = cht_surface_quirk_cb,
34 		.matches = {
35 			DMI_MATCH(DMI_SYS_VENDOR, "Microsoft Corporation"),
36 			DMI_MATCH(DMI_PRODUCT_NAME, "Surface 3"),
37 		},
38 	},
39 	{ }
40 };
41 
42 
43 static struct snd_soc_acpi_mach cht_surface_mach = {
44 	.id = "10EC5640",
45 	.drv_name = "cht-bsw-rt5645",
46 	.fw_filename = "intel/fw_sst_22a8.bin",
47 	.board = "cht-bsw",
48 };
49 
50 static struct snd_soc_acpi_mach *cht_quirk(void *arg)
51 {
52 	struct snd_soc_acpi_mach *mach = arg;
53 
54 	dmi_check_system(cht_table);
55 
56 	if (cht_machine_id == CHT_SURFACE_MACH)
57 		return &cht_surface_mach;
58 	else
59 		return mach;
60 }
61 
62 /* Cherryview-based platforms: CherryTrail and Braswell */
63 struct snd_soc_acpi_mach  snd_soc_acpi_intel_cherrytrail_machines[] = {
64 	{
65 		.id = "10EC5670",
66 		.drv_name = "cht-bsw-rt5672",
67 		.fw_filename = "intel/fw_sst_22a8.bin",
68 		.board = "cht-bsw",
69 	},
70 	{
71 		.id = "10EC5672",
72 		.drv_name = "cht-bsw-rt5672",
73 		.fw_filename = "intel/fw_sst_22a8.bin",
74 		.board = "cht-bsw",
75 	},
76 	{
77 		.id = "10EC5645",
78 		.drv_name = "cht-bsw-rt5645",
79 		.fw_filename = "intel/fw_sst_22a8.bin",
80 		.board = "cht-bsw",
81 	},
82 	{
83 		.id = "10EC5650",
84 		.drv_name = "cht-bsw-rt5645",
85 		.fw_filename = "intel/fw_sst_22a8.bin",
86 		.board = "cht-bsw",
87 	},
88 	{
89 		.id = "10EC3270",
90 		.drv_name = "cht-bsw-rt5645",
91 		.fw_filename = "intel/fw_sst_22a8.bin",
92 		.board = "cht-bsw",
93 	},
94 	{
95 		.id = "193C9890",
96 		.drv_name = "cht-bsw-max98090",
97 		.fw_filename = "intel/fw_sst_22a8.bin",
98 		.board = "cht-bsw",
99 	},
100 	{
101 		.id = "DLGS7212",
102 		.drv_name = "bytcht_da7213",
103 		.fw_filename = "intel/fw_sst_22a8.bin",
104 		.board = "bytcht_da7213",
105 	},
106 	{
107 		.id = "DLGS7213",
108 		.drv_name = "bytcht_da7213",
109 		.fw_filename = "intel/fw_sst_22a8.bin",
110 		.board = "bytcht_da7213",
111 	},
112 	{
113 		.id = "ESSX8316",
114 		.drv_name = "bytcht_es8316",
115 		.fw_filename = "intel/fw_sst_22a8.bin",
116 		.board = "bytcht_es8316",
117 	},
118 	/* some CHT-T platforms rely on RT5640, use Baytrail machine driver */
119 	{
120 		.id = "10EC5640",
121 		.drv_name = "bytcr_rt5640",
122 		.fw_filename = "intel/fw_sst_22a8.bin",
123 		.board = "bytcr_rt5640",
124 		.machine_quirk = cht_quirk,
125 	},
126 	{
127 		.id = "10EC3276",
128 		.drv_name = "bytcr_rt5640",
129 		.fw_filename = "intel/fw_sst_22a8.bin",
130 		.board = "bytcr_rt5640",
131 	},
132 	/* some CHT-T platforms rely on RT5651, use Baytrail machine driver */
133 	{
134 		.id = "10EC5651",
135 		.drv_name = "bytcr_rt5651",
136 		.fw_filename = "intel/fw_sst_22a8.bin",
137 		.board = "bytcr_rt5651",
138 	},
139 #if IS_ENABLED(CONFIG_SND_SOC_INTEL_BYT_CHT_NOCODEC_MACH)
140 	/*
141 	 * This is always last in the table so that it is selected only when
142 	 * enabled explicitly and there is no codec-related information in SSDT
143 	 */
144 	{
145 		.id = "808622A8",
146 		.drv_name = "bytcht_nocodec",
147 		.fw_filename = "intel/fw_sst_22a8.bin",
148 		.board = "bytcht_nocodec",
149 	},
150 #endif
151 	{},
152 };
153 EXPORT_SYMBOL_GPL(snd_soc_acpi_intel_cherrytrail_machines);
154 
155 MODULE_LICENSE("GPL v2");
156 MODULE_DESCRIPTION("Intel Common ACPI Match module");
157