blob: 82061c1d98356e10060a9d9d5b8a46ba77b8b7f0 [file] [log] [blame]
Pierre-Louis Bossartf6594cd2021-03-02 15:51:04 +08001// 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
13struct adr_remap {
14 u64 adr;
15 u64 remapped_adr;
16};
17
18/*
19 * HP Spectre 360 Convertible devices do not expose the correct _ADR
20 * in the DSDT.
21 * Remap the bad _ADR values to the ones reported by hardware
22 */
23static const struct adr_remap hp_spectre_360[] = {
24 {
25 0x000010025D070100,
26 0x000020025D071100
27 },
28 {
29 0x000110025d070100,
30 0x000120025D130800
31 },
32 {}
33};
34
Pierre-Louis Bossartbe3ae002021-03-02 15:51:05 +080035/*
36 * The initial version of the Dell SKU 0A3E did not expose the devices
37 * on the correct links.
38 */
39static const struct adr_remap dell_sku_0A3E[] = {
40 /* rt715 on link0 */
41 {
42 0x00020025d071100,
43 0x00021025d071500
44 },
45 /* rt711 on link1 */
46 {
47 0x000120025d130800,
48 0x000120025d071100,
49 },
50 /* rt1308 on link2 */
51 {
52 0x000220025d071500,
53 0x000220025d130800
54 },
55 {}
56};
57
Pierre-Louis Bossartf6594cd2021-03-02 15:51:04 +080058static const struct dmi_system_id adr_remap_quirk_table[] = {
59 {
60 .matches = {
61 DMI_MATCH(DMI_SYS_VENDOR, "HP"),
62 DMI_MATCH(DMI_PRODUCT_NAME, "HP Spectre x360 Convertible"),
63 },
64 .driver_data = (void *)hp_spectre_360,
65 },
Pierre-Louis Bossartbe3ae002021-03-02 15:51:05 +080066 {
67 .matches = {
68 DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc"),
69 DMI_EXACT_MATCH(DMI_PRODUCT_SKU, "0A3E")
70 },
71 .driver_data = (void *)dell_sku_0A3E,
72 },
Pierre-Louis Bossartf6594cd2021-03-02 15:51:04 +080073 {}
74};
75
76u64 sdw_dmi_override_adr(struct sdw_bus *bus, u64 addr)
77{
78 const struct dmi_system_id *dmi_id;
79
80 /* check if any address remap quirk applies */
81 dmi_id = dmi_first_match(adr_remap_quirk_table);
82 if (dmi_id) {
83 struct adr_remap *map = dmi_id->driver_data;
84
85 for (map = dmi_id->driver_data; map->adr; map++) {
86 if (map->adr == addr) {
87 dev_dbg(bus->dev, "remapped _ADR 0x%llx as 0x%llx\n",
88 addr, map->remapped_adr);
89 addr = map->remapped_adr;
90 break;
91 }
92 }
93 }
94
95 return addr;
96}