Merge tag 'drm-intel-next-2019-05-24' of git://anongit.freedesktop.org/drm/drm-intel...
[linux-2.6-microblaze.git] / drivers / gpu / drm / i915 / intel_dpio_phy.c
1 /*
2  * Copyright © 2014-2016 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
21  * DEALINGS IN THE SOFTWARE.
22  */
23
24 #include "intel_dp.h"
25 #include "intel_dpio_phy.h"
26 #include "intel_drv.h"
27 #include "intel_sideband.h"
28
29 /**
30  * DOC: DPIO
31  *
32  * VLV, CHV and BXT have slightly peculiar display PHYs for driving DP/HDMI
33  * ports. DPIO is the name given to such a display PHY. These PHYs
34  * don't follow the standard programming model using direct MMIO
35  * registers, and instead their registers must be accessed trough IOSF
36  * sideband. VLV has one such PHY for driving ports B and C, and CHV
37  * adds another PHY for driving port D. Each PHY responds to specific
38  * IOSF-SB port.
39  *
40  * Each display PHY is made up of one or two channels. Each channel
41  * houses a common lane part which contains the PLL and other common
42  * logic. CH0 common lane also contains the IOSF-SB logic for the
43  * Common Register Interface (CRI) ie. the DPIO registers. CRI clock
44  * must be running when any DPIO registers are accessed.
45  *
46  * In addition to having their own registers, the PHYs are also
47  * controlled through some dedicated signals from the display
48  * controller. These include PLL reference clock enable, PLL enable,
49  * and CRI clock selection, for example.
50  *
51  * Eeach channel also has two splines (also called data lanes), and
52  * each spline is made up of one Physical Access Coding Sub-Layer
53  * (PCS) block and two TX lanes. So each channel has two PCS blocks
54  * and four TX lanes. The TX lanes are used as DP lanes or TMDS
55  * data/clock pairs depending on the output type.
56  *
57  * Additionally the PHY also contains an AUX lane with AUX blocks
58  * for each channel. This is used for DP AUX communication, but
59  * this fact isn't really relevant for the driver since AUX is
60  * controlled from the display controller side. No DPIO registers
61  * need to be accessed during AUX communication,
62  *
63  * Generally on VLV/CHV the common lane corresponds to the pipe and
64  * the spline (PCS/TX) corresponds to the port.
65  *
66  * For dual channel PHY (VLV/CHV):
67  *
68  *  pipe A == CMN/PLL/REF CH0
69  *
70  *  pipe B == CMN/PLL/REF CH1
71  *
72  *  port B == PCS/TX CH0
73  *
74  *  port C == PCS/TX CH1
75  *
76  * This is especially important when we cross the streams
77  * ie. drive port B with pipe B, or port C with pipe A.
78  *
79  * For single channel PHY (CHV):
80  *
81  *  pipe C == CMN/PLL/REF CH0
82  *
83  *  port D == PCS/TX CH0
84  *
85  * On BXT the entire PHY channel corresponds to the port. That means
86  * the PLL is also now associated with the port rather than the pipe,
87  * and so the clock needs to be routed to the appropriate transcoder.
88  * Port A PLL is directly connected to transcoder EDP and port B/C
89  * PLLs can be routed to any transcoder A/B/C.
90  *
91  * Note: DDI0 is digital port B, DD1 is digital port C, and DDI2 is
92  * digital port D (CHV) or port A (BXT). ::
93  *
94  *
95  *     Dual channel PHY (VLV/CHV/BXT)
96  *     ---------------------------------
97  *     |      CH0      |      CH1      |
98  *     |  CMN/PLL/REF  |  CMN/PLL/REF  |
99  *     |---------------|---------------| Display PHY
100  *     | PCS01 | PCS23 | PCS01 | PCS23 |
101  *     |-------|-------|-------|-------|
102  *     |TX0|TX1|TX2|TX3|TX0|TX1|TX2|TX3|
103  *     ---------------------------------
104  *     |     DDI0      |     DDI1      | DP/HDMI ports
105  *     ---------------------------------
106  *
107  *     Single channel PHY (CHV/BXT)
108  *     -----------------
109  *     |      CH0      |
110  *     |  CMN/PLL/REF  |
111  *     |---------------| Display PHY
112  *     | PCS01 | PCS23 |
113  *     |-------|-------|
114  *     |TX0|TX1|TX2|TX3|
115  *     -----------------
116  *     |     DDI2      | DP/HDMI port
117  *     -----------------
118  */
119
120 /**
121  * struct bxt_ddi_phy_info - Hold info for a broxton DDI phy
122  */
123 struct bxt_ddi_phy_info {
124         /**
125          * @dual_channel: true if this phy has a second channel.
126          */
127         bool dual_channel;
128
129         /**
130          * @rcomp_phy: If -1, indicates this phy has its own rcomp resistor.
131          * Otherwise the GRC value will be copied from the phy indicated by
132          * this field.
133          */
134         enum dpio_phy rcomp_phy;
135
136         /**
137          * @reset_delay: delay in us to wait before setting the common reset
138          * bit in BXT_PHY_CTL_FAMILY, which effectively enables the phy.
139          */
140         int reset_delay;
141
142         /**
143          * @pwron_mask: Mask with the appropriate bit set that would cause the
144          * punit to power this phy if written to BXT_P_CR_GT_DISP_PWRON.
145          */
146         u32 pwron_mask;
147
148         /**
149          * @channel: struct containing per channel information.
150          */
151         struct {
152                 /**
153                  * @channel.port: which port maps to this channel.
154                  */
155                 enum port port;
156         } channel[2];
157 };
158
159 static const struct bxt_ddi_phy_info bxt_ddi_phy_info[] = {
160         [DPIO_PHY0] = {
161                 .dual_channel = true,
162                 .rcomp_phy = DPIO_PHY1,
163                 .pwron_mask = BIT(0),
164
165                 .channel = {
166                         [DPIO_CH0] = { .port = PORT_B },
167                         [DPIO_CH1] = { .port = PORT_C },
168                 }
169         },
170         [DPIO_PHY1] = {
171                 .dual_channel = false,
172                 .rcomp_phy = -1,
173                 .pwron_mask = BIT(1),
174
175                 .channel = {
176                         [DPIO_CH0] = { .port = PORT_A },
177                 }
178         },
179 };
180
181 static const struct bxt_ddi_phy_info glk_ddi_phy_info[] = {
182         [DPIO_PHY0] = {
183                 .dual_channel = false,
184                 .rcomp_phy = DPIO_PHY1,
185                 .pwron_mask = BIT(0),
186                 .reset_delay = 20,
187
188                 .channel = {
189                         [DPIO_CH0] = { .port = PORT_B },
190                 }
191         },
192         [DPIO_PHY1] = {
193                 .dual_channel = false,
194                 .rcomp_phy = -1,
195                 .pwron_mask = BIT(3),
196                 .reset_delay = 20,
197
198                 .channel = {
199                         [DPIO_CH0] = { .port = PORT_A },
200                 }
201         },
202         [DPIO_PHY2] = {
203                 .dual_channel = false,
204                 .rcomp_phy = DPIO_PHY1,
205                 .pwron_mask = BIT(1),
206                 .reset_delay = 20,
207
208                 .channel = {
209                         [DPIO_CH0] = { .port = PORT_C },
210                 }
211         },
212 };
213
214 static const struct bxt_ddi_phy_info *
215 bxt_get_phy_list(struct drm_i915_private *dev_priv, int *count)
216 {
217         if (IS_GEMINILAKE(dev_priv)) {
218                 *count =  ARRAY_SIZE(glk_ddi_phy_info);
219                 return glk_ddi_phy_info;
220         } else {
221                 *count =  ARRAY_SIZE(bxt_ddi_phy_info);
222                 return bxt_ddi_phy_info;
223         }
224 }
225
226 static const struct bxt_ddi_phy_info *
227 bxt_get_phy_info(struct drm_i915_private *dev_priv, enum dpio_phy phy)
228 {
229         int count;
230         const struct bxt_ddi_phy_info *phy_list =
231                 bxt_get_phy_list(dev_priv, &count);
232
233         return &phy_list[phy];
234 }
235
236 void bxt_port_to_phy_channel(struct drm_i915_private *dev_priv, enum port port,
237                              enum dpio_phy *phy, enum dpio_channel *ch)
238 {
239         const struct bxt_ddi_phy_info *phy_info, *phys;
240         int i, count;
241
242         phys = bxt_get_phy_list(dev_priv, &count);
243
244         for (i = 0; i < count; i++) {
245                 phy_info = &phys[i];
246
247                 if (port == phy_info->channel[DPIO_CH0].port) {
248                         *phy = i;
249                         *ch = DPIO_CH0;
250                         return;
251                 }
252
253                 if (phy_info->dual_channel &&
254                     port == phy_info->channel[DPIO_CH1].port) {
255                         *phy = i;
256                         *ch = DPIO_CH1;
257                         return;
258                 }
259         }
260
261         WARN(1, "PHY not found for PORT %c", port_name(port));
262         *phy = DPIO_PHY0;
263         *ch = DPIO_CH0;
264 }
265
266 void bxt_ddi_phy_set_signal_level(struct drm_i915_private *dev_priv,
267                                   enum port port, u32 margin, u32 scale,
268                                   u32 enable, u32 deemphasis)
269 {
270         u32 val;
271         enum dpio_phy phy;
272         enum dpio_channel ch;
273
274         bxt_port_to_phy_channel(dev_priv, port, &phy, &ch);
275
276         /*
277          * While we write to the group register to program all lanes at once we
278          * can read only lane registers and we pick lanes 0/1 for that.
279          */
280         val = I915_READ(BXT_PORT_PCS_DW10_LN01(phy, ch));
281         val &= ~(TX2_SWING_CALC_INIT | TX1_SWING_CALC_INIT);
282         I915_WRITE(BXT_PORT_PCS_DW10_GRP(phy, ch), val);
283
284         val = I915_READ(BXT_PORT_TX_DW2_LN0(phy, ch));
285         val &= ~(MARGIN_000 | UNIQ_TRANS_SCALE);
286         val |= margin << MARGIN_000_SHIFT | scale << UNIQ_TRANS_SCALE_SHIFT;
287         I915_WRITE(BXT_PORT_TX_DW2_GRP(phy, ch), val);
288
289         val = I915_READ(BXT_PORT_TX_DW3_LN0(phy, ch));
290         val &= ~SCALE_DCOMP_METHOD;
291         if (enable)
292                 val |= SCALE_DCOMP_METHOD;
293
294         if ((val & UNIQUE_TRANGE_EN_METHOD) && !(val & SCALE_DCOMP_METHOD))
295                 DRM_ERROR("Disabled scaling while ouniqetrangenmethod was set");
296
297         I915_WRITE(BXT_PORT_TX_DW3_GRP(phy, ch), val);
298
299         val = I915_READ(BXT_PORT_TX_DW4_LN0(phy, ch));
300         val &= ~DE_EMPHASIS;
301         val |= deemphasis << DEEMPH_SHIFT;
302         I915_WRITE(BXT_PORT_TX_DW4_GRP(phy, ch), val);
303
304         val = I915_READ(BXT_PORT_PCS_DW10_LN01(phy, ch));
305         val |= TX2_SWING_CALC_INIT | TX1_SWING_CALC_INIT;
306         I915_WRITE(BXT_PORT_PCS_DW10_GRP(phy, ch), val);
307 }
308
309 bool bxt_ddi_phy_is_enabled(struct drm_i915_private *dev_priv,
310                             enum dpio_phy phy)
311 {
312         const struct bxt_ddi_phy_info *phy_info;
313
314         phy_info = bxt_get_phy_info(dev_priv, phy);
315
316         if (!(I915_READ(BXT_P_CR_GT_DISP_PWRON) & phy_info->pwron_mask))
317                 return false;
318
319         if ((I915_READ(BXT_PORT_CL1CM_DW0(phy)) &
320              (PHY_POWER_GOOD | PHY_RESERVED)) != PHY_POWER_GOOD) {
321                 DRM_DEBUG_DRIVER("DDI PHY %d powered, but power hasn't settled\n",
322                                  phy);
323
324                 return false;
325         }
326
327         if (!(I915_READ(BXT_PHY_CTL_FAMILY(phy)) & COMMON_RESET_DIS)) {
328                 DRM_DEBUG_DRIVER("DDI PHY %d powered, but still in reset\n",
329                                  phy);
330
331                 return false;
332         }
333
334         return true;
335 }
336
337 static u32 bxt_get_grc(struct drm_i915_private *dev_priv, enum dpio_phy phy)
338 {
339         u32 val = I915_READ(BXT_PORT_REF_DW6(phy));
340
341         return (val & GRC_CODE_MASK) >> GRC_CODE_SHIFT;
342 }
343
344 static void bxt_phy_wait_grc_done(struct drm_i915_private *dev_priv,
345                                   enum dpio_phy phy)
346 {
347         if (intel_wait_for_register(&dev_priv->uncore,
348                                     BXT_PORT_REF_DW3(phy),
349                                     GRC_DONE, GRC_DONE,
350                                     10))
351                 DRM_ERROR("timeout waiting for PHY%d GRC\n", phy);
352 }
353
354 static void _bxt_ddi_phy_init(struct drm_i915_private *dev_priv,
355                               enum dpio_phy phy)
356 {
357         const struct bxt_ddi_phy_info *phy_info;
358         u32 val;
359
360         phy_info = bxt_get_phy_info(dev_priv, phy);
361
362         if (bxt_ddi_phy_is_enabled(dev_priv, phy)) {
363                 /* Still read out the GRC value for state verification */
364                 if (phy_info->rcomp_phy != -1)
365                         dev_priv->bxt_phy_grc = bxt_get_grc(dev_priv, phy);
366
367                 if (bxt_ddi_phy_verify_state(dev_priv, phy)) {
368                         DRM_DEBUG_DRIVER("DDI PHY %d already enabled, "
369                                          "won't reprogram it\n", phy);
370                         return;
371                 }
372
373                 DRM_DEBUG_DRIVER("DDI PHY %d enabled with invalid state, "
374                                  "force reprogramming it\n", phy);
375         }
376
377         val = I915_READ(BXT_P_CR_GT_DISP_PWRON);
378         val |= phy_info->pwron_mask;
379         I915_WRITE(BXT_P_CR_GT_DISP_PWRON, val);
380
381         /*
382          * The PHY registers start out inaccessible and respond to reads with
383          * all 1s.  Eventually they become accessible as they power up, then
384          * the reserved bit will give the default 0.  Poll on the reserved bit
385          * becoming 0 to find when the PHY is accessible.
386          * The flag should get set in 100us according to the HW team, but
387          * use 1ms due to occasional timeouts observed with that.
388          */
389         if (intel_wait_for_register_fw(&dev_priv->uncore,
390                                        BXT_PORT_CL1CM_DW0(phy),
391                                        PHY_RESERVED | PHY_POWER_GOOD,
392                                        PHY_POWER_GOOD,
393                                        1))
394                 DRM_ERROR("timeout during PHY%d power on\n", phy);
395
396         /* Program PLL Rcomp code offset */
397         val = I915_READ(BXT_PORT_CL1CM_DW9(phy));
398         val &= ~IREF0RC_OFFSET_MASK;
399         val |= 0xE4 << IREF0RC_OFFSET_SHIFT;
400         I915_WRITE(BXT_PORT_CL1CM_DW9(phy), val);
401
402         val = I915_READ(BXT_PORT_CL1CM_DW10(phy));
403         val &= ~IREF1RC_OFFSET_MASK;
404         val |= 0xE4 << IREF1RC_OFFSET_SHIFT;
405         I915_WRITE(BXT_PORT_CL1CM_DW10(phy), val);
406
407         /* Program power gating */
408         val = I915_READ(BXT_PORT_CL1CM_DW28(phy));
409         val |= OCL1_POWER_DOWN_EN | DW28_OLDO_DYN_PWR_DOWN_EN |
410                 SUS_CLK_CONFIG;
411         I915_WRITE(BXT_PORT_CL1CM_DW28(phy), val);
412
413         if (phy_info->dual_channel) {
414                 val = I915_READ(BXT_PORT_CL2CM_DW6(phy));
415                 val |= DW6_OLDO_DYN_PWR_DOWN_EN;
416                 I915_WRITE(BXT_PORT_CL2CM_DW6(phy), val);
417         }
418
419         if (phy_info->rcomp_phy != -1) {
420                 u32 grc_code;
421
422                 bxt_phy_wait_grc_done(dev_priv, phy_info->rcomp_phy);
423
424                 /*
425                  * PHY0 isn't connected to an RCOMP resistor so copy over
426                  * the corresponding calibrated value from PHY1, and disable
427                  * the automatic calibration on PHY0.
428                  */
429                 val = dev_priv->bxt_phy_grc = bxt_get_grc(dev_priv,
430                                                           phy_info->rcomp_phy);
431                 grc_code = val << GRC_CODE_FAST_SHIFT |
432                            val << GRC_CODE_SLOW_SHIFT |
433                            val;
434                 I915_WRITE(BXT_PORT_REF_DW6(phy), grc_code);
435
436                 val = I915_READ(BXT_PORT_REF_DW8(phy));
437                 val |= GRC_DIS | GRC_RDY_OVRD;
438                 I915_WRITE(BXT_PORT_REF_DW8(phy), val);
439         }
440
441         if (phy_info->reset_delay)
442                 udelay(phy_info->reset_delay);
443
444         val = I915_READ(BXT_PHY_CTL_FAMILY(phy));
445         val |= COMMON_RESET_DIS;
446         I915_WRITE(BXT_PHY_CTL_FAMILY(phy), val);
447 }
448
449 void bxt_ddi_phy_uninit(struct drm_i915_private *dev_priv, enum dpio_phy phy)
450 {
451         const struct bxt_ddi_phy_info *phy_info;
452         u32 val;
453
454         phy_info = bxt_get_phy_info(dev_priv, phy);
455
456         val = I915_READ(BXT_PHY_CTL_FAMILY(phy));
457         val &= ~COMMON_RESET_DIS;
458         I915_WRITE(BXT_PHY_CTL_FAMILY(phy), val);
459
460         val = I915_READ(BXT_P_CR_GT_DISP_PWRON);
461         val &= ~phy_info->pwron_mask;
462         I915_WRITE(BXT_P_CR_GT_DISP_PWRON, val);
463 }
464
465 void bxt_ddi_phy_init(struct drm_i915_private *dev_priv, enum dpio_phy phy)
466 {
467         const struct bxt_ddi_phy_info *phy_info =
468                 bxt_get_phy_info(dev_priv, phy);
469         enum dpio_phy rcomp_phy = phy_info->rcomp_phy;
470         bool was_enabled;
471
472         lockdep_assert_held(&dev_priv->power_domains.lock);
473
474         was_enabled = true;
475         if (rcomp_phy != -1)
476                 was_enabled = bxt_ddi_phy_is_enabled(dev_priv, rcomp_phy);
477
478         /*
479          * We need to copy the GRC calibration value from rcomp_phy,
480          * so make sure it's powered up.
481          */
482         if (!was_enabled)
483                 _bxt_ddi_phy_init(dev_priv, rcomp_phy);
484
485         _bxt_ddi_phy_init(dev_priv, phy);
486
487         if (!was_enabled)
488                 bxt_ddi_phy_uninit(dev_priv, rcomp_phy);
489 }
490
491 static bool __printf(6, 7)
492 __phy_reg_verify_state(struct drm_i915_private *dev_priv, enum dpio_phy phy,
493                        i915_reg_t reg, u32 mask, u32 expected,
494                        const char *reg_fmt, ...)
495 {
496         struct va_format vaf;
497         va_list args;
498         u32 val;
499
500         val = I915_READ(reg);
501         if ((val & mask) == expected)
502                 return true;
503
504         va_start(args, reg_fmt);
505         vaf.fmt = reg_fmt;
506         vaf.va = &args;
507
508         DRM_DEBUG_DRIVER("DDI PHY %d reg %pV [%08x] state mismatch: "
509                          "current %08x, expected %08x (mask %08x)\n",
510                          phy, &vaf, reg.reg, val, (val & ~mask) | expected,
511                          mask);
512
513         va_end(args);
514
515         return false;
516 }
517
518 bool bxt_ddi_phy_verify_state(struct drm_i915_private *dev_priv,
519                               enum dpio_phy phy)
520 {
521         const struct bxt_ddi_phy_info *phy_info;
522         u32 mask;
523         bool ok;
524
525         phy_info = bxt_get_phy_info(dev_priv, phy);
526
527 #define _CHK(reg, mask, exp, fmt, ...)                                  \
528         __phy_reg_verify_state(dev_priv, phy, reg, mask, exp, fmt,      \
529                                ## __VA_ARGS__)
530
531         if (!bxt_ddi_phy_is_enabled(dev_priv, phy))
532                 return false;
533
534         ok = true;
535
536         /* PLL Rcomp code offset */
537         ok &= _CHK(BXT_PORT_CL1CM_DW9(phy),
538                     IREF0RC_OFFSET_MASK, 0xe4 << IREF0RC_OFFSET_SHIFT,
539                     "BXT_PORT_CL1CM_DW9(%d)", phy);
540         ok &= _CHK(BXT_PORT_CL1CM_DW10(phy),
541                     IREF1RC_OFFSET_MASK, 0xe4 << IREF1RC_OFFSET_SHIFT,
542                     "BXT_PORT_CL1CM_DW10(%d)", phy);
543
544         /* Power gating */
545         mask = OCL1_POWER_DOWN_EN | DW28_OLDO_DYN_PWR_DOWN_EN | SUS_CLK_CONFIG;
546         ok &= _CHK(BXT_PORT_CL1CM_DW28(phy), mask, mask,
547                     "BXT_PORT_CL1CM_DW28(%d)", phy);
548
549         if (phy_info->dual_channel)
550                 ok &= _CHK(BXT_PORT_CL2CM_DW6(phy),
551                            DW6_OLDO_DYN_PWR_DOWN_EN, DW6_OLDO_DYN_PWR_DOWN_EN,
552                            "BXT_PORT_CL2CM_DW6(%d)", phy);
553
554         if (phy_info->rcomp_phy != -1) {
555                 u32 grc_code = dev_priv->bxt_phy_grc;
556
557                 grc_code = grc_code << GRC_CODE_FAST_SHIFT |
558                            grc_code << GRC_CODE_SLOW_SHIFT |
559                            grc_code;
560                 mask = GRC_CODE_FAST_MASK | GRC_CODE_SLOW_MASK |
561                        GRC_CODE_NOM_MASK;
562                 ok &= _CHK(BXT_PORT_REF_DW6(phy), mask, grc_code,
563                            "BXT_PORT_REF_DW6(%d)", phy);
564
565                 mask = GRC_DIS | GRC_RDY_OVRD;
566                 ok &= _CHK(BXT_PORT_REF_DW8(phy), mask, mask,
567                             "BXT_PORT_REF_DW8(%d)", phy);
568         }
569
570         return ok;
571 #undef _CHK
572 }
573
574 u8
575 bxt_ddi_phy_calc_lane_lat_optim_mask(u8 lane_count)
576 {
577         switch (lane_count) {
578         case 1:
579                 return 0;
580         case 2:
581                 return BIT(2) | BIT(0);
582         case 4:
583                 return BIT(3) | BIT(2) | BIT(0);
584         default:
585                 MISSING_CASE(lane_count);
586
587                 return 0;
588         }
589 }
590
591 void bxt_ddi_phy_set_lane_optim_mask(struct intel_encoder *encoder,
592                                      u8 lane_lat_optim_mask)
593 {
594         struct drm_i915_private *dev_priv = to_i915(encoder->base.dev);
595         enum port port = encoder->port;
596         enum dpio_phy phy;
597         enum dpio_channel ch;
598         int lane;
599
600         bxt_port_to_phy_channel(dev_priv, port, &phy, &ch);
601
602         for (lane = 0; lane < 4; lane++) {
603                 u32 val = I915_READ(BXT_PORT_TX_DW14_LN(phy, ch, lane));
604
605                 /*
606                  * Note that on CHV this flag is called UPAR, but has
607                  * the same function.
608                  */
609                 val &= ~LATENCY_OPTIM;
610                 if (lane_lat_optim_mask & BIT(lane))
611                         val |= LATENCY_OPTIM;
612
613                 I915_WRITE(BXT_PORT_TX_DW14_LN(phy, ch, lane), val);
614         }
615 }
616
617 u8
618 bxt_ddi_phy_get_lane_lat_optim_mask(struct intel_encoder *encoder)
619 {
620         struct drm_i915_private *dev_priv = to_i915(encoder->base.dev);
621         enum port port = encoder->port;
622         enum dpio_phy phy;
623         enum dpio_channel ch;
624         int lane;
625         u8 mask;
626
627         bxt_port_to_phy_channel(dev_priv, port, &phy, &ch);
628
629         mask = 0;
630         for (lane = 0; lane < 4; lane++) {
631                 u32 val = I915_READ(BXT_PORT_TX_DW14_LN(phy, ch, lane));
632
633                 if (val & LATENCY_OPTIM)
634                         mask |= BIT(lane);
635         }
636
637         return mask;
638 }
639
640
641 void chv_set_phy_signal_level(struct intel_encoder *encoder,
642                               u32 deemph_reg_value, u32 margin_reg_value,
643                               bool uniq_trans_scale)
644 {
645         struct drm_i915_private *dev_priv = to_i915(encoder->base.dev);
646         struct intel_digital_port *dport = enc_to_dig_port(&encoder->base);
647         struct intel_crtc *intel_crtc = to_intel_crtc(encoder->base.crtc);
648         enum dpio_channel ch = vlv_dport_to_channel(dport);
649         enum pipe pipe = intel_crtc->pipe;
650         u32 val;
651         int i;
652
653         vlv_dpio_get(dev_priv);
654
655         /* Clear calc init */
656         val = vlv_dpio_read(dev_priv, pipe, VLV_PCS01_DW10(ch));
657         val &= ~(DPIO_PCS_SWING_CALC_TX0_TX2 | DPIO_PCS_SWING_CALC_TX1_TX3);
658         val &= ~(DPIO_PCS_TX1DEEMP_MASK | DPIO_PCS_TX2DEEMP_MASK);
659         val |= DPIO_PCS_TX1DEEMP_9P5 | DPIO_PCS_TX2DEEMP_9P5;
660         vlv_dpio_write(dev_priv, pipe, VLV_PCS01_DW10(ch), val);
661
662         if (intel_crtc->config->lane_count > 2) {
663                 val = vlv_dpio_read(dev_priv, pipe, VLV_PCS23_DW10(ch));
664                 val &= ~(DPIO_PCS_SWING_CALC_TX0_TX2 | DPIO_PCS_SWING_CALC_TX1_TX3);
665                 val &= ~(DPIO_PCS_TX1DEEMP_MASK | DPIO_PCS_TX2DEEMP_MASK);
666                 val |= DPIO_PCS_TX1DEEMP_9P5 | DPIO_PCS_TX2DEEMP_9P5;
667                 vlv_dpio_write(dev_priv, pipe, VLV_PCS23_DW10(ch), val);
668         }
669
670         val = vlv_dpio_read(dev_priv, pipe, VLV_PCS01_DW9(ch));
671         val &= ~(DPIO_PCS_TX1MARGIN_MASK | DPIO_PCS_TX2MARGIN_MASK);
672         val |= DPIO_PCS_TX1MARGIN_000 | DPIO_PCS_TX2MARGIN_000;
673         vlv_dpio_write(dev_priv, pipe, VLV_PCS01_DW9(ch), val);
674
675         if (intel_crtc->config->lane_count > 2) {
676                 val = vlv_dpio_read(dev_priv, pipe, VLV_PCS23_DW9(ch));
677                 val &= ~(DPIO_PCS_TX1MARGIN_MASK | DPIO_PCS_TX2MARGIN_MASK);
678                 val |= DPIO_PCS_TX1MARGIN_000 | DPIO_PCS_TX2MARGIN_000;
679                 vlv_dpio_write(dev_priv, pipe, VLV_PCS23_DW9(ch), val);
680         }
681
682         /* Program swing deemph */
683         for (i = 0; i < intel_crtc->config->lane_count; i++) {
684                 val = vlv_dpio_read(dev_priv, pipe, CHV_TX_DW4(ch, i));
685                 val &= ~DPIO_SWING_DEEMPH9P5_MASK;
686                 val |= deemph_reg_value << DPIO_SWING_DEEMPH9P5_SHIFT;
687                 vlv_dpio_write(dev_priv, pipe, CHV_TX_DW4(ch, i), val);
688         }
689
690         /* Program swing margin */
691         for (i = 0; i < intel_crtc->config->lane_count; i++) {
692                 val = vlv_dpio_read(dev_priv, pipe, CHV_TX_DW2(ch, i));
693
694                 val &= ~DPIO_SWING_MARGIN000_MASK;
695                 val |= margin_reg_value << DPIO_SWING_MARGIN000_SHIFT;
696
697                 /*
698                  * Supposedly this value shouldn't matter when unique transition
699                  * scale is disabled, but in fact it does matter. Let's just
700                  * always program the same value and hope it's OK.
701                  */
702                 val &= ~(0xff << DPIO_UNIQ_TRANS_SCALE_SHIFT);
703                 val |= 0x9a << DPIO_UNIQ_TRANS_SCALE_SHIFT;
704
705                 vlv_dpio_write(dev_priv, pipe, CHV_TX_DW2(ch, i), val);
706         }
707
708         /*
709          * The document said it needs to set bit 27 for ch0 and bit 26
710          * for ch1. Might be a typo in the doc.
711          * For now, for this unique transition scale selection, set bit
712          * 27 for ch0 and ch1.
713          */
714         for (i = 0; i < intel_crtc->config->lane_count; i++) {
715                 val = vlv_dpio_read(dev_priv, pipe, CHV_TX_DW3(ch, i));
716                 if (uniq_trans_scale)
717                         val |= DPIO_TX_UNIQ_TRANS_SCALE_EN;
718                 else
719                         val &= ~DPIO_TX_UNIQ_TRANS_SCALE_EN;
720                 vlv_dpio_write(dev_priv, pipe, CHV_TX_DW3(ch, i), val);
721         }
722
723         /* Start swing calculation */
724         val = vlv_dpio_read(dev_priv, pipe, VLV_PCS01_DW10(ch));
725         val |= DPIO_PCS_SWING_CALC_TX0_TX2 | DPIO_PCS_SWING_CALC_TX1_TX3;
726         vlv_dpio_write(dev_priv, pipe, VLV_PCS01_DW10(ch), val);
727
728         if (intel_crtc->config->lane_count > 2) {
729                 val = vlv_dpio_read(dev_priv, pipe, VLV_PCS23_DW10(ch));
730                 val |= DPIO_PCS_SWING_CALC_TX0_TX2 | DPIO_PCS_SWING_CALC_TX1_TX3;
731                 vlv_dpio_write(dev_priv, pipe, VLV_PCS23_DW10(ch), val);
732         }
733
734         vlv_dpio_put(dev_priv);
735 }
736
737 void chv_data_lane_soft_reset(struct intel_encoder *encoder,
738                               const struct intel_crtc_state *crtc_state,
739                               bool reset)
740 {
741         struct drm_i915_private *dev_priv = to_i915(encoder->base.dev);
742         enum dpio_channel ch = vlv_dport_to_channel(enc_to_dig_port(&encoder->base));
743         struct intel_crtc *crtc = to_intel_crtc(crtc_state->base.crtc);
744         enum pipe pipe = crtc->pipe;
745         u32 val;
746
747         val = vlv_dpio_read(dev_priv, pipe, VLV_PCS01_DW0(ch));
748         if (reset)
749                 val &= ~(DPIO_PCS_TX_LANE2_RESET | DPIO_PCS_TX_LANE1_RESET);
750         else
751                 val |= DPIO_PCS_TX_LANE2_RESET | DPIO_PCS_TX_LANE1_RESET;
752         vlv_dpio_write(dev_priv, pipe, VLV_PCS01_DW0(ch), val);
753
754         if (crtc_state->lane_count > 2) {
755                 val = vlv_dpio_read(dev_priv, pipe, VLV_PCS23_DW0(ch));
756                 if (reset)
757                         val &= ~(DPIO_PCS_TX_LANE2_RESET | DPIO_PCS_TX_LANE1_RESET);
758                 else
759                         val |= DPIO_PCS_TX_LANE2_RESET | DPIO_PCS_TX_LANE1_RESET;
760                 vlv_dpio_write(dev_priv, pipe, VLV_PCS23_DW0(ch), val);
761         }
762
763         val = vlv_dpio_read(dev_priv, pipe, VLV_PCS01_DW1(ch));
764         val |= CHV_PCS_REQ_SOFTRESET_EN;
765         if (reset)
766                 val &= ~DPIO_PCS_CLK_SOFT_RESET;
767         else
768                 val |= DPIO_PCS_CLK_SOFT_RESET;
769         vlv_dpio_write(dev_priv, pipe, VLV_PCS01_DW1(ch), val);
770
771         if (crtc_state->lane_count > 2) {
772                 val = vlv_dpio_read(dev_priv, pipe, VLV_PCS23_DW1(ch));
773                 val |= CHV_PCS_REQ_SOFTRESET_EN;
774                 if (reset)
775                         val &= ~DPIO_PCS_CLK_SOFT_RESET;
776                 else
777                         val |= DPIO_PCS_CLK_SOFT_RESET;
778                 vlv_dpio_write(dev_priv, pipe, VLV_PCS23_DW1(ch), val);
779         }
780 }
781
782 void chv_phy_pre_pll_enable(struct intel_encoder *encoder,
783                             const struct intel_crtc_state *crtc_state)
784 {
785         struct intel_digital_port *dport = enc_to_dig_port(&encoder->base);
786         struct drm_i915_private *dev_priv = to_i915(encoder->base.dev);
787         struct intel_crtc *crtc = to_intel_crtc(crtc_state->base.crtc);
788         enum dpio_channel ch = vlv_dport_to_channel(dport);
789         enum pipe pipe = crtc->pipe;
790         unsigned int lane_mask =
791                 intel_dp_unused_lane_mask(crtc_state->lane_count);
792         u32 val;
793
794         /*
795          * Must trick the second common lane into life.
796          * Otherwise we can't even access the PLL.
797          */
798         if (ch == DPIO_CH0 && pipe == PIPE_B)
799                 dport->release_cl2_override =
800                         !chv_phy_powergate_ch(dev_priv, DPIO_PHY0, DPIO_CH1, true);
801
802         chv_phy_powergate_lanes(encoder, true, lane_mask);
803
804         vlv_dpio_get(dev_priv);
805
806         /* Assert data lane reset */
807         chv_data_lane_soft_reset(encoder, crtc_state, true);
808
809         /* program left/right clock distribution */
810         if (pipe != PIPE_B) {
811                 val = vlv_dpio_read(dev_priv, pipe, _CHV_CMN_DW5_CH0);
812                 val &= ~(CHV_BUFLEFTENA1_MASK | CHV_BUFRIGHTENA1_MASK);
813                 if (ch == DPIO_CH0)
814                         val |= CHV_BUFLEFTENA1_FORCE;
815                 if (ch == DPIO_CH1)
816                         val |= CHV_BUFRIGHTENA1_FORCE;
817                 vlv_dpio_write(dev_priv, pipe, _CHV_CMN_DW5_CH0, val);
818         } else {
819                 val = vlv_dpio_read(dev_priv, pipe, _CHV_CMN_DW1_CH1);
820                 val &= ~(CHV_BUFLEFTENA2_MASK | CHV_BUFRIGHTENA2_MASK);
821                 if (ch == DPIO_CH0)
822                         val |= CHV_BUFLEFTENA2_FORCE;
823                 if (ch == DPIO_CH1)
824                         val |= CHV_BUFRIGHTENA2_FORCE;
825                 vlv_dpio_write(dev_priv, pipe, _CHV_CMN_DW1_CH1, val);
826         }
827
828         /* program clock channel usage */
829         val = vlv_dpio_read(dev_priv, pipe, VLV_PCS01_DW8(ch));
830         val |= CHV_PCS_USEDCLKCHANNEL_OVRRIDE;
831         if (pipe != PIPE_B)
832                 val &= ~CHV_PCS_USEDCLKCHANNEL;
833         else
834                 val |= CHV_PCS_USEDCLKCHANNEL;
835         vlv_dpio_write(dev_priv, pipe, VLV_PCS01_DW8(ch), val);
836
837         if (crtc_state->lane_count > 2) {
838                 val = vlv_dpio_read(dev_priv, pipe, VLV_PCS23_DW8(ch));
839                 val |= CHV_PCS_USEDCLKCHANNEL_OVRRIDE;
840                 if (pipe != PIPE_B)
841                         val &= ~CHV_PCS_USEDCLKCHANNEL;
842                 else
843                         val |= CHV_PCS_USEDCLKCHANNEL;
844                 vlv_dpio_write(dev_priv, pipe, VLV_PCS23_DW8(ch), val);
845         }
846
847         /*
848          * This a a bit weird since generally CL
849          * matches the pipe, but here we need to
850          * pick the CL based on the port.
851          */
852         val = vlv_dpio_read(dev_priv, pipe, CHV_CMN_DW19(ch));
853         if (pipe != PIPE_B)
854                 val &= ~CHV_CMN_USEDCLKCHANNEL;
855         else
856                 val |= CHV_CMN_USEDCLKCHANNEL;
857         vlv_dpio_write(dev_priv, pipe, CHV_CMN_DW19(ch), val);
858
859         vlv_dpio_put(dev_priv);
860 }
861
862 void chv_phy_pre_encoder_enable(struct intel_encoder *encoder,
863                                 const struct intel_crtc_state *crtc_state)
864 {
865         struct intel_dp *intel_dp = enc_to_intel_dp(&encoder->base);
866         struct intel_digital_port *dport = dp_to_dig_port(intel_dp);
867         struct drm_i915_private *dev_priv = to_i915(encoder->base.dev);
868         struct intel_crtc *crtc = to_intel_crtc(crtc_state->base.crtc);
869         enum dpio_channel ch = vlv_dport_to_channel(dport);
870         enum pipe pipe = crtc->pipe;
871         int data, i, stagger;
872         u32 val;
873
874         vlv_dpio_get(dev_priv);
875
876         /* allow hardware to manage TX FIFO reset source */
877         val = vlv_dpio_read(dev_priv, pipe, VLV_PCS01_DW11(ch));
878         val &= ~DPIO_LANEDESKEW_STRAP_OVRD;
879         vlv_dpio_write(dev_priv, pipe, VLV_PCS01_DW11(ch), val);
880
881         if (crtc_state->lane_count > 2) {
882                 val = vlv_dpio_read(dev_priv, pipe, VLV_PCS23_DW11(ch));
883                 val &= ~DPIO_LANEDESKEW_STRAP_OVRD;
884                 vlv_dpio_write(dev_priv, pipe, VLV_PCS23_DW11(ch), val);
885         }
886
887         /* Program Tx lane latency optimal setting*/
888         for (i = 0; i < crtc_state->lane_count; i++) {
889                 /* Set the upar bit */
890                 if (crtc_state->lane_count == 1)
891                         data = 0x0;
892                 else
893                         data = (i == 1) ? 0x0 : 0x1;
894                 vlv_dpio_write(dev_priv, pipe, CHV_TX_DW14(ch, i),
895                                 data << DPIO_UPAR_SHIFT);
896         }
897
898         /* Data lane stagger programming */
899         if (crtc_state->port_clock > 270000)
900                 stagger = 0x18;
901         else if (crtc_state->port_clock > 135000)
902                 stagger = 0xd;
903         else if (crtc_state->port_clock > 67500)
904                 stagger = 0x7;
905         else if (crtc_state->port_clock > 33750)
906                 stagger = 0x4;
907         else
908                 stagger = 0x2;
909
910         val = vlv_dpio_read(dev_priv, pipe, VLV_PCS01_DW11(ch));
911         val |= DPIO_TX2_STAGGER_MASK(0x1f);
912         vlv_dpio_write(dev_priv, pipe, VLV_PCS01_DW11(ch), val);
913
914         if (crtc_state->lane_count > 2) {
915                 val = vlv_dpio_read(dev_priv, pipe, VLV_PCS23_DW11(ch));
916                 val |= DPIO_TX2_STAGGER_MASK(0x1f);
917                 vlv_dpio_write(dev_priv, pipe, VLV_PCS23_DW11(ch), val);
918         }
919
920         vlv_dpio_write(dev_priv, pipe, VLV_PCS01_DW12(ch),
921                        DPIO_LANESTAGGER_STRAP(stagger) |
922                        DPIO_LANESTAGGER_STRAP_OVRD |
923                        DPIO_TX1_STAGGER_MASK(0x1f) |
924                        DPIO_TX1_STAGGER_MULT(6) |
925                        DPIO_TX2_STAGGER_MULT(0));
926
927         if (crtc_state->lane_count > 2) {
928                 vlv_dpio_write(dev_priv, pipe, VLV_PCS23_DW12(ch),
929                                DPIO_LANESTAGGER_STRAP(stagger) |
930                                DPIO_LANESTAGGER_STRAP_OVRD |
931                                DPIO_TX1_STAGGER_MASK(0x1f) |
932                                DPIO_TX1_STAGGER_MULT(7) |
933                                DPIO_TX2_STAGGER_MULT(5));
934         }
935
936         /* Deassert data lane reset */
937         chv_data_lane_soft_reset(encoder, crtc_state, false);
938
939         vlv_dpio_put(dev_priv);
940 }
941
942 void chv_phy_release_cl2_override(struct intel_encoder *encoder)
943 {
944         struct intel_digital_port *dport = enc_to_dig_port(&encoder->base);
945         struct drm_i915_private *dev_priv = to_i915(encoder->base.dev);
946
947         if (dport->release_cl2_override) {
948                 chv_phy_powergate_ch(dev_priv, DPIO_PHY0, DPIO_CH1, false);
949                 dport->release_cl2_override = false;
950         }
951 }
952
953 void chv_phy_post_pll_disable(struct intel_encoder *encoder,
954                               const struct intel_crtc_state *old_crtc_state)
955 {
956         struct drm_i915_private *dev_priv = to_i915(encoder->base.dev);
957         enum pipe pipe = to_intel_crtc(old_crtc_state->base.crtc)->pipe;
958         u32 val;
959
960         vlv_dpio_get(dev_priv);
961
962         /* disable left/right clock distribution */
963         if (pipe != PIPE_B) {
964                 val = vlv_dpio_read(dev_priv, pipe, _CHV_CMN_DW5_CH0);
965                 val &= ~(CHV_BUFLEFTENA1_MASK | CHV_BUFRIGHTENA1_MASK);
966                 vlv_dpio_write(dev_priv, pipe, _CHV_CMN_DW5_CH0, val);
967         } else {
968                 val = vlv_dpio_read(dev_priv, pipe, _CHV_CMN_DW1_CH1);
969                 val &= ~(CHV_BUFLEFTENA2_MASK | CHV_BUFRIGHTENA2_MASK);
970                 vlv_dpio_write(dev_priv, pipe, _CHV_CMN_DW1_CH1, val);
971         }
972
973         vlv_dpio_put(dev_priv);
974
975         /*
976          * Leave the power down bit cleared for at least one
977          * lane so that chv_powergate_phy_ch() will power
978          * on something when the channel is otherwise unused.
979          * When the port is off and the override is removed
980          * the lanes power down anyway, so otherwise it doesn't
981          * really matter what the state of power down bits is
982          * after this.
983          */
984         chv_phy_powergate_lanes(encoder, false, 0x0);
985 }
986
987 void vlv_set_phy_signal_level(struct intel_encoder *encoder,
988                               u32 demph_reg_value, u32 preemph_reg_value,
989                               u32 uniqtranscale_reg_value, u32 tx3_demph)
990 {
991         struct drm_i915_private *dev_priv = to_i915(encoder->base.dev);
992         struct intel_crtc *intel_crtc = to_intel_crtc(encoder->base.crtc);
993         struct intel_digital_port *dport = enc_to_dig_port(&encoder->base);
994         enum dpio_channel port = vlv_dport_to_channel(dport);
995         enum pipe pipe = intel_crtc->pipe;
996
997         vlv_dpio_get(dev_priv);
998
999         vlv_dpio_write(dev_priv, pipe, VLV_TX_DW5(port), 0x00000000);
1000         vlv_dpio_write(dev_priv, pipe, VLV_TX_DW4(port), demph_reg_value);
1001         vlv_dpio_write(dev_priv, pipe, VLV_TX_DW2(port),
1002                          uniqtranscale_reg_value);
1003         vlv_dpio_write(dev_priv, pipe, VLV_TX_DW3(port), 0x0C782040);
1004
1005         if (tx3_demph)
1006                 vlv_dpio_write(dev_priv, pipe, VLV_TX3_DW4(port), tx3_demph);
1007
1008         vlv_dpio_write(dev_priv, pipe, VLV_PCS_DW11(port), 0x00030000);
1009         vlv_dpio_write(dev_priv, pipe, VLV_PCS_DW9(port), preemph_reg_value);
1010         vlv_dpio_write(dev_priv, pipe, VLV_TX_DW5(port), DPIO_TX_OCALINIT_EN);
1011
1012         vlv_dpio_put(dev_priv);
1013 }
1014
1015 void vlv_phy_pre_pll_enable(struct intel_encoder *encoder,
1016                             const struct intel_crtc_state *crtc_state)
1017 {
1018         struct intel_digital_port *dport = enc_to_dig_port(&encoder->base);
1019         struct drm_i915_private *dev_priv = to_i915(encoder->base.dev);
1020         struct intel_crtc *crtc = to_intel_crtc(crtc_state->base.crtc);
1021         enum dpio_channel port = vlv_dport_to_channel(dport);
1022         enum pipe pipe = crtc->pipe;
1023
1024         /* Program Tx lane resets to default */
1025         vlv_dpio_get(dev_priv);
1026
1027         vlv_dpio_write(dev_priv, pipe, VLV_PCS_DW0(port),
1028                          DPIO_PCS_TX_LANE2_RESET |
1029                          DPIO_PCS_TX_LANE1_RESET);
1030         vlv_dpio_write(dev_priv, pipe, VLV_PCS_DW1(port),
1031                          DPIO_PCS_CLK_CRI_RXEB_EIOS_EN |
1032                          DPIO_PCS_CLK_CRI_RXDIGFILTSG_EN |
1033                          (1<<DPIO_PCS_CLK_DATAWIDTH_SHIFT) |
1034                                  DPIO_PCS_CLK_SOFT_RESET);
1035
1036         /* Fix up inter-pair skew failure */
1037         vlv_dpio_write(dev_priv, pipe, VLV_PCS_DW12(port), 0x00750f00);
1038         vlv_dpio_write(dev_priv, pipe, VLV_TX_DW11(port), 0x00001500);
1039         vlv_dpio_write(dev_priv, pipe, VLV_TX_DW14(port), 0x40400000);
1040
1041         vlv_dpio_put(dev_priv);
1042 }
1043
1044 void vlv_phy_pre_encoder_enable(struct intel_encoder *encoder,
1045                                 const struct intel_crtc_state *crtc_state)
1046 {
1047         struct intel_dp *intel_dp = enc_to_intel_dp(&encoder->base);
1048         struct intel_digital_port *dport = dp_to_dig_port(intel_dp);
1049         struct drm_i915_private *dev_priv = to_i915(encoder->base.dev);
1050         struct intel_crtc *crtc = to_intel_crtc(crtc_state->base.crtc);
1051         enum dpio_channel port = vlv_dport_to_channel(dport);
1052         enum pipe pipe = crtc->pipe;
1053         u32 val;
1054
1055         vlv_dpio_get(dev_priv);
1056
1057         /* Enable clock channels for this port */
1058         val = vlv_dpio_read(dev_priv, pipe, VLV_PCS01_DW8(port));
1059         val = 0;
1060         if (pipe)
1061                 val |= (1<<21);
1062         else
1063                 val &= ~(1<<21);
1064         val |= 0x001000c4;
1065         vlv_dpio_write(dev_priv, pipe, VLV_PCS_DW8(port), val);
1066
1067         /* Program lane clock */
1068         vlv_dpio_write(dev_priv, pipe, VLV_PCS_DW14(port), 0x00760018);
1069         vlv_dpio_write(dev_priv, pipe, VLV_PCS_DW23(port), 0x00400888);
1070
1071         vlv_dpio_put(dev_priv);
1072 }
1073
1074 void vlv_phy_reset_lanes(struct intel_encoder *encoder,
1075                          const struct intel_crtc_state *old_crtc_state)
1076 {
1077         struct intel_digital_port *dport = enc_to_dig_port(&encoder->base);
1078         struct drm_i915_private *dev_priv = to_i915(encoder->base.dev);
1079         struct intel_crtc *crtc = to_intel_crtc(old_crtc_state->base.crtc);
1080         enum dpio_channel port = vlv_dport_to_channel(dport);
1081         enum pipe pipe = crtc->pipe;
1082
1083         vlv_dpio_get(dev_priv);
1084         vlv_dpio_write(dev_priv, pipe, VLV_PCS_DW0(port), 0x00000000);
1085         vlv_dpio_write(dev_priv, pipe, VLV_PCS_DW1(port), 0x00e00060);
1086         vlv_dpio_put(dev_priv);
1087 }