summaryrefslogtreecommitdiffstats
path: root/drivers/thunderbolt
diff options
context:
space:
mode:
authorMika Westerberg <mika.westerberg@linux.intel.com>2017-06-06 08:25:13 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2017-06-09 05:42:43 -0400
commit2c3c4197c9dd878e39e249e1da64bcffceb8a5c4 (patch)
tree42c2c7a7c6ecf052e5dd210ae5ce26c1bd083d45 /drivers/thunderbolt
parentcd446ee2e64f03d0e3d8463bf826aaebe0005149 (diff)
thunderbolt: Store Thunderbolt generation in the switch structure
In some cases it is useful to know what is the Thunderbolt generation the switch supports. This introduces a new field to struct switch that stores the generation of the switch based on the device ID. Unknown switches (there should be none) are assumed to be first generation to be on the safe side. Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com> Reviewed-by: Yehezkel Bernat <yehezkel.bernat@intel.com> Reviewed-by: Michael Jamet <michael.jamet@intel.com> Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Signed-off-by: Andreas Noever <andreas.noever@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/thunderbolt')
-rw-r--r--drivers/thunderbolt/switch.c55
-rw-r--r--drivers/thunderbolt/tb.h2
2 files changed, 40 insertions, 17 deletions
diff --git a/drivers/thunderbolt/switch.c b/drivers/thunderbolt/switch.c
index 1497518aceff..6384061100b0 100644
--- a/drivers/thunderbolt/switch.c
+++ b/drivers/thunderbolt/switch.c
@@ -390,6 +390,42 @@ struct device_type tb_switch_type = {
390 .release = tb_switch_release, 390 .release = tb_switch_release,
391}; 391};
392 392
393static int tb_switch_get_generation(struct tb_switch *sw)
394{
395 switch (sw->config.device_id) {
396 case PCI_DEVICE_ID_INTEL_LIGHT_RIDGE:
397 case PCI_DEVICE_ID_INTEL_EAGLE_RIDGE:
398 case PCI_DEVICE_ID_INTEL_LIGHT_PEAK:
399 case PCI_DEVICE_ID_INTEL_CACTUS_RIDGE_2C:
400 case PCI_DEVICE_ID_INTEL_CACTUS_RIDGE_4C:
401 case PCI_DEVICE_ID_INTEL_PORT_RIDGE:
402 case PCI_DEVICE_ID_INTEL_REDWOOD_RIDGE_2C_BRIDGE:
403 case PCI_DEVICE_ID_INTEL_REDWOOD_RIDGE_4C_BRIDGE:
404 return 1;
405
406 case PCI_DEVICE_ID_INTEL_WIN_RIDGE_2C_BRIDGE:
407 case PCI_DEVICE_ID_INTEL_FALCON_RIDGE_2C_BRIDGE:
408 case PCI_DEVICE_ID_INTEL_FALCON_RIDGE_4C_BRIDGE:
409 return 2;
410
411 case PCI_DEVICE_ID_INTEL_ALPINE_RIDGE_LP_BRIDGE:
412 case PCI_DEVICE_ID_INTEL_ALPINE_RIDGE_2C_BRIDGE:
413 case PCI_DEVICE_ID_INTEL_ALPINE_RIDGE_4C_BRIDGE:
414 case PCI_DEVICE_ID_INTEL_ALPINE_RIDGE_C_2C_BRIDGE:
415 case PCI_DEVICE_ID_INTEL_ALPINE_RIDGE_C_4C_BRIDGE:
416 return 3;
417
418 default:
419 /*
420 * For unknown switches assume generation to be 1 to be
421 * on the safe side.
422 */
423 tb_sw_warn(sw, "unsupported switch device id %#x\n",
424 sw->config.device_id);
425 return 1;
426 }
427}
428
393/** 429/**
394 * tb_switch_alloc() - allocate a switch 430 * tb_switch_alloc() - allocate a switch
395 * @tb: Pointer to the owning domain 431 * @tb: Pointer to the owning domain
@@ -443,6 +479,8 @@ struct tb_switch *tb_switch_alloc(struct tb *tb, struct device *parent,
443 sw->ports[i].port = i; 479 sw->ports[i].port = i;
444 } 480 }
445 481
482 sw->generation = tb_switch_get_generation(sw);
483
446 cap = tb_switch_find_vse_cap(sw, TB_VSE_CAP_PLUG_EVENTS); 484 cap = tb_switch_find_vse_cap(sw, TB_VSE_CAP_PLUG_EVENTS);
447 if (cap < 0) { 485 if (cap < 0) {
448 tb_sw_warn(sw, "cannot find TB_VSE_CAP_PLUG_EVENTS aborting\n"); 486 tb_sw_warn(sw, "cannot find TB_VSE_CAP_PLUG_EVENTS aborting\n");
@@ -491,23 +529,6 @@ int tb_switch_configure(struct tb_switch *sw)
491 tb_sw_warn(sw, "unknown switch vendor id %#x\n", 529 tb_sw_warn(sw, "unknown switch vendor id %#x\n",
492 sw->config.vendor_id); 530 sw->config.vendor_id);
493 531
494 switch (sw->config.device_id) {
495 case PCI_DEVICE_ID_INTEL_LIGHT_RIDGE:
496 case PCI_DEVICE_ID_INTEL_CACTUS_RIDGE_4C:
497 case PCI_DEVICE_ID_INTEL_PORT_RIDGE:
498 case PCI_DEVICE_ID_INTEL_FALCON_RIDGE_2C_BRIDGE:
499 case PCI_DEVICE_ID_INTEL_FALCON_RIDGE_4C_BRIDGE:
500 case PCI_DEVICE_ID_INTEL_ALPINE_RIDGE_2C_BRIDGE:
501 case PCI_DEVICE_ID_INTEL_ALPINE_RIDGE_4C_BRIDGE:
502 case PCI_DEVICE_ID_INTEL_ALPINE_RIDGE_C_2C_BRIDGE:
503 case PCI_DEVICE_ID_INTEL_ALPINE_RIDGE_C_4C_BRIDGE:
504 break;
505
506 default:
507 tb_sw_warn(sw, "unsupported switch device id %#x\n",
508 sw->config.device_id);
509 }
510
511 sw->config.enabled = 1; 532 sw->config.enabled = 1;
512 533
513 /* upload configuration */ 534 /* upload configuration */
diff --git a/drivers/thunderbolt/tb.h b/drivers/thunderbolt/tb.h
index 98a405384596..39d24dff82c5 100644
--- a/drivers/thunderbolt/tb.h
+++ b/drivers/thunderbolt/tb.h
@@ -25,6 +25,7 @@
25 * @device: Device ID of the switch 25 * @device: Device ID of the switch
26 * @vendor_name: Name of the vendor (or %NULL if not known) 26 * @vendor_name: Name of the vendor (or %NULL if not known)
27 * @device_name: Name of the device (or %NULL if not known) 27 * @device_name: Name of the device (or %NULL if not known)
28 * @generation: Switch Thunderbolt generation
28 * @cap_plug_events: Offset to the plug events capability (%0 if not found) 29 * @cap_plug_events: Offset to the plug events capability (%0 if not found)
29 * @is_unplugged: The switch is going away 30 * @is_unplugged: The switch is going away
30 * @drom: DROM of the switch (%NULL if not found) 31 * @drom: DROM of the switch (%NULL if not found)
@@ -40,6 +41,7 @@ struct tb_switch {
40 u16 device; 41 u16 device;
41 const char *vendor_name; 42 const char *vendor_name;
42 const char *device_name; 43 const char *device_name;
44 unsigned int generation;
43 int cap_plug_events; 45 int cap_plug_events;
44 bool is_unplugged; 46 bool is_unplugged;
45 u8 *drom; 47 u8 *drom;