Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0
0002 /*
0003  * Thunderbolt driver - quirks
0004  *
0005  * Copyright (c) 2020 Mario Limonciello <mario.limonciello@dell.com>
0006  */
0007 
0008 #include "tb.h"
0009 
0010 static void quirk_force_power_link(struct tb_switch *sw)
0011 {
0012     sw->quirks |= QUIRK_FORCE_POWER_LINK_CONTROLLER;
0013 }
0014 
0015 static void quirk_dp_credit_allocation(struct tb_switch *sw)
0016 {
0017     if (sw->credit_allocation && sw->min_dp_main_credits == 56) {
0018         sw->min_dp_main_credits = 18;
0019         tb_sw_dbg(sw, "quirked DP main: %u\n", sw->min_dp_main_credits);
0020     }
0021 }
0022 
0023 struct tb_quirk {
0024     u16 hw_vendor_id;
0025     u16 hw_device_id;
0026     u16 vendor;
0027     u16 device;
0028     void (*hook)(struct tb_switch *sw);
0029 };
0030 
0031 static const struct tb_quirk tb_quirks[] = {
0032     /* Dell WD19TB supports self-authentication on unplug */
0033     { 0x0000, 0x0000, 0x00d4, 0xb070, quirk_force_power_link },
0034     { 0x0000, 0x0000, 0x00d4, 0xb071, quirk_force_power_link },
0035     /*
0036      * Intel Goshen Ridge NVM 27 and before report wrong number of
0037      * DP buffers.
0038      */
0039     { 0x8087, 0x0b26, 0x0000, 0x0000, quirk_dp_credit_allocation },
0040 };
0041 
0042 /**
0043  * tb_check_quirks() - Check for quirks to apply
0044  * @sw: Thunderbolt switch
0045  *
0046  * Apply any quirks for the Thunderbolt controller.
0047  */
0048 void tb_check_quirks(struct tb_switch *sw)
0049 {
0050     int i;
0051 
0052     for (i = 0; i < ARRAY_SIZE(tb_quirks); i++) {
0053         const struct tb_quirk *q = &tb_quirks[i];
0054 
0055         if (q->hw_vendor_id && q->hw_vendor_id != sw->config.vendor_id)
0056             continue;
0057         if (q->hw_device_id && q->hw_device_id != sw->config.device_id)
0058             continue;
0059         if (q->vendor && q->vendor != sw->vendor)
0060             continue;
0061         if (q->device && q->device != sw->device)
0062             continue;
0063 
0064         q->hook(sw);
0065     }
0066 }