blob: b5f2ec79c4d6e53e20266aff1ee7c57d9008669f [file] [log] [blame]
Mario Limonciello1cb36292020-06-23 11:14:29 -05001// 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
10static void quirk_force_power_link(struct tb_switch *sw)
11{
12 sw->quirks |= QUIRK_FORCE_POWER_LINK_CONTROLLER;
13}
14
Mika Westerberg7c37bb32021-03-23 19:05:23 +020015static 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
Mario Limonciello1cb36292020-06-23 11:14:29 -050023struct tb_quirk {
Mika Westerberg7c37bb32021-03-23 19:05:23 +020024 u16 hw_vendor_id;
25 u16 hw_device_id;
Mario Limonciello1cb36292020-06-23 11:14:29 -050026 u16 vendor;
27 u16 device;
28 void (*hook)(struct tb_switch *sw);
29};
30
Wei Yongjunef7e1202020-07-02 16:07:50 +080031static const struct tb_quirk tb_quirks[] = {
Mario Limonciello1cb36292020-06-23 11:14:29 -050032 /* Dell WD19TB supports self-authentication on unplug */
Mika Westerberg7c37bb32021-03-23 19:05:23 +020033 { 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 },
Mario Limonciello1cb36292020-06-23 11:14:29 -050040};
41
42/**
43 * tb_check_quirks() - Check for quirks to apply
44 * @sw: Thunderbolt switch
45 *
Mika Westerberg9c8cac62020-08-26 08:57:00 +030046 * Apply any quirks for the Thunderbolt controller.
Mario Limonciello1cb36292020-06-23 11:14:29 -050047 */
48void 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
Mika Westerberg7c37bb32021-03-23 19:05:23 +020055 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);
Mario Limonciello1cb36292020-06-23 11:14:29 -050065 }
66}