drm/i915/icl: store the port type for TC ports
authorPaulo Zanoni <paulo.r.zanoni@intel.com>
Wed, 25 Jul 2018 00:28:10 +0000 (17:28 -0700)
committerPaulo Zanoni <paulo.r.zanoni@intel.com>
Wed, 25 Jul 2018 20:33:25 +0000 (13:33 -0700)
The type is detected based on the live status bits. Once detected,
it's not supposed to be changed, so we have some sanity checks for
that.

v2: Rebase.

Cc: Animesh Manna <animesh.manna@intel.com>
Reviewed-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
Signed-off-by: Paulo Zanoni <paulo.r.zanoni@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20180725002813.6938-3-paulo.r.zanoni@intel.com
drivers/gpu/drm/i915/intel_display.h
drivers/gpu/drm/i915/intel_dp.c
drivers/gpu/drm/i915/intel_drv.h

index 9292001cdd14defd45e8ad75fe34d7b4bed1e52d..0a79a46d5805a0eff57bac0591d5676b34ffc3ee 100644 (file)
@@ -137,6 +137,13 @@ enum tc_port {
        I915_MAX_TC_PORTS
 };
 
+enum tc_port_type {
+       TC_PORT_UNKNOWN = 0,
+       TC_PORT_TYPEC,
+       TC_PORT_TBT,
+       TC_PORT_LEGACY,
+};
+
 enum dpio_channel {
        DPIO_CH0,
        DPIO_CH1
index 998d698788f986b2712a24742c027bfb0d04a2d7..90c5ba6b222b0060cccba20ed93183c56afe458f 100644 (file)
@@ -4594,6 +4594,38 @@ static bool icl_combo_port_connected(struct drm_i915_private *dev_priv,
        return I915_READ(SDEISR) & SDE_DDI_HOTPLUG_ICP(port);
 }
 
+static void icl_update_tc_port_type(struct drm_i915_private *dev_priv,
+                                   struct intel_digital_port *intel_dig_port,
+                                   bool is_legacy, bool is_typec, bool is_tbt)
+{
+       enum port port = intel_dig_port->base.port;
+       enum tc_port_type old_type = intel_dig_port->tc_type;
+       const char *type_str;
+
+       WARN_ON(is_legacy + is_typec + is_tbt != 1);
+
+       if (is_legacy) {
+               intel_dig_port->tc_type = TC_PORT_LEGACY;
+               type_str = "legacy";
+       } else if (is_typec) {
+               intel_dig_port->tc_type = TC_PORT_TYPEC;
+               type_str = "typec";
+       } else if (is_tbt) {
+               intel_dig_port->tc_type = TC_PORT_TBT;
+               type_str = "tbt";
+       } else {
+               return;
+       }
+
+       /* Types are not supposed to be changed at runtime. */
+       WARN_ON(old_type != TC_PORT_UNKNOWN &&
+               old_type != intel_dig_port->tc_type);
+
+       if (old_type != intel_dig_port->tc_type)
+               DRM_DEBUG_KMS("Port %c has TC type %s\n", port_name(port),
+                             type_str);
+}
+
 static bool icl_tc_port_connected(struct drm_i915_private *dev_priv,
                                  struct intel_digital_port *intel_dig_port)
 {
@@ -4612,9 +4644,13 @@ static bool icl_tc_port_connected(struct drm_i915_private *dev_priv,
        is_typec = dpsp & TC_LIVE_STATE_TC(tc_port);
        is_tbt = dpsp & TC_LIVE_STATE_TBT(tc_port);
 
-       WARN_ON(is_legacy + is_typec + is_tbt > 1);
+       if (!is_legacy && !is_typec && !is_tbt)
+               return false;
+
+       icl_update_tc_port_type(dev_priv, intel_dig_port, is_legacy, is_typec,
+                               is_tbt);
 
-       return is_legacy || is_typec || is_tbt;
+       return true;
 }
 
 static bool icl_digital_port_connected(struct intel_encoder *encoder)
index c275f91244a6ced7a143cb8242de99eafd7410ea..5e225d8ba09ad94d1f4609250cff5888329518a6 100644 (file)
@@ -1164,6 +1164,7 @@ struct intel_digital_port {
        bool release_cl2_override;
        uint8_t max_lanes;
        enum intel_display_power_domain ddi_io_power_domain;
+       enum tc_port_type tc_type;
 
        void (*write_infoframe)(struct drm_encoder *encoder,
                                const struct intel_crtc_state *crtc_state,