Keith Packard | a4fc5ed | 2009-04-07 16:16:42 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright © 2008 Intel Corporation |
| 3 | * |
| 4 | * Permission is hereby granted, free of charge, to any person obtaining a |
| 5 | * copy of this software and associated documentation files (the "Software"), |
| 6 | * to deal in the Software without restriction, including without limitation |
| 7 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, |
| 8 | * and/or sell copies of the Software, and to permit persons to whom the |
| 9 | * Software is furnished to do so, subject to the following conditions: |
| 10 | * |
| 11 | * The above copyright notice and this permission notice (including the next |
| 12 | * paragraph) shall be included in all copies or substantial portions of the |
| 13 | * Software. |
| 14 | * |
| 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
| 18 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
| 20 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS |
| 21 | * IN THE SOFTWARE. |
| 22 | * |
| 23 | * Authors: |
| 24 | * Keith Packard <keithp@keithp.com> |
| 25 | * |
| 26 | */ |
| 27 | |
| 28 | #include <linux/i2c.h> |
Tejun Heo | 5a0e3ad | 2010-03-24 17:04:11 +0900 | [diff] [blame] | 29 | #include <linux/slab.h> |
Paul Gortmaker | 2d1a8a4 | 2011-08-30 18:16:33 -0400 | [diff] [blame] | 30 | #include <linux/export.h> |
David Howells | 760285e | 2012-10-02 18:01:07 +0100 | [diff] [blame] | 31 | #include <drm/drmP.h> |
| 32 | #include <drm/drm_crtc.h> |
| 33 | #include <drm/drm_crtc_helper.h> |
| 34 | #include <drm/drm_edid.h> |
Keith Packard | a4fc5ed | 2009-04-07 16:16:42 -0700 | [diff] [blame] | 35 | #include "intel_drv.h" |
David Howells | 760285e | 2012-10-02 18:01:07 +0100 | [diff] [blame] | 36 | #include <drm/i915_drm.h> |
Keith Packard | a4fc5ed | 2009-04-07 16:16:42 -0700 | [diff] [blame] | 37 | #include "i915_drv.h" |
Keith Packard | a4fc5ed | 2009-04-07 16:16:42 -0700 | [diff] [blame] | 38 | |
Keith Packard | a4fc5ed | 2009-04-07 16:16:42 -0700 | [diff] [blame] | 39 | #define DP_LINK_CHECK_TIMEOUT (10 * 1000) |
| 40 | |
Jesse Barnes | cfcb0fc | 2010-10-07 16:01:06 -0700 | [diff] [blame] | 41 | /** |
| 42 | * is_edp - is the given port attached to an eDP panel (either CPU or PCH) |
| 43 | * @intel_dp: DP struct |
| 44 | * |
| 45 | * If a CPU or PCH DP output is attached to an eDP panel, this function |
| 46 | * will return true, and false otherwise. |
| 47 | */ |
| 48 | static bool is_edp(struct intel_dp *intel_dp) |
| 49 | { |
Paulo Zanoni | da63a9f | 2012-10-26 19:05:46 -0200 | [diff] [blame] | 50 | struct intel_digital_port *intel_dig_port = dp_to_dig_port(intel_dp); |
| 51 | |
| 52 | return intel_dig_port->base.type == INTEL_OUTPUT_EDP; |
Jesse Barnes | cfcb0fc | 2010-10-07 16:01:06 -0700 | [diff] [blame] | 53 | } |
| 54 | |
Imre Deak | 68b4d82 | 2013-05-08 13:14:06 +0300 | [diff] [blame] | 55 | static struct drm_device *intel_dp_to_dev(struct intel_dp *intel_dp) |
Jesse Barnes | cfcb0fc | 2010-10-07 16:01:06 -0700 | [diff] [blame] | 56 | { |
Imre Deak | 68b4d82 | 2013-05-08 13:14:06 +0300 | [diff] [blame] | 57 | struct intel_digital_port *intel_dig_port = dp_to_dig_port(intel_dp); |
| 58 | |
| 59 | return intel_dig_port->base.base.dev; |
Jesse Barnes | cfcb0fc | 2010-10-07 16:01:06 -0700 | [diff] [blame] | 60 | } |
| 61 | |
Chris Wilson | df0e924 | 2010-09-09 16:20:55 +0100 | [diff] [blame] | 62 | static struct intel_dp *intel_attached_dp(struct drm_connector *connector) |
| 63 | { |
Paulo Zanoni | fa90ece | 2012-10-26 19:05:44 -0200 | [diff] [blame] | 64 | return enc_to_intel_dp(&intel_attached_encoder(connector)->base); |
Chris Wilson | df0e924 | 2010-09-09 16:20:55 +0100 | [diff] [blame] | 65 | } |
| 66 | |
Chris Wilson | ea5b213 | 2010-08-04 13:50:23 +0100 | [diff] [blame] | 67 | static void intel_dp_link_down(struct intel_dp *intel_dp); |
Keith Packard | a4fc5ed | 2009-04-07 16:16:42 -0700 | [diff] [blame] | 68 | |
| 69 | static int |
Chris Wilson | ea5b213 | 2010-08-04 13:50:23 +0100 | [diff] [blame] | 70 | intel_dp_max_link_bw(struct intel_dp *intel_dp) |
Keith Packard | a4fc5ed | 2009-04-07 16:16:42 -0700 | [diff] [blame] | 71 | { |
Jesse Barnes | 7183dc2 | 2011-07-07 11:10:58 -0700 | [diff] [blame] | 72 | int max_link_bw = intel_dp->dpcd[DP_MAX_LINK_RATE]; |
Keith Packard | a4fc5ed | 2009-04-07 16:16:42 -0700 | [diff] [blame] | 73 | |
| 74 | switch (max_link_bw) { |
| 75 | case DP_LINK_BW_1_62: |
| 76 | case DP_LINK_BW_2_7: |
| 77 | break; |
| 78 | default: |
| 79 | max_link_bw = DP_LINK_BW_1_62; |
| 80 | break; |
| 81 | } |
| 82 | return max_link_bw; |
| 83 | } |
| 84 | |
Adam Jackson | cd9dde4 | 2011-10-14 12:43:49 -0400 | [diff] [blame] | 85 | /* |
| 86 | * The units on the numbers in the next two are... bizarre. Examples will |
| 87 | * make it clearer; this one parallels an example in the eDP spec. |
| 88 | * |
| 89 | * intel_dp_max_data_rate for one lane of 2.7GHz evaluates as: |
| 90 | * |
| 91 | * 270000 * 1 * 8 / 10 == 216000 |
| 92 | * |
| 93 | * The actual data capacity of that configuration is 2.16Gbit/s, so the |
| 94 | * units are decakilobits. ->clock in a drm_display_mode is in kilohertz - |
| 95 | * or equivalently, kilopixels per second - so for 1680x1050R it'd be |
| 96 | * 119000. At 18bpp that's 2142000 kilobits per second. |
| 97 | * |
| 98 | * Thus the strange-looking division by 10 in intel_dp_link_required, to |
| 99 | * get the result in decakilobits instead of kilobits. |
| 100 | */ |
| 101 | |
Keith Packard | a4fc5ed | 2009-04-07 16:16:42 -0700 | [diff] [blame] | 102 | static int |
Keith Packard | c898261 | 2012-01-25 08:16:25 -0800 | [diff] [blame] | 103 | intel_dp_link_required(int pixel_clock, int bpp) |
Keith Packard | a4fc5ed | 2009-04-07 16:16:42 -0700 | [diff] [blame] | 104 | { |
Adam Jackson | cd9dde4 | 2011-10-14 12:43:49 -0400 | [diff] [blame] | 105 | return (pixel_clock * bpp + 9) / 10; |
Keith Packard | a4fc5ed | 2009-04-07 16:16:42 -0700 | [diff] [blame] | 106 | } |
| 107 | |
| 108 | static int |
Dave Airlie | fe27d53 | 2010-06-30 11:46:17 +1000 | [diff] [blame] | 109 | intel_dp_max_data_rate(int max_link_clock, int max_lanes) |
| 110 | { |
| 111 | return (max_link_clock * max_lanes * 8) / 10; |
| 112 | } |
| 113 | |
| 114 | static int |
Keith Packard | a4fc5ed | 2009-04-07 16:16:42 -0700 | [diff] [blame] | 115 | intel_dp_mode_valid(struct drm_connector *connector, |
| 116 | struct drm_display_mode *mode) |
| 117 | { |
Chris Wilson | df0e924 | 2010-09-09 16:20:55 +0100 | [diff] [blame] | 118 | struct intel_dp *intel_dp = intel_attached_dp(connector); |
Jani Nikula | dd06f90 | 2012-10-19 14:51:50 +0300 | [diff] [blame] | 119 | struct intel_connector *intel_connector = to_intel_connector(connector); |
| 120 | struct drm_display_mode *fixed_mode = intel_connector->panel.fixed_mode; |
Daniel Vetter | 3600836 | 2013-03-27 00:44:59 +0100 | [diff] [blame] | 121 | int target_clock = mode->clock; |
| 122 | int max_rate, mode_rate, max_lanes, max_link_clock; |
Keith Packard | a4fc5ed | 2009-04-07 16:16:42 -0700 | [diff] [blame] | 123 | |
Jani Nikula | dd06f90 | 2012-10-19 14:51:50 +0300 | [diff] [blame] | 124 | if (is_edp(intel_dp) && fixed_mode) { |
| 125 | if (mode->hdisplay > fixed_mode->hdisplay) |
Zhao Yakui | 7de56f4 | 2010-07-19 09:43:14 +0100 | [diff] [blame] | 126 | return MODE_PANEL; |
| 127 | |
Jani Nikula | dd06f90 | 2012-10-19 14:51:50 +0300 | [diff] [blame] | 128 | if (mode->vdisplay > fixed_mode->vdisplay) |
Zhao Yakui | 7de56f4 | 2010-07-19 09:43:14 +0100 | [diff] [blame] | 129 | return MODE_PANEL; |
Daniel Vetter | 03afc4a | 2013-04-02 23:42:31 +0200 | [diff] [blame] | 130 | |
| 131 | target_clock = fixed_mode->clock; |
Zhao Yakui | 7de56f4 | 2010-07-19 09:43:14 +0100 | [diff] [blame] | 132 | } |
| 133 | |
Daniel Vetter | 3600836 | 2013-03-27 00:44:59 +0100 | [diff] [blame] | 134 | max_link_clock = drm_dp_bw_code_to_link_rate(intel_dp_max_link_bw(intel_dp)); |
| 135 | max_lanes = drm_dp_max_lane_count(intel_dp->dpcd); |
| 136 | |
| 137 | max_rate = intel_dp_max_data_rate(max_link_clock, max_lanes); |
| 138 | mode_rate = intel_dp_link_required(target_clock, 18); |
| 139 | |
| 140 | if (mode_rate > max_rate) |
Daniel Vetter | c486793 | 2012-04-10 10:42:36 +0200 | [diff] [blame] | 141 | return MODE_CLOCK_HIGH; |
Keith Packard | a4fc5ed | 2009-04-07 16:16:42 -0700 | [diff] [blame] | 142 | |
| 143 | if (mode->clock < 10000) |
| 144 | return MODE_CLOCK_LOW; |
| 145 | |
Daniel Vetter | 0af78a2 | 2012-05-23 11:30:55 +0200 | [diff] [blame] | 146 | if (mode->flags & DRM_MODE_FLAG_DBLCLK) |
| 147 | return MODE_H_ILLEGAL; |
| 148 | |
Keith Packard | a4fc5ed | 2009-04-07 16:16:42 -0700 | [diff] [blame] | 149 | return MODE_OK; |
| 150 | } |
| 151 | |
| 152 | static uint32_t |
| 153 | pack_aux(uint8_t *src, int src_bytes) |
| 154 | { |
| 155 | int i; |
| 156 | uint32_t v = 0; |
| 157 | |
| 158 | if (src_bytes > 4) |
| 159 | src_bytes = 4; |
| 160 | for (i = 0; i < src_bytes; i++) |
| 161 | v |= ((uint32_t) src[i]) << ((3-i) * 8); |
| 162 | return v; |
| 163 | } |
| 164 | |
| 165 | static void |
| 166 | unpack_aux(uint32_t src, uint8_t *dst, int dst_bytes) |
| 167 | { |
| 168 | int i; |
| 169 | if (dst_bytes > 4) |
| 170 | dst_bytes = 4; |
| 171 | for (i = 0; i < dst_bytes; i++) |
| 172 | dst[i] = src >> ((3-i) * 8); |
| 173 | } |
| 174 | |
Keith Packard | fb0f8fb | 2009-06-11 22:31:31 -0700 | [diff] [blame] | 175 | /* hrawclock is 1/4 the FSB frequency */ |
| 176 | static int |
| 177 | intel_hrawclk(struct drm_device *dev) |
| 178 | { |
| 179 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 180 | uint32_t clkcfg; |
| 181 | |
Vijay Purushothaman | 9473c8f | 2012-09-27 19:13:01 +0530 | [diff] [blame] | 182 | /* There is no CLKCFG reg in Valleyview. VLV hrawclk is 200 MHz */ |
| 183 | if (IS_VALLEYVIEW(dev)) |
| 184 | return 200; |
| 185 | |
Keith Packard | fb0f8fb | 2009-06-11 22:31:31 -0700 | [diff] [blame] | 186 | clkcfg = I915_READ(CLKCFG); |
| 187 | switch (clkcfg & CLKCFG_FSB_MASK) { |
| 188 | case CLKCFG_FSB_400: |
| 189 | return 100; |
| 190 | case CLKCFG_FSB_533: |
| 191 | return 133; |
| 192 | case CLKCFG_FSB_667: |
| 193 | return 166; |
| 194 | case CLKCFG_FSB_800: |
| 195 | return 200; |
| 196 | case CLKCFG_FSB_1067: |
| 197 | return 266; |
| 198 | case CLKCFG_FSB_1333: |
| 199 | return 333; |
| 200 | /* these two are just a guess; one of them might be right */ |
| 201 | case CLKCFG_FSB_1600: |
| 202 | case CLKCFG_FSB_1600_ALT: |
| 203 | return 400; |
| 204 | default: |
| 205 | return 133; |
| 206 | } |
| 207 | } |
| 208 | |
Keith Packard | ebf33b1 | 2011-09-29 15:53:27 -0700 | [diff] [blame] | 209 | static bool ironlake_edp_have_panel_power(struct intel_dp *intel_dp) |
| 210 | { |
Paulo Zanoni | 30add22 | 2012-10-26 19:05:45 -0200 | [diff] [blame] | 211 | struct drm_device *dev = intel_dp_to_dev(intel_dp); |
Keith Packard | ebf33b1 | 2011-09-29 15:53:27 -0700 | [diff] [blame] | 212 | struct drm_i915_private *dev_priv = dev->dev_private; |
Jesse Barnes | 453c542 | 2013-03-28 09:55:41 -0700 | [diff] [blame] | 213 | u32 pp_stat_reg; |
Keith Packard | ebf33b1 | 2011-09-29 15:53:27 -0700 | [diff] [blame] | 214 | |
Jesse Barnes | 453c542 | 2013-03-28 09:55:41 -0700 | [diff] [blame] | 215 | pp_stat_reg = IS_VALLEYVIEW(dev) ? PIPEA_PP_STATUS : PCH_PP_STATUS; |
| 216 | return (I915_READ(pp_stat_reg) & PP_ON) != 0; |
Keith Packard | ebf33b1 | 2011-09-29 15:53:27 -0700 | [diff] [blame] | 217 | } |
| 218 | |
| 219 | static bool ironlake_edp_have_panel_vdd(struct intel_dp *intel_dp) |
| 220 | { |
Paulo Zanoni | 30add22 | 2012-10-26 19:05:45 -0200 | [diff] [blame] | 221 | struct drm_device *dev = intel_dp_to_dev(intel_dp); |
Keith Packard | ebf33b1 | 2011-09-29 15:53:27 -0700 | [diff] [blame] | 222 | struct drm_i915_private *dev_priv = dev->dev_private; |
Jesse Barnes | 453c542 | 2013-03-28 09:55:41 -0700 | [diff] [blame] | 223 | u32 pp_ctrl_reg; |
Keith Packard | ebf33b1 | 2011-09-29 15:53:27 -0700 | [diff] [blame] | 224 | |
Jesse Barnes | 453c542 | 2013-03-28 09:55:41 -0700 | [diff] [blame] | 225 | pp_ctrl_reg = IS_VALLEYVIEW(dev) ? PIPEA_PP_CONTROL : PCH_PP_CONTROL; |
| 226 | return (I915_READ(pp_ctrl_reg) & EDP_FORCE_VDD) != 0; |
Keith Packard | ebf33b1 | 2011-09-29 15:53:27 -0700 | [diff] [blame] | 227 | } |
| 228 | |
Keith Packard | 9b984da | 2011-09-19 13:54:47 -0700 | [diff] [blame] | 229 | static void |
| 230 | intel_dp_check_edp(struct intel_dp *intel_dp) |
| 231 | { |
Paulo Zanoni | 30add22 | 2012-10-26 19:05:45 -0200 | [diff] [blame] | 232 | struct drm_device *dev = intel_dp_to_dev(intel_dp); |
Keith Packard | 9b984da | 2011-09-19 13:54:47 -0700 | [diff] [blame] | 233 | struct drm_i915_private *dev_priv = dev->dev_private; |
Jesse Barnes | 453c542 | 2013-03-28 09:55:41 -0700 | [diff] [blame] | 234 | u32 pp_stat_reg, pp_ctrl_reg; |
Keith Packard | ebf33b1 | 2011-09-29 15:53:27 -0700 | [diff] [blame] | 235 | |
Keith Packard | 9b984da | 2011-09-19 13:54:47 -0700 | [diff] [blame] | 236 | if (!is_edp(intel_dp)) |
| 237 | return; |
Jesse Barnes | 453c542 | 2013-03-28 09:55:41 -0700 | [diff] [blame] | 238 | |
| 239 | pp_stat_reg = IS_VALLEYVIEW(dev) ? PIPEA_PP_STATUS : PCH_PP_STATUS; |
| 240 | pp_ctrl_reg = IS_VALLEYVIEW(dev) ? PIPEA_PP_CONTROL : PCH_PP_CONTROL; |
| 241 | |
Keith Packard | ebf33b1 | 2011-09-29 15:53:27 -0700 | [diff] [blame] | 242 | if (!ironlake_edp_have_panel_power(intel_dp) && !ironlake_edp_have_panel_vdd(intel_dp)) { |
Keith Packard | 9b984da | 2011-09-19 13:54:47 -0700 | [diff] [blame] | 243 | WARN(1, "eDP powered off while attempting aux channel communication.\n"); |
| 244 | DRM_DEBUG_KMS("Status 0x%08x Control 0x%08x\n", |
Jesse Barnes | 453c542 | 2013-03-28 09:55:41 -0700 | [diff] [blame] | 245 | I915_READ(pp_stat_reg), |
| 246 | I915_READ(pp_ctrl_reg)); |
Keith Packard | 9b984da | 2011-09-19 13:54:47 -0700 | [diff] [blame] | 247 | } |
| 248 | } |
| 249 | |
Daniel Vetter | 9ee32fea | 2012-12-01 13:53:48 +0100 | [diff] [blame] | 250 | static uint32_t |
| 251 | intel_dp_aux_wait_done(struct intel_dp *intel_dp, bool has_aux_irq) |
| 252 | { |
| 253 | struct intel_digital_port *intel_dig_port = dp_to_dig_port(intel_dp); |
| 254 | struct drm_device *dev = intel_dig_port->base.base.dev; |
| 255 | struct drm_i915_private *dev_priv = dev->dev_private; |
Paulo Zanoni | 9ed35ab | 2013-02-18 19:00:25 -0300 | [diff] [blame] | 256 | uint32_t ch_ctl = intel_dp->aux_ch_ctl_reg; |
Daniel Vetter | 9ee32fea | 2012-12-01 13:53:48 +0100 | [diff] [blame] | 257 | uint32_t status; |
| 258 | bool done; |
| 259 | |
Daniel Vetter | ef04f00 | 2012-12-01 21:03:59 +0100 | [diff] [blame] | 260 | #define C (((status = I915_READ_NOTRACE(ch_ctl)) & DP_AUX_CH_CTL_SEND_BUSY) == 0) |
Daniel Vetter | 9ee32fea | 2012-12-01 13:53:48 +0100 | [diff] [blame] | 261 | if (has_aux_irq) |
Paulo Zanoni | b18ac46 | 2013-02-18 19:00:24 -0300 | [diff] [blame] | 262 | done = wait_event_timeout(dev_priv->gmbus_wait_queue, C, |
Imre Deak | 3598706 | 2013-05-21 20:03:20 +0300 | [diff] [blame] | 263 | msecs_to_jiffies_timeout(10)); |
Daniel Vetter | 9ee32fea | 2012-12-01 13:53:48 +0100 | [diff] [blame] | 264 | else |
| 265 | done = wait_for_atomic(C, 10) == 0; |
| 266 | if (!done) |
| 267 | DRM_ERROR("dp aux hw did not signal timeout (has irq: %i)!\n", |
| 268 | has_aux_irq); |
| 269 | #undef C |
| 270 | |
| 271 | return status; |
| 272 | } |
| 273 | |
Rodrigo Vivi | b84a1cf | 2013-07-11 18:44:57 -0300 | [diff] [blame^] | 274 | static uint32_t get_aux_clock_divider(struct intel_dp *intel_dp) |
| 275 | { |
| 276 | struct intel_digital_port *intel_dig_port = dp_to_dig_port(intel_dp); |
| 277 | struct drm_device *dev = intel_dig_port->base.base.dev; |
| 278 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 279 | |
| 280 | /* The clock divider is based off the hrawclk, |
| 281 | * and would like to run at 2MHz. So, take the |
| 282 | * hrawclk value and divide by 2 and use that |
| 283 | * |
| 284 | * Note that PCH attached eDP panels should use a 125MHz input |
| 285 | * clock divider. |
| 286 | */ |
| 287 | if (IS_VALLEYVIEW(dev)) { |
| 288 | return 100; |
| 289 | } else if (intel_dig_port->port == PORT_A) { |
| 290 | if (HAS_DDI(dev)) |
| 291 | return DIV_ROUND_CLOSEST( |
| 292 | intel_ddi_get_cdclk_freq(dev_priv), 2000); |
| 293 | else if (IS_GEN6(dev) || IS_GEN7(dev)) |
| 294 | return 200; /* SNB & IVB eDP input clock at 400Mhz */ |
| 295 | else |
| 296 | return 225; /* eDP input clock at 450Mhz */ |
| 297 | } else if (dev_priv->pch_id == INTEL_PCH_LPT_DEVICE_ID_TYPE) { |
| 298 | /* Workaround for non-ULT HSW */ |
| 299 | return 74; |
| 300 | } else if (HAS_PCH_SPLIT(dev)) { |
| 301 | return DIV_ROUND_UP(intel_pch_rawclk(dev), 2); |
| 302 | } else { |
| 303 | return intel_hrawclk(dev) / 2; |
| 304 | } |
| 305 | } |
| 306 | |
Keith Packard | a4fc5ed | 2009-04-07 16:16:42 -0700 | [diff] [blame] | 307 | static int |
Chris Wilson | ea5b213 | 2010-08-04 13:50:23 +0100 | [diff] [blame] | 308 | intel_dp_aux_ch(struct intel_dp *intel_dp, |
Keith Packard | a4fc5ed | 2009-04-07 16:16:42 -0700 | [diff] [blame] | 309 | uint8_t *send, int send_bytes, |
| 310 | uint8_t *recv, int recv_size) |
| 311 | { |
Paulo Zanoni | 174edf1 | 2012-10-26 19:05:50 -0200 | [diff] [blame] | 312 | struct intel_digital_port *intel_dig_port = dp_to_dig_port(intel_dp); |
| 313 | struct drm_device *dev = intel_dig_port->base.base.dev; |
Keith Packard | a4fc5ed | 2009-04-07 16:16:42 -0700 | [diff] [blame] | 314 | struct drm_i915_private *dev_priv = dev->dev_private; |
Paulo Zanoni | 9ed35ab | 2013-02-18 19:00:25 -0300 | [diff] [blame] | 315 | uint32_t ch_ctl = intel_dp->aux_ch_ctl_reg; |
Keith Packard | a4fc5ed | 2009-04-07 16:16:42 -0700 | [diff] [blame] | 316 | uint32_t ch_data = ch_ctl + 4; |
Daniel Vetter | 9ee32fea | 2012-12-01 13:53:48 +0100 | [diff] [blame] | 317 | int i, ret, recv_bytes; |
Keith Packard | a4fc5ed | 2009-04-07 16:16:42 -0700 | [diff] [blame] | 318 | uint32_t status; |
Rodrigo Vivi | b84a1cf | 2013-07-11 18:44:57 -0300 | [diff] [blame^] | 319 | uint32_t aux_clock_divider = get_aux_clock_divider(intel_dp); |
Daniel Vetter | 6b4e0a9 | 2012-06-14 22:15:00 +0200 | [diff] [blame] | 320 | int try, precharge; |
Daniel Vetter | 9ee32fea | 2012-12-01 13:53:48 +0100 | [diff] [blame] | 321 | bool has_aux_irq = INTEL_INFO(dev)->gen >= 5 && !IS_VALLEYVIEW(dev); |
| 322 | |
| 323 | /* dp aux is extremely sensitive to irq latency, hence request the |
| 324 | * lowest possible wakeup latency and so prevent the cpu from going into |
| 325 | * deep sleep states. |
| 326 | */ |
| 327 | pm_qos_update_request(&dev_priv->pm_qos, 0); |
Keith Packard | a4fc5ed | 2009-04-07 16:16:42 -0700 | [diff] [blame] | 328 | |
Keith Packard | 9b984da | 2011-09-19 13:54:47 -0700 | [diff] [blame] | 329 | intel_dp_check_edp(intel_dp); |
Zhenyu Wang | 5eb08b6 | 2009-07-24 01:00:31 +0800 | [diff] [blame] | 330 | |
Daniel Vetter | 6b4e0a9 | 2012-06-14 22:15:00 +0200 | [diff] [blame] | 331 | if (IS_GEN6(dev)) |
| 332 | precharge = 3; |
| 333 | else |
| 334 | precharge = 5; |
| 335 | |
Jesse Barnes | 11bee43 | 2011-08-01 15:02:20 -0700 | [diff] [blame] | 336 | /* Try to wait for any previous AUX channel activity */ |
| 337 | for (try = 0; try < 3; try++) { |
Daniel Vetter | ef04f00 | 2012-12-01 21:03:59 +0100 | [diff] [blame] | 338 | status = I915_READ_NOTRACE(ch_ctl); |
Jesse Barnes | 11bee43 | 2011-08-01 15:02:20 -0700 | [diff] [blame] | 339 | if ((status & DP_AUX_CH_CTL_SEND_BUSY) == 0) |
| 340 | break; |
| 341 | msleep(1); |
| 342 | } |
| 343 | |
| 344 | if (try == 3) { |
| 345 | WARN(1, "dp_aux_ch not started status 0x%08x\n", |
| 346 | I915_READ(ch_ctl)); |
Daniel Vetter | 9ee32fea | 2012-12-01 13:53:48 +0100 | [diff] [blame] | 347 | ret = -EBUSY; |
| 348 | goto out; |
Chris Wilson | 4f7f7b7 | 2010-08-18 18:12:56 +0100 | [diff] [blame] | 349 | } |
| 350 | |
Keith Packard | fb0f8fb | 2009-06-11 22:31:31 -0700 | [diff] [blame] | 351 | /* Must try at least 3 times according to DP spec */ |
| 352 | for (try = 0; try < 5; try++) { |
| 353 | /* Load the send data into the aux channel data registers */ |
Chris Wilson | 4f7f7b7 | 2010-08-18 18:12:56 +0100 | [diff] [blame] | 354 | for (i = 0; i < send_bytes; i += 4) |
| 355 | I915_WRITE(ch_data + i, |
| 356 | pack_aux(send + i, send_bytes - i)); |
Akshay Joshi | 0206e35 | 2011-08-16 15:34:10 -0400 | [diff] [blame] | 357 | |
Keith Packard | fb0f8fb | 2009-06-11 22:31:31 -0700 | [diff] [blame] | 358 | /* Send the command and wait for it to complete */ |
Chris Wilson | 4f7f7b7 | 2010-08-18 18:12:56 +0100 | [diff] [blame] | 359 | I915_WRITE(ch_ctl, |
| 360 | DP_AUX_CH_CTL_SEND_BUSY | |
Daniel Vetter | 9ee32fea | 2012-12-01 13:53:48 +0100 | [diff] [blame] | 361 | (has_aux_irq ? DP_AUX_CH_CTL_INTERRUPT : 0) | |
Chris Wilson | 4f7f7b7 | 2010-08-18 18:12:56 +0100 | [diff] [blame] | 362 | DP_AUX_CH_CTL_TIME_OUT_400us | |
| 363 | (send_bytes << DP_AUX_CH_CTL_MESSAGE_SIZE_SHIFT) | |
| 364 | (precharge << DP_AUX_CH_CTL_PRECHARGE_2US_SHIFT) | |
| 365 | (aux_clock_divider << DP_AUX_CH_CTL_BIT_CLOCK_2X_SHIFT) | |
| 366 | DP_AUX_CH_CTL_DONE | |
| 367 | DP_AUX_CH_CTL_TIME_OUT_ERROR | |
| 368 | DP_AUX_CH_CTL_RECEIVE_ERROR); |
Daniel Vetter | 9ee32fea | 2012-12-01 13:53:48 +0100 | [diff] [blame] | 369 | |
| 370 | status = intel_dp_aux_wait_done(intel_dp, has_aux_irq); |
Akshay Joshi | 0206e35 | 2011-08-16 15:34:10 -0400 | [diff] [blame] | 371 | |
Keith Packard | fb0f8fb | 2009-06-11 22:31:31 -0700 | [diff] [blame] | 372 | /* Clear done status and any errors */ |
Chris Wilson | 4f7f7b7 | 2010-08-18 18:12:56 +0100 | [diff] [blame] | 373 | I915_WRITE(ch_ctl, |
| 374 | status | |
| 375 | DP_AUX_CH_CTL_DONE | |
| 376 | DP_AUX_CH_CTL_TIME_OUT_ERROR | |
| 377 | DP_AUX_CH_CTL_RECEIVE_ERROR); |
Adam Jackson | d7e96fe | 2011-07-26 15:39:46 -0400 | [diff] [blame] | 378 | |
| 379 | if (status & (DP_AUX_CH_CTL_TIME_OUT_ERROR | |
| 380 | DP_AUX_CH_CTL_RECEIVE_ERROR)) |
| 381 | continue; |
Chris Wilson | 4f7f7b7 | 2010-08-18 18:12:56 +0100 | [diff] [blame] | 382 | if (status & DP_AUX_CH_CTL_DONE) |
Keith Packard | a4fc5ed | 2009-04-07 16:16:42 -0700 | [diff] [blame] | 383 | break; |
| 384 | } |
| 385 | |
Keith Packard | a4fc5ed | 2009-04-07 16:16:42 -0700 | [diff] [blame] | 386 | if ((status & DP_AUX_CH_CTL_DONE) == 0) { |
Keith Packard | 1ae8c0a | 2009-06-28 15:42:17 -0700 | [diff] [blame] | 387 | DRM_ERROR("dp_aux_ch not done status 0x%08x\n", status); |
Daniel Vetter | 9ee32fea | 2012-12-01 13:53:48 +0100 | [diff] [blame] | 388 | ret = -EBUSY; |
| 389 | goto out; |
Keith Packard | a4fc5ed | 2009-04-07 16:16:42 -0700 | [diff] [blame] | 390 | } |
| 391 | |
| 392 | /* Check for timeout or receive error. |
| 393 | * Timeouts occur when the sink is not connected |
| 394 | */ |
Keith Packard | a5b3da5 | 2009-06-11 22:30:32 -0700 | [diff] [blame] | 395 | if (status & DP_AUX_CH_CTL_RECEIVE_ERROR) { |
Keith Packard | 1ae8c0a | 2009-06-28 15:42:17 -0700 | [diff] [blame] | 396 | DRM_ERROR("dp_aux_ch receive error status 0x%08x\n", status); |
Daniel Vetter | 9ee32fea | 2012-12-01 13:53:48 +0100 | [diff] [blame] | 397 | ret = -EIO; |
| 398 | goto out; |
Keith Packard | a5b3da5 | 2009-06-11 22:30:32 -0700 | [diff] [blame] | 399 | } |
Keith Packard | 1ae8c0a | 2009-06-28 15:42:17 -0700 | [diff] [blame] | 400 | |
| 401 | /* Timeouts occur when the device isn't connected, so they're |
| 402 | * "normal" -- don't fill the kernel log with these */ |
Keith Packard | a5b3da5 | 2009-06-11 22:30:32 -0700 | [diff] [blame] | 403 | if (status & DP_AUX_CH_CTL_TIME_OUT_ERROR) { |
Zhao Yakui | 28c9773 | 2009-10-09 11:39:41 +0800 | [diff] [blame] | 404 | DRM_DEBUG_KMS("dp_aux_ch timeout status 0x%08x\n", status); |
Daniel Vetter | 9ee32fea | 2012-12-01 13:53:48 +0100 | [diff] [blame] | 405 | ret = -ETIMEDOUT; |
| 406 | goto out; |
Keith Packard | a4fc5ed | 2009-04-07 16:16:42 -0700 | [diff] [blame] | 407 | } |
| 408 | |
| 409 | /* Unload any bytes sent back from the other side */ |
| 410 | recv_bytes = ((status & DP_AUX_CH_CTL_MESSAGE_SIZE_MASK) >> |
| 411 | DP_AUX_CH_CTL_MESSAGE_SIZE_SHIFT); |
Keith Packard | a4fc5ed | 2009-04-07 16:16:42 -0700 | [diff] [blame] | 412 | if (recv_bytes > recv_size) |
| 413 | recv_bytes = recv_size; |
Akshay Joshi | 0206e35 | 2011-08-16 15:34:10 -0400 | [diff] [blame] | 414 | |
Chris Wilson | 4f7f7b7 | 2010-08-18 18:12:56 +0100 | [diff] [blame] | 415 | for (i = 0; i < recv_bytes; i += 4) |
| 416 | unpack_aux(I915_READ(ch_data + i), |
| 417 | recv + i, recv_bytes - i); |
Keith Packard | a4fc5ed | 2009-04-07 16:16:42 -0700 | [diff] [blame] | 418 | |
Daniel Vetter | 9ee32fea | 2012-12-01 13:53:48 +0100 | [diff] [blame] | 419 | ret = recv_bytes; |
| 420 | out: |
| 421 | pm_qos_update_request(&dev_priv->pm_qos, PM_QOS_DEFAULT_VALUE); |
| 422 | |
| 423 | return ret; |
Keith Packard | a4fc5ed | 2009-04-07 16:16:42 -0700 | [diff] [blame] | 424 | } |
| 425 | |
| 426 | /* Write data to the aux channel in native mode */ |
| 427 | static int |
Chris Wilson | ea5b213 | 2010-08-04 13:50:23 +0100 | [diff] [blame] | 428 | intel_dp_aux_native_write(struct intel_dp *intel_dp, |
Keith Packard | a4fc5ed | 2009-04-07 16:16:42 -0700 | [diff] [blame] | 429 | uint16_t address, uint8_t *send, int send_bytes) |
| 430 | { |
| 431 | int ret; |
| 432 | uint8_t msg[20]; |
| 433 | int msg_bytes; |
| 434 | uint8_t ack; |
| 435 | |
Keith Packard | 9b984da | 2011-09-19 13:54:47 -0700 | [diff] [blame] | 436 | intel_dp_check_edp(intel_dp); |
Keith Packard | a4fc5ed | 2009-04-07 16:16:42 -0700 | [diff] [blame] | 437 | if (send_bytes > 16) |
| 438 | return -1; |
| 439 | msg[0] = AUX_NATIVE_WRITE << 4; |
| 440 | msg[1] = address >> 8; |
Zhenyu Wang | eebc863 | 2009-07-24 01:00:30 +0800 | [diff] [blame] | 441 | msg[2] = address & 0xff; |
Keith Packard | a4fc5ed | 2009-04-07 16:16:42 -0700 | [diff] [blame] | 442 | msg[3] = send_bytes - 1; |
| 443 | memcpy(&msg[4], send, send_bytes); |
| 444 | msg_bytes = send_bytes + 4; |
| 445 | for (;;) { |
Chris Wilson | ea5b213 | 2010-08-04 13:50:23 +0100 | [diff] [blame] | 446 | ret = intel_dp_aux_ch(intel_dp, msg, msg_bytes, &ack, 1); |
Keith Packard | a4fc5ed | 2009-04-07 16:16:42 -0700 | [diff] [blame] | 447 | if (ret < 0) |
| 448 | return ret; |
| 449 | if ((ack & AUX_NATIVE_REPLY_MASK) == AUX_NATIVE_REPLY_ACK) |
| 450 | break; |
| 451 | else if ((ack & AUX_NATIVE_REPLY_MASK) == AUX_NATIVE_REPLY_DEFER) |
| 452 | udelay(100); |
| 453 | else |
Keith Packard | a5b3da5 | 2009-06-11 22:30:32 -0700 | [diff] [blame] | 454 | return -EIO; |
Keith Packard | a4fc5ed | 2009-04-07 16:16:42 -0700 | [diff] [blame] | 455 | } |
| 456 | return send_bytes; |
| 457 | } |
| 458 | |
| 459 | /* Write a single byte to the aux channel in native mode */ |
| 460 | static int |
Chris Wilson | ea5b213 | 2010-08-04 13:50:23 +0100 | [diff] [blame] | 461 | intel_dp_aux_native_write_1(struct intel_dp *intel_dp, |
Keith Packard | a4fc5ed | 2009-04-07 16:16:42 -0700 | [diff] [blame] | 462 | uint16_t address, uint8_t byte) |
| 463 | { |
Chris Wilson | ea5b213 | 2010-08-04 13:50:23 +0100 | [diff] [blame] | 464 | return intel_dp_aux_native_write(intel_dp, address, &byte, 1); |
Keith Packard | a4fc5ed | 2009-04-07 16:16:42 -0700 | [diff] [blame] | 465 | } |
| 466 | |
| 467 | /* read bytes from a native aux channel */ |
| 468 | static int |
Chris Wilson | ea5b213 | 2010-08-04 13:50:23 +0100 | [diff] [blame] | 469 | intel_dp_aux_native_read(struct intel_dp *intel_dp, |
Keith Packard | a4fc5ed | 2009-04-07 16:16:42 -0700 | [diff] [blame] | 470 | uint16_t address, uint8_t *recv, int recv_bytes) |
| 471 | { |
| 472 | uint8_t msg[4]; |
| 473 | int msg_bytes; |
| 474 | uint8_t reply[20]; |
| 475 | int reply_bytes; |
| 476 | uint8_t ack; |
| 477 | int ret; |
| 478 | |
Keith Packard | 9b984da | 2011-09-19 13:54:47 -0700 | [diff] [blame] | 479 | intel_dp_check_edp(intel_dp); |
Keith Packard | a4fc5ed | 2009-04-07 16:16:42 -0700 | [diff] [blame] | 480 | msg[0] = AUX_NATIVE_READ << 4; |
| 481 | msg[1] = address >> 8; |
| 482 | msg[2] = address & 0xff; |
| 483 | msg[3] = recv_bytes - 1; |
| 484 | |
| 485 | msg_bytes = 4; |
| 486 | reply_bytes = recv_bytes + 1; |
| 487 | |
| 488 | for (;;) { |
Chris Wilson | ea5b213 | 2010-08-04 13:50:23 +0100 | [diff] [blame] | 489 | ret = intel_dp_aux_ch(intel_dp, msg, msg_bytes, |
Keith Packard | a4fc5ed | 2009-04-07 16:16:42 -0700 | [diff] [blame] | 490 | reply, reply_bytes); |
Keith Packard | a5b3da5 | 2009-06-11 22:30:32 -0700 | [diff] [blame] | 491 | if (ret == 0) |
| 492 | return -EPROTO; |
| 493 | if (ret < 0) |
Keith Packard | a4fc5ed | 2009-04-07 16:16:42 -0700 | [diff] [blame] | 494 | return ret; |
| 495 | ack = reply[0]; |
| 496 | if ((ack & AUX_NATIVE_REPLY_MASK) == AUX_NATIVE_REPLY_ACK) { |
| 497 | memcpy(recv, reply + 1, ret - 1); |
| 498 | return ret - 1; |
| 499 | } |
| 500 | else if ((ack & AUX_NATIVE_REPLY_MASK) == AUX_NATIVE_REPLY_DEFER) |
| 501 | udelay(100); |
| 502 | else |
Keith Packard | a5b3da5 | 2009-06-11 22:30:32 -0700 | [diff] [blame] | 503 | return -EIO; |
Keith Packard | a4fc5ed | 2009-04-07 16:16:42 -0700 | [diff] [blame] | 504 | } |
| 505 | } |
| 506 | |
| 507 | static int |
Dave Airlie | ab2c067 | 2009-12-04 10:55:24 +1000 | [diff] [blame] | 508 | intel_dp_i2c_aux_ch(struct i2c_adapter *adapter, int mode, |
| 509 | uint8_t write_byte, uint8_t *read_byte) |
Keith Packard | a4fc5ed | 2009-04-07 16:16:42 -0700 | [diff] [blame] | 510 | { |
Dave Airlie | ab2c067 | 2009-12-04 10:55:24 +1000 | [diff] [blame] | 511 | struct i2c_algo_dp_aux_data *algo_data = adapter->algo_data; |
Chris Wilson | ea5b213 | 2010-08-04 13:50:23 +0100 | [diff] [blame] | 512 | struct intel_dp *intel_dp = container_of(adapter, |
| 513 | struct intel_dp, |
| 514 | adapter); |
Dave Airlie | ab2c067 | 2009-12-04 10:55:24 +1000 | [diff] [blame] | 515 | uint16_t address = algo_data->address; |
| 516 | uint8_t msg[5]; |
| 517 | uint8_t reply[2]; |
David Flynn | 8316f33 | 2010-12-08 16:10:21 +0000 | [diff] [blame] | 518 | unsigned retry; |
Dave Airlie | ab2c067 | 2009-12-04 10:55:24 +1000 | [diff] [blame] | 519 | int msg_bytes; |
| 520 | int reply_bytes; |
| 521 | int ret; |
Keith Packard | a4fc5ed | 2009-04-07 16:16:42 -0700 | [diff] [blame] | 522 | |
Keith Packard | 9b984da | 2011-09-19 13:54:47 -0700 | [diff] [blame] | 523 | intel_dp_check_edp(intel_dp); |
Dave Airlie | ab2c067 | 2009-12-04 10:55:24 +1000 | [diff] [blame] | 524 | /* Set up the command byte */ |
| 525 | if (mode & MODE_I2C_READ) |
| 526 | msg[0] = AUX_I2C_READ << 4; |
| 527 | else |
| 528 | msg[0] = AUX_I2C_WRITE << 4; |
| 529 | |
| 530 | if (!(mode & MODE_I2C_STOP)) |
| 531 | msg[0] |= AUX_I2C_MOT << 4; |
| 532 | |
| 533 | msg[1] = address >> 8; |
| 534 | msg[2] = address; |
| 535 | |
| 536 | switch (mode) { |
| 537 | case MODE_I2C_WRITE: |
| 538 | msg[3] = 0; |
| 539 | msg[4] = write_byte; |
| 540 | msg_bytes = 5; |
| 541 | reply_bytes = 1; |
| 542 | break; |
| 543 | case MODE_I2C_READ: |
| 544 | msg[3] = 0; |
| 545 | msg_bytes = 4; |
| 546 | reply_bytes = 2; |
| 547 | break; |
| 548 | default: |
| 549 | msg_bytes = 3; |
| 550 | reply_bytes = 1; |
| 551 | break; |
| 552 | } |
| 553 | |
David Flynn | 8316f33 | 2010-12-08 16:10:21 +0000 | [diff] [blame] | 554 | for (retry = 0; retry < 5; retry++) { |
| 555 | ret = intel_dp_aux_ch(intel_dp, |
| 556 | msg, msg_bytes, |
| 557 | reply, reply_bytes); |
Dave Airlie | ab2c067 | 2009-12-04 10:55:24 +1000 | [diff] [blame] | 558 | if (ret < 0) { |
Dave Airlie | 3ff9916 | 2009-12-08 14:03:47 +1000 | [diff] [blame] | 559 | DRM_DEBUG_KMS("aux_ch failed %d\n", ret); |
Dave Airlie | ab2c067 | 2009-12-04 10:55:24 +1000 | [diff] [blame] | 560 | return ret; |
| 561 | } |
David Flynn | 8316f33 | 2010-12-08 16:10:21 +0000 | [diff] [blame] | 562 | |
| 563 | switch (reply[0] & AUX_NATIVE_REPLY_MASK) { |
| 564 | case AUX_NATIVE_REPLY_ACK: |
| 565 | /* I2C-over-AUX Reply field is only valid |
| 566 | * when paired with AUX ACK. |
| 567 | */ |
| 568 | break; |
| 569 | case AUX_NATIVE_REPLY_NACK: |
| 570 | DRM_DEBUG_KMS("aux_ch native nack\n"); |
| 571 | return -EREMOTEIO; |
| 572 | case AUX_NATIVE_REPLY_DEFER: |
| 573 | udelay(100); |
| 574 | continue; |
| 575 | default: |
| 576 | DRM_ERROR("aux_ch invalid native reply 0x%02x\n", |
| 577 | reply[0]); |
| 578 | return -EREMOTEIO; |
| 579 | } |
| 580 | |
Dave Airlie | ab2c067 | 2009-12-04 10:55:24 +1000 | [diff] [blame] | 581 | switch (reply[0] & AUX_I2C_REPLY_MASK) { |
| 582 | case AUX_I2C_REPLY_ACK: |
| 583 | if (mode == MODE_I2C_READ) { |
| 584 | *read_byte = reply[1]; |
| 585 | } |
| 586 | return reply_bytes - 1; |
| 587 | case AUX_I2C_REPLY_NACK: |
David Flynn | 8316f33 | 2010-12-08 16:10:21 +0000 | [diff] [blame] | 588 | DRM_DEBUG_KMS("aux_i2c nack\n"); |
Dave Airlie | ab2c067 | 2009-12-04 10:55:24 +1000 | [diff] [blame] | 589 | return -EREMOTEIO; |
| 590 | case AUX_I2C_REPLY_DEFER: |
David Flynn | 8316f33 | 2010-12-08 16:10:21 +0000 | [diff] [blame] | 591 | DRM_DEBUG_KMS("aux_i2c defer\n"); |
Dave Airlie | ab2c067 | 2009-12-04 10:55:24 +1000 | [diff] [blame] | 592 | udelay(100); |
| 593 | break; |
| 594 | default: |
David Flynn | 8316f33 | 2010-12-08 16:10:21 +0000 | [diff] [blame] | 595 | DRM_ERROR("aux_i2c invalid reply 0x%02x\n", reply[0]); |
Dave Airlie | ab2c067 | 2009-12-04 10:55:24 +1000 | [diff] [blame] | 596 | return -EREMOTEIO; |
| 597 | } |
| 598 | } |
David Flynn | 8316f33 | 2010-12-08 16:10:21 +0000 | [diff] [blame] | 599 | |
| 600 | DRM_ERROR("too many retries, giving up\n"); |
| 601 | return -EREMOTEIO; |
Keith Packard | a4fc5ed | 2009-04-07 16:16:42 -0700 | [diff] [blame] | 602 | } |
| 603 | |
| 604 | static int |
Chris Wilson | ea5b213 | 2010-08-04 13:50:23 +0100 | [diff] [blame] | 605 | intel_dp_i2c_init(struct intel_dp *intel_dp, |
Zhenyu Wang | 55f78c4 | 2010-03-29 16:13:57 +0800 | [diff] [blame] | 606 | struct intel_connector *intel_connector, const char *name) |
Keith Packard | a4fc5ed | 2009-04-07 16:16:42 -0700 | [diff] [blame] | 607 | { |
Keith Packard | 0b5c541 | 2011-09-28 16:41:05 -0700 | [diff] [blame] | 608 | int ret; |
| 609 | |
Zhenyu Wang | d54e9d2 | 2009-10-19 15:43:51 +0800 | [diff] [blame] | 610 | DRM_DEBUG_KMS("i2c_init %s\n", name); |
Chris Wilson | ea5b213 | 2010-08-04 13:50:23 +0100 | [diff] [blame] | 611 | intel_dp->algo.running = false; |
| 612 | intel_dp->algo.address = 0; |
| 613 | intel_dp->algo.aux_ch = intel_dp_i2c_aux_ch; |
Keith Packard | a4fc5ed | 2009-04-07 16:16:42 -0700 | [diff] [blame] | 614 | |
Akshay Joshi | 0206e35 | 2011-08-16 15:34:10 -0400 | [diff] [blame] | 615 | memset(&intel_dp->adapter, '\0', sizeof(intel_dp->adapter)); |
Chris Wilson | ea5b213 | 2010-08-04 13:50:23 +0100 | [diff] [blame] | 616 | intel_dp->adapter.owner = THIS_MODULE; |
| 617 | intel_dp->adapter.class = I2C_CLASS_DDC; |
Akshay Joshi | 0206e35 | 2011-08-16 15:34:10 -0400 | [diff] [blame] | 618 | strncpy(intel_dp->adapter.name, name, sizeof(intel_dp->adapter.name) - 1); |
Chris Wilson | ea5b213 | 2010-08-04 13:50:23 +0100 | [diff] [blame] | 619 | intel_dp->adapter.name[sizeof(intel_dp->adapter.name) - 1] = '\0'; |
| 620 | intel_dp->adapter.algo_data = &intel_dp->algo; |
| 621 | intel_dp->adapter.dev.parent = &intel_connector->base.kdev; |
| 622 | |
Keith Packard | 0b5c541 | 2011-09-28 16:41:05 -0700 | [diff] [blame] | 623 | ironlake_edp_panel_vdd_on(intel_dp); |
| 624 | ret = i2c_dp_aux_add_bus(&intel_dp->adapter); |
Keith Packard | bd94315 | 2011-09-18 23:09:52 -0700 | [diff] [blame] | 625 | ironlake_edp_panel_vdd_off(intel_dp, false); |
Keith Packard | 0b5c541 | 2011-09-28 16:41:05 -0700 | [diff] [blame] | 626 | return ret; |
Keith Packard | a4fc5ed | 2009-04-07 16:16:42 -0700 | [diff] [blame] | 627 | } |
| 628 | |
Daniel Vetter | c6bb353 | 2013-04-19 11:14:33 +0200 | [diff] [blame] | 629 | static void |
| 630 | intel_dp_set_clock(struct intel_encoder *encoder, |
| 631 | struct intel_crtc_config *pipe_config, int link_bw) |
| 632 | { |
| 633 | struct drm_device *dev = encoder->base.dev; |
| 634 | |
| 635 | if (IS_G4X(dev)) { |
| 636 | if (link_bw == DP_LINK_BW_1_62) { |
| 637 | pipe_config->dpll.p1 = 2; |
| 638 | pipe_config->dpll.p2 = 10; |
| 639 | pipe_config->dpll.n = 2; |
| 640 | pipe_config->dpll.m1 = 23; |
| 641 | pipe_config->dpll.m2 = 8; |
| 642 | } else { |
| 643 | pipe_config->dpll.p1 = 1; |
| 644 | pipe_config->dpll.p2 = 10; |
| 645 | pipe_config->dpll.n = 1; |
| 646 | pipe_config->dpll.m1 = 14; |
| 647 | pipe_config->dpll.m2 = 2; |
| 648 | } |
| 649 | pipe_config->clock_set = true; |
| 650 | } else if (IS_HASWELL(dev)) { |
| 651 | /* Haswell has special-purpose DP DDI clocks. */ |
| 652 | } else if (HAS_PCH_SPLIT(dev)) { |
| 653 | if (link_bw == DP_LINK_BW_1_62) { |
| 654 | pipe_config->dpll.n = 1; |
| 655 | pipe_config->dpll.p1 = 2; |
| 656 | pipe_config->dpll.p2 = 10; |
| 657 | pipe_config->dpll.m1 = 12; |
| 658 | pipe_config->dpll.m2 = 9; |
| 659 | } else { |
| 660 | pipe_config->dpll.n = 2; |
| 661 | pipe_config->dpll.p1 = 1; |
| 662 | pipe_config->dpll.p2 = 10; |
| 663 | pipe_config->dpll.m1 = 14; |
| 664 | pipe_config->dpll.m2 = 8; |
| 665 | } |
| 666 | pipe_config->clock_set = true; |
| 667 | } else if (IS_VALLEYVIEW(dev)) { |
| 668 | /* FIXME: Need to figure out optimized DP clocks for vlv. */ |
| 669 | } |
| 670 | } |
| 671 | |
Paulo Zanoni | 00c09d7 | 2012-10-26 19:05:52 -0200 | [diff] [blame] | 672 | bool |
Daniel Vetter | 5bfe2ac | 2013-03-27 00:44:55 +0100 | [diff] [blame] | 673 | intel_dp_compute_config(struct intel_encoder *encoder, |
| 674 | struct intel_crtc_config *pipe_config) |
Keith Packard | a4fc5ed | 2009-04-07 16:16:42 -0700 | [diff] [blame] | 675 | { |
Daniel Vetter | 5bfe2ac | 2013-03-27 00:44:55 +0100 | [diff] [blame] | 676 | struct drm_device *dev = encoder->base.dev; |
Daniel Vetter | 3600836 | 2013-03-27 00:44:59 +0100 | [diff] [blame] | 677 | struct drm_i915_private *dev_priv = dev->dev_private; |
Daniel Vetter | 5bfe2ac | 2013-03-27 00:44:55 +0100 | [diff] [blame] | 678 | struct drm_display_mode *adjusted_mode = &pipe_config->adjusted_mode; |
Daniel Vetter | 5bfe2ac | 2013-03-27 00:44:55 +0100 | [diff] [blame] | 679 | struct intel_dp *intel_dp = enc_to_intel_dp(&encoder->base); |
Imre Deak | bc7d38a | 2013-05-16 14:40:36 +0300 | [diff] [blame] | 680 | enum port port = dp_to_dig_port(intel_dp)->port; |
Jesse Barnes | 2dd2455 | 2013-04-25 12:55:01 -0700 | [diff] [blame] | 681 | struct intel_crtc *intel_crtc = encoder->new_crtc; |
Jani Nikula | dd06f90 | 2012-10-19 14:51:50 +0300 | [diff] [blame] | 682 | struct intel_connector *intel_connector = intel_dp->attached_connector; |
Keith Packard | a4fc5ed | 2009-04-07 16:16:42 -0700 | [diff] [blame] | 683 | int lane_count, clock; |
Daniel Vetter | 397fe15 | 2012-10-22 22:56:43 +0200 | [diff] [blame] | 684 | int max_lane_count = drm_dp_max_lane_count(intel_dp->dpcd); |
Chris Wilson | ea5b213 | 2010-08-04 13:50:23 +0100 | [diff] [blame] | 685 | int max_clock = intel_dp_max_link_bw(intel_dp) == DP_LINK_BW_2_7 ? 1 : 0; |
Daniel Vetter | 083f956 | 2012-04-20 20:23:49 +0200 | [diff] [blame] | 686 | int bpp, mode_rate; |
Keith Packard | a4fc5ed | 2009-04-07 16:16:42 -0700 | [diff] [blame] | 687 | static int bws[2] = { DP_LINK_BW_1_62, DP_LINK_BW_2_7 }; |
Daniel Vetter | ff9a675 | 2013-06-01 17:16:21 +0200 | [diff] [blame] | 688 | int link_avail, link_clock; |
Keith Packard | a4fc5ed | 2009-04-07 16:16:42 -0700 | [diff] [blame] | 689 | |
Imre Deak | bc7d38a | 2013-05-16 14:40:36 +0300 | [diff] [blame] | 690 | if (HAS_PCH_SPLIT(dev) && !HAS_DDI(dev) && port != PORT_A) |
Daniel Vetter | 5bfe2ac | 2013-03-27 00:44:55 +0100 | [diff] [blame] | 691 | pipe_config->has_pch_encoder = true; |
| 692 | |
Daniel Vetter | 03afc4a | 2013-04-02 23:42:31 +0200 | [diff] [blame] | 693 | pipe_config->has_dp_encoder = true; |
Keith Packard | a4fc5ed | 2009-04-07 16:16:42 -0700 | [diff] [blame] | 694 | |
Jani Nikula | dd06f90 | 2012-10-19 14:51:50 +0300 | [diff] [blame] | 695 | if (is_edp(intel_dp) && intel_connector->panel.fixed_mode) { |
| 696 | intel_fixed_panel_mode(intel_connector->panel.fixed_mode, |
| 697 | adjusted_mode); |
Jesse Barnes | 2dd2455 | 2013-04-25 12:55:01 -0700 | [diff] [blame] | 698 | if (!HAS_PCH_SPLIT(dev)) |
| 699 | intel_gmch_panel_fitting(intel_crtc, pipe_config, |
| 700 | intel_connector->panel.fitting_mode); |
| 701 | else |
Jesse Barnes | b074cec | 2013-04-25 12:55:02 -0700 | [diff] [blame] | 702 | intel_pch_panel_fitting(intel_crtc, pipe_config, |
| 703 | intel_connector->panel.fitting_mode); |
Zhao Yakui | 0d3a1be | 2010-07-19 09:43:13 +0100 | [diff] [blame] | 704 | } |
| 705 | |
Daniel Vetter | cb1793c | 2012-06-04 18:39:21 +0200 | [diff] [blame] | 706 | if (adjusted_mode->flags & DRM_MODE_FLAG_DBLCLK) |
Daniel Vetter | 0af78a2 | 2012-05-23 11:30:55 +0200 | [diff] [blame] | 707 | return false; |
| 708 | |
Daniel Vetter | 083f956 | 2012-04-20 20:23:49 +0200 | [diff] [blame] | 709 | DRM_DEBUG_KMS("DP link computation with max lane count %i " |
| 710 | "max bw %02x pixel clock %iKHz\n", |
Daniel Vetter | 7124465 | 2012-06-04 18:39:20 +0200 | [diff] [blame] | 711 | max_lane_count, bws[max_clock], adjusted_mode->clock); |
Daniel Vetter | 083f956 | 2012-04-20 20:23:49 +0200 | [diff] [blame] | 712 | |
Daniel Vetter | 3600836 | 2013-03-27 00:44:59 +0100 | [diff] [blame] | 713 | /* Walk through all bpp values. Luckily they're all nicely spaced with 2 |
| 714 | * bpc in between. */ |
Daniel Vetter | 3e7ca98 | 2013-06-01 19:45:56 +0200 | [diff] [blame] | 715 | bpp = pipe_config->pipe_bpp; |
Daniel Vetter | e1b73cb | 2013-05-21 09:52:16 +0200 | [diff] [blame] | 716 | if (is_edp(intel_dp) && dev_priv->vbt.edp_bpp) |
| 717 | bpp = min_t(int, bpp, dev_priv->vbt.edp_bpp); |
Daniel Vetter | 657445f | 2013-05-04 10:09:18 +0200 | [diff] [blame] | 718 | |
Daniel Vetter | 3600836 | 2013-03-27 00:44:59 +0100 | [diff] [blame] | 719 | for (; bpp >= 6*3; bpp -= 2*3) { |
Daniel Vetter | ff9a675 | 2013-06-01 17:16:21 +0200 | [diff] [blame] | 720 | mode_rate = intel_dp_link_required(adjusted_mode->clock, bpp); |
Daniel Vetter | c486793 | 2012-04-10 10:42:36 +0200 | [diff] [blame] | 721 | |
Daniel Vetter | 3600836 | 2013-03-27 00:44:59 +0100 | [diff] [blame] | 722 | for (clock = 0; clock <= max_clock; clock++) { |
| 723 | for (lane_count = 1; lane_count <= max_lane_count; lane_count <<= 1) { |
| 724 | link_clock = drm_dp_bw_code_to_link_rate(bws[clock]); |
| 725 | link_avail = intel_dp_max_data_rate(link_clock, |
| 726 | lane_count); |
Ville Syrjälä | 3685a8f | 2013-01-17 16:31:28 +0200 | [diff] [blame] | 727 | |
Daniel Vetter | 3600836 | 2013-03-27 00:44:59 +0100 | [diff] [blame] | 728 | if (mode_rate <= link_avail) { |
| 729 | goto found; |
| 730 | } |
| 731 | } |
| 732 | } |
| 733 | } |
| 734 | |
| 735 | return false; |
| 736 | |
| 737 | found: |
Ville Syrjälä | 55bc60d | 2013-01-17 16:31:29 +0200 | [diff] [blame] | 738 | if (intel_dp->color_range_auto) { |
| 739 | /* |
| 740 | * See: |
| 741 | * CEA-861-E - 5.1 Default Encoding Parameters |
| 742 | * VESA DisplayPort Ver.1.2a - 5.1.1.1 Video Colorimetry |
| 743 | */ |
Thierry Reding | 18316c8 | 2012-12-20 15:41:44 +0100 | [diff] [blame] | 744 | if (bpp != 18 && drm_match_cea_mode(adjusted_mode) > 1) |
Ville Syrjälä | 55bc60d | 2013-01-17 16:31:29 +0200 | [diff] [blame] | 745 | intel_dp->color_range = DP_COLOR_RANGE_16_235; |
| 746 | else |
| 747 | intel_dp->color_range = 0; |
| 748 | } |
| 749 | |
Ville Syrjälä | 3685a8f | 2013-01-17 16:31:28 +0200 | [diff] [blame] | 750 | if (intel_dp->color_range) |
Daniel Vetter | 50f3b01 | 2013-03-27 00:44:56 +0100 | [diff] [blame] | 751 | pipe_config->limited_color_range = true; |
Ville Syrjälä | 3685a8f | 2013-01-17 16:31:28 +0200 | [diff] [blame] | 752 | |
Daniel Vetter | 3600836 | 2013-03-27 00:44:59 +0100 | [diff] [blame] | 753 | intel_dp->link_bw = bws[clock]; |
| 754 | intel_dp->lane_count = lane_count; |
Daniel Vetter | 657445f | 2013-05-04 10:09:18 +0200 | [diff] [blame] | 755 | pipe_config->pipe_bpp = bpp; |
Daniel Vetter | ff9a675 | 2013-06-01 17:16:21 +0200 | [diff] [blame] | 756 | pipe_config->port_clock = drm_dp_bw_code_to_link_rate(intel_dp->link_bw); |
Daniel Vetter | c486793 | 2012-04-10 10:42:36 +0200 | [diff] [blame] | 757 | |
Daniel Vetter | 3600836 | 2013-03-27 00:44:59 +0100 | [diff] [blame] | 758 | DRM_DEBUG_KMS("DP link bw %02x lane count %d clock %d bpp %d\n", |
| 759 | intel_dp->link_bw, intel_dp->lane_count, |
Daniel Vetter | ff9a675 | 2013-06-01 17:16:21 +0200 | [diff] [blame] | 760 | pipe_config->port_clock, bpp); |
Daniel Vetter | 3600836 | 2013-03-27 00:44:59 +0100 | [diff] [blame] | 761 | DRM_DEBUG_KMS("DP link bw required %i available %i\n", |
| 762 | mode_rate, link_avail); |
Keith Packard | a4fc5ed | 2009-04-07 16:16:42 -0700 | [diff] [blame] | 763 | |
Daniel Vetter | 03afc4a | 2013-04-02 23:42:31 +0200 | [diff] [blame] | 764 | intel_link_compute_m_n(bpp, lane_count, |
Daniel Vetter | ff9a675 | 2013-06-01 17:16:21 +0200 | [diff] [blame] | 765 | adjusted_mode->clock, pipe_config->port_clock, |
Daniel Vetter | 03afc4a | 2013-04-02 23:42:31 +0200 | [diff] [blame] | 766 | &pipe_config->dp_m_n); |
Keith Packard | a4fc5ed | 2009-04-07 16:16:42 -0700 | [diff] [blame] | 767 | |
Daniel Vetter | c6bb353 | 2013-04-19 11:14:33 +0200 | [diff] [blame] | 768 | intel_dp_set_clock(encoder, pipe_config, intel_dp->link_bw); |
| 769 | |
Daniel Vetter | 3600836 | 2013-03-27 00:44:59 +0100 | [diff] [blame] | 770 | return true; |
Keith Packard | a4fc5ed | 2009-04-07 16:16:42 -0700 | [diff] [blame] | 771 | } |
| 772 | |
Paulo Zanoni | 247d89f | 2012-10-15 15:51:33 -0300 | [diff] [blame] | 773 | void intel_dp_init_link_config(struct intel_dp *intel_dp) |
| 774 | { |
| 775 | memset(intel_dp->link_configuration, 0, DP_LINK_CONFIGURATION_SIZE); |
| 776 | intel_dp->link_configuration[0] = intel_dp->link_bw; |
| 777 | intel_dp->link_configuration[1] = intel_dp->lane_count; |
| 778 | intel_dp->link_configuration[8] = DP_SET_ANSI_8B10B; |
| 779 | /* |
| 780 | * Check for DPCD version > 1.1 and enhanced framing support |
| 781 | */ |
| 782 | if (intel_dp->dpcd[DP_DPCD_REV] >= 0x11 && |
| 783 | (intel_dp->dpcd[DP_MAX_LANE_COUNT] & DP_ENHANCED_FRAME_CAP)) { |
| 784 | intel_dp->link_configuration[1] |= DP_LANE_COUNT_ENHANCED_FRAME_EN; |
| 785 | } |
| 786 | } |
| 787 | |
Daniel Vetter | 7c62a16 | 2013-06-01 17:16:20 +0200 | [diff] [blame] | 788 | static void ironlake_set_pll_cpu_edp(struct intel_dp *intel_dp) |
Daniel Vetter | ea9b600 | 2012-11-29 15:59:31 +0100 | [diff] [blame] | 789 | { |
Daniel Vetter | 7c62a16 | 2013-06-01 17:16:20 +0200 | [diff] [blame] | 790 | struct intel_digital_port *dig_port = dp_to_dig_port(intel_dp); |
| 791 | struct intel_crtc *crtc = to_intel_crtc(dig_port->base.base.crtc); |
| 792 | struct drm_device *dev = crtc->base.dev; |
Daniel Vetter | ea9b600 | 2012-11-29 15:59:31 +0100 | [diff] [blame] | 793 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 794 | u32 dpa_ctl; |
| 795 | |
Daniel Vetter | ff9a675 | 2013-06-01 17:16:21 +0200 | [diff] [blame] | 796 | DRM_DEBUG_KMS("eDP PLL enable for clock %d\n", crtc->config.port_clock); |
Daniel Vetter | ea9b600 | 2012-11-29 15:59:31 +0100 | [diff] [blame] | 797 | dpa_ctl = I915_READ(DP_A); |
| 798 | dpa_ctl &= ~DP_PLL_FREQ_MASK; |
| 799 | |
Daniel Vetter | ff9a675 | 2013-06-01 17:16:21 +0200 | [diff] [blame] | 800 | if (crtc->config.port_clock == 162000) { |
Daniel Vetter | 1ce1703 | 2012-11-29 15:59:32 +0100 | [diff] [blame] | 801 | /* For a long time we've carried around a ILK-DevA w/a for the |
| 802 | * 160MHz clock. If we're really unlucky, it's still required. |
| 803 | */ |
| 804 | DRM_DEBUG_KMS("160MHz cpu eDP clock, might need ilk devA w/a\n"); |
Daniel Vetter | ea9b600 | 2012-11-29 15:59:31 +0100 | [diff] [blame] | 805 | dpa_ctl |= DP_PLL_FREQ_160MHZ; |
Daniel Vetter | 7c62a16 | 2013-06-01 17:16:20 +0200 | [diff] [blame] | 806 | intel_dp->DP |= DP_PLL_FREQ_160MHZ; |
Daniel Vetter | ea9b600 | 2012-11-29 15:59:31 +0100 | [diff] [blame] | 807 | } else { |
| 808 | dpa_ctl |= DP_PLL_FREQ_270MHZ; |
Daniel Vetter | 7c62a16 | 2013-06-01 17:16:20 +0200 | [diff] [blame] | 809 | intel_dp->DP |= DP_PLL_FREQ_270MHZ; |
Daniel Vetter | ea9b600 | 2012-11-29 15:59:31 +0100 | [diff] [blame] | 810 | } |
Daniel Vetter | 1ce1703 | 2012-11-29 15:59:32 +0100 | [diff] [blame] | 811 | |
Daniel Vetter | ea9b600 | 2012-11-29 15:59:31 +0100 | [diff] [blame] | 812 | I915_WRITE(DP_A, dpa_ctl); |
| 813 | |
| 814 | POSTING_READ(DP_A); |
| 815 | udelay(500); |
| 816 | } |
| 817 | |
Keith Packard | a4fc5ed | 2009-04-07 16:16:42 -0700 | [diff] [blame] | 818 | static void |
| 819 | intel_dp_mode_set(struct drm_encoder *encoder, struct drm_display_mode *mode, |
| 820 | struct drm_display_mode *adjusted_mode) |
| 821 | { |
Zhenyu Wang | e3421a1 | 2010-04-08 09:43:27 +0800 | [diff] [blame] | 822 | struct drm_device *dev = encoder->dev; |
Keith Packard | 417e822 | 2011-11-01 19:54:11 -0700 | [diff] [blame] | 823 | struct drm_i915_private *dev_priv = dev->dev_private; |
Chris Wilson | ea5b213 | 2010-08-04 13:50:23 +0100 | [diff] [blame] | 824 | struct intel_dp *intel_dp = enc_to_intel_dp(encoder); |
Imre Deak | bc7d38a | 2013-05-16 14:40:36 +0300 | [diff] [blame] | 825 | enum port port = dp_to_dig_port(intel_dp)->port; |
Daniel Vetter | 7c62a16 | 2013-06-01 17:16:20 +0200 | [diff] [blame] | 826 | struct intel_crtc *crtc = to_intel_crtc(encoder->crtc); |
Keith Packard | a4fc5ed | 2009-04-07 16:16:42 -0700 | [diff] [blame] | 827 | |
Keith Packard | 417e822 | 2011-11-01 19:54:11 -0700 | [diff] [blame] | 828 | /* |
Keith Packard | 1a2eb46 | 2011-11-16 16:26:07 -0800 | [diff] [blame] | 829 | * There are four kinds of DP registers: |
Keith Packard | 417e822 | 2011-11-01 19:54:11 -0700 | [diff] [blame] | 830 | * |
| 831 | * IBX PCH |
Keith Packard | 1a2eb46 | 2011-11-16 16:26:07 -0800 | [diff] [blame] | 832 | * SNB CPU |
| 833 | * IVB CPU |
Keith Packard | 417e822 | 2011-11-01 19:54:11 -0700 | [diff] [blame] | 834 | * CPT PCH |
| 835 | * |
| 836 | * IBX PCH and CPU are the same for almost everything, |
| 837 | * except that the CPU DP PLL is configured in this |
| 838 | * register |
| 839 | * |
| 840 | * CPT PCH is quite different, having many bits moved |
| 841 | * to the TRANS_DP_CTL register instead. That |
| 842 | * configuration happens (oddly) in ironlake_pch_enable |
| 843 | */ |
Adam Jackson | 9c9e792 | 2010-04-05 17:57:59 -0400 | [diff] [blame] | 844 | |
Keith Packard | 417e822 | 2011-11-01 19:54:11 -0700 | [diff] [blame] | 845 | /* Preserve the BIOS-computed detected bit. This is |
| 846 | * supposed to be read-only. |
| 847 | */ |
| 848 | intel_dp->DP = I915_READ(intel_dp->output_reg) & DP_DETECTED; |
Keith Packard | a4fc5ed | 2009-04-07 16:16:42 -0700 | [diff] [blame] | 849 | |
Keith Packard | 417e822 | 2011-11-01 19:54:11 -0700 | [diff] [blame] | 850 | /* Handle DP bits in common between all three register formats */ |
Keith Packard | 417e822 | 2011-11-01 19:54:11 -0700 | [diff] [blame] | 851 | intel_dp->DP |= DP_VOLTAGE_0_4 | DP_PRE_EMPHASIS_0; |
Daniel Vetter | 17aa6be | 2013-04-30 14:01:40 +0200 | [diff] [blame] | 852 | intel_dp->DP |= DP_PORT_WIDTH(intel_dp->lane_count); |
Keith Packard | a4fc5ed | 2009-04-07 16:16:42 -0700 | [diff] [blame] | 853 | |
Wu Fengguang | e0dac65 | 2011-09-05 14:25:34 +0800 | [diff] [blame] | 854 | if (intel_dp->has_audio) { |
| 855 | DRM_DEBUG_DRIVER("Enabling DP audio on pipe %c\n", |
Daniel Vetter | 7c62a16 | 2013-06-01 17:16:20 +0200 | [diff] [blame] | 856 | pipe_name(crtc->pipe)); |
Chris Wilson | ea5b213 | 2010-08-04 13:50:23 +0100 | [diff] [blame] | 857 | intel_dp->DP |= DP_AUDIO_OUTPUT_ENABLE; |
Wu Fengguang | e0dac65 | 2011-09-05 14:25:34 +0800 | [diff] [blame] | 858 | intel_write_eld(encoder, adjusted_mode); |
| 859 | } |
Paulo Zanoni | 247d89f | 2012-10-15 15:51:33 -0300 | [diff] [blame] | 860 | |
| 861 | intel_dp_init_link_config(intel_dp); |
Keith Packard | a4fc5ed | 2009-04-07 16:16:42 -0700 | [diff] [blame] | 862 | |
Keith Packard | 417e822 | 2011-11-01 19:54:11 -0700 | [diff] [blame] | 863 | /* Split out the IBX/CPU vs CPT settings */ |
Zhenyu Wang | 32f9d65 | 2009-07-24 01:00:32 +0800 | [diff] [blame] | 864 | |
Imre Deak | bc7d38a | 2013-05-16 14:40:36 +0300 | [diff] [blame] | 865 | if (port == PORT_A && IS_GEN7(dev) && !IS_VALLEYVIEW(dev)) { |
Keith Packard | 1a2eb46 | 2011-11-16 16:26:07 -0800 | [diff] [blame] | 866 | if (adjusted_mode->flags & DRM_MODE_FLAG_PHSYNC) |
| 867 | intel_dp->DP |= DP_SYNC_HS_HIGH; |
| 868 | if (adjusted_mode->flags & DRM_MODE_FLAG_PVSYNC) |
| 869 | intel_dp->DP |= DP_SYNC_VS_HIGH; |
| 870 | intel_dp->DP |= DP_LINK_TRAIN_OFF_CPT; |
| 871 | |
| 872 | if (intel_dp->link_configuration[1] & DP_LANE_COUNT_ENHANCED_FRAME_EN) |
| 873 | intel_dp->DP |= DP_ENHANCED_FRAMING; |
| 874 | |
Daniel Vetter | 7c62a16 | 2013-06-01 17:16:20 +0200 | [diff] [blame] | 875 | intel_dp->DP |= crtc->pipe << 29; |
Imre Deak | bc7d38a | 2013-05-16 14:40:36 +0300 | [diff] [blame] | 876 | } else if (!HAS_PCH_CPT(dev) || port == PORT_A) { |
Jesse Barnes | b263401 | 2013-03-28 09:55:40 -0700 | [diff] [blame] | 877 | if (!HAS_PCH_SPLIT(dev) && !IS_VALLEYVIEW(dev)) |
Ville Syrjälä | 3685a8f | 2013-01-17 16:31:28 +0200 | [diff] [blame] | 878 | intel_dp->DP |= intel_dp->color_range; |
Keith Packard | 417e822 | 2011-11-01 19:54:11 -0700 | [diff] [blame] | 879 | |
| 880 | if (adjusted_mode->flags & DRM_MODE_FLAG_PHSYNC) |
| 881 | intel_dp->DP |= DP_SYNC_HS_HIGH; |
| 882 | if (adjusted_mode->flags & DRM_MODE_FLAG_PVSYNC) |
| 883 | intel_dp->DP |= DP_SYNC_VS_HIGH; |
| 884 | intel_dp->DP |= DP_LINK_TRAIN_OFF; |
| 885 | |
| 886 | if (intel_dp->link_configuration[1] & DP_LANE_COUNT_ENHANCED_FRAME_EN) |
| 887 | intel_dp->DP |= DP_ENHANCED_FRAMING; |
| 888 | |
Daniel Vetter | 7c62a16 | 2013-06-01 17:16:20 +0200 | [diff] [blame] | 889 | if (crtc->pipe == 1) |
Keith Packard | 417e822 | 2011-11-01 19:54:11 -0700 | [diff] [blame] | 890 | intel_dp->DP |= DP_PIPEB_SELECT; |
Keith Packard | 417e822 | 2011-11-01 19:54:11 -0700 | [diff] [blame] | 891 | } else { |
| 892 | intel_dp->DP |= DP_LINK_TRAIN_OFF_CPT; |
Zhenyu Wang | 32f9d65 | 2009-07-24 01:00:32 +0800 | [diff] [blame] | 893 | } |
Daniel Vetter | ea9b600 | 2012-11-29 15:59:31 +0100 | [diff] [blame] | 894 | |
Imre Deak | bc7d38a | 2013-05-16 14:40:36 +0300 | [diff] [blame] | 895 | if (port == PORT_A && !IS_VALLEYVIEW(dev)) |
Daniel Vetter | 7c62a16 | 2013-06-01 17:16:20 +0200 | [diff] [blame] | 896 | ironlake_set_pll_cpu_edp(intel_dp); |
Keith Packard | a4fc5ed | 2009-04-07 16:16:42 -0700 | [diff] [blame] | 897 | } |
| 898 | |
Keith Packard | 99ea712 | 2011-11-01 19:57:50 -0700 | [diff] [blame] | 899 | #define IDLE_ON_MASK (PP_ON | 0 | PP_SEQUENCE_MASK | 0 | PP_SEQUENCE_STATE_MASK) |
| 900 | #define IDLE_ON_VALUE (PP_ON | 0 | PP_SEQUENCE_NONE | 0 | PP_SEQUENCE_STATE_ON_IDLE) |
| 901 | |
| 902 | #define IDLE_OFF_MASK (PP_ON | 0 | PP_SEQUENCE_MASK | 0 | PP_SEQUENCE_STATE_MASK) |
| 903 | #define IDLE_OFF_VALUE (0 | 0 | PP_SEQUENCE_NONE | 0 | PP_SEQUENCE_STATE_OFF_IDLE) |
| 904 | |
| 905 | #define IDLE_CYCLE_MASK (PP_ON | 0 | PP_SEQUENCE_MASK | PP_CYCLE_DELAY_ACTIVE | PP_SEQUENCE_STATE_MASK) |
| 906 | #define IDLE_CYCLE_VALUE (0 | 0 | PP_SEQUENCE_NONE | 0 | PP_SEQUENCE_STATE_OFF_IDLE) |
| 907 | |
| 908 | static void ironlake_wait_panel_status(struct intel_dp *intel_dp, |
| 909 | u32 mask, |
| 910 | u32 value) |
| 911 | { |
Paulo Zanoni | 30add22 | 2012-10-26 19:05:45 -0200 | [diff] [blame] | 912 | struct drm_device *dev = intel_dp_to_dev(intel_dp); |
Keith Packard | 99ea712 | 2011-11-01 19:57:50 -0700 | [diff] [blame] | 913 | struct drm_i915_private *dev_priv = dev->dev_private; |
Jesse Barnes | 453c542 | 2013-03-28 09:55:41 -0700 | [diff] [blame] | 914 | u32 pp_stat_reg, pp_ctrl_reg; |
| 915 | |
| 916 | pp_stat_reg = IS_VALLEYVIEW(dev) ? PIPEA_PP_STATUS : PCH_PP_STATUS; |
| 917 | pp_ctrl_reg = IS_VALLEYVIEW(dev) ? PIPEA_PP_CONTROL : PCH_PP_CONTROL; |
Keith Packard | 99ea712 | 2011-11-01 19:57:50 -0700 | [diff] [blame] | 918 | |
| 919 | DRM_DEBUG_KMS("mask %08x value %08x status %08x control %08x\n", |
Jesse Barnes | 453c542 | 2013-03-28 09:55:41 -0700 | [diff] [blame] | 920 | mask, value, |
| 921 | I915_READ(pp_stat_reg), |
| 922 | I915_READ(pp_ctrl_reg)); |
Keith Packard | 99ea712 | 2011-11-01 19:57:50 -0700 | [diff] [blame] | 923 | |
Jesse Barnes | 453c542 | 2013-03-28 09:55:41 -0700 | [diff] [blame] | 924 | if (_wait_for((I915_READ(pp_stat_reg) & mask) == value, 5000, 10)) { |
Keith Packard | 99ea712 | 2011-11-01 19:57:50 -0700 | [diff] [blame] | 925 | DRM_ERROR("Panel status timeout: status %08x control %08x\n", |
Jesse Barnes | 453c542 | 2013-03-28 09:55:41 -0700 | [diff] [blame] | 926 | I915_READ(pp_stat_reg), |
| 927 | I915_READ(pp_ctrl_reg)); |
Keith Packard | 99ea712 | 2011-11-01 19:57:50 -0700 | [diff] [blame] | 928 | } |
| 929 | } |
| 930 | |
| 931 | static void ironlake_wait_panel_on(struct intel_dp *intel_dp) |
| 932 | { |
| 933 | DRM_DEBUG_KMS("Wait for panel power on\n"); |
| 934 | ironlake_wait_panel_status(intel_dp, IDLE_ON_MASK, IDLE_ON_VALUE); |
| 935 | } |
| 936 | |
Keith Packard | bd94315 | 2011-09-18 23:09:52 -0700 | [diff] [blame] | 937 | static void ironlake_wait_panel_off(struct intel_dp *intel_dp) |
| 938 | { |
Keith Packard | bd94315 | 2011-09-18 23:09:52 -0700 | [diff] [blame] | 939 | DRM_DEBUG_KMS("Wait for panel power off time\n"); |
Keith Packard | 99ea712 | 2011-11-01 19:57:50 -0700 | [diff] [blame] | 940 | ironlake_wait_panel_status(intel_dp, IDLE_OFF_MASK, IDLE_OFF_VALUE); |
Keith Packard | bd94315 | 2011-09-18 23:09:52 -0700 | [diff] [blame] | 941 | } |
Keith Packard | bd94315 | 2011-09-18 23:09:52 -0700 | [diff] [blame] | 942 | |
Keith Packard | 99ea712 | 2011-11-01 19:57:50 -0700 | [diff] [blame] | 943 | static void ironlake_wait_panel_power_cycle(struct intel_dp *intel_dp) |
| 944 | { |
| 945 | DRM_DEBUG_KMS("Wait for panel power cycle\n"); |
| 946 | ironlake_wait_panel_status(intel_dp, IDLE_CYCLE_MASK, IDLE_CYCLE_VALUE); |
| 947 | } |
Keith Packard | bd94315 | 2011-09-18 23:09:52 -0700 | [diff] [blame] | 948 | |
Keith Packard | 99ea712 | 2011-11-01 19:57:50 -0700 | [diff] [blame] | 949 | |
Keith Packard | 832dd3c | 2011-11-01 19:34:06 -0700 | [diff] [blame] | 950 | /* Read the current pp_control value, unlocking the register if it |
| 951 | * is locked |
| 952 | */ |
| 953 | |
Jesse Barnes | 453c542 | 2013-03-28 09:55:41 -0700 | [diff] [blame] | 954 | static u32 ironlake_get_pp_control(struct intel_dp *intel_dp) |
Keith Packard | 832dd3c | 2011-11-01 19:34:06 -0700 | [diff] [blame] | 955 | { |
Jesse Barnes | 453c542 | 2013-03-28 09:55:41 -0700 | [diff] [blame] | 956 | struct drm_device *dev = intel_dp_to_dev(intel_dp); |
| 957 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 958 | u32 control; |
| 959 | u32 pp_ctrl_reg; |
| 960 | |
| 961 | pp_ctrl_reg = IS_VALLEYVIEW(dev) ? PIPEA_PP_CONTROL : PCH_PP_CONTROL; |
| 962 | control = I915_READ(pp_ctrl_reg); |
Keith Packard | 832dd3c | 2011-11-01 19:34:06 -0700 | [diff] [blame] | 963 | |
| 964 | control &= ~PANEL_UNLOCK_MASK; |
| 965 | control |= PANEL_UNLOCK_REGS; |
| 966 | return control; |
Keith Packard | bd94315 | 2011-09-18 23:09:52 -0700 | [diff] [blame] | 967 | } |
| 968 | |
Paulo Zanoni | 82a4d9c | 2012-10-23 18:30:07 -0200 | [diff] [blame] | 969 | void ironlake_edp_panel_vdd_on(struct intel_dp *intel_dp) |
Jesse Barnes | 5d61350 | 2011-01-24 17:10:54 -0800 | [diff] [blame] | 970 | { |
Paulo Zanoni | 30add22 | 2012-10-26 19:05:45 -0200 | [diff] [blame] | 971 | struct drm_device *dev = intel_dp_to_dev(intel_dp); |
Jesse Barnes | 5d61350 | 2011-01-24 17:10:54 -0800 | [diff] [blame] | 972 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 973 | u32 pp; |
Jesse Barnes | 453c542 | 2013-03-28 09:55:41 -0700 | [diff] [blame] | 974 | u32 pp_stat_reg, pp_ctrl_reg; |
Jesse Barnes | 5d61350 | 2011-01-24 17:10:54 -0800 | [diff] [blame] | 975 | |
Keith Packard | 97af61f57 | 2011-09-28 16:23:51 -0700 | [diff] [blame] | 976 | if (!is_edp(intel_dp)) |
| 977 | return; |
Keith Packard | f01eca2 | 2011-09-28 16:48:10 -0700 | [diff] [blame] | 978 | DRM_DEBUG_KMS("Turn eDP VDD on\n"); |
Jesse Barnes | 5d61350 | 2011-01-24 17:10:54 -0800 | [diff] [blame] | 979 | |
Keith Packard | bd94315 | 2011-09-18 23:09:52 -0700 | [diff] [blame] | 980 | WARN(intel_dp->want_panel_vdd, |
| 981 | "eDP VDD already requested on\n"); |
| 982 | |
| 983 | intel_dp->want_panel_vdd = true; |
Keith Packard | 99ea712 | 2011-11-01 19:57:50 -0700 | [diff] [blame] | 984 | |
Keith Packard | bd94315 | 2011-09-18 23:09:52 -0700 | [diff] [blame] | 985 | if (ironlake_edp_have_panel_vdd(intel_dp)) { |
| 986 | DRM_DEBUG_KMS("eDP VDD already on\n"); |
| 987 | return; |
| 988 | } |
| 989 | |
Keith Packard | 99ea712 | 2011-11-01 19:57:50 -0700 | [diff] [blame] | 990 | if (!ironlake_edp_have_panel_power(intel_dp)) |
| 991 | ironlake_wait_panel_power_cycle(intel_dp); |
| 992 | |
Jesse Barnes | 453c542 | 2013-03-28 09:55:41 -0700 | [diff] [blame] | 993 | pp = ironlake_get_pp_control(intel_dp); |
Jesse Barnes | 5d61350 | 2011-01-24 17:10:54 -0800 | [diff] [blame] | 994 | pp |= EDP_FORCE_VDD; |
Keith Packard | ebf33b1 | 2011-09-29 15:53:27 -0700 | [diff] [blame] | 995 | |
Jesse Barnes | 453c542 | 2013-03-28 09:55:41 -0700 | [diff] [blame] | 996 | pp_stat_reg = IS_VALLEYVIEW(dev) ? PIPEA_PP_STATUS : PCH_PP_STATUS; |
| 997 | pp_ctrl_reg = IS_VALLEYVIEW(dev) ? PIPEA_PP_CONTROL : PCH_PP_CONTROL; |
| 998 | |
| 999 | I915_WRITE(pp_ctrl_reg, pp); |
| 1000 | POSTING_READ(pp_ctrl_reg); |
| 1001 | DRM_DEBUG_KMS("PP_STATUS: 0x%08x PP_CONTROL: 0x%08x\n", |
| 1002 | I915_READ(pp_stat_reg), I915_READ(pp_ctrl_reg)); |
Keith Packard | ebf33b1 | 2011-09-29 15:53:27 -0700 | [diff] [blame] | 1003 | /* |
| 1004 | * If the panel wasn't on, delay before accessing aux channel |
| 1005 | */ |
| 1006 | if (!ironlake_edp_have_panel_power(intel_dp)) { |
Keith Packard | bd94315 | 2011-09-18 23:09:52 -0700 | [diff] [blame] | 1007 | DRM_DEBUG_KMS("eDP was not running\n"); |
Keith Packard | f01eca2 | 2011-09-28 16:48:10 -0700 | [diff] [blame] | 1008 | msleep(intel_dp->panel_power_up_delay); |
Keith Packard | f01eca2 | 2011-09-28 16:48:10 -0700 | [diff] [blame] | 1009 | } |
Jesse Barnes | 5d61350 | 2011-01-24 17:10:54 -0800 | [diff] [blame] | 1010 | } |
| 1011 | |
Keith Packard | bd94315 | 2011-09-18 23:09:52 -0700 | [diff] [blame] | 1012 | static void ironlake_panel_vdd_off_sync(struct intel_dp *intel_dp) |
Jesse Barnes | 5d61350 | 2011-01-24 17:10:54 -0800 | [diff] [blame] | 1013 | { |
Paulo Zanoni | 30add22 | 2012-10-26 19:05:45 -0200 | [diff] [blame] | 1014 | struct drm_device *dev = intel_dp_to_dev(intel_dp); |
Jesse Barnes | 5d61350 | 2011-01-24 17:10:54 -0800 | [diff] [blame] | 1015 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 1016 | u32 pp; |
Jesse Barnes | 453c542 | 2013-03-28 09:55:41 -0700 | [diff] [blame] | 1017 | u32 pp_stat_reg, pp_ctrl_reg; |
Jesse Barnes | 5d61350 | 2011-01-24 17:10:54 -0800 | [diff] [blame] | 1018 | |
Daniel Vetter | a0e99e6 | 2012-12-02 01:05:46 +0100 | [diff] [blame] | 1019 | WARN_ON(!mutex_is_locked(&dev->mode_config.mutex)); |
| 1020 | |
Keith Packard | bd94315 | 2011-09-18 23:09:52 -0700 | [diff] [blame] | 1021 | if (!intel_dp->want_panel_vdd && ironlake_edp_have_panel_vdd(intel_dp)) { |
Jesse Barnes | 453c542 | 2013-03-28 09:55:41 -0700 | [diff] [blame] | 1022 | pp = ironlake_get_pp_control(intel_dp); |
Keith Packard | bd94315 | 2011-09-18 23:09:52 -0700 | [diff] [blame] | 1023 | pp &= ~EDP_FORCE_VDD; |
Jesse Barnes | 453c542 | 2013-03-28 09:55:41 -0700 | [diff] [blame] | 1024 | |
| 1025 | pp_stat_reg = IS_VALLEYVIEW(dev) ? PIPEA_PP_STATUS : PCH_PP_STATUS; |
| 1026 | pp_ctrl_reg = IS_VALLEYVIEW(dev) ? PIPEA_PP_CONTROL : PCH_PP_CONTROL; |
| 1027 | |
| 1028 | I915_WRITE(pp_ctrl_reg, pp); |
| 1029 | POSTING_READ(pp_ctrl_reg); |
Jesse Barnes | 5d61350 | 2011-01-24 17:10:54 -0800 | [diff] [blame] | 1030 | |
Keith Packard | bd94315 | 2011-09-18 23:09:52 -0700 | [diff] [blame] | 1031 | /* Make sure sequencer is idle before allowing subsequent activity */ |
Jesse Barnes | 453c542 | 2013-03-28 09:55:41 -0700 | [diff] [blame] | 1032 | DRM_DEBUG_KMS("PP_STATUS: 0x%08x PP_CONTROL: 0x%08x\n", |
| 1033 | I915_READ(pp_stat_reg), I915_READ(pp_ctrl_reg)); |
Keith Packard | 99ea712 | 2011-11-01 19:57:50 -0700 | [diff] [blame] | 1034 | msleep(intel_dp->panel_power_down_delay); |
Keith Packard | bd94315 | 2011-09-18 23:09:52 -0700 | [diff] [blame] | 1035 | } |
| 1036 | } |
| 1037 | |
| 1038 | static void ironlake_panel_vdd_work(struct work_struct *__work) |
| 1039 | { |
| 1040 | struct intel_dp *intel_dp = container_of(to_delayed_work(__work), |
| 1041 | struct intel_dp, panel_vdd_work); |
Paulo Zanoni | 30add22 | 2012-10-26 19:05:45 -0200 | [diff] [blame] | 1042 | struct drm_device *dev = intel_dp_to_dev(intel_dp); |
Keith Packard | bd94315 | 2011-09-18 23:09:52 -0700 | [diff] [blame] | 1043 | |
Keith Packard | 627f767 | 2011-10-31 11:30:10 -0700 | [diff] [blame] | 1044 | mutex_lock(&dev->mode_config.mutex); |
Keith Packard | bd94315 | 2011-09-18 23:09:52 -0700 | [diff] [blame] | 1045 | ironlake_panel_vdd_off_sync(intel_dp); |
Keith Packard | 627f767 | 2011-10-31 11:30:10 -0700 | [diff] [blame] | 1046 | mutex_unlock(&dev->mode_config.mutex); |
Keith Packard | bd94315 | 2011-09-18 23:09:52 -0700 | [diff] [blame] | 1047 | } |
| 1048 | |
Paulo Zanoni | 82a4d9c | 2012-10-23 18:30:07 -0200 | [diff] [blame] | 1049 | void ironlake_edp_panel_vdd_off(struct intel_dp *intel_dp, bool sync) |
Keith Packard | bd94315 | 2011-09-18 23:09:52 -0700 | [diff] [blame] | 1050 | { |
Keith Packard | 97af61f57 | 2011-09-28 16:23:51 -0700 | [diff] [blame] | 1051 | if (!is_edp(intel_dp)) |
| 1052 | return; |
Jesse Barnes | 5d61350 | 2011-01-24 17:10:54 -0800 | [diff] [blame] | 1053 | |
Keith Packard | bd94315 | 2011-09-18 23:09:52 -0700 | [diff] [blame] | 1054 | DRM_DEBUG_KMS("Turn eDP VDD off %d\n", intel_dp->want_panel_vdd); |
| 1055 | WARN(!intel_dp->want_panel_vdd, "eDP VDD not forced on"); |
Keith Packard | f2e8b18 | 2011-11-01 20:01:35 -0700 | [diff] [blame] | 1056 | |
Keith Packard | bd94315 | 2011-09-18 23:09:52 -0700 | [diff] [blame] | 1057 | intel_dp->want_panel_vdd = false; |
| 1058 | |
| 1059 | if (sync) { |
| 1060 | ironlake_panel_vdd_off_sync(intel_dp); |
| 1061 | } else { |
| 1062 | /* |
| 1063 | * Queue the timer to fire a long |
| 1064 | * time from now (relative to the power down delay) |
| 1065 | * to keep the panel power up across a sequence of operations |
| 1066 | */ |
| 1067 | schedule_delayed_work(&intel_dp->panel_vdd_work, |
| 1068 | msecs_to_jiffies(intel_dp->panel_power_cycle_delay * 5)); |
| 1069 | } |
Jesse Barnes | 5d61350 | 2011-01-24 17:10:54 -0800 | [diff] [blame] | 1070 | } |
| 1071 | |
Paulo Zanoni | 82a4d9c | 2012-10-23 18:30:07 -0200 | [diff] [blame] | 1072 | void ironlake_edp_panel_on(struct intel_dp *intel_dp) |
Jesse Barnes | 9934c13 | 2010-07-22 13:18:19 -0700 | [diff] [blame] | 1073 | { |
Paulo Zanoni | 30add22 | 2012-10-26 19:05:45 -0200 | [diff] [blame] | 1074 | struct drm_device *dev = intel_dp_to_dev(intel_dp); |
Jesse Barnes | 9934c13 | 2010-07-22 13:18:19 -0700 | [diff] [blame] | 1075 | struct drm_i915_private *dev_priv = dev->dev_private; |
Keith Packard | 99ea712 | 2011-11-01 19:57:50 -0700 | [diff] [blame] | 1076 | u32 pp; |
Jesse Barnes | 453c542 | 2013-03-28 09:55:41 -0700 | [diff] [blame] | 1077 | u32 pp_ctrl_reg; |
Jesse Barnes | 9934c13 | 2010-07-22 13:18:19 -0700 | [diff] [blame] | 1078 | |
Keith Packard | 97af61f57 | 2011-09-28 16:23:51 -0700 | [diff] [blame] | 1079 | if (!is_edp(intel_dp)) |
Keith Packard | bd94315 | 2011-09-18 23:09:52 -0700 | [diff] [blame] | 1080 | return; |
Keith Packard | 99ea712 | 2011-11-01 19:57:50 -0700 | [diff] [blame] | 1081 | |
| 1082 | DRM_DEBUG_KMS("Turn eDP power on\n"); |
| 1083 | |
| 1084 | if (ironlake_edp_have_panel_power(intel_dp)) { |
| 1085 | DRM_DEBUG_KMS("eDP power already on\n"); |
Keith Packard | 7d639f3 | 2011-09-29 16:05:34 -0700 | [diff] [blame] | 1086 | return; |
Keith Packard | 99ea712 | 2011-11-01 19:57:50 -0700 | [diff] [blame] | 1087 | } |
Jesse Barnes | 9934c13 | 2010-07-22 13:18:19 -0700 | [diff] [blame] | 1088 | |
Keith Packard | 99ea712 | 2011-11-01 19:57:50 -0700 | [diff] [blame] | 1089 | ironlake_wait_panel_power_cycle(intel_dp); |
Jesse Barnes | 37c6c9b | 2010-08-11 10:04:43 -0700 | [diff] [blame] | 1090 | |
Jesse Barnes | 453c542 | 2013-03-28 09:55:41 -0700 | [diff] [blame] | 1091 | pp = ironlake_get_pp_control(intel_dp); |
Keith Packard | 05ce1a4 | 2011-09-29 16:33:01 -0700 | [diff] [blame] | 1092 | if (IS_GEN5(dev)) { |
| 1093 | /* ILK workaround: disable reset around power sequence */ |
| 1094 | pp &= ~PANEL_POWER_RESET; |
| 1095 | I915_WRITE(PCH_PP_CONTROL, pp); |
| 1096 | POSTING_READ(PCH_PP_CONTROL); |
| 1097 | } |
Jesse Barnes | 37c6c9b | 2010-08-11 10:04:43 -0700 | [diff] [blame] | 1098 | |
Keith Packard | 1c0ae80 | 2011-09-19 13:59:29 -0700 | [diff] [blame] | 1099 | pp |= POWER_TARGET_ON; |
Keith Packard | 99ea712 | 2011-11-01 19:57:50 -0700 | [diff] [blame] | 1100 | if (!IS_GEN5(dev)) |
| 1101 | pp |= PANEL_POWER_RESET; |
| 1102 | |
Jesse Barnes | 453c542 | 2013-03-28 09:55:41 -0700 | [diff] [blame] | 1103 | pp_ctrl_reg = IS_VALLEYVIEW(dev) ? PIPEA_PP_CONTROL : PCH_PP_CONTROL; |
| 1104 | |
| 1105 | I915_WRITE(pp_ctrl_reg, pp); |
| 1106 | POSTING_READ(pp_ctrl_reg); |
Jesse Barnes | 9934c13 | 2010-07-22 13:18:19 -0700 | [diff] [blame] | 1107 | |
Keith Packard | 99ea712 | 2011-11-01 19:57:50 -0700 | [diff] [blame] | 1108 | ironlake_wait_panel_on(intel_dp); |
Jesse Barnes | 9934c13 | 2010-07-22 13:18:19 -0700 | [diff] [blame] | 1109 | |
Keith Packard | 05ce1a4 | 2011-09-29 16:33:01 -0700 | [diff] [blame] | 1110 | if (IS_GEN5(dev)) { |
| 1111 | pp |= PANEL_POWER_RESET; /* restore panel reset bit */ |
| 1112 | I915_WRITE(PCH_PP_CONTROL, pp); |
| 1113 | POSTING_READ(PCH_PP_CONTROL); |
| 1114 | } |
Jesse Barnes | 9934c13 | 2010-07-22 13:18:19 -0700 | [diff] [blame] | 1115 | } |
| 1116 | |
Paulo Zanoni | 82a4d9c | 2012-10-23 18:30:07 -0200 | [diff] [blame] | 1117 | void ironlake_edp_panel_off(struct intel_dp *intel_dp) |
Jesse Barnes | 9934c13 | 2010-07-22 13:18:19 -0700 | [diff] [blame] | 1118 | { |
Paulo Zanoni | 30add22 | 2012-10-26 19:05:45 -0200 | [diff] [blame] | 1119 | struct drm_device *dev = intel_dp_to_dev(intel_dp); |
Jesse Barnes | 9934c13 | 2010-07-22 13:18:19 -0700 | [diff] [blame] | 1120 | struct drm_i915_private *dev_priv = dev->dev_private; |
Keith Packard | 99ea712 | 2011-11-01 19:57:50 -0700 | [diff] [blame] | 1121 | u32 pp; |
Jesse Barnes | 453c542 | 2013-03-28 09:55:41 -0700 | [diff] [blame] | 1122 | u32 pp_ctrl_reg; |
Jesse Barnes | 9934c13 | 2010-07-22 13:18:19 -0700 | [diff] [blame] | 1123 | |
Keith Packard | 97af61f57 | 2011-09-28 16:23:51 -0700 | [diff] [blame] | 1124 | if (!is_edp(intel_dp)) |
| 1125 | return; |
Jesse Barnes | 37c6c9b | 2010-08-11 10:04:43 -0700 | [diff] [blame] | 1126 | |
Keith Packard | 99ea712 | 2011-11-01 19:57:50 -0700 | [diff] [blame] | 1127 | DRM_DEBUG_KMS("Turn eDP power off\n"); |
Jesse Barnes | 37c6c9b | 2010-08-11 10:04:43 -0700 | [diff] [blame] | 1128 | |
Daniel Vetter | 6cb4983 | 2012-05-20 17:14:50 +0200 | [diff] [blame] | 1129 | WARN(!intel_dp->want_panel_vdd, "Need VDD to turn off panel\n"); |
Jesse Barnes | 9934c13 | 2010-07-22 13:18:19 -0700 | [diff] [blame] | 1130 | |
Jesse Barnes | 453c542 | 2013-03-28 09:55:41 -0700 | [diff] [blame] | 1131 | pp = ironlake_get_pp_control(intel_dp); |
Daniel Vetter | 35a3855 | 2012-08-12 22:17:14 +0200 | [diff] [blame] | 1132 | /* We need to switch off panel power _and_ force vdd, for otherwise some |
| 1133 | * panels get very unhappy and cease to work. */ |
| 1134 | pp &= ~(POWER_TARGET_ON | EDP_FORCE_VDD | PANEL_POWER_RESET | EDP_BLC_ENABLE); |
Jesse Barnes | 453c542 | 2013-03-28 09:55:41 -0700 | [diff] [blame] | 1135 | |
| 1136 | pp_ctrl_reg = IS_VALLEYVIEW(dev) ? PIPEA_PP_CONTROL : PCH_PP_CONTROL; |
| 1137 | |
| 1138 | I915_WRITE(pp_ctrl_reg, pp); |
| 1139 | POSTING_READ(pp_ctrl_reg); |
Jesse Barnes | 9934c13 | 2010-07-22 13:18:19 -0700 | [diff] [blame] | 1140 | |
Daniel Vetter | 35a3855 | 2012-08-12 22:17:14 +0200 | [diff] [blame] | 1141 | intel_dp->want_panel_vdd = false; |
| 1142 | |
Keith Packard | 99ea712 | 2011-11-01 19:57:50 -0700 | [diff] [blame] | 1143 | ironlake_wait_panel_off(intel_dp); |
Jesse Barnes | 9934c13 | 2010-07-22 13:18:19 -0700 | [diff] [blame] | 1144 | } |
| 1145 | |
Paulo Zanoni | d6c50ff | 2012-10-23 18:30:06 -0200 | [diff] [blame] | 1146 | void ironlake_edp_backlight_on(struct intel_dp *intel_dp) |
Zhenyu Wang | 32f9d65 | 2009-07-24 01:00:32 +0800 | [diff] [blame] | 1147 | { |
Paulo Zanoni | da63a9f | 2012-10-26 19:05:46 -0200 | [diff] [blame] | 1148 | struct intel_digital_port *intel_dig_port = dp_to_dig_port(intel_dp); |
| 1149 | struct drm_device *dev = intel_dig_port->base.base.dev; |
Zhenyu Wang | 32f9d65 | 2009-07-24 01:00:32 +0800 | [diff] [blame] | 1150 | struct drm_i915_private *dev_priv = dev->dev_private; |
Paulo Zanoni | da63a9f | 2012-10-26 19:05:46 -0200 | [diff] [blame] | 1151 | int pipe = to_intel_crtc(intel_dig_port->base.base.crtc)->pipe; |
Zhenyu Wang | 32f9d65 | 2009-07-24 01:00:32 +0800 | [diff] [blame] | 1152 | u32 pp; |
Jesse Barnes | 453c542 | 2013-03-28 09:55:41 -0700 | [diff] [blame] | 1153 | u32 pp_ctrl_reg; |
Zhenyu Wang | 32f9d65 | 2009-07-24 01:00:32 +0800 | [diff] [blame] | 1154 | |
Keith Packard | f01eca2 | 2011-09-28 16:48:10 -0700 | [diff] [blame] | 1155 | if (!is_edp(intel_dp)) |
| 1156 | return; |
| 1157 | |
Zhao Yakui | 28c9773 | 2009-10-09 11:39:41 +0800 | [diff] [blame] | 1158 | DRM_DEBUG_KMS("\n"); |
Jesse Barnes | 01cb9ea | 2010-10-07 16:01:12 -0700 | [diff] [blame] | 1159 | /* |
| 1160 | * If we enable the backlight right away following a panel power |
| 1161 | * on, we may see slight flicker as the panel syncs with the eDP |
| 1162 | * link. So delay a bit to make sure the image is solid before |
| 1163 | * allowing it to appear. |
| 1164 | */ |
Keith Packard | f01eca2 | 2011-09-28 16:48:10 -0700 | [diff] [blame] | 1165 | msleep(intel_dp->backlight_on_delay); |
Jesse Barnes | 453c542 | 2013-03-28 09:55:41 -0700 | [diff] [blame] | 1166 | pp = ironlake_get_pp_control(intel_dp); |
Zhenyu Wang | 32f9d65 | 2009-07-24 01:00:32 +0800 | [diff] [blame] | 1167 | pp |= EDP_BLC_ENABLE; |
Jesse Barnes | 453c542 | 2013-03-28 09:55:41 -0700 | [diff] [blame] | 1168 | |
| 1169 | pp_ctrl_reg = IS_VALLEYVIEW(dev) ? PIPEA_PP_CONTROL : PCH_PP_CONTROL; |
| 1170 | |
| 1171 | I915_WRITE(pp_ctrl_reg, pp); |
| 1172 | POSTING_READ(pp_ctrl_reg); |
Daniel Vetter | 035aa3d | 2012-10-20 20:57:42 +0200 | [diff] [blame] | 1173 | |
| 1174 | intel_panel_enable_backlight(dev, pipe); |
Zhenyu Wang | 32f9d65 | 2009-07-24 01:00:32 +0800 | [diff] [blame] | 1175 | } |
| 1176 | |
Paulo Zanoni | d6c50ff | 2012-10-23 18:30:06 -0200 | [diff] [blame] | 1177 | void ironlake_edp_backlight_off(struct intel_dp *intel_dp) |
Zhenyu Wang | 32f9d65 | 2009-07-24 01:00:32 +0800 | [diff] [blame] | 1178 | { |
Paulo Zanoni | 30add22 | 2012-10-26 19:05:45 -0200 | [diff] [blame] | 1179 | struct drm_device *dev = intel_dp_to_dev(intel_dp); |
Zhenyu Wang | 32f9d65 | 2009-07-24 01:00:32 +0800 | [diff] [blame] | 1180 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 1181 | u32 pp; |
Jesse Barnes | 453c542 | 2013-03-28 09:55:41 -0700 | [diff] [blame] | 1182 | u32 pp_ctrl_reg; |
Zhenyu Wang | 32f9d65 | 2009-07-24 01:00:32 +0800 | [diff] [blame] | 1183 | |
Keith Packard | f01eca2 | 2011-09-28 16:48:10 -0700 | [diff] [blame] | 1184 | if (!is_edp(intel_dp)) |
| 1185 | return; |
| 1186 | |
Daniel Vetter | 035aa3d | 2012-10-20 20:57:42 +0200 | [diff] [blame] | 1187 | intel_panel_disable_backlight(dev); |
| 1188 | |
Zhao Yakui | 28c9773 | 2009-10-09 11:39:41 +0800 | [diff] [blame] | 1189 | DRM_DEBUG_KMS("\n"); |
Jesse Barnes | 453c542 | 2013-03-28 09:55:41 -0700 | [diff] [blame] | 1190 | pp = ironlake_get_pp_control(intel_dp); |
Zhenyu Wang | 32f9d65 | 2009-07-24 01:00:32 +0800 | [diff] [blame] | 1191 | pp &= ~EDP_BLC_ENABLE; |
Jesse Barnes | 453c542 | 2013-03-28 09:55:41 -0700 | [diff] [blame] | 1192 | |
| 1193 | pp_ctrl_reg = IS_VALLEYVIEW(dev) ? PIPEA_PP_CONTROL : PCH_PP_CONTROL; |
| 1194 | |
| 1195 | I915_WRITE(pp_ctrl_reg, pp); |
| 1196 | POSTING_READ(pp_ctrl_reg); |
Keith Packard | f01eca2 | 2011-09-28 16:48:10 -0700 | [diff] [blame] | 1197 | msleep(intel_dp->backlight_off_delay); |
Zhenyu Wang | 32f9d65 | 2009-07-24 01:00:32 +0800 | [diff] [blame] | 1198 | } |
Keith Packard | a4fc5ed | 2009-04-07 16:16:42 -0700 | [diff] [blame] | 1199 | |
Daniel Vetter | 2bd2ad6 | 2012-09-06 22:15:41 +0200 | [diff] [blame] | 1200 | static void ironlake_edp_pll_on(struct intel_dp *intel_dp) |
Jesse Barnes | d240f20 | 2010-08-13 15:43:26 -0700 | [diff] [blame] | 1201 | { |
Paulo Zanoni | da63a9f | 2012-10-26 19:05:46 -0200 | [diff] [blame] | 1202 | struct intel_digital_port *intel_dig_port = dp_to_dig_port(intel_dp); |
| 1203 | struct drm_crtc *crtc = intel_dig_port->base.base.crtc; |
| 1204 | struct drm_device *dev = crtc->dev; |
Jesse Barnes | d240f20 | 2010-08-13 15:43:26 -0700 | [diff] [blame] | 1205 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 1206 | u32 dpa_ctl; |
| 1207 | |
Daniel Vetter | 2bd2ad6 | 2012-09-06 22:15:41 +0200 | [diff] [blame] | 1208 | assert_pipe_disabled(dev_priv, |
| 1209 | to_intel_crtc(crtc)->pipe); |
| 1210 | |
Jesse Barnes | d240f20 | 2010-08-13 15:43:26 -0700 | [diff] [blame] | 1211 | DRM_DEBUG_KMS("\n"); |
| 1212 | dpa_ctl = I915_READ(DP_A); |
Daniel Vetter | 0767935 | 2012-09-06 22:15:42 +0200 | [diff] [blame] | 1213 | WARN(dpa_ctl & DP_PLL_ENABLE, "dp pll on, should be off\n"); |
| 1214 | WARN(dpa_ctl & DP_PORT_EN, "dp port still on, should be off\n"); |
| 1215 | |
| 1216 | /* We don't adjust intel_dp->DP while tearing down the link, to |
| 1217 | * facilitate link retraining (e.g. after hotplug). Hence clear all |
| 1218 | * enable bits here to ensure that we don't enable too much. */ |
| 1219 | intel_dp->DP &= ~(DP_PORT_EN | DP_AUDIO_OUTPUT_ENABLE); |
| 1220 | intel_dp->DP |= DP_PLL_ENABLE; |
| 1221 | I915_WRITE(DP_A, intel_dp->DP); |
Jesse Barnes | 298b0b3 | 2010-10-07 16:01:24 -0700 | [diff] [blame] | 1222 | POSTING_READ(DP_A); |
| 1223 | udelay(200); |
Jesse Barnes | d240f20 | 2010-08-13 15:43:26 -0700 | [diff] [blame] | 1224 | } |
| 1225 | |
Daniel Vetter | 2bd2ad6 | 2012-09-06 22:15:41 +0200 | [diff] [blame] | 1226 | static void ironlake_edp_pll_off(struct intel_dp *intel_dp) |
Jesse Barnes | d240f20 | 2010-08-13 15:43:26 -0700 | [diff] [blame] | 1227 | { |
Paulo Zanoni | da63a9f | 2012-10-26 19:05:46 -0200 | [diff] [blame] | 1228 | struct intel_digital_port *intel_dig_port = dp_to_dig_port(intel_dp); |
| 1229 | struct drm_crtc *crtc = intel_dig_port->base.base.crtc; |
| 1230 | struct drm_device *dev = crtc->dev; |
Jesse Barnes | d240f20 | 2010-08-13 15:43:26 -0700 | [diff] [blame] | 1231 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 1232 | u32 dpa_ctl; |
| 1233 | |
Daniel Vetter | 2bd2ad6 | 2012-09-06 22:15:41 +0200 | [diff] [blame] | 1234 | assert_pipe_disabled(dev_priv, |
| 1235 | to_intel_crtc(crtc)->pipe); |
| 1236 | |
Jesse Barnes | d240f20 | 2010-08-13 15:43:26 -0700 | [diff] [blame] | 1237 | dpa_ctl = I915_READ(DP_A); |
Daniel Vetter | 0767935 | 2012-09-06 22:15:42 +0200 | [diff] [blame] | 1238 | WARN((dpa_ctl & DP_PLL_ENABLE) == 0, |
| 1239 | "dp pll off, should be on\n"); |
| 1240 | WARN(dpa_ctl & DP_PORT_EN, "dp port still on, should be off\n"); |
| 1241 | |
| 1242 | /* We can't rely on the value tracked for the DP register in |
| 1243 | * intel_dp->DP because link_down must not change that (otherwise link |
| 1244 | * re-training will fail. */ |
Jesse Barnes | 298b0b3 | 2010-10-07 16:01:24 -0700 | [diff] [blame] | 1245 | dpa_ctl &= ~DP_PLL_ENABLE; |
Jesse Barnes | d240f20 | 2010-08-13 15:43:26 -0700 | [diff] [blame] | 1246 | I915_WRITE(DP_A, dpa_ctl); |
Chris Wilson | 1af5fa1 | 2010-09-08 21:07:28 +0100 | [diff] [blame] | 1247 | POSTING_READ(DP_A); |
Jesse Barnes | d240f20 | 2010-08-13 15:43:26 -0700 | [diff] [blame] | 1248 | udelay(200); |
| 1249 | } |
| 1250 | |
Jesse Barnes | c7ad381 | 2011-07-07 11:11:03 -0700 | [diff] [blame] | 1251 | /* If the sink supports it, try to set the power state appropriately */ |
Paulo Zanoni | c19b066 | 2012-10-15 15:51:41 -0300 | [diff] [blame] | 1252 | void intel_dp_sink_dpms(struct intel_dp *intel_dp, int mode) |
Jesse Barnes | c7ad381 | 2011-07-07 11:11:03 -0700 | [diff] [blame] | 1253 | { |
| 1254 | int ret, i; |
| 1255 | |
| 1256 | /* Should have a valid DPCD by this point */ |
| 1257 | if (intel_dp->dpcd[DP_DPCD_REV] < 0x11) |
| 1258 | return; |
| 1259 | |
| 1260 | if (mode != DRM_MODE_DPMS_ON) { |
| 1261 | ret = intel_dp_aux_native_write_1(intel_dp, DP_SET_POWER, |
| 1262 | DP_SET_POWER_D3); |
| 1263 | if (ret != 1) |
| 1264 | DRM_DEBUG_DRIVER("failed to write sink power state\n"); |
| 1265 | } else { |
| 1266 | /* |
| 1267 | * When turning on, we need to retry for 1ms to give the sink |
| 1268 | * time to wake up. |
| 1269 | */ |
| 1270 | for (i = 0; i < 3; i++) { |
| 1271 | ret = intel_dp_aux_native_write_1(intel_dp, |
| 1272 | DP_SET_POWER, |
| 1273 | DP_SET_POWER_D0); |
| 1274 | if (ret == 1) |
| 1275 | break; |
| 1276 | msleep(1); |
| 1277 | } |
| 1278 | } |
| 1279 | } |
| 1280 | |
Daniel Vetter | 19d8fe1 | 2012-07-02 13:26:27 +0200 | [diff] [blame] | 1281 | static bool intel_dp_get_hw_state(struct intel_encoder *encoder, |
| 1282 | enum pipe *pipe) |
Jesse Barnes | d240f20 | 2010-08-13 15:43:26 -0700 | [diff] [blame] | 1283 | { |
Daniel Vetter | 19d8fe1 | 2012-07-02 13:26:27 +0200 | [diff] [blame] | 1284 | struct intel_dp *intel_dp = enc_to_intel_dp(&encoder->base); |
Imre Deak | bc7d38a | 2013-05-16 14:40:36 +0300 | [diff] [blame] | 1285 | enum port port = dp_to_dig_port(intel_dp)->port; |
Daniel Vetter | 19d8fe1 | 2012-07-02 13:26:27 +0200 | [diff] [blame] | 1286 | struct drm_device *dev = encoder->base.dev; |
| 1287 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 1288 | u32 tmp = I915_READ(intel_dp->output_reg); |
Jesse Barnes | d240f20 | 2010-08-13 15:43:26 -0700 | [diff] [blame] | 1289 | |
Daniel Vetter | 19d8fe1 | 2012-07-02 13:26:27 +0200 | [diff] [blame] | 1290 | if (!(tmp & DP_PORT_EN)) |
| 1291 | return false; |
| 1292 | |
Imre Deak | bc7d38a | 2013-05-16 14:40:36 +0300 | [diff] [blame] | 1293 | if (port == PORT_A && IS_GEN7(dev) && !IS_VALLEYVIEW(dev)) { |
Daniel Vetter | 19d8fe1 | 2012-07-02 13:26:27 +0200 | [diff] [blame] | 1294 | *pipe = PORT_TO_PIPE_CPT(tmp); |
Imre Deak | bc7d38a | 2013-05-16 14:40:36 +0300 | [diff] [blame] | 1295 | } else if (!HAS_PCH_CPT(dev) || port == PORT_A) { |
Daniel Vetter | 19d8fe1 | 2012-07-02 13:26:27 +0200 | [diff] [blame] | 1296 | *pipe = PORT_TO_PIPE(tmp); |
| 1297 | } else { |
| 1298 | u32 trans_sel; |
| 1299 | u32 trans_dp; |
| 1300 | int i; |
| 1301 | |
| 1302 | switch (intel_dp->output_reg) { |
| 1303 | case PCH_DP_B: |
| 1304 | trans_sel = TRANS_DP_PORT_SEL_B; |
| 1305 | break; |
| 1306 | case PCH_DP_C: |
| 1307 | trans_sel = TRANS_DP_PORT_SEL_C; |
| 1308 | break; |
| 1309 | case PCH_DP_D: |
| 1310 | trans_sel = TRANS_DP_PORT_SEL_D; |
| 1311 | break; |
| 1312 | default: |
| 1313 | return true; |
| 1314 | } |
| 1315 | |
| 1316 | for_each_pipe(i) { |
| 1317 | trans_dp = I915_READ(TRANS_DP_CTL(i)); |
| 1318 | if ((trans_dp & TRANS_DP_PORT_SEL_MASK) == trans_sel) { |
| 1319 | *pipe = i; |
| 1320 | return true; |
| 1321 | } |
| 1322 | } |
Daniel Vetter | 19d8fe1 | 2012-07-02 13:26:27 +0200 | [diff] [blame] | 1323 | |
Daniel Vetter | 4a0833e | 2012-10-26 10:58:11 +0200 | [diff] [blame] | 1324 | DRM_DEBUG_KMS("No pipe for dp port 0x%x found\n", |
| 1325 | intel_dp->output_reg); |
| 1326 | } |
Daniel Vetter | 19d8fe1 | 2012-07-02 13:26:27 +0200 | [diff] [blame] | 1327 | |
| 1328 | return true; |
| 1329 | } |
| 1330 | |
Jesse Barnes | 045ac3b | 2013-05-14 17:08:26 -0700 | [diff] [blame] | 1331 | static void intel_dp_get_config(struct intel_encoder *encoder, |
| 1332 | struct intel_crtc_config *pipe_config) |
| 1333 | { |
| 1334 | struct intel_dp *intel_dp = enc_to_intel_dp(&encoder->base); |
Jesse Barnes | 045ac3b | 2013-05-14 17:08:26 -0700 | [diff] [blame] | 1335 | u32 tmp, flags = 0; |
Xiong Zhang | 63000ef | 2013-06-28 12:59:06 +0800 | [diff] [blame] | 1336 | struct drm_device *dev = encoder->base.dev; |
| 1337 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 1338 | enum port port = dp_to_dig_port(intel_dp)->port; |
| 1339 | struct intel_crtc *crtc = to_intel_crtc(encoder->base.crtc); |
Jesse Barnes | 045ac3b | 2013-05-14 17:08:26 -0700 | [diff] [blame] | 1340 | |
Xiong Zhang | 63000ef | 2013-06-28 12:59:06 +0800 | [diff] [blame] | 1341 | if ((port == PORT_A) || !HAS_PCH_CPT(dev)) { |
| 1342 | tmp = I915_READ(intel_dp->output_reg); |
| 1343 | if (tmp & DP_SYNC_HS_HIGH) |
| 1344 | flags |= DRM_MODE_FLAG_PHSYNC; |
| 1345 | else |
| 1346 | flags |= DRM_MODE_FLAG_NHSYNC; |
Jesse Barnes | 045ac3b | 2013-05-14 17:08:26 -0700 | [diff] [blame] | 1347 | |
Xiong Zhang | 63000ef | 2013-06-28 12:59:06 +0800 | [diff] [blame] | 1348 | if (tmp & DP_SYNC_VS_HIGH) |
| 1349 | flags |= DRM_MODE_FLAG_PVSYNC; |
| 1350 | else |
| 1351 | flags |= DRM_MODE_FLAG_NVSYNC; |
| 1352 | } else { |
| 1353 | tmp = I915_READ(TRANS_DP_CTL(crtc->pipe)); |
| 1354 | if (tmp & TRANS_DP_HSYNC_ACTIVE_HIGH) |
| 1355 | flags |= DRM_MODE_FLAG_PHSYNC; |
| 1356 | else |
| 1357 | flags |= DRM_MODE_FLAG_NHSYNC; |
Jesse Barnes | 045ac3b | 2013-05-14 17:08:26 -0700 | [diff] [blame] | 1358 | |
Xiong Zhang | 63000ef | 2013-06-28 12:59:06 +0800 | [diff] [blame] | 1359 | if (tmp & TRANS_DP_VSYNC_ACTIVE_HIGH) |
| 1360 | flags |= DRM_MODE_FLAG_PVSYNC; |
| 1361 | else |
| 1362 | flags |= DRM_MODE_FLAG_NVSYNC; |
| 1363 | } |
Jesse Barnes | 045ac3b | 2013-05-14 17:08:26 -0700 | [diff] [blame] | 1364 | |
| 1365 | pipe_config->adjusted_mode.flags |= flags; |
Jesse Barnes | f1f644d | 2013-06-27 00:39:25 +0300 | [diff] [blame] | 1366 | |
| 1367 | if (dp_to_dig_port(intel_dp)->port == PORT_A) { |
| 1368 | if ((I915_READ(DP_A) & DP_PLL_FREQ_MASK) == DP_PLL_FREQ_160MHZ) |
| 1369 | pipe_config->port_clock = 162000; |
| 1370 | else |
| 1371 | pipe_config->port_clock = 270000; |
| 1372 | } |
Jesse Barnes | 045ac3b | 2013-05-14 17:08:26 -0700 | [diff] [blame] | 1373 | } |
| 1374 | |
Shobhit Kumar | 2293bb5 | 2013-07-11 18:44:56 -0300 | [diff] [blame] | 1375 | static bool is_edp_psr(struct intel_dp *intel_dp) |
| 1376 | { |
| 1377 | return is_edp(intel_dp) && |
| 1378 | intel_dp->psr_dpcd[0] & DP_PSR_IS_SUPPORTED; |
| 1379 | } |
| 1380 | |
Daniel Vetter | e8cb455 | 2012-07-01 13:05:48 +0200 | [diff] [blame] | 1381 | static void intel_disable_dp(struct intel_encoder *encoder) |
Jesse Barnes | d240f20 | 2010-08-13 15:43:26 -0700 | [diff] [blame] | 1382 | { |
Daniel Vetter | e8cb455 | 2012-07-01 13:05:48 +0200 | [diff] [blame] | 1383 | struct intel_dp *intel_dp = enc_to_intel_dp(&encoder->base); |
Imre Deak | 982a386 | 2013-05-23 19:39:40 +0300 | [diff] [blame] | 1384 | enum port port = dp_to_dig_port(intel_dp)->port; |
| 1385 | struct drm_device *dev = encoder->base.dev; |
Daniel Vetter | 6cb4983 | 2012-05-20 17:14:50 +0200 | [diff] [blame] | 1386 | |
| 1387 | /* Make sure the panel is off before trying to change the mode. But also |
| 1388 | * ensure that we have vdd while we switch off the panel. */ |
| 1389 | ironlake_edp_panel_vdd_on(intel_dp); |
Keith Packard | 21264c6 | 2011-11-01 20:25:21 -0700 | [diff] [blame] | 1390 | ironlake_edp_backlight_off(intel_dp); |
Jesse Barnes | c7ad381 | 2011-07-07 11:11:03 -0700 | [diff] [blame] | 1391 | intel_dp_sink_dpms(intel_dp, DRM_MODE_DPMS_ON); |
Daniel Vetter | 35a3855 | 2012-08-12 22:17:14 +0200 | [diff] [blame] | 1392 | ironlake_edp_panel_off(intel_dp); |
Daniel Vetter | 3739850 | 2012-09-06 22:15:44 +0200 | [diff] [blame] | 1393 | |
| 1394 | /* cpu edp my only be disable _after_ the cpu pipe/plane is disabled. */ |
Imre Deak | 982a386 | 2013-05-23 19:39:40 +0300 | [diff] [blame] | 1395 | if (!(port == PORT_A || IS_VALLEYVIEW(dev))) |
Daniel Vetter | 3739850 | 2012-09-06 22:15:44 +0200 | [diff] [blame] | 1396 | intel_dp_link_down(intel_dp); |
Jesse Barnes | d240f20 | 2010-08-13 15:43:26 -0700 | [diff] [blame] | 1397 | } |
| 1398 | |
Daniel Vetter | 2bd2ad6 | 2012-09-06 22:15:41 +0200 | [diff] [blame] | 1399 | static void intel_post_disable_dp(struct intel_encoder *encoder) |
Jesse Barnes | d240f20 | 2010-08-13 15:43:26 -0700 | [diff] [blame] | 1400 | { |
Daniel Vetter | 2bd2ad6 | 2012-09-06 22:15:41 +0200 | [diff] [blame] | 1401 | struct intel_dp *intel_dp = enc_to_intel_dp(&encoder->base); |
Imre Deak | 982a386 | 2013-05-23 19:39:40 +0300 | [diff] [blame] | 1402 | enum port port = dp_to_dig_port(intel_dp)->port; |
Jesse Barnes | b263401 | 2013-03-28 09:55:40 -0700 | [diff] [blame] | 1403 | struct drm_device *dev = encoder->base.dev; |
Daniel Vetter | 2bd2ad6 | 2012-09-06 22:15:41 +0200 | [diff] [blame] | 1404 | |
Imre Deak | 982a386 | 2013-05-23 19:39:40 +0300 | [diff] [blame] | 1405 | if (port == PORT_A || IS_VALLEYVIEW(dev)) { |
Daniel Vetter | 3739850 | 2012-09-06 22:15:44 +0200 | [diff] [blame] | 1406 | intel_dp_link_down(intel_dp); |
Jesse Barnes | b263401 | 2013-03-28 09:55:40 -0700 | [diff] [blame] | 1407 | if (!IS_VALLEYVIEW(dev)) |
| 1408 | ironlake_edp_pll_off(intel_dp); |
Daniel Vetter | 3739850 | 2012-09-06 22:15:44 +0200 | [diff] [blame] | 1409 | } |
Daniel Vetter | 2bd2ad6 | 2012-09-06 22:15:41 +0200 | [diff] [blame] | 1410 | } |
| 1411 | |
Daniel Vetter | e8cb455 | 2012-07-01 13:05:48 +0200 | [diff] [blame] | 1412 | static void intel_enable_dp(struct intel_encoder *encoder) |
Jesse Barnes | d240f20 | 2010-08-13 15:43:26 -0700 | [diff] [blame] | 1413 | { |
Daniel Vetter | e8cb455 | 2012-07-01 13:05:48 +0200 | [diff] [blame] | 1414 | struct intel_dp *intel_dp = enc_to_intel_dp(&encoder->base); |
| 1415 | struct drm_device *dev = encoder->base.dev; |
Keith Packard | a4fc5ed | 2009-04-07 16:16:42 -0700 | [diff] [blame] | 1416 | struct drm_i915_private *dev_priv = dev->dev_private; |
Chris Wilson | ea5b213 | 2010-08-04 13:50:23 +0100 | [diff] [blame] | 1417 | uint32_t dp_reg = I915_READ(intel_dp->output_reg); |
Keith Packard | a4fc5ed | 2009-04-07 16:16:42 -0700 | [diff] [blame] | 1418 | |
Daniel Vetter | 0c33d8d | 2012-09-06 22:15:43 +0200 | [diff] [blame] | 1419 | if (WARN_ON(dp_reg & DP_PORT_EN)) |
| 1420 | return; |
Keith Packard | a4fc5ed | 2009-04-07 16:16:42 -0700 | [diff] [blame] | 1421 | |
| 1422 | ironlake_edp_panel_vdd_on(intel_dp); |
| 1423 | intel_dp_sink_dpms(intel_dp, DRM_MODE_DPMS_ON); |
| 1424 | intel_dp_start_link_train(intel_dp); |
| 1425 | ironlake_edp_panel_on(intel_dp); |
| 1426 | ironlake_edp_panel_vdd_off(intel_dp, true); |
| 1427 | intel_dp_complete_link_train(intel_dp); |
Imre Deak | 3ab9c63 | 2013-05-03 12:57:41 +0300 | [diff] [blame] | 1428 | intel_dp_stop_link_train(intel_dp); |
Keith Packard | a4fc5ed | 2009-04-07 16:16:42 -0700 | [diff] [blame] | 1429 | ironlake_edp_backlight_on(intel_dp); |
Jesse Barnes | 89b667f | 2013-04-18 14:51:36 -0700 | [diff] [blame] | 1430 | |
| 1431 | if (IS_VALLEYVIEW(dev)) { |
| 1432 | struct intel_digital_port *dport = |
| 1433 | enc_to_dig_port(&encoder->base); |
| 1434 | int channel = vlv_dport_to_channel(dport); |
| 1435 | |
| 1436 | vlv_wait_port_ready(dev_priv, channel); |
| 1437 | } |
Keith Packard | a4fc5ed | 2009-04-07 16:16:42 -0700 | [diff] [blame] | 1438 | } |
| 1439 | |
Daniel Vetter | 2bd2ad6 | 2012-09-06 22:15:41 +0200 | [diff] [blame] | 1440 | static void intel_pre_enable_dp(struct intel_encoder *encoder) |
Keith Packard | a4fc5ed | 2009-04-07 16:16:42 -0700 | [diff] [blame] | 1441 | { |
Daniel Vetter | 2bd2ad6 | 2012-09-06 22:15:41 +0200 | [diff] [blame] | 1442 | struct intel_dp *intel_dp = enc_to_intel_dp(&encoder->base); |
Imre Deak | bc7d38a | 2013-05-16 14:40:36 +0300 | [diff] [blame] | 1443 | struct intel_digital_port *dport = dp_to_dig_port(intel_dp); |
Jesse Barnes | b263401 | 2013-03-28 09:55:40 -0700 | [diff] [blame] | 1444 | struct drm_device *dev = encoder->base.dev; |
Jesse Barnes | 89b667f | 2013-04-18 14:51:36 -0700 | [diff] [blame] | 1445 | struct drm_i915_private *dev_priv = dev->dev_private; |
Keith Packard | a4fc5ed | 2009-04-07 16:16:42 -0700 | [diff] [blame] | 1446 | |
Imre Deak | bc7d38a | 2013-05-16 14:40:36 +0300 | [diff] [blame] | 1447 | if (dport->port == PORT_A && !IS_VALLEYVIEW(dev)) |
Daniel Vetter | 2bd2ad6 | 2012-09-06 22:15:41 +0200 | [diff] [blame] | 1448 | ironlake_edp_pll_on(intel_dp); |
Jesse Barnes | 89b667f | 2013-04-18 14:51:36 -0700 | [diff] [blame] | 1449 | |
| 1450 | if (IS_VALLEYVIEW(dev)) { |
Jesse Barnes | 89b667f | 2013-04-18 14:51:36 -0700 | [diff] [blame] | 1451 | struct intel_crtc *intel_crtc = |
| 1452 | to_intel_crtc(encoder->base.crtc); |
| 1453 | int port = vlv_dport_to_channel(dport); |
| 1454 | int pipe = intel_crtc->pipe; |
| 1455 | u32 val; |
| 1456 | |
Jani Nikula | ae99258 | 2013-05-22 15:36:19 +0300 | [diff] [blame] | 1457 | val = vlv_dpio_read(dev_priv, DPIO_DATA_LANE_A(port)); |
Jesse Barnes | 89b667f | 2013-04-18 14:51:36 -0700 | [diff] [blame] | 1458 | val = 0; |
| 1459 | if (pipe) |
| 1460 | val |= (1<<21); |
| 1461 | else |
| 1462 | val &= ~(1<<21); |
| 1463 | val |= 0x001000c4; |
Jani Nikula | ae99258 | 2013-05-22 15:36:19 +0300 | [diff] [blame] | 1464 | vlv_dpio_write(dev_priv, DPIO_DATA_CHANNEL(port), val); |
Jesse Barnes | 89b667f | 2013-04-18 14:51:36 -0700 | [diff] [blame] | 1465 | |
Jani Nikula | ae99258 | 2013-05-22 15:36:19 +0300 | [diff] [blame] | 1466 | vlv_dpio_write(dev_priv, DPIO_PCS_CLOCKBUF0(port), |
Jesse Barnes | 89b667f | 2013-04-18 14:51:36 -0700 | [diff] [blame] | 1467 | 0x00760018); |
Jani Nikula | ae99258 | 2013-05-22 15:36:19 +0300 | [diff] [blame] | 1468 | vlv_dpio_write(dev_priv, DPIO_PCS_CLOCKBUF8(port), |
Jesse Barnes | 89b667f | 2013-04-18 14:51:36 -0700 | [diff] [blame] | 1469 | 0x00400888); |
| 1470 | } |
| 1471 | } |
| 1472 | |
| 1473 | static void intel_dp_pre_pll_enable(struct intel_encoder *encoder) |
| 1474 | { |
| 1475 | struct intel_digital_port *dport = enc_to_dig_port(&encoder->base); |
| 1476 | struct drm_device *dev = encoder->base.dev; |
| 1477 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 1478 | int port = vlv_dport_to_channel(dport); |
| 1479 | |
| 1480 | if (!IS_VALLEYVIEW(dev)) |
| 1481 | return; |
| 1482 | |
Jesse Barnes | 89b667f | 2013-04-18 14:51:36 -0700 | [diff] [blame] | 1483 | /* Program Tx lane resets to default */ |
Jani Nikula | ae99258 | 2013-05-22 15:36:19 +0300 | [diff] [blame] | 1484 | vlv_dpio_write(dev_priv, DPIO_PCS_TX(port), |
Jesse Barnes | 89b667f | 2013-04-18 14:51:36 -0700 | [diff] [blame] | 1485 | DPIO_PCS_TX_LANE2_RESET | |
| 1486 | DPIO_PCS_TX_LANE1_RESET); |
Jani Nikula | ae99258 | 2013-05-22 15:36:19 +0300 | [diff] [blame] | 1487 | vlv_dpio_write(dev_priv, DPIO_PCS_CLK(port), |
Jesse Barnes | 89b667f | 2013-04-18 14:51:36 -0700 | [diff] [blame] | 1488 | DPIO_PCS_CLK_CRI_RXEB_EIOS_EN | |
| 1489 | DPIO_PCS_CLK_CRI_RXDIGFILTSG_EN | |
| 1490 | (1<<DPIO_PCS_CLK_DATAWIDTH_SHIFT) | |
| 1491 | DPIO_PCS_CLK_SOFT_RESET); |
| 1492 | |
| 1493 | /* Fix up inter-pair skew failure */ |
Jani Nikula | ae99258 | 2013-05-22 15:36:19 +0300 | [diff] [blame] | 1494 | vlv_dpio_write(dev_priv, DPIO_PCS_STAGGER1(port), 0x00750f00); |
| 1495 | vlv_dpio_write(dev_priv, DPIO_TX_CTL(port), 0x00001500); |
| 1496 | vlv_dpio_write(dev_priv, DPIO_TX_LANE(port), 0x40400000); |
Keith Packard | a4fc5ed | 2009-04-07 16:16:42 -0700 | [diff] [blame] | 1497 | } |
| 1498 | |
| 1499 | /* |
Jesse Barnes | df0c237 | 2011-07-07 11:11:02 -0700 | [diff] [blame] | 1500 | * Native read with retry for link status and receiver capability reads for |
| 1501 | * cases where the sink may still be asleep. |
| 1502 | */ |
| 1503 | static bool |
| 1504 | intel_dp_aux_native_read_retry(struct intel_dp *intel_dp, uint16_t address, |
| 1505 | uint8_t *recv, int recv_bytes) |
| 1506 | { |
| 1507 | int ret, i; |
| 1508 | |
| 1509 | /* |
| 1510 | * Sinks are *supposed* to come up within 1ms from an off state, |
| 1511 | * but we're also supposed to retry 3 times per the spec. |
| 1512 | */ |
| 1513 | for (i = 0; i < 3; i++) { |
| 1514 | ret = intel_dp_aux_native_read(intel_dp, address, recv, |
| 1515 | recv_bytes); |
| 1516 | if (ret == recv_bytes) |
| 1517 | return true; |
| 1518 | msleep(1); |
| 1519 | } |
| 1520 | |
| 1521 | return false; |
Keith Packard | a4fc5ed | 2009-04-07 16:16:42 -0700 | [diff] [blame] | 1522 | } |
| 1523 | |
| 1524 | /* |
| 1525 | * Fetch AUX CH registers 0x202 - 0x207 which contain |
| 1526 | * link status information |
| 1527 | */ |
| 1528 | static bool |
Keith Packard | 93f62da | 2011-11-01 19:45:03 -0700 | [diff] [blame] | 1529 | intel_dp_get_link_status(struct intel_dp *intel_dp, uint8_t link_status[DP_LINK_STATUS_SIZE]) |
Keith Packard | a4fc5ed | 2009-04-07 16:16:42 -0700 | [diff] [blame] | 1530 | { |
Jesse Barnes | df0c237 | 2011-07-07 11:11:02 -0700 | [diff] [blame] | 1531 | return intel_dp_aux_native_read_retry(intel_dp, |
| 1532 | DP_LANE0_1_STATUS, |
Keith Packard | 93f62da | 2011-11-01 19:45:03 -0700 | [diff] [blame] | 1533 | link_status, |
Jesse Barnes | df0c237 | 2011-07-07 11:11:02 -0700 | [diff] [blame] | 1534 | DP_LINK_STATUS_SIZE); |
Keith Packard | a4fc5ed | 2009-04-07 16:16:42 -0700 | [diff] [blame] | 1535 | } |
| 1536 | |
Keith Packard | a4fc5ed | 2009-04-07 16:16:42 -0700 | [diff] [blame] | 1537 | #if 0 |
| 1538 | static char *voltage_names[] = { |
| 1539 | "0.4V", "0.6V", "0.8V", "1.2V" |
| 1540 | }; |
| 1541 | static char *pre_emph_names[] = { |
| 1542 | "0dB", "3.5dB", "6dB", "9.5dB" |
| 1543 | }; |
| 1544 | static char *link_train_names[] = { |
| 1545 | "pattern 1", "pattern 2", "idle", "off" |
| 1546 | }; |
| 1547 | #endif |
| 1548 | |
| 1549 | /* |
| 1550 | * These are source-specific values; current Intel hardware supports |
| 1551 | * a maximum voltage of 800mV and a maximum pre-emphasis of 6dB |
| 1552 | */ |
Keith Packard | a4fc5ed | 2009-04-07 16:16:42 -0700 | [diff] [blame] | 1553 | |
| 1554 | static uint8_t |
Keith Packard | 1a2eb46 | 2011-11-16 16:26:07 -0800 | [diff] [blame] | 1555 | intel_dp_voltage_max(struct intel_dp *intel_dp) |
Keith Packard | a4fc5ed | 2009-04-07 16:16:42 -0700 | [diff] [blame] | 1556 | { |
Paulo Zanoni | 30add22 | 2012-10-26 19:05:45 -0200 | [diff] [blame] | 1557 | struct drm_device *dev = intel_dp_to_dev(intel_dp); |
Imre Deak | bc7d38a | 2013-05-16 14:40:36 +0300 | [diff] [blame] | 1558 | enum port port = dp_to_dig_port(intel_dp)->port; |
Keith Packard | 1a2eb46 | 2011-11-16 16:26:07 -0800 | [diff] [blame] | 1559 | |
Pallavi G | e2fa6fb | 2013-04-18 14:44:28 -0700 | [diff] [blame] | 1560 | if (IS_VALLEYVIEW(dev)) |
| 1561 | return DP_TRAIN_VOLTAGE_SWING_1200; |
Imre Deak | bc7d38a | 2013-05-16 14:40:36 +0300 | [diff] [blame] | 1562 | else if (IS_GEN7(dev) && port == PORT_A) |
Keith Packard | 1a2eb46 | 2011-11-16 16:26:07 -0800 | [diff] [blame] | 1563 | return DP_TRAIN_VOLTAGE_SWING_800; |
Imre Deak | bc7d38a | 2013-05-16 14:40:36 +0300 | [diff] [blame] | 1564 | else if (HAS_PCH_CPT(dev) && port != PORT_A) |
Keith Packard | 1a2eb46 | 2011-11-16 16:26:07 -0800 | [diff] [blame] | 1565 | return DP_TRAIN_VOLTAGE_SWING_1200; |
| 1566 | else |
| 1567 | return DP_TRAIN_VOLTAGE_SWING_800; |
| 1568 | } |
| 1569 | |
| 1570 | static uint8_t |
| 1571 | intel_dp_pre_emphasis_max(struct intel_dp *intel_dp, uint8_t voltage_swing) |
| 1572 | { |
Paulo Zanoni | 30add22 | 2012-10-26 19:05:45 -0200 | [diff] [blame] | 1573 | struct drm_device *dev = intel_dp_to_dev(intel_dp); |
Imre Deak | bc7d38a | 2013-05-16 14:40:36 +0300 | [diff] [blame] | 1574 | enum port port = dp_to_dig_port(intel_dp)->port; |
Keith Packard | 1a2eb46 | 2011-11-16 16:26:07 -0800 | [diff] [blame] | 1575 | |
Paulo Zanoni | 22b8bf1 | 2013-02-18 19:00:23 -0300 | [diff] [blame] | 1576 | if (HAS_DDI(dev)) { |
Paulo Zanoni | d6c0d72 | 2012-10-15 15:51:34 -0300 | [diff] [blame] | 1577 | switch (voltage_swing & DP_TRAIN_VOLTAGE_SWING_MASK) { |
| 1578 | case DP_TRAIN_VOLTAGE_SWING_400: |
| 1579 | return DP_TRAIN_PRE_EMPHASIS_9_5; |
| 1580 | case DP_TRAIN_VOLTAGE_SWING_600: |
| 1581 | return DP_TRAIN_PRE_EMPHASIS_6; |
| 1582 | case DP_TRAIN_VOLTAGE_SWING_800: |
| 1583 | return DP_TRAIN_PRE_EMPHASIS_3_5; |
| 1584 | case DP_TRAIN_VOLTAGE_SWING_1200: |
| 1585 | default: |
| 1586 | return DP_TRAIN_PRE_EMPHASIS_0; |
| 1587 | } |
Pallavi G | e2fa6fb | 2013-04-18 14:44:28 -0700 | [diff] [blame] | 1588 | } else if (IS_VALLEYVIEW(dev)) { |
| 1589 | switch (voltage_swing & DP_TRAIN_VOLTAGE_SWING_MASK) { |
| 1590 | case DP_TRAIN_VOLTAGE_SWING_400: |
| 1591 | return DP_TRAIN_PRE_EMPHASIS_9_5; |
| 1592 | case DP_TRAIN_VOLTAGE_SWING_600: |
| 1593 | return DP_TRAIN_PRE_EMPHASIS_6; |
| 1594 | case DP_TRAIN_VOLTAGE_SWING_800: |
| 1595 | return DP_TRAIN_PRE_EMPHASIS_3_5; |
| 1596 | case DP_TRAIN_VOLTAGE_SWING_1200: |
| 1597 | default: |
| 1598 | return DP_TRAIN_PRE_EMPHASIS_0; |
| 1599 | } |
Imre Deak | bc7d38a | 2013-05-16 14:40:36 +0300 | [diff] [blame] | 1600 | } else if (IS_GEN7(dev) && port == PORT_A) { |
Keith Packard | 1a2eb46 | 2011-11-16 16:26:07 -0800 | [diff] [blame] | 1601 | switch (voltage_swing & DP_TRAIN_VOLTAGE_SWING_MASK) { |
| 1602 | case DP_TRAIN_VOLTAGE_SWING_400: |
| 1603 | return DP_TRAIN_PRE_EMPHASIS_6; |
| 1604 | case DP_TRAIN_VOLTAGE_SWING_600: |
| 1605 | case DP_TRAIN_VOLTAGE_SWING_800: |
| 1606 | return DP_TRAIN_PRE_EMPHASIS_3_5; |
| 1607 | default: |
| 1608 | return DP_TRAIN_PRE_EMPHASIS_0; |
| 1609 | } |
| 1610 | } else { |
| 1611 | switch (voltage_swing & DP_TRAIN_VOLTAGE_SWING_MASK) { |
| 1612 | case DP_TRAIN_VOLTAGE_SWING_400: |
| 1613 | return DP_TRAIN_PRE_EMPHASIS_6; |
| 1614 | case DP_TRAIN_VOLTAGE_SWING_600: |
| 1615 | return DP_TRAIN_PRE_EMPHASIS_6; |
| 1616 | case DP_TRAIN_VOLTAGE_SWING_800: |
| 1617 | return DP_TRAIN_PRE_EMPHASIS_3_5; |
| 1618 | case DP_TRAIN_VOLTAGE_SWING_1200: |
| 1619 | default: |
| 1620 | return DP_TRAIN_PRE_EMPHASIS_0; |
| 1621 | } |
Keith Packard | a4fc5ed | 2009-04-07 16:16:42 -0700 | [diff] [blame] | 1622 | } |
| 1623 | } |
| 1624 | |
Pallavi G | e2fa6fb | 2013-04-18 14:44:28 -0700 | [diff] [blame] | 1625 | static uint32_t intel_vlv_signal_levels(struct intel_dp *intel_dp) |
| 1626 | { |
| 1627 | struct drm_device *dev = intel_dp_to_dev(intel_dp); |
| 1628 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 1629 | struct intel_digital_port *dport = dp_to_dig_port(intel_dp); |
| 1630 | unsigned long demph_reg_value, preemph_reg_value, |
| 1631 | uniqtranscale_reg_value; |
| 1632 | uint8_t train_set = intel_dp->train_set[0]; |
Jesse Barnes | cece5d5 | 2013-04-19 08:46:35 -0700 | [diff] [blame] | 1633 | int port = vlv_dport_to_channel(dport); |
Pallavi G | e2fa6fb | 2013-04-18 14:44:28 -0700 | [diff] [blame] | 1634 | |
| 1635 | switch (train_set & DP_TRAIN_PRE_EMPHASIS_MASK) { |
| 1636 | case DP_TRAIN_PRE_EMPHASIS_0: |
| 1637 | preemph_reg_value = 0x0004000; |
| 1638 | switch (train_set & DP_TRAIN_VOLTAGE_SWING_MASK) { |
| 1639 | case DP_TRAIN_VOLTAGE_SWING_400: |
| 1640 | demph_reg_value = 0x2B405555; |
| 1641 | uniqtranscale_reg_value = 0x552AB83A; |
| 1642 | break; |
| 1643 | case DP_TRAIN_VOLTAGE_SWING_600: |
| 1644 | demph_reg_value = 0x2B404040; |
| 1645 | uniqtranscale_reg_value = 0x5548B83A; |
| 1646 | break; |
| 1647 | case DP_TRAIN_VOLTAGE_SWING_800: |
| 1648 | demph_reg_value = 0x2B245555; |
| 1649 | uniqtranscale_reg_value = 0x5560B83A; |
| 1650 | break; |
| 1651 | case DP_TRAIN_VOLTAGE_SWING_1200: |
| 1652 | demph_reg_value = 0x2B405555; |
| 1653 | uniqtranscale_reg_value = 0x5598DA3A; |
| 1654 | break; |
| 1655 | default: |
| 1656 | return 0; |
| 1657 | } |
| 1658 | break; |
| 1659 | case DP_TRAIN_PRE_EMPHASIS_3_5: |
| 1660 | preemph_reg_value = 0x0002000; |
| 1661 | switch (train_set & DP_TRAIN_VOLTAGE_SWING_MASK) { |
| 1662 | case DP_TRAIN_VOLTAGE_SWING_400: |
| 1663 | demph_reg_value = 0x2B404040; |
| 1664 | uniqtranscale_reg_value = 0x5552B83A; |
| 1665 | break; |
| 1666 | case DP_TRAIN_VOLTAGE_SWING_600: |
| 1667 | demph_reg_value = 0x2B404848; |
| 1668 | uniqtranscale_reg_value = 0x5580B83A; |
| 1669 | break; |
| 1670 | case DP_TRAIN_VOLTAGE_SWING_800: |
| 1671 | demph_reg_value = 0x2B404040; |
| 1672 | uniqtranscale_reg_value = 0x55ADDA3A; |
| 1673 | break; |
| 1674 | default: |
| 1675 | return 0; |
| 1676 | } |
| 1677 | break; |
| 1678 | case DP_TRAIN_PRE_EMPHASIS_6: |
| 1679 | preemph_reg_value = 0x0000000; |
| 1680 | switch (train_set & DP_TRAIN_VOLTAGE_SWING_MASK) { |
| 1681 | case DP_TRAIN_VOLTAGE_SWING_400: |
| 1682 | demph_reg_value = 0x2B305555; |
| 1683 | uniqtranscale_reg_value = 0x5570B83A; |
| 1684 | break; |
| 1685 | case DP_TRAIN_VOLTAGE_SWING_600: |
| 1686 | demph_reg_value = 0x2B2B4040; |
| 1687 | uniqtranscale_reg_value = 0x55ADDA3A; |
| 1688 | break; |
| 1689 | default: |
| 1690 | return 0; |
| 1691 | } |
| 1692 | break; |
| 1693 | case DP_TRAIN_PRE_EMPHASIS_9_5: |
| 1694 | preemph_reg_value = 0x0006000; |
| 1695 | switch (train_set & DP_TRAIN_VOLTAGE_SWING_MASK) { |
| 1696 | case DP_TRAIN_VOLTAGE_SWING_400: |
| 1697 | demph_reg_value = 0x1B405555; |
| 1698 | uniqtranscale_reg_value = 0x55ADDA3A; |
| 1699 | break; |
| 1700 | default: |
| 1701 | return 0; |
| 1702 | } |
| 1703 | break; |
| 1704 | default: |
| 1705 | return 0; |
| 1706 | } |
| 1707 | |
Jani Nikula | ae99258 | 2013-05-22 15:36:19 +0300 | [diff] [blame] | 1708 | vlv_dpio_write(dev_priv, DPIO_TX_OCALINIT(port), 0x00000000); |
| 1709 | vlv_dpio_write(dev_priv, DPIO_TX_SWING_CTL4(port), demph_reg_value); |
| 1710 | vlv_dpio_write(dev_priv, DPIO_TX_SWING_CTL2(port), |
Pallavi G | e2fa6fb | 2013-04-18 14:44:28 -0700 | [diff] [blame] | 1711 | uniqtranscale_reg_value); |
Jani Nikula | ae99258 | 2013-05-22 15:36:19 +0300 | [diff] [blame] | 1712 | vlv_dpio_write(dev_priv, DPIO_TX_SWING_CTL3(port), 0x0C782040); |
| 1713 | vlv_dpio_write(dev_priv, DPIO_PCS_STAGGER0(port), 0x00030000); |
| 1714 | vlv_dpio_write(dev_priv, DPIO_PCS_CTL_OVER1(port), preemph_reg_value); |
| 1715 | vlv_dpio_write(dev_priv, DPIO_TX_OCALINIT(port), 0x80000000); |
Pallavi G | e2fa6fb | 2013-04-18 14:44:28 -0700 | [diff] [blame] | 1716 | |
| 1717 | return 0; |
| 1718 | } |
| 1719 | |
Keith Packard | a4fc5ed | 2009-04-07 16:16:42 -0700 | [diff] [blame] | 1720 | static void |
Keith Packard | 93f62da | 2011-11-01 19:45:03 -0700 | [diff] [blame] | 1721 | intel_get_adjust_train(struct intel_dp *intel_dp, uint8_t link_status[DP_LINK_STATUS_SIZE]) |
Keith Packard | a4fc5ed | 2009-04-07 16:16:42 -0700 | [diff] [blame] | 1722 | { |
| 1723 | uint8_t v = 0; |
| 1724 | uint8_t p = 0; |
| 1725 | int lane; |
Keith Packard | 1a2eb46 | 2011-11-16 16:26:07 -0800 | [diff] [blame] | 1726 | uint8_t voltage_max; |
| 1727 | uint8_t preemph_max; |
Keith Packard | a4fc5ed | 2009-04-07 16:16:42 -0700 | [diff] [blame] | 1728 | |
Jesse Barnes | 33a34e4 | 2010-09-08 12:42:02 -0700 | [diff] [blame] | 1729 | for (lane = 0; lane < intel_dp->lane_count; lane++) { |
Daniel Vetter | 0f037bd | 2012-10-18 10:15:27 +0200 | [diff] [blame] | 1730 | uint8_t this_v = drm_dp_get_adjust_request_voltage(link_status, lane); |
| 1731 | uint8_t this_p = drm_dp_get_adjust_request_pre_emphasis(link_status, lane); |
Keith Packard | a4fc5ed | 2009-04-07 16:16:42 -0700 | [diff] [blame] | 1732 | |
| 1733 | if (this_v > v) |
| 1734 | v = this_v; |
| 1735 | if (this_p > p) |
| 1736 | p = this_p; |
| 1737 | } |
| 1738 | |
Keith Packard | 1a2eb46 | 2011-11-16 16:26:07 -0800 | [diff] [blame] | 1739 | voltage_max = intel_dp_voltage_max(intel_dp); |
Keith Packard | 417e822 | 2011-11-01 19:54:11 -0700 | [diff] [blame] | 1740 | if (v >= voltage_max) |
| 1741 | v = voltage_max | DP_TRAIN_MAX_SWING_REACHED; |
Keith Packard | a4fc5ed | 2009-04-07 16:16:42 -0700 | [diff] [blame] | 1742 | |
Keith Packard | 1a2eb46 | 2011-11-16 16:26:07 -0800 | [diff] [blame] | 1743 | preemph_max = intel_dp_pre_emphasis_max(intel_dp, v); |
| 1744 | if (p >= preemph_max) |
| 1745 | p = preemph_max | DP_TRAIN_MAX_PRE_EMPHASIS_REACHED; |
Keith Packard | a4fc5ed | 2009-04-07 16:16:42 -0700 | [diff] [blame] | 1746 | |
| 1747 | for (lane = 0; lane < 4; lane++) |
Jesse Barnes | 33a34e4 | 2010-09-08 12:42:02 -0700 | [diff] [blame] | 1748 | intel_dp->train_set[lane] = v | p; |
Keith Packard | a4fc5ed | 2009-04-07 16:16:42 -0700 | [diff] [blame] | 1749 | } |
| 1750 | |
| 1751 | static uint32_t |
Paulo Zanoni | f0a3424 | 2012-12-06 16:51:50 -0200 | [diff] [blame] | 1752 | intel_gen4_signal_levels(uint8_t train_set) |
Keith Packard | a4fc5ed | 2009-04-07 16:16:42 -0700 | [diff] [blame] | 1753 | { |
Chris Wilson | 3cf2efb | 2010-11-29 10:09:55 +0000 | [diff] [blame] | 1754 | uint32_t signal_levels = 0; |
Keith Packard | a4fc5ed | 2009-04-07 16:16:42 -0700 | [diff] [blame] | 1755 | |
Chris Wilson | 3cf2efb | 2010-11-29 10:09:55 +0000 | [diff] [blame] | 1756 | switch (train_set & DP_TRAIN_VOLTAGE_SWING_MASK) { |
Keith Packard | a4fc5ed | 2009-04-07 16:16:42 -0700 | [diff] [blame] | 1757 | case DP_TRAIN_VOLTAGE_SWING_400: |
| 1758 | default: |
| 1759 | signal_levels |= DP_VOLTAGE_0_4; |
| 1760 | break; |
| 1761 | case DP_TRAIN_VOLTAGE_SWING_600: |
| 1762 | signal_levels |= DP_VOLTAGE_0_6; |
| 1763 | break; |
| 1764 | case DP_TRAIN_VOLTAGE_SWING_800: |
| 1765 | signal_levels |= DP_VOLTAGE_0_8; |
| 1766 | break; |
| 1767 | case DP_TRAIN_VOLTAGE_SWING_1200: |
| 1768 | signal_levels |= DP_VOLTAGE_1_2; |
| 1769 | break; |
| 1770 | } |
Chris Wilson | 3cf2efb | 2010-11-29 10:09:55 +0000 | [diff] [blame] | 1771 | switch (train_set & DP_TRAIN_PRE_EMPHASIS_MASK) { |
Keith Packard | a4fc5ed | 2009-04-07 16:16:42 -0700 | [diff] [blame] | 1772 | case DP_TRAIN_PRE_EMPHASIS_0: |
| 1773 | default: |
| 1774 | signal_levels |= DP_PRE_EMPHASIS_0; |
| 1775 | break; |
| 1776 | case DP_TRAIN_PRE_EMPHASIS_3_5: |
| 1777 | signal_levels |= DP_PRE_EMPHASIS_3_5; |
| 1778 | break; |
| 1779 | case DP_TRAIN_PRE_EMPHASIS_6: |
| 1780 | signal_levels |= DP_PRE_EMPHASIS_6; |
| 1781 | break; |
| 1782 | case DP_TRAIN_PRE_EMPHASIS_9_5: |
| 1783 | signal_levels |= DP_PRE_EMPHASIS_9_5; |
| 1784 | break; |
| 1785 | } |
| 1786 | return signal_levels; |
| 1787 | } |
| 1788 | |
Zhenyu Wang | e3421a1 | 2010-04-08 09:43:27 +0800 | [diff] [blame] | 1789 | /* Gen6's DP voltage swing and pre-emphasis control */ |
| 1790 | static uint32_t |
| 1791 | intel_gen6_edp_signal_levels(uint8_t train_set) |
| 1792 | { |
Yuanhan Liu | 3c5a62b | 2011-01-06 18:26:08 +0800 | [diff] [blame] | 1793 | int signal_levels = train_set & (DP_TRAIN_VOLTAGE_SWING_MASK | |
| 1794 | DP_TRAIN_PRE_EMPHASIS_MASK); |
| 1795 | switch (signal_levels) { |
Zhenyu Wang | e3421a1 | 2010-04-08 09:43:27 +0800 | [diff] [blame] | 1796 | case DP_TRAIN_VOLTAGE_SWING_400 | DP_TRAIN_PRE_EMPHASIS_0: |
Yuanhan Liu | 3c5a62b | 2011-01-06 18:26:08 +0800 | [diff] [blame] | 1797 | case DP_TRAIN_VOLTAGE_SWING_600 | DP_TRAIN_PRE_EMPHASIS_0: |
| 1798 | return EDP_LINK_TRAIN_400_600MV_0DB_SNB_B; |
| 1799 | case DP_TRAIN_VOLTAGE_SWING_400 | DP_TRAIN_PRE_EMPHASIS_3_5: |
| 1800 | return EDP_LINK_TRAIN_400MV_3_5DB_SNB_B; |
Zhenyu Wang | e3421a1 | 2010-04-08 09:43:27 +0800 | [diff] [blame] | 1801 | case DP_TRAIN_VOLTAGE_SWING_400 | DP_TRAIN_PRE_EMPHASIS_6: |
Yuanhan Liu | 3c5a62b | 2011-01-06 18:26:08 +0800 | [diff] [blame] | 1802 | case DP_TRAIN_VOLTAGE_SWING_600 | DP_TRAIN_PRE_EMPHASIS_6: |
| 1803 | return EDP_LINK_TRAIN_400_600MV_6DB_SNB_B; |
Zhenyu Wang | e3421a1 | 2010-04-08 09:43:27 +0800 | [diff] [blame] | 1804 | case DP_TRAIN_VOLTAGE_SWING_600 | DP_TRAIN_PRE_EMPHASIS_3_5: |
Yuanhan Liu | 3c5a62b | 2011-01-06 18:26:08 +0800 | [diff] [blame] | 1805 | case DP_TRAIN_VOLTAGE_SWING_800 | DP_TRAIN_PRE_EMPHASIS_3_5: |
| 1806 | return EDP_LINK_TRAIN_600_800MV_3_5DB_SNB_B; |
Zhenyu Wang | e3421a1 | 2010-04-08 09:43:27 +0800 | [diff] [blame] | 1807 | case DP_TRAIN_VOLTAGE_SWING_800 | DP_TRAIN_PRE_EMPHASIS_0: |
Yuanhan Liu | 3c5a62b | 2011-01-06 18:26:08 +0800 | [diff] [blame] | 1808 | case DP_TRAIN_VOLTAGE_SWING_1200 | DP_TRAIN_PRE_EMPHASIS_0: |
| 1809 | return EDP_LINK_TRAIN_800_1200MV_0DB_SNB_B; |
Zhenyu Wang | e3421a1 | 2010-04-08 09:43:27 +0800 | [diff] [blame] | 1810 | default: |
Yuanhan Liu | 3c5a62b | 2011-01-06 18:26:08 +0800 | [diff] [blame] | 1811 | DRM_DEBUG_KMS("Unsupported voltage swing/pre-emphasis level:" |
| 1812 | "0x%x\n", signal_levels); |
| 1813 | return EDP_LINK_TRAIN_400_600MV_0DB_SNB_B; |
Zhenyu Wang | e3421a1 | 2010-04-08 09:43:27 +0800 | [diff] [blame] | 1814 | } |
| 1815 | } |
| 1816 | |
Keith Packard | 1a2eb46 | 2011-11-16 16:26:07 -0800 | [diff] [blame] | 1817 | /* Gen7's DP voltage swing and pre-emphasis control */ |
| 1818 | static uint32_t |
| 1819 | intel_gen7_edp_signal_levels(uint8_t train_set) |
| 1820 | { |
| 1821 | int signal_levels = train_set & (DP_TRAIN_VOLTAGE_SWING_MASK | |
| 1822 | DP_TRAIN_PRE_EMPHASIS_MASK); |
| 1823 | switch (signal_levels) { |
| 1824 | case DP_TRAIN_VOLTAGE_SWING_400 | DP_TRAIN_PRE_EMPHASIS_0: |
| 1825 | return EDP_LINK_TRAIN_400MV_0DB_IVB; |
| 1826 | case DP_TRAIN_VOLTAGE_SWING_400 | DP_TRAIN_PRE_EMPHASIS_3_5: |
| 1827 | return EDP_LINK_TRAIN_400MV_3_5DB_IVB; |
| 1828 | case DP_TRAIN_VOLTAGE_SWING_400 | DP_TRAIN_PRE_EMPHASIS_6: |
| 1829 | return EDP_LINK_TRAIN_400MV_6DB_IVB; |
| 1830 | |
| 1831 | case DP_TRAIN_VOLTAGE_SWING_600 | DP_TRAIN_PRE_EMPHASIS_0: |
| 1832 | return EDP_LINK_TRAIN_600MV_0DB_IVB; |
| 1833 | case DP_TRAIN_VOLTAGE_SWING_600 | DP_TRAIN_PRE_EMPHASIS_3_5: |
| 1834 | return EDP_LINK_TRAIN_600MV_3_5DB_IVB; |
| 1835 | |
| 1836 | case DP_TRAIN_VOLTAGE_SWING_800 | DP_TRAIN_PRE_EMPHASIS_0: |
| 1837 | return EDP_LINK_TRAIN_800MV_0DB_IVB; |
| 1838 | case DP_TRAIN_VOLTAGE_SWING_800 | DP_TRAIN_PRE_EMPHASIS_3_5: |
| 1839 | return EDP_LINK_TRAIN_800MV_3_5DB_IVB; |
| 1840 | |
| 1841 | default: |
| 1842 | DRM_DEBUG_KMS("Unsupported voltage swing/pre-emphasis level:" |
| 1843 | "0x%x\n", signal_levels); |
| 1844 | return EDP_LINK_TRAIN_500MV_0DB_IVB; |
| 1845 | } |
| 1846 | } |
| 1847 | |
Paulo Zanoni | d6c0d72 | 2012-10-15 15:51:34 -0300 | [diff] [blame] | 1848 | /* Gen7.5's (HSW) DP voltage swing and pre-emphasis control */ |
| 1849 | static uint32_t |
Paulo Zanoni | f0a3424 | 2012-12-06 16:51:50 -0200 | [diff] [blame] | 1850 | intel_hsw_signal_levels(uint8_t train_set) |
Keith Packard | a4fc5ed | 2009-04-07 16:16:42 -0700 | [diff] [blame] | 1851 | { |
Paulo Zanoni | d6c0d72 | 2012-10-15 15:51:34 -0300 | [diff] [blame] | 1852 | int signal_levels = train_set & (DP_TRAIN_VOLTAGE_SWING_MASK | |
| 1853 | DP_TRAIN_PRE_EMPHASIS_MASK); |
| 1854 | switch (signal_levels) { |
| 1855 | case DP_TRAIN_VOLTAGE_SWING_400 | DP_TRAIN_PRE_EMPHASIS_0: |
| 1856 | return DDI_BUF_EMP_400MV_0DB_HSW; |
| 1857 | case DP_TRAIN_VOLTAGE_SWING_400 | DP_TRAIN_PRE_EMPHASIS_3_5: |
| 1858 | return DDI_BUF_EMP_400MV_3_5DB_HSW; |
| 1859 | case DP_TRAIN_VOLTAGE_SWING_400 | DP_TRAIN_PRE_EMPHASIS_6: |
| 1860 | return DDI_BUF_EMP_400MV_6DB_HSW; |
| 1861 | case DP_TRAIN_VOLTAGE_SWING_400 | DP_TRAIN_PRE_EMPHASIS_9_5: |
| 1862 | return DDI_BUF_EMP_400MV_9_5DB_HSW; |
Keith Packard | a4fc5ed | 2009-04-07 16:16:42 -0700 | [diff] [blame] | 1863 | |
Paulo Zanoni | d6c0d72 | 2012-10-15 15:51:34 -0300 | [diff] [blame] | 1864 | case DP_TRAIN_VOLTAGE_SWING_600 | DP_TRAIN_PRE_EMPHASIS_0: |
| 1865 | return DDI_BUF_EMP_600MV_0DB_HSW; |
| 1866 | case DP_TRAIN_VOLTAGE_SWING_600 | DP_TRAIN_PRE_EMPHASIS_3_5: |
| 1867 | return DDI_BUF_EMP_600MV_3_5DB_HSW; |
| 1868 | case DP_TRAIN_VOLTAGE_SWING_600 | DP_TRAIN_PRE_EMPHASIS_6: |
| 1869 | return DDI_BUF_EMP_600MV_6DB_HSW; |
Keith Packard | a4fc5ed | 2009-04-07 16:16:42 -0700 | [diff] [blame] | 1870 | |
Paulo Zanoni | d6c0d72 | 2012-10-15 15:51:34 -0300 | [diff] [blame] | 1871 | case DP_TRAIN_VOLTAGE_SWING_800 | DP_TRAIN_PRE_EMPHASIS_0: |
| 1872 | return DDI_BUF_EMP_800MV_0DB_HSW; |
| 1873 | case DP_TRAIN_VOLTAGE_SWING_800 | DP_TRAIN_PRE_EMPHASIS_3_5: |
| 1874 | return DDI_BUF_EMP_800MV_3_5DB_HSW; |
| 1875 | default: |
| 1876 | DRM_DEBUG_KMS("Unsupported voltage swing/pre-emphasis level:" |
| 1877 | "0x%x\n", signal_levels); |
| 1878 | return DDI_BUF_EMP_400MV_0DB_HSW; |
Keith Packard | a4fc5ed | 2009-04-07 16:16:42 -0700 | [diff] [blame] | 1879 | } |
Keith Packard | a4fc5ed | 2009-04-07 16:16:42 -0700 | [diff] [blame] | 1880 | } |
| 1881 | |
Paulo Zanoni | f0a3424 | 2012-12-06 16:51:50 -0200 | [diff] [blame] | 1882 | /* Properly updates "DP" with the correct signal levels. */ |
| 1883 | static void |
| 1884 | intel_dp_set_signal_levels(struct intel_dp *intel_dp, uint32_t *DP) |
| 1885 | { |
| 1886 | struct intel_digital_port *intel_dig_port = dp_to_dig_port(intel_dp); |
Imre Deak | bc7d38a | 2013-05-16 14:40:36 +0300 | [diff] [blame] | 1887 | enum port port = intel_dig_port->port; |
Paulo Zanoni | f0a3424 | 2012-12-06 16:51:50 -0200 | [diff] [blame] | 1888 | struct drm_device *dev = intel_dig_port->base.base.dev; |
| 1889 | uint32_t signal_levels, mask; |
| 1890 | uint8_t train_set = intel_dp->train_set[0]; |
| 1891 | |
Paulo Zanoni | 22b8bf1 | 2013-02-18 19:00:23 -0300 | [diff] [blame] | 1892 | if (HAS_DDI(dev)) { |
Paulo Zanoni | f0a3424 | 2012-12-06 16:51:50 -0200 | [diff] [blame] | 1893 | signal_levels = intel_hsw_signal_levels(train_set); |
| 1894 | mask = DDI_BUF_EMP_MASK; |
Pallavi G | e2fa6fb | 2013-04-18 14:44:28 -0700 | [diff] [blame] | 1895 | } else if (IS_VALLEYVIEW(dev)) { |
| 1896 | signal_levels = intel_vlv_signal_levels(intel_dp); |
| 1897 | mask = 0; |
Imre Deak | bc7d38a | 2013-05-16 14:40:36 +0300 | [diff] [blame] | 1898 | } else if (IS_GEN7(dev) && port == PORT_A) { |
Paulo Zanoni | f0a3424 | 2012-12-06 16:51:50 -0200 | [diff] [blame] | 1899 | signal_levels = intel_gen7_edp_signal_levels(train_set); |
| 1900 | mask = EDP_LINK_TRAIN_VOL_EMP_MASK_IVB; |
Imre Deak | bc7d38a | 2013-05-16 14:40:36 +0300 | [diff] [blame] | 1901 | } else if (IS_GEN6(dev) && port == PORT_A) { |
Paulo Zanoni | f0a3424 | 2012-12-06 16:51:50 -0200 | [diff] [blame] | 1902 | signal_levels = intel_gen6_edp_signal_levels(train_set); |
| 1903 | mask = EDP_LINK_TRAIN_VOL_EMP_MASK_SNB; |
| 1904 | } else { |
| 1905 | signal_levels = intel_gen4_signal_levels(train_set); |
| 1906 | mask = DP_VOLTAGE_MASK | DP_PRE_EMPHASIS_MASK; |
| 1907 | } |
| 1908 | |
| 1909 | DRM_DEBUG_KMS("Using signal levels %08x\n", signal_levels); |
| 1910 | |
| 1911 | *DP = (*DP & ~mask) | signal_levels; |
| 1912 | } |
| 1913 | |
Keith Packard | a4fc5ed | 2009-04-07 16:16:42 -0700 | [diff] [blame] | 1914 | static bool |
Chris Wilson | ea5b213 | 2010-08-04 13:50:23 +0100 | [diff] [blame] | 1915 | intel_dp_set_link_train(struct intel_dp *intel_dp, |
Keith Packard | a4fc5ed | 2009-04-07 16:16:42 -0700 | [diff] [blame] | 1916 | uint32_t dp_reg_value, |
Chris Wilson | 58e10eb | 2010-10-03 10:56:11 +0100 | [diff] [blame] | 1917 | uint8_t dp_train_pat) |
Keith Packard | a4fc5ed | 2009-04-07 16:16:42 -0700 | [diff] [blame] | 1918 | { |
Paulo Zanoni | 174edf1 | 2012-10-26 19:05:50 -0200 | [diff] [blame] | 1919 | struct intel_digital_port *intel_dig_port = dp_to_dig_port(intel_dp); |
| 1920 | struct drm_device *dev = intel_dig_port->base.base.dev; |
Keith Packard | a4fc5ed | 2009-04-07 16:16:42 -0700 | [diff] [blame] | 1921 | struct drm_i915_private *dev_priv = dev->dev_private; |
Paulo Zanoni | 174edf1 | 2012-10-26 19:05:50 -0200 | [diff] [blame] | 1922 | enum port port = intel_dig_port->port; |
Keith Packard | a4fc5ed | 2009-04-07 16:16:42 -0700 | [diff] [blame] | 1923 | int ret; |
| 1924 | |
Paulo Zanoni | 22b8bf1 | 2013-02-18 19:00:23 -0300 | [diff] [blame] | 1925 | if (HAS_DDI(dev)) { |
Imre Deak | 3ab9c63 | 2013-05-03 12:57:41 +0300 | [diff] [blame] | 1926 | uint32_t temp = I915_READ(DP_TP_CTL(port)); |
Paulo Zanoni | d6c0d72 | 2012-10-15 15:51:34 -0300 | [diff] [blame] | 1927 | |
| 1928 | if (dp_train_pat & DP_LINK_SCRAMBLING_DISABLE) |
| 1929 | temp |= DP_TP_CTL_SCRAMBLE_DISABLE; |
| 1930 | else |
| 1931 | temp &= ~DP_TP_CTL_SCRAMBLE_DISABLE; |
| 1932 | |
| 1933 | temp &= ~DP_TP_CTL_LINK_TRAIN_MASK; |
| 1934 | switch (dp_train_pat & DP_TRAINING_PATTERN_MASK) { |
| 1935 | case DP_TRAINING_PATTERN_DISABLE: |
Paulo Zanoni | d6c0d72 | 2012-10-15 15:51:34 -0300 | [diff] [blame] | 1936 | temp |= DP_TP_CTL_LINK_TRAIN_NORMAL; |
| 1937 | |
| 1938 | break; |
| 1939 | case DP_TRAINING_PATTERN_1: |
| 1940 | temp |= DP_TP_CTL_LINK_TRAIN_PAT1; |
| 1941 | break; |
| 1942 | case DP_TRAINING_PATTERN_2: |
| 1943 | temp |= DP_TP_CTL_LINK_TRAIN_PAT2; |
| 1944 | break; |
| 1945 | case DP_TRAINING_PATTERN_3: |
| 1946 | temp |= DP_TP_CTL_LINK_TRAIN_PAT3; |
| 1947 | break; |
| 1948 | } |
Paulo Zanoni | 174edf1 | 2012-10-26 19:05:50 -0200 | [diff] [blame] | 1949 | I915_WRITE(DP_TP_CTL(port), temp); |
Paulo Zanoni | d6c0d72 | 2012-10-15 15:51:34 -0300 | [diff] [blame] | 1950 | |
Imre Deak | bc7d38a | 2013-05-16 14:40:36 +0300 | [diff] [blame] | 1951 | } else if (HAS_PCH_CPT(dev) && (IS_GEN7(dev) || port != PORT_A)) { |
Paulo Zanoni | 47ea754 | 2012-07-17 16:55:16 -0300 | [diff] [blame] | 1952 | dp_reg_value &= ~DP_LINK_TRAIN_MASK_CPT; |
| 1953 | |
| 1954 | switch (dp_train_pat & DP_TRAINING_PATTERN_MASK) { |
| 1955 | case DP_TRAINING_PATTERN_DISABLE: |
| 1956 | dp_reg_value |= DP_LINK_TRAIN_OFF_CPT; |
| 1957 | break; |
| 1958 | case DP_TRAINING_PATTERN_1: |
| 1959 | dp_reg_value |= DP_LINK_TRAIN_PAT_1_CPT; |
| 1960 | break; |
| 1961 | case DP_TRAINING_PATTERN_2: |
| 1962 | dp_reg_value |= DP_LINK_TRAIN_PAT_2_CPT; |
| 1963 | break; |
| 1964 | case DP_TRAINING_PATTERN_3: |
| 1965 | DRM_ERROR("DP training pattern 3 not supported\n"); |
| 1966 | dp_reg_value |= DP_LINK_TRAIN_PAT_2_CPT; |
| 1967 | break; |
| 1968 | } |
| 1969 | |
| 1970 | } else { |
| 1971 | dp_reg_value &= ~DP_LINK_TRAIN_MASK; |
| 1972 | |
| 1973 | switch (dp_train_pat & DP_TRAINING_PATTERN_MASK) { |
| 1974 | case DP_TRAINING_PATTERN_DISABLE: |
| 1975 | dp_reg_value |= DP_LINK_TRAIN_OFF; |
| 1976 | break; |
| 1977 | case DP_TRAINING_PATTERN_1: |
| 1978 | dp_reg_value |= DP_LINK_TRAIN_PAT_1; |
| 1979 | break; |
| 1980 | case DP_TRAINING_PATTERN_2: |
| 1981 | dp_reg_value |= DP_LINK_TRAIN_PAT_2; |
| 1982 | break; |
| 1983 | case DP_TRAINING_PATTERN_3: |
| 1984 | DRM_ERROR("DP training pattern 3 not supported\n"); |
| 1985 | dp_reg_value |= DP_LINK_TRAIN_PAT_2; |
| 1986 | break; |
| 1987 | } |
| 1988 | } |
| 1989 | |
Chris Wilson | ea5b213 | 2010-08-04 13:50:23 +0100 | [diff] [blame] | 1990 | I915_WRITE(intel_dp->output_reg, dp_reg_value); |
| 1991 | POSTING_READ(intel_dp->output_reg); |
Keith Packard | a4fc5ed | 2009-04-07 16:16:42 -0700 | [diff] [blame] | 1992 | |
Chris Wilson | ea5b213 | 2010-08-04 13:50:23 +0100 | [diff] [blame] | 1993 | intel_dp_aux_native_write_1(intel_dp, |
Keith Packard | a4fc5ed | 2009-04-07 16:16:42 -0700 | [diff] [blame] | 1994 | DP_TRAINING_PATTERN_SET, |
| 1995 | dp_train_pat); |
| 1996 | |
Paulo Zanoni | 47ea754 | 2012-07-17 16:55:16 -0300 | [diff] [blame] | 1997 | if ((dp_train_pat & DP_TRAINING_PATTERN_MASK) != |
| 1998 | DP_TRAINING_PATTERN_DISABLE) { |
| 1999 | ret = intel_dp_aux_native_write(intel_dp, |
| 2000 | DP_TRAINING_LANE0_SET, |
| 2001 | intel_dp->train_set, |
| 2002 | intel_dp->lane_count); |
| 2003 | if (ret != intel_dp->lane_count) |
| 2004 | return false; |
| 2005 | } |
Keith Packard | a4fc5ed | 2009-04-07 16:16:42 -0700 | [diff] [blame] | 2006 | |
| 2007 | return true; |
| 2008 | } |
| 2009 | |
Imre Deak | 3ab9c63 | 2013-05-03 12:57:41 +0300 | [diff] [blame] | 2010 | static void intel_dp_set_idle_link_train(struct intel_dp *intel_dp) |
| 2011 | { |
| 2012 | struct intel_digital_port *intel_dig_port = dp_to_dig_port(intel_dp); |
| 2013 | struct drm_device *dev = intel_dig_port->base.base.dev; |
| 2014 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 2015 | enum port port = intel_dig_port->port; |
| 2016 | uint32_t val; |
| 2017 | |
| 2018 | if (!HAS_DDI(dev)) |
| 2019 | return; |
| 2020 | |
| 2021 | val = I915_READ(DP_TP_CTL(port)); |
| 2022 | val &= ~DP_TP_CTL_LINK_TRAIN_MASK; |
| 2023 | val |= DP_TP_CTL_LINK_TRAIN_IDLE; |
| 2024 | I915_WRITE(DP_TP_CTL(port), val); |
| 2025 | |
| 2026 | /* |
| 2027 | * On PORT_A we can have only eDP in SST mode. There the only reason |
| 2028 | * we need to set idle transmission mode is to work around a HW issue |
| 2029 | * where we enable the pipe while not in idle link-training mode. |
| 2030 | * In this case there is requirement to wait for a minimum number of |
| 2031 | * idle patterns to be sent. |
| 2032 | */ |
| 2033 | if (port == PORT_A) |
| 2034 | return; |
| 2035 | |
| 2036 | if (wait_for((I915_READ(DP_TP_STATUS(port)) & DP_TP_STATUS_IDLE_DONE), |
| 2037 | 1)) |
| 2038 | DRM_ERROR("Timed out waiting for DP idle patterns\n"); |
| 2039 | } |
| 2040 | |
Jesse Barnes | 33a34e4 | 2010-09-08 12:42:02 -0700 | [diff] [blame] | 2041 | /* Enable corresponding port and start training pattern 1 */ |
Paulo Zanoni | c19b066 | 2012-10-15 15:51:41 -0300 | [diff] [blame] | 2042 | void |
Jesse Barnes | 33a34e4 | 2010-09-08 12:42:02 -0700 | [diff] [blame] | 2043 | intel_dp_start_link_train(struct intel_dp *intel_dp) |
Keith Packard | a4fc5ed | 2009-04-07 16:16:42 -0700 | [diff] [blame] | 2044 | { |
Paulo Zanoni | da63a9f | 2012-10-26 19:05:46 -0200 | [diff] [blame] | 2045 | struct drm_encoder *encoder = &dp_to_dig_port(intel_dp)->base.base; |
Paulo Zanoni | c19b066 | 2012-10-15 15:51:41 -0300 | [diff] [blame] | 2046 | struct drm_device *dev = encoder->dev; |
Keith Packard | a4fc5ed | 2009-04-07 16:16:42 -0700 | [diff] [blame] | 2047 | int i; |
| 2048 | uint8_t voltage; |
| 2049 | bool clock_recovery = false; |
Keith Packard | cdb0e95 | 2011-11-01 20:00:06 -0700 | [diff] [blame] | 2050 | int voltage_tries, loop_tries; |
Chris Wilson | ea5b213 | 2010-08-04 13:50:23 +0100 | [diff] [blame] | 2051 | uint32_t DP = intel_dp->DP; |
Keith Packard | a4fc5ed | 2009-04-07 16:16:42 -0700 | [diff] [blame] | 2052 | |
Paulo Zanoni | affa935 | 2012-11-23 15:30:39 -0200 | [diff] [blame] | 2053 | if (HAS_DDI(dev)) |
Paulo Zanoni | c19b066 | 2012-10-15 15:51:41 -0300 | [diff] [blame] | 2054 | intel_ddi_prepare_link_retrain(encoder); |
| 2055 | |
Chris Wilson | 3cf2efb | 2010-11-29 10:09:55 +0000 | [diff] [blame] | 2056 | /* Write the link configuration data */ |
| 2057 | intel_dp_aux_native_write(intel_dp, DP_LINK_BW_SET, |
| 2058 | intel_dp->link_configuration, |
| 2059 | DP_LINK_CONFIGURATION_SIZE); |
Keith Packard | a4fc5ed | 2009-04-07 16:16:42 -0700 | [diff] [blame] | 2060 | |
| 2061 | DP |= DP_PORT_EN; |
Keith Packard | 1a2eb46 | 2011-11-16 16:26:07 -0800 | [diff] [blame] | 2062 | |
Jesse Barnes | 33a34e4 | 2010-09-08 12:42:02 -0700 | [diff] [blame] | 2063 | memset(intel_dp->train_set, 0, 4); |
Keith Packard | a4fc5ed | 2009-04-07 16:16:42 -0700 | [diff] [blame] | 2064 | voltage = 0xff; |
Keith Packard | cdb0e95 | 2011-11-01 20:00:06 -0700 | [diff] [blame] | 2065 | voltage_tries = 0; |
| 2066 | loop_tries = 0; |
Keith Packard | a4fc5ed | 2009-04-07 16:16:42 -0700 | [diff] [blame] | 2067 | clock_recovery = false; |
| 2068 | for (;;) { |
Jesse Barnes | 33a34e4 | 2010-09-08 12:42:02 -0700 | [diff] [blame] | 2069 | /* Use intel_dp->train_set[0] to set the voltage and pre emphasis values */ |
Keith Packard | 93f62da | 2011-11-01 19:45:03 -0700 | [diff] [blame] | 2070 | uint8_t link_status[DP_LINK_STATUS_SIZE]; |
Keith Packard | 417e822 | 2011-11-01 19:54:11 -0700 | [diff] [blame] | 2071 | |
Paulo Zanoni | f0a3424 | 2012-12-06 16:51:50 -0200 | [diff] [blame] | 2072 | intel_dp_set_signal_levels(intel_dp, &DP); |
Keith Packard | a4fc5ed | 2009-04-07 16:16:42 -0700 | [diff] [blame] | 2073 | |
Daniel Vetter | a7c9655 | 2012-10-18 10:15:30 +0200 | [diff] [blame] | 2074 | /* Set training pattern 1 */ |
Paulo Zanoni | 47ea754 | 2012-07-17 16:55:16 -0300 | [diff] [blame] | 2075 | if (!intel_dp_set_link_train(intel_dp, DP, |
Adam Jackson | 8105585 | 2011-07-21 17:48:37 -0400 | [diff] [blame] | 2076 | DP_TRAINING_PATTERN_1 | |
| 2077 | DP_LINK_SCRAMBLING_DISABLE)) |
Keith Packard | a4fc5ed | 2009-04-07 16:16:42 -0700 | [diff] [blame] | 2078 | break; |
Keith Packard | a4fc5ed | 2009-04-07 16:16:42 -0700 | [diff] [blame] | 2079 | |
Daniel Vetter | a7c9655 | 2012-10-18 10:15:30 +0200 | [diff] [blame] | 2080 | drm_dp_link_train_clock_recovery_delay(intel_dp->dpcd); |
Keith Packard | 93f62da | 2011-11-01 19:45:03 -0700 | [diff] [blame] | 2081 | if (!intel_dp_get_link_status(intel_dp, link_status)) { |
| 2082 | DRM_ERROR("failed to get link status\n"); |
Keith Packard | a4fc5ed | 2009-04-07 16:16:42 -0700 | [diff] [blame] | 2083 | break; |
Keith Packard | 93f62da | 2011-11-01 19:45:03 -0700 | [diff] [blame] | 2084 | } |
Keith Packard | a4fc5ed | 2009-04-07 16:16:42 -0700 | [diff] [blame] | 2085 | |
Daniel Vetter | 0191627 | 2012-10-18 10:15:25 +0200 | [diff] [blame] | 2086 | if (drm_dp_clock_recovery_ok(link_status, intel_dp->lane_count)) { |
Keith Packard | 93f62da | 2011-11-01 19:45:03 -0700 | [diff] [blame] | 2087 | DRM_DEBUG_KMS("clock recovery OK\n"); |
Chris Wilson | 3cf2efb | 2010-11-29 10:09:55 +0000 | [diff] [blame] | 2088 | clock_recovery = true; |
| 2089 | break; |
Keith Packard | a4fc5ed | 2009-04-07 16:16:42 -0700 | [diff] [blame] | 2090 | } |
Chris Wilson | 3cf2efb | 2010-11-29 10:09:55 +0000 | [diff] [blame] | 2091 | |
| 2092 | /* Check to see if we've tried the max voltage */ |
| 2093 | for (i = 0; i < intel_dp->lane_count; i++) |
| 2094 | if ((intel_dp->train_set[i] & DP_TRAIN_MAX_SWING_REACHED) == 0) |
| 2095 | break; |
Takashi Iwai | 3b4f819 | 2013-03-11 18:40:16 +0100 | [diff] [blame] | 2096 | if (i == intel_dp->lane_count) { |
Daniel Vetter | b06fbda | 2012-10-16 09:50:25 +0200 | [diff] [blame] | 2097 | ++loop_tries; |
| 2098 | if (loop_tries == 5) { |
Keith Packard | cdb0e95 | 2011-11-01 20:00:06 -0700 | [diff] [blame] | 2099 | DRM_DEBUG_KMS("too many full retries, give up\n"); |
| 2100 | break; |
| 2101 | } |
| 2102 | memset(intel_dp->train_set, 0, 4); |
| 2103 | voltage_tries = 0; |
| 2104 | continue; |
| 2105 | } |
Chris Wilson | 3cf2efb | 2010-11-29 10:09:55 +0000 | [diff] [blame] | 2106 | |
| 2107 | /* Check to see if we've tried the same voltage 5 times */ |
Daniel Vetter | b06fbda | 2012-10-16 09:50:25 +0200 | [diff] [blame] | 2108 | if ((intel_dp->train_set[0] & DP_TRAIN_VOLTAGE_SWING_MASK) == voltage) { |
Chris Wilson | 2477367 | 2012-09-26 16:48:30 +0100 | [diff] [blame] | 2109 | ++voltage_tries; |
Daniel Vetter | b06fbda | 2012-10-16 09:50:25 +0200 | [diff] [blame] | 2110 | if (voltage_tries == 5) { |
| 2111 | DRM_DEBUG_KMS("too many voltage retries, give up\n"); |
| 2112 | break; |
| 2113 | } |
| 2114 | } else |
| 2115 | voltage_tries = 0; |
| 2116 | voltage = intel_dp->train_set[0] & DP_TRAIN_VOLTAGE_SWING_MASK; |
Chris Wilson | 3cf2efb | 2010-11-29 10:09:55 +0000 | [diff] [blame] | 2117 | |
| 2118 | /* Compute new intel_dp->train_set as requested by target */ |
Keith Packard | 93f62da | 2011-11-01 19:45:03 -0700 | [diff] [blame] | 2119 | intel_get_adjust_train(intel_dp, link_status); |
Keith Packard | a4fc5ed | 2009-04-07 16:16:42 -0700 | [diff] [blame] | 2120 | } |
| 2121 | |
Jesse Barnes | 33a34e4 | 2010-09-08 12:42:02 -0700 | [diff] [blame] | 2122 | intel_dp->DP = DP; |
| 2123 | } |
| 2124 | |
Paulo Zanoni | c19b066 | 2012-10-15 15:51:41 -0300 | [diff] [blame] | 2125 | void |
Jesse Barnes | 33a34e4 | 2010-09-08 12:42:02 -0700 | [diff] [blame] | 2126 | intel_dp_complete_link_train(struct intel_dp *intel_dp) |
| 2127 | { |
Jesse Barnes | 33a34e4 | 2010-09-08 12:42:02 -0700 | [diff] [blame] | 2128 | bool channel_eq = false; |
Jesse Barnes | 37f8097 | 2011-01-05 14:45:24 -0800 | [diff] [blame] | 2129 | int tries, cr_tries; |
Jesse Barnes | 33a34e4 | 2010-09-08 12:42:02 -0700 | [diff] [blame] | 2130 | uint32_t DP = intel_dp->DP; |
| 2131 | |
Keith Packard | a4fc5ed | 2009-04-07 16:16:42 -0700 | [diff] [blame] | 2132 | /* channel equalization */ |
| 2133 | tries = 0; |
Jesse Barnes | 37f8097 | 2011-01-05 14:45:24 -0800 | [diff] [blame] | 2134 | cr_tries = 0; |
Keith Packard | a4fc5ed | 2009-04-07 16:16:42 -0700 | [diff] [blame] | 2135 | channel_eq = false; |
| 2136 | for (;;) { |
Keith Packard | 93f62da | 2011-11-01 19:45:03 -0700 | [diff] [blame] | 2137 | uint8_t link_status[DP_LINK_STATUS_SIZE]; |
Zhenyu Wang | e3421a1 | 2010-04-08 09:43:27 +0800 | [diff] [blame] | 2138 | |
Jesse Barnes | 37f8097 | 2011-01-05 14:45:24 -0800 | [diff] [blame] | 2139 | if (cr_tries > 5) { |
| 2140 | DRM_ERROR("failed to train DP, aborting\n"); |
| 2141 | intel_dp_link_down(intel_dp); |
| 2142 | break; |
| 2143 | } |
| 2144 | |
Paulo Zanoni | f0a3424 | 2012-12-06 16:51:50 -0200 | [diff] [blame] | 2145 | intel_dp_set_signal_levels(intel_dp, &DP); |
Zhenyu Wang | e3421a1 | 2010-04-08 09:43:27 +0800 | [diff] [blame] | 2146 | |
Keith Packard | a4fc5ed | 2009-04-07 16:16:42 -0700 | [diff] [blame] | 2147 | /* channel eq pattern */ |
Paulo Zanoni | 47ea754 | 2012-07-17 16:55:16 -0300 | [diff] [blame] | 2148 | if (!intel_dp_set_link_train(intel_dp, DP, |
Adam Jackson | 8105585 | 2011-07-21 17:48:37 -0400 | [diff] [blame] | 2149 | DP_TRAINING_PATTERN_2 | |
| 2150 | DP_LINK_SCRAMBLING_DISABLE)) |
Keith Packard | a4fc5ed | 2009-04-07 16:16:42 -0700 | [diff] [blame] | 2151 | break; |
| 2152 | |
Daniel Vetter | a7c9655 | 2012-10-18 10:15:30 +0200 | [diff] [blame] | 2153 | drm_dp_link_train_channel_eq_delay(intel_dp->dpcd); |
Keith Packard | 93f62da | 2011-11-01 19:45:03 -0700 | [diff] [blame] | 2154 | if (!intel_dp_get_link_status(intel_dp, link_status)) |
Keith Packard | a4fc5ed | 2009-04-07 16:16:42 -0700 | [diff] [blame] | 2155 | break; |
Jesse Barnes | 869184a | 2010-10-07 16:01:22 -0700 | [diff] [blame] | 2156 | |
Jesse Barnes | 37f8097 | 2011-01-05 14:45:24 -0800 | [diff] [blame] | 2157 | /* Make sure clock is still ok */ |
Daniel Vetter | 0191627 | 2012-10-18 10:15:25 +0200 | [diff] [blame] | 2158 | if (!drm_dp_clock_recovery_ok(link_status, intel_dp->lane_count)) { |
Jesse Barnes | 37f8097 | 2011-01-05 14:45:24 -0800 | [diff] [blame] | 2159 | intel_dp_start_link_train(intel_dp); |
| 2160 | cr_tries++; |
| 2161 | continue; |
| 2162 | } |
| 2163 | |
Daniel Vetter | 1ffdff1 | 2012-10-18 10:15:24 +0200 | [diff] [blame] | 2164 | if (drm_dp_channel_eq_ok(link_status, intel_dp->lane_count)) { |
Chris Wilson | 3cf2efb | 2010-11-29 10:09:55 +0000 | [diff] [blame] | 2165 | channel_eq = true; |
| 2166 | break; |
Keith Packard | a4fc5ed | 2009-04-07 16:16:42 -0700 | [diff] [blame] | 2167 | } |
Chris Wilson | 3cf2efb | 2010-11-29 10:09:55 +0000 | [diff] [blame] | 2168 | |
Jesse Barnes | 37f8097 | 2011-01-05 14:45:24 -0800 | [diff] [blame] | 2169 | /* Try 5 times, then try clock recovery if that fails */ |
| 2170 | if (tries > 5) { |
| 2171 | intel_dp_link_down(intel_dp); |
| 2172 | intel_dp_start_link_train(intel_dp); |
| 2173 | tries = 0; |
| 2174 | cr_tries++; |
| 2175 | continue; |
| 2176 | } |
Chris Wilson | 3cf2efb | 2010-11-29 10:09:55 +0000 | [diff] [blame] | 2177 | |
| 2178 | /* Compute new intel_dp->train_set as requested by target */ |
Keith Packard | 93f62da | 2011-11-01 19:45:03 -0700 | [diff] [blame] | 2179 | intel_get_adjust_train(intel_dp, link_status); |
Chris Wilson | 3cf2efb | 2010-11-29 10:09:55 +0000 | [diff] [blame] | 2180 | ++tries; |
Keith Packard | a4fc5ed | 2009-04-07 16:16:42 -0700 | [diff] [blame] | 2181 | } |
Chris Wilson | 3cf2efb | 2010-11-29 10:09:55 +0000 | [diff] [blame] | 2182 | |
Imre Deak | 3ab9c63 | 2013-05-03 12:57:41 +0300 | [diff] [blame] | 2183 | intel_dp_set_idle_link_train(intel_dp); |
| 2184 | |
| 2185 | intel_dp->DP = DP; |
| 2186 | |
Paulo Zanoni | d6c0d72 | 2012-10-15 15:51:34 -0300 | [diff] [blame] | 2187 | if (channel_eq) |
Masanari Iida | 07f4225 | 2013-03-20 11:00:34 +0900 | [diff] [blame] | 2188 | DRM_DEBUG_KMS("Channel EQ done. DP Training successful\n"); |
Paulo Zanoni | d6c0d72 | 2012-10-15 15:51:34 -0300 | [diff] [blame] | 2189 | |
Imre Deak | 3ab9c63 | 2013-05-03 12:57:41 +0300 | [diff] [blame] | 2190 | } |
| 2191 | |
| 2192 | void intel_dp_stop_link_train(struct intel_dp *intel_dp) |
| 2193 | { |
| 2194 | intel_dp_set_link_train(intel_dp, intel_dp->DP, |
| 2195 | DP_TRAINING_PATTERN_DISABLE); |
Keith Packard | a4fc5ed | 2009-04-07 16:16:42 -0700 | [diff] [blame] | 2196 | } |
| 2197 | |
| 2198 | static void |
Chris Wilson | ea5b213 | 2010-08-04 13:50:23 +0100 | [diff] [blame] | 2199 | intel_dp_link_down(struct intel_dp *intel_dp) |
Keith Packard | a4fc5ed | 2009-04-07 16:16:42 -0700 | [diff] [blame] | 2200 | { |
Paulo Zanoni | da63a9f | 2012-10-26 19:05:46 -0200 | [diff] [blame] | 2201 | struct intel_digital_port *intel_dig_port = dp_to_dig_port(intel_dp); |
Imre Deak | bc7d38a | 2013-05-16 14:40:36 +0300 | [diff] [blame] | 2202 | enum port port = intel_dig_port->port; |
Paulo Zanoni | da63a9f | 2012-10-26 19:05:46 -0200 | [diff] [blame] | 2203 | struct drm_device *dev = intel_dig_port->base.base.dev; |
Keith Packard | a4fc5ed | 2009-04-07 16:16:42 -0700 | [diff] [blame] | 2204 | struct drm_i915_private *dev_priv = dev->dev_private; |
Daniel Vetter | ab527ef | 2012-11-29 15:59:33 +0100 | [diff] [blame] | 2205 | struct intel_crtc *intel_crtc = |
| 2206 | to_intel_crtc(intel_dig_port->base.base.crtc); |
Chris Wilson | ea5b213 | 2010-08-04 13:50:23 +0100 | [diff] [blame] | 2207 | uint32_t DP = intel_dp->DP; |
Keith Packard | a4fc5ed | 2009-04-07 16:16:42 -0700 | [diff] [blame] | 2208 | |
Paulo Zanoni | c19b066 | 2012-10-15 15:51:41 -0300 | [diff] [blame] | 2209 | /* |
| 2210 | * DDI code has a strict mode set sequence and we should try to respect |
| 2211 | * it, otherwise we might hang the machine in many different ways. So we |
| 2212 | * really should be disabling the port only on a complete crtc_disable |
| 2213 | * sequence. This function is just called under two conditions on DDI |
| 2214 | * code: |
| 2215 | * - Link train failed while doing crtc_enable, and on this case we |
| 2216 | * really should respect the mode set sequence and wait for a |
| 2217 | * crtc_disable. |
| 2218 | * - Someone turned the monitor off and intel_dp_check_link_status |
| 2219 | * called us. We don't need to disable the whole port on this case, so |
| 2220 | * when someone turns the monitor on again, |
| 2221 | * intel_ddi_prepare_link_retrain will take care of redoing the link |
| 2222 | * train. |
| 2223 | */ |
Paulo Zanoni | affa935 | 2012-11-23 15:30:39 -0200 | [diff] [blame] | 2224 | if (HAS_DDI(dev)) |
Paulo Zanoni | c19b066 | 2012-10-15 15:51:41 -0300 | [diff] [blame] | 2225 | return; |
| 2226 | |
Daniel Vetter | 0c33d8d | 2012-09-06 22:15:43 +0200 | [diff] [blame] | 2227 | if (WARN_ON((I915_READ(intel_dp->output_reg) & DP_PORT_EN) == 0)) |
Chris Wilson | 1b39d6f | 2010-12-06 11:20:45 +0000 | [diff] [blame] | 2228 | return; |
| 2229 | |
Zhao Yakui | 28c9773 | 2009-10-09 11:39:41 +0800 | [diff] [blame] | 2230 | DRM_DEBUG_KMS("\n"); |
Zhenyu Wang | 32f9d65 | 2009-07-24 01:00:32 +0800 | [diff] [blame] | 2231 | |
Imre Deak | bc7d38a | 2013-05-16 14:40:36 +0300 | [diff] [blame] | 2232 | if (HAS_PCH_CPT(dev) && (IS_GEN7(dev) || port != PORT_A)) { |
Zhenyu Wang | e3421a1 | 2010-04-08 09:43:27 +0800 | [diff] [blame] | 2233 | DP &= ~DP_LINK_TRAIN_MASK_CPT; |
Chris Wilson | ea5b213 | 2010-08-04 13:50:23 +0100 | [diff] [blame] | 2234 | I915_WRITE(intel_dp->output_reg, DP | DP_LINK_TRAIN_PAT_IDLE_CPT); |
Zhenyu Wang | e3421a1 | 2010-04-08 09:43:27 +0800 | [diff] [blame] | 2235 | } else { |
| 2236 | DP &= ~DP_LINK_TRAIN_MASK; |
Chris Wilson | ea5b213 | 2010-08-04 13:50:23 +0100 | [diff] [blame] | 2237 | I915_WRITE(intel_dp->output_reg, DP | DP_LINK_TRAIN_PAT_IDLE); |
Zhenyu Wang | e3421a1 | 2010-04-08 09:43:27 +0800 | [diff] [blame] | 2238 | } |
Chris Wilson | fe255d0 | 2010-09-11 21:37:48 +0100 | [diff] [blame] | 2239 | POSTING_READ(intel_dp->output_reg); |
Zhenyu Wang | 5eb08b6 | 2009-07-24 01:00:31 +0800 | [diff] [blame] | 2240 | |
Daniel Vetter | ab527ef | 2012-11-29 15:59:33 +0100 | [diff] [blame] | 2241 | /* We don't really know why we're doing this */ |
| 2242 | intel_wait_for_vblank(dev, intel_crtc->pipe); |
Zhenyu Wang | 5eb08b6 | 2009-07-24 01:00:31 +0800 | [diff] [blame] | 2243 | |
Daniel Vetter | 493a708 | 2012-05-30 12:31:56 +0200 | [diff] [blame] | 2244 | if (HAS_PCH_IBX(dev) && |
Chris Wilson | 1b39d6f | 2010-12-06 11:20:45 +0000 | [diff] [blame] | 2245 | I915_READ(intel_dp->output_reg) & DP_PIPEB_SELECT) { |
Paulo Zanoni | da63a9f | 2012-10-26 19:05:46 -0200 | [diff] [blame] | 2246 | struct drm_crtc *crtc = intel_dig_port->base.base.crtc; |
Chris Wilson | 31acbcc | 2011-04-17 06:38:35 +0100 | [diff] [blame] | 2247 | |
Eric Anholt | 5bddd17 | 2010-11-18 09:32:59 +0800 | [diff] [blame] | 2248 | /* Hardware workaround: leaving our transcoder select |
| 2249 | * set to transcoder B while it's off will prevent the |
| 2250 | * corresponding HDMI output on transcoder A. |
| 2251 | * |
| 2252 | * Combine this with another hardware workaround: |
| 2253 | * transcoder select bit can only be cleared while the |
| 2254 | * port is enabled. |
| 2255 | */ |
| 2256 | DP &= ~DP_PIPEB_SELECT; |
| 2257 | I915_WRITE(intel_dp->output_reg, DP); |
| 2258 | |
| 2259 | /* Changes to enable or select take place the vblank |
| 2260 | * after being written. |
| 2261 | */ |
Daniel Vetter | ff50afe | 2012-11-29 15:59:34 +0100 | [diff] [blame] | 2262 | if (WARN_ON(crtc == NULL)) { |
| 2263 | /* We should never try to disable a port without a crtc |
| 2264 | * attached. For paranoia keep the code around for a |
| 2265 | * bit. */ |
Chris Wilson | 31acbcc | 2011-04-17 06:38:35 +0100 | [diff] [blame] | 2266 | POSTING_READ(intel_dp->output_reg); |
| 2267 | msleep(50); |
| 2268 | } else |
Daniel Vetter | ab527ef | 2012-11-29 15:59:33 +0100 | [diff] [blame] | 2269 | intel_wait_for_vblank(dev, intel_crtc->pipe); |
Eric Anholt | 5bddd17 | 2010-11-18 09:32:59 +0800 | [diff] [blame] | 2270 | } |
| 2271 | |
Wu Fengguang | 832afda | 2011-12-09 20:42:21 +0800 | [diff] [blame] | 2272 | DP &= ~DP_AUDIO_OUTPUT_ENABLE; |
Chris Wilson | ea5b213 | 2010-08-04 13:50:23 +0100 | [diff] [blame] | 2273 | I915_WRITE(intel_dp->output_reg, DP & ~DP_PORT_EN); |
| 2274 | POSTING_READ(intel_dp->output_reg); |
Keith Packard | f01eca2 | 2011-09-28 16:48:10 -0700 | [diff] [blame] | 2275 | msleep(intel_dp->panel_power_down_delay); |
Keith Packard | a4fc5ed | 2009-04-07 16:16:42 -0700 | [diff] [blame] | 2276 | } |
| 2277 | |
Keith Packard | 26d61aa | 2011-07-25 20:01:09 -0700 | [diff] [blame] | 2278 | static bool |
| 2279 | intel_dp_get_dpcd(struct intel_dp *intel_dp) |
Keith Packard | 92fd8fd | 2011-07-25 19:50:10 -0700 | [diff] [blame] | 2280 | { |
Damien Lespiau | 577c7a5 | 2012-12-13 16:09:02 +0000 | [diff] [blame] | 2281 | char dpcd_hex_dump[sizeof(intel_dp->dpcd) * 3]; |
| 2282 | |
Keith Packard | 92fd8fd | 2011-07-25 19:50:10 -0700 | [diff] [blame] | 2283 | if (intel_dp_aux_native_read_retry(intel_dp, 0x000, intel_dp->dpcd, |
Adam Jackson | edb3924 | 2012-09-18 10:58:49 -0400 | [diff] [blame] | 2284 | sizeof(intel_dp->dpcd)) == 0) |
| 2285 | return false; /* aux transfer failed */ |
Keith Packard | 92fd8fd | 2011-07-25 19:50:10 -0700 | [diff] [blame] | 2286 | |
Damien Lespiau | 577c7a5 | 2012-12-13 16:09:02 +0000 | [diff] [blame] | 2287 | hex_dump_to_buffer(intel_dp->dpcd, sizeof(intel_dp->dpcd), |
| 2288 | 32, 1, dpcd_hex_dump, sizeof(dpcd_hex_dump), false); |
| 2289 | DRM_DEBUG_KMS("DPCD: %s\n", dpcd_hex_dump); |
| 2290 | |
Adam Jackson | edb3924 | 2012-09-18 10:58:49 -0400 | [diff] [blame] | 2291 | if (intel_dp->dpcd[DP_DPCD_REV] == 0) |
| 2292 | return false; /* DPCD not present */ |
| 2293 | |
Shobhit Kumar | 2293bb5 | 2013-07-11 18:44:56 -0300 | [diff] [blame] | 2294 | /* Check if the panel supports PSR */ |
| 2295 | memset(intel_dp->psr_dpcd, 0, sizeof(intel_dp->psr_dpcd)); |
| 2296 | intel_dp_aux_native_read_retry(intel_dp, DP_PSR_SUPPORT, |
| 2297 | intel_dp->psr_dpcd, |
| 2298 | sizeof(intel_dp->psr_dpcd)); |
| 2299 | if (is_edp_psr(intel_dp)) |
| 2300 | DRM_DEBUG_KMS("Detected EDP PSR Panel.\n"); |
Adam Jackson | edb3924 | 2012-09-18 10:58:49 -0400 | [diff] [blame] | 2301 | if (!(intel_dp->dpcd[DP_DOWNSTREAMPORT_PRESENT] & |
| 2302 | DP_DWN_STRM_PORT_PRESENT)) |
| 2303 | return true; /* native DP sink */ |
| 2304 | |
| 2305 | if (intel_dp->dpcd[DP_DPCD_REV] == 0x10) |
| 2306 | return true; /* no per-port downstream info */ |
| 2307 | |
| 2308 | if (intel_dp_aux_native_read_retry(intel_dp, DP_DOWNSTREAM_PORT_0, |
| 2309 | intel_dp->downstream_ports, |
| 2310 | DP_MAX_DOWNSTREAM_PORTS) == 0) |
| 2311 | return false; /* downstream port status fetch failed */ |
| 2312 | |
| 2313 | return true; |
Keith Packard | 92fd8fd | 2011-07-25 19:50:10 -0700 | [diff] [blame] | 2314 | } |
| 2315 | |
Adam Jackson | 0d19832 | 2012-05-14 16:05:47 -0400 | [diff] [blame] | 2316 | static void |
| 2317 | intel_dp_probe_oui(struct intel_dp *intel_dp) |
| 2318 | { |
| 2319 | u8 buf[3]; |
| 2320 | |
| 2321 | if (!(intel_dp->dpcd[DP_DOWN_STREAM_PORT_COUNT] & DP_OUI_SUPPORT)) |
| 2322 | return; |
| 2323 | |
Daniel Vetter | 351cfc3 | 2012-06-12 13:20:47 +0200 | [diff] [blame] | 2324 | ironlake_edp_panel_vdd_on(intel_dp); |
| 2325 | |
Adam Jackson | 0d19832 | 2012-05-14 16:05:47 -0400 | [diff] [blame] | 2326 | if (intel_dp_aux_native_read_retry(intel_dp, DP_SINK_OUI, buf, 3)) |
| 2327 | DRM_DEBUG_KMS("Sink OUI: %02hx%02hx%02hx\n", |
| 2328 | buf[0], buf[1], buf[2]); |
| 2329 | |
| 2330 | if (intel_dp_aux_native_read_retry(intel_dp, DP_BRANCH_OUI, buf, 3)) |
| 2331 | DRM_DEBUG_KMS("Branch OUI: %02hx%02hx%02hx\n", |
| 2332 | buf[0], buf[1], buf[2]); |
Daniel Vetter | 351cfc3 | 2012-06-12 13:20:47 +0200 | [diff] [blame] | 2333 | |
| 2334 | ironlake_edp_panel_vdd_off(intel_dp, false); |
Adam Jackson | 0d19832 | 2012-05-14 16:05:47 -0400 | [diff] [blame] | 2335 | } |
| 2336 | |
Jesse Barnes | a60f0e3 | 2011-10-20 15:09:17 -0700 | [diff] [blame] | 2337 | static bool |
| 2338 | intel_dp_get_sink_irq(struct intel_dp *intel_dp, u8 *sink_irq_vector) |
| 2339 | { |
| 2340 | int ret; |
| 2341 | |
| 2342 | ret = intel_dp_aux_native_read_retry(intel_dp, |
| 2343 | DP_DEVICE_SERVICE_IRQ_VECTOR, |
| 2344 | sink_irq_vector, 1); |
| 2345 | if (!ret) |
| 2346 | return false; |
| 2347 | |
| 2348 | return true; |
| 2349 | } |
| 2350 | |
| 2351 | static void |
| 2352 | intel_dp_handle_test_request(struct intel_dp *intel_dp) |
| 2353 | { |
| 2354 | /* NAK by default */ |
Daniel Vetter | 9324cf7 | 2012-10-20 21:13:05 +0200 | [diff] [blame] | 2355 | intel_dp_aux_native_write_1(intel_dp, DP_TEST_RESPONSE, DP_TEST_NAK); |
Jesse Barnes | a60f0e3 | 2011-10-20 15:09:17 -0700 | [diff] [blame] | 2356 | } |
| 2357 | |
Keith Packard | a4fc5ed | 2009-04-07 16:16:42 -0700 | [diff] [blame] | 2358 | /* |
| 2359 | * According to DP spec |
| 2360 | * 5.1.2: |
| 2361 | * 1. Read DPCD |
| 2362 | * 2. Configure link according to Receiver Capabilities |
| 2363 | * 3. Use Link Training from 2.5.3.3 and 3.5.1.3 |
| 2364 | * 4. Check link status on receipt of hot-plug interrupt |
| 2365 | */ |
| 2366 | |
Paulo Zanoni | 00c09d7 | 2012-10-26 19:05:52 -0200 | [diff] [blame] | 2367 | void |
Chris Wilson | ea5b213 | 2010-08-04 13:50:23 +0100 | [diff] [blame] | 2368 | intel_dp_check_link_status(struct intel_dp *intel_dp) |
Keith Packard | a4fc5ed | 2009-04-07 16:16:42 -0700 | [diff] [blame] | 2369 | { |
Paulo Zanoni | da63a9f | 2012-10-26 19:05:46 -0200 | [diff] [blame] | 2370 | struct intel_encoder *intel_encoder = &dp_to_dig_port(intel_dp)->base; |
Jesse Barnes | a60f0e3 | 2011-10-20 15:09:17 -0700 | [diff] [blame] | 2371 | u8 sink_irq_vector; |
Keith Packard | 93f62da | 2011-11-01 19:45:03 -0700 | [diff] [blame] | 2372 | u8 link_status[DP_LINK_STATUS_SIZE]; |
Jesse Barnes | a60f0e3 | 2011-10-20 15:09:17 -0700 | [diff] [blame] | 2373 | |
Paulo Zanoni | da63a9f | 2012-10-26 19:05:46 -0200 | [diff] [blame] | 2374 | if (!intel_encoder->connectors_active) |
Keith Packard | d2b996a | 2011-07-25 22:37:51 -0700 | [diff] [blame] | 2375 | return; |
Jesse Barnes | 59cd09e | 2011-07-07 11:10:59 -0700 | [diff] [blame] | 2376 | |
Paulo Zanoni | da63a9f | 2012-10-26 19:05:46 -0200 | [diff] [blame] | 2377 | if (WARN_ON(!intel_encoder->base.crtc)) |
Keith Packard | a4fc5ed | 2009-04-07 16:16:42 -0700 | [diff] [blame] | 2378 | return; |
| 2379 | |
Keith Packard | 92fd8fd | 2011-07-25 19:50:10 -0700 | [diff] [blame] | 2380 | /* Try to read receiver status if the link appears to be up */ |
Keith Packard | 93f62da | 2011-11-01 19:45:03 -0700 | [diff] [blame] | 2381 | if (!intel_dp_get_link_status(intel_dp, link_status)) { |
Chris Wilson | ea5b213 | 2010-08-04 13:50:23 +0100 | [diff] [blame] | 2382 | intel_dp_link_down(intel_dp); |
Keith Packard | a4fc5ed | 2009-04-07 16:16:42 -0700 | [diff] [blame] | 2383 | return; |
| 2384 | } |
| 2385 | |
Keith Packard | 92fd8fd | 2011-07-25 19:50:10 -0700 | [diff] [blame] | 2386 | /* Now read the DPCD to see if it's actually running */ |
Keith Packard | 26d61aa | 2011-07-25 20:01:09 -0700 | [diff] [blame] | 2387 | if (!intel_dp_get_dpcd(intel_dp)) { |
Jesse Barnes | 59cd09e | 2011-07-07 11:10:59 -0700 | [diff] [blame] | 2388 | intel_dp_link_down(intel_dp); |
| 2389 | return; |
| 2390 | } |
| 2391 | |
Jesse Barnes | a60f0e3 | 2011-10-20 15:09:17 -0700 | [diff] [blame] | 2392 | /* Try to read the source of the interrupt */ |
| 2393 | if (intel_dp->dpcd[DP_DPCD_REV] >= 0x11 && |
| 2394 | intel_dp_get_sink_irq(intel_dp, &sink_irq_vector)) { |
| 2395 | /* Clear interrupt source */ |
| 2396 | intel_dp_aux_native_write_1(intel_dp, |
| 2397 | DP_DEVICE_SERVICE_IRQ_VECTOR, |
| 2398 | sink_irq_vector); |
| 2399 | |
| 2400 | if (sink_irq_vector & DP_AUTOMATED_TEST_REQUEST) |
| 2401 | intel_dp_handle_test_request(intel_dp); |
| 2402 | if (sink_irq_vector & (DP_CP_IRQ | DP_SINK_SPECIFIC_IRQ)) |
| 2403 | DRM_DEBUG_DRIVER("CP or sink specific irq unhandled\n"); |
| 2404 | } |
| 2405 | |
Daniel Vetter | 1ffdff1 | 2012-10-18 10:15:24 +0200 | [diff] [blame] | 2406 | if (!drm_dp_channel_eq_ok(link_status, intel_dp->lane_count)) { |
Keith Packard | 92fd8fd | 2011-07-25 19:50:10 -0700 | [diff] [blame] | 2407 | DRM_DEBUG_KMS("%s: channel EQ not ok, retraining\n", |
Paulo Zanoni | da63a9f | 2012-10-26 19:05:46 -0200 | [diff] [blame] | 2408 | drm_get_encoder_name(&intel_encoder->base)); |
Jesse Barnes | 33a34e4 | 2010-09-08 12:42:02 -0700 | [diff] [blame] | 2409 | intel_dp_start_link_train(intel_dp); |
| 2410 | intel_dp_complete_link_train(intel_dp); |
Imre Deak | 3ab9c63 | 2013-05-03 12:57:41 +0300 | [diff] [blame] | 2411 | intel_dp_stop_link_train(intel_dp); |
Jesse Barnes | 33a34e4 | 2010-09-08 12:42:02 -0700 | [diff] [blame] | 2412 | } |
Keith Packard | a4fc5ed | 2009-04-07 16:16:42 -0700 | [diff] [blame] | 2413 | } |
Keith Packard | a4fc5ed | 2009-04-07 16:16:42 -0700 | [diff] [blame] | 2414 | |
Adam Jackson | caf9ab2 | 2012-09-18 10:58:50 -0400 | [diff] [blame] | 2415 | /* XXX this is probably wrong for multiple downstream ports */ |
Zhenyu Wang | 5eb08b6 | 2009-07-24 01:00:31 +0800 | [diff] [blame] | 2416 | static enum drm_connector_status |
Keith Packard | 26d61aa | 2011-07-25 20:01:09 -0700 | [diff] [blame] | 2417 | intel_dp_detect_dpcd(struct intel_dp *intel_dp) |
Adam Jackson | 71ba9000 | 2011-07-12 17:38:04 -0400 | [diff] [blame] | 2418 | { |
Adam Jackson | caf9ab2 | 2012-09-18 10:58:50 -0400 | [diff] [blame] | 2419 | uint8_t *dpcd = intel_dp->dpcd; |
| 2420 | bool hpd; |
| 2421 | uint8_t type; |
| 2422 | |
| 2423 | if (!intel_dp_get_dpcd(intel_dp)) |
| 2424 | return connector_status_disconnected; |
| 2425 | |
| 2426 | /* if there's no downstream port, we're done */ |
| 2427 | if (!(dpcd[DP_DOWNSTREAMPORT_PRESENT] & DP_DWN_STRM_PORT_PRESENT)) |
Keith Packard | 26d61aa | 2011-07-25 20:01:09 -0700 | [diff] [blame] | 2428 | return connector_status_connected; |
Adam Jackson | caf9ab2 | 2012-09-18 10:58:50 -0400 | [diff] [blame] | 2429 | |
| 2430 | /* If we're HPD-aware, SINK_COUNT changes dynamically */ |
| 2431 | hpd = !!(intel_dp->downstream_ports[0] & DP_DS_PORT_HPD); |
| 2432 | if (hpd) { |
Adam Jackson | 2323517 | 2012-09-20 16:42:45 -0400 | [diff] [blame] | 2433 | uint8_t reg; |
Adam Jackson | caf9ab2 | 2012-09-18 10:58:50 -0400 | [diff] [blame] | 2434 | if (!intel_dp_aux_native_read_retry(intel_dp, DP_SINK_COUNT, |
Adam Jackson | 2323517 | 2012-09-20 16:42:45 -0400 | [diff] [blame] | 2435 | ®, 1)) |
Adam Jackson | caf9ab2 | 2012-09-18 10:58:50 -0400 | [diff] [blame] | 2436 | return connector_status_unknown; |
Adam Jackson | 2323517 | 2012-09-20 16:42:45 -0400 | [diff] [blame] | 2437 | return DP_GET_SINK_COUNT(reg) ? connector_status_connected |
| 2438 | : connector_status_disconnected; |
Adam Jackson | caf9ab2 | 2012-09-18 10:58:50 -0400 | [diff] [blame] | 2439 | } |
| 2440 | |
| 2441 | /* If no HPD, poke DDC gently */ |
| 2442 | if (drm_probe_ddc(&intel_dp->adapter)) |
| 2443 | return connector_status_connected; |
| 2444 | |
| 2445 | /* Well we tried, say unknown for unreliable port types */ |
| 2446 | type = intel_dp->downstream_ports[0] & DP_DS_PORT_TYPE_MASK; |
| 2447 | if (type == DP_DS_PORT_TYPE_VGA || type == DP_DS_PORT_TYPE_NON_EDID) |
| 2448 | return connector_status_unknown; |
| 2449 | |
| 2450 | /* Anything else is out of spec, warn and ignore */ |
| 2451 | DRM_DEBUG_KMS("Broken DP branch device, ignoring\n"); |
Keith Packard | 26d61aa | 2011-07-25 20:01:09 -0700 | [diff] [blame] | 2452 | return connector_status_disconnected; |
Adam Jackson | 71ba9000 | 2011-07-12 17:38:04 -0400 | [diff] [blame] | 2453 | } |
| 2454 | |
| 2455 | static enum drm_connector_status |
Zhenyu Wang | a9756bb | 2010-09-19 13:09:06 +0800 | [diff] [blame] | 2456 | ironlake_dp_detect(struct intel_dp *intel_dp) |
Zhenyu Wang | 5eb08b6 | 2009-07-24 01:00:31 +0800 | [diff] [blame] | 2457 | { |
Paulo Zanoni | 30add22 | 2012-10-26 19:05:45 -0200 | [diff] [blame] | 2458 | struct drm_device *dev = intel_dp_to_dev(intel_dp); |
Damien Lespiau | 1b46963 | 2012-12-13 16:09:01 +0000 | [diff] [blame] | 2459 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 2460 | struct intel_digital_port *intel_dig_port = dp_to_dig_port(intel_dp); |
Zhenyu Wang | 5eb08b6 | 2009-07-24 01:00:31 +0800 | [diff] [blame] | 2461 | enum drm_connector_status status; |
| 2462 | |
Chris Wilson | fe16d94 | 2011-02-12 10:29:38 +0000 | [diff] [blame] | 2463 | /* Can't disconnect eDP, but you can close the lid... */ |
| 2464 | if (is_edp(intel_dp)) { |
Paulo Zanoni | 30add22 | 2012-10-26 19:05:45 -0200 | [diff] [blame] | 2465 | status = intel_panel_detect(dev); |
Chris Wilson | fe16d94 | 2011-02-12 10:29:38 +0000 | [diff] [blame] | 2466 | if (status == connector_status_unknown) |
| 2467 | status = connector_status_connected; |
| 2468 | return status; |
| 2469 | } |
Jesse Barnes | 01cb9ea | 2010-10-07 16:01:12 -0700 | [diff] [blame] | 2470 | |
Damien Lespiau | 1b46963 | 2012-12-13 16:09:01 +0000 | [diff] [blame] | 2471 | if (!ibx_digital_port_connected(dev_priv, intel_dig_port)) |
| 2472 | return connector_status_disconnected; |
| 2473 | |
Keith Packard | 26d61aa | 2011-07-25 20:01:09 -0700 | [diff] [blame] | 2474 | return intel_dp_detect_dpcd(intel_dp); |
Zhenyu Wang | 5eb08b6 | 2009-07-24 01:00:31 +0800 | [diff] [blame] | 2475 | } |
| 2476 | |
Keith Packard | a4fc5ed | 2009-04-07 16:16:42 -0700 | [diff] [blame] | 2477 | static enum drm_connector_status |
Zhenyu Wang | a9756bb | 2010-09-19 13:09:06 +0800 | [diff] [blame] | 2478 | g4x_dp_detect(struct intel_dp *intel_dp) |
Keith Packard | a4fc5ed | 2009-04-07 16:16:42 -0700 | [diff] [blame] | 2479 | { |
Paulo Zanoni | 30add22 | 2012-10-26 19:05:45 -0200 | [diff] [blame] | 2480 | struct drm_device *dev = intel_dp_to_dev(intel_dp); |
Keith Packard | a4fc5ed | 2009-04-07 16:16:42 -0700 | [diff] [blame] | 2481 | struct drm_i915_private *dev_priv = dev->dev_private; |
Ville Syrjälä | 34f2be4 | 2013-01-24 15:29:27 +0200 | [diff] [blame] | 2482 | struct intel_digital_port *intel_dig_port = dp_to_dig_port(intel_dp); |
Chris Wilson | 10f76a3 | 2012-05-11 18:01:32 +0100 | [diff] [blame] | 2483 | uint32_t bit; |
Zhenyu Wang | 5eb08b6 | 2009-07-24 01:00:31 +0800 | [diff] [blame] | 2484 | |
Jesse Barnes | 35aad75 | 2013-03-01 13:14:31 -0800 | [diff] [blame] | 2485 | /* Can't disconnect eDP, but you can close the lid... */ |
| 2486 | if (is_edp(intel_dp)) { |
| 2487 | enum drm_connector_status status; |
| 2488 | |
| 2489 | status = intel_panel_detect(dev); |
| 2490 | if (status == connector_status_unknown) |
| 2491 | status = connector_status_connected; |
| 2492 | return status; |
| 2493 | } |
| 2494 | |
Ville Syrjälä | 34f2be4 | 2013-01-24 15:29:27 +0200 | [diff] [blame] | 2495 | switch (intel_dig_port->port) { |
| 2496 | case PORT_B: |
Daniel Vetter | 26739f1 | 2013-02-07 12:42:32 +0100 | [diff] [blame] | 2497 | bit = PORTB_HOTPLUG_LIVE_STATUS; |
Keith Packard | a4fc5ed | 2009-04-07 16:16:42 -0700 | [diff] [blame] | 2498 | break; |
Ville Syrjälä | 34f2be4 | 2013-01-24 15:29:27 +0200 | [diff] [blame] | 2499 | case PORT_C: |
Daniel Vetter | 26739f1 | 2013-02-07 12:42:32 +0100 | [diff] [blame] | 2500 | bit = PORTC_HOTPLUG_LIVE_STATUS; |
Keith Packard | a4fc5ed | 2009-04-07 16:16:42 -0700 | [diff] [blame] | 2501 | break; |
Ville Syrjälä | 34f2be4 | 2013-01-24 15:29:27 +0200 | [diff] [blame] | 2502 | case PORT_D: |
Daniel Vetter | 26739f1 | 2013-02-07 12:42:32 +0100 | [diff] [blame] | 2503 | bit = PORTD_HOTPLUG_LIVE_STATUS; |
Keith Packard | a4fc5ed | 2009-04-07 16:16:42 -0700 | [diff] [blame] | 2504 | break; |
| 2505 | default: |
| 2506 | return connector_status_unknown; |
| 2507 | } |
| 2508 | |
Chris Wilson | 10f76a3 | 2012-05-11 18:01:32 +0100 | [diff] [blame] | 2509 | if ((I915_READ(PORT_HOTPLUG_STAT) & bit) == 0) |
Keith Packard | a4fc5ed | 2009-04-07 16:16:42 -0700 | [diff] [blame] | 2510 | return connector_status_disconnected; |
| 2511 | |
Keith Packard | 26d61aa | 2011-07-25 20:01:09 -0700 | [diff] [blame] | 2512 | return intel_dp_detect_dpcd(intel_dp); |
Zhenyu Wang | a9756bb | 2010-09-19 13:09:06 +0800 | [diff] [blame] | 2513 | } |
| 2514 | |
Keith Packard | 8c241fe | 2011-09-28 16:38:44 -0700 | [diff] [blame] | 2515 | static struct edid * |
| 2516 | intel_dp_get_edid(struct drm_connector *connector, struct i2c_adapter *adapter) |
| 2517 | { |
Jani Nikula | 9cd300e | 2012-10-19 14:51:52 +0300 | [diff] [blame] | 2518 | struct intel_connector *intel_connector = to_intel_connector(connector); |
Keith Packard | 8c241fe | 2011-09-28 16:38:44 -0700 | [diff] [blame] | 2519 | |
Jani Nikula | 9cd300e | 2012-10-19 14:51:52 +0300 | [diff] [blame] | 2520 | /* use cached edid if we have one */ |
| 2521 | if (intel_connector->edid) { |
| 2522 | struct edid *edid; |
| 2523 | int size; |
| 2524 | |
| 2525 | /* invalid edid */ |
| 2526 | if (IS_ERR(intel_connector->edid)) |
Jesse Barnes | d6f24d0 | 2012-06-14 15:28:33 -0400 | [diff] [blame] | 2527 | return NULL; |
| 2528 | |
Jani Nikula | 9cd300e | 2012-10-19 14:51:52 +0300 | [diff] [blame] | 2529 | size = (intel_connector->edid->extensions + 1) * EDID_LENGTH; |
Thomas Meyer | edbe158 | 2013-05-22 23:07:09 +0200 | [diff] [blame] | 2530 | edid = kmemdup(intel_connector->edid, size, GFP_KERNEL); |
Jesse Barnes | d6f24d0 | 2012-06-14 15:28:33 -0400 | [diff] [blame] | 2531 | if (!edid) |
| 2532 | return NULL; |
| 2533 | |
Jesse Barnes | d6f24d0 | 2012-06-14 15:28:33 -0400 | [diff] [blame] | 2534 | return edid; |
| 2535 | } |
| 2536 | |
Jani Nikula | 9cd300e | 2012-10-19 14:51:52 +0300 | [diff] [blame] | 2537 | return drm_get_edid(connector, adapter); |
Keith Packard | 8c241fe | 2011-09-28 16:38:44 -0700 | [diff] [blame] | 2538 | } |
| 2539 | |
| 2540 | static int |
| 2541 | intel_dp_get_edid_modes(struct drm_connector *connector, struct i2c_adapter *adapter) |
| 2542 | { |
Jani Nikula | 9cd300e | 2012-10-19 14:51:52 +0300 | [diff] [blame] | 2543 | struct intel_connector *intel_connector = to_intel_connector(connector); |
Keith Packard | 8c241fe | 2011-09-28 16:38:44 -0700 | [diff] [blame] | 2544 | |
Jani Nikula | 9cd300e | 2012-10-19 14:51:52 +0300 | [diff] [blame] | 2545 | /* use cached edid if we have one */ |
| 2546 | if (intel_connector->edid) { |
| 2547 | /* invalid edid */ |
| 2548 | if (IS_ERR(intel_connector->edid)) |
| 2549 | return 0; |
| 2550 | |
| 2551 | return intel_connector_update_modes(connector, |
| 2552 | intel_connector->edid); |
Jesse Barnes | d6f24d0 | 2012-06-14 15:28:33 -0400 | [diff] [blame] | 2553 | } |
| 2554 | |
Jani Nikula | 9cd300e | 2012-10-19 14:51:52 +0300 | [diff] [blame] | 2555 | return intel_ddc_get_modes(connector, adapter); |
Keith Packard | 8c241fe | 2011-09-28 16:38:44 -0700 | [diff] [blame] | 2556 | } |
| 2557 | |
Zhenyu Wang | a9756bb | 2010-09-19 13:09:06 +0800 | [diff] [blame] | 2558 | static enum drm_connector_status |
| 2559 | intel_dp_detect(struct drm_connector *connector, bool force) |
| 2560 | { |
| 2561 | struct intel_dp *intel_dp = intel_attached_dp(connector); |
Paulo Zanoni | d63885d | 2012-10-26 19:05:49 -0200 | [diff] [blame] | 2562 | struct intel_digital_port *intel_dig_port = dp_to_dig_port(intel_dp); |
| 2563 | struct intel_encoder *intel_encoder = &intel_dig_port->base; |
Paulo Zanoni | fa90ece | 2012-10-26 19:05:44 -0200 | [diff] [blame] | 2564 | struct drm_device *dev = connector->dev; |
Zhenyu Wang | a9756bb | 2010-09-19 13:09:06 +0800 | [diff] [blame] | 2565 | enum drm_connector_status status; |
| 2566 | struct edid *edid = NULL; |
| 2567 | |
| 2568 | intel_dp->has_audio = false; |
| 2569 | |
| 2570 | if (HAS_PCH_SPLIT(dev)) |
| 2571 | status = ironlake_dp_detect(intel_dp); |
| 2572 | else |
| 2573 | status = g4x_dp_detect(intel_dp); |
Adam Jackson | 1b9be9d | 2011-07-12 17:38:01 -0400 | [diff] [blame] | 2574 | |
Zhenyu Wang | a9756bb | 2010-09-19 13:09:06 +0800 | [diff] [blame] | 2575 | if (status != connector_status_connected) |
| 2576 | return status; |
| 2577 | |
Adam Jackson | 0d19832 | 2012-05-14 16:05:47 -0400 | [diff] [blame] | 2578 | intel_dp_probe_oui(intel_dp); |
| 2579 | |
Daniel Vetter | c3e5f67 | 2012-02-23 17:14:47 +0100 | [diff] [blame] | 2580 | if (intel_dp->force_audio != HDMI_AUDIO_AUTO) { |
| 2581 | intel_dp->has_audio = (intel_dp->force_audio == HDMI_AUDIO_ON); |
Chris Wilson | f684960 | 2010-09-19 09:29:33 +0100 | [diff] [blame] | 2582 | } else { |
Keith Packard | 8c241fe | 2011-09-28 16:38:44 -0700 | [diff] [blame] | 2583 | edid = intel_dp_get_edid(connector, &intel_dp->adapter); |
Chris Wilson | f684960 | 2010-09-19 09:29:33 +0100 | [diff] [blame] | 2584 | if (edid) { |
| 2585 | intel_dp->has_audio = drm_detect_monitor_audio(edid); |
Chris Wilson | f684960 | 2010-09-19 09:29:33 +0100 | [diff] [blame] | 2586 | kfree(edid); |
| 2587 | } |
Zhenyu Wang | a9756bb | 2010-09-19 13:09:06 +0800 | [diff] [blame] | 2588 | } |
| 2589 | |
Paulo Zanoni | d63885d | 2012-10-26 19:05:49 -0200 | [diff] [blame] | 2590 | if (intel_encoder->type != INTEL_OUTPUT_EDP) |
| 2591 | intel_encoder->type = INTEL_OUTPUT_DISPLAYPORT; |
Zhenyu Wang | a9756bb | 2010-09-19 13:09:06 +0800 | [diff] [blame] | 2592 | return connector_status_connected; |
Keith Packard | a4fc5ed | 2009-04-07 16:16:42 -0700 | [diff] [blame] | 2593 | } |
| 2594 | |
| 2595 | static int intel_dp_get_modes(struct drm_connector *connector) |
| 2596 | { |
Chris Wilson | df0e924 | 2010-09-09 16:20:55 +0100 | [diff] [blame] | 2597 | struct intel_dp *intel_dp = intel_attached_dp(connector); |
Jani Nikula | dd06f90 | 2012-10-19 14:51:50 +0300 | [diff] [blame] | 2598 | struct intel_connector *intel_connector = to_intel_connector(connector); |
Paulo Zanoni | fa90ece | 2012-10-26 19:05:44 -0200 | [diff] [blame] | 2599 | struct drm_device *dev = connector->dev; |
Zhenyu Wang | 32f9d65 | 2009-07-24 01:00:32 +0800 | [diff] [blame] | 2600 | int ret; |
Keith Packard | a4fc5ed | 2009-04-07 16:16:42 -0700 | [diff] [blame] | 2601 | |
| 2602 | /* We should parse the EDID data and find out if it has an audio sink |
| 2603 | */ |
| 2604 | |
Keith Packard | 8c241fe | 2011-09-28 16:38:44 -0700 | [diff] [blame] | 2605 | ret = intel_dp_get_edid_modes(connector, &intel_dp->adapter); |
Jani Nikula | f8779fd | 2012-10-19 14:51:48 +0300 | [diff] [blame] | 2606 | if (ret) |
Zhenyu Wang | 32f9d65 | 2009-07-24 01:00:32 +0800 | [diff] [blame] | 2607 | return ret; |
| 2608 | |
Jani Nikula | f8779fd | 2012-10-19 14:51:48 +0300 | [diff] [blame] | 2609 | /* if eDP has no EDID, fall back to fixed mode */ |
Jani Nikula | dd06f90 | 2012-10-19 14:51:50 +0300 | [diff] [blame] | 2610 | if (is_edp(intel_dp) && intel_connector->panel.fixed_mode) { |
Jani Nikula | f8779fd | 2012-10-19 14:51:48 +0300 | [diff] [blame] | 2611 | struct drm_display_mode *mode; |
Jani Nikula | dd06f90 | 2012-10-19 14:51:50 +0300 | [diff] [blame] | 2612 | mode = drm_mode_duplicate(dev, |
| 2613 | intel_connector->panel.fixed_mode); |
Jani Nikula | f8779fd | 2012-10-19 14:51:48 +0300 | [diff] [blame] | 2614 | if (mode) { |
Zhenyu Wang | 32f9d65 | 2009-07-24 01:00:32 +0800 | [diff] [blame] | 2615 | drm_mode_probed_add(connector, mode); |
| 2616 | return 1; |
| 2617 | } |
| 2618 | } |
| 2619 | return 0; |
Keith Packard | a4fc5ed | 2009-04-07 16:16:42 -0700 | [diff] [blame] | 2620 | } |
| 2621 | |
Chris Wilson | 1aad7ac | 2011-02-09 18:46:58 +0000 | [diff] [blame] | 2622 | static bool |
| 2623 | intel_dp_detect_audio(struct drm_connector *connector) |
| 2624 | { |
| 2625 | struct intel_dp *intel_dp = intel_attached_dp(connector); |
| 2626 | struct edid *edid; |
| 2627 | bool has_audio = false; |
| 2628 | |
Keith Packard | 8c241fe | 2011-09-28 16:38:44 -0700 | [diff] [blame] | 2629 | edid = intel_dp_get_edid(connector, &intel_dp->adapter); |
Chris Wilson | 1aad7ac | 2011-02-09 18:46:58 +0000 | [diff] [blame] | 2630 | if (edid) { |
| 2631 | has_audio = drm_detect_monitor_audio(edid); |
Chris Wilson | 1aad7ac | 2011-02-09 18:46:58 +0000 | [diff] [blame] | 2632 | kfree(edid); |
| 2633 | } |
| 2634 | |
| 2635 | return has_audio; |
| 2636 | } |
| 2637 | |
Chris Wilson | f684960 | 2010-09-19 09:29:33 +0100 | [diff] [blame] | 2638 | static int |
| 2639 | intel_dp_set_property(struct drm_connector *connector, |
| 2640 | struct drm_property *property, |
| 2641 | uint64_t val) |
| 2642 | { |
Chris Wilson | e953fd7 | 2011-02-21 22:23:52 +0000 | [diff] [blame] | 2643 | struct drm_i915_private *dev_priv = connector->dev->dev_private; |
Yuly Novikov | 53b4183 | 2012-10-26 12:04:00 +0300 | [diff] [blame] | 2644 | struct intel_connector *intel_connector = to_intel_connector(connector); |
Paulo Zanoni | da63a9f | 2012-10-26 19:05:46 -0200 | [diff] [blame] | 2645 | struct intel_encoder *intel_encoder = intel_attached_encoder(connector); |
| 2646 | struct intel_dp *intel_dp = enc_to_intel_dp(&intel_encoder->base); |
Chris Wilson | f684960 | 2010-09-19 09:29:33 +0100 | [diff] [blame] | 2647 | int ret; |
| 2648 | |
Rob Clark | 662595d | 2012-10-11 20:36:04 -0500 | [diff] [blame] | 2649 | ret = drm_object_property_set_value(&connector->base, property, val); |
Chris Wilson | f684960 | 2010-09-19 09:29:33 +0100 | [diff] [blame] | 2650 | if (ret) |
| 2651 | return ret; |
| 2652 | |
Chris Wilson | 3f43c48 | 2011-05-12 22:17:24 +0100 | [diff] [blame] | 2653 | if (property == dev_priv->force_audio_property) { |
Chris Wilson | 1aad7ac | 2011-02-09 18:46:58 +0000 | [diff] [blame] | 2654 | int i = val; |
| 2655 | bool has_audio; |
| 2656 | |
| 2657 | if (i == intel_dp->force_audio) |
Chris Wilson | f684960 | 2010-09-19 09:29:33 +0100 | [diff] [blame] | 2658 | return 0; |
| 2659 | |
Chris Wilson | 1aad7ac | 2011-02-09 18:46:58 +0000 | [diff] [blame] | 2660 | intel_dp->force_audio = i; |
Chris Wilson | f684960 | 2010-09-19 09:29:33 +0100 | [diff] [blame] | 2661 | |
Daniel Vetter | c3e5f67 | 2012-02-23 17:14:47 +0100 | [diff] [blame] | 2662 | if (i == HDMI_AUDIO_AUTO) |
Chris Wilson | 1aad7ac | 2011-02-09 18:46:58 +0000 | [diff] [blame] | 2663 | has_audio = intel_dp_detect_audio(connector); |
| 2664 | else |
Daniel Vetter | c3e5f67 | 2012-02-23 17:14:47 +0100 | [diff] [blame] | 2665 | has_audio = (i == HDMI_AUDIO_ON); |
Chris Wilson | 1aad7ac | 2011-02-09 18:46:58 +0000 | [diff] [blame] | 2666 | |
| 2667 | if (has_audio == intel_dp->has_audio) |
Chris Wilson | f684960 | 2010-09-19 09:29:33 +0100 | [diff] [blame] | 2668 | return 0; |
| 2669 | |
Chris Wilson | 1aad7ac | 2011-02-09 18:46:58 +0000 | [diff] [blame] | 2670 | intel_dp->has_audio = has_audio; |
Chris Wilson | f684960 | 2010-09-19 09:29:33 +0100 | [diff] [blame] | 2671 | goto done; |
| 2672 | } |
| 2673 | |
Chris Wilson | e953fd7 | 2011-02-21 22:23:52 +0000 | [diff] [blame] | 2674 | if (property == dev_priv->broadcast_rgb_property) { |
Daniel Vetter | ae4edb8 | 2013-04-22 17:07:23 +0200 | [diff] [blame] | 2675 | bool old_auto = intel_dp->color_range_auto; |
| 2676 | uint32_t old_range = intel_dp->color_range; |
| 2677 | |
Ville Syrjälä | 55bc60d | 2013-01-17 16:31:29 +0200 | [diff] [blame] | 2678 | switch (val) { |
| 2679 | case INTEL_BROADCAST_RGB_AUTO: |
| 2680 | intel_dp->color_range_auto = true; |
| 2681 | break; |
| 2682 | case INTEL_BROADCAST_RGB_FULL: |
| 2683 | intel_dp->color_range_auto = false; |
| 2684 | intel_dp->color_range = 0; |
| 2685 | break; |
| 2686 | case INTEL_BROADCAST_RGB_LIMITED: |
| 2687 | intel_dp->color_range_auto = false; |
| 2688 | intel_dp->color_range = DP_COLOR_RANGE_16_235; |
| 2689 | break; |
| 2690 | default: |
| 2691 | return -EINVAL; |
| 2692 | } |
Daniel Vetter | ae4edb8 | 2013-04-22 17:07:23 +0200 | [diff] [blame] | 2693 | |
| 2694 | if (old_auto == intel_dp->color_range_auto && |
| 2695 | old_range == intel_dp->color_range) |
| 2696 | return 0; |
| 2697 | |
Chris Wilson | e953fd7 | 2011-02-21 22:23:52 +0000 | [diff] [blame] | 2698 | goto done; |
| 2699 | } |
| 2700 | |
Yuly Novikov | 53b4183 | 2012-10-26 12:04:00 +0300 | [diff] [blame] | 2701 | if (is_edp(intel_dp) && |
| 2702 | property == connector->dev->mode_config.scaling_mode_property) { |
| 2703 | if (val == DRM_MODE_SCALE_NONE) { |
| 2704 | DRM_DEBUG_KMS("no scaling not supported\n"); |
| 2705 | return -EINVAL; |
| 2706 | } |
| 2707 | |
| 2708 | if (intel_connector->panel.fitting_mode == val) { |
| 2709 | /* the eDP scaling property is not changed */ |
| 2710 | return 0; |
| 2711 | } |
| 2712 | intel_connector->panel.fitting_mode = val; |
| 2713 | |
| 2714 | goto done; |
| 2715 | } |
| 2716 | |
Chris Wilson | f684960 | 2010-09-19 09:29:33 +0100 | [diff] [blame] | 2717 | return -EINVAL; |
| 2718 | |
| 2719 | done: |
Chris Wilson | c0c36b94 | 2012-12-19 16:08:43 +0000 | [diff] [blame] | 2720 | if (intel_encoder->base.crtc) |
| 2721 | intel_crtc_restore_mode(intel_encoder->base.crtc); |
Chris Wilson | f684960 | 2010-09-19 09:29:33 +0100 | [diff] [blame] | 2722 | |
| 2723 | return 0; |
| 2724 | } |
| 2725 | |
Keith Packard | a4fc5ed | 2009-04-07 16:16:42 -0700 | [diff] [blame] | 2726 | static void |
Paulo Zanoni | 73845ad | 2013-06-12 17:27:30 -0300 | [diff] [blame] | 2727 | intel_dp_connector_destroy(struct drm_connector *connector) |
Keith Packard | a4fc5ed | 2009-04-07 16:16:42 -0700 | [diff] [blame] | 2728 | { |
Jani Nikula | 1d50870 | 2012-10-19 14:51:49 +0300 | [diff] [blame] | 2729 | struct intel_connector *intel_connector = to_intel_connector(connector); |
Matthew Garrett | aaa6fd2 | 2011-08-12 12:11:33 +0200 | [diff] [blame] | 2730 | |
Jani Nikula | 9cd300e | 2012-10-19 14:51:52 +0300 | [diff] [blame] | 2731 | if (!IS_ERR_OR_NULL(intel_connector->edid)) |
| 2732 | kfree(intel_connector->edid); |
| 2733 | |
Paulo Zanoni | acd8db10 | 2013-06-12 17:27:23 -0300 | [diff] [blame] | 2734 | /* Can't call is_edp() since the encoder may have been destroyed |
| 2735 | * already. */ |
| 2736 | if (connector->connector_type == DRM_MODE_CONNECTOR_eDP) |
Jani Nikula | 1d50870 | 2012-10-19 14:51:49 +0300 | [diff] [blame] | 2737 | intel_panel_fini(&intel_connector->panel); |
Matthew Garrett | aaa6fd2 | 2011-08-12 12:11:33 +0200 | [diff] [blame] | 2738 | |
Keith Packard | a4fc5ed | 2009-04-07 16:16:42 -0700 | [diff] [blame] | 2739 | drm_sysfs_connector_remove(connector); |
| 2740 | drm_connector_cleanup(connector); |
Zhenyu Wang | 55f78c4 | 2010-03-29 16:13:57 +0800 | [diff] [blame] | 2741 | kfree(connector); |
Keith Packard | a4fc5ed | 2009-04-07 16:16:42 -0700 | [diff] [blame] | 2742 | } |
| 2743 | |
Paulo Zanoni | 00c09d7 | 2012-10-26 19:05:52 -0200 | [diff] [blame] | 2744 | void intel_dp_encoder_destroy(struct drm_encoder *encoder) |
Daniel Vetter | 24d0592 | 2010-08-20 18:08:28 +0200 | [diff] [blame] | 2745 | { |
Paulo Zanoni | da63a9f | 2012-10-26 19:05:46 -0200 | [diff] [blame] | 2746 | struct intel_digital_port *intel_dig_port = enc_to_dig_port(encoder); |
| 2747 | struct intel_dp *intel_dp = &intel_dig_port->dp; |
Daniel Vetter | bd17381 | 2013-03-25 11:24:10 +0100 | [diff] [blame] | 2748 | struct drm_device *dev = intel_dp_to_dev(intel_dp); |
Daniel Vetter | 24d0592 | 2010-08-20 18:08:28 +0200 | [diff] [blame] | 2749 | |
| 2750 | i2c_del_adapter(&intel_dp->adapter); |
| 2751 | drm_encoder_cleanup(encoder); |
Keith Packard | bd94315 | 2011-09-18 23:09:52 -0700 | [diff] [blame] | 2752 | if (is_edp(intel_dp)) { |
| 2753 | cancel_delayed_work_sync(&intel_dp->panel_vdd_work); |
Daniel Vetter | bd17381 | 2013-03-25 11:24:10 +0100 | [diff] [blame] | 2754 | mutex_lock(&dev->mode_config.mutex); |
Keith Packard | bd94315 | 2011-09-18 23:09:52 -0700 | [diff] [blame] | 2755 | ironlake_panel_vdd_off_sync(intel_dp); |
Daniel Vetter | bd17381 | 2013-03-25 11:24:10 +0100 | [diff] [blame] | 2756 | mutex_unlock(&dev->mode_config.mutex); |
Keith Packard | bd94315 | 2011-09-18 23:09:52 -0700 | [diff] [blame] | 2757 | } |
Paulo Zanoni | da63a9f | 2012-10-26 19:05:46 -0200 | [diff] [blame] | 2758 | kfree(intel_dig_port); |
Daniel Vetter | 24d0592 | 2010-08-20 18:08:28 +0200 | [diff] [blame] | 2759 | } |
| 2760 | |
Keith Packard | a4fc5ed | 2009-04-07 16:16:42 -0700 | [diff] [blame] | 2761 | static const struct drm_encoder_helper_funcs intel_dp_helper_funcs = { |
Keith Packard | a4fc5ed | 2009-04-07 16:16:42 -0700 | [diff] [blame] | 2762 | .mode_set = intel_dp_mode_set, |
Keith Packard | a4fc5ed | 2009-04-07 16:16:42 -0700 | [diff] [blame] | 2763 | }; |
| 2764 | |
| 2765 | static const struct drm_connector_funcs intel_dp_connector_funcs = { |
Daniel Vetter | 2bd2ad6 | 2012-09-06 22:15:41 +0200 | [diff] [blame] | 2766 | .dpms = intel_connector_dpms, |
Keith Packard | a4fc5ed | 2009-04-07 16:16:42 -0700 | [diff] [blame] | 2767 | .detect = intel_dp_detect, |
| 2768 | .fill_modes = drm_helper_probe_single_connector_modes, |
Chris Wilson | f684960 | 2010-09-19 09:29:33 +0100 | [diff] [blame] | 2769 | .set_property = intel_dp_set_property, |
Paulo Zanoni | 73845ad | 2013-06-12 17:27:30 -0300 | [diff] [blame] | 2770 | .destroy = intel_dp_connector_destroy, |
Keith Packard | a4fc5ed | 2009-04-07 16:16:42 -0700 | [diff] [blame] | 2771 | }; |
| 2772 | |
| 2773 | static const struct drm_connector_helper_funcs intel_dp_connector_helper_funcs = { |
| 2774 | .get_modes = intel_dp_get_modes, |
| 2775 | .mode_valid = intel_dp_mode_valid, |
Chris Wilson | df0e924 | 2010-09-09 16:20:55 +0100 | [diff] [blame] | 2776 | .best_encoder = intel_best_encoder, |
Keith Packard | a4fc5ed | 2009-04-07 16:16:42 -0700 | [diff] [blame] | 2777 | }; |
| 2778 | |
Keith Packard | a4fc5ed | 2009-04-07 16:16:42 -0700 | [diff] [blame] | 2779 | static const struct drm_encoder_funcs intel_dp_enc_funcs = { |
Daniel Vetter | 24d0592 | 2010-08-20 18:08:28 +0200 | [diff] [blame] | 2780 | .destroy = intel_dp_encoder_destroy, |
Keith Packard | a4fc5ed | 2009-04-07 16:16:42 -0700 | [diff] [blame] | 2781 | }; |
| 2782 | |
Chris Wilson | 995b676 | 2010-08-20 13:23:26 +0100 | [diff] [blame] | 2783 | static void |
Eric Anholt | 21d40d3 | 2010-03-25 11:11:14 -0700 | [diff] [blame] | 2784 | intel_dp_hot_plug(struct intel_encoder *intel_encoder) |
Keith Packard | c8110e5 | 2009-05-06 11:51:10 -0700 | [diff] [blame] | 2785 | { |
Paulo Zanoni | fa90ece | 2012-10-26 19:05:44 -0200 | [diff] [blame] | 2786 | struct intel_dp *intel_dp = enc_to_intel_dp(&intel_encoder->base); |
Keith Packard | c8110e5 | 2009-05-06 11:51:10 -0700 | [diff] [blame] | 2787 | |
Jesse Barnes | 885a501 | 2011-07-07 11:11:01 -0700 | [diff] [blame] | 2788 | intel_dp_check_link_status(intel_dp); |
Keith Packard | c8110e5 | 2009-05-06 11:51:10 -0700 | [diff] [blame] | 2789 | } |
| 2790 | |
Zhenyu Wang | e3421a1 | 2010-04-08 09:43:27 +0800 | [diff] [blame] | 2791 | /* Return which DP Port should be selected for Transcoder DP control */ |
| 2792 | int |
Akshay Joshi | 0206e35 | 2011-08-16 15:34:10 -0400 | [diff] [blame] | 2793 | intel_trans_dp_port_sel(struct drm_crtc *crtc) |
Zhenyu Wang | e3421a1 | 2010-04-08 09:43:27 +0800 | [diff] [blame] | 2794 | { |
| 2795 | struct drm_device *dev = crtc->dev; |
Paulo Zanoni | fa90ece | 2012-10-26 19:05:44 -0200 | [diff] [blame] | 2796 | struct intel_encoder *intel_encoder; |
| 2797 | struct intel_dp *intel_dp; |
Zhenyu Wang | e3421a1 | 2010-04-08 09:43:27 +0800 | [diff] [blame] | 2798 | |
Paulo Zanoni | fa90ece | 2012-10-26 19:05:44 -0200 | [diff] [blame] | 2799 | for_each_encoder_on_crtc(dev, crtc, intel_encoder) { |
| 2800 | intel_dp = enc_to_intel_dp(&intel_encoder->base); |
Chris Wilson | ea5b213 | 2010-08-04 13:50:23 +0100 | [diff] [blame] | 2801 | |
Paulo Zanoni | fa90ece | 2012-10-26 19:05:44 -0200 | [diff] [blame] | 2802 | if (intel_encoder->type == INTEL_OUTPUT_DISPLAYPORT || |
| 2803 | intel_encoder->type == INTEL_OUTPUT_EDP) |
Chris Wilson | ea5b213 | 2010-08-04 13:50:23 +0100 | [diff] [blame] | 2804 | return intel_dp->output_reg; |
Zhenyu Wang | e3421a1 | 2010-04-08 09:43:27 +0800 | [diff] [blame] | 2805 | } |
Chris Wilson | ea5b213 | 2010-08-04 13:50:23 +0100 | [diff] [blame] | 2806 | |
Zhenyu Wang | e3421a1 | 2010-04-08 09:43:27 +0800 | [diff] [blame] | 2807 | return -1; |
| 2808 | } |
| 2809 | |
Zhao Yakui | 36e83a1 | 2010-06-12 14:32:21 +0800 | [diff] [blame] | 2810 | /* check the VBT to see whether the eDP is on DP-D port */ |
Adam Jackson | cb0953d | 2010-07-16 14:46:29 -0400 | [diff] [blame] | 2811 | bool intel_dpd_is_edp(struct drm_device *dev) |
Zhao Yakui | 36e83a1 | 2010-06-12 14:32:21 +0800 | [diff] [blame] | 2812 | { |
| 2813 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 2814 | struct child_device_config *p_child; |
| 2815 | int i; |
| 2816 | |
Rodrigo Vivi | 41aa344 | 2013-05-09 20:03:18 -0300 | [diff] [blame] | 2817 | if (!dev_priv->vbt.child_dev_num) |
Zhao Yakui | 36e83a1 | 2010-06-12 14:32:21 +0800 | [diff] [blame] | 2818 | return false; |
| 2819 | |
Rodrigo Vivi | 41aa344 | 2013-05-09 20:03:18 -0300 | [diff] [blame] | 2820 | for (i = 0; i < dev_priv->vbt.child_dev_num; i++) { |
| 2821 | p_child = dev_priv->vbt.child_dev + i; |
Zhao Yakui | 36e83a1 | 2010-06-12 14:32:21 +0800 | [diff] [blame] | 2822 | |
| 2823 | if (p_child->dvo_port == PORT_IDPD && |
| 2824 | p_child->device_type == DEVICE_TYPE_eDP) |
| 2825 | return true; |
| 2826 | } |
| 2827 | return false; |
| 2828 | } |
| 2829 | |
Chris Wilson | f684960 | 2010-09-19 09:29:33 +0100 | [diff] [blame] | 2830 | static void |
| 2831 | intel_dp_add_properties(struct intel_dp *intel_dp, struct drm_connector *connector) |
| 2832 | { |
Yuly Novikov | 53b4183 | 2012-10-26 12:04:00 +0300 | [diff] [blame] | 2833 | struct intel_connector *intel_connector = to_intel_connector(connector); |
| 2834 | |
Chris Wilson | 3f43c48 | 2011-05-12 22:17:24 +0100 | [diff] [blame] | 2835 | intel_attach_force_audio_property(connector); |
Chris Wilson | e953fd7 | 2011-02-21 22:23:52 +0000 | [diff] [blame] | 2836 | intel_attach_broadcast_rgb_property(connector); |
Ville Syrjälä | 55bc60d | 2013-01-17 16:31:29 +0200 | [diff] [blame] | 2837 | intel_dp->color_range_auto = true; |
Yuly Novikov | 53b4183 | 2012-10-26 12:04:00 +0300 | [diff] [blame] | 2838 | |
| 2839 | if (is_edp(intel_dp)) { |
| 2840 | drm_mode_create_scaling_mode_property(connector->dev); |
Rob Clark | 6de6d84 | 2012-10-11 20:36:04 -0500 | [diff] [blame] | 2841 | drm_object_attach_property( |
| 2842 | &connector->base, |
Yuly Novikov | 53b4183 | 2012-10-26 12:04:00 +0300 | [diff] [blame] | 2843 | connector->dev->mode_config.scaling_mode_property, |
Yuly Novikov | 8e740cd | 2012-10-26 12:04:01 +0300 | [diff] [blame] | 2844 | DRM_MODE_SCALE_ASPECT); |
| 2845 | intel_connector->panel.fitting_mode = DRM_MODE_SCALE_ASPECT; |
Yuly Novikov | 53b4183 | 2012-10-26 12:04:00 +0300 | [diff] [blame] | 2846 | } |
Chris Wilson | f684960 | 2010-09-19 09:29:33 +0100 | [diff] [blame] | 2847 | } |
| 2848 | |
Daniel Vetter | 67a5456 | 2012-10-20 20:57:45 +0200 | [diff] [blame] | 2849 | static void |
| 2850 | intel_dp_init_panel_power_sequencer(struct drm_device *dev, |
Jani Nikula | f30d26e | 2013-01-16 10:53:40 +0200 | [diff] [blame] | 2851 | struct intel_dp *intel_dp, |
| 2852 | struct edp_power_seq *out) |
Daniel Vetter | 67a5456 | 2012-10-20 20:57:45 +0200 | [diff] [blame] | 2853 | { |
| 2854 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 2855 | struct edp_power_seq cur, vbt, spec, final; |
| 2856 | u32 pp_on, pp_off, pp_div, pp; |
Jesse Barnes | 453c542 | 2013-03-28 09:55:41 -0700 | [diff] [blame] | 2857 | int pp_control_reg, pp_on_reg, pp_off_reg, pp_div_reg; |
| 2858 | |
| 2859 | if (HAS_PCH_SPLIT(dev)) { |
| 2860 | pp_control_reg = PCH_PP_CONTROL; |
| 2861 | pp_on_reg = PCH_PP_ON_DELAYS; |
| 2862 | pp_off_reg = PCH_PP_OFF_DELAYS; |
| 2863 | pp_div_reg = PCH_PP_DIVISOR; |
| 2864 | } else { |
| 2865 | pp_control_reg = PIPEA_PP_CONTROL; |
| 2866 | pp_on_reg = PIPEA_PP_ON_DELAYS; |
| 2867 | pp_off_reg = PIPEA_PP_OFF_DELAYS; |
| 2868 | pp_div_reg = PIPEA_PP_DIVISOR; |
| 2869 | } |
Daniel Vetter | 67a5456 | 2012-10-20 20:57:45 +0200 | [diff] [blame] | 2870 | |
| 2871 | /* Workaround: Need to write PP_CONTROL with the unlock key as |
| 2872 | * the very first thing. */ |
Jesse Barnes | 453c542 | 2013-03-28 09:55:41 -0700 | [diff] [blame] | 2873 | pp = ironlake_get_pp_control(intel_dp); |
| 2874 | I915_WRITE(pp_control_reg, pp); |
Daniel Vetter | 67a5456 | 2012-10-20 20:57:45 +0200 | [diff] [blame] | 2875 | |
Jesse Barnes | 453c542 | 2013-03-28 09:55:41 -0700 | [diff] [blame] | 2876 | pp_on = I915_READ(pp_on_reg); |
| 2877 | pp_off = I915_READ(pp_off_reg); |
| 2878 | pp_div = I915_READ(pp_div_reg); |
Daniel Vetter | 67a5456 | 2012-10-20 20:57:45 +0200 | [diff] [blame] | 2879 | |
| 2880 | /* Pull timing values out of registers */ |
| 2881 | cur.t1_t3 = (pp_on & PANEL_POWER_UP_DELAY_MASK) >> |
| 2882 | PANEL_POWER_UP_DELAY_SHIFT; |
| 2883 | |
| 2884 | cur.t8 = (pp_on & PANEL_LIGHT_ON_DELAY_MASK) >> |
| 2885 | PANEL_LIGHT_ON_DELAY_SHIFT; |
| 2886 | |
| 2887 | cur.t9 = (pp_off & PANEL_LIGHT_OFF_DELAY_MASK) >> |
| 2888 | PANEL_LIGHT_OFF_DELAY_SHIFT; |
| 2889 | |
| 2890 | cur.t10 = (pp_off & PANEL_POWER_DOWN_DELAY_MASK) >> |
| 2891 | PANEL_POWER_DOWN_DELAY_SHIFT; |
| 2892 | |
| 2893 | cur.t11_t12 = ((pp_div & PANEL_POWER_CYCLE_DELAY_MASK) >> |
| 2894 | PANEL_POWER_CYCLE_DELAY_SHIFT) * 1000; |
| 2895 | |
| 2896 | DRM_DEBUG_KMS("cur t1_t3 %d t8 %d t9 %d t10 %d t11_t12 %d\n", |
| 2897 | cur.t1_t3, cur.t8, cur.t9, cur.t10, cur.t11_t12); |
| 2898 | |
Rodrigo Vivi | 41aa344 | 2013-05-09 20:03:18 -0300 | [diff] [blame] | 2899 | vbt = dev_priv->vbt.edp_pps; |
Daniel Vetter | 67a5456 | 2012-10-20 20:57:45 +0200 | [diff] [blame] | 2900 | |
| 2901 | /* Upper limits from eDP 1.3 spec. Note that we use the clunky units of |
| 2902 | * our hw here, which are all in 100usec. */ |
| 2903 | spec.t1_t3 = 210 * 10; |
| 2904 | spec.t8 = 50 * 10; /* no limit for t8, use t7 instead */ |
| 2905 | spec.t9 = 50 * 10; /* no limit for t9, make it symmetric with t8 */ |
| 2906 | spec.t10 = 500 * 10; |
| 2907 | /* This one is special and actually in units of 100ms, but zero |
| 2908 | * based in the hw (so we need to add 100 ms). But the sw vbt |
| 2909 | * table multiplies it with 1000 to make it in units of 100usec, |
| 2910 | * too. */ |
| 2911 | spec.t11_t12 = (510 + 100) * 10; |
| 2912 | |
| 2913 | DRM_DEBUG_KMS("vbt t1_t3 %d t8 %d t9 %d t10 %d t11_t12 %d\n", |
| 2914 | vbt.t1_t3, vbt.t8, vbt.t9, vbt.t10, vbt.t11_t12); |
| 2915 | |
| 2916 | /* Use the max of the register settings and vbt. If both are |
| 2917 | * unset, fall back to the spec limits. */ |
| 2918 | #define assign_final(field) final.field = (max(cur.field, vbt.field) == 0 ? \ |
| 2919 | spec.field : \ |
| 2920 | max(cur.field, vbt.field)) |
| 2921 | assign_final(t1_t3); |
| 2922 | assign_final(t8); |
| 2923 | assign_final(t9); |
| 2924 | assign_final(t10); |
| 2925 | assign_final(t11_t12); |
| 2926 | #undef assign_final |
| 2927 | |
| 2928 | #define get_delay(field) (DIV_ROUND_UP(final.field, 10)) |
| 2929 | intel_dp->panel_power_up_delay = get_delay(t1_t3); |
| 2930 | intel_dp->backlight_on_delay = get_delay(t8); |
| 2931 | intel_dp->backlight_off_delay = get_delay(t9); |
| 2932 | intel_dp->panel_power_down_delay = get_delay(t10); |
| 2933 | intel_dp->panel_power_cycle_delay = get_delay(t11_t12); |
| 2934 | #undef get_delay |
| 2935 | |
Jani Nikula | f30d26e | 2013-01-16 10:53:40 +0200 | [diff] [blame] | 2936 | DRM_DEBUG_KMS("panel power up delay %d, power down delay %d, power cycle delay %d\n", |
| 2937 | intel_dp->panel_power_up_delay, intel_dp->panel_power_down_delay, |
| 2938 | intel_dp->panel_power_cycle_delay); |
| 2939 | |
| 2940 | DRM_DEBUG_KMS("backlight on delay %d, off delay %d\n", |
| 2941 | intel_dp->backlight_on_delay, intel_dp->backlight_off_delay); |
| 2942 | |
| 2943 | if (out) |
| 2944 | *out = final; |
| 2945 | } |
| 2946 | |
| 2947 | static void |
| 2948 | intel_dp_init_panel_power_sequencer_registers(struct drm_device *dev, |
| 2949 | struct intel_dp *intel_dp, |
| 2950 | struct edp_power_seq *seq) |
| 2951 | { |
| 2952 | struct drm_i915_private *dev_priv = dev->dev_private; |
Jesse Barnes | 453c542 | 2013-03-28 09:55:41 -0700 | [diff] [blame] | 2953 | u32 pp_on, pp_off, pp_div, port_sel = 0; |
| 2954 | int div = HAS_PCH_SPLIT(dev) ? intel_pch_rawclk(dev) : intel_hrawclk(dev); |
| 2955 | int pp_on_reg, pp_off_reg, pp_div_reg; |
| 2956 | |
| 2957 | if (HAS_PCH_SPLIT(dev)) { |
| 2958 | pp_on_reg = PCH_PP_ON_DELAYS; |
| 2959 | pp_off_reg = PCH_PP_OFF_DELAYS; |
| 2960 | pp_div_reg = PCH_PP_DIVISOR; |
| 2961 | } else { |
| 2962 | pp_on_reg = PIPEA_PP_ON_DELAYS; |
| 2963 | pp_off_reg = PIPEA_PP_OFF_DELAYS; |
| 2964 | pp_div_reg = PIPEA_PP_DIVISOR; |
| 2965 | } |
| 2966 | |
Daniel Vetter | 67a5456 | 2012-10-20 20:57:45 +0200 | [diff] [blame] | 2967 | /* And finally store the new values in the power sequencer. */ |
Jani Nikula | f30d26e | 2013-01-16 10:53:40 +0200 | [diff] [blame] | 2968 | pp_on = (seq->t1_t3 << PANEL_POWER_UP_DELAY_SHIFT) | |
| 2969 | (seq->t8 << PANEL_LIGHT_ON_DELAY_SHIFT); |
| 2970 | pp_off = (seq->t9 << PANEL_LIGHT_OFF_DELAY_SHIFT) | |
| 2971 | (seq->t10 << PANEL_POWER_DOWN_DELAY_SHIFT); |
Daniel Vetter | 67a5456 | 2012-10-20 20:57:45 +0200 | [diff] [blame] | 2972 | /* Compute the divisor for the pp clock, simply match the Bspec |
| 2973 | * formula. */ |
Jesse Barnes | 453c542 | 2013-03-28 09:55:41 -0700 | [diff] [blame] | 2974 | pp_div = ((100 * div)/2 - 1) << PP_REFERENCE_DIVIDER_SHIFT; |
Jani Nikula | f30d26e | 2013-01-16 10:53:40 +0200 | [diff] [blame] | 2975 | pp_div |= (DIV_ROUND_UP(seq->t11_t12, 1000) |
Daniel Vetter | 67a5456 | 2012-10-20 20:57:45 +0200 | [diff] [blame] | 2976 | << PANEL_POWER_CYCLE_DELAY_SHIFT); |
| 2977 | |
| 2978 | /* Haswell doesn't have any port selection bits for the panel |
| 2979 | * power sequencer any more. */ |
Imre Deak | bc7d38a | 2013-05-16 14:40:36 +0300 | [diff] [blame] | 2980 | if (IS_VALLEYVIEW(dev)) { |
| 2981 | port_sel = I915_READ(pp_on_reg) & 0xc0000000; |
| 2982 | } else if (HAS_PCH_IBX(dev) || HAS_PCH_CPT(dev)) { |
| 2983 | if (dp_to_dig_port(intel_dp)->port == PORT_A) |
Jesse Barnes | 453c542 | 2013-03-28 09:55:41 -0700 | [diff] [blame] | 2984 | port_sel = PANEL_POWER_PORT_DP_A; |
Daniel Vetter | 67a5456 | 2012-10-20 20:57:45 +0200 | [diff] [blame] | 2985 | else |
Jesse Barnes | 453c542 | 2013-03-28 09:55:41 -0700 | [diff] [blame] | 2986 | port_sel = PANEL_POWER_PORT_DP_D; |
Daniel Vetter | 67a5456 | 2012-10-20 20:57:45 +0200 | [diff] [blame] | 2987 | } |
| 2988 | |
Jesse Barnes | 453c542 | 2013-03-28 09:55:41 -0700 | [diff] [blame] | 2989 | pp_on |= port_sel; |
| 2990 | |
| 2991 | I915_WRITE(pp_on_reg, pp_on); |
| 2992 | I915_WRITE(pp_off_reg, pp_off); |
| 2993 | I915_WRITE(pp_div_reg, pp_div); |
Daniel Vetter | 67a5456 | 2012-10-20 20:57:45 +0200 | [diff] [blame] | 2994 | |
Daniel Vetter | 67a5456 | 2012-10-20 20:57:45 +0200 | [diff] [blame] | 2995 | DRM_DEBUG_KMS("panel power sequencer register settings: PP_ON %#x, PP_OFF %#x, PP_DIV %#x\n", |
Jesse Barnes | 453c542 | 2013-03-28 09:55:41 -0700 | [diff] [blame] | 2996 | I915_READ(pp_on_reg), |
| 2997 | I915_READ(pp_off_reg), |
| 2998 | I915_READ(pp_div_reg)); |
Keith Packard | c8110e5 | 2009-05-06 11:51:10 -0700 | [diff] [blame] | 2999 | } |
| 3000 | |
Paulo Zanoni | ed92f0b | 2013-06-12 17:27:24 -0300 | [diff] [blame] | 3001 | static bool intel_edp_init_connector(struct intel_dp *intel_dp, |
| 3002 | struct intel_connector *intel_connector) |
| 3003 | { |
| 3004 | struct drm_connector *connector = &intel_connector->base; |
| 3005 | struct intel_digital_port *intel_dig_port = dp_to_dig_port(intel_dp); |
| 3006 | struct drm_device *dev = intel_dig_port->base.base.dev; |
| 3007 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 3008 | struct drm_display_mode *fixed_mode = NULL; |
| 3009 | struct edp_power_seq power_seq = { 0 }; |
| 3010 | bool has_dpcd; |
| 3011 | struct drm_display_mode *scan; |
| 3012 | struct edid *edid; |
| 3013 | |
| 3014 | if (!is_edp(intel_dp)) |
| 3015 | return true; |
| 3016 | |
| 3017 | intel_dp_init_panel_power_sequencer(dev, intel_dp, &power_seq); |
| 3018 | |
| 3019 | /* Cache DPCD and EDID for edp. */ |
| 3020 | ironlake_edp_panel_vdd_on(intel_dp); |
| 3021 | has_dpcd = intel_dp_get_dpcd(intel_dp); |
| 3022 | ironlake_edp_panel_vdd_off(intel_dp, false); |
| 3023 | |
| 3024 | if (has_dpcd) { |
| 3025 | if (intel_dp->dpcd[DP_DPCD_REV] >= 0x11) |
| 3026 | dev_priv->no_aux_handshake = |
| 3027 | intel_dp->dpcd[DP_MAX_DOWNSPREAD] & |
| 3028 | DP_NO_AUX_HANDSHAKE_LINK_TRAINING; |
| 3029 | } else { |
| 3030 | /* if this fails, presume the device is a ghost */ |
| 3031 | DRM_INFO("failed to retrieve link info, disabling eDP\n"); |
Paulo Zanoni | ed92f0b | 2013-06-12 17:27:24 -0300 | [diff] [blame] | 3032 | return false; |
| 3033 | } |
| 3034 | |
| 3035 | /* We now know it's not a ghost, init power sequence regs. */ |
| 3036 | intel_dp_init_panel_power_sequencer_registers(dev, intel_dp, |
| 3037 | &power_seq); |
| 3038 | |
| 3039 | ironlake_edp_panel_vdd_on(intel_dp); |
| 3040 | edid = drm_get_edid(connector, &intel_dp->adapter); |
| 3041 | if (edid) { |
| 3042 | if (drm_add_edid_modes(connector, edid)) { |
| 3043 | drm_mode_connector_update_edid_property(connector, |
| 3044 | edid); |
| 3045 | drm_edid_to_eld(connector, edid); |
| 3046 | } else { |
| 3047 | kfree(edid); |
| 3048 | edid = ERR_PTR(-EINVAL); |
| 3049 | } |
| 3050 | } else { |
| 3051 | edid = ERR_PTR(-ENOENT); |
| 3052 | } |
| 3053 | intel_connector->edid = edid; |
| 3054 | |
| 3055 | /* prefer fixed mode from EDID if available */ |
| 3056 | list_for_each_entry(scan, &connector->probed_modes, head) { |
| 3057 | if ((scan->type & DRM_MODE_TYPE_PREFERRED)) { |
| 3058 | fixed_mode = drm_mode_duplicate(dev, scan); |
| 3059 | break; |
| 3060 | } |
| 3061 | } |
| 3062 | |
| 3063 | /* fallback to VBT if available for eDP */ |
| 3064 | if (!fixed_mode && dev_priv->vbt.lfp_lvds_vbt_mode) { |
| 3065 | fixed_mode = drm_mode_duplicate(dev, |
| 3066 | dev_priv->vbt.lfp_lvds_vbt_mode); |
| 3067 | if (fixed_mode) |
| 3068 | fixed_mode->type |= DRM_MODE_TYPE_PREFERRED; |
| 3069 | } |
| 3070 | |
| 3071 | ironlake_edp_panel_vdd_off(intel_dp, false); |
| 3072 | |
| 3073 | intel_panel_init(&intel_connector->panel, fixed_mode); |
| 3074 | intel_panel_setup_backlight(connector); |
| 3075 | |
| 3076 | return true; |
| 3077 | } |
| 3078 | |
Paulo Zanoni | 16c2553 | 2013-06-12 17:27:25 -0300 | [diff] [blame] | 3079 | bool |
Paulo Zanoni | f0fec3f | 2012-10-26 19:05:48 -0200 | [diff] [blame] | 3080 | intel_dp_init_connector(struct intel_digital_port *intel_dig_port, |
| 3081 | struct intel_connector *intel_connector) |
Keith Packard | a4fc5ed | 2009-04-07 16:16:42 -0700 | [diff] [blame] | 3082 | { |
Paulo Zanoni | f0fec3f | 2012-10-26 19:05:48 -0200 | [diff] [blame] | 3083 | struct drm_connector *connector = &intel_connector->base; |
| 3084 | struct intel_dp *intel_dp = &intel_dig_port->dp; |
| 3085 | struct intel_encoder *intel_encoder = &intel_dig_port->base; |
| 3086 | struct drm_device *dev = intel_encoder->base.dev; |
Keith Packard | a4fc5ed | 2009-04-07 16:16:42 -0700 | [diff] [blame] | 3087 | struct drm_i915_private *dev_priv = dev->dev_private; |
Paulo Zanoni | 174edf1 | 2012-10-26 19:05:50 -0200 | [diff] [blame] | 3088 | enum port port = intel_dig_port->port; |
Zhenyu Wang | 5eb08b6 | 2009-07-24 01:00:31 +0800 | [diff] [blame] | 3089 | const char *name = NULL; |
Paulo Zanoni | b2a1475 | 2013-06-12 17:27:28 -0300 | [diff] [blame] | 3090 | int type, error; |
Keith Packard | a4fc5ed | 2009-04-07 16:16:42 -0700 | [diff] [blame] | 3091 | |
Daniel Vetter | 0767935 | 2012-09-06 22:15:42 +0200 | [diff] [blame] | 3092 | /* Preserve the current hw state. */ |
| 3093 | intel_dp->DP = I915_READ(intel_dp->output_reg); |
Jani Nikula | dd06f90 | 2012-10-19 14:51:50 +0300 | [diff] [blame] | 3094 | intel_dp->attached_connector = intel_connector; |
Chris Wilson | 3d3dc14 | 2011-02-12 10:33:12 +0000 | [diff] [blame] | 3095 | |
Imre Deak | f7d2490 | 2013-05-08 13:14:05 +0300 | [diff] [blame] | 3096 | type = DRM_MODE_CONNECTOR_DisplayPort; |
Gajanan Bhat | 19c0392 | 2012-09-27 19:13:07 +0530 | [diff] [blame] | 3097 | /* |
| 3098 | * FIXME : We need to initialize built-in panels before external panels. |
| 3099 | * For X0, DP_C is fixed as eDP. Revisit this as part of VLV eDP cleanup |
| 3100 | */ |
Imre Deak | f7d2490 | 2013-05-08 13:14:05 +0300 | [diff] [blame] | 3101 | switch (port) { |
| 3102 | case PORT_A: |
Gajanan Bhat | 19c0392 | 2012-09-27 19:13:07 +0530 | [diff] [blame] | 3103 | type = DRM_MODE_CONNECTOR_eDP; |
Imre Deak | f7d2490 | 2013-05-08 13:14:05 +0300 | [diff] [blame] | 3104 | break; |
| 3105 | case PORT_C: |
| 3106 | if (IS_VALLEYVIEW(dev)) |
| 3107 | type = DRM_MODE_CONNECTOR_eDP; |
| 3108 | break; |
| 3109 | case PORT_D: |
| 3110 | if (HAS_PCH_SPLIT(dev) && intel_dpd_is_edp(dev)) |
| 3111 | type = DRM_MODE_CONNECTOR_eDP; |
| 3112 | break; |
| 3113 | default: /* silence GCC warning */ |
| 3114 | break; |
Adam Jackson | b329530 | 2010-07-16 14:46:28 -0400 | [diff] [blame] | 3115 | } |
| 3116 | |
Imre Deak | f7d2490 | 2013-05-08 13:14:05 +0300 | [diff] [blame] | 3117 | /* |
| 3118 | * For eDP we always set the encoder type to INTEL_OUTPUT_EDP, but |
| 3119 | * for DP the encoder type can be set by the caller to |
| 3120 | * INTEL_OUTPUT_UNKNOWN for DDI, so don't rewrite it. |
| 3121 | */ |
| 3122 | if (type == DRM_MODE_CONNECTOR_eDP) |
| 3123 | intel_encoder->type = INTEL_OUTPUT_EDP; |
| 3124 | |
Imre Deak | e7281ea | 2013-05-08 13:14:08 +0300 | [diff] [blame] | 3125 | DRM_DEBUG_KMS("Adding %s connector on port %c\n", |
| 3126 | type == DRM_MODE_CONNECTOR_eDP ? "eDP" : "DP", |
| 3127 | port_name(port)); |
| 3128 | |
Adam Jackson | b329530 | 2010-07-16 14:46:28 -0400 | [diff] [blame] | 3129 | drm_connector_init(dev, connector, &intel_dp_connector_funcs, type); |
Keith Packard | a4fc5ed | 2009-04-07 16:16:42 -0700 | [diff] [blame] | 3130 | drm_connector_helper_add(connector, &intel_dp_connector_helper_funcs); |
| 3131 | |
Paulo Zanoni | f0fec3f | 2012-10-26 19:05:48 -0200 | [diff] [blame] | 3132 | connector->interlace_allowed = true; |
| 3133 | connector->doublescan_allowed = 0; |
Ma Ling | f8aed70 | 2009-08-24 13:50:24 +0800 | [diff] [blame] | 3134 | |
Daniel Vetter | 66a9278 | 2012-07-12 20:08:18 +0200 | [diff] [blame] | 3135 | INIT_DELAYED_WORK(&intel_dp->panel_vdd_work, |
| 3136 | ironlake_panel_vdd_work); |
Zhenyu Wang | 6251ec0 | 2010-01-12 05:38:32 +0800 | [diff] [blame] | 3137 | |
Chris Wilson | df0e924 | 2010-09-09 16:20:55 +0100 | [diff] [blame] | 3138 | intel_connector_attach_encoder(intel_connector, intel_encoder); |
Keith Packard | a4fc5ed | 2009-04-07 16:16:42 -0700 | [diff] [blame] | 3139 | drm_sysfs_connector_add(connector); |
| 3140 | |
Paulo Zanoni | affa935 | 2012-11-23 15:30:39 -0200 | [diff] [blame] | 3141 | if (HAS_DDI(dev)) |
Paulo Zanoni | bcbc889 | 2012-10-26 19:05:51 -0200 | [diff] [blame] | 3142 | intel_connector->get_hw_state = intel_ddi_connector_get_hw_state; |
| 3143 | else |
| 3144 | intel_connector->get_hw_state = intel_connector_get_hw_state; |
| 3145 | |
Paulo Zanoni | 9ed35ab | 2013-02-18 19:00:25 -0300 | [diff] [blame] | 3146 | intel_dp->aux_ch_ctl_reg = intel_dp->output_reg + 0x10; |
| 3147 | if (HAS_DDI(dev)) { |
| 3148 | switch (intel_dig_port->port) { |
| 3149 | case PORT_A: |
| 3150 | intel_dp->aux_ch_ctl_reg = DPA_AUX_CH_CTL; |
| 3151 | break; |
| 3152 | case PORT_B: |
| 3153 | intel_dp->aux_ch_ctl_reg = PCH_DPB_AUX_CH_CTL; |
| 3154 | break; |
| 3155 | case PORT_C: |
| 3156 | intel_dp->aux_ch_ctl_reg = PCH_DPC_AUX_CH_CTL; |
| 3157 | break; |
| 3158 | case PORT_D: |
| 3159 | intel_dp->aux_ch_ctl_reg = PCH_DPD_AUX_CH_CTL; |
| 3160 | break; |
| 3161 | default: |
| 3162 | BUG(); |
| 3163 | } |
| 3164 | } |
Daniel Vetter | e8cb455 | 2012-07-01 13:05:48 +0200 | [diff] [blame] | 3165 | |
Keith Packard | a4fc5ed | 2009-04-07 16:16:42 -0700 | [diff] [blame] | 3166 | /* Set up the DDC bus. */ |
Paulo Zanoni | ab9d7c3 | 2012-07-17 17:53:45 -0300 | [diff] [blame] | 3167 | switch (port) { |
| 3168 | case PORT_A: |
Egbert Eich | 1d843f9 | 2013-02-25 12:06:49 -0500 | [diff] [blame] | 3169 | intel_encoder->hpd_pin = HPD_PORT_A; |
Paulo Zanoni | ab9d7c3 | 2012-07-17 17:53:45 -0300 | [diff] [blame] | 3170 | name = "DPDDC-A"; |
| 3171 | break; |
| 3172 | case PORT_B: |
Egbert Eich | 1d843f9 | 2013-02-25 12:06:49 -0500 | [diff] [blame] | 3173 | intel_encoder->hpd_pin = HPD_PORT_B; |
Paulo Zanoni | ab9d7c3 | 2012-07-17 17:53:45 -0300 | [diff] [blame] | 3174 | name = "DPDDC-B"; |
| 3175 | break; |
| 3176 | case PORT_C: |
Egbert Eich | 1d843f9 | 2013-02-25 12:06:49 -0500 | [diff] [blame] | 3177 | intel_encoder->hpd_pin = HPD_PORT_C; |
Paulo Zanoni | ab9d7c3 | 2012-07-17 17:53:45 -0300 | [diff] [blame] | 3178 | name = "DPDDC-C"; |
| 3179 | break; |
| 3180 | case PORT_D: |
Egbert Eich | 1d843f9 | 2013-02-25 12:06:49 -0500 | [diff] [blame] | 3181 | intel_encoder->hpd_pin = HPD_PORT_D; |
Paulo Zanoni | ab9d7c3 | 2012-07-17 17:53:45 -0300 | [diff] [blame] | 3182 | name = "DPDDC-D"; |
| 3183 | break; |
| 3184 | default: |
Damien Lespiau | ad1c0b1 | 2013-03-07 15:30:28 +0000 | [diff] [blame] | 3185 | BUG(); |
Zhenyu Wang | 5eb08b6 | 2009-07-24 01:00:31 +0800 | [diff] [blame] | 3186 | } |
| 3187 | |
Paulo Zanoni | b2a1475 | 2013-06-12 17:27:28 -0300 | [diff] [blame] | 3188 | error = intel_dp_i2c_init(intel_dp, intel_connector, name); |
| 3189 | WARN(error, "intel_dp_i2c_init failed with error %d for port %c\n", |
| 3190 | error, port_name(port)); |
Dave Airlie | c1f0526 | 2012-08-30 11:06:18 +1000 | [diff] [blame] | 3191 | |
Paulo Zanoni | b2f246a | 2013-06-12 17:27:26 -0300 | [diff] [blame] | 3192 | if (!intel_edp_init_connector(intel_dp, intel_connector)) { |
Paulo Zanoni | 15b1d17 | 2013-06-12 17:27:27 -0300 | [diff] [blame] | 3193 | i2c_del_adapter(&intel_dp->adapter); |
| 3194 | if (is_edp(intel_dp)) { |
| 3195 | cancel_delayed_work_sync(&intel_dp->panel_vdd_work); |
| 3196 | mutex_lock(&dev->mode_config.mutex); |
| 3197 | ironlake_panel_vdd_off_sync(intel_dp); |
| 3198 | mutex_unlock(&dev->mode_config.mutex); |
| 3199 | } |
Paulo Zanoni | b2f246a | 2013-06-12 17:27:26 -0300 | [diff] [blame] | 3200 | drm_sysfs_connector_remove(connector); |
| 3201 | drm_connector_cleanup(connector); |
Paulo Zanoni | 16c2553 | 2013-06-12 17:27:25 -0300 | [diff] [blame] | 3202 | return false; |
Paulo Zanoni | b2f246a | 2013-06-12 17:27:26 -0300 | [diff] [blame] | 3203 | } |
Zhenyu Wang | 32f9d65 | 2009-07-24 01:00:32 +0800 | [diff] [blame] | 3204 | |
Chris Wilson | f684960 | 2010-09-19 09:29:33 +0100 | [diff] [blame] | 3205 | intel_dp_add_properties(intel_dp, connector); |
| 3206 | |
Keith Packard | a4fc5ed | 2009-04-07 16:16:42 -0700 | [diff] [blame] | 3207 | /* For G4X desktop chip, PEG_BAND_GAP_DATA 3:0 must first be written |
| 3208 | * 0xd. Failure to do so will result in spurious interrupts being |
| 3209 | * generated on the port when a cable is not attached. |
| 3210 | */ |
| 3211 | if (IS_G4X(dev) && !IS_GM45(dev)) { |
| 3212 | u32 temp = I915_READ(PEG_BAND_GAP_DATA); |
| 3213 | I915_WRITE(PEG_BAND_GAP_DATA, (temp & ~0xf) | 0xd); |
| 3214 | } |
Paulo Zanoni | 16c2553 | 2013-06-12 17:27:25 -0300 | [diff] [blame] | 3215 | |
| 3216 | return true; |
Keith Packard | a4fc5ed | 2009-04-07 16:16:42 -0700 | [diff] [blame] | 3217 | } |
Paulo Zanoni | f0fec3f | 2012-10-26 19:05:48 -0200 | [diff] [blame] | 3218 | |
| 3219 | void |
| 3220 | intel_dp_init(struct drm_device *dev, int output_reg, enum port port) |
| 3221 | { |
| 3222 | struct intel_digital_port *intel_dig_port; |
| 3223 | struct intel_encoder *intel_encoder; |
| 3224 | struct drm_encoder *encoder; |
| 3225 | struct intel_connector *intel_connector; |
| 3226 | |
| 3227 | intel_dig_port = kzalloc(sizeof(struct intel_digital_port), GFP_KERNEL); |
| 3228 | if (!intel_dig_port) |
| 3229 | return; |
| 3230 | |
| 3231 | intel_connector = kzalloc(sizeof(struct intel_connector), GFP_KERNEL); |
| 3232 | if (!intel_connector) { |
| 3233 | kfree(intel_dig_port); |
| 3234 | return; |
| 3235 | } |
| 3236 | |
| 3237 | intel_encoder = &intel_dig_port->base; |
| 3238 | encoder = &intel_encoder->base; |
| 3239 | |
| 3240 | drm_encoder_init(dev, &intel_encoder->base, &intel_dp_enc_funcs, |
| 3241 | DRM_MODE_ENCODER_TMDS); |
Paulo Zanoni | 00c09d7 | 2012-10-26 19:05:52 -0200 | [diff] [blame] | 3242 | drm_encoder_helper_add(&intel_encoder->base, &intel_dp_helper_funcs); |
Paulo Zanoni | f0fec3f | 2012-10-26 19:05:48 -0200 | [diff] [blame] | 3243 | |
Daniel Vetter | 5bfe2ac | 2013-03-27 00:44:55 +0100 | [diff] [blame] | 3244 | intel_encoder->compute_config = intel_dp_compute_config; |
Paulo Zanoni | 00c09d7 | 2012-10-26 19:05:52 -0200 | [diff] [blame] | 3245 | intel_encoder->enable = intel_enable_dp; |
| 3246 | intel_encoder->pre_enable = intel_pre_enable_dp; |
| 3247 | intel_encoder->disable = intel_disable_dp; |
| 3248 | intel_encoder->post_disable = intel_post_disable_dp; |
| 3249 | intel_encoder->get_hw_state = intel_dp_get_hw_state; |
Jesse Barnes | 045ac3b | 2013-05-14 17:08:26 -0700 | [diff] [blame] | 3250 | intel_encoder->get_config = intel_dp_get_config; |
Jesse Barnes | 89b667f | 2013-04-18 14:51:36 -0700 | [diff] [blame] | 3251 | if (IS_VALLEYVIEW(dev)) |
| 3252 | intel_encoder->pre_pll_enable = intel_dp_pre_pll_enable; |
Paulo Zanoni | f0fec3f | 2012-10-26 19:05:48 -0200 | [diff] [blame] | 3253 | |
Paulo Zanoni | 174edf1 | 2012-10-26 19:05:50 -0200 | [diff] [blame] | 3254 | intel_dig_port->port = port; |
Paulo Zanoni | f0fec3f | 2012-10-26 19:05:48 -0200 | [diff] [blame] | 3255 | intel_dig_port->dp.output_reg = output_reg; |
| 3256 | |
Paulo Zanoni | 00c09d7 | 2012-10-26 19:05:52 -0200 | [diff] [blame] | 3257 | intel_encoder->type = INTEL_OUTPUT_DISPLAYPORT; |
Paulo Zanoni | f0fec3f | 2012-10-26 19:05:48 -0200 | [diff] [blame] | 3258 | intel_encoder->crtc_mask = (1 << 0) | (1 << 1) | (1 << 2); |
| 3259 | intel_encoder->cloneable = false; |
| 3260 | intel_encoder->hot_plug = intel_dp_hot_plug; |
| 3261 | |
Paulo Zanoni | 15b1d17 | 2013-06-12 17:27:27 -0300 | [diff] [blame] | 3262 | if (!intel_dp_init_connector(intel_dig_port, intel_connector)) { |
| 3263 | drm_encoder_cleanup(encoder); |
| 3264 | kfree(intel_dig_port); |
Paulo Zanoni | b2f246a | 2013-06-12 17:27:26 -0300 | [diff] [blame] | 3265 | kfree(intel_connector); |
Paulo Zanoni | 15b1d17 | 2013-06-12 17:27:27 -0300 | [diff] [blame] | 3266 | } |
Paulo Zanoni | f0fec3f | 2012-10-26 19:05:48 -0200 | [diff] [blame] | 3267 | } |