drm/tegra: sor: Split out tegra_sor_apply_config()
authorThierry Reding <treding@nvidia.com>
Tue, 21 Jul 2015 14:48:19 +0000 (16:48 +0200)
committerThierry Reding <treding@nvidia.com>
Fri, 1 Jul 2016 12:42:07 +0000 (14:42 +0200)
This function is useful in both eDP and DP modes, so split it out in
anticipation of adding DP support.

Signed-off-by: Thierry Reding <treding@nvidia.com>
drivers/gpu/drm/tegra/sor.c

index fb536c1..5d9a9f2 100644 (file)
@@ -678,6 +678,46 @@ static int tegra_sor_compute_config(struct tegra_sor *sor,
        return 0;
 }
 
+static void tegra_sor_apply_config(struct tegra_sor *sor,
+                                  const struct tegra_sor_config *config)
+{
+       u32 value;
+
+       value = tegra_sor_readl(sor, SOR_DP_LINKCTL0);
+       value &= ~SOR_DP_LINKCTL_TU_SIZE_MASK;
+       value |= SOR_DP_LINKCTL_TU_SIZE(config->tu_size);
+       tegra_sor_writel(sor, value, SOR_DP_LINKCTL0);
+
+       value = tegra_sor_readl(sor, SOR_DP_CONFIG0);
+       value &= ~SOR_DP_CONFIG_WATERMARK_MASK;
+       value |= SOR_DP_CONFIG_WATERMARK(config->watermark);
+
+       value &= ~SOR_DP_CONFIG_ACTIVE_SYM_COUNT_MASK;
+       value |= SOR_DP_CONFIG_ACTIVE_SYM_COUNT(config->active_count);
+
+       value &= ~SOR_DP_CONFIG_ACTIVE_SYM_FRAC_MASK;
+       value |= SOR_DP_CONFIG_ACTIVE_SYM_FRAC(config->active_frac);
+
+       if (config->active_polarity)
+               value |= SOR_DP_CONFIG_ACTIVE_SYM_POLARITY;
+       else
+               value &= ~SOR_DP_CONFIG_ACTIVE_SYM_POLARITY;
+
+       value |= SOR_DP_CONFIG_ACTIVE_SYM_ENABLE;
+       value |= SOR_DP_CONFIG_DISPARITY_NEGATIVE;
+       tegra_sor_writel(sor, value, SOR_DP_CONFIG0);
+
+       value = tegra_sor_readl(sor, SOR_DP_AUDIO_HBLANK_SYMBOLS);
+       value &= ~SOR_DP_AUDIO_HBLANK_SYMBOLS_MASK;
+       value |= config->hblank_symbols & 0xffff;
+       tegra_sor_writel(sor, value, SOR_DP_AUDIO_HBLANK_SYMBOLS);
+
+       value = tegra_sor_readl(sor, SOR_DP_AUDIO_VBLANK_SYMBOLS);
+       value &= ~SOR_DP_AUDIO_VBLANK_SYMBOLS_MASK;
+       value |= config->vblank_symbols & 0xffff;
+       tegra_sor_writel(sor, value, SOR_DP_AUDIO_VBLANK_SYMBOLS);
+}
+
 static int tegra_sor_detach(struct tegra_sor *sor)
 {
        unsigned long value, timeout;
@@ -1393,13 +1433,11 @@ static void tegra_sor_edp_enable(struct drm_encoder *encoder)
        value |= drm_dp_link_rate_to_bw_code(link.rate) << 2;
        tegra_sor_writel(sor, value, SOR_CLK_CNTRL);
 
-       /* set linkctl */
+       tegra_sor_apply_config(sor, &config);
+
+       /* enable link */
        value = tegra_sor_readl(sor, SOR_DP_LINKCTL0);
        value |= SOR_DP_LINKCTL_ENABLE;
-
-       value &= ~SOR_DP_LINKCTL_TU_SIZE_MASK;
-       value |= SOR_DP_LINKCTL_TU_SIZE(config.tu_size);
-
        value |= SOR_DP_LINKCTL_ENHANCED_FRAME;
        tegra_sor_writel(sor, value, SOR_DP_LINKCTL0);
 
@@ -1412,35 +1450,6 @@ static void tegra_sor_edp_enable(struct drm_encoder *encoder)
 
        tegra_sor_writel(sor, value, SOR_DP_TPG);
 
-       value = tegra_sor_readl(sor, SOR_DP_CONFIG0);
-       value &= ~SOR_DP_CONFIG_WATERMARK_MASK;
-       value |= SOR_DP_CONFIG_WATERMARK(config.watermark);
-
-       value &= ~SOR_DP_CONFIG_ACTIVE_SYM_COUNT_MASK;
-       value |= SOR_DP_CONFIG_ACTIVE_SYM_COUNT(config.active_count);
-
-       value &= ~SOR_DP_CONFIG_ACTIVE_SYM_FRAC_MASK;
-       value |= SOR_DP_CONFIG_ACTIVE_SYM_FRAC(config.active_frac);
-
-       if (config.active_polarity)
-               value |= SOR_DP_CONFIG_ACTIVE_SYM_POLARITY;
-       else
-               value &= ~SOR_DP_CONFIG_ACTIVE_SYM_POLARITY;
-
-       value |= SOR_DP_CONFIG_ACTIVE_SYM_ENABLE;
-       value |= SOR_DP_CONFIG_DISPARITY_NEGATIVE;
-       tegra_sor_writel(sor, value, SOR_DP_CONFIG0);
-
-       value = tegra_sor_readl(sor, SOR_DP_AUDIO_HBLANK_SYMBOLS);
-       value &= ~SOR_DP_AUDIO_HBLANK_SYMBOLS_MASK;
-       value |= config.hblank_symbols & 0xffff;
-       tegra_sor_writel(sor, value, SOR_DP_AUDIO_HBLANK_SYMBOLS);
-
-       value = tegra_sor_readl(sor, SOR_DP_AUDIO_VBLANK_SYMBOLS);
-       value &= ~SOR_DP_AUDIO_VBLANK_SYMBOLS_MASK;
-       value |= config.vblank_symbols & 0xffff;
-       tegra_sor_writel(sor, value, SOR_DP_AUDIO_VBLANK_SYMBOLS);
-
        /* enable pad calibration logic */
        value = tegra_sor_readl(sor, SOR_DP_PADCTL0);
        value |= SOR_DP_PADCTL_PAD_CAL_PD;