Re: [Intel-gfx] [PATCH 08/11] drm/i915: migrate hsw fdi code to new file.

2020-12-16 Thread Jani Nikula
On Fri, 11 Dec 2020, Dave Airlie  wrote:
> From: Dave Airlie 
>
> Daniel asked for this, but it's a bit messy and I'm not sure
> how best to clean it up yet.

Cleaned it up some locally by moving both hsw and bdw buf trans tables
to intel_fdi.c, and adding a function to get them.

Surely this could be improved further, but I think it's forward
progress.

BR,
Jani.


>
> Signed-off-by: Dave Airlie 
> ---
>  drivers/gpu/drm/i915/display/intel_crt.c |   1 +
>  drivers/gpu/drm/i915/display/intel_ddi.c | 151 +--
>  drivers/gpu/drm/i915/display/intel_ddi.h |  14 ++-
>  drivers/gpu/drm/i915/display/intel_fdi.c | 147 ++
>  drivers/gpu/drm/i915/display/intel_fdi.h |   3 +
>  5 files changed, 168 insertions(+), 148 deletions(-)
>
> diff --git a/drivers/gpu/drm/i915/display/intel_crt.c 
> b/drivers/gpu/drm/i915/display/intel_crt.c
> index 4934edd51cb0..077ebc7e6396 100644
> --- a/drivers/gpu/drm/i915/display/intel_crt.c
> +++ b/drivers/gpu/drm/i915/display/intel_crt.c
> @@ -38,6 +38,7 @@
>  #include "intel_crt.h"
>  #include "intel_ddi.h"
>  #include "intel_display_types.h"
> +#include "intel_fdi.h"
>  #include "intel_fifo_underrun.h"
>  #include "intel_gmbus.h"
>  #include "intel_hotplug.h"
> diff --git a/drivers/gpu/drm/i915/display/intel_ddi.c 
> b/drivers/gpu/drm/i915/display/intel_ddi.c
> index 6863236df1d0..2d903962f9dd 100644
> --- a/drivers/gpu/drm/i915/display/intel_ddi.c
> +++ b/drivers/gpu/drm/i915/display/intel_ddi.c
> @@ -51,12 +51,6 @@
>  #include "intel_tc.h"
>  #include "intel_vdsc.h"
>  
> -struct ddi_buf_trans {
> - u32 trans1; /* balance leg enable, de-emph level */
> - u32 trans2; /* vref sel, vswing */
> - u8 i_boost; /* SKL: I_boost; valid: 0x0, 0x1, 0x3, 0x7 */
> -};
> -
>  static const u8 index_to_dp_signal_levels[] = {
>   [0] = DP_TRAIN_VOLTAGE_SWING_LEVEL_0 | DP_TRAIN_PRE_EMPH_LEVEL_0,
>   [1] = DP_TRAIN_VOLTAGE_SWING_LEVEL_0 | DP_TRAIN_PRE_EMPH_LEVEL_1,
> @@ -1398,8 +1392,8 @@ static int intel_ddi_hdmi_level(struct intel_encoder 
> *encoder,
>   * values in advance. This function programs the correct values for
>   * DP/eDP/FDI use cases.
>   */
> -static void intel_prepare_dp_ddi_buffers(struct intel_encoder *encoder,
> -  const struct intel_crtc_state 
> *crtc_state)
> +void intel_prepare_dp_ddi_buffers(struct intel_encoder *encoder,
> +   const struct intel_crtc_state *crtc_state)
>  {
>   struct drm_i915_private *dev_priv = to_i915(encoder->base.dev);
>   u32 iboost_bit = 0;
> @@ -1461,8 +1455,8 @@ static void intel_prepare_hdmi_ddi_buffers(struct 
> intel_encoder *encoder,
>  ddi_translations[level].trans2);
>  }
>  
> -static void intel_wait_ddi_buf_idle(struct drm_i915_private *dev_priv,
> - enum port port)
> +void intel_wait_ddi_buf_idle(struct drm_i915_private *dev_priv,
> +  enum port port)
>  {
>   if (IS_BROXTON(dev_priv)) {
>   udelay(16);
> @@ -1490,7 +1484,7 @@ static void intel_wait_ddi_buf_active(struct 
> drm_i915_private *dev_priv,
>   port_name(port));
>  }
>  
> -static u32 hsw_pll_to_ddi_pll_sel(const struct intel_shared_dpll *pll)
> +u32 hsw_pll_to_ddi_pll_sel(const struct intel_shared_dpll *pll)
>  {
>   switch (pll->info->id) {
>   case DPLL_ID_WRPLL1:
> @@ -1550,141 +1544,6 @@ static u32 icl_pll_to_ddi_clk_sel(struct 
> intel_encoder *encoder,
>   }
>  }
>  
> -/* Starting with Haswell, different DDI ports can work in FDI mode for
> - * connection to the PCH-located connectors. For this, it is necessary to 
> train
> - * both the DDI port and PCH receiver for the desired DDI buffer settings.
> - *
> - * The recommended port to work in FDI mode is DDI E, which we use here. 
> Also,
> - * please note that when FDI mode is active on DDI E, it shares 2 lines with
> - * DDI A (which is used for eDP)
> - */
> -
> -void hsw_fdi_link_train(struct intel_encoder *encoder,
> - const struct intel_crtc_state *crtc_state)
> -{
> - struct intel_crtc *crtc = to_intel_crtc(crtc_state->uapi.crtc);
> - struct drm_i915_private *dev_priv = to_i915(crtc->base.dev);
> - u32 temp, i, rx_ctl_val, ddi_pll_sel;
> -
> - intel_prepare_dp_ddi_buffers(encoder, crtc_state);
> -
> - /* Set the FDI_RX_MISC pwrdn lanes and the 2 workarounds listed at the
> -  * mode set "sequence for CRT port" document:
> -  * - TP1 to TP2 time with the default value
> -  * - FDI delay to 90h
> -  *
> -  * WaFDIAutoLinkSetTimingOverrride:hsw
> -  */
> - intel_de_write(dev_priv, FDI_RX_MISC(PIPE_A),
> -FDI_RX_PWRDN_LANE1_VAL(2) | FDI_RX_PWRDN_LANE0_VAL(2) | 
> FDI_RX_TP1_TO_TP2_48 | FDI_RX_FDI_DELAY_90);
> -
> - /* Enable the PCH Receiver FDI PLL */
> - rx_ctl_val = dev_priv->fdi_rx_config | FDI_RX_ENHANCE_FRAME_ENABLE |
> -  FDI_RX_PLL_ENABLE

[Intel-gfx] [PATCH 08/11] drm/i915: migrate hsw fdi code to new file.

2020-12-10 Thread Dave Airlie
From: Dave Airlie 

Daniel asked for this, but it's a bit messy and I'm not sure
how best to clean it up yet.

Signed-off-by: Dave Airlie 
---
 drivers/gpu/drm/i915/display/intel_crt.c |   1 +
 drivers/gpu/drm/i915/display/intel_ddi.c | 151 +--
 drivers/gpu/drm/i915/display/intel_ddi.h |  14 ++-
 drivers/gpu/drm/i915/display/intel_fdi.c | 147 ++
 drivers/gpu/drm/i915/display/intel_fdi.h |   3 +
 5 files changed, 168 insertions(+), 148 deletions(-)

diff --git a/drivers/gpu/drm/i915/display/intel_crt.c 
b/drivers/gpu/drm/i915/display/intel_crt.c
index 4934edd51cb0..077ebc7e6396 100644
--- a/drivers/gpu/drm/i915/display/intel_crt.c
+++ b/drivers/gpu/drm/i915/display/intel_crt.c
@@ -38,6 +38,7 @@
 #include "intel_crt.h"
 #include "intel_ddi.h"
 #include "intel_display_types.h"
+#include "intel_fdi.h"
 #include "intel_fifo_underrun.h"
 #include "intel_gmbus.h"
 #include "intel_hotplug.h"
diff --git a/drivers/gpu/drm/i915/display/intel_ddi.c 
b/drivers/gpu/drm/i915/display/intel_ddi.c
index 6863236df1d0..2d903962f9dd 100644
--- a/drivers/gpu/drm/i915/display/intel_ddi.c
+++ b/drivers/gpu/drm/i915/display/intel_ddi.c
@@ -51,12 +51,6 @@
 #include "intel_tc.h"
 #include "intel_vdsc.h"
 
-struct ddi_buf_trans {
-   u32 trans1; /* balance leg enable, de-emph level */
-   u32 trans2; /* vref sel, vswing */
-   u8 i_boost; /* SKL: I_boost; valid: 0x0, 0x1, 0x3, 0x7 */
-};
-
 static const u8 index_to_dp_signal_levels[] = {
[0] = DP_TRAIN_VOLTAGE_SWING_LEVEL_0 | DP_TRAIN_PRE_EMPH_LEVEL_0,
[1] = DP_TRAIN_VOLTAGE_SWING_LEVEL_0 | DP_TRAIN_PRE_EMPH_LEVEL_1,
@@ -1398,8 +1392,8 @@ static int intel_ddi_hdmi_level(struct intel_encoder 
*encoder,
  * values in advance. This function programs the correct values for
  * DP/eDP/FDI use cases.
  */
-static void intel_prepare_dp_ddi_buffers(struct intel_encoder *encoder,
-const struct intel_crtc_state 
*crtc_state)
+void intel_prepare_dp_ddi_buffers(struct intel_encoder *encoder,
+ const struct intel_crtc_state *crtc_state)
 {
struct drm_i915_private *dev_priv = to_i915(encoder->base.dev);
u32 iboost_bit = 0;
@@ -1461,8 +1455,8 @@ static void intel_prepare_hdmi_ddi_buffers(struct 
intel_encoder *encoder,
   ddi_translations[level].trans2);
 }
 
-static void intel_wait_ddi_buf_idle(struct drm_i915_private *dev_priv,
-   enum port port)
+void intel_wait_ddi_buf_idle(struct drm_i915_private *dev_priv,
+enum port port)
 {
if (IS_BROXTON(dev_priv)) {
udelay(16);
@@ -1490,7 +1484,7 @@ static void intel_wait_ddi_buf_active(struct 
drm_i915_private *dev_priv,
port_name(port));
 }
 
-static u32 hsw_pll_to_ddi_pll_sel(const struct intel_shared_dpll *pll)
+u32 hsw_pll_to_ddi_pll_sel(const struct intel_shared_dpll *pll)
 {
switch (pll->info->id) {
case DPLL_ID_WRPLL1:
@@ -1550,141 +1544,6 @@ static u32 icl_pll_to_ddi_clk_sel(struct intel_encoder 
*encoder,
}
 }
 
-/* Starting with Haswell, different DDI ports can work in FDI mode for
- * connection to the PCH-located connectors. For this, it is necessary to train
- * both the DDI port and PCH receiver for the desired DDI buffer settings.
- *
- * The recommended port to work in FDI mode is DDI E, which we use here. Also,
- * please note that when FDI mode is active on DDI E, it shares 2 lines with
- * DDI A (which is used for eDP)
- */
-
-void hsw_fdi_link_train(struct intel_encoder *encoder,
-   const struct intel_crtc_state *crtc_state)
-{
-   struct intel_crtc *crtc = to_intel_crtc(crtc_state->uapi.crtc);
-   struct drm_i915_private *dev_priv = to_i915(crtc->base.dev);
-   u32 temp, i, rx_ctl_val, ddi_pll_sel;
-
-   intel_prepare_dp_ddi_buffers(encoder, crtc_state);
-
-   /* Set the FDI_RX_MISC pwrdn lanes and the 2 workarounds listed at the
-* mode set "sequence for CRT port" document:
-* - TP1 to TP2 time with the default value
-* - FDI delay to 90h
-*
-* WaFDIAutoLinkSetTimingOverrride:hsw
-*/
-   intel_de_write(dev_priv, FDI_RX_MISC(PIPE_A),
-  FDI_RX_PWRDN_LANE1_VAL(2) | FDI_RX_PWRDN_LANE0_VAL(2) | 
FDI_RX_TP1_TO_TP2_48 | FDI_RX_FDI_DELAY_90);
-
-   /* Enable the PCH Receiver FDI PLL */
-   rx_ctl_val = dev_priv->fdi_rx_config | FDI_RX_ENHANCE_FRAME_ENABLE |
-FDI_RX_PLL_ENABLE |
-FDI_DP_PORT_WIDTH(crtc_state->fdi_lanes);
-   intel_de_write(dev_priv, FDI_RX_CTL(PIPE_A), rx_ctl_val);
-   intel_de_posting_read(dev_priv, FDI_RX_CTL(PIPE_A));
-   udelay(220);
-
-   /* Switch from Rawclk to PCDclk */
-   rx_ctl_val |= FDI_PCDCLK;
-   intel_de_write(dev_priv, FDI_RX_CTL(PIPE_A), rx_ctl_val);
-
-   /* Configure Port Clock Select */
-   ddi_pll_