]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/blob - drivers/thunderbolt/quirks.c
Merge tag 'sched-core-2021-08-30' of git://git.kernel.org/pub/scm/linux/kernel/git...
[mirror_ubuntu-jammy-kernel.git] / drivers / thunderbolt / quirks.c
1 // SPDX-License-Identifier: GPL-2.0
2 /*
3 * Thunderbolt driver - quirks
4 *
5 * Copyright (c) 2020 Mario Limonciello <mario.limonciello@dell.com>
6 */
7
8 #include "tb.h"
9
10 static void quirk_force_power_link(struct tb_switch *sw)
11 {
12 sw->quirks |= QUIRK_FORCE_POWER_LINK_CONTROLLER;
13 }
14
15 static void quirk_dp_credit_allocation(struct tb_switch *sw)
16 {
17 if (sw->credit_allocation && sw->min_dp_main_credits == 56) {
18 sw->min_dp_main_credits = 18;
19 tb_sw_dbg(sw, "quirked DP main: %u\n", sw->min_dp_main_credits);
20 }
21 }
22
23 struct tb_quirk {
24 u16 hw_vendor_id;
25 u16 hw_device_id;
26 u16 vendor;
27 u16 device;
28 void (*hook)(struct tb_switch *sw);
29 };
30
31 static const struct tb_quirk tb_quirks[] = {
32 /* Dell WD19TB supports self-authentication on unplug */
33 { 0x0000, 0x0000, 0x00d4, 0xb070, quirk_force_power_link },
34 { 0x0000, 0x0000, 0x00d4, 0xb071, quirk_force_power_link },
35 /*
36 * Intel Goshen Ridge NVM 27 and before report wrong number of
37 * DP buffers.
38 */
39 { 0x8087, 0x0b26, 0x0000, 0x0000, quirk_dp_credit_allocation },
40 };
41
42 /**
43 * tb_check_quirks() - Check for quirks to apply
44 * @sw: Thunderbolt switch
45 *
46 * Apply any quirks for the Thunderbolt controller.
47 */
48 void tb_check_quirks(struct tb_switch *sw)
49 {
50 int i;
51
52 for (i = 0; i < ARRAY_SIZE(tb_quirks); i++) {
53 const struct tb_quirk *q = &tb_quirks[i];
54
55 if (q->hw_vendor_id && q->hw_vendor_id != sw->config.vendor_id)
56 continue;
57 if (q->hw_device_id && q->hw_device_id != sw->config.device_id)
58 continue;
59 if (q->vendor && q->vendor != sw->vendor)
60 continue;
61 if (q->device && q->device != sw->device)
62 continue;
63
64 q->hook(sw);
65 }
66 }