Mario Limonciello | 1cb3629 | 2020-06-23 11:14:29 -0500 | [diff] [blame] | 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 | |
Mika Westerberg | 7c37bb3 | 2021-03-23 19:05:23 +0200 | [diff] [blame] | 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 | |
Mario Limonciello | 1cb3629 | 2020-06-23 11:14:29 -0500 | [diff] [blame] | 23 | struct tb_quirk { |
Mika Westerberg | 7c37bb3 | 2021-03-23 19:05:23 +0200 | [diff] [blame] | 24 | u16 hw_vendor_id; |
| 25 | u16 hw_device_id; |
Mario Limonciello | 1cb3629 | 2020-06-23 11:14:29 -0500 | [diff] [blame] | 26 | u16 vendor; |
| 27 | u16 device; |
| 28 | void (*hook)(struct tb_switch *sw); |
| 29 | }; |
| 30 | |
Wei Yongjun | ef7e120 | 2020-07-02 16:07:50 +0800 | [diff] [blame] | 31 | static const struct tb_quirk tb_quirks[] = { |
Mario Limonciello | 1cb3629 | 2020-06-23 11:14:29 -0500 | [diff] [blame] | 32 | /* Dell WD19TB supports self-authentication on unplug */ |
Mika Westerberg | 7c37bb3 | 2021-03-23 19:05:23 +0200 | [diff] [blame] | 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 }, |
Mario Limonciello | 1cb3629 | 2020-06-23 11:14:29 -0500 | [diff] [blame] | 40 | }; |
| 41 | |
| 42 | /** |
| 43 | * tb_check_quirks() - Check for quirks to apply |
| 44 | * @sw: Thunderbolt switch |
| 45 | * |
Mika Westerberg | 9c8cac6 | 2020-08-26 08:57:00 +0300 | [diff] [blame] | 46 | * Apply any quirks for the Thunderbolt controller. |
Mario Limonciello | 1cb3629 | 2020-06-23 11:14:29 -0500 | [diff] [blame] | 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 | |
Mika Westerberg | 7c37bb3 | 2021-03-23 19:05:23 +0200 | [diff] [blame] | 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); |
Mario Limonciello | 1cb3629 | 2020-06-23 11:14:29 -0500 | [diff] [blame] | 65 | } |
| 66 | } |