Merge tag 'v5.9-rc4' into drm-next
[linux-2.6-microblaze.git] / drivers / gpu / drm / i915 / display / intel_ddi.c
index a49ff3a..19ac6b2 100644 (file)
@@ -706,6 +706,42 @@ static const struct cnl_ddi_buf_trans tgl_combo_phy_ddi_translations_dp_hbr2[] =
        { 0x6, 0x7F, 0x3F, 0x00, 0x00 },        /* 900   900      0.0   */
 };
 
+static const struct cnl_ddi_buf_trans tgl_uy_combo_phy_ddi_translations_dp_hbr2[] = {
+                                               /* NT mV Trans mV db    */
+       { 0xA, 0x35, 0x3F, 0x00, 0x00 },        /* 350   350      0.0   */
+       { 0xA, 0x4F, 0x36, 0x00, 0x09 },        /* 350   500      3.1   */
+       { 0xC, 0x60, 0x32, 0x00, 0x0D },        /* 350   700      6.0   */
+       { 0xC, 0x7F, 0x2D, 0x00, 0x12 },        /* 350   900      8.2   */
+       { 0xC, 0x47, 0x3F, 0x00, 0x00 },        /* 500   500      0.0   */
+       { 0xC, 0x6F, 0x36, 0x00, 0x09 },        /* 500   700      2.9   */
+       { 0x6, 0x7D, 0x32, 0x00, 0x0D },        /* 500   900      5.1   */
+       { 0x6, 0x60, 0x3C, 0x00, 0x03 },        /* 650   700      0.6   */
+       { 0x6, 0x7F, 0x34, 0x00, 0x0B },        /* 600   900      3.5   */
+       { 0x6, 0x7F, 0x3F, 0x00, 0x00 },        /* 900   900      0.0   */
+};
+
+/*
+ * Cloned the HOBL entry to comply with the voltage and pre-emphasis entries
+ * that DisplayPort specification requires
+ */
+static const struct cnl_ddi_buf_trans tgl_combo_phy_ddi_translations_edp_hbr2_hobl[] = {
+                                               /* VS   pre-emp */
+       { 0x6, 0x7F, 0x3F, 0x00, 0x00 },        /* 0    0       */
+       { 0x6, 0x7F, 0x3F, 0x00, 0x00 },        /* 0    1       */
+       { 0x6, 0x7F, 0x3F, 0x00, 0x00 },        /* 0    2       */
+       { 0x6, 0x7F, 0x3F, 0x00, 0x00 },        /* 0    3       */
+       { 0x6, 0x7F, 0x3F, 0x00, 0x00 },        /* 1    0       */
+       { 0x6, 0x7F, 0x3F, 0x00, 0x00 },        /* 1    1       */
+       { 0x6, 0x7F, 0x3F, 0x00, 0x00 },        /* 1    2       */
+       { 0x6, 0x7F, 0x3F, 0x00, 0x00 },        /* 2    0       */
+       { 0x6, 0x7F, 0x3F, 0x00, 0x00 },        /* 2    1       */
+};
+
+static bool is_hobl_buf_trans(const struct cnl_ddi_buf_trans *table)
+{
+       return table == tgl_combo_phy_ddi_translations_edp_hbr2_hobl;
+}
+
 static const struct ddi_buf_trans *
 bdw_get_buf_trans_edp(struct intel_encoder *encoder, int *n_entries)
 {
@@ -1050,9 +1086,26 @@ static const struct cnl_ddi_buf_trans *
 tgl_get_combo_buf_trans(struct intel_encoder *encoder, int type, int rate,
                        int *n_entries)
 {
+       struct drm_i915_private *dev_priv = to_i915(encoder->base.dev);
+
+       if (type == INTEL_OUTPUT_EDP && dev_priv->vbt.edp.hobl) {
+               struct intel_dp *intel_dp = enc_to_intel_dp(encoder);
+
+               if (!intel_dp->hobl_failed && rate <= 540000) {
+                       /* Same table applies to TGL, RKL and DG1 */
+                       *n_entries = ARRAY_SIZE(tgl_combo_phy_ddi_translations_edp_hbr2_hobl);
+                       return tgl_combo_phy_ddi_translations_edp_hbr2_hobl;
+               }
+       }
+
        if (type == INTEL_OUTPUT_HDMI || type == INTEL_OUTPUT_EDP) {
                return icl_get_combo_buf_trans(encoder, type, rate, n_entries);
        } else if (rate > 270000) {
+               if (IS_TGL_U(dev_priv) || IS_TGL_Y(dev_priv)) {
+                       *n_entries = ARRAY_SIZE(tgl_uy_combo_phy_ddi_translations_dp_hbr2);
+                       return tgl_uy_combo_phy_ddi_translations_dp_hbr2;
+               }
+
                *n_entries = ARRAY_SIZE(tgl_combo_phy_ddi_translations_dp_hbr2);
                return tgl_combo_phy_ddi_translations_dp_hbr2;
        }
@@ -2392,6 +2445,15 @@ static void icl_ddi_combo_vswing_program(struct intel_encoder *encoder,
                level = n_entries - 1;
        }
 
+       if (type == INTEL_OUTPUT_EDP) {
+               struct intel_dp *intel_dp = enc_to_intel_dp(encoder);
+
+               val = EDP4K2K_MODE_OVRD_EN | EDP4K2K_MODE_OVRD_OPTIMIZED;
+               intel_dp->hobl_active = is_hobl_buf_trans(ddi_translations);
+               intel_de_rmw(dev_priv, ICL_PORT_CL_DW10(phy), val,
+                            intel_dp->hobl_active ? val : 0);
+       }
+
        /* Set PORT_TX_DW5 */
        val = intel_de_read(dev_priv, ICL_PORT_TX_DW5_LN0(phy));
        val &= ~(SCALING_MODE_SEL_MASK | RTERM_SELECT_MASK |
@@ -2802,7 +2864,9 @@ hsw_set_signal_levels(struct intel_dp *intel_dp)
 static u32 icl_dpclka_cfgcr0_clk_off(struct drm_i915_private *dev_priv,
                                     enum phy phy)
 {
-       if (intel_phy_is_combo(dev_priv, phy)) {
+       if (IS_ROCKETLAKE(dev_priv)) {
+               return RKL_DPCLKA_CFGCR0_DDI_CLK_OFF(phy);
+       } else if (intel_phy_is_combo(dev_priv, phy)) {
                return ICL_DPCLKA_CFGCR0_DDI_CLK_OFF(phy);
        } else if (intel_phy_is_tc(dev_priv, phy)) {
                enum tc_port tc_port = intel_port_to_tc(dev_priv,
@@ -2829,6 +2893,16 @@ static void icl_map_plls_to_ports(struct intel_encoder *encoder,
                    (val & icl_dpclka_cfgcr0_clk_off(dev_priv, phy)) == 0);
 
        if (intel_phy_is_combo(dev_priv, phy)) {
+               u32 mask, sel;
+
+               if (IS_ROCKETLAKE(dev_priv)) {
+                       mask = RKL_DPCLKA_CFGCR0_DDI_CLK_SEL_MASK(phy);
+                       sel = RKL_DPCLKA_CFGCR0_DDI_CLK_SEL(pll->info->id, phy);
+               } else {
+                       mask = ICL_DPCLKA_CFGCR0_DDI_CLK_SEL_MASK(phy);
+                       sel = ICL_DPCLKA_CFGCR0_DDI_CLK_SEL(pll->info->id, phy);
+               }
+
                /*
                 * Even though this register references DDIs, note that we
                 * want to pass the PHY rather than the port (DDI).  For
@@ -2839,8 +2913,8 @@ static void icl_map_plls_to_ports(struct intel_encoder *encoder,
                 *   Clock Select chooses the PLL for both DDIA and DDID and
                 *   drives port A in all cases."
                 */
-               val &= ~ICL_DPCLKA_CFGCR0_DDI_CLK_SEL_MASK(phy);
-               val |= ICL_DPCLKA_CFGCR0_DDI_CLK_SEL(pll->info->id, phy);
+               val &= ~mask;
+               val |= sel;
                intel_de_write(dev_priv, ICL_DPCLKA_CFGCR0, val);
                intel_de_posting_read(dev_priv, ICL_DPCLKA_CFGCR0);
        }
@@ -4037,8 +4111,7 @@ static void intel_ddi_prepare_link_retrain(struct intel_dp *intel_dp)
                        intel_wait_ddi_buf_idle(dev_priv, port);
        }
 
-       dp_tp_ctl = DP_TP_CTL_ENABLE |
-                   DP_TP_CTL_LINK_TRAIN_PAT1 | DP_TP_CTL_SCRAMBLE_DISABLE;
+       dp_tp_ctl = DP_TP_CTL_ENABLE | DP_TP_CTL_LINK_TRAIN_PAT1;
        if (intel_dp->link_mst)
                dp_tp_ctl |= DP_TP_CTL_MODE_MST;
        else {
@@ -4061,16 +4134,10 @@ static void intel_ddi_set_link_train(struct intel_dp *intel_dp,
 {
        struct drm_i915_private *dev_priv = dp_to_i915(intel_dp);
        u8 train_pat_mask = drm_dp_training_pattern_mask(intel_dp->dpcd);
-       enum port port = dp_to_dig_port(intel_dp)->base.port;
        u32 temp;
 
        temp = intel_de_read(dev_priv, intel_dp->regs.dp_tp_ctl);
 
-       if (dp_train_pat & DP_LINK_SCRAMBLING_DISABLE)
-               temp |= DP_TP_CTL_SCRAMBLE_DISABLE;
-       else
-               temp &= ~DP_TP_CTL_SCRAMBLE_DISABLE;
-
        temp &= ~DP_TP_CTL_LINK_TRAIN_MASK;
        switch (dp_train_pat & train_pat_mask) {
        case DP_TRAINING_PATTERN_DISABLE:
@@ -4091,9 +4158,6 @@ static void intel_ddi_set_link_train(struct intel_dp *intel_dp,
        }
 
        intel_de_write(dev_priv, intel_dp->regs.dp_tp_ctl, temp);
-
-       intel_de_write(dev_priv, DDI_BUF_CTL(port), intel_dp->DP);
-       intel_de_posting_read(dev_priv, DDI_BUF_CTL(port));
 }
 
 static void intel_ddi_set_idle_link_train(struct intel_dp *intel_dp)
@@ -4878,6 +4942,13 @@ intel_ddi_max_lanes(struct intel_digital_port *dig_port)
        return max_lanes;
 }
 
+static bool hti_uses_phy(struct drm_i915_private *i915, enum phy phy)
+{
+       return i915->hti_state & HDPORT_ENABLED &&
+               (i915->hti_state & HDPORT_PHY_USED_DP(phy) ||
+                i915->hti_state & HDPORT_PHY_USED_HDMI(phy));
+}
+
 void intel_ddi_init(struct drm_i915_private *dev_priv, enum port port)
 {
        struct intel_digital_port *dig_port;
@@ -4885,6 +4956,18 @@ void intel_ddi_init(struct drm_i915_private *dev_priv, enum port port)
        bool init_hdmi, init_dp, init_lspcon = false;
        enum phy phy = intel_port_to_phy(dev_priv, port);
 
+       /*
+        * On platforms with HTI (aka HDPORT), if it's enabled at boot it may
+        * have taken over some of the PHYs and made them unavailable to the
+        * driver.  In that case we should skip initializing the corresponding
+        * outputs.
+        */
+       if (hti_uses_phy(dev_priv, phy)) {
+               drm_dbg_kms(&dev_priv->drm, "PORT %c / PHY %c reserved by HTI\n",
+                           port_name(port), phy_name(phy));
+               return;
+       }
+
        init_hdmi = intel_bios_port_supports_dvi(dev_priv, port) ||
                intel_bios_port_supports_hdmi(dev_priv, port);
        init_dp = intel_bios_port_supports_dp(dev_priv, port);