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