xref: /linux/drivers/thunderbolt/quirks.c (revision ec8a42e7343234802b9054874fe01810880289ce)
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 struct tb_quirk {
16 	u16 vendor;
17 	u16 device;
18 	void (*hook)(struct tb_switch *sw);
19 };
20 
21 static const struct tb_quirk tb_quirks[] = {
22 	/* Dell WD19TB supports self-authentication on unplug */
23 	{ 0x00d4, 0xb070, quirk_force_power_link },
24 };
25 
26 /**
27  * tb_check_quirks() - Check for quirks to apply
28  * @sw: Thunderbolt switch
29  *
30  * Apply any quirks for the Thunderbolt controller.
31  */
32 void tb_check_quirks(struct tb_switch *sw)
33 {
34 	int i;
35 
36 	for (i = 0; i < ARRAY_SIZE(tb_quirks); i++) {
37 		const struct tb_quirk *q = &tb_quirks[i];
38 
39 		if (sw->device == q->device && sw->vendor == q->vendor)
40 			q->hook(sw);
41 	}
42 }
43