xref: /linux/drivers/soundwire/dmi-quirks.c (revision f74495761df10c25a98256d16ea7465191b6e2cd)
1f6594cdfSPierre-Louis Bossart // SPDX-License-Identifier: (GPL-2.0 OR BSD-3-Clause)
2f6594cdfSPierre-Louis Bossart // Copyright(c) 2021 Intel Corporation.
3f6594cdfSPierre-Louis Bossart 
4f6594cdfSPierre-Louis Bossart /*
5f6594cdfSPierre-Louis Bossart  * Soundwire DMI quirks
6f6594cdfSPierre-Louis Bossart  */
7f6594cdfSPierre-Louis Bossart 
8f6594cdfSPierre-Louis Bossart #include <linux/device.h>
9f6594cdfSPierre-Louis Bossart #include <linux/dmi.h>
10f6594cdfSPierre-Louis Bossart #include <linux/soundwire/sdw.h>
11f6594cdfSPierre-Louis Bossart #include "bus.h"
12f6594cdfSPierre-Louis Bossart 
13f6594cdfSPierre-Louis Bossart struct adr_remap {
14f6594cdfSPierre-Louis Bossart 	u64 adr;
15f6594cdfSPierre-Louis Bossart 	u64 remapped_adr;
16f6594cdfSPierre-Louis Bossart };
17f6594cdfSPierre-Louis Bossart 
18f6594cdfSPierre-Louis Bossart /*
19caa15c8dSPierre-Louis Bossart  * Some TigerLake devices based on an initial Intel BIOS do not expose
20caa15c8dSPierre-Louis Bossart  * the correct _ADR in the DSDT.
21f6594cdfSPierre-Louis Bossart  * Remap the bad _ADR values to the ones reported by hardware
22f6594cdfSPierre-Louis Bossart  */
23caa15c8dSPierre-Louis Bossart static const struct adr_remap intel_tgl_bios[] = {
24f6594cdfSPierre-Louis Bossart 	{
25433b3084SPierre-Louis Bossart 		0x000010025D070100ull,
26433b3084SPierre-Louis Bossart 		0x000020025D071100ull
27f6594cdfSPierre-Louis Bossart 	},
28f6594cdfSPierre-Louis Bossart 	{
29433b3084SPierre-Louis Bossart 		0x000110025d070100ull,
30433b3084SPierre-Louis Bossart 		0x000120025D130800ull
31f6594cdfSPierre-Louis Bossart 	},
32f6594cdfSPierre-Louis Bossart 	{}
33f6594cdfSPierre-Louis Bossart };
34f6594cdfSPierre-Louis Bossart 
35be3ae00fSPierre-Louis Bossart /*
36be3ae00fSPierre-Louis Bossart  * The initial version of the Dell SKU 0A3E did not expose the devices
37be3ae00fSPierre-Louis Bossart  * on the correct links.
38be3ae00fSPierre-Louis Bossart  */
39be3ae00fSPierre-Louis Bossart static const struct adr_remap dell_sku_0A3E[] = {
40be3ae00fSPierre-Louis Bossart 	/* rt715 on link0 */
41be3ae00fSPierre-Louis Bossart 	{
42433b3084SPierre-Louis Bossart 		0x00020025d071100ull,
43433b3084SPierre-Louis Bossart 		0x00021025d071500ull
44be3ae00fSPierre-Louis Bossart 	},
45be3ae00fSPierre-Louis Bossart 	/* rt711 on link1 */
46be3ae00fSPierre-Louis Bossart 	{
47433b3084SPierre-Louis Bossart 		0x000120025d130800ull,
48433b3084SPierre-Louis Bossart 		0x000120025d071100ull,
49be3ae00fSPierre-Louis Bossart 	},
50be3ae00fSPierre-Louis Bossart 	/* rt1308 on link2 */
51be3ae00fSPierre-Louis Bossart 	{
52433b3084SPierre-Louis Bossart 		0x000220025d071500ull,
53433b3084SPierre-Louis Bossart 		0x000220025d130800ull
54be3ae00fSPierre-Louis Bossart 	},
55be3ae00fSPierre-Louis Bossart 	{}
56be3ae00fSPierre-Louis Bossart };
57be3ae00fSPierre-Louis Bossart 
58df551005SPierre-Louis Bossart /*
59df551005SPierre-Louis Bossart  * The HP Omen 16-k0005TX does not expose the correct version of RT711 on link0
60df551005SPierre-Louis Bossart  * and does not expose a RT1316 on link3
61df551005SPierre-Louis Bossart  */
62df551005SPierre-Louis Bossart static const struct adr_remap hp_omen_16[] = {
63df551005SPierre-Louis Bossart 	/* rt711-sdca on link0 */
64df551005SPierre-Louis Bossart 	{
65df551005SPierre-Louis Bossart 		0x000020025d071100ull,
66df551005SPierre-Louis Bossart 		0x000030025d071101ull
67df551005SPierre-Louis Bossart 	},
68df551005SPierre-Louis Bossart 	/* rt1316-sdca on link3 */
69df551005SPierre-Louis Bossart 	{
70df551005SPierre-Louis Bossart 		0x000120025d071100ull,
71df551005SPierre-Louis Bossart 		0x000330025d131601ull
72df551005SPierre-Louis Bossart 	},
73df551005SPierre-Louis Bossart 	{}
74df551005SPierre-Louis Bossart };
75df551005SPierre-Louis Bossart 
76f6594cdfSPierre-Louis Bossart static const struct dmi_system_id adr_remap_quirk_table[] = {
77df551005SPierre-Louis Bossart 	/* TGL devices */
78f6594cdfSPierre-Louis Bossart 	{
79f6594cdfSPierre-Louis Bossart 		.matches = {
80f6594cdfSPierre-Louis Bossart 			DMI_MATCH(DMI_SYS_VENDOR, "HP"),
81ce73ef6eSAnthony I Gilea 			DMI_MATCH(DMI_PRODUCT_NAME, "HP Spectre x360 Conv"),
82f6594cdfSPierre-Louis Bossart 		},
83caa15c8dSPierre-Louis Bossart 		.driver_data = (void *)intel_tgl_bios,
84caa15c8dSPierre-Louis Bossart 	},
85caa15c8dSPierre-Louis Bossart 	{
86caa15c8dSPierre-Louis Bossart 		/* quirk used for NUC15 'Bishop County' LAPBC510 and LAPBC710 skews */
87caa15c8dSPierre-Louis Bossart 		.matches = {
88caa15c8dSPierre-Louis Bossart 			DMI_MATCH(DMI_SYS_VENDOR, "Intel(R) Client Systems"),
89caa15c8dSPierre-Louis Bossart 			DMI_MATCH(DMI_PRODUCT_NAME, "LAPBC"),
90caa15c8dSPierre-Louis Bossart 		},
91caa15c8dSPierre-Louis Bossart 		.driver_data = (void *)intel_tgl_bios,
92f6594cdfSPierre-Louis Bossart 	},
93be3ae00fSPierre-Louis Bossart 	{
94*f7449576SPierre-Louis Bossart 		/* quirk used for NUC15 LAPBC710 skew */
95*f7449576SPierre-Louis Bossart 		.matches = {
96*f7449576SPierre-Louis Bossart 			DMI_MATCH(DMI_BOARD_VENDOR, "Intel Corporation"),
97*f7449576SPierre-Louis Bossart 			DMI_MATCH(DMI_BOARD_NAME, "LAPBC710"),
98*f7449576SPierre-Louis Bossart 		},
99*f7449576SPierre-Louis Bossart 		.driver_data = (void *)intel_tgl_bios,
100*f7449576SPierre-Louis Bossart 	},
101*f7449576SPierre-Louis Bossart 	{
102be3ae00fSPierre-Louis Bossart 		.matches = {
103be3ae00fSPierre-Louis Bossart 			DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc"),
104be3ae00fSPierre-Louis Bossart 			DMI_EXACT_MATCH(DMI_PRODUCT_SKU, "0A3E")
105be3ae00fSPierre-Louis Bossart 		},
106be3ae00fSPierre-Louis Bossart 		.driver_data = (void *)dell_sku_0A3E,
107be3ae00fSPierre-Louis Bossart 	},
108df551005SPierre-Louis Bossart 	/* ADL devices */
109df551005SPierre-Louis Bossart 	{
110df551005SPierre-Louis Bossart 		.matches = {
111df551005SPierre-Louis Bossart 			DMI_MATCH(DMI_SYS_VENDOR, "HP"),
112df551005SPierre-Louis Bossart 			DMI_MATCH(DMI_PRODUCT_NAME, "OMEN by HP Gaming Laptop 16-k0xxx"),
113df551005SPierre-Louis Bossart 		},
114df551005SPierre-Louis Bossart 		.driver_data = (void *)hp_omen_16,
115df551005SPierre-Louis Bossart 	},
116f6594cdfSPierre-Louis Bossart 	{}
117f6594cdfSPierre-Louis Bossart };
118f6594cdfSPierre-Louis Bossart 
119f6594cdfSPierre-Louis Bossart u64 sdw_dmi_override_adr(struct sdw_bus *bus, u64 addr)
120f6594cdfSPierre-Louis Bossart {
121f6594cdfSPierre-Louis Bossart 	const struct dmi_system_id *dmi_id;
122f6594cdfSPierre-Louis Bossart 
123f6594cdfSPierre-Louis Bossart 	/* check if any address remap quirk applies */
124f6594cdfSPierre-Louis Bossart 	dmi_id = dmi_first_match(adr_remap_quirk_table);
125f6594cdfSPierre-Louis Bossart 	if (dmi_id) {
12603721992SPierre-Louis Bossart 		struct adr_remap *map;
127f6594cdfSPierre-Louis Bossart 
128f6594cdfSPierre-Louis Bossart 		for (map = dmi_id->driver_data; map->adr; map++) {
129f6594cdfSPierre-Louis Bossart 			if (map->adr == addr) {
130f6594cdfSPierre-Louis Bossart 				dev_dbg(bus->dev, "remapped _ADR 0x%llx as 0x%llx\n",
131f6594cdfSPierre-Louis Bossart 					addr, map->remapped_adr);
132f6594cdfSPierre-Louis Bossart 				addr = map->remapped_adr;
133f6594cdfSPierre-Louis Bossart 				break;
134f6594cdfSPierre-Louis Bossart 			}
135f6594cdfSPierre-Louis Bossart 		}
136f6594cdfSPierre-Louis Bossart 	}
137f6594cdfSPierre-Louis Bossart 
138f6594cdfSPierre-Louis Bossart 	return addr;
139f6594cdfSPierre-Louis Bossart }
140