drm/i915: Clean up eDP PLL state asserts
authorVille Syrjälä <ville.syrjala@linux.intel.com>
Thu, 29 Oct 2015 19:26:01 +0000 (21:26 +0200)
committerVille Syrjälä <ville.syrjala@linux.intel.com>
Tue, 10 Nov 2015 14:23:58 +0000 (16:23 +0200)
Rewrite the eDP PLL state asserts to conform to our usual state assert
style.

Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Link: http://patchwork.freedesktop.org/patch/msgid/1446146763-31821-13-git-send-email-ville.syrjala@linux.intel.com
Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>
drivers/gpu/drm/i915/intel_dp.c

index 52a3e3d42a3ce0f275ed1b8e0b92f01ffbe0f472..019283f439513cb0f1765aab72ba15b028d81b30 100644 (file)
@@ -2145,21 +2145,48 @@ static void intel_edp_backlight_power(struct intel_connector *connector,
                _intel_edp_backlight_off(intel_dp);
 }
 
+static const char *state_string(bool enabled)
+{
+       return enabled ? "on" : "off";
+}
+
+static void assert_dp_port(struct intel_dp *intel_dp, bool state)
+{
+       struct intel_digital_port *dig_port = dp_to_dig_port(intel_dp);
+       struct drm_i915_private *dev_priv = to_i915(dig_port->base.base.dev);
+       bool cur_state = I915_READ(intel_dp->output_reg) & DP_PORT_EN;
+
+       I915_STATE_WARN(cur_state != state,
+                       "DP port %c state assertion failure (expected %s, current %s)\n",
+                       port_name(dig_port->port),
+                       state_string(state), state_string(cur_state));
+}
+#define assert_dp_port_disabled(d) assert_dp_port((d), false)
+
+static void assert_edp_pll(struct drm_i915_private *dev_priv, bool state)
+{
+       bool cur_state = I915_READ(DP_A) & DP_PLL_ENABLE;
+
+       I915_STATE_WARN(cur_state != state,
+                       "eDP PLL state assertion failure (expected %s, current %s)\n",
+                       state_string(state), state_string(cur_state));
+}
+#define assert_edp_pll_enabled(d) assert_edp_pll((d), true)
+#define assert_edp_pll_disabled(d) assert_edp_pll((d), false)
+
 static void ironlake_edp_pll_on(struct intel_dp *intel_dp)
 {
        struct intel_digital_port *intel_dig_port = dp_to_dig_port(intel_dp);
-       struct drm_crtc *crtc = intel_dig_port->base.base.crtc;
-       struct drm_device *dev = crtc->dev;
-       struct drm_i915_private *dev_priv = dev->dev_private;
+       struct intel_crtc *crtc = to_intel_crtc(intel_dig_port->base.base.crtc);
+       struct drm_i915_private *dev_priv = to_i915(crtc->base.dev);
        u32 dpa_ctl;
 
-       assert_pipe_disabled(dev_priv,
-                            to_intel_crtc(crtc)->pipe);
+       assert_pipe_disabled(dev_priv, crtc->pipe);
+       assert_dp_port_disabled(intel_dp);
+       assert_edp_pll_disabled(dev_priv);
 
        DRM_DEBUG_KMS("\n");
        dpa_ctl = I915_READ(DP_A);
-       WARN(dpa_ctl & DP_PLL_ENABLE, "dp pll on, should be off\n");
-       WARN(dpa_ctl & DP_PORT_EN, "dp port still on, should be off\n");
 
        /* We don't adjust intel_dp->DP while tearing down the link, to
         * facilitate link retraining (e.g. after hotplug). Hence clear all
@@ -2174,18 +2201,15 @@ static void ironlake_edp_pll_on(struct intel_dp *intel_dp)
 static void ironlake_edp_pll_off(struct intel_dp *intel_dp)
 {
        struct intel_digital_port *intel_dig_port = dp_to_dig_port(intel_dp);
-       struct drm_crtc *crtc = intel_dig_port->base.base.crtc;
-       struct drm_device *dev = crtc->dev;
-       struct drm_i915_private *dev_priv = dev->dev_private;
+       struct intel_crtc *crtc = to_intel_crtc(intel_dig_port->base.base.crtc);
+       struct drm_i915_private *dev_priv = to_i915(crtc->base.dev);
        u32 dpa_ctl;
 
-       assert_pipe_disabled(dev_priv,
-                            to_intel_crtc(crtc)->pipe);
+       assert_pipe_disabled(dev_priv, crtc->pipe);
+       assert_dp_port_disabled(intel_dp);
+       assert_edp_pll_enabled(dev_priv);
 
        dpa_ctl = I915_READ(DP_A);
-       WARN((dpa_ctl & DP_PLL_ENABLE) == 0,
-            "dp pll off, should be on\n");
-       WARN(dpa_ctl & DP_PORT_EN, "dp port still on, should be off\n");
 
        /* We can't rely on the value tracked for the DP register in
         * intel_dp->DP because link_down must not change that (otherwise link