aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/i915/intel_dp.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/gpu/drm/i915/intel_dp.c')
-rw-r--r--drivers/gpu/drm/i915/intel_dp.c191
1 files changed, 110 insertions, 81 deletions
diff --git a/drivers/gpu/drm/i915/intel_dp.c b/drivers/gpu/drm/i915/intel_dp.c
index 30c627c7b7ba..2688f6d64bb9 100644
--- a/drivers/gpu/drm/i915/intel_dp.c
+++ b/drivers/gpu/drm/i915/intel_dp.c
@@ -142,7 +142,7 @@ intel_dp_max_data_rate(int max_link_clock, int max_lanes)
142 return (max_link_clock * max_lanes * 8) / 10; 142 return (max_link_clock * max_lanes * 8) / 10;
143} 143}
144 144
145static int 145static enum drm_mode_status
146intel_dp_mode_valid(struct drm_connector *connector, 146intel_dp_mode_valid(struct drm_connector *connector,
147 struct drm_display_mode *mode) 147 struct drm_display_mode *mode)
148{ 148{
@@ -404,7 +404,7 @@ intel_dp_aux_ch(struct intel_dp *intel_dp,
404 int i, ret, recv_bytes; 404 int i, ret, recv_bytes;
405 uint32_t status; 405 uint32_t status;
406 int try, precharge, clock = 0; 406 int try, precharge, clock = 0;
407 bool has_aux_irq = INTEL_INFO(dev)->gen >= 5 && !IS_VALLEYVIEW(dev); 407 bool has_aux_irq = HAS_AUX_IRQ(dev);
408 uint32_t timeout; 408 uint32_t timeout;
409 409
410 /* dp aux is extremely sensitive to irq latency, hence request the 410 /* dp aux is extremely sensitive to irq latency, hence request the
@@ -537,29 +537,33 @@ intel_dp_aux_native_write(struct intel_dp *intel_dp,
537 uint8_t msg[20]; 537 uint8_t msg[20];
538 int msg_bytes; 538 int msg_bytes;
539 uint8_t ack; 539 uint8_t ack;
540 int retry;
540 541
541 if (WARN_ON(send_bytes > 16)) 542 if (WARN_ON(send_bytes > 16))
542 return -E2BIG; 543 return -E2BIG;
543 544
544 intel_dp_check_edp(intel_dp); 545 intel_dp_check_edp(intel_dp);
545 msg[0] = AUX_NATIVE_WRITE << 4; 546 msg[0] = DP_AUX_NATIVE_WRITE << 4;
546 msg[1] = address >> 8; 547 msg[1] = address >> 8;
547 msg[2] = address & 0xff; 548 msg[2] = address & 0xff;
548 msg[3] = send_bytes - 1; 549 msg[3] = send_bytes - 1;
549 memcpy(&msg[4], send, send_bytes); 550 memcpy(&msg[4], send, send_bytes);
550 msg_bytes = send_bytes + 4; 551 msg_bytes = send_bytes + 4;
551 for (;;) { 552 for (retry = 0; retry < 7; retry++) {
552 ret = intel_dp_aux_ch(intel_dp, msg, msg_bytes, &ack, 1); 553 ret = intel_dp_aux_ch(intel_dp, msg, msg_bytes, &ack, 1);
553 if (ret < 0) 554 if (ret < 0)
554 return ret; 555 return ret;
555 if ((ack & AUX_NATIVE_REPLY_MASK) == AUX_NATIVE_REPLY_ACK) 556 ack >>= 4;
556 break; 557 if ((ack & DP_AUX_NATIVE_REPLY_MASK) == DP_AUX_NATIVE_REPLY_ACK)
557 else if ((ack & AUX_NATIVE_REPLY_MASK) == AUX_NATIVE_REPLY_DEFER) 558 return send_bytes;
558 udelay(100); 559 else if ((ack & DP_AUX_NATIVE_REPLY_MASK) == DP_AUX_NATIVE_REPLY_DEFER)
560 usleep_range(400, 500);
559 else 561 else
560 return -EIO; 562 return -EIO;
561 } 563 }
562 return send_bytes; 564
565 DRM_ERROR("too many retries, giving up\n");
566 return -EIO;
563} 567}
564 568
565/* Write a single byte to the aux channel in native mode */ 569/* Write a single byte to the aux channel in native mode */
@@ -581,12 +585,13 @@ intel_dp_aux_native_read(struct intel_dp *intel_dp,
581 int reply_bytes; 585 int reply_bytes;
582 uint8_t ack; 586 uint8_t ack;
583 int ret; 587 int ret;
588 int retry;
584 589
585 if (WARN_ON(recv_bytes > 19)) 590 if (WARN_ON(recv_bytes > 19))
586 return -E2BIG; 591 return -E2BIG;
587 592
588 intel_dp_check_edp(intel_dp); 593 intel_dp_check_edp(intel_dp);
589 msg[0] = AUX_NATIVE_READ << 4; 594 msg[0] = DP_AUX_NATIVE_READ << 4;
590 msg[1] = address >> 8; 595 msg[1] = address >> 8;
591 msg[2] = address & 0xff; 596 msg[2] = address & 0xff;
592 msg[3] = recv_bytes - 1; 597 msg[3] = recv_bytes - 1;
@@ -594,23 +599,26 @@ intel_dp_aux_native_read(struct intel_dp *intel_dp,
594 msg_bytes = 4; 599 msg_bytes = 4;
595 reply_bytes = recv_bytes + 1; 600 reply_bytes = recv_bytes + 1;
596 601
597 for (;;) { 602 for (retry = 0; retry < 7; retry++) {
598 ret = intel_dp_aux_ch(intel_dp, msg, msg_bytes, 603 ret = intel_dp_aux_ch(intel_dp, msg, msg_bytes,
599 reply, reply_bytes); 604 reply, reply_bytes);
600 if (ret == 0) 605 if (ret == 0)
601 return -EPROTO; 606 return -EPROTO;
602 if (ret < 0) 607 if (ret < 0)
603 return ret; 608 return ret;
604 ack = reply[0]; 609 ack = reply[0] >> 4;
605 if ((ack & AUX_NATIVE_REPLY_MASK) == AUX_NATIVE_REPLY_ACK) { 610 if ((ack & DP_AUX_NATIVE_REPLY_MASK) == DP_AUX_NATIVE_REPLY_ACK) {
606 memcpy(recv, reply + 1, ret - 1); 611 memcpy(recv, reply + 1, ret - 1);
607 return ret - 1; 612 return ret - 1;
608 } 613 }
609 else if ((ack & AUX_NATIVE_REPLY_MASK) == AUX_NATIVE_REPLY_DEFER) 614 else if ((ack & DP_AUX_NATIVE_REPLY_MASK) == DP_AUX_NATIVE_REPLY_DEFER)
610 udelay(100); 615 usleep_range(400, 500);
611 else 616 else
612 return -EIO; 617 return -EIO;
613 } 618 }
619
620 DRM_ERROR("too many retries, giving up\n");
621 return -EIO;
614} 622}
615 623
616static int 624static int
@@ -633,12 +641,12 @@ intel_dp_i2c_aux_ch(struct i2c_adapter *adapter, int mode,
633 intel_dp_check_edp(intel_dp); 641 intel_dp_check_edp(intel_dp);
634 /* Set up the command byte */ 642 /* Set up the command byte */
635 if (mode & MODE_I2C_READ) 643 if (mode & MODE_I2C_READ)
636 msg[0] = AUX_I2C_READ << 4; 644 msg[0] = DP_AUX_I2C_READ << 4;
637 else 645 else
638 msg[0] = AUX_I2C_WRITE << 4; 646 msg[0] = DP_AUX_I2C_WRITE << 4;
639 647
640 if (!(mode & MODE_I2C_STOP)) 648 if (!(mode & MODE_I2C_STOP))
641 msg[0] |= AUX_I2C_MOT << 4; 649 msg[0] |= DP_AUX_I2C_MOT << 4;
642 650
643 msg[1] = address >> 8; 651 msg[1] = address >> 8;
644 msg[2] = address; 652 msg[2] = address;
@@ -675,17 +683,17 @@ intel_dp_i2c_aux_ch(struct i2c_adapter *adapter, int mode,
675 goto out; 683 goto out;
676 } 684 }
677 685
678 switch (reply[0] & AUX_NATIVE_REPLY_MASK) { 686 switch ((reply[0] >> 4) & DP_AUX_NATIVE_REPLY_MASK) {
679 case AUX_NATIVE_REPLY_ACK: 687 case DP_AUX_NATIVE_REPLY_ACK:
680 /* I2C-over-AUX Reply field is only valid 688 /* I2C-over-AUX Reply field is only valid
681 * when paired with AUX ACK. 689 * when paired with AUX ACK.
682 */ 690 */
683 break; 691 break;
684 case AUX_NATIVE_REPLY_NACK: 692 case DP_AUX_NATIVE_REPLY_NACK:
685 DRM_DEBUG_KMS("aux_ch native nack\n"); 693 DRM_DEBUG_KMS("aux_ch native nack\n");
686 ret = -EREMOTEIO; 694 ret = -EREMOTEIO;
687 goto out; 695 goto out;
688 case AUX_NATIVE_REPLY_DEFER: 696 case DP_AUX_NATIVE_REPLY_DEFER:
689 /* 697 /*
690 * For now, just give more slack to branch devices. We 698 * For now, just give more slack to branch devices. We
691 * could check the DPCD for I2C bit rate capabilities, 699 * could check the DPCD for I2C bit rate capabilities,
@@ -706,18 +714,18 @@ intel_dp_i2c_aux_ch(struct i2c_adapter *adapter, int mode,
706 goto out; 714 goto out;
707 } 715 }
708 716
709 switch (reply[0] & AUX_I2C_REPLY_MASK) { 717 switch ((reply[0] >> 4) & DP_AUX_I2C_REPLY_MASK) {
710 case AUX_I2C_REPLY_ACK: 718 case DP_AUX_I2C_REPLY_ACK:
711 if (mode == MODE_I2C_READ) { 719 if (mode == MODE_I2C_READ) {
712 *read_byte = reply[1]; 720 *read_byte = reply[1];
713 } 721 }
714 ret = reply_bytes - 1; 722 ret = reply_bytes - 1;
715 goto out; 723 goto out;
716 case AUX_I2C_REPLY_NACK: 724 case DP_AUX_I2C_REPLY_NACK:
717 DRM_DEBUG_KMS("aux_i2c nack\n"); 725 DRM_DEBUG_KMS("aux_i2c nack\n");
718 ret = -EREMOTEIO; 726 ret = -EREMOTEIO;
719 goto out; 727 goto out;
720 case AUX_I2C_REPLY_DEFER: 728 case DP_AUX_I2C_REPLY_DEFER:
721 DRM_DEBUG_KMS("aux_i2c defer\n"); 729 DRM_DEBUG_KMS("aux_i2c defer\n");
722 udelay(100); 730 udelay(100);
723 break; 731 break;
@@ -1037,6 +1045,8 @@ static void ironlake_wait_panel_status(struct intel_dp *intel_dp,
1037 I915_READ(pp_stat_reg), 1045 I915_READ(pp_stat_reg),
1038 I915_READ(pp_ctrl_reg)); 1046 I915_READ(pp_ctrl_reg));
1039 } 1047 }
1048
1049 DRM_DEBUG_KMS("Wait complete\n");
1040} 1050}
1041 1051
1042static void ironlake_wait_panel_on(struct intel_dp *intel_dp) 1052static void ironlake_wait_panel_on(struct intel_dp *intel_dp)
@@ -1092,6 +1102,8 @@ void ironlake_edp_panel_vdd_on(struct intel_dp *intel_dp)
1092 if (ironlake_edp_have_panel_vdd(intel_dp)) 1102 if (ironlake_edp_have_panel_vdd(intel_dp))
1093 return; 1103 return;
1094 1104
1105 intel_runtime_pm_get(dev_priv);
1106
1095 DRM_DEBUG_KMS("Turning eDP VDD on\n"); 1107 DRM_DEBUG_KMS("Turning eDP VDD on\n");
1096 1108
1097 if (!ironlake_edp_have_panel_power(intel_dp)) 1109 if (!ironlake_edp_have_panel_power(intel_dp))
@@ -1140,7 +1152,11 @@ static void ironlake_panel_vdd_off_sync(struct intel_dp *intel_dp)
1140 /* Make sure sequencer is idle before allowing subsequent activity */ 1152 /* Make sure sequencer is idle before allowing subsequent activity */
1141 DRM_DEBUG_KMS("PP_STATUS: 0x%08x PP_CONTROL: 0x%08x\n", 1153 DRM_DEBUG_KMS("PP_STATUS: 0x%08x PP_CONTROL: 0x%08x\n",
1142 I915_READ(pp_stat_reg), I915_READ(pp_ctrl_reg)); 1154 I915_READ(pp_stat_reg), I915_READ(pp_ctrl_reg));
1143 msleep(intel_dp->panel_power_down_delay); 1155
1156 if ((pp & POWER_TARGET_ON) == 0)
1157 msleep(intel_dp->panel_power_cycle_delay);
1158
1159 intel_runtime_pm_put(dev_priv);
1144 } 1160 }
1145} 1161}
1146 1162
@@ -1248,6 +1264,9 @@ void ironlake_edp_panel_off(struct intel_dp *intel_dp)
1248 intel_dp->want_panel_vdd = false; 1264 intel_dp->want_panel_vdd = false;
1249 1265
1250 ironlake_wait_panel_off(intel_dp); 1266 ironlake_wait_panel_off(intel_dp);
1267
1268 /* We got a reference when we enabled the VDD. */
1269 intel_runtime_pm_put(dev_priv);
1251} 1270}
1252 1271
1253void ironlake_edp_backlight_on(struct intel_dp *intel_dp) 1272void ironlake_edp_backlight_on(struct intel_dp *intel_dp)
@@ -1627,7 +1646,7 @@ static void intel_edp_psr_enable_source(struct intel_dp *intel_dp)
1627 val |= EDP_PSR_LINK_DISABLE; 1646 val |= EDP_PSR_LINK_DISABLE;
1628 1647
1629 I915_WRITE(EDP_PSR_CTL(dev), val | 1648 I915_WRITE(EDP_PSR_CTL(dev), val |
1630 IS_BROADWELL(dev) ? 0 : link_entry_time | 1649 (IS_BROADWELL(dev) ? 0 : link_entry_time) |
1631 max_sleep_time << EDP_PSR_MAX_SLEEP_TIME_SHIFT | 1650 max_sleep_time << EDP_PSR_MAX_SLEEP_TIME_SHIFT |
1632 idle_frames << EDP_PSR_IDLE_FRAME_SHIFT | 1651 idle_frames << EDP_PSR_IDLE_FRAME_SHIFT |
1633 EDP_PSR_ENABLE); 1652 EDP_PSR_ENABLE);
@@ -1845,34 +1864,36 @@ static void vlv_pre_enable_dp(struct intel_encoder *encoder)
1845 struct drm_device *dev = encoder->base.dev; 1864 struct drm_device *dev = encoder->base.dev;
1846 struct drm_i915_private *dev_priv = dev->dev_private; 1865 struct drm_i915_private *dev_priv = dev->dev_private;
1847 struct intel_crtc *intel_crtc = to_intel_crtc(encoder->base.crtc); 1866 struct intel_crtc *intel_crtc = to_intel_crtc(encoder->base.crtc);
1848 int port = vlv_dport_to_channel(dport); 1867 enum dpio_channel port = vlv_dport_to_channel(dport);
1849 int pipe = intel_crtc->pipe; 1868 int pipe = intel_crtc->pipe;
1850 struct edp_power_seq power_seq; 1869 struct edp_power_seq power_seq;
1851 u32 val; 1870 u32 val;
1852 1871
1853 mutex_lock(&dev_priv->dpio_lock); 1872 mutex_lock(&dev_priv->dpio_lock);
1854 1873
1855 val = vlv_dpio_read(dev_priv, pipe, DPIO_DATA_LANE_A(port)); 1874 val = vlv_dpio_read(dev_priv, pipe, VLV_PCS01_DW8(port));
1856 val = 0; 1875 val = 0;
1857 if (pipe) 1876 if (pipe)
1858 val |= (1<<21); 1877 val |= (1<<21);
1859 else 1878 else
1860 val &= ~(1<<21); 1879 val &= ~(1<<21);
1861 val |= 0x001000c4; 1880 val |= 0x001000c4;
1862 vlv_dpio_write(dev_priv, pipe, DPIO_DATA_CHANNEL(port), val); 1881 vlv_dpio_write(dev_priv, pipe, VLV_PCS_DW8(port), val);
1863 vlv_dpio_write(dev_priv, pipe, DPIO_PCS_CLOCKBUF0(port), 0x00760018); 1882 vlv_dpio_write(dev_priv, pipe, VLV_PCS_DW14(port), 0x00760018);
1864 vlv_dpio_write(dev_priv, pipe, DPIO_PCS_CLOCKBUF8(port), 0x00400888); 1883 vlv_dpio_write(dev_priv, pipe, VLV_PCS_DW23(port), 0x00400888);
1865 1884
1866 mutex_unlock(&dev_priv->dpio_lock); 1885 mutex_unlock(&dev_priv->dpio_lock);
1867 1886
1868 /* init power sequencer on this pipe and port */ 1887 if (is_edp(intel_dp)) {
1869 intel_dp_init_panel_power_sequencer(dev, intel_dp, &power_seq); 1888 /* init power sequencer on this pipe and port */
1870 intel_dp_init_panel_power_sequencer_registers(dev, intel_dp, 1889 intel_dp_init_panel_power_sequencer(dev, intel_dp, &power_seq);
1871 &power_seq); 1890 intel_dp_init_panel_power_sequencer_registers(dev, intel_dp,
1891 &power_seq);
1892 }
1872 1893
1873 intel_enable_dp(encoder); 1894 intel_enable_dp(encoder);
1874 1895
1875 vlv_wait_port_ready(dev_priv, port); 1896 vlv_wait_port_ready(dev_priv, dport);
1876} 1897}
1877 1898
1878static void vlv_dp_pre_pll_enable(struct intel_encoder *encoder) 1899static void vlv_dp_pre_pll_enable(struct intel_encoder *encoder)
@@ -1882,24 +1903,24 @@ static void vlv_dp_pre_pll_enable(struct intel_encoder *encoder)
1882 struct drm_i915_private *dev_priv = dev->dev_private; 1903 struct drm_i915_private *dev_priv = dev->dev_private;
1883 struct intel_crtc *intel_crtc = 1904 struct intel_crtc *intel_crtc =
1884 to_intel_crtc(encoder->base.crtc); 1905 to_intel_crtc(encoder->base.crtc);
1885 int port = vlv_dport_to_channel(dport); 1906 enum dpio_channel port = vlv_dport_to_channel(dport);
1886 int pipe = intel_crtc->pipe; 1907 int pipe = intel_crtc->pipe;
1887 1908
1888 /* Program Tx lane resets to default */ 1909 /* Program Tx lane resets to default */
1889 mutex_lock(&dev_priv->dpio_lock); 1910 mutex_lock(&dev_priv->dpio_lock);
1890 vlv_dpio_write(dev_priv, pipe, DPIO_PCS_TX(port), 1911 vlv_dpio_write(dev_priv, pipe, VLV_PCS_DW0(port),
1891 DPIO_PCS_TX_LANE2_RESET | 1912 DPIO_PCS_TX_LANE2_RESET |
1892 DPIO_PCS_TX_LANE1_RESET); 1913 DPIO_PCS_TX_LANE1_RESET);
1893 vlv_dpio_write(dev_priv, pipe, DPIO_PCS_CLK(port), 1914 vlv_dpio_write(dev_priv, pipe, VLV_PCS_DW1(port),
1894 DPIO_PCS_CLK_CRI_RXEB_EIOS_EN | 1915 DPIO_PCS_CLK_CRI_RXEB_EIOS_EN |
1895 DPIO_PCS_CLK_CRI_RXDIGFILTSG_EN | 1916 DPIO_PCS_CLK_CRI_RXDIGFILTSG_EN |
1896 (1<<DPIO_PCS_CLK_DATAWIDTH_SHIFT) | 1917 (1<<DPIO_PCS_CLK_DATAWIDTH_SHIFT) |
1897 DPIO_PCS_CLK_SOFT_RESET); 1918 DPIO_PCS_CLK_SOFT_RESET);
1898 1919
1899 /* Fix up inter-pair skew failure */ 1920 /* Fix up inter-pair skew failure */
1900 vlv_dpio_write(dev_priv, pipe, DPIO_PCS_STAGGER1(port), 0x00750f00); 1921 vlv_dpio_write(dev_priv, pipe, VLV_PCS_DW12(port), 0x00750f00);
1901 vlv_dpio_write(dev_priv, pipe, DPIO_TX_CTL(port), 0x00001500); 1922 vlv_dpio_write(dev_priv, pipe, VLV_TX_DW11(port), 0x00001500);
1902 vlv_dpio_write(dev_priv, pipe, DPIO_TX_LANE(port), 0x40400000); 1923 vlv_dpio_write(dev_priv, pipe, VLV_TX_DW14(port), 0x40400000);
1903 mutex_unlock(&dev_priv->dpio_lock); 1924 mutex_unlock(&dev_priv->dpio_lock);
1904} 1925}
1905 1926
@@ -1941,18 +1962,6 @@ intel_dp_get_link_status(struct intel_dp *intel_dp, uint8_t link_status[DP_LINK_
1941 DP_LINK_STATUS_SIZE); 1962 DP_LINK_STATUS_SIZE);
1942} 1963}
1943 1964
1944#if 0
1945static char *voltage_names[] = {
1946 "0.4V", "0.6V", "0.8V", "1.2V"
1947};
1948static char *pre_emph_names[] = {
1949 "0dB", "3.5dB", "6dB", "9.5dB"
1950};
1951static char *link_train_names[] = {
1952 "pattern 1", "pattern 2", "idle", "off"
1953};
1954#endif
1955
1956/* 1965/*
1957 * These are source-specific values; current Intel hardware supports 1966 * These are source-specific values; current Intel hardware supports
1958 * a maximum voltage of 800mV and a maximum pre-emphasis of 6dB 1967 * a maximum voltage of 800mV and a maximum pre-emphasis of 6dB
@@ -2050,7 +2059,7 @@ static uint32_t intel_vlv_signal_levels(struct intel_dp *intel_dp)
2050 unsigned long demph_reg_value, preemph_reg_value, 2059 unsigned long demph_reg_value, preemph_reg_value,
2051 uniqtranscale_reg_value; 2060 uniqtranscale_reg_value;
2052 uint8_t train_set = intel_dp->train_set[0]; 2061 uint8_t train_set = intel_dp->train_set[0];
2053 int port = vlv_dport_to_channel(dport); 2062 enum dpio_channel port = vlv_dport_to_channel(dport);
2054 int pipe = intel_crtc->pipe; 2063 int pipe = intel_crtc->pipe;
2055 2064
2056 switch (train_set & DP_TRAIN_PRE_EMPHASIS_MASK) { 2065 switch (train_set & DP_TRAIN_PRE_EMPHASIS_MASK) {
@@ -2127,14 +2136,14 @@ static uint32_t intel_vlv_signal_levels(struct intel_dp *intel_dp)
2127 } 2136 }
2128 2137
2129 mutex_lock(&dev_priv->dpio_lock); 2138 mutex_lock(&dev_priv->dpio_lock);
2130 vlv_dpio_write(dev_priv, pipe, DPIO_TX_OCALINIT(port), 0x00000000); 2139 vlv_dpio_write(dev_priv, pipe, VLV_TX_DW5(port), 0x00000000);
2131 vlv_dpio_write(dev_priv, pipe, DPIO_TX_SWING_CTL4(port), demph_reg_value); 2140 vlv_dpio_write(dev_priv, pipe, VLV_TX_DW4(port), demph_reg_value);
2132 vlv_dpio_write(dev_priv, pipe, DPIO_TX_SWING_CTL2(port), 2141 vlv_dpio_write(dev_priv, pipe, VLV_TX_DW2(port),
2133 uniqtranscale_reg_value); 2142 uniqtranscale_reg_value);
2134 vlv_dpio_write(dev_priv, pipe, DPIO_TX_SWING_CTL3(port), 0x0C782040); 2143 vlv_dpio_write(dev_priv, pipe, VLV_TX_DW3(port), 0x0C782040);
2135 vlv_dpio_write(dev_priv, pipe, DPIO_PCS_STAGGER0(port), 0x00030000); 2144 vlv_dpio_write(dev_priv, pipe, VLV_PCS_DW11(port), 0x00030000);
2136 vlv_dpio_write(dev_priv, pipe, DPIO_PCS_CTL_OVER1(port), preemph_reg_value); 2145 vlv_dpio_write(dev_priv, pipe, VLV_PCS_DW9(port), preemph_reg_value);
2137 vlv_dpio_write(dev_priv, pipe, DPIO_TX_OCALINIT(port), 0x80000000); 2146 vlv_dpio_write(dev_priv, pipe, VLV_TX_DW5(port), 0x80000000);
2138 mutex_unlock(&dev_priv->dpio_lock); 2147 mutex_unlock(&dev_priv->dpio_lock);
2139 2148
2140 return 0; 2149 return 0;
@@ -2646,7 +2655,6 @@ intel_dp_complete_link_train(struct intel_dp *intel_dp)
2646 2655
2647 if (cr_tries > 5) { 2656 if (cr_tries > 5) {
2648 DRM_ERROR("failed to train DP, aborting\n"); 2657 DRM_ERROR("failed to train DP, aborting\n");
2649 intel_dp_link_down(intel_dp);
2650 break; 2658 break;
2651 } 2659 }
2652 2660
@@ -2899,13 +2907,11 @@ intel_dp_check_link_status(struct intel_dp *intel_dp)
2899 2907
2900 /* Try to read receiver status if the link appears to be up */ 2908 /* Try to read receiver status if the link appears to be up */
2901 if (!intel_dp_get_link_status(intel_dp, link_status)) { 2909 if (!intel_dp_get_link_status(intel_dp, link_status)) {
2902 intel_dp_link_down(intel_dp);
2903 return; 2910 return;
2904 } 2911 }
2905 2912
2906 /* Now read the DPCD to see if it's actually running */ 2913 /* Now read the DPCD to see if it's actually running */
2907 if (!intel_dp_get_dpcd(intel_dp)) { 2914 if (!intel_dp_get_dpcd(intel_dp)) {
2908 intel_dp_link_down(intel_dp);
2909 return; 2915 return;
2910 } 2916 }
2911 2917
@@ -3020,18 +3026,34 @@ g4x_dp_detect(struct intel_dp *intel_dp)
3020 return status; 3026 return status;
3021 } 3027 }
3022 3028
3023 switch (intel_dig_port->port) { 3029 if (IS_VALLEYVIEW(dev)) {
3024 case PORT_B: 3030 switch (intel_dig_port->port) {
3025 bit = PORTB_HOTPLUG_LIVE_STATUS; 3031 case PORT_B:
3026 break; 3032 bit = PORTB_HOTPLUG_LIVE_STATUS_VLV;
3027 case PORT_C: 3033 break;
3028 bit = PORTC_HOTPLUG_LIVE_STATUS; 3034 case PORT_C:
3029 break; 3035 bit = PORTC_HOTPLUG_LIVE_STATUS_VLV;
3030 case PORT_D: 3036 break;
3031 bit = PORTD_HOTPLUG_LIVE_STATUS; 3037 case PORT_D:
3032 break; 3038 bit = PORTD_HOTPLUG_LIVE_STATUS_VLV;
3033 default: 3039 break;
3034 return connector_status_unknown; 3040 default:
3041 return connector_status_unknown;
3042 }
3043 } else {
3044 switch (intel_dig_port->port) {
3045 case PORT_B:
3046 bit = PORTB_HOTPLUG_LIVE_STATUS_G4X;
3047 break;
3048 case PORT_C:
3049 bit = PORTC_HOTPLUG_LIVE_STATUS_G4X;
3050 break;
3051 case PORT_D:
3052 bit = PORTD_HOTPLUG_LIVE_STATUS_G4X;
3053 break;
3054 default:
3055 return connector_status_unknown;
3056 }
3035 } 3057 }
3036 3058
3037 if ((I915_READ(PORT_HOTPLUG_STAT) & bit) == 0) 3059 if ((I915_READ(PORT_HOTPLUG_STAT) & bit) == 0)
@@ -3082,9 +3104,12 @@ intel_dp_detect(struct drm_connector *connector, bool force)
3082 struct intel_digital_port *intel_dig_port = dp_to_dig_port(intel_dp); 3104 struct intel_digital_port *intel_dig_port = dp_to_dig_port(intel_dp);
3083 struct intel_encoder *intel_encoder = &intel_dig_port->base; 3105 struct intel_encoder *intel_encoder = &intel_dig_port->base;
3084 struct drm_device *dev = connector->dev; 3106 struct drm_device *dev = connector->dev;
3107 struct drm_i915_private *dev_priv = dev->dev_private;
3085 enum drm_connector_status status; 3108 enum drm_connector_status status;
3086 struct edid *edid = NULL; 3109 struct edid *edid = NULL;
3087 3110
3111 intel_runtime_pm_get(dev_priv);
3112
3088 DRM_DEBUG_KMS("[CONNECTOR:%d:%s]\n", 3113 DRM_DEBUG_KMS("[CONNECTOR:%d:%s]\n",
3089 connector->base.id, drm_get_connector_name(connector)); 3114 connector->base.id, drm_get_connector_name(connector));
3090 3115
@@ -3096,7 +3121,7 @@ intel_dp_detect(struct drm_connector *connector, bool force)
3096 status = g4x_dp_detect(intel_dp); 3121 status = g4x_dp_detect(intel_dp);
3097 3122
3098 if (status != connector_status_connected) 3123 if (status != connector_status_connected)
3099 return status; 3124 goto out;
3100 3125
3101 intel_dp_probe_oui(intel_dp); 3126 intel_dp_probe_oui(intel_dp);
3102 3127
@@ -3112,7 +3137,11 @@ intel_dp_detect(struct drm_connector *connector, bool force)
3112 3137
3113 if (intel_encoder->type != INTEL_OUTPUT_EDP) 3138 if (intel_encoder->type != INTEL_OUTPUT_EDP)
3114 intel_encoder->type = INTEL_OUTPUT_DISPLAYPORT; 3139 intel_encoder->type = INTEL_OUTPUT_DISPLAYPORT;
3115 return connector_status_connected; 3140 status = connector_status_connected;
3141
3142out:
3143 intel_runtime_pm_put(dev_priv);
3144 return status;
3116} 3145}
3117 3146
3118static int intel_dp_get_modes(struct drm_connector *connector) 3147static int intel_dp_get_modes(struct drm_connector *connector)