| /* |
| * Copyright © 2008 Intel Corporation |
| * |
| * Permission is hereby granted, free of charge, to any person obtaining a |
| * copy of this software and associated documentation files (the "Software"), |
| * to deal in the Software without restriction, including without limitation |
| * the rights to use, copy, modify, merge, publish, distribute, sublicense, |
| * and/or sell copies of the Software, and to permit persons to whom the |
| * Software is furnished to do so, subject to the following conditions: |
| * |
| * The above copyright notice and this permission notice (including the next |
| * paragraph) shall be included in all copies or substantial portions of the |
| * Software. |
| * |
| * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
| * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
| * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS |
| * IN THE SOFTWARE. |
| * |
| * Authors: |
| * Keith Packard <keithp@keithp.com> |
| * |
| */ |
| |
| #include <linux/i2c.h> |
| #include <linux/slab.h> |
| #include <linux/export.h> |
| #include <linux/types.h> |
| #include <linux/notifier.h> |
| #include <linux/reboot.h> |
| #include <asm/byteorder.h> |
| #include <drm/drmP.h> |
| #include <drm/drm_atomic_helper.h> |
| #include <drm/drm_crtc.h> |
| #include <drm/drm_crtc_helper.h> |
| #include <drm/drm_edid.h> |
| #include "intel_drv.h" |
| #include <drm/i915_drm.h> |
| #include "i915_drv.h" |
| |
| #define DP_LINK_CHECK_TIMEOUT (10 * 1000) |
| |
| /* Compliance test status bits */ |
| #define INTEL_DP_RESOLUTION_SHIFT_MASK 0 |
| #define INTEL_DP_RESOLUTION_PREFERRED (1 << INTEL_DP_RESOLUTION_SHIFT_MASK) |
| #define INTEL_DP_RESOLUTION_STANDARD (2 << INTEL_DP_RESOLUTION_SHIFT_MASK) |
| #define INTEL_DP_RESOLUTION_FAILSAFE (3 << INTEL_DP_RESOLUTION_SHIFT_MASK) |
| |
| struct dp_link_dpll { |
| int clock; |
| struct dpll dpll; |
| }; |
| |
| static const struct dp_link_dpll gen4_dpll[] = { |
| { 162000, |
| { .p1 = 2, .p2 = 10, .n = 2, .m1 = 23, .m2 = 8 } }, |
| { 270000, |
| { .p1 = 1, .p2 = 10, .n = 1, .m1 = 14, .m2 = 2 } } |
| }; |
| |
| static const struct dp_link_dpll pch_dpll[] = { |
| { 162000, |
| { .p1 = 2, .p2 = 10, .n = 1, .m1 = 12, .m2 = 9 } }, |
| { 270000, |
| { .p1 = 1, .p2 = 10, .n = 2, .m1 = 14, .m2 = 8 } } |
| }; |
| |
| static const struct dp_link_dpll vlv_dpll[] = { |
| { 162000, |
| { .p1 = 3, .p2 = 2, .n = 5, .m1 = 3, .m2 = 81 } }, |
| { 270000, |
| { .p1 = 2, .p2 = 2, .n = 1, .m1 = 2, .m2 = 27 } } |
| }; |
| |
| /* |
| * CHV supports eDP 1.4 that have more link rates. |
| * Below only provides the fixed rate but exclude variable rate. |
| */ |
| static const struct dp_link_dpll chv_dpll[] = { |
| /* |
| * CHV requires to program fractional division for m2. |
| * m2 is stored in fixed point format using formula below |
| * (m2_int << 22) | m2_fraction |
| */ |
| { 162000, /* m2_int = 32, m2_fraction = 1677722 */ |
| { .p1 = 4, .p2 = 2, .n = 1, .m1 = 2, .m2 = 0x819999a } }, |
| { 270000, /* m2_int = 27, m2_fraction = 0 */ |
| { .p1 = 4, .p2 = 1, .n = 1, .m1 = 2, .m2 = 0x6c00000 } }, |
| { 540000, /* m2_int = 27, m2_fraction = 0 */ |
| { .p1 = 2, .p2 = 1, .n = 1, .m1 = 2, .m2 = 0x6c00000 } } |
| }; |
| |
| static const int bxt_rates[] = { 162000, 216000, 243000, 270000, |
| 324000, 432000, 540000 }; |
| static const int skl_rates[] = { 162000, 216000, 270000, |
| 324000, 432000, 540000 }; |
| static const int cnl_rates[] = { 162000, 216000, 270000, |
| 324000, 432000, 540000, |
| 648000, 810000 }; |
| static const int default_rates[] = { 162000, 270000, 540000 }; |
| |
| /** |
| * is_edp - is the given port attached to an eDP panel (either CPU or PCH) |
| * @intel_dp: DP struct |
| * |
| * If a CPU or PCH DP output is attached to an eDP panel, this function |
| * will return true, and false otherwise. |
| */ |
| static bool is_edp(struct intel_dp *intel_dp) |
| { |
| struct intel_digital_port *intel_dig_port = dp_to_dig_port(intel_dp); |
| |
| return intel_dig_port->base.type == INTEL_OUTPUT_EDP; |
| } |
| |
| static struct drm_device *intel_dp_to_dev(struct intel_dp *intel_dp) |
| { |
| struct intel_digital_port *intel_dig_port = dp_to_dig_port(intel_dp); |
| |
| return intel_dig_port->base.base.dev; |
| } |
| |
| static struct intel_dp *intel_attached_dp(struct drm_connector *connector) |
| { |
| return enc_to_intel_dp(&intel_attached_encoder(connector)->base); |
| } |
| |
| static void intel_dp_link_down(struct intel_dp *intel_dp); |
| static bool edp_panel_vdd_on(struct intel_dp *intel_dp); |
| static void edp_panel_vdd_off(struct intel_dp *intel_dp, bool sync); |
| static void vlv_init_panel_power_sequencer(struct intel_dp *intel_dp); |
| static void vlv_steal_power_sequencer(struct drm_device *dev, |
| enum pipe pipe); |
| static void intel_dp_unset_edid(struct intel_dp *intel_dp); |
| |
| static int intel_dp_num_rates(u8 link_bw_code) |
| { |
| switch (link_bw_code) { |
| default: |
| WARN(1, "invalid max DP link bw val %x, using 1.62Gbps\n", |
| link_bw_code); |
| case DP_LINK_BW_1_62: |
| return 1; |
| case DP_LINK_BW_2_7: |
| return 2; |
| case DP_LINK_BW_5_4: |
| return 3; |
| } |
| } |
| |
| /* update sink rates from dpcd */ |
| static void intel_dp_set_sink_rates(struct intel_dp *intel_dp) |
| { |
| int i, num_rates; |
| |
| num_rates = intel_dp_num_rates(intel_dp->dpcd[DP_MAX_LINK_RATE]); |
| |
| for (i = 0; i < num_rates; i++) |
| intel_dp->sink_rates[i] = default_rates[i]; |
| |
| intel_dp->num_sink_rates = num_rates; |
| } |
| |
| /* Theoretical max between source and sink */ |
| static int intel_dp_max_common_rate(struct intel_dp *intel_dp) |
| { |
| return intel_dp->common_rates[intel_dp->num_common_rates - 1]; |
| } |
| |
| /* Theoretical max between source and sink */ |
| static int intel_dp_max_common_lane_count(struct intel_dp *intel_dp) |
| { |
| struct intel_digital_port *intel_dig_port = dp_to_dig_port(intel_dp); |
| int source_max = intel_dig_port->max_lanes; |
| int sink_max = drm_dp_max_lane_count(intel_dp->dpcd); |
| |
| return min(source_max, sink_max); |
| } |
| |
| int intel_dp_max_lane_count(struct intel_dp *intel_dp) |
| { |
| return intel_dp->max_link_lane_count; |
| } |
| |
| int |
| intel_dp_link_required(int pixel_clock, int bpp) |
| { |
| /* pixel_clock is in kHz, divide bpp by 8 for bit to Byte conversion */ |
| return DIV_ROUND_UP(pixel_clock * bpp, 8); |
| } |
| |
| int |
| intel_dp_max_data_rate(int max_link_clock, int max_lanes) |
| { |
| /* max_link_clock is the link symbol clock (LS_Clk) in kHz and not the |
| * link rate that is generally expressed in Gbps. Since, 8 bits of data |
| * is transmitted every LS_Clk per lane, there is no need to account for |
| * the channel encoding that is done in the PHY layer here. |
| */ |
| |
| return max_link_clock * max_lanes; |
| } |
| |
| static int |
| intel_dp_downstream_max_dotclock(struct intel_dp *intel_dp) |
| { |
| struct intel_digital_port *intel_dig_port = dp_to_dig_port(intel_dp); |
| struct intel_encoder *encoder = &intel_dig_port->base; |
| struct drm_i915_private *dev_priv = to_i915(encoder->base.dev); |
| int max_dotclk = dev_priv->max_dotclk_freq; |
| int ds_max_dotclk; |
| |
| int type = intel_dp->downstream_ports[0] & DP_DS_PORT_TYPE_MASK; |
| |
| if (type != DP_DS_PORT_TYPE_VGA) |
| return max_dotclk; |
| |
| ds_max_dotclk = drm_dp_downstream_max_clock(intel_dp->dpcd, |
| intel_dp->downstream_ports); |
| |
| if (ds_max_dotclk != 0) |
| max_dotclk = min(max_dotclk, ds_max_dotclk); |
| |
| return max_dotclk; |
| } |
| |
| static void |
| intel_dp_set_source_rates(struct intel_dp *intel_dp) |
| { |
| 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); |
| enum port port = dig_port->port; |
| const int *source_rates; |
| int size; |
| u32 voltage; |
| |
| /* This should only be done once */ |
| WARN_ON(intel_dp->source_rates || intel_dp->num_source_rates); |
| |
| if (IS_GEN9_LP(dev_priv)) { |
| source_rates = bxt_rates; |
| size = ARRAY_SIZE(bxt_rates); |
| } else if (IS_CANNONLAKE(dev_priv)) { |
| source_rates = cnl_rates; |
| size = ARRAY_SIZE(cnl_rates); |
| voltage = I915_READ(CNL_PORT_COMP_DW3) & VOLTAGE_INFO_MASK; |
| if (port == PORT_A || port == PORT_D || |
| voltage == VOLTAGE_INFO_0_85V) |
| size -= 2; |
| } else if (IS_GEN9_BC(dev_priv)) { |
| source_rates = skl_rates; |
| size = ARRAY_SIZE(skl_rates); |
| } else { |
| source_rates = default_rates; |
| size = ARRAY_SIZE(default_rates); |
| } |
| |
| /* This depends on the fact that 5.4 is last value in the array */ |
| if (!intel_dp_source_supports_hbr2(intel_dp)) |
| size--; |
| |
| intel_dp->source_rates = source_rates; |
| intel_dp->num_source_rates = size; |
| } |
| |
| static int intersect_rates(const int *source_rates, int source_len, |
| const int *sink_rates, int sink_len, |
| int *common_rates) |
| { |
| int i = 0, j = 0, k = 0; |
| |
| while (i < source_len && j < sink_len) { |
| if (source_rates[i] == sink_rates[j]) { |
| if (WARN_ON(k >= DP_MAX_SUPPORTED_RATES)) |
| return k; |
| common_rates[k] = source_rates[i]; |
| ++k; |
| ++i; |
| ++j; |
| } else if (source_rates[i] < sink_rates[j]) { |
| ++i; |
| } else { |
| ++j; |
| } |
| } |
| return k; |
| } |
| |
| /* return index of rate in rates array, or -1 if not found */ |
| static int intel_dp_rate_index(const int *rates, int len, int rate) |
| { |
| int i; |
| |
| for (i = 0; i < len; i++) |
| if (rate == rates[i]) |
| return i; |
| |
| return -1; |
| } |
| |
| static void intel_dp_set_common_rates(struct intel_dp *intel_dp) |
| { |
| WARN_ON(!intel_dp->num_source_rates || !intel_dp->num_sink_rates); |
| |
| intel_dp->num_common_rates = intersect_rates(intel_dp->source_rates, |
| intel_dp->num_source_rates, |
| intel_dp->sink_rates, |
| intel_dp->num_sink_rates, |
| intel_dp->common_rates); |
| |
| /* Paranoia, there should always be something in common. */ |
| if (WARN_ON(intel_dp->num_common_rates == 0)) { |
| intel_dp->common_rates[0] = default_rates[0]; |
| intel_dp->num_common_rates = 1; |
| } |
| } |
| |
| /* get length of common rates potentially limited by max_rate */ |
| static int intel_dp_common_len_rate_limit(struct intel_dp *intel_dp, |
| int max_rate) |
| { |
| const int *common_rates = intel_dp->common_rates; |
| int i, common_len = intel_dp->num_common_rates; |
| |
| /* Limit results by potentially reduced max rate */ |
| for (i = 0; i < common_len; i++) { |
| if (common_rates[common_len - i - 1] <= max_rate) |
| return common_len - i; |
| } |
| |
| return 0; |
| } |
| |
| static bool intel_dp_link_params_valid(struct intel_dp *intel_dp, int link_rate, |
| uint8_t lane_count) |
| { |
| /* |
| * FIXME: we need to synchronize the current link parameters with |
| * hardware readout. Currently fast link training doesn't work on |
| * boot-up. |
| */ |
| if (link_rate == 0 || |
| link_rate > intel_dp->max_link_rate) |
| return false; |
| |
| if (lane_count == 0 || |
| lane_count > intel_dp_max_lane_count(intel_dp)) |
| return false; |
| |
| return true; |
| } |
| |
| int intel_dp_get_link_train_fallback_values(struct intel_dp *intel_dp, |
| int link_rate, uint8_t lane_count) |
| { |
| int index; |
| |
| index = intel_dp_rate_index(intel_dp->common_rates, |
| intel_dp->num_common_rates, |
| link_rate); |
| if (index > 0) { |
| intel_dp->max_link_rate = intel_dp->common_rates[index - 1]; |
| intel_dp->max_link_lane_count = lane_count; |
| } else if (lane_count > 1) { |
| intel_dp->max_link_rate = intel_dp_max_common_rate(intel_dp); |
| intel_dp->max_link_lane_count = lane_count >> 1; |
| } else { |
| DRM_ERROR("Link Training Unsuccessful\n"); |
| return -1; |
| } |
| |
| return 0; |
| } |
| |
| static enum drm_mode_status |
| intel_dp_mode_valid(struct drm_connector *connector, |
| struct drm_display_mode *mode) |
| { |
| struct intel_dp *intel_dp = intel_attached_dp(connector); |
| struct intel_connector *intel_connector = to_intel_connector(connector); |
| struct drm_display_mode *fixed_mode = intel_connector->panel.fixed_mode; |
| int target_clock = mode->clock; |
| int max_rate, mode_rate, max_lanes, max_link_clock; |
| int max_dotclk; |
| |
| max_dotclk = intel_dp_downstream_max_dotclock(intel_dp); |
| |
| if (is_edp(intel_dp) && fixed_mode) { |
| if (mode->hdisplay > fixed_mode->hdisplay) |
| return MODE_PANEL; |
| |
| if (mode->vdisplay > fixed_mode->vdisplay) |
| return MODE_PANEL; |
| |
| target_clock = fixed_mode->clock; |
| } |
| |
| max_link_clock = intel_dp_max_link_rate(intel_dp); |
| max_lanes = intel_dp_max_lane_count(intel_dp); |
| |
| max_rate = intel_dp_max_data_rate(max_link_clock, max_lanes); |
| mode_rate = intel_dp_link_required(target_clock, 18); |
| |
| if (mode_rate > max_rate || target_clock > max_dotclk) |
| return MODE_CLOCK_HIGH; |
| |
| if (mode->clock < 10000) |
| return MODE_CLOCK_LOW; |
| |
| if (mode->flags & DRM_MODE_FLAG_DBLCLK) |
| return MODE_H_ILLEGAL; |
| |
| return MODE_OK; |
| } |
| |
| uint32_t intel_dp_pack_aux(const uint8_t *src, int src_bytes) |
| { |
| int i; |
| uint32_t v = 0; |
| |
| if (src_bytes > 4) |
| src_bytes = 4; |
| for (i = 0; i < src_bytes; i++) |
| v |= ((uint32_t) src[i]) << ((3-i) * 8); |
| return v; |
| } |
| |
| static void intel_dp_unpack_aux(uint32_t src, uint8_t *dst, int dst_bytes) |
| { |
| int i; |
| if (dst_bytes > 4) |
| dst_bytes = 4; |
| for (i = 0; i < dst_bytes; i++) |
| dst[i] = src >> ((3-i) * 8); |
| } |
| |
| static void |
| intel_dp_init_panel_power_sequencer(struct drm_device *dev, |
| struct intel_dp *intel_dp); |
| static void |
| intel_dp_init_panel_power_sequencer_registers(struct drm_device *dev, |
| struct intel_dp *intel_dp, |
| bool force_disable_vdd); |
| static void |
| intel_dp_pps_init(struct drm_device *dev, struct intel_dp *intel_dp); |
| |
| static void pps_lock(struct intel_dp *intel_dp) |
| { |
| struct intel_digital_port *intel_dig_port = dp_to_dig_port(intel_dp); |
| struct intel_encoder *encoder = &intel_dig_port->base; |
| struct drm_device *dev = encoder->base.dev; |
| struct drm_i915_private *dev_priv = to_i915(dev); |
| |
| /* |
| * See vlv_power_sequencer_reset() why we need |
| * a power domain reference here. |
| */ |
| intel_display_power_get(dev_priv, intel_dp->aux_power_domain); |
| |
| mutex_lock(&dev_priv->pps_mutex); |
| } |
| |
| static void pps_unlock(struct intel_dp *intel_dp) |
| { |
| struct intel_digital_port *intel_dig_port = dp_to_dig_port(intel_dp); |
| struct intel_encoder *encoder = &intel_dig_port->base; |
| struct drm_device *dev = encoder->base.dev; |
| struct drm_i915_private *dev_priv = to_i915(dev); |
| |
| mutex_unlock(&dev_priv->pps_mutex); |
| |
| intel_display_power_put(dev_priv, intel_dp->aux_power_domain); |
| } |
| |
| static void |
| vlv_power_sequencer_kick(struct intel_dp *intel_dp) |
| { |
| struct intel_digital_port *intel_dig_port = dp_to_dig_port(intel_dp); |
| struct drm_i915_private *dev_priv = to_i915(intel_dig_port->base.base.dev); |
| enum pipe pipe = intel_dp->pps_pipe; |
| bool pll_enabled, release_cl_override = false; |
| enum dpio_phy phy = DPIO_PHY(pipe); |
| enum dpio_channel ch = vlv_pipe_to_channel(pipe); |
| uint32_t DP; |
| |
| if (WARN(I915_READ(intel_dp->output_reg) & DP_PORT_EN, |
| "skipping pipe %c power seqeuncer kick due to port %c being active\n", |
| pipe_name(pipe), port_name(intel_dig_port->port))) |
| return; |
| |
| DRM_DEBUG_KMS("kicking pipe %c power sequencer for port %c\n", |
| pipe_name(pipe), port_name(intel_dig_port->port)); |
| |
| /* Preserve the BIOS-computed detected bit. This is |
| * supposed to be read-only. |
| */ |
| DP = I915_READ(intel_dp->output_reg) & DP_DETECTED; |
| DP |= DP_VOLTAGE_0_4 | DP_PRE_EMPHASIS_0; |
| DP |= DP_PORT_WIDTH(1); |
| DP |= DP_LINK_TRAIN_PAT_1; |
| |
| if (IS_CHERRYVIEW(dev_priv)) |
| DP |= DP_PIPE_SELECT_CHV(pipe); |
| else if (pipe == PIPE_B) |
| DP |= DP_PIPEB_SELECT; |
| |
| pll_enabled = I915_READ(DPLL(pipe)) & DPLL_VCO_ENABLE; |
| |
| /* |
| * The DPLL for the pipe must be enabled for this to work. |
| * So enable temporarily it if it's not already enabled. |
| */ |
| if (!pll_enabled) { |
| release_cl_override = IS_CHERRYVIEW(dev_priv) && |
| !chv_phy_powergate_ch(dev_priv, phy, ch, true); |
| |
| if (vlv_force_pll_on(dev_priv, pipe, IS_CHERRYVIEW(dev_priv) ? |
| &chv_dpll[0].dpll : &vlv_dpll[0].dpll)) { |
| DRM_ERROR("Failed to force on pll for pipe %c!\n", |
| pipe_name(pipe)); |
| return; |
| } |
| } |
| |
| /* |
| * Similar magic as in intel_dp_enable_port(). |
| * We _must_ do this port enable + disable trick |
| * to make this power seqeuencer lock onto the port. |
| * Otherwise even VDD force bit won't work. |
| */ |
| I915_WRITE(intel_dp->output_reg, DP); |
| POSTING_READ(intel_dp->output_reg); |
| |
| I915_WRITE(intel_dp->output_reg, DP | DP_PORT_EN); |
| POSTING_READ(intel_dp->output_reg); |
| |
| I915_WRITE(intel_dp->output_reg, DP & ~DP_PORT_EN); |
| POSTING_READ(intel_dp->output_reg); |
| |
| if (!pll_enabled) { |
| vlv_force_pll_off(dev_priv, pipe); |
| |
| if (release_cl_override) |
| chv_phy_powergate_ch(dev_priv, phy, ch, false); |
| } |
| } |
| |
| static enum pipe vlv_find_free_pps(struct drm_i915_private *dev_priv) |
| { |
| struct intel_encoder *encoder; |
| unsigned int pipes = (1 << PIPE_A) | (1 << PIPE_B); |
| |
| /* |
| * We don't have power sequencer currently. |
| * Pick one that's not used by other ports. |
| */ |
| for_each_intel_encoder(&dev_priv->drm, encoder) { |
| struct intel_dp *intel_dp; |
| |
| if (encoder->type != INTEL_OUTPUT_DP && |
| encoder->type != INTEL_OUTPUT_EDP) |
| continue; |
| |
| intel_dp = enc_to_intel_dp(&encoder->base); |
| |
| if (encoder->type == INTEL_OUTPUT_EDP) { |
| WARN_ON(intel_dp->active_pipe != INVALID_PIPE && |
| intel_dp->active_pipe != intel_dp->pps_pipe); |
| |
| if (intel_dp->pps_pipe != INVALID_PIPE) |
| pipes &= ~(1 << intel_dp->pps_pipe); |
| } else { |
| WARN_ON(intel_dp->pps_pipe != INVALID_PIPE); |
| |
| if (intel_dp->active_pipe != INVALID_PIPE) |
| pipes &= ~(1 << intel_dp->active_pipe); |
| } |
| } |
| |
| if (pipes == 0) |
| return INVALID_PIPE; |
| |
| return ffs(pipes) - 1; |
| } |
| |
| static enum pipe |
| vlv_power_sequencer_pipe(struct intel_dp *intel_dp) |
| { |
| struct intel_digital_port *intel_dig_port = dp_to_dig_port(intel_dp); |
| struct drm_device *dev = intel_dig_port->base.base.dev; |
| struct drm_i915_private *dev_priv = to_i915(dev); |
| enum pipe pipe; |
| |
| lockdep_assert_held(&dev_priv->pps_mutex); |
| |
| /* We should never land here with regular DP ports */ |
| WARN_ON(!is_edp(intel_dp)); |
| |
| WARN_ON(intel_dp->active_pipe != INVALID_PIPE && |
| intel_dp->active_pipe != intel_dp->pps_pipe); |
| |
| if (intel_dp->pps_pipe != INVALID_PIPE) |
| return intel_dp->pps_pipe; |
| |
| pipe = vlv_find_free_pps(dev_priv); |
| |
| /* |
| * Didn't find one. This should not happen since there |
| * are two power sequencers and up to two eDP ports. |
| */ |
| if (WARN_ON(pipe == INVALID_PIPE)) |
| pipe = PIPE_A; |
| |
| vlv_steal_power_sequencer(dev, pipe); |
| intel_dp->pps_pipe = pipe; |
| |
| DRM_DEBUG_KMS("picked pipe %c power sequencer for port %c\n", |
| pipe_name(intel_dp->pps_pipe), |
| port_name(intel_dig_port->port)); |
| |
| /* init power sequencer on this pipe and port */ |
| intel_dp_init_panel_power_sequencer(dev, intel_dp); |
| intel_dp_init_panel_power_sequencer_registers(dev, intel_dp, true); |
| |
| /* |
| * Even vdd force doesn't work until we've made |
| * the power sequencer lock in on the port. |
| */ |
| vlv_power_sequencer_kick(intel_dp); |
| |
| return intel_dp->pps_pipe; |
| } |
| |
| static int |
| bxt_power_sequencer_idx(struct intel_dp *intel_dp) |
| { |
| struct intel_digital_port *intel_dig_port = dp_to_dig_port(intel_dp); |
| struct drm_device *dev = intel_dig_port->base.base.dev; |
| struct drm_i915_private *dev_priv = to_i915(dev); |
| |
| lockdep_assert_held(&dev_priv->pps_mutex); |
| |
| /* We should never land here with regular DP ports */ |
| WARN_ON(!is_edp(intel_dp)); |
| |
| /* |
| * TODO: BXT has 2 PPS instances. The correct port->PPS instance |
| * mapping needs to be retrieved from VBT, for now just hard-code to |
| * use instance #0 always. |
| */ |
| if (!intel_dp->pps_reset) |
| return 0; |
| |
| intel_dp->pps_reset = false; |
| |
| /* |
| * Only the HW needs to be reprogrammed, the SW state is fixed and |
| * has been setup during connector init. |
| */ |
| intel_dp_init_panel_power_sequencer_registers(dev, intel_dp, false); |
| |
| return 0; |
| } |
| |
| typedef bool (*vlv_pipe_check)(struct drm_i915_private *dev_priv, |
| enum pipe pipe); |
| |
| static bool vlv_pipe_has_pp_on(struct drm_i915_private *dev_priv, |
| enum pipe pipe) |
| { |
| return I915_READ(PP_STATUS(pipe)) & PP_ON; |
| } |
| |
| static bool vlv_pipe_has_vdd_on(struct drm_i915_private *dev_priv, |
| enum pipe pipe) |
| { |
| return I915_READ(PP_CONTROL(pipe)) & EDP_FORCE_VDD; |
| } |
| |
| static bool vlv_pipe_any(struct drm_i915_private *dev_priv, |
| enum pipe pipe) |
| { |
| return true; |
| } |
| |
| static enum pipe |
| vlv_initial_pps_pipe(struct drm_i915_private *dev_priv, |
| enum port port, |
| vlv_pipe_check pipe_check) |
| { |
| enum pipe pipe; |
| |
| for (pipe = PIPE_A; pipe <= PIPE_B; pipe++) { |
| u32 port_sel = I915_READ(PP_ON_DELAYS(pipe)) & |
| PANEL_PORT_SELECT_MASK; |
| |
| if (port_sel != PANEL_PORT_SELECT_VLV(port)) |
| continue; |
| |
| if (!pipe_check(dev_priv, pipe)) |
| continue; |
| |
| return pipe; |
| } |
| |
| return INVALID_PIPE; |
| } |
| |
| static void |
| vlv_initial_power_sequencer_setup(struct intel_dp *intel_dp) |
| { |
| struct intel_digital_port *intel_dig_port = dp_to_dig_port(intel_dp); |
| struct drm_device *dev = intel_dig_port->base.base.dev; |
| struct drm_i915_private *dev_priv = to_i915(dev); |
| enum port port = intel_dig_port->port; |
| |
| lockdep_assert_held(&dev_priv->pps_mutex); |
| |
| /* try to find a pipe with this port selected */ |
| /* first pick one where the panel is on */ |
| intel_dp->pps_pipe = vlv_initial_pps_pipe(dev_priv, port, |
| vlv_pipe_has_pp_on); |
| /* didn't find one? pick one where vdd is on */ |
| if (intel_dp->pps_pipe == INVALID_PIPE) |
| intel_dp->pps_pipe = vlv_initial_pps_pipe(dev_priv, port, |
| vlv_pipe_has_vdd_on); |
| /* didn't find one? pick one with just the correct port */ |
| if (intel_dp->pps_pipe == INVALID_PIPE) |
| intel_dp->pps_pipe = vlv_initial_pps_pipe(dev_priv, port, |
| vlv_pipe_any); |
| |
| /* didn't find one? just let vlv_power_sequencer_pipe() pick one when needed */ |
| if (intel_dp->pps_pipe == INVALID_PIPE) { |
| DRM_DEBUG_KMS("no initial power sequencer for port %c\n", |
| port_name(port)); |
| return; |
| } |
| |
| DRM_DEBUG_KMS("initial power sequencer for port %c: pipe %c\n", |
| port_name(port), pipe_name(intel_dp->pps_pipe)); |
| |
| intel_dp_init_panel_power_sequencer(dev, intel_dp); |
| intel_dp_init_panel_power_sequencer_registers(dev, intel_dp, false); |
| } |
| |
| void intel_power_sequencer_reset(struct drm_i915_private *dev_priv) |
| { |
| struct drm_device *dev = &dev_priv->drm; |
| struct intel_encoder *encoder; |
| |
| if (WARN_ON(!IS_VALLEYVIEW(dev_priv) && !IS_CHERRYVIEW(dev_priv) && |
| !IS_GEN9_LP(dev_priv))) |
| return; |
| |
| /* |
| * We can't grab pps_mutex here due to deadlock with power_domain |
| * mutex when power_domain functions are called while holding pps_mutex. |
| * That also means that in order to use pps_pipe the code needs to |
| * hold both a power domain reference and pps_mutex, and the power domain |
| * reference get/put must be done while _not_ holding pps_mutex. |
| * pps_{lock,unlock}() do these steps in the correct order, so one |
| * should use them always. |
| */ |
| |
| for_each_intel_encoder(dev, encoder) { |
| struct intel_dp *intel_dp; |
| |
| if (encoder->type != INTEL_OUTPUT_DP && |
| encoder->type != INTEL_OUTPUT_EDP) |
| continue; |
| |
| intel_dp = enc_to_intel_dp(&encoder->base); |
| |
| WARN_ON(intel_dp->active_pipe != INVALID_PIPE); |
| |
| if (encoder->type != INTEL_OUTPUT_EDP) |
| continue; |
| |
| if (IS_GEN9_LP(dev_priv)) |
| intel_dp->pps_reset = true; |
| else |
| intel_dp->pps_pipe = INVALID_PIPE; |
| } |
| } |
| |
| struct pps_registers { |
| i915_reg_t pp_ctrl; |
| i915_reg_t pp_stat; |
| i915_reg_t pp_on; |
| i915_reg_t pp_off; |
| i915_reg_t pp_div; |
| }; |
| |
| static void intel_pps_get_registers(struct drm_i915_private *dev_priv, |
| struct intel_dp *intel_dp, |
| struct pps_registers *regs) |
| { |
| int pps_idx = 0; |
| |
| memset(regs, 0, sizeof(*regs)); |
| |
| if (IS_GEN9_LP(dev_priv)) |
| pps_idx = bxt_power_sequencer_idx(intel_dp); |
| else if (IS_VALLEYVIEW(dev_priv) || IS_CHERRYVIEW(dev_priv)) |
| pps_idx = vlv_power_sequencer_pipe(intel_dp); |
| |
| regs->pp_ctrl = PP_CONTROL(pps_idx); |
| regs->pp_stat = PP_STATUS(pps_idx); |
| regs->pp_on = PP_ON_DELAYS(pps_idx); |
| regs->pp_off = PP_OFF_DELAYS(pps_idx); |
| if (!IS_GEN9_LP(dev_priv) && !HAS_PCH_CNP(dev_priv)) |
| regs->pp_div = PP_DIVISOR(pps_idx); |
| } |
| |
| static i915_reg_t |
| _pp_ctrl_reg(struct intel_dp *intel_dp) |
| { |
| struct pps_registers regs; |
| |
| intel_pps_get_registers(to_i915(intel_dp_to_dev(intel_dp)), intel_dp, |
| ®s); |
| |
| return regs.pp_ctrl; |
| } |
| |
| static i915_reg_t |
| _pp_stat_reg(struct intel_dp *intel_dp) |
| { |
| struct pps_registers regs; |
| |
| intel_pps_get_registers(to_i915(intel_dp_to_dev(intel_dp)), intel_dp, |
| ®s); |
| |
| return regs.pp_stat; |
| } |
| |
| /* Reboot notifier handler to shutdown panel power to guarantee T12 timing |
| This function only applicable when panel PM state is not to be tracked */ |
| static int edp_notify_handler(struct notifier_block *this, unsigned long code, |
| void *unused) |
| { |
| struct intel_dp *intel_dp = container_of(this, typeof(* intel_dp), |
| edp_notifier); |
| struct drm_device *dev = intel_dp_to_dev(intel_dp); |
| struct drm_i915_private *dev_priv = to_i915(dev); |
| |
| if (!is_edp(intel_dp) || code != SYS_RESTART) |
| return 0; |
| |
| pps_lock(intel_dp); |
| |
| if (IS_VALLEYVIEW(dev_priv) || IS_CHERRYVIEW(dev_priv)) { |
| enum pipe pipe = vlv_power_sequencer_pipe(intel_dp); |
| i915_reg_t pp_ctrl_reg, pp_div_reg; |
| u32 pp_div; |
| |
| pp_ctrl_reg = PP_CONTROL(pipe); |
| pp_div_reg = PP_DIVISOR(pipe); |
| pp_div = I915_READ(pp_div_reg); |
| pp_div &= PP_REFERENCE_DIVIDER_MASK; |
| |
| /* 0x1F write to PP_DIV_REG sets max cycle delay */ |
| I915_WRITE(pp_div_reg, pp_div | 0x1F); |
| I915_WRITE(pp_ctrl_reg, PANEL_UNLOCK_REGS | PANEL_POWER_OFF); |
| msleep(intel_dp->panel_power_cycle_delay); |
| } |
| |
| pps_unlock(intel_dp); |
| |
| return 0; |
| } |
| |
| static bool edp_have_panel_power(struct intel_dp *intel_dp) |
| { |
| struct drm_device *dev = intel_dp_to_dev(intel_dp); |
| struct drm_i915_private *dev_priv = to_i915(dev); |
| |
| lockdep_assert_held(&dev_priv->pps_mutex); |
| |
| if ((IS_VALLEYVIEW(dev_priv) || IS_CHERRYVIEW(dev_priv)) && |
| intel_dp->pps_pipe == INVALID_PIPE) |
| return false; |
| |
| return (I915_READ(_pp_stat_reg(intel_dp)) & PP_ON) != 0; |
| } |
| |
| static bool edp_have_panel_vdd(struct intel_dp *intel_dp) |
| { |
| struct drm_device *dev = intel_dp_to_dev(intel_dp); |
| struct drm_i915_private *dev_priv = to_i915(dev); |
| |
| lockdep_assert_held(&dev_priv->pps_mutex); |
| |
| if ((IS_VALLEYVIEW(dev_priv) || IS_CHERRYVIEW(dev_priv)) && |
| intel_dp->pps_pipe == INVALID_PIPE) |
| return false; |
| |
| return I915_READ(_pp_ctrl_reg(intel_dp)) & EDP_FORCE_VDD; |
| } |
| |
| static void |
| intel_dp_check_edp(struct intel_dp *intel_dp) |
| { |
| struct drm_device *dev = intel_dp_to_dev(intel_dp); |
| struct drm_i915_private *dev_priv = to_i915(dev); |
| |
| if (!is_edp(intel_dp)) |
| return; |
| |
| if (!edp_have_panel_power(intel_dp) && !edp_have_panel_vdd(intel_dp)) { |
| WARN(1, "eDP powered off while attempting aux channel communication.\n"); |
| DRM_DEBUG_KMS("Status 0x%08x Control 0x%08x\n", |
| I915_READ(_pp_stat_reg(intel_dp)), |
| I915_READ(_pp_ctrl_reg(intel_dp))); |
| } |
| } |
| |
| static uint32_t |
| intel_dp_aux_wait_done(struct intel_dp *intel_dp, bool has_aux_irq) |
| { |
| struct intel_digital_port *intel_dig_port = dp_to_dig_port(intel_dp); |
| struct drm_device *dev = intel_dig_port->base.base.dev; |
| struct drm_i915_private *dev_priv = to_i915(dev); |
| i915_reg_t ch_ctl = intel_dp->aux_ch_ctl_reg; |
| uint32_t status; |
| bool done; |
| |
| #define C (((status = I915_READ_NOTRACE(ch_ctl)) & DP_AUX_CH_CTL_SEND_BUSY) == 0) |
| if (has_aux_irq) |
| done = wait_event_timeout(dev_priv->gmbus_wait_queue, C, |
| msecs_to_jiffies_timeout(10)); |
| else |
| done = wait_for(C, 10) == 0; |
| if (!done) |
| DRM_ERROR("dp aux hw did not signal timeout (has irq: %i)!\n", |
| has_aux_irq); |
| #undef C |
| |
| return status; |
| } |
| |
| static uint32_t g4x_get_aux_clock_divider(struct intel_dp *intel_dp, int index) |
| { |
| struct intel_digital_port *intel_dig_port = dp_to_dig_port(intel_dp); |
| struct drm_i915_private *dev_priv = to_i915(intel_dig_port->base.base.dev); |
| |
| if (index) |
| return 0; |
| |
| /* |
| * The clock divider is based off the hrawclk, and would like to run at |
| * 2MHz. So, take the hrawclk value and divide by 2000 and use that |
| */ |
| return DIV_ROUND_CLOSEST(dev_priv->rawclk_freq, 2000); |
| } |
| |
| static uint32_t ilk_get_aux_clock_divider(struct intel_dp *intel_dp, int index) |
| { |
| struct intel_digital_port *intel_dig_port = dp_to_dig_port(intel_dp); |
| struct drm_i915_private *dev_priv = to_i915(intel_dig_port->base.base.dev); |
| |
| if (index) |
| return 0; |
| |
| /* |
| * The clock divider is based off the cdclk or PCH rawclk, and would |
| * like to run at 2MHz. So, take the cdclk or PCH rawclk value and |
| * divide by 2000 and use that |
| */ |
| if (intel_dig_port->port == PORT_A) |
| return DIV_ROUND_CLOSEST(dev_priv->cdclk.hw.cdclk, 2000); |
| else |
| return DIV_ROUND_CLOSEST(dev_priv->rawclk_freq, 2000); |
| } |
| |
| static uint32_t hsw_get_aux_clock_divider(struct intel_dp *intel_dp, int index) |
| { |
| struct intel_digital_port *intel_dig_port = dp_to_dig_port(intel_dp); |
| struct drm_i915_private *dev_priv = to_i915(intel_dig_port->base.base.dev); |
| |
| if (intel_dig_port->port != PORT_A && HAS_PCH_LPT_H(dev_priv)) { |
| /* Workaround for non-ULT HSW */ |
| switch (index) { |
| case 0: return 63; |
| case 1: return 72; |
| default: return 0; |
| } |
| } |
| |
| return ilk_get_aux_clock_divider(intel_dp, index); |
| } |
| |
| static uint32_t skl_get_aux_clock_divider(struct intel_dp *intel_dp, int index) |
| { |
| /* |
| * SKL doesn't need us to program the AUX clock divider (Hardware will |
| * derive the clock from CDCLK automatically). We still implement the |
| * get_aux_clock_divider vfunc to plug-in into the existing code. |
| */ |
| return index ? 0 : 1; |
| } |
| |
| static uint32_t g4x_get_aux_send_ctl(struct intel_dp *intel_dp, |
| bool has_aux_irq, |
| int send_bytes, |
| uint32_t aux_clock_divider) |
| { |
| struct intel_digital_port *intel_dig_port = dp_to_dig_port(intel_dp); |
| struct drm_i915_private *dev_priv = |
| to_i915(intel_dig_port->base.base.dev); |
| uint32_t precharge, timeout; |
| |
| if (IS_GEN6(dev_priv)) |
| precharge = 3; |
| else |
| precharge = 5; |
| |
| if (IS_BROADWELL(dev_priv) && intel_dig_port->port == PORT_A) |
| timeout = DP_AUX_CH_CTL_TIME_OUT_600us; |
| else |
| timeout = DP_AUX_CH_CTL_TIME_OUT_400us; |
| |
| return DP_AUX_CH_CTL_SEND_BUSY | |
| DP_AUX_CH_CTL_DONE | |
| (has_aux_irq ? DP_AUX_CH_CTL_INTERRUPT : 0) | |
| DP_AUX_CH_CTL_TIME_OUT_ERROR | |
| timeout | |
| DP_AUX_CH_CTL_RECEIVE_ERROR | |
| (send_bytes << DP_AUX_CH_CTL_MESSAGE_SIZE_SHIFT) | |
| (precharge << DP_AUX_CH_CTL_PRECHARGE_2US_SHIFT) | |
| (aux_clock_divider << DP_AUX_CH_CTL_BIT_CLOCK_2X_SHIFT); |
| } |
| |
| static uint32_t skl_get_aux_send_ctl(struct intel_dp *intel_dp, |
| bool has_aux_irq, |
| int send_bytes, |
| uint32_t unused) |
| { |
| return DP_AUX_CH_CTL_SEND_BUSY | |
| DP_AUX_CH_CTL_DONE | |
| (has_aux_irq ? DP_AUX_CH_CTL_INTERRUPT : 0) | |
| DP_AUX_CH_CTL_TIME_OUT_ERROR | |
| DP_AUX_CH_CTL_TIME_OUT_1600us | |
| DP_AUX_CH_CTL_RECEIVE_ERROR | |
| (send_bytes << DP_AUX_CH_CTL_MESSAGE_SIZE_SHIFT) | |
| DP_AUX_CH_CTL_FW_SYNC_PULSE_SKL(32) | |
| DP_AUX_CH_CTL_SYNC_PULSE_SKL(32); |
| } |
| |
| static int |
| intel_dp_aux_ch(struct intel_dp *intel_dp, |
| const uint8_t *send, int send_bytes, |
| uint8_t *recv, int recv_size) |
| { |
| struct intel_digital_port *intel_dig_port = dp_to_dig_port(intel_dp); |
| struct drm_i915_private *dev_priv = |
| to_i915(intel_dig_port->base.base.dev); |
| i915_reg_t ch_ctl = intel_dp->aux_ch_ctl_reg; |
| uint32_t aux_clock_divider; |
| int i, ret, recv_bytes; |
| uint32_t status; |
| int try, clock = 0; |
| bool has_aux_irq = HAS_AUX_IRQ(dev_priv); |
| bool vdd; |
| |
| pps_lock(intel_dp); |
| |
| /* |
| * We will be called with VDD already enabled for dpcd/edid/oui reads. |
| * In such cases we want to leave VDD enabled and it's up to upper layers |
| * to turn it off. But for eg. i2c-dev access we need to turn it on/off |
| * ourselves. |
| */ |
| vdd = edp_panel_vdd_on(intel_dp); |
| |
| /* dp aux is extremely sensitive to irq latency, hence request the |
| * lowest possible wakeup latency and so prevent the cpu from going into |
| * deep sleep states. |
| */ |
| pm_qos_update_request(&dev_priv->pm_qos, 0); |
| |
| intel_dp_check_edp(intel_dp); |
| |
| /* Try to wait for any previous AUX channel activity */ |
| for (try = 0; try < 3; try++) { |
| status = I915_READ_NOTRACE(ch_ctl); |
| if ((status & DP_AUX_CH_CTL_SEND_BUSY) == 0) |
| break; |
| msleep(1); |
| } |
| |
| if (try == 3) { |
| static u32 last_status = -1; |
| const u32 status = I915_READ(ch_ctl); |
| |
| if (status != last_status) { |
| WARN(1, "dp_aux_ch not started status 0x%08x\n", |
| status); |
| last_status = status; |
| } |
| |
| ret = -EBUSY; |
| goto out; |
| } |
| |
| /* Only 5 data registers! */ |
| if (WARN_ON(send_bytes > 20 || recv_size > 20)) { |
| ret = -E2BIG; |
| goto out; |
| } |
| |
| while ((aux_clock_divider = intel_dp->get_aux_clock_divider(intel_dp, clock++))) { |
| u32 send_ctl = intel_dp->get_aux_send_ctl(intel_dp, |
| has_aux_irq, |
| send_bytes, |
| aux_clock_divider); |
| |
| /* Must try at least 3 times according to DP spec */ |
| for (try = 0; try < 5; try++) { |
| /* Load the send data into the aux channel data registers */ |
| for (i = 0; i < send_bytes; i += 4) |
| I915_WRITE(intel_dp->aux_ch_data_reg[i >> 2], |
| intel_dp_pack_aux(send + i, |
| send_bytes - i)); |
| |
| /* Send the command and wait for it to complete */ |
| I915_WRITE(ch_ctl, send_ctl); |
| |
| status = intel_dp_aux_wait_done(intel_dp, has_aux_irq); |
| |
| /* Clear done status and any errors */ |
| I915_WRITE(ch_ctl, |
| status | |
| DP_AUX_CH_CTL_DONE | |
| DP_AUX_CH_CTL_TIME_OUT_ERROR | |
| DP_AUX_CH_CTL_RECEIVE_ERROR); |
| |
| if (status & DP_AUX_CH_CTL_TIME_OUT_ERROR) |
| continue; |
| |
| /* DP CTS 1.2 Core Rev 1.1, 4.2.1.1 & 4.2.1.2 |
| * 400us delay required for errors and timeouts |
| * Timeout errors from the HW already meet this |
| * requirement so skip to next iteration |
| */ |
| if (status & DP_AUX_CH_CTL_RECEIVE_ERROR) { |
| usleep_range(400, 500); |
| continue; |
| } |
| if (status & DP_AUX_CH_CTL_DONE) |
| goto done; |
| } |
| } |
| |
| if ((status & DP_AUX_CH_CTL_DONE) == 0) { |
| DRM_ERROR("dp_aux_ch not done status 0x%08x\n", status); |
| ret = -EBUSY; |
| goto out; |
| } |
| |
| done: |
| /* Check for timeout or receive error. |
| * Timeouts occur when the sink is not connected |
| */ |
| if (status & DP_AUX_CH_CTL_RECEIVE_ERROR) { |
| DRM_ERROR("dp_aux_ch receive error status 0x%08x\n", status); |
| ret = -EIO; |
| goto out; |
| } |
| |
| /* Timeouts occur when the device isn't connected, so they're |
| * "normal" -- don't fill the kernel log with these */ |
| if (status & DP_AUX_CH_CTL_TIME_OUT_ERROR) { |
| DRM_DEBUG_KMS("dp_aux_ch timeout status 0x%08x\n", status); |
| ret = -ETIMEDOUT; |
| goto out; |
| } |
| |
| /* Unload any bytes sent back from the other side */ |
| recv_bytes = ((status & DP_AUX_CH_CTL_MESSAGE_SIZE_MASK) >> |
| DP_AUX_CH_CTL_MESSAGE_SIZE_SHIFT); |
| |
| /* |
| * By BSpec: "Message sizes of 0 or >20 are not allowed." |
| * We have no idea of what happened so we return -EBUSY so |
| * drm layer takes care for the necessary retries. |
| */ |
| if (recv_bytes == 0 || recv_bytes > 20) { |
| DRM_DEBUG_KMS("Forbidden recv_bytes = %d on aux transaction\n", |
| recv_bytes); |
| /* |
| * FIXME: This patch was created on top of a series that |
| * organize the retries at drm level. There EBUSY should |
| * also take care for 1ms wait before retrying. |
| * That aux retries re-org is still needed and after that is |
| * merged we remove this sleep from here. |
| */ |
| usleep_range(1000, 1500); |
| ret = -EBUSY; |
| goto out; |
| } |
| |
| if (recv_bytes > recv_size) |
| recv_bytes = recv_size; |
| |
| for (i = 0; i < recv_bytes; i += 4) |
| intel_dp_unpack_aux(I915_READ(intel_dp->aux_ch_data_reg[i >> 2]), |
| recv + i, recv_bytes - i); |
| |
| ret = recv_bytes; |
| out: |
| pm_qos_update_request(&dev_priv->pm_qos, PM_QOS_DEFAULT_VALUE); |
| |
| if (vdd) |
| edp_panel_vdd_off(intel_dp, false); |
| |
| pps_unlock(intel_dp); |
| |
| return ret; |
| } |
| |
| #define BARE_ADDRESS_SIZE 3 |
| #define HEADER_SIZE (BARE_ADDRESS_SIZE + 1) |
| static ssize_t |
| intel_dp_aux_transfer(struct drm_dp_aux *aux, struct drm_dp_aux_msg *msg) |
| { |
| struct intel_dp *intel_dp = container_of(aux, struct intel_dp, aux); |
| uint8_t txbuf[20], rxbuf[20]; |
| size_t txsize, rxsize; |
| int ret; |
| |
| txbuf[0] = (msg->request << 4) | |
| ((msg->address >> 16) & 0xf); |
| txbuf[1] = (msg->address >> 8) & 0xff; |
| txbuf[2] = msg->address & 0xff; |
| txbuf[3] = msg->size - 1; |
| |
| switch (msg->request & ~DP_AUX_I2C_MOT) { |
| case DP_AUX_NATIVE_WRITE: |
| case DP_AUX_I2C_WRITE: |
| case DP_AUX_I2C_WRITE_STATUS_UPDATE: |
| txsize = msg->size ? HEADER_SIZE + msg->size : BARE_ADDRESS_SIZE; |
| rxsize = 2; /* 0 or 1 data bytes */ |
| |
| if (WARN_ON(txsize > 20)) |
| return -E2BIG; |
| |
| WARN_ON(!msg->buffer != !msg->size); |
| |
| if (msg->buffer) |
| memcpy(txbuf + HEADER_SIZE, msg->buffer, msg->size); |
| |
| ret = intel_dp_aux_ch(intel_dp, txbuf, txsize, rxbuf, rxsize); |
| if (ret > 0) { |
| msg->reply = rxbuf[0] >> 4; |
| |
| if (ret > 1) { |
| /* Number of bytes written in a short write. */ |
| ret = clamp_t(int, rxbuf[1], 0, msg->size); |
| } else { |
| /* Return payload size. */ |
| ret = msg->size; |
| } |
| } |
| break; |
| |
| case DP_AUX_NATIVE_READ: |
| case DP_AUX_I2C_READ: |
| txsize = msg->size ? HEADER_SIZE : BARE_ADDRESS_SIZE; |
| rxsize = msg->size + 1; |
| |
| if (WARN_ON(rxsize > 20)) |
| return -E2BIG; |
| |
| ret = intel_dp_aux_ch(intel_dp, txbuf, txsize, rxbuf, rxsize); |
| if (ret > 0) { |
| msg->reply = rxbuf[0] >> 4; |
| /* |
| * Assume happy day, and copy the data. The caller is |
| * expected to check msg->reply before touching it. |
| * |
| * Return payload size. |
| */ |
| ret--; |
| memcpy(msg->buffer, rxbuf + 1, ret); |
| } |
| break; |
| |
| default: |
| ret = -EINVAL; |
| break; |
| } |
| |
| return ret; |
| } |
| |
| static enum port intel_aux_port(struct drm_i915_private *dev_priv, |
| enum port port) |
| { |
| const struct ddi_vbt_port_info *info = |
| &dev_priv->vbt.ddi_port_info[port]; |
| enum port aux_port; |
| |
| if (!info->alternate_aux_channel) { |
| DRM_DEBUG_KMS("using AUX %c for port %c (platform default)\n", |
| port_name(port), port_name(port)); |
| return port; |
| } |
| |
| switch (info->alternate_aux_channel) { |
| case DP_AUX_A: |
| aux_port = PORT_A; |
| break; |
| case DP_AUX_B: |
| aux_port = PORT_B; |
| break; |
| case DP_AUX_C: |
| aux_port = PORT_C; |
| break; |
| case DP_AUX_D: |
| aux_port = PORT_D; |
| break; |
| default: |
| MISSING_CASE(info->alternate_aux_channel); |
| aux_port = PORT_A; |
| break; |
| } |
| |
| DRM_DEBUG_KMS("using AUX %c for port %c (VBT)\n", |
| port_name(aux_port), port_name(port)); |
| |
| return aux_port; |
| } |
| |
| static i915_reg_t g4x_aux_ctl_reg(struct drm_i915_private *dev_priv, |
| enum port port) |
| { |
| switch (port) { |
| case PORT_B: |
| case PORT_C: |
| case PORT_D: |
| return DP_AUX_CH_CTL(port); |
| default: |
| MISSING_CASE(port); |
| return DP_AUX_CH_CTL(PORT_B); |
| } |
| } |
| |
| static i915_reg_t g4x_aux_data_reg(struct drm_i915_private *dev_priv, |
| enum port port, int index) |
| { |
| switch (port) { |
| case PORT_B: |
| case PORT_C: |
| case PORT_D: |
| return DP_AUX_CH_DATA(port, index); |
| default: |
| MISSING_CASE(port); |
| return DP_AUX_CH_DATA(PORT_B, index); |
| } |
| } |
| |
| static i915_reg_t ilk_aux_ctl_reg(struct drm_i915_private *dev_priv, |
| enum port port) |
| { |
| switch (port) { |
| case PORT_A: |
| return DP_AUX_CH_CTL(port); |
| case PORT_B: |
| case PORT_C: |
| case PORT_D: |
| return PCH_DP_AUX_CH_CTL(port); |
| default: |
| MISSING_CASE(port); |
| return DP_AUX_CH_CTL(PORT_A); |
| } |
| } |
| |
| static i915_reg_t ilk_aux_data_reg(struct drm_i915_private *dev_priv, |
| enum port port, int index) |
| { |
| switch (port) { |
| case PORT_A: |
| return DP_AUX_CH_DATA(port, index); |
| case PORT_B: |
| case PORT_C: |
| case PORT_D: |
| return PCH_DP_AUX_CH_DATA(port, index); |
| default: |
| MISSING_CASE(port); |
| return DP_AUX_CH_DATA(PORT_A, index); |
| } |
| } |
| |
| static i915_reg_t skl_aux_ctl_reg(struct drm_i915_private *dev_priv, |
| enum port port) |
| { |
| switch (port) { |
| case PORT_A: |
| case PORT_B: |
| case PORT_C: |
| case PORT_D: |
| return DP_AUX_CH_CTL(port); |
| default: |
| MISSING_CASE(port); |
| return DP_AUX_CH_CTL(PORT_A); |
| } |
| } |
| |
| static i915_reg_t skl_aux_data_reg(struct drm_i915_private *dev_priv, |
| enum port port, int index) |
| { |
| switch (port) { |
| case PORT_A: |
| case PORT_B: |
| case PORT_C: |
| case PORT_D: |
| return DP_AUX_CH_DATA(port, index); |
| default: |
| MISSING_CASE(port); |
| return DP_AUX_CH_DATA(PORT_A, index); |
| } |
| } |
| |
| static i915_reg_t intel_aux_ctl_reg(struct drm_i915_private *dev_priv, |
| enum port port) |
| { |
| if (INTEL_INFO(dev_priv)->gen >= 9) |
| return skl_aux_ctl_reg(dev_priv, port); |
| else if (HAS_PCH_SPLIT(dev_priv)) |
| return ilk_aux_ctl_reg(dev_priv, port); |
| else |
| return g4x_aux_ctl_reg(dev_priv, port); |
| } |
| |
| static i915_reg_t intel_aux_data_reg(struct drm_i915_private *dev_priv, |
| enum port port, int index) |
| { |
| if (INTEL_INFO(dev_priv)->gen >= 9) |
| return skl_aux_data_reg(dev_priv, port, index); |
| else if (HAS_PCH_SPLIT(dev_priv)) |
| return ilk_aux_data_reg(dev_priv, port, index); |
| else |
| return g4x_aux_data_reg(dev_priv, port, index); |
| } |
| |
| static void intel_aux_reg_init(struct intel_dp *intel_dp) |
| { |
| struct drm_i915_private *dev_priv = to_i915(intel_dp_to_dev(intel_dp)); |
| enum port port = intel_aux_port(dev_priv, |
| dp_to_dig_port(intel_dp)->port); |
| int i; |
| |
| intel_dp->aux_ch_ctl_reg = intel_aux_ctl_reg(dev_priv, port); |
| for (i = 0; i < ARRAY_SIZE(intel_dp->aux_ch_data_reg); i++) |
| intel_dp->aux_ch_data_reg[i] = intel_aux_data_reg(dev_priv, port, i); |
| } |
| |
| static void |
| intel_dp_aux_fini(struct intel_dp *intel_dp) |
| { |
| kfree(intel_dp->aux.name); |
| } |
| |
| static void |
| intel_dp_aux_init(struct intel_dp *intel_dp) |
| { |
| struct intel_digital_port *intel_dig_port = dp_to_dig_port(intel_dp); |
| enum port port = intel_dig_port->port; |
| |
| intel_aux_reg_init(intel_dp); |
| drm_dp_aux_init(&intel_dp->aux); |
| |
| /* Failure to allocate our preferred name is not critical */ |
| intel_dp->aux.name = kasprintf(GFP_KERNEL, "DPDDC-%c", port_name(port)); |
| intel_dp->aux.transfer = intel_dp_aux_transfer; |
| } |
| |
| bool intel_dp_source_supports_hbr2(struct intel_dp *intel_dp) |
| { |
| 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); |
| |
| if ((IS_HASWELL(dev_priv) && !IS_HSW_ULX(dev_priv)) || |
| IS_BROADWELL(dev_priv) || (INTEL_GEN(dev_priv) >= 9)) |
| return true; |
| else |
| return false; |
| } |
| |
| static void |
| intel_dp_set_clock(struct intel_encoder *encoder, |
| struct intel_crtc_state *pipe_config) |
| { |
| struct drm_device *dev = encoder->base.dev; |
| struct drm_i915_private *dev_priv = to_i915(dev); |
| const struct dp_link_dpll *divisor = NULL; |
| int i, count = 0; |
| |
| if (IS_G4X(dev_priv)) { |
| divisor = gen4_dpll; |
| count = ARRAY_SIZE(gen4_dpll); |
| } else if (HAS_PCH_SPLIT(dev_priv)) { |
| divisor = pch_dpll; |
| count = ARRAY_SIZE(pch_dpll); |
| } else if (IS_CHERRYVIEW(dev_priv)) { |
| divisor = chv_dpll; |
| count = ARRAY_SIZE(chv_dpll); |
| } else if (IS_VALLEYVIEW(dev_priv)) { |
| divisor = vlv_dpll; |
| count = ARRAY_SIZE(vlv_dpll); |
| } |
| |
| if (divisor && count) { |
| for (i = 0; i < count; i++) { |
| if (pipe_config->port_clock == divisor[i].clock) { |
| pipe_config->dpll = divisor[i].dpll; |
| pipe_config->clock_set = true; |
| break; |
| } |
| } |
| } |
| } |
| |
| static void snprintf_int_array(char *str, size_t len, |
| const int *array, int nelem) |
| { |
| int i; |
| |
| str[0] = '\0'; |
| |
| for (i = 0; i < nelem; i++) { |
| int r = snprintf(str, len, "%s%d", i ? ", " : "", array[i]); |
| if (r >= len) |
| return; |
| str += r; |
| len -= r; |
| } |
| } |
| |
| static void intel_dp_print_rates(struct intel_dp *intel_dp) |
| { |
| char str[128]; /* FIXME: too big for stack? */ |
| |
| if ((drm_debug & DRM_UT_KMS) == 0) |
| return; |
| |
| snprintf_int_array(str, sizeof(str), |
| intel_dp->source_rates, intel_dp->num_source_rates); |
| DRM_DEBUG_KMS("source rates: %s\n", str); |
| |
| snprintf_int_array(str, sizeof(str), |
| intel_dp->sink_rates, intel_dp->num_sink_rates); |
| DRM_DEBUG_KMS("sink rates: %s\n", str); |
| |
| snprintf_int_array(str, sizeof(str), |
| intel_dp->common_rates, intel_dp->num_common_rates); |
| DRM_DEBUG_KMS("common rates: %s\n", str); |
| } |
| |
| int |
| intel_dp_max_link_rate(struct intel_dp *intel_dp) |
| { |
| int len; |
| |
| len = intel_dp_common_len_rate_limit(intel_dp, intel_dp->max_link_rate); |
| if (WARN_ON(len <= 0)) |
| return 162000; |
| |
| return intel_dp->common_rates[len - 1]; |
| } |
| |
| int intel_dp_rate_select(struct intel_dp *intel_dp, int rate) |
| { |
| int i = intel_dp_rate_index(intel_dp->sink_rates, |
| intel_dp->num_sink_rates, rate); |
| |
| if (WARN_ON(i < 0)) |
| i = 0; |
| |
| return i; |
| } |
| |
| void intel_dp_compute_rate(struct intel_dp *intel_dp, int port_clock, |
| uint8_t *link_bw, uint8_t *rate_select) |
| { |
| /* eDP 1.4 rate select method. */ |
| if (intel_dp->use_rate_select) { |
| *link_bw = 0; |
| *rate_select = |
| intel_dp_rate_select(intel_dp, port_clock); |
| } else { |
| *link_bw = drm_dp_link_rate_to_bw_code(port_clock); |
| *rate_select = 0; |
| } |
| } |
| |
| static int intel_dp_compute_bpp(struct intel_dp *intel_dp, |
| struct intel_crtc_state *pipe_config) |
| { |
| int bpp, bpc; |
| |
| bpp = pipe_config->pipe_bpp; |
| bpc = drm_dp_downstream_max_bpc(intel_dp->dpcd, intel_dp->downstream_ports); |
| |
| if (bpc > 0) |
| bpp = min(bpp, 3*bpc); |
| |
| /* For DP Compliance we override the computed bpp for the pipe */ |
| if (intel_dp->compliance.test_data.bpc != 0) { |
| pipe_config->pipe_bpp = 3*intel_dp->compliance.test_data.bpc; |
| pipe_config->dither_force_disable = pipe_config->pipe_bpp == 6*3; |
| DRM_DEBUG_KMS("Setting pipe_bpp to %d\n", |
| pipe_config->pipe_bpp); |
| } |
| return bpp; |
| } |
| |
| static bool intel_edp_compare_alt_mode(struct drm_display_mode *m1, |
| struct drm_display_mode *m2) |
| { |
| bool bres = false; |
| |
| if (m1 && m2) |
| bres = (m1->hdisplay == m2->hdisplay && |
| m1->hsync_start == m2->hsync_start && |
| m1->hsync_end == m2->hsync_end && |
| m1->htotal == m2->htotal && |
| m1->vdisplay == m2->vdisplay && |
| m1->vsync_start == m2->vsync_start && |
| m1->vsync_end == m2->vsync_end && |
| m1->vtotal == m2->vtotal); |
| return bres; |
| } |
| |
| bool |
| intel_dp_compute_config(struct intel_encoder *encoder, |
| struct intel_crtc_state *pipe_config, |
| struct drm_connector_state *conn_state) |
| { |
| struct drm_i915_private *dev_priv = to_i915(encoder->base.dev); |
| struct drm_display_mode *adjusted_mode = &pipe_config->base.adjusted_mode; |
| struct intel_dp *intel_dp = enc_to_intel_dp(&encoder->base); |
| enum port port = dp_to_dig_port(intel_dp)->port; |
| struct intel_crtc *intel_crtc = to_intel_crtc(pipe_config->base.crtc); |
| struct intel_connector *intel_connector = intel_dp->attached_connector; |
| struct intel_digital_connector_state *intel_conn_state = |
| to_intel_digital_connector_state(conn_state); |
| int lane_count, clock; |
| int min_lane_count = 1; |
| int max_lane_count = intel_dp_max_lane_count(intel_dp); |
| /* Conveniently, the link BW constants become indices with a shift...*/ |
| int min_clock = 0; |
| int max_clock; |
| int bpp, mode_rate; |
| int link_avail, link_clock; |
| int common_len; |
| uint8_t link_bw, rate_select; |
| bool reduce_m_n = drm_dp_has_quirk(&intel_dp->desc, |
| DP_DPCD_QUIRK_LIMITED_M_N); |
| |
| common_len = intel_dp_common_len_rate_limit(intel_dp, |
| intel_dp->max_link_rate); |
| |
| /* No common link rates between source and sink */ |
| WARN_ON(common_len <= 0); |
| |
| max_clock = common_len - 1; |
| |
| if (HAS_PCH_SPLIT(dev_priv) && !HAS_DDI(dev_priv) && port != PORT_A) |
| pipe_config->has_pch_encoder = true; |
| |
| pipe_config->has_drrs = false; |
| if (port == PORT_A) |
| pipe_config->has_audio = false; |
| else if (intel_conn_state->force_audio == HDMI_AUDIO_AUTO) |
| pipe_config->has_audio = intel_dp->has_audio; |
| else |
| pipe_config->has_audio = intel_conn_state->force_audio == HDMI_AUDIO_ON; |
| |
| if (is_edp(intel_dp) && intel_connector->panel.fixed_mode) { |
| struct drm_display_mode *panel_mode = |
| intel_connector->panel.alt_fixed_mode; |
| struct drm_display_mode *req_mode = &pipe_config->base.mode; |
| |
| if (!intel_edp_compare_alt_mode(req_mode, panel_mode)) |
| panel_mode = intel_connector->panel.fixed_mode; |
| |
| drm_mode_debug_printmodeline(panel_mode); |
| |
| intel_fixed_panel_mode(panel_mode, adjusted_mode); |
| |
| if (INTEL_GEN(dev_priv) >= 9) { |
| int ret; |
| ret = skl_update_scaler_crtc(pipe_config); |
| if (ret) |
| return ret; |
| } |
| |
| if (HAS_GMCH_DISPLAY(dev_priv)) |
| intel_gmch_panel_fitting(intel_crtc, pipe_config, |
| conn_state->scaling_mode); |
| else |
| intel_pch_panel_fitting(intel_crtc, pipe_config, |
| conn_state->scaling_mode); |
| } |
| |
| if (adjusted_mode->flags & DRM_MODE_FLAG_DBLCLK) |
| return false; |
| |
| /* Use values requested by Compliance Test Request */ |
| if (intel_dp->compliance.test_type == DP_TEST_LINK_TRAINING) { |
| int index; |
| |
| /* Validate the compliance test data since max values |
| * might have changed due to link train fallback. |
| */ |
| if (intel_dp_link_params_valid(intel_dp, intel_dp->compliance.test_link_rate, |
| intel_dp->compliance.test_lane_count)) { |
| index = intel_dp_rate_index(intel_dp->common_rates, |
| intel_dp->num_common_rates, |
| intel_dp->compliance.test_link_rate); |
| if (index >= 0) |
| min_clock = max_clock = index; |
| min_lane_count = max_lane_count = intel_dp->compliance.test_lane_count; |
| } |
| } |
| DRM_DEBUG_KMS("DP link computation with max lane count %i " |
| "max bw %d pixel clock %iKHz\n", |
| max_lane_count, intel_dp->common_rates[max_clock], |
| adjusted_mode->crtc_clock); |
| |
| /* Walk through all bpp values. Luckily they're all nicely spaced with 2 |
| * bpc in between. */ |
| bpp = intel_dp_compute_bpp(intel_dp, pipe_config); |
| if (is_edp(intel_dp)) { |
| |
| /* Get bpp from vbt only for panels that dont have bpp in edid */ |
| if (intel_connector->base.display_info.bpc == 0 && |
| (dev_priv->vbt.edp.bpp && dev_priv->vbt.edp.bpp < bpp)) { |
| DRM_DEBUG_KMS("clamping bpp for eDP panel to BIOS-provided %i\n", |
| dev_priv->vbt.edp.bpp); |
| bpp = dev_priv->vbt.edp.bpp; |
| } |
| |
| /* |
| * Use the maximum clock and number of lanes the eDP panel |
| * advertizes being capable of. The panels are generally |
| * designed to support only a single clock and lane |
| * configuration, and typically these values correspond to the |
| * native resolution of the panel. |
| */ |
| min_lane_count = max_lane_count; |
| min_clock = max_clock; |
| } |
| |
| for (; bpp >= 6*3; bpp -= 2*3) { |
| mode_rate = intel_dp_link_required(adjusted_mode->crtc_clock, |
| bpp); |
| |
| for (clock = min_clock; clock <= max_clock; clock++) { |
| for (lane_count = min_lane_count; |
| lane_count <= max_lane_count; |
| lane_count <<= 1) { |
| |
| link_clock = intel_dp->common_rates[clock]; |
| link_avail = intel_dp_max_data_rate(link_clock, |
| lane_count); |
| |
| if (mode_rate <= link_avail) { |
| goto found; |
| } |
| } |
| } |
| } |
| |
| return false; |
| |
| found: |
| if (intel_conn_state->broadcast_rgb == INTEL_BROADCAST_RGB_AUTO) { |
| /* |
| * See: |
| * CEA-861-E - 5.1 Default Encoding Parameters |
| * VESA DisplayPort Ver.1.2a - 5.1.1.1 Video Colorimetry |
| */ |
| pipe_config->limited_color_range = |
| bpp != 18 && |
| drm_default_rgb_quant_range(adjusted_mode) == |
| HDMI_QUANTIZATION_RANGE_LIMITED; |
| } else { |
| pipe_config->limited_color_range = |
| intel_conn_state->broadcast_rgb == INTEL_BROADCAST_RGB_LIMITED; |
| } |
| |
| pipe_config->lane_count = lane_count; |
| |
| pipe_config->pipe_bpp = bpp; |
| pipe_config->port_clock = intel_dp->common_rates[clock]; |
| |
| intel_dp_compute_rate(intel_dp, pipe_config->port_clock, |
| &link_bw, &rate_select); |
| |
| DRM_DEBUG_KMS("DP link bw %02x rate select %02x lane count %d clock %d bpp %d\n", |
| link_bw, rate_select, pipe_config->lane_count, |
| pipe_config->port_clock, bpp); |
| DRM_DEBUG_KMS("DP link bw required %i available %i\n", |
| mode_rate, link_avail); |
| |
| intel_link_compute_m_n(bpp, lane_count, |
| adjusted_mode->crtc_clock, |
| pipe_config->port_clock, |
| &pipe_config->dp_m_n, |
| reduce_m_n); |
| |
| if (intel_connector->panel.downclock_mode != NULL && |
| dev_priv->drrs.type == SEAMLESS_DRRS_SUPPORT) { |
| pipe_config->has_drrs = true; |
| intel_link_compute_m_n(bpp, lane_count, |
| intel_connector->panel.downclock_mode->clock, |
| pipe_config->port_clock, |
| &pipe_config->dp_m2_n2, |
| reduce_m_n); |
| } |
| |
| /* |
| * DPLL0 VCO may need to be adjusted to get the correct |
| * clock for eDP. This will affect cdclk as well. |
| */ |
| if (is_edp(intel_dp) && IS_GEN9_BC(dev_priv)) { |
| int vco; |
| |
| switch (pipe_config->port_clock / 2) { |
| case 108000: |
| case 216000: |
| vco = 8640000; |
| break; |
| default: |
| vco = 8100000; |
| break; |
| } |
| |
| to_intel_atomic_state(pipe_config->base.state)->cdclk.logical.vco = vco; |
| } |
| |
| if (!HAS_DDI(dev_priv)) |
| intel_dp_set_clock(encoder, pipe_config); |
| |
| return true; |
| } |
| |
| void intel_dp_set_link_params(struct intel_dp *intel_dp, |
| int link_rate, uint8_t lane_count, |
| bool link_mst) |
| { |
| intel_dp->link_rate = link_rate; |
| intel_dp->lane_count = lane_count; |
| intel_dp->link_mst = link_mst; |
| } |
| |
| static void intel_dp_prepare(struct intel_encoder *encoder, |
| struct intel_crtc_state *pipe_config) |
| { |
| struct drm_device *dev = encoder->base.dev; |
| struct drm_i915_private *dev_priv = to_i915(dev); |
| struct intel_dp *intel_dp = enc_to_intel_dp(&encoder->base); |
| enum port port = dp_to_dig_port(intel_dp)->port; |
| struct intel_crtc *crtc = to_intel_crtc(encoder->base.crtc); |
| const struct drm_display_mode *adjusted_mode = &pipe_config->base.adjusted_mode; |
| |
| intel_dp_set_link_params(intel_dp, pipe_config->port_clock, |
| pipe_config->lane_count, |
| intel_crtc_has_type(pipe_config, |
| INTEL_OUTPUT_DP_MST)); |
| |
| /* |
| * There are four kinds of DP registers: |
| * |
| * IBX PCH |
| * SNB CPU |
| * IVB CPU |
| * CPT PCH |
| * |
| * IBX PCH and CPU are the same for almost everything, |
| * except that the CPU DP PLL is configured in this |
| * register |
| * |
| * CPT PCH is quite different, having many bits moved |
| * to the TRANS_DP_CTL register instead. That |
| * configuration happens (oddly) in ironlake_pch_enable |
| */ |
| |
| /* Preserve the BIOS-computed detected bit. This is |
| * supposed to be read-only. |
| */ |
| intel_dp->DP = I915_READ(intel_dp->output_reg) & DP_DETECTED; |
| |
| /* Handle DP bits in common between all three register formats */ |
| intel_dp->DP |= DP_VOLTAGE_0_4 | DP_PRE_EMPHASIS_0; |
| intel_dp->DP |= DP_PORT_WIDTH(pipe_config->lane_count); |
| |
| /* Split out the IBX/CPU vs CPT settings */ |
| |
| if (IS_GEN7(dev_priv) && port == PORT_A) { |
| if (adjusted_mode->flags & DRM_MODE_FLAG_PHSYNC) |
| intel_dp->DP |= DP_SYNC_HS_HIGH; |
| if (adjusted_mode->flags & DRM_MODE_FLAG_PVSYNC) |
| intel_dp->DP |= DP_SYNC_VS_HIGH; |
| intel_dp->DP |= DP_LINK_TRAIN_OFF_CPT; |
| |
| if (drm_dp_enhanced_frame_cap(intel_dp->dpcd)) |
| intel_dp->DP |= DP_ENHANCED_FRAMING; |
| |
| intel_dp->DP |= crtc->pipe << 29; |
| } else if (HAS_PCH_CPT(dev_priv) && port != PORT_A) { |
| u32 trans_dp; |
| |
| intel_dp->DP |= DP_LINK_TRAIN_OFF_CPT; |
| |
| trans_dp = I915_READ(TRANS_DP_CTL(crtc->pipe)); |
| if (drm_dp_enhanced_frame_cap(intel_dp->dpcd)) |
| trans_dp |= TRANS_DP_ENH_FRAMING; |
| else |
| trans_dp &= ~TRANS_DP_ENH_FRAMING; |
| I915_WRITE(TRANS_DP_CTL(crtc->pipe), trans_dp); |
| } else { |
| if (IS_G4X(dev_priv) && pipe_config->limited_color_range) |
| intel_dp->DP |= DP_COLOR_RANGE_16_235; |
| |
| if (adjusted_mode->flags & DRM_MODE_FLAG_PHSYNC) |
| intel_dp->DP |= DP_SYNC_HS_HIGH; |
| if (adjusted_mode->flags & DRM_MODE_FLAG_PVSYNC) |
| intel_dp->DP |= DP_SYNC_VS_HIGH; |
| intel_dp->DP |= DP_LINK_TRAIN_OFF; |
| |
| if (drm_dp_enhanced_frame_cap(intel_dp->dpcd)) |
| intel_dp->DP |= DP_ENHANCED_FRAMING; |
| |
| if (IS_CHERRYVIEW(dev_priv)) |
| intel_dp->DP |= DP_PIPE_SELECT_CHV(crtc->pipe); |
| else if (crtc->pipe == PIPE_B) |
| intel_dp->DP |= DP_PIPEB_SELECT; |
| } |
| } |
| |
| #define IDLE_ON_MASK (PP_ON | PP_SEQUENCE_MASK | 0 | PP_SEQUENCE_STATE_MASK) |
| #define IDLE_ON_VALUE (PP_ON | PP_SEQUENCE_NONE | 0 | PP_SEQUENCE_STATE_ON_IDLE) |
| |
| #define IDLE_OFF_MASK (PP_ON | PP_SEQUENCE_MASK | 0 | 0) |
| #define IDLE_OFF_VALUE (0 | PP_SEQUENCE_NONE | 0 | 0) |
| |
| #define IDLE_CYCLE_MASK (PP_ON | PP_SEQUENCE_MASK | PP_CYCLE_DELAY_ACTIVE | PP_SEQUENCE_STATE_MASK) |
| #define IDLE_CYCLE_VALUE (0 | PP_SEQUENCE_NONE | 0 | PP_SEQUENCE_STATE_OFF_IDLE) |
| |
| static void intel_pps_verify_state(struct drm_i915_private *dev_priv, |
| struct intel_dp *intel_dp); |
| |
| static void wait_panel_status(struct intel_dp *intel_dp, |
| u32 mask, |
| u32 value) |
| { |
| struct drm_device *dev = intel_dp_to_dev(intel_dp); |
| struct drm_i915_private *dev_priv = to_i915(dev); |
| i915_reg_t pp_stat_reg, pp_ctrl_reg; |
| |
| lockdep_assert_held(&dev_priv->pps_mutex); |
| |
| intel_pps_verify_state(dev_priv, intel_dp); |
| |
| pp_stat_reg = _pp_stat_reg(intel_dp); |
| pp_ctrl_reg = _pp_ctrl_reg(intel_dp); |
| |
| DRM_DEBUG_KMS("mask %08x value %08x status %08x control %08x\n", |
| mask, value, |
| I915_READ(pp_stat_reg), |
| I915_READ(pp_ctrl_reg)); |
| |
| if (intel_wait_for_register(dev_priv, |
| pp_stat_reg, mask, value, |
| 5000)) |
| DRM_ERROR("Panel status timeout: status %08x control %08x\n", |
| I915_READ(pp_stat_reg), |
| I915_READ(pp_ctrl_reg)); |
| |
| DRM_DEBUG_KMS("Wait complete\n"); |
| } |
| |
| static void wait_panel_on(struct intel_dp *intel_dp) |
| { |
| DRM_DEBUG_KMS("Wait for panel power on\n"); |
| wait_panel_status(intel_dp, IDLE_ON_MASK, IDLE_ON_VALUE); |
| } |
| |
| static void wait_panel_off(struct intel_dp *intel_dp) |
| { |
| DRM_DEBUG_KMS("Wait for panel power off time\n"); |
| wait_panel_status(intel_dp, IDLE_OFF_MASK, IDLE_OFF_VALUE); |
| } |
| |
| static void wait_panel_power_cycle(struct intel_dp *intel_dp) |
| { |
| ktime_t panel_power_on_time; |
| s64 panel_power_off_duration; |
| |
| DRM_DEBUG_KMS("Wait for panel power cycle\n"); |
| |
| /* take the difference of currrent time and panel power off time |
| * and then make panel wait for t11_t12 if needed. */ |
| panel_power_on_time = ktime_get_boottime(); |
| panel_power_off_duration = ktime_ms_delta(panel_power_on_time, intel_dp->panel_power_off_time); |
| |
| /* When we disable the VDD override bit last we have to do the manual |
| * wait. */ |
| if (panel_power_off_duration < (s64)intel_dp->panel_power_cycle_delay) |
| wait_remaining_ms_from_jiffies(jiffies, |
| intel_dp->panel_power_cycle_delay - panel_power_off_duration); |
| |
| wait_panel_status(intel_dp, IDLE_CYCLE_MASK, IDLE_CYCLE_VALUE); |
| } |
| |
| static void wait_backlight_on(struct intel_dp *intel_dp) |
| { |
| wait_remaining_ms_from_jiffies(intel_dp->last_power_on, |
| intel_dp->backlight_on_delay); |
| } |
| |
| static void edp_wait_backlight_off(struct intel_dp *intel_dp) |
| { |
| wait_remaining_ms_from_jiffies(intel_dp->last_backlight_off, |
| intel_dp->backlight_off_delay); |
| } |
| |
| /* Read the current pp_control value, unlocking the register if it |
| * is locked |
| */ |
| |
| static u32 ironlake_get_pp_control(struct intel_dp *intel_dp) |
| { |
| struct drm_device *dev = intel_dp_to_dev(intel_dp); |
| struct drm_i915_private *dev_priv = to_i915(dev); |
| u32 control; |
| |
| lockdep_assert_held(&dev_priv->pps_mutex); |
| |
| control = I915_READ(_pp_ctrl_reg(intel_dp)); |
| if (WARN_ON(!HAS_DDI(dev_priv) && |
| (control & PANEL_UNLOCK_MASK) != PANEL_UNLOCK_REGS)) { |
| control &= ~PANEL_UNLOCK_MASK; |
| control |= PANEL_UNLOCK_REGS; |
| } |
| return control; |
| } |
| |
| /* |
| * Must be paired with edp_panel_vdd_off(). |
| * Must hold pps_mutex around the whole on/off sequence. |
| * Can be nested with intel_edp_panel_vdd_{on,off}() calls. |
| */ |
| static bool edp_panel_vdd_on(struct intel_dp *intel_dp) |
| { |
| struct drm_device *dev = intel_dp_to_dev(intel_dp); |
| struct intel_digital_port *intel_dig_port = dp_to_dig_port(intel_dp); |
| struct drm_i915_private *dev_priv = to_i915(dev); |
| u32 pp; |
| i915_reg_t pp_stat_reg, pp_ctrl_reg; |
| bool need_to_disable = !intel_dp->want_panel_vdd; |
| |
| lockdep_assert_held(&dev_priv->pps_mutex); |
| |
| if (!is_edp(intel_dp)) |
| return false; |
| |
| cancel_delayed_work(&intel_dp->panel_vdd_work); |
| intel_dp->want_panel_vdd = true; |
| |
| if (edp_have_panel_vdd(intel_dp)) |
| return need_to_disable; |
| |
| intel_display_power_get(dev_priv, intel_dp->aux_power_domain); |
| |
| DRM_DEBUG_KMS("Turning eDP port %c VDD on\n", |
| port_name(intel_dig_port->port)); |
| |
| if (!edp_have_panel_power(intel_dp)) |
| wait_panel_power_cycle(intel_dp); |
| |
| pp = ironlake_get_pp_control(intel_dp); |
| pp |= EDP_FORCE_VDD; |
| |
| pp_stat_reg = _pp_stat_reg(intel_dp); |
| pp_ctrl_reg = _pp_ctrl_reg(intel_dp); |
| |
| I915_WRITE(pp_ctrl_reg, pp); |
| POSTING_READ(pp_ctrl_reg); |
| DRM_DEBUG_KMS("PP_STATUS: 0x%08x PP_CONTROL: 0x%08x\n", |
| I915_READ(pp_stat_reg), I915_READ(pp_ctrl_reg)); |
| /* |
| * If the panel wasn't on, delay before accessing aux channel |
| */ |
| if (!edp_have_panel_power(intel_dp)) { |
| DRM_DEBUG_KMS("eDP port %c panel power wasn't enabled\n", |
| port_name(intel_dig_port->port)); |
| msleep(intel_dp->panel_power_up_delay); |
| } |
| |
| return need_to_disable; |
| } |
| |
| /* |
| * Must be paired with intel_edp_panel_vdd_off() or |
| * intel_edp_panel_off(). |
| * Nested calls to these functions are not allowed since |
| * we drop the lock. Caller must use some higher level |
| * locking to prevent nested calls from other threads. |
| */ |
| void intel_edp_panel_vdd_on(struct intel_dp *intel_dp) |
| { |
| bool vdd; |
| |
| if (!is_edp(intel_dp)) |
| return; |
| |
| pps_lock(intel_dp); |
| vdd = edp_panel_vdd_on(intel_dp); |
| pps_unlock(intel_dp); |
| |
| I915_STATE_WARN(!vdd, "eDP port %c VDD already requested on\n", |
| port_name(dp_to_dig_port(intel_dp)->port)); |
| } |
| |
| static void edp_panel_vdd_off_sync(struct intel_dp *intel_dp) |
| { |
| struct drm_device *dev = intel_dp_to_dev(intel_dp); |
| struct drm_i915_private *dev_priv = to_i915(dev); |
| struct intel_digital_port *intel_dig_port = |
| dp_to_dig_port(intel_dp); |
| u32 pp; |
| i915_reg_t pp_stat_reg, pp_ctrl_reg; |
| |
| lockdep_assert_held(&dev_priv->pps_mutex); |
| |
| WARN_ON(intel_dp->want_panel_vdd); |
| |
| if (!edp_have_panel_vdd(intel_dp)) |
| return; |
| |
| DRM_DEBUG_KMS("Turning eDP port %c VDD off\n", |
| port_name(intel_dig_port->port)); |
| |
| pp = ironlake_get_pp_control(intel_dp); |
| pp &= ~EDP_FORCE_VDD; |
| |
| pp_ctrl_reg = _pp_ctrl_reg(intel_dp); |
| pp_stat_reg = _pp_stat_reg(intel_dp); |
| |
| I915_WRITE(pp_ctrl_reg, pp); |
| POSTING_READ(pp_ctrl_reg); |
| |
| /* Make sure sequencer is idle before allowing subsequent activity */ |
| DRM_DEBUG_KMS("PP_STATUS: 0x%08x PP_CONTROL: 0x%08x\n", |
| I915_READ(pp_stat_reg), I915_READ(pp_ctrl_reg)); |
| |
| if ((pp & PANEL_POWER_ON) == 0) |
| intel_dp->panel_power_off_time = ktime_get_boottime(); |
| |
| intel_display_power_put(dev_priv, intel_dp->aux_power_domain); |
| } |
| |
| static void edp_panel_vdd_work(struct work_struct *__work) |
| { |
| struct intel_dp *intel_dp = container_of(to_delayed_work(__work), |
| struct intel_dp, panel_vdd_work); |
| |
| pps_lock(intel_dp); |
| if (!intel_dp->want_panel_vdd) |
| edp_panel_vdd_off_sync(intel_dp); |
| pps_unlock(intel_dp); |
| } |
| |
| static void edp_panel_vdd_schedule_off(struct intel_dp *intel_dp) |
| { |
| unsigned long delay; |
| |
| /* |
| * Queue the timer to fire a long time from now (relative to the power |
| * down delay) to keep the panel power up across a sequence of |
| * operations. |
| */ |
| delay = msecs_to_jiffies(intel_dp->panel_power_cycle_delay * 5); |
| schedule_delayed_work(&intel_dp->panel_vdd_work, delay); |
| } |
| |
| /* |
| * Must be paired with edp_panel_vdd_on(). |
| * Must hold pps_mutex around the whole on/off sequence. |
| * Can be nested with intel_edp_panel_vdd_{on,off}() calls. |
| */ |
| static void edp_panel_vdd_off(struct intel_dp *intel_dp, bool sync) |
| { |
| struct drm_i915_private *dev_priv = to_i915(intel_dp_to_dev(intel_dp)); |
| |
| lockdep_assert_held(&dev_priv->pps_mutex); |
| |
| if (!is_edp(intel_dp)) |
| return; |
| |
| I915_STATE_WARN(!intel_dp->want_panel_vdd, "eDP port %c VDD not forced on", |
| port_name(dp_to_dig_port(intel_dp)->port)); |
| |
| intel_dp->want_panel_vdd = false; |
| |
| if (sync) |
| edp_panel_vdd_off_sync(intel_dp); |
| else |
| edp_panel_vdd_schedule_off(intel_dp); |
| } |
| |
| static void edp_panel_on(struct intel_dp *intel_dp) |
| { |
| struct drm_device *dev = intel_dp_to_dev(intel_dp); |
| struct drm_i915_private *dev_priv = to_i915(dev); |
| u32 pp; |
| i915_reg_t pp_ctrl_reg; |
| |
| lockdep_assert_held(&dev_priv->pps_mutex); |
| |
| if (!is_edp(intel_dp)) |
| return; |
| |
| DRM_DEBUG_KMS("Turn eDP port %c panel power on\n", |
| port_name(dp_to_dig_port(intel_dp)->port)); |
| |
| if (WARN(edp_have_panel_power(intel_dp), |
| "eDP port %c panel power already on\n", |
| port_name(dp_to_dig_port(intel_dp)->port))) |
| return; |
| |
| wait_panel_power_cycle(intel_dp); |
| |
| pp_ctrl_reg = _pp_ctrl_reg(intel_dp); |
| pp = ironlake_get_pp_control(intel_dp); |
| if (IS_GEN5(dev_priv)) { |
| /* ILK workaround: disable reset around power sequence */ |
| pp &= ~PANEL_POWER_RESET; |
| I915_WRITE(pp_ctrl_reg, pp); |
| POSTING_READ(pp_ctrl_reg); |
| } |
| |
| pp |= PANEL_POWER_ON; |
| if (!IS_GEN5(dev_priv)) |
| pp |= PANEL_POWER_RESET; |
| |
| I915_WRITE(pp_ctrl_reg, pp); |
| POSTING_READ(pp_ctrl_reg); |
| |
| wait_panel_on(intel_dp); |
| intel_dp->last_power_on = jiffies; |
| |
| if (IS_GEN5(dev_priv)) { |
| pp |= PANEL_POWER_RESET; /* restore panel reset bit */ |
| I915_WRITE(pp_ctrl_reg, pp); |
| POSTING_READ(pp_ctrl_reg); |
| } |
| } |
| |
| void intel_edp_panel_on(struct intel_dp *intel_dp) |
| { |
| if (!is_edp(intel_dp)) |
| return; |
| |
| pps_lock(intel_dp); |
| edp_panel_on(intel_dp); |
| pps_unlock(intel_dp); |
| } |
| |
| |
| static void edp_panel_off(struct intel_dp *intel_dp) |
| { |
| struct drm_device *dev = intel_dp_to_dev(intel_dp); |
| struct drm_i915_private *dev_priv = to_i915(dev); |
| u32 pp; |
| i915_reg_t pp_ctrl_reg; |
| |
| lockdep_assert_held(&dev_priv->pps_mutex); |
| |
| if (!is_edp(intel_dp)) |
| return; |
| |
| DRM_DEBUG_KMS("Turn eDP port %c panel power off\n", |
| port_name(dp_to_dig_port(intel_dp)->port)); |
| |
| WARN(!intel_dp->want_panel_vdd, "Need eDP port %c VDD to turn off panel\n", |
| port_name(dp_to_dig_port(intel_dp)->port)); |
| |
| pp = ironlake_get_pp_control(intel_dp); |
| /* We need to switch off panel power _and_ force vdd, for otherwise some |
| * panels get very unhappy and cease to work. */ |
| pp &= ~(PANEL_POWER_ON | PANEL_POWER_RESET | EDP_FORCE_VDD | |
| EDP_BLC_ENABLE); |
| |
| pp_ctrl_reg = _pp_ctrl_reg(intel_dp); |
| |
| intel_dp->want_panel_vdd = false; |
| |
| I915_WRITE(pp_ctrl_reg, pp); |
| POSTING_READ(pp_ctrl_reg); |
| |
| wait_panel_off(intel_dp); |
| intel_dp->panel_power_off_time = ktime_get_boottime(); |
| |
| /* We got a reference when we enabled the VDD. */ |
| intel_display_power_put(dev_priv, intel_dp->aux_power_domain); |
| } |
| |
| void intel_edp_panel_off(struct intel_dp *intel_dp) |
| { |
| if (!is_edp(intel_dp)) |
| return; |
| |
| pps_lock(intel_dp); |
| edp_panel_off(intel_dp); |
| pps_unlock(intel_dp); |
| } |
| |
| /* Enable backlight in the panel power control. */ |
| static void _intel_edp_backlight_on(struct intel_dp *intel_dp) |
| { |
| struct intel_digital_port *intel_dig_port = dp_to_dig_port(intel_dp); |
| struct drm_device *dev = intel_dig_port->base.base.dev; |
| struct drm_i915_private *dev_priv = to_i915(dev); |
| u32 pp; |
| i915_reg_t pp_ctrl_reg; |
| |
| /* |
| * If we enable the backlight right away following a panel power |
| * on, we may see slight flicker as the panel syncs with the eDP |
| * link. So delay a bit to make sure the image is solid before |
| * allowing it to appear. |
| */ |
| wait_backlight_on(intel_dp); |
| |
| pps_lock(intel_dp); |
| |
| pp = ironlake_get_pp_control(intel_dp); |
| pp |= EDP_BLC_ENABLE; |
| |
| pp_ctrl_reg = _pp_ctrl_reg(intel_dp); |
| |
| I915_WRITE(pp_ctrl_reg, pp); |
| POSTING_READ(pp_ctrl_reg); |
| |
| pps_unlock(intel_dp); |
| } |
| |
| /* Enable backlight PWM and backlight PP control. */ |
| void intel_edp_backlight_on(const struct intel_crtc_state *crtc_state, |
| const struct drm_connector_state *conn_state) |
| { |
| struct intel_dp *intel_dp = enc_to_intel_dp(conn_state->best_encoder); |
| |
| if (!is_edp(intel_dp)) |
| return; |
| |
| DRM_DEBUG_KMS("\n"); |
| |
| intel_panel_enable_backlight(crtc_state, conn_state); |
| _intel_edp_backlight_on(intel_dp); |
| } |
| |
| /* Disable backlight in the panel power control. */ |
| static void _intel_edp_backlight_off(struct intel_dp *intel_dp) |
| { |
| struct drm_device *dev = intel_dp_to_dev(intel_dp); |
| struct drm_i915_private *dev_priv = to_i915(dev); |
| u32 pp; |
| i915_reg_t pp_ctrl_reg; |
| |
| if (!is_edp(intel_dp)) |
| return; |
| |
| pps_lock(intel_dp); |
| |
| pp = ironlake_get_pp_control(intel_dp); |
| pp &= ~EDP_BLC_ENABLE; |
| |
| pp_ctrl_reg = _pp_ctrl_reg(intel_dp); |
| |
| I915_WRITE(pp_ctrl_reg, pp); |
| POSTING_READ(pp_ctrl_reg); |
| |
| pps_unlock(intel_dp); |
| |
| intel_dp->last_backlight_off = jiffies; |
| edp_wait_backlight_off(intel_dp); |
| } |
| |
| /* Disable backlight PP control and backlight PWM. */ |
| void intel_edp_backlight_off(const struct drm_connector_state *old_conn_state) |
| { |
| struct intel_dp *intel_dp = enc_to_intel_dp(old_conn_state->best_encoder); |
| |
| if (!is_edp(intel_dp)) |
| return; |
| |
| DRM_DEBUG_KMS("\n"); |
| |
| _intel_edp_backlight_off(intel_dp); |
| intel_panel_disable_backlight(old_conn_state); |
| } |
| |
| /* |
| * Hook for controlling the panel power control backlight through the bl_power |
| * sysfs attribute. Take care to handle multiple calls. |
| */ |
| static void intel_edp_backlight_power(struct intel_connector *connector, |
| bool enable) |
| { |
| struct intel_dp *intel_dp = intel_attached_dp(&connector->base); |
| bool is_enabled; |
| |
| pps_lock(intel_dp); |
| is_enabled = ironlake_get_pp_control(intel_dp) & EDP_BLC_ENABLE; |
| pps_unlock(intel_dp); |
| |
| if (is_enabled == enable) |
| return; |
| |
| DRM_DEBUG_KMS("panel power control backlight %s\n", |
| enable ? "enable" : "disable"); |
| |
| if (enable) |
| _intel_edp_backlight_on(intel_dp); |
| else |
| _intel_edp_backlight_off(intel_dp); |
| } |
| |
| 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), |
| onoff(state), onoff(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", |
| onoff(state), onoff(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_crtc_state *pipe_config) |
| { |
| struct intel_crtc *crtc = to_intel_crtc(pipe_config->base.crtc); |
| struct drm_i915_private *dev_priv = to_i915(crtc->base.dev); |
| |
| assert_pipe_disabled(dev_priv, crtc->pipe); |
| assert_dp_port_disabled(intel_dp); |
| assert_edp_pll_disabled(dev_priv); |
| |
| DRM_DEBUG_KMS("enabling eDP PLL for clock %d\n", |
| pipe_config->port_clock); |
| |
| intel_dp->DP &= ~DP_PLL_FREQ_MASK; |
| |
| if (pipe_config->port_clock == 162000) |
| intel_dp->DP |= DP_PLL_FREQ_162MHZ; |
| else |
| intel_dp->DP |= DP_PLL_FREQ_270MHZ; |
| |
| I915_WRITE(DP_A, intel_dp->DP); |
| POSTING_READ(DP_A); |
| udelay(500); |
| |
| /* |
| * [DevILK] Work around required when enabling DP PLL |
| * while a pipe is enabled going to FDI: |
| * 1. Wait for the start of vertical blank on the enabled pipe going to FDI |
| * 2. Program DP PLL enable |
| */ |
| if (IS_GEN5(dev_priv)) |
| intel_wait_for_vblank_if_active(dev_priv, !crtc->pipe); |
| |
| intel_dp->DP |= DP_PLL_ENABLE; |
| |
| I915_WRITE(DP_A, intel_dp->DP); |
| POSTING_READ(DP_A); |
| udelay(200); |
| } |
| |
| 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 intel_crtc *crtc = to_intel_crtc(intel_dig_port->base.base.crtc); |
| struct drm_i915_private *dev_priv = to_i915(crtc->base.dev); |
| |
| assert_pipe_disabled(dev_priv, crtc->pipe); |
| assert_dp_port_disabled(intel_dp); |
| assert_edp_pll_enabled(dev_priv); |
| |
| DRM_DEBUG_KMS("disabling eDP PLL\n"); |
| |
| intel_dp->DP &= ~DP_PLL_ENABLE; |
| |
| I915_WRITE(DP_A, intel_dp->DP); |
| POSTING_READ(DP_A); |
| udelay(200); |
| } |
| |
| /* If the sink supports it, try to set the power state appropriately */ |
| void intel_dp_sink_dpms(struct intel_dp *intel_dp, int mode) |
| { |
| int ret, i; |
| |
| /* Should have a valid DPCD by this point */ |
| if (intel_dp->dpcd[DP_DPCD_REV] < 0x11) |
| return; |
| |
| if (mode != DRM_MODE_DPMS_ON) { |
| ret = drm_dp_dpcd_writeb(&intel_dp->aux, DP_SET_POWER, |
| DP_SET_POWER_D3); |
| } else { |
| struct intel_lspcon *lspcon = dp_to_lspcon(intel_dp); |
| |
| /* |
| * When turning on, we need to retry for 1ms to give the sink |
| * time to wake up. |
| */ |
| for (i = 0; i < 3; i++) { |
| ret = drm_dp_dpcd_writeb(&intel_dp->aux, DP_SET_POWER, |
| DP_SET_POWER_D0); |
| if (ret == 1) |
| break; |
| msleep(1); |
| } |
| |
| if (ret == 1 && lspcon->active) |
| lspcon_wait_pcon_mode(lspcon); |
| } |
| |
| if (ret != 1) |
| DRM_DEBUG_KMS("failed to %s sink power state\n", |
| mode == DRM_MODE_DPMS_ON ? "enable" : "disable"); |
| } |
| |
| static bool intel_dp_get_hw_state(struct intel_encoder *encoder, |
| enum pipe *pipe) |
| { |
| struct intel_dp *intel_dp = enc_to_intel_dp(&encoder->base); |
| enum port port = dp_to_dig_port(intel_dp)->port; |
| struct drm_device *dev = encoder->base.dev; |
| struct drm_i915_private *dev_priv = to_i915(dev); |
| u32 tmp; |
| bool ret; |
| |
| if (!intel_display_power_get_if_enabled(dev_priv, |
| encoder->power_domain)) |
| return false; |
| |
| ret = false; |
| |
| tmp = I915_READ(intel_dp->output_reg); |
| |
| if (!(tmp & DP_PORT_EN)) |
| goto out; |
| |
| if (IS_GEN7(dev_priv) && port == PORT_A) { |
| *pipe = PORT_TO_PIPE_CPT(tmp); |
| } else if (HAS_PCH_CPT(dev_priv) && port != PORT_A) { |
| enum pipe p; |
| |
| for_each_pipe(dev_priv, p) { |
| u32 trans_dp = I915_READ(TRANS_DP_CTL(p)); |
| if (TRANS_DP_PIPE_TO_PORT(trans_dp) == port) { |
| *pipe = p; |
| ret = true; |
| |
| goto out; |
| } |
| } |
| |
| DRM_DEBUG_KMS("No pipe for dp port 0x%x found\n", |
| i915_mmio_reg_offset(intel_dp->output_reg)); |
| } else if (IS_CHERRYVIEW(dev_priv)) { |
| *pipe = DP_PORT_TO_PIPE_CHV(tmp); |
| } else { |
| *pipe = PORT_TO_PIPE(tmp); |
| } |
| |
| ret = true; |
| |
| out: |
| intel_display_power_put(dev_priv, encoder->power_domain); |
| |
| return ret; |
| } |
| |
| static void intel_dp_get_config(struct intel_encoder *encoder, |
| struct intel_crtc_state *pipe_config) |
| { |
| struct intel_dp *intel_dp = enc_to_intel_dp(&encoder->base); |
| u32 tmp, flags = 0; |
| struct drm_device *dev = encoder->base.dev; |
| struct drm_i915_private *dev_priv = to_i915(dev); |
| enum port port = dp_to_dig_port(intel_dp)->port; |
| struct intel_crtc *crtc = to_intel_crtc(encoder->base.crtc); |
| |
| tmp = I915_READ(intel_dp->output_reg); |
| |
| pipe_config->has_audio = tmp & DP_AUDIO_OUTPUT_ENABLE && port != PORT_A; |
| |
| if (HAS_PCH_CPT(dev_priv) && port != PORT_A) { |
| u32 trans_dp = I915_READ(TRANS_DP_CTL(crtc->pipe)); |
| |
| if (trans_dp & TRANS_DP_HSYNC_ACTIVE_HIGH) |
| flags |= DRM_MODE_FLAG_PHSYNC; |
| else |
| flags |= DRM_MODE_FLAG_NHSYNC; |
| |
| if (trans_dp & TRANS_DP_VSYNC_ACTIVE_HIGH) |
| flags |= DRM_MODE_FLAG_PVSYNC; |
| else |
| flags |= DRM_MODE_FLAG_NVSYNC; |
| } else { |
| if (tmp & DP_SYNC_HS_HIGH) |
| flags |= DRM_MODE_FLAG_PHSYNC; |
| else |
| flags |= DRM_MODE_FLAG_NHSYNC; |
| |
| if (tmp & DP_SYNC_VS_HIGH) |
| flags |= DRM_MODE_FLAG_PVSYNC; |
| else |
| flags |= DRM_MODE_FLAG_NVSYNC; |
| } |
| |
| pipe_config->base.adjusted_mode.flags |= flags; |
| |
| if (IS_G4X(dev_priv) && tmp & DP_COLOR_RANGE_16_235) |
| pipe_config->limited_color_range = true; |
| |
| pipe_config->lane_count = |
| ((tmp & DP_PORT_WIDTH_MASK) >> DP_PORT_WIDTH_SHIFT) + 1; |
| |
| intel_dp_get_m_n(crtc, pipe_config); |
| |
| if (port == PORT_A) { |
| if ((I915_READ(DP_A) & DP_PLL_FREQ_MASK) == DP_PLL_FREQ_162MHZ) |
| pipe_config->port_clock = 162000; |
| else |
| pipe_config->port_clock = 270000; |
| } |
| |
| pipe_config->base.adjusted_mode.crtc_clock = |
| intel_dotclock_calculate(pipe_config->port_clock, |
| &pipe_config->dp_m_n); |
| |
| if (is_edp(intel_dp) && dev_priv->vbt.edp.bpp && |
| pipe_config->pipe_bpp > dev_priv->vbt.edp.bpp) { |
| /* |
| * This is a big fat ugly hack. |
| * |
| * Some machines in UEFI boot mode provide us a VBT that has 18 |
| * bpp and 1.62 GHz link bandwidth for eDP, which for reasons |
| * unknown we fail to light up. Yet the same BIOS boots up with |
| * 24 bpp and 2.7 GHz link. Use the same bpp as the BIOS uses as |
| * max, not what it tells us to use. |
| * |
| * Note: This will still be broken if the eDP panel is not lit |
| * up by the BIOS, and thus we can't get the mode at module |
| * load. |
| */ |
| DRM_DEBUG_KMS("pipe has %d bpp for eDP panel, overriding BIOS-provided max %d bpp\n", |
| pipe_config->pipe_bpp, dev_priv->vbt.edp.bpp); |
| dev_priv->vbt.edp.bpp = pipe_config->pipe_bpp; |
| } |
| } |
| |
| static void intel_disable_dp(struct intel_encoder *encoder, |
| struct intel_crtc_state *old_crtc_state, |
| struct drm_connector_state *old_conn_state) |
| { |
| struct intel_dp *intel_dp = enc_to_intel_dp(&encoder->base); |
| struct drm_i915_private *dev_priv = to_i915(encoder->base.dev); |
| |
| if (old_crtc_state->has_audio) |
| intel_audio_codec_disable(encoder); |
| |
| if (HAS_PSR(dev_priv) && !HAS_DDI(dev_priv)) |
| intel_psr_disable(intel_dp); |
| |
| /* Make sure the panel is off before trying to change the mode. But also |
| * ensure that we have vdd while we switch off the panel. */ |
| intel_edp_panel_vdd_on(intel_dp); |
| intel_edp_backlight_off(old_conn_state); |
| intel_dp_sink_dpms(intel_dp, DRM_MODE_DPMS_OFF); |
| intel_edp_panel_off(intel_dp); |
| |
| /* disable the port before the pipe on g4x */ |
| if (INTEL_GEN(dev_priv) < 5) |
| intel_dp_link_down(intel_dp); |
| } |
| |
| static void ilk_post_disable_dp(struct intel_encoder *encoder, |
| struct intel_crtc_state *old_crtc_state, |
| struct drm_connector_state *old_conn_state) |
| { |
| struct intel_dp *intel_dp = enc_to_intel_dp(&encoder->base); |
| enum port port = dp_to_dig_port(intel_dp)->port; |
| |
| intel_dp_link_down(intel_dp); |
| |
| /* Only ilk+ has port A */ |
| if (port == PORT_A) |
| ironlake_edp_pll_off(intel_dp); |
| } |
| |
| static void vlv_post_disable_dp(struct intel_encoder *encoder, |
| struct intel_crtc_state *old_crtc_state, |
| struct drm_connector_state *old_conn_state) |
| { |
| struct intel_dp *intel_dp = enc_to_intel_dp(&encoder->base); |
| |
| intel_dp_link_down(intel_dp); |
| } |
| |
| static void chv_post_disable_dp(struct intel_encoder *encoder, |
| struct intel_crtc_state *old_crtc_state, |
| struct drm_connector_state *old_conn_state) |
| { |
| struct intel_dp *intel_dp = enc_to_intel_dp(&encoder->base); |
| struct drm_device *dev = encoder->base.dev; |
| struct drm_i915_private *dev_priv = to_i915(dev); |
| |
| intel_dp_link_down(intel_dp); |
| |
| mutex_lock(&dev_priv->sb_lock); |
| |
| /* Assert data lane reset */ |
| chv_data_lane_soft_reset(encoder, true); |
| |
| mutex_unlock(&dev_priv->sb_lock); |
| } |
| |
| static void |
| _intel_dp_set_link_train(struct intel_dp *intel_dp, |
| uint32_t *DP, |
| uint8_t dp_train_pat) |
| { |
| struct intel_digital_port *intel_dig_port = dp_to_dig_port(intel_dp); |
| struct drm_device *dev = intel_dig_port->base.base.dev; |
| struct drm_i915_private *dev_priv = to_i915(dev); |
| enum port port = intel_dig_port->port; |
| |
| if (dp_train_pat & DP_TRAINING_PATTERN_MASK) |
| DRM_DEBUG_KMS("Using DP training pattern TPS%d\n", |
| dp_train_pat & DP_TRAINING_PATTERN_MASK); |
| |
| if (HAS_DDI(dev_priv)) { |
| uint32_t temp = I915_READ(DP_TP_CTL(port)); |
| |
| 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 & DP_TRAINING_PATTERN_MASK) { |
| case DP_TRAINING_PATTERN_DISABLE: |
| temp |= DP_TP_CTL_LINK_TRAIN_NORMAL; |
| |
| break; |
| case DP_TRAINING_PATTERN_1: |
| temp |= DP_TP_CTL_LINK_TRAIN_PAT1; |
| break; |
| case DP_TRAINING_PATTERN_2: |
| temp |= DP_TP_CTL_LINK_TRAIN_PAT2; |
| break; |
| case DP_TRAINING_PATTERN_3: |
| temp |= DP_TP_CTL_LINK_TRAIN_PAT3; |
| break; |
| } |
| I915_WRITE(DP_TP_CTL(port), temp); |
| |
| } else if ((IS_GEN7(dev_priv) && port == PORT_A) || |
| (HAS_PCH_CPT(dev_priv) && port != PORT_A)) { |
| *DP &= ~DP_LINK_TRAIN_MASK_CPT; |
| |
| switch (dp_train_pat & DP_TRAINING_PATTERN_MASK) { |
| case DP_TRAINING_PATTERN_DISABLE: |
| *DP |= DP_LINK_TRAIN_OFF_CPT; |
| break; |
| case DP_TRAINING_PATTERN_1: |
| *DP |= DP_LINK_TRAIN_PAT_1_CPT; |
| break; |
| case DP_TRAINING_PATTERN_2: |
| *DP |= DP_LINK_TRAIN_PAT_2_CPT; |
| break; |
| case DP_TRAINING_PATTERN_3: |
| DRM_DEBUG_KMS("TPS3 not supported, using TPS2 instead\n"); |
| *DP |= DP_LINK_TRAIN_PAT_2_CPT; |
| break; |
| } |
| |
| } else { |
| if (IS_CHERRYVIEW(dev_priv)) |
| *DP &= ~DP_LINK_TRAIN_MASK_CHV; |
| else |
| *DP &= ~DP_LINK_TRAIN_MASK; |
| |
| switch (dp_train_pat & DP_TRAINING_PATTERN_MASK) { |
| case DP_TRAINING_PATTERN_DISABLE: |
| *DP |= DP_LINK_TRAIN_OFF; |
| break; |
| case DP_TRAINING_PATTERN_1: |
| *DP |= DP_LINK_TRAIN_PAT_1; |
| break; |
| case DP_TRAINING_PATTERN_2: |
| *DP |= DP_LINK_TRAIN_PAT_2; |
| break; |
| case DP_TRAINING_PATTERN_3: |
| if (IS_CHERRYVIEW(dev_priv)) { |
| *DP |= DP_LINK_TRAIN_PAT_3_CHV; |
| } else { |
| DRM_DEBUG_KMS("TPS3 not supported, using TPS2 instead\n"); |
| *DP |= DP_LINK_TRAIN_PAT_2; |
| } |
| break; |
| } |
| } |
| } |
| |
| static void intel_dp_enable_port(struct intel_dp *intel_dp, |
| struct intel_crtc_state *old_crtc_state) |
| { |
| struct drm_device *dev = intel_dp_to_dev(intel_dp); |
| struct drm_i915_private *dev_priv = to_i915(dev); |
| |
| /* enable with pattern 1 (as per spec) */ |
| |
| intel_dp_program_link_training_pattern(intel_dp, DP_TRAINING_PATTERN_1); |
| |
| /* |
| * Magic for VLV/CHV. We _must_ first set up the register |
| * without actually enabling the port, and then do another |
| * write to enable the port. Otherwise link training will |
| * fail when the power sequencer is freshly used for this port. |
| */ |
| intel_dp->DP |= DP_PORT_EN; |
| if (old_crtc_state->has_audio) |
| intel_dp->DP |= DP_AUDIO_OUTPUT_ENABLE; |
| |
| I915_WRITE(intel_dp->output_reg, intel_dp->DP); |
| POSTING_READ(intel_dp->output_reg); |
| } |
| |
| static void intel_enable_dp(struct intel_encoder *encoder, |
| struct intel_crtc_state *pipe_config, |
| struct drm_connector_state *conn_state) |
| { |
| struct intel_dp *intel_dp = enc_to_intel_dp(&encoder->base); |
| struct drm_device *dev = encoder->base.dev; |
| struct drm_i915_private *dev_priv = to_i915(dev); |
| struct intel_crtc *crtc = to_intel_crtc(encoder->base.crtc); |
| uint32_t dp_reg = I915_READ(intel_dp->output_reg); |
| enum pipe pipe = crtc->pipe; |
| |
| if (WARN_ON(dp_reg & DP_PORT_EN)) |
| return; |
| |
| pps_lock(intel_dp); |
| |
| if (IS_VALLEYVIEW(dev_priv) || IS_CHERRYVIEW(dev_priv)) |
| vlv_init_panel_power_sequencer(intel_dp); |
| |
| intel_dp_enable_port(intel_dp, pipe_config); |
| |
| edp_panel_vdd_on(intel_dp); |
| edp_panel_on(intel_dp); |
| edp_panel_vdd_off(intel_dp, true); |
| |
| pps_unlock(intel_dp); |
| |
| if (IS_VALLEYVIEW(dev_priv) || IS_CHERRYVIEW(dev_priv)) { |
| unsigned int lane_mask = 0x0; |
| |
| if (IS_CHERRYVIEW(dev_priv)) |
| lane_mask = intel_dp_unused_lane_mask(pipe_config->lane_count); |
| |
| vlv_wait_port_ready(dev_priv, dp_to_dig_port(intel_dp), |
| lane_mask); |
| } |
| |
| intel_dp_sink_dpms(intel_dp, DRM_MODE_DPMS_ON); |
| intel_dp_start_link_train(intel_dp); |
| intel_dp_stop_link_train(intel_dp); |
| |
| if (pipe_config->has_audio) { |
| DRM_DEBUG_DRIVER("Enabling DP audio on pipe %c\n", |
| pipe_name(pipe)); |
| intel_audio_codec_enable(encoder, pipe_config, conn_state); |
| } |
| } |
| |
| static void g4x_enable_dp(struct intel_encoder *encoder, |
| struct intel_crtc_state *pipe_config, |
| struct drm_connector_state *conn_state) |
| { |
| intel_enable_dp(encoder, pipe_config, conn_state); |
| intel_edp_backlight_on(pipe_config, conn_state); |
| } |
| |
| static void vlv_enable_dp(struct intel_encoder *encoder, |
| struct intel_crtc_state *pipe_config, |
| struct drm_connector_state *conn_state) |
| { |
| struct intel_dp *intel_dp = enc_to_intel_dp(&encoder->base); |
| |
| intel_edp_backlight_on(pipe_config, conn_state); |
| intel_psr_enable(intel_dp); |
| } |
| |
| static void g4x_pre_enable_dp(struct intel_encoder *encoder, |
| struct intel_crtc_state *pipe_config, |
| struct drm_connector_state *conn_state) |
| { |
| struct intel_dp *intel_dp = enc_to_intel_dp(&encoder->base); |
| enum port port = dp_to_dig_port(intel_dp)->port; |
| |
| intel_dp_prepare(encoder, pipe_config); |
| |
| /* Only ilk+ has port A */ |
| if (port == PORT_A) |
| ironlake_edp_pll_on(intel_dp, pipe_config); |
| } |
| |
| static void vlv_detach_power_sequencer(struct intel_dp *intel_dp) |
| { |
| struct intel_digital_port *intel_dig_port = dp_to_dig_port(intel_dp); |
| struct drm_i915_private *dev_priv = to_i915(intel_dig_port->base.base.dev); |
| enum pipe pipe = intel_dp->pps_pipe; |
| i915_reg_t pp_on_reg = PP_ON_DELAYS(pipe); |
| |
| WARN_ON(intel_dp->active_pipe != INVALID_PIPE); |
| |
| if (WARN_ON(pipe != PIPE_A && pipe != PIPE_B)) |
| return; |
| |
| edp_panel_vdd_off_sync(intel_dp); |
| |
| /* |
| * VLV seems to get confused when multiple power seqeuencers |
| * have the same port selected (even if only one has power/vdd |
| * enabled). The failure manifests as vlv_wait_port_ready() failing |
| * CHV on the other hand doesn't seem to mind having the same port |
| * selected in multiple power seqeuencers, but let's clear the |
| * port select always when logically disconnecting a power sequencer |
| * from a port. |
| */ |
| DRM_DEBUG_KMS("detaching pipe %c power sequencer from port %c\n", |
| pipe_name(pipe), port_name(intel_dig_port->port)); |
| I915_WRITE(pp_on_reg, 0); |
| POSTING_READ(pp_on_reg); |
| |
| intel_dp->pps_pipe = INVALID_PIPE; |
| } |
| |
| static void vlv_steal_power_sequencer(struct drm_device *dev, |
| enum pipe pipe) |
| { |
| struct drm_i915_private *dev_priv = to_i915(dev); |
| struct intel_encoder *encoder; |
| |
| lockdep_assert_held(&dev_priv->pps_mutex); |
| |
| for_each_intel_encoder(dev, encoder) { |
| struct intel_dp *intel_dp; |
| enum port port; |
| |
| if (encoder->type != INTEL_OUTPUT_DP && |
| encoder->type != INTEL_OUTPUT_EDP) |
| continue; |
| |
| intel_dp = enc_to_intel_dp(&encoder->base); |
| port = dp_to_dig_port(intel_dp)->port; |
| |
| WARN(intel_dp->active_pipe == pipe, |
| "stealing pipe %c power sequencer from active (e)DP port %c\n", |
| pipe_name(pipe), port_name(port)); |
| |
| if (intel_dp->pps_pipe != pipe) |
| continue; |
| |
| DRM_DEBUG_KMS("stealing pipe %c power sequencer from port %c\n", |
| pipe_name(pipe), port_name(port)); |
| |
| /* make sure vdd is off before we steal it */ |
| vlv_detach_power_sequencer(intel_dp); |
| } |
| } |
| |
| static void vlv_init_panel_power_sequencer(struct intel_dp *intel_dp) |
| { |
| struct intel_digital_port *intel_dig_port = dp_to_dig_port(intel_dp); |
| struct intel_encoder *encoder = &intel_dig_port->base; |
| struct drm_device *dev = encoder->base.dev; |
| struct drm_i915_private *dev_priv = to_i915(dev); |
| struct intel_crtc *crtc = to_intel_crtc(encoder->base.crtc); |
| |
| lockdep_assert_held(&dev_priv->pps_mutex); |
| |
| WARN_ON(intel_dp->active_pipe != INVALID_PIPE); |
| |
| if (intel_dp->pps_pipe != INVALID_PIPE && |
| intel_dp->pps_pipe != crtc->pipe) { |
| /* |
| * If another power sequencer was being used on this |
| * port previously make sure to turn off vdd there while |
| * we still have control of it. |
| */ |
| vlv_detach_power_sequencer(intel_dp); |
| } |
| |
| /* |
| * We may be stealing the power |
| * sequencer from another port. |
| */ |
| vlv_steal_power_sequencer(dev, crtc->pipe); |
| |
| intel_dp->active_pipe = crtc->pipe; |
| |
| if (!is_edp(intel_dp)) |
| return; |
| |
| /* now it's all ours */ |
| intel_dp->pps_pipe = crtc->pipe; |
| |
| DRM_DEBUG_KMS("initializing pipe %c power sequencer for port %c\n", |
| pipe_name(intel_dp->pps_pipe), port_name(intel_dig_port->port)); |
| |
| /* init power sequencer on this pipe and port */ |
| intel_dp_init_panel_power_sequencer(dev, intel_dp); |
| intel_dp_init_panel_power_sequencer_registers(dev, intel_dp, true); |
| } |
| |
| static void vlv_pre_enable_dp(struct intel_encoder *encoder, |
| struct intel_crtc_state *pipe_config, |
| struct drm_connector_state *conn_state) |
| { |
| vlv_phy_pre_encoder_enable(encoder); |
| |
| intel_enable_dp(encoder, pipe_config, conn_state); |
| } |
| |
| static void vlv_dp_pre_pll_enable(struct intel_encoder *encoder, |
| struct intel_crtc_state *pipe_config, |
| struct drm_connector_state *conn_state) |
| { |
| intel_dp_prepare(encoder, pipe_config); |
| |
| vlv_phy_pre_pll_enable(encoder); |
| } |
| |
| static void chv_pre_enable_dp(struct intel_encoder *encoder, |
| struct intel_crtc_state *pipe_config, |
| struct drm_connector_state *conn_state) |
| { |
| chv_phy_pre_encoder_enable(encoder); |
| |
| intel_enable_dp(encoder, pipe_config, conn_state); |
| |
| /* Second common lane will stay alive on its own now */ |
| chv_phy_release_cl2_override(encoder); |
| } |
| |
| static void chv_dp_pre_pll_enable(struct intel_encoder *encoder, |
| struct intel_crtc_state *pipe_config, |
| struct drm_connector_state *conn_state) |
| { |
| intel_dp_prepare(encoder, pipe_config); |
| |
| chv_phy_pre_pll_enable(encoder); |
| } |
| |
| static void chv_dp_post_pll_disable(struct intel_encoder *encoder, |
| struct intel_crtc_state *pipe_config, |
| struct drm_connector_state *conn_state) |
| { |
| chv_phy_post_pll_disable(encoder); |
| } |
| |
| /* |
| * Fetch AUX CH registers 0x202 - 0x207 which contain |
| * link status information |
| */ |
| bool |
| intel_dp_get_link_status(struct intel_dp *intel_dp, uint8_t link_status[DP_LINK_STATUS_SIZE]) |
| { |
| return drm_dp_dpcd_read(&intel_dp->aux, DP_LANE0_1_STATUS, link_status, |
| DP_LINK_STATUS_SIZE) == DP_LINK_STATUS_SIZE; |
| } |
| |
| static bool intel_dp_get_y_cord_status(struct intel_dp *intel_dp) |
| { |
| uint8_t psr_caps = 0; |
|