summaryrefslogtreecommitdiff
path: root/drivers/soundwire/dmi-quirks.c
blob: 9ebdd0cd0b1cf598b35902541c0997c5934578d3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
// SPDX-License-Identifier: (GPL-2.0 OR BSD-3-Clause)
// Copyright(c) 2021 Intel Corporation.

/*
 * Soundwire DMI quirks
 */

#include <linux/device.h>
#include <linux/dmi.h>
#include <linux/soundwire/sdw.h>
#include "bus.h"

struct adr_remap {
	u64 adr;
	u64 remapped_adr;
};

/*
 * Some TigerLake devices based on an initial Intel BIOS do not expose
 * the correct _ADR in the DSDT.
 * Remap the bad _ADR values to the ones reported by hardware
 */
static const struct adr_remap intel_tgl_bios[] = {
	{
		0x000010025D070100ull,
		0x000020025D071100ull
	},
	{
		0x000110025d070100ull,
		0x000120025D130800ull
	},
	{}
};

/*
 * The initial version of the Dell SKU 0A3E did not expose the devices
 * on the correct links.
 */
static const struct adr_remap dell_sku_0A3E[] = {
	/* rt715 on link0 */
	{
		0x00020025d071100ull,
		0x00021025d071500ull
	},
	/* rt711 on link1 */
	{
		0x000120025d130800ull,
		0x000120025d071100ull,
	},
	/* rt1308 on link2 */
	{
		0x000220025d071500ull,
		0x000220025d130800ull
	},
	{}
};

/*
 * The HP Omen 16-k0005TX does not expose the correct version of RT711 on link0
 * and does not expose a RT1316 on link3
 */
static const struct adr_remap hp_omen_16[] = {
	/* rt711-sdca on link0 */
	{
		0x000020025d071100ull,
		0x000030025d071101ull
	},
	/* rt1316-sdca on link3 */
	{
		0x000120025d071100ull,
		0x000330025d131601ull
	},
	{}
};

/*
 * Intel NUC M15 LAPRC510 and LAPRC710
 */
static const struct adr_remap intel_rooks_county[] = {
	/* rt711-sdca on link0 */
	{
		0x000020025d071100ull,
		0x000030025d071101ull
	},
	/* rt1316-sdca on link2 */
	{
		0x000120025d071100ull,
		0x000230025d131601ull
	},
	{}
};

static const struct dmi_system_id adr_remap_quirk_table[] = {
	/* TGL devices */
	{
		.matches = {
			DMI_MATCH(DMI_SYS_VENDOR, "HP"),
			DMI_MATCH(DMI_PRODUCT_NAME, "HP Spectre x360 Conv"),
		},
		.driver_data = (void *)intel_tgl_bios,
	},
	{
		.matches = {
			DMI_MATCH(DMI_SYS_VENDOR, "HP"),
			DMI_MATCH(DMI_BOARD_NAME, "8709"),
		},
		.driver_data = (void *)intel_tgl_bios,
	},
	{
		/* quirk used for NUC15 'Bishop County' LAPBC510 and LAPBC710 skews */
		.matches = {
			DMI_MATCH(DMI_SYS_VENDOR, "Intel(R) Client Systems"),
			DMI_MATCH(DMI_PRODUCT_NAME, "LAPBC"),
		},
		.driver_data = (void *)intel_tgl_bios,
	},
	{
		/* quirk used for NUC15 LAPBC710 skew */
		.matches = {
			DMI_MATCH(DMI_BOARD_VENDOR, "Intel Corporation"),
			DMI_MATCH(DMI_BOARD_NAME, "LAPBC710"),
		},
		.driver_data = (void *)intel_tgl_bios,
	},
	{
		/* quirk used for NUC15 'Rooks County' LAPRC510 and LAPRC710 skews */
		.matches = {
			DMI_MATCH(DMI_SYS_VENDOR, "Intel(R) Client Systems"),
			DMI_MATCH(DMI_PRODUCT_NAME, "LAPRC"),
		},
		.driver_data = (void *)intel_rooks_county,
	},
	{
		.matches = {
			DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc"),
			DMI_EXACT_MATCH(DMI_PRODUCT_SKU, "0A3E")
		},
		.driver_data = (void *)dell_sku_0A3E,
	},
	/* ADL devices */
	{
		.matches = {
			DMI_MATCH(DMI_SYS_VENDOR, "HP"),
			DMI_MATCH(DMI_PRODUCT_NAME, "OMEN by HP Gaming Laptop 16"),
		},
		.driver_data = (void *)hp_omen_16,
	},
	{}
};

u64 sdw_dmi_override_adr(struct sdw_bus *bus, u64 addr)
{
	const struct dmi_system_id *dmi_id;

	/* check if any address remap quirk applies */
	dmi_id = dmi_first_match(adr_remap_quirk_table);
	if (dmi_id) {
		struct adr_remap *map;

		for (map = dmi_id->driver_data; map->adr; map++) {
			if (map->adr == addr) {
				dev_dbg(bus->dev, "remapped _ADR 0x%llx as 0x%llx\n",
					addr, map->remapped_adr);
				addr = map->remapped_adr;
				break;
			}
		}
	}

	return addr;
}