Eugeni Dodonov | 45244b8 | 2012-05-09 15:37:20 -0300 | [diff] [blame] | 1 | /* |
| 2 | * Copyright © 2012 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 | * Eugeni Dodonov <eugeni.dodonov@intel.com> |
| 25 | * |
| 26 | */ |
| 27 | |
| 28 | #include "i915_drv.h" |
| 29 | #include "intel_drv.h" |
| 30 | |
| 31 | /* HDMI/DVI modes ignore everything but the last 2 items. So we share |
| 32 | * them for both DP and FDI transports, allowing those ports to |
| 33 | * automatically adapt to HDMI connections as well |
| 34 | */ |
| 35 | static const u32 hsw_ddi_translations_dp[] = { |
| 36 | 0x00FFFFFF, 0x0006000E, /* DP parameters */ |
| 37 | 0x00D75FFF, 0x0005000A, |
| 38 | 0x00C30FFF, 0x00040006, |
| 39 | 0x80AAAFFF, 0x000B0000, |
| 40 | 0x00FFFFFF, 0x0005000A, |
| 41 | 0x00D75FFF, 0x000C0004, |
| 42 | 0x80C30FFF, 0x000B0000, |
| 43 | 0x00FFFFFF, 0x00040006, |
| 44 | 0x80D75FFF, 0x000B0000, |
Eugeni Dodonov | 45244b8 | 2012-05-09 15:37:20 -0300 | [diff] [blame] | 45 | }; |
| 46 | |
| 47 | static const u32 hsw_ddi_translations_fdi[] = { |
| 48 | 0x00FFFFFF, 0x0007000E, /* FDI parameters */ |
| 49 | 0x00D75FFF, 0x000F000A, |
| 50 | 0x00C30FFF, 0x00060006, |
| 51 | 0x00AAAFFF, 0x001E0000, |
| 52 | 0x00FFFFFF, 0x000F000A, |
| 53 | 0x00D75FFF, 0x00160004, |
| 54 | 0x00C30FFF, 0x001E0000, |
| 55 | 0x00FFFFFF, 0x00060006, |
| 56 | 0x00D75FFF, 0x001E0000, |
Paulo Zanoni | 6acab15 | 2013-09-12 17:06:24 -0300 | [diff] [blame] | 57 | }; |
| 58 | |
| 59 | static const u32 hsw_ddi_translations_hdmi[] = { |
| 60 | /* Idx NT mV diff T mV diff db */ |
| 61 | 0x00FFFFFF, 0x0006000E, /* 0: 400 400 0 */ |
| 62 | 0x00E79FFF, 0x000E000C, /* 1: 400 500 2 */ |
| 63 | 0x00D75FFF, 0x0005000A, /* 2: 400 600 3.5 */ |
| 64 | 0x00FFFFFF, 0x0005000A, /* 3: 600 600 0 */ |
| 65 | 0x00E79FFF, 0x001D0007, /* 4: 600 750 2 */ |
| 66 | 0x00D75FFF, 0x000C0004, /* 5: 600 900 3.5 */ |
| 67 | 0x00FFFFFF, 0x00040006, /* 6: 800 800 0 */ |
| 68 | 0x80E79FFF, 0x00030002, /* 7: 800 1000 2 */ |
| 69 | 0x00FFFFFF, 0x00140005, /* 8: 850 850 0 */ |
| 70 | 0x00FFFFFF, 0x000C0004, /* 9: 900 900 0 */ |
| 71 | 0x00FFFFFF, 0x001C0003, /* 10: 950 950 0 */ |
| 72 | 0x80FFFFFF, 0x00030002, /* 11: 1000 1000 0 */ |
Eugeni Dodonov | 45244b8 | 2012-05-09 15:37:20 -0300 | [diff] [blame] | 73 | }; |
| 74 | |
Paulo Zanoni | 300644c | 2013-11-02 21:07:42 -0700 | [diff] [blame] | 75 | static const u32 bdw_ddi_translations_edp[] = { |
| 76 | 0x00FFFFFF, 0x00000012, /* DP parameters */ |
| 77 | 0x00EBAFFF, 0x00020011, |
| 78 | 0x00C71FFF, 0x0006000F, |
| 79 | 0x00FFFFFF, 0x00020011, |
| 80 | 0x00DB6FFF, 0x0005000F, |
| 81 | 0x00BEEFFF, 0x000A000C, |
| 82 | 0x00FFFFFF, 0x0005000F, |
| 83 | 0x00DB6FFF, 0x000A000C, |
| 84 | 0x00FFFFFF, 0x000A000C, |
| 85 | 0x00FFFFFF, 0x00140006 /* HDMI parameters 800mV 0dB*/ |
| 86 | }; |
| 87 | |
Art Runyan | e58623c | 2013-11-02 21:07:41 -0700 | [diff] [blame] | 88 | static const u32 bdw_ddi_translations_dp[] = { |
| 89 | 0x00FFFFFF, 0x0007000E, /* DP parameters */ |
| 90 | 0x00D75FFF, 0x000E000A, |
| 91 | 0x00BEFFFF, 0x00140006, |
| 92 | 0x00FFFFFF, 0x000E000A, |
| 93 | 0x00D75FFF, 0x00180004, |
| 94 | 0x80CB2FFF, 0x001B0002, |
| 95 | 0x00F7DFFF, 0x00180004, |
| 96 | 0x80D75FFF, 0x001B0002, |
| 97 | 0x80FFFFFF, 0x001B0002, |
| 98 | 0x00FFFFFF, 0x00140006 /* HDMI parameters 800mV 0dB*/ |
| 99 | }; |
| 100 | |
| 101 | static const u32 bdw_ddi_translations_fdi[] = { |
| 102 | 0x00FFFFFF, 0x0001000E, /* FDI parameters */ |
| 103 | 0x00D75FFF, 0x0004000A, |
| 104 | 0x00C30FFF, 0x00070006, |
| 105 | 0x00AAAFFF, 0x000C0000, |
| 106 | 0x00FFFFFF, 0x0004000A, |
| 107 | 0x00D75FFF, 0x00090004, |
| 108 | 0x00C30FFF, 0x000C0000, |
| 109 | 0x00FFFFFF, 0x00070006, |
| 110 | 0x00D75FFF, 0x000C0000, |
| 111 | 0x00FFFFFF, 0x00140006 /* HDMI parameters 800mV 0dB*/ |
| 112 | }; |
| 113 | |
Jani Nikula | 20f4dbe | 2013-08-30 19:40:28 +0300 | [diff] [blame] | 114 | enum port intel_ddi_get_encoder_port(struct intel_encoder *intel_encoder) |
Paulo Zanoni | fc91463 | 2012-10-05 12:05:54 -0300 | [diff] [blame] | 115 | { |
Paulo Zanoni | 0bdee30 | 2012-10-15 15:51:38 -0300 | [diff] [blame] | 116 | struct drm_encoder *encoder = &intel_encoder->base; |
Paulo Zanoni | fc91463 | 2012-10-05 12:05:54 -0300 | [diff] [blame] | 117 | int type = intel_encoder->type; |
| 118 | |
Paulo Zanoni | 174edf1 | 2012-10-26 19:05:50 -0200 | [diff] [blame] | 119 | if (type == INTEL_OUTPUT_DISPLAYPORT || type == INTEL_OUTPUT_EDP || |
Paulo Zanoni | 00c09d7 | 2012-10-26 19:05:52 -0200 | [diff] [blame] | 120 | type == INTEL_OUTPUT_HDMI || type == INTEL_OUTPUT_UNKNOWN) { |
Paulo Zanoni | 174edf1 | 2012-10-26 19:05:50 -0200 | [diff] [blame] | 121 | struct intel_digital_port *intel_dig_port = |
| 122 | enc_to_dig_port(encoder); |
| 123 | return intel_dig_port->port; |
Paulo Zanoni | 0bdee30 | 2012-10-15 15:51:38 -0300 | [diff] [blame] | 124 | |
Paulo Zanoni | fc91463 | 2012-10-05 12:05:54 -0300 | [diff] [blame] | 125 | } else if (type == INTEL_OUTPUT_ANALOG) { |
| 126 | return PORT_E; |
Paulo Zanoni | 0bdee30 | 2012-10-15 15:51:38 -0300 | [diff] [blame] | 127 | |
Paulo Zanoni | fc91463 | 2012-10-05 12:05:54 -0300 | [diff] [blame] | 128 | } else { |
| 129 | DRM_ERROR("Invalid DDI encoder type %d\n", type); |
| 130 | BUG(); |
| 131 | } |
| 132 | } |
| 133 | |
Art Runyan | e58623c | 2013-11-02 21:07:41 -0700 | [diff] [blame] | 134 | /* |
| 135 | * Starting with Haswell, DDI port buffers must be programmed with correct |
| 136 | * values in advance. The buffer values are different for FDI and DP modes, |
Eugeni Dodonov | 45244b8 | 2012-05-09 15:37:20 -0300 | [diff] [blame] | 137 | * but the HDMI/DVI fields are shared among those. So we program the DDI |
| 138 | * in either FDI or DP modes only, as HDMI connections will work with both |
| 139 | * of those |
| 140 | */ |
Paulo Zanoni | ad8d270 | 2013-08-05 17:25:56 -0300 | [diff] [blame] | 141 | static void intel_prepare_ddi_buffers(struct drm_device *dev, enum port port) |
Eugeni Dodonov | 45244b8 | 2012-05-09 15:37:20 -0300 | [diff] [blame] | 142 | { |
| 143 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 144 | u32 reg; |
| 145 | int i; |
Paulo Zanoni | 6acab15 | 2013-09-12 17:06:24 -0300 | [diff] [blame] | 146 | int hdmi_level = dev_priv->vbt.ddi_port_info[port].hdmi_level_shift; |
Art Runyan | e58623c | 2013-11-02 21:07:41 -0700 | [diff] [blame] | 147 | const u32 *ddi_translations_fdi; |
| 148 | const u32 *ddi_translations_dp; |
Paulo Zanoni | 300644c | 2013-11-02 21:07:42 -0700 | [diff] [blame] | 149 | const u32 *ddi_translations_edp; |
Art Runyan | e58623c | 2013-11-02 21:07:41 -0700 | [diff] [blame] | 150 | const u32 *ddi_translations; |
| 151 | |
| 152 | if (IS_BROADWELL(dev)) { |
| 153 | ddi_translations_fdi = bdw_ddi_translations_fdi; |
| 154 | ddi_translations_dp = bdw_ddi_translations_dp; |
Paulo Zanoni | 300644c | 2013-11-02 21:07:42 -0700 | [diff] [blame] | 155 | ddi_translations_edp = bdw_ddi_translations_edp; |
Art Runyan | e58623c | 2013-11-02 21:07:41 -0700 | [diff] [blame] | 156 | } else if (IS_HASWELL(dev)) { |
| 157 | ddi_translations_fdi = hsw_ddi_translations_fdi; |
| 158 | ddi_translations_dp = hsw_ddi_translations_dp; |
Paulo Zanoni | 300644c | 2013-11-02 21:07:42 -0700 | [diff] [blame] | 159 | ddi_translations_edp = hsw_ddi_translations_dp; |
Art Runyan | e58623c | 2013-11-02 21:07:41 -0700 | [diff] [blame] | 160 | } else { |
| 161 | WARN(1, "ddi translation table missing\n"); |
Paulo Zanoni | 300644c | 2013-11-02 21:07:42 -0700 | [diff] [blame] | 162 | ddi_translations_edp = bdw_ddi_translations_dp; |
Art Runyan | e58623c | 2013-11-02 21:07:41 -0700 | [diff] [blame] | 163 | ddi_translations_fdi = bdw_ddi_translations_fdi; |
| 164 | ddi_translations_dp = bdw_ddi_translations_dp; |
| 165 | } |
| 166 | |
Paulo Zanoni | 300644c | 2013-11-02 21:07:42 -0700 | [diff] [blame] | 167 | switch (port) { |
| 168 | case PORT_A: |
| 169 | ddi_translations = ddi_translations_edp; |
| 170 | break; |
| 171 | case PORT_B: |
| 172 | case PORT_C: |
Paulo Zanoni | 300644c | 2013-11-02 21:07:42 -0700 | [diff] [blame] | 173 | ddi_translations = ddi_translations_dp; |
| 174 | break; |
Paulo Zanoni | 77d8d00 | 2013-11-02 21:07:45 -0700 | [diff] [blame] | 175 | case PORT_D: |
Ville Syrjälä | 5d8a775 | 2013-11-01 18:22:39 +0200 | [diff] [blame] | 176 | if (intel_dp_is_edp(dev, PORT_D)) |
Paulo Zanoni | 77d8d00 | 2013-11-02 21:07:45 -0700 | [diff] [blame] | 177 | ddi_translations = ddi_translations_edp; |
| 178 | else |
| 179 | ddi_translations = ddi_translations_dp; |
| 180 | break; |
Paulo Zanoni | 300644c | 2013-11-02 21:07:42 -0700 | [diff] [blame] | 181 | case PORT_E: |
| 182 | ddi_translations = ddi_translations_fdi; |
| 183 | break; |
| 184 | default: |
| 185 | BUG(); |
| 186 | } |
Eugeni Dodonov | 45244b8 | 2012-05-09 15:37:20 -0300 | [diff] [blame] | 187 | |
Paulo Zanoni | f72d19f | 2013-08-05 17:25:55 -0300 | [diff] [blame] | 188 | for (i = 0, reg = DDI_BUF_TRANS(port); |
| 189 | i < ARRAY_SIZE(hsw_ddi_translations_fdi); i++) { |
Eugeni Dodonov | 45244b8 | 2012-05-09 15:37:20 -0300 | [diff] [blame] | 190 | I915_WRITE(reg, ddi_translations[i]); |
| 191 | reg += 4; |
| 192 | } |
Paulo Zanoni | 6acab15 | 2013-09-12 17:06:24 -0300 | [diff] [blame] | 193 | /* Entry 9 is for HDMI: */ |
| 194 | for (i = 0; i < 2; i++) { |
| 195 | I915_WRITE(reg, hsw_ddi_translations_hdmi[hdmi_level * 2 + i]); |
| 196 | reg += 4; |
| 197 | } |
Eugeni Dodonov | 45244b8 | 2012-05-09 15:37:20 -0300 | [diff] [blame] | 198 | } |
| 199 | |
| 200 | /* Program DDI buffers translations for DP. By default, program ports A-D in DP |
| 201 | * mode and port E for FDI. |
| 202 | */ |
| 203 | void intel_prepare_ddi(struct drm_device *dev) |
| 204 | { |
| 205 | int port; |
| 206 | |
Paulo Zanoni | 0d536cb | 2012-11-23 16:46:41 -0200 | [diff] [blame] | 207 | if (!HAS_DDI(dev)) |
| 208 | return; |
Eugeni Dodonov | 45244b8 | 2012-05-09 15:37:20 -0300 | [diff] [blame] | 209 | |
Paulo Zanoni | ad8d270 | 2013-08-05 17:25:56 -0300 | [diff] [blame] | 210 | for (port = PORT_A; port <= PORT_E; port++) |
| 211 | intel_prepare_ddi_buffers(dev, port); |
Eugeni Dodonov | 45244b8 | 2012-05-09 15:37:20 -0300 | [diff] [blame] | 212 | } |
Eugeni Dodonov | c82e4d2 | 2012-05-09 15:37:21 -0300 | [diff] [blame] | 213 | |
| 214 | static const long hsw_ddi_buf_ctl_values[] = { |
| 215 | DDI_BUF_EMP_400MV_0DB_HSW, |
| 216 | DDI_BUF_EMP_400MV_3_5DB_HSW, |
| 217 | DDI_BUF_EMP_400MV_6DB_HSW, |
| 218 | DDI_BUF_EMP_400MV_9_5DB_HSW, |
| 219 | DDI_BUF_EMP_600MV_0DB_HSW, |
| 220 | DDI_BUF_EMP_600MV_3_5DB_HSW, |
| 221 | DDI_BUF_EMP_600MV_6DB_HSW, |
| 222 | DDI_BUF_EMP_800MV_0DB_HSW, |
| 223 | DDI_BUF_EMP_800MV_3_5DB_HSW |
| 224 | }; |
| 225 | |
Paulo Zanoni | 248138b | 2012-11-29 11:29:31 -0200 | [diff] [blame] | 226 | static void intel_wait_ddi_buf_idle(struct drm_i915_private *dev_priv, |
| 227 | enum port port) |
| 228 | { |
| 229 | uint32_t reg = DDI_BUF_CTL(port); |
| 230 | int i; |
| 231 | |
| 232 | for (i = 0; i < 8; i++) { |
| 233 | udelay(1); |
| 234 | if (I915_READ(reg) & DDI_BUF_IS_IDLE) |
| 235 | return; |
| 236 | } |
| 237 | DRM_ERROR("Timeout waiting for DDI BUF %c idle bit\n", port_name(port)); |
| 238 | } |
Eugeni Dodonov | c82e4d2 | 2012-05-09 15:37:21 -0300 | [diff] [blame] | 239 | |
| 240 | /* Starting with Haswell, different DDI ports can work in FDI mode for |
| 241 | * connection to the PCH-located connectors. For this, it is necessary to train |
| 242 | * both the DDI port and PCH receiver for the desired DDI buffer settings. |
| 243 | * |
| 244 | * The recommended port to work in FDI mode is DDI E, which we use here. Also, |
| 245 | * please note that when FDI mode is active on DDI E, it shares 2 lines with |
| 246 | * DDI A (which is used for eDP) |
| 247 | */ |
| 248 | |
| 249 | void hsw_fdi_link_train(struct drm_crtc *crtc) |
| 250 | { |
| 251 | struct drm_device *dev = crtc->dev; |
| 252 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 253 | struct intel_crtc *intel_crtc = to_intel_crtc(crtc); |
Paulo Zanoni | 0494564 | 2012-11-01 21:00:59 -0200 | [diff] [blame] | 254 | u32 temp, i, rx_ctl_val; |
Eugeni Dodonov | c82e4d2 | 2012-05-09 15:37:21 -0300 | [diff] [blame] | 255 | |
Paulo Zanoni | 0494564 | 2012-11-01 21:00:59 -0200 | [diff] [blame] | 256 | /* Set the FDI_RX_MISC pwrdn lanes and the 2 workarounds listed at the |
| 257 | * mode set "sequence for CRT port" document: |
| 258 | * - TP1 to TP2 time with the default value |
| 259 | * - FDI delay to 90h |
Damien Lespiau | 8693a82 | 2013-05-03 18:48:11 +0100 | [diff] [blame] | 260 | * |
| 261 | * WaFDIAutoLinkSetTimingOverrride:hsw |
Paulo Zanoni | 0494564 | 2012-11-01 21:00:59 -0200 | [diff] [blame] | 262 | */ |
| 263 | I915_WRITE(_FDI_RXA_MISC, FDI_RX_PWRDN_LANE1_VAL(2) | |
| 264 | FDI_RX_PWRDN_LANE0_VAL(2) | |
| 265 | FDI_RX_TP1_TO_TP2_48 | FDI_RX_FDI_DELAY_90); |
| 266 | |
| 267 | /* Enable the PCH Receiver FDI PLL */ |
Damien Lespiau | 3e68320 | 2012-12-11 18:48:29 +0000 | [diff] [blame] | 268 | rx_ctl_val = dev_priv->fdi_rx_config | FDI_RX_ENHANCE_FRAME_ENABLE | |
Daniel Vetter | 33d29b1 | 2013-02-13 18:04:45 +0100 | [diff] [blame] | 269 | FDI_RX_PLL_ENABLE | |
Daniel Vetter | 627eb5a | 2013-04-29 19:33:42 +0200 | [diff] [blame] | 270 | FDI_DP_PORT_WIDTH(intel_crtc->config.fdi_lanes); |
Paulo Zanoni | 0494564 | 2012-11-01 21:00:59 -0200 | [diff] [blame] | 271 | I915_WRITE(_FDI_RXA_CTL, rx_ctl_val); |
| 272 | POSTING_READ(_FDI_RXA_CTL); |
| 273 | udelay(220); |
| 274 | |
| 275 | /* Switch from Rawclk to PCDclk */ |
| 276 | rx_ctl_val |= FDI_PCDCLK; |
| 277 | I915_WRITE(_FDI_RXA_CTL, rx_ctl_val); |
| 278 | |
| 279 | /* Configure Port Clock Select */ |
| 280 | I915_WRITE(PORT_CLK_SEL(PORT_E), intel_crtc->ddi_pll_sel); |
| 281 | |
| 282 | /* Start the training iterating through available voltages and emphasis, |
| 283 | * testing each value twice. */ |
| 284 | for (i = 0; i < ARRAY_SIZE(hsw_ddi_buf_ctl_values) * 2; i++) { |
Eugeni Dodonov | c82e4d2 | 2012-05-09 15:37:21 -0300 | [diff] [blame] | 285 | /* Configure DP_TP_CTL with auto-training */ |
| 286 | I915_WRITE(DP_TP_CTL(PORT_E), |
| 287 | DP_TP_CTL_FDI_AUTOTRAIN | |
| 288 | DP_TP_CTL_ENHANCED_FRAME_ENABLE | |
| 289 | DP_TP_CTL_LINK_TRAIN_PAT1 | |
| 290 | DP_TP_CTL_ENABLE); |
| 291 | |
Damien Lespiau | 876a8cd | 2012-12-11 18:48:30 +0000 | [diff] [blame] | 292 | /* Configure and enable DDI_BUF_CTL for DDI E with next voltage. |
| 293 | * DDI E does not support port reversal, the functionality is |
| 294 | * achieved on the PCH side in FDI_RX_CTL, so no need to set the |
| 295 | * port reversal bit */ |
Eugeni Dodonov | c82e4d2 | 2012-05-09 15:37:21 -0300 | [diff] [blame] | 296 | I915_WRITE(DDI_BUF_CTL(PORT_E), |
Paulo Zanoni | 0494564 | 2012-11-01 21:00:59 -0200 | [diff] [blame] | 297 | DDI_BUF_CTL_ENABLE | |
Daniel Vetter | 33d29b1 | 2013-02-13 18:04:45 +0100 | [diff] [blame] | 298 | ((intel_crtc->config.fdi_lanes - 1) << 1) | |
Paulo Zanoni | 0494564 | 2012-11-01 21:00:59 -0200 | [diff] [blame] | 299 | hsw_ddi_buf_ctl_values[i / 2]); |
| 300 | POSTING_READ(DDI_BUF_CTL(PORT_E)); |
Eugeni Dodonov | c82e4d2 | 2012-05-09 15:37:21 -0300 | [diff] [blame] | 301 | |
| 302 | udelay(600); |
| 303 | |
Paulo Zanoni | 0494564 | 2012-11-01 21:00:59 -0200 | [diff] [blame] | 304 | /* Program PCH FDI Receiver TU */ |
| 305 | I915_WRITE(_FDI_RXA_TUSIZE1, TU_SIZE(64)); |
Eugeni Dodonov | 4acf518 | 2012-07-04 20:15:16 -0300 | [diff] [blame] | 306 | |
Paulo Zanoni | 0494564 | 2012-11-01 21:00:59 -0200 | [diff] [blame] | 307 | /* Enable PCH FDI Receiver with auto-training */ |
| 308 | rx_ctl_val |= FDI_RX_ENABLE | FDI_LINK_TRAIN_AUTO; |
| 309 | I915_WRITE(_FDI_RXA_CTL, rx_ctl_val); |
| 310 | POSTING_READ(_FDI_RXA_CTL); |
| 311 | |
| 312 | /* Wait for FDI receiver lane calibration */ |
| 313 | udelay(30); |
| 314 | |
| 315 | /* Unset FDI_RX_MISC pwrdn lanes */ |
| 316 | temp = I915_READ(_FDI_RXA_MISC); |
| 317 | temp &= ~(FDI_RX_PWRDN_LANE1_MASK | FDI_RX_PWRDN_LANE0_MASK); |
| 318 | I915_WRITE(_FDI_RXA_MISC, temp); |
| 319 | POSTING_READ(_FDI_RXA_MISC); |
| 320 | |
| 321 | /* Wait for FDI auto training time */ |
| 322 | udelay(5); |
Eugeni Dodonov | c82e4d2 | 2012-05-09 15:37:21 -0300 | [diff] [blame] | 323 | |
| 324 | temp = I915_READ(DP_TP_STATUS(PORT_E)); |
| 325 | if (temp & DP_TP_STATUS_AUTOTRAIN_DONE) { |
Paulo Zanoni | 0494564 | 2012-11-01 21:00:59 -0200 | [diff] [blame] | 326 | DRM_DEBUG_KMS("FDI link training done on step %d\n", i); |
Eugeni Dodonov | c82e4d2 | 2012-05-09 15:37:21 -0300 | [diff] [blame] | 327 | |
| 328 | /* Enable normal pixel sending for FDI */ |
| 329 | I915_WRITE(DP_TP_CTL(PORT_E), |
Paulo Zanoni | 0494564 | 2012-11-01 21:00:59 -0200 | [diff] [blame] | 330 | DP_TP_CTL_FDI_AUTOTRAIN | |
| 331 | DP_TP_CTL_LINK_TRAIN_NORMAL | |
| 332 | DP_TP_CTL_ENHANCED_FRAME_ENABLE | |
| 333 | DP_TP_CTL_ENABLE); |
Eugeni Dodonov | c82e4d2 | 2012-05-09 15:37:21 -0300 | [diff] [blame] | 334 | |
Paulo Zanoni | 0494564 | 2012-11-01 21:00:59 -0200 | [diff] [blame] | 335 | return; |
Eugeni Dodonov | c82e4d2 | 2012-05-09 15:37:21 -0300 | [diff] [blame] | 336 | } |
Paulo Zanoni | 0494564 | 2012-11-01 21:00:59 -0200 | [diff] [blame] | 337 | |
Paulo Zanoni | 248138b | 2012-11-29 11:29:31 -0200 | [diff] [blame] | 338 | temp = I915_READ(DDI_BUF_CTL(PORT_E)); |
| 339 | temp &= ~DDI_BUF_CTL_ENABLE; |
| 340 | I915_WRITE(DDI_BUF_CTL(PORT_E), temp); |
| 341 | POSTING_READ(DDI_BUF_CTL(PORT_E)); |
| 342 | |
Paulo Zanoni | 0494564 | 2012-11-01 21:00:59 -0200 | [diff] [blame] | 343 | /* Disable DP_TP_CTL and FDI_RX_CTL and retry */ |
Paulo Zanoni | 248138b | 2012-11-29 11:29:31 -0200 | [diff] [blame] | 344 | temp = I915_READ(DP_TP_CTL(PORT_E)); |
| 345 | temp &= ~(DP_TP_CTL_ENABLE | DP_TP_CTL_LINK_TRAIN_MASK); |
| 346 | temp |= DP_TP_CTL_LINK_TRAIN_PAT1; |
| 347 | I915_WRITE(DP_TP_CTL(PORT_E), temp); |
| 348 | POSTING_READ(DP_TP_CTL(PORT_E)); |
| 349 | |
| 350 | intel_wait_ddi_buf_idle(dev_priv, PORT_E); |
Paulo Zanoni | 0494564 | 2012-11-01 21:00:59 -0200 | [diff] [blame] | 351 | |
| 352 | rx_ctl_val &= ~FDI_RX_ENABLE; |
| 353 | I915_WRITE(_FDI_RXA_CTL, rx_ctl_val); |
Paulo Zanoni | 248138b | 2012-11-29 11:29:31 -0200 | [diff] [blame] | 354 | POSTING_READ(_FDI_RXA_CTL); |
Paulo Zanoni | 0494564 | 2012-11-01 21:00:59 -0200 | [diff] [blame] | 355 | |
| 356 | /* Reset FDI_RX_MISC pwrdn lanes */ |
| 357 | temp = I915_READ(_FDI_RXA_MISC); |
| 358 | temp &= ~(FDI_RX_PWRDN_LANE1_MASK | FDI_RX_PWRDN_LANE0_MASK); |
| 359 | temp |= FDI_RX_PWRDN_LANE1_VAL(2) | FDI_RX_PWRDN_LANE0_VAL(2); |
| 360 | I915_WRITE(_FDI_RXA_MISC, temp); |
Paulo Zanoni | 248138b | 2012-11-29 11:29:31 -0200 | [diff] [blame] | 361 | POSTING_READ(_FDI_RXA_MISC); |
Eugeni Dodonov | c82e4d2 | 2012-05-09 15:37:21 -0300 | [diff] [blame] | 362 | } |
| 363 | |
Paulo Zanoni | 0494564 | 2012-11-01 21:00:59 -0200 | [diff] [blame] | 364 | DRM_ERROR("FDI link training failed!\n"); |
Eugeni Dodonov | c82e4d2 | 2012-05-09 15:37:21 -0300 | [diff] [blame] | 365 | } |
Eugeni Dodonov | 0e72a5b | 2012-05-09 15:37:27 -0300 | [diff] [blame] | 366 | |
Daniel Vetter | c7d8be3 | 2013-07-21 21:37:07 +0200 | [diff] [blame] | 367 | static void intel_ddi_mode_set(struct intel_encoder *encoder) |
Eugeni Dodonov | 72662e1 | 2012-05-09 15:37:31 -0300 | [diff] [blame] | 368 | { |
Daniel Vetter | c7d8be3 | 2013-07-21 21:37:07 +0200 | [diff] [blame] | 369 | struct intel_crtc *crtc = to_intel_crtc(encoder->base.crtc); |
| 370 | int port = intel_ddi_get_encoder_port(encoder); |
| 371 | int pipe = crtc->pipe; |
| 372 | int type = encoder->type; |
| 373 | struct drm_display_mode *adjusted_mode = &crtc->config.adjusted_mode; |
Eugeni Dodonov | 72662e1 | 2012-05-09 15:37:31 -0300 | [diff] [blame] | 374 | |
Damien Lespiau | bf98a72 | 2013-04-19 14:27:31 +0100 | [diff] [blame] | 375 | DRM_DEBUG_KMS("Preparing DDI mode on port %c, pipe %c\n", |
Paulo Zanoni | 247d89f | 2012-10-15 15:51:33 -0300 | [diff] [blame] | 376 | port_name(port), pipe_name(pipe)); |
Eugeni Dodonov | 72662e1 | 2012-05-09 15:37:31 -0300 | [diff] [blame] | 377 | |
Daniel Vetter | c7d8be3 | 2013-07-21 21:37:07 +0200 | [diff] [blame] | 378 | crtc->eld_vld = false; |
Paulo Zanoni | 247d89f | 2012-10-15 15:51:33 -0300 | [diff] [blame] | 379 | if (type == INTEL_OUTPUT_DISPLAYPORT || type == INTEL_OUTPUT_EDP) { |
Daniel Vetter | c7d8be3 | 2013-07-21 21:37:07 +0200 | [diff] [blame] | 380 | struct intel_dp *intel_dp = enc_to_intel_dp(&encoder->base); |
Damien Lespiau | 876a8cd | 2012-12-11 18:48:30 +0000 | [diff] [blame] | 381 | struct intel_digital_port *intel_dig_port = |
Daniel Vetter | c7d8be3 | 2013-07-21 21:37:07 +0200 | [diff] [blame] | 382 | enc_to_dig_port(&encoder->base); |
Wang Xingchao | 4f07854 | 2012-08-09 16:52:16 +0800 | [diff] [blame] | 383 | |
Stéphane Marchesin | bcf53de | 2013-07-12 13:54:41 -0700 | [diff] [blame] | 384 | intel_dp->DP = intel_dig_port->saved_port_bits | |
Damien Lespiau | 876a8cd | 2012-12-11 18:48:30 +0000 | [diff] [blame] | 385 | DDI_BUF_CTL_ENABLE | DDI_BUF_EMP_400MV_0DB_HSW; |
Daniel Vetter | 17aa6be | 2013-04-30 14:01:40 +0200 | [diff] [blame] | 386 | intel_dp->DP |= DDI_PORT_WIDTH(intel_dp->lane_count); |
Paulo Zanoni | 247d89f | 2012-10-15 15:51:33 -0300 | [diff] [blame] | 387 | |
Takashi Iwai | 8fed619 | 2012-11-19 18:06:51 +0100 | [diff] [blame] | 388 | if (intel_dp->has_audio) { |
| 389 | DRM_DEBUG_DRIVER("DP audio on pipe %c on DDI\n", |
Daniel Vetter | c7d8be3 | 2013-07-21 21:37:07 +0200 | [diff] [blame] | 390 | pipe_name(crtc->pipe)); |
Takashi Iwai | 8fed619 | 2012-11-19 18:06:51 +0100 | [diff] [blame] | 391 | |
| 392 | /* write eld */ |
| 393 | DRM_DEBUG_DRIVER("DP audio: write eld information\n"); |
Daniel Vetter | c7d8be3 | 2013-07-21 21:37:07 +0200 | [diff] [blame] | 394 | intel_write_eld(&encoder->base, adjusted_mode); |
Takashi Iwai | 8fed619 | 2012-11-19 18:06:51 +0100 | [diff] [blame] | 395 | } |
Paulo Zanoni | 247d89f | 2012-10-15 15:51:33 -0300 | [diff] [blame] | 396 | } else if (type == INTEL_OUTPUT_HDMI) { |
Daniel Vetter | c7d8be3 | 2013-07-21 21:37:07 +0200 | [diff] [blame] | 397 | struct intel_hdmi *intel_hdmi = enc_to_intel_hdmi(&encoder->base); |
Paulo Zanoni | 247d89f | 2012-10-15 15:51:33 -0300 | [diff] [blame] | 398 | |
| 399 | if (intel_hdmi->has_audio) { |
| 400 | /* Proper support for digital audio needs a new logic |
| 401 | * and a new set of registers, so we leave it for future |
| 402 | * patch bombing. |
| 403 | */ |
| 404 | DRM_DEBUG_DRIVER("HDMI audio on pipe %c on DDI\n", |
Daniel Vetter | c7d8be3 | 2013-07-21 21:37:07 +0200 | [diff] [blame] | 405 | pipe_name(crtc->pipe)); |
Paulo Zanoni | 247d89f | 2012-10-15 15:51:33 -0300 | [diff] [blame] | 406 | |
| 407 | /* write eld */ |
| 408 | DRM_DEBUG_DRIVER("HDMI audio: write eld information\n"); |
Daniel Vetter | c7d8be3 | 2013-07-21 21:37:07 +0200 | [diff] [blame] | 409 | intel_write_eld(&encoder->base, adjusted_mode); |
Paulo Zanoni | 247d89f | 2012-10-15 15:51:33 -0300 | [diff] [blame] | 410 | } |
| 411 | |
Daniel Vetter | c7d8be3 | 2013-07-21 21:37:07 +0200 | [diff] [blame] | 412 | intel_hdmi->set_infoframes(&encoder->base, adjusted_mode); |
Eugeni Dodonov | 72662e1 | 2012-05-09 15:37:31 -0300 | [diff] [blame] | 413 | } |
Paulo Zanoni | 8d9ddbc | 2012-10-05 12:05:53 -0300 | [diff] [blame] | 414 | } |
| 415 | |
| 416 | static struct intel_encoder * |
| 417 | intel_ddi_get_crtc_encoder(struct drm_crtc *crtc) |
| 418 | { |
| 419 | struct drm_device *dev = crtc->dev; |
| 420 | struct intel_crtc *intel_crtc = to_intel_crtc(crtc); |
| 421 | struct intel_encoder *intel_encoder, *ret = NULL; |
| 422 | int num_encoders = 0; |
| 423 | |
| 424 | for_each_encoder_on_crtc(dev, crtc, intel_encoder) { |
| 425 | ret = intel_encoder; |
| 426 | num_encoders++; |
| 427 | } |
| 428 | |
| 429 | if (num_encoders != 1) |
Ville Syrjälä | 84f44ce | 2013-04-17 17:48:49 +0300 | [diff] [blame] | 430 | WARN(1, "%d encoders on crtc for pipe %c\n", num_encoders, |
| 431 | pipe_name(intel_crtc->pipe)); |
Paulo Zanoni | 8d9ddbc | 2012-10-05 12:05:53 -0300 | [diff] [blame] | 432 | |
| 433 | BUG_ON(ret == NULL); |
| 434 | return ret; |
| 435 | } |
| 436 | |
Paulo Zanoni | 6441ab5 | 2012-10-05 12:05:58 -0300 | [diff] [blame] | 437 | void intel_ddi_put_crtc_pll(struct drm_crtc *crtc) |
| 438 | { |
| 439 | struct drm_i915_private *dev_priv = crtc->dev->dev_private; |
| 440 | struct intel_ddi_plls *plls = &dev_priv->ddi_plls; |
| 441 | struct intel_crtc *intel_crtc = to_intel_crtc(crtc); |
| 442 | uint32_t val; |
| 443 | |
| 444 | switch (intel_crtc->ddi_pll_sel) { |
| 445 | case PORT_CLK_SEL_SPLL: |
| 446 | plls->spll_refcount--; |
| 447 | if (plls->spll_refcount == 0) { |
| 448 | DRM_DEBUG_KMS("Disabling SPLL\n"); |
| 449 | val = I915_READ(SPLL_CTL); |
| 450 | WARN_ON(!(val & SPLL_PLL_ENABLE)); |
| 451 | I915_WRITE(SPLL_CTL, val & ~SPLL_PLL_ENABLE); |
| 452 | POSTING_READ(SPLL_CTL); |
| 453 | } |
| 454 | break; |
| 455 | case PORT_CLK_SEL_WRPLL1: |
| 456 | plls->wrpll1_refcount--; |
| 457 | if (plls->wrpll1_refcount == 0) { |
| 458 | DRM_DEBUG_KMS("Disabling WRPLL 1\n"); |
| 459 | val = I915_READ(WRPLL_CTL1); |
| 460 | WARN_ON(!(val & WRPLL_PLL_ENABLE)); |
| 461 | I915_WRITE(WRPLL_CTL1, val & ~WRPLL_PLL_ENABLE); |
| 462 | POSTING_READ(WRPLL_CTL1); |
| 463 | } |
| 464 | break; |
| 465 | case PORT_CLK_SEL_WRPLL2: |
| 466 | plls->wrpll2_refcount--; |
| 467 | if (plls->wrpll2_refcount == 0) { |
| 468 | DRM_DEBUG_KMS("Disabling WRPLL 2\n"); |
| 469 | val = I915_READ(WRPLL_CTL2); |
| 470 | WARN_ON(!(val & WRPLL_PLL_ENABLE)); |
| 471 | I915_WRITE(WRPLL_CTL2, val & ~WRPLL_PLL_ENABLE); |
| 472 | POSTING_READ(WRPLL_CTL2); |
| 473 | } |
| 474 | break; |
| 475 | } |
| 476 | |
| 477 | WARN(plls->spll_refcount < 0, "Invalid SPLL refcount\n"); |
| 478 | WARN(plls->wrpll1_refcount < 0, "Invalid WRPLL1 refcount\n"); |
| 479 | WARN(plls->wrpll2_refcount < 0, "Invalid WRPLL2 refcount\n"); |
| 480 | |
| 481 | intel_crtc->ddi_pll_sel = PORT_CLK_SEL_NONE; |
| 482 | } |
| 483 | |
Damien Lespiau | 1c0b85c | 2013-05-10 14:01:51 +0100 | [diff] [blame] | 484 | #define LC_FREQ 2700 |
| 485 | #define LC_FREQ_2K (LC_FREQ * 2000) |
| 486 | |
| 487 | #define P_MIN 2 |
| 488 | #define P_MAX 64 |
| 489 | #define P_INC 2 |
| 490 | |
| 491 | /* Constraints for PLL good behavior */ |
| 492 | #define REF_MIN 48 |
| 493 | #define REF_MAX 400 |
| 494 | #define VCO_MIN 2400 |
| 495 | #define VCO_MAX 4800 |
| 496 | |
| 497 | #define ABS_DIFF(a, b) ((a > b) ? (a - b) : (b - a)) |
| 498 | |
| 499 | struct wrpll_rnp { |
| 500 | unsigned p, n2, r2; |
| 501 | }; |
| 502 | |
| 503 | static unsigned wrpll_get_budget_for_freq(int clock) |
Paulo Zanoni | 6441ab5 | 2012-10-05 12:05:58 -0300 | [diff] [blame] | 504 | { |
Damien Lespiau | 1c0b85c | 2013-05-10 14:01:51 +0100 | [diff] [blame] | 505 | unsigned budget; |
Paulo Zanoni | 6441ab5 | 2012-10-05 12:05:58 -0300 | [diff] [blame] | 506 | |
Damien Lespiau | 1c0b85c | 2013-05-10 14:01:51 +0100 | [diff] [blame] | 507 | switch (clock) { |
| 508 | case 25175000: |
| 509 | case 25200000: |
| 510 | case 27000000: |
| 511 | case 27027000: |
| 512 | case 37762500: |
| 513 | case 37800000: |
| 514 | case 40500000: |
| 515 | case 40541000: |
| 516 | case 54000000: |
| 517 | case 54054000: |
| 518 | case 59341000: |
| 519 | case 59400000: |
| 520 | case 72000000: |
| 521 | case 74176000: |
| 522 | case 74250000: |
| 523 | case 81000000: |
| 524 | case 81081000: |
| 525 | case 89012000: |
| 526 | case 89100000: |
| 527 | case 108000000: |
| 528 | case 108108000: |
| 529 | case 111264000: |
| 530 | case 111375000: |
| 531 | case 148352000: |
| 532 | case 148500000: |
| 533 | case 162000000: |
| 534 | case 162162000: |
| 535 | case 222525000: |
| 536 | case 222750000: |
| 537 | case 296703000: |
| 538 | case 297000000: |
| 539 | budget = 0; |
| 540 | break; |
| 541 | case 233500000: |
| 542 | case 245250000: |
| 543 | case 247750000: |
| 544 | case 253250000: |
| 545 | case 298000000: |
| 546 | budget = 1500; |
| 547 | break; |
| 548 | case 169128000: |
| 549 | case 169500000: |
| 550 | case 179500000: |
| 551 | case 202000000: |
| 552 | budget = 2000; |
| 553 | break; |
| 554 | case 256250000: |
| 555 | case 262500000: |
| 556 | case 270000000: |
| 557 | case 272500000: |
| 558 | case 273750000: |
| 559 | case 280750000: |
| 560 | case 281250000: |
| 561 | case 286000000: |
| 562 | case 291750000: |
| 563 | budget = 4000; |
| 564 | break; |
| 565 | case 267250000: |
| 566 | case 268500000: |
| 567 | budget = 5000; |
| 568 | break; |
| 569 | default: |
| 570 | budget = 1000; |
| 571 | break; |
| 572 | } |
Paulo Zanoni | 6441ab5 | 2012-10-05 12:05:58 -0300 | [diff] [blame] | 573 | |
Damien Lespiau | 1c0b85c | 2013-05-10 14:01:51 +0100 | [diff] [blame] | 574 | return budget; |
| 575 | } |
Paulo Zanoni | 6441ab5 | 2012-10-05 12:05:58 -0300 | [diff] [blame] | 576 | |
Damien Lespiau | 1c0b85c | 2013-05-10 14:01:51 +0100 | [diff] [blame] | 577 | static void wrpll_update_rnp(uint64_t freq2k, unsigned budget, |
| 578 | unsigned r2, unsigned n2, unsigned p, |
| 579 | struct wrpll_rnp *best) |
| 580 | { |
| 581 | uint64_t a, b, c, d, diff, diff_best; |
Paulo Zanoni | 6441ab5 | 2012-10-05 12:05:58 -0300 | [diff] [blame] | 582 | |
Damien Lespiau | 1c0b85c | 2013-05-10 14:01:51 +0100 | [diff] [blame] | 583 | /* No best (r,n,p) yet */ |
| 584 | if (best->p == 0) { |
| 585 | best->p = p; |
| 586 | best->n2 = n2; |
| 587 | best->r2 = r2; |
| 588 | return; |
| 589 | } |
Paulo Zanoni | 6441ab5 | 2012-10-05 12:05:58 -0300 | [diff] [blame] | 590 | |
Damien Lespiau | 1c0b85c | 2013-05-10 14:01:51 +0100 | [diff] [blame] | 591 | /* |
| 592 | * Output clock is (LC_FREQ_2K / 2000) * N / (P * R), which compares to |
| 593 | * freq2k. |
| 594 | * |
| 595 | * delta = 1e6 * |
| 596 | * abs(freq2k - (LC_FREQ_2K * n2/(p * r2))) / |
| 597 | * freq2k; |
| 598 | * |
| 599 | * and we would like delta <= budget. |
| 600 | * |
| 601 | * If the discrepancy is above the PPM-based budget, always prefer to |
| 602 | * improve upon the previous solution. However, if you're within the |
| 603 | * budget, try to maximize Ref * VCO, that is N / (P * R^2). |
| 604 | */ |
| 605 | a = freq2k * budget * p * r2; |
| 606 | b = freq2k * budget * best->p * best->r2; |
| 607 | diff = ABS_DIFF((freq2k * p * r2), (LC_FREQ_2K * n2)); |
| 608 | diff_best = ABS_DIFF((freq2k * best->p * best->r2), |
| 609 | (LC_FREQ_2K * best->n2)); |
| 610 | c = 1000000 * diff; |
| 611 | d = 1000000 * diff_best; |
| 612 | |
| 613 | if (a < c && b < d) { |
| 614 | /* If both are above the budget, pick the closer */ |
| 615 | if (best->p * best->r2 * diff < p * r2 * diff_best) { |
| 616 | best->p = p; |
| 617 | best->n2 = n2; |
| 618 | best->r2 = r2; |
| 619 | } |
| 620 | } else if (a >= c && b < d) { |
| 621 | /* If A is below the threshold but B is above it? Update. */ |
| 622 | best->p = p; |
| 623 | best->n2 = n2; |
| 624 | best->r2 = r2; |
| 625 | } else if (a >= c && b >= d) { |
| 626 | /* Both are below the limit, so pick the higher n2/(r2*r2) */ |
| 627 | if (n2 * best->r2 * best->r2 > best->n2 * r2 * r2) { |
| 628 | best->p = p; |
| 629 | best->n2 = n2; |
| 630 | best->r2 = r2; |
| 631 | } |
| 632 | } |
| 633 | /* Otherwise a < c && b >= d, do nothing */ |
| 634 | } |
| 635 | |
| 636 | static void |
| 637 | intel_ddi_calculate_wrpll(int clock /* in Hz */, |
| 638 | unsigned *r2_out, unsigned *n2_out, unsigned *p_out) |
| 639 | { |
| 640 | uint64_t freq2k; |
| 641 | unsigned p, n2, r2; |
| 642 | struct wrpll_rnp best = { 0, 0, 0 }; |
| 643 | unsigned budget; |
| 644 | |
| 645 | freq2k = clock / 100; |
| 646 | |
| 647 | budget = wrpll_get_budget_for_freq(clock); |
| 648 | |
| 649 | /* Special case handling for 540 pixel clock: bypass WR PLL entirely |
| 650 | * and directly pass the LC PLL to it. */ |
| 651 | if (freq2k == 5400000) { |
| 652 | *n2_out = 2; |
| 653 | *p_out = 1; |
| 654 | *r2_out = 2; |
| 655 | return; |
| 656 | } |
| 657 | |
| 658 | /* |
| 659 | * Ref = LC_FREQ / R, where Ref is the actual reference input seen by |
| 660 | * the WR PLL. |
| 661 | * |
| 662 | * We want R so that REF_MIN <= Ref <= REF_MAX. |
| 663 | * Injecting R2 = 2 * R gives: |
| 664 | * REF_MAX * r2 > LC_FREQ * 2 and |
| 665 | * REF_MIN * r2 < LC_FREQ * 2 |
| 666 | * |
| 667 | * Which means the desired boundaries for r2 are: |
| 668 | * LC_FREQ * 2 / REF_MAX < r2 < LC_FREQ * 2 / REF_MIN |
| 669 | * |
| 670 | */ |
| 671 | for (r2 = LC_FREQ * 2 / REF_MAX + 1; |
| 672 | r2 <= LC_FREQ * 2 / REF_MIN; |
| 673 | r2++) { |
| 674 | |
| 675 | /* |
| 676 | * VCO = N * Ref, that is: VCO = N * LC_FREQ / R |
| 677 | * |
| 678 | * Once again we want VCO_MIN <= VCO <= VCO_MAX. |
| 679 | * Injecting R2 = 2 * R and N2 = 2 * N, we get: |
| 680 | * VCO_MAX * r2 > n2 * LC_FREQ and |
| 681 | * VCO_MIN * r2 < n2 * LC_FREQ) |
| 682 | * |
| 683 | * Which means the desired boundaries for n2 are: |
| 684 | * VCO_MIN * r2 / LC_FREQ < n2 < VCO_MAX * r2 / LC_FREQ |
| 685 | */ |
| 686 | for (n2 = VCO_MIN * r2 / LC_FREQ + 1; |
| 687 | n2 <= VCO_MAX * r2 / LC_FREQ; |
| 688 | n2++) { |
| 689 | |
| 690 | for (p = P_MIN; p <= P_MAX; p += P_INC) |
| 691 | wrpll_update_rnp(freq2k, budget, |
| 692 | r2, n2, p, &best); |
| 693 | } |
| 694 | } |
| 695 | |
| 696 | *n2_out = best.n2; |
| 697 | *p_out = best.p; |
| 698 | *r2_out = best.r2; |
| 699 | |
| 700 | DRM_DEBUG_KMS("WRPLL: %dHz refresh rate with p=%d, n2=%d r2=%d\n", |
| 701 | clock, *p_out, *n2_out, *r2_out); |
Paulo Zanoni | 6441ab5 | 2012-10-05 12:05:58 -0300 | [diff] [blame] | 702 | } |
| 703 | |
Daniel Vetter | ff9a675 | 2013-06-01 17:16:21 +0200 | [diff] [blame] | 704 | bool intel_ddi_pll_mode_set(struct drm_crtc *crtc) |
Paulo Zanoni | 6441ab5 | 2012-10-05 12:05:58 -0300 | [diff] [blame] | 705 | { |
| 706 | struct intel_crtc *intel_crtc = to_intel_crtc(crtc); |
| 707 | struct intel_encoder *intel_encoder = intel_ddi_get_crtc_encoder(crtc); |
Paulo Zanoni | 068759b | 2012-10-15 15:51:31 -0300 | [diff] [blame] | 708 | struct drm_encoder *encoder = &intel_encoder->base; |
Paulo Zanoni | 6441ab5 | 2012-10-05 12:05:58 -0300 | [diff] [blame] | 709 | struct drm_i915_private *dev_priv = crtc->dev->dev_private; |
| 710 | struct intel_ddi_plls *plls = &dev_priv->ddi_plls; |
| 711 | int type = intel_encoder->type; |
| 712 | enum pipe pipe = intel_crtc->pipe; |
| 713 | uint32_t reg, val; |
Daniel Vetter | ff9a675 | 2013-06-01 17:16:21 +0200 | [diff] [blame] | 714 | int clock = intel_crtc->config.port_clock; |
Paulo Zanoni | 6441ab5 | 2012-10-05 12:05:58 -0300 | [diff] [blame] | 715 | |
| 716 | /* TODO: reuse PLLs when possible (compare values) */ |
| 717 | |
| 718 | intel_ddi_put_crtc_pll(crtc); |
| 719 | |
Paulo Zanoni | 068759b | 2012-10-15 15:51:31 -0300 | [diff] [blame] | 720 | if (type == INTEL_OUTPUT_DISPLAYPORT || type == INTEL_OUTPUT_EDP) { |
| 721 | struct intel_dp *intel_dp = enc_to_intel_dp(encoder); |
| 722 | |
| 723 | switch (intel_dp->link_bw) { |
| 724 | case DP_LINK_BW_1_62: |
| 725 | intel_crtc->ddi_pll_sel = PORT_CLK_SEL_LCPLL_810; |
| 726 | break; |
| 727 | case DP_LINK_BW_2_7: |
| 728 | intel_crtc->ddi_pll_sel = PORT_CLK_SEL_LCPLL_1350; |
| 729 | break; |
| 730 | case DP_LINK_BW_5_4: |
| 731 | intel_crtc->ddi_pll_sel = PORT_CLK_SEL_LCPLL_2700; |
| 732 | break; |
| 733 | default: |
| 734 | DRM_ERROR("Link bandwidth %d unsupported\n", |
| 735 | intel_dp->link_bw); |
| 736 | return false; |
| 737 | } |
| 738 | |
| 739 | /* We don't need to turn any PLL on because we'll use LCPLL. */ |
| 740 | return true; |
| 741 | |
| 742 | } else if (type == INTEL_OUTPUT_HDMI) { |
Damien Lespiau | 1c0b85c | 2013-05-10 14:01:51 +0100 | [diff] [blame] | 743 | unsigned p, n2, r2; |
Paulo Zanoni | 6441ab5 | 2012-10-05 12:05:58 -0300 | [diff] [blame] | 744 | |
| 745 | if (plls->wrpll1_refcount == 0) { |
| 746 | DRM_DEBUG_KMS("Using WRPLL 1 on pipe %c\n", |
| 747 | pipe_name(pipe)); |
| 748 | plls->wrpll1_refcount++; |
| 749 | reg = WRPLL_CTL1; |
| 750 | intel_crtc->ddi_pll_sel = PORT_CLK_SEL_WRPLL1; |
| 751 | } else if (plls->wrpll2_refcount == 0) { |
| 752 | DRM_DEBUG_KMS("Using WRPLL 2 on pipe %c\n", |
| 753 | pipe_name(pipe)); |
| 754 | plls->wrpll2_refcount++; |
| 755 | reg = WRPLL_CTL2; |
| 756 | intel_crtc->ddi_pll_sel = PORT_CLK_SEL_WRPLL2; |
| 757 | } else { |
| 758 | DRM_ERROR("No WRPLLs available!\n"); |
| 759 | return false; |
| 760 | } |
| 761 | |
| 762 | WARN(I915_READ(reg) & WRPLL_PLL_ENABLE, |
| 763 | "WRPLL already enabled\n"); |
| 764 | |
Damien Lespiau | 1c0b85c | 2013-05-10 14:01:51 +0100 | [diff] [blame] | 765 | intel_ddi_calculate_wrpll(clock * 1000, &r2, &n2, &p); |
Paulo Zanoni | 6441ab5 | 2012-10-05 12:05:58 -0300 | [diff] [blame] | 766 | |
| 767 | val = WRPLL_PLL_ENABLE | WRPLL_PLL_SELECT_LCPLL_2700 | |
| 768 | WRPLL_DIVIDER_REFERENCE(r2) | WRPLL_DIVIDER_FEEDBACK(n2) | |
| 769 | WRPLL_DIVIDER_POST(p); |
| 770 | |
| 771 | } else if (type == INTEL_OUTPUT_ANALOG) { |
| 772 | if (plls->spll_refcount == 0) { |
| 773 | DRM_DEBUG_KMS("Using SPLL on pipe %c\n", |
| 774 | pipe_name(pipe)); |
| 775 | plls->spll_refcount++; |
| 776 | reg = SPLL_CTL; |
| 777 | intel_crtc->ddi_pll_sel = PORT_CLK_SEL_SPLL; |
Damien Lespiau | 00037c2 | 2013-03-07 15:30:25 +0000 | [diff] [blame] | 778 | } else { |
| 779 | DRM_ERROR("SPLL already in use\n"); |
| 780 | return false; |
Paulo Zanoni | 6441ab5 | 2012-10-05 12:05:58 -0300 | [diff] [blame] | 781 | } |
| 782 | |
| 783 | WARN(I915_READ(reg) & SPLL_PLL_ENABLE, |
| 784 | "SPLL already enabled\n"); |
| 785 | |
Damien Lespiau | 39bc66c | 2012-10-11 15:24:04 +0100 | [diff] [blame] | 786 | val = SPLL_PLL_ENABLE | SPLL_PLL_FREQ_1350MHz | SPLL_PLL_SSC; |
Paulo Zanoni | 6441ab5 | 2012-10-05 12:05:58 -0300 | [diff] [blame] | 787 | |
| 788 | } else { |
| 789 | WARN(1, "Invalid DDI encoder type %d\n", type); |
| 790 | return false; |
| 791 | } |
| 792 | |
| 793 | I915_WRITE(reg, val); |
| 794 | udelay(20); |
| 795 | |
| 796 | return true; |
| 797 | } |
| 798 | |
Paulo Zanoni | dae8479 | 2012-10-15 15:51:30 -0300 | [diff] [blame] | 799 | void intel_ddi_set_pipe_settings(struct drm_crtc *crtc) |
| 800 | { |
| 801 | struct drm_i915_private *dev_priv = crtc->dev->dev_private; |
| 802 | struct intel_crtc *intel_crtc = to_intel_crtc(crtc); |
| 803 | struct intel_encoder *intel_encoder = intel_ddi_get_crtc_encoder(crtc); |
Daniel Vetter | 3b117c8 | 2013-04-17 20:15:07 +0200 | [diff] [blame] | 804 | enum transcoder cpu_transcoder = intel_crtc->config.cpu_transcoder; |
Paulo Zanoni | dae8479 | 2012-10-15 15:51:30 -0300 | [diff] [blame] | 805 | int type = intel_encoder->type; |
| 806 | uint32_t temp; |
| 807 | |
| 808 | if (type == INTEL_OUTPUT_DISPLAYPORT || type == INTEL_OUTPUT_EDP) { |
| 809 | |
Paulo Zanoni | c980979 | 2012-10-23 18:30:00 -0200 | [diff] [blame] | 810 | temp = TRANS_MSA_SYNC_CLK; |
Daniel Vetter | 965e0c4 | 2013-03-27 00:44:57 +0100 | [diff] [blame] | 811 | switch (intel_crtc->config.pipe_bpp) { |
Paulo Zanoni | dae8479 | 2012-10-15 15:51:30 -0300 | [diff] [blame] | 812 | case 18: |
Paulo Zanoni | c980979 | 2012-10-23 18:30:00 -0200 | [diff] [blame] | 813 | temp |= TRANS_MSA_6_BPC; |
Paulo Zanoni | dae8479 | 2012-10-15 15:51:30 -0300 | [diff] [blame] | 814 | break; |
| 815 | case 24: |
Paulo Zanoni | c980979 | 2012-10-23 18:30:00 -0200 | [diff] [blame] | 816 | temp |= TRANS_MSA_8_BPC; |
Paulo Zanoni | dae8479 | 2012-10-15 15:51:30 -0300 | [diff] [blame] | 817 | break; |
| 818 | case 30: |
Paulo Zanoni | c980979 | 2012-10-23 18:30:00 -0200 | [diff] [blame] | 819 | temp |= TRANS_MSA_10_BPC; |
Paulo Zanoni | dae8479 | 2012-10-15 15:51:30 -0300 | [diff] [blame] | 820 | break; |
| 821 | case 36: |
Paulo Zanoni | c980979 | 2012-10-23 18:30:00 -0200 | [diff] [blame] | 822 | temp |= TRANS_MSA_12_BPC; |
Paulo Zanoni | dae8479 | 2012-10-15 15:51:30 -0300 | [diff] [blame] | 823 | break; |
| 824 | default: |
Daniel Vetter | 4e53c2e | 2013-03-27 00:44:58 +0100 | [diff] [blame] | 825 | BUG(); |
Paulo Zanoni | dae8479 | 2012-10-15 15:51:30 -0300 | [diff] [blame] | 826 | } |
Paulo Zanoni | c980979 | 2012-10-23 18:30:00 -0200 | [diff] [blame] | 827 | I915_WRITE(TRANS_MSA_MISC(cpu_transcoder), temp); |
Paulo Zanoni | dae8479 | 2012-10-15 15:51:30 -0300 | [diff] [blame] | 828 | } |
| 829 | } |
| 830 | |
Damien Lespiau | 8228c25 | 2013-03-07 15:30:27 +0000 | [diff] [blame] | 831 | void intel_ddi_enable_transcoder_func(struct drm_crtc *crtc) |
Paulo Zanoni | 8d9ddbc | 2012-10-05 12:05:53 -0300 | [diff] [blame] | 832 | { |
| 833 | struct intel_crtc *intel_crtc = to_intel_crtc(crtc); |
| 834 | struct intel_encoder *intel_encoder = intel_ddi_get_crtc_encoder(crtc); |
Paulo Zanoni | 7739c33 | 2012-10-15 15:51:29 -0300 | [diff] [blame] | 835 | struct drm_encoder *encoder = &intel_encoder->base; |
Paulo Zanoni | c7670b1 | 2013-11-02 21:07:37 -0700 | [diff] [blame] | 836 | struct drm_device *dev = crtc->dev; |
| 837 | struct drm_i915_private *dev_priv = dev->dev_private; |
Paulo Zanoni | 8d9ddbc | 2012-10-05 12:05:53 -0300 | [diff] [blame] | 838 | enum pipe pipe = intel_crtc->pipe; |
Daniel Vetter | 3b117c8 | 2013-04-17 20:15:07 +0200 | [diff] [blame] | 839 | enum transcoder cpu_transcoder = intel_crtc->config.cpu_transcoder; |
Paulo Zanoni | 174edf1 | 2012-10-26 19:05:50 -0200 | [diff] [blame] | 840 | enum port port = intel_ddi_get_encoder_port(intel_encoder); |
Paulo Zanoni | 7739c33 | 2012-10-15 15:51:29 -0300 | [diff] [blame] | 841 | int type = intel_encoder->type; |
Paulo Zanoni | 8d9ddbc | 2012-10-05 12:05:53 -0300 | [diff] [blame] | 842 | uint32_t temp; |
| 843 | |
Paulo Zanoni | ad80a81 | 2012-10-24 16:06:19 -0200 | [diff] [blame] | 844 | /* Enable TRANS_DDI_FUNC_CTL for the pipe to work in HDMI mode */ |
| 845 | temp = TRANS_DDI_FUNC_ENABLE; |
Paulo Zanoni | 174edf1 | 2012-10-26 19:05:50 -0200 | [diff] [blame] | 846 | temp |= TRANS_DDI_SELECT_PORT(port); |
Paulo Zanoni | dfcef25 | 2012-08-08 14:15:29 -0300 | [diff] [blame] | 847 | |
Daniel Vetter | 965e0c4 | 2013-03-27 00:44:57 +0100 | [diff] [blame] | 848 | switch (intel_crtc->config.pipe_bpp) { |
Paulo Zanoni | dfcef25 | 2012-08-08 14:15:29 -0300 | [diff] [blame] | 849 | case 18: |
Paulo Zanoni | ad80a81 | 2012-10-24 16:06:19 -0200 | [diff] [blame] | 850 | temp |= TRANS_DDI_BPC_6; |
Paulo Zanoni | dfcef25 | 2012-08-08 14:15:29 -0300 | [diff] [blame] | 851 | break; |
| 852 | case 24: |
Paulo Zanoni | ad80a81 | 2012-10-24 16:06:19 -0200 | [diff] [blame] | 853 | temp |= TRANS_DDI_BPC_8; |
Paulo Zanoni | dfcef25 | 2012-08-08 14:15:29 -0300 | [diff] [blame] | 854 | break; |
| 855 | case 30: |
Paulo Zanoni | ad80a81 | 2012-10-24 16:06:19 -0200 | [diff] [blame] | 856 | temp |= TRANS_DDI_BPC_10; |
Paulo Zanoni | dfcef25 | 2012-08-08 14:15:29 -0300 | [diff] [blame] | 857 | break; |
| 858 | case 36: |
Paulo Zanoni | ad80a81 | 2012-10-24 16:06:19 -0200 | [diff] [blame] | 859 | temp |= TRANS_DDI_BPC_12; |
Paulo Zanoni | dfcef25 | 2012-08-08 14:15:29 -0300 | [diff] [blame] | 860 | break; |
| 861 | default: |
Daniel Vetter | 4e53c2e | 2013-03-27 00:44:58 +0100 | [diff] [blame] | 862 | BUG(); |
Paulo Zanoni | dfcef25 | 2012-08-08 14:15:29 -0300 | [diff] [blame] | 863 | } |
Eugeni Dodonov | 72662e1 | 2012-05-09 15:37:31 -0300 | [diff] [blame] | 864 | |
Ville Syrjälä | a666283 | 2013-09-10 17:03:41 +0300 | [diff] [blame] | 865 | if (intel_crtc->config.adjusted_mode.flags & DRM_MODE_FLAG_PVSYNC) |
Paulo Zanoni | ad80a81 | 2012-10-24 16:06:19 -0200 | [diff] [blame] | 866 | temp |= TRANS_DDI_PVSYNC; |
Ville Syrjälä | a666283 | 2013-09-10 17:03:41 +0300 | [diff] [blame] | 867 | if (intel_crtc->config.adjusted_mode.flags & DRM_MODE_FLAG_PHSYNC) |
Paulo Zanoni | ad80a81 | 2012-10-24 16:06:19 -0200 | [diff] [blame] | 868 | temp |= TRANS_DDI_PHSYNC; |
Paulo Zanoni | f63eb7c4 | 2012-08-08 14:15:28 -0300 | [diff] [blame] | 869 | |
Paulo Zanoni | e6f0bfc | 2012-10-23 18:30:04 -0200 | [diff] [blame] | 870 | if (cpu_transcoder == TRANSCODER_EDP) { |
| 871 | switch (pipe) { |
| 872 | case PIPE_A: |
Paulo Zanoni | c7670b1 | 2013-11-02 21:07:37 -0700 | [diff] [blame] | 873 | /* On Haswell, can only use the always-on power well for |
| 874 | * eDP when not using the panel fitter, and when not |
| 875 | * using motion blur mitigation (which we don't |
| 876 | * support). */ |
| 877 | if (IS_HASWELL(dev) && intel_crtc->config.pch_pfit.enabled) |
Daniel Vetter | d6dd9eb | 2013-01-29 16:35:20 -0200 | [diff] [blame] | 878 | temp |= TRANS_DDI_EDP_INPUT_A_ONOFF; |
| 879 | else |
| 880 | temp |= TRANS_DDI_EDP_INPUT_A_ON; |
Paulo Zanoni | e6f0bfc | 2012-10-23 18:30:04 -0200 | [diff] [blame] | 881 | break; |
| 882 | case PIPE_B: |
| 883 | temp |= TRANS_DDI_EDP_INPUT_B_ONOFF; |
| 884 | break; |
| 885 | case PIPE_C: |
| 886 | temp |= TRANS_DDI_EDP_INPUT_C_ONOFF; |
| 887 | break; |
| 888 | default: |
| 889 | BUG(); |
| 890 | break; |
| 891 | } |
| 892 | } |
| 893 | |
Paulo Zanoni | 7739c33 | 2012-10-15 15:51:29 -0300 | [diff] [blame] | 894 | if (type == INTEL_OUTPUT_HDMI) { |
| 895 | struct intel_hdmi *intel_hdmi = enc_to_intel_hdmi(encoder); |
Eugeni Dodonov | 72662e1 | 2012-05-09 15:37:31 -0300 | [diff] [blame] | 896 | |
Paulo Zanoni | 8d9ddbc | 2012-10-05 12:05:53 -0300 | [diff] [blame] | 897 | if (intel_hdmi->has_hdmi_sink) |
Paulo Zanoni | ad80a81 | 2012-10-24 16:06:19 -0200 | [diff] [blame] | 898 | temp |= TRANS_DDI_MODE_SELECT_HDMI; |
Paulo Zanoni | 8d9ddbc | 2012-10-05 12:05:53 -0300 | [diff] [blame] | 899 | else |
Paulo Zanoni | ad80a81 | 2012-10-24 16:06:19 -0200 | [diff] [blame] | 900 | temp |= TRANS_DDI_MODE_SELECT_DVI; |
Paulo Zanoni | 8d9ddbc | 2012-10-05 12:05:53 -0300 | [diff] [blame] | 901 | |
Paulo Zanoni | 7739c33 | 2012-10-15 15:51:29 -0300 | [diff] [blame] | 902 | } else if (type == INTEL_OUTPUT_ANALOG) { |
Paulo Zanoni | ad80a81 | 2012-10-24 16:06:19 -0200 | [diff] [blame] | 903 | temp |= TRANS_DDI_MODE_SELECT_FDI; |
Daniel Vetter | 33d29b1 | 2013-02-13 18:04:45 +0100 | [diff] [blame] | 904 | temp |= (intel_crtc->config.fdi_lanes - 1) << 1; |
Paulo Zanoni | 7739c33 | 2012-10-15 15:51:29 -0300 | [diff] [blame] | 905 | |
| 906 | } else if (type == INTEL_OUTPUT_DISPLAYPORT || |
| 907 | type == INTEL_OUTPUT_EDP) { |
| 908 | struct intel_dp *intel_dp = enc_to_intel_dp(encoder); |
| 909 | |
Paulo Zanoni | ad80a81 | 2012-10-24 16:06:19 -0200 | [diff] [blame] | 910 | temp |= TRANS_DDI_MODE_SELECT_DP_SST; |
Paulo Zanoni | 7739c33 | 2012-10-15 15:51:29 -0300 | [diff] [blame] | 911 | |
Daniel Vetter | 17aa6be | 2013-04-30 14:01:40 +0200 | [diff] [blame] | 912 | temp |= DDI_PORT_WIDTH(intel_dp->lane_count); |
Paulo Zanoni | 8d9ddbc | 2012-10-05 12:05:53 -0300 | [diff] [blame] | 913 | } else { |
Ville Syrjälä | 84f44ce | 2013-04-17 17:48:49 +0300 | [diff] [blame] | 914 | WARN(1, "Invalid encoder type %d for pipe %c\n", |
| 915 | intel_encoder->type, pipe_name(pipe)); |
Paulo Zanoni | 8d9ddbc | 2012-10-05 12:05:53 -0300 | [diff] [blame] | 916 | } |
| 917 | |
Paulo Zanoni | ad80a81 | 2012-10-24 16:06:19 -0200 | [diff] [blame] | 918 | I915_WRITE(TRANS_DDI_FUNC_CTL(cpu_transcoder), temp); |
Paulo Zanoni | 8d9ddbc | 2012-10-05 12:05:53 -0300 | [diff] [blame] | 919 | } |
| 920 | |
Paulo Zanoni | ad80a81 | 2012-10-24 16:06:19 -0200 | [diff] [blame] | 921 | void intel_ddi_disable_transcoder_func(struct drm_i915_private *dev_priv, |
| 922 | enum transcoder cpu_transcoder) |
Paulo Zanoni | 8d9ddbc | 2012-10-05 12:05:53 -0300 | [diff] [blame] | 923 | { |
Paulo Zanoni | ad80a81 | 2012-10-24 16:06:19 -0200 | [diff] [blame] | 924 | uint32_t reg = TRANS_DDI_FUNC_CTL(cpu_transcoder); |
Paulo Zanoni | 8d9ddbc | 2012-10-05 12:05:53 -0300 | [diff] [blame] | 925 | uint32_t val = I915_READ(reg); |
| 926 | |
Paulo Zanoni | ad80a81 | 2012-10-24 16:06:19 -0200 | [diff] [blame] | 927 | val &= ~(TRANS_DDI_FUNC_ENABLE | TRANS_DDI_PORT_MASK); |
| 928 | val |= TRANS_DDI_PORT_NONE; |
Paulo Zanoni | 8d9ddbc | 2012-10-05 12:05:53 -0300 | [diff] [blame] | 929 | I915_WRITE(reg, val); |
Eugeni Dodonov | 72662e1 | 2012-05-09 15:37:31 -0300 | [diff] [blame] | 930 | } |
| 931 | |
Paulo Zanoni | bcbc889 | 2012-10-26 19:05:51 -0200 | [diff] [blame] | 932 | bool intel_ddi_connector_get_hw_state(struct intel_connector *intel_connector) |
| 933 | { |
| 934 | struct drm_device *dev = intel_connector->base.dev; |
| 935 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 936 | struct intel_encoder *intel_encoder = intel_connector->encoder; |
| 937 | int type = intel_connector->base.connector_type; |
| 938 | enum port port = intel_ddi_get_encoder_port(intel_encoder); |
| 939 | enum pipe pipe = 0; |
| 940 | enum transcoder cpu_transcoder; |
| 941 | uint32_t tmp; |
| 942 | |
| 943 | if (!intel_encoder->get_hw_state(intel_encoder, &pipe)) |
| 944 | return false; |
| 945 | |
| 946 | if (port == PORT_A) |
| 947 | cpu_transcoder = TRANSCODER_EDP; |
| 948 | else |
Daniel Vetter | 1a240d4 | 2012-11-29 22:18:51 +0100 | [diff] [blame] | 949 | cpu_transcoder = (enum transcoder) pipe; |
Paulo Zanoni | bcbc889 | 2012-10-26 19:05:51 -0200 | [diff] [blame] | 950 | |
| 951 | tmp = I915_READ(TRANS_DDI_FUNC_CTL(cpu_transcoder)); |
| 952 | |
| 953 | switch (tmp & TRANS_DDI_MODE_SELECT_MASK) { |
| 954 | case TRANS_DDI_MODE_SELECT_HDMI: |
| 955 | case TRANS_DDI_MODE_SELECT_DVI: |
| 956 | return (type == DRM_MODE_CONNECTOR_HDMIA); |
| 957 | |
| 958 | case TRANS_DDI_MODE_SELECT_DP_SST: |
| 959 | if (type == DRM_MODE_CONNECTOR_eDP) |
| 960 | return true; |
| 961 | case TRANS_DDI_MODE_SELECT_DP_MST: |
| 962 | return (type == DRM_MODE_CONNECTOR_DisplayPort); |
| 963 | |
| 964 | case TRANS_DDI_MODE_SELECT_FDI: |
| 965 | return (type == DRM_MODE_CONNECTOR_VGA); |
| 966 | |
| 967 | default: |
| 968 | return false; |
| 969 | } |
| 970 | } |
| 971 | |
Daniel Vetter | 85234cd | 2012-07-02 13:27:29 +0200 | [diff] [blame] | 972 | bool intel_ddi_get_hw_state(struct intel_encoder *encoder, |
| 973 | enum pipe *pipe) |
| 974 | { |
| 975 | struct drm_device *dev = encoder->base.dev; |
| 976 | struct drm_i915_private *dev_priv = dev->dev_private; |
Paulo Zanoni | fe43d3f | 2012-10-15 15:51:39 -0300 | [diff] [blame] | 977 | enum port port = intel_ddi_get_encoder_port(encoder); |
Daniel Vetter | 85234cd | 2012-07-02 13:27:29 +0200 | [diff] [blame] | 978 | u32 tmp; |
| 979 | int i; |
| 980 | |
Paulo Zanoni | fe43d3f | 2012-10-15 15:51:39 -0300 | [diff] [blame] | 981 | tmp = I915_READ(DDI_BUF_CTL(port)); |
Daniel Vetter | 85234cd | 2012-07-02 13:27:29 +0200 | [diff] [blame] | 982 | |
| 983 | if (!(tmp & DDI_BUF_CTL_ENABLE)) |
| 984 | return false; |
| 985 | |
Paulo Zanoni | ad80a81 | 2012-10-24 16:06:19 -0200 | [diff] [blame] | 986 | if (port == PORT_A) { |
| 987 | tmp = I915_READ(TRANS_DDI_FUNC_CTL(TRANSCODER_EDP)); |
Daniel Vetter | 85234cd | 2012-07-02 13:27:29 +0200 | [diff] [blame] | 988 | |
Paulo Zanoni | ad80a81 | 2012-10-24 16:06:19 -0200 | [diff] [blame] | 989 | switch (tmp & TRANS_DDI_EDP_INPUT_MASK) { |
| 990 | case TRANS_DDI_EDP_INPUT_A_ON: |
| 991 | case TRANS_DDI_EDP_INPUT_A_ONOFF: |
| 992 | *pipe = PIPE_A; |
| 993 | break; |
| 994 | case TRANS_DDI_EDP_INPUT_B_ONOFF: |
| 995 | *pipe = PIPE_B; |
| 996 | break; |
| 997 | case TRANS_DDI_EDP_INPUT_C_ONOFF: |
| 998 | *pipe = PIPE_C; |
| 999 | break; |
| 1000 | } |
| 1001 | |
| 1002 | return true; |
| 1003 | } else { |
| 1004 | for (i = TRANSCODER_A; i <= TRANSCODER_C; i++) { |
| 1005 | tmp = I915_READ(TRANS_DDI_FUNC_CTL(i)); |
| 1006 | |
| 1007 | if ((tmp & TRANS_DDI_PORT_MASK) |
| 1008 | == TRANS_DDI_SELECT_PORT(port)) { |
| 1009 | *pipe = i; |
| 1010 | return true; |
| 1011 | } |
Daniel Vetter | 85234cd | 2012-07-02 13:27:29 +0200 | [diff] [blame] | 1012 | } |
| 1013 | } |
| 1014 | |
Ville Syrjälä | 84f44ce | 2013-04-17 17:48:49 +0300 | [diff] [blame] | 1015 | DRM_DEBUG_KMS("No pipe for ddi port %c found\n", port_name(port)); |
Daniel Vetter | 85234cd | 2012-07-02 13:27:29 +0200 | [diff] [blame] | 1016 | |
Jesse Barnes | 22f9fe5 | 2013-04-02 10:03:55 -0700 | [diff] [blame] | 1017 | return false; |
Daniel Vetter | 85234cd | 2012-07-02 13:27:29 +0200 | [diff] [blame] | 1018 | } |
| 1019 | |
Paulo Zanoni | 6441ab5 | 2012-10-05 12:05:58 -0300 | [diff] [blame] | 1020 | static uint32_t intel_ddi_get_crtc_pll(struct drm_i915_private *dev_priv, |
| 1021 | enum pipe pipe) |
| 1022 | { |
| 1023 | uint32_t temp, ret; |
Damien Lespiau | a42f704 | 2013-03-25 15:16:14 +0000 | [diff] [blame] | 1024 | enum port port = I915_MAX_PORTS; |
Paulo Zanoni | ad80a81 | 2012-10-24 16:06:19 -0200 | [diff] [blame] | 1025 | enum transcoder cpu_transcoder = intel_pipe_to_cpu_transcoder(dev_priv, |
| 1026 | pipe); |
Paulo Zanoni | 6441ab5 | 2012-10-05 12:05:58 -0300 | [diff] [blame] | 1027 | int i; |
| 1028 | |
Paulo Zanoni | ad80a81 | 2012-10-24 16:06:19 -0200 | [diff] [blame] | 1029 | if (cpu_transcoder == TRANSCODER_EDP) { |
| 1030 | port = PORT_A; |
| 1031 | } else { |
| 1032 | temp = I915_READ(TRANS_DDI_FUNC_CTL(cpu_transcoder)); |
| 1033 | temp &= TRANS_DDI_PORT_MASK; |
| 1034 | |
| 1035 | for (i = PORT_B; i <= PORT_E; i++) |
| 1036 | if (temp == TRANS_DDI_SELECT_PORT(i)) |
| 1037 | port = i; |
| 1038 | } |
Paulo Zanoni | 6441ab5 | 2012-10-05 12:05:58 -0300 | [diff] [blame] | 1039 | |
Damien Lespiau | a42f704 | 2013-03-25 15:16:14 +0000 | [diff] [blame] | 1040 | if (port == I915_MAX_PORTS) { |
| 1041 | WARN(1, "Pipe %c enabled on an unknown port\n", |
| 1042 | pipe_name(pipe)); |
| 1043 | ret = PORT_CLK_SEL_NONE; |
| 1044 | } else { |
| 1045 | ret = I915_READ(PORT_CLK_SEL(port)); |
| 1046 | DRM_DEBUG_KMS("Pipe %c connected to port %c using clock " |
| 1047 | "0x%08x\n", pipe_name(pipe), port_name(port), |
| 1048 | ret); |
| 1049 | } |
Paulo Zanoni | 6441ab5 | 2012-10-05 12:05:58 -0300 | [diff] [blame] | 1050 | |
| 1051 | return ret; |
| 1052 | } |
| 1053 | |
| 1054 | void intel_ddi_setup_hw_pll_state(struct drm_device *dev) |
| 1055 | { |
| 1056 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 1057 | enum pipe pipe; |
| 1058 | struct intel_crtc *intel_crtc; |
| 1059 | |
Paulo Zanoni | 0882dae | 2014-01-08 11:12:27 -0200 | [diff] [blame^] | 1060 | dev_priv->ddi_plls.spll_refcount = 0; |
| 1061 | dev_priv->ddi_plls.wrpll1_refcount = 0; |
| 1062 | dev_priv->ddi_plls.wrpll2_refcount = 0; |
| 1063 | |
Paulo Zanoni | 6441ab5 | 2012-10-05 12:05:58 -0300 | [diff] [blame] | 1064 | for_each_pipe(pipe) { |
| 1065 | intel_crtc = |
| 1066 | to_intel_crtc(dev_priv->pipe_to_crtc_mapping[pipe]); |
| 1067 | |
Paulo Zanoni | 0882dae | 2014-01-08 11:12:27 -0200 | [diff] [blame^] | 1068 | if (!intel_crtc->active) { |
| 1069 | intel_crtc->ddi_pll_sel = PORT_CLK_SEL_NONE; |
Paulo Zanoni | 6441ab5 | 2012-10-05 12:05:58 -0300 | [diff] [blame] | 1070 | continue; |
Paulo Zanoni | 0882dae | 2014-01-08 11:12:27 -0200 | [diff] [blame^] | 1071 | } |
Paulo Zanoni | 6441ab5 | 2012-10-05 12:05:58 -0300 | [diff] [blame] | 1072 | |
| 1073 | intel_crtc->ddi_pll_sel = intel_ddi_get_crtc_pll(dev_priv, |
| 1074 | pipe); |
| 1075 | |
| 1076 | switch (intel_crtc->ddi_pll_sel) { |
| 1077 | case PORT_CLK_SEL_SPLL: |
| 1078 | dev_priv->ddi_plls.spll_refcount++; |
| 1079 | break; |
| 1080 | case PORT_CLK_SEL_WRPLL1: |
| 1081 | dev_priv->ddi_plls.wrpll1_refcount++; |
| 1082 | break; |
| 1083 | case PORT_CLK_SEL_WRPLL2: |
| 1084 | dev_priv->ddi_plls.wrpll2_refcount++; |
| 1085 | break; |
| 1086 | } |
| 1087 | } |
| 1088 | } |
| 1089 | |
Paulo Zanoni | fc91463 | 2012-10-05 12:05:54 -0300 | [diff] [blame] | 1090 | void intel_ddi_enable_pipe_clock(struct intel_crtc *intel_crtc) |
| 1091 | { |
| 1092 | struct drm_crtc *crtc = &intel_crtc->base; |
| 1093 | struct drm_i915_private *dev_priv = crtc->dev->dev_private; |
| 1094 | struct intel_encoder *intel_encoder = intel_ddi_get_crtc_encoder(crtc); |
| 1095 | enum port port = intel_ddi_get_encoder_port(intel_encoder); |
Daniel Vetter | 3b117c8 | 2013-04-17 20:15:07 +0200 | [diff] [blame] | 1096 | enum transcoder cpu_transcoder = intel_crtc->config.cpu_transcoder; |
Paulo Zanoni | fc91463 | 2012-10-05 12:05:54 -0300 | [diff] [blame] | 1097 | |
Paulo Zanoni | bb523fc | 2012-10-23 18:29:56 -0200 | [diff] [blame] | 1098 | if (cpu_transcoder != TRANSCODER_EDP) |
| 1099 | I915_WRITE(TRANS_CLK_SEL(cpu_transcoder), |
| 1100 | TRANS_CLK_SEL_PORT(port)); |
Paulo Zanoni | fc91463 | 2012-10-05 12:05:54 -0300 | [diff] [blame] | 1101 | } |
| 1102 | |
| 1103 | void intel_ddi_disable_pipe_clock(struct intel_crtc *intel_crtc) |
| 1104 | { |
| 1105 | struct drm_i915_private *dev_priv = intel_crtc->base.dev->dev_private; |
Daniel Vetter | 3b117c8 | 2013-04-17 20:15:07 +0200 | [diff] [blame] | 1106 | enum transcoder cpu_transcoder = intel_crtc->config.cpu_transcoder; |
Paulo Zanoni | fc91463 | 2012-10-05 12:05:54 -0300 | [diff] [blame] | 1107 | |
Paulo Zanoni | bb523fc | 2012-10-23 18:29:56 -0200 | [diff] [blame] | 1108 | if (cpu_transcoder != TRANSCODER_EDP) |
| 1109 | I915_WRITE(TRANS_CLK_SEL(cpu_transcoder), |
| 1110 | TRANS_CLK_SEL_DISABLED); |
Paulo Zanoni | fc91463 | 2012-10-05 12:05:54 -0300 | [diff] [blame] | 1111 | } |
| 1112 | |
Paulo Zanoni | 00c09d7 | 2012-10-26 19:05:52 -0200 | [diff] [blame] | 1113 | static void intel_ddi_pre_enable(struct intel_encoder *intel_encoder) |
Paulo Zanoni | 6441ab5 | 2012-10-05 12:05:58 -0300 | [diff] [blame] | 1114 | { |
Paulo Zanoni | c19b066 | 2012-10-15 15:51:41 -0300 | [diff] [blame] | 1115 | struct drm_encoder *encoder = &intel_encoder->base; |
| 1116 | struct drm_crtc *crtc = encoder->crtc; |
| 1117 | struct drm_i915_private *dev_priv = encoder->dev->dev_private; |
Paulo Zanoni | 6441ab5 | 2012-10-05 12:05:58 -0300 | [diff] [blame] | 1118 | struct intel_crtc *intel_crtc = to_intel_crtc(crtc); |
| 1119 | enum port port = intel_ddi_get_encoder_port(intel_encoder); |
Paulo Zanoni | 82a4d9c | 2012-10-23 18:30:07 -0200 | [diff] [blame] | 1120 | int type = intel_encoder->type; |
| 1121 | |
| 1122 | if (type == INTEL_OUTPUT_EDP) { |
| 1123 | struct intel_dp *intel_dp = enc_to_intel_dp(encoder); |
| 1124 | ironlake_edp_panel_vdd_on(intel_dp); |
| 1125 | ironlake_edp_panel_on(intel_dp); |
| 1126 | ironlake_edp_panel_vdd_off(intel_dp, true); |
| 1127 | } |
Paulo Zanoni | 6441ab5 | 2012-10-05 12:05:58 -0300 | [diff] [blame] | 1128 | |
| 1129 | WARN_ON(intel_crtc->ddi_pll_sel == PORT_CLK_SEL_NONE); |
Paulo Zanoni | 6441ab5 | 2012-10-05 12:05:58 -0300 | [diff] [blame] | 1130 | I915_WRITE(PORT_CLK_SEL(port), intel_crtc->ddi_pll_sel); |
Paulo Zanoni | c19b066 | 2012-10-15 15:51:41 -0300 | [diff] [blame] | 1131 | |
Paulo Zanoni | 82a4d9c | 2012-10-23 18:30:07 -0200 | [diff] [blame] | 1132 | if (type == INTEL_OUTPUT_DISPLAYPORT || type == INTEL_OUTPUT_EDP) { |
Paulo Zanoni | c19b066 | 2012-10-15 15:51:41 -0300 | [diff] [blame] | 1133 | struct intel_dp *intel_dp = enc_to_intel_dp(encoder); |
| 1134 | |
| 1135 | intel_dp_sink_dpms(intel_dp, DRM_MODE_DPMS_ON); |
| 1136 | intel_dp_start_link_train(intel_dp); |
| 1137 | intel_dp_complete_link_train(intel_dp); |
Imre Deak | 3ab9c63 | 2013-05-03 12:57:41 +0300 | [diff] [blame] | 1138 | if (port != PORT_A) |
| 1139 | intel_dp_stop_link_train(intel_dp); |
Paulo Zanoni | c19b066 | 2012-10-15 15:51:41 -0300 | [diff] [blame] | 1140 | } |
Paulo Zanoni | 6441ab5 | 2012-10-05 12:05:58 -0300 | [diff] [blame] | 1141 | } |
| 1142 | |
Paulo Zanoni | 00c09d7 | 2012-10-26 19:05:52 -0200 | [diff] [blame] | 1143 | static void intel_ddi_post_disable(struct intel_encoder *intel_encoder) |
Paulo Zanoni | 6441ab5 | 2012-10-05 12:05:58 -0300 | [diff] [blame] | 1144 | { |
| 1145 | struct drm_encoder *encoder = &intel_encoder->base; |
| 1146 | struct drm_i915_private *dev_priv = encoder->dev->dev_private; |
| 1147 | enum port port = intel_ddi_get_encoder_port(intel_encoder); |
Paulo Zanoni | 82a4d9c | 2012-10-23 18:30:07 -0200 | [diff] [blame] | 1148 | int type = intel_encoder->type; |
Paulo Zanoni | 2886e93 | 2012-10-05 12:06:00 -0300 | [diff] [blame] | 1149 | uint32_t val; |
Paulo Zanoni | a836bdf | 2012-10-15 15:51:32 -0300 | [diff] [blame] | 1150 | bool wait = false; |
Paulo Zanoni | 2886e93 | 2012-10-05 12:06:00 -0300 | [diff] [blame] | 1151 | |
| 1152 | val = I915_READ(DDI_BUF_CTL(port)); |
| 1153 | if (val & DDI_BUF_CTL_ENABLE) { |
| 1154 | val &= ~DDI_BUF_CTL_ENABLE; |
| 1155 | I915_WRITE(DDI_BUF_CTL(port), val); |
Paulo Zanoni | a836bdf | 2012-10-15 15:51:32 -0300 | [diff] [blame] | 1156 | wait = true; |
Paulo Zanoni | 2886e93 | 2012-10-05 12:06:00 -0300 | [diff] [blame] | 1157 | } |
Paulo Zanoni | 6441ab5 | 2012-10-05 12:05:58 -0300 | [diff] [blame] | 1158 | |
Paulo Zanoni | a836bdf | 2012-10-15 15:51:32 -0300 | [diff] [blame] | 1159 | val = I915_READ(DP_TP_CTL(port)); |
| 1160 | val &= ~(DP_TP_CTL_ENABLE | DP_TP_CTL_LINK_TRAIN_MASK); |
| 1161 | val |= DP_TP_CTL_LINK_TRAIN_PAT1; |
| 1162 | I915_WRITE(DP_TP_CTL(port), val); |
| 1163 | |
| 1164 | if (wait) |
| 1165 | intel_wait_ddi_buf_idle(dev_priv, port); |
| 1166 | |
Jani Nikula | 76bb80e | 2013-11-15 15:29:57 +0200 | [diff] [blame] | 1167 | if (type == INTEL_OUTPUT_DISPLAYPORT || type == INTEL_OUTPUT_EDP) { |
Paulo Zanoni | 82a4d9c | 2012-10-23 18:30:07 -0200 | [diff] [blame] | 1168 | struct intel_dp *intel_dp = enc_to_intel_dp(encoder); |
| 1169 | ironlake_edp_panel_vdd_on(intel_dp); |
Jani Nikula | 76bb80e | 2013-11-15 15:29:57 +0200 | [diff] [blame] | 1170 | intel_dp_sink_dpms(intel_dp, DRM_MODE_DPMS_OFF); |
Paulo Zanoni | 82a4d9c | 2012-10-23 18:30:07 -0200 | [diff] [blame] | 1171 | ironlake_edp_panel_off(intel_dp); |
| 1172 | } |
| 1173 | |
Paulo Zanoni | 6441ab5 | 2012-10-05 12:05:58 -0300 | [diff] [blame] | 1174 | I915_WRITE(PORT_CLK_SEL(port), PORT_CLK_SEL_NONE); |
| 1175 | } |
| 1176 | |
Paulo Zanoni | 00c09d7 | 2012-10-26 19:05:52 -0200 | [diff] [blame] | 1177 | static void intel_enable_ddi(struct intel_encoder *intel_encoder) |
Eugeni Dodonov | 72662e1 | 2012-05-09 15:37:31 -0300 | [diff] [blame] | 1178 | { |
Paulo Zanoni | 6547fef | 2012-10-15 15:51:40 -0300 | [diff] [blame] | 1179 | struct drm_encoder *encoder = &intel_encoder->base; |
Wang Xingchao | 7b9f35a | 2013-01-22 23:25:25 +0800 | [diff] [blame] | 1180 | struct drm_crtc *crtc = encoder->crtc; |
| 1181 | struct intel_crtc *intel_crtc = to_intel_crtc(crtc); |
| 1182 | int pipe = intel_crtc->pipe; |
Paulo Zanoni | 6547fef | 2012-10-15 15:51:40 -0300 | [diff] [blame] | 1183 | struct drm_device *dev = encoder->dev; |
Eugeni Dodonov | 72662e1 | 2012-05-09 15:37:31 -0300 | [diff] [blame] | 1184 | struct drm_i915_private *dev_priv = dev->dev_private; |
Paulo Zanoni | 6547fef | 2012-10-15 15:51:40 -0300 | [diff] [blame] | 1185 | enum port port = intel_ddi_get_encoder_port(intel_encoder); |
| 1186 | int type = intel_encoder->type; |
Wang Xingchao | 7b9f35a | 2013-01-22 23:25:25 +0800 | [diff] [blame] | 1187 | uint32_t tmp; |
Eugeni Dodonov | 72662e1 | 2012-05-09 15:37:31 -0300 | [diff] [blame] | 1188 | |
Paulo Zanoni | 6547fef | 2012-10-15 15:51:40 -0300 | [diff] [blame] | 1189 | if (type == INTEL_OUTPUT_HDMI) { |
Damien Lespiau | 876a8cd | 2012-12-11 18:48:30 +0000 | [diff] [blame] | 1190 | struct intel_digital_port *intel_dig_port = |
| 1191 | enc_to_dig_port(encoder); |
| 1192 | |
Paulo Zanoni | 6547fef | 2012-10-15 15:51:40 -0300 | [diff] [blame] | 1193 | /* In HDMI/DVI mode, the port width, and swing/emphasis values |
| 1194 | * are ignored so nothing special needs to be done besides |
| 1195 | * enabling the port. |
| 1196 | */ |
Damien Lespiau | 876a8cd | 2012-12-11 18:48:30 +0000 | [diff] [blame] | 1197 | I915_WRITE(DDI_BUF_CTL(port), |
Stéphane Marchesin | bcf53de | 2013-07-12 13:54:41 -0700 | [diff] [blame] | 1198 | intel_dig_port->saved_port_bits | |
| 1199 | DDI_BUF_CTL_ENABLE); |
Paulo Zanoni | d6c50ff | 2012-10-23 18:30:06 -0200 | [diff] [blame] | 1200 | } else if (type == INTEL_OUTPUT_EDP) { |
| 1201 | struct intel_dp *intel_dp = enc_to_intel_dp(encoder); |
| 1202 | |
Imre Deak | 3ab9c63 | 2013-05-03 12:57:41 +0300 | [diff] [blame] | 1203 | if (port == PORT_A) |
| 1204 | intel_dp_stop_link_train(intel_dp); |
| 1205 | |
Paulo Zanoni | d6c50ff | 2012-10-23 18:30:06 -0200 | [diff] [blame] | 1206 | ironlake_edp_backlight_on(intel_dp); |
Rodrigo Vivi | 4906557 | 2013-07-11 18:45:05 -0300 | [diff] [blame] | 1207 | intel_edp_psr_enable(intel_dp); |
Paulo Zanoni | 6547fef | 2012-10-15 15:51:40 -0300 | [diff] [blame] | 1208 | } |
Wang Xingchao | 7b9f35a | 2013-01-22 23:25:25 +0800 | [diff] [blame] | 1209 | |
Paulo Zanoni | c77bf56 | 2013-05-03 12:15:40 -0300 | [diff] [blame] | 1210 | if (intel_crtc->eld_vld && type != INTEL_OUTPUT_EDP) { |
Wang Xingchao | 7b9f35a | 2013-01-22 23:25:25 +0800 | [diff] [blame] | 1211 | tmp = I915_READ(HSW_AUD_PIN_ELD_CP_VLD); |
| 1212 | tmp |= ((AUDIO_OUTPUT_ENABLE_A | AUDIO_ELD_VALID_A) << (pipe * 4)); |
| 1213 | I915_WRITE(HSW_AUD_PIN_ELD_CP_VLD, tmp); |
| 1214 | } |
Daniel Vetter | 5ab432e | 2012-06-30 08:59:56 +0200 | [diff] [blame] | 1215 | } |
| 1216 | |
Paulo Zanoni | 00c09d7 | 2012-10-26 19:05:52 -0200 | [diff] [blame] | 1217 | static void intel_disable_ddi(struct intel_encoder *intel_encoder) |
Daniel Vetter | 5ab432e | 2012-06-30 08:59:56 +0200 | [diff] [blame] | 1218 | { |
Paulo Zanoni | d6c50ff | 2012-10-23 18:30:06 -0200 | [diff] [blame] | 1219 | struct drm_encoder *encoder = &intel_encoder->base; |
Wang Xingchao | 7b9f35a | 2013-01-22 23:25:25 +0800 | [diff] [blame] | 1220 | struct drm_crtc *crtc = encoder->crtc; |
| 1221 | struct intel_crtc *intel_crtc = to_intel_crtc(crtc); |
| 1222 | int pipe = intel_crtc->pipe; |
Paulo Zanoni | d6c50ff | 2012-10-23 18:30:06 -0200 | [diff] [blame] | 1223 | int type = intel_encoder->type; |
Wang Xingchao | 7b9f35a | 2013-01-22 23:25:25 +0800 | [diff] [blame] | 1224 | struct drm_device *dev = encoder->dev; |
| 1225 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 1226 | uint32_t tmp; |
Paulo Zanoni | d6c50ff | 2012-10-23 18:30:06 -0200 | [diff] [blame] | 1227 | |
Paulo Zanoni | c77bf56 | 2013-05-03 12:15:40 -0300 | [diff] [blame] | 1228 | if (intel_crtc->eld_vld && type != INTEL_OUTPUT_EDP) { |
| 1229 | tmp = I915_READ(HSW_AUD_PIN_ELD_CP_VLD); |
| 1230 | tmp &= ~((AUDIO_OUTPUT_ENABLE_A | AUDIO_ELD_VALID_A) << |
| 1231 | (pipe * 4)); |
| 1232 | I915_WRITE(HSW_AUD_PIN_ELD_CP_VLD, tmp); |
| 1233 | } |
Paulo Zanoni | 2831d842 | 2013-03-06 20:03:09 -0300 | [diff] [blame] | 1234 | |
Paulo Zanoni | d6c50ff | 2012-10-23 18:30:06 -0200 | [diff] [blame] | 1235 | if (type == INTEL_OUTPUT_EDP) { |
| 1236 | struct intel_dp *intel_dp = enc_to_intel_dp(encoder); |
| 1237 | |
Rodrigo Vivi | 4906557 | 2013-07-11 18:45:05 -0300 | [diff] [blame] | 1238 | intel_edp_psr_disable(intel_dp); |
Paulo Zanoni | d6c50ff | 2012-10-23 18:30:06 -0200 | [diff] [blame] | 1239 | ironlake_edp_backlight_off(intel_dp); |
| 1240 | } |
Eugeni Dodonov | 72662e1 | 2012-05-09 15:37:31 -0300 | [diff] [blame] | 1241 | } |
Paulo Zanoni | 79f689a | 2012-10-05 12:05:52 -0300 | [diff] [blame] | 1242 | |
Paulo Zanoni | b8fc2f6 | 2012-10-23 18:30:05 -0200 | [diff] [blame] | 1243 | int intel_ddi_get_cdclk_freq(struct drm_i915_private *dev_priv) |
Paulo Zanoni | 79f689a | 2012-10-05 12:05:52 -0300 | [diff] [blame] | 1244 | { |
Paulo Zanoni | e39bf98 | 2013-11-02 21:07:36 -0700 | [diff] [blame] | 1245 | struct drm_device *dev = dev_priv->dev; |
Paulo Zanoni | a400664 | 2013-08-06 18:57:11 -0300 | [diff] [blame] | 1246 | uint32_t lcpll = I915_READ(LCPLL_CTL); |
Paulo Zanoni | e39bf98 | 2013-11-02 21:07:36 -0700 | [diff] [blame] | 1247 | uint32_t freq = lcpll & LCPLL_CLK_FREQ_MASK; |
Paulo Zanoni | a400664 | 2013-08-06 18:57:11 -0300 | [diff] [blame] | 1248 | |
Paulo Zanoni | e39bf98 | 2013-11-02 21:07:36 -0700 | [diff] [blame] | 1249 | if (lcpll & LCPLL_CD_SOURCE_FCLK) { |
Paulo Zanoni | a400664 | 2013-08-06 18:57:11 -0300 | [diff] [blame] | 1250 | return 800000; |
Paulo Zanoni | e39bf98 | 2013-11-02 21:07:36 -0700 | [diff] [blame] | 1251 | } else if (I915_READ(HSW_FUSE_STRAP) & HSW_CDCLK_LIMIT) { |
Paulo Zanoni | b2b877f | 2013-05-03 17:23:42 -0300 | [diff] [blame] | 1252 | return 450000; |
Paulo Zanoni | e39bf98 | 2013-11-02 21:07:36 -0700 | [diff] [blame] | 1253 | } else if (freq == LCPLL_CLK_FREQ_450) { |
Paulo Zanoni | b2b877f | 2013-05-03 17:23:42 -0300 | [diff] [blame] | 1254 | return 450000; |
Paulo Zanoni | e39bf98 | 2013-11-02 21:07:36 -0700 | [diff] [blame] | 1255 | } else if (IS_HASWELL(dev)) { |
| 1256 | if (IS_ULT(dev)) |
| 1257 | return 337500; |
| 1258 | else |
| 1259 | return 540000; |
| 1260 | } else { |
| 1261 | if (freq == LCPLL_CLK_FREQ_54O_BDW) |
| 1262 | return 540000; |
| 1263 | else if (freq == LCPLL_CLK_FREQ_337_5_BDW) |
| 1264 | return 337500; |
| 1265 | else |
| 1266 | return 675000; |
| 1267 | } |
Paulo Zanoni | 79f689a | 2012-10-05 12:05:52 -0300 | [diff] [blame] | 1268 | } |
| 1269 | |
| 1270 | void intel_ddi_pll_init(struct drm_device *dev) |
| 1271 | { |
| 1272 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 1273 | uint32_t val = I915_READ(LCPLL_CTL); |
| 1274 | |
| 1275 | /* The LCPLL register should be turned on by the BIOS. For now let's |
| 1276 | * just check its state and print errors in case something is wrong. |
| 1277 | * Don't even try to turn it on. |
| 1278 | */ |
| 1279 | |
Paulo Zanoni | b2b877f | 2013-05-03 17:23:42 -0300 | [diff] [blame] | 1280 | DRM_DEBUG_KMS("CDCLK running at %dKHz\n", |
Paulo Zanoni | 79f689a | 2012-10-05 12:05:52 -0300 | [diff] [blame] | 1281 | intel_ddi_get_cdclk_freq(dev_priv)); |
| 1282 | |
| 1283 | if (val & LCPLL_CD_SOURCE_FCLK) |
| 1284 | DRM_ERROR("CDCLK source is not LCPLL\n"); |
| 1285 | |
| 1286 | if (val & LCPLL_PLL_DISABLE) |
| 1287 | DRM_ERROR("LCPLL is disabled\n"); |
| 1288 | } |
Paulo Zanoni | c19b066 | 2012-10-15 15:51:41 -0300 | [diff] [blame] | 1289 | |
| 1290 | void intel_ddi_prepare_link_retrain(struct drm_encoder *encoder) |
| 1291 | { |
Paulo Zanoni | 174edf1 | 2012-10-26 19:05:50 -0200 | [diff] [blame] | 1292 | struct intel_digital_port *intel_dig_port = enc_to_dig_port(encoder); |
| 1293 | struct intel_dp *intel_dp = &intel_dig_port->dp; |
Paulo Zanoni | c19b066 | 2012-10-15 15:51:41 -0300 | [diff] [blame] | 1294 | struct drm_i915_private *dev_priv = encoder->dev->dev_private; |
Paulo Zanoni | 174edf1 | 2012-10-26 19:05:50 -0200 | [diff] [blame] | 1295 | enum port port = intel_dig_port->port; |
Paulo Zanoni | c19b066 | 2012-10-15 15:51:41 -0300 | [diff] [blame] | 1296 | uint32_t val; |
Syam Sidhardhan | f3e227d | 2013-02-25 04:05:38 +0530 | [diff] [blame] | 1297 | bool wait = false; |
Paulo Zanoni | c19b066 | 2012-10-15 15:51:41 -0300 | [diff] [blame] | 1298 | |
| 1299 | if (I915_READ(DP_TP_CTL(port)) & DP_TP_CTL_ENABLE) { |
| 1300 | val = I915_READ(DDI_BUF_CTL(port)); |
| 1301 | if (val & DDI_BUF_CTL_ENABLE) { |
| 1302 | val &= ~DDI_BUF_CTL_ENABLE; |
| 1303 | I915_WRITE(DDI_BUF_CTL(port), val); |
| 1304 | wait = true; |
| 1305 | } |
| 1306 | |
| 1307 | val = I915_READ(DP_TP_CTL(port)); |
| 1308 | val &= ~(DP_TP_CTL_ENABLE | DP_TP_CTL_LINK_TRAIN_MASK); |
| 1309 | val |= DP_TP_CTL_LINK_TRAIN_PAT1; |
| 1310 | I915_WRITE(DP_TP_CTL(port), val); |
| 1311 | POSTING_READ(DP_TP_CTL(port)); |
| 1312 | |
| 1313 | if (wait) |
| 1314 | intel_wait_ddi_buf_idle(dev_priv, port); |
| 1315 | } |
| 1316 | |
| 1317 | val = DP_TP_CTL_ENABLE | DP_TP_CTL_MODE_SST | |
| 1318 | DP_TP_CTL_LINK_TRAIN_PAT1 | DP_TP_CTL_SCRAMBLE_DISABLE; |
Jani Nikula | 6aba5b6 | 2013-10-04 15:08:10 +0300 | [diff] [blame] | 1319 | if (drm_dp_enhanced_frame_cap(intel_dp->dpcd)) |
Paulo Zanoni | c19b066 | 2012-10-15 15:51:41 -0300 | [diff] [blame] | 1320 | val |= DP_TP_CTL_ENHANCED_FRAME_ENABLE; |
| 1321 | I915_WRITE(DP_TP_CTL(port), val); |
| 1322 | POSTING_READ(DP_TP_CTL(port)); |
| 1323 | |
| 1324 | intel_dp->DP |= DDI_BUF_CTL_ENABLE; |
| 1325 | I915_WRITE(DDI_BUF_CTL(port), intel_dp->DP); |
| 1326 | POSTING_READ(DDI_BUF_CTL(port)); |
| 1327 | |
| 1328 | udelay(600); |
| 1329 | } |
Paulo Zanoni | 00c09d7 | 2012-10-26 19:05:52 -0200 | [diff] [blame] | 1330 | |
Paulo Zanoni | 1ad960f | 2012-11-01 21:05:05 -0200 | [diff] [blame] | 1331 | void intel_ddi_fdi_disable(struct drm_crtc *crtc) |
| 1332 | { |
| 1333 | struct drm_i915_private *dev_priv = crtc->dev->dev_private; |
| 1334 | struct intel_encoder *intel_encoder = intel_ddi_get_crtc_encoder(crtc); |
| 1335 | uint32_t val; |
| 1336 | |
| 1337 | intel_ddi_post_disable(intel_encoder); |
| 1338 | |
| 1339 | val = I915_READ(_FDI_RXA_CTL); |
| 1340 | val &= ~FDI_RX_ENABLE; |
| 1341 | I915_WRITE(_FDI_RXA_CTL, val); |
| 1342 | |
| 1343 | val = I915_READ(_FDI_RXA_MISC); |
| 1344 | val &= ~(FDI_RX_PWRDN_LANE1_MASK | FDI_RX_PWRDN_LANE0_MASK); |
| 1345 | val |= FDI_RX_PWRDN_LANE1_VAL(2) | FDI_RX_PWRDN_LANE0_VAL(2); |
| 1346 | I915_WRITE(_FDI_RXA_MISC, val); |
| 1347 | |
| 1348 | val = I915_READ(_FDI_RXA_CTL); |
| 1349 | val &= ~FDI_PCDCLK; |
| 1350 | I915_WRITE(_FDI_RXA_CTL, val); |
| 1351 | |
| 1352 | val = I915_READ(_FDI_RXA_CTL); |
| 1353 | val &= ~FDI_RX_PLL_ENABLE; |
| 1354 | I915_WRITE(_FDI_RXA_CTL, val); |
| 1355 | } |
| 1356 | |
Paulo Zanoni | 00c09d7 | 2012-10-26 19:05:52 -0200 | [diff] [blame] | 1357 | static void intel_ddi_hot_plug(struct intel_encoder *intel_encoder) |
| 1358 | { |
| 1359 | struct intel_dp *intel_dp = enc_to_intel_dp(&intel_encoder->base); |
| 1360 | int type = intel_encoder->type; |
| 1361 | |
| 1362 | if (type == INTEL_OUTPUT_DISPLAYPORT || type == INTEL_OUTPUT_EDP) |
| 1363 | intel_dp_check_link_status(intel_dp); |
| 1364 | } |
| 1365 | |
Ville Syrjälä | 6801c18 | 2013-09-24 14:24:05 +0300 | [diff] [blame] | 1366 | void intel_ddi_get_config(struct intel_encoder *encoder, |
| 1367 | struct intel_crtc_config *pipe_config) |
Jesse Barnes | 045ac3b | 2013-05-14 17:08:26 -0700 | [diff] [blame] | 1368 | { |
| 1369 | struct drm_i915_private *dev_priv = encoder->base.dev->dev_private; |
| 1370 | struct intel_crtc *intel_crtc = to_intel_crtc(encoder->base.crtc); |
| 1371 | enum transcoder cpu_transcoder = intel_crtc->config.cpu_transcoder; |
| 1372 | u32 temp, flags = 0; |
| 1373 | |
| 1374 | temp = I915_READ(TRANS_DDI_FUNC_CTL(cpu_transcoder)); |
| 1375 | if (temp & TRANS_DDI_PHSYNC) |
| 1376 | flags |= DRM_MODE_FLAG_PHSYNC; |
| 1377 | else |
| 1378 | flags |= DRM_MODE_FLAG_NHSYNC; |
| 1379 | if (temp & TRANS_DDI_PVSYNC) |
| 1380 | flags |= DRM_MODE_FLAG_PVSYNC; |
| 1381 | else |
| 1382 | flags |= DRM_MODE_FLAG_NVSYNC; |
| 1383 | |
| 1384 | pipe_config->adjusted_mode.flags |= flags; |
Ville Syrjälä | 42571ae | 2013-09-06 23:29:00 +0300 | [diff] [blame] | 1385 | |
| 1386 | switch (temp & TRANS_DDI_BPC_MASK) { |
| 1387 | case TRANS_DDI_BPC_6: |
| 1388 | pipe_config->pipe_bpp = 18; |
| 1389 | break; |
| 1390 | case TRANS_DDI_BPC_8: |
| 1391 | pipe_config->pipe_bpp = 24; |
| 1392 | break; |
| 1393 | case TRANS_DDI_BPC_10: |
| 1394 | pipe_config->pipe_bpp = 30; |
| 1395 | break; |
| 1396 | case TRANS_DDI_BPC_12: |
| 1397 | pipe_config->pipe_bpp = 36; |
| 1398 | break; |
| 1399 | default: |
| 1400 | break; |
| 1401 | } |
Ville Syrjälä | eb14cb7 | 2013-09-10 17:02:54 +0300 | [diff] [blame] | 1402 | |
| 1403 | switch (temp & TRANS_DDI_MODE_SELECT_MASK) { |
| 1404 | case TRANS_DDI_MODE_SELECT_HDMI: |
| 1405 | case TRANS_DDI_MODE_SELECT_DVI: |
| 1406 | case TRANS_DDI_MODE_SELECT_FDI: |
| 1407 | break; |
| 1408 | case TRANS_DDI_MODE_SELECT_DP_SST: |
| 1409 | case TRANS_DDI_MODE_SELECT_DP_MST: |
| 1410 | pipe_config->has_dp_encoder = true; |
| 1411 | intel_dp_get_m_n(intel_crtc, pipe_config); |
| 1412 | break; |
| 1413 | default: |
| 1414 | break; |
| 1415 | } |
Daniel Vetter | 1021442 | 2013-11-18 07:38:16 +0100 | [diff] [blame] | 1416 | |
| 1417 | if (encoder->type == INTEL_OUTPUT_EDP && dev_priv->vbt.edp_bpp && |
| 1418 | pipe_config->pipe_bpp > dev_priv->vbt.edp_bpp) { |
| 1419 | /* |
| 1420 | * This is a big fat ugly hack. |
| 1421 | * |
| 1422 | * Some machines in UEFI boot mode provide us a VBT that has 18 |
| 1423 | * bpp and 1.62 GHz link bandwidth for eDP, which for reasons |
| 1424 | * unknown we fail to light up. Yet the same BIOS boots up with |
| 1425 | * 24 bpp and 2.7 GHz link. Use the same bpp as the BIOS uses as |
| 1426 | * max, not what it tells us to use. |
| 1427 | * |
| 1428 | * Note: This will still be broken if the eDP panel is not lit |
| 1429 | * up by the BIOS, and thus we can't get the mode at module |
| 1430 | * load. |
| 1431 | */ |
| 1432 | DRM_DEBUG_KMS("pipe has %d bpp for eDP panel, overriding BIOS-provided max %d bpp\n", |
| 1433 | pipe_config->pipe_bpp, dev_priv->vbt.edp_bpp); |
| 1434 | dev_priv->vbt.edp_bpp = pipe_config->pipe_bpp; |
| 1435 | } |
Jesse Barnes | 045ac3b | 2013-05-14 17:08:26 -0700 | [diff] [blame] | 1436 | } |
| 1437 | |
Paulo Zanoni | 00c09d7 | 2012-10-26 19:05:52 -0200 | [diff] [blame] | 1438 | static void intel_ddi_destroy(struct drm_encoder *encoder) |
| 1439 | { |
| 1440 | /* HDMI has nothing special to destroy, so we can go with this. */ |
| 1441 | intel_dp_encoder_destroy(encoder); |
| 1442 | } |
| 1443 | |
Daniel Vetter | 5bfe2ac | 2013-03-27 00:44:55 +0100 | [diff] [blame] | 1444 | static bool intel_ddi_compute_config(struct intel_encoder *encoder, |
| 1445 | struct intel_crtc_config *pipe_config) |
Paulo Zanoni | 00c09d7 | 2012-10-26 19:05:52 -0200 | [diff] [blame] | 1446 | { |
Daniel Vetter | 5bfe2ac | 2013-03-27 00:44:55 +0100 | [diff] [blame] | 1447 | int type = encoder->type; |
Daniel Vetter | eccb140 | 2013-05-22 00:50:22 +0200 | [diff] [blame] | 1448 | int port = intel_ddi_get_encoder_port(encoder); |
Paulo Zanoni | 00c09d7 | 2012-10-26 19:05:52 -0200 | [diff] [blame] | 1449 | |
Daniel Vetter | 5bfe2ac | 2013-03-27 00:44:55 +0100 | [diff] [blame] | 1450 | WARN(type == INTEL_OUTPUT_UNKNOWN, "compute_config() on unknown output!\n"); |
Paulo Zanoni | 00c09d7 | 2012-10-26 19:05:52 -0200 | [diff] [blame] | 1451 | |
Daniel Vetter | eccb140 | 2013-05-22 00:50:22 +0200 | [diff] [blame] | 1452 | if (port == PORT_A) |
| 1453 | pipe_config->cpu_transcoder = TRANSCODER_EDP; |
| 1454 | |
Paulo Zanoni | 00c09d7 | 2012-10-26 19:05:52 -0200 | [diff] [blame] | 1455 | if (type == INTEL_OUTPUT_HDMI) |
Daniel Vetter | 5bfe2ac | 2013-03-27 00:44:55 +0100 | [diff] [blame] | 1456 | return intel_hdmi_compute_config(encoder, pipe_config); |
Paulo Zanoni | 00c09d7 | 2012-10-26 19:05:52 -0200 | [diff] [blame] | 1457 | else |
Daniel Vetter | 5bfe2ac | 2013-03-27 00:44:55 +0100 | [diff] [blame] | 1458 | return intel_dp_compute_config(encoder, pipe_config); |
Paulo Zanoni | 00c09d7 | 2012-10-26 19:05:52 -0200 | [diff] [blame] | 1459 | } |
| 1460 | |
| 1461 | static const struct drm_encoder_funcs intel_ddi_funcs = { |
| 1462 | .destroy = intel_ddi_destroy, |
| 1463 | }; |
| 1464 | |
Paulo Zanoni | 4a28ae5 | 2013-10-09 13:52:36 -0300 | [diff] [blame] | 1465 | static struct intel_connector * |
| 1466 | intel_ddi_init_dp_connector(struct intel_digital_port *intel_dig_port) |
| 1467 | { |
| 1468 | struct intel_connector *connector; |
| 1469 | enum port port = intel_dig_port->port; |
| 1470 | |
| 1471 | connector = kzalloc(sizeof(*connector), GFP_KERNEL); |
| 1472 | if (!connector) |
| 1473 | return NULL; |
| 1474 | |
| 1475 | intel_dig_port->dp.output_reg = DDI_BUF_CTL(port); |
| 1476 | if (!intel_dp_init_connector(intel_dig_port, connector)) { |
| 1477 | kfree(connector); |
| 1478 | return NULL; |
| 1479 | } |
| 1480 | |
| 1481 | return connector; |
| 1482 | } |
| 1483 | |
| 1484 | static struct intel_connector * |
| 1485 | intel_ddi_init_hdmi_connector(struct intel_digital_port *intel_dig_port) |
| 1486 | { |
| 1487 | struct intel_connector *connector; |
| 1488 | enum port port = intel_dig_port->port; |
| 1489 | |
| 1490 | connector = kzalloc(sizeof(*connector), GFP_KERNEL); |
| 1491 | if (!connector) |
| 1492 | return NULL; |
| 1493 | |
| 1494 | intel_dig_port->hdmi.hdmi_reg = DDI_BUF_CTL(port); |
| 1495 | intel_hdmi_init_connector(intel_dig_port, connector); |
| 1496 | |
| 1497 | return connector; |
| 1498 | } |
| 1499 | |
Paulo Zanoni | 00c09d7 | 2012-10-26 19:05:52 -0200 | [diff] [blame] | 1500 | void intel_ddi_init(struct drm_device *dev, enum port port) |
| 1501 | { |
Damien Lespiau | 876a8cd | 2012-12-11 18:48:30 +0000 | [diff] [blame] | 1502 | struct drm_i915_private *dev_priv = dev->dev_private; |
Paulo Zanoni | 00c09d7 | 2012-10-26 19:05:52 -0200 | [diff] [blame] | 1503 | struct intel_digital_port *intel_dig_port; |
| 1504 | struct intel_encoder *intel_encoder; |
| 1505 | struct drm_encoder *encoder; |
| 1506 | struct intel_connector *hdmi_connector = NULL; |
| 1507 | struct intel_connector *dp_connector = NULL; |
Paulo Zanoni | 311a209 | 2013-09-12 17:12:18 -0300 | [diff] [blame] | 1508 | bool init_hdmi, init_dp; |
| 1509 | |
| 1510 | init_hdmi = (dev_priv->vbt.ddi_port_info[port].supports_dvi || |
| 1511 | dev_priv->vbt.ddi_port_info[port].supports_hdmi); |
| 1512 | init_dp = dev_priv->vbt.ddi_port_info[port].supports_dp; |
| 1513 | if (!init_dp && !init_hdmi) { |
| 1514 | DRM_DEBUG_KMS("VBT says port %c is not DVI/HDMI/DP compatible\n", |
| 1515 | port_name(port)); |
| 1516 | init_hdmi = true; |
| 1517 | init_dp = true; |
| 1518 | } |
Paulo Zanoni | 00c09d7 | 2012-10-26 19:05:52 -0200 | [diff] [blame] | 1519 | |
Daniel Vetter | b14c567 | 2013-09-19 12:18:32 +0200 | [diff] [blame] | 1520 | intel_dig_port = kzalloc(sizeof(*intel_dig_port), GFP_KERNEL); |
Paulo Zanoni | 00c09d7 | 2012-10-26 19:05:52 -0200 | [diff] [blame] | 1521 | if (!intel_dig_port) |
| 1522 | return; |
| 1523 | |
Paulo Zanoni | 00c09d7 | 2012-10-26 19:05:52 -0200 | [diff] [blame] | 1524 | intel_encoder = &intel_dig_port->base; |
| 1525 | encoder = &intel_encoder->base; |
| 1526 | |
| 1527 | drm_encoder_init(dev, encoder, &intel_ddi_funcs, |
| 1528 | DRM_MODE_ENCODER_TMDS); |
Paulo Zanoni | 00c09d7 | 2012-10-26 19:05:52 -0200 | [diff] [blame] | 1529 | |
Daniel Vetter | 5bfe2ac | 2013-03-27 00:44:55 +0100 | [diff] [blame] | 1530 | intel_encoder->compute_config = intel_ddi_compute_config; |
Daniel Vetter | c7d8be3 | 2013-07-21 21:37:07 +0200 | [diff] [blame] | 1531 | intel_encoder->mode_set = intel_ddi_mode_set; |
Paulo Zanoni | 00c09d7 | 2012-10-26 19:05:52 -0200 | [diff] [blame] | 1532 | intel_encoder->enable = intel_enable_ddi; |
| 1533 | intel_encoder->pre_enable = intel_ddi_pre_enable; |
| 1534 | intel_encoder->disable = intel_disable_ddi; |
| 1535 | intel_encoder->post_disable = intel_ddi_post_disable; |
| 1536 | intel_encoder->get_hw_state = intel_ddi_get_hw_state; |
Jesse Barnes | 045ac3b | 2013-05-14 17:08:26 -0700 | [diff] [blame] | 1537 | intel_encoder->get_config = intel_ddi_get_config; |
Paulo Zanoni | 00c09d7 | 2012-10-26 19:05:52 -0200 | [diff] [blame] | 1538 | |
| 1539 | intel_dig_port->port = port; |
Stéphane Marchesin | bcf53de | 2013-07-12 13:54:41 -0700 | [diff] [blame] | 1540 | intel_dig_port->saved_port_bits = I915_READ(DDI_BUF_CTL(port)) & |
| 1541 | (DDI_BUF_PORT_REVERSAL | |
| 1542 | DDI_A_4_LANES); |
Paulo Zanoni | 00c09d7 | 2012-10-26 19:05:52 -0200 | [diff] [blame] | 1543 | |
| 1544 | intel_encoder->type = INTEL_OUTPUT_UNKNOWN; |
| 1545 | intel_encoder->crtc_mask = (1 << 0) | (1 << 1) | (1 << 2); |
| 1546 | intel_encoder->cloneable = false; |
| 1547 | intel_encoder->hot_plug = intel_ddi_hot_plug; |
| 1548 | |
Paulo Zanoni | 4a28ae5 | 2013-10-09 13:52:36 -0300 | [diff] [blame] | 1549 | if (init_dp) |
| 1550 | dp_connector = intel_ddi_init_dp_connector(intel_dig_port); |
Daniel Vetter | 21a8e6a | 2013-04-10 23:28:35 +0200 | [diff] [blame] | 1551 | |
Paulo Zanoni | 311a209 | 2013-09-12 17:12:18 -0300 | [diff] [blame] | 1552 | /* In theory we don't need the encoder->type check, but leave it just in |
| 1553 | * case we have some really bad VBTs... */ |
Paulo Zanoni | 4a28ae5 | 2013-10-09 13:52:36 -0300 | [diff] [blame] | 1554 | if (intel_encoder->type != INTEL_OUTPUT_EDP && init_hdmi) |
| 1555 | hdmi_connector = intel_ddi_init_hdmi_connector(intel_dig_port); |
Daniel Vetter | 21a8e6a | 2013-04-10 23:28:35 +0200 | [diff] [blame] | 1556 | |
Paulo Zanoni | 4a28ae5 | 2013-10-09 13:52:36 -0300 | [diff] [blame] | 1557 | if (!dp_connector && !hdmi_connector) { |
| 1558 | drm_encoder_cleanup(encoder); |
| 1559 | kfree(intel_dig_port); |
Daniel Vetter | 21a8e6a | 2013-04-10 23:28:35 +0200 | [diff] [blame] | 1560 | } |
Paulo Zanoni | 00c09d7 | 2012-10-26 19:05:52 -0200 | [diff] [blame] | 1561 | } |