drm/i915/xe2lpd: Re-order DP AUX regs
authorLucas De Marchi <lucas.demarchi@intel.com>
Tue, 19 Sep 2023 19:21:18 +0000 (12:21 -0700)
committerLucas De Marchi <lucas.demarchi@intel.com>
Thu, 21 Sep 2023 15:18:02 +0000 (08:18 -0700)
The address of CTL and DATA registers for DP AUX were changed in Xe2_LPD:
now they are all in a single range, with CH_A and CH_B coming right after
the USBC instances. Like was done when moving registers to PICA, use
a helper macro to remap the ch passed to an index that can be used to
calculate the right offset.

Signed-off-by: Lucas De Marchi <lucas.demarchi@intel.com>
Reviewed-by: Matt Roper <matthew.d.roper@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20230919192128.2045154-12-lucas.demarchi@intel.com
drivers/gpu/drm/i915/display/intel_display_power_well.c
drivers/gpu/drm/i915/display/intel_dp_aux.c
drivers/gpu/drm/i915/display/intel_dp_aux_regs.h

index 820b7d4..ca0714e 100644 (file)
@@ -1800,7 +1800,7 @@ static void xelpdp_aux_power_well_enable(struct drm_i915_private *dev_priv,
                icl_tc_port_assert_ref_held(dev_priv, power_well,
                                            aux_ch_to_digital_port(dev_priv, aux_ch));
 
-       intel_de_rmw(dev_priv, XELPDP_DP_AUX_CH_CTL(aux_ch),
+       intel_de_rmw(dev_priv, XELPDP_DP_AUX_CH_CTL(dev_priv, aux_ch),
                     XELPDP_DP_AUX_CH_CTL_POWER_REQUEST,
                     XELPDP_DP_AUX_CH_CTL_POWER_REQUEST);
 
@@ -1818,7 +1818,7 @@ static void xelpdp_aux_power_well_disable(struct drm_i915_private *dev_priv,
 {
        enum aux_ch aux_ch = i915_power_well_instance(power_well)->xelpdp.aux_ch;
 
-       intel_de_rmw(dev_priv, XELPDP_DP_AUX_CH_CTL(aux_ch),
+       intel_de_rmw(dev_priv, XELPDP_DP_AUX_CH_CTL(dev_priv, aux_ch),
                     XELPDP_DP_AUX_CH_CTL_POWER_REQUEST,
                     0);
        usleep_range(10, 30);
@@ -1829,7 +1829,7 @@ static bool xelpdp_aux_power_well_enabled(struct drm_i915_private *dev_priv,
 {
        enum aux_ch aux_ch = i915_power_well_instance(power_well)->xelpdp.aux_ch;
 
-       return intel_de_read(dev_priv, XELPDP_DP_AUX_CH_CTL(aux_ch)) &
+       return intel_de_read(dev_priv, XELPDP_DP_AUX_CH_CTL(dev_priv, aux_ch)) &
                XELPDP_DP_AUX_CH_CTL_POWER_STATUS;
 }
 
index 2d173bd..b90cad7 100644 (file)
@@ -687,10 +687,10 @@ static i915_reg_t xelpdp_aux_ctl_reg(struct intel_dp *intel_dp)
        case AUX_CH_USBC2:
        case AUX_CH_USBC3:
        case AUX_CH_USBC4:
-               return XELPDP_DP_AUX_CH_CTL(aux_ch);
+               return XELPDP_DP_AUX_CH_CTL(dev_priv, aux_ch);
        default:
                MISSING_CASE(aux_ch);
-               return XELPDP_DP_AUX_CH_CTL(AUX_CH_A);
+               return XELPDP_DP_AUX_CH_CTL(dev_priv, AUX_CH_A);
        }
 }
 
@@ -707,10 +707,10 @@ static i915_reg_t xelpdp_aux_data_reg(struct intel_dp *intel_dp, int index)
        case AUX_CH_USBC2:
        case AUX_CH_USBC3:
        case AUX_CH_USBC4:
-               return XELPDP_DP_AUX_CH_DATA(aux_ch, index);
+               return XELPDP_DP_AUX_CH_DATA(dev_priv, aux_ch, index);
        default:
                MISSING_CASE(aux_ch);
-               return XELPDP_DP_AUX_CH_DATA(AUX_CH_A, index);
+               return XELPDP_DP_AUX_CH_DATA(dev_priv, AUX_CH_A, index);
        }
 }
 
index 1e9e018..844369f 100644 (file)
  * registers
  */
 
+/*
+ * Wrapper macro to convert from aux_ch to the index used in some of the
+ * registers.
+ */
+#define __xe2lpd_aux_ch_idx(aux_ch)                                            \
+       (aux_ch >= AUX_CH_USBC1 ? aux_ch : AUX_CH_USBC4 + 1 + (aux_ch) - AUX_CH_A)
+
 /* TODO: Remove implicit dev_priv */
 #define _DPA_AUX_CH_CTL                        (DISPLAY_MMIO_BASE(dev_priv) + 0x64010)
 #define _DPB_AUX_CH_CTL                        (DISPLAY_MMIO_BASE(dev_priv) + 0x64110)
 #define _XELPDP_USBC2_AUX_CH_CTL       0x16f410
 #define DP_AUX_CH_CTL(aux_ch)          _MMIO_PORT(aux_ch, _DPA_AUX_CH_CTL,     \
                                                   _DPB_AUX_CH_CTL)
-#define XELPDP_DP_AUX_CH_CTL(aux_ch)                                           \
+#define _XELPDP_DP_AUX_CH_CTL(aux_ch)                                          \
                _MMIO(_PICK_EVEN_2RANGES(aux_ch, AUX_CH_USBC1,                  \
                                         _DPA_AUX_CH_CTL, _DPB_AUX_CH_CTL,      \
                                         _XELPDP_USBC1_AUX_CH_CTL,              \
                                         _XELPDP_USBC2_AUX_CH_CTL))
+#define XELPDP_DP_AUX_CH_CTL(i915__, aux_ch)                                   \
+               (DISPLAY_VER(i915__) >= 20 ?                                    \
+                _XELPDP_DP_AUX_CH_CTL(__xe2lpd_aux_ch_idx(aux_ch)) :           \
+                _XELPDP_DP_AUX_CH_CTL(aux_ch))
 #define   DP_AUX_CH_CTL_SEND_BUSY              REG_BIT(31)
 #define   DP_AUX_CH_CTL_DONE                   REG_BIT(30)
 #define   DP_AUX_CH_CTL_INTERRUPT              REG_BIT(29)
 #define _XELPDP_USBC2_AUX_CH_DATA1     0x16f414
 #define DP_AUX_CH_DATA(aux_ch, i)      _MMIO(_PORT(aux_ch, _DPA_AUX_CH_DATA1,  \
                                                    _DPB_AUX_CH_DATA1) + (i) * 4) /* 5 registers */
-#define XELPDP_DP_AUX_CH_DATA(aux_ch, i)                                       \
+#define _XELPDP_DP_AUX_CH_DATA(aux_ch, i)                                      \
                _MMIO(_PICK_EVEN_2RANGES(aux_ch, AUX_CH_USBC1,                  \
                                         _DPA_AUX_CH_DATA1, _DPB_AUX_CH_DATA1,  \
                                         _XELPDP_USBC1_AUX_CH_DATA1,            \
                                         _XELPDP_USBC2_AUX_CH_DATA1) + (i) * 4) /* 5 registers */
+#define XELPDP_DP_AUX_CH_DATA(i915__, aux_ch, i)                               \
+               (DISPLAY_VER(i915__) >= 20 ?                                    \
+                _XELPDP_DP_AUX_CH_DATA(__xe2lpd_aux_ch_idx(aux_ch), i) :       \
+                _XELPDP_DP_AUX_CH_DATA(aux_ch, i))
 
 #endif /* __INTEL_DP_AUX_REGS_H__ */