Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

drm/i915/tc: Add an enum for the TypeC pin assignment

Add an enum for the TypeC pin assignment, which is a better way to pass
its value around than a plain integer. While at it add a description for
each pin assignment, based on the DP and DP Alt mode Standards, opting
for more details to ease any future debugging related to a given pin
assignment and the cables / sink types used.

Reviewed-by: Mika Kahola <mika.kahola@intel.com>
[Imre: s/deined/defined in pin assignment enum documentation.]
Link: https://lore.kernel.org/r/20250805073700.642107-10-imre.deak@intel.com
Signed-off-by: Imre Deak <imre.deak@intel.com>

Imre Deak 6eaec941 f1ecaa7a

+78 -12
+2
drivers/gpu/drm/i915/display/intel_display_regs.h
··· 2890 2890 #define DP_PIN_ASSIGNMENT_SHIFT(idx) ((idx) * 4) 2891 2891 #define DP_PIN_ASSIGNMENT_MASK(idx) (0xf << ((idx) * 4)) 2892 2892 #define DP_PIN_ASSIGNMENT(idx, x) ((x) << ((idx) * 4)) 2893 + /* See enum intel_tc_pin_assignment for the pin assignment field values. */ 2893 2894 2894 2895 #define _TCSS_DDI_STATUS_1 0x161500 2895 2896 #define _TCSS_DDI_STATUS_2 0x161504 ··· 2898 2897 _TCSS_DDI_STATUS_1, \ 2899 2898 _TCSS_DDI_STATUS_2)) 2900 2899 #define TCSS_DDI_STATUS_PIN_ASSIGNMENT_MASK REG_GENMASK(28, 25) 2900 + /* See enum intel_tc_pin_assignment for the pin assignment field values. */ 2901 2901 #define TCSS_DDI_STATUS_READY REG_BIT(2) 2902 2902 #define TCSS_DDI_STATUS_HPD_LIVE_STATUS_TBT REG_BIT(1) 2903 2903 #define TCSS_DDI_STATUS_HPD_LIVE_STATUS_ALT REG_BIT(0)
+7 -12
drivers/gpu/drm/i915/display/intel_tc.c
··· 23 23 #include "intel_modeset_lock.h" 24 24 #include "intel_tc.h" 25 25 26 - #define DP_PIN_ASSIGNMENT_NONE 0x0 27 - #define DP_PIN_ASSIGNMENT_C 0x3 28 - #define DP_PIN_ASSIGNMENT_D 0x4 29 - #define DP_PIN_ASSIGNMENT_E 0x5 30 - 31 26 enum tc_port_mode { 32 27 TC_PORT_DISCONNECTED, 33 28 TC_PORT_TBT_ALT, ··· 312 317 REG_FIELD_GET(TCSS_DDI_STATUS_PIN_ASSIGNMENT_MASK, val); 313 318 314 319 switch (pin_assignment) { 315 - case DP_PIN_ASSIGNMENT_NONE: 320 + case INTEL_TC_PIN_ASSIGNMENT_NONE: 316 321 return 0; 317 322 default: 318 323 MISSING_CASE(pin_assignment); 319 324 fallthrough; 320 - case DP_PIN_ASSIGNMENT_D: 325 + case INTEL_TC_PIN_ASSIGNMENT_D: 321 326 return 2; 322 - case DP_PIN_ASSIGNMENT_C: 323 - case DP_PIN_ASSIGNMENT_E: 327 + case INTEL_TC_PIN_ASSIGNMENT_C: 328 + case INTEL_TC_PIN_ASSIGNMENT_E: 324 329 return 4; 325 330 } 326 331 } ··· 335 340 default: 336 341 MISSING_CASE(pin_mask); 337 342 fallthrough; 338 - case DP_PIN_ASSIGNMENT_D: 343 + case INTEL_TC_PIN_ASSIGNMENT_D: 339 344 return 2; 340 - case DP_PIN_ASSIGNMENT_C: 341 - case DP_PIN_ASSIGNMENT_E: 345 + case INTEL_TC_PIN_ASSIGNMENT_C: 346 + case INTEL_TC_PIN_ASSIGNMENT_E: 342 347 return 4; 343 348 } 344 349 }
+69
drivers/gpu/drm/i915/display/intel_tc.h
··· 12 12 struct intel_digital_port; 13 13 struct intel_encoder; 14 14 15 + /* 16 + * The following enum values must stay fixed, as they match the corresponding 17 + * pin assignment fields in the PORT_TX_DFLEXPA1 and TCSS_DDI_STATUS registers. 18 + */ 19 + enum intel_tc_pin_assignment { /* Lanes (a) Signal/ Cable Notes */ 20 + /* DP USB Rate (b) type */ 21 + INTEL_TC_PIN_ASSIGNMENT_NONE = 0, /* 4 - - - (c) */ 22 + INTEL_TC_PIN_ASSIGNMENT_A, /* 2/4 0 GEN2 TC->TC (d,e) */ 23 + INTEL_TC_PIN_ASSIGNMENT_B, /* 1/2 1 GEN2 TC->TC (d,f,g) */ 24 + INTEL_TC_PIN_ASSIGNMENT_C, /* 4 0 DP2 TC->TC (h) */ 25 + INTEL_TC_PIN_ASSIGNMENT_D, /* 2 1 DP2 TC->TC (h,g) */ 26 + INTEL_TC_PIN_ASSIGNMENT_E, /* 4 0 DP2 TC->DP */ 27 + INTEL_TC_PIN_ASSIGNMENT_F, /* 2 1 GEN1/DP1 TC->DP (d,g,i) */ 28 + /* 29 + * (a) - DP unidirectional lanes, each lane using 1 differential signal 30 + * pair. 31 + * - USB SuperSpeed bidirectional lane, using 2 differential (TX and 32 + * RX) signal pairs. 33 + * - USB 2.0 (HighSpeed) unidirectional lane, using 1 differential 34 + * signal pair. Not indicated, this lane is always present on pin 35 + * assignments A-D and never present on pin assignments E/F. 36 + * (b) - GEN1: USB 3.1 GEN1 bit rate (5 Gbps) and signaling. This 37 + * is used for transferring only a USB stream. 38 + * - GEN2: USB 3.1 GEN2 bit rate (10 Gbps) and signaling. This 39 + * allows transferring an HBR3 (8.1 Gbps) DP stream. 40 + * - DP1: Display Port signaling defined by the DP v1.3 Standard, 41 + * with a maximum bit rate of HBR3. 42 + * - DP2: Display Port signaling defined by the DP v2.1 Standard, 43 + * with a maximum bit rate defined by the DP Alt Mode 44 + * v2.1a Standard depending on the cable type as follows: 45 + * - Passive (Full-Featured) USB 3.2 GEN1 46 + * TC->TC cables (CC3G1-X) : UHBR10 47 + * - Passive (Full-Featured) USB 3.2/4 GEN2 and 48 + * Thunderbolt Alt Mode GEN2 49 + * TC->TC cables (CC3G2-X) all : UHBR10 50 + * DP54 logo : UHBR13.5 51 + * - Passive (Full-Featured) USB4 GEN3+ and 52 + * Thunderbolt Alt Mode GEN3+ 53 + * TC->TC cables (CC4G3-X) all : UHBR13.5 54 + * DP80 logo : UHBR20 55 + * - Active Re-Timed or 56 + * Active Linear Re-driven (LRD) 57 + * USB3.2 GEN1/2 and USB4 GEN2+ 58 + * TC->TC cables all : HBR3 59 + * with DP_BR CTS : UHBR10 60 + * DP54 logo : UHBR13.5 61 + * DP80 logo : UHBR20 62 + * - Passive/Active Re-Timed or 63 + * Active Linear Re-driven (LRD) 64 + * TC->DP cables with DP_BR CTS/DP8K logo : HBR3 65 + * with DP_BR CTS : UHBR10 66 + * DP54 logo : UHBR13.5 67 + * DP80 logo : UHBR20 68 + * (c) Used in TBT-alt/legacy modes and on LNL+ after the sink 69 + * disconnected in DP-alt mode. 70 + * (d) Only defined by the DP Alt Standard v1.0a, deprecated by v1.0b, 71 + * only supported on ICL. 72 + * (e) GEN2 passive 1 m cable: 4 DP lanes, GEN2 active cable: 2 DP lanes. 73 + * (f) GEN2 passive 1 m cable: 2 DP lanes, GEN2 active cable: 1 DP lane. 74 + * (g) These pin assignments are also referred to as (USB/DP) 75 + * multifunction or Multifunction Display Port (MFD) modes. 76 + * (h) Also used where one end of the cable is a captive connector, 77 + * attached to a DP->HDMI/DVI/VGA converter. 78 + * (i) The DP end of the cable is a captive connector attached to a 79 + * (DP/USB) multifunction dock as defined by the DockPort v1.0a 80 + * specification. 81 + */ 82 + }; 83 + 15 84 bool intel_tc_port_in_tbt_alt_mode(struct intel_digital_port *dig_port); 16 85 bool intel_tc_port_in_dp_alt_mode(struct intel_digital_port *dig_port); 17 86 bool intel_tc_port_in_legacy_mode(struct intel_digital_port *dig_port);