Keith Packard | a4fc5ed | 2009-04-07 16:16:42 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright © 2008 Intel Corporation |
| 3 | * |
| 4 | * Permission is hereby granted, free of charge, to any person obtaining a |
| 5 | * copy of this software and associated documentation files (the "Software"), |
| 6 | * to deal in the Software without restriction, including without limitation |
| 7 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, |
| 8 | * and/or sell copies of the Software, and to permit persons to whom the |
| 9 | * Software is furnished to do so, subject to the following conditions: |
| 10 | * |
| 11 | * The above copyright notice and this permission notice (including the next |
| 12 | * paragraph) shall be included in all copies or substantial portions of the |
| 13 | * Software. |
| 14 | * |
| 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
| 18 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
| 20 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS |
| 21 | * IN THE SOFTWARE. |
| 22 | * |
| 23 | * Authors: |
| 24 | * Keith Packard <keithp@keithp.com> |
| 25 | * |
| 26 | */ |
| 27 | |
| 28 | #include <linux/i2c.h> |
Tejun Heo | 5a0e3ad | 2010-03-24 17:04:11 +0900 | [diff] [blame] | 29 | #include <linux/slab.h> |
Paul Gortmaker | 2d1a8a4 | 2011-08-30 18:16:33 -0400 | [diff] [blame] | 30 | #include <linux/export.h> |
Manasi Navare | 611032b | 2017-01-24 08:21:49 -0800 | [diff] [blame] | 31 | #include <linux/types.h> |
Clint Taylor | 01527b3 | 2014-07-07 13:01:46 -0700 | [diff] [blame] | 32 | #include <linux/notifier.h> |
| 33 | #include <linux/reboot.h> |
Manasi Navare | 611032b | 2017-01-24 08:21:49 -0800 | [diff] [blame] | 34 | #include <asm/byteorder.h> |
David Howells | 760285e | 2012-10-02 18:01:07 +0100 | [diff] [blame] | 35 | #include <drm/drmP.h> |
Matt Roper | c6f95f2 | 2015-01-22 16:50:32 -0800 | [diff] [blame] | 36 | #include <drm/drm_atomic_helper.h> |
David Howells | 760285e | 2012-10-02 18:01:07 +0100 | [diff] [blame] | 37 | #include <drm/drm_crtc.h> |
| 38 | #include <drm/drm_crtc_helper.h> |
Sean Paul | 20f24d7 | 2018-01-08 14:55:43 -0500 | [diff] [blame] | 39 | #include <drm/drm_dp_helper.h> |
David Howells | 760285e | 2012-10-02 18:01:07 +0100 | [diff] [blame] | 40 | #include <drm/drm_edid.h> |
Sean Paul | 20f24d7 | 2018-01-08 14:55:43 -0500 | [diff] [blame] | 41 | #include <drm/drm_hdcp.h> |
Keith Packard | a4fc5ed | 2009-04-07 16:16:42 -0700 | [diff] [blame] | 42 | #include "intel_drv.h" |
David Howells | 760285e | 2012-10-02 18:01:07 +0100 | [diff] [blame] | 43 | #include <drm/i915_drm.h> |
Keith Packard | a4fc5ed | 2009-04-07 16:16:42 -0700 | [diff] [blame] | 44 | #include "i915_drv.h" |
Keith Packard | a4fc5ed | 2009-04-07 16:16:42 -0700 | [diff] [blame] | 45 | |
Keith Packard | a4fc5ed | 2009-04-07 16:16:42 -0700 | [diff] [blame] | 46 | #define DP_LINK_CHECK_TIMEOUT (10 * 1000) |
Pandiyan, Dhinakaran | e8b2577 | 2017-09-18 15:21:39 -0700 | [diff] [blame] | 47 | #define DP_DPRX_ESI_LEN 14 |
Keith Packard | a4fc5ed | 2009-04-07 16:16:42 -0700 | [diff] [blame] | 48 | |
Todd Previte | 559be30 | 2015-05-04 07:48:20 -0700 | [diff] [blame] | 49 | /* Compliance test status bits */ |
| 50 | #define INTEL_DP_RESOLUTION_SHIFT_MASK 0 |
| 51 | #define INTEL_DP_RESOLUTION_PREFERRED (1 << INTEL_DP_RESOLUTION_SHIFT_MASK) |
| 52 | #define INTEL_DP_RESOLUTION_STANDARD (2 << INTEL_DP_RESOLUTION_SHIFT_MASK) |
| 53 | #define INTEL_DP_RESOLUTION_FAILSAFE (3 << INTEL_DP_RESOLUTION_SHIFT_MASK) |
| 54 | |
Chon Ming Lee | 9dd4ffd | 2013-09-04 01:30:37 +0800 | [diff] [blame] | 55 | struct dp_link_dpll { |
Ville Syrjälä | 840b32b | 2015-08-11 20:21:46 +0300 | [diff] [blame] | 56 | int clock; |
Chon Ming Lee | 9dd4ffd | 2013-09-04 01:30:37 +0800 | [diff] [blame] | 57 | struct dpll dpll; |
| 58 | }; |
| 59 | |
| 60 | static const struct dp_link_dpll gen4_dpll[] = { |
Ville Syrjälä | 840b32b | 2015-08-11 20:21:46 +0300 | [diff] [blame] | 61 | { 162000, |
Chon Ming Lee | 9dd4ffd | 2013-09-04 01:30:37 +0800 | [diff] [blame] | 62 | { .p1 = 2, .p2 = 10, .n = 2, .m1 = 23, .m2 = 8 } }, |
Ville Syrjälä | 840b32b | 2015-08-11 20:21:46 +0300 | [diff] [blame] | 63 | { 270000, |
Chon Ming Lee | 9dd4ffd | 2013-09-04 01:30:37 +0800 | [diff] [blame] | 64 | { .p1 = 1, .p2 = 10, .n = 1, .m1 = 14, .m2 = 2 } } |
| 65 | }; |
| 66 | |
| 67 | static const struct dp_link_dpll pch_dpll[] = { |
Ville Syrjälä | 840b32b | 2015-08-11 20:21:46 +0300 | [diff] [blame] | 68 | { 162000, |
Chon Ming Lee | 9dd4ffd | 2013-09-04 01:30:37 +0800 | [diff] [blame] | 69 | { .p1 = 2, .p2 = 10, .n = 1, .m1 = 12, .m2 = 9 } }, |
Ville Syrjälä | 840b32b | 2015-08-11 20:21:46 +0300 | [diff] [blame] | 70 | { 270000, |
Chon Ming Lee | 9dd4ffd | 2013-09-04 01:30:37 +0800 | [diff] [blame] | 71 | { .p1 = 1, .p2 = 10, .n = 2, .m1 = 14, .m2 = 8 } } |
| 72 | }; |
| 73 | |
Chon Ming Lee | 65ce4bf | 2013-09-04 01:30:38 +0800 | [diff] [blame] | 74 | static const struct dp_link_dpll vlv_dpll[] = { |
Ville Syrjälä | 840b32b | 2015-08-11 20:21:46 +0300 | [diff] [blame] | 75 | { 162000, |
Chon Ming Lee | 58f6e63 | 2013-09-25 15:47:51 +0800 | [diff] [blame] | 76 | { .p1 = 3, .p2 = 2, .n = 5, .m1 = 3, .m2 = 81 } }, |
Ville Syrjälä | 840b32b | 2015-08-11 20:21:46 +0300 | [diff] [blame] | 77 | { 270000, |
Chon Ming Lee | 65ce4bf | 2013-09-04 01:30:38 +0800 | [diff] [blame] | 78 | { .p1 = 2, .p2 = 2, .n = 1, .m1 = 2, .m2 = 27 } } |
| 79 | }; |
| 80 | |
Chon Ming Lee | ef9348c | 2014-04-09 13:28:18 +0300 | [diff] [blame] | 81 | /* |
| 82 | * CHV supports eDP 1.4 that have more link rates. |
| 83 | * Below only provides the fixed rate but exclude variable rate. |
| 84 | */ |
| 85 | static const struct dp_link_dpll chv_dpll[] = { |
| 86 | /* |
| 87 | * CHV requires to program fractional division for m2. |
| 88 | * m2 is stored in fixed point format using formula below |
| 89 | * (m2_int << 22) | m2_fraction |
| 90 | */ |
Ville Syrjälä | 840b32b | 2015-08-11 20:21:46 +0300 | [diff] [blame] | 91 | { 162000, /* m2_int = 32, m2_fraction = 1677722 */ |
Chon Ming Lee | ef9348c | 2014-04-09 13:28:18 +0300 | [diff] [blame] | 92 | { .p1 = 4, .p2 = 2, .n = 1, .m1 = 2, .m2 = 0x819999a } }, |
Ville Syrjälä | 840b32b | 2015-08-11 20:21:46 +0300 | [diff] [blame] | 93 | { 270000, /* m2_int = 27, m2_fraction = 0 */ |
Chon Ming Lee | ef9348c | 2014-04-09 13:28:18 +0300 | [diff] [blame] | 94 | { .p1 = 4, .p2 = 1, .n = 1, .m1 = 2, .m2 = 0x6c00000 } }, |
Ville Syrjälä | 840b32b | 2015-08-11 20:21:46 +0300 | [diff] [blame] | 95 | { 540000, /* m2_int = 27, m2_fraction = 0 */ |
Chon Ming Lee | ef9348c | 2014-04-09 13:28:18 +0300 | [diff] [blame] | 96 | { .p1 = 2, .p2 = 1, .n = 1, .m1 = 2, .m2 = 0x6c00000 } } |
| 97 | }; |
Sonika Jindal | 637a9c6 | 2015-05-07 09:52:08 +0530 | [diff] [blame] | 98 | |
Sonika Jindal | 64987fc | 2015-05-26 17:50:13 +0530 | [diff] [blame] | 99 | static const int bxt_rates[] = { 162000, 216000, 243000, 270000, |
| 100 | 324000, 432000, 540000 }; |
Sonika Jindal | 637a9c6 | 2015-05-07 09:52:08 +0530 | [diff] [blame] | 101 | static const int skl_rates[] = { 162000, 216000, 270000, |
Ville Syrjälä | f4896f1 | 2015-03-12 17:10:27 +0200 | [diff] [blame] | 102 | 324000, 432000, 540000 }; |
Rodrigo Vivi | d907b66 | 2017-08-10 15:40:08 -0700 | [diff] [blame] | 103 | static const int cnl_rates[] = { 162000, 216000, 270000, |
| 104 | 324000, 432000, 540000, |
| 105 | 648000, 810000 }; |
Ville Syrjälä | f4896f1 | 2015-03-12 17:10:27 +0200 | [diff] [blame] | 106 | static const int default_rates[] = { 162000, 270000, 540000 }; |
Chon Ming Lee | ef9348c | 2014-04-09 13:28:18 +0300 | [diff] [blame] | 107 | |
Jesse Barnes | cfcb0fc | 2010-10-07 16:01:06 -0700 | [diff] [blame] | 108 | /** |
Jani Nikula | 1853a9d | 2017-08-18 12:30:20 +0300 | [diff] [blame] | 109 | * intel_dp_is_edp - is the given port attached to an eDP panel (either CPU or PCH) |
Jesse Barnes | cfcb0fc | 2010-10-07 16:01:06 -0700 | [diff] [blame] | 110 | * @intel_dp: DP struct |
| 111 | * |
| 112 | * If a CPU or PCH DP output is attached to an eDP panel, this function |
| 113 | * will return true, and false otherwise. |
| 114 | */ |
Jani Nikula | 1853a9d | 2017-08-18 12:30:20 +0300 | [diff] [blame] | 115 | bool intel_dp_is_edp(struct intel_dp *intel_dp) |
Jesse Barnes | cfcb0fc | 2010-10-07 16:01:06 -0700 | [diff] [blame] | 116 | { |
Paulo Zanoni | da63a9f | 2012-10-26 19:05:46 -0200 | [diff] [blame] | 117 | struct intel_digital_port *intel_dig_port = dp_to_dig_port(intel_dp); |
| 118 | |
| 119 | return intel_dig_port->base.type == INTEL_OUTPUT_EDP; |
Jesse Barnes | cfcb0fc | 2010-10-07 16:01:06 -0700 | [diff] [blame] | 120 | } |
| 121 | |
Imre Deak | 68b4d82 | 2013-05-08 13:14:06 +0300 | [diff] [blame] | 122 | static struct drm_device *intel_dp_to_dev(struct intel_dp *intel_dp) |
Jesse Barnes | cfcb0fc | 2010-10-07 16:01:06 -0700 | [diff] [blame] | 123 | { |
Imre Deak | 68b4d82 | 2013-05-08 13:14:06 +0300 | [diff] [blame] | 124 | struct intel_digital_port *intel_dig_port = dp_to_dig_port(intel_dp); |
| 125 | |
| 126 | return intel_dig_port->base.base.dev; |
Jesse Barnes | cfcb0fc | 2010-10-07 16:01:06 -0700 | [diff] [blame] | 127 | } |
| 128 | |
Chris Wilson | df0e924 | 2010-09-09 16:20:55 +0100 | [diff] [blame] | 129 | static struct intel_dp *intel_attached_dp(struct drm_connector *connector) |
| 130 | { |
Paulo Zanoni | fa90ece | 2012-10-26 19:05:44 -0200 | [diff] [blame] | 131 | return enc_to_intel_dp(&intel_attached_encoder(connector)->base); |
Chris Wilson | df0e924 | 2010-09-09 16:20:55 +0100 | [diff] [blame] | 132 | } |
| 133 | |
Ville Syrjälä | adc1030 | 2017-10-31 22:51:14 +0200 | [diff] [blame] | 134 | static void intel_dp_link_down(struct intel_encoder *encoder, |
| 135 | const struct intel_crtc_state *old_crtc_state); |
Ville Syrjälä | 1e0560e | 2014-08-19 13:24:25 +0300 | [diff] [blame] | 136 | static bool edp_panel_vdd_on(struct intel_dp *intel_dp); |
Daniel Vetter | 4be7378 | 2014-01-17 14:39:48 +0100 | [diff] [blame] | 137 | static void edp_panel_vdd_off(struct intel_dp *intel_dp, bool sync); |
Ville Syrjälä | adc1030 | 2017-10-31 22:51:14 +0200 | [diff] [blame] | 138 | static void vlv_init_panel_power_sequencer(struct intel_encoder *encoder, |
| 139 | const struct intel_crtc_state *crtc_state); |
Ville Syrjälä | 46bd838 | 2017-10-31 22:51:22 +0200 | [diff] [blame] | 140 | static void vlv_steal_power_sequencer(struct drm_i915_private *dev_priv, |
Ville Syrjälä | a8c3344 | 2014-10-16 21:29:59 +0300 | [diff] [blame] | 141 | enum pipe pipe); |
Shubhangi Shrivastava | f21a219 | 2016-03-30 18:05:22 +0530 | [diff] [blame] | 142 | static void intel_dp_unset_edid(struct intel_dp *intel_dp); |
Keith Packard | a4fc5ed | 2009-04-07 16:16:42 -0700 | [diff] [blame] | 143 | |
Jani Nikula | 68f357c | 2017-03-28 17:59:05 +0300 | [diff] [blame] | 144 | /* update sink rates from dpcd */ |
| 145 | static void intel_dp_set_sink_rates(struct intel_dp *intel_dp) |
| 146 | { |
Jani Nikula | a8a0888 | 2017-10-09 12:29:59 +0300 | [diff] [blame] | 147 | int i, max_rate; |
Jani Nikula | 68f357c | 2017-03-28 17:59:05 +0300 | [diff] [blame] | 148 | |
Jani Nikula | a8a0888 | 2017-10-09 12:29:59 +0300 | [diff] [blame] | 149 | max_rate = drm_dp_bw_code_to_link_rate(intel_dp->dpcd[DP_MAX_LINK_RATE]); |
Jani Nikula | 68f357c | 2017-03-28 17:59:05 +0300 | [diff] [blame] | 150 | |
Jani Nikula | a8a0888 | 2017-10-09 12:29:59 +0300 | [diff] [blame] | 151 | for (i = 0; i < ARRAY_SIZE(default_rates); i++) { |
| 152 | if (default_rates[i] > max_rate) |
| 153 | break; |
Jani Nikula | 68f357c | 2017-03-28 17:59:05 +0300 | [diff] [blame] | 154 | intel_dp->sink_rates[i] = default_rates[i]; |
Jani Nikula | a8a0888 | 2017-10-09 12:29:59 +0300 | [diff] [blame] | 155 | } |
Jani Nikula | 68f357c | 2017-03-28 17:59:05 +0300 | [diff] [blame] | 156 | |
Jani Nikula | a8a0888 | 2017-10-09 12:29:59 +0300 | [diff] [blame] | 157 | intel_dp->num_sink_rates = i; |
Jani Nikula | 68f357c | 2017-03-28 17:59:05 +0300 | [diff] [blame] | 158 | } |
| 159 | |
Jani Nikula | 540b0b7f | 2017-04-06 16:44:13 +0300 | [diff] [blame] | 160 | /* Theoretical max between source and sink */ |
| 161 | static int intel_dp_max_common_rate(struct intel_dp *intel_dp) |
Keith Packard | a4fc5ed | 2009-04-07 16:16:42 -0700 | [diff] [blame] | 162 | { |
Jani Nikula | 540b0b7f | 2017-04-06 16:44:13 +0300 | [diff] [blame] | 163 | return intel_dp->common_rates[intel_dp->num_common_rates - 1]; |
Keith Packard | a4fc5ed | 2009-04-07 16:16:42 -0700 | [diff] [blame] | 164 | } |
| 165 | |
Jani Nikula | 540b0b7f | 2017-04-06 16:44:13 +0300 | [diff] [blame] | 166 | /* Theoretical max between source and sink */ |
| 167 | static int intel_dp_max_common_lane_count(struct intel_dp *intel_dp) |
Paulo Zanoni | eeb6324 | 2014-05-06 14:56:50 +0300 | [diff] [blame] | 168 | { |
| 169 | struct intel_digital_port *intel_dig_port = dp_to_dig_port(intel_dp); |
Jani Nikula | 540b0b7f | 2017-04-06 16:44:13 +0300 | [diff] [blame] | 170 | int source_max = intel_dig_port->max_lanes; |
| 171 | int sink_max = drm_dp_max_lane_count(intel_dp->dpcd); |
Paulo Zanoni | eeb6324 | 2014-05-06 14:56:50 +0300 | [diff] [blame] | 172 | |
| 173 | return min(source_max, sink_max); |
| 174 | } |
| 175 | |
Jani Nikula | 3d65a73 | 2017-04-06 16:44:14 +0300 | [diff] [blame] | 176 | int intel_dp_max_lane_count(struct intel_dp *intel_dp) |
Jani Nikula | 540b0b7f | 2017-04-06 16:44:13 +0300 | [diff] [blame] | 177 | { |
| 178 | return intel_dp->max_link_lane_count; |
| 179 | } |
| 180 | |
Dhinakaran Pandiyan | 22a2c8e | 2016-11-15 12:59:06 -0800 | [diff] [blame] | 181 | int |
Keith Packard | c898261 | 2012-01-25 08:16:25 -0800 | [diff] [blame] | 182 | intel_dp_link_required(int pixel_clock, int bpp) |
Keith Packard | a4fc5ed | 2009-04-07 16:16:42 -0700 | [diff] [blame] | 183 | { |
Dhinakaran Pandiyan | fd81c44 | 2016-11-14 13:50:20 -0800 | [diff] [blame] | 184 | /* pixel_clock is in kHz, divide bpp by 8 for bit to Byte conversion */ |
| 185 | return DIV_ROUND_UP(pixel_clock * bpp, 8); |
Keith Packard | a4fc5ed | 2009-04-07 16:16:42 -0700 | [diff] [blame] | 186 | } |
| 187 | |
Dhinakaran Pandiyan | 22a2c8e | 2016-11-15 12:59:06 -0800 | [diff] [blame] | 188 | int |
Dave Airlie | fe27d53 | 2010-06-30 11:46:17 +1000 | [diff] [blame] | 189 | intel_dp_max_data_rate(int max_link_clock, int max_lanes) |
| 190 | { |
Dhinakaran Pandiyan | fd81c44 | 2016-11-14 13:50:20 -0800 | [diff] [blame] | 191 | /* max_link_clock is the link symbol clock (LS_Clk) in kHz and not the |
| 192 | * link rate that is generally expressed in Gbps. Since, 8 bits of data |
| 193 | * is transmitted every LS_Clk per lane, there is no need to account for |
| 194 | * the channel encoding that is done in the PHY layer here. |
| 195 | */ |
| 196 | |
| 197 | return max_link_clock * max_lanes; |
Dave Airlie | fe27d53 | 2010-06-30 11:46:17 +1000 | [diff] [blame] | 198 | } |
| 199 | |
Mika Kahola | 70ec064 | 2016-09-09 14:10:55 +0300 | [diff] [blame] | 200 | static int |
| 201 | intel_dp_downstream_max_dotclock(struct intel_dp *intel_dp) |
| 202 | { |
| 203 | struct intel_digital_port *intel_dig_port = dp_to_dig_port(intel_dp); |
| 204 | struct intel_encoder *encoder = &intel_dig_port->base; |
| 205 | struct drm_i915_private *dev_priv = to_i915(encoder->base.dev); |
| 206 | int max_dotclk = dev_priv->max_dotclk_freq; |
| 207 | int ds_max_dotclk; |
| 208 | |
| 209 | int type = intel_dp->downstream_ports[0] & DP_DS_PORT_TYPE_MASK; |
| 210 | |
| 211 | if (type != DP_DS_PORT_TYPE_VGA) |
| 212 | return max_dotclk; |
| 213 | |
| 214 | ds_max_dotclk = drm_dp_downstream_max_clock(intel_dp->dpcd, |
| 215 | intel_dp->downstream_ports); |
| 216 | |
| 217 | if (ds_max_dotclk != 0) |
| 218 | max_dotclk = min(max_dotclk, ds_max_dotclk); |
| 219 | |
| 220 | return max_dotclk; |
| 221 | } |
| 222 | |
Jani Nikula | 55cfc58 | 2017-03-28 17:59:04 +0300 | [diff] [blame] | 223 | static void |
| 224 | intel_dp_set_source_rates(struct intel_dp *intel_dp) |
Navare, Manasi D | 40dba34 | 2016-10-26 16:25:55 -0700 | [diff] [blame] | 225 | { |
| 226 | struct intel_digital_port *dig_port = dp_to_dig_port(intel_dp); |
| 227 | struct drm_i915_private *dev_priv = to_i915(dig_port->base.base.dev); |
Ville Syrjälä | 8f4f279 | 2017-11-09 17:24:34 +0200 | [diff] [blame] | 228 | enum port port = dig_port->base.port; |
Jani Nikula | 55cfc58 | 2017-03-28 17:59:04 +0300 | [diff] [blame] | 229 | const int *source_rates; |
Navare, Manasi D | 40dba34 | 2016-10-26 16:25:55 -0700 | [diff] [blame] | 230 | int size; |
Rodrigo Vivi | d907b66 | 2017-08-10 15:40:08 -0700 | [diff] [blame] | 231 | u32 voltage; |
Navare, Manasi D | 40dba34 | 2016-10-26 16:25:55 -0700 | [diff] [blame] | 232 | |
Jani Nikula | 55cfc58 | 2017-03-28 17:59:04 +0300 | [diff] [blame] | 233 | /* This should only be done once */ |
| 234 | WARN_ON(intel_dp->source_rates || intel_dp->num_source_rates); |
| 235 | |
Ander Conselvan de Oliveira | cc3f90f | 2016-12-02 10:23:49 +0200 | [diff] [blame] | 236 | if (IS_GEN9_LP(dev_priv)) { |
Jani Nikula | 55cfc58 | 2017-03-28 17:59:04 +0300 | [diff] [blame] | 237 | source_rates = bxt_rates; |
Navare, Manasi D | 40dba34 | 2016-10-26 16:25:55 -0700 | [diff] [blame] | 238 | size = ARRAY_SIZE(bxt_rates); |
Rodrigo Vivi | d907b66 | 2017-08-10 15:40:08 -0700 | [diff] [blame] | 239 | } else if (IS_CANNONLAKE(dev_priv)) { |
| 240 | source_rates = cnl_rates; |
| 241 | size = ARRAY_SIZE(cnl_rates); |
| 242 | voltage = I915_READ(CNL_PORT_COMP_DW3) & VOLTAGE_INFO_MASK; |
| 243 | if (port == PORT_A || port == PORT_D || |
| 244 | voltage == VOLTAGE_INFO_0_85V) |
| 245 | size -= 2; |
Rodrigo Vivi | b976dc5 | 2017-01-23 10:32:37 -0800 | [diff] [blame] | 246 | } else if (IS_GEN9_BC(dev_priv)) { |
Jani Nikula | 55cfc58 | 2017-03-28 17:59:04 +0300 | [diff] [blame] | 247 | source_rates = skl_rates; |
Navare, Manasi D | 40dba34 | 2016-10-26 16:25:55 -0700 | [diff] [blame] | 248 | size = ARRAY_SIZE(skl_rates); |
Jani Nikula | fc603ca | 2017-10-09 12:29:58 +0300 | [diff] [blame] | 249 | } else if ((IS_HASWELL(dev_priv) && !IS_HSW_ULX(dev_priv)) || |
| 250 | IS_BROADWELL(dev_priv)) { |
Jani Nikula | 55cfc58 | 2017-03-28 17:59:04 +0300 | [diff] [blame] | 251 | source_rates = default_rates; |
Navare, Manasi D | 40dba34 | 2016-10-26 16:25:55 -0700 | [diff] [blame] | 252 | size = ARRAY_SIZE(default_rates); |
Jani Nikula | fc603ca | 2017-10-09 12:29:58 +0300 | [diff] [blame] | 253 | } else { |
| 254 | source_rates = default_rates; |
| 255 | size = ARRAY_SIZE(default_rates) - 1; |
Navare, Manasi D | 40dba34 | 2016-10-26 16:25:55 -0700 | [diff] [blame] | 256 | } |
| 257 | |
Jani Nikula | 55cfc58 | 2017-03-28 17:59:04 +0300 | [diff] [blame] | 258 | intel_dp->source_rates = source_rates; |
| 259 | intel_dp->num_source_rates = size; |
Navare, Manasi D | 40dba34 | 2016-10-26 16:25:55 -0700 | [diff] [blame] | 260 | } |
| 261 | |
| 262 | static int intersect_rates(const int *source_rates, int source_len, |
| 263 | const int *sink_rates, int sink_len, |
| 264 | int *common_rates) |
| 265 | { |
| 266 | int i = 0, j = 0, k = 0; |
| 267 | |
| 268 | while (i < source_len && j < sink_len) { |
| 269 | if (source_rates[i] == sink_rates[j]) { |
| 270 | if (WARN_ON(k >= DP_MAX_SUPPORTED_RATES)) |
| 271 | return k; |
| 272 | common_rates[k] = source_rates[i]; |
| 273 | ++k; |
| 274 | ++i; |
| 275 | ++j; |
| 276 | } else if (source_rates[i] < sink_rates[j]) { |
| 277 | ++i; |
| 278 | } else { |
| 279 | ++j; |
| 280 | } |
| 281 | } |
| 282 | return k; |
| 283 | } |
| 284 | |
Jani Nikula | 8001b75 | 2017-03-28 17:59:03 +0300 | [diff] [blame] | 285 | /* return index of rate in rates array, or -1 if not found */ |
| 286 | static int intel_dp_rate_index(const int *rates, int len, int rate) |
| 287 | { |
| 288 | int i; |
| 289 | |
| 290 | for (i = 0; i < len; i++) |
| 291 | if (rate == rates[i]) |
| 292 | return i; |
| 293 | |
| 294 | return -1; |
| 295 | } |
| 296 | |
Jani Nikula | 975ee5fca | 2017-04-06 16:44:10 +0300 | [diff] [blame] | 297 | static void intel_dp_set_common_rates(struct intel_dp *intel_dp) |
Navare, Manasi D | 40dba34 | 2016-10-26 16:25:55 -0700 | [diff] [blame] | 298 | { |
Jani Nikula | 975ee5fca | 2017-04-06 16:44:10 +0300 | [diff] [blame] | 299 | WARN_ON(!intel_dp->num_source_rates || !intel_dp->num_sink_rates); |
Navare, Manasi D | 40dba34 | 2016-10-26 16:25:55 -0700 | [diff] [blame] | 300 | |
Jani Nikula | 975ee5fca | 2017-04-06 16:44:10 +0300 | [diff] [blame] | 301 | intel_dp->num_common_rates = intersect_rates(intel_dp->source_rates, |
| 302 | intel_dp->num_source_rates, |
| 303 | intel_dp->sink_rates, |
| 304 | intel_dp->num_sink_rates, |
| 305 | intel_dp->common_rates); |
| 306 | |
| 307 | /* Paranoia, there should always be something in common. */ |
| 308 | if (WARN_ON(intel_dp->num_common_rates == 0)) { |
| 309 | intel_dp->common_rates[0] = default_rates[0]; |
| 310 | intel_dp->num_common_rates = 1; |
| 311 | } |
| 312 | } |
| 313 | |
| 314 | /* get length of common rates potentially limited by max_rate */ |
| 315 | static int intel_dp_common_len_rate_limit(struct intel_dp *intel_dp, |
| 316 | int max_rate) |
| 317 | { |
| 318 | const int *common_rates = intel_dp->common_rates; |
| 319 | int i, common_len = intel_dp->num_common_rates; |
Navare, Manasi D | 40dba34 | 2016-10-26 16:25:55 -0700 | [diff] [blame] | 320 | |
Jani Nikula | 68f357c | 2017-03-28 17:59:05 +0300 | [diff] [blame] | 321 | /* Limit results by potentially reduced max rate */ |
| 322 | for (i = 0; i < common_len; i++) { |
| 323 | if (common_rates[common_len - i - 1] <= max_rate) |
| 324 | return common_len - i; |
| 325 | } |
| 326 | |
| 327 | return 0; |
Navare, Manasi D | 40dba34 | 2016-10-26 16:25:55 -0700 | [diff] [blame] | 328 | } |
| 329 | |
Manasi Navare | 1a92c70 | 2017-06-08 13:41:02 -0700 | [diff] [blame] | 330 | static bool intel_dp_link_params_valid(struct intel_dp *intel_dp, int link_rate, |
| 331 | uint8_t lane_count) |
Manasi Navare | 14c562c | 2017-04-06 14:00:12 -0700 | [diff] [blame] | 332 | { |
| 333 | /* |
| 334 | * FIXME: we need to synchronize the current link parameters with |
| 335 | * hardware readout. Currently fast link training doesn't work on |
| 336 | * boot-up. |
| 337 | */ |
Manasi Navare | 1a92c70 | 2017-06-08 13:41:02 -0700 | [diff] [blame] | 338 | if (link_rate == 0 || |
| 339 | link_rate > intel_dp->max_link_rate) |
Manasi Navare | 14c562c | 2017-04-06 14:00:12 -0700 | [diff] [blame] | 340 | return false; |
| 341 | |
Manasi Navare | 1a92c70 | 2017-06-08 13:41:02 -0700 | [diff] [blame] | 342 | if (lane_count == 0 || |
| 343 | lane_count > intel_dp_max_lane_count(intel_dp)) |
Manasi Navare | 14c562c | 2017-04-06 14:00:12 -0700 | [diff] [blame] | 344 | return false; |
| 345 | |
| 346 | return true; |
| 347 | } |
| 348 | |
Manasi Navare | fdb14d3 | 2016-12-08 19:05:12 -0800 | [diff] [blame] | 349 | int intel_dp_get_link_train_fallback_values(struct intel_dp *intel_dp, |
| 350 | int link_rate, uint8_t lane_count) |
| 351 | { |
Jani Nikula | b1810a7 | 2017-04-06 16:44:11 +0300 | [diff] [blame] | 352 | int index; |
Manasi Navare | fdb14d3 | 2016-12-08 19:05:12 -0800 | [diff] [blame] | 353 | |
Jani Nikula | b1810a7 | 2017-04-06 16:44:11 +0300 | [diff] [blame] | 354 | index = intel_dp_rate_index(intel_dp->common_rates, |
| 355 | intel_dp->num_common_rates, |
| 356 | link_rate); |
| 357 | if (index > 0) { |
Jani Nikula | e6c0c64 | 2017-04-06 16:44:12 +0300 | [diff] [blame] | 358 | intel_dp->max_link_rate = intel_dp->common_rates[index - 1]; |
| 359 | intel_dp->max_link_lane_count = lane_count; |
Manasi Navare | fdb14d3 | 2016-12-08 19:05:12 -0800 | [diff] [blame] | 360 | } else if (lane_count > 1) { |
Jani Nikula | 540b0b7f | 2017-04-06 16:44:13 +0300 | [diff] [blame] | 361 | intel_dp->max_link_rate = intel_dp_max_common_rate(intel_dp); |
Jani Nikula | e6c0c64 | 2017-04-06 16:44:12 +0300 | [diff] [blame] | 362 | intel_dp->max_link_lane_count = lane_count >> 1; |
Manasi Navare | fdb14d3 | 2016-12-08 19:05:12 -0800 | [diff] [blame] | 363 | } else { |
| 364 | DRM_ERROR("Link Training Unsuccessful\n"); |
| 365 | return -1; |
| 366 | } |
| 367 | |
| 368 | return 0; |
| 369 | } |
| 370 | |
Damien Lespiau | c19de8e | 2013-11-28 15:29:18 +0000 | [diff] [blame] | 371 | static enum drm_mode_status |
Keith Packard | a4fc5ed | 2009-04-07 16:16:42 -0700 | [diff] [blame] | 372 | intel_dp_mode_valid(struct drm_connector *connector, |
| 373 | struct drm_display_mode *mode) |
| 374 | { |
Chris Wilson | df0e924 | 2010-09-09 16:20:55 +0100 | [diff] [blame] | 375 | struct intel_dp *intel_dp = intel_attached_dp(connector); |
Jani Nikula | dd06f90 | 2012-10-19 14:51:50 +0300 | [diff] [blame] | 376 | struct intel_connector *intel_connector = to_intel_connector(connector); |
| 377 | struct drm_display_mode *fixed_mode = intel_connector->panel.fixed_mode; |
Daniel Vetter | 3600836 | 2013-03-27 00:44:59 +0100 | [diff] [blame] | 378 | int target_clock = mode->clock; |
| 379 | int max_rate, mode_rate, max_lanes, max_link_clock; |
Mika Kahola | 70ec064 | 2016-09-09 14:10:55 +0300 | [diff] [blame] | 380 | int max_dotclk; |
| 381 | |
| 382 | max_dotclk = intel_dp_downstream_max_dotclock(intel_dp); |
Keith Packard | a4fc5ed | 2009-04-07 16:16:42 -0700 | [diff] [blame] | 383 | |
Jani Nikula | 1853a9d | 2017-08-18 12:30:20 +0300 | [diff] [blame] | 384 | if (intel_dp_is_edp(intel_dp) && fixed_mode) { |
Jani Nikula | dd06f90 | 2012-10-19 14:51:50 +0300 | [diff] [blame] | 385 | if (mode->hdisplay > fixed_mode->hdisplay) |
Zhao Yakui | 7de56f4 | 2010-07-19 09:43:14 +0100 | [diff] [blame] | 386 | return MODE_PANEL; |
| 387 | |
Jani Nikula | dd06f90 | 2012-10-19 14:51:50 +0300 | [diff] [blame] | 388 | if (mode->vdisplay > fixed_mode->vdisplay) |
Zhao Yakui | 7de56f4 | 2010-07-19 09:43:14 +0100 | [diff] [blame] | 389 | return MODE_PANEL; |
Daniel Vetter | 03afc4a | 2013-04-02 23:42:31 +0200 | [diff] [blame] | 390 | |
| 391 | target_clock = fixed_mode->clock; |
Zhao Yakui | 7de56f4 | 2010-07-19 09:43:14 +0100 | [diff] [blame] | 392 | } |
| 393 | |
Ville Syrjälä | 50fec21 | 2015-03-12 17:10:34 +0200 | [diff] [blame] | 394 | max_link_clock = intel_dp_max_link_rate(intel_dp); |
Paulo Zanoni | eeb6324 | 2014-05-06 14:56:50 +0300 | [diff] [blame] | 395 | max_lanes = intel_dp_max_lane_count(intel_dp); |
Daniel Vetter | 3600836 | 2013-03-27 00:44:59 +0100 | [diff] [blame] | 396 | |
| 397 | max_rate = intel_dp_max_data_rate(max_link_clock, max_lanes); |
| 398 | mode_rate = intel_dp_link_required(target_clock, 18); |
| 399 | |
Mika Kahola | 799487f | 2016-02-02 15:16:38 +0200 | [diff] [blame] | 400 | if (mode_rate > max_rate || target_clock > max_dotclk) |
Daniel Vetter | c486793 | 2012-04-10 10:42:36 +0200 | [diff] [blame] | 401 | return MODE_CLOCK_HIGH; |
Keith Packard | a4fc5ed | 2009-04-07 16:16:42 -0700 | [diff] [blame] | 402 | |
| 403 | if (mode->clock < 10000) |
| 404 | return MODE_CLOCK_LOW; |
| 405 | |
Daniel Vetter | 0af78a2 | 2012-05-23 11:30:55 +0200 | [diff] [blame] | 406 | if (mode->flags & DRM_MODE_FLAG_DBLCLK) |
| 407 | return MODE_H_ILLEGAL; |
| 408 | |
Keith Packard | a4fc5ed | 2009-04-07 16:16:42 -0700 | [diff] [blame] | 409 | return MODE_OK; |
| 410 | } |
| 411 | |
Rodrigo Vivi | a4f1289 | 2014-11-14 08:52:27 -0800 | [diff] [blame] | 412 | uint32_t intel_dp_pack_aux(const uint8_t *src, int src_bytes) |
Keith Packard | a4fc5ed | 2009-04-07 16:16:42 -0700 | [diff] [blame] | 413 | { |
| 414 | int i; |
| 415 | uint32_t v = 0; |
| 416 | |
| 417 | if (src_bytes > 4) |
| 418 | src_bytes = 4; |
| 419 | for (i = 0; i < src_bytes; i++) |
| 420 | v |= ((uint32_t) src[i]) << ((3-i) * 8); |
| 421 | return v; |
| 422 | } |
| 423 | |
Damien Lespiau | c2af70e | 2015-02-10 19:32:23 +0000 | [diff] [blame] | 424 | static void intel_dp_unpack_aux(uint32_t src, uint8_t *dst, int dst_bytes) |
Keith Packard | a4fc5ed | 2009-04-07 16:16:42 -0700 | [diff] [blame] | 425 | { |
| 426 | int i; |
| 427 | if (dst_bytes > 4) |
| 428 | dst_bytes = 4; |
| 429 | for (i = 0; i < dst_bytes; i++) |
| 430 | dst[i] = src >> ((3-i) * 8); |
| 431 | } |
| 432 | |
Jani Nikula | bf13e81 | 2013-09-06 07:40:05 +0300 | [diff] [blame] | 433 | static void |
Ville Syrjälä | 46bd838 | 2017-10-31 22:51:22 +0200 | [diff] [blame] | 434 | intel_dp_init_panel_power_sequencer(struct intel_dp *intel_dp); |
Jani Nikula | bf13e81 | 2013-09-06 07:40:05 +0300 | [diff] [blame] | 435 | static void |
Ville Syrjälä | 46bd838 | 2017-10-31 22:51:22 +0200 | [diff] [blame] | 436 | intel_dp_init_panel_power_sequencer_registers(struct intel_dp *intel_dp, |
Ville Syrjälä | 5d5ab2d | 2016-12-20 18:51:17 +0200 | [diff] [blame] | 437 | bool force_disable_vdd); |
Imre Deak | 335f752 | 2016-08-10 14:07:32 +0300 | [diff] [blame] | 438 | static void |
Ville Syrjälä | 46bd838 | 2017-10-31 22:51:22 +0200 | [diff] [blame] | 439 | intel_dp_pps_init(struct intel_dp *intel_dp); |
Jani Nikula | bf13e81 | 2013-09-06 07:40:05 +0300 | [diff] [blame] | 440 | |
Ville Syrjälä | 773538e8 | 2014-09-04 14:54:56 +0300 | [diff] [blame] | 441 | static void pps_lock(struct intel_dp *intel_dp) |
| 442 | { |
Ville Syrjälä | 2f77347 | 2017-11-09 17:27:58 +0200 | [diff] [blame] | 443 | struct drm_i915_private *dev_priv = to_i915(intel_dp_to_dev(intel_dp)); |
Ville Syrjälä | 773538e8 | 2014-09-04 14:54:56 +0300 | [diff] [blame] | 444 | |
| 445 | /* |
Lucas De Marchi | 40c7ae4 | 2017-11-13 16:46:38 -0800 | [diff] [blame] | 446 | * See intel_power_sequencer_reset() why we need |
Ville Syrjälä | 773538e8 | 2014-09-04 14:54:56 +0300 | [diff] [blame] | 447 | * a power domain reference here. |
| 448 | */ |
Ander Conselvan de Oliveira | 5432fca | 2017-02-22 08:34:26 +0200 | [diff] [blame] | 449 | intel_display_power_get(dev_priv, intel_dp->aux_power_domain); |
Ville Syrjälä | 773538e8 | 2014-09-04 14:54:56 +0300 | [diff] [blame] | 450 | |
| 451 | mutex_lock(&dev_priv->pps_mutex); |
| 452 | } |
| 453 | |
| 454 | static void pps_unlock(struct intel_dp *intel_dp) |
| 455 | { |
Ville Syrjälä | 2f77347 | 2017-11-09 17:27:58 +0200 | [diff] [blame] | 456 | struct drm_i915_private *dev_priv = to_i915(intel_dp_to_dev(intel_dp)); |
Ville Syrjälä | 773538e8 | 2014-09-04 14:54:56 +0300 | [diff] [blame] | 457 | |
| 458 | mutex_unlock(&dev_priv->pps_mutex); |
| 459 | |
Ander Conselvan de Oliveira | 5432fca | 2017-02-22 08:34:26 +0200 | [diff] [blame] | 460 | intel_display_power_put(dev_priv, intel_dp->aux_power_domain); |
Ville Syrjälä | 773538e8 | 2014-09-04 14:54:56 +0300 | [diff] [blame] | 461 | } |
| 462 | |
Ville Syrjälä | 961a0db | 2014-10-16 21:29:42 +0300 | [diff] [blame] | 463 | static void |
| 464 | vlv_power_sequencer_kick(struct intel_dp *intel_dp) |
| 465 | { |
Ville Syrjälä | 2f77347 | 2017-11-09 17:27:58 +0200 | [diff] [blame] | 466 | struct drm_i915_private *dev_priv = to_i915(intel_dp_to_dev(intel_dp)); |
Ville Syrjälä | 961a0db | 2014-10-16 21:29:42 +0300 | [diff] [blame] | 467 | struct intel_digital_port *intel_dig_port = dp_to_dig_port(intel_dp); |
Ville Syrjälä | 961a0db | 2014-10-16 21:29:42 +0300 | [diff] [blame] | 468 | enum pipe pipe = intel_dp->pps_pipe; |
Ville Syrjälä | 0047eed | 2015-07-10 10:56:24 +0300 | [diff] [blame] | 469 | bool pll_enabled, release_cl_override = false; |
| 470 | enum dpio_phy phy = DPIO_PHY(pipe); |
| 471 | enum dpio_channel ch = vlv_pipe_to_channel(pipe); |
Ville Syrjälä | 961a0db | 2014-10-16 21:29:42 +0300 | [diff] [blame] | 472 | uint32_t DP; |
| 473 | |
| 474 | if (WARN(I915_READ(intel_dp->output_reg) & DP_PORT_EN, |
| 475 | "skipping pipe %c power seqeuncer kick due to port %c being active\n", |
Ville Syrjälä | 8f4f279 | 2017-11-09 17:24:34 +0200 | [diff] [blame] | 476 | pipe_name(pipe), port_name(intel_dig_port->base.port))) |
Ville Syrjälä | 961a0db | 2014-10-16 21:29:42 +0300 | [diff] [blame] | 477 | return; |
| 478 | |
| 479 | DRM_DEBUG_KMS("kicking pipe %c power sequencer for port %c\n", |
Ville Syrjälä | 8f4f279 | 2017-11-09 17:24:34 +0200 | [diff] [blame] | 480 | pipe_name(pipe), port_name(intel_dig_port->base.port)); |
Ville Syrjälä | 961a0db | 2014-10-16 21:29:42 +0300 | [diff] [blame] | 481 | |
| 482 | /* Preserve the BIOS-computed detected bit. This is |
| 483 | * supposed to be read-only. |
| 484 | */ |
| 485 | DP = I915_READ(intel_dp->output_reg) & DP_DETECTED; |
| 486 | DP |= DP_VOLTAGE_0_4 | DP_PRE_EMPHASIS_0; |
| 487 | DP |= DP_PORT_WIDTH(1); |
| 488 | DP |= DP_LINK_TRAIN_PAT_1; |
| 489 | |
Tvrtko Ursulin | 920a14b | 2016-10-14 10:13:44 +0100 | [diff] [blame] | 490 | if (IS_CHERRYVIEW(dev_priv)) |
Ville Syrjälä | 961a0db | 2014-10-16 21:29:42 +0300 | [diff] [blame] | 491 | DP |= DP_PIPE_SELECT_CHV(pipe); |
| 492 | else if (pipe == PIPE_B) |
| 493 | DP |= DP_PIPEB_SELECT; |
| 494 | |
Ville Syrjälä | d288f65 | 2014-10-28 13:20:22 +0200 | [diff] [blame] | 495 | pll_enabled = I915_READ(DPLL(pipe)) & DPLL_VCO_ENABLE; |
| 496 | |
| 497 | /* |
| 498 | * The DPLL for the pipe must be enabled for this to work. |
| 499 | * So enable temporarily it if it's not already enabled. |
| 500 | */ |
Ville Syrjälä | 0047eed | 2015-07-10 10:56:24 +0300 | [diff] [blame] | 501 | if (!pll_enabled) { |
Tvrtko Ursulin | 920a14b | 2016-10-14 10:13:44 +0100 | [diff] [blame] | 502 | release_cl_override = IS_CHERRYVIEW(dev_priv) && |
Ville Syrjälä | 0047eed | 2015-07-10 10:56:24 +0300 | [diff] [blame] | 503 | !chv_phy_powergate_ch(dev_priv, phy, ch, true); |
| 504 | |
Ville Syrjälä | 30ad981 | 2016-10-31 22:37:07 +0200 | [diff] [blame] | 505 | if (vlv_force_pll_on(dev_priv, pipe, IS_CHERRYVIEW(dev_priv) ? |
Tvrtko Ursulin | 3f36b93 | 2016-01-19 15:25:17 +0000 | [diff] [blame] | 506 | &chv_dpll[0].dpll : &vlv_dpll[0].dpll)) { |
| 507 | DRM_ERROR("Failed to force on pll for pipe %c!\n", |
| 508 | pipe_name(pipe)); |
| 509 | return; |
| 510 | } |
Ville Syrjälä | 0047eed | 2015-07-10 10:56:24 +0300 | [diff] [blame] | 511 | } |
Ville Syrjälä | d288f65 | 2014-10-28 13:20:22 +0200 | [diff] [blame] | 512 | |
Ville Syrjälä | 961a0db | 2014-10-16 21:29:42 +0300 | [diff] [blame] | 513 | /* |
| 514 | * Similar magic as in intel_dp_enable_port(). |
| 515 | * We _must_ do this port enable + disable trick |
| 516 | * to make this power seqeuencer lock onto the port. |
| 517 | * Otherwise even VDD force bit won't work. |
| 518 | */ |
| 519 | I915_WRITE(intel_dp->output_reg, DP); |
| 520 | POSTING_READ(intel_dp->output_reg); |
| 521 | |
| 522 | I915_WRITE(intel_dp->output_reg, DP | DP_PORT_EN); |
| 523 | POSTING_READ(intel_dp->output_reg); |
| 524 | |
| 525 | I915_WRITE(intel_dp->output_reg, DP & ~DP_PORT_EN); |
| 526 | POSTING_READ(intel_dp->output_reg); |
Ville Syrjälä | d288f65 | 2014-10-28 13:20:22 +0200 | [diff] [blame] | 527 | |
Ville Syrjälä | 0047eed | 2015-07-10 10:56:24 +0300 | [diff] [blame] | 528 | if (!pll_enabled) { |
Ville Syrjälä | 30ad981 | 2016-10-31 22:37:07 +0200 | [diff] [blame] | 529 | vlv_force_pll_off(dev_priv, pipe); |
Ville Syrjälä | 0047eed | 2015-07-10 10:56:24 +0300 | [diff] [blame] | 530 | |
| 531 | if (release_cl_override) |
| 532 | chv_phy_powergate_ch(dev_priv, phy, ch, false); |
| 533 | } |
Ville Syrjälä | 961a0db | 2014-10-16 21:29:42 +0300 | [diff] [blame] | 534 | } |
| 535 | |
Ville Syrjälä | 9f2bdb0 | 2016-12-14 20:00:23 +0200 | [diff] [blame] | 536 | static enum pipe vlv_find_free_pps(struct drm_i915_private *dev_priv) |
| 537 | { |
| 538 | struct intel_encoder *encoder; |
| 539 | unsigned int pipes = (1 << PIPE_A) | (1 << PIPE_B); |
| 540 | |
| 541 | /* |
| 542 | * We don't have power sequencer currently. |
| 543 | * Pick one that's not used by other ports. |
| 544 | */ |
| 545 | for_each_intel_encoder(&dev_priv->drm, encoder) { |
| 546 | struct intel_dp *intel_dp; |
| 547 | |
| 548 | if (encoder->type != INTEL_OUTPUT_DP && |
| 549 | encoder->type != INTEL_OUTPUT_EDP) |
| 550 | continue; |
| 551 | |
| 552 | intel_dp = enc_to_intel_dp(&encoder->base); |
| 553 | |
| 554 | if (encoder->type == INTEL_OUTPUT_EDP) { |
| 555 | WARN_ON(intel_dp->active_pipe != INVALID_PIPE && |
| 556 | intel_dp->active_pipe != intel_dp->pps_pipe); |
| 557 | |
| 558 | if (intel_dp->pps_pipe != INVALID_PIPE) |
| 559 | pipes &= ~(1 << intel_dp->pps_pipe); |
| 560 | } else { |
| 561 | WARN_ON(intel_dp->pps_pipe != INVALID_PIPE); |
| 562 | |
| 563 | if (intel_dp->active_pipe != INVALID_PIPE) |
| 564 | pipes &= ~(1 << intel_dp->active_pipe); |
| 565 | } |
| 566 | } |
| 567 | |
| 568 | if (pipes == 0) |
| 569 | return INVALID_PIPE; |
| 570 | |
| 571 | return ffs(pipes) - 1; |
| 572 | } |
| 573 | |
Jani Nikula | bf13e81 | 2013-09-06 07:40:05 +0300 | [diff] [blame] | 574 | static enum pipe |
| 575 | vlv_power_sequencer_pipe(struct intel_dp *intel_dp) |
| 576 | { |
Ville Syrjälä | 46bd838 | 2017-10-31 22:51:22 +0200 | [diff] [blame] | 577 | struct drm_i915_private *dev_priv = to_i915(intel_dp_to_dev(intel_dp)); |
Jani Nikula | bf13e81 | 2013-09-06 07:40:05 +0300 | [diff] [blame] | 578 | struct intel_digital_port *intel_dig_port = dp_to_dig_port(intel_dp); |
Ville Syrjälä | a8c3344 | 2014-10-16 21:29:59 +0300 | [diff] [blame] | 579 | enum pipe pipe; |
Jani Nikula | bf13e81 | 2013-09-06 07:40:05 +0300 | [diff] [blame] | 580 | |
Ville Syrjälä | e39b999 | 2014-09-04 14:53:14 +0300 | [diff] [blame] | 581 | lockdep_assert_held(&dev_priv->pps_mutex); |
| 582 | |
Ville Syrjälä | a8c3344 | 2014-10-16 21:29:59 +0300 | [diff] [blame] | 583 | /* We should never land here with regular DP ports */ |
Jani Nikula | 1853a9d | 2017-08-18 12:30:20 +0300 | [diff] [blame] | 584 | WARN_ON(!intel_dp_is_edp(intel_dp)); |
Ville Syrjälä | a8c3344 | 2014-10-16 21:29:59 +0300 | [diff] [blame] | 585 | |
Ville Syrjälä | 9f2bdb0 | 2016-12-14 20:00:23 +0200 | [diff] [blame] | 586 | WARN_ON(intel_dp->active_pipe != INVALID_PIPE && |
| 587 | intel_dp->active_pipe != intel_dp->pps_pipe); |
| 588 | |
Ville Syrjälä | a4a5d2f | 2014-09-04 14:54:20 +0300 | [diff] [blame] | 589 | if (intel_dp->pps_pipe != INVALID_PIPE) |
| 590 | return intel_dp->pps_pipe; |
Jani Nikula | bf13e81 | 2013-09-06 07:40:05 +0300 | [diff] [blame] | 591 | |
Ville Syrjälä | 9f2bdb0 | 2016-12-14 20:00:23 +0200 | [diff] [blame] | 592 | pipe = vlv_find_free_pps(dev_priv); |
Ville Syrjälä | a4a5d2f | 2014-09-04 14:54:20 +0300 | [diff] [blame] | 593 | |
| 594 | /* |
| 595 | * Didn't find one. This should not happen since there |
| 596 | * are two power sequencers and up to two eDP ports. |
| 597 | */ |
Ville Syrjälä | 9f2bdb0 | 2016-12-14 20:00:23 +0200 | [diff] [blame] | 598 | if (WARN_ON(pipe == INVALID_PIPE)) |
Ville Syrjälä | a8c3344 | 2014-10-16 21:29:59 +0300 | [diff] [blame] | 599 | pipe = PIPE_A; |
Ville Syrjälä | a4a5d2f | 2014-09-04 14:54:20 +0300 | [diff] [blame] | 600 | |
Ville Syrjälä | 46bd838 | 2017-10-31 22:51:22 +0200 | [diff] [blame] | 601 | vlv_steal_power_sequencer(dev_priv, pipe); |
Ville Syrjälä | a8c3344 | 2014-10-16 21:29:59 +0300 | [diff] [blame] | 602 | intel_dp->pps_pipe = pipe; |
Ville Syrjälä | a4a5d2f | 2014-09-04 14:54:20 +0300 | [diff] [blame] | 603 | |
| 604 | DRM_DEBUG_KMS("picked pipe %c power sequencer for port %c\n", |
| 605 | pipe_name(intel_dp->pps_pipe), |
Ville Syrjälä | 8f4f279 | 2017-11-09 17:24:34 +0200 | [diff] [blame] | 606 | port_name(intel_dig_port->base.port)); |
Ville Syrjälä | a4a5d2f | 2014-09-04 14:54:20 +0300 | [diff] [blame] | 607 | |
| 608 | /* init power sequencer on this pipe and port */ |
Ville Syrjälä | 46bd838 | 2017-10-31 22:51:22 +0200 | [diff] [blame] | 609 | intel_dp_init_panel_power_sequencer(intel_dp); |
| 610 | intel_dp_init_panel_power_sequencer_registers(intel_dp, true); |
Ville Syrjälä | a4a5d2f | 2014-09-04 14:54:20 +0300 | [diff] [blame] | 611 | |
Ville Syrjälä | 961a0db | 2014-10-16 21:29:42 +0300 | [diff] [blame] | 612 | /* |
| 613 | * Even vdd force doesn't work until we've made |
| 614 | * the power sequencer lock in on the port. |
| 615 | */ |
| 616 | vlv_power_sequencer_kick(intel_dp); |
Ville Syrjälä | a4a5d2f | 2014-09-04 14:54:20 +0300 | [diff] [blame] | 617 | |
| 618 | return intel_dp->pps_pipe; |
| 619 | } |
| 620 | |
Imre Deak | 7859799 | 2016-06-16 16:37:20 +0300 | [diff] [blame] | 621 | static int |
| 622 | bxt_power_sequencer_idx(struct intel_dp *intel_dp) |
| 623 | { |
Ville Syrjälä | 46bd838 | 2017-10-31 22:51:22 +0200 | [diff] [blame] | 624 | struct drm_i915_private *dev_priv = to_i915(intel_dp_to_dev(intel_dp)); |
Imre Deak | 7859799 | 2016-06-16 16:37:20 +0300 | [diff] [blame] | 625 | |
| 626 | lockdep_assert_held(&dev_priv->pps_mutex); |
| 627 | |
| 628 | /* We should never land here with regular DP ports */ |
Jani Nikula | 1853a9d | 2017-08-18 12:30:20 +0300 | [diff] [blame] | 629 | WARN_ON(!intel_dp_is_edp(intel_dp)); |
Imre Deak | 7859799 | 2016-06-16 16:37:20 +0300 | [diff] [blame] | 630 | |
| 631 | /* |
| 632 | * TODO: BXT has 2 PPS instances. The correct port->PPS instance |
| 633 | * mapping needs to be retrieved from VBT, for now just hard-code to |
| 634 | * use instance #0 always. |
| 635 | */ |
| 636 | if (!intel_dp->pps_reset) |
| 637 | return 0; |
| 638 | |
| 639 | intel_dp->pps_reset = false; |
| 640 | |
| 641 | /* |
| 642 | * Only the HW needs to be reprogrammed, the SW state is fixed and |
| 643 | * has been setup during connector init. |
| 644 | */ |
Ville Syrjälä | 46bd838 | 2017-10-31 22:51:22 +0200 | [diff] [blame] | 645 | intel_dp_init_panel_power_sequencer_registers(intel_dp, false); |
Imre Deak | 7859799 | 2016-06-16 16:37:20 +0300 | [diff] [blame] | 646 | |
| 647 | return 0; |
| 648 | } |
| 649 | |
Ville Syrjälä | 6491ab2 | 2014-08-18 22:16:06 +0300 | [diff] [blame] | 650 | typedef bool (*vlv_pipe_check)(struct drm_i915_private *dev_priv, |
| 651 | enum pipe pipe); |
| 652 | |
| 653 | static bool vlv_pipe_has_pp_on(struct drm_i915_private *dev_priv, |
| 654 | enum pipe pipe) |
| 655 | { |
Imre Deak | 44cb734 | 2016-08-10 14:07:29 +0300 | [diff] [blame] | 656 | return I915_READ(PP_STATUS(pipe)) & PP_ON; |
Ville Syrjälä | 6491ab2 | 2014-08-18 22:16:06 +0300 | [diff] [blame] | 657 | } |
| 658 | |
| 659 | static bool vlv_pipe_has_vdd_on(struct drm_i915_private *dev_priv, |
| 660 | enum pipe pipe) |
| 661 | { |
Imre Deak | 44cb734 | 2016-08-10 14:07:29 +0300 | [diff] [blame] | 662 | return I915_READ(PP_CONTROL(pipe)) & EDP_FORCE_VDD; |
Ville Syrjälä | 6491ab2 | 2014-08-18 22:16:06 +0300 | [diff] [blame] | 663 | } |
| 664 | |
| 665 | static bool vlv_pipe_any(struct drm_i915_private *dev_priv, |
| 666 | enum pipe pipe) |
| 667 | { |
| 668 | return true; |
| 669 | } |
| 670 | |
Ville Syrjälä | a4a5d2f | 2014-09-04 14:54:20 +0300 | [diff] [blame] | 671 | static enum pipe |
Ville Syrjälä | 6491ab2 | 2014-08-18 22:16:06 +0300 | [diff] [blame] | 672 | vlv_initial_pps_pipe(struct drm_i915_private *dev_priv, |
| 673 | enum port port, |
| 674 | vlv_pipe_check pipe_check) |
Ville Syrjälä | a4a5d2f | 2014-09-04 14:54:20 +0300 | [diff] [blame] | 675 | { |
Jani Nikula | bf13e81 | 2013-09-06 07:40:05 +0300 | [diff] [blame] | 676 | enum pipe pipe; |
| 677 | |
Jani Nikula | bf13e81 | 2013-09-06 07:40:05 +0300 | [diff] [blame] | 678 | for (pipe = PIPE_A; pipe <= PIPE_B; pipe++) { |
Imre Deak | 44cb734 | 2016-08-10 14:07:29 +0300 | [diff] [blame] | 679 | u32 port_sel = I915_READ(PP_ON_DELAYS(pipe)) & |
Jani Nikula | bf13e81 | 2013-09-06 07:40:05 +0300 | [diff] [blame] | 680 | PANEL_PORT_SELECT_MASK; |
Ville Syrjälä | a4a5d2f | 2014-09-04 14:54:20 +0300 | [diff] [blame] | 681 | |
| 682 | if (port_sel != PANEL_PORT_SELECT_VLV(port)) |
| 683 | continue; |
| 684 | |
Ville Syrjälä | 6491ab2 | 2014-08-18 22:16:06 +0300 | [diff] [blame] | 685 | if (!pipe_check(dev_priv, pipe)) |
| 686 | continue; |
| 687 | |
Ville Syrjälä | a4a5d2f | 2014-09-04 14:54:20 +0300 | [diff] [blame] | 688 | return pipe; |
Jani Nikula | bf13e81 | 2013-09-06 07:40:05 +0300 | [diff] [blame] | 689 | } |
| 690 | |
Ville Syrjälä | a4a5d2f | 2014-09-04 14:54:20 +0300 | [diff] [blame] | 691 | return INVALID_PIPE; |
| 692 | } |
| 693 | |
| 694 | static void |
| 695 | vlv_initial_power_sequencer_setup(struct intel_dp *intel_dp) |
| 696 | { |
Ville Syrjälä | 46bd838 | 2017-10-31 22:51:22 +0200 | [diff] [blame] | 697 | struct drm_i915_private *dev_priv = to_i915(intel_dp_to_dev(intel_dp)); |
Ville Syrjälä | a4a5d2f | 2014-09-04 14:54:20 +0300 | [diff] [blame] | 698 | struct intel_digital_port *intel_dig_port = dp_to_dig_port(intel_dp); |
Ville Syrjälä | 8f4f279 | 2017-11-09 17:24:34 +0200 | [diff] [blame] | 699 | enum port port = intel_dig_port->base.port; |
Ville Syrjälä | a4a5d2f | 2014-09-04 14:54:20 +0300 | [diff] [blame] | 700 | |
| 701 | lockdep_assert_held(&dev_priv->pps_mutex); |
| 702 | |
| 703 | /* try to find a pipe with this port selected */ |
Ville Syrjälä | 6491ab2 | 2014-08-18 22:16:06 +0300 | [diff] [blame] | 704 | /* first pick one where the panel is on */ |
| 705 | intel_dp->pps_pipe = vlv_initial_pps_pipe(dev_priv, port, |
| 706 | vlv_pipe_has_pp_on); |
| 707 | /* didn't find one? pick one where vdd is on */ |
| 708 | if (intel_dp->pps_pipe == INVALID_PIPE) |
| 709 | intel_dp->pps_pipe = vlv_initial_pps_pipe(dev_priv, port, |
| 710 | vlv_pipe_has_vdd_on); |
| 711 | /* didn't find one? pick one with just the correct port */ |
| 712 | if (intel_dp->pps_pipe == INVALID_PIPE) |
| 713 | intel_dp->pps_pipe = vlv_initial_pps_pipe(dev_priv, port, |
| 714 | vlv_pipe_any); |
Ville Syrjälä | a4a5d2f | 2014-09-04 14:54:20 +0300 | [diff] [blame] | 715 | |
| 716 | /* didn't find one? just let vlv_power_sequencer_pipe() pick one when needed */ |
| 717 | if (intel_dp->pps_pipe == INVALID_PIPE) { |
| 718 | DRM_DEBUG_KMS("no initial power sequencer for port %c\n", |
| 719 | port_name(port)); |
| 720 | return; |
| 721 | } |
| 722 | |
| 723 | DRM_DEBUG_KMS("initial power sequencer for port %c: pipe %c\n", |
| 724 | port_name(port), pipe_name(intel_dp->pps_pipe)); |
| 725 | |
Ville Syrjälä | 46bd838 | 2017-10-31 22:51:22 +0200 | [diff] [blame] | 726 | intel_dp_init_panel_power_sequencer(intel_dp); |
| 727 | intel_dp_init_panel_power_sequencer_registers(intel_dp, false); |
Jani Nikula | bf13e81 | 2013-09-06 07:40:05 +0300 | [diff] [blame] | 728 | } |
| 729 | |
Imre Deak | 7859799 | 2016-06-16 16:37:20 +0300 | [diff] [blame] | 730 | void intel_power_sequencer_reset(struct drm_i915_private *dev_priv) |
Ville Syrjälä | 773538e8 | 2014-09-04 14:54:56 +0300 | [diff] [blame] | 731 | { |
Ville Syrjälä | 773538e8 | 2014-09-04 14:54:56 +0300 | [diff] [blame] | 732 | struct intel_encoder *encoder; |
| 733 | |
Tvrtko Ursulin | 920a14b | 2016-10-14 10:13:44 +0100 | [diff] [blame] | 734 | if (WARN_ON(!IS_VALLEYVIEW(dev_priv) && !IS_CHERRYVIEW(dev_priv) && |
Ander Conselvan de Oliveira | cc3f90f | 2016-12-02 10:23:49 +0200 | [diff] [blame] | 735 | !IS_GEN9_LP(dev_priv))) |
Ville Syrjälä | 773538e8 | 2014-09-04 14:54:56 +0300 | [diff] [blame] | 736 | return; |
| 737 | |
| 738 | /* |
| 739 | * We can't grab pps_mutex here due to deadlock with power_domain |
| 740 | * mutex when power_domain functions are called while holding pps_mutex. |
| 741 | * That also means that in order to use pps_pipe the code needs to |
| 742 | * hold both a power domain reference and pps_mutex, and the power domain |
| 743 | * reference get/put must be done while _not_ holding pps_mutex. |
| 744 | * pps_{lock,unlock}() do these steps in the correct order, so one |
| 745 | * should use them always. |
| 746 | */ |
| 747 | |
Ville Syrjälä | 2f77347 | 2017-11-09 17:27:58 +0200 | [diff] [blame] | 748 | for_each_intel_encoder(&dev_priv->drm, encoder) { |
Ville Syrjälä | 773538e8 | 2014-09-04 14:54:56 +0300 | [diff] [blame] | 749 | struct intel_dp *intel_dp; |
| 750 | |
Ville Syrjälä | 9f2bdb0 | 2016-12-14 20:00:23 +0200 | [diff] [blame] | 751 | if (encoder->type != INTEL_OUTPUT_DP && |
Ville Syrjälä | 7e732ca | 2017-10-27 22:31:24 +0300 | [diff] [blame] | 752 | encoder->type != INTEL_OUTPUT_EDP && |
| 753 | encoder->type != INTEL_OUTPUT_DDI) |
Ville Syrjälä | 773538e8 | 2014-09-04 14:54:56 +0300 | [diff] [blame] | 754 | continue; |
| 755 | |
| 756 | intel_dp = enc_to_intel_dp(&encoder->base); |
Ville Syrjälä | 9f2bdb0 | 2016-12-14 20:00:23 +0200 | [diff] [blame] | 757 | |
Ville Syrjälä | 7e732ca | 2017-10-27 22:31:24 +0300 | [diff] [blame] | 758 | /* Skip pure DVI/HDMI DDI encoders */ |
| 759 | if (!i915_mmio_reg_valid(intel_dp->output_reg)) |
| 760 | continue; |
| 761 | |
Ville Syrjälä | 9f2bdb0 | 2016-12-14 20:00:23 +0200 | [diff] [blame] | 762 | WARN_ON(intel_dp->active_pipe != INVALID_PIPE); |
| 763 | |
| 764 | if (encoder->type != INTEL_OUTPUT_EDP) |
| 765 | continue; |
| 766 | |
Ander Conselvan de Oliveira | cc3f90f | 2016-12-02 10:23:49 +0200 | [diff] [blame] | 767 | if (IS_GEN9_LP(dev_priv)) |
Imre Deak | 7859799 | 2016-06-16 16:37:20 +0300 | [diff] [blame] | 768 | intel_dp->pps_reset = true; |
| 769 | else |
| 770 | intel_dp->pps_pipe = INVALID_PIPE; |
Ville Syrjälä | 773538e8 | 2014-09-04 14:54:56 +0300 | [diff] [blame] | 771 | } |
Jani Nikula | bf13e81 | 2013-09-06 07:40:05 +0300 | [diff] [blame] | 772 | } |
| 773 | |
Imre Deak | 8e8232d | 2016-06-16 16:37:21 +0300 | [diff] [blame] | 774 | struct pps_registers { |
| 775 | i915_reg_t pp_ctrl; |
| 776 | i915_reg_t pp_stat; |
| 777 | i915_reg_t pp_on; |
| 778 | i915_reg_t pp_off; |
| 779 | i915_reg_t pp_div; |
| 780 | }; |
| 781 | |
Ville Syrjälä | 46bd838 | 2017-10-31 22:51:22 +0200 | [diff] [blame] | 782 | static void intel_pps_get_registers(struct intel_dp *intel_dp, |
Imre Deak | 8e8232d | 2016-06-16 16:37:21 +0300 | [diff] [blame] | 783 | struct pps_registers *regs) |
| 784 | { |
Ville Syrjälä | 46bd838 | 2017-10-31 22:51:22 +0200 | [diff] [blame] | 785 | struct drm_i915_private *dev_priv = to_i915(intel_dp_to_dev(intel_dp)); |
Imre Deak | 44cb734 | 2016-08-10 14:07:29 +0300 | [diff] [blame] | 786 | int pps_idx = 0; |
| 787 | |
Imre Deak | 8e8232d | 2016-06-16 16:37:21 +0300 | [diff] [blame] | 788 | memset(regs, 0, sizeof(*regs)); |
| 789 | |
Ander Conselvan de Oliveira | cc3f90f | 2016-12-02 10:23:49 +0200 | [diff] [blame] | 790 | if (IS_GEN9_LP(dev_priv)) |
Imre Deak | 44cb734 | 2016-08-10 14:07:29 +0300 | [diff] [blame] | 791 | pps_idx = bxt_power_sequencer_idx(intel_dp); |
| 792 | else if (IS_VALLEYVIEW(dev_priv) || IS_CHERRYVIEW(dev_priv)) |
| 793 | pps_idx = vlv_power_sequencer_pipe(intel_dp); |
Imre Deak | 8e8232d | 2016-06-16 16:37:21 +0300 | [diff] [blame] | 794 | |
Imre Deak | 44cb734 | 2016-08-10 14:07:29 +0300 | [diff] [blame] | 795 | regs->pp_ctrl = PP_CONTROL(pps_idx); |
| 796 | regs->pp_stat = PP_STATUS(pps_idx); |
| 797 | regs->pp_on = PP_ON_DELAYS(pps_idx); |
| 798 | regs->pp_off = PP_OFF_DELAYS(pps_idx); |
Rodrigo Vivi | 938361e | 2017-06-02 13:06:44 -0700 | [diff] [blame] | 799 | if (!IS_GEN9_LP(dev_priv) && !HAS_PCH_CNP(dev_priv)) |
Imre Deak | 44cb734 | 2016-08-10 14:07:29 +0300 | [diff] [blame] | 800 | regs->pp_div = PP_DIVISOR(pps_idx); |
Imre Deak | 8e8232d | 2016-06-16 16:37:21 +0300 | [diff] [blame] | 801 | } |
| 802 | |
Ville Syrjälä | f0f59a0 | 2015-11-18 15:33:26 +0200 | [diff] [blame] | 803 | static i915_reg_t |
| 804 | _pp_ctrl_reg(struct intel_dp *intel_dp) |
Jani Nikula | bf13e81 | 2013-09-06 07:40:05 +0300 | [diff] [blame] | 805 | { |
Imre Deak | 8e8232d | 2016-06-16 16:37:21 +0300 | [diff] [blame] | 806 | struct pps_registers regs; |
Jani Nikula | bf13e81 | 2013-09-06 07:40:05 +0300 | [diff] [blame] | 807 | |
Ville Syrjälä | 46bd838 | 2017-10-31 22:51:22 +0200 | [diff] [blame] | 808 | intel_pps_get_registers(intel_dp, ®s); |
Imre Deak | 8e8232d | 2016-06-16 16:37:21 +0300 | [diff] [blame] | 809 | |
| 810 | return regs.pp_ctrl; |
Jani Nikula | bf13e81 | 2013-09-06 07:40:05 +0300 | [diff] [blame] | 811 | } |
| 812 | |
Ville Syrjälä | f0f59a0 | 2015-11-18 15:33:26 +0200 | [diff] [blame] | 813 | static i915_reg_t |
| 814 | _pp_stat_reg(struct intel_dp *intel_dp) |
Jani Nikula | bf13e81 | 2013-09-06 07:40:05 +0300 | [diff] [blame] | 815 | { |
Imre Deak | 8e8232d | 2016-06-16 16:37:21 +0300 | [diff] [blame] | 816 | struct pps_registers regs; |
Jani Nikula | bf13e81 | 2013-09-06 07:40:05 +0300 | [diff] [blame] | 817 | |
Ville Syrjälä | 46bd838 | 2017-10-31 22:51:22 +0200 | [diff] [blame] | 818 | intel_pps_get_registers(intel_dp, ®s); |
Imre Deak | 8e8232d | 2016-06-16 16:37:21 +0300 | [diff] [blame] | 819 | |
| 820 | return regs.pp_stat; |
Jani Nikula | bf13e81 | 2013-09-06 07:40:05 +0300 | [diff] [blame] | 821 | } |
| 822 | |
Clint Taylor | 01527b3 | 2014-07-07 13:01:46 -0700 | [diff] [blame] | 823 | /* Reboot notifier handler to shutdown panel power to guarantee T12 timing |
| 824 | This function only applicable when panel PM state is not to be tracked */ |
| 825 | static int edp_notify_handler(struct notifier_block *this, unsigned long code, |
| 826 | void *unused) |
| 827 | { |
| 828 | struct intel_dp *intel_dp = container_of(this, typeof(* intel_dp), |
| 829 | edp_notifier); |
Ville Syrjälä | 2f77347 | 2017-11-09 17:27:58 +0200 | [diff] [blame] | 830 | struct drm_i915_private *dev_priv = to_i915(intel_dp_to_dev(intel_dp)); |
Clint Taylor | 01527b3 | 2014-07-07 13:01:46 -0700 | [diff] [blame] | 831 | |
Jani Nikula | 1853a9d | 2017-08-18 12:30:20 +0300 | [diff] [blame] | 832 | if (!intel_dp_is_edp(intel_dp) || code != SYS_RESTART) |
Clint Taylor | 01527b3 | 2014-07-07 13:01:46 -0700 | [diff] [blame] | 833 | return 0; |
| 834 | |
Ville Syrjälä | 773538e8 | 2014-09-04 14:54:56 +0300 | [diff] [blame] | 835 | pps_lock(intel_dp); |
Ville Syrjälä | e39b999 | 2014-09-04 14:53:14 +0300 | [diff] [blame] | 836 | |
Tvrtko Ursulin | 920a14b | 2016-10-14 10:13:44 +0100 | [diff] [blame] | 837 | if (IS_VALLEYVIEW(dev_priv) || IS_CHERRYVIEW(dev_priv)) { |
Ville Syrjälä | e39b999 | 2014-09-04 14:53:14 +0300 | [diff] [blame] | 838 | enum pipe pipe = vlv_power_sequencer_pipe(intel_dp); |
Ville Syrjälä | f0f59a0 | 2015-11-18 15:33:26 +0200 | [diff] [blame] | 839 | i915_reg_t pp_ctrl_reg, pp_div_reg; |
Ville Syrjälä | 649636e | 2015-09-22 19:50:01 +0300 | [diff] [blame] | 840 | u32 pp_div; |
Ville Syrjälä | e39b999 | 2014-09-04 14:53:14 +0300 | [diff] [blame] | 841 | |
Imre Deak | 44cb734 | 2016-08-10 14:07:29 +0300 | [diff] [blame] | 842 | pp_ctrl_reg = PP_CONTROL(pipe); |
| 843 | pp_div_reg = PP_DIVISOR(pipe); |
Clint Taylor | 01527b3 | 2014-07-07 13:01:46 -0700 | [diff] [blame] | 844 | pp_div = I915_READ(pp_div_reg); |
| 845 | pp_div &= PP_REFERENCE_DIVIDER_MASK; |
| 846 | |
| 847 | /* 0x1F write to PP_DIV_REG sets max cycle delay */ |
| 848 | I915_WRITE(pp_div_reg, pp_div | 0x1F); |
| 849 | I915_WRITE(pp_ctrl_reg, PANEL_UNLOCK_REGS | PANEL_POWER_OFF); |
| 850 | msleep(intel_dp->panel_power_cycle_delay); |
| 851 | } |
| 852 | |
Ville Syrjälä | 773538e8 | 2014-09-04 14:54:56 +0300 | [diff] [blame] | 853 | pps_unlock(intel_dp); |
Ville Syrjälä | e39b999 | 2014-09-04 14:53:14 +0300 | [diff] [blame] | 854 | |
Clint Taylor | 01527b3 | 2014-07-07 13:01:46 -0700 | [diff] [blame] | 855 | return 0; |
| 856 | } |
| 857 | |
Daniel Vetter | 4be7378 | 2014-01-17 14:39:48 +0100 | [diff] [blame] | 858 | static bool edp_have_panel_power(struct intel_dp *intel_dp) |
Keith Packard | ebf33b1 | 2011-09-29 15:53:27 -0700 | [diff] [blame] | 859 | { |
Ville Syrjälä | 2f77347 | 2017-11-09 17:27:58 +0200 | [diff] [blame] | 860 | struct drm_i915_private *dev_priv = to_i915(intel_dp_to_dev(intel_dp)); |
Keith Packard | ebf33b1 | 2011-09-29 15:53:27 -0700 | [diff] [blame] | 861 | |
Ville Syrjälä | e39b999 | 2014-09-04 14:53:14 +0300 | [diff] [blame] | 862 | lockdep_assert_held(&dev_priv->pps_mutex); |
| 863 | |
Tvrtko Ursulin | 920a14b | 2016-10-14 10:13:44 +0100 | [diff] [blame] | 864 | if ((IS_VALLEYVIEW(dev_priv) || IS_CHERRYVIEW(dev_priv)) && |
Ville Syrjälä | 9a42356 | 2014-10-16 21:29:48 +0300 | [diff] [blame] | 865 | intel_dp->pps_pipe == INVALID_PIPE) |
| 866 | return false; |
| 867 | |
Jani Nikula | bf13e81 | 2013-09-06 07:40:05 +0300 | [diff] [blame] | 868 | return (I915_READ(_pp_stat_reg(intel_dp)) & PP_ON) != 0; |
Keith Packard | ebf33b1 | 2011-09-29 15:53:27 -0700 | [diff] [blame] | 869 | } |
| 870 | |
Daniel Vetter | 4be7378 | 2014-01-17 14:39:48 +0100 | [diff] [blame] | 871 | static bool edp_have_panel_vdd(struct intel_dp *intel_dp) |
Keith Packard | ebf33b1 | 2011-09-29 15:53:27 -0700 | [diff] [blame] | 872 | { |
Ville Syrjälä | 2f77347 | 2017-11-09 17:27:58 +0200 | [diff] [blame] | 873 | struct drm_i915_private *dev_priv = to_i915(intel_dp_to_dev(intel_dp)); |
Keith Packard | ebf33b1 | 2011-09-29 15:53:27 -0700 | [diff] [blame] | 874 | |
Ville Syrjälä | e39b999 | 2014-09-04 14:53:14 +0300 | [diff] [blame] | 875 | lockdep_assert_held(&dev_priv->pps_mutex); |
| 876 | |
Tvrtko Ursulin | 920a14b | 2016-10-14 10:13:44 +0100 | [diff] [blame] | 877 | if ((IS_VALLEYVIEW(dev_priv) || IS_CHERRYVIEW(dev_priv)) && |
Ville Syrjälä | 9a42356 | 2014-10-16 21:29:48 +0300 | [diff] [blame] | 878 | intel_dp->pps_pipe == INVALID_PIPE) |
| 879 | return false; |
| 880 | |
Ville Syrjälä | 773538e8 | 2014-09-04 14:54:56 +0300 | [diff] [blame] | 881 | return I915_READ(_pp_ctrl_reg(intel_dp)) & EDP_FORCE_VDD; |
Keith Packard | ebf33b1 | 2011-09-29 15:53:27 -0700 | [diff] [blame] | 882 | } |
| 883 | |
Keith Packard | 9b984da | 2011-09-19 13:54:47 -0700 | [diff] [blame] | 884 | static void |
| 885 | intel_dp_check_edp(struct intel_dp *intel_dp) |
| 886 | { |
Ville Syrjälä | 2f77347 | 2017-11-09 17:27:58 +0200 | [diff] [blame] | 887 | struct drm_i915_private *dev_priv = to_i915(intel_dp_to_dev(intel_dp)); |
Keith Packard | ebf33b1 | 2011-09-29 15:53:27 -0700 | [diff] [blame] | 888 | |
Jani Nikula | 1853a9d | 2017-08-18 12:30:20 +0300 | [diff] [blame] | 889 | if (!intel_dp_is_edp(intel_dp)) |
Keith Packard | 9b984da | 2011-09-19 13:54:47 -0700 | [diff] [blame] | 890 | return; |
Jesse Barnes | 453c542 | 2013-03-28 09:55:41 -0700 | [diff] [blame] | 891 | |
Daniel Vetter | 4be7378 | 2014-01-17 14:39:48 +0100 | [diff] [blame] | 892 | if (!edp_have_panel_power(intel_dp) && !edp_have_panel_vdd(intel_dp)) { |
Keith Packard | 9b984da | 2011-09-19 13:54:47 -0700 | [diff] [blame] | 893 | WARN(1, "eDP powered off while attempting aux channel communication.\n"); |
| 894 | DRM_DEBUG_KMS("Status 0x%08x Control 0x%08x\n", |
Jani Nikula | bf13e81 | 2013-09-06 07:40:05 +0300 | [diff] [blame] | 895 | I915_READ(_pp_stat_reg(intel_dp)), |
| 896 | I915_READ(_pp_ctrl_reg(intel_dp))); |
Keith Packard | 9b984da | 2011-09-19 13:54:47 -0700 | [diff] [blame] | 897 | } |
| 898 | } |
| 899 | |
Daniel Vetter | 9ee32fea | 2012-12-01 13:53:48 +0100 | [diff] [blame] | 900 | static uint32_t |
| 901 | intel_dp_aux_wait_done(struct intel_dp *intel_dp, bool has_aux_irq) |
| 902 | { |
Ville Syrjälä | 2f77347 | 2017-11-09 17:27:58 +0200 | [diff] [blame] | 903 | struct drm_i915_private *dev_priv = to_i915(intel_dp_to_dev(intel_dp)); |
Ville Syrjälä | f0f59a0 | 2015-11-18 15:33:26 +0200 | [diff] [blame] | 904 | i915_reg_t ch_ctl = intel_dp->aux_ch_ctl_reg; |
Daniel Vetter | 9ee32fea | 2012-12-01 13:53:48 +0100 | [diff] [blame] | 905 | uint32_t status; |
| 906 | bool done; |
| 907 | |
Daniel Vetter | ef04f00 | 2012-12-01 21:03:59 +0100 | [diff] [blame] | 908 | #define C (((status = I915_READ_NOTRACE(ch_ctl)) & DP_AUX_CH_CTL_SEND_BUSY) == 0) |
Daniel Vetter | 9ee32fea | 2012-12-01 13:53:48 +0100 | [diff] [blame] | 909 | if (has_aux_irq) |
Paulo Zanoni | b18ac46 | 2013-02-18 19:00:24 -0300 | [diff] [blame] | 910 | done = wait_event_timeout(dev_priv->gmbus_wait_queue, C, |
Imre Deak | 3598706 | 2013-05-21 20:03:20 +0300 | [diff] [blame] | 911 | msecs_to_jiffies_timeout(10)); |
Daniel Vetter | 9ee32fea | 2012-12-01 13:53:48 +0100 | [diff] [blame] | 912 | else |
Imre Deak | 713a6b66 | 2016-06-28 13:37:33 +0300 | [diff] [blame] | 913 | done = wait_for(C, 10) == 0; |
Daniel Vetter | 9ee32fea | 2012-12-01 13:53:48 +0100 | [diff] [blame] | 914 | if (!done) |
| 915 | DRM_ERROR("dp aux hw did not signal timeout (has irq: %i)!\n", |
| 916 | has_aux_irq); |
| 917 | #undef C |
| 918 | |
| 919 | return status; |
| 920 | } |
| 921 | |
Ville Syrjälä | 6ffb1be | 2016-03-02 17:22:14 +0200 | [diff] [blame] | 922 | static uint32_t g4x_get_aux_clock_divider(struct intel_dp *intel_dp, int index) |
Damien Lespiau | ec5b01d | 2014-01-21 13:35:39 +0000 | [diff] [blame] | 923 | { |
| 924 | struct intel_digital_port *intel_dig_port = dp_to_dig_port(intel_dp); |
Ville Syrjälä | e7dc33f | 2016-03-02 17:22:13 +0200 | [diff] [blame] | 925 | struct drm_i915_private *dev_priv = to_i915(intel_dig_port->base.base.dev); |
Damien Lespiau | ec5b01d | 2014-01-21 13:35:39 +0000 | [diff] [blame] | 926 | |
Ville Syrjälä | a457f54 | 2016-03-02 17:22:17 +0200 | [diff] [blame] | 927 | if (index) |
| 928 | return 0; |
| 929 | |
Damien Lespiau | ec5b01d | 2014-01-21 13:35:39 +0000 | [diff] [blame] | 930 | /* |
| 931 | * The clock divider is based off the hrawclk, and would like to run at |
Ville Syrjälä | a457f54 | 2016-03-02 17:22:17 +0200 | [diff] [blame] | 932 | * 2MHz. So, take the hrawclk value and divide by 2000 and use that |
Damien Lespiau | ec5b01d | 2014-01-21 13:35:39 +0000 | [diff] [blame] | 933 | */ |
Ville Syrjälä | a457f54 | 2016-03-02 17:22:17 +0200 | [diff] [blame] | 934 | return DIV_ROUND_CLOSEST(dev_priv->rawclk_freq, 2000); |
Damien Lespiau | ec5b01d | 2014-01-21 13:35:39 +0000 | [diff] [blame] | 935 | } |
| 936 | |
| 937 | static uint32_t ilk_get_aux_clock_divider(struct intel_dp *intel_dp, int index) |
| 938 | { |
| 939 | struct intel_digital_port *intel_dig_port = dp_to_dig_port(intel_dp); |
Ville Syrjälä | a457f54 | 2016-03-02 17:22:17 +0200 | [diff] [blame] | 940 | struct drm_i915_private *dev_priv = to_i915(intel_dig_port->base.base.dev); |
Damien Lespiau | ec5b01d | 2014-01-21 13:35:39 +0000 | [diff] [blame] | 941 | |
| 942 | if (index) |
| 943 | return 0; |
| 944 | |
Ville Syrjälä | a457f54 | 2016-03-02 17:22:17 +0200 | [diff] [blame] | 945 | /* |
| 946 | * The clock divider is based off the cdclk or PCH rawclk, and would |
| 947 | * like to run at 2MHz. So, take the cdclk or PCH rawclk value and |
| 948 | * divide by 2000 and use that |
| 949 | */ |
Ville Syrjälä | 8f4f279 | 2017-11-09 17:24:34 +0200 | [diff] [blame] | 950 | if (intel_dig_port->base.port == PORT_A) |
Ville Syrjälä | 49cd97a | 2017-02-07 20:33:45 +0200 | [diff] [blame] | 951 | return DIV_ROUND_CLOSEST(dev_priv->cdclk.hw.cdclk, 2000); |
Ville Syrjälä | e7dc33f | 2016-03-02 17:22:13 +0200 | [diff] [blame] | 952 | else |
| 953 | return DIV_ROUND_CLOSEST(dev_priv->rawclk_freq, 2000); |
Damien Lespiau | ec5b01d | 2014-01-21 13:35:39 +0000 | [diff] [blame] | 954 | } |
| 955 | |
| 956 | static uint32_t hsw_get_aux_clock_divider(struct intel_dp *intel_dp, int index) |
Rodrigo Vivi | b84a1cf | 2013-07-11 18:44:57 -0300 | [diff] [blame] | 957 | { |
| 958 | struct intel_digital_port *intel_dig_port = dp_to_dig_port(intel_dp); |
Ville Syrjälä | a457f54 | 2016-03-02 17:22:17 +0200 | [diff] [blame] | 959 | struct drm_i915_private *dev_priv = to_i915(intel_dig_port->base.base.dev); |
Rodrigo Vivi | b84a1cf | 2013-07-11 18:44:57 -0300 | [diff] [blame] | 960 | |
Ville Syrjälä | 8f4f279 | 2017-11-09 17:24:34 +0200 | [diff] [blame] | 961 | if (intel_dig_port->base.port != PORT_A && HAS_PCH_LPT_H(dev_priv)) { |
Rodrigo Vivi | b84a1cf | 2013-07-11 18:44:57 -0300 | [diff] [blame] | 962 | /* Workaround for non-ULT HSW */ |
Chris Wilson | bc86625 | 2013-07-21 16:00:03 +0100 | [diff] [blame] | 963 | switch (index) { |
| 964 | case 0: return 63; |
| 965 | case 1: return 72; |
| 966 | default: return 0; |
| 967 | } |
Rodrigo Vivi | b84a1cf | 2013-07-11 18:44:57 -0300 | [diff] [blame] | 968 | } |
Ville Syrjälä | a457f54 | 2016-03-02 17:22:17 +0200 | [diff] [blame] | 969 | |
| 970 | return ilk_get_aux_clock_divider(intel_dp, index); |
Rodrigo Vivi | b84a1cf | 2013-07-11 18:44:57 -0300 | [diff] [blame] | 971 | } |
| 972 | |
Damien Lespiau | b6b5e38 | 2014-01-20 16:00:59 +0000 | [diff] [blame] | 973 | static uint32_t skl_get_aux_clock_divider(struct intel_dp *intel_dp, int index) |
| 974 | { |
| 975 | /* |
| 976 | * SKL doesn't need us to program the AUX clock divider (Hardware will |
| 977 | * derive the clock from CDCLK automatically). We still implement the |
| 978 | * get_aux_clock_divider vfunc to plug-in into the existing code. |
| 979 | */ |
| 980 | return index ? 0 : 1; |
| 981 | } |
| 982 | |
Ville Syrjälä | 6ffb1be | 2016-03-02 17:22:14 +0200 | [diff] [blame] | 983 | static uint32_t g4x_get_aux_send_ctl(struct intel_dp *intel_dp, |
| 984 | bool has_aux_irq, |
| 985 | int send_bytes, |
| 986 | uint32_t aux_clock_divider) |
Damien Lespiau | 5ed12a1 | 2014-01-20 15:52:30 +0000 | [diff] [blame] | 987 | { |
| 988 | struct intel_digital_port *intel_dig_port = dp_to_dig_port(intel_dp); |
Tvrtko Ursulin | 8652744 | 2016-10-13 11:03:00 +0100 | [diff] [blame] | 989 | struct drm_i915_private *dev_priv = |
| 990 | to_i915(intel_dig_port->base.base.dev); |
Damien Lespiau | 5ed12a1 | 2014-01-20 15:52:30 +0000 | [diff] [blame] | 991 | uint32_t precharge, timeout; |
| 992 | |
Tvrtko Ursulin | 8652744 | 2016-10-13 11:03:00 +0100 | [diff] [blame] | 993 | if (IS_GEN6(dev_priv)) |
Damien Lespiau | 5ed12a1 | 2014-01-20 15:52:30 +0000 | [diff] [blame] | 994 | precharge = 3; |
| 995 | else |
| 996 | precharge = 5; |
| 997 | |
James Ausmus | 8f5f63d | 2017-10-12 14:30:37 -0700 | [diff] [blame] | 998 | if (IS_BROADWELL(dev_priv)) |
Damien Lespiau | 5ed12a1 | 2014-01-20 15:52:30 +0000 | [diff] [blame] | 999 | timeout = DP_AUX_CH_CTL_TIME_OUT_600us; |
| 1000 | else |
| 1001 | timeout = DP_AUX_CH_CTL_TIME_OUT_400us; |
| 1002 | |
| 1003 | return DP_AUX_CH_CTL_SEND_BUSY | |
Damien Lespiau | 788d443 | 2014-01-20 15:52:31 +0000 | [diff] [blame] | 1004 | DP_AUX_CH_CTL_DONE | |
Damien Lespiau | 5ed12a1 | 2014-01-20 15:52:30 +0000 | [diff] [blame] | 1005 | (has_aux_irq ? DP_AUX_CH_CTL_INTERRUPT : 0) | |
Damien Lespiau | 788d443 | 2014-01-20 15:52:31 +0000 | [diff] [blame] | 1006 | DP_AUX_CH_CTL_TIME_OUT_ERROR | |
Damien Lespiau | 5ed12a1 | 2014-01-20 15:52:30 +0000 | [diff] [blame] | 1007 | timeout | |
Damien Lespiau | 788d443 | 2014-01-20 15:52:31 +0000 | [diff] [blame] | 1008 | DP_AUX_CH_CTL_RECEIVE_ERROR | |
Damien Lespiau | 5ed12a1 | 2014-01-20 15:52:30 +0000 | [diff] [blame] | 1009 | (send_bytes << DP_AUX_CH_CTL_MESSAGE_SIZE_SHIFT) | |
| 1010 | (precharge << DP_AUX_CH_CTL_PRECHARGE_2US_SHIFT) | |
Damien Lespiau | 788d443 | 2014-01-20 15:52:31 +0000 | [diff] [blame] | 1011 | (aux_clock_divider << DP_AUX_CH_CTL_BIT_CLOCK_2X_SHIFT); |
Damien Lespiau | 5ed12a1 | 2014-01-20 15:52:30 +0000 | [diff] [blame] | 1012 | } |
| 1013 | |
Damien Lespiau | b9ca5fa | 2014-01-20 16:01:00 +0000 | [diff] [blame] | 1014 | static uint32_t skl_get_aux_send_ctl(struct intel_dp *intel_dp, |
| 1015 | bool has_aux_irq, |
| 1016 | int send_bytes, |
| 1017 | uint32_t unused) |
| 1018 | { |
| 1019 | return DP_AUX_CH_CTL_SEND_BUSY | |
| 1020 | DP_AUX_CH_CTL_DONE | |
| 1021 | (has_aux_irq ? DP_AUX_CH_CTL_INTERRUPT : 0) | |
| 1022 | DP_AUX_CH_CTL_TIME_OUT_ERROR | |
James Ausmus | 6fa228b | 2017-10-12 14:30:36 -0700 | [diff] [blame] | 1023 | DP_AUX_CH_CTL_TIME_OUT_MAX | |
Damien Lespiau | b9ca5fa | 2014-01-20 16:01:00 +0000 | [diff] [blame] | 1024 | DP_AUX_CH_CTL_RECEIVE_ERROR | |
| 1025 | (send_bytes << DP_AUX_CH_CTL_MESSAGE_SIZE_SHIFT) | |
Daniel Vetter | d4dcbdc | 2016-05-18 18:47:15 +0200 | [diff] [blame] | 1026 | DP_AUX_CH_CTL_FW_SYNC_PULSE_SKL(32) | |
Damien Lespiau | b9ca5fa | 2014-01-20 16:01:00 +0000 | [diff] [blame] | 1027 | DP_AUX_CH_CTL_SYNC_PULSE_SKL(32); |
| 1028 | } |
| 1029 | |
Sean Paul | 20f24d7 | 2018-01-08 14:55:43 -0500 | [diff] [blame] | 1030 | static uint32_t intel_dp_get_aux_send_ctl(struct intel_dp *intel_dp, |
| 1031 | bool has_aux_irq, |
| 1032 | int send_bytes, |
| 1033 | uint32_t aux_clock_divider, |
| 1034 | bool aksv_write) |
| 1035 | { |
| 1036 | uint32_t val = 0; |
| 1037 | |
| 1038 | if (aksv_write) { |
| 1039 | send_bytes += 5; |
| 1040 | val |= DP_AUX_CH_CTL_AUX_AKSV_SELECT; |
| 1041 | } |
| 1042 | |
| 1043 | return val | intel_dp->get_aux_send_ctl(intel_dp, |
| 1044 | has_aux_irq, |
| 1045 | send_bytes, |
| 1046 | aux_clock_divider); |
| 1047 | } |
| 1048 | |
Keith Packard | a4fc5ed | 2009-04-07 16:16:42 -0700 | [diff] [blame] | 1049 | static int |
Chris Wilson | ea5b213 | 2010-08-04 13:50:23 +0100 | [diff] [blame] | 1050 | intel_dp_aux_ch(struct intel_dp *intel_dp, |
Daniel Vetter | bd9f74a | 2014-10-02 09:45:35 +0200 | [diff] [blame] | 1051 | const uint8_t *send, int send_bytes, |
Sean Paul | 20f24d7 | 2018-01-08 14:55:43 -0500 | [diff] [blame] | 1052 | uint8_t *recv, int recv_size, bool aksv_write) |
Keith Packard | a4fc5ed | 2009-04-07 16:16:42 -0700 | [diff] [blame] | 1053 | { |
Paulo Zanoni | 174edf1 | 2012-10-26 19:05:50 -0200 | [diff] [blame] | 1054 | struct intel_digital_port *intel_dig_port = dp_to_dig_port(intel_dp); |
Tvrtko Ursulin | 0031fb9 | 2016-11-04 14:42:44 +0000 | [diff] [blame] | 1055 | struct drm_i915_private *dev_priv = |
| 1056 | to_i915(intel_dig_port->base.base.dev); |
Ville Syrjälä | f0f59a0 | 2015-11-18 15:33:26 +0200 | [diff] [blame] | 1057 | i915_reg_t ch_ctl = intel_dp->aux_ch_ctl_reg; |
Chris Wilson | bc86625 | 2013-07-21 16:00:03 +0100 | [diff] [blame] | 1058 | uint32_t aux_clock_divider; |
Daniel Vetter | 9ee32fea | 2012-12-01 13:53:48 +0100 | [diff] [blame] | 1059 | int i, ret, recv_bytes; |
Keith Packard | a4fc5ed | 2009-04-07 16:16:42 -0700 | [diff] [blame] | 1060 | uint32_t status; |
Damien Lespiau | 5ed12a1 | 2014-01-20 15:52:30 +0000 | [diff] [blame] | 1061 | int try, clock = 0; |
Tvrtko Ursulin | 0031fb9 | 2016-11-04 14:42:44 +0000 | [diff] [blame] | 1062 | bool has_aux_irq = HAS_AUX_IRQ(dev_priv); |
Jani Nikula | 884f19e | 2014-03-14 16:51:14 +0200 | [diff] [blame] | 1063 | bool vdd; |
| 1064 | |
Ville Syrjälä | 773538e8 | 2014-09-04 14:54:56 +0300 | [diff] [blame] | 1065 | pps_lock(intel_dp); |
Ville Syrjälä | e39b999 | 2014-09-04 14:53:14 +0300 | [diff] [blame] | 1066 | |
Ville Syrjälä | 72c3500 | 2014-08-18 22:16:00 +0300 | [diff] [blame] | 1067 | /* |
| 1068 | * We will be called with VDD already enabled for dpcd/edid/oui reads. |
| 1069 | * In such cases we want to leave VDD enabled and it's up to upper layers |
| 1070 | * to turn it off. But for eg. i2c-dev access we need to turn it on/off |
| 1071 | * ourselves. |
| 1072 | */ |
Ville Syrjälä | 1e0560e | 2014-08-19 13:24:25 +0300 | [diff] [blame] | 1073 | vdd = edp_panel_vdd_on(intel_dp); |
Daniel Vetter | 9ee32fea | 2012-12-01 13:53:48 +0100 | [diff] [blame] | 1074 | |
| 1075 | /* dp aux is extremely sensitive to irq latency, hence request the |
| 1076 | * lowest possible wakeup latency and so prevent the cpu from going into |
| 1077 | * deep sleep states. |
| 1078 | */ |
| 1079 | pm_qos_update_request(&dev_priv->pm_qos, 0); |
Keith Packard | a4fc5ed | 2009-04-07 16:16:42 -0700 | [diff] [blame] | 1080 | |
Keith Packard | 9b984da | 2011-09-19 13:54:47 -0700 | [diff] [blame] | 1081 | intel_dp_check_edp(intel_dp); |
Zhenyu Wang | 5eb08b6 | 2009-07-24 01:00:31 +0800 | [diff] [blame] | 1082 | |
Jesse Barnes | 11bee43 | 2011-08-01 15:02:20 -0700 | [diff] [blame] | 1083 | /* Try to wait for any previous AUX channel activity */ |
| 1084 | for (try = 0; try < 3; try++) { |
Daniel Vetter | ef04f00 | 2012-12-01 21:03:59 +0100 | [diff] [blame] | 1085 | status = I915_READ_NOTRACE(ch_ctl); |
Jesse Barnes | 11bee43 | 2011-08-01 15:02:20 -0700 | [diff] [blame] | 1086 | if ((status & DP_AUX_CH_CTL_SEND_BUSY) == 0) |
| 1087 | break; |
| 1088 | msleep(1); |
| 1089 | } |
| 1090 | |
| 1091 | if (try == 3) { |
Mika Kuoppala | 02196c7 | 2015-08-06 16:48:58 +0300 | [diff] [blame] | 1092 | static u32 last_status = -1; |
| 1093 | const u32 status = I915_READ(ch_ctl); |
| 1094 | |
| 1095 | if (status != last_status) { |
| 1096 | WARN(1, "dp_aux_ch not started status 0x%08x\n", |
| 1097 | status); |
| 1098 | last_status = status; |
| 1099 | } |
| 1100 | |
Daniel Vetter | 9ee32fea | 2012-12-01 13:53:48 +0100 | [diff] [blame] | 1101 | ret = -EBUSY; |
| 1102 | goto out; |
Chris Wilson | 4f7f7b7 | 2010-08-18 18:12:56 +0100 | [diff] [blame] | 1103 | } |
| 1104 | |
Paulo Zanoni | 46a5ae9 | 2013-09-17 11:14:10 -0300 | [diff] [blame] | 1105 | /* Only 5 data registers! */ |
| 1106 | if (WARN_ON(send_bytes > 20 || recv_size > 20)) { |
| 1107 | ret = -E2BIG; |
| 1108 | goto out; |
| 1109 | } |
| 1110 | |
Damien Lespiau | ec5b01d | 2014-01-21 13:35:39 +0000 | [diff] [blame] | 1111 | while ((aux_clock_divider = intel_dp->get_aux_clock_divider(intel_dp, clock++))) { |
Sean Paul | 20f24d7 | 2018-01-08 14:55:43 -0500 | [diff] [blame] | 1112 | u32 send_ctl = intel_dp_get_aux_send_ctl(intel_dp, |
| 1113 | has_aux_irq, |
| 1114 | send_bytes, |
| 1115 | aux_clock_divider, |
| 1116 | aksv_write); |
Damien Lespiau | 5ed12a1 | 2014-01-20 15:52:30 +0000 | [diff] [blame] | 1117 | |
Chris Wilson | bc86625 | 2013-07-21 16:00:03 +0100 | [diff] [blame] | 1118 | /* Must try at least 3 times according to DP spec */ |
| 1119 | for (try = 0; try < 5; try++) { |
| 1120 | /* Load the send data into the aux channel data registers */ |
| 1121 | for (i = 0; i < send_bytes; i += 4) |
Ville Syrjälä | 330e20e | 2015-11-11 20:34:14 +0200 | [diff] [blame] | 1122 | I915_WRITE(intel_dp->aux_ch_data_reg[i >> 2], |
Rodrigo Vivi | a4f1289 | 2014-11-14 08:52:27 -0800 | [diff] [blame] | 1123 | intel_dp_pack_aux(send + i, |
| 1124 | send_bytes - i)); |
Akshay Joshi | 0206e35 | 2011-08-16 15:34:10 -0400 | [diff] [blame] | 1125 | |
Chris Wilson | bc86625 | 2013-07-21 16:00:03 +0100 | [diff] [blame] | 1126 | /* Send the command and wait for it to complete */ |
Damien Lespiau | 5ed12a1 | 2014-01-20 15:52:30 +0000 | [diff] [blame] | 1127 | I915_WRITE(ch_ctl, send_ctl); |
Daniel Vetter | 9ee32fea | 2012-12-01 13:53:48 +0100 | [diff] [blame] | 1128 | |
Chris Wilson | bc86625 | 2013-07-21 16:00:03 +0100 | [diff] [blame] | 1129 | status = intel_dp_aux_wait_done(intel_dp, has_aux_irq); |
Akshay Joshi | 0206e35 | 2011-08-16 15:34:10 -0400 | [diff] [blame] | 1130 | |
Chris Wilson | bc86625 | 2013-07-21 16:00:03 +0100 | [diff] [blame] | 1131 | /* Clear done status and any errors */ |
| 1132 | I915_WRITE(ch_ctl, |
| 1133 | status | |
| 1134 | DP_AUX_CH_CTL_DONE | |
| 1135 | DP_AUX_CH_CTL_TIME_OUT_ERROR | |
| 1136 | DP_AUX_CH_CTL_RECEIVE_ERROR); |
Adam Jackson | d7e96fe | 2011-07-26 15:39:46 -0400 | [diff] [blame] | 1137 | |
Todd Previte | 74ebf29 | 2015-04-15 08:38:41 -0700 | [diff] [blame] | 1138 | if (status & DP_AUX_CH_CTL_TIME_OUT_ERROR) |
Chris Wilson | bc86625 | 2013-07-21 16:00:03 +0100 | [diff] [blame] | 1139 | continue; |
Todd Previte | 74ebf29 | 2015-04-15 08:38:41 -0700 | [diff] [blame] | 1140 | |
| 1141 | /* DP CTS 1.2 Core Rev 1.1, 4.2.1.1 & 4.2.1.2 |
| 1142 | * 400us delay required for errors and timeouts |
| 1143 | * Timeout errors from the HW already meet this |
| 1144 | * requirement so skip to next iteration |
| 1145 | */ |
| 1146 | if (status & DP_AUX_CH_CTL_RECEIVE_ERROR) { |
| 1147 | usleep_range(400, 500); |
| 1148 | continue; |
| 1149 | } |
Chris Wilson | bc86625 | 2013-07-21 16:00:03 +0100 | [diff] [blame] | 1150 | if (status & DP_AUX_CH_CTL_DONE) |
Jim Bride | e058c94 | 2015-05-27 10:21:48 -0700 | [diff] [blame] | 1151 | goto done; |
Chris Wilson | bc86625 | 2013-07-21 16:00:03 +0100 | [diff] [blame] | 1152 | } |
Keith Packard | a4fc5ed | 2009-04-07 16:16:42 -0700 | [diff] [blame] | 1153 | } |
| 1154 | |
Keith Packard | a4fc5ed | 2009-04-07 16:16:42 -0700 | [diff] [blame] | 1155 | if ((status & DP_AUX_CH_CTL_DONE) == 0) { |
Keith Packard | 1ae8c0a | 2009-06-28 15:42:17 -0700 | [diff] [blame] | 1156 | DRM_ERROR("dp_aux_ch not done status 0x%08x\n", status); |
Daniel Vetter | 9ee32fea | 2012-12-01 13:53:48 +0100 | [diff] [blame] | 1157 | ret = -EBUSY; |
| 1158 | goto out; |
Keith Packard | a4fc5ed | 2009-04-07 16:16:42 -0700 | [diff] [blame] | 1159 | } |
| 1160 | |
Jim Bride | e058c94 | 2015-05-27 10:21:48 -0700 | [diff] [blame] | 1161 | done: |
Keith Packard | a4fc5ed | 2009-04-07 16:16:42 -0700 | [diff] [blame] | 1162 | /* Check for timeout or receive error. |
| 1163 | * Timeouts occur when the sink is not connected |
| 1164 | */ |
Keith Packard | a5b3da5 | 2009-06-11 22:30:32 -0700 | [diff] [blame] | 1165 | if (status & DP_AUX_CH_CTL_RECEIVE_ERROR) { |
Keith Packard | 1ae8c0a | 2009-06-28 15:42:17 -0700 | [diff] [blame] | 1166 | DRM_ERROR("dp_aux_ch receive error status 0x%08x\n", status); |
Daniel Vetter | 9ee32fea | 2012-12-01 13:53:48 +0100 | [diff] [blame] | 1167 | ret = -EIO; |
| 1168 | goto out; |
Keith Packard | a5b3da5 | 2009-06-11 22:30:32 -0700 | [diff] [blame] | 1169 | } |
Keith Packard | 1ae8c0a | 2009-06-28 15:42:17 -0700 | [diff] [blame] | 1170 | |
| 1171 | /* Timeouts occur when the device isn't connected, so they're |
| 1172 | * "normal" -- don't fill the kernel log with these */ |
Keith Packard | a5b3da5 | 2009-06-11 22:30:32 -0700 | [diff] [blame] | 1173 | if (status & DP_AUX_CH_CTL_TIME_OUT_ERROR) { |
Chris Wilson | a5570fe | 2017-02-23 11:51:02 +0000 | [diff] [blame] | 1174 | DRM_DEBUG_KMS("dp_aux_ch timeout status 0x%08x\n", status); |
Daniel Vetter | 9ee32fea | 2012-12-01 13:53:48 +0100 | [diff] [blame] | 1175 | ret = -ETIMEDOUT; |
| 1176 | goto out; |
Keith Packard | a4fc5ed | 2009-04-07 16:16:42 -0700 | [diff] [blame] | 1177 | } |
| 1178 | |
| 1179 | /* Unload any bytes sent back from the other side */ |
| 1180 | recv_bytes = ((status & DP_AUX_CH_CTL_MESSAGE_SIZE_MASK) >> |
| 1181 | DP_AUX_CH_CTL_MESSAGE_SIZE_SHIFT); |
Rodrigo Vivi | 14e0188 | 2015-12-10 11:12:27 -0800 | [diff] [blame] | 1182 | |
| 1183 | /* |
| 1184 | * By BSpec: "Message sizes of 0 or >20 are not allowed." |
| 1185 | * We have no idea of what happened so we return -EBUSY so |
| 1186 | * drm layer takes care for the necessary retries. |
| 1187 | */ |
| 1188 | if (recv_bytes == 0 || recv_bytes > 20) { |
| 1189 | DRM_DEBUG_KMS("Forbidden recv_bytes = %d on aux transaction\n", |
| 1190 | recv_bytes); |
| 1191 | /* |
| 1192 | * FIXME: This patch was created on top of a series that |
| 1193 | * organize the retries at drm level. There EBUSY should |
| 1194 | * also take care for 1ms wait before retrying. |
| 1195 | * That aux retries re-org is still needed and after that is |
| 1196 | * merged we remove this sleep from here. |
| 1197 | */ |
| 1198 | usleep_range(1000, 1500); |
| 1199 | ret = -EBUSY; |
| 1200 | goto out; |
| 1201 | } |
| 1202 | |
Keith Packard | a4fc5ed | 2009-04-07 16:16:42 -0700 | [diff] [blame] | 1203 | if (recv_bytes > recv_size) |
| 1204 | recv_bytes = recv_size; |
Akshay Joshi | 0206e35 | 2011-08-16 15:34:10 -0400 | [diff] [blame] | 1205 | |
Chris Wilson | 4f7f7b7 | 2010-08-18 18:12:56 +0100 | [diff] [blame] | 1206 | for (i = 0; i < recv_bytes; i += 4) |
Ville Syrjälä | 330e20e | 2015-11-11 20:34:14 +0200 | [diff] [blame] | 1207 | intel_dp_unpack_aux(I915_READ(intel_dp->aux_ch_data_reg[i >> 2]), |
Rodrigo Vivi | a4f1289 | 2014-11-14 08:52:27 -0800 | [diff] [blame] | 1208 | recv + i, recv_bytes - i); |
Keith Packard | a4fc5ed | 2009-04-07 16:16:42 -0700 | [diff] [blame] | 1209 | |
Daniel Vetter | 9ee32fea | 2012-12-01 13:53:48 +0100 | [diff] [blame] | 1210 | ret = recv_bytes; |
| 1211 | out: |
| 1212 | pm_qos_update_request(&dev_priv->pm_qos, PM_QOS_DEFAULT_VALUE); |
| 1213 | |
Jani Nikula | 884f19e | 2014-03-14 16:51:14 +0200 | [diff] [blame] | 1214 | if (vdd) |
| 1215 | edp_panel_vdd_off(intel_dp, false); |
| 1216 | |
Ville Syrjälä | 773538e8 | 2014-09-04 14:54:56 +0300 | [diff] [blame] | 1217 | pps_unlock(intel_dp); |
Ville Syrjälä | e39b999 | 2014-09-04 14:53:14 +0300 | [diff] [blame] | 1218 | |
Daniel Vetter | 9ee32fea | 2012-12-01 13:53:48 +0100 | [diff] [blame] | 1219 | return ret; |
Keith Packard | a4fc5ed | 2009-04-07 16:16:42 -0700 | [diff] [blame] | 1220 | } |
| 1221 | |
Jani Nikula | a6c8aff0 | 2014-04-07 12:37:25 +0300 | [diff] [blame] | 1222 | #define BARE_ADDRESS_SIZE 3 |
| 1223 | #define HEADER_SIZE (BARE_ADDRESS_SIZE + 1) |
Jani Nikula | 9d1a103 | 2014-03-14 16:51:15 +0200 | [diff] [blame] | 1224 | static ssize_t |
| 1225 | intel_dp_aux_transfer(struct drm_dp_aux *aux, struct drm_dp_aux_msg *msg) |
Keith Packard | a4fc5ed | 2009-04-07 16:16:42 -0700 | [diff] [blame] | 1226 | { |
Jani Nikula | 9d1a103 | 2014-03-14 16:51:15 +0200 | [diff] [blame] | 1227 | struct intel_dp *intel_dp = container_of(aux, struct intel_dp, aux); |
| 1228 | uint8_t txbuf[20], rxbuf[20]; |
| 1229 | size_t txsize, rxsize; |
Keith Packard | a4fc5ed | 2009-04-07 16:16:42 -0700 | [diff] [blame] | 1230 | int ret; |
Keith Packard | a4fc5ed | 2009-04-07 16:16:42 -0700 | [diff] [blame] | 1231 | |
Ville Syrjälä | d2d9cbb | 2015-03-19 11:44:06 +0200 | [diff] [blame] | 1232 | txbuf[0] = (msg->request << 4) | |
| 1233 | ((msg->address >> 16) & 0xf); |
| 1234 | txbuf[1] = (msg->address >> 8) & 0xff; |
Jani Nikula | 9d1a103 | 2014-03-14 16:51:15 +0200 | [diff] [blame] | 1235 | txbuf[2] = msg->address & 0xff; |
| 1236 | txbuf[3] = msg->size - 1; |
Paulo Zanoni | 46a5ae9 | 2013-09-17 11:14:10 -0300 | [diff] [blame] | 1237 | |
Jani Nikula | 9d1a103 | 2014-03-14 16:51:15 +0200 | [diff] [blame] | 1238 | switch (msg->request & ~DP_AUX_I2C_MOT) { |
| 1239 | case DP_AUX_NATIVE_WRITE: |
| 1240 | case DP_AUX_I2C_WRITE: |
Ville Syrjälä | c1e74122 | 2015-08-27 17:23:27 +0300 | [diff] [blame] | 1241 | case DP_AUX_I2C_WRITE_STATUS_UPDATE: |
Jani Nikula | a6c8aff0 | 2014-04-07 12:37:25 +0300 | [diff] [blame] | 1242 | txsize = msg->size ? HEADER_SIZE + msg->size : BARE_ADDRESS_SIZE; |
Jani Nikula | a1ddefd | 2015-03-17 17:18:54 +0200 | [diff] [blame] | 1243 | rxsize = 2; /* 0 or 1 data bytes */ |
Jani Nikula | f51a44b | 2014-02-11 11:52:05 +0200 | [diff] [blame] | 1244 | |
Jani Nikula | 9d1a103 | 2014-03-14 16:51:15 +0200 | [diff] [blame] | 1245 | if (WARN_ON(txsize > 20)) |
| 1246 | return -E2BIG; |
Keith Packard | a4fc5ed | 2009-04-07 16:16:42 -0700 | [diff] [blame] | 1247 | |
Ville Syrjälä | dd78809 | 2016-07-28 17:55:04 +0300 | [diff] [blame] | 1248 | WARN_ON(!msg->buffer != !msg->size); |
| 1249 | |
Imre Deak | d81a67c | 2016-01-29 14:52:26 +0200 | [diff] [blame] | 1250 | if (msg->buffer) |
| 1251 | memcpy(txbuf + HEADER_SIZE, msg->buffer, msg->size); |
Keith Packard | a4fc5ed | 2009-04-07 16:16:42 -0700 | [diff] [blame] | 1252 | |
Sean Paul | 20f24d7 | 2018-01-08 14:55:43 -0500 | [diff] [blame] | 1253 | ret = intel_dp_aux_ch(intel_dp, txbuf, txsize, rxbuf, rxsize, |
| 1254 | false); |
Jani Nikula | 9d1a103 | 2014-03-14 16:51:15 +0200 | [diff] [blame] | 1255 | if (ret > 0) { |
| 1256 | msg->reply = rxbuf[0] >> 4; |
Keith Packard | a4fc5ed | 2009-04-07 16:16:42 -0700 | [diff] [blame] | 1257 | |
Jani Nikula | a1ddefd | 2015-03-17 17:18:54 +0200 | [diff] [blame] | 1258 | if (ret > 1) { |
| 1259 | /* Number of bytes written in a short write. */ |
| 1260 | ret = clamp_t(int, rxbuf[1], 0, msg->size); |
| 1261 | } else { |
| 1262 | /* Return payload size. */ |
| 1263 | ret = msg->size; |
| 1264 | } |
Keith Packard | a4fc5ed | 2009-04-07 16:16:42 -0700 | [diff] [blame] | 1265 | } |
Jani Nikula | 9d1a103 | 2014-03-14 16:51:15 +0200 | [diff] [blame] | 1266 | break; |
| 1267 | |
| 1268 | case DP_AUX_NATIVE_READ: |
| 1269 | case DP_AUX_I2C_READ: |
Jani Nikula | a6c8aff0 | 2014-04-07 12:37:25 +0300 | [diff] [blame] | 1270 | txsize = msg->size ? HEADER_SIZE : BARE_ADDRESS_SIZE; |
Jani Nikula | 9d1a103 | 2014-03-14 16:51:15 +0200 | [diff] [blame] | 1271 | rxsize = msg->size + 1; |
| 1272 | |
| 1273 | if (WARN_ON(rxsize > 20)) |
| 1274 | return -E2BIG; |
| 1275 | |
Sean Paul | 20f24d7 | 2018-01-08 14:55:43 -0500 | [diff] [blame] | 1276 | ret = intel_dp_aux_ch(intel_dp, txbuf, txsize, rxbuf, rxsize, |
| 1277 | false); |
Jani Nikula | 9d1a103 | 2014-03-14 16:51:15 +0200 | [diff] [blame] | 1278 | if (ret > 0) { |
| 1279 | msg->reply = rxbuf[0] >> 4; |
| 1280 | /* |
| 1281 | * Assume happy day, and copy the data. The caller is |
| 1282 | * expected to check msg->reply before touching it. |
| 1283 | * |
| 1284 | * Return payload size. |
| 1285 | */ |
| 1286 | ret--; |
| 1287 | memcpy(msg->buffer, rxbuf + 1, ret); |
| 1288 | } |
| 1289 | break; |
| 1290 | |
| 1291 | default: |
| 1292 | ret = -EINVAL; |
| 1293 | break; |
Keith Packard | a4fc5ed | 2009-04-07 16:16:42 -0700 | [diff] [blame] | 1294 | } |
Jani Nikula | f51a44b | 2014-02-11 11:52:05 +0200 | [diff] [blame] | 1295 | |
Jani Nikula | 9d1a103 | 2014-03-14 16:51:15 +0200 | [diff] [blame] | 1296 | return ret; |
Keith Packard | a4fc5ed | 2009-04-07 16:16:42 -0700 | [diff] [blame] | 1297 | } |
| 1298 | |
Ville Syrjälä | 8f7ce03 | 2016-10-11 20:52:45 +0300 | [diff] [blame] | 1299 | static enum port intel_aux_port(struct drm_i915_private *dev_priv, |
| 1300 | enum port port) |
| 1301 | { |
| 1302 | const struct ddi_vbt_port_info *info = |
| 1303 | &dev_priv->vbt.ddi_port_info[port]; |
| 1304 | enum port aux_port; |
| 1305 | |
| 1306 | if (!info->alternate_aux_channel) { |
| 1307 | DRM_DEBUG_KMS("using AUX %c for port %c (platform default)\n", |
| 1308 | port_name(port), port_name(port)); |
| 1309 | return port; |
| 1310 | } |
| 1311 | |
| 1312 | switch (info->alternate_aux_channel) { |
| 1313 | case DP_AUX_A: |
| 1314 | aux_port = PORT_A; |
| 1315 | break; |
| 1316 | case DP_AUX_B: |
| 1317 | aux_port = PORT_B; |
| 1318 | break; |
| 1319 | case DP_AUX_C: |
| 1320 | aux_port = PORT_C; |
| 1321 | break; |
| 1322 | case DP_AUX_D: |
| 1323 | aux_port = PORT_D; |
| 1324 | break; |
| 1325 | default: |
| 1326 | MISSING_CASE(info->alternate_aux_channel); |
| 1327 | aux_port = PORT_A; |
| 1328 | break; |
| 1329 | } |
| 1330 | |
| 1331 | DRM_DEBUG_KMS("using AUX %c for port %c (VBT)\n", |
| 1332 | port_name(aux_port), port_name(port)); |
| 1333 | |
| 1334 | return aux_port; |
| 1335 | } |
| 1336 | |
Ville Syrjälä | f0f59a0 | 2015-11-18 15:33:26 +0200 | [diff] [blame] | 1337 | static i915_reg_t g4x_aux_ctl_reg(struct drm_i915_private *dev_priv, |
Ville Syrjälä | c8a89b0 | 2016-10-11 20:52:48 +0300 | [diff] [blame] | 1338 | enum port port) |
Ville Syrjälä | da00bdc | 2015-11-11 20:34:13 +0200 | [diff] [blame] | 1339 | { |
| 1340 | switch (port) { |
| 1341 | case PORT_B: |
| 1342 | case PORT_C: |
| 1343 | case PORT_D: |
| 1344 | return DP_AUX_CH_CTL(port); |
| 1345 | default: |
| 1346 | MISSING_CASE(port); |
| 1347 | return DP_AUX_CH_CTL(PORT_B); |
| 1348 | } |
| 1349 | } |
| 1350 | |
Ville Syrjälä | f0f59a0 | 2015-11-18 15:33:26 +0200 | [diff] [blame] | 1351 | static i915_reg_t g4x_aux_data_reg(struct drm_i915_private *dev_priv, |
Ville Syrjälä | c8a89b0 | 2016-10-11 20:52:48 +0300 | [diff] [blame] | 1352 | enum port port, int index) |
Ville Syrjälä | 330e20e | 2015-11-11 20:34:14 +0200 | [diff] [blame] | 1353 | { |
| 1354 | switch (port) { |
| 1355 | case PORT_B: |
| 1356 | case PORT_C: |
| 1357 | case PORT_D: |
| 1358 | return DP_AUX_CH_DATA(port, index); |
| 1359 | default: |
| 1360 | MISSING_CASE(port); |
| 1361 | return DP_AUX_CH_DATA(PORT_B, index); |
| 1362 | } |
| 1363 | } |
| 1364 | |
Ville Syrjälä | f0f59a0 | 2015-11-18 15:33:26 +0200 | [diff] [blame] | 1365 | static i915_reg_t ilk_aux_ctl_reg(struct drm_i915_private *dev_priv, |
Ville Syrjälä | c8a89b0 | 2016-10-11 20:52:48 +0300 | [diff] [blame] | 1366 | enum port port) |
Ville Syrjälä | da00bdc | 2015-11-11 20:34:13 +0200 | [diff] [blame] | 1367 | { |
| 1368 | switch (port) { |
| 1369 | case PORT_A: |
| 1370 | return DP_AUX_CH_CTL(port); |
| 1371 | case PORT_B: |
| 1372 | case PORT_C: |
| 1373 | case PORT_D: |
| 1374 | return PCH_DP_AUX_CH_CTL(port); |
| 1375 | default: |
| 1376 | MISSING_CASE(port); |
| 1377 | return DP_AUX_CH_CTL(PORT_A); |
| 1378 | } |
| 1379 | } |
| 1380 | |
Ville Syrjälä | f0f59a0 | 2015-11-18 15:33:26 +0200 | [diff] [blame] | 1381 | static i915_reg_t ilk_aux_data_reg(struct drm_i915_private *dev_priv, |
Ville Syrjälä | c8a89b0 | 2016-10-11 20:52:48 +0300 | [diff] [blame] | 1382 | enum port port, int index) |
Ville Syrjälä | 330e20e | 2015-11-11 20:34:14 +0200 | [diff] [blame] | 1383 | { |
| 1384 | switch (port) { |
| 1385 | case PORT_A: |
| 1386 | return DP_AUX_CH_DATA(port, index); |
| 1387 | case PORT_B: |
| 1388 | case PORT_C: |
| 1389 | case PORT_D: |
| 1390 | return PCH_DP_AUX_CH_DATA(port, index); |
| 1391 | default: |
| 1392 | MISSING_CASE(port); |
| 1393 | return DP_AUX_CH_DATA(PORT_A, index); |
| 1394 | } |
| 1395 | } |
| 1396 | |
Ville Syrjälä | f0f59a0 | 2015-11-18 15:33:26 +0200 | [diff] [blame] | 1397 | static i915_reg_t skl_aux_ctl_reg(struct drm_i915_private *dev_priv, |
Ville Syrjälä | c8a89b0 | 2016-10-11 20:52:48 +0300 | [diff] [blame] | 1398 | enum port port) |
Ville Syrjälä | da00bdc | 2015-11-11 20:34:13 +0200 | [diff] [blame] | 1399 | { |
Ville Syrjälä | da00bdc | 2015-11-11 20:34:13 +0200 | [diff] [blame] | 1400 | switch (port) { |
| 1401 | case PORT_A: |
| 1402 | case PORT_B: |
| 1403 | case PORT_C: |
| 1404 | case PORT_D: |
| 1405 | return DP_AUX_CH_CTL(port); |
| 1406 | default: |
| 1407 | MISSING_CASE(port); |
| 1408 | return DP_AUX_CH_CTL(PORT_A); |
| 1409 | } |
| 1410 | } |
| 1411 | |
Ville Syrjälä | f0f59a0 | 2015-11-18 15:33:26 +0200 | [diff] [blame] | 1412 | static i915_reg_t skl_aux_data_reg(struct drm_i915_private *dev_priv, |
Ville Syrjälä | c8a89b0 | 2016-10-11 20:52:48 +0300 | [diff] [blame] | 1413 | enum port port, int index) |
Ville Syrjälä | 330e20e | 2015-11-11 20:34:14 +0200 | [diff] [blame] | 1414 | { |
Ville Syrjälä | 330e20e | 2015-11-11 20:34:14 +0200 | [diff] [blame] | 1415 | switch (port) { |
| 1416 | case PORT_A: |
| 1417 | case PORT_B: |
| 1418 | case PORT_C: |
| 1419 | case PORT_D: |
| 1420 | return DP_AUX_CH_DATA(port, index); |
| 1421 | default: |
| 1422 | MISSING_CASE(port); |
| 1423 | return DP_AUX_CH_DATA(PORT_A, index); |
| 1424 | } |
| 1425 | } |
| 1426 | |
Ville Syrjälä | f0f59a0 | 2015-11-18 15:33:26 +0200 | [diff] [blame] | 1427 | static i915_reg_t intel_aux_ctl_reg(struct drm_i915_private *dev_priv, |
Ville Syrjälä | c8a89b0 | 2016-10-11 20:52:48 +0300 | [diff] [blame] | 1428 | enum port port) |
Ville Syrjälä | 330e20e | 2015-11-11 20:34:14 +0200 | [diff] [blame] | 1429 | { |
| 1430 | if (INTEL_INFO(dev_priv)->gen >= 9) |
| 1431 | return skl_aux_ctl_reg(dev_priv, port); |
| 1432 | else if (HAS_PCH_SPLIT(dev_priv)) |
| 1433 | return ilk_aux_ctl_reg(dev_priv, port); |
| 1434 | else |
| 1435 | return g4x_aux_ctl_reg(dev_priv, port); |
| 1436 | } |
| 1437 | |
Ville Syrjälä | f0f59a0 | 2015-11-18 15:33:26 +0200 | [diff] [blame] | 1438 | static i915_reg_t intel_aux_data_reg(struct drm_i915_private *dev_priv, |
Ville Syrjälä | c8a89b0 | 2016-10-11 20:52:48 +0300 | [diff] [blame] | 1439 | enum port port, int index) |
Ville Syrjälä | 330e20e | 2015-11-11 20:34:14 +0200 | [diff] [blame] | 1440 | { |
| 1441 | if (INTEL_INFO(dev_priv)->gen >= 9) |
| 1442 | return skl_aux_data_reg(dev_priv, port, index); |
| 1443 | else if (HAS_PCH_SPLIT(dev_priv)) |
| 1444 | return ilk_aux_data_reg(dev_priv, port, index); |
| 1445 | else |
| 1446 | return g4x_aux_data_reg(dev_priv, port, index); |
| 1447 | } |
| 1448 | |
| 1449 | static void intel_aux_reg_init(struct intel_dp *intel_dp) |
| 1450 | { |
| 1451 | struct drm_i915_private *dev_priv = to_i915(intel_dp_to_dev(intel_dp)); |
Ville Syrjälä | 8f7ce03 | 2016-10-11 20:52:45 +0300 | [diff] [blame] | 1452 | enum port port = intel_aux_port(dev_priv, |
Ville Syrjälä | 8f4f279 | 2017-11-09 17:24:34 +0200 | [diff] [blame] | 1453 | dp_to_dig_port(intel_dp)->base.port); |
Ville Syrjälä | 330e20e | 2015-11-11 20:34:14 +0200 | [diff] [blame] | 1454 | int i; |
| 1455 | |
| 1456 | intel_dp->aux_ch_ctl_reg = intel_aux_ctl_reg(dev_priv, port); |
| 1457 | for (i = 0; i < ARRAY_SIZE(intel_dp->aux_ch_data_reg); i++) |
| 1458 | intel_dp->aux_ch_data_reg[i] = intel_aux_data_reg(dev_priv, port, i); |
| 1459 | } |
| 1460 | |
Jani Nikula | 9d1a103 | 2014-03-14 16:51:15 +0200 | [diff] [blame] | 1461 | static void |
Ville Syrjälä | a121f4e | 2015-11-11 20:34:11 +0200 | [diff] [blame] | 1462 | intel_dp_aux_fini(struct intel_dp *intel_dp) |
| 1463 | { |
Ville Syrjälä | a121f4e | 2015-11-11 20:34:11 +0200 | [diff] [blame] | 1464 | kfree(intel_dp->aux.name); |
| 1465 | } |
| 1466 | |
Chris Wilson | 7a418e3 | 2016-06-24 14:00:14 +0100 | [diff] [blame] | 1467 | static void |
Mika Kahola | b633958 | 2016-09-09 14:10:52 +0300 | [diff] [blame] | 1468 | intel_dp_aux_init(struct intel_dp *intel_dp) |
Keith Packard | a4fc5ed | 2009-04-07 16:16:42 -0700 | [diff] [blame] | 1469 | { |
Jani Nikula | 33ad662 | 2014-03-14 16:51:16 +0200 | [diff] [blame] | 1470 | struct intel_digital_port *intel_dig_port = dp_to_dig_port(intel_dp); |
Ville Syrjälä | 8f4f279 | 2017-11-09 17:24:34 +0200 | [diff] [blame] | 1471 | enum port port = intel_dig_port->base.port; |
Keith Packard | a4fc5ed | 2009-04-07 16:16:42 -0700 | [diff] [blame] | 1472 | |
Ville Syrjälä | 330e20e | 2015-11-11 20:34:14 +0200 | [diff] [blame] | 1473 | intel_aux_reg_init(intel_dp); |
Chris Wilson | 7a418e3 | 2016-06-24 14:00:14 +0100 | [diff] [blame] | 1474 | drm_dp_aux_init(&intel_dp->aux); |
David Flynn | 8316f33 | 2010-12-08 16:10:21 +0000 | [diff] [blame] | 1475 | |
Chris Wilson | 7a418e3 | 2016-06-24 14:00:14 +0100 | [diff] [blame] | 1476 | /* Failure to allocate our preferred name is not critical */ |
Ville Syrjälä | a121f4e | 2015-11-11 20:34:11 +0200 | [diff] [blame] | 1477 | intel_dp->aux.name = kasprintf(GFP_KERNEL, "DPDDC-%c", port_name(port)); |
Jani Nikula | 9d1a103 | 2014-03-14 16:51:15 +0200 | [diff] [blame] | 1478 | intel_dp->aux.transfer = intel_dp_aux_transfer; |
Keith Packard | a4fc5ed | 2009-04-07 16:16:42 -0700 | [diff] [blame] | 1479 | } |
| 1480 | |
Ander Conselvan de Oliveira | e588fa1 | 2015-10-23 13:01:50 +0300 | [diff] [blame] | 1481 | bool intel_dp_source_supports_hbr2(struct intel_dp *intel_dp) |
Thulasimani,Sivakumar | ed63baa | 2015-08-18 15:30:37 +0530 | [diff] [blame] | 1482 | { |
Jani Nikula | fc603ca | 2017-10-09 12:29:58 +0300 | [diff] [blame] | 1483 | int max_rate = intel_dp->source_rates[intel_dp->num_source_rates - 1]; |
Ander Conselvan de Oliveira | e588fa1 | 2015-10-23 13:01:50 +0300 | [diff] [blame] | 1484 | |
Jani Nikula | fc603ca | 2017-10-09 12:29:58 +0300 | [diff] [blame] | 1485 | return max_rate >= 540000; |
Thulasimani,Sivakumar | ed63baa | 2015-08-18 15:30:37 +0530 | [diff] [blame] | 1486 | } |
| 1487 | |
Daniel Vetter | 0e50338 | 2014-07-04 11:26:04 -0300 | [diff] [blame] | 1488 | static void |
Daniel Vetter | c6bb353 | 2013-04-19 11:14:33 +0200 | [diff] [blame] | 1489 | intel_dp_set_clock(struct intel_encoder *encoder, |
Ville Syrjälä | 840b32b | 2015-08-11 20:21:46 +0300 | [diff] [blame] | 1490 | struct intel_crtc_state *pipe_config) |
Daniel Vetter | c6bb353 | 2013-04-19 11:14:33 +0200 | [diff] [blame] | 1491 | { |
Ville Syrjälä | 2f77347 | 2017-11-09 17:27:58 +0200 | [diff] [blame] | 1492 | struct drm_i915_private *dev_priv = to_i915(encoder->base.dev); |
Chon Ming Lee | 9dd4ffd | 2013-09-04 01:30:37 +0800 | [diff] [blame] | 1493 | const struct dp_link_dpll *divisor = NULL; |
| 1494 | int i, count = 0; |
Daniel Vetter | c6bb353 | 2013-04-19 11:14:33 +0200 | [diff] [blame] | 1495 | |
Tvrtko Ursulin | 9beb5fe | 2016-10-13 11:03:06 +0100 | [diff] [blame] | 1496 | if (IS_G4X(dev_priv)) { |
Chon Ming Lee | 9dd4ffd | 2013-09-04 01:30:37 +0800 | [diff] [blame] | 1497 | divisor = gen4_dpll; |
| 1498 | count = ARRAY_SIZE(gen4_dpll); |
Tvrtko Ursulin | 6e26695 | 2016-10-13 11:02:53 +0100 | [diff] [blame] | 1499 | } else if (HAS_PCH_SPLIT(dev_priv)) { |
Chon Ming Lee | 9dd4ffd | 2013-09-04 01:30:37 +0800 | [diff] [blame] | 1500 | divisor = pch_dpll; |
| 1501 | count = ARRAY_SIZE(pch_dpll); |
Tvrtko Ursulin | 920a14b | 2016-10-14 10:13:44 +0100 | [diff] [blame] | 1502 | } else if (IS_CHERRYVIEW(dev_priv)) { |
Chon Ming Lee | ef9348c | 2014-04-09 13:28:18 +0300 | [diff] [blame] | 1503 | divisor = chv_dpll; |
| 1504 | count = ARRAY_SIZE(chv_dpll); |
Tvrtko Ursulin | 11a914c | 2016-10-13 11:03:08 +0100 | [diff] [blame] | 1505 | } else if (IS_VALLEYVIEW(dev_priv)) { |
Chon Ming Lee | 65ce4bf | 2013-09-04 01:30:38 +0800 | [diff] [blame] | 1506 | divisor = vlv_dpll; |
| 1507 | count = ARRAY_SIZE(vlv_dpll); |
Daniel Vetter | c6bb353 | 2013-04-19 11:14:33 +0200 | [diff] [blame] | 1508 | } |
Chon Ming Lee | 9dd4ffd | 2013-09-04 01:30:37 +0800 | [diff] [blame] | 1509 | |
| 1510 | if (divisor && count) { |
| 1511 | for (i = 0; i < count; i++) { |
Ville Syrjälä | 840b32b | 2015-08-11 20:21:46 +0300 | [diff] [blame] | 1512 | if (pipe_config->port_clock == divisor[i].clock) { |
Chon Ming Lee | 9dd4ffd | 2013-09-04 01:30:37 +0800 | [diff] [blame] | 1513 | pipe_config->dpll = divisor[i].dpll; |
| 1514 | pipe_config->clock_set = true; |
| 1515 | break; |
| 1516 | } |
| 1517 | } |
Daniel Vetter | c6bb353 | 2013-04-19 11:14:33 +0200 | [diff] [blame] | 1518 | } |
| 1519 | } |
| 1520 | |
Ville Syrjälä | 0336400e | 2015-03-12 17:10:39 +0200 | [diff] [blame] | 1521 | static void snprintf_int_array(char *str, size_t len, |
| 1522 | const int *array, int nelem) |
| 1523 | { |
| 1524 | int i; |
| 1525 | |
| 1526 | str[0] = '\0'; |
| 1527 | |
| 1528 | for (i = 0; i < nelem; i++) { |
Jani Nikula | b2f505b | 2015-05-18 16:01:45 +0300 | [diff] [blame] | 1529 | int r = snprintf(str, len, "%s%d", i ? ", " : "", array[i]); |
Ville Syrjälä | 0336400e | 2015-03-12 17:10:39 +0200 | [diff] [blame] | 1530 | if (r >= len) |
| 1531 | return; |
| 1532 | str += r; |
| 1533 | len -= r; |
| 1534 | } |
| 1535 | } |
| 1536 | |
| 1537 | static void intel_dp_print_rates(struct intel_dp *intel_dp) |
| 1538 | { |
Ville Syrjälä | 0336400e | 2015-03-12 17:10:39 +0200 | [diff] [blame] | 1539 | char str[128]; /* FIXME: too big for stack? */ |
| 1540 | |
| 1541 | if ((drm_debug & DRM_UT_KMS) == 0) |
| 1542 | return; |
| 1543 | |
Jani Nikula | 55cfc58 | 2017-03-28 17:59:04 +0300 | [diff] [blame] | 1544 | snprintf_int_array(str, sizeof(str), |
| 1545 | intel_dp->source_rates, intel_dp->num_source_rates); |
Ville Syrjälä | 0336400e | 2015-03-12 17:10:39 +0200 | [diff] [blame] | 1546 | DRM_DEBUG_KMS("source rates: %s\n", str); |
| 1547 | |
Jani Nikula | 68f357c | 2017-03-28 17:59:05 +0300 | [diff] [blame] | 1548 | snprintf_int_array(str, sizeof(str), |
| 1549 | intel_dp->sink_rates, intel_dp->num_sink_rates); |
Ville Syrjälä | 0336400e | 2015-03-12 17:10:39 +0200 | [diff] [blame] | 1550 | DRM_DEBUG_KMS("sink rates: %s\n", str); |
| 1551 | |
Jani Nikula | 975ee5fca | 2017-04-06 16:44:10 +0300 | [diff] [blame] | 1552 | snprintf_int_array(str, sizeof(str), |
| 1553 | intel_dp->common_rates, intel_dp->num_common_rates); |
Ville Syrjälä | 94ca719 | 2015-03-13 19:40:31 +0200 | [diff] [blame] | 1554 | DRM_DEBUG_KMS("common rates: %s\n", str); |
Ville Syrjälä | 0336400e | 2015-03-12 17:10:39 +0200 | [diff] [blame] | 1555 | } |
| 1556 | |
Ville Syrjälä | 50fec21 | 2015-03-12 17:10:34 +0200 | [diff] [blame] | 1557 | int |
| 1558 | intel_dp_max_link_rate(struct intel_dp *intel_dp) |
| 1559 | { |
Ville Syrjälä | 50fec21 | 2015-03-12 17:10:34 +0200 | [diff] [blame] | 1560 | int len; |
| 1561 | |
Jani Nikula | e6c0c64 | 2017-04-06 16:44:12 +0300 | [diff] [blame] | 1562 | len = intel_dp_common_len_rate_limit(intel_dp, intel_dp->max_link_rate); |
Ville Syrjälä | 50fec21 | 2015-03-12 17:10:34 +0200 | [diff] [blame] | 1563 | if (WARN_ON(len <= 0)) |
| 1564 | return 162000; |
| 1565 | |
Jani Nikula | 975ee5fca | 2017-04-06 16:44:10 +0300 | [diff] [blame] | 1566 | return intel_dp->common_rates[len - 1]; |
Ville Syrjälä | 50fec21 | 2015-03-12 17:10:34 +0200 | [diff] [blame] | 1567 | } |
| 1568 | |
Ville Syrjälä | ed4e9c1 | 2015-03-12 17:10:36 +0200 | [diff] [blame] | 1569 | int intel_dp_rate_select(struct intel_dp *intel_dp, int rate) |
| 1570 | { |
Jani Nikula | 8001b75 | 2017-03-28 17:59:03 +0300 | [diff] [blame] | 1571 | int i = intel_dp_rate_index(intel_dp->sink_rates, |
| 1572 | intel_dp->num_sink_rates, rate); |
Jani Nikula | b5c72b2 | 2017-03-28 17:59:02 +0300 | [diff] [blame] | 1573 | |
| 1574 | if (WARN_ON(i < 0)) |
| 1575 | i = 0; |
| 1576 | |
| 1577 | return i; |
Ville Syrjälä | ed4e9c1 | 2015-03-12 17:10:36 +0200 | [diff] [blame] | 1578 | } |
| 1579 | |
Ander Conselvan de Oliveira | 94223d0 | 2015-10-23 13:01:48 +0300 | [diff] [blame] | 1580 | void intel_dp_compute_rate(struct intel_dp *intel_dp, int port_clock, |
| 1581 | uint8_t *link_bw, uint8_t *rate_select) |
Ville Syrjälä | 04a60f9 | 2015-07-06 15:10:06 +0300 | [diff] [blame] | 1582 | { |
Jani Nikula | 68f357c | 2017-03-28 17:59:05 +0300 | [diff] [blame] | 1583 | /* eDP 1.4 rate select method. */ |
| 1584 | if (intel_dp->use_rate_select) { |
Ville Syrjälä | 04a60f9 | 2015-07-06 15:10:06 +0300 | [diff] [blame] | 1585 | *link_bw = 0; |
| 1586 | *rate_select = |
| 1587 | intel_dp_rate_select(intel_dp, port_clock); |
| 1588 | } else { |
| 1589 | *link_bw = drm_dp_link_rate_to_bw_code(port_clock); |
| 1590 | *rate_select = 0; |
| 1591 | } |
| 1592 | } |
| 1593 | |
Jani Nikula | f580bea | 2016-09-15 16:28:52 +0300 | [diff] [blame] | 1594 | static int intel_dp_compute_bpp(struct intel_dp *intel_dp, |
| 1595 | struct intel_crtc_state *pipe_config) |
Mika Kahola | f9bb705 | 2016-09-09 14:10:56 +0300 | [diff] [blame] | 1596 | { |
| 1597 | int bpp, bpc; |
| 1598 | |
| 1599 | bpp = pipe_config->pipe_bpp; |
| 1600 | bpc = drm_dp_downstream_max_bpc(intel_dp->dpcd, intel_dp->downstream_ports); |
| 1601 | |
| 1602 | if (bpc > 0) |
| 1603 | bpp = min(bpp, 3*bpc); |
| 1604 | |
Manasi Navare | 611032b | 2017-01-24 08:21:49 -0800 | [diff] [blame] | 1605 | /* For DP Compliance we override the computed bpp for the pipe */ |
| 1606 | if (intel_dp->compliance.test_data.bpc != 0) { |
| 1607 | pipe_config->pipe_bpp = 3*intel_dp->compliance.test_data.bpc; |
| 1608 | pipe_config->dither_force_disable = pipe_config->pipe_bpp == 6*3; |
| 1609 | DRM_DEBUG_KMS("Setting pipe_bpp to %d\n", |
| 1610 | pipe_config->pipe_bpp); |
| 1611 | } |
Mika Kahola | f9bb705 | 2016-09-09 14:10:56 +0300 | [diff] [blame] | 1612 | return bpp; |
| 1613 | } |
| 1614 | |
Jim Bride | dc911f5 | 2017-08-09 12:48:53 -0700 | [diff] [blame] | 1615 | static bool intel_edp_compare_alt_mode(struct drm_display_mode *m1, |
| 1616 | struct drm_display_mode *m2) |
| 1617 | { |
| 1618 | bool bres = false; |
| 1619 | |
| 1620 | if (m1 && m2) |
| 1621 | bres = (m1->hdisplay == m2->hdisplay && |
| 1622 | m1->hsync_start == m2->hsync_start && |
| 1623 | m1->hsync_end == m2->hsync_end && |
| 1624 | m1->htotal == m2->htotal && |
| 1625 | m1->vdisplay == m2->vdisplay && |
| 1626 | m1->vsync_start == m2->vsync_start && |
| 1627 | m1->vsync_end == m2->vsync_end && |
| 1628 | m1->vtotal == m2->vtotal); |
| 1629 | return bres; |
| 1630 | } |
| 1631 | |
Paulo Zanoni | 00c09d7 | 2012-10-26 19:05:52 -0200 | [diff] [blame] | 1632 | bool |
Daniel Vetter | 5bfe2ac | 2013-03-27 00:44:55 +0100 | [diff] [blame] | 1633 | intel_dp_compute_config(struct intel_encoder *encoder, |
Maarten Lankhorst | 0a478c2 | 2016-08-09 17:04:05 +0200 | [diff] [blame] | 1634 | struct intel_crtc_state *pipe_config, |
| 1635 | struct drm_connector_state *conn_state) |
Keith Packard | a4fc5ed | 2009-04-07 16:16:42 -0700 | [diff] [blame] | 1636 | { |
Tvrtko Ursulin | dd11bc1 | 2016-11-16 08:55:41 +0000 | [diff] [blame] | 1637 | struct drm_i915_private *dev_priv = to_i915(encoder->base.dev); |
Ander Conselvan de Oliveira | 2d112de | 2015-01-15 14:55:22 +0200 | [diff] [blame] | 1638 | struct drm_display_mode *adjusted_mode = &pipe_config->base.adjusted_mode; |
Daniel Vetter | 5bfe2ac | 2013-03-27 00:44:55 +0100 | [diff] [blame] | 1639 | struct intel_dp *intel_dp = enc_to_intel_dp(&encoder->base); |
Ville Syrjälä | 8f4f279 | 2017-11-09 17:24:34 +0200 | [diff] [blame] | 1640 | enum port port = encoder->port; |
Ander Conselvan de Oliveira | 84556d5 | 2015-03-20 16:18:10 +0200 | [diff] [blame] | 1641 | struct intel_crtc *intel_crtc = to_intel_crtc(pipe_config->base.crtc); |
Jani Nikula | dd06f90 | 2012-10-19 14:51:50 +0300 | [diff] [blame] | 1642 | struct intel_connector *intel_connector = intel_dp->attached_connector; |
Maarten Lankhorst | 8f647a0 | 2017-05-01 15:38:01 +0200 | [diff] [blame] | 1643 | struct intel_digital_connector_state *intel_conn_state = |
| 1644 | to_intel_digital_connector_state(conn_state); |
Keith Packard | a4fc5ed | 2009-04-07 16:16:42 -0700 | [diff] [blame] | 1645 | int lane_count, clock; |
Jani Nikula | 56071a2 | 2014-05-06 14:56:52 +0300 | [diff] [blame] | 1646 | int min_lane_count = 1; |
Paulo Zanoni | eeb6324 | 2014-05-06 14:56:50 +0300 | [diff] [blame] | 1647 | int max_lane_count = intel_dp_max_lane_count(intel_dp); |
Todd Previte | 06ea66b | 2014-01-20 10:19:39 -0700 | [diff] [blame] | 1648 | /* Conveniently, the link BW constants become indices with a shift...*/ |
Jani Nikula | 56071a2 | 2014-05-06 14:56:52 +0300 | [diff] [blame] | 1649 | int min_clock = 0; |
Sonika Jindal | a8f3ef6 | 2015-03-05 10:02:30 +0530 | [diff] [blame] | 1650 | int max_clock; |
Daniel Vetter | 083f956 | 2012-04-20 20:23:49 +0200 | [diff] [blame] | 1651 | int bpp, mode_rate; |
Daniel Vetter | ff9a675 | 2013-06-01 17:16:21 +0200 | [diff] [blame] | 1652 | int link_avail, link_clock; |
Ville Syrjälä | 94ca719 | 2015-03-13 19:40:31 +0200 | [diff] [blame] | 1653 | int common_len; |
Ville Syrjälä | 04a60f9 | 2015-07-06 15:10:06 +0300 | [diff] [blame] | 1654 | uint8_t link_bw, rate_select; |
Jani Nikula | b31e85e | 2017-05-18 14:10:25 +0300 | [diff] [blame] | 1655 | bool reduce_m_n = drm_dp_has_quirk(&intel_dp->desc, |
| 1656 | DP_DPCD_QUIRK_LIMITED_M_N); |
Sonika Jindal | a8f3ef6 | 2015-03-05 10:02:30 +0530 | [diff] [blame] | 1657 | |
Jani Nikula | 975ee5fca | 2017-04-06 16:44:10 +0300 | [diff] [blame] | 1658 | common_len = intel_dp_common_len_rate_limit(intel_dp, |
Jani Nikula | e6c0c64 | 2017-04-06 16:44:12 +0300 | [diff] [blame] | 1659 | intel_dp->max_link_rate); |
Sonika Jindal | a8f3ef6 | 2015-03-05 10:02:30 +0530 | [diff] [blame] | 1660 | |
| 1661 | /* No common link rates between source and sink */ |
Ville Syrjälä | 94ca719 | 2015-03-13 19:40:31 +0200 | [diff] [blame] | 1662 | WARN_ON(common_len <= 0); |
Sonika Jindal | a8f3ef6 | 2015-03-05 10:02:30 +0530 | [diff] [blame] | 1663 | |
Ville Syrjälä | 94ca719 | 2015-03-13 19:40:31 +0200 | [diff] [blame] | 1664 | max_clock = common_len - 1; |
Keith Packard | a4fc5ed | 2009-04-07 16:16:42 -0700 | [diff] [blame] | 1665 | |
Tvrtko Ursulin | 4f8036a | 2016-10-13 11:02:52 +0100 | [diff] [blame] | 1666 | if (HAS_PCH_SPLIT(dev_priv) && !HAS_DDI(dev_priv) && port != PORT_A) |
Daniel Vetter | 5bfe2ac | 2013-03-27 00:44:55 +0100 | [diff] [blame] | 1667 | pipe_config->has_pch_encoder = true; |
| 1668 | |
Vandana Kannan | f769cd2 | 2014-08-05 07:51:22 -0700 | [diff] [blame] | 1669 | pipe_config->has_drrs = false; |
Ville Syrjälä | 20ff39f | 2017-11-29 18:43:01 +0200 | [diff] [blame] | 1670 | if (IS_G4X(dev_priv) || port == PORT_A) |
Maarten Lankhorst | e6b72c9 | 2017-05-01 15:38:00 +0200 | [diff] [blame] | 1671 | pipe_config->has_audio = false; |
Maarten Lankhorst | 8f647a0 | 2017-05-01 15:38:01 +0200 | [diff] [blame] | 1672 | else if (intel_conn_state->force_audio == HDMI_AUDIO_AUTO) |
Maarten Lankhorst | e6b72c9 | 2017-05-01 15:38:00 +0200 | [diff] [blame] | 1673 | pipe_config->has_audio = intel_dp->has_audio; |
| 1674 | else |
Maarten Lankhorst | 8f647a0 | 2017-05-01 15:38:01 +0200 | [diff] [blame] | 1675 | pipe_config->has_audio = intel_conn_state->force_audio == HDMI_AUDIO_ON; |
Keith Packard | a4fc5ed | 2009-04-07 16:16:42 -0700 | [diff] [blame] | 1676 | |
Jani Nikula | 1853a9d | 2017-08-18 12:30:20 +0300 | [diff] [blame] | 1677 | if (intel_dp_is_edp(intel_dp) && intel_connector->panel.fixed_mode) { |
Jim Bride | dc911f5 | 2017-08-09 12:48:53 -0700 | [diff] [blame] | 1678 | struct drm_display_mode *panel_mode = |
| 1679 | intel_connector->panel.alt_fixed_mode; |
| 1680 | struct drm_display_mode *req_mode = &pipe_config->base.mode; |
| 1681 | |
| 1682 | if (!intel_edp_compare_alt_mode(req_mode, panel_mode)) |
| 1683 | panel_mode = intel_connector->panel.fixed_mode; |
| 1684 | |
| 1685 | drm_mode_debug_printmodeline(panel_mode); |
| 1686 | |
| 1687 | intel_fixed_panel_mode(panel_mode, adjusted_mode); |
Chandra Konduru | a1b2278 | 2015-04-07 15:28:45 -0700 | [diff] [blame] | 1688 | |
Tvrtko Ursulin | dd11bc1 | 2016-11-16 08:55:41 +0000 | [diff] [blame] | 1689 | if (INTEL_GEN(dev_priv) >= 9) { |
Chandra Konduru | a1b2278 | 2015-04-07 15:28:45 -0700 | [diff] [blame] | 1690 | int ret; |
Maarten Lankhorst | e435d6e | 2015-07-13 16:30:15 +0200 | [diff] [blame] | 1691 | ret = skl_update_scaler_crtc(pipe_config); |
Chandra Konduru | a1b2278 | 2015-04-07 15:28:45 -0700 | [diff] [blame] | 1692 | if (ret) |
| 1693 | return ret; |
| 1694 | } |
| 1695 | |
Tvrtko Ursulin | 49cff96 | 2016-10-13 11:02:54 +0100 | [diff] [blame] | 1696 | if (HAS_GMCH_DISPLAY(dev_priv)) |
Jesse Barnes | 2dd2455 | 2013-04-25 12:55:01 -0700 | [diff] [blame] | 1697 | intel_gmch_panel_fitting(intel_crtc, pipe_config, |
Maarten Lankhorst | eead06d | 2017-05-01 15:37:55 +0200 | [diff] [blame] | 1698 | conn_state->scaling_mode); |
Jesse Barnes | 2dd2455 | 2013-04-25 12:55:01 -0700 | [diff] [blame] | 1699 | else |
Jesse Barnes | b074cec | 2013-04-25 12:55:02 -0700 | [diff] [blame] | 1700 | intel_pch_panel_fitting(intel_crtc, pipe_config, |
Maarten Lankhorst | eead06d | 2017-05-01 15:37:55 +0200 | [diff] [blame] | 1701 | conn_state->scaling_mode); |
Zhao Yakui | 0d3a1be | 2010-07-19 09:43:13 +0100 | [diff] [blame] | 1702 | } |
| 1703 | |
Ville Syrjälä | 05021389 | 2017-11-29 20:08:47 +0200 | [diff] [blame] | 1704 | if ((IS_VALLEYVIEW(dev_priv) || IS_CHERRYVIEW(dev_priv)) && |
| 1705 | adjusted_mode->flags & DRM_MODE_FLAG_INTERLACE) |
| 1706 | return false; |
| 1707 | |
Daniel Vetter | cb1793c | 2012-06-04 18:39:21 +0200 | [diff] [blame] | 1708 | if (adjusted_mode->flags & DRM_MODE_FLAG_DBLCLK) |
Daniel Vetter | 0af78a2 | 2012-05-23 11:30:55 +0200 | [diff] [blame] | 1709 | return false; |
| 1710 | |
Manasi Navare | da15f7c | 2017-01-24 08:16:34 -0800 | [diff] [blame] | 1711 | /* Use values requested by Compliance Test Request */ |
| 1712 | if (intel_dp->compliance.test_type == DP_TEST_LINK_TRAINING) { |
Jani Nikula | ec990e2 | 2017-04-06 16:44:15 +0300 | [diff] [blame] | 1713 | int index; |
| 1714 | |
Manasi Navare | 140ef13 | 2017-06-08 13:41:03 -0700 | [diff] [blame] | 1715 | /* Validate the compliance test data since max values |
| 1716 | * might have changed due to link train fallback. |
| 1717 | */ |
| 1718 | if (intel_dp_link_params_valid(intel_dp, intel_dp->compliance.test_link_rate, |
| 1719 | intel_dp->compliance.test_lane_count)) { |
| 1720 | index = intel_dp_rate_index(intel_dp->common_rates, |
| 1721 | intel_dp->num_common_rates, |
| 1722 | intel_dp->compliance.test_link_rate); |
| 1723 | if (index >= 0) |
| 1724 | min_clock = max_clock = index; |
| 1725 | min_lane_count = max_lane_count = intel_dp->compliance.test_lane_count; |
| 1726 | } |
Manasi Navare | da15f7c | 2017-01-24 08:16:34 -0800 | [diff] [blame] | 1727 | } |
Daniel Vetter | 083f956 | 2012-04-20 20:23:49 +0200 | [diff] [blame] | 1728 | DRM_DEBUG_KMS("DP link computation with max lane count %i " |
Sonika Jindal | a8f3ef6 | 2015-03-05 10:02:30 +0530 | [diff] [blame] | 1729 | "max bw %d pixel clock %iKHz\n", |
Jani Nikula | 975ee5fca | 2017-04-06 16:44:10 +0300 | [diff] [blame] | 1730 | max_lane_count, intel_dp->common_rates[max_clock], |
Damien Lespiau | 241bfc3 | 2013-09-25 16:45:37 +0100 | [diff] [blame] | 1731 | adjusted_mode->crtc_clock); |
Daniel Vetter | 083f956 | 2012-04-20 20:23:49 +0200 | [diff] [blame] | 1732 | |
Daniel Vetter | 3600836 | 2013-03-27 00:44:59 +0100 | [diff] [blame] | 1733 | /* Walk through all bpp values. Luckily they're all nicely spaced with 2 |
| 1734 | * bpc in between. */ |
Mika Kahola | f9bb705 | 2016-09-09 14:10:56 +0300 | [diff] [blame] | 1735 | bpp = intel_dp_compute_bpp(intel_dp, pipe_config); |
Jani Nikula | 1853a9d | 2017-08-18 12:30:20 +0300 | [diff] [blame] | 1736 | if (intel_dp_is_edp(intel_dp)) { |
Thulasimani,Sivakumar | 22ce562 | 2015-07-31 11:05:27 +0530 | [diff] [blame] | 1737 | |
| 1738 | /* Get bpp from vbt only for panels that dont have bpp in edid */ |
| 1739 | if (intel_connector->base.display_info.bpc == 0 && |
Jani Nikula | 6aa23e6 | 2016-03-24 17:50:20 +0200 | [diff] [blame] | 1740 | (dev_priv->vbt.edp.bpp && dev_priv->vbt.edp.bpp < bpp)) { |
Jani Nikula | 56071a2 | 2014-05-06 14:56:52 +0300 | [diff] [blame] | 1741 | DRM_DEBUG_KMS("clamping bpp for eDP panel to BIOS-provided %i\n", |
Jani Nikula | 6aa23e6 | 2016-03-24 17:50:20 +0200 | [diff] [blame] | 1742 | dev_priv->vbt.edp.bpp); |
| 1743 | bpp = dev_priv->vbt.edp.bpp; |
Jani Nikula | 56071a2 | 2014-05-06 14:56:52 +0300 | [diff] [blame] | 1744 | } |
| 1745 | |
Jani Nikula | 344c5bb | 2014-09-09 11:25:13 +0300 | [diff] [blame] | 1746 | /* |
| 1747 | * Use the maximum clock and number of lanes the eDP panel |
| 1748 | * advertizes being capable of. The panels are generally |
| 1749 | * designed to support only a single clock and lane |
| 1750 | * configuration, and typically these values correspond to the |
| 1751 | * native resolution of the panel. |
| 1752 | */ |
| 1753 | min_lane_count = max_lane_count; |
| 1754 | min_clock = max_clock; |
Imre Deak | 7984211 | 2013-07-18 17:44:13 +0300 | [diff] [blame] | 1755 | } |
Daniel Vetter | 657445f | 2013-05-04 10:09:18 +0200 | [diff] [blame] | 1756 | |
Daniel Vetter | 3600836 | 2013-03-27 00:44:59 +0100 | [diff] [blame] | 1757 | for (; bpp >= 6*3; bpp -= 2*3) { |
Damien Lespiau | 241bfc3 | 2013-09-25 16:45:37 +0100 | [diff] [blame] | 1758 | mode_rate = intel_dp_link_required(adjusted_mode->crtc_clock, |
| 1759 | bpp); |
Daniel Vetter | c486793 | 2012-04-10 10:42:36 +0200 | [diff] [blame] | 1760 | |
Dave Airlie | c693099 | 2014-07-14 11:04:39 +1000 | [diff] [blame] | 1761 | for (clock = min_clock; clock <= max_clock; clock++) { |
Sonika Jindal | a8f3ef6 | 2015-03-05 10:02:30 +0530 | [diff] [blame] | 1762 | for (lane_count = min_lane_count; |
| 1763 | lane_count <= max_lane_count; |
| 1764 | lane_count <<= 1) { |
| 1765 | |
Jani Nikula | 975ee5fca | 2017-04-06 16:44:10 +0300 | [diff] [blame] | 1766 | link_clock = intel_dp->common_rates[clock]; |
Daniel Vetter | 3600836 | 2013-03-27 00:44:59 +0100 | [diff] [blame] | 1767 | link_avail = intel_dp_max_data_rate(link_clock, |
| 1768 | lane_count); |
Ville Syrjälä | 3685a8f | 2013-01-17 16:31:28 +0200 | [diff] [blame] | 1769 | |
Daniel Vetter | 3600836 | 2013-03-27 00:44:59 +0100 | [diff] [blame] | 1770 | if (mode_rate <= link_avail) { |
| 1771 | goto found; |
| 1772 | } |
| 1773 | } |
| 1774 | } |
| 1775 | } |
| 1776 | |
| 1777 | return false; |
| 1778 | |
| 1779 | found: |
Maarten Lankhorst | 8f647a0 | 2017-05-01 15:38:01 +0200 | [diff] [blame] | 1780 | if (intel_conn_state->broadcast_rgb == INTEL_BROADCAST_RGB_AUTO) { |
Ville Syrjälä | 55bc60d | 2013-01-17 16:31:29 +0200 | [diff] [blame] | 1781 | /* |
| 1782 | * See: |
| 1783 | * CEA-861-E - 5.1 Default Encoding Parameters |
| 1784 | * VESA DisplayPort Ver.1.2a - 5.1.1.1 Video Colorimetry |
| 1785 | */ |
Ville Syrjälä | 0f2a2a7 | 2015-07-06 15:10:00 +0300 | [diff] [blame] | 1786 | pipe_config->limited_color_range = |
Ville Syrjälä | c8127cf0 | 2017-01-11 16:18:35 +0200 | [diff] [blame] | 1787 | bpp != 18 && |
| 1788 | drm_default_rgb_quant_range(adjusted_mode) == |
| 1789 | HDMI_QUANTIZATION_RANGE_LIMITED; |
Ville Syrjälä | 0f2a2a7 | 2015-07-06 15:10:00 +0300 | [diff] [blame] | 1790 | } else { |
| 1791 | pipe_config->limited_color_range = |
Maarten Lankhorst | 8f647a0 | 2017-05-01 15:38:01 +0200 | [diff] [blame] | 1792 | intel_conn_state->broadcast_rgb == INTEL_BROADCAST_RGB_LIMITED; |
Ville Syrjälä | 55bc60d | 2013-01-17 16:31:29 +0200 | [diff] [blame] | 1793 | } |
| 1794 | |
Ville Syrjälä | 90a6b7b | 2015-07-06 16:39:15 +0300 | [diff] [blame] | 1795 | pipe_config->lane_count = lane_count; |
Sonika Jindal | a8f3ef6 | 2015-03-05 10:02:30 +0530 | [diff] [blame] | 1796 | |
Daniel Vetter | 657445f | 2013-05-04 10:09:18 +0200 | [diff] [blame] | 1797 | pipe_config->pipe_bpp = bpp; |
Jani Nikula | 975ee5fca | 2017-04-06 16:44:10 +0300 | [diff] [blame] | 1798 | pipe_config->port_clock = intel_dp->common_rates[clock]; |
Daniel Vetter | c486793 | 2012-04-10 10:42:36 +0200 | [diff] [blame] | 1799 | |
Ville Syrjälä | 04a60f9 | 2015-07-06 15:10:06 +0300 | [diff] [blame] | 1800 | intel_dp_compute_rate(intel_dp, pipe_config->port_clock, |
| 1801 | &link_bw, &rate_select); |
| 1802 | |
| 1803 | DRM_DEBUG_KMS("DP link bw %02x rate select %02x lane count %d clock %d bpp %d\n", |
| 1804 | link_bw, rate_select, pipe_config->lane_count, |
Daniel Vetter | ff9a675 | 2013-06-01 17:16:21 +0200 | [diff] [blame] | 1805 | pipe_config->port_clock, bpp); |
Daniel Vetter | 3600836 | 2013-03-27 00:44:59 +0100 | [diff] [blame] | 1806 | DRM_DEBUG_KMS("DP link bw required %i available %i\n", |
| 1807 | mode_rate, link_avail); |
Keith Packard | a4fc5ed | 2009-04-07 16:16:42 -0700 | [diff] [blame] | 1808 | |
Daniel Vetter | 03afc4a | 2013-04-02 23:42:31 +0200 | [diff] [blame] | 1809 | intel_link_compute_m_n(bpp, lane_count, |
Damien Lespiau | 241bfc3 | 2013-09-25 16:45:37 +0100 | [diff] [blame] | 1810 | adjusted_mode->crtc_clock, |
| 1811 | pipe_config->port_clock, |
Jani Nikula | b31e85e | 2017-05-18 14:10:25 +0300 | [diff] [blame] | 1812 | &pipe_config->dp_m_n, |
| 1813 | reduce_m_n); |
Keith Packard | a4fc5ed | 2009-04-07 16:16:42 -0700 | [diff] [blame] | 1814 | |
Pradeep Bhat | 439d7ac | 2014-04-05 12:13:28 +0530 | [diff] [blame] | 1815 | if (intel_connector->panel.downclock_mode != NULL && |
Vandana Kannan | 96178ee | 2015-01-10 02:25:56 +0530 | [diff] [blame] | 1816 | dev_priv->drrs.type == SEAMLESS_DRRS_SUPPORT) { |
Vandana Kannan | f769cd2 | 2014-08-05 07:51:22 -0700 | [diff] [blame] | 1817 | pipe_config->has_drrs = true; |
Pradeep Bhat | 439d7ac | 2014-04-05 12:13:28 +0530 | [diff] [blame] | 1818 | intel_link_compute_m_n(bpp, lane_count, |
| 1819 | intel_connector->panel.downclock_mode->clock, |
| 1820 | pipe_config->port_clock, |
Jani Nikula | b31e85e | 2017-05-18 14:10:25 +0300 | [diff] [blame] | 1821 | &pipe_config->dp_m2_n2, |
| 1822 | reduce_m_n); |
Pradeep Bhat | 439d7ac | 2014-04-05 12:13:28 +0530 | [diff] [blame] | 1823 | } |
| 1824 | |
Ville Syrjälä | 14d41b3 | 2016-05-13 23:41:22 +0300 | [diff] [blame] | 1825 | /* |
| 1826 | * DPLL0 VCO may need to be adjusted to get the correct |
| 1827 | * clock for eDP. This will affect cdclk as well. |
| 1828 | */ |
Jani Nikula | 1853a9d | 2017-08-18 12:30:20 +0300 | [diff] [blame] | 1829 | if (intel_dp_is_edp(intel_dp) && IS_GEN9_BC(dev_priv)) { |
Ville Syrjälä | 14d41b3 | 2016-05-13 23:41:22 +0300 | [diff] [blame] | 1830 | int vco; |
| 1831 | |
| 1832 | switch (pipe_config->port_clock / 2) { |
| 1833 | case 108000: |
| 1834 | case 216000: |
Ville Syrjälä | 63911d7 | 2016-05-13 23:41:32 +0300 | [diff] [blame] | 1835 | vco = 8640000; |
Ville Syrjälä | 14d41b3 | 2016-05-13 23:41:22 +0300 | [diff] [blame] | 1836 | break; |
| 1837 | default: |
Ville Syrjälä | 63911d7 | 2016-05-13 23:41:32 +0300 | [diff] [blame] | 1838 | vco = 8100000; |
Ville Syrjälä | 14d41b3 | 2016-05-13 23:41:22 +0300 | [diff] [blame] | 1839 | break; |
| 1840 | } |
| 1841 | |
Ville Syrjälä | bb0f4aa | 2017-01-20 20:21:59 +0200 | [diff] [blame] | 1842 | to_intel_atomic_state(pipe_config->base.state)->cdclk.logical.vco = vco; |
Ville Syrjälä | 14d41b3 | 2016-05-13 23:41:22 +0300 | [diff] [blame] | 1843 | } |
| 1844 | |
Tvrtko Ursulin | 4f8036a | 2016-10-13 11:02:52 +0100 | [diff] [blame] | 1845 | if (!HAS_DDI(dev_priv)) |
Ville Syrjälä | 840b32b | 2015-08-11 20:21:46 +0300 | [diff] [blame] | 1846 | intel_dp_set_clock(encoder, pipe_config); |
Daniel Vetter | c6bb353 | 2013-04-19 11:14:33 +0200 | [diff] [blame] | 1847 | |
Ville Syrjälä | 4d90f2d | 2017-10-12 16:02:01 +0300 | [diff] [blame] | 1848 | intel_psr_compute_config(intel_dp, pipe_config); |
| 1849 | |
Daniel Vetter | 3600836 | 2013-03-27 00:44:59 +0100 | [diff] [blame] | 1850 | return true; |
Keith Packard | a4fc5ed | 2009-04-07 16:16:42 -0700 | [diff] [blame] | 1851 | } |
| 1852 | |
Ville Syrjälä | 901c2da | 2015-08-17 18:05:12 +0300 | [diff] [blame] | 1853 | void intel_dp_set_link_params(struct intel_dp *intel_dp, |
Ander Conselvan de Oliveira | dfa1048 | 2016-09-01 15:08:06 -0700 | [diff] [blame] | 1854 | int link_rate, uint8_t lane_count, |
| 1855 | bool link_mst) |
Ville Syrjälä | 901c2da | 2015-08-17 18:05:12 +0300 | [diff] [blame] | 1856 | { |
Ander Conselvan de Oliveira | dfa1048 | 2016-09-01 15:08:06 -0700 | [diff] [blame] | 1857 | intel_dp->link_rate = link_rate; |
| 1858 | intel_dp->lane_count = lane_count; |
| 1859 | intel_dp->link_mst = link_mst; |
Ville Syrjälä | 901c2da | 2015-08-17 18:05:12 +0300 | [diff] [blame] | 1860 | } |
| 1861 | |
Maarten Lankhorst | 85cb48a | 2016-08-09 17:04:13 +0200 | [diff] [blame] | 1862 | static void intel_dp_prepare(struct intel_encoder *encoder, |
Ville Syrjälä | 5f88a9c | 2017-08-18 16:49:58 +0300 | [diff] [blame] | 1863 | const struct intel_crtc_state *pipe_config) |
Keith Packard | a4fc5ed | 2009-04-07 16:16:42 -0700 | [diff] [blame] | 1864 | { |
Ville Syrjälä | 2f77347 | 2017-11-09 17:27:58 +0200 | [diff] [blame] | 1865 | struct drm_i915_private *dev_priv = to_i915(encoder->base.dev); |
Daniel Vetter | b934223d | 2013-07-21 21:37:05 +0200 | [diff] [blame] | 1866 | struct intel_dp *intel_dp = enc_to_intel_dp(&encoder->base); |
Ville Syrjälä | 8f4f279 | 2017-11-09 17:24:34 +0200 | [diff] [blame] | 1867 | enum port port = encoder->port; |
Ville Syrjälä | adc1030 | 2017-10-31 22:51:14 +0200 | [diff] [blame] | 1868 | struct intel_crtc *crtc = to_intel_crtc(pipe_config->base.crtc); |
Maarten Lankhorst | 85cb48a | 2016-08-09 17:04:13 +0200 | [diff] [blame] | 1869 | const struct drm_display_mode *adjusted_mode = &pipe_config->base.adjusted_mode; |
Keith Packard | a4fc5ed | 2009-04-07 16:16:42 -0700 | [diff] [blame] | 1870 | |
Ander Conselvan de Oliveira | dfa1048 | 2016-09-01 15:08:06 -0700 | [diff] [blame] | 1871 | intel_dp_set_link_params(intel_dp, pipe_config->port_clock, |
| 1872 | pipe_config->lane_count, |
| 1873 | intel_crtc_has_type(pipe_config, |
| 1874 | INTEL_OUTPUT_DP_MST)); |
Ville Syrjälä | 901c2da | 2015-08-17 18:05:12 +0300 | [diff] [blame] | 1875 | |
Keith Packard | 417e822 | 2011-11-01 19:54:11 -0700 | [diff] [blame] | 1876 | /* |
Keith Packard | 1a2eb46 | 2011-11-16 16:26:07 -0800 | [diff] [blame] | 1877 | * There are four kinds of DP registers: |
Keith Packard | 417e822 | 2011-11-01 19:54:11 -0700 | [diff] [blame] | 1878 | * |
| 1879 | * IBX PCH |
Keith Packard | 1a2eb46 | 2011-11-16 16:26:07 -0800 | [diff] [blame] | 1880 | * SNB CPU |
| 1881 | * IVB CPU |
Keith Packard | 417e822 | 2011-11-01 19:54:11 -0700 | [diff] [blame] | 1882 | * CPT PCH |
| 1883 | * |
| 1884 | * IBX PCH and CPU are the same for almost everything, |
| 1885 | * except that the CPU DP PLL is configured in this |
| 1886 | * register |
| 1887 | * |
| 1888 | * CPT PCH is quite different, having many bits moved |
| 1889 | * to the TRANS_DP_CTL register instead. That |
| 1890 | * configuration happens (oddly) in ironlake_pch_enable |
| 1891 | */ |
Adam Jackson | 9c9e792 | 2010-04-05 17:57:59 -0400 | [diff] [blame] | 1892 | |
Keith Packard | 417e822 | 2011-11-01 19:54:11 -0700 | [diff] [blame] | 1893 | /* Preserve the BIOS-computed detected bit. This is |
| 1894 | * supposed to be read-only. |
| 1895 | */ |
| 1896 | intel_dp->DP = I915_READ(intel_dp->output_reg) & DP_DETECTED; |
Keith Packard | a4fc5ed | 2009-04-07 16:16:42 -0700 | [diff] [blame] | 1897 | |
Keith Packard | 417e822 | 2011-11-01 19:54:11 -0700 | [diff] [blame] | 1898 | /* Handle DP bits in common between all three register formats */ |
Keith Packard | 417e822 | 2011-11-01 19:54:11 -0700 | [diff] [blame] | 1899 | intel_dp->DP |= DP_VOLTAGE_0_4 | DP_PRE_EMPHASIS_0; |
Maarten Lankhorst | 85cb48a | 2016-08-09 17:04:13 +0200 | [diff] [blame] | 1900 | intel_dp->DP |= DP_PORT_WIDTH(pipe_config->lane_count); |
Keith Packard | a4fc5ed | 2009-04-07 16:16:42 -0700 | [diff] [blame] | 1901 | |
Keith Packard | 417e822 | 2011-11-01 19:54:11 -0700 | [diff] [blame] | 1902 | /* Split out the IBX/CPU vs CPT settings */ |
Zhenyu Wang | 32f9d65 | 2009-07-24 01:00:32 +0800 | [diff] [blame] | 1903 | |
Tvrtko Ursulin | 5db9401 | 2016-10-13 11:03:10 +0100 | [diff] [blame] | 1904 | if (IS_GEN7(dev_priv) && port == PORT_A) { |
Keith Packard | 1a2eb46 | 2011-11-16 16:26:07 -0800 | [diff] [blame] | 1905 | if (adjusted_mode->flags & DRM_MODE_FLAG_PHSYNC) |
| 1906 | intel_dp->DP |= DP_SYNC_HS_HIGH; |
| 1907 | if (adjusted_mode->flags & DRM_MODE_FLAG_PVSYNC) |
| 1908 | intel_dp->DP |= DP_SYNC_VS_HIGH; |
| 1909 | intel_dp->DP |= DP_LINK_TRAIN_OFF_CPT; |
| 1910 | |
Jani Nikula | 6aba5b6 | 2013-10-04 15:08:10 +0300 | [diff] [blame] | 1911 | if (drm_dp_enhanced_frame_cap(intel_dp->dpcd)) |
Keith Packard | 1a2eb46 | 2011-11-16 16:26:07 -0800 | [diff] [blame] | 1912 | intel_dp->DP |= DP_ENHANCED_FRAMING; |
| 1913 | |
Daniel Vetter | 7c62a16 | 2013-06-01 17:16:20 +0200 | [diff] [blame] | 1914 | intel_dp->DP |= crtc->pipe << 29; |
Tvrtko Ursulin | 6e26695 | 2016-10-13 11:02:53 +0100 | [diff] [blame] | 1915 | } else if (HAS_PCH_CPT(dev_priv) && port != PORT_A) { |
Ville Syrjälä | e3ef447 | 2015-05-05 17:17:31 +0300 | [diff] [blame] | 1916 | u32 trans_dp; |
| 1917 | |
Ville Syrjälä | 39e5fa8 | 2015-05-05 17:17:29 +0300 | [diff] [blame] | 1918 | intel_dp->DP |= DP_LINK_TRAIN_OFF_CPT; |
Ville Syrjälä | e3ef447 | 2015-05-05 17:17:31 +0300 | [diff] [blame] | 1919 | |
| 1920 | trans_dp = I915_READ(TRANS_DP_CTL(crtc->pipe)); |
| 1921 | if (drm_dp_enhanced_frame_cap(intel_dp->dpcd)) |
| 1922 | trans_dp |= TRANS_DP_ENH_FRAMING; |
| 1923 | else |
| 1924 | trans_dp &= ~TRANS_DP_ENH_FRAMING; |
| 1925 | I915_WRITE(TRANS_DP_CTL(crtc->pipe), trans_dp); |
Ville Syrjälä | 39e5fa8 | 2015-05-05 17:17:29 +0300 | [diff] [blame] | 1926 | } else { |
Ville Syrjälä | c99f53f | 2016-11-14 19:44:07 +0200 | [diff] [blame] | 1927 | if (IS_G4X(dev_priv) && pipe_config->limited_color_range) |
Ville Syrjälä | 0f2a2a7 | 2015-07-06 15:10:00 +0300 | [diff] [blame] | 1928 | intel_dp->DP |= DP_COLOR_RANGE_16_235; |
Keith Packard | 417e822 | 2011-11-01 19:54:11 -0700 | [diff] [blame] | 1929 | |
| 1930 | if (adjusted_mode->flags & DRM_MODE_FLAG_PHSYNC) |
| 1931 | intel_dp->DP |= DP_SYNC_HS_HIGH; |
| 1932 | if (adjusted_mode->flags & DRM_MODE_FLAG_PVSYNC) |
| 1933 | intel_dp->DP |= DP_SYNC_VS_HIGH; |
| 1934 | intel_dp->DP |= DP_LINK_TRAIN_OFF; |
| 1935 | |
Jani Nikula | 6aba5b6 | 2013-10-04 15:08:10 +0300 | [diff] [blame] | 1936 | if (drm_dp_enhanced_frame_cap(intel_dp->dpcd)) |
Keith Packard | 417e822 | 2011-11-01 19:54:11 -0700 | [diff] [blame] | 1937 | intel_dp->DP |= DP_ENHANCED_FRAMING; |
| 1938 | |
Tvrtko Ursulin | 920a14b | 2016-10-14 10:13:44 +0100 | [diff] [blame] | 1939 | if (IS_CHERRYVIEW(dev_priv)) |
Chon Ming Lee | 44f37d1 | 2014-04-09 13:28:21 +0300 | [diff] [blame] | 1940 | intel_dp->DP |= DP_PIPE_SELECT_CHV(crtc->pipe); |
Ville Syrjälä | 39e5fa8 | 2015-05-05 17:17:29 +0300 | [diff] [blame] | 1941 | else if (crtc->pipe == PIPE_B) |
| 1942 | intel_dp->DP |= DP_PIPEB_SELECT; |
Zhenyu Wang | 32f9d65 | 2009-07-24 01:00:32 +0800 | [diff] [blame] | 1943 | } |
Keith Packard | a4fc5ed | 2009-04-07 16:16:42 -0700 | [diff] [blame] | 1944 | } |
| 1945 | |
Paulo Zanoni | ffd6749d | 2013-12-19 14:29:42 -0200 | [diff] [blame] | 1946 | #define IDLE_ON_MASK (PP_ON | PP_SEQUENCE_MASK | 0 | PP_SEQUENCE_STATE_MASK) |
| 1947 | #define IDLE_ON_VALUE (PP_ON | PP_SEQUENCE_NONE | 0 | PP_SEQUENCE_STATE_ON_IDLE) |
Keith Packard | 99ea712 | 2011-11-01 19:57:50 -0700 | [diff] [blame] | 1948 | |
Paulo Zanoni | 1a5ef5b | 2013-12-19 14:29:43 -0200 | [diff] [blame] | 1949 | #define IDLE_OFF_MASK (PP_ON | PP_SEQUENCE_MASK | 0 | 0) |
| 1950 | #define IDLE_OFF_VALUE (0 | PP_SEQUENCE_NONE | 0 | 0) |
Keith Packard | 99ea712 | 2011-11-01 19:57:50 -0700 | [diff] [blame] | 1951 | |
Paulo Zanoni | ffd6749d | 2013-12-19 14:29:42 -0200 | [diff] [blame] | 1952 | #define IDLE_CYCLE_MASK (PP_ON | PP_SEQUENCE_MASK | PP_CYCLE_DELAY_ACTIVE | PP_SEQUENCE_STATE_MASK) |
| 1953 | #define IDLE_CYCLE_VALUE (0 | PP_SEQUENCE_NONE | 0 | PP_SEQUENCE_STATE_OFF_IDLE) |
Keith Packard | 99ea712 | 2011-11-01 19:57:50 -0700 | [diff] [blame] | 1954 | |
Ville Syrjälä | 46bd838 | 2017-10-31 22:51:22 +0200 | [diff] [blame] | 1955 | static void intel_pps_verify_state(struct intel_dp *intel_dp); |
Imre Deak | de9c1b6 | 2016-06-16 20:01:46 +0300 | [diff] [blame] | 1956 | |
Daniel Vetter | 4be7378 | 2014-01-17 14:39:48 +0100 | [diff] [blame] | 1957 | static void wait_panel_status(struct intel_dp *intel_dp, |
Keith Packard | 99ea712 | 2011-11-01 19:57:50 -0700 | [diff] [blame] | 1958 | u32 mask, |
| 1959 | u32 value) |
| 1960 | { |
Ville Syrjälä | 2f77347 | 2017-11-09 17:27:58 +0200 | [diff] [blame] | 1961 | struct drm_i915_private *dev_priv = to_i915(intel_dp_to_dev(intel_dp)); |
Ville Syrjälä | f0f59a0 | 2015-11-18 15:33:26 +0200 | [diff] [blame] | 1962 | i915_reg_t pp_stat_reg, pp_ctrl_reg; |
Jesse Barnes | 453c542 | 2013-03-28 09:55:41 -0700 | [diff] [blame] | 1963 | |
Ville Syrjälä | e39b999 | 2014-09-04 14:53:14 +0300 | [diff] [blame] | 1964 | lockdep_assert_held(&dev_priv->pps_mutex); |
| 1965 | |
Ville Syrjälä | 46bd838 | 2017-10-31 22:51:22 +0200 | [diff] [blame] | 1966 | intel_pps_verify_state(intel_dp); |
Imre Deak | de9c1b6 | 2016-06-16 20:01:46 +0300 | [diff] [blame] | 1967 | |
Jani Nikula | bf13e81 | 2013-09-06 07:40:05 +0300 | [diff] [blame] | 1968 | pp_stat_reg = _pp_stat_reg(intel_dp); |
| 1969 | pp_ctrl_reg = _pp_ctrl_reg(intel_dp); |
Keith Packard | 99ea712 | 2011-11-01 19:57:50 -0700 | [diff] [blame] | 1970 | |
| 1971 | DRM_DEBUG_KMS("mask %08x value %08x status %08x control %08x\n", |
Jesse Barnes | 453c542 | 2013-03-28 09:55:41 -0700 | [diff] [blame] | 1972 | mask, value, |
| 1973 | I915_READ(pp_stat_reg), |
| 1974 | I915_READ(pp_ctrl_reg)); |
Keith Packard | 99ea712 | 2011-11-01 19:57:50 -0700 | [diff] [blame] | 1975 | |
Chris Wilson | 9036ff0 | 2016-06-30 15:33:09 +0100 | [diff] [blame] | 1976 | if (intel_wait_for_register(dev_priv, |
| 1977 | pp_stat_reg, mask, value, |
| 1978 | 5000)) |
Keith Packard | 99ea712 | 2011-11-01 19:57:50 -0700 | [diff] [blame] | 1979 | DRM_ERROR("Panel status timeout: status %08x control %08x\n", |
Jesse Barnes | 453c542 | 2013-03-28 09:55:41 -0700 | [diff] [blame] | 1980 | I915_READ(pp_stat_reg), |
| 1981 | I915_READ(pp_ctrl_reg)); |
Chris Wilson | 54c136d | 2013-12-02 09:57:16 +0000 | [diff] [blame] | 1982 | |
| 1983 | DRM_DEBUG_KMS("Wait complete\n"); |
Keith Packard | 99ea712 | 2011-11-01 19:57:50 -0700 | [diff] [blame] | 1984 | } |
| 1985 | |
Daniel Vetter | 4be7378 | 2014-01-17 14:39:48 +0100 | [diff] [blame] | 1986 | static void wait_panel_on(struct intel_dp *intel_dp) |
Keith Packard | 99ea712 | 2011-11-01 19:57:50 -0700 | [diff] [blame] | 1987 | { |
| 1988 | DRM_DEBUG_KMS("Wait for panel power on\n"); |
Daniel Vetter | 4be7378 | 2014-01-17 14:39:48 +0100 | [diff] [blame] | 1989 | wait_panel_status(intel_dp, IDLE_ON_MASK, IDLE_ON_VALUE); |
Keith Packard | 99ea712 | 2011-11-01 19:57:50 -0700 | [diff] [blame] | 1990 | } |
| 1991 | |
Daniel Vetter | 4be7378 | 2014-01-17 14:39:48 +0100 | [diff] [blame] | 1992 | static void wait_panel_off(struct intel_dp *intel_dp) |
Keith Packard | bd94315 | 2011-09-18 23:09:52 -0700 | [diff] [blame] | 1993 | { |
Keith Packard | bd94315 | 2011-09-18 23:09:52 -0700 | [diff] [blame] | 1994 | DRM_DEBUG_KMS("Wait for panel power off time\n"); |
Daniel Vetter | 4be7378 | 2014-01-17 14:39:48 +0100 | [diff] [blame] | 1995 | wait_panel_status(intel_dp, IDLE_OFF_MASK, IDLE_OFF_VALUE); |
Keith Packard | bd94315 | 2011-09-18 23:09:52 -0700 | [diff] [blame] | 1996 | } |
Keith Packard | bd94315 | 2011-09-18 23:09:52 -0700 | [diff] [blame] | 1997 | |
Daniel Vetter | 4be7378 | 2014-01-17 14:39:48 +0100 | [diff] [blame] | 1998 | static void wait_panel_power_cycle(struct intel_dp *intel_dp) |
Keith Packard | 99ea712 | 2011-11-01 19:57:50 -0700 | [diff] [blame] | 1999 | { |
Abhay Kumar | d28d473 | 2016-01-22 17:39:04 -0800 | [diff] [blame] | 2000 | ktime_t panel_power_on_time; |
| 2001 | s64 panel_power_off_duration; |
| 2002 | |
Keith Packard | 99ea712 | 2011-11-01 19:57:50 -0700 | [diff] [blame] | 2003 | DRM_DEBUG_KMS("Wait for panel power cycle\n"); |
Paulo Zanoni | dce56b3 | 2013-12-19 14:29:40 -0200 | [diff] [blame] | 2004 | |
Abhay Kumar | d28d473 | 2016-01-22 17:39:04 -0800 | [diff] [blame] | 2005 | /* take the difference of currrent time and panel power off time |
| 2006 | * and then make panel wait for t11_t12 if needed. */ |
| 2007 | panel_power_on_time = ktime_get_boottime(); |
| 2008 | panel_power_off_duration = ktime_ms_delta(panel_power_on_time, intel_dp->panel_power_off_time); |
| 2009 | |
Paulo Zanoni | dce56b3 | 2013-12-19 14:29:40 -0200 | [diff] [blame] | 2010 | /* When we disable the VDD override bit last we have to do the manual |
| 2011 | * wait. */ |
Abhay Kumar | d28d473 | 2016-01-22 17:39:04 -0800 | [diff] [blame] | 2012 | if (panel_power_off_duration < (s64)intel_dp->panel_power_cycle_delay) |
| 2013 | wait_remaining_ms_from_jiffies(jiffies, |
| 2014 | intel_dp->panel_power_cycle_delay - panel_power_off_duration); |
Paulo Zanoni | dce56b3 | 2013-12-19 14:29:40 -0200 | [diff] [blame] | 2015 | |
Daniel Vetter | 4be7378 | 2014-01-17 14:39:48 +0100 | [diff] [blame] | 2016 | wait_panel_status(intel_dp, IDLE_CYCLE_MASK, IDLE_CYCLE_VALUE); |
Keith Packard | 99ea712 | 2011-11-01 19:57:50 -0700 | [diff] [blame] | 2017 | } |
Keith Packard | bd94315 | 2011-09-18 23:09:52 -0700 | [diff] [blame] | 2018 | |
Daniel Vetter | 4be7378 | 2014-01-17 14:39:48 +0100 | [diff] [blame] | 2019 | static void wait_backlight_on(struct intel_dp *intel_dp) |
Paulo Zanoni | dce56b3 | 2013-12-19 14:29:40 -0200 | [diff] [blame] | 2020 | { |
| 2021 | wait_remaining_ms_from_jiffies(intel_dp->last_power_on, |
| 2022 | intel_dp->backlight_on_delay); |
| 2023 | } |
| 2024 | |
Daniel Vetter | 4be7378 | 2014-01-17 14:39:48 +0100 | [diff] [blame] | 2025 | static void edp_wait_backlight_off(struct intel_dp *intel_dp) |
Paulo Zanoni | dce56b3 | 2013-12-19 14:29:40 -0200 | [diff] [blame] | 2026 | { |
| 2027 | wait_remaining_ms_from_jiffies(intel_dp->last_backlight_off, |
| 2028 | intel_dp->backlight_off_delay); |
| 2029 | } |
Keith Packard | 99ea712 | 2011-11-01 19:57:50 -0700 | [diff] [blame] | 2030 | |
Keith Packard | 832dd3c | 2011-11-01 19:34:06 -0700 | [diff] [blame] | 2031 | /* Read the current pp_control value, unlocking the register if it |
| 2032 | * is locked |
| 2033 | */ |
| 2034 | |
Jesse Barnes | 453c542 | 2013-03-28 09:55:41 -0700 | [diff] [blame] | 2035 | static u32 ironlake_get_pp_control(struct intel_dp *intel_dp) |
Keith Packard | 832dd3c | 2011-11-01 19:34:06 -0700 | [diff] [blame] | 2036 | { |
Ville Syrjälä | 2f77347 | 2017-11-09 17:27:58 +0200 | [diff] [blame] | 2037 | struct drm_i915_private *dev_priv = to_i915(intel_dp_to_dev(intel_dp)); |
Jesse Barnes | 453c542 | 2013-03-28 09:55:41 -0700 | [diff] [blame] | 2038 | u32 control; |
Jesse Barnes | 453c542 | 2013-03-28 09:55:41 -0700 | [diff] [blame] | 2039 | |
Ville Syrjälä | e39b999 | 2014-09-04 14:53:14 +0300 | [diff] [blame] | 2040 | lockdep_assert_held(&dev_priv->pps_mutex); |
| 2041 | |
Jani Nikula | bf13e81 | 2013-09-06 07:40:05 +0300 | [diff] [blame] | 2042 | control = I915_READ(_pp_ctrl_reg(intel_dp)); |
Imre Deak | 8090ba8 | 2016-08-10 14:07:33 +0300 | [diff] [blame] | 2043 | if (WARN_ON(!HAS_DDI(dev_priv) && |
| 2044 | (control & PANEL_UNLOCK_MASK) != PANEL_UNLOCK_REGS)) { |
Vandana Kannan | b0a08be | 2015-06-18 11:00:55 +0530 | [diff] [blame] | 2045 | control &= ~PANEL_UNLOCK_MASK; |
| 2046 | control |= PANEL_UNLOCK_REGS; |
| 2047 | } |
Keith Packard | 832dd3c | 2011-11-01 19:34:06 -0700 | [diff] [blame] | 2048 | return control; |
Keith Packard | bd94315 | 2011-09-18 23:09:52 -0700 | [diff] [blame] | 2049 | } |
| 2050 | |
Ville Syrjälä | 951468f | 2014-09-04 14:55:31 +0300 | [diff] [blame] | 2051 | /* |
| 2052 | * Must be paired with edp_panel_vdd_off(). |
| 2053 | * Must hold pps_mutex around the whole on/off sequence. |
| 2054 | * Can be nested with intel_edp_panel_vdd_{on,off}() calls. |
| 2055 | */ |
Ville Syrjälä | 1e0560e | 2014-08-19 13:24:25 +0300 | [diff] [blame] | 2056 | static bool edp_panel_vdd_on(struct intel_dp *intel_dp) |
Jesse Barnes | 5d61350 | 2011-01-24 17:10:54 -0800 | [diff] [blame] | 2057 | { |
Ville Syrjälä | 2f77347 | 2017-11-09 17:27:58 +0200 | [diff] [blame] | 2058 | struct drm_i915_private *dev_priv = to_i915(intel_dp_to_dev(intel_dp)); |
Imre Deak | 4e6e1a5 | 2014-03-27 17:45:11 +0200 | [diff] [blame] | 2059 | struct intel_digital_port *intel_dig_port = dp_to_dig_port(intel_dp); |
Jesse Barnes | 5d61350 | 2011-01-24 17:10:54 -0800 | [diff] [blame] | 2060 | u32 pp; |
Ville Syrjälä | f0f59a0 | 2015-11-18 15:33:26 +0200 | [diff] [blame] | 2061 | i915_reg_t pp_stat_reg, pp_ctrl_reg; |
Jani Nikula | adddaaf | 2014-03-14 16:51:13 +0200 | [diff] [blame] | 2062 | bool need_to_disable = !intel_dp->want_panel_vdd; |
Jesse Barnes | 5d61350 | 2011-01-24 17:10:54 -0800 | [diff] [blame] | 2063 | |
Ville Syrjälä | e39b999 | 2014-09-04 14:53:14 +0300 | [diff] [blame] | 2064 | lockdep_assert_held(&dev_priv->pps_mutex); |
| 2065 | |
Jani Nikula | 1853a9d | 2017-08-18 12:30:20 +0300 | [diff] [blame] | 2066 | if (!intel_dp_is_edp(intel_dp)) |
Jani Nikula | adddaaf | 2014-03-14 16:51:13 +0200 | [diff] [blame] | 2067 | return false; |
Keith Packard | bd94315 | 2011-09-18 23:09:52 -0700 | [diff] [blame] | 2068 | |
Egbert Eich | 2c623c1 | 2014-11-25 12:54:57 +0100 | [diff] [blame] | 2069 | cancel_delayed_work(&intel_dp->panel_vdd_work); |
Keith Packard | bd94315 | 2011-09-18 23:09:52 -0700 | [diff] [blame] | 2070 | intel_dp->want_panel_vdd = true; |
Keith Packard | 99ea712 | 2011-11-01 19:57:50 -0700 | [diff] [blame] | 2071 | |
Daniel Vetter | 4be7378 | 2014-01-17 14:39:48 +0100 | [diff] [blame] | 2072 | if (edp_have_panel_vdd(intel_dp)) |
Jani Nikula | adddaaf | 2014-03-14 16:51:13 +0200 | [diff] [blame] | 2073 | return need_to_disable; |
Paulo Zanoni | b0665d5 | 2013-10-30 19:50:27 -0200 | [diff] [blame] | 2074 | |
Ander Conselvan de Oliveira | 5432fca | 2017-02-22 08:34:26 +0200 | [diff] [blame] | 2075 | intel_display_power_get(dev_priv, intel_dp->aux_power_domain); |
Paulo Zanoni | e9cb81a | 2013-11-21 13:47:23 -0200 | [diff] [blame] | 2076 | |
Ville Syrjälä | 3936fcf | 2014-10-16 21:30:02 +0300 | [diff] [blame] | 2077 | DRM_DEBUG_KMS("Turning eDP port %c VDD on\n", |
Ville Syrjälä | 8f4f279 | 2017-11-09 17:24:34 +0200 | [diff] [blame] | 2078 | port_name(intel_dig_port->base.port)); |
Keith Packard | bd94315 | 2011-09-18 23:09:52 -0700 | [diff] [blame] | 2079 | |
Daniel Vetter | 4be7378 | 2014-01-17 14:39:48 +0100 | [diff] [blame] | 2080 | if (!edp_have_panel_power(intel_dp)) |
| 2081 | wait_panel_power_cycle(intel_dp); |
Keith Packard | 99ea712 | 2011-11-01 19:57:50 -0700 | [diff] [blame] | 2082 | |
Jesse Barnes | 453c542 | 2013-03-28 09:55:41 -0700 | [diff] [blame] | 2083 | pp = ironlake_get_pp_control(intel_dp); |
Jesse Barnes | 5d61350 | 2011-01-24 17:10:54 -0800 | [diff] [blame] | 2084 | pp |= EDP_FORCE_VDD; |
Keith Packard | ebf33b1 | 2011-09-29 15:53:27 -0700 | [diff] [blame] | 2085 | |
Jani Nikula | bf13e81 | 2013-09-06 07:40:05 +0300 | [diff] [blame] | 2086 | pp_stat_reg = _pp_stat_reg(intel_dp); |
| 2087 | pp_ctrl_reg = _pp_ctrl_reg(intel_dp); |
Jesse Barnes | 453c542 | 2013-03-28 09:55:41 -0700 | [diff] [blame] | 2088 | |
| 2089 | I915_WRITE(pp_ctrl_reg, pp); |
| 2090 | POSTING_READ(pp_ctrl_reg); |
| 2091 | DRM_DEBUG_KMS("PP_STATUS: 0x%08x PP_CONTROL: 0x%08x\n", |
| 2092 | I915_READ(pp_stat_reg), I915_READ(pp_ctrl_reg)); |
Keith Packard | ebf33b1 | 2011-09-29 15:53:27 -0700 | [diff] [blame] | 2093 | /* |
| 2094 | * If the panel wasn't on, delay before accessing aux channel |
| 2095 | */ |
Daniel Vetter | 4be7378 | 2014-01-17 14:39:48 +0100 | [diff] [blame] | 2096 | if (!edp_have_panel_power(intel_dp)) { |
Ville Syrjälä | 3936fcf | 2014-10-16 21:30:02 +0300 | [diff] [blame] | 2097 | DRM_DEBUG_KMS("eDP port %c panel power wasn't enabled\n", |
Ville Syrjälä | 8f4f279 | 2017-11-09 17:24:34 +0200 | [diff] [blame] | 2098 | port_name(intel_dig_port->base.port)); |
Keith Packard | f01eca2 | 2011-09-28 16:48:10 -0700 | [diff] [blame] | 2099 | msleep(intel_dp->panel_power_up_delay); |
Keith Packard | f01eca2 | 2011-09-28 16:48:10 -0700 | [diff] [blame] | 2100 | } |
Jani Nikula | adddaaf | 2014-03-14 16:51:13 +0200 | [diff] [blame] | 2101 | |
| 2102 | return need_to_disable; |
| 2103 | } |
| 2104 | |
Ville Syrjälä | 951468f | 2014-09-04 14:55:31 +0300 | [diff] [blame] | 2105 | /* |
| 2106 | * Must be paired with intel_edp_panel_vdd_off() or |
| 2107 | * intel_edp_panel_off(). |
| 2108 | * Nested calls to these functions are not allowed since |
| 2109 | * we drop the lock. Caller must use some higher level |
| 2110 | * locking to prevent nested calls from other threads. |
| 2111 | */ |
Daniel Vetter | b80d6c7 | 2014-03-19 15:54:37 +0100 | [diff] [blame] | 2112 | void intel_edp_panel_vdd_on(struct intel_dp *intel_dp) |
Jani Nikula | adddaaf | 2014-03-14 16:51:13 +0200 | [diff] [blame] | 2113 | { |
Ville Syrjälä | c695b6b | 2014-08-18 22:16:03 +0300 | [diff] [blame] | 2114 | bool vdd; |
Jani Nikula | adddaaf | 2014-03-14 16:51:13 +0200 | [diff] [blame] | 2115 | |
Jani Nikula | 1853a9d | 2017-08-18 12:30:20 +0300 | [diff] [blame] | 2116 | if (!intel_dp_is_edp(intel_dp)) |
Ville Syrjälä | c695b6b | 2014-08-18 22:16:03 +0300 | [diff] [blame] | 2117 | return; |
| 2118 | |
Ville Syrjälä | 773538e8 | 2014-09-04 14:54:56 +0300 | [diff] [blame] | 2119 | pps_lock(intel_dp); |
Ville Syrjälä | c695b6b | 2014-08-18 22:16:03 +0300 | [diff] [blame] | 2120 | vdd = edp_panel_vdd_on(intel_dp); |
Ville Syrjälä | 773538e8 | 2014-09-04 14:54:56 +0300 | [diff] [blame] | 2121 | pps_unlock(intel_dp); |
Ville Syrjälä | c695b6b | 2014-08-18 22:16:03 +0300 | [diff] [blame] | 2122 | |
Rob Clark | e2c719b | 2014-12-15 13:56:32 -0500 | [diff] [blame] | 2123 | I915_STATE_WARN(!vdd, "eDP port %c VDD already requested on\n", |
Ville Syrjälä | 8f4f279 | 2017-11-09 17:24:34 +0200 | [diff] [blame] | 2124 | port_name(dp_to_dig_port(intel_dp)->base.port)); |
Jesse Barnes | 5d61350 | 2011-01-24 17:10:54 -0800 | [diff] [blame] | 2125 | } |
| 2126 | |
Daniel Vetter | 4be7378 | 2014-01-17 14:39:48 +0100 | [diff] [blame] | 2127 | static void edp_panel_vdd_off_sync(struct intel_dp *intel_dp) |
Jesse Barnes | 5d61350 | 2011-01-24 17:10:54 -0800 | [diff] [blame] | 2128 | { |
Ville Syrjälä | 2f77347 | 2017-11-09 17:27:58 +0200 | [diff] [blame] | 2129 | struct drm_i915_private *dev_priv = to_i915(intel_dp_to_dev(intel_dp)); |
Ville Syrjälä | be2c919 | 2014-08-18 22:16:01 +0300 | [diff] [blame] | 2130 | struct intel_digital_port *intel_dig_port = |
| 2131 | dp_to_dig_port(intel_dp); |
Jesse Barnes | 5d61350 | 2011-01-24 17:10:54 -0800 | [diff] [blame] | 2132 | u32 pp; |
Ville Syrjälä | f0f59a0 | 2015-11-18 15:33:26 +0200 | [diff] [blame] | 2133 | i915_reg_t pp_stat_reg, pp_ctrl_reg; |
Jesse Barnes | 5d61350 | 2011-01-24 17:10:54 -0800 | [diff] [blame] | 2134 | |
Ville Syrjälä | e39b999 | 2014-09-04 14:53:14 +0300 | [diff] [blame] | 2135 | lockdep_assert_held(&dev_priv->pps_mutex); |
Daniel Vetter | a0e99e6 | 2012-12-02 01:05:46 +0100 | [diff] [blame] | 2136 | |
Ville Syrjälä | 15e899a | 2014-08-18 22:16:02 +0300 | [diff] [blame] | 2137 | WARN_ON(intel_dp->want_panel_vdd); |
Imre Deak | 4e6e1a5 | 2014-03-27 17:45:11 +0200 | [diff] [blame] | 2138 | |
Ville Syrjälä | 15e899a | 2014-08-18 22:16:02 +0300 | [diff] [blame] | 2139 | if (!edp_have_panel_vdd(intel_dp)) |
Ville Syrjälä | be2c919 | 2014-08-18 22:16:01 +0300 | [diff] [blame] | 2140 | return; |
Paulo Zanoni | b0665d5 | 2013-10-30 19:50:27 -0200 | [diff] [blame] | 2141 | |
Ville Syrjälä | 3936fcf | 2014-10-16 21:30:02 +0300 | [diff] [blame] | 2142 | DRM_DEBUG_KMS("Turning eDP port %c VDD off\n", |
Ville Syrjälä | 8f4f279 | 2017-11-09 17:24:34 +0200 | [diff] [blame] | 2143 | port_name(intel_dig_port->base.port)); |
Jesse Barnes | 453c542 | 2013-03-28 09:55:41 -0700 | [diff] [blame] | 2144 | |
Ville Syrjälä | be2c919 | 2014-08-18 22:16:01 +0300 | [diff] [blame] | 2145 | pp = ironlake_get_pp_control(intel_dp); |
| 2146 | pp &= ~EDP_FORCE_VDD; |
Jesse Barnes | 453c542 | 2013-03-28 09:55:41 -0700 | [diff] [blame] | 2147 | |
Ville Syrjälä | be2c919 | 2014-08-18 22:16:01 +0300 | [diff] [blame] | 2148 | pp_ctrl_reg = _pp_ctrl_reg(intel_dp); |
| 2149 | pp_stat_reg = _pp_stat_reg(intel_dp); |
Jesse Barnes | 5d61350 | 2011-01-24 17:10:54 -0800 | [diff] [blame] | 2150 | |
Ville Syrjälä | be2c919 | 2014-08-18 22:16:01 +0300 | [diff] [blame] | 2151 | I915_WRITE(pp_ctrl_reg, pp); |
| 2152 | POSTING_READ(pp_ctrl_reg); |
Paulo Zanoni | 90791a5 | 2013-12-06 17:32:42 -0200 | [diff] [blame] | 2153 | |
Ville Syrjälä | be2c919 | 2014-08-18 22:16:01 +0300 | [diff] [blame] | 2154 | /* Make sure sequencer is idle before allowing subsequent activity */ |
| 2155 | DRM_DEBUG_KMS("PP_STATUS: 0x%08x PP_CONTROL: 0x%08x\n", |
| 2156 | I915_READ(pp_stat_reg), I915_READ(pp_ctrl_reg)); |
Paulo Zanoni | e9cb81a | 2013-11-21 13:47:23 -0200 | [diff] [blame] | 2157 | |
Imre Deak | 5a162e2 | 2016-08-10 14:07:30 +0300 | [diff] [blame] | 2158 | if ((pp & PANEL_POWER_ON) == 0) |
Abhay Kumar | d28d473 | 2016-01-22 17:39:04 -0800 | [diff] [blame] | 2159 | intel_dp->panel_power_off_time = ktime_get_boottime(); |
Paulo Zanoni | e9cb81a | 2013-11-21 13:47:23 -0200 | [diff] [blame] | 2160 | |
Ander Conselvan de Oliveira | 5432fca | 2017-02-22 08:34:26 +0200 | [diff] [blame] | 2161 | intel_display_power_put(dev_priv, intel_dp->aux_power_domain); |
Keith Packard | bd94315 | 2011-09-18 23:09:52 -0700 | [diff] [blame] | 2162 | } |
| 2163 | |
Daniel Vetter | 4be7378 | 2014-01-17 14:39:48 +0100 | [diff] [blame] | 2164 | static void edp_panel_vdd_work(struct work_struct *__work) |
Keith Packard | bd94315 | 2011-09-18 23:09:52 -0700 | [diff] [blame] | 2165 | { |
| 2166 | struct intel_dp *intel_dp = container_of(to_delayed_work(__work), |
| 2167 | struct intel_dp, panel_vdd_work); |
Keith Packard | bd94315 | 2011-09-18 23:09:52 -0700 | [diff] [blame] | 2168 | |
Ville Syrjälä | 773538e8 | 2014-09-04 14:54:56 +0300 | [diff] [blame] | 2169 | pps_lock(intel_dp); |
Ville Syrjälä | 15e899a | 2014-08-18 22:16:02 +0300 | [diff] [blame] | 2170 | if (!intel_dp->want_panel_vdd) |
| 2171 | edp_panel_vdd_off_sync(intel_dp); |
Ville Syrjälä | 773538e8 | 2014-09-04 14:54:56 +0300 | [diff] [blame] | 2172 | pps_unlock(intel_dp); |
Keith Packard | bd94315 | 2011-09-18 23:09:52 -0700 | [diff] [blame] | 2173 | } |
| 2174 | |
Imre Deak | aba8689 | 2014-07-30 15:57:31 +0300 | [diff] [blame] | 2175 | static void edp_panel_vdd_schedule_off(struct intel_dp *intel_dp) |
| 2176 | { |
| 2177 | unsigned long delay; |
| 2178 | |
| 2179 | /* |
| 2180 | * Queue the timer to fire a long time from now (relative to the power |
| 2181 | * down delay) to keep the panel power up across a sequence of |
| 2182 | * operations. |
| 2183 | */ |
| 2184 | delay = msecs_to_jiffies(intel_dp->panel_power_cycle_delay * 5); |
| 2185 | schedule_delayed_work(&intel_dp->panel_vdd_work, delay); |
| 2186 | } |
| 2187 | |
Ville Syrjälä | 951468f | 2014-09-04 14:55:31 +0300 | [diff] [blame] | 2188 | /* |
| 2189 | * Must be paired with edp_panel_vdd_on(). |
| 2190 | * Must hold pps_mutex around the whole on/off sequence. |
| 2191 | * Can be nested with intel_edp_panel_vdd_{on,off}() calls. |
| 2192 | */ |
Daniel Vetter | 4be7378 | 2014-01-17 14:39:48 +0100 | [diff] [blame] | 2193 | static void edp_panel_vdd_off(struct intel_dp *intel_dp, bool sync) |
Keith Packard | bd94315 | 2011-09-18 23:09:52 -0700 | [diff] [blame] | 2194 | { |
Chris Wilson | fac5e23 | 2016-07-04 11:34:36 +0100 | [diff] [blame] | 2195 | struct drm_i915_private *dev_priv = to_i915(intel_dp_to_dev(intel_dp)); |
Ville Syrjälä | e39b999 | 2014-09-04 14:53:14 +0300 | [diff] [blame] | 2196 | |
| 2197 | lockdep_assert_held(&dev_priv->pps_mutex); |
| 2198 | |
Jani Nikula | 1853a9d | 2017-08-18 12:30:20 +0300 | [diff] [blame] | 2199 | if (!intel_dp_is_edp(intel_dp)) |
Keith Packard | 97af61f57 | 2011-09-28 16:23:51 -0700 | [diff] [blame] | 2200 | return; |
Jesse Barnes | 5d61350 | 2011-01-24 17:10:54 -0800 | [diff] [blame] | 2201 | |
Rob Clark | e2c719b | 2014-12-15 13:56:32 -0500 | [diff] [blame] | 2202 | I915_STATE_WARN(!intel_dp->want_panel_vdd, "eDP port %c VDD not forced on", |
Ville Syrjälä | 8f4f279 | 2017-11-09 17:24:34 +0200 | [diff] [blame] | 2203 | port_name(dp_to_dig_port(intel_dp)->base.port)); |
Keith Packard | f2e8b18 | 2011-11-01 20:01:35 -0700 | [diff] [blame] | 2204 | |
Keith Packard | bd94315 | 2011-09-18 23:09:52 -0700 | [diff] [blame] | 2205 | intel_dp->want_panel_vdd = false; |
| 2206 | |
Imre Deak | aba8689 | 2014-07-30 15:57:31 +0300 | [diff] [blame] | 2207 | if (sync) |
Daniel Vetter | 4be7378 | 2014-01-17 14:39:48 +0100 | [diff] [blame] | 2208 | edp_panel_vdd_off_sync(intel_dp); |
Imre Deak | aba8689 | 2014-07-30 15:57:31 +0300 | [diff] [blame] | 2209 | else |
| 2210 | edp_panel_vdd_schedule_off(intel_dp); |
Jesse Barnes | 5d61350 | 2011-01-24 17:10:54 -0800 | [diff] [blame] | 2211 | } |
| 2212 | |
Ville Syrjälä | 9f0fb5b | 2014-10-16 21:27:32 +0300 | [diff] [blame] | 2213 | static void edp_panel_on(struct intel_dp *intel_dp) |
Jesse Barnes | 9934c13 | 2010-07-22 13:18:19 -0700 | [diff] [blame] | 2214 | { |
Ville Syrjälä | 2f77347 | 2017-11-09 17:27:58 +0200 | [diff] [blame] | 2215 | struct drm_i915_private *dev_priv = to_i915(intel_dp_to_dev(intel_dp)); |
Keith Packard | 99ea712 | 2011-11-01 19:57:50 -0700 | [diff] [blame] | 2216 | u32 pp; |
Ville Syrjälä | f0f59a0 | 2015-11-18 15:33:26 +0200 | [diff] [blame] | 2217 | i915_reg_t pp_ctrl_reg; |
Jesse Barnes | 9934c13 | 2010-07-22 13:18:19 -0700 | [diff] [blame] | 2218 | |
Ville Syrjälä | 9f0fb5b | 2014-10-16 21:27:32 +0300 | [diff] [blame] | 2219 | lockdep_assert_held(&dev_priv->pps_mutex); |
| 2220 | |
Jani Nikula | 1853a9d | 2017-08-18 12:30:20 +0300 | [diff] [blame] | 2221 | if (!intel_dp_is_edp(intel_dp)) |
Keith Packard | bd94315 | 2011-09-18 23:09:52 -0700 | [diff] [blame] | 2222 | return; |
Keith Packard | 99ea712 | 2011-11-01 19:57:50 -0700 | [diff] [blame] | 2223 | |
Ville Syrjälä | 3936fcf | 2014-10-16 21:30:02 +0300 | [diff] [blame] | 2224 | DRM_DEBUG_KMS("Turn eDP port %c panel power on\n", |
Ville Syrjälä | 8f4f279 | 2017-11-09 17:24:34 +0200 | [diff] [blame] | 2225 | port_name(dp_to_dig_port(intel_dp)->base.port)); |
Keith Packard | 99ea712 | 2011-11-01 19:57:50 -0700 | [diff] [blame] | 2226 | |
Ville Syrjälä | e7a89ac | 2014-10-16 21:30:07 +0300 | [diff] [blame] | 2227 | if (WARN(edp_have_panel_power(intel_dp), |
| 2228 | "eDP port %c panel power already on\n", |
Ville Syrjälä | 8f4f279 | 2017-11-09 17:24:34 +0200 | [diff] [blame] | 2229 | port_name(dp_to_dig_port(intel_dp)->base.port))) |
Ville Syrjälä | 9f0fb5b | 2014-10-16 21:27:32 +0300 | [diff] [blame] | 2230 | return; |
Jesse Barnes | 9934c13 | 2010-07-22 13:18:19 -0700 | [diff] [blame] | 2231 | |
Daniel Vetter | 4be7378 | 2014-01-17 14:39:48 +0100 | [diff] [blame] | 2232 | wait_panel_power_cycle(intel_dp); |
Jesse Barnes | 37c6c9b | 2010-08-11 10:04:43 -0700 | [diff] [blame] | 2233 | |
Jani Nikula | bf13e81 | 2013-09-06 07:40:05 +0300 | [diff] [blame] | 2234 | pp_ctrl_reg = _pp_ctrl_reg(intel_dp); |
Jesse Barnes | 453c542 | 2013-03-28 09:55:41 -0700 | [diff] [blame] | 2235 | pp = ironlake_get_pp_control(intel_dp); |
Tvrtko Ursulin | 5db9401 | 2016-10-13 11:03:10 +0100 | [diff] [blame] | 2236 | if (IS_GEN5(dev_priv)) { |
Keith Packard | 05ce1a4 | 2011-09-29 16:33:01 -0700 | [diff] [blame] | 2237 | /* ILK workaround: disable reset around power sequence */ |
| 2238 | pp &= ~PANEL_POWER_RESET; |
Jani Nikula | bf13e81 | 2013-09-06 07:40:05 +0300 | [diff] [blame] | 2239 | I915_WRITE(pp_ctrl_reg, pp); |
| 2240 | POSTING_READ(pp_ctrl_reg); |
Keith Packard | 05ce1a4 | 2011-09-29 16:33:01 -0700 | [diff] [blame] | 2241 | } |
Jesse Barnes | 37c6c9b | 2010-08-11 10:04:43 -0700 | [diff] [blame] | 2242 | |
Imre Deak | 5a162e2 | 2016-08-10 14:07:30 +0300 | [diff] [blame] | 2243 | pp |= PANEL_POWER_ON; |
Tvrtko Ursulin | 5db9401 | 2016-10-13 11:03:10 +0100 | [diff] [blame] | 2244 | if (!IS_GEN5(dev_priv)) |
Keith Packard | 99ea712 | 2011-11-01 19:57:50 -0700 | [diff] [blame] | 2245 | pp |= PANEL_POWER_RESET; |
| 2246 | |
Jesse Barnes | 453c542 | 2013-03-28 09:55:41 -0700 | [diff] [blame] | 2247 | I915_WRITE(pp_ctrl_reg, pp); |
| 2248 | POSTING_READ(pp_ctrl_reg); |
Jesse Barnes | 9934c13 | 2010-07-22 13:18:19 -0700 | [diff] [blame] | 2249 | |
Daniel Vetter | 4be7378 | 2014-01-17 14:39:48 +0100 | [diff] [blame] | 2250 | wait_panel_on(intel_dp); |
Paulo Zanoni | dce56b3 | 2013-12-19 14:29:40 -0200 | [diff] [blame] | 2251 | intel_dp->last_power_on = jiffies; |
Jesse Barnes | 9934c13 | 2010-07-22 13:18:19 -0700 | [diff] [blame] | 2252 | |
Tvrtko Ursulin | 5db9401 | 2016-10-13 11:03:10 +0100 | [diff] [blame] | 2253 | if (IS_GEN5(dev_priv)) { |
Keith Packard | 05ce1a4 | 2011-09-29 16:33:01 -0700 | [diff] [blame] | 2254 | pp |= PANEL_POWER_RESET; /* restore panel reset bit */ |
Jani Nikula | bf13e81 | 2013-09-06 07:40:05 +0300 | [diff] [blame] | 2255 | I915_WRITE(pp_ctrl_reg, pp); |
| 2256 | POSTING_READ(pp_ctrl_reg); |
Keith Packard | 05ce1a4 | 2011-09-29 16:33:01 -0700 | [diff] [blame] | 2257 | } |
Ville Syrjälä | 9f0fb5b | 2014-10-16 21:27:32 +0300 | [diff] [blame] | 2258 | } |
Ville Syrjälä | e39b999 | 2014-09-04 14:53:14 +0300 | [diff] [blame] | 2259 | |
Ville Syrjälä | 9f0fb5b | 2014-10-16 21:27:32 +0300 | [diff] [blame] | 2260 | void intel_edp_panel_on(struct intel_dp *intel_dp) |
| 2261 | { |
Jani Nikula | 1853a9d | 2017-08-18 12:30:20 +0300 | [diff] [blame] | 2262 | if (!intel_dp_is_edp(intel_dp)) |
Ville Syrjälä | 9f0fb5b | 2014-10-16 21:27:32 +0300 | [diff] [blame] | 2263 | return; |
| 2264 | |
| 2265 | pps_lock(intel_dp); |
| 2266 | edp_panel_on(intel_dp); |
Ville Syrjälä | 773538e8 | 2014-09-04 14:54:56 +0300 | [diff] [blame] | 2267 | pps_unlock(intel_dp); |
Jesse Barnes | 9934c13 | 2010-07-22 13:18:19 -0700 | [diff] [blame] | 2268 | } |
| 2269 | |
Ville Syrjälä | 9f0fb5b | 2014-10-16 21:27:32 +0300 | [diff] [blame] | 2270 | |
| 2271 | static void edp_panel_off(struct intel_dp *intel_dp) |
Jesse Barnes | 9934c13 | 2010-07-22 13:18:19 -0700 | [diff] [blame] | 2272 | { |
Ville Syrjälä | 2f77347 | 2017-11-09 17:27:58 +0200 | [diff] [blame] | 2273 | struct drm_i915_private *dev_priv = to_i915(intel_dp_to_dev(intel_dp)); |
Keith Packard | 99ea712 | 2011-11-01 19:57:50 -0700 | [diff] [blame] | 2274 | u32 pp; |
Ville Syrjälä | f0f59a0 | 2015-11-18 15:33:26 +0200 | [diff] [blame] | 2275 | i915_reg_t pp_ctrl_reg; |
Jesse Barnes | 9934c13 | 2010-07-22 13:18:19 -0700 | [diff] [blame] | 2276 | |
Ville Syrjälä | 9f0fb5b | 2014-10-16 21:27:32 +0300 | [diff] [blame] | 2277 | lockdep_assert_held(&dev_priv->pps_mutex); |
| 2278 | |
Jani Nikula | 1853a9d | 2017-08-18 12:30:20 +0300 | [diff] [blame] | 2279 | if (!intel_dp_is_edp(intel_dp)) |
Keith Packard | 97af61f57 | 2011-09-28 16:23:51 -0700 | [diff] [blame] | 2280 | return; |
Jesse Barnes | 37c6c9b | 2010-08-11 10:04:43 -0700 | [diff] [blame] | 2281 | |
Ville Syrjälä | 3936fcf | 2014-10-16 21:30:02 +0300 | [diff] [blame] | 2282 | DRM_DEBUG_KMS("Turn eDP port %c panel power off\n", |
Ville Syrjälä | 8f4f279 | 2017-11-09 17:24:34 +0200 | [diff] [blame] | 2283 | port_name(dp_to_dig_port(intel_dp)->base.port)); |
Jesse Barnes | 37c6c9b | 2010-08-11 10:04:43 -0700 | [diff] [blame] | 2284 | |
Ville Syrjälä | 3936fcf | 2014-10-16 21:30:02 +0300 | [diff] [blame] | 2285 | WARN(!intel_dp->want_panel_vdd, "Need eDP port %c VDD to turn off panel\n", |
Ville Syrjälä | 8f4f279 | 2017-11-09 17:24:34 +0200 | [diff] [blame] | 2286 | port_name(dp_to_dig_port(intel_dp)->base.port)); |
Jani Nikula | 24f3e09 | 2014-03-17 16:43:36 +0200 | [diff] [blame] | 2287 | |
Jesse Barnes | 453c542 | 2013-03-28 09:55:41 -0700 | [diff] [blame] | 2288 | pp = ironlake_get_pp_control(intel_dp); |
Daniel Vetter | 35a3855 | 2012-08-12 22:17:14 +0200 | [diff] [blame] | 2289 | /* We need to switch off panel power _and_ force vdd, for otherwise some |
| 2290 | * panels get very unhappy and cease to work. */ |
Imre Deak | 5a162e2 | 2016-08-10 14:07:30 +0300 | [diff] [blame] | 2291 | pp &= ~(PANEL_POWER_ON | PANEL_POWER_RESET | EDP_FORCE_VDD | |
Patrik Jakobsson | b306415 | 2014-03-04 00:42:44 +0100 | [diff] [blame] | 2292 | EDP_BLC_ENABLE); |
Jesse Barnes | 453c542 | 2013-03-28 09:55:41 -0700 | [diff] [blame] | 2293 | |
Jani Nikula | bf13e81 | 2013-09-06 07:40:05 +0300 | [diff] [blame] | 2294 | pp_ctrl_reg = _pp_ctrl_reg(intel_dp); |
Jesse Barnes | 453c542 | 2013-03-28 09:55:41 -0700 | [diff] [blame] | 2295 | |
Paulo Zanoni | 849e39f | 2014-03-07 20:05:20 -0300 | [diff] [blame] | 2296 | intel_dp->want_panel_vdd = false; |
| 2297 | |
Jesse Barnes | 453c542 | 2013-03-28 09:55:41 -0700 | [diff] [blame] | 2298 | I915_WRITE(pp_ctrl_reg, pp); |
| 2299 | POSTING_READ(pp_ctrl_reg); |
Jesse Barnes | 9934c13 | 2010-07-22 13:18:19 -0700 | [diff] [blame] | 2300 | |
Daniel Vetter | 4be7378 | 2014-01-17 14:39:48 +0100 | [diff] [blame] | 2301 | wait_panel_off(intel_dp); |
Manasi Navare | d7ba25b | 2017-10-04 09:48:26 -0700 | [diff] [blame] | 2302 | intel_dp->panel_power_off_time = ktime_get_boottime(); |
Paulo Zanoni | 849e39f | 2014-03-07 20:05:20 -0300 | [diff] [blame] | 2303 | |
| 2304 | /* We got a reference when we enabled the VDD. */ |
Ander Conselvan de Oliveira | 5432fca | 2017-02-22 08:34:26 +0200 | [diff] [blame] | 2305 | intel_display_power_put(dev_priv, intel_dp->aux_power_domain); |
Ville Syrjälä | 9f0fb5b | 2014-10-16 21:27:32 +0300 | [diff] [blame] | 2306 | } |
Ville Syrjälä | e39b999 | 2014-09-04 14:53:14 +0300 | [diff] [blame] | 2307 | |
Ville Syrjälä | 9f0fb5b | 2014-10-16 21:27:32 +0300 | [diff] [blame] | 2308 | void intel_edp_panel_off(struct intel_dp *intel_dp) |
| 2309 | { |
Jani Nikula | 1853a9d | 2017-08-18 12:30:20 +0300 | [diff] [blame] | 2310 | if (!intel_dp_is_edp(intel_dp)) |
Ville Syrjälä | 9f0fb5b | 2014-10-16 21:27:32 +0300 | [diff] [blame] | 2311 | return; |
| 2312 | |
| 2313 | pps_lock(intel_dp); |
| 2314 | edp_panel_off(intel_dp); |
Ville Syrjälä | 773538e8 | 2014-09-04 14:54:56 +0300 | [diff] [blame] | 2315 | pps_unlock(intel_dp); |
Jesse Barnes | 9934c13 | 2010-07-22 13:18:19 -0700 | [diff] [blame] | 2316 | } |
| 2317 | |
Jani Nikula | 1250d10 | 2014-08-12 17:11:39 +0300 | [diff] [blame] | 2318 | /* Enable backlight in the panel power control. */ |
| 2319 | static void _intel_edp_backlight_on(struct intel_dp *intel_dp) |
Zhenyu Wang | 32f9d65 | 2009-07-24 01:00:32 +0800 | [diff] [blame] | 2320 | { |
Ville Syrjälä | 2f77347 | 2017-11-09 17:27:58 +0200 | [diff] [blame] | 2321 | struct drm_i915_private *dev_priv = to_i915(intel_dp_to_dev(intel_dp)); |
Zhenyu Wang | 32f9d65 | 2009-07-24 01:00:32 +0800 | [diff] [blame] | 2322 | u32 pp; |
Ville Syrjälä | f0f59a0 | 2015-11-18 15:33:26 +0200 | [diff] [blame] | 2323 | i915_reg_t pp_ctrl_reg; |
Zhenyu Wang | 32f9d65 | 2009-07-24 01:00:32 +0800 | [diff] [blame] | 2324 | |
Jesse Barnes | 01cb9ea | 2010-10-07 16:01:12 -0700 | [diff] [blame] | 2325 | /* |
| 2326 | * If we enable the backlight right away following a panel power |
| 2327 | * on, we may see slight flicker as the panel syncs with the eDP |
| 2328 | * link. So delay a bit to make sure the image is solid before |
| 2329 | * allowing it to appear. |
| 2330 | */ |
Daniel Vetter | 4be7378 | 2014-01-17 14:39:48 +0100 | [diff] [blame] | 2331 | wait_backlight_on(intel_dp); |
Ville Syrjälä | e39b999 | 2014-09-04 14:53:14 +0300 | [diff] [blame] | 2332 | |
Ville Syrjälä | 773538e8 | 2014-09-04 14:54:56 +0300 | [diff] [blame] | 2333 | pps_lock(intel_dp); |
Ville Syrjälä | e39b999 | 2014-09-04 14:53:14 +0300 | [diff] [blame] | 2334 | |
Jesse Barnes | 453c542 | 2013-03-28 09:55:41 -0700 | [diff] [blame] | 2335 | pp = ironlake_get_pp_control(intel_dp); |
Zhenyu Wang | 32f9d65 | 2009-07-24 01:00:32 +0800 | [diff] [blame] | 2336 | pp |= EDP_BLC_ENABLE; |
Jesse Barnes | 453c542 | 2013-03-28 09:55:41 -0700 | [diff] [blame] | 2337 | |
Jani Nikula | bf13e81 | 2013-09-06 07:40:05 +0300 | [diff] [blame] | 2338 | pp_ctrl_reg = _pp_ctrl_reg(intel_dp); |
Jesse Barnes | 453c542 | 2013-03-28 09:55:41 -0700 | [diff] [blame] | 2339 | |
| 2340 | I915_WRITE(pp_ctrl_reg, pp); |
| 2341 | POSTING_READ(pp_ctrl_reg); |
Ville Syrjälä | e39b999 | 2014-09-04 14:53:14 +0300 | [diff] [blame] | 2342 | |
Ville Syrjälä | 773538e8 | 2014-09-04 14:54:56 +0300 | [diff] [blame] | 2343 | pps_unlock(intel_dp); |
Zhenyu Wang | 32f9d65 | 2009-07-24 01:00:32 +0800 | [diff] [blame] | 2344 | } |
| 2345 | |
Jani Nikula | 1250d10 | 2014-08-12 17:11:39 +0300 | [diff] [blame] | 2346 | /* Enable backlight PWM and backlight PP control. */ |
Maarten Lankhorst | b037d58 | 2017-06-12 12:21:13 +0200 | [diff] [blame] | 2347 | void intel_edp_backlight_on(const struct intel_crtc_state *crtc_state, |
| 2348 | const struct drm_connector_state *conn_state) |
Jani Nikula | 1250d10 | 2014-08-12 17:11:39 +0300 | [diff] [blame] | 2349 | { |
Maarten Lankhorst | b037d58 | 2017-06-12 12:21:13 +0200 | [diff] [blame] | 2350 | struct intel_dp *intel_dp = enc_to_intel_dp(conn_state->best_encoder); |
| 2351 | |
Jani Nikula | 1853a9d | 2017-08-18 12:30:20 +0300 | [diff] [blame] | 2352 | if (!intel_dp_is_edp(intel_dp)) |
Jani Nikula | 1250d10 | 2014-08-12 17:11:39 +0300 | [diff] [blame] | 2353 | return; |
| 2354 | |
| 2355 | DRM_DEBUG_KMS("\n"); |
| 2356 | |
Maarten Lankhorst | b037d58 | 2017-06-12 12:21:13 +0200 | [diff] [blame] | 2357 | intel_panel_enable_backlight(crtc_state, conn_state); |
Jani Nikula | 1250d10 | 2014-08-12 17:11:39 +0300 | [diff] [blame] | 2358 | _intel_edp_backlight_on(intel_dp); |
| 2359 | } |
| 2360 | |
| 2361 | /* Disable backlight in the panel power control. */ |
| 2362 | static void _intel_edp_backlight_off(struct intel_dp *intel_dp) |
Zhenyu Wang | 32f9d65 | 2009-07-24 01:00:32 +0800 | [diff] [blame] | 2363 | { |
Ville Syrjälä | 2f77347 | 2017-11-09 17:27:58 +0200 | [diff] [blame] | 2364 | struct drm_i915_private *dev_priv = to_i915(intel_dp_to_dev(intel_dp)); |
Zhenyu Wang | 32f9d65 | 2009-07-24 01:00:32 +0800 | [diff] [blame] | 2365 | u32 pp; |
Ville Syrjälä | f0f59a0 | 2015-11-18 15:33:26 +0200 | [diff] [blame] | 2366 | i915_reg_t pp_ctrl_reg; |
Zhenyu Wang | 32f9d65 | 2009-07-24 01:00:32 +0800 | [diff] [blame] | 2367 | |
Jani Nikula | 1853a9d | 2017-08-18 12:30:20 +0300 | [diff] [blame] | 2368 | if (!intel_dp_is_edp(intel_dp)) |
Keith Packard | f01eca2 | 2011-09-28 16:48:10 -0700 | [diff] [blame] | 2369 | return; |
| 2370 | |
Ville Syrjälä | 773538e8 | 2014-09-04 14:54:56 +0300 | [diff] [blame] | 2371 | pps_lock(intel_dp); |
Ville Syrjälä | e39b999 | 2014-09-04 14:53:14 +0300 | [diff] [blame] | 2372 | |
Jesse Barnes | 453c542 | 2013-03-28 09:55:41 -0700 | [diff] [blame] | 2373 | pp = ironlake_get_pp_control(intel_dp); |
Zhenyu Wang | 32f9d65 | 2009-07-24 01:00:32 +0800 | [diff] [blame] | 2374 | pp &= ~EDP_BLC_ENABLE; |
Jesse Barnes | 453c542 | 2013-03-28 09:55:41 -0700 | [diff] [blame] | 2375 | |
Jani Nikula | bf13e81 | 2013-09-06 07:40:05 +0300 | [diff] [blame] | 2376 | pp_ctrl_reg = _pp_ctrl_reg(intel_dp); |
Jesse Barnes | 453c542 | 2013-03-28 09:55:41 -0700 | [diff] [blame] | 2377 | |
| 2378 | I915_WRITE(pp_ctrl_reg, pp); |
| 2379 | POSTING_READ(pp_ctrl_reg); |
Jesse Barnes | f7d2323 | 2014-03-31 11:13:56 -0700 | [diff] [blame] | 2380 | |
Ville Syrjälä | 773538e8 | 2014-09-04 14:54:56 +0300 | [diff] [blame] | 2381 | pps_unlock(intel_dp); |
Ville Syrjälä | e39b999 | 2014-09-04 14:53:14 +0300 | [diff] [blame] | 2382 | |
Paulo Zanoni | dce56b3 | 2013-12-19 14:29:40 -0200 | [diff] [blame] | 2383 | intel_dp->last_backlight_off = jiffies; |
Jesse Barnes | f7d2323 | 2014-03-31 11:13:56 -0700 | [diff] [blame] | 2384 | edp_wait_backlight_off(intel_dp); |
Jani Nikula | 1250d10 | 2014-08-12 17:11:39 +0300 | [diff] [blame] | 2385 | } |
Jesse Barnes | f7d2323 | 2014-03-31 11:13:56 -0700 | [diff] [blame] | 2386 | |
Jani Nikula | 1250d10 | 2014-08-12 17:11:39 +0300 | [diff] [blame] | 2387 | /* Disable backlight PP control and backlight PWM. */ |
Maarten Lankhorst | b037d58 | 2017-06-12 12:21:13 +0200 | [diff] [blame] | 2388 | void intel_edp_backlight_off(const struct drm_connector_state *old_conn_state) |
Jani Nikula | 1250d10 | 2014-08-12 17:11:39 +0300 | [diff] [blame] | 2389 | { |
Maarten Lankhorst | b037d58 | 2017-06-12 12:21:13 +0200 | [diff] [blame] | 2390 | struct intel_dp *intel_dp = enc_to_intel_dp(old_conn_state->best_encoder); |
| 2391 | |
Jani Nikula | 1853a9d | 2017-08-18 12:30:20 +0300 | [diff] [blame] | 2392 | if (!intel_dp_is_edp(intel_dp)) |
Jani Nikula | 1250d10 | 2014-08-12 17:11:39 +0300 | [diff] [blame] | 2393 | return; |
| 2394 | |
| 2395 | DRM_DEBUG_KMS("\n"); |
| 2396 | |
| 2397 | _intel_edp_backlight_off(intel_dp); |
Maarten Lankhorst | b037d58 | 2017-06-12 12:21:13 +0200 | [diff] [blame] | 2398 | intel_panel_disable_backlight(old_conn_state); |
Zhenyu Wang | 32f9d65 | 2009-07-24 01:00:32 +0800 | [diff] [blame] | 2399 | } |
Keith Packard | a4fc5ed | 2009-04-07 16:16:42 -0700 | [diff] [blame] | 2400 | |
Jani Nikula | 73580fb7 | 2014-08-12 17:11:41 +0300 | [diff] [blame] | 2401 | /* |
| 2402 | * Hook for controlling the panel power control backlight through the bl_power |
| 2403 | * sysfs attribute. Take care to handle multiple calls. |
| 2404 | */ |
| 2405 | static void intel_edp_backlight_power(struct intel_connector *connector, |
| 2406 | bool enable) |
| 2407 | { |
| 2408 | struct intel_dp *intel_dp = intel_attached_dp(&connector->base); |
Ville Syrjälä | e39b999 | 2014-09-04 14:53:14 +0300 | [diff] [blame] | 2409 | bool is_enabled; |
| 2410 | |
Ville Syrjälä | 773538e8 | 2014-09-04 14:54:56 +0300 | [diff] [blame] | 2411 | pps_lock(intel_dp); |
Ville Syrjälä | e39b999 | 2014-09-04 14:53:14 +0300 | [diff] [blame] | 2412 | is_enabled = ironlake_get_pp_control(intel_dp) & EDP_BLC_ENABLE; |
Ville Syrjälä | 773538e8 | 2014-09-04 14:54:56 +0300 | [diff] [blame] | 2413 | pps_unlock(intel_dp); |
Jani Nikula | 73580fb7 | 2014-08-12 17:11:41 +0300 | [diff] [blame] | 2414 | |
| 2415 | if (is_enabled == enable) |
| 2416 | return; |
| 2417 | |
Jani Nikula | 23ba937 | 2014-08-27 14:08:43 +0300 | [diff] [blame] | 2418 | DRM_DEBUG_KMS("panel power control backlight %s\n", |
| 2419 | enable ? "enable" : "disable"); |
Jani Nikula | 73580fb7 | 2014-08-12 17:11:41 +0300 | [diff] [blame] | 2420 | |
| 2421 | if (enable) |
| 2422 | _intel_edp_backlight_on(intel_dp); |
| 2423 | else |
| 2424 | _intel_edp_backlight_off(intel_dp); |
| 2425 | } |
| 2426 | |
Ville Syrjälä | 64e1077 | 2015-10-29 21:26:01 +0200 | [diff] [blame] | 2427 | static void assert_dp_port(struct intel_dp *intel_dp, bool state) |
| 2428 | { |
| 2429 | struct intel_digital_port *dig_port = dp_to_dig_port(intel_dp); |
| 2430 | struct drm_i915_private *dev_priv = to_i915(dig_port->base.base.dev); |
| 2431 | bool cur_state = I915_READ(intel_dp->output_reg) & DP_PORT_EN; |
| 2432 | |
| 2433 | I915_STATE_WARN(cur_state != state, |
| 2434 | "DP port %c state assertion failure (expected %s, current %s)\n", |
Ville Syrjälä | 8f4f279 | 2017-11-09 17:24:34 +0200 | [diff] [blame] | 2435 | port_name(dig_port->base.port), |
Jani Nikula | 87ad321 | 2016-01-14 12:53:34 +0200 | [diff] [blame] | 2436 | onoff(state), onoff(cur_state)); |
Ville Syrjälä | 64e1077 | 2015-10-29 21:26:01 +0200 | [diff] [blame] | 2437 | } |
| 2438 | #define assert_dp_port_disabled(d) assert_dp_port((d), false) |
| 2439 | |
| 2440 | static void assert_edp_pll(struct drm_i915_private *dev_priv, bool state) |
| 2441 | { |
| 2442 | bool cur_state = I915_READ(DP_A) & DP_PLL_ENABLE; |
| 2443 | |
| 2444 | I915_STATE_WARN(cur_state != state, |
| 2445 | "eDP PLL state assertion failure (expected %s, current %s)\n", |
Jani Nikula | 87ad321 | 2016-01-14 12:53:34 +0200 | [diff] [blame] | 2446 | onoff(state), onoff(cur_state)); |
Ville Syrjälä | 64e1077 | 2015-10-29 21:26:01 +0200 | [diff] [blame] | 2447 | } |
| 2448 | #define assert_edp_pll_enabled(d) assert_edp_pll((d), true) |
| 2449 | #define assert_edp_pll_disabled(d) assert_edp_pll((d), false) |
| 2450 | |
Maarten Lankhorst | 85cb48a | 2016-08-09 17:04:13 +0200 | [diff] [blame] | 2451 | static void ironlake_edp_pll_on(struct intel_dp *intel_dp, |
Ville Syrjälä | 5f88a9c | 2017-08-18 16:49:58 +0300 | [diff] [blame] | 2452 | const struct intel_crtc_state *pipe_config) |
Jesse Barnes | d240f20 | 2010-08-13 15:43:26 -0700 | [diff] [blame] | 2453 | { |
Maarten Lankhorst | 85cb48a | 2016-08-09 17:04:13 +0200 | [diff] [blame] | 2454 | struct intel_crtc *crtc = to_intel_crtc(pipe_config->base.crtc); |
Ville Syrjälä | 64e1077 | 2015-10-29 21:26:01 +0200 | [diff] [blame] | 2455 | struct drm_i915_private *dev_priv = to_i915(crtc->base.dev); |
Jesse Barnes | d240f20 | 2010-08-13 15:43:26 -0700 | [diff] [blame] | 2456 | |
Ville Syrjälä | 64e1077 | 2015-10-29 21:26:01 +0200 | [diff] [blame] | 2457 | assert_pipe_disabled(dev_priv, crtc->pipe); |
| 2458 | assert_dp_port_disabled(intel_dp); |
| 2459 | assert_edp_pll_disabled(dev_priv); |
Daniel Vetter | 2bd2ad6 | 2012-09-06 22:15:41 +0200 | [diff] [blame] | 2460 | |
Ville Syrjälä | abfce94 | 2015-10-29 21:26:03 +0200 | [diff] [blame] | 2461 | DRM_DEBUG_KMS("enabling eDP PLL for clock %d\n", |
Maarten Lankhorst | 85cb48a | 2016-08-09 17:04:13 +0200 | [diff] [blame] | 2462 | pipe_config->port_clock); |
Ville Syrjälä | abfce94 | 2015-10-29 21:26:03 +0200 | [diff] [blame] | 2463 | |
| 2464 | intel_dp->DP &= ~DP_PLL_FREQ_MASK; |
| 2465 | |
Maarten Lankhorst | 85cb48a | 2016-08-09 17:04:13 +0200 | [diff] [blame] | 2466 | if (pipe_config->port_clock == 162000) |
Ville Syrjälä | abfce94 | 2015-10-29 21:26:03 +0200 | [diff] [blame] | 2467 | intel_dp->DP |= DP_PLL_FREQ_162MHZ; |
| 2468 | else |
| 2469 | intel_dp->DP |= DP_PLL_FREQ_270MHZ; |
| 2470 | |
| 2471 | I915_WRITE(DP_A, intel_dp->DP); |
| 2472 | POSTING_READ(DP_A); |
| 2473 | udelay(500); |
| 2474 | |
Ville Syrjälä | 6b23f3e | 2016-04-01 21:53:19 +0300 | [diff] [blame] | 2475 | /* |
| 2476 | * [DevILK] Work around required when enabling DP PLL |
| 2477 | * while a pipe is enabled going to FDI: |
| 2478 | * 1. Wait for the start of vertical blank on the enabled pipe going to FDI |
| 2479 | * 2. Program DP PLL enable |
| 2480 | */ |
| 2481 | if (IS_GEN5(dev_priv)) |
Ville Syrjälä | 0f0f74b | 2016-10-31 22:37:06 +0200 | [diff] [blame] | 2482 | intel_wait_for_vblank_if_active(dev_priv, !crtc->pipe); |
Ville Syrjälä | 6b23f3e | 2016-04-01 21:53:19 +0300 | [diff] [blame] | 2483 | |
Daniel Vetter | 0767935 | 2012-09-06 22:15:42 +0200 | [diff] [blame] | 2484 | intel_dp->DP |= DP_PLL_ENABLE; |
Ville Syrjälä | 6fec766 | 2015-11-10 16:16:17 +0200 | [diff] [blame] | 2485 | |
Daniel Vetter | 0767935 | 2012-09-06 22:15:42 +0200 | [diff] [blame] | 2486 | I915_WRITE(DP_A, intel_dp->DP); |
Jesse Barnes | 298b0b3 | 2010-10-07 16:01:24 -0700 | [diff] [blame] | 2487 | POSTING_READ(DP_A); |
| 2488 | udelay(200); |
Jesse Barnes | d240f20 | 2010-08-13 15:43:26 -0700 | [diff] [blame] | 2489 | } |
| 2490 | |
Ville Syrjälä | adc1030 | 2017-10-31 22:51:14 +0200 | [diff] [blame] | 2491 | static void ironlake_edp_pll_off(struct intel_dp *intel_dp, |
| 2492 | const struct intel_crtc_state *old_crtc_state) |
Jesse Barnes | d240f20 | 2010-08-13 15:43:26 -0700 | [diff] [blame] | 2493 | { |
Ville Syrjälä | adc1030 | 2017-10-31 22:51:14 +0200 | [diff] [blame] | 2494 | struct intel_crtc *crtc = to_intel_crtc(old_crtc_state->base.crtc); |
Ville Syrjälä | 64e1077 | 2015-10-29 21:26:01 +0200 | [diff] [blame] | 2495 | struct drm_i915_private *dev_priv = to_i915(crtc->base.dev); |
Jesse Barnes | d240f20 | 2010-08-13 15:43:26 -0700 | [diff] [blame] | 2496 | |
Ville Syrjälä | 64e1077 | 2015-10-29 21:26:01 +0200 | [diff] [blame] | 2497 | assert_pipe_disabled(dev_priv, crtc->pipe); |
| 2498 | assert_dp_port_disabled(intel_dp); |
| 2499 | assert_edp_pll_enabled(dev_priv); |
Daniel Vetter | 2bd2ad6 | 2012-09-06 22:15:41 +0200 | [diff] [blame] | 2500 | |
Ville Syrjälä | abfce94 | 2015-10-29 21:26:03 +0200 | [diff] [blame] | 2501 | DRM_DEBUG_KMS("disabling eDP PLL\n"); |
| 2502 | |
Ville Syrjälä | 6fec766 | 2015-11-10 16:16:17 +0200 | [diff] [blame] | 2503 | intel_dp->DP &= ~DP_PLL_ENABLE; |
Daniel Vetter | 0767935 | 2012-09-06 22:15:42 +0200 | [diff] [blame] | 2504 | |
Ville Syrjälä | 6fec766 | 2015-11-10 16:16:17 +0200 | [diff] [blame] | 2505 | I915_WRITE(DP_A, intel_dp->DP); |
Chris Wilson | 1af5fa1 | 2010-09-08 21:07:28 +0100 | [diff] [blame] | 2506 | POSTING_READ(DP_A); |
Jesse Barnes | d240f20 | 2010-08-13 15:43:26 -0700 | [diff] [blame] | 2507 | udelay(200); |
| 2508 | } |
| 2509 | |
Ville Syrjälä | 857c416 | 2017-10-27 12:45:23 +0300 | [diff] [blame] | 2510 | static bool downstream_hpd_needs_d0(struct intel_dp *intel_dp) |
| 2511 | { |
| 2512 | /* |
| 2513 | * DPCD 1.2+ should support BRANCH_DEVICE_CTRL, and thus |
| 2514 | * be capable of signalling downstream hpd with a long pulse. |
| 2515 | * Whether or not that means D3 is safe to use is not clear, |
| 2516 | * but let's assume so until proven otherwise. |
| 2517 | * |
| 2518 | * FIXME should really check all downstream ports... |
| 2519 | */ |
| 2520 | return intel_dp->dpcd[DP_DPCD_REV] == 0x11 && |
| 2521 | intel_dp->dpcd[DP_DOWNSTREAMPORT_PRESENT] & DP_DWN_STRM_PORT_PRESENT && |
| 2522 | intel_dp->downstream_ports[0] & DP_DS_PORT_HPD; |
| 2523 | } |
| 2524 | |
Jesse Barnes | c7ad381 | 2011-07-07 11:11:03 -0700 | [diff] [blame] | 2525 | /* If the sink supports it, try to set the power state appropriately */ |
Paulo Zanoni | c19b066 | 2012-10-15 15:51:41 -0300 | [diff] [blame] | 2526 | void intel_dp_sink_dpms(struct intel_dp *intel_dp, int mode) |
Jesse Barnes | c7ad381 | 2011-07-07 11:11:03 -0700 | [diff] [blame] | 2527 | { |
| 2528 | int ret, i; |
| 2529 | |
| 2530 | /* Should have a valid DPCD by this point */ |
| 2531 | if (intel_dp->dpcd[DP_DPCD_REV] < 0x11) |
| 2532 | return; |
| 2533 | |
| 2534 | if (mode != DRM_MODE_DPMS_ON) { |
Ville Syrjälä | 857c416 | 2017-10-27 12:45:23 +0300 | [diff] [blame] | 2535 | if (downstream_hpd_needs_d0(intel_dp)) |
| 2536 | return; |
| 2537 | |
Jani Nikula | 9d1a103 | 2014-03-14 16:51:15 +0200 | [diff] [blame] | 2538 | ret = drm_dp_dpcd_writeb(&intel_dp->aux, DP_SET_POWER, |
| 2539 | DP_SET_POWER_D3); |
Jesse Barnes | c7ad381 | 2011-07-07 11:11:03 -0700 | [diff] [blame] | 2540 | } else { |
Imre Deak | 357c0ae | 2016-11-21 21:15:06 +0200 | [diff] [blame] | 2541 | struct intel_lspcon *lspcon = dp_to_lspcon(intel_dp); |
| 2542 | |
Jesse Barnes | c7ad381 | 2011-07-07 11:11:03 -0700 | [diff] [blame] | 2543 | /* |
| 2544 | * When turning on, we need to retry for 1ms to give the sink |
| 2545 | * time to wake up. |
| 2546 | */ |
| 2547 | for (i = 0; i < 3; i++) { |
Jani Nikula | 9d1a103 | 2014-03-14 16:51:15 +0200 | [diff] [blame] | 2548 | ret = drm_dp_dpcd_writeb(&intel_dp->aux, DP_SET_POWER, |
| 2549 | DP_SET_POWER_D0); |
Jesse Barnes | c7ad381 | 2011-07-07 11:11:03 -0700 | [diff] [blame] | 2550 | if (ret == 1) |
| 2551 | break; |
| 2552 | msleep(1); |
| 2553 | } |
Imre Deak | 357c0ae | 2016-11-21 21:15:06 +0200 | [diff] [blame] | 2554 | |
| 2555 | if (ret == 1 && lspcon->active) |
| 2556 | lspcon_wait_pcon_mode(lspcon); |
Jesse Barnes | c7ad381 | 2011-07-07 11:11:03 -0700 | [diff] [blame] | 2557 | } |
Jani Nikula | f9cac72 | 2014-09-02 16:33:52 +0300 | [diff] [blame] | 2558 | |
| 2559 | if (ret != 1) |
| 2560 | DRM_DEBUG_KMS("failed to %s sink power state\n", |
| 2561 | mode == DRM_MODE_DPMS_ON ? "enable" : "disable"); |
Jesse Barnes | c7ad381 | 2011-07-07 11:11:03 -0700 | [diff] [blame] | 2562 | } |
| 2563 | |
Daniel Vetter | 19d8fe1 | 2012-07-02 13:26:27 +0200 | [diff] [blame] | 2564 | static bool intel_dp_get_hw_state(struct intel_encoder *encoder, |
| 2565 | enum pipe *pipe) |
Jesse Barnes | d240f20 | 2010-08-13 15:43:26 -0700 | [diff] [blame] | 2566 | { |
Ville Syrjälä | 2f77347 | 2017-11-09 17:27:58 +0200 | [diff] [blame] | 2567 | struct drm_i915_private *dev_priv = to_i915(encoder->base.dev); |
Daniel Vetter | 19d8fe1 | 2012-07-02 13:26:27 +0200 | [diff] [blame] | 2568 | struct intel_dp *intel_dp = enc_to_intel_dp(&encoder->base); |
Ville Syrjälä | 8f4f279 | 2017-11-09 17:24:34 +0200 | [diff] [blame] | 2569 | enum port port = encoder->port; |
Imre Deak | 6d129be | 2014-03-05 16:20:54 +0200 | [diff] [blame] | 2570 | u32 tmp; |
Imre Deak | 6fa9a5e | 2016-02-12 18:55:18 +0200 | [diff] [blame] | 2571 | bool ret; |
Imre Deak | 6d129be | 2014-03-05 16:20:54 +0200 | [diff] [blame] | 2572 | |
Ander Conselvan de Oliveira | 79f255a | 2017-02-22 08:34:27 +0200 | [diff] [blame] | 2573 | if (!intel_display_power_get_if_enabled(dev_priv, |
| 2574 | encoder->power_domain)) |
Imre Deak | 6d129be | 2014-03-05 16:20:54 +0200 | [diff] [blame] | 2575 | return false; |
| 2576 | |
Imre Deak | 6fa9a5e | 2016-02-12 18:55:18 +0200 | [diff] [blame] | 2577 | ret = false; |
| 2578 | |
Imre Deak | 6d129be | 2014-03-05 16:20:54 +0200 | [diff] [blame] | 2579 | tmp = I915_READ(intel_dp->output_reg); |
Jesse Barnes | d240f20 | 2010-08-13 15:43:26 -0700 | [diff] [blame] | 2580 | |
Daniel Vetter | 19d8fe1 | 2012-07-02 13:26:27 +0200 | [diff] [blame] | 2581 | if (!(tmp & DP_PORT_EN)) |
Imre Deak | 6fa9a5e | 2016-02-12 18:55:18 +0200 | [diff] [blame] | 2582 | goto out; |
Daniel Vetter | 19d8fe1 | 2012-07-02 13:26:27 +0200 | [diff] [blame] | 2583 | |
Tvrtko Ursulin | 5db9401 | 2016-10-13 11:03:10 +0100 | [diff] [blame] | 2584 | if (IS_GEN7(dev_priv) && port == PORT_A) { |
Daniel Vetter | 19d8fe1 | 2012-07-02 13:26:27 +0200 | [diff] [blame] | 2585 | *pipe = PORT_TO_PIPE_CPT(tmp); |
Tvrtko Ursulin | 6e26695 | 2016-10-13 11:02:53 +0100 | [diff] [blame] | 2586 | } else if (HAS_PCH_CPT(dev_priv) && port != PORT_A) { |
Ville Syrjälä | adc289d | 2015-05-05 17:17:30 +0300 | [diff] [blame] | 2587 | enum pipe p; |
Daniel Vetter | 19d8fe1 | 2012-07-02 13:26:27 +0200 | [diff] [blame] | 2588 | |
Ville Syrjälä | adc289d | 2015-05-05 17:17:30 +0300 | [diff] [blame] | 2589 | for_each_pipe(dev_priv, p) { |
| 2590 | u32 trans_dp = I915_READ(TRANS_DP_CTL(p)); |
| 2591 | if (TRANS_DP_PIPE_TO_PORT(trans_dp) == port) { |
| 2592 | *pipe = p; |
Imre Deak | 6fa9a5e | 2016-02-12 18:55:18 +0200 | [diff] [blame] | 2593 | ret = true; |
| 2594 | |
| 2595 | goto out; |
Daniel Vetter | 19d8fe1 | 2012-07-02 13:26:27 +0200 | [diff] [blame] | 2596 | } |
| 2597 | } |
Daniel Vetter | 19d8fe1 | 2012-07-02 13:26:27 +0200 | [diff] [blame] | 2598 | |
Daniel Vetter | 4a0833e | 2012-10-26 10:58:11 +0200 | [diff] [blame] | 2599 | DRM_DEBUG_KMS("No pipe for dp port 0x%x found\n", |
Ville Syrjälä | f0f59a0 | 2015-11-18 15:33:26 +0200 | [diff] [blame] | 2600 | i915_mmio_reg_offset(intel_dp->output_reg)); |
Tvrtko Ursulin | 920a14b | 2016-10-14 10:13:44 +0100 | [diff] [blame] | 2601 | } else if (IS_CHERRYVIEW(dev_priv)) { |
Ville Syrjälä | 39e5fa8 | 2015-05-05 17:17:29 +0300 | [diff] [blame] | 2602 | *pipe = DP_PORT_TO_PIPE_CHV(tmp); |
| 2603 | } else { |
| 2604 | *pipe = PORT_TO_PIPE(tmp); |
Daniel Vetter | 4a0833e | 2012-10-26 10:58:11 +0200 | [diff] [blame] | 2605 | } |
Daniel Vetter | 19d8fe1 | 2012-07-02 13:26:27 +0200 | [diff] [blame] | 2606 | |
Imre Deak | 6fa9a5e | 2016-02-12 18:55:18 +0200 | [diff] [blame] | 2607 | ret = true; |
| 2608 | |
| 2609 | out: |
Ander Conselvan de Oliveira | 79f255a | 2017-02-22 08:34:27 +0200 | [diff] [blame] | 2610 | intel_display_power_put(dev_priv, encoder->power_domain); |
Imre Deak | 6fa9a5e | 2016-02-12 18:55:18 +0200 | [diff] [blame] | 2611 | |
| 2612 | return ret; |
Daniel Vetter | 19d8fe1 | 2012-07-02 13:26:27 +0200 | [diff] [blame] | 2613 | } |
| 2614 | |
Jesse Barnes | 045ac3b | 2013-05-14 17:08:26 -0700 | [diff] [blame] | 2615 | static void intel_dp_get_config(struct intel_encoder *encoder, |
Ander Conselvan de Oliveira | 5cec258 | 2015-01-15 14:55:21 +0200 | [diff] [blame] | 2616 | struct intel_crtc_state *pipe_config) |
Jesse Barnes | 045ac3b | 2013-05-14 17:08:26 -0700 | [diff] [blame] | 2617 | { |
Ville Syrjälä | 2f77347 | 2017-11-09 17:27:58 +0200 | [diff] [blame] | 2618 | struct drm_i915_private *dev_priv = to_i915(encoder->base.dev); |
Jesse Barnes | 045ac3b | 2013-05-14 17:08:26 -0700 | [diff] [blame] | 2619 | struct intel_dp *intel_dp = enc_to_intel_dp(&encoder->base); |
Jesse Barnes | 045ac3b | 2013-05-14 17:08:26 -0700 | [diff] [blame] | 2620 | u32 tmp, flags = 0; |
Ville Syrjälä | 8f4f279 | 2017-11-09 17:24:34 +0200 | [diff] [blame] | 2621 | enum port port = encoder->port; |
Ville Syrjälä | adc1030 | 2017-10-31 22:51:14 +0200 | [diff] [blame] | 2622 | struct intel_crtc *crtc = to_intel_crtc(pipe_config->base.crtc); |
Jesse Barnes | 045ac3b | 2013-05-14 17:08:26 -0700 | [diff] [blame] | 2623 | |
Ville Syrjälä | e1214b9 | 2017-10-27 22:31:23 +0300 | [diff] [blame] | 2624 | if (encoder->type == INTEL_OUTPUT_EDP) |
| 2625 | pipe_config->output_types |= BIT(INTEL_OUTPUT_EDP); |
| 2626 | else |
| 2627 | pipe_config->output_types |= BIT(INTEL_OUTPUT_DP); |
Jesse Barnes | 045ac3b | 2013-05-14 17:08:26 -0700 | [diff] [blame] | 2628 | |
Daniel Vetter | 9ed109a | 2014-04-24 23:54:52 +0200 | [diff] [blame] | 2629 | tmp = I915_READ(intel_dp->output_reg); |
Jani Nikula | 9fcb170 | 2015-05-05 16:32:12 +0300 | [diff] [blame] | 2630 | |
| 2631 | pipe_config->has_audio = tmp & DP_AUDIO_OUTPUT_ENABLE && port != PORT_A; |
Daniel Vetter | 9ed109a | 2014-04-24 23:54:52 +0200 | [diff] [blame] | 2632 | |
Tvrtko Ursulin | 6e26695 | 2016-10-13 11:02:53 +0100 | [diff] [blame] | 2633 | if (HAS_PCH_CPT(dev_priv) && port != PORT_A) { |
Ville Syrjälä | b81e34c | 2015-07-06 15:10:03 +0300 | [diff] [blame] | 2634 | u32 trans_dp = I915_READ(TRANS_DP_CTL(crtc->pipe)); |
| 2635 | |
| 2636 | if (trans_dp & TRANS_DP_HSYNC_ACTIVE_HIGH) |
Xiong Zhang | 63000ef | 2013-06-28 12:59:06 +0800 | [diff] [blame] | 2637 | flags |= DRM_MODE_FLAG_PHSYNC; |
| 2638 | else |
| 2639 | flags |= DRM_MODE_FLAG_NHSYNC; |
Jesse Barnes | 045ac3b | 2013-05-14 17:08:26 -0700 | [diff] [blame] | 2640 | |
Ville Syrjälä | b81e34c | 2015-07-06 15:10:03 +0300 | [diff] [blame] | 2641 | if (trans_dp & TRANS_DP_VSYNC_ACTIVE_HIGH) |
Xiong Zhang | 63000ef | 2013-06-28 12:59:06 +0800 | [diff] [blame] | 2642 | flags |= DRM_MODE_FLAG_PVSYNC; |
| 2643 | else |
| 2644 | flags |= DRM_MODE_FLAG_NVSYNC; |
Ville Syrjälä | 39e5fa8 | 2015-05-05 17:17:29 +0300 | [diff] [blame] | 2645 | } else { |
| 2646 | if (tmp & DP_SYNC_HS_HIGH) |
| 2647 | flags |= DRM_MODE_FLAG_PHSYNC; |
| 2648 | else |
| 2649 | flags |= DRM_MODE_FLAG_NHSYNC; |
| 2650 | |
| 2651 | if (tmp & DP_SYNC_VS_HIGH) |
| 2652 | flags |= DRM_MODE_FLAG_PVSYNC; |
| 2653 | else |
| 2654 | flags |= DRM_MODE_FLAG_NVSYNC; |
Xiong Zhang | 63000ef | 2013-06-28 12:59:06 +0800 | [diff] [blame] | 2655 | } |
Jesse Barnes | 045ac3b | 2013-05-14 17:08:26 -0700 | [diff] [blame] | 2656 | |
Ander Conselvan de Oliveira | 2d112de | 2015-01-15 14:55:22 +0200 | [diff] [blame] | 2657 | pipe_config->base.adjusted_mode.flags |= flags; |
Jesse Barnes | f1f644d | 2013-06-27 00:39:25 +0300 | [diff] [blame] | 2658 | |
Ville Syrjälä | c99f53f | 2016-11-14 19:44:07 +0200 | [diff] [blame] | 2659 | if (IS_G4X(dev_priv) && tmp & DP_COLOR_RANGE_16_235) |
Ville Syrjälä | 8c875fc | 2014-09-12 15:46:29 +0300 | [diff] [blame] | 2660 | pipe_config->limited_color_range = true; |
| 2661 | |
Ville Syrjälä | 90a6b7b | 2015-07-06 16:39:15 +0300 | [diff] [blame] | 2662 | pipe_config->lane_count = |
| 2663 | ((tmp & DP_PORT_WIDTH_MASK) >> DP_PORT_WIDTH_SHIFT) + 1; |
| 2664 | |
Ville Syrjälä | eb14cb7 | 2013-09-10 17:02:54 +0300 | [diff] [blame] | 2665 | intel_dp_get_m_n(crtc, pipe_config); |
| 2666 | |
Ville Syrjälä | 18442d0 | 2013-09-13 16:00:08 +0300 | [diff] [blame] | 2667 | if (port == PORT_A) { |
Ville Syrjälä | b377e0d | 2015-10-29 21:25:59 +0200 | [diff] [blame] | 2668 | if ((I915_READ(DP_A) & DP_PLL_FREQ_MASK) == DP_PLL_FREQ_162MHZ) |
Jesse Barnes | f1f644d | 2013-06-27 00:39:25 +0300 | [diff] [blame] | 2669 | pipe_config->port_clock = 162000; |
| 2670 | else |
| 2671 | pipe_config->port_clock = 270000; |
| 2672 | } |
Ville Syrjälä | 18442d0 | 2013-09-13 16:00:08 +0300 | [diff] [blame] | 2673 | |
Ville Syrjälä | e3b247d | 2016-02-17 21:41:09 +0200 | [diff] [blame] | 2674 | pipe_config->base.adjusted_mode.crtc_clock = |
| 2675 | intel_dotclock_calculate(pipe_config->port_clock, |
| 2676 | &pipe_config->dp_m_n); |
Daniel Vetter | 7f16e5c | 2013-11-04 16:28:47 +0100 | [diff] [blame] | 2677 | |
Jani Nikula | 1853a9d | 2017-08-18 12:30:20 +0300 | [diff] [blame] | 2678 | if (intel_dp_is_edp(intel_dp) && dev_priv->vbt.edp.bpp && |
Jani Nikula | 6aa23e6 | 2016-03-24 17:50:20 +0200 | [diff] [blame] | 2679 | pipe_config->pipe_bpp > dev_priv->vbt.edp.bpp) { |
Jani Nikula | c6cd2ee | 2013-10-21 10:52:07 +0300 | [diff] [blame] | 2680 | /* |
| 2681 | * This is a big fat ugly hack. |
| 2682 | * |
| 2683 | * Some machines in UEFI boot mode provide us a VBT that has 18 |
| 2684 | * bpp and 1.62 GHz link bandwidth for eDP, which for reasons |
| 2685 | * unknown we fail to light up. Yet the same BIOS boots up with |
| 2686 | * 24 bpp and 2.7 GHz link. Use the same bpp as the BIOS uses as |
| 2687 | * max, not what it tells us to use. |
| 2688 | * |
| 2689 | * Note: This will still be broken if the eDP panel is not lit |
| 2690 | * up by the BIOS, and thus we can't get the mode at module |
| 2691 | * load. |
| 2692 | */ |
| 2693 | DRM_DEBUG_KMS("pipe has %d bpp for eDP panel, overriding BIOS-provided max %d bpp\n", |
Jani Nikula | 6aa23e6 | 2016-03-24 17:50:20 +0200 | [diff] [blame] | 2694 | pipe_config->pipe_bpp, dev_priv->vbt.edp.bpp); |
| 2695 | dev_priv->vbt.edp.bpp = pipe_config->pipe_bpp; |
Jani Nikula | c6cd2ee | 2013-10-21 10:52:07 +0300 | [diff] [blame] | 2696 | } |
Jesse Barnes | 045ac3b | 2013-05-14 17:08:26 -0700 | [diff] [blame] | 2697 | } |
| 2698 | |
Maarten Lankhorst | fd6bbda | 2016-08-09 17:04:04 +0200 | [diff] [blame] | 2699 | static void intel_disable_dp(struct intel_encoder *encoder, |
Ville Syrjälä | 5f88a9c | 2017-08-18 16:49:58 +0300 | [diff] [blame] | 2700 | const struct intel_crtc_state *old_crtc_state, |
| 2701 | const struct drm_connector_state *old_conn_state) |
Jesse Barnes | d240f20 | 2010-08-13 15:43:26 -0700 | [diff] [blame] | 2702 | { |
Daniel Vetter | e8cb455 | 2012-07-01 13:05:48 +0200 | [diff] [blame] | 2703 | struct intel_dp *intel_dp = enc_to_intel_dp(&encoder->base); |
Jani Nikula | 495a5bb | 2014-10-27 16:26:55 +0200 | [diff] [blame] | 2704 | |
Maarten Lankhorst | 85cb48a | 2016-08-09 17:04:13 +0200 | [diff] [blame] | 2705 | if (old_crtc_state->has_audio) |
Ville Syrjälä | 8ec47de | 2017-10-30 20:46:53 +0200 | [diff] [blame] | 2706 | intel_audio_codec_disable(encoder, |
| 2707 | old_crtc_state, old_conn_state); |
Daniel Vetter | 6cb4983 | 2012-05-20 17:14:50 +0200 | [diff] [blame] | 2708 | |
| 2709 | /* Make sure the panel is off before trying to change the mode. But also |
| 2710 | * ensure that we have vdd while we switch off the panel. */ |
Jani Nikula | 24f3e09 | 2014-03-17 16:43:36 +0200 | [diff] [blame] | 2711 | intel_edp_panel_vdd_on(intel_dp); |
Maarten Lankhorst | b037d58 | 2017-06-12 12:21:13 +0200 | [diff] [blame] | 2712 | intel_edp_backlight_off(old_conn_state); |
Jani Nikula | fdbc3b1 | 2013-11-12 17:10:13 +0200 | [diff] [blame] | 2713 | intel_dp_sink_dpms(intel_dp, DRM_MODE_DPMS_OFF); |
Daniel Vetter | 4be7378 | 2014-01-17 14:39:48 +0100 | [diff] [blame] | 2714 | intel_edp_panel_off(intel_dp); |
Ville Syrjälä | 1a8ff60 | 2017-09-20 18:12:51 +0300 | [diff] [blame] | 2715 | } |
| 2716 | |
| 2717 | static void g4x_disable_dp(struct intel_encoder *encoder, |
| 2718 | const struct intel_crtc_state *old_crtc_state, |
| 2719 | const struct drm_connector_state *old_conn_state) |
| 2720 | { |
Ville Syrjälä | 1a8ff60 | 2017-09-20 18:12:51 +0300 | [diff] [blame] | 2721 | intel_disable_dp(encoder, old_crtc_state, old_conn_state); |
Daniel Vetter | 3739850 | 2012-09-06 22:15:44 +0200 | [diff] [blame] | 2722 | |
Ville Syrjälä | 08aff3f | 2014-08-18 22:16:09 +0300 | [diff] [blame] | 2723 | /* disable the port before the pipe on g4x */ |
Ville Syrjälä | adc1030 | 2017-10-31 22:51:14 +0200 | [diff] [blame] | 2724 | intel_dp_link_down(encoder, old_crtc_state); |
Ville Syrjälä | 1a8ff60 | 2017-09-20 18:12:51 +0300 | [diff] [blame] | 2725 | } |
| 2726 | |
| 2727 | static void ilk_disable_dp(struct intel_encoder *encoder, |
| 2728 | const struct intel_crtc_state *old_crtc_state, |
| 2729 | const struct drm_connector_state *old_conn_state) |
| 2730 | { |
| 2731 | intel_disable_dp(encoder, old_crtc_state, old_conn_state); |
| 2732 | } |
| 2733 | |
| 2734 | static void vlv_disable_dp(struct intel_encoder *encoder, |
| 2735 | const struct intel_crtc_state *old_crtc_state, |
| 2736 | const struct drm_connector_state *old_conn_state) |
| 2737 | { |
| 2738 | struct intel_dp *intel_dp = enc_to_intel_dp(&encoder->base); |
| 2739 | |
| 2740 | intel_psr_disable(intel_dp, old_crtc_state); |
| 2741 | |
| 2742 | intel_disable_dp(encoder, old_crtc_state, old_conn_state); |
Jesse Barnes | d240f20 | 2010-08-13 15:43:26 -0700 | [diff] [blame] | 2743 | } |
| 2744 | |
Maarten Lankhorst | fd6bbda | 2016-08-09 17:04:04 +0200 | [diff] [blame] | 2745 | static void ilk_post_disable_dp(struct intel_encoder *encoder, |
Ville Syrjälä | 5f88a9c | 2017-08-18 16:49:58 +0300 | [diff] [blame] | 2746 | const struct intel_crtc_state *old_crtc_state, |
| 2747 | const struct drm_connector_state *old_conn_state) |
Jesse Barnes | d240f20 | 2010-08-13 15:43:26 -0700 | [diff] [blame] | 2748 | { |
Daniel Vetter | 2bd2ad6 | 2012-09-06 22:15:41 +0200 | [diff] [blame] | 2749 | struct intel_dp *intel_dp = enc_to_intel_dp(&encoder->base); |
Ville Syrjälä | adc1030 | 2017-10-31 22:51:14 +0200 | [diff] [blame] | 2750 | enum port port = encoder->port; |
Daniel Vetter | 2bd2ad6 | 2012-09-06 22:15:41 +0200 | [diff] [blame] | 2751 | |
Ville Syrjälä | adc1030 | 2017-10-31 22:51:14 +0200 | [diff] [blame] | 2752 | intel_dp_link_down(encoder, old_crtc_state); |
Ville Syrjälä | abfce94 | 2015-10-29 21:26:03 +0200 | [diff] [blame] | 2753 | |
| 2754 | /* Only ilk+ has port A */ |
Ville Syrjälä | 08aff3f | 2014-08-18 22:16:09 +0300 | [diff] [blame] | 2755 | if (port == PORT_A) |
Ville Syrjälä | adc1030 | 2017-10-31 22:51:14 +0200 | [diff] [blame] | 2756 | ironlake_edp_pll_off(intel_dp, old_crtc_state); |
Ville Syrjälä | 49277c3 | 2014-03-31 18:21:26 +0300 | [diff] [blame] | 2757 | } |
| 2758 | |
Maarten Lankhorst | fd6bbda | 2016-08-09 17:04:04 +0200 | [diff] [blame] | 2759 | static void vlv_post_disable_dp(struct intel_encoder *encoder, |
Ville Syrjälä | 5f88a9c | 2017-08-18 16:49:58 +0300 | [diff] [blame] | 2760 | const struct intel_crtc_state *old_crtc_state, |
| 2761 | const struct drm_connector_state *old_conn_state) |
Ville Syrjälä | 49277c3 | 2014-03-31 18:21:26 +0300 | [diff] [blame] | 2762 | { |
Ville Syrjälä | adc1030 | 2017-10-31 22:51:14 +0200 | [diff] [blame] | 2763 | intel_dp_link_down(encoder, old_crtc_state); |
Daniel Vetter | 2bd2ad6 | 2012-09-06 22:15:41 +0200 | [diff] [blame] | 2764 | } |
| 2765 | |
Maarten Lankhorst | fd6bbda | 2016-08-09 17:04:04 +0200 | [diff] [blame] | 2766 | static void chv_post_disable_dp(struct intel_encoder *encoder, |
Ville Syrjälä | 5f88a9c | 2017-08-18 16:49:58 +0300 | [diff] [blame] | 2767 | const struct intel_crtc_state *old_crtc_state, |
| 2768 | const struct drm_connector_state *old_conn_state) |
Ville Syrjälä | 580d381 | 2014-04-09 13:29:00 +0300 | [diff] [blame] | 2769 | { |
Ville Syrjälä | adc1030 | 2017-10-31 22:51:14 +0200 | [diff] [blame] | 2770 | struct drm_i915_private *dev_priv = to_i915(encoder->base.dev); |
Ville Syrjälä | 580d381 | 2014-04-09 13:29:00 +0300 | [diff] [blame] | 2771 | |
Ville Syrjälä | adc1030 | 2017-10-31 22:51:14 +0200 | [diff] [blame] | 2772 | intel_dp_link_down(encoder, old_crtc_state); |
Ville Syrjälä | 580d381 | 2014-04-09 13:29:00 +0300 | [diff] [blame] | 2773 | |
Ville Syrjälä | a580516 | 2015-05-26 20:42:30 +0300 | [diff] [blame] | 2774 | mutex_lock(&dev_priv->sb_lock); |
Ville Syrjälä | 580d381 | 2014-04-09 13:29:00 +0300 | [diff] [blame] | 2775 | |
Ville Syrjälä | a8f327f | 2015-07-09 20:14:11 +0300 | [diff] [blame] | 2776 | /* Assert data lane reset */ |
Ville Syrjälä | 2e1029c | 2017-10-31 22:51:18 +0200 | [diff] [blame] | 2777 | chv_data_lane_soft_reset(encoder, old_crtc_state, true); |
Ville Syrjälä | 580d381 | 2014-04-09 13:29:00 +0300 | [diff] [blame] | 2778 | |
Ville Syrjälä | a580516 | 2015-05-26 20:42:30 +0300 | [diff] [blame] | 2779 | mutex_unlock(&dev_priv->sb_lock); |
Ville Syrjälä | 580d381 | 2014-04-09 13:29:00 +0300 | [diff] [blame] | 2780 | } |
| 2781 | |
Ville Syrjälä | 7b13b58 | 2014-08-18 22:16:08 +0300 | [diff] [blame] | 2782 | static void |
| 2783 | _intel_dp_set_link_train(struct intel_dp *intel_dp, |
| 2784 | uint32_t *DP, |
| 2785 | uint8_t dp_train_pat) |
| 2786 | { |
Ville Syrjälä | 2f77347 | 2017-11-09 17:27:58 +0200 | [diff] [blame] | 2787 | struct drm_i915_private *dev_priv = to_i915(intel_dp_to_dev(intel_dp)); |
Ville Syrjälä | 7b13b58 | 2014-08-18 22:16:08 +0300 | [diff] [blame] | 2788 | struct intel_digital_port *intel_dig_port = dp_to_dig_port(intel_dp); |
Ville Syrjälä | 8f4f279 | 2017-11-09 17:24:34 +0200 | [diff] [blame] | 2789 | enum port port = intel_dig_port->base.port; |
Ville Syrjälä | 7b13b58 | 2014-08-18 22:16:08 +0300 | [diff] [blame] | 2790 | |
Pandiyan, Dhinakaran | 8b0878a | 2016-08-04 13:48:35 -0700 | [diff] [blame] | 2791 | if (dp_train_pat & DP_TRAINING_PATTERN_MASK) |
| 2792 | DRM_DEBUG_KMS("Using DP training pattern TPS%d\n", |
| 2793 | dp_train_pat & DP_TRAINING_PATTERN_MASK); |
| 2794 | |
Tvrtko Ursulin | 4f8036a | 2016-10-13 11:02:52 +0100 | [diff] [blame] | 2795 | if (HAS_DDI(dev_priv)) { |
Ville Syrjälä | 7b13b58 | 2014-08-18 22:16:08 +0300 | [diff] [blame] | 2796 | uint32_t temp = I915_READ(DP_TP_CTL(port)); |
| 2797 | |
| 2798 | if (dp_train_pat & DP_LINK_SCRAMBLING_DISABLE) |
| 2799 | temp |= DP_TP_CTL_SCRAMBLE_DISABLE; |
| 2800 | else |
| 2801 | temp &= ~DP_TP_CTL_SCRAMBLE_DISABLE; |
| 2802 | |
| 2803 | temp &= ~DP_TP_CTL_LINK_TRAIN_MASK; |
| 2804 | switch (dp_train_pat & DP_TRAINING_PATTERN_MASK) { |
| 2805 | case DP_TRAINING_PATTERN_DISABLE: |
| 2806 | temp |= DP_TP_CTL_LINK_TRAIN_NORMAL; |
| 2807 | |
| 2808 | break; |
| 2809 | case DP_TRAINING_PATTERN_1: |
| 2810 | temp |= DP_TP_CTL_LINK_TRAIN_PAT1; |
| 2811 | break; |
| 2812 | case DP_TRAINING_PATTERN_2: |
| 2813 | temp |= DP_TP_CTL_LINK_TRAIN_PAT2; |
| 2814 | break; |
| 2815 | case DP_TRAINING_PATTERN_3: |
| 2816 | temp |= DP_TP_CTL_LINK_TRAIN_PAT3; |
| 2817 | break; |
| 2818 | } |
| 2819 | I915_WRITE(DP_TP_CTL(port), temp); |
| 2820 | |
Tvrtko Ursulin | 5db9401 | 2016-10-13 11:03:10 +0100 | [diff] [blame] | 2821 | } else if ((IS_GEN7(dev_priv) && port == PORT_A) || |
Tvrtko Ursulin | 6e26695 | 2016-10-13 11:02:53 +0100 | [diff] [blame] | 2822 | (HAS_PCH_CPT(dev_priv) && port != PORT_A)) { |
Ville Syrjälä | 7b13b58 | 2014-08-18 22:16:08 +0300 | [diff] [blame] | 2823 | *DP &= ~DP_LINK_TRAIN_MASK_CPT; |
| 2824 | |
| 2825 | switch (dp_train_pat & DP_TRAINING_PATTERN_MASK) { |
| 2826 | case DP_TRAINING_PATTERN_DISABLE: |
| 2827 | *DP |= DP_LINK_TRAIN_OFF_CPT; |
| 2828 | break; |
| 2829 | case DP_TRAINING_PATTERN_1: |
| 2830 | *DP |= DP_LINK_TRAIN_PAT_1_CPT; |
| 2831 | break; |
| 2832 | case DP_TRAINING_PATTERN_2: |
| 2833 | *DP |= DP_LINK_TRAIN_PAT_2_CPT; |
| 2834 | break; |
| 2835 | case DP_TRAINING_PATTERN_3: |
Pandiyan, Dhinakaran | 8b0878a | 2016-08-04 13:48:35 -0700 | [diff] [blame] | 2836 | DRM_DEBUG_KMS("TPS3 not supported, using TPS2 instead\n"); |
Ville Syrjälä | 7b13b58 | 2014-08-18 22:16:08 +0300 | [diff] [blame] | 2837 | *DP |= DP_LINK_TRAIN_PAT_2_CPT; |
| 2838 | break; |
| 2839 | } |
| 2840 | |
| 2841 | } else { |
Tvrtko Ursulin | 920a14b | 2016-10-14 10:13:44 +0100 | [diff] [blame] | 2842 | if (IS_CHERRYVIEW(dev_priv)) |
Ville Syrjälä | 7b13b58 | 2014-08-18 22:16:08 +0300 | [diff] [blame] | 2843 | *DP &= ~DP_LINK_TRAIN_MASK_CHV; |
| 2844 | else |
| 2845 | *DP &= ~DP_LINK_TRAIN_MASK; |
| 2846 | |
| 2847 | switch (dp_train_pat & DP_TRAINING_PATTERN_MASK) { |
| 2848 | case DP_TRAINING_PATTERN_DISABLE: |
| 2849 | *DP |= DP_LINK_TRAIN_OFF; |
| 2850 | break; |
| 2851 | case DP_TRAINING_PATTERN_1: |
| 2852 | *DP |= DP_LINK_TRAIN_PAT_1; |
| 2853 | break; |
| 2854 | case DP_TRAINING_PATTERN_2: |
| 2855 | *DP |= DP_LINK_TRAIN_PAT_2; |
| 2856 | break; |
| 2857 | case DP_TRAINING_PATTERN_3: |
Tvrtko Ursulin | 920a14b | 2016-10-14 10:13:44 +0100 | [diff] [blame] | 2858 | if (IS_CHERRYVIEW(dev_priv)) { |
Ville Syrjälä | 7b13b58 | 2014-08-18 22:16:08 +0300 | [diff] [blame] | 2859 | *DP |= DP_LINK_TRAIN_PAT_3_CHV; |
| 2860 | } else { |
Pandiyan, Dhinakaran | 8b0878a | 2016-08-04 13:48:35 -0700 | [diff] [blame] | 2861 | DRM_DEBUG_KMS("TPS3 not supported, using TPS2 instead\n"); |
Ville Syrjälä | 7b13b58 | 2014-08-18 22:16:08 +0300 | [diff] [blame] | 2862 | *DP |= DP_LINK_TRAIN_PAT_2; |
| 2863 | } |
| 2864 | break; |
| 2865 | } |
| 2866 | } |
| 2867 | } |
| 2868 | |
Maarten Lankhorst | 85cb48a | 2016-08-09 17:04:13 +0200 | [diff] [blame] | 2869 | static void intel_dp_enable_port(struct intel_dp *intel_dp, |
Ville Syrjälä | 5f88a9c | 2017-08-18 16:49:58 +0300 | [diff] [blame] | 2870 | const struct intel_crtc_state *old_crtc_state) |
Ville Syrjälä | 7b13b58 | 2014-08-18 22:16:08 +0300 | [diff] [blame] | 2871 | { |
Ville Syrjälä | 2f77347 | 2017-11-09 17:27:58 +0200 | [diff] [blame] | 2872 | struct drm_i915_private *dev_priv = to_i915(intel_dp_to_dev(intel_dp)); |
Ville Syrjälä | 7b13b58 | 2014-08-18 22:16:08 +0300 | [diff] [blame] | 2873 | |
Ville Syrjälä | 7b13b58 | 2014-08-18 22:16:08 +0300 | [diff] [blame] | 2874 | /* enable with pattern 1 (as per spec) */ |
Ville Syrjälä | 7b13b58 | 2014-08-18 22:16:08 +0300 | [diff] [blame] | 2875 | |
Pandiyan, Dhinakaran | 8b0878a | 2016-08-04 13:48:35 -0700 | [diff] [blame] | 2876 | intel_dp_program_link_training_pattern(intel_dp, DP_TRAINING_PATTERN_1); |
Ville Syrjälä | 7b713f5 | 2014-10-16 21:27:35 +0300 | [diff] [blame] | 2877 | |
| 2878 | /* |
| 2879 | * Magic for VLV/CHV. We _must_ first set up the register |
| 2880 | * without actually enabling the port, and then do another |
| 2881 | * write to enable the port. Otherwise link training will |
| 2882 | * fail when the power sequencer is freshly used for this port. |
| 2883 | */ |
| 2884 | intel_dp->DP |= DP_PORT_EN; |
Maarten Lankhorst | 85cb48a | 2016-08-09 17:04:13 +0200 | [diff] [blame] | 2885 | if (old_crtc_state->has_audio) |
Ville Syrjälä | 6fec766 | 2015-11-10 16:16:17 +0200 | [diff] [blame] | 2886 | intel_dp->DP |= DP_AUDIO_OUTPUT_ENABLE; |
Ville Syrjälä | 7b713f5 | 2014-10-16 21:27:35 +0300 | [diff] [blame] | 2887 | |
| 2888 | I915_WRITE(intel_dp->output_reg, intel_dp->DP); |
| 2889 | POSTING_READ(intel_dp->output_reg); |
Ville Syrjälä | 7b13b58 | 2014-08-18 22:16:08 +0300 | [diff] [blame] | 2890 | } |
| 2891 | |
Maarten Lankhorst | 85cb48a | 2016-08-09 17:04:13 +0200 | [diff] [blame] | 2892 | static void intel_enable_dp(struct intel_encoder *encoder, |
Ville Syrjälä | 5f88a9c | 2017-08-18 16:49:58 +0300 | [diff] [blame] | 2893 | const struct intel_crtc_state *pipe_config, |
| 2894 | const struct drm_connector_state *conn_state) |
Jesse Barnes | d240f20 | 2010-08-13 15:43:26 -0700 | [diff] [blame] | 2895 | { |
Ville Syrjälä | 2f77347 | 2017-11-09 17:27:58 +0200 | [diff] [blame] | 2896 | struct drm_i915_private *dev_priv = to_i915(encoder->base.dev); |
Daniel Vetter | e8cb455 | 2012-07-01 13:05:48 +0200 | [diff] [blame] | 2897 | struct intel_dp *intel_dp = enc_to_intel_dp(&encoder->base); |
Ville Syrjälä | adc1030 | 2017-10-31 22:51:14 +0200 | [diff] [blame] | 2898 | struct intel_crtc *crtc = to_intel_crtc(pipe_config->base.crtc); |
Chris Wilson | ea5b213 | 2010-08-04 13:50:23 +0100 | [diff] [blame] | 2899 | uint32_t dp_reg = I915_READ(intel_dp->output_reg); |
Ville Syrjälä | d6fbdd1 | 2015-10-29 21:25:58 +0200 | [diff] [blame] | 2900 | enum pipe pipe = crtc->pipe; |
Keith Packard | a4fc5ed | 2009-04-07 16:16:42 -0700 | [diff] [blame] | 2901 | |
Daniel Vetter | 0c33d8d | 2012-09-06 22:15:43 +0200 | [diff] [blame] | 2902 | if (WARN_ON(dp_reg & DP_PORT_EN)) |
| 2903 | return; |
Keith Packard | a4fc5ed | 2009-04-07 16:16:42 -0700 | [diff] [blame] | 2904 | |
Ville Syrjälä | 093e3f1 | 2014-10-16 21:27:33 +0300 | [diff] [blame] | 2905 | pps_lock(intel_dp); |
| 2906 | |
Tvrtko Ursulin | 920a14b | 2016-10-14 10:13:44 +0100 | [diff] [blame] | 2907 | if (IS_VALLEYVIEW(dev_priv) || IS_CHERRYVIEW(dev_priv)) |
Ville Syrjälä | adc1030 | 2017-10-31 22:51:14 +0200 | [diff] [blame] | 2908 | vlv_init_panel_power_sequencer(encoder, pipe_config); |
Ville Syrjälä | 093e3f1 | 2014-10-16 21:27:33 +0300 | [diff] [blame] | 2909 | |
Maarten Lankhorst | 85cb48a | 2016-08-09 17:04:13 +0200 | [diff] [blame] | 2910 | intel_dp_enable_port(intel_dp, pipe_config); |
Ville Syrjälä | 093e3f1 | 2014-10-16 21:27:33 +0300 | [diff] [blame] | 2911 | |
| 2912 | edp_panel_vdd_on(intel_dp); |
| 2913 | edp_panel_on(intel_dp); |
| 2914 | edp_panel_vdd_off(intel_dp, true); |
| 2915 | |
| 2916 | pps_unlock(intel_dp); |
| 2917 | |
Tvrtko Ursulin | 920a14b | 2016-10-14 10:13:44 +0100 | [diff] [blame] | 2918 | if (IS_VALLEYVIEW(dev_priv) || IS_CHERRYVIEW(dev_priv)) { |
Ville Syrjälä | e0fce78 | 2015-07-08 23:45:54 +0300 | [diff] [blame] | 2919 | unsigned int lane_mask = 0x0; |
| 2920 | |
Tvrtko Ursulin | 920a14b | 2016-10-14 10:13:44 +0100 | [diff] [blame] | 2921 | if (IS_CHERRYVIEW(dev_priv)) |
Maarten Lankhorst | 85cb48a | 2016-08-09 17:04:13 +0200 | [diff] [blame] | 2922 | lane_mask = intel_dp_unused_lane_mask(pipe_config->lane_count); |
Ville Syrjälä | e0fce78 | 2015-07-08 23:45:54 +0300 | [diff] [blame] | 2923 | |
Ville Syrjälä | 9b6de0a | 2015-04-10 18:21:31 +0300 | [diff] [blame] | 2924 | vlv_wait_port_ready(dev_priv, dp_to_dig_port(intel_dp), |
| 2925 | lane_mask); |
Ville Syrjälä | e0fce78 | 2015-07-08 23:45:54 +0300 | [diff] [blame] | 2926 | } |
Ville Syrjälä | 61234fa | 2014-10-16 21:27:34 +0300 | [diff] [blame] | 2927 | |
Keith Packard | a4fc5ed | 2009-04-07 16:16:42 -0700 | [diff] [blame] | 2928 | intel_dp_sink_dpms(intel_dp, DRM_MODE_DPMS_ON); |
| 2929 | intel_dp_start_link_train(intel_dp); |
Imre Deak | 3ab9c63 | 2013-05-03 12:57:41 +0300 | [diff] [blame] | 2930 | intel_dp_stop_link_train(intel_dp); |
Jani Nikula | c1dec79 | 2014-10-27 16:26:56 +0200 | [diff] [blame] | 2931 | |
Maarten Lankhorst | 85cb48a | 2016-08-09 17:04:13 +0200 | [diff] [blame] | 2932 | if (pipe_config->has_audio) { |
Jani Nikula | c1dec79 | 2014-10-27 16:26:56 +0200 | [diff] [blame] | 2933 | DRM_DEBUG_DRIVER("Enabling DP audio on pipe %c\n", |
Ville Syrjälä | d6fbdd1 | 2015-10-29 21:25:58 +0200 | [diff] [blame] | 2934 | pipe_name(pipe)); |
Maarten Lankhorst | bbf35e9 | 2016-11-08 13:55:38 +0100 | [diff] [blame] | 2935 | intel_audio_codec_enable(encoder, pipe_config, conn_state); |
Jani Nikula | c1dec79 | 2014-10-27 16:26:56 +0200 | [diff] [blame] | 2936 | } |
Jani Nikula | ab1f90f | 2013-07-30 12:20:30 +0300 | [diff] [blame] | 2937 | } |
Jesse Barnes | 89b667f | 2013-04-18 14:51:36 -0700 | [diff] [blame] | 2938 | |
Maarten Lankhorst | fd6bbda | 2016-08-09 17:04:04 +0200 | [diff] [blame] | 2939 | static void g4x_enable_dp(struct intel_encoder *encoder, |
Ville Syrjälä | 5f88a9c | 2017-08-18 16:49:58 +0300 | [diff] [blame] | 2940 | const struct intel_crtc_state *pipe_config, |
| 2941 | const struct drm_connector_state *conn_state) |
Jani Nikula | ecff4f3 | 2013-09-06 07:38:29 +0300 | [diff] [blame] | 2942 | { |
Maarten Lankhorst | bbf35e9 | 2016-11-08 13:55:38 +0100 | [diff] [blame] | 2943 | intel_enable_dp(encoder, pipe_config, conn_state); |
Maarten Lankhorst | b037d58 | 2017-06-12 12:21:13 +0200 | [diff] [blame] | 2944 | intel_edp_backlight_on(pipe_config, conn_state); |
Keith Packard | a4fc5ed | 2009-04-07 16:16:42 -0700 | [diff] [blame] | 2945 | } |
Jesse Barnes | 89b667f | 2013-04-18 14:51:36 -0700 | [diff] [blame] | 2946 | |
Maarten Lankhorst | fd6bbda | 2016-08-09 17:04:04 +0200 | [diff] [blame] | 2947 | static void vlv_enable_dp(struct intel_encoder *encoder, |
Ville Syrjälä | 5f88a9c | 2017-08-18 16:49:58 +0300 | [diff] [blame] | 2948 | const struct intel_crtc_state *pipe_config, |
| 2949 | const struct drm_connector_state *conn_state) |
Jani Nikula | ab1f90f | 2013-07-30 12:20:30 +0300 | [diff] [blame] | 2950 | { |
Jani Nikula | 828f5c6 | 2013-09-05 16:44:45 +0300 | [diff] [blame] | 2951 | struct intel_dp *intel_dp = enc_to_intel_dp(&encoder->base); |
| 2952 | |
Maarten Lankhorst | b037d58 | 2017-06-12 12:21:13 +0200 | [diff] [blame] | 2953 | intel_edp_backlight_on(pipe_config, conn_state); |
Ville Syrjälä | d2419ff | 2017-08-18 16:49:56 +0300 | [diff] [blame] | 2954 | intel_psr_enable(intel_dp, pipe_config); |
Keith Packard | a4fc5ed | 2009-04-07 16:16:42 -0700 | [diff] [blame] | 2955 | } |
| 2956 | |
Maarten Lankhorst | fd6bbda | 2016-08-09 17:04:04 +0200 | [diff] [blame] | 2957 | static void g4x_pre_enable_dp(struct intel_encoder *encoder, |
Ville Syrjälä | 5f88a9c | 2017-08-18 16:49:58 +0300 | [diff] [blame] | 2958 | const struct intel_crtc_state *pipe_config, |
| 2959 | const struct drm_connector_state *conn_state) |
Keith Packard | a4fc5ed | 2009-04-07 16:16:42 -0700 | [diff] [blame] | 2960 | { |
Daniel Vetter | 2bd2ad6 | 2012-09-06 22:15:41 +0200 | [diff] [blame] | 2961 | struct intel_dp *intel_dp = enc_to_intel_dp(&encoder->base); |
Ville Syrjälä | 8f4f279 | 2017-11-09 17:24:34 +0200 | [diff] [blame] | 2962 | enum port port = encoder->port; |
Jani Nikula | ab1f90f | 2013-07-30 12:20:30 +0300 | [diff] [blame] | 2963 | |
Maarten Lankhorst | 85cb48a | 2016-08-09 17:04:13 +0200 | [diff] [blame] | 2964 | intel_dp_prepare(encoder, pipe_config); |
Daniel Vetter | 8ac33ed | 2014-04-24 23:54:54 +0200 | [diff] [blame] | 2965 | |
Daniel Vetter | d41f1ef | 2014-04-24 23:54:53 +0200 | [diff] [blame] | 2966 | /* Only ilk+ has port A */ |
Ville Syrjälä | abfce94 | 2015-10-29 21:26:03 +0200 | [diff] [blame] | 2967 | if (port == PORT_A) |
Maarten Lankhorst | 85cb48a | 2016-08-09 17:04:13 +0200 | [diff] [blame] | 2968 | ironlake_edp_pll_on(intel_dp, pipe_config); |
Jani Nikula | ab1f90f | 2013-07-30 12:20:30 +0300 | [diff] [blame] | 2969 | } |
| 2970 | |
Ville Syrjälä | 83b8459 | 2014-10-16 21:29:51 +0300 | [diff] [blame] | 2971 | static void vlv_detach_power_sequencer(struct intel_dp *intel_dp) |
| 2972 | { |
| 2973 | struct intel_digital_port *intel_dig_port = dp_to_dig_port(intel_dp); |
Chris Wilson | fac5e23 | 2016-07-04 11:34:36 +0100 | [diff] [blame] | 2974 | struct drm_i915_private *dev_priv = to_i915(intel_dig_port->base.base.dev); |
Ville Syrjälä | 83b8459 | 2014-10-16 21:29:51 +0300 | [diff] [blame] | 2975 | enum pipe pipe = intel_dp->pps_pipe; |
Imre Deak | 44cb734 | 2016-08-10 14:07:29 +0300 | [diff] [blame] | 2976 | i915_reg_t pp_on_reg = PP_ON_DELAYS(pipe); |
Ville Syrjälä | 83b8459 | 2014-10-16 21:29:51 +0300 | [diff] [blame] | 2977 | |
Ville Syrjälä | 9f2bdb0 | 2016-12-14 20:00:23 +0200 | [diff] [blame] | 2978 | WARN_ON(intel_dp->active_pipe != INVALID_PIPE); |
| 2979 | |
Ville Syrjälä | d158694 | 2017-02-08 19:52:54 +0200 | [diff] [blame] | 2980 | if (WARN_ON(pipe != PIPE_A && pipe != PIPE_B)) |
| 2981 | return; |
| 2982 | |
Ville Syrjälä | 83b8459 | 2014-10-16 21:29:51 +0300 | [diff] [blame] | 2983 | edp_panel_vdd_off_sync(intel_dp); |
| 2984 | |
| 2985 | /* |
| 2986 | * VLV seems to get confused when multiple power seqeuencers |
| 2987 | * have the same port selected (even if only one has power/vdd |
| 2988 | * enabled). The failure manifests as vlv_wait_port_ready() failing |
| 2989 | * CHV on the other hand doesn't seem to mind having the same port |
| 2990 | * selected in multiple power seqeuencers, but let's clear the |
| 2991 | * port select always when logically disconnecting a power sequencer |
| 2992 | * from a port. |
| 2993 | */ |
| 2994 | DRM_DEBUG_KMS("detaching pipe %c power sequencer from port %c\n", |
Ville Syrjälä | 8f4f279 | 2017-11-09 17:24:34 +0200 | [diff] [blame] | 2995 | pipe_name(pipe), port_name(intel_dig_port->base.port)); |
Ville Syrjälä | 83b8459 | 2014-10-16 21:29:51 +0300 | [diff] [blame] | 2996 | I915_WRITE(pp_on_reg, 0); |
| 2997 | POSTING_READ(pp_on_reg); |
| 2998 | |
| 2999 | intel_dp->pps_pipe = INVALID_PIPE; |
| 3000 | } |
| 3001 | |
Ville Syrjälä | 46bd838 | 2017-10-31 22:51:22 +0200 | [diff] [blame] | 3002 | static void vlv_steal_power_sequencer(struct drm_i915_private *dev_priv, |
Ville Syrjälä | a4a5d2f | 2014-09-04 14:54:20 +0300 | [diff] [blame] | 3003 | enum pipe pipe) |
| 3004 | { |
Ville Syrjälä | a4a5d2f | 2014-09-04 14:54:20 +0300 | [diff] [blame] | 3005 | struct intel_encoder *encoder; |
| 3006 | |
| 3007 | lockdep_assert_held(&dev_priv->pps_mutex); |
| 3008 | |
Ville Syrjälä | 46bd838 | 2017-10-31 22:51:22 +0200 | [diff] [blame] | 3009 | for_each_intel_encoder(&dev_priv->drm, encoder) { |
Ville Syrjälä | a4a5d2f | 2014-09-04 14:54:20 +0300 | [diff] [blame] | 3010 | struct intel_dp *intel_dp; |
Ville Syrjälä | 773538e8 | 2014-09-04 14:54:56 +0300 | [diff] [blame] | 3011 | enum port port; |
Ville Syrjälä | a4a5d2f | 2014-09-04 14:54:20 +0300 | [diff] [blame] | 3012 | |
Ville Syrjälä | 9f2bdb0 | 2016-12-14 20:00:23 +0200 | [diff] [blame] | 3013 | if (encoder->type != INTEL_OUTPUT_DP && |
| 3014 | encoder->type != INTEL_OUTPUT_EDP) |
Ville Syrjälä | a4a5d2f | 2014-09-04 14:54:20 +0300 | [diff] [blame] | 3015 | continue; |
| 3016 | |
| 3017 | intel_dp = enc_to_intel_dp(&encoder->base); |
Ville Syrjälä | 8f4f279 | 2017-11-09 17:24:34 +0200 | [diff] [blame] | 3018 | port = dp_to_dig_port(intel_dp)->base.port; |
Ville Syrjälä | a4a5d2f | 2014-09-04 14:54:20 +0300 | [diff] [blame] | 3019 | |
Ville Syrjälä | 9f2bdb0 | 2016-12-14 20:00:23 +0200 | [diff] [blame] | 3020 | WARN(intel_dp->active_pipe == pipe, |
| 3021 | "stealing pipe %c power sequencer from active (e)DP port %c\n", |
| 3022 | pipe_name(pipe), port_name(port)); |
| 3023 | |
Ville Syrjälä | a4a5d2f | 2014-09-04 14:54:20 +0300 | [diff] [blame] | 3024 | if (intel_dp->pps_pipe != pipe) |
| 3025 | continue; |
| 3026 | |
| 3027 | DRM_DEBUG_KMS("stealing pipe %c power sequencer from port %c\n", |
Ville Syrjälä | 773538e8 | 2014-09-04 14:54:56 +0300 | [diff] [blame] | 3028 | pipe_name(pipe), port_name(port)); |
Ville Syrjälä | a4a5d2f | 2014-09-04 14:54:20 +0300 | [diff] [blame] | 3029 | |
| 3030 | /* make sure vdd is off before we steal it */ |
Ville Syrjälä | 83b8459 | 2014-10-16 21:29:51 +0300 | [diff] [blame] | 3031 | vlv_detach_power_sequencer(intel_dp); |
Ville Syrjälä | a4a5d2f | 2014-09-04 14:54:20 +0300 | [diff] [blame] | 3032 | } |
| 3033 | } |
| 3034 | |
Ville Syrjälä | adc1030 | 2017-10-31 22:51:14 +0200 | [diff] [blame] | 3035 | static void vlv_init_panel_power_sequencer(struct intel_encoder *encoder, |
| 3036 | const struct intel_crtc_state *crtc_state) |
Ville Syrjälä | a4a5d2f | 2014-09-04 14:54:20 +0300 | [diff] [blame] | 3037 | { |
Ville Syrjälä | 46bd838 | 2017-10-31 22:51:22 +0200 | [diff] [blame] | 3038 | struct drm_i915_private *dev_priv = to_i915(encoder->base.dev); |
Ville Syrjälä | adc1030 | 2017-10-31 22:51:14 +0200 | [diff] [blame] | 3039 | struct intel_dp *intel_dp = enc_to_intel_dp(&encoder->base); |
Ville Syrjälä | adc1030 | 2017-10-31 22:51:14 +0200 | [diff] [blame] | 3040 | struct intel_crtc *crtc = to_intel_crtc(crtc_state->base.crtc); |
Ville Syrjälä | a4a5d2f | 2014-09-04 14:54:20 +0300 | [diff] [blame] | 3041 | |
| 3042 | lockdep_assert_held(&dev_priv->pps_mutex); |
| 3043 | |
Ville Syrjälä | 9f2bdb0 | 2016-12-14 20:00:23 +0200 | [diff] [blame] | 3044 | WARN_ON(intel_dp->active_pipe != INVALID_PIPE); |
Ville Syrjälä | 093e3f1 | 2014-10-16 21:27:33 +0300 | [diff] [blame] | 3045 | |
Ville Syrjälä | 9f2bdb0 | 2016-12-14 20:00:23 +0200 | [diff] [blame] | 3046 | if (intel_dp->pps_pipe != INVALID_PIPE && |
| 3047 | intel_dp->pps_pipe != crtc->pipe) { |
| 3048 | /* |
| 3049 | * If another power sequencer was being used on this |
| 3050 | * port previously make sure to turn off vdd there while |
| 3051 | * we still have control of it. |
| 3052 | */ |
Ville Syrjälä | 83b8459 | 2014-10-16 21:29:51 +0300 | [diff] [blame] | 3053 | vlv_detach_power_sequencer(intel_dp); |
Ville Syrjälä | 9f2bdb0 | 2016-12-14 20:00:23 +0200 | [diff] [blame] | 3054 | } |
Ville Syrjälä | a4a5d2f | 2014-09-04 14:54:20 +0300 | [diff] [blame] | 3055 | |
| 3056 | /* |
| 3057 | * We may be stealing the power |
| 3058 | * sequencer from another port. |
| 3059 | */ |
Ville Syrjälä | 46bd838 | 2017-10-31 22:51:22 +0200 | [diff] [blame] | 3060 | vlv_steal_power_sequencer(dev_priv, crtc->pipe); |
Ville Syrjälä | a4a5d2f | 2014-09-04 14:54:20 +0300 | [diff] [blame] | 3061 | |
Ville Syrjälä | 9f2bdb0 | 2016-12-14 20:00:23 +0200 | [diff] [blame] | 3062 | intel_dp->active_pipe = crtc->pipe; |
| 3063 | |
Jani Nikula | 1853a9d | 2017-08-18 12:30:20 +0300 | [diff] [blame] | 3064 | if (!intel_dp_is_edp(intel_dp)) |
Ville Syrjälä | 9f2bdb0 | 2016-12-14 20:00:23 +0200 | [diff] [blame] | 3065 | return; |
| 3066 | |
Ville Syrjälä | a4a5d2f | 2014-09-04 14:54:20 +0300 | [diff] [blame] | 3067 | /* now it's all ours */ |
| 3068 | intel_dp->pps_pipe = crtc->pipe; |
| 3069 | |
| 3070 | DRM_DEBUG_KMS("initializing pipe %c power sequencer for port %c\n", |
Ville Syrjälä | adc1030 | 2017-10-31 22:51:14 +0200 | [diff] [blame] | 3071 | pipe_name(intel_dp->pps_pipe), port_name(encoder->port)); |
Ville Syrjälä | a4a5d2f | 2014-09-04 14:54:20 +0300 | [diff] [blame] | 3072 | |
| 3073 | /* init power sequencer on this pipe and port */ |
Ville Syrjälä | 46bd838 | 2017-10-31 22:51:22 +0200 | [diff] [blame] | 3074 | intel_dp_init_panel_power_sequencer(intel_dp); |
| 3075 | intel_dp_init_panel_power_sequencer_registers(intel_dp, true); |
Ville Syrjälä | a4a5d2f | 2014-09-04 14:54:20 +0300 | [diff] [blame] | 3076 | } |
| 3077 | |
Maarten Lankhorst | fd6bbda | 2016-08-09 17:04:04 +0200 | [diff] [blame] | 3078 | static void vlv_pre_enable_dp(struct intel_encoder *encoder, |
Ville Syrjälä | 5f88a9c | 2017-08-18 16:49:58 +0300 | [diff] [blame] | 3079 | const struct intel_crtc_state *pipe_config, |
| 3080 | const struct drm_connector_state *conn_state) |
Jani Nikula | ab1f90f | 2013-07-30 12:20:30 +0300 | [diff] [blame] | 3081 | { |
Ville Syrjälä | 2e1029c | 2017-10-31 22:51:18 +0200 | [diff] [blame] | 3082 | vlv_phy_pre_encoder_enable(encoder, pipe_config); |
Jesse Barnes | 89b667f | 2013-04-18 14:51:36 -0700 | [diff] [blame] | 3083 | |
Maarten Lankhorst | bbf35e9 | 2016-11-08 13:55:38 +0100 | [diff] [blame] | 3084 | intel_enable_dp(encoder, pipe_config, conn_state); |
Jesse Barnes | 89b667f | 2013-04-18 14:51:36 -0700 | [diff] [blame] | 3085 | } |
| 3086 | |
Maarten Lankhorst | fd6bbda | 2016-08-09 17:04:04 +0200 | [diff] [blame] | 3087 | static void vlv_dp_pre_pll_enable(struct intel_encoder *encoder, |
Ville Syrjälä | 5f88a9c | 2017-08-18 16:49:58 +0300 | [diff] [blame] | 3088 | const struct intel_crtc_state *pipe_config, |
| 3089 | const struct drm_connector_state *conn_state) |
Jesse Barnes | 89b667f | 2013-04-18 14:51:36 -0700 | [diff] [blame] | 3090 | { |
Maarten Lankhorst | 85cb48a | 2016-08-09 17:04:13 +0200 | [diff] [blame] | 3091 | intel_dp_prepare(encoder, pipe_config); |
Daniel Vetter | 8ac33ed | 2014-04-24 23:54:54 +0200 | [diff] [blame] | 3092 | |
Ville Syrjälä | 2e1029c | 2017-10-31 22:51:18 +0200 | [diff] [blame] | 3093 | vlv_phy_pre_pll_enable(encoder, pipe_config); |
Keith Packard | a4fc5ed | 2009-04-07 16:16:42 -0700 | [diff] [blame] | 3094 | } |
| 3095 | |
Maarten Lankhorst | fd6bbda | 2016-08-09 17:04:04 +0200 | [diff] [blame] | 3096 | static void chv_pre_enable_dp(struct intel_encoder *encoder, |
Ville Syrjälä | 5f88a9c | 2017-08-18 16:49:58 +0300 | [diff] [blame] | 3097 | const struct intel_crtc_state *pipe_config, |
| 3098 | const struct drm_connector_state *conn_state) |
Chon Ming Lee | e4a1d84 | 2014-04-09 13:28:20 +0300 | [diff] [blame] | 3099 | { |
Ville Syrjälä | 2e1029c | 2017-10-31 22:51:18 +0200 | [diff] [blame] | 3100 | chv_phy_pre_encoder_enable(encoder, pipe_config); |
Chon Ming Lee | e4a1d84 | 2014-04-09 13:28:20 +0300 | [diff] [blame] | 3101 | |
Maarten Lankhorst | bbf35e9 | 2016-11-08 13:55:38 +0100 | [diff] [blame] | 3102 | intel_enable_dp(encoder, pipe_config, conn_state); |
Ville Syrjälä | b0b3384 | 2015-07-08 23:45:55 +0300 | [diff] [blame] | 3103 | |
| 3104 | /* Second common lane will stay alive on its own now */ |
Ander Conselvan de Oliveira | e7d2a717 | 2016-04-27 15:44:20 +0300 | [diff] [blame] | 3105 | chv_phy_release_cl2_override(encoder); |
Chon Ming Lee | e4a1d84 | 2014-04-09 13:28:20 +0300 | [diff] [blame] | 3106 | } |
| 3107 | |
Maarten Lankhorst | fd6bbda | 2016-08-09 17:04:04 +0200 | [diff] [blame] | 3108 | static void chv_dp_pre_pll_enable(struct intel_encoder *encoder, |
Ville Syrjälä | 5f88a9c | 2017-08-18 16:49:58 +0300 | [diff] [blame] | 3109 | const struct intel_crtc_state *pipe_config, |
| 3110 | const struct drm_connector_state *conn_state) |
Ville Syrjälä | 9197c88 | 2014-04-09 13:29:05 +0300 | [diff] [blame] | 3111 | { |
Maarten Lankhorst | 85cb48a | 2016-08-09 17:04:13 +0200 | [diff] [blame] | 3112 | intel_dp_prepare(encoder, pipe_config); |
Ville Syrjälä | 625695f | 2014-06-28 02:04:02 +0300 | [diff] [blame] | 3113 | |
Ville Syrjälä | 2e1029c | 2017-10-31 22:51:18 +0200 | [diff] [blame] | 3114 | chv_phy_pre_pll_enable(encoder, pipe_config); |
Ville Syrjälä | 9197c88 | 2014-04-09 13:29:05 +0300 | [diff] [blame] | 3115 | } |
| 3116 | |
Maarten Lankhorst | fd6bbda | 2016-08-09 17:04:04 +0200 | [diff] [blame] | 3117 | static void chv_dp_post_pll_disable(struct intel_encoder *encoder, |
Ville Syrjälä | 2e1029c | 2017-10-31 22:51:18 +0200 | [diff] [blame] | 3118 | const struct intel_crtc_state *old_crtc_state, |
| 3119 | const struct drm_connector_state *old_conn_state) |
Ville Syrjälä | d6db995 | 2015-07-08 23:45:49 +0300 | [diff] [blame] | 3120 | { |
Ville Syrjälä | 2e1029c | 2017-10-31 22:51:18 +0200 | [diff] [blame] | 3121 | chv_phy_post_pll_disable(encoder, old_crtc_state); |
Ville Syrjälä | d6db995 | 2015-07-08 23:45:49 +0300 | [diff] [blame] | 3122 | } |
| 3123 | |
Keith Packard | a4fc5ed | 2009-04-07 16:16:42 -0700 | [diff] [blame] | 3124 | /* |
| 3125 | * Fetch AUX CH registers 0x202 - 0x207 which contain |
| 3126 | * link status information |
| 3127 | */ |
Ander Conselvan de Oliveira | 94223d0 | 2015-10-23 13:01:48 +0300 | [diff] [blame] | 3128 | bool |
Keith Packard | 93f62da | 2011-11-01 19:45:03 -0700 | [diff] [blame] | 3129 | intel_dp_get_link_status(struct intel_dp *intel_dp, uint8_t link_status[DP_LINK_STATUS_SIZE]) |
Keith Packard | a4fc5ed | 2009-04-07 16:16:42 -0700 | [diff] [blame] | 3130 | { |
Lyude | 9f085eb | 2016-04-13 10:58:33 -0400 | [diff] [blame] | 3131 | return drm_dp_dpcd_read(&intel_dp->aux, DP_LANE0_1_STATUS, link_status, |
| 3132 | DP_LINK_STATUS_SIZE) == DP_LINK_STATUS_SIZE; |
Keith Packard | a4fc5ed | 2009-04-07 16:16:42 -0700 | [diff] [blame] | 3133 | } |
| 3134 | |
Nagaraju, Vathsala | 97da2ef | 2017-01-02 17:00:55 +0530 | [diff] [blame] | 3135 | static bool intel_dp_get_y_cord_status(struct intel_dp *intel_dp) |
| 3136 | { |
| 3137 | uint8_t psr_caps = 0; |
| 3138 | |
Imre Deak | 9bacd4b | 2017-05-10 12:21:48 +0300 | [diff] [blame] | 3139 | if (drm_dp_dpcd_readb(&intel_dp->aux, DP_PSR_CAPS, &psr_caps) != 1) |
| 3140 | return false; |
Nagaraju, Vathsala | 97da2ef | 2017-01-02 17:00:55 +0530 | [diff] [blame] | 3141 | return psr_caps & DP_PSR2_SU_Y_COORDINATE_REQUIRED; |
| 3142 | } |
| 3143 | |
| 3144 | static bool intel_dp_get_colorimetry_status(struct intel_dp *intel_dp) |
| 3145 | { |
| 3146 | uint8_t dprx = 0; |
| 3147 | |
Imre Deak | 9bacd4b | 2017-05-10 12:21:48 +0300 | [diff] [blame] | 3148 | if (drm_dp_dpcd_readb(&intel_dp->aux, DP_DPRX_FEATURE_ENUMERATION_LIST, |
| 3149 | &dprx) != 1) |
| 3150 | return false; |
Nagaraju, Vathsala | 97da2ef | 2017-01-02 17:00:55 +0530 | [diff] [blame] | 3151 | return dprx & DP_VSC_SDP_EXT_FOR_COLORIMETRY_SUPPORTED; |
| 3152 | } |
| 3153 | |
Chris Wilson | a76f73d | 2017-01-14 10:51:13 +0000 | [diff] [blame] | 3154 | static bool intel_dp_get_alpm_status(struct intel_dp *intel_dp) |
Nagaraju, Vathsala | 340c93c | 2017-01-02 17:00:58 +0530 | [diff] [blame] | 3155 | { |
| 3156 | uint8_t alpm_caps = 0; |
| 3157 | |
Imre Deak | 9bacd4b | 2017-05-10 12:21:48 +0300 | [diff] [blame] | 3158 | if (drm_dp_dpcd_readb(&intel_dp->aux, DP_RECEIVER_ALPM_CAP, |
| 3159 | &alpm_caps) != 1) |
| 3160 | return false; |
Nagaraju, Vathsala | 340c93c | 2017-01-02 17:00:58 +0530 | [diff] [blame] | 3161 | return alpm_caps & DP_ALPM_CAP; |
| 3162 | } |
| 3163 | |
Paulo Zanoni | 1100244 | 2014-06-13 18:45:41 -0300 | [diff] [blame] | 3164 | /* These are source-specific values. */ |
Ander Conselvan de Oliveira | 94223d0 | 2015-10-23 13:01:48 +0300 | [diff] [blame] | 3165 | uint8_t |
Keith Packard | 1a2eb46 | 2011-11-16 16:26:07 -0800 | [diff] [blame] | 3166 | intel_dp_voltage_max(struct intel_dp *intel_dp) |
Keith Packard | a4fc5ed | 2009-04-07 16:16:42 -0700 | [diff] [blame] | 3167 | { |
Tvrtko Ursulin | dd11bc1 | 2016-11-16 08:55:41 +0000 | [diff] [blame] | 3168 | struct drm_i915_private *dev_priv = to_i915(intel_dp_to_dev(intel_dp)); |
Ville Syrjälä | 8f4f279 | 2017-11-09 17:24:34 +0200 | [diff] [blame] | 3169 | enum port port = dp_to_dig_port(intel_dp)->base.port; |
Keith Packard | 1a2eb46 | 2011-11-16 16:26:07 -0800 | [diff] [blame] | 3170 | |
Ville Syrjälä | 7d4f37b | 2017-10-16 17:57:00 +0300 | [diff] [blame] | 3171 | if (INTEL_GEN(dev_priv) >= 9) { |
Ville Syrjälä | ffe5111 | 2017-02-23 19:49:01 +0200 | [diff] [blame] | 3172 | struct intel_encoder *encoder = &dp_to_dig_port(intel_dp)->base; |
| 3173 | return intel_ddi_dp_voltage_max(encoder); |
Tvrtko Ursulin | 920a14b | 2016-10-14 10:13:44 +0100 | [diff] [blame] | 3174 | } else if (IS_VALLEYVIEW(dev_priv) || IS_CHERRYVIEW(dev_priv)) |
Sonika Jindal | bd60018 | 2014-08-08 16:23:41 +0530 | [diff] [blame] | 3175 | return DP_TRAIN_VOLTAGE_SWING_LEVEL_3; |
Tvrtko Ursulin | 5db9401 | 2016-10-13 11:03:10 +0100 | [diff] [blame] | 3176 | else if (IS_GEN7(dev_priv) && port == PORT_A) |
Sonika Jindal | bd60018 | 2014-08-08 16:23:41 +0530 | [diff] [blame] | 3177 | return DP_TRAIN_VOLTAGE_SWING_LEVEL_2; |
Tvrtko Ursulin | 6e26695 | 2016-10-13 11:02:53 +0100 | [diff] [blame] | 3178 | else if (HAS_PCH_CPT(dev_priv) && port != PORT_A) |
Sonika Jindal | bd60018 | 2014-08-08 16:23:41 +0530 | [diff] [blame] | 3179 | return DP_TRAIN_VOLTAGE_SWING_LEVEL_3; |
Keith Packard | 1a2eb46 | 2011-11-16 16:26:07 -0800 | [diff] [blame] | 3180 | else |
Sonika Jindal | bd60018 | 2014-08-08 16:23:41 +0530 | [diff] [blame] | 3181 | return DP_TRAIN_VOLTAGE_SWING_LEVEL_2; |
Keith Packard | 1a2eb46 | 2011-11-16 16:26:07 -0800 | [diff] [blame] | 3182 | } |
| 3183 | |
Ander Conselvan de Oliveira | 94223d0 | 2015-10-23 13:01:48 +0300 | [diff] [blame] | 3184 | uint8_t |
Keith Packard | 1a2eb46 | 2011-11-16 16:26:07 -0800 | [diff] [blame] | 3185 | intel_dp_pre_emphasis_max(struct intel_dp *intel_dp, uint8_t voltage_swing) |
| 3186 | { |
Tvrtko Ursulin | 8652744 | 2016-10-13 11:03:00 +0100 | [diff] [blame] | 3187 | struct drm_i915_private *dev_priv = to_i915(intel_dp_to_dev(intel_dp)); |
Ville Syrjälä | 8f4f279 | 2017-11-09 17:24:34 +0200 | [diff] [blame] | 3188 | enum port port = dp_to_dig_port(intel_dp)->base.port; |
Keith Packard | 1a2eb46 | 2011-11-16 16:26:07 -0800 | [diff] [blame] | 3189 | |
Tvrtko Ursulin | 8652744 | 2016-10-13 11:03:00 +0100 | [diff] [blame] | 3190 | if (INTEL_GEN(dev_priv) >= 9) { |
Damien Lespiau | 5a9d1f1 | 2013-12-03 13:56:26 +0000 | [diff] [blame] | 3191 | switch (voltage_swing & DP_TRAIN_VOLTAGE_SWING_MASK) { |
| 3192 | case DP_TRAIN_VOLTAGE_SWING_LEVEL_0: |
| 3193 | return DP_TRAIN_PRE_EMPH_LEVEL_3; |
| 3194 | case DP_TRAIN_VOLTAGE_SWING_LEVEL_1: |
| 3195 | return DP_TRAIN_PRE_EMPH_LEVEL_2; |
| 3196 | case DP_TRAIN_VOLTAGE_SWING_LEVEL_2: |
| 3197 | return DP_TRAIN_PRE_EMPH_LEVEL_1; |
Sonika Jindal | 7ad14a2 | 2015-02-25 10:29:12 +0530 | [diff] [blame] | 3198 | case DP_TRAIN_VOLTAGE_SWING_LEVEL_3: |
| 3199 | return DP_TRAIN_PRE_EMPH_LEVEL_0; |
Damien Lespiau | 5a9d1f1 | 2013-12-03 13:56:26 +0000 | [diff] [blame] | 3200 | default: |
| 3201 | return DP_TRAIN_PRE_EMPH_LEVEL_0; |
| 3202 | } |
Tvrtko Ursulin | 8652744 | 2016-10-13 11:03:00 +0100 | [diff] [blame] | 3203 | } else if (IS_HASWELL(dev_priv) || IS_BROADWELL(dev_priv)) { |
Paulo Zanoni | d6c0d72 | 2012-10-15 15:51:34 -0300 | [diff] [blame] | 3204 | switch (voltage_swing & DP_TRAIN_VOLTAGE_SWING_MASK) { |
Sonika Jindal | bd60018 | 2014-08-08 16:23:41 +0530 | [diff] [blame] | 3205 | case DP_TRAIN_VOLTAGE_SWING_LEVEL_0: |
| 3206 | return DP_TRAIN_PRE_EMPH_LEVEL_3; |
| 3207 | case DP_TRAIN_VOLTAGE_SWING_LEVEL_1: |
| 3208 | return DP_TRAIN_PRE_EMPH_LEVEL_2; |
| 3209 | case DP_TRAIN_VOLTAGE_SWING_LEVEL_2: |
| 3210 | return DP_TRAIN_PRE_EMPH_LEVEL_1; |
| 3211 | case DP_TRAIN_VOLTAGE_SWING_LEVEL_3: |
Paulo Zanoni | d6c0d72 | 2012-10-15 15:51:34 -0300 | [diff] [blame] | 3212 | default: |
Sonika Jindal | bd60018 | 2014-08-08 16:23:41 +0530 | [diff] [blame] | 3213 | return DP_TRAIN_PRE_EMPH_LEVEL_0; |
Paulo Zanoni | d6c0d72 | 2012-10-15 15:51:34 -0300 | [diff] [blame] | 3214 | } |
Tvrtko Ursulin | 8652744 | 2016-10-13 11:03:00 +0100 | [diff] [blame] | 3215 | } else if (IS_VALLEYVIEW(dev_priv) || IS_CHERRYVIEW(dev_priv)) { |
Pallavi G | e2fa6fb | 2013-04-18 14:44:28 -0700 | [diff] [blame] | 3216 | switch (voltage_swing & DP_TRAIN_VOLTAGE_SWING_MASK) { |
Sonika Jindal | bd60018 | 2014-08-08 16:23:41 +0530 | [diff] [blame] | 3217 | case DP_TRAIN_VOLTAGE_SWING_LEVEL_0: |
| 3218 | return DP_TRAIN_PRE_EMPH_LEVEL_3; |
| 3219 | case DP_TRAIN_VOLTAGE_SWING_LEVEL_1: |
| 3220 | return DP_TRAIN_PRE_EMPH_LEVEL_2; |
| 3221 | case DP_TRAIN_VOLTAGE_SWING_LEVEL_2: |
| 3222 | return DP_TRAIN_PRE_EMPH_LEVEL_1; |
| 3223 | case DP_TRAIN_VOLTAGE_SWING_LEVEL_3: |
Pallavi G | e2fa6fb | 2013-04-18 14:44:28 -0700 | [diff] [blame] | 3224 | default: |
Sonika Jindal | bd60018 | 2014-08-08 16:23:41 +0530 | [diff] [blame] | 3225 | return DP_TRAIN_PRE_EMPH_LEVEL_0; |
Pallavi G | e2fa6fb | 2013-04-18 14:44:28 -0700 | [diff] [blame] | 3226 | } |
Tvrtko Ursulin | 8652744 | 2016-10-13 11:03:00 +0100 | [diff] [blame] | 3227 | } else if (IS_GEN7(dev_priv) && port == PORT_A) { |
Keith Packard | 1a2eb46 | 2011-11-16 16:26:07 -0800 | [diff] [blame] | 3228 | switch (voltage_swing & DP_TRAIN_VOLTAGE_SWING_MASK) { |
Sonika Jindal | bd60018 | 2014-08-08 16:23:41 +0530 | [diff] [blame] | 3229 | case DP_TRAIN_VOLTAGE_SWING_LEVEL_0: |
| 3230 | return DP_TRAIN_PRE_EMPH_LEVEL_2; |
| 3231 | case DP_TRAIN_VOLTAGE_SWING_LEVEL_1: |
| 3232 | case DP_TRAIN_VOLTAGE_SWING_LEVEL_2: |
| 3233 | return DP_TRAIN_PRE_EMPH_LEVEL_1; |
Keith Packard | 1a2eb46 | 2011-11-16 16:26:07 -0800 | [diff] [blame] | 3234 | default: |
Sonika Jindal | bd60018 | 2014-08-08 16:23:41 +0530 | [diff] [blame] | 3235 | return DP_TRAIN_PRE_EMPH_LEVEL_0; |
Keith Packard | 1a2eb46 | 2011-11-16 16:26:07 -0800 | [diff] [blame] | 3236 | } |
| 3237 | } else { |
| 3238 | switch (voltage_swing & DP_TRAIN_VOLTAGE_SWING_MASK) { |
Sonika Jindal | bd60018 | 2014-08-08 16:23:41 +0530 | [diff] [blame] | 3239 | case DP_TRAIN_VOLTAGE_SWING_LEVEL_0: |
| 3240 | return DP_TRAIN_PRE_EMPH_LEVEL_2; |
| 3241 | case DP_TRAIN_VOLTAGE_SWING_LEVEL_1: |
| 3242 | return DP_TRAIN_PRE_EMPH_LEVEL_2; |
| 3243 | case DP_TRAIN_VOLTAGE_SWING_LEVEL_2: |
| 3244 | return DP_TRAIN_PRE_EMPH_LEVEL_1; |
| 3245 | case DP_TRAIN_VOLTAGE_SWING_LEVEL_3: |
Keith Packard | 1a2eb46 | 2011-11-16 16:26:07 -0800 | [diff] [blame] | 3246 | default: |
Sonika Jindal | bd60018 | 2014-08-08 16:23:41 +0530 | [diff] [blame] | 3247 | return DP_TRAIN_PRE_EMPH_LEVEL_0; |
Keith Packard | 1a2eb46 | 2011-11-16 16:26:07 -0800 | [diff] [blame] | 3248 | } |
Keith Packard | a4fc5ed | 2009-04-07 16:16:42 -0700 | [diff] [blame] | 3249 | } |
| 3250 | } |
| 3251 | |
Daniel Vetter | 5829975c | 2015-04-16 11:36:52 +0200 | [diff] [blame] | 3252 | static uint32_t vlv_signal_levels(struct intel_dp *intel_dp) |
Pallavi G | e2fa6fb | 2013-04-18 14:44:28 -0700 | [diff] [blame] | 3253 | { |
Ander Conselvan de Oliveira | 53d9872 | 2016-04-27 15:44:22 +0300 | [diff] [blame] | 3254 | struct intel_encoder *encoder = &dp_to_dig_port(intel_dp)->base; |
Pallavi G | e2fa6fb | 2013-04-18 14:44:28 -0700 | [diff] [blame] | 3255 | unsigned long demph_reg_value, preemph_reg_value, |
| 3256 | uniqtranscale_reg_value; |
| 3257 | uint8_t train_set = intel_dp->train_set[0]; |
Pallavi G | e2fa6fb | 2013-04-18 14:44:28 -0700 | [diff] [blame] | 3258 | |
| 3259 | switch (train_set & DP_TRAIN_PRE_EMPHASIS_MASK) { |
Sonika Jindal | bd60018 | 2014-08-08 16:23:41 +0530 | [diff] [blame] | 3260 | case DP_TRAIN_PRE_EMPH_LEVEL_0: |
Pallavi G | e2fa6fb | 2013-04-18 14:44:28 -0700 | [diff] [blame] | 3261 | preemph_reg_value = 0x0004000; |
| 3262 | switch (train_set & DP_TRAIN_VOLTAGE_SWING_MASK) { |
Sonika Jindal | bd60018 | 2014-08-08 16:23:41 +0530 | [diff] [blame] | 3263 | case DP_TRAIN_VOLTAGE_SWING_LEVEL_0: |
Pallavi G | e2fa6fb | 2013-04-18 14:44:28 -0700 | [diff] [blame] | 3264 | demph_reg_value = 0x2B405555; |
| 3265 | uniqtranscale_reg_value = 0x552AB83A; |
| 3266 | break; |
Sonika Jindal | bd60018 | 2014-08-08 16:23:41 +0530 | [diff] [blame] | 3267 | case DP_TRAIN_VOLTAGE_SWING_LEVEL_1: |
Pallavi G | e2fa6fb | 2013-04-18 14:44:28 -0700 | [diff] [blame] | 3268 | demph_reg_value = 0x2B404040; |
| 3269 | uniqtranscale_reg_value = 0x5548B83A; |
| 3270 | break; |
Sonika Jindal | bd60018 | 2014-08-08 16:23:41 +0530 | [diff] [blame] | 3271 | case DP_TRAIN_VOLTAGE_SWING_LEVEL_2: |
Pallavi G | e2fa6fb | 2013-04-18 14:44:28 -0700 | [diff] [blame] | 3272 | demph_reg_value = 0x2B245555; |
| 3273 | uniqtranscale_reg_value = 0x5560B83A; |
| 3274 | break; |
Sonika Jindal | bd60018 | 2014-08-08 16:23:41 +0530 | [diff] [blame] | 3275 | case DP_TRAIN_VOLTAGE_SWING_LEVEL_3: |
Pallavi G | e2fa6fb | 2013-04-18 14:44:28 -0700 | [diff] [blame] | 3276 | demph_reg_value = 0x2B405555; |
| 3277 | uniqtranscale_reg_value = 0x5598DA3A; |
| 3278 | break; |
| 3279 | default: |
| 3280 | return 0; |
| 3281 | } |
| 3282 | break; |
Sonika Jindal | bd60018 | 2014-08-08 16:23:41 +0530 | [diff] [blame] | 3283 | case DP_TRAIN_PRE_EMPH_LEVEL_1: |
Pallavi G | e2fa6fb | 2013-04-18 14:44:28 -0700 | [diff] [blame] | 3284 | preemph_reg_value = 0x0002000; |
| 3285 | switch (train_set & DP_TRAIN_VOLTAGE_SWING_MASK) { |
Sonika Jindal | bd60018 | 2014-08-08 16:23:41 +0530 | [diff] [blame] | 3286 | case DP_TRAIN_VOLTAGE_SWING_LEVEL_0: |
Pallavi G | e2fa6fb | 2013-04-18 14:44:28 -0700 | [diff] [blame] | 3287 | demph_reg_value = 0x2B404040; |
| 3288 | uniqtranscale_reg_value = 0x5552B83A; |
| 3289 | break; |
Sonika Jindal | bd60018 | 2014-08-08 16:23:41 +0530 | [diff] [blame] | 3290 | case DP_TRAIN_VOLTAGE_SWING_LEVEL_1: |
Pallavi G | e2fa6fb | 2013-04-18 14:44:28 -0700 | [diff] [blame] | 3291 | demph_reg_value = 0x2B404848; |
| 3292 | uniqtranscale_reg_value = 0x5580B83A; |
| 3293 | break; |
Sonika Jindal | bd60018 | 2014-08-08 16:23:41 +0530 | [diff] [blame] | 3294 | case DP_TRAIN_VOLTAGE_SWING_LEVEL_2: |
Pallavi G | e2fa6fb | 2013-04-18 14:44:28 -0700 | [diff] [blame] | 3295 | demph_reg_value = 0x2B404040; |
| 3296 | uniqtranscale_reg_value = 0x55ADDA3A; |
| 3297 | break; |
| 3298 | default: |
| 3299 | return 0; |
| 3300 | } |
| 3301 | break; |
Sonika Jindal | bd60018 | 2014-08-08 16:23:41 +0530 | [diff] [blame] | 3302 | case DP_TRAIN_PRE_EMPH_LEVEL_2: |
Pallavi G | e2fa6fb | 2013-04-18 14:44:28 -0700 | [diff] [blame] | 3303 | preemph_reg_value = 0x0000000; |
| 3304 | switch (train_set & DP_TRAIN_VOLTAGE_SWING_MASK) { |
Sonika Jindal | bd60018 | 2014-08-08 16:23:41 +0530 | [diff] [blame] | 3305 | case DP_TRAIN_VOLTAGE_SWING_LEVEL_0: |
Pallavi G | e2fa6fb | 2013-04-18 14:44:28 -0700 | [diff] [blame] | 3306 | demph_reg_value = 0x2B305555; |
| 3307 | uniqtranscale_reg_value = 0x5570B83A; |
| 3308 | break; |
Sonika Jindal | bd60018 | 2014-08-08 16:23:41 +0530 | [diff] [blame] | 3309 | case DP_TRAIN_VOLTAGE_SWING_LEVEL_1: |
Pallavi G | e2fa6fb | 2013-04-18 14:44:28 -0700 | [diff] [blame] | 3310 | demph_reg_value = 0x2B2B4040; |
| 3311 | uniqtranscale_reg_value = 0x55ADDA3A; |
| 3312 | break; |
| 3313 | default: |
| 3314 | return 0; |
| 3315 | } |
| 3316 | break; |
Sonika Jindal | bd60018 | 2014-08-08 16:23:41 +0530 | [diff] [blame] | 3317 | case DP_TRAIN_PRE_EMPH_LEVEL_3: |
Pallavi G | e2fa6fb | 2013-04-18 14:44:28 -0700 | [diff] [blame] | 3318 | preemph_reg_value = 0x0006000; |
| 3319 | switch (train_set & DP_TRAIN_VOLTAGE_SWING_MASK) { |
Sonika Jindal | bd60018 | 2014-08-08 16:23:41 +0530 | [diff] [blame] | 3320 | case DP_TRAIN_VOLTAGE_SWING_LEVEL_0: |
Pallavi G | e2fa6fb | 2013-04-18 14:44:28 -0700 | [diff] [blame] | 3321 | demph_reg_value = 0x1B405555; |
| 3322 | uniqtranscale_reg_value = 0x55ADDA3A; |
| 3323 | break; |
| 3324 | default: |
| 3325 | return 0; |
| 3326 | } |
| 3327 | break; |
| 3328 | default: |
| 3329 | return 0; |
| 3330 | } |
| 3331 | |
Ander Conselvan de Oliveira | 53d9872 | 2016-04-27 15:44:22 +0300 | [diff] [blame] | 3332 | vlv_set_phy_signal_level(encoder, demph_reg_value, preemph_reg_value, |
| 3333 | uniqtranscale_reg_value, 0); |
Pallavi G | e2fa6fb | 2013-04-18 14:44:28 -0700 | [diff] [blame] | 3334 | |
| 3335 | return 0; |
| 3336 | } |
| 3337 | |
Daniel Vetter | 5829975c | 2015-04-16 11:36:52 +0200 | [diff] [blame] | 3338 | static uint32_t chv_signal_levels(struct intel_dp *intel_dp) |
Chon Ming Lee | e4a1d84 | 2014-04-09 13:28:20 +0300 | [diff] [blame] | 3339 | { |
Ander Conselvan de Oliveira | b7fa22d | 2016-04-27 15:44:17 +0300 | [diff] [blame] | 3340 | struct intel_encoder *encoder = &dp_to_dig_port(intel_dp)->base; |
| 3341 | u32 deemph_reg_value, margin_reg_value; |
| 3342 | bool uniq_trans_scale = false; |
Chon Ming Lee | e4a1d84 | 2014-04-09 13:28:20 +0300 | [diff] [blame] | 3343 | uint8_t train_set = intel_dp->train_set[0]; |
Chon Ming Lee | e4a1d84 | 2014-04-09 13:28:20 +0300 | [diff] [blame] | 3344 | |
| 3345 | switch (train_set & DP_TRAIN_PRE_EMPHASIS_MASK) { |
Sonika Jindal | bd60018 | 2014-08-08 16:23:41 +0530 | [diff] [blame] | 3346 | case DP_TRAIN_PRE_EMPH_LEVEL_0: |
Chon Ming Lee | e4a1d84 | 2014-04-09 13:28:20 +0300 | [diff] [blame] | 3347 | switch (train_set & DP_TRAIN_VOLTAGE_SWING_MASK) { |
Sonika Jindal | bd60018 | 2014-08-08 16:23:41 +0530 | [diff] [blame] | 3348 | case DP_TRAIN_VOLTAGE_SWING_LEVEL_0: |
Chon Ming Lee | e4a1d84 | 2014-04-09 13:28:20 +0300 | [diff] [blame] | 3349 | deemph_reg_value = 128; |
| 3350 | margin_reg_value = 52; |
| 3351 | break; |
Sonika Jindal | bd60018 | 2014-08-08 16:23:41 +0530 | [diff] [blame] | 3352 | case DP_TRAIN_VOLTAGE_SWING_LEVEL_1: |
Chon Ming Lee | e4a1d84 | 2014-04-09 13:28:20 +0300 | [diff] [blame] | 3353 | deemph_reg_value = 128; |
| 3354 | margin_reg_value = 77; |
| 3355 | break; |
Sonika Jindal | bd60018 | 2014-08-08 16:23:41 +0530 | [diff] [blame] | 3356 | case DP_TRAIN_VOLTAGE_SWING_LEVEL_2: |
Chon Ming Lee | e4a1d84 | 2014-04-09 13:28:20 +0300 | [diff] [blame] | 3357 | deemph_reg_value = 128; |
| 3358 | margin_reg_value = 102; |
| 3359 | break; |
Sonika Jindal | bd60018 | 2014-08-08 16:23:41 +0530 | [diff] [blame] | 3360 | case DP_TRAIN_VOLTAGE_SWING_LEVEL_3: |
Chon Ming Lee | e4a1d84 | 2014-04-09 13:28:20 +0300 | [diff] [blame] | 3361 | deemph_reg_value = 128; |
| 3362 | margin_reg_value = 154; |
Ander Conselvan de Oliveira | b7fa22d | 2016-04-27 15:44:17 +0300 | [diff] [blame] | 3363 | uniq_trans_scale = true; |
Chon Ming Lee | e4a1d84 | 2014-04-09 13:28:20 +0300 | [diff] [blame] | 3364 | break; |
| 3365 | default: |
| 3366 | return 0; |
| 3367 | } |
| 3368 | break; |
Sonika Jindal | bd60018 | 2014-08-08 16:23:41 +0530 | [diff] [blame] | 3369 | case DP_TRAIN_PRE_EMPH_LEVEL_1: |
Chon Ming Lee | e4a1d84 | 2014-04-09 13:28:20 +0300 | [diff] [blame] | 3370 | switch (train_set & DP_TRAIN_VOLTAGE_SWING_MASK) { |
Sonika Jindal | bd60018 | 2014-08-08 16:23:41 +0530 | [diff] [blame] | 3371 | case DP_TRAIN_VOLTAGE_SWING_LEVEL_0: |
Chon Ming Lee | e4a1d84 | 2014-04-09 13:28:20 +0300 | [diff] [blame] | 3372 | deemph_reg_value = 85; |
| 3373 | margin_reg_value = 78; |
| 3374 | break; |
Sonika Jindal | bd60018 | 2014-08-08 16:23:41 +0530 | [diff] [blame] | 3375 | case DP_TRAIN_VOLTAGE_SWING_LEVEL_1: |
Chon Ming Lee | e4a1d84 | 2014-04-09 13:28:20 +0300 | [diff] [blame] | 3376 | deemph_reg_value = 85; |
| 3377 | margin_reg_value = 116; |
| 3378 | break; |
Sonika Jindal | bd60018 | 2014-08-08 16:23:41 +0530 | [diff] [blame] | 3379 | case DP_TRAIN_VOLTAGE_SWING_LEVEL_2: |
Chon Ming Lee | e4a1d84 | 2014-04-09 13:28:20 +0300 | [diff] [blame] | 3380 | deemph_reg_value = 85; |
| 3381 | margin_reg_value = 154; |
| 3382 | break; |
| 3383 | default: |
| 3384 | return 0; |
| 3385 | } |
| 3386 | break; |
Sonika Jindal | bd60018 | 2014-08-08 16:23:41 +0530 | [diff] [blame] | 3387 | case DP_TRAIN_PRE_EMPH_LEVEL_2: |
Chon Ming Lee | e4a1d84 | 2014-04-09 13:28:20 +0300 | [diff] [blame] | 3388 | switch (train_set & DP_TRAIN_VOLTAGE_SWING_MASK) { |
Sonika Jindal | bd60018 | 2014-08-08 16:23:41 +0530 | [diff] [blame] | 3389 | case DP_TRAIN_VOLTAGE_SWING_LEVEL_0: |
Chon Ming Lee | e4a1d84 | 2014-04-09 13:28:20 +0300 | [diff] [blame] | 3390 | deemph_reg_value = 64; |
| 3391 | margin_reg_value = 104; |
| 3392 | break; |
Sonika Jindal | bd60018 | 2014-08-08 16:23:41 +0530 | [diff] [blame] | 3393 | case DP_TRAIN_VOLTAGE_SWING_LEVEL_1: |
Chon Ming Lee | e4a1d84 | 2014-04-09 13:28:20 +0300 | [diff] [blame] | 3394 | deemph_reg_value = 64; |
| 3395 | margin_reg_value = 154; |
| 3396 | break; |
| 3397 | default: |
| 3398 | return 0; |
| 3399 | } |
| 3400 | break; |
Sonika Jindal | bd60018 | 2014-08-08 16:23:41 +0530 | [diff] [blame] | 3401 | case DP_TRAIN_PRE_EMPH_LEVEL_3: |
Chon Ming Lee | e4a1d84 | 2014-04-09 13:28:20 +0300 | [diff] [blame] | 3402 | switch (train_set & DP_TRAIN_VOLTAGE_SWING_MASK) { |
Sonika Jindal | bd60018 | 2014-08-08 16:23:41 +0530 | [diff] [blame] | 3403 | case DP_TRAIN_VOLTAGE_SWING_LEVEL_0: |
Chon Ming Lee | e4a1d84 | 2014-04-09 13:28:20 +0300 | [diff] [blame] | 3404 | deemph_reg_value = 43; |
| 3405 | margin_reg_value = 154; |
| 3406 | break; |
| 3407 | default: |
| 3408 | return 0; |
| 3409 | } |
| 3410 | break; |
| 3411 | default: |
| 3412 | return 0; |
| 3413 | } |
| 3414 | |
Ander Conselvan de Oliveira | b7fa22d | 2016-04-27 15:44:17 +0300 | [diff] [blame] | 3415 | chv_set_phy_signal_level(encoder, deemph_reg_value, |
| 3416 | margin_reg_value, uniq_trans_scale); |
Chon Ming Lee | e4a1d84 | 2014-04-09 13:28:20 +0300 | [diff] [blame] | 3417 | |
| 3418 | return 0; |
| 3419 | } |
| 3420 | |
Keith Packard | a4fc5ed | 2009-04-07 16:16:42 -0700 | [diff] [blame] | 3421 | static uint32_t |
Daniel Vetter | 5829975c | 2015-04-16 11:36:52 +0200 | [diff] [blame] | 3422 | gen4_signal_levels(uint8_t train_set) |
Keith Packard | a4fc5ed | 2009-04-07 16:16:42 -0700 | [diff] [blame] | 3423 | { |
Chris Wilson | 3cf2efb | 2010-11-29 10:09:55 +0000 | [diff] [blame] | 3424 | uint32_t signal_levels = 0; |
Keith Packard | a4fc5ed | 2009-04-07 16:16:42 -0700 | [diff] [blame] | 3425 | |
Chris Wilson | 3cf2efb | 2010-11-29 10:09:55 +0000 | [diff] [blame] | 3426 | switch (train_set & DP_TRAIN_VOLTAGE_SWING_MASK) { |
Sonika Jindal | bd60018 | 2014-08-08 16:23:41 +0530 | [diff] [blame] | 3427 | case DP_TRAIN_VOLTAGE_SWING_LEVEL_0: |
Keith Packard | a4fc5ed | 2009-04-07 16:16:42 -0700 | [diff] [blame] | 3428 | default: |
| 3429 | signal_levels |= DP_VOLTAGE_0_4; |
| 3430 | break; |
Sonika Jindal | bd60018 | 2014-08-08 16:23:41 +0530 | [diff] [blame] | 3431 | case DP_TRAIN_VOLTAGE_SWING_LEVEL_1: |
Keith Packard | a4fc5ed | 2009-04-07 16:16:42 -0700 | [diff] [blame] | 3432 | signal_levels |= DP_VOLTAGE_0_6; |
| 3433 | break; |
Sonika Jindal | bd60018 | 2014-08-08 16:23:41 +0530 | [diff] [blame] | 3434 | case DP_TRAIN_VOLTAGE_SWING_LEVEL_2: |
Keith Packard | a4fc5ed | 2009-04-07 16:16:42 -0700 | [diff] [blame] | 3435 | signal_levels |= DP_VOLTAGE_0_8; |
| 3436 | break; |
Sonika Jindal | bd60018 | 2014-08-08 16:23:41 +0530 | [diff] [blame] | 3437 | case DP_TRAIN_VOLTAGE_SWING_LEVEL_3: |
Keith Packard | a4fc5ed | 2009-04-07 16:16:42 -0700 | [diff] [blame] | 3438 | signal_levels |= DP_VOLTAGE_1_2; |
| 3439 | break; |
| 3440 | } |
Chris Wilson | 3cf2efb | 2010-11-29 10:09:55 +0000 | [diff] [blame] | 3441 | switch (train_set & DP_TRAIN_PRE_EMPHASIS_MASK) { |
Sonika Jindal | bd60018 | 2014-08-08 16:23:41 +0530 | [diff] [blame] | 3442 | case DP_TRAIN_PRE_EMPH_LEVEL_0: |
Keith Packard | a4fc5ed | 2009-04-07 16:16:42 -0700 | [diff] [blame] | 3443 | default: |
| 3444 | signal_levels |= DP_PRE_EMPHASIS_0; |
| 3445 | break; |
Sonika Jindal | bd60018 | 2014-08-08 16:23:41 +0530 | [diff] [blame] | 3446 | case DP_TRAIN_PRE_EMPH_LEVEL_1: |
Keith Packard | a4fc5ed | 2009-04-07 16:16:42 -0700 | [diff] [blame] | 3447 | signal_levels |= DP_PRE_EMPHASIS_3_5; |
| 3448 | break; |
Sonika Jindal | bd60018 | 2014-08-08 16:23:41 +0530 | [diff] [blame] | 3449 | case DP_TRAIN_PRE_EMPH_LEVEL_2: |
Keith Packard | a4fc5ed | 2009-04-07 16:16:42 -0700 | [diff] [blame] | 3450 | signal_levels |= DP_PRE_EMPHASIS_6; |
| 3451 | break; |
Sonika Jindal | bd60018 | 2014-08-08 16:23:41 +0530 | [diff] [blame] | 3452 | case DP_TRAIN_PRE_EMPH_LEVEL_3: |
Keith Packard | a4fc5ed | 2009-04-07 16:16:42 -0700 | [diff] [blame] | 3453 | signal_levels |= DP_PRE_EMPHASIS_9_5; |
| 3454 | break; |
| 3455 | } |
| 3456 | return signal_levels; |
| 3457 | } |
| 3458 | |
Zhenyu Wang | e3421a1 | 2010-04-08 09:43:27 +0800 | [diff] [blame] | 3459 | /* Gen6's DP voltage swing and pre-emphasis control */ |
| 3460 | static uint32_t |
Daniel Vetter | 5829975c | 2015-04-16 11:36:52 +0200 | [diff] [blame] | 3461 | gen6_edp_signal_levels(uint8_t train_set) |
Zhenyu Wang | e3421a1 | 2010-04-08 09:43:27 +0800 | [diff] [blame] | 3462 | { |
Yuanhan Liu | 3c5a62b | 2011-01-06 18:26:08 +0800 | [diff] [blame] | 3463 | int signal_levels = train_set & (DP_TRAIN_VOLTAGE_SWING_MASK | |
| 3464 | DP_TRAIN_PRE_EMPHASIS_MASK); |
| 3465 | switch (signal_levels) { |
Sonika Jindal | bd60018 | 2014-08-08 16:23:41 +0530 | [diff] [blame] | 3466 | case DP_TRAIN_VOLTAGE_SWING_LEVEL_0 | DP_TRAIN_PRE_EMPH_LEVEL_0: |
| 3467 | case DP_TRAIN_VOLTAGE_SWING_LEVEL_1 | DP_TRAIN_PRE_EMPH_LEVEL_0: |
Yuanhan Liu | 3c5a62b | 2011-01-06 18:26:08 +0800 | [diff] [blame] | 3468 | return EDP_LINK_TRAIN_400_600MV_0DB_SNB_B; |
Sonika Jindal | bd60018 | 2014-08-08 16:23:41 +0530 | [diff] [blame] | 3469 | case DP_TRAIN_VOLTAGE_SWING_LEVEL_0 | DP_TRAIN_PRE_EMPH_LEVEL_1: |
Yuanhan Liu | 3c5a62b | 2011-01-06 18:26:08 +0800 | [diff] [blame] | 3470 | return EDP_LINK_TRAIN_400MV_3_5DB_SNB_B; |
Sonika Jindal | bd60018 | 2014-08-08 16:23:41 +0530 | [diff] [blame] | 3471 | case DP_TRAIN_VOLTAGE_SWING_LEVEL_0 | DP_TRAIN_PRE_EMPH_LEVEL_2: |
| 3472 | case DP_TRAIN_VOLTAGE_SWING_LEVEL_1 | DP_TRAIN_PRE_EMPH_LEVEL_2: |
Yuanhan Liu | 3c5a62b | 2011-01-06 18:26:08 +0800 | [diff] [blame] | 3473 | return EDP_LINK_TRAIN_400_600MV_6DB_SNB_B; |
Sonika Jindal | bd60018 | 2014-08-08 16:23:41 +0530 | [diff] [blame] | 3474 | case DP_TRAIN_VOLTAGE_SWING_LEVEL_1 | DP_TRAIN_PRE_EMPH_LEVEL_1: |
| 3475 | case DP_TRAIN_VOLTAGE_SWING_LEVEL_2 | DP_TRAIN_PRE_EMPH_LEVEL_1: |
Yuanhan Liu | 3c5a62b | 2011-01-06 18:26:08 +0800 | [diff] [blame] | 3476 | return EDP_LINK_TRAIN_600_800MV_3_5DB_SNB_B; |
Sonika Jindal | bd60018 | 2014-08-08 16:23:41 +0530 | [diff] [blame] | 3477 | case DP_TRAIN_VOLTAGE_SWING_LEVEL_2 | DP_TRAIN_PRE_EMPH_LEVEL_0: |
| 3478 | case DP_TRAIN_VOLTAGE_SWING_LEVEL_3 | DP_TRAIN_PRE_EMPH_LEVEL_0: |
Yuanhan Liu | 3c5a62b | 2011-01-06 18:26:08 +0800 | [diff] [blame] | 3479 | return EDP_LINK_TRAIN_800_1200MV_0DB_SNB_B; |
Zhenyu Wang | e3421a1 | 2010-04-08 09:43:27 +0800 | [diff] [blame] | 3480 | default: |
Yuanhan Liu | 3c5a62b | 2011-01-06 18:26:08 +0800 | [diff] [blame] | 3481 | DRM_DEBUG_KMS("Unsupported voltage swing/pre-emphasis level:" |
| 3482 | "0x%x\n", signal_levels); |
| 3483 | return EDP_LINK_TRAIN_400_600MV_0DB_SNB_B; |
Zhenyu Wang | e3421a1 | 2010-04-08 09:43:27 +0800 | [diff] [blame] | 3484 | } |
| 3485 | } |
| 3486 | |
Keith Packard | 1a2eb46 | 2011-11-16 16:26:07 -0800 | [diff] [blame] | 3487 | /* Gen7's DP voltage swing and pre-emphasis control */ |
| 3488 | static uint32_t |
Daniel Vetter | 5829975c | 2015-04-16 11:36:52 +0200 | [diff] [blame] | 3489 | gen7_edp_signal_levels(uint8_t train_set) |
Keith Packard | 1a2eb46 | 2011-11-16 16:26:07 -0800 | [diff] [blame] | 3490 | { |
| 3491 | int signal_levels = train_set & (DP_TRAIN_VOLTAGE_SWING_MASK | |
| 3492 | DP_TRAIN_PRE_EMPHASIS_MASK); |
| 3493 | switch (signal_levels) { |
Sonika Jindal | bd60018 | 2014-08-08 16:23:41 +0530 | [diff] [blame] | 3494 | case DP_TRAIN_VOLTAGE_SWING_LEVEL_0 | DP_TRAIN_PRE_EMPH_LEVEL_0: |
Keith Packard | 1a2eb46 | 2011-11-16 16:26:07 -0800 | [diff] [blame] | 3495 | return EDP_LINK_TRAIN_400MV_0DB_IVB; |
Sonika Jindal | bd60018 | 2014-08-08 16:23:41 +0530 | [diff] [blame] | 3496 | case DP_TRAIN_VOLTAGE_SWING_LEVEL_0 | DP_TRAIN_PRE_EMPH_LEVEL_1: |
Keith Packard | 1a2eb46 | 2011-11-16 16:26:07 -0800 | [diff] [blame] | 3497 | return EDP_LINK_TRAIN_400MV_3_5DB_IVB; |
Sonika Jindal | bd60018 | 2014-08-08 16:23:41 +0530 | [diff] [blame] | 3498 | case DP_TRAIN_VOLTAGE_SWING_LEVEL_0 | DP_TRAIN_PRE_EMPH_LEVEL_2: |
Keith Packard | 1a2eb46 | 2011-11-16 16:26:07 -0800 | [diff] [blame] | 3499 | return EDP_LINK_TRAIN_400MV_6DB_IVB; |
| 3500 | |
Sonika Jindal | bd60018 | 2014-08-08 16:23:41 +0530 | [diff] [blame] | 3501 | case DP_TRAIN_VOLTAGE_SWING_LEVEL_1 | DP_TRAIN_PRE_EMPH_LEVEL_0: |
Keith Packard | 1a2eb46 | 2011-11-16 16:26:07 -0800 | [diff] [blame] | 3502 | return EDP_LINK_TRAIN_600MV_0DB_IVB; |
Sonika Jindal | bd60018 | 2014-08-08 16:23:41 +0530 | [diff] [blame] | 3503 | case DP_TRAIN_VOLTAGE_SWING_LEVEL_1 | DP_TRAIN_PRE_EMPH_LEVEL_1: |
Keith Packard | 1a2eb46 | 2011-11-16 16:26:07 -0800 | [diff] [blame] | 3504 | return EDP_LINK_TRAIN_600MV_3_5DB_IVB; |
| 3505 | |
Sonika Jindal | bd60018 | 2014-08-08 16:23:41 +0530 | [diff] [blame] | 3506 | case DP_TRAIN_VOLTAGE_SWING_LEVEL_2 | DP_TRAIN_PRE_EMPH_LEVEL_0: |
Keith Packard | 1a2eb46 | 2011-11-16 16:26:07 -0800 | [diff] [blame] | 3507 | return EDP_LINK_TRAIN_800MV_0DB_IVB; |
Sonika Jindal | bd60018 | 2014-08-08 16:23:41 +0530 | [diff] [blame] | 3508 | case DP_TRAIN_VOLTAGE_SWING_LEVEL_2 | DP_TRAIN_PRE_EMPH_LEVEL_1: |
Keith Packard | 1a2eb46 | 2011-11-16 16:26:07 -0800 | [diff] [blame] | 3509 | return EDP_LINK_TRAIN_800MV_3_5DB_IVB; |
| 3510 | |
| 3511 | default: |
| 3512 | DRM_DEBUG_KMS("Unsupported voltage swing/pre-emphasis level:" |
| 3513 | "0x%x\n", signal_levels); |
| 3514 | return EDP_LINK_TRAIN_500MV_0DB_IVB; |
| 3515 | } |
| 3516 | } |
| 3517 | |
Ander Conselvan de Oliveira | 94223d0 | 2015-10-23 13:01:48 +0300 | [diff] [blame] | 3518 | void |
Ander Conselvan de Oliveira | f4eb692 | 2015-10-23 13:01:44 +0300 | [diff] [blame] | 3519 | intel_dp_set_signal_levels(struct intel_dp *intel_dp) |
Paulo Zanoni | f0a3424 | 2012-12-06 16:51:50 -0200 | [diff] [blame] | 3520 | { |
Ville Syrjälä | 2f77347 | 2017-11-09 17:27:58 +0200 | [diff] [blame] | 3521 | struct drm_i915_private *dev_priv = to_i915(intel_dp_to_dev(intel_dp)); |
Paulo Zanoni | f0a3424 | 2012-12-06 16:51:50 -0200 | [diff] [blame] | 3522 | struct intel_digital_port *intel_dig_port = dp_to_dig_port(intel_dp); |
Ville Syrjälä | 8f4f279 | 2017-11-09 17:24:34 +0200 | [diff] [blame] | 3523 | enum port port = intel_dig_port->base.port; |
David Weinehall | f8896f5 | 2015-06-25 11:11:03 +0300 | [diff] [blame] | 3524 | uint32_t signal_levels, mask = 0; |
Paulo Zanoni | f0a3424 | 2012-12-06 16:51:50 -0200 | [diff] [blame] | 3525 | uint8_t train_set = intel_dp->train_set[0]; |
| 3526 | |
Rodrigo Vivi | d509af6 | 2017-08-29 16:22:24 -0700 | [diff] [blame] | 3527 | if (IS_GEN9_LP(dev_priv) || IS_CANNONLAKE(dev_priv)) { |
| 3528 | signal_levels = bxt_signal_levels(intel_dp); |
| 3529 | } else if (HAS_DDI(dev_priv)) { |
David Weinehall | f8896f5 | 2015-06-25 11:11:03 +0300 | [diff] [blame] | 3530 | signal_levels = ddi_signal_levels(intel_dp); |
Rodrigo Vivi | d509af6 | 2017-08-29 16:22:24 -0700 | [diff] [blame] | 3531 | mask = DDI_BUF_EMP_MASK; |
Tvrtko Ursulin | 920a14b | 2016-10-14 10:13:44 +0100 | [diff] [blame] | 3532 | } else if (IS_CHERRYVIEW(dev_priv)) { |
Daniel Vetter | 5829975c | 2015-04-16 11:36:52 +0200 | [diff] [blame] | 3533 | signal_levels = chv_signal_levels(intel_dp); |
Tvrtko Ursulin | 11a914c | 2016-10-13 11:03:08 +0100 | [diff] [blame] | 3534 | } else if (IS_VALLEYVIEW(dev_priv)) { |
Daniel Vetter | 5829975c | 2015-04-16 11:36:52 +0200 | [diff] [blame] | 3535 | signal_levels = vlv_signal_levels(intel_dp); |
Tvrtko Ursulin | 5db9401 | 2016-10-13 11:03:10 +0100 | [diff] [blame] | 3536 | } else if (IS_GEN7(dev_priv) && port == PORT_A) { |
Daniel Vetter | 5829975c | 2015-04-16 11:36:52 +0200 | [diff] [blame] | 3537 | signal_levels = gen7_edp_signal_levels(train_set); |
Paulo Zanoni | f0a3424 | 2012-12-06 16:51:50 -0200 | [diff] [blame] | 3538 | mask = EDP_LINK_TRAIN_VOL_EMP_MASK_IVB; |
Tvrtko Ursulin | 5db9401 | 2016-10-13 11:03:10 +0100 | [diff] [blame] | 3539 | } else if (IS_GEN6(dev_priv) && port == PORT_A) { |
Daniel Vetter | 5829975c | 2015-04-16 11:36:52 +0200 | [diff] [blame] | 3540 | signal_levels = gen6_edp_signal_levels(train_set); |
Paulo Zanoni | f0a3424 | 2012-12-06 16:51:50 -0200 | [diff] [blame] | 3541 | mask = EDP_LINK_TRAIN_VOL_EMP_MASK_SNB; |
| 3542 | } else { |
Daniel Vetter | 5829975c | 2015-04-16 11:36:52 +0200 | [diff] [blame] | 3543 | signal_levels = gen4_signal_levels(train_set); |
Paulo Zanoni | f0a3424 | 2012-12-06 16:51:50 -0200 | [diff] [blame] | 3544 | mask = DP_VOLTAGE_MASK | DP_PRE_EMPHASIS_MASK; |
| 3545 | } |
| 3546 | |
Vandana Kannan | 96fb9f9 | 2014-11-18 15:45:27 +0530 | [diff] [blame] | 3547 | if (mask) |
| 3548 | DRM_DEBUG_KMS("Using signal levels %08x\n", signal_levels); |
| 3549 | |
| 3550 | DRM_DEBUG_KMS("Using vswing level %d\n", |
| 3551 | train_set & DP_TRAIN_VOLTAGE_SWING_MASK); |
| 3552 | DRM_DEBUG_KMS("Using pre-emphasis level %d\n", |
| 3553 | (train_set & DP_TRAIN_PRE_EMPHASIS_MASK) >> |
| 3554 | DP_TRAIN_PRE_EMPHASIS_SHIFT); |
Paulo Zanoni | f0a3424 | 2012-12-06 16:51:50 -0200 | [diff] [blame] | 3555 | |
Ander Conselvan de Oliveira | f4eb692 | 2015-10-23 13:01:44 +0300 | [diff] [blame] | 3556 | intel_dp->DP = (intel_dp->DP & ~mask) | signal_levels; |
Ander Conselvan de Oliveira | b905a91 | 2015-10-23 13:01:47 +0300 | [diff] [blame] | 3557 | |
| 3558 | I915_WRITE(intel_dp->output_reg, intel_dp->DP); |
| 3559 | POSTING_READ(intel_dp->output_reg); |
Paulo Zanoni | f0a3424 | 2012-12-06 16:51:50 -0200 | [diff] [blame] | 3560 | } |
| 3561 | |
Ander Conselvan de Oliveira | 94223d0 | 2015-10-23 13:01:48 +0300 | [diff] [blame] | 3562 | void |
Ander Conselvan de Oliveira | e9c176d | 2015-10-23 13:01:45 +0300 | [diff] [blame] | 3563 | intel_dp_program_link_training_pattern(struct intel_dp *intel_dp, |
| 3564 | uint8_t dp_train_pat) |
Keith Packard | a4fc5ed | 2009-04-07 16:16:42 -0700 | [diff] [blame] | 3565 | { |
Paulo Zanoni | 174edf1 | 2012-10-26 19:05:50 -0200 | [diff] [blame] | 3566 | struct intel_digital_port *intel_dig_port = dp_to_dig_port(intel_dp); |
Ville Syrjälä | 90a6b7b | 2015-07-06 16:39:15 +0300 | [diff] [blame] | 3567 | struct drm_i915_private *dev_priv = |
| 3568 | to_i915(intel_dig_port->base.base.dev); |
Keith Packard | a4fc5ed | 2009-04-07 16:16:42 -0700 | [diff] [blame] | 3569 | |
Ander Conselvan de Oliveira | f4eb692 | 2015-10-23 13:01:44 +0300 | [diff] [blame] | 3570 | _intel_dp_set_link_train(intel_dp, &intel_dp->DP, dp_train_pat); |
Paulo Zanoni | 47ea754 | 2012-07-17 16:55:16 -0300 | [diff] [blame] | 3571 | |
Ander Conselvan de Oliveira | f4eb692 | 2015-10-23 13:01:44 +0300 | [diff] [blame] | 3572 | I915_WRITE(intel_dp->output_reg, intel_dp->DP); |
Chris Wilson | ea5b213 | 2010-08-04 13:50:23 +0100 | [diff] [blame] | 3573 | POSTING_READ(intel_dp->output_reg); |
Ander Conselvan de Oliveira | e9c176d | 2015-10-23 13:01:45 +0300 | [diff] [blame] | 3574 | } |
| 3575 | |
Ander Conselvan de Oliveira | 94223d0 | 2015-10-23 13:01:48 +0300 | [diff] [blame] | 3576 | void intel_dp_set_idle_link_train(struct intel_dp *intel_dp) |
Imre Deak | 3ab9c63 | 2013-05-03 12:57:41 +0300 | [diff] [blame] | 3577 | { |
Ville Syrjälä | 2f77347 | 2017-11-09 17:27:58 +0200 | [diff] [blame] | 3578 | struct drm_i915_private *dev_priv = to_i915(intel_dp_to_dev(intel_dp)); |
Imre Deak | 3ab9c63 | 2013-05-03 12:57:41 +0300 | [diff] [blame] | 3579 | struct intel_digital_port *intel_dig_port = dp_to_dig_port(intel_dp); |
Ville Syrjälä | 8f4f279 | 2017-11-09 17:24:34 +0200 | [diff] [blame] | 3580 | enum port port = intel_dig_port->base.port; |
Imre Deak | 3ab9c63 | 2013-05-03 12:57:41 +0300 | [diff] [blame] | 3581 | uint32_t val; |
| 3582 | |
Tvrtko Ursulin | 4f8036a | 2016-10-13 11:02:52 +0100 | [diff] [blame] | 3583 | if (!HAS_DDI(dev_priv)) |
Imre Deak | 3ab9c63 | 2013-05-03 12:57:41 +0300 | [diff] [blame] | 3584 | return; |
| 3585 | |
| 3586 | val = I915_READ(DP_TP_CTL(port)); |
| 3587 | val &= ~DP_TP_CTL_LINK_TRAIN_MASK; |
| 3588 | val |= DP_TP_CTL_LINK_TRAIN_IDLE; |
| 3589 | I915_WRITE(DP_TP_CTL(port), val); |
| 3590 | |
| 3591 | /* |
| 3592 | * On PORT_A we can have only eDP in SST mode. There the only reason |
| 3593 | * we need to set idle transmission mode is to work around a HW issue |
| 3594 | * where we enable the pipe while not in idle link-training mode. |
| 3595 | * In this case there is requirement to wait for a minimum number of |
| 3596 | * idle patterns to be sent. |
| 3597 | */ |
| 3598 | if (port == PORT_A) |
| 3599 | return; |
| 3600 | |
Chris Wilson | a767017 | 2016-06-30 15:33:10 +0100 | [diff] [blame] | 3601 | if (intel_wait_for_register(dev_priv,DP_TP_STATUS(port), |
| 3602 | DP_TP_STATUS_IDLE_DONE, |
| 3603 | DP_TP_STATUS_IDLE_DONE, |
| 3604 | 1)) |
Imre Deak | 3ab9c63 | 2013-05-03 12:57:41 +0300 | [diff] [blame] | 3605 | DRM_ERROR("Timed out waiting for DP idle patterns\n"); |
| 3606 | } |
| 3607 | |
Keith Packard | a4fc5ed | 2009-04-07 16:16:42 -0700 | [diff] [blame] | 3608 | static void |
Ville Syrjälä | adc1030 | 2017-10-31 22:51:14 +0200 | [diff] [blame] | 3609 | intel_dp_link_down(struct intel_encoder *encoder, |
| 3610 | const struct intel_crtc_state *old_crtc_state) |
Keith Packard | a4fc5ed | 2009-04-07 16:16:42 -0700 | [diff] [blame] | 3611 | { |
Ville Syrjälä | adc1030 | 2017-10-31 22:51:14 +0200 | [diff] [blame] | 3612 | struct drm_i915_private *dev_priv = to_i915(encoder->base.dev); |
| 3613 | struct intel_dp *intel_dp = enc_to_intel_dp(&encoder->base); |
| 3614 | struct intel_crtc *crtc = to_intel_crtc(old_crtc_state->base.crtc); |
| 3615 | enum port port = encoder->port; |
Chris Wilson | ea5b213 | 2010-08-04 13:50:23 +0100 | [diff] [blame] | 3616 | uint32_t DP = intel_dp->DP; |
Keith Packard | a4fc5ed | 2009-04-07 16:16:42 -0700 | [diff] [blame] | 3617 | |
Tvrtko Ursulin | 4f8036a | 2016-10-13 11:02:52 +0100 | [diff] [blame] | 3618 | if (WARN_ON(HAS_DDI(dev_priv))) |
Paulo Zanoni | c19b066 | 2012-10-15 15:51:41 -0300 | [diff] [blame] | 3619 | return; |
| 3620 | |
Daniel Vetter | 0c33d8d | 2012-09-06 22:15:43 +0200 | [diff] [blame] | 3621 | if (WARN_ON((I915_READ(intel_dp->output_reg) & DP_PORT_EN) == 0)) |
Chris Wilson | 1b39d6f | 2010-12-06 11:20:45 +0000 | [diff] [blame] | 3622 | return; |
| 3623 | |
Zhao Yakui | 28c9773 | 2009-10-09 11:39:41 +0800 | [diff] [blame] | 3624 | DRM_DEBUG_KMS("\n"); |
Zhenyu Wang | 32f9d65 | 2009-07-24 01:00:32 +0800 | [diff] [blame] | 3625 | |
Tvrtko Ursulin | 5db9401 | 2016-10-13 11:03:10 +0100 | [diff] [blame] | 3626 | if ((IS_GEN7(dev_priv) && port == PORT_A) || |
Tvrtko Ursulin | 6e26695 | 2016-10-13 11:02:53 +0100 | [diff] [blame] | 3627 | (HAS_PCH_CPT(dev_priv) && port != PORT_A)) { |
Zhenyu Wang | e3421a1 | 2010-04-08 09:43:27 +0800 | [diff] [blame] | 3628 | DP &= ~DP_LINK_TRAIN_MASK_CPT; |
Ville Syrjälä | 1612c8b | 2015-05-05 17:17:34 +0300 | [diff] [blame] | 3629 | DP |= DP_LINK_TRAIN_PAT_IDLE_CPT; |
Zhenyu Wang | e3421a1 | 2010-04-08 09:43:27 +0800 | [diff] [blame] | 3630 | } else { |
Tvrtko Ursulin | 920a14b | 2016-10-14 10:13:44 +0100 | [diff] [blame] | 3631 | if (IS_CHERRYVIEW(dev_priv)) |
Ville Syrjälä | aad3d14 | 2014-06-28 02:04:25 +0300 | [diff] [blame] | 3632 | DP &= ~DP_LINK_TRAIN_MASK_CHV; |
| 3633 | else |
| 3634 | DP &= ~DP_LINK_TRAIN_MASK; |
Ville Syrjälä | 1612c8b | 2015-05-05 17:17:34 +0300 | [diff] [blame] | 3635 | DP |= DP_LINK_TRAIN_PAT_IDLE; |
Zhenyu Wang | e3421a1 | 2010-04-08 09:43:27 +0800 | [diff] [blame] | 3636 | } |
Ville Syrjälä | 1612c8b | 2015-05-05 17:17:34 +0300 | [diff] [blame] | 3637 | I915_WRITE(intel_dp->output_reg, DP); |
Chris Wilson | fe255d0 | 2010-09-11 21:37:48 +0100 | [diff] [blame] | 3638 | POSTING_READ(intel_dp->output_reg); |
Zhenyu Wang | 5eb08b6 | 2009-07-24 01:00:31 +0800 | [diff] [blame] | 3639 | |
Ville Syrjälä | 1612c8b | 2015-05-05 17:17:34 +0300 | [diff] [blame] | 3640 | DP &= ~(DP_PORT_EN | DP_AUDIO_OUTPUT_ENABLE); |
| 3641 | I915_WRITE(intel_dp->output_reg, DP); |
| 3642 | POSTING_READ(intel_dp->output_reg); |
| 3643 | |
| 3644 | /* |
| 3645 | * HW workaround for IBX, we need to move the port |
| 3646 | * to transcoder A after disabling it to allow the |
| 3647 | * matching HDMI port to be enabled on transcoder A. |
| 3648 | */ |
Tvrtko Ursulin | 6e26695 | 2016-10-13 11:02:53 +0100 | [diff] [blame] | 3649 | if (HAS_PCH_IBX(dev_priv) && crtc->pipe == PIPE_B && port != PORT_A) { |
Ville Syrjälä | 0c241d5 | 2015-10-30 19:23:22 +0200 | [diff] [blame] | 3650 | /* |
| 3651 | * We get CPU/PCH FIFO underruns on the other pipe when |
| 3652 | * doing the workaround. Sweep them under the rug. |
| 3653 | */ |
| 3654 | intel_set_cpu_fifo_underrun_reporting(dev_priv, PIPE_A, false); |
| 3655 | intel_set_pch_fifo_underrun_reporting(dev_priv, PIPE_A, false); |
| 3656 | |
Ville Syrjälä | 1612c8b | 2015-05-05 17:17:34 +0300 | [diff] [blame] | 3657 | /* always enable with pattern 1 (as per spec) */ |
| 3658 | DP &= ~(DP_PIPEB_SELECT | DP_LINK_TRAIN_MASK); |
| 3659 | DP |= DP_PORT_EN | DP_LINK_TRAIN_PAT_1; |
| 3660 | I915_WRITE(intel_dp->output_reg, DP); |
| 3661 | POSTING_READ(intel_dp->output_reg); |
| 3662 | |
| 3663 | DP &= ~DP_PORT_EN; |
Eric Anholt | 5bddd17 | 2010-11-18 09:32:59 +0800 | [diff] [blame] | 3664 | I915_WRITE(intel_dp->output_reg, DP); |
Daniel Vetter | 0ca0968 | 2014-11-24 16:54:11 +0100 | [diff] [blame] | 3665 | POSTING_READ(intel_dp->output_reg); |
Ville Syrjälä | 0c241d5 | 2015-10-30 19:23:22 +0200 | [diff] [blame] | 3666 | |
Ville Syrjälä | 0f0f74b | 2016-10-31 22:37:06 +0200 | [diff] [blame] | 3667 | intel_wait_for_vblank_if_active(dev_priv, PIPE_A); |
Ville Syrjälä | 0c241d5 | 2015-10-30 19:23:22 +0200 | [diff] [blame] | 3668 | intel_set_cpu_fifo_underrun_reporting(dev_priv, PIPE_A, true); |
| 3669 | intel_set_pch_fifo_underrun_reporting(dev_priv, PIPE_A, true); |
Eric Anholt | 5bddd17 | 2010-11-18 09:32:59 +0800 | [diff] [blame] | 3670 | } |
| 3671 | |
Keith Packard | f01eca2 | 2011-09-28 16:48:10 -0700 | [diff] [blame] | 3672 | msleep(intel_dp->panel_power_down_delay); |
Ville Syrjälä | 6fec766 | 2015-11-10 16:16:17 +0200 | [diff] [blame] | 3673 | |
| 3674 | intel_dp->DP = DP; |
Ville Syrjälä | 9f2bdb0 | 2016-12-14 20:00:23 +0200 | [diff] [blame] | 3675 | |
| 3676 | if (IS_VALLEYVIEW(dev_priv) || IS_CHERRYVIEW(dev_priv)) { |
| 3677 | pps_lock(intel_dp); |
| 3678 | intel_dp->active_pipe = INVALID_PIPE; |
| 3679 | pps_unlock(intel_dp); |
| 3680 | } |
Keith Packard | a4fc5ed | 2009-04-07 16:16:42 -0700 | [diff] [blame] | 3681 | } |
| 3682 | |
Imre Deak | 24e807e | 2016-10-24 19:33:28 +0300 | [diff] [blame] | 3683 | bool |
Ville Syrjälä | fe5a66f | 2016-07-29 16:52:39 +0300 | [diff] [blame] | 3684 | intel_dp_read_dpcd(struct intel_dp *intel_dp) |
Keith Packard | 92fd8fd | 2011-07-25 19:50:10 -0700 | [diff] [blame] | 3685 | { |
Lyude | 9f085eb | 2016-04-13 10:58:33 -0400 | [diff] [blame] | 3686 | if (drm_dp_dpcd_read(&intel_dp->aux, 0x000, intel_dp->dpcd, |
| 3687 | sizeof(intel_dp->dpcd)) < 0) |
Adam Jackson | edb3924 | 2012-09-18 10:58:49 -0400 | [diff] [blame] | 3688 | return false; /* aux transfer failed */ |
Keith Packard | 92fd8fd | 2011-07-25 19:50:10 -0700 | [diff] [blame] | 3689 | |
Andy Shevchenko | a8e9815 | 2014-09-01 14:12:01 +0300 | [diff] [blame] | 3690 | DRM_DEBUG_KMS("DPCD: %*ph\n", (int) sizeof(intel_dp->dpcd), intel_dp->dpcd); |
Damien Lespiau | 577c7a5 | 2012-12-13 16:09:02 +0000 | [diff] [blame] | 3691 | |
Ville Syrjälä | fe5a66f | 2016-07-29 16:52:39 +0300 | [diff] [blame] | 3692 | return intel_dp->dpcd[DP_DPCD_REV] != 0; |
| 3693 | } |
| 3694 | |
| 3695 | static bool |
| 3696 | intel_edp_init_dpcd(struct intel_dp *intel_dp) |
| 3697 | { |
| 3698 | struct drm_i915_private *dev_priv = |
| 3699 | to_i915(dp_to_dig_port(intel_dp)->base.base.dev); |
| 3700 | |
| 3701 | /* this function is meant to be called only once */ |
| 3702 | WARN_ON(intel_dp->dpcd[DP_DPCD_REV] != 0); |
| 3703 | |
| 3704 | if (!intel_dp_read_dpcd(intel_dp)) |
| 3705 | return false; |
| 3706 | |
Jani Nikula | 84c3675 | 2017-05-18 14:10:23 +0300 | [diff] [blame] | 3707 | drm_dp_read_desc(&intel_dp->aux, &intel_dp->desc, |
| 3708 | drm_dp_is_branch(intel_dp->dpcd)); |
Imre Deak | 12a47a42 | 2016-10-24 19:33:29 +0300 | [diff] [blame] | 3709 | |
Ville Syrjälä | fe5a66f | 2016-07-29 16:52:39 +0300 | [diff] [blame] | 3710 | if (intel_dp->dpcd[DP_DPCD_REV] >= 0x11) |
| 3711 | dev_priv->no_aux_handshake = intel_dp->dpcd[DP_MAX_DOWNSPREAD] & |
| 3712 | DP_NO_AUX_HANDSHAKE_LINK_TRAINING; |
| 3713 | |
| 3714 | /* Check if the panel supports PSR */ |
| 3715 | drm_dp_dpcd_read(&intel_dp->aux, DP_PSR_SUPPORT, |
| 3716 | intel_dp->psr_dpcd, |
| 3717 | sizeof(intel_dp->psr_dpcd)); |
| 3718 | if (intel_dp->psr_dpcd[0] & DP_PSR_IS_SUPPORTED) { |
| 3719 | dev_priv->psr.sink_support = true; |
| 3720 | DRM_DEBUG_KMS("Detected EDP PSR Panel.\n"); |
| 3721 | } |
| 3722 | |
| 3723 | if (INTEL_GEN(dev_priv) >= 9 && |
| 3724 | (intel_dp->psr_dpcd[0] & DP_PSR2_IS_SUPPORTED)) { |
| 3725 | uint8_t frame_sync_cap; |
| 3726 | |
| 3727 | dev_priv->psr.sink_support = true; |
Imre Deak | 9bacd4b | 2017-05-10 12:21:48 +0300 | [diff] [blame] | 3728 | if (drm_dp_dpcd_readb(&intel_dp->aux, |
| 3729 | DP_SINK_DEVICE_AUX_FRAME_SYNC_CAP, |
| 3730 | &frame_sync_cap) != 1) |
| 3731 | frame_sync_cap = 0; |
Ville Syrjälä | fe5a66f | 2016-07-29 16:52:39 +0300 | [diff] [blame] | 3732 | dev_priv->psr.aux_frame_sync = frame_sync_cap ? true : false; |
| 3733 | /* PSR2 needs frame sync as well */ |
| 3734 | dev_priv->psr.psr2_support = dev_priv->psr.aux_frame_sync; |
| 3735 | DRM_DEBUG_KMS("PSR2 %s on sink", |
| 3736 | dev_priv->psr.psr2_support ? "supported" : "not supported"); |
Nagaraju, Vathsala | 97da2ef | 2017-01-02 17:00:55 +0530 | [diff] [blame] | 3737 | |
| 3738 | if (dev_priv->psr.psr2_support) { |
| 3739 | dev_priv->psr.y_cord_support = |
| 3740 | intel_dp_get_y_cord_status(intel_dp); |
| 3741 | dev_priv->psr.colorimetry_support = |
| 3742 | intel_dp_get_colorimetry_status(intel_dp); |
Nagaraju, Vathsala | 340c93c | 2017-01-02 17:00:58 +0530 | [diff] [blame] | 3743 | dev_priv->psr.alpm = |
| 3744 | intel_dp_get_alpm_status(intel_dp); |
Nagaraju, Vathsala | 97da2ef | 2017-01-02 17:00:55 +0530 | [diff] [blame] | 3745 | } |
| 3746 | |
Ville Syrjälä | fe5a66f | 2016-07-29 16:52:39 +0300 | [diff] [blame] | 3747 | } |
| 3748 | |
Jani Nikula | 7c838e2 | 2017-10-26 17:29:31 +0300 | [diff] [blame] | 3749 | /* |
| 3750 | * Read the eDP display control registers. |
| 3751 | * |
| 3752 | * Do this independent of DP_DPCD_DISPLAY_CONTROL_CAPABLE bit in |
| 3753 | * DP_EDP_CONFIGURATION_CAP, because some buggy displays do not have it |
| 3754 | * set, but require eDP 1.4+ detection (e.g. for supported link rates |
| 3755 | * method). The display control registers should read zero if they're |
| 3756 | * not supported anyway. |
| 3757 | */ |
| 3758 | if (drm_dp_dpcd_read(&intel_dp->aux, DP_EDP_DPCD_REV, |
Dan Carpenter | f7170e2 | 2016-10-13 11:55:08 +0300 | [diff] [blame] | 3759 | intel_dp->edp_dpcd, sizeof(intel_dp->edp_dpcd)) == |
| 3760 | sizeof(intel_dp->edp_dpcd)) |
Jani Nikula | e6ed2a1 | 2017-10-26 17:29:32 +0300 | [diff] [blame] | 3761 | DRM_DEBUG_KMS("eDP DPCD: %*ph\n", (int) sizeof(intel_dp->edp_dpcd), |
Ville Syrjälä | fe5a66f | 2016-07-29 16:52:39 +0300 | [diff] [blame] | 3762 | intel_dp->edp_dpcd); |
| 3763 | |
Jani Nikula | e6ed2a1 | 2017-10-26 17:29:32 +0300 | [diff] [blame] | 3764 | /* Read the eDP 1.4+ supported link rates. */ |
| 3765 | if (intel_dp->edp_dpcd[0] >= DP_EDP_14) { |
Ville Syrjälä | fe5a66f | 2016-07-29 16:52:39 +0300 | [diff] [blame] | 3766 | __le16 sink_rates[DP_MAX_SUPPORTED_RATES]; |
| 3767 | int i; |
| 3768 | |
| 3769 | drm_dp_dpcd_read(&intel_dp->aux, DP_SUPPORTED_LINK_RATES, |
| 3770 | sink_rates, sizeof(sink_rates)); |
| 3771 | |
| 3772 | for (i = 0; i < ARRAY_SIZE(sink_rates); i++) { |
| 3773 | int val = le16_to_cpu(sink_rates[i]); |
| 3774 | |
| 3775 | if (val == 0) |
| 3776 | break; |
| 3777 | |
Dhinakaran Pandiyan | fd81c44 | 2016-11-14 13:50:20 -0800 | [diff] [blame] | 3778 | /* Value read multiplied by 200kHz gives the per-lane |
| 3779 | * link rate in kHz. The source rates are, however, |
| 3780 | * stored in terms of LS_Clk kHz. The full conversion |
| 3781 | * back to symbols is |
| 3782 | * (val * 200kHz)*(8/10 ch. encoding)*(1/8 bit to Byte) |
| 3783 | */ |
Ville Syrjälä | fe5a66f | 2016-07-29 16:52:39 +0300 | [diff] [blame] | 3784 | intel_dp->sink_rates[i] = (val * 200) / 10; |
| 3785 | } |
| 3786 | intel_dp->num_sink_rates = i; |
| 3787 | } |
| 3788 | |
Jani Nikula | e6ed2a1 | 2017-10-26 17:29:32 +0300 | [diff] [blame] | 3789 | /* |
| 3790 | * Use DP_LINK_RATE_SET if DP_SUPPORTED_LINK_RATES are available, |
| 3791 | * default to DP_MAX_LINK_RATE and DP_LINK_BW_SET otherwise. |
| 3792 | */ |
Jani Nikula | 68f357c | 2017-03-28 17:59:05 +0300 | [diff] [blame] | 3793 | if (intel_dp->num_sink_rates) |
| 3794 | intel_dp->use_rate_select = true; |
| 3795 | else |
| 3796 | intel_dp_set_sink_rates(intel_dp); |
| 3797 | |
Jani Nikula | 975ee5fca | 2017-04-06 16:44:10 +0300 | [diff] [blame] | 3798 | intel_dp_set_common_rates(intel_dp); |
| 3799 | |
Ville Syrjälä | fe5a66f | 2016-07-29 16:52:39 +0300 | [diff] [blame] | 3800 | return true; |
| 3801 | } |
| 3802 | |
| 3803 | |
| 3804 | static bool |
| 3805 | intel_dp_get_dpcd(struct intel_dp *intel_dp) |
| 3806 | { |
Jani Nikula | 27dbefb | 2017-04-06 16:44:17 +0300 | [diff] [blame] | 3807 | u8 sink_count; |
| 3808 | |
Ville Syrjälä | fe5a66f | 2016-07-29 16:52:39 +0300 | [diff] [blame] | 3809 | if (!intel_dp_read_dpcd(intel_dp)) |
| 3810 | return false; |
Adam Jackson | edb3924 | 2012-09-18 10:58:49 -0400 | [diff] [blame] | 3811 | |
Jani Nikula | 68f357c | 2017-03-28 17:59:05 +0300 | [diff] [blame] | 3812 | /* Don't clobber cached eDP rates. */ |
Jani Nikula | 1853a9d | 2017-08-18 12:30:20 +0300 | [diff] [blame] | 3813 | if (!intel_dp_is_edp(intel_dp)) { |
Jani Nikula | 68f357c | 2017-03-28 17:59:05 +0300 | [diff] [blame] | 3814 | intel_dp_set_sink_rates(intel_dp); |
Jani Nikula | 975ee5fca | 2017-04-06 16:44:10 +0300 | [diff] [blame] | 3815 | intel_dp_set_common_rates(intel_dp); |
| 3816 | } |
Jani Nikula | 68f357c | 2017-03-28 17:59:05 +0300 | [diff] [blame] | 3817 | |
Jani Nikula | 27dbefb | 2017-04-06 16:44:17 +0300 | [diff] [blame] | 3818 | if (drm_dp_dpcd_readb(&intel_dp->aux, DP_SINK_COUNT, &sink_count) <= 0) |
Shubhangi Shrivastava | 30d9aa4 | 2016-03-30 18:05:25 +0530 | [diff] [blame] | 3819 | return false; |
| 3820 | |
| 3821 | /* |
| 3822 | * Sink count can change between short pulse hpd hence |
| 3823 | * a member variable in intel_dp will track any changes |
| 3824 | * between short pulse interrupts. |
| 3825 | */ |
Jani Nikula | 27dbefb | 2017-04-06 16:44:17 +0300 | [diff] [blame] | 3826 | intel_dp->sink_count = DP_GET_SINK_COUNT(sink_count); |
Shubhangi Shrivastava | 30d9aa4 | 2016-03-30 18:05:25 +0530 | [diff] [blame] | 3827 | |
| 3828 | /* |
| 3829 | * SINK_COUNT == 0 and DOWNSTREAM_PORT_PRESENT == 1 implies that |
| 3830 | * a dongle is present but no display. Unless we require to know |
| 3831 | * if a dongle is present or not, we don't need to update |
| 3832 | * downstream port information. So, an early return here saves |
| 3833 | * time from performing other operations which are not required. |
| 3834 | */ |
Jani Nikula | 1853a9d | 2017-08-18 12:30:20 +0300 | [diff] [blame] | 3835 | if (!intel_dp_is_edp(intel_dp) && !intel_dp->sink_count) |
Shubhangi Shrivastava | 30d9aa4 | 2016-03-30 18:05:25 +0530 | [diff] [blame] | 3836 | return false; |
| 3837 | |
Imre Deak | c726ad0 | 2016-10-24 19:33:24 +0300 | [diff] [blame] | 3838 | if (!drm_dp_is_branch(intel_dp->dpcd)) |
Adam Jackson | edb3924 | 2012-09-18 10:58:49 -0400 | [diff] [blame] | 3839 | return true; /* native DP sink */ |
| 3840 | |
| 3841 | if (intel_dp->dpcd[DP_DPCD_REV] == 0x10) |
| 3842 | return true; /* no per-port downstream info */ |
| 3843 | |
Lyude | 9f085eb | 2016-04-13 10:58:33 -0400 | [diff] [blame] | 3844 | if (drm_dp_dpcd_read(&intel_dp->aux, DP_DOWNSTREAM_PORT_0, |
| 3845 | intel_dp->downstream_ports, |
| 3846 | DP_MAX_DOWNSTREAM_PORTS) < 0) |
Adam Jackson | edb3924 | 2012-09-18 10:58:49 -0400 | [diff] [blame] | 3847 | return false; /* downstream port status fetch failed */ |
| 3848 | |
| 3849 | return true; |
Keith Packard | 92fd8fd | 2011-07-25 19:50:10 -0700 | [diff] [blame] | 3850 | } |
| 3851 | |
Dave Airlie | 0e32b39 | 2014-05-02 14:02:48 +1000 | [diff] [blame] | 3852 | static bool |
Ville Syrjälä | c4e3170 | 2016-07-29 16:51:16 +0300 | [diff] [blame] | 3853 | intel_dp_can_mst(struct intel_dp *intel_dp) |
Dave Airlie | 0e32b39 | 2014-05-02 14:02:48 +1000 | [diff] [blame] | 3854 | { |
Jani Nikula | 010b9b3 | 2017-04-06 16:44:16 +0300 | [diff] [blame] | 3855 | u8 mstm_cap; |
Dave Airlie | 0e32b39 | 2014-05-02 14:02:48 +1000 | [diff] [blame] | 3856 | |
Michal Wajdeczko | 4f044a8 | 2017-09-19 19:38:44 +0000 | [diff] [blame] | 3857 | if (!i915_modparams.enable_dp_mst) |
Nathan Schulte | 7cc9613 | 2016-03-15 10:14:05 -0500 | [diff] [blame] | 3858 | return false; |
| 3859 | |
Dave Airlie | 0e32b39 | 2014-05-02 14:02:48 +1000 | [diff] [blame] | 3860 | if (!intel_dp->can_mst) |
| 3861 | return false; |
| 3862 | |
| 3863 | if (intel_dp->dpcd[DP_DPCD_REV] < 0x12) |
| 3864 | return false; |
| 3865 | |
Jani Nikula | 010b9b3 | 2017-04-06 16:44:16 +0300 | [diff] [blame] | 3866 | if (drm_dp_dpcd_readb(&intel_dp->aux, DP_MSTM_CAP, &mstm_cap) != 1) |
Ville Syrjälä | c4e3170 | 2016-07-29 16:51:16 +0300 | [diff] [blame] | 3867 | return false; |
Dave Airlie | 0e32b39 | 2014-05-02 14:02:48 +1000 | [diff] [blame] | 3868 | |
Jani Nikula | 010b9b3 | 2017-04-06 16:44:16 +0300 | [diff] [blame] | 3869 | return mstm_cap & DP_MST_CAP; |
Ville Syrjälä | c4e3170 | 2016-07-29 16:51:16 +0300 | [diff] [blame] | 3870 | } |
| 3871 | |
| 3872 | static void |
| 3873 | intel_dp_configure_mst(struct intel_dp *intel_dp) |
| 3874 | { |
Michal Wajdeczko | 4f044a8 | 2017-09-19 19:38:44 +0000 | [diff] [blame] | 3875 | if (!i915_modparams.enable_dp_mst) |
Ville Syrjälä | c4e3170 | 2016-07-29 16:51:16 +0300 | [diff] [blame] | 3876 | return; |
| 3877 | |
| 3878 | if (!intel_dp->can_mst) |
| 3879 | return; |
| 3880 | |
| 3881 | intel_dp->is_mst = intel_dp_can_mst(intel_dp); |
| 3882 | |
| 3883 | if (intel_dp->is_mst) |
| 3884 | DRM_DEBUG_KMS("Sink is MST capable\n"); |
| 3885 | else |
| 3886 | DRM_DEBUG_KMS("Sink is not MST capable\n"); |
| 3887 | |
| 3888 | drm_dp_mst_topology_mgr_set_mst(&intel_dp->mst_mgr, |
| 3889 | intel_dp->is_mst); |
Dave Airlie | 0e32b39 | 2014-05-02 14:02:48 +1000 | [diff] [blame] | 3890 | } |
| 3891 | |
Maarten Lankhorst | 9331353 | 2017-11-10 12:34:59 +0100 | [diff] [blame] | 3892 | static int intel_dp_sink_crc_stop(struct intel_dp *intel_dp, |
| 3893 | struct intel_crtc_state *crtc_state, bool disable_wa) |
Rodrigo Vivi | d2e216d | 2014-01-24 13:36:17 -0200 | [diff] [blame] | 3894 | { |
Rodrigo Vivi | 082dcc7 | 2015-07-30 16:26:39 -0700 | [diff] [blame] | 3895 | struct intel_digital_port *dig_port = dp_to_dig_port(intel_dp); |
Ville Syrjälä | 0f0f74b | 2016-10-31 22:37:06 +0200 | [diff] [blame] | 3896 | struct drm_i915_private *dev_priv = to_i915(dig_port->base.base.dev); |
Maarten Lankhorst | 9331353 | 2017-11-10 12:34:59 +0100 | [diff] [blame] | 3897 | struct intel_crtc *intel_crtc = to_intel_crtc(crtc_state->base.crtc); |
Rodrigo Vivi | ad9dc91 | 2014-09-16 19:18:12 -0400 | [diff] [blame] | 3898 | u8 buf; |
Rodrigo Vivi | e5a1cab | 2015-07-23 16:35:48 -0700 | [diff] [blame] | 3899 | int ret = 0; |
Rodrigo Vivi | c629784 | 2015-11-05 10:50:20 -0800 | [diff] [blame] | 3900 | int count = 0; |
| 3901 | int attempts = 10; |
Paulo Zanoni | 4373f0f | 2015-05-25 18:52:29 -0300 | [diff] [blame] | 3902 | |
| 3903 | if (drm_dp_dpcd_readb(&intel_dp->aux, DP_TEST_SINK, &buf) < 0) { |
Rodrigo Vivi | 082dcc7 | 2015-07-30 16:26:39 -0700 | [diff] [blame] | 3904 | DRM_DEBUG_KMS("Sink CRC couldn't be stopped properly\n"); |
Rodrigo Vivi | e5a1cab | 2015-07-23 16:35:48 -0700 | [diff] [blame] | 3905 | ret = -EIO; |
| 3906 | goto out; |
Paulo Zanoni | 4373f0f | 2015-05-25 18:52:29 -0300 | [diff] [blame] | 3907 | } |
Rodrigo Vivi | d2e216d | 2014-01-24 13:36:17 -0200 | [diff] [blame] | 3908 | |
Rodrigo Vivi | d2e216d | 2014-01-24 13:36:17 -0200 | [diff] [blame] | 3909 | if (drm_dp_dpcd_writeb(&intel_dp->aux, DP_TEST_SINK, |
Rodrigo Vivi | e5a1cab | 2015-07-23 16:35:48 -0700 | [diff] [blame] | 3910 | buf & ~DP_TEST_SINK_START) < 0) { |
Rodrigo Vivi | 082dcc7 | 2015-07-30 16:26:39 -0700 | [diff] [blame] | 3911 | DRM_DEBUG_KMS("Sink CRC couldn't be stopped properly\n"); |
Rodrigo Vivi | e5a1cab | 2015-07-23 16:35:48 -0700 | [diff] [blame] | 3912 | ret = -EIO; |
| 3913 | goto out; |
| 3914 | } |
Rodrigo Vivi | 082dcc7 | 2015-07-30 16:26:39 -0700 | [diff] [blame] | 3915 | |
Rodrigo Vivi | c629784 | 2015-11-05 10:50:20 -0800 | [diff] [blame] | 3916 | do { |
Ville Syrjälä | 0f0f74b | 2016-10-31 22:37:06 +0200 | [diff] [blame] | 3917 | intel_wait_for_vblank(dev_priv, intel_crtc->pipe); |
Rodrigo Vivi | c629784 | 2015-11-05 10:50:20 -0800 | [diff] [blame] | 3918 | |
| 3919 | if (drm_dp_dpcd_readb(&intel_dp->aux, |
| 3920 | DP_TEST_SINK_MISC, &buf) < 0) { |
| 3921 | ret = -EIO; |
| 3922 | goto out; |
| 3923 | } |
| 3924 | count = buf & DP_TEST_COUNT_MASK; |
| 3925 | } while (--attempts && count); |
| 3926 | |
| 3927 | if (attempts == 0) { |
Rodrigo Vivi | dc5a903 | 2016-01-29 14:44:59 -0800 | [diff] [blame] | 3928 | DRM_DEBUG_KMS("TIMEOUT: Sink CRC counter is not zeroed after calculation is stopped\n"); |
Rodrigo Vivi | c629784 | 2015-11-05 10:50:20 -0800 | [diff] [blame] | 3929 | ret = -ETIMEDOUT; |
| 3930 | } |
| 3931 | |
Rodrigo Vivi | e5a1cab | 2015-07-23 16:35:48 -0700 | [diff] [blame] | 3932 | out: |
Maarten Lankhorst | 9331353 | 2017-11-10 12:34:59 +0100 | [diff] [blame] | 3933 | if (disable_wa) |
Maarten Lankhorst | 199ea38 | 2017-11-10 12:35:00 +0100 | [diff] [blame] | 3934 | hsw_enable_ips(crtc_state); |
Rodrigo Vivi | e5a1cab | 2015-07-23 16:35:48 -0700 | [diff] [blame] | 3935 | return ret; |
Rodrigo Vivi | 082dcc7 | 2015-07-30 16:26:39 -0700 | [diff] [blame] | 3936 | } |
| 3937 | |
Maarten Lankhorst | 9331353 | 2017-11-10 12:34:59 +0100 | [diff] [blame] | 3938 | static int intel_dp_sink_crc_start(struct intel_dp *intel_dp, |
| 3939 | struct intel_crtc_state *crtc_state) |
Rodrigo Vivi | 082dcc7 | 2015-07-30 16:26:39 -0700 | [diff] [blame] | 3940 | { |
| 3941 | struct intel_digital_port *dig_port = dp_to_dig_port(intel_dp); |
Ville Syrjälä | 0f0f74b | 2016-10-31 22:37:06 +0200 | [diff] [blame] | 3942 | struct drm_i915_private *dev_priv = to_i915(dig_port->base.base.dev); |
Maarten Lankhorst | 9331353 | 2017-11-10 12:34:59 +0100 | [diff] [blame] | 3943 | struct intel_crtc *intel_crtc = to_intel_crtc(crtc_state->base.crtc); |
Rodrigo Vivi | 082dcc7 | 2015-07-30 16:26:39 -0700 | [diff] [blame] | 3944 | u8 buf; |
Rodrigo Vivi | e5a1cab | 2015-07-23 16:35:48 -0700 | [diff] [blame] | 3945 | int ret; |
| 3946 | |
Rodrigo Vivi | 082dcc7 | 2015-07-30 16:26:39 -0700 | [diff] [blame] | 3947 | if (drm_dp_dpcd_readb(&intel_dp->aux, DP_TEST_SINK_MISC, &buf) < 0) |
| 3948 | return -EIO; |
| 3949 | |
| 3950 | if (!(buf & DP_TEST_CRC_SUPPORTED)) |
| 3951 | return -ENOTTY; |
| 3952 | |
| 3953 | if (drm_dp_dpcd_readb(&intel_dp->aux, DP_TEST_SINK, &buf) < 0) |
| 3954 | return -EIO; |
| 3955 | |
Rodrigo Vivi | 6d8175d | 2015-11-05 10:50:22 -0800 | [diff] [blame] | 3956 | if (buf & DP_TEST_SINK_START) { |
Maarten Lankhorst | 9331353 | 2017-11-10 12:34:59 +0100 | [diff] [blame] | 3957 | ret = intel_dp_sink_crc_stop(intel_dp, crtc_state, false); |
Rodrigo Vivi | 6d8175d | 2015-11-05 10:50:22 -0800 | [diff] [blame] | 3958 | if (ret) |
| 3959 | return ret; |
| 3960 | } |
| 3961 | |
Maarten Lankhorst | 199ea38 | 2017-11-10 12:35:00 +0100 | [diff] [blame] | 3962 | hsw_disable_ips(crtc_state); |
Rodrigo Vivi | 082dcc7 | 2015-07-30 16:26:39 -0700 | [diff] [blame] | 3963 | |
| 3964 | if (drm_dp_dpcd_writeb(&intel_dp->aux, DP_TEST_SINK, |
| 3965 | buf | DP_TEST_SINK_START) < 0) { |
Maarten Lankhorst | 199ea38 | 2017-11-10 12:35:00 +0100 | [diff] [blame] | 3966 | hsw_enable_ips(crtc_state); |
Rodrigo Vivi | 082dcc7 | 2015-07-30 16:26:39 -0700 | [diff] [blame] | 3967 | return -EIO; |
Paulo Zanoni | 4373f0f | 2015-05-25 18:52:29 -0300 | [diff] [blame] | 3968 | } |
Rodrigo Vivi | d2e216d | 2014-01-24 13:36:17 -0200 | [diff] [blame] | 3969 | |
Ville Syrjälä | 0f0f74b | 2016-10-31 22:37:06 +0200 | [diff] [blame] | 3970 | intel_wait_for_vblank(dev_priv, intel_crtc->pipe); |
Rodrigo Vivi | 082dcc7 | 2015-07-30 16:26:39 -0700 | [diff] [blame] | 3971 | return 0; |
| 3972 | } |
| 3973 | |
Maarten Lankhorst | 9331353 | 2017-11-10 12:34:59 +0100 | [diff] [blame] | 3974 | int intel_dp_sink_crc(struct intel_dp *intel_dp, struct intel_crtc_state *crtc_state, u8 *crc) |
Rodrigo Vivi | 082dcc7 | 2015-07-30 16:26:39 -0700 | [diff] [blame] | 3975 | { |
| 3976 | struct intel_digital_port *dig_port = dp_to_dig_port(intel_dp); |
Ville Syrjälä | 0f0f74b | 2016-10-31 22:37:06 +0200 | [diff] [blame] | 3977 | struct drm_i915_private *dev_priv = to_i915(dig_port->base.base.dev); |
Maarten Lankhorst | 9331353 | 2017-11-10 12:34:59 +0100 | [diff] [blame] | 3978 | struct intel_crtc *intel_crtc = to_intel_crtc(crtc_state->base.crtc); |
Rodrigo Vivi | 082dcc7 | 2015-07-30 16:26:39 -0700 | [diff] [blame] | 3979 | u8 buf; |
Rodrigo Vivi | 621d4c7 | 2015-07-23 16:35:49 -0700 | [diff] [blame] | 3980 | int count, ret; |
Rodrigo Vivi | 082dcc7 | 2015-07-30 16:26:39 -0700 | [diff] [blame] | 3981 | int attempts = 6; |
Rodrigo Vivi | 082dcc7 | 2015-07-30 16:26:39 -0700 | [diff] [blame] | 3982 | |
Maarten Lankhorst | 9331353 | 2017-11-10 12:34:59 +0100 | [diff] [blame] | 3983 | ret = intel_dp_sink_crc_start(intel_dp, crtc_state); |
Rodrigo Vivi | 082dcc7 | 2015-07-30 16:26:39 -0700 | [diff] [blame] | 3984 | if (ret) |
| 3985 | return ret; |
| 3986 | |
Rodrigo Vivi | ad9dc91 | 2014-09-16 19:18:12 -0400 | [diff] [blame] | 3987 | do { |
Ville Syrjälä | 0f0f74b | 2016-10-31 22:37:06 +0200 | [diff] [blame] | 3988 | intel_wait_for_vblank(dev_priv, intel_crtc->pipe); |
Rodrigo Vivi | 621d4c7 | 2015-07-23 16:35:49 -0700 | [diff] [blame] | 3989 | |
Rodrigo Vivi | 1dda5f9 | 2014-10-01 07:32:37 -0700 | [diff] [blame] | 3990 | if (drm_dp_dpcd_readb(&intel_dp->aux, |
Paulo Zanoni | 4373f0f | 2015-05-25 18:52:29 -0300 | [diff] [blame] | 3991 | DP_TEST_SINK_MISC, &buf) < 0) { |
| 3992 | ret = -EIO; |
Rodrigo Vivi | afe0d67 | 2015-07-23 16:35:45 -0700 | [diff] [blame] | 3993 | goto stop; |
Paulo Zanoni | 4373f0f | 2015-05-25 18:52:29 -0300 | [diff] [blame] | 3994 | } |
Rodrigo Vivi | 621d4c7 | 2015-07-23 16:35:49 -0700 | [diff] [blame] | 3995 | count = buf & DP_TEST_COUNT_MASK; |
Rodrigo Vivi | aabc95d | 2015-07-23 16:35:50 -0700 | [diff] [blame] | 3996 | |
Rodrigo Vivi | 7e38eef | 2015-11-05 10:50:21 -0800 | [diff] [blame] | 3997 | } while (--attempts && count == 0); |
Rodrigo Vivi | ad9dc91 | 2014-09-16 19:18:12 -0400 | [diff] [blame] | 3998 | |
| 3999 | if (attempts == 0) { |
Rodrigo Vivi | 7e38eef | 2015-11-05 10:50:21 -0800 | [diff] [blame] | 4000 | DRM_ERROR("Panel is unable to calculate any CRC after 6 vblanks\n"); |
| 4001 | ret = -ETIMEDOUT; |
| 4002 | goto stop; |
| 4003 | } |
| 4004 | |
| 4005 | if (drm_dp_dpcd_read(&intel_dp->aux, DP_TEST_CRC_R_CR, crc, 6) < 0) { |
| 4006 | ret = -EIO; |
| 4007 | goto stop; |
Rodrigo Vivi | ad9dc91 | 2014-09-16 19:18:12 -0400 | [diff] [blame] | 4008 | } |
Rodrigo Vivi | d2e216d | 2014-01-24 13:36:17 -0200 | [diff] [blame] | 4009 | |
Rodrigo Vivi | afe0d67 | 2015-07-23 16:35:45 -0700 | [diff] [blame] | 4010 | stop: |
Maarten Lankhorst | 9331353 | 2017-11-10 12:34:59 +0100 | [diff] [blame] | 4011 | intel_dp_sink_crc_stop(intel_dp, crtc_state, true); |
Paulo Zanoni | 4373f0f | 2015-05-25 18:52:29 -0300 | [diff] [blame] | 4012 | return ret; |
Rodrigo Vivi | d2e216d | 2014-01-24 13:36:17 -0200 | [diff] [blame] | 4013 | } |
| 4014 | |
Jesse Barnes | a60f0e3 | 2011-10-20 15:09:17 -0700 | [diff] [blame] | 4015 | static bool |
| 4016 | intel_dp_get_sink_irq(struct intel_dp *intel_dp, u8 *sink_irq_vector) |
| 4017 | { |
Jani Nikula | 010b9b3 | 2017-04-06 16:44:16 +0300 | [diff] [blame] | 4018 | return drm_dp_dpcd_readb(&intel_dp->aux, DP_DEVICE_SERVICE_IRQ_VECTOR, |
| 4019 | sink_irq_vector) == 1; |
Jesse Barnes | a60f0e3 | 2011-10-20 15:09:17 -0700 | [diff] [blame] | 4020 | } |
| 4021 | |
Dave Airlie | 0e32b39 | 2014-05-02 14:02:48 +1000 | [diff] [blame] | 4022 | static bool |
| 4023 | intel_dp_get_sink_irq_esi(struct intel_dp *intel_dp, u8 *sink_irq_vector) |
| 4024 | { |
Pandiyan, Dhinakaran | e8b2577 | 2017-09-18 15:21:39 -0700 | [diff] [blame] | 4025 | return drm_dp_dpcd_read(&intel_dp->aux, DP_SINK_COUNT_ESI, |
| 4026 | sink_irq_vector, DP_DPRX_ESI_LEN) == |
| 4027 | DP_DPRX_ESI_LEN; |
Dave Airlie | 0e32b39 | 2014-05-02 14:02:48 +1000 | [diff] [blame] | 4028 | } |
| 4029 | |
Todd Previte | c5d5ab7 | 2015-04-15 08:38:38 -0700 | [diff] [blame] | 4030 | static uint8_t intel_dp_autotest_link_training(struct intel_dp *intel_dp) |
Jesse Barnes | a60f0e3 | 2011-10-20 15:09:17 -0700 | [diff] [blame] | 4031 | { |
Manasi Navare | da15f7c | 2017-01-24 08:16:34 -0800 | [diff] [blame] | 4032 | int status = 0; |
Manasi Navare | 140ef13 | 2017-06-08 13:41:03 -0700 | [diff] [blame] | 4033 | int test_link_rate; |
Manasi Navare | da15f7c | 2017-01-24 08:16:34 -0800 | [diff] [blame] | 4034 | uint8_t test_lane_count, test_link_bw; |
| 4035 | /* (DP CTS 1.2) |
| 4036 | * 4.3.1.11 |
| 4037 | */ |
| 4038 | /* Read the TEST_LANE_COUNT and TEST_LINK_RTAE fields (DP CTS 3.1.4) */ |
| 4039 | status = drm_dp_dpcd_readb(&intel_dp->aux, DP_TEST_LANE_COUNT, |
| 4040 | &test_lane_count); |
| 4041 | |
| 4042 | if (status <= 0) { |
| 4043 | DRM_DEBUG_KMS("Lane count read failed\n"); |
| 4044 | return DP_TEST_NAK; |
| 4045 | } |
| 4046 | test_lane_count &= DP_MAX_LANE_COUNT_MASK; |
Manasi Navare | da15f7c | 2017-01-24 08:16:34 -0800 | [diff] [blame] | 4047 | |
| 4048 | status = drm_dp_dpcd_readb(&intel_dp->aux, DP_TEST_LINK_RATE, |
| 4049 | &test_link_bw); |
| 4050 | if (status <= 0) { |
| 4051 | DRM_DEBUG_KMS("Link Rate read failed\n"); |
| 4052 | return DP_TEST_NAK; |
| 4053 | } |
Manasi Navare | da15f7c | 2017-01-24 08:16:34 -0800 | [diff] [blame] | 4054 | test_link_rate = drm_dp_bw_code_to_link_rate(test_link_bw); |
Manasi Navare | 140ef13 | 2017-06-08 13:41:03 -0700 | [diff] [blame] | 4055 | |
| 4056 | /* Validate the requested link rate and lane count */ |
| 4057 | if (!intel_dp_link_params_valid(intel_dp, test_link_rate, |
| 4058 | test_lane_count)) |
Manasi Navare | da15f7c | 2017-01-24 08:16:34 -0800 | [diff] [blame] | 4059 | return DP_TEST_NAK; |
| 4060 | |
| 4061 | intel_dp->compliance.test_lane_count = test_lane_count; |
| 4062 | intel_dp->compliance.test_link_rate = test_link_rate; |
| 4063 | |
| 4064 | return DP_TEST_ACK; |
Todd Previte | c5d5ab7 | 2015-04-15 08:38:38 -0700 | [diff] [blame] | 4065 | } |
| 4066 | |
| 4067 | static uint8_t intel_dp_autotest_video_pattern(struct intel_dp *intel_dp) |
| 4068 | { |
Manasi Navare | 611032b | 2017-01-24 08:21:49 -0800 | [diff] [blame] | 4069 | uint8_t test_pattern; |
Jani Nikula | 010b9b3 | 2017-04-06 16:44:16 +0300 | [diff] [blame] | 4070 | uint8_t test_misc; |
Manasi Navare | 611032b | 2017-01-24 08:21:49 -0800 | [diff] [blame] | 4071 | __be16 h_width, v_height; |
| 4072 | int status = 0; |
| 4073 | |
| 4074 | /* Read the TEST_PATTERN (DP CTS 3.1.5) */ |
Jani Nikula | 010b9b3 | 2017-04-06 16:44:16 +0300 | [diff] [blame] | 4075 | status = drm_dp_dpcd_readb(&intel_dp->aux, DP_TEST_PATTERN, |
| 4076 | &test_pattern); |
Manasi Navare | 611032b | 2017-01-24 08:21:49 -0800 | [diff] [blame] | 4077 | if (status <= 0) { |
| 4078 | DRM_DEBUG_KMS("Test pattern read failed\n"); |
| 4079 | return DP_TEST_NAK; |
| 4080 | } |
| 4081 | if (test_pattern != DP_COLOR_RAMP) |
| 4082 | return DP_TEST_NAK; |
| 4083 | |
| 4084 | status = drm_dp_dpcd_read(&intel_dp->aux, DP_TEST_H_WIDTH_HI, |
| 4085 | &h_width, 2); |
| 4086 | if (status <= 0) { |
| 4087 | DRM_DEBUG_KMS("H Width read failed\n"); |
| 4088 | return DP_TEST_NAK; |
| 4089 | } |
| 4090 | |
| 4091 | status = drm_dp_dpcd_read(&intel_dp->aux, DP_TEST_V_HEIGHT_HI, |
| 4092 | &v_height, 2); |
| 4093 | if (status <= 0) { |
| 4094 | DRM_DEBUG_KMS("V Height read failed\n"); |
| 4095 | return DP_TEST_NAK; |
| 4096 | } |
| 4097 | |
Jani Nikula | 010b9b3 | 2017-04-06 16:44:16 +0300 | [diff] [blame] | 4098 | status = drm_dp_dpcd_readb(&intel_dp->aux, DP_TEST_MISC0, |
| 4099 | &test_misc); |
Manasi Navare | 611032b | 2017-01-24 08:21:49 -0800 | [diff] [blame] | 4100 | if (status <= 0) { |
| 4101 | DRM_DEBUG_KMS("TEST MISC read failed\n"); |
| 4102 | return DP_TEST_NAK; |
| 4103 | } |
| 4104 | if ((test_misc & DP_TEST_COLOR_FORMAT_MASK) != DP_COLOR_FORMAT_RGB) |
| 4105 | return DP_TEST_NAK; |
| 4106 | if (test_misc & DP_TEST_DYNAMIC_RANGE_CEA) |
| 4107 | return DP_TEST_NAK; |
| 4108 | switch (test_misc & DP_TEST_BIT_DEPTH_MASK) { |
| 4109 | case DP_TEST_BIT_DEPTH_6: |
| 4110 | intel_dp->compliance.test_data.bpc = 6; |
| 4111 | break; |
| 4112 | case DP_TEST_BIT_DEPTH_8: |
| 4113 | intel_dp->compliance.test_data.bpc = 8; |
| 4114 | break; |
| 4115 | default: |
| 4116 | return DP_TEST_NAK; |
| 4117 | } |
| 4118 | |
| 4119 | intel_dp->compliance.test_data.video_pattern = test_pattern; |
| 4120 | intel_dp->compliance.test_data.hdisplay = be16_to_cpu(h_width); |
| 4121 | intel_dp->compliance.test_data.vdisplay = be16_to_cpu(v_height); |
| 4122 | /* Set test active flag here so userspace doesn't interrupt things */ |
| 4123 | intel_dp->compliance.test_active = 1; |
| 4124 | |
| 4125 | return DP_TEST_ACK; |
Todd Previte | c5d5ab7 | 2015-04-15 08:38:38 -0700 | [diff] [blame] | 4126 | } |
| 4127 | |
| 4128 | static uint8_t intel_dp_autotest_edid(struct intel_dp *intel_dp) |
| 4129 | { |
Manasi Navare | b48a5ba | 2017-01-20 19:09:28 -0800 | [diff] [blame] | 4130 | uint8_t test_result = DP_TEST_ACK; |
Todd Previte | 559be30 | 2015-05-04 07:48:20 -0700 | [diff] [blame] | 4131 | struct intel_connector *intel_connector = intel_dp->attached_connector; |
| 4132 | struct drm_connector *connector = &intel_connector->base; |
| 4133 | |
| 4134 | if (intel_connector->detect_edid == NULL || |
Daniel Vetter | ac6f2e2 | 2015-05-08 16:15:41 +0200 | [diff] [blame] | 4135 | connector->edid_corrupt || |
Todd Previte | 559be30 | 2015-05-04 07:48:20 -0700 | [diff] [blame] | 4136 | intel_dp->aux.i2c_defer_count > 6) { |
| 4137 | /* Check EDID read for NACKs, DEFERs and corruption |
| 4138 | * (DP CTS 1.2 Core r1.1) |
| 4139 | * 4.2.2.4 : Failed EDID read, I2C_NAK |
| 4140 | * 4.2.2.5 : Failed EDID read, I2C_DEFER |
| 4141 | * 4.2.2.6 : EDID corruption detected |
| 4142 | * Use failsafe mode for all cases |
| 4143 | */ |
| 4144 | if (intel_dp->aux.i2c_nack_count > 0 || |
| 4145 | intel_dp->aux.i2c_defer_count > 0) |
| 4146 | DRM_DEBUG_KMS("EDID read had %d NACKs, %d DEFERs\n", |
| 4147 | intel_dp->aux.i2c_nack_count, |
| 4148 | intel_dp->aux.i2c_defer_count); |
Manasi Navare | c1617ab | 2016-12-09 16:22:50 -0800 | [diff] [blame] | 4149 | intel_dp->compliance.test_data.edid = INTEL_DP_RESOLUTION_FAILSAFE; |
Todd Previte | 559be30 | 2015-05-04 07:48:20 -0700 | [diff] [blame] | 4150 | } else { |
Thulasimani,Sivakumar | f79b468e | 2015-08-07 15:14:30 +0530 | [diff] [blame] | 4151 | struct edid *block = intel_connector->detect_edid; |
| 4152 | |
| 4153 | /* We have to write the checksum |
| 4154 | * of the last block read |
| 4155 | */ |
| 4156 | block += intel_connector->detect_edid->extensions; |
| 4157 | |
Jani Nikula | 010b9b3 | 2017-04-06 16:44:16 +0300 | [diff] [blame] | 4158 | if (drm_dp_dpcd_writeb(&intel_dp->aux, DP_TEST_EDID_CHECKSUM, |
| 4159 | block->checksum) <= 0) |
Todd Previte | 559be30 | 2015-05-04 07:48:20 -0700 | [diff] [blame] | 4160 | DRM_DEBUG_KMS("Failed to write EDID checksum\n"); |
| 4161 | |
| 4162 | test_result = DP_TEST_ACK | DP_TEST_EDID_CHECKSUM_WRITE; |
Manasi Navare | b48a5ba | 2017-01-20 19:09:28 -0800 | [diff] [blame] | 4163 | intel_dp->compliance.test_data.edid = INTEL_DP_RESOLUTION_PREFERRED; |
Todd Previte | 559be30 | 2015-05-04 07:48:20 -0700 | [diff] [blame] | 4164 | } |
| 4165 | |
| 4166 | /* Set test active flag here so userspace doesn't interrupt things */ |
Manasi Navare | c1617ab | 2016-12-09 16:22:50 -0800 | [diff] [blame] | 4167 | intel_dp->compliance.test_active = 1; |
Todd Previte | 559be30 | 2015-05-04 07:48:20 -0700 | [diff] [blame] | 4168 | |
Todd Previte | c5d5ab7 | 2015-04-15 08:38:38 -0700 | [diff] [blame] | 4169 | return test_result; |
| 4170 | } |
| 4171 | |
| 4172 | static uint8_t intel_dp_autotest_phy_pattern(struct intel_dp *intel_dp) |
| 4173 | { |
| 4174 | uint8_t test_result = DP_TEST_NAK; |
| 4175 | return test_result; |
| 4176 | } |
| 4177 | |
| 4178 | static void intel_dp_handle_test_request(struct intel_dp *intel_dp) |
| 4179 | { |
| 4180 | uint8_t response = DP_TEST_NAK; |
Jani Nikula | 5ec63bb | 2017-01-20 19:04:06 +0200 | [diff] [blame] | 4181 | uint8_t request = 0; |
| 4182 | int status; |
Todd Previte | c5d5ab7 | 2015-04-15 08:38:38 -0700 | [diff] [blame] | 4183 | |
Jani Nikula | 5ec63bb | 2017-01-20 19:04:06 +0200 | [diff] [blame] | 4184 | status = drm_dp_dpcd_readb(&intel_dp->aux, DP_TEST_REQUEST, &request); |
Todd Previte | c5d5ab7 | 2015-04-15 08:38:38 -0700 | [diff] [blame] | 4185 | if (status <= 0) { |
| 4186 | DRM_DEBUG_KMS("Could not read test request from sink\n"); |
| 4187 | goto update_status; |
| 4188 | } |
| 4189 | |
Jani Nikula | 5ec63bb | 2017-01-20 19:04:06 +0200 | [diff] [blame] | 4190 | switch (request) { |
Todd Previte | c5d5ab7 | 2015-04-15 08:38:38 -0700 | [diff] [blame] | 4191 | case DP_TEST_LINK_TRAINING: |
| 4192 | DRM_DEBUG_KMS("LINK_TRAINING test requested\n"); |
Todd Previte | c5d5ab7 | 2015-04-15 08:38:38 -0700 | [diff] [blame] | 4193 | response = intel_dp_autotest_link_training(intel_dp); |
| 4194 | break; |
| 4195 | case DP_TEST_LINK_VIDEO_PATTERN: |
| 4196 | DRM_DEBUG_KMS("TEST_PATTERN test requested\n"); |
Todd Previte | c5d5ab7 | 2015-04-15 08:38:38 -0700 | [diff] [blame] | 4197 | response = intel_dp_autotest_video_pattern(intel_dp); |
| 4198 | break; |
| 4199 | case DP_TEST_LINK_EDID_READ: |
| 4200 | DRM_DEBUG_KMS("EDID test requested\n"); |
Todd Previte | c5d5ab7 | 2015-04-15 08:38:38 -0700 | [diff] [blame] | 4201 | response = intel_dp_autotest_edid(intel_dp); |
| 4202 | break; |
| 4203 | case DP_TEST_LINK_PHY_TEST_PATTERN: |
| 4204 | DRM_DEBUG_KMS("PHY_PATTERN test requested\n"); |
Todd Previte | c5d5ab7 | 2015-04-15 08:38:38 -0700 | [diff] [blame] | 4205 | response = intel_dp_autotest_phy_pattern(intel_dp); |
| 4206 | break; |
| 4207 | default: |
Jani Nikula | 5ec63bb | 2017-01-20 19:04:06 +0200 | [diff] [blame] | 4208 | DRM_DEBUG_KMS("Invalid test request '%02x'\n", request); |
Todd Previte | c5d5ab7 | 2015-04-15 08:38:38 -0700 | [diff] [blame] | 4209 | break; |
| 4210 | } |
| 4211 | |
Jani Nikula | 5ec63bb | 2017-01-20 19:04:06 +0200 | [diff] [blame] | 4212 | if (response & DP_TEST_ACK) |
| 4213 | intel_dp->compliance.test_type = request; |
| 4214 | |
Todd Previte | c5d5ab7 | 2015-04-15 08:38:38 -0700 | [diff] [blame] | 4215 | update_status: |
Jani Nikula | 5ec63bb | 2017-01-20 19:04:06 +0200 | [diff] [blame] | 4216 | status = drm_dp_dpcd_writeb(&intel_dp->aux, DP_TEST_RESPONSE, response); |
Todd Previte | c5d5ab7 | 2015-04-15 08:38:38 -0700 | [diff] [blame] | 4217 | if (status <= 0) |
| 4218 | DRM_DEBUG_KMS("Could not write test response to sink\n"); |
Jesse Barnes | a60f0e3 | 2011-10-20 15:09:17 -0700 | [diff] [blame] | 4219 | } |
| 4220 | |
Dave Airlie | 0e32b39 | 2014-05-02 14:02:48 +1000 | [diff] [blame] | 4221 | static int |
| 4222 | intel_dp_check_mst_status(struct intel_dp *intel_dp) |
| 4223 | { |
| 4224 | bool bret; |
| 4225 | |
| 4226 | if (intel_dp->is_mst) { |
Pandiyan, Dhinakaran | e8b2577 | 2017-09-18 15:21:39 -0700 | [diff] [blame] | 4227 | u8 esi[DP_DPRX_ESI_LEN] = { 0 }; |
Dave Airlie | 0e32b39 | 2014-05-02 14:02:48 +1000 | [diff] [blame] | 4228 | int ret = 0; |
| 4229 | int retry; |
| 4230 | bool handled; |
| 4231 | bret = intel_dp_get_sink_irq_esi(intel_dp, esi); |
| 4232 | go_again: |
| 4233 | if (bret == true) { |
| 4234 | |
| 4235 | /* check link status - esi[10] = 0x200c */ |
Ville Syrjälä | 19e0b4c | 2016-08-05 19:05:42 +0300 | [diff] [blame] | 4236 | if (intel_dp->active_mst_links && |
Ville Syrjälä | 901c2da | 2015-08-17 18:05:12 +0300 | [diff] [blame] | 4237 | !drm_dp_channel_eq_ok(&esi[10], intel_dp->lane_count)) { |
Dave Airlie | 0e32b39 | 2014-05-02 14:02:48 +1000 | [diff] [blame] | 4238 | DRM_DEBUG_KMS("channel EQ not ok, retraining\n"); |
| 4239 | intel_dp_start_link_train(intel_dp); |
Dave Airlie | 0e32b39 | 2014-05-02 14:02:48 +1000 | [diff] [blame] | 4240 | intel_dp_stop_link_train(intel_dp); |
| 4241 | } |
| 4242 | |
Andy Shevchenko | 6f34cc3 | 2015-01-15 13:45:09 +0200 | [diff] [blame] | 4243 | DRM_DEBUG_KMS("got esi %3ph\n", esi); |
Dave Airlie | 0e32b39 | 2014-05-02 14:02:48 +1000 | [diff] [blame] | 4244 | ret = drm_dp_mst_hpd_irq(&intel_dp->mst_mgr, esi, &handled); |
| 4245 | |
| 4246 | if (handled) { |
| 4247 | for (retry = 0; retry < 3; retry++) { |
| 4248 | int wret; |
| 4249 | wret = drm_dp_dpcd_write(&intel_dp->aux, |
| 4250 | DP_SINK_COUNT_ESI+1, |
| 4251 | &esi[1], 3); |
| 4252 | if (wret == 3) { |
| 4253 | break; |
| 4254 | } |
| 4255 | } |
| 4256 | |
| 4257 | bret = intel_dp_get_sink_irq_esi(intel_dp, esi); |
| 4258 | if (bret == true) { |
Andy Shevchenko | 6f34cc3 | 2015-01-15 13:45:09 +0200 | [diff] [blame] | 4259 | DRM_DEBUG_KMS("got esi2 %3ph\n", esi); |
Dave Airlie | 0e32b39 | 2014-05-02 14:02:48 +1000 | [diff] [blame] | 4260 | goto go_again; |
| 4261 | } |
| 4262 | } else |
| 4263 | ret = 0; |
| 4264 | |
| 4265 | return ret; |
| 4266 | } else { |
| 4267 | struct intel_digital_port *intel_dig_port = dp_to_dig_port(intel_dp); |
| 4268 | DRM_DEBUG_KMS("failed to get ESI - device may have failed\n"); |
| 4269 | intel_dp->is_mst = false; |
| 4270 | drm_dp_mst_topology_mgr_set_mst(&intel_dp->mst_mgr, intel_dp->is_mst); |
| 4271 | /* send a hotplug event */ |
| 4272 | drm_kms_helper_hotplug_event(intel_dig_port->base.base.dev); |
| 4273 | } |
| 4274 | } |
| 4275 | return -EINVAL; |
| 4276 | } |
| 4277 | |
Shubhangi Shrivastava | 5c9114d | 2016-03-30 18:05:24 +0530 | [diff] [blame] | 4278 | static void |
Ville Syrjälä | bfd02b3 | 2016-10-14 20:02:54 +0300 | [diff] [blame] | 4279 | intel_dp_retrain_link(struct intel_dp *intel_dp) |
| 4280 | { |
| 4281 | struct intel_encoder *encoder = &dp_to_dig_port(intel_dp)->base; |
| 4282 | struct drm_i915_private *dev_priv = to_i915(encoder->base.dev); |
| 4283 | struct intel_crtc *crtc = to_intel_crtc(encoder->base.crtc); |
| 4284 | |
| 4285 | /* Suppress underruns caused by re-training */ |
| 4286 | intel_set_cpu_fifo_underrun_reporting(dev_priv, crtc->pipe, false); |
| 4287 | if (crtc->config->has_pch_encoder) |
| 4288 | intel_set_pch_fifo_underrun_reporting(dev_priv, |
| 4289 | intel_crtc_pch_transcoder(crtc), false); |
| 4290 | |
| 4291 | intel_dp_start_link_train(intel_dp); |
| 4292 | intel_dp_stop_link_train(intel_dp); |
| 4293 | |
| 4294 | /* Keep underrun reporting disabled until things are stable */ |
Ville Syrjälä | 0f0f74b | 2016-10-31 22:37:06 +0200 | [diff] [blame] | 4295 | intel_wait_for_vblank(dev_priv, crtc->pipe); |
Ville Syrjälä | bfd02b3 | 2016-10-14 20:02:54 +0300 | [diff] [blame] | 4296 | |
| 4297 | intel_set_cpu_fifo_underrun_reporting(dev_priv, crtc->pipe, true); |
| 4298 | if (crtc->config->has_pch_encoder) |
| 4299 | intel_set_pch_fifo_underrun_reporting(dev_priv, |
| 4300 | intel_crtc_pch_transcoder(crtc), true); |
| 4301 | } |
| 4302 | |
| 4303 | static void |
Shubhangi Shrivastava | 5c9114d | 2016-03-30 18:05:24 +0530 | [diff] [blame] | 4304 | intel_dp_check_link_status(struct intel_dp *intel_dp) |
| 4305 | { |
Ville Syrjälä | 2f77347 | 2017-11-09 17:27:58 +0200 | [diff] [blame] | 4306 | struct drm_i915_private *dev_priv = to_i915(intel_dp_to_dev(intel_dp)); |
Shubhangi Shrivastava | 5c9114d | 2016-03-30 18:05:24 +0530 | [diff] [blame] | 4307 | struct intel_encoder *intel_encoder = &dp_to_dig_port(intel_dp)->base; |
Daniel Vetter | 42e5e65 | 2017-11-13 17:01:40 +0100 | [diff] [blame] | 4308 | struct drm_connector_state *conn_state = |
| 4309 | intel_dp->attached_connector->base.state; |
Shubhangi Shrivastava | 5c9114d | 2016-03-30 18:05:24 +0530 | [diff] [blame] | 4310 | u8 link_status[DP_LINK_STATUS_SIZE]; |
| 4311 | |
Ville Syrjälä | 2f77347 | 2017-11-09 17:27:58 +0200 | [diff] [blame] | 4312 | WARN_ON(!drm_modeset_is_locked(&dev_priv->drm.mode_config.connection_mutex)); |
Shubhangi Shrivastava | 5c9114d | 2016-03-30 18:05:24 +0530 | [diff] [blame] | 4313 | |
| 4314 | if (!intel_dp_get_link_status(intel_dp, link_status)) { |
| 4315 | DRM_ERROR("Failed to get link status\n"); |
| 4316 | return; |
| 4317 | } |
| 4318 | |
Daniel Vetter | 42e5e65 | 2017-11-13 17:01:40 +0100 | [diff] [blame] | 4319 | if (!conn_state->crtc) |
Shubhangi Shrivastava | 5c9114d | 2016-03-30 18:05:24 +0530 | [diff] [blame] | 4320 | return; |
| 4321 | |
Daniel Vetter | 42e5e65 | 2017-11-13 17:01:40 +0100 | [diff] [blame] | 4322 | WARN_ON(!drm_modeset_is_locked(&conn_state->crtc->mutex)); |
| 4323 | |
| 4324 | if (!conn_state->crtc->state->active) |
| 4325 | return; |
| 4326 | |
| 4327 | if (conn_state->commit && |
| 4328 | !try_wait_for_completion(&conn_state->commit->hw_done)) |
Shubhangi Shrivastava | 5c9114d | 2016-03-30 18:05:24 +0530 | [diff] [blame] | 4329 | return; |
| 4330 | |
Manasi Navare | 14c562c | 2017-04-06 14:00:12 -0700 | [diff] [blame] | 4331 | /* |
| 4332 | * Validate the cached values of intel_dp->link_rate and |
| 4333 | * intel_dp->lane_count before attempting to retrain. |
| 4334 | */ |
Manasi Navare | 1a92c70 | 2017-06-08 13:41:02 -0700 | [diff] [blame] | 4335 | if (!intel_dp_link_params_valid(intel_dp, intel_dp->link_rate, |
| 4336 | intel_dp->lane_count)) |
Matthew Auld | d4cb3fd | 2016-10-19 22:29:53 +0100 | [diff] [blame] | 4337 | return; |
| 4338 | |
Manasi Navare | da15f7c | 2017-01-24 08:16:34 -0800 | [diff] [blame] | 4339 | /* Retrain if Channel EQ or CR not ok */ |
| 4340 | if (!drm_dp_channel_eq_ok(link_status, intel_dp->lane_count)) { |
Shubhangi Shrivastava | 5c9114d | 2016-03-30 18:05:24 +0530 | [diff] [blame] | 4341 | DRM_DEBUG_KMS("%s: channel EQ not ok, retraining\n", |
| 4342 | intel_encoder->base.name); |
Ville Syrjälä | bfd02b3 | 2016-10-14 20:02:54 +0300 | [diff] [blame] | 4343 | |
| 4344 | intel_dp_retrain_link(intel_dp); |
Shubhangi Shrivastava | 5c9114d | 2016-03-30 18:05:24 +0530 | [diff] [blame] | 4345 | } |
| 4346 | } |
| 4347 | |
Keith Packard | a4fc5ed | 2009-04-07 16:16:42 -0700 | [diff] [blame] | 4348 | /* |
| 4349 | * According to DP spec |
| 4350 | * 5.1.2: |
| 4351 | * 1. Read DPCD |
| 4352 | * 2. Configure link according to Receiver Capabilities |
| 4353 | * 3. Use Link Training from 2.5.3.3 and 3.5.1.3 |
| 4354 | * 4. Check link status on receipt of hot-plug interrupt |
Shubhangi Shrivastava | 39ff747 | 2016-03-30 18:05:26 +0530 | [diff] [blame] | 4355 | * |
| 4356 | * intel_dp_short_pulse - handles short pulse interrupts |
| 4357 | * when full detection is not required. |
| 4358 | * Returns %true if short pulse is handled and full detection |
| 4359 | * is NOT required and %false otherwise. |
Keith Packard | a4fc5ed | 2009-04-07 16:16:42 -0700 | [diff] [blame] | 4360 | */ |
Shubhangi Shrivastava | 39ff747 | 2016-03-30 18:05:26 +0530 | [diff] [blame] | 4361 | static bool |
Shubhangi Shrivastava | 5c9114d | 2016-03-30 18:05:24 +0530 | [diff] [blame] | 4362 | intel_dp_short_pulse(struct intel_dp *intel_dp) |
Keith Packard | a4fc5ed | 2009-04-07 16:16:42 -0700 | [diff] [blame] | 4363 | { |
Ville Syrjälä | 2f77347 | 2017-11-09 17:27:58 +0200 | [diff] [blame] | 4364 | struct drm_i915_private *dev_priv = to_i915(intel_dp_to_dev(intel_dp)); |
Ville Syrjälä | 65fbb4e | 2016-07-28 17:50:47 +0300 | [diff] [blame] | 4365 | u8 sink_irq_vector = 0; |
Shubhangi Shrivastava | 39ff747 | 2016-03-30 18:05:26 +0530 | [diff] [blame] | 4366 | u8 old_sink_count = intel_dp->sink_count; |
| 4367 | bool ret; |
Dave Airlie | 5b215bc | 2014-08-05 10:40:20 +1000 | [diff] [blame] | 4368 | |
Shubhangi Shrivastava | 4df6960 | 2015-10-28 15:30:36 +0530 | [diff] [blame] | 4369 | /* |
| 4370 | * Clearing compliance test variables to allow capturing |
| 4371 | * of values for next automated test request. |
| 4372 | */ |
Manasi Navare | c1617ab | 2016-12-09 16:22:50 -0800 | [diff] [blame] | 4373 | memset(&intel_dp->compliance, 0, sizeof(intel_dp->compliance)); |
Shubhangi Shrivastava | 4df6960 | 2015-10-28 15:30:36 +0530 | [diff] [blame] | 4374 | |
Shubhangi Shrivastava | 39ff747 | 2016-03-30 18:05:26 +0530 | [diff] [blame] | 4375 | /* |
| 4376 | * Now read the DPCD to see if it's actually running |
| 4377 | * If the current value of sink count doesn't match with |
| 4378 | * the value that was stored earlier or dpcd read failed |
| 4379 | * we need to do full detection |
| 4380 | */ |
| 4381 | ret = intel_dp_get_dpcd(intel_dp); |
| 4382 | |
| 4383 | if ((old_sink_count != intel_dp->sink_count) || !ret) { |
| 4384 | /* No need to proceed if we are going to do full detect */ |
| 4385 | return false; |
Jesse Barnes | 59cd09e | 2011-07-07 11:10:59 -0700 | [diff] [blame] | 4386 | } |
| 4387 | |
Jesse Barnes | a60f0e3 | 2011-10-20 15:09:17 -0700 | [diff] [blame] | 4388 | /* Try to read the source of the interrupt */ |
| 4389 | if (intel_dp->dpcd[DP_DPCD_REV] >= 0x11 && |
Ville Syrjälä | 65fbb4e | 2016-07-28 17:50:47 +0300 | [diff] [blame] | 4390 | intel_dp_get_sink_irq(intel_dp, &sink_irq_vector) && |
| 4391 | sink_irq_vector != 0) { |
Jesse Barnes | a60f0e3 | 2011-10-20 15:09:17 -0700 | [diff] [blame] | 4392 | /* Clear interrupt source */ |
Jani Nikula | 9d1a103 | 2014-03-14 16:51:15 +0200 | [diff] [blame] | 4393 | drm_dp_dpcd_writeb(&intel_dp->aux, |
| 4394 | DP_DEVICE_SERVICE_IRQ_VECTOR, |
| 4395 | sink_irq_vector); |
Jesse Barnes | a60f0e3 | 2011-10-20 15:09:17 -0700 | [diff] [blame] | 4396 | |
| 4397 | if (sink_irq_vector & DP_AUTOMATED_TEST_REQUEST) |
Manasi Navare | da15f7c | 2017-01-24 08:16:34 -0800 | [diff] [blame] | 4398 | intel_dp_handle_test_request(intel_dp); |
Jesse Barnes | a60f0e3 | 2011-10-20 15:09:17 -0700 | [diff] [blame] | 4399 | if (sink_irq_vector & (DP_CP_IRQ | DP_SINK_SPECIFIC_IRQ)) |
| 4400 | DRM_DEBUG_DRIVER("CP or sink specific irq unhandled\n"); |
| 4401 | } |
| 4402 | |
Shubhangi Shrivastava | 5c9114d | 2016-03-30 18:05:24 +0530 | [diff] [blame] | 4403 | intel_dp_check_link_status(intel_dp); |
Daniel Vetter | 42e5e65 | 2017-11-13 17:01:40 +0100 | [diff] [blame] | 4404 | |
Manasi Navare | da15f7c | 2017-01-24 08:16:34 -0800 | [diff] [blame] | 4405 | if (intel_dp->compliance.test_type == DP_TEST_LINK_TRAINING) { |
| 4406 | DRM_DEBUG_KMS("Link Training Compliance Test requested\n"); |
| 4407 | /* Send a Hotplug Uevent to userspace to start modeset */ |
Ville Syrjälä | 2f77347 | 2017-11-09 17:27:58 +0200 | [diff] [blame] | 4408 | drm_kms_helper_hotplug_event(&dev_priv->drm); |
Manasi Navare | da15f7c | 2017-01-24 08:16:34 -0800 | [diff] [blame] | 4409 | } |
Shubhangi Shrivastava | 39ff747 | 2016-03-30 18:05:26 +0530 | [diff] [blame] | 4410 | |
| 4411 | return true; |
Keith Packard | a4fc5ed | 2009-04-07 16:16:42 -0700 | [diff] [blame] | 4412 | } |
Keith Packard | a4fc5ed | 2009-04-07 16:16:42 -0700 | [diff] [blame] | 4413 | |
Adam Jackson | caf9ab2 | 2012-09-18 10:58:50 -0400 | [diff] [blame] | 4414 | /* XXX this is probably wrong for multiple downstream ports */ |
Zhenyu Wang | 5eb08b6 | 2009-07-24 01:00:31 +0800 | [diff] [blame] | 4415 | static enum drm_connector_status |
Keith Packard | 26d61aa | 2011-07-25 20:01:09 -0700 | [diff] [blame] | 4416 | intel_dp_detect_dpcd(struct intel_dp *intel_dp) |
Adam Jackson | 71ba9000 | 2011-07-12 17:38:04 -0400 | [diff] [blame] | 4417 | { |
Imre Deak | e393d0d | 2017-02-22 17:10:52 +0200 | [diff] [blame] | 4418 | struct intel_lspcon *lspcon = dp_to_lspcon(intel_dp); |
Adam Jackson | caf9ab2 | 2012-09-18 10:58:50 -0400 | [diff] [blame] | 4419 | uint8_t *dpcd = intel_dp->dpcd; |
Adam Jackson | caf9ab2 | 2012-09-18 10:58:50 -0400 | [diff] [blame] | 4420 | uint8_t type; |
| 4421 | |
Imre Deak | e393d0d | 2017-02-22 17:10:52 +0200 | [diff] [blame] | 4422 | if (lspcon->active) |
| 4423 | lspcon_resume(lspcon); |
| 4424 | |
Adam Jackson | caf9ab2 | 2012-09-18 10:58:50 -0400 | [diff] [blame] | 4425 | if (!intel_dp_get_dpcd(intel_dp)) |
| 4426 | return connector_status_disconnected; |
| 4427 | |
Jani Nikula | 1853a9d | 2017-08-18 12:30:20 +0300 | [diff] [blame] | 4428 | if (intel_dp_is_edp(intel_dp)) |
Shubhangi Shrivastava | 1034ce7 | 2016-04-12 12:23:54 +0530 | [diff] [blame] | 4429 | return connector_status_connected; |
| 4430 | |
Adam Jackson | caf9ab2 | 2012-09-18 10:58:50 -0400 | [diff] [blame] | 4431 | /* if there's no downstream port, we're done */ |
Imre Deak | c726ad0 | 2016-10-24 19:33:24 +0300 | [diff] [blame] | 4432 | if (!drm_dp_is_branch(dpcd)) |
Keith Packard | 26d61aa | 2011-07-25 20:01:09 -0700 | [diff] [blame] | 4433 | return connector_status_connected; |
Adam Jackson | caf9ab2 | 2012-09-18 10:58:50 -0400 | [diff] [blame] | 4434 | |
| 4435 | /* If we're HPD-aware, SINK_COUNT changes dynamically */ |
Jani Nikula | c9ff160 | 2013-09-27 14:48:42 +0300 | [diff] [blame] | 4436 | if (intel_dp->dpcd[DP_DPCD_REV] >= 0x11 && |
| 4437 | intel_dp->downstream_ports[0] & DP_DS_PORT_HPD) { |
Jani Nikula | 9d1a103 | 2014-03-14 16:51:15 +0200 | [diff] [blame] | 4438 | |
Shubhangi Shrivastava | 30d9aa4 | 2016-03-30 18:05:25 +0530 | [diff] [blame] | 4439 | return intel_dp->sink_count ? |
| 4440 | connector_status_connected : connector_status_disconnected; |
Adam Jackson | caf9ab2 | 2012-09-18 10:58:50 -0400 | [diff] [blame] | 4441 | } |
| 4442 | |
Ville Syrjälä | c4e3170 | 2016-07-29 16:51:16 +0300 | [diff] [blame] | 4443 | if (intel_dp_can_mst(intel_dp)) |
| 4444 | return connector_status_connected; |
| 4445 | |
Adam Jackson | caf9ab2 | 2012-09-18 10:58:50 -0400 | [diff] [blame] | 4446 | /* If no HPD, poke DDC gently */ |
Jani Nikula | 0b99836 | 2014-03-14 16:51:17 +0200 | [diff] [blame] | 4447 | if (drm_probe_ddc(&intel_dp->aux.ddc)) |
Adam Jackson | caf9ab2 | 2012-09-18 10:58:50 -0400 | [diff] [blame] | 4448 | return connector_status_connected; |
| 4449 | |
| 4450 | /* Well we tried, say unknown for unreliable port types */ |
Jani Nikula | c9ff160 | 2013-09-27 14:48:42 +0300 | [diff] [blame] | 4451 | if (intel_dp->dpcd[DP_DPCD_REV] >= 0x11) { |
| 4452 | type = intel_dp->downstream_ports[0] & DP_DS_PORT_TYPE_MASK; |
| 4453 | if (type == DP_DS_PORT_TYPE_VGA || |
| 4454 | type == DP_DS_PORT_TYPE_NON_EDID) |
| 4455 | return connector_status_unknown; |
| 4456 | } else { |
| 4457 | type = intel_dp->dpcd[DP_DOWNSTREAMPORT_PRESENT] & |
| 4458 | DP_DWN_STRM_PORT_TYPE_MASK; |
| 4459 | if (type == DP_DWN_STRM_PORT_TYPE_ANALOG || |
| 4460 | type == DP_DWN_STRM_PORT_TYPE_OTHER) |
| 4461 | return connector_status_unknown; |
| 4462 | } |
Adam Jackson | caf9ab2 | 2012-09-18 10:58:50 -0400 | [diff] [blame] | 4463 | |
| 4464 | /* Anything else is out of spec, warn and ignore */ |
| 4465 | DRM_DEBUG_KMS("Broken DP branch device, ignoring\n"); |
Keith Packard | 26d61aa | 2011-07-25 20:01:09 -0700 | [diff] [blame] | 4466 | return connector_status_disconnected; |
Adam Jackson | 71ba9000 | 2011-07-12 17:38:04 -0400 | [diff] [blame] | 4467 | } |
| 4468 | |
| 4469 | static enum drm_connector_status |
Chris Wilson | d410b56 | 2014-09-02 20:03:59 +0100 | [diff] [blame] | 4470 | edp_detect(struct intel_dp *intel_dp) |
| 4471 | { |
Ville Syrjälä | 2f77347 | 2017-11-09 17:27:58 +0200 | [diff] [blame] | 4472 | struct drm_i915_private *dev_priv = to_i915(intel_dp_to_dev(intel_dp)); |
Chris Wilson | d410b56 | 2014-09-02 20:03:59 +0100 | [diff] [blame] | 4473 | enum drm_connector_status status; |
| 4474 | |
Mika Kahola | 1650be7 | 2016-12-13 10:02:47 +0200 | [diff] [blame] | 4475 | status = intel_panel_detect(dev_priv); |
Chris Wilson | d410b56 | 2014-09-02 20:03:59 +0100 | [diff] [blame] | 4476 | if (status == connector_status_unknown) |
| 4477 | status = connector_status_connected; |
| 4478 | |
| 4479 | return status; |
| 4480 | } |
| 4481 | |
Jani Nikula | b93433c | 2015-08-20 10:47:36 +0300 | [diff] [blame] | 4482 | static bool ibx_digital_port_connected(struct drm_i915_private *dev_priv, |
| 4483 | struct intel_digital_port *port) |
Zhenyu Wang | 5eb08b6 | 2009-07-24 01:00:31 +0800 | [diff] [blame] | 4484 | { |
Jani Nikula | b93433c | 2015-08-20 10:47:36 +0300 | [diff] [blame] | 4485 | u32 bit; |
Jesse Barnes | 01cb9ea | 2010-10-07 16:01:12 -0700 | [diff] [blame] | 4486 | |
Ville Syrjälä | 8f4f279 | 2017-11-09 17:24:34 +0200 | [diff] [blame] | 4487 | switch (port->base.port) { |
Jani Nikula | 0df53b7 | 2015-08-20 10:47:40 +0300 | [diff] [blame] | 4488 | case PORT_B: |
| 4489 | bit = SDE_PORTB_HOTPLUG; |
| 4490 | break; |
| 4491 | case PORT_C: |
| 4492 | bit = SDE_PORTC_HOTPLUG; |
| 4493 | break; |
| 4494 | case PORT_D: |
| 4495 | bit = SDE_PORTD_HOTPLUG; |
| 4496 | break; |
| 4497 | default: |
Ville Syrjälä | 8f4f279 | 2017-11-09 17:24:34 +0200 | [diff] [blame] | 4498 | MISSING_CASE(port->base.port); |
Jani Nikula | 0df53b7 | 2015-08-20 10:47:40 +0300 | [diff] [blame] | 4499 | return false; |
| 4500 | } |
| 4501 | |
| 4502 | return I915_READ(SDEISR) & bit; |
| 4503 | } |
| 4504 | |
| 4505 | static bool cpt_digital_port_connected(struct drm_i915_private *dev_priv, |
| 4506 | struct intel_digital_port *port) |
| 4507 | { |
| 4508 | u32 bit; |
| 4509 | |
Ville Syrjälä | 8f4f279 | 2017-11-09 17:24:34 +0200 | [diff] [blame] | 4510 | switch (port->base.port) { |
Jani Nikula | 0df53b7 | 2015-08-20 10:47:40 +0300 | [diff] [blame] | 4511 | case PORT_B: |
| 4512 | bit = SDE_PORTB_HOTPLUG_CPT; |
| 4513 | break; |
| 4514 | case PORT_C: |
| 4515 | bit = SDE_PORTC_HOTPLUG_CPT; |
| 4516 | break; |
| 4517 | case PORT_D: |
| 4518 | bit = SDE_PORTD_HOTPLUG_CPT; |
| 4519 | break; |
Ville Syrjälä | 93e5f0b | 2017-06-15 20:12:52 +0300 | [diff] [blame] | 4520 | default: |
Ville Syrjälä | 8f4f279 | 2017-11-09 17:24:34 +0200 | [diff] [blame] | 4521 | MISSING_CASE(port->base.port); |
Ville Syrjälä | 93e5f0b | 2017-06-15 20:12:52 +0300 | [diff] [blame] | 4522 | return false; |
| 4523 | } |
| 4524 | |
| 4525 | return I915_READ(SDEISR) & bit; |
| 4526 | } |
| 4527 | |
| 4528 | static bool spt_digital_port_connected(struct drm_i915_private *dev_priv, |
| 4529 | struct intel_digital_port *port) |
| 4530 | { |
| 4531 | u32 bit; |
| 4532 | |
Ville Syrjälä | 8f4f279 | 2017-11-09 17:24:34 +0200 | [diff] [blame] | 4533 | switch (port->base.port) { |
Ville Syrjälä | 93e5f0b | 2017-06-15 20:12:52 +0300 | [diff] [blame] | 4534 | case PORT_A: |
| 4535 | bit = SDE_PORTA_HOTPLUG_SPT; |
| 4536 | break; |
Jani Nikula | a78695d | 2015-09-18 15:54:50 +0300 | [diff] [blame] | 4537 | case PORT_E: |
| 4538 | bit = SDE_PORTE_HOTPLUG_SPT; |
| 4539 | break; |
Jani Nikula | 0df53b7 | 2015-08-20 10:47:40 +0300 | [diff] [blame] | 4540 | default: |
Ville Syrjälä | 93e5f0b | 2017-06-15 20:12:52 +0300 | [diff] [blame] | 4541 | return cpt_digital_port_connected(dev_priv, port); |
Jani Nikula | b93433c | 2015-08-20 10:47:36 +0300 | [diff] [blame] | 4542 | } |
Damien Lespiau | 1b46963 | 2012-12-13 16:09:01 +0000 | [diff] [blame] | 4543 | |
Jani Nikula | b93433c | 2015-08-20 10:47:36 +0300 | [diff] [blame] | 4544 | return I915_READ(SDEISR) & bit; |
Zhenyu Wang | 5eb08b6 | 2009-07-24 01:00:31 +0800 | [diff] [blame] | 4545 | } |
| 4546 | |
Jani Nikula | 7e66bcf | 2015-08-20 10:47:39 +0300 | [diff] [blame] | 4547 | static bool g4x_digital_port_connected(struct drm_i915_private *dev_priv, |
Jani Nikula | 1d24598 | 2015-08-20 10:47:37 +0300 | [diff] [blame] | 4548 | struct intel_digital_port *port) |
Keith Packard | a4fc5ed | 2009-04-07 16:16:42 -0700 | [diff] [blame] | 4549 | { |
Jani Nikula | 9642c81 | 2015-08-20 10:47:41 +0300 | [diff] [blame] | 4550 | u32 bit; |
Zhenyu Wang | 5eb08b6 | 2009-07-24 01:00:31 +0800 | [diff] [blame] | 4551 | |
Ville Syrjälä | 8f4f279 | 2017-11-09 17:24:34 +0200 | [diff] [blame] | 4552 | switch (port->base.port) { |
Jani Nikula | 9642c81 | 2015-08-20 10:47:41 +0300 | [diff] [blame] | 4553 | case PORT_B: |
| 4554 | bit = PORTB_HOTPLUG_LIVE_STATUS_G4X; |
| 4555 | break; |
| 4556 | case PORT_C: |
| 4557 | bit = PORTC_HOTPLUG_LIVE_STATUS_G4X; |
| 4558 | break; |
| 4559 | case PORT_D: |
| 4560 | bit = PORTD_HOTPLUG_LIVE_STATUS_G4X; |
| 4561 | break; |
| 4562 | default: |
Ville Syrjälä | 8f4f279 | 2017-11-09 17:24:34 +0200 | [diff] [blame] | 4563 | MISSING_CASE(port->base.port); |
Jani Nikula | 9642c81 | 2015-08-20 10:47:41 +0300 | [diff] [blame] | 4564 | return false; |
| 4565 | } |
| 4566 | |
| 4567 | return I915_READ(PORT_HOTPLUG_STAT) & bit; |
| 4568 | } |
| 4569 | |
Ville Syrjälä | 0780cd3 | 2016-02-10 19:59:05 +0200 | [diff] [blame] | 4570 | static bool gm45_digital_port_connected(struct drm_i915_private *dev_priv, |
| 4571 | struct intel_digital_port *port) |
Jani Nikula | 9642c81 | 2015-08-20 10:47:41 +0300 | [diff] [blame] | 4572 | { |
| 4573 | u32 bit; |
| 4574 | |
Ville Syrjälä | 8f4f279 | 2017-11-09 17:24:34 +0200 | [diff] [blame] | 4575 | switch (port->base.port) { |
Jani Nikula | 9642c81 | 2015-08-20 10:47:41 +0300 | [diff] [blame] | 4576 | case PORT_B: |
Ville Syrjälä | 0780cd3 | 2016-02-10 19:59:05 +0200 | [diff] [blame] | 4577 | bit = PORTB_HOTPLUG_LIVE_STATUS_GM45; |
Jani Nikula | 9642c81 | 2015-08-20 10:47:41 +0300 | [diff] [blame] | 4578 | break; |
| 4579 | case PORT_C: |
Ville Syrjälä | 0780cd3 | 2016-02-10 19:59:05 +0200 | [diff] [blame] | 4580 | bit = PORTC_HOTPLUG_LIVE_STATUS_GM45; |
Jani Nikula | 9642c81 | 2015-08-20 10:47:41 +0300 | [diff] [blame] | 4581 | break; |
| 4582 | case PORT_D: |
Ville Syrjälä | 0780cd3 | 2016-02-10 19:59:05 +0200 | [diff] [blame] | 4583 | bit = PORTD_HOTPLUG_LIVE_STATUS_GM45; |
Jani Nikula | 9642c81 | 2015-08-20 10:47:41 +0300 | [diff] [blame] | 4584 | break; |
| 4585 | default: |
Ville Syrjälä | 8f4f279 | 2017-11-09 17:24:34 +0200 | [diff] [blame] | 4586 | MISSING_CASE(port->base.port); |
Jani Nikula | 9642c81 | 2015-08-20 10:47:41 +0300 | [diff] [blame] | 4587 | return false; |
Keith Packard | a4fc5ed | 2009-04-07 16:16:42 -0700 | [diff] [blame] | 4588 | } |
| 4589 | |
Jani Nikula | 1d24598 | 2015-08-20 10:47:37 +0300 | [diff] [blame] | 4590 | return I915_READ(PORT_HOTPLUG_STAT) & bit; |
Dave Airlie | 2a592be | 2014-09-01 16:58:12 +1000 | [diff] [blame] | 4591 | } |
| 4592 | |
Ville Syrjälä | 93e5f0b | 2017-06-15 20:12:52 +0300 | [diff] [blame] | 4593 | static bool ilk_digital_port_connected(struct drm_i915_private *dev_priv, |
| 4594 | struct intel_digital_port *port) |
| 4595 | { |
Ville Syrjälä | 8f4f279 | 2017-11-09 17:24:34 +0200 | [diff] [blame] | 4596 | if (port->base.port == PORT_A) |
Ville Syrjälä | 93e5f0b | 2017-06-15 20:12:52 +0300 | [diff] [blame] | 4597 | return I915_READ(DEISR) & DE_DP_A_HOTPLUG; |
| 4598 | else |
| 4599 | return ibx_digital_port_connected(dev_priv, port); |
| 4600 | } |
| 4601 | |
| 4602 | static bool snb_digital_port_connected(struct drm_i915_private *dev_priv, |
| 4603 | struct intel_digital_port *port) |
| 4604 | { |
Ville Syrjälä | 8f4f279 | 2017-11-09 17:24:34 +0200 | [diff] [blame] | 4605 | if (port->base.port == PORT_A) |
Ville Syrjälä | 93e5f0b | 2017-06-15 20:12:52 +0300 | [diff] [blame] | 4606 | return I915_READ(DEISR) & DE_DP_A_HOTPLUG; |
| 4607 | else |
| 4608 | return cpt_digital_port_connected(dev_priv, port); |
| 4609 | } |
| 4610 | |
| 4611 | static bool ivb_digital_port_connected(struct drm_i915_private *dev_priv, |
| 4612 | struct intel_digital_port *port) |
| 4613 | { |
Ville Syrjälä | 8f4f279 | 2017-11-09 17:24:34 +0200 | [diff] [blame] | 4614 | if (port->base.port == PORT_A) |
Ville Syrjälä | 93e5f0b | 2017-06-15 20:12:52 +0300 | [diff] [blame] | 4615 | return I915_READ(DEISR) & DE_DP_A_HOTPLUG_IVB; |
| 4616 | else |
| 4617 | return cpt_digital_port_connected(dev_priv, port); |
| 4618 | } |
| 4619 | |
| 4620 | static bool bdw_digital_port_connected(struct drm_i915_private *dev_priv, |
| 4621 | struct intel_digital_port *port) |
| 4622 | { |
Ville Syrjälä | 8f4f279 | 2017-11-09 17:24:34 +0200 | [diff] [blame] | 4623 | if (port->base.port == PORT_A) |
Ville Syrjälä | 93e5f0b | 2017-06-15 20:12:52 +0300 | [diff] [blame] | 4624 | return I915_READ(GEN8_DE_PORT_ISR) & GEN8_PORT_DP_A_HOTPLUG; |
| 4625 | else |
| 4626 | return cpt_digital_port_connected(dev_priv, port); |
| 4627 | } |
| 4628 | |
Jani Nikula | e464bfd | 2015-08-20 10:47:42 +0300 | [diff] [blame] | 4629 | static bool bxt_digital_port_connected(struct drm_i915_private *dev_priv, |
Sonika Jindal | e2ec35a | 2015-09-11 16:58:32 +0530 | [diff] [blame] | 4630 | struct intel_digital_port *intel_dig_port) |
Jani Nikula | e464bfd | 2015-08-20 10:47:42 +0300 | [diff] [blame] | 4631 | { |
Sonika Jindal | e2ec35a | 2015-09-11 16:58:32 +0530 | [diff] [blame] | 4632 | struct intel_encoder *intel_encoder = &intel_dig_port->base; |
| 4633 | enum port port; |
Jani Nikula | e464bfd | 2015-08-20 10:47:42 +0300 | [diff] [blame] | 4634 | u32 bit; |
| 4635 | |
Rodrigo Vivi | 256cfdd | 2017-08-11 11:26:49 -0700 | [diff] [blame] | 4636 | port = intel_hpd_pin_to_port(intel_encoder->hpd_pin); |
Sonika Jindal | e2ec35a | 2015-09-11 16:58:32 +0530 | [diff] [blame] | 4637 | switch (port) { |
Jani Nikula | e464bfd | 2015-08-20 10:47:42 +0300 | [diff] [blame] | 4638 | case PORT_A: |
| 4639 | bit = BXT_DE_PORT_HP_DDIA; |
| 4640 | break; |
| 4641 | case PORT_B: |
| 4642 | bit = BXT_DE_PORT_HP_DDIB; |
| 4643 | break; |
| 4644 | case PORT_C: |
| 4645 | bit = BXT_DE_PORT_HP_DDIC; |
| 4646 | break; |
| 4647 | default: |
Sonika Jindal | e2ec35a | 2015-09-11 16:58:32 +0530 | [diff] [blame] | 4648 | MISSING_CASE(port); |
Jani Nikula | e464bfd | 2015-08-20 10:47:42 +0300 | [diff] [blame] | 4649 | return false; |
| 4650 | } |
| 4651 | |
| 4652 | return I915_READ(GEN8_DE_PORT_ISR) & bit; |
| 4653 | } |
| 4654 | |
Jani Nikula | 7e66bcf | 2015-08-20 10:47:39 +0300 | [diff] [blame] | 4655 | /* |
| 4656 | * intel_digital_port_connected - is the specified port connected? |
| 4657 | * @dev_priv: i915 private structure |
| 4658 | * @port: the port to test |
| 4659 | * |
| 4660 | * Return %true if @port is connected, %false otherwise. |
| 4661 | */ |
Imre Deak | 390b4e0 | 2017-01-27 11:39:19 +0200 | [diff] [blame] | 4662 | bool intel_digital_port_connected(struct drm_i915_private *dev_priv, |
| 4663 | struct intel_digital_port *port) |
Jani Nikula | 7e66bcf | 2015-08-20 10:47:39 +0300 | [diff] [blame] | 4664 | { |
Ville Syrjälä | 93e5f0b | 2017-06-15 20:12:52 +0300 | [diff] [blame] | 4665 | if (HAS_GMCH_DISPLAY(dev_priv)) { |
| 4666 | if (IS_GM45(dev_priv)) |
| 4667 | return gm45_digital_port_connected(dev_priv, port); |
| 4668 | else |
| 4669 | return g4x_digital_port_connected(dev_priv, port); |
| 4670 | } |
| 4671 | |
| 4672 | if (IS_GEN5(dev_priv)) |
| 4673 | return ilk_digital_port_connected(dev_priv, port); |
| 4674 | else if (IS_GEN6(dev_priv)) |
| 4675 | return snb_digital_port_connected(dev_priv, port); |
| 4676 | else if (IS_GEN7(dev_priv)) |
| 4677 | return ivb_digital_port_connected(dev_priv, port); |
| 4678 | else if (IS_GEN8(dev_priv)) |
| 4679 | return bdw_digital_port_connected(dev_priv, port); |
Ander Conselvan de Oliveira | cc3f90f | 2016-12-02 10:23:49 +0200 | [diff] [blame] | 4680 | else if (IS_GEN9_LP(dev_priv)) |
Jani Nikula | e464bfd | 2015-08-20 10:47:42 +0300 | [diff] [blame] | 4681 | return bxt_digital_port_connected(dev_priv, port); |
Jani Nikula | 7e66bcf | 2015-08-20 10:47:39 +0300 | [diff] [blame] | 4682 | else |
Ville Syrjälä | 93e5f0b | 2017-06-15 20:12:52 +0300 | [diff] [blame] | 4683 | return spt_digital_port_connected(dev_priv, port); |
Jani Nikula | 7e66bcf | 2015-08-20 10:47:39 +0300 | [diff] [blame] | 4684 | } |
| 4685 | |
Keith Packard | 8c241fe | 2011-09-28 16:38:44 -0700 | [diff] [blame] | 4686 | static struct edid * |
Chris Wilson | beb6060 | 2014-09-02 20:04:00 +0100 | [diff] [blame] | 4687 | intel_dp_get_edid(struct intel_dp *intel_dp) |
Keith Packard | 8c241fe | 2011-09-28 16:38:44 -0700 | [diff] [blame] | 4688 | { |
Chris Wilson | beb6060 | 2014-09-02 20:04:00 +0100 | [diff] [blame] | 4689 | struct intel_connector *intel_connector = intel_dp->attached_connector; |
Keith Packard | 8c241fe | 2011-09-28 16:38:44 -0700 | [diff] [blame] | 4690 | |
Jani Nikula | 9cd300e | 2012-10-19 14:51:52 +0300 | [diff] [blame] | 4691 | /* use cached edid if we have one */ |
| 4692 | if (intel_connector->edid) { |
Jani Nikula | 9cd300e | 2012-10-19 14:51:52 +0300 | [diff] [blame] | 4693 | /* invalid edid */ |
| 4694 | if (IS_ERR(intel_connector->edid)) |
Jesse Barnes | d6f24d0 | 2012-06-14 15:28:33 -0400 | [diff] [blame] | 4695 | return NULL; |
| 4696 | |
Jani Nikula | 55e9ede | 2013-10-01 10:38:54 +0300 | [diff] [blame] | 4697 | return drm_edid_duplicate(intel_connector->edid); |
Chris Wilson | beb6060 | 2014-09-02 20:04:00 +0100 | [diff] [blame] | 4698 | } else |
| 4699 | return drm_get_edid(&intel_connector->base, |
| 4700 | &intel_dp->aux.ddc); |
Keith Packard | 8c241fe | 2011-09-28 16:38:44 -0700 | [diff] [blame] | 4701 | } |
| 4702 | |
Chris Wilson | beb6060 | 2014-09-02 20:04:00 +0100 | [diff] [blame] | 4703 | static void |
| 4704 | intel_dp_set_edid(struct intel_dp *intel_dp) |
Keith Packard | 8c241fe | 2011-09-28 16:38:44 -0700 | [diff] [blame] | 4705 | { |
Chris Wilson | beb6060 | 2014-09-02 20:04:00 +0100 | [diff] [blame] | 4706 | struct intel_connector *intel_connector = intel_dp->attached_connector; |
| 4707 | struct edid *edid; |
Keith Packard | 8c241fe | 2011-09-28 16:38:44 -0700 | [diff] [blame] | 4708 | |
Shubhangi Shrivastava | f21a219 | 2016-03-30 18:05:22 +0530 | [diff] [blame] | 4709 | intel_dp_unset_edid(intel_dp); |
Chris Wilson | beb6060 | 2014-09-02 20:04:00 +0100 | [diff] [blame] | 4710 | edid = intel_dp_get_edid(intel_dp); |
| 4711 | intel_connector->detect_edid = edid; |
Jani Nikula | 9cd300e | 2012-10-19 14:51:52 +0300 | [diff] [blame] | 4712 | |
Maarten Lankhorst | e6b72c9 | 2017-05-01 15:38:00 +0200 | [diff] [blame] | 4713 | intel_dp->has_audio = drm_detect_monitor_audio(edid); |
Chris Wilson | beb6060 | 2014-09-02 20:04:00 +0100 | [diff] [blame] | 4714 | } |
Jesse Barnes | d6f24d0 | 2012-06-14 15:28:33 -0400 | [diff] [blame] | 4715 | |
Chris Wilson | beb6060 | 2014-09-02 20:04:00 +0100 | [diff] [blame] | 4716 | static void |
| 4717 | intel_dp_unset_edid(struct intel_dp *intel_dp) |
| 4718 | { |
| 4719 | struct intel_connector *intel_connector = intel_dp->attached_connector; |
| 4720 | |
| 4721 | kfree(intel_connector->detect_edid); |
| 4722 | intel_connector->detect_edid = NULL; |
| 4723 | |
| 4724 | intel_dp->has_audio = false; |
| 4725 | } |
| 4726 | |
Maarten Lankhorst | 6c5ed5a | 2017-04-06 20:55:20 +0200 | [diff] [blame] | 4727 | static int |
Ville Syrjälä | 2f77347 | 2017-11-09 17:27:58 +0200 | [diff] [blame] | 4728 | intel_dp_long_pulse(struct intel_connector *connector) |
Zhenyu Wang | a9756bb | 2010-09-19 13:09:06 +0800 | [diff] [blame] | 4729 | { |
Ville Syrjälä | 2f77347 | 2017-11-09 17:27:58 +0200 | [diff] [blame] | 4730 | struct drm_i915_private *dev_priv = to_i915(connector->base.dev); |
| 4731 | struct intel_dp *intel_dp = intel_attached_dp(&connector->base); |
Zhenyu Wang | a9756bb | 2010-09-19 13:09:06 +0800 | [diff] [blame] | 4732 | enum drm_connector_status status; |
Ville Syrjälä | 65fbb4e | 2016-07-28 17:50:47 +0300 | [diff] [blame] | 4733 | u8 sink_irq_vector = 0; |
Zhenyu Wang | a9756bb | 2010-09-19 13:09:06 +0800 | [diff] [blame] | 4734 | |
Ville Syrjälä | 2f77347 | 2017-11-09 17:27:58 +0200 | [diff] [blame] | 4735 | WARN_ON(!drm_modeset_is_locked(&dev_priv->drm.mode_config.connection_mutex)); |
Maarten Lankhorst | 6c5ed5a | 2017-04-06 20:55:20 +0200 | [diff] [blame] | 4736 | |
Ville Syrjälä | 2f77347 | 2017-11-09 17:27:58 +0200 | [diff] [blame] | 4737 | intel_display_power_get(dev_priv, intel_dp->aux_power_domain); |
Zhenyu Wang | a9756bb | 2010-09-19 13:09:06 +0800 | [diff] [blame] | 4738 | |
Chris Wilson | d410b56 | 2014-09-02 20:03:59 +0100 | [diff] [blame] | 4739 | /* Can't disconnect eDP, but you can close the lid... */ |
Jani Nikula | 1853a9d | 2017-08-18 12:30:20 +0300 | [diff] [blame] | 4740 | if (intel_dp_is_edp(intel_dp)) |
Chris Wilson | d410b56 | 2014-09-02 20:03:59 +0100 | [diff] [blame] | 4741 | status = edp_detect(intel_dp); |
Ville Syrjälä | 2f77347 | 2017-11-09 17:27:58 +0200 | [diff] [blame] | 4742 | else if (intel_digital_port_connected(dev_priv, |
Ander Conselvan de Oliveira | c555a81 | 2015-11-18 17:19:30 +0200 | [diff] [blame] | 4743 | dp_to_dig_port(intel_dp))) |
| 4744 | status = intel_dp_detect_dpcd(intel_dp); |
Zhenyu Wang | a9756bb | 2010-09-19 13:09:06 +0800 | [diff] [blame] | 4745 | else |
Ander Conselvan de Oliveira | c555a81 | 2015-11-18 17:19:30 +0200 | [diff] [blame] | 4746 | status = connector_status_disconnected; |
| 4747 | |
Ville Syrjälä | 5cb651a | 2016-10-03 10:55:16 +0300 | [diff] [blame] | 4748 | if (status == connector_status_disconnected) { |
Manasi Navare | c1617ab | 2016-12-09 16:22:50 -0800 | [diff] [blame] | 4749 | memset(&intel_dp->compliance, 0, sizeof(intel_dp->compliance)); |
Shubhangi Shrivastava | 4df6960 | 2015-10-28 15:30:36 +0530 | [diff] [blame] | 4750 | |
jim.bride@linux.intel.com | 0e505a0 | 2016-04-11 10:11:24 -0700 | [diff] [blame] | 4751 | if (intel_dp->is_mst) { |
| 4752 | DRM_DEBUG_KMS("MST device may have disappeared %d vs %d\n", |
| 4753 | intel_dp->is_mst, |
| 4754 | intel_dp->mst_mgr.mst_state); |
| 4755 | intel_dp->is_mst = false; |
| 4756 | drm_dp_mst_topology_mgr_set_mst(&intel_dp->mst_mgr, |
| 4757 | intel_dp->is_mst); |
| 4758 | } |
| 4759 | |
Paulo Zanoni | c8c8fb3 | 2013-11-27 18:21:54 -0200 | [diff] [blame] | 4760 | goto out; |
Shubhangi Shrivastava | 4df6960 | 2015-10-28 15:30:36 +0530 | [diff] [blame] | 4761 | } |
Zhenyu Wang | a9756bb | 2010-09-19 13:09:06 +0800 | [diff] [blame] | 4762 | |
Manasi Navare | d7e8ef0 | 2017-02-07 16:54:11 -0800 | [diff] [blame] | 4763 | if (intel_dp->reset_link_params) { |
Jani Nikula | 540b0b7f | 2017-04-06 16:44:13 +0300 | [diff] [blame] | 4764 | /* Initial max link lane count */ |
| 4765 | intel_dp->max_link_lane_count = intel_dp_max_common_lane_count(intel_dp); |
Manasi Navare | f482984 | 2016-12-05 16:27:36 -0800 | [diff] [blame] | 4766 | |
Jani Nikula | 540b0b7f | 2017-04-06 16:44:13 +0300 | [diff] [blame] | 4767 | /* Initial max link rate */ |
| 4768 | intel_dp->max_link_rate = intel_dp_max_common_rate(intel_dp); |
Manasi Navare | d7e8ef0 | 2017-02-07 16:54:11 -0800 | [diff] [blame] | 4769 | |
| 4770 | intel_dp->reset_link_params = false; |
| 4771 | } |
Manasi Navare | f482984 | 2016-12-05 16:27:36 -0800 | [diff] [blame] | 4772 | |
Ville Syrjälä | fe5a66f | 2016-07-29 16:52:39 +0300 | [diff] [blame] | 4773 | intel_dp_print_rates(intel_dp); |
| 4774 | |
Jani Nikula | 84c3675 | 2017-05-18 14:10:23 +0300 | [diff] [blame] | 4775 | drm_dp_read_desc(&intel_dp->aux, &intel_dp->desc, |
| 4776 | drm_dp_is_branch(intel_dp->dpcd)); |
Mika Kahola | 0e390a3 | 2016-09-09 14:10:53 +0300 | [diff] [blame] | 4777 | |
Ville Syrjälä | c4e3170 | 2016-07-29 16:51:16 +0300 | [diff] [blame] | 4778 | intel_dp_configure_mst(intel_dp); |
| 4779 | |
| 4780 | if (intel_dp->is_mst) { |
Shubhangi Shrivastava | f21a219 | 2016-03-30 18:05:22 +0530 | [diff] [blame] | 4781 | /* |
| 4782 | * If we are in MST mode then this connector |
| 4783 | * won't appear connected or have anything |
| 4784 | * with EDID on it |
| 4785 | */ |
Dave Airlie | 0e32b39 | 2014-05-02 14:02:48 +1000 | [diff] [blame] | 4786 | status = connector_status_disconnected; |
| 4787 | goto out; |
Ville Syrjälä | 1a36147 | 2017-04-12 22:30:17 +0300 | [diff] [blame] | 4788 | } else { |
| 4789 | /* |
| 4790 | * If display is now connected check links status, |
| 4791 | * there has been known issues of link loss triggerring |
| 4792 | * long pulse. |
| 4793 | * |
| 4794 | * Some sinks (eg. ASUS PB287Q) seem to perform some |
| 4795 | * weird HPD ping pong during modesets. So we can apparently |
| 4796 | * end up with HPD going low during a modeset, and then |
| 4797 | * going back up soon after. And once that happens we must |
| 4798 | * retrain the link to get a picture. That's in case no |
| 4799 | * userspace component reacted to intermittent HPD dip. |
| 4800 | */ |
Shubhangi Shrivastava | 7d23e3c | 2016-03-30 18:05:23 +0530 | [diff] [blame] | 4801 | intel_dp_check_link_status(intel_dp); |
Dave Airlie | 0e32b39 | 2014-05-02 14:02:48 +1000 | [diff] [blame] | 4802 | } |
| 4803 | |
Shubhangi Shrivastava | 4df6960 | 2015-10-28 15:30:36 +0530 | [diff] [blame] | 4804 | /* |
| 4805 | * Clearing NACK and defer counts to get their exact values |
| 4806 | * while reading EDID which are required by Compliance tests |
| 4807 | * 4.2.2.4 and 4.2.2.5 |
| 4808 | */ |
| 4809 | intel_dp->aux.i2c_nack_count = 0; |
| 4810 | intel_dp->aux.i2c_defer_count = 0; |
| 4811 | |
Chris Wilson | beb6060 | 2014-09-02 20:04:00 +0100 | [diff] [blame] | 4812 | intel_dp_set_edid(intel_dp); |
Ville Syrjälä | 2f77347 | 2017-11-09 17:27:58 +0200 | [diff] [blame] | 4813 | if (intel_dp_is_edp(intel_dp) || connector->detect_edid) |
Ville Syrjälä | 5cb651a | 2016-10-03 10:55:16 +0300 | [diff] [blame] | 4814 | status = connector_status_connected; |
Shubhangi Shrivastava | 7d23e3c | 2016-03-30 18:05:23 +0530 | [diff] [blame] | 4815 | intel_dp->detect_done = true; |
Paulo Zanoni | c8c8fb3 | 2013-11-27 18:21:54 -0200 | [diff] [blame] | 4816 | |
Todd Previte | 09b1eb1 | 2015-04-20 15:27:34 -0700 | [diff] [blame] | 4817 | /* Try to read the source of the interrupt */ |
| 4818 | if (intel_dp->dpcd[DP_DPCD_REV] >= 0x11 && |
Ville Syrjälä | 65fbb4e | 2016-07-28 17:50:47 +0300 | [diff] [blame] | 4819 | intel_dp_get_sink_irq(intel_dp, &sink_irq_vector) && |
| 4820 | sink_irq_vector != 0) { |
Todd Previte | 09b1eb1 | 2015-04-20 15:27:34 -0700 | [diff] [blame] | 4821 | /* Clear interrupt source */ |
| 4822 | drm_dp_dpcd_writeb(&intel_dp->aux, |
| 4823 | DP_DEVICE_SERVICE_IRQ_VECTOR, |
| 4824 | sink_irq_vector); |
| 4825 | |
| 4826 | if (sink_irq_vector & DP_AUTOMATED_TEST_REQUEST) |
| 4827 | intel_dp_handle_test_request(intel_dp); |
| 4828 | if (sink_irq_vector & (DP_CP_IRQ | DP_SINK_SPECIFIC_IRQ)) |
| 4829 | DRM_DEBUG_DRIVER("CP or sink specific irq unhandled\n"); |
| 4830 | } |
| 4831 | |
Paulo Zanoni | c8c8fb3 | 2013-11-27 18:21:54 -0200 | [diff] [blame] | 4832 | out: |
Ville Syrjälä | 5cb651a | 2016-10-03 10:55:16 +0300 | [diff] [blame] | 4833 | if (status != connector_status_connected && !intel_dp->is_mst) |
Shubhangi Shrivastava | f21a219 | 2016-03-30 18:05:22 +0530 | [diff] [blame] | 4834 | intel_dp_unset_edid(intel_dp); |
Shubhangi Shrivastava | 7d23e3c | 2016-03-30 18:05:23 +0530 | [diff] [blame] | 4835 | |
Ville Syrjälä | 2f77347 | 2017-11-09 17:27:58 +0200 | [diff] [blame] | 4836 | intel_display_power_put(dev_priv, intel_dp->aux_power_domain); |
Ville Syrjälä | 5cb651a | 2016-10-03 10:55:16 +0300 | [diff] [blame] | 4837 | return status; |
Shubhangi Shrivastava | f21a219 | 2016-03-30 18:05:22 +0530 | [diff] [blame] | 4838 | } |
| 4839 | |
Maarten Lankhorst | 6c5ed5a | 2017-04-06 20:55:20 +0200 | [diff] [blame] | 4840 | static int |
| 4841 | intel_dp_detect(struct drm_connector *connector, |
| 4842 | struct drm_modeset_acquire_ctx *ctx, |
| 4843 | bool force) |
Shubhangi Shrivastava | f21a219 | 2016-03-30 18:05:22 +0530 | [diff] [blame] | 4844 | { |
| 4845 | struct intel_dp *intel_dp = intel_attached_dp(connector); |
Maarten Lankhorst | 6c5ed5a | 2017-04-06 20:55:20 +0200 | [diff] [blame] | 4846 | int status = connector->status; |
Shubhangi Shrivastava | f21a219 | 2016-03-30 18:05:22 +0530 | [diff] [blame] | 4847 | |
| 4848 | DRM_DEBUG_KMS("[CONNECTOR:%d:%s]\n", |
| 4849 | connector->base.id, connector->name); |
| 4850 | |
Shubhangi Shrivastava | 7d23e3c | 2016-03-30 18:05:23 +0530 | [diff] [blame] | 4851 | /* If full detect is not performed yet, do a full detect */ |
Daniel Vetter | 42e5e65 | 2017-11-13 17:01:40 +0100 | [diff] [blame] | 4852 | if (!intel_dp->detect_done) { |
| 4853 | struct drm_crtc *crtc; |
| 4854 | int ret; |
| 4855 | |
| 4856 | crtc = connector->state->crtc; |
| 4857 | if (crtc) { |
| 4858 | ret = drm_modeset_lock(&crtc->mutex, ctx); |
| 4859 | if (ret) |
| 4860 | return ret; |
| 4861 | } |
| 4862 | |
Ville Syrjälä | 5cb651a | 2016-10-03 10:55:16 +0300 | [diff] [blame] | 4863 | status = intel_dp_long_pulse(intel_dp->attached_connector); |
Daniel Vetter | 42e5e65 | 2017-11-13 17:01:40 +0100 | [diff] [blame] | 4864 | } |
Shubhangi Shrivastava | 7d23e3c | 2016-03-30 18:05:23 +0530 | [diff] [blame] | 4865 | |
| 4866 | intel_dp->detect_done = false; |
Shubhangi Shrivastava | f21a219 | 2016-03-30 18:05:22 +0530 | [diff] [blame] | 4867 | |
Ville Syrjälä | 5cb651a | 2016-10-03 10:55:16 +0300 | [diff] [blame] | 4868 | return status; |
Keith Packard | a4fc5ed | 2009-04-07 16:16:42 -0700 | [diff] [blame] | 4869 | } |
| 4870 | |
Chris Wilson | beb6060 | 2014-09-02 20:04:00 +0100 | [diff] [blame] | 4871 | static void |
| 4872 | intel_dp_force(struct drm_connector *connector) |
| 4873 | { |
| 4874 | struct intel_dp *intel_dp = intel_attached_dp(connector); |
| 4875 | struct intel_encoder *intel_encoder = &dp_to_dig_port(intel_dp)->base; |
Ville Syrjälä | 25f78f5 | 2015-11-16 15:01:04 +0100 | [diff] [blame] | 4876 | struct drm_i915_private *dev_priv = to_i915(intel_encoder->base.dev); |
Chris Wilson | beb6060 | 2014-09-02 20:04:00 +0100 | [diff] [blame] | 4877 | |
| 4878 | DRM_DEBUG_KMS("[CONNECTOR:%d:%s]\n", |
| 4879 | connector->base.id, connector->name); |
| 4880 | intel_dp_unset_edid(intel_dp); |
| 4881 | |
| 4882 | if (connector->status != connector_status_connected) |
| 4883 | return; |
| 4884 | |
Ander Conselvan de Oliveira | 5432fca | 2017-02-22 08:34:26 +0200 | [diff] [blame] | 4885 | intel_display_power_get(dev_priv, intel_dp->aux_power_domain); |
Chris Wilson | beb6060 | 2014-09-02 20:04:00 +0100 | [diff] [blame] | 4886 | |
| 4887 | intel_dp_set_edid(intel_dp); |
| 4888 | |
Ander Conselvan de Oliveira | 5432fca | 2017-02-22 08:34:26 +0200 | [diff] [blame] | 4889 | intel_display_power_put(dev_priv, intel_dp->aux_power_domain); |
Chris Wilson | beb6060 | 2014-09-02 20:04:00 +0100 | [diff] [blame] | 4890 | } |
| 4891 | |
Keith Packard | a4fc5ed | 2009-04-07 16:16:42 -0700 | [diff] [blame] | 4892 | static int intel_dp_get_modes(struct drm_connector *connector) |
| 4893 | { |
Jani Nikula | dd06f90 | 2012-10-19 14:51:50 +0300 | [diff] [blame] | 4894 | struct intel_connector *intel_connector = to_intel_connector(connector); |
Chris Wilson | beb6060 | 2014-09-02 20:04:00 +0100 | [diff] [blame] | 4895 | struct edid *edid; |
Keith Packard | a4fc5ed | 2009-04-07 16:16:42 -0700 | [diff] [blame] | 4896 | |
Chris Wilson | beb6060 | 2014-09-02 20:04:00 +0100 | [diff] [blame] | 4897 | edid = intel_connector->detect_edid; |
| 4898 | if (edid) { |
| 4899 | int ret = intel_connector_update_modes(connector, edid); |
| 4900 | if (ret) |
| 4901 | return ret; |
| 4902 | } |
Zhenyu Wang | 32f9d65 | 2009-07-24 01:00:32 +0800 | [diff] [blame] | 4903 | |
Jani Nikula | f8779fd | 2012-10-19 14:51:48 +0300 | [diff] [blame] | 4904 | /* if eDP has no EDID, fall back to fixed mode */ |
Jani Nikula | 1853a9d | 2017-08-18 12:30:20 +0300 | [diff] [blame] | 4905 | if (intel_dp_is_edp(intel_attached_dp(connector)) && |
Chris Wilson | beb6060 | 2014-09-02 20:04:00 +0100 | [diff] [blame] | 4906 | intel_connector->panel.fixed_mode) { |
Jani Nikula | f8779fd | 2012-10-19 14:51:48 +0300 | [diff] [blame] | 4907 | struct drm_display_mode *mode; |
Chris Wilson | beb6060 | 2014-09-02 20:04:00 +0100 | [diff] [blame] | 4908 | |
| 4909 | mode = drm_mode_duplicate(connector->dev, |
Jani Nikula | dd06f90 | 2012-10-19 14:51:50 +0300 | [diff] [blame] | 4910 | intel_connector->panel.fixed_mode); |
Jani Nikula | f8779fd | 2012-10-19 14:51:48 +0300 | [diff] [blame] | 4911 | if (mode) { |
Zhenyu Wang | 32f9d65 | 2009-07-24 01:00:32 +0800 | [diff] [blame] | 4912 | drm_mode_probed_add(connector, mode); |
| 4913 | return 1; |
| 4914 | } |
| 4915 | } |
Chris Wilson | beb6060 | 2014-09-02 20:04:00 +0100 | [diff] [blame] | 4916 | |
Zhenyu Wang | 32f9d65 | 2009-07-24 01:00:32 +0800 | [diff] [blame] | 4917 | return 0; |
Keith Packard | a4fc5ed | 2009-04-07 16:16:42 -0700 | [diff] [blame] | 4918 | } |
| 4919 | |
Chris Wilson | f684960 | 2010-09-19 09:29:33 +0100 | [diff] [blame] | 4920 | static int |
Chris Wilson | 7a418e3 | 2016-06-24 14:00:14 +0100 | [diff] [blame] | 4921 | intel_dp_connector_register(struct drm_connector *connector) |
| 4922 | { |
| 4923 | struct intel_dp *intel_dp = intel_attached_dp(connector); |
Chris Wilson | 1ebaa0b | 2016-06-24 14:00:15 +0100 | [diff] [blame] | 4924 | int ret; |
| 4925 | |
| 4926 | ret = intel_connector_register(connector); |
| 4927 | if (ret) |
| 4928 | return ret; |
Chris Wilson | 7a418e3 | 2016-06-24 14:00:14 +0100 | [diff] [blame] | 4929 | |
| 4930 | i915_debugfs_connector_add(connector); |
| 4931 | |
| 4932 | DRM_DEBUG_KMS("registering %s bus for %s\n", |
| 4933 | intel_dp->aux.name, connector->kdev->kobj.name); |
| 4934 | |
| 4935 | intel_dp->aux.dev = connector->kdev; |
| 4936 | return drm_dp_aux_register(&intel_dp->aux); |
| 4937 | } |
| 4938 | |
Keith Packard | a4fc5ed | 2009-04-07 16:16:42 -0700 | [diff] [blame] | 4939 | static void |
Chris Wilson | c191eca | 2016-06-17 11:40:33 +0100 | [diff] [blame] | 4940 | intel_dp_connector_unregister(struct drm_connector *connector) |
| 4941 | { |
| 4942 | drm_dp_aux_unregister(&intel_attached_dp(connector)->aux); |
| 4943 | intel_connector_unregister(connector); |
| 4944 | } |
| 4945 | |
| 4946 | static void |
Paulo Zanoni | 73845ad | 2013-06-12 17:27:30 -0300 | [diff] [blame] | 4947 | intel_dp_connector_destroy(struct drm_connector *connector) |
Keith Packard | a4fc5ed | 2009-04-07 16:16:42 -0700 | [diff] [blame] | 4948 | { |
Jani Nikula | 1d50870 | 2012-10-19 14:51:49 +0300 | [diff] [blame] | 4949 | struct intel_connector *intel_connector = to_intel_connector(connector); |
Matthew Garrett | aaa6fd2 | 2011-08-12 12:11:33 +0200 | [diff] [blame] | 4950 | |
Chris Wilson | 10e972d | 2014-09-04 21:43:45 +0100 | [diff] [blame] | 4951 | kfree(intel_connector->detect_edid); |
Chris Wilson | beb6060 | 2014-09-02 20:04:00 +0100 | [diff] [blame] | 4952 | |
Jani Nikula | 9cd300e | 2012-10-19 14:51:52 +0300 | [diff] [blame] | 4953 | if (!IS_ERR_OR_NULL(intel_connector->edid)) |
| 4954 | kfree(intel_connector->edid); |
| 4955 | |
Jani Nikula | 1853a9d | 2017-08-18 12:30:20 +0300 | [diff] [blame] | 4956 | /* |
| 4957 | * Can't call intel_dp_is_edp() since the encoder may have been |
| 4958 | * destroyed already. |
| 4959 | */ |
Paulo Zanoni | acd8db10 | 2013-06-12 17:27:23 -0300 | [diff] [blame] | 4960 | if (connector->connector_type == DRM_MODE_CONNECTOR_eDP) |
Jani Nikula | 1d50870 | 2012-10-19 14:51:49 +0300 | [diff] [blame] | 4961 | intel_panel_fini(&intel_connector->panel); |
Matthew Garrett | aaa6fd2 | 2011-08-12 12:11:33 +0200 | [diff] [blame] | 4962 | |
Keith Packard | a4fc5ed | 2009-04-07 16:16:42 -0700 | [diff] [blame] | 4963 | drm_connector_cleanup(connector); |
Zhenyu Wang | 55f78c4 | 2010-03-29 16:13:57 +0800 | [diff] [blame] | 4964 | kfree(connector); |
Keith Packard | a4fc5ed | 2009-04-07 16:16:42 -0700 | [diff] [blame] | 4965 | } |
| 4966 | |
Paulo Zanoni | 00c09d7 | 2012-10-26 19:05:52 -0200 | [diff] [blame] | 4967 | void intel_dp_encoder_destroy(struct drm_encoder *encoder) |
Daniel Vetter | 24d0592 | 2010-08-20 18:08:28 +0200 | [diff] [blame] | 4968 | { |
Paulo Zanoni | da63a9f | 2012-10-26 19:05:46 -0200 | [diff] [blame] | 4969 | struct intel_digital_port *intel_dig_port = enc_to_dig_port(encoder); |
| 4970 | struct intel_dp *intel_dp = &intel_dig_port->dp; |
Daniel Vetter | 24d0592 | 2010-08-20 18:08:28 +0200 | [diff] [blame] | 4971 | |
Dave Airlie | 0e32b39 | 2014-05-02 14:02:48 +1000 | [diff] [blame] | 4972 | intel_dp_mst_encoder_cleanup(intel_dig_port); |
Jani Nikula | 1853a9d | 2017-08-18 12:30:20 +0300 | [diff] [blame] | 4973 | if (intel_dp_is_edp(intel_dp)) { |
Keith Packard | bd94315 | 2011-09-18 23:09:52 -0700 | [diff] [blame] | 4974 | cancel_delayed_work_sync(&intel_dp->panel_vdd_work); |
Ville Syrjälä | 951468f | 2014-09-04 14:55:31 +0300 | [diff] [blame] | 4975 | /* |
| 4976 | * vdd might still be enabled do to the delayed vdd off. |
| 4977 | * Make sure vdd is actually turned off here. |
| 4978 | */ |
Ville Syrjälä | 773538e8 | 2014-09-04 14:54:56 +0300 | [diff] [blame] | 4979 | pps_lock(intel_dp); |
Daniel Vetter | 4be7378 | 2014-01-17 14:39:48 +0100 | [diff] [blame] | 4980 | edp_panel_vdd_off_sync(intel_dp); |
Ville Syrjälä | 773538e8 | 2014-09-04 14:54:56 +0300 | [diff] [blame] | 4981 | pps_unlock(intel_dp); |
| 4982 | |
Clint Taylor | 01527b3 | 2014-07-07 13:01:46 -0700 | [diff] [blame] | 4983 | if (intel_dp->edp_notifier.notifier_call) { |
| 4984 | unregister_reboot_notifier(&intel_dp->edp_notifier); |
| 4985 | intel_dp->edp_notifier.notifier_call = NULL; |
| 4986 | } |
Keith Packard | bd94315 | 2011-09-18 23:09:52 -0700 | [diff] [blame] | 4987 | } |
Chris Wilson | 9968188 | 2016-06-20 09:29:17 +0100 | [diff] [blame] | 4988 | |
| 4989 | intel_dp_aux_fini(intel_dp); |
| 4990 | |
Imre Deak | c8bd0e4 | 2014-12-12 17:57:38 +0200 | [diff] [blame] | 4991 | drm_encoder_cleanup(encoder); |
Paulo Zanoni | da63a9f | 2012-10-26 19:05:46 -0200 | [diff] [blame] | 4992 | kfree(intel_dig_port); |
Daniel Vetter | 24d0592 | 2010-08-20 18:08:28 +0200 | [diff] [blame] | 4993 | } |
| 4994 | |
Imre Deak | bf93ba6 | 2016-04-18 10:04:21 +0300 | [diff] [blame] | 4995 | void intel_dp_encoder_suspend(struct intel_encoder *intel_encoder) |
Imre Deak | 07f9cd0 | 2014-08-18 14:42:45 +0300 | [diff] [blame] | 4996 | { |
| 4997 | struct intel_dp *intel_dp = enc_to_intel_dp(&intel_encoder->base); |
| 4998 | |
Jani Nikula | 1853a9d | 2017-08-18 12:30:20 +0300 | [diff] [blame] | 4999 | if (!intel_dp_is_edp(intel_dp)) |
Imre Deak | 07f9cd0 | 2014-08-18 14:42:45 +0300 | [diff] [blame] | 5000 | return; |
| 5001 | |
Ville Syrjälä | 951468f | 2014-09-04 14:55:31 +0300 | [diff] [blame] | 5002 | /* |
| 5003 | * vdd might still be enabled do to the delayed vdd off. |
| 5004 | * Make sure vdd is actually turned off here. |
| 5005 | */ |
Ville Syrjälä | afa4e53 | 2014-11-25 15:43:48 +0200 | [diff] [blame] | 5006 | cancel_delayed_work_sync(&intel_dp->panel_vdd_work); |
Ville Syrjälä | 773538e8 | 2014-09-04 14:54:56 +0300 | [diff] [blame] | 5007 | pps_lock(intel_dp); |
Imre Deak | 07f9cd0 | 2014-08-18 14:42:45 +0300 | [diff] [blame] | 5008 | edp_panel_vdd_off_sync(intel_dp); |
Ville Syrjälä | 773538e8 | 2014-09-04 14:54:56 +0300 | [diff] [blame] | 5009 | pps_unlock(intel_dp); |
Imre Deak | 07f9cd0 | 2014-08-18 14:42:45 +0300 | [diff] [blame] | 5010 | } |
| 5011 | |
Sean Paul | 20f24d7 | 2018-01-08 14:55:43 -0500 | [diff] [blame] | 5012 | static |
| 5013 | int intel_dp_hdcp_write_an_aksv(struct intel_digital_port *intel_dig_port, |
| 5014 | u8 *an) |
| 5015 | { |
| 5016 | struct intel_dp *intel_dp = enc_to_intel_dp(&intel_dig_port->base.base); |
| 5017 | uint8_t txbuf[4], rxbuf[2], reply = 0; |
| 5018 | ssize_t dpcd_ret; |
| 5019 | int ret; |
| 5020 | |
| 5021 | /* Output An first, that's easy */ |
| 5022 | dpcd_ret = drm_dp_dpcd_write(&intel_dig_port->dp.aux, DP_AUX_HDCP_AN, |
| 5023 | an, DRM_HDCP_AN_LEN); |
| 5024 | if (dpcd_ret != DRM_HDCP_AN_LEN) { |
| 5025 | DRM_ERROR("Failed to write An over DP/AUX (%zd)\n", dpcd_ret); |
| 5026 | return dpcd_ret >= 0 ? -EIO : dpcd_ret; |
| 5027 | } |
| 5028 | |
| 5029 | /* |
| 5030 | * Since Aksv is Oh-So-Secret, we can't access it in software. So in |
| 5031 | * order to get it on the wire, we need to create the AUX header as if |
| 5032 | * we were writing the data, and then tickle the hardware to output the |
| 5033 | * data once the header is sent out. |
| 5034 | */ |
| 5035 | txbuf[0] = (DP_AUX_NATIVE_WRITE << 4) | |
| 5036 | ((DP_AUX_HDCP_AKSV >> 16) & 0xf); |
| 5037 | txbuf[1] = (DP_AUX_HDCP_AKSV >> 8) & 0xff; |
| 5038 | txbuf[2] = DP_AUX_HDCP_AKSV & 0xff; |
| 5039 | txbuf[3] = DRM_HDCP_KSV_LEN - 1; |
| 5040 | |
| 5041 | ret = intel_dp_aux_ch(intel_dp, txbuf, sizeof(txbuf), rxbuf, |
| 5042 | sizeof(rxbuf), true); |
| 5043 | if (ret < 0) { |
| 5044 | DRM_ERROR("Write Aksv over DP/AUX failed (%d)\n", ret); |
| 5045 | return ret; |
| 5046 | } else if (ret == 0) { |
| 5047 | DRM_ERROR("Aksv write over DP/AUX was empty\n"); |
| 5048 | return -EIO; |
| 5049 | } |
| 5050 | |
| 5051 | reply = (rxbuf[0] >> 4) & DP_AUX_NATIVE_REPLY_MASK; |
| 5052 | return reply == DP_AUX_NATIVE_REPLY_ACK ? 0 : -EIO; |
| 5053 | } |
| 5054 | |
| 5055 | static int intel_dp_hdcp_read_bksv(struct intel_digital_port *intel_dig_port, |
| 5056 | u8 *bksv) |
| 5057 | { |
| 5058 | ssize_t ret; |
| 5059 | ret = drm_dp_dpcd_read(&intel_dig_port->dp.aux, DP_AUX_HDCP_BKSV, bksv, |
| 5060 | DRM_HDCP_KSV_LEN); |
| 5061 | if (ret != DRM_HDCP_KSV_LEN) { |
| 5062 | DRM_ERROR("Read Bksv from DP/AUX failed (%zd)\n", ret); |
| 5063 | return ret >= 0 ? -EIO : ret; |
| 5064 | } |
| 5065 | return 0; |
| 5066 | } |
| 5067 | |
| 5068 | static int intel_dp_hdcp_read_bstatus(struct intel_digital_port *intel_dig_port, |
| 5069 | u8 *bstatus) |
| 5070 | { |
| 5071 | ssize_t ret; |
| 5072 | /* |
| 5073 | * For some reason the HDMI and DP HDCP specs call this register |
| 5074 | * definition by different names. In the HDMI spec, it's called BSTATUS, |
| 5075 | * but in DP it's called BINFO. |
| 5076 | */ |
| 5077 | ret = drm_dp_dpcd_read(&intel_dig_port->dp.aux, DP_AUX_HDCP_BINFO, |
| 5078 | bstatus, DRM_HDCP_BSTATUS_LEN); |
| 5079 | if (ret != DRM_HDCP_BSTATUS_LEN) { |
| 5080 | DRM_ERROR("Read bstatus from DP/AUX failed (%zd)\n", ret); |
| 5081 | return ret >= 0 ? -EIO : ret; |
| 5082 | } |
| 5083 | return 0; |
| 5084 | } |
| 5085 | |
| 5086 | static |
| 5087 | int intel_dp_hdcp_repeater_present(struct intel_digital_port *intel_dig_port, |
| 5088 | bool *repeater_present) |
| 5089 | { |
| 5090 | ssize_t ret; |
| 5091 | u8 bcaps; |
| 5092 | ret = drm_dp_dpcd_read(&intel_dig_port->dp.aux, DP_AUX_HDCP_BCAPS, |
| 5093 | &bcaps, 1); |
| 5094 | if (ret != 1) { |
| 5095 | DRM_ERROR("Read bcaps from DP/AUX failed (%zd)\n", ret); |
| 5096 | return ret >= 0 ? -EIO : ret; |
| 5097 | } |
| 5098 | *repeater_present = bcaps & DP_BCAPS_REPEATER_PRESENT; |
| 5099 | return 0; |
| 5100 | } |
| 5101 | |
| 5102 | static |
| 5103 | int intel_dp_hdcp_read_ri_prime(struct intel_digital_port *intel_dig_port, |
| 5104 | u8 *ri_prime) |
| 5105 | { |
| 5106 | ssize_t ret; |
| 5107 | ret = drm_dp_dpcd_read(&intel_dig_port->dp.aux, DP_AUX_HDCP_RI_PRIME, |
| 5108 | ri_prime, DRM_HDCP_RI_LEN); |
| 5109 | if (ret != DRM_HDCP_RI_LEN) { |
| 5110 | DRM_ERROR("Read Ri' from DP/AUX failed (%zd)\n", ret); |
| 5111 | return ret >= 0 ? -EIO : ret; |
| 5112 | } |
| 5113 | return 0; |
| 5114 | } |
| 5115 | |
| 5116 | static |
| 5117 | int intel_dp_hdcp_read_ksv_ready(struct intel_digital_port *intel_dig_port, |
| 5118 | bool *ksv_ready) |
| 5119 | { |
| 5120 | ssize_t ret; |
| 5121 | u8 bstatus; |
| 5122 | ret = drm_dp_dpcd_read(&intel_dig_port->dp.aux, DP_AUX_HDCP_BSTATUS, |
| 5123 | &bstatus, 1); |
| 5124 | if (ret != 1) { |
| 5125 | DRM_ERROR("Read bstatus from DP/AUX failed (%zd)\n", ret); |
| 5126 | return ret >= 0 ? -EIO : ret; |
| 5127 | } |
| 5128 | *ksv_ready = bstatus & DP_BSTATUS_READY; |
| 5129 | return 0; |
| 5130 | } |
| 5131 | |
| 5132 | static |
| 5133 | int intel_dp_hdcp_read_ksv_fifo(struct intel_digital_port *intel_dig_port, |
| 5134 | int num_downstream, u8 *ksv_fifo) |
| 5135 | { |
| 5136 | ssize_t ret; |
| 5137 | int i; |
| 5138 | |
| 5139 | /* KSV list is read via 15 byte window (3 entries @ 5 bytes each) */ |
| 5140 | for (i = 0; i < num_downstream; i += 3) { |
| 5141 | size_t len = min(num_downstream - i, 3) * DRM_HDCP_KSV_LEN; |
| 5142 | ret = drm_dp_dpcd_read(&intel_dig_port->dp.aux, |
| 5143 | DP_AUX_HDCP_KSV_FIFO, |
| 5144 | ksv_fifo + i * DRM_HDCP_KSV_LEN, |
| 5145 | len); |
| 5146 | if (ret != len) { |
| 5147 | DRM_ERROR("Read ksv[%d] from DP/AUX failed (%zd)\n", i, |
| 5148 | ret); |
| 5149 | return ret >= 0 ? -EIO : ret; |
| 5150 | } |
| 5151 | } |
| 5152 | return 0; |
| 5153 | } |
| 5154 | |
| 5155 | static |
| 5156 | int intel_dp_hdcp_read_v_prime_part(struct intel_digital_port *intel_dig_port, |
| 5157 | int i, u32 *part) |
| 5158 | { |
| 5159 | ssize_t ret; |
| 5160 | |
| 5161 | if (i >= DRM_HDCP_V_PRIME_NUM_PARTS) |
| 5162 | return -EINVAL; |
| 5163 | |
| 5164 | ret = drm_dp_dpcd_read(&intel_dig_port->dp.aux, |
| 5165 | DP_AUX_HDCP_V_PRIME(i), part, |
| 5166 | DRM_HDCP_V_PRIME_PART_LEN); |
| 5167 | if (ret != DRM_HDCP_V_PRIME_PART_LEN) { |
| 5168 | DRM_ERROR("Read v'[%d] from DP/AUX failed (%zd)\n", i, ret); |
| 5169 | return ret >= 0 ? -EIO : ret; |
| 5170 | } |
| 5171 | return 0; |
| 5172 | } |
| 5173 | |
| 5174 | static |
| 5175 | int intel_dp_hdcp_toggle_signalling(struct intel_digital_port *intel_dig_port, |
| 5176 | bool enable) |
| 5177 | { |
| 5178 | /* Not used for single stream DisplayPort setups */ |
| 5179 | return 0; |
| 5180 | } |
| 5181 | |
| 5182 | static |
| 5183 | bool intel_dp_hdcp_check_link(struct intel_digital_port *intel_dig_port) |
| 5184 | { |
| 5185 | ssize_t ret; |
| 5186 | u8 bstatus; |
Chris Wilson | b7fc1a9 | 2018-01-18 16:10:25 +0000 | [diff] [blame^] | 5187 | |
Sean Paul | 20f24d7 | 2018-01-08 14:55:43 -0500 | [diff] [blame] | 5188 | ret = drm_dp_dpcd_read(&intel_dig_port->dp.aux, DP_AUX_HDCP_BSTATUS, |
| 5189 | &bstatus, 1); |
| 5190 | if (ret != 1) { |
| 5191 | DRM_ERROR("Read bstatus from DP/AUX failed (%zd)\n", ret); |
Chris Wilson | b7fc1a9 | 2018-01-18 16:10:25 +0000 | [diff] [blame^] | 5192 | return false; |
Sean Paul | 20f24d7 | 2018-01-08 14:55:43 -0500 | [diff] [blame] | 5193 | } |
Chris Wilson | b7fc1a9 | 2018-01-18 16:10:25 +0000 | [diff] [blame^] | 5194 | |
Sean Paul | 20f24d7 | 2018-01-08 14:55:43 -0500 | [diff] [blame] | 5195 | return !(bstatus & (DP_BSTATUS_LINK_FAILURE | DP_BSTATUS_REAUTH_REQ)); |
| 5196 | } |
| 5197 | |
| 5198 | static const struct intel_hdcp_shim intel_dp_hdcp_shim = { |
| 5199 | .write_an_aksv = intel_dp_hdcp_write_an_aksv, |
| 5200 | .read_bksv = intel_dp_hdcp_read_bksv, |
| 5201 | .read_bstatus = intel_dp_hdcp_read_bstatus, |
| 5202 | .repeater_present = intel_dp_hdcp_repeater_present, |
| 5203 | .read_ri_prime = intel_dp_hdcp_read_ri_prime, |
| 5204 | .read_ksv_ready = intel_dp_hdcp_read_ksv_ready, |
| 5205 | .read_ksv_fifo = intel_dp_hdcp_read_ksv_fifo, |
| 5206 | .read_v_prime_part = intel_dp_hdcp_read_v_prime_part, |
| 5207 | .toggle_signalling = intel_dp_hdcp_toggle_signalling, |
| 5208 | .check_link = intel_dp_hdcp_check_link, |
| 5209 | }; |
| 5210 | |
Ville Syrjälä | 49e6bc5 | 2014-10-28 16:15:52 +0200 | [diff] [blame] | 5211 | static void intel_edp_panel_vdd_sanitize(struct intel_dp *intel_dp) |
| 5212 | { |
Ville Syrjälä | 2f77347 | 2017-11-09 17:27:58 +0200 | [diff] [blame] | 5213 | struct drm_i915_private *dev_priv = to_i915(intel_dp_to_dev(intel_dp)); |
Ville Syrjälä | 49e6bc5 | 2014-10-28 16:15:52 +0200 | [diff] [blame] | 5214 | |
| 5215 | lockdep_assert_held(&dev_priv->pps_mutex); |
| 5216 | |
| 5217 | if (!edp_have_panel_vdd(intel_dp)) |
| 5218 | return; |
| 5219 | |
| 5220 | /* |
| 5221 | * The VDD bit needs a power domain reference, so if the bit is |
| 5222 | * already enabled when we boot or resume, grab this reference and |
| 5223 | * schedule a vdd off, so we don't hold on to the reference |
| 5224 | * indefinitely. |
| 5225 | */ |
| 5226 | DRM_DEBUG_KMS("VDD left on by BIOS, adjusting state tracking\n"); |
Ander Conselvan de Oliveira | 5432fca | 2017-02-22 08:34:26 +0200 | [diff] [blame] | 5227 | intel_display_power_get(dev_priv, intel_dp->aux_power_domain); |
Ville Syrjälä | 49e6bc5 | 2014-10-28 16:15:52 +0200 | [diff] [blame] | 5228 | |
| 5229 | edp_panel_vdd_schedule_off(intel_dp); |
| 5230 | } |
| 5231 | |
Ville Syrjälä | 9f2bdb0 | 2016-12-14 20:00:23 +0200 | [diff] [blame] | 5232 | static enum pipe vlv_active_pipe(struct intel_dp *intel_dp) |
| 5233 | { |
| 5234 | struct drm_i915_private *dev_priv = to_i915(intel_dp_to_dev(intel_dp)); |
| 5235 | |
| 5236 | if ((intel_dp->DP & DP_PORT_EN) == 0) |
| 5237 | return INVALID_PIPE; |
| 5238 | |
| 5239 | if (IS_CHERRYVIEW(dev_priv)) |
| 5240 | return DP_PORT_TO_PIPE_CHV(intel_dp->DP); |
| 5241 | else |
| 5242 | return PORT_TO_PIPE(intel_dp->DP); |
| 5243 | } |
| 5244 | |
Imre Deak | bf93ba6 | 2016-04-18 10:04:21 +0300 | [diff] [blame] | 5245 | void intel_dp_encoder_reset(struct drm_encoder *encoder) |
Imre Deak | 6d93c0c | 2014-07-31 14:03:36 +0300 | [diff] [blame] | 5246 | { |
Ville Syrjälä | 64989ca4 | 2016-05-13 20:53:56 +0300 | [diff] [blame] | 5247 | struct drm_i915_private *dev_priv = to_i915(encoder->dev); |
Imre Deak | dd75f6d | 2016-11-21 21:15:05 +0200 | [diff] [blame] | 5248 | struct intel_dp *intel_dp = enc_to_intel_dp(encoder); |
| 5249 | struct intel_lspcon *lspcon = dp_to_lspcon(intel_dp); |
Ville Syrjälä | 64989ca4 | 2016-05-13 20:53:56 +0300 | [diff] [blame] | 5250 | |
| 5251 | if (!HAS_DDI(dev_priv)) |
| 5252 | intel_dp->DP = I915_READ(intel_dp->output_reg); |
Ville Syrjälä | 49e6bc5 | 2014-10-28 16:15:52 +0200 | [diff] [blame] | 5253 | |
Imre Deak | dd75f6d | 2016-11-21 21:15:05 +0200 | [diff] [blame] | 5254 | if (lspcon->active) |
Shashank Sharma | 910530c | 2016-10-14 19:56:52 +0530 | [diff] [blame] | 5255 | lspcon_resume(lspcon); |
| 5256 | |
Manasi Navare | d7e8ef0 | 2017-02-07 16:54:11 -0800 | [diff] [blame] | 5257 | intel_dp->reset_link_params = true; |
| 5258 | |
Ville Syrjälä | 49e6bc5 | 2014-10-28 16:15:52 +0200 | [diff] [blame] | 5259 | pps_lock(intel_dp); |
| 5260 | |
Ville Syrjälä | 9f2bdb0 | 2016-12-14 20:00:23 +0200 | [diff] [blame] | 5261 | if (IS_VALLEYVIEW(dev_priv) || IS_CHERRYVIEW(dev_priv)) |
| 5262 | intel_dp->active_pipe = vlv_active_pipe(intel_dp); |
| 5263 | |
Jani Nikula | 1853a9d | 2017-08-18 12:30:20 +0300 | [diff] [blame] | 5264 | if (intel_dp_is_edp(intel_dp)) { |
Ville Syrjälä | 9f2bdb0 | 2016-12-14 20:00:23 +0200 | [diff] [blame] | 5265 | /* Reinit the power sequencer, in case BIOS did something with it. */ |
Ville Syrjälä | 46bd838 | 2017-10-31 22:51:22 +0200 | [diff] [blame] | 5266 | intel_dp_pps_init(intel_dp); |
Ville Syrjälä | 9f2bdb0 | 2016-12-14 20:00:23 +0200 | [diff] [blame] | 5267 | intel_edp_panel_vdd_sanitize(intel_dp); |
| 5268 | } |
Ville Syrjälä | 49e6bc5 | 2014-10-28 16:15:52 +0200 | [diff] [blame] | 5269 | |
| 5270 | pps_unlock(intel_dp); |
Imre Deak | 6d93c0c | 2014-07-31 14:03:36 +0300 | [diff] [blame] | 5271 | } |
| 5272 | |
Keith Packard | a4fc5ed | 2009-04-07 16:16:42 -0700 | [diff] [blame] | 5273 | static const struct drm_connector_funcs intel_dp_connector_funcs = { |
Chris Wilson | beb6060 | 2014-09-02 20:04:00 +0100 | [diff] [blame] | 5274 | .force = intel_dp_force, |
Keith Packard | a4fc5ed | 2009-04-07 16:16:42 -0700 | [diff] [blame] | 5275 | .fill_modes = drm_helper_probe_single_connector_modes, |
Maarten Lankhorst | 8f647a0 | 2017-05-01 15:38:01 +0200 | [diff] [blame] | 5276 | .atomic_get_property = intel_digital_connector_atomic_get_property, |
| 5277 | .atomic_set_property = intel_digital_connector_atomic_set_property, |
Chris Wilson | 7a418e3 | 2016-06-24 14:00:14 +0100 | [diff] [blame] | 5278 | .late_register = intel_dp_connector_register, |
Chris Wilson | c191eca | 2016-06-17 11:40:33 +0100 | [diff] [blame] | 5279 | .early_unregister = intel_dp_connector_unregister, |
Paulo Zanoni | 73845ad | 2013-06-12 17:27:30 -0300 | [diff] [blame] | 5280 | .destroy = intel_dp_connector_destroy, |
Matt Roper | c6f95f2 | 2015-01-22 16:50:32 -0800 | [diff] [blame] | 5281 | .atomic_destroy_state = drm_atomic_helper_connector_destroy_state, |
Maarten Lankhorst | 8f647a0 | 2017-05-01 15:38:01 +0200 | [diff] [blame] | 5282 | .atomic_duplicate_state = intel_digital_connector_duplicate_state, |
Keith Packard | a4fc5ed | 2009-04-07 16:16:42 -0700 | [diff] [blame] | 5283 | }; |
| 5284 | |
| 5285 | static const struct drm_connector_helper_funcs intel_dp_connector_helper_funcs = { |
Maarten Lankhorst | 6c5ed5a | 2017-04-06 20:55:20 +0200 | [diff] [blame] | 5286 | .detect_ctx = intel_dp_detect, |
Keith Packard | a4fc5ed | 2009-04-07 16:16:42 -0700 | [diff] [blame] | 5287 | .get_modes = intel_dp_get_modes, |
| 5288 | .mode_valid = intel_dp_mode_valid, |
Maarten Lankhorst | 8f647a0 | 2017-05-01 15:38:01 +0200 | [diff] [blame] | 5289 | .atomic_check = intel_digital_connector_atomic_check, |
Keith Packard | a4fc5ed | 2009-04-07 16:16:42 -0700 | [diff] [blame] | 5290 | }; |
| 5291 | |
Keith Packard | a4fc5ed | 2009-04-07 16:16:42 -0700 | [diff] [blame] | 5292 | static const struct drm_encoder_funcs intel_dp_enc_funcs = { |
Imre Deak | 6d93c0c | 2014-07-31 14:03:36 +0300 | [diff] [blame] | 5293 | .reset = intel_dp_encoder_reset, |
Daniel Vetter | 24d0592 | 2010-08-20 18:08:28 +0200 | [diff] [blame] | 5294 | .destroy = intel_dp_encoder_destroy, |
Keith Packard | a4fc5ed | 2009-04-07 16:16:42 -0700 | [diff] [blame] | 5295 | }; |
| 5296 | |
Daniel Vetter | b2c5c18 | 2015-01-23 06:00:31 +0100 | [diff] [blame] | 5297 | enum irqreturn |
Dave Airlie | 13cf550 | 2014-06-18 11:29:35 +1000 | [diff] [blame] | 5298 | intel_dp_hpd_pulse(struct intel_digital_port *intel_dig_port, bool long_hpd) |
| 5299 | { |
| 5300 | struct intel_dp *intel_dp = &intel_dig_port->dp; |
Ville Syrjälä | 2f77347 | 2017-11-09 17:27:58 +0200 | [diff] [blame] | 5301 | struct drm_i915_private *dev_priv = to_i915(intel_dp_to_dev(intel_dp)); |
Daniel Vetter | b2c5c18 | 2015-01-23 06:00:31 +0100 | [diff] [blame] | 5302 | enum irqreturn ret = IRQ_NONE; |
Imre Deak | 1c767b3 | 2014-08-18 14:42:42 +0300 | [diff] [blame] | 5303 | |
Ville Syrjälä | 7a7f84c | 2014-10-16 20:46:10 +0300 | [diff] [blame] | 5304 | if (long_hpd && intel_dig_port->base.type == INTEL_OUTPUT_EDP) { |
| 5305 | /* |
| 5306 | * vdd off can generate a long pulse on eDP which |
| 5307 | * would require vdd on to handle it, and thus we |
| 5308 | * would end up in an endless cycle of |
| 5309 | * "vdd off -> long hpd -> vdd on -> detect -> vdd off -> ..." |
| 5310 | */ |
| 5311 | DRM_DEBUG_KMS("ignoring long hpd on eDP port %c\n", |
Ville Syrjälä | 8f4f279 | 2017-11-09 17:24:34 +0200 | [diff] [blame] | 5312 | port_name(intel_dig_port->base.port)); |
Ville Syrjälä | a8b3d52 | 2015-02-10 14:11:46 +0200 | [diff] [blame] | 5313 | return IRQ_HANDLED; |
Ville Syrjälä | 7a7f84c | 2014-10-16 20:46:10 +0300 | [diff] [blame] | 5314 | } |
| 5315 | |
Ville Syrjälä | 26fbb77 | 2014-08-11 18:37:37 +0300 | [diff] [blame] | 5316 | DRM_DEBUG_KMS("got hpd irq on port %c - %s\n", |
Ville Syrjälä | 8f4f279 | 2017-11-09 17:24:34 +0200 | [diff] [blame] | 5317 | port_name(intel_dig_port->base.port), |
Dave Airlie | 0e32b39 | 2014-05-02 14:02:48 +1000 | [diff] [blame] | 5318 | long_hpd ? "long" : "short"); |
Dave Airlie | 13cf550 | 2014-06-18 11:29:35 +1000 | [diff] [blame] | 5319 | |
Ville Syrjälä | 27d4efc | 2016-10-03 10:55:15 +0300 | [diff] [blame] | 5320 | if (long_hpd) { |
Manasi Navare | d7e8ef0 | 2017-02-07 16:54:11 -0800 | [diff] [blame] | 5321 | intel_dp->reset_link_params = true; |
Ville Syrjälä | 27d4efc | 2016-10-03 10:55:15 +0300 | [diff] [blame] | 5322 | intel_dp->detect_done = false; |
| 5323 | return IRQ_NONE; |
| 5324 | } |
| 5325 | |
Ander Conselvan de Oliveira | 5432fca | 2017-02-22 08:34:26 +0200 | [diff] [blame] | 5326 | intel_display_power_get(dev_priv, intel_dp->aux_power_domain); |
Imre Deak | 1c767b3 | 2014-08-18 14:42:42 +0300 | [diff] [blame] | 5327 | |
Ville Syrjälä | 27d4efc | 2016-10-03 10:55:15 +0300 | [diff] [blame] | 5328 | if (intel_dp->is_mst) { |
| 5329 | if (intel_dp_check_mst_status(intel_dp) == -EINVAL) { |
| 5330 | /* |
| 5331 | * If we were in MST mode, and device is not |
| 5332 | * there, get out of MST mode |
| 5333 | */ |
| 5334 | DRM_DEBUG_KMS("MST device may have disappeared %d vs %d\n", |
| 5335 | intel_dp->is_mst, intel_dp->mst_mgr.mst_state); |
| 5336 | intel_dp->is_mst = false; |
| 5337 | drm_dp_mst_topology_mgr_set_mst(&intel_dp->mst_mgr, |
| 5338 | intel_dp->is_mst); |
| 5339 | intel_dp->detect_done = false; |
| 5340 | goto put_power; |
Dave Airlie | 0e32b39 | 2014-05-02 14:02:48 +1000 | [diff] [blame] | 5341 | } |
Ville Syrjälä | 27d4efc | 2016-10-03 10:55:15 +0300 | [diff] [blame] | 5342 | } |
Dave Airlie | 0e32b39 | 2014-05-02 14:02:48 +1000 | [diff] [blame] | 5343 | |
Ville Syrjälä | 27d4efc | 2016-10-03 10:55:15 +0300 | [diff] [blame] | 5344 | if (!intel_dp->is_mst) { |
Daniel Vetter | 42e5e65 | 2017-11-13 17:01:40 +0100 | [diff] [blame] | 5345 | struct drm_modeset_acquire_ctx ctx; |
| 5346 | struct drm_connector *connector = &intel_dp->attached_connector->base; |
| 5347 | struct drm_crtc *crtc; |
| 5348 | int iret; |
| 5349 | bool handled = false; |
| 5350 | |
| 5351 | drm_modeset_acquire_init(&ctx, 0); |
| 5352 | retry: |
| 5353 | iret = drm_modeset_lock(&dev_priv->drm.mode_config.connection_mutex, &ctx); |
| 5354 | if (iret) |
| 5355 | goto err; |
| 5356 | |
| 5357 | crtc = connector->state->crtc; |
| 5358 | if (crtc) { |
| 5359 | iret = drm_modeset_lock(&crtc->mutex, &ctx); |
| 5360 | if (iret) |
| 5361 | goto err; |
| 5362 | } |
| 5363 | |
| 5364 | handled = intel_dp_short_pulse(intel_dp); |
| 5365 | |
| 5366 | err: |
| 5367 | if (iret == -EDEADLK) { |
| 5368 | drm_modeset_backoff(&ctx); |
| 5369 | goto retry; |
| 5370 | } |
| 5371 | |
| 5372 | drm_modeset_drop_locks(&ctx); |
| 5373 | drm_modeset_acquire_fini(&ctx); |
| 5374 | WARN(iret, "Acquiring modeset locks failed with %i\n", iret); |
| 5375 | |
Sean Paul | 20f24d7 | 2018-01-08 14:55:43 -0500 | [diff] [blame] | 5376 | /* Short pulse can signify loss of hdcp authentication */ |
| 5377 | intel_hdcp_check_link(intel_dp->attached_connector); |
| 5378 | |
Daniel Vetter | 42e5e65 | 2017-11-13 17:01:40 +0100 | [diff] [blame] | 5379 | if (!handled) { |
Ville Syrjälä | 27d4efc | 2016-10-03 10:55:15 +0300 | [diff] [blame] | 5380 | intel_dp->detect_done = false; |
| 5381 | goto put_power; |
Shubhangi Shrivastava | 39ff747 | 2016-03-30 18:05:26 +0530 | [diff] [blame] | 5382 | } |
Dave Airlie | 0e32b39 | 2014-05-02 14:02:48 +1000 | [diff] [blame] | 5383 | } |
Daniel Vetter | b2c5c18 | 2015-01-23 06:00:31 +0100 | [diff] [blame] | 5384 | |
| 5385 | ret = IRQ_HANDLED; |
| 5386 | |
Imre Deak | 1c767b3 | 2014-08-18 14:42:42 +0300 | [diff] [blame] | 5387 | put_power: |
Ander Conselvan de Oliveira | 5432fca | 2017-02-22 08:34:26 +0200 | [diff] [blame] | 5388 | intel_display_power_put(dev_priv, intel_dp->aux_power_domain); |
Imre Deak | 1c767b3 | 2014-08-18 14:42:42 +0300 | [diff] [blame] | 5389 | |
| 5390 | return ret; |
Dave Airlie | 13cf550 | 2014-06-18 11:29:35 +1000 | [diff] [blame] | 5391 | } |
| 5392 | |
Rodrigo Vivi | 477ec32 | 2015-08-06 15:51:39 +0800 | [diff] [blame] | 5393 | /* check the VBT to see whether the eDP is on another port */ |
Jani Nikula | 7b91bf7 | 2017-08-18 12:30:19 +0300 | [diff] [blame] | 5394 | bool intel_dp_is_port_edp(struct drm_i915_private *dev_priv, enum port port) |
Zhao Yakui | 36e83a1 | 2010-06-12 14:32:21 +0800 | [diff] [blame] | 5395 | { |
Ville Syrjälä | 53ce81a | 2015-09-11 21:04:38 +0300 | [diff] [blame] | 5396 | /* |
| 5397 | * eDP not supported on g4x. so bail out early just |
| 5398 | * for a bit extra safety in case the VBT is bonkers. |
| 5399 | */ |
Tvrtko Ursulin | dd11bc1 | 2016-11-16 08:55:41 +0000 | [diff] [blame] | 5400 | if (INTEL_GEN(dev_priv) < 5) |
Ville Syrjälä | 53ce81a | 2015-09-11 21:04:38 +0300 | [diff] [blame] | 5401 | return false; |
| 5402 | |
Imre Deak | a98d9c1 | 2016-12-21 12:17:24 +0200 | [diff] [blame] | 5403 | if (INTEL_GEN(dev_priv) < 9 && port == PORT_A) |
Ville Syrjälä | 3b32a35 | 2013-11-01 18:22:41 +0200 | [diff] [blame] | 5404 | return true; |
| 5405 | |
Jani Nikula | 951d9ef | 2016-03-16 12:43:31 +0200 | [diff] [blame] | 5406 | return intel_bios_is_port_edp(dev_priv, port); |
Zhao Yakui | 36e83a1 | 2010-06-12 14:32:21 +0800 | [diff] [blame] | 5407 | } |
| 5408 | |
Maarten Lankhorst | 200819a | 2017-04-10 12:51:10 +0200 | [diff] [blame] | 5409 | static void |
Chris Wilson | f684960 | 2010-09-19 09:29:33 +0100 | [diff] [blame] | 5410 | intel_dp_add_properties(struct intel_dp *intel_dp, struct drm_connector *connector) |
| 5411 | { |
Maarten Lankhorst | 8b45330 | 2017-05-01 15:37:56 +0200 | [diff] [blame] | 5412 | struct drm_i915_private *dev_priv = to_i915(connector->dev); |
Ville Syrjälä | 68ec073 | 2017-11-29 18:43:02 +0200 | [diff] [blame] | 5413 | enum port port = dp_to_dig_port(intel_dp)->base.port; |
Maarten Lankhorst | 8b45330 | 2017-05-01 15:37:56 +0200 | [diff] [blame] | 5414 | |
Ville Syrjälä | 68ec073 | 2017-11-29 18:43:02 +0200 | [diff] [blame] | 5415 | if (!IS_G4X(dev_priv) && port != PORT_A) |
| 5416 | intel_attach_force_audio_property(connector); |
| 5417 | |
Chris Wilson | e953fd7 | 2011-02-21 22:23:52 +0000 | [diff] [blame] | 5418 | intel_attach_broadcast_rgb_property(connector); |
Yuly Novikov | 53b4183 | 2012-10-26 12:04:00 +0300 | [diff] [blame] | 5419 | |
Jani Nikula | 1853a9d | 2017-08-18 12:30:20 +0300 | [diff] [blame] | 5420 | if (intel_dp_is_edp(intel_dp)) { |
Maarten Lankhorst | 8b45330 | 2017-05-01 15:37:56 +0200 | [diff] [blame] | 5421 | u32 allowed_scalers; |
| 5422 | |
| 5423 | allowed_scalers = BIT(DRM_MODE_SCALE_ASPECT) | BIT(DRM_MODE_SCALE_FULLSCREEN); |
| 5424 | if (!HAS_GMCH_DISPLAY(dev_priv)) |
| 5425 | allowed_scalers |= BIT(DRM_MODE_SCALE_CENTER); |
| 5426 | |
| 5427 | drm_connector_attach_scaling_mode_property(connector, allowed_scalers); |
| 5428 | |
Maarten Lankhorst | eead06d | 2017-05-01 15:37:55 +0200 | [diff] [blame] | 5429 | connector->state->scaling_mode = DRM_MODE_SCALE_ASPECT; |
Maarten Lankhorst | 8b45330 | 2017-05-01 15:37:56 +0200 | [diff] [blame] | 5430 | |
Yuly Novikov | 53b4183 | 2012-10-26 12:04:00 +0300 | [diff] [blame] | 5431 | } |
Chris Wilson | f684960 | 2010-09-19 09:29:33 +0100 | [diff] [blame] | 5432 | } |
| 5433 | |
Imre Deak | dada1a9 | 2014-01-29 13:25:41 +0200 | [diff] [blame] | 5434 | static void intel_dp_init_panel_power_timestamps(struct intel_dp *intel_dp) |
| 5435 | { |
Abhay Kumar | d28d473 | 2016-01-22 17:39:04 -0800 | [diff] [blame] | 5436 | intel_dp->panel_power_off_time = ktime_get_boottime(); |
Imre Deak | dada1a9 | 2014-01-29 13:25:41 +0200 | [diff] [blame] | 5437 | intel_dp->last_power_on = jiffies; |
| 5438 | intel_dp->last_backlight_off = jiffies; |
| 5439 | } |
| 5440 | |
Daniel Vetter | 67a5456 | 2012-10-20 20:57:45 +0200 | [diff] [blame] | 5441 | static void |
Ville Syrjälä | 46bd838 | 2017-10-31 22:51:22 +0200 | [diff] [blame] | 5442 | intel_pps_readout_hw_state(struct intel_dp *intel_dp, struct edp_power_seq *seq) |
Daniel Vetter | 67a5456 | 2012-10-20 20:57:45 +0200 | [diff] [blame] | 5443 | { |
Ville Syrjälä | 46bd838 | 2017-10-31 22:51:22 +0200 | [diff] [blame] | 5444 | struct drm_i915_private *dev_priv = to_i915(intel_dp_to_dev(intel_dp)); |
Vandana Kannan | b0a08be | 2015-06-18 11:00:55 +0530 | [diff] [blame] | 5445 | u32 pp_on, pp_off, pp_div = 0, pp_ctl = 0; |
Imre Deak | 8e8232d | 2016-06-16 16:37:21 +0300 | [diff] [blame] | 5446 | struct pps_registers regs; |
Jesse Barnes | 453c542 | 2013-03-28 09:55:41 -0700 | [diff] [blame] | 5447 | |
Ville Syrjälä | 46bd838 | 2017-10-31 22:51:22 +0200 | [diff] [blame] | 5448 | intel_pps_get_registers(intel_dp, ®s); |
Daniel Vetter | 67a5456 | 2012-10-20 20:57:45 +0200 | [diff] [blame] | 5449 | |
| 5450 | /* Workaround: Need to write PP_CONTROL with the unlock key as |
| 5451 | * the very first thing. */ |
Vandana Kannan | b0a08be | 2015-06-18 11:00:55 +0530 | [diff] [blame] | 5452 | pp_ctl = ironlake_get_pp_control(intel_dp); |
Daniel Vetter | 67a5456 | 2012-10-20 20:57:45 +0200 | [diff] [blame] | 5453 | |
Imre Deak | 8e8232d | 2016-06-16 16:37:21 +0300 | [diff] [blame] | 5454 | pp_on = I915_READ(regs.pp_on); |
| 5455 | pp_off = I915_READ(regs.pp_off); |
Rodrigo Vivi | 938361e | 2017-06-02 13:06:44 -0700 | [diff] [blame] | 5456 | if (!IS_GEN9_LP(dev_priv) && !HAS_PCH_CNP(dev_priv)) { |
Imre Deak | 8e8232d | 2016-06-16 16:37:21 +0300 | [diff] [blame] | 5457 | I915_WRITE(regs.pp_ctrl, pp_ctl); |
| 5458 | pp_div = I915_READ(regs.pp_div); |
Vandana Kannan | b0a08be | 2015-06-18 11:00:55 +0530 | [diff] [blame] | 5459 | } |
Daniel Vetter | 67a5456 | 2012-10-20 20:57:45 +0200 | [diff] [blame] | 5460 | |
| 5461 | /* Pull timing values out of registers */ |
Imre Deak | 5464861 | 2016-06-16 16:37:22 +0300 | [diff] [blame] | 5462 | seq->t1_t3 = (pp_on & PANEL_POWER_UP_DELAY_MASK) >> |
| 5463 | PANEL_POWER_UP_DELAY_SHIFT; |
Daniel Vetter | 67a5456 | 2012-10-20 20:57:45 +0200 | [diff] [blame] | 5464 | |
Imre Deak | 5464861 | 2016-06-16 16:37:22 +0300 | [diff] [blame] | 5465 | seq->t8 = (pp_on & PANEL_LIGHT_ON_DELAY_MASK) >> |
| 5466 | PANEL_LIGHT_ON_DELAY_SHIFT; |
Daniel Vetter | 67a5456 | 2012-10-20 20:57:45 +0200 | [diff] [blame] | 5467 | |
Imre Deak | 5464861 | 2016-06-16 16:37:22 +0300 | [diff] [blame] | 5468 | seq->t9 = (pp_off & PANEL_LIGHT_OFF_DELAY_MASK) >> |
| 5469 | PANEL_LIGHT_OFF_DELAY_SHIFT; |
Daniel Vetter | 67a5456 | 2012-10-20 20:57:45 +0200 | [diff] [blame] | 5470 | |
Imre Deak | 5464861 | 2016-06-16 16:37:22 +0300 | [diff] [blame] | 5471 | seq->t10 = (pp_off & PANEL_POWER_DOWN_DELAY_MASK) >> |
| 5472 | PANEL_POWER_DOWN_DELAY_SHIFT; |
Daniel Vetter | 67a5456 | 2012-10-20 20:57:45 +0200 | [diff] [blame] | 5473 | |
Rodrigo Vivi | 938361e | 2017-06-02 13:06:44 -0700 | [diff] [blame] | 5474 | if (IS_GEN9_LP(dev_priv) || HAS_PCH_CNP(dev_priv)) { |
Manasi Navare | 12c8ca9 | 2017-06-26 12:21:45 -0700 | [diff] [blame] | 5475 | seq->t11_t12 = ((pp_ctl & BXT_POWER_CYCLE_DELAY_MASK) >> |
| 5476 | BXT_POWER_CYCLE_DELAY_SHIFT) * 1000; |
Vandana Kannan | b0a08be | 2015-06-18 11:00:55 +0530 | [diff] [blame] | 5477 | } else { |
Imre Deak | 5464861 | 2016-06-16 16:37:22 +0300 | [diff] [blame] | 5478 | seq->t11_t12 = ((pp_div & PANEL_POWER_CYCLE_DELAY_MASK) >> |
Daniel Vetter | 67a5456 | 2012-10-20 20:57:45 +0200 | [diff] [blame] | 5479 | PANEL_POWER_CYCLE_DELAY_SHIFT) * 1000; |
Vandana Kannan | b0a08be | 2015-06-18 11:00:55 +0530 | [diff] [blame] | 5480 | } |
Imre Deak | 5464861 | 2016-06-16 16:37:22 +0300 | [diff] [blame] | 5481 | } |
| 5482 | |
| 5483 | static void |
Imre Deak | de9c1b6 | 2016-06-16 20:01:46 +0300 | [diff] [blame] | 5484 | intel_pps_dump_state(const char *state_name, const struct edp_power_seq *seq) |
| 5485 | { |
| 5486 | DRM_DEBUG_KMS("%s t1_t3 %d t8 %d t9 %d t10 %d t11_t12 %d\n", |
| 5487 | state_name, |
| 5488 | seq->t1_t3, seq->t8, seq->t9, seq->t10, seq->t11_t12); |
| 5489 | } |
| 5490 | |
| 5491 | static void |
Ville Syrjälä | 46bd838 | 2017-10-31 22:51:22 +0200 | [diff] [blame] | 5492 | intel_pps_verify_state(struct intel_dp *intel_dp) |
Imre Deak | de9c1b6 | 2016-06-16 20:01:46 +0300 | [diff] [blame] | 5493 | { |
| 5494 | struct edp_power_seq hw; |
| 5495 | struct edp_power_seq *sw = &intel_dp->pps_delays; |
| 5496 | |
Ville Syrjälä | 46bd838 | 2017-10-31 22:51:22 +0200 | [diff] [blame] | 5497 | intel_pps_readout_hw_state(intel_dp, &hw); |
Imre Deak | de9c1b6 | 2016-06-16 20:01:46 +0300 | [diff] [blame] | 5498 | |
| 5499 | if (hw.t1_t3 != sw->t1_t3 || hw.t8 != sw->t8 || hw.t9 != sw->t9 || |
| 5500 | hw.t10 != sw->t10 || hw.t11_t12 != sw->t11_t12) { |
| 5501 | DRM_ERROR("PPS state mismatch\n"); |
| 5502 | intel_pps_dump_state("sw", sw); |
| 5503 | intel_pps_dump_state("hw", &hw); |
| 5504 | } |
| 5505 | } |
| 5506 | |
| 5507 | static void |
Ville Syrjälä | 46bd838 | 2017-10-31 22:51:22 +0200 | [diff] [blame] | 5508 | intel_dp_init_panel_power_sequencer(struct intel_dp *intel_dp) |
Imre Deak | 5464861 | 2016-06-16 16:37:22 +0300 | [diff] [blame] | 5509 | { |
Ville Syrjälä | 46bd838 | 2017-10-31 22:51:22 +0200 | [diff] [blame] | 5510 | struct drm_i915_private *dev_priv = to_i915(intel_dp_to_dev(intel_dp)); |
Imre Deak | 5464861 | 2016-06-16 16:37:22 +0300 | [diff] [blame] | 5511 | struct edp_power_seq cur, vbt, spec, |
| 5512 | *final = &intel_dp->pps_delays; |
| 5513 | |
| 5514 | lockdep_assert_held(&dev_priv->pps_mutex); |
| 5515 | |
| 5516 | /* already initialized? */ |
| 5517 | if (final->t11_t12 != 0) |
| 5518 | return; |
| 5519 | |
Ville Syrjälä | 46bd838 | 2017-10-31 22:51:22 +0200 | [diff] [blame] | 5520 | intel_pps_readout_hw_state(intel_dp, &cur); |
Daniel Vetter | 67a5456 | 2012-10-20 20:57:45 +0200 | [diff] [blame] | 5521 | |
Imre Deak | de9c1b6 | 2016-06-16 20:01:46 +0300 | [diff] [blame] | 5522 | intel_pps_dump_state("cur", &cur); |
Daniel Vetter | 67a5456 | 2012-10-20 20:57:45 +0200 | [diff] [blame] | 5523 | |
Jani Nikula | 6aa23e6 | 2016-03-24 17:50:20 +0200 | [diff] [blame] | 5524 | vbt = dev_priv->vbt.edp.pps; |
Manasi Navare | c99a259 | 2017-06-30 09:33:48 -0700 | [diff] [blame] | 5525 | /* On Toshiba Satellite P50-C-18C system the VBT T12 delay |
| 5526 | * of 500ms appears to be too short. Ocassionally the panel |
| 5527 | * just fails to power back on. Increasing the delay to 800ms |
| 5528 | * seems sufficient to avoid this problem. |
| 5529 | */ |
| 5530 | if (dev_priv->quirks & QUIRK_INCREASE_T12_DELAY) { |
Manasi Navare | 7313f5a | 2017-10-03 16:37:25 -0700 | [diff] [blame] | 5531 | vbt.t11_t12 = max_t(u16, vbt.t11_t12, 1300 * 10); |
Manasi Navare | c99a259 | 2017-06-30 09:33:48 -0700 | [diff] [blame] | 5532 | DRM_DEBUG_KMS("Increasing T12 panel delay as per the quirk to %d\n", |
| 5533 | vbt.t11_t12); |
| 5534 | } |
Manasi Navare | 770a17a | 2017-06-26 12:21:44 -0700 | [diff] [blame] | 5535 | /* T11_T12 delay is special and actually in units of 100ms, but zero |
| 5536 | * based in the hw (so we need to add 100 ms). But the sw vbt |
| 5537 | * table multiplies it with 1000 to make it in units of 100usec, |
| 5538 | * too. */ |
| 5539 | vbt.t11_t12 += 100 * 10; |
Daniel Vetter | 67a5456 | 2012-10-20 20:57:45 +0200 | [diff] [blame] | 5540 | |
| 5541 | /* Upper limits from eDP 1.3 spec. Note that we use the clunky units of |
| 5542 | * our hw here, which are all in 100usec. */ |
| 5543 | spec.t1_t3 = 210 * 10; |
| 5544 | spec.t8 = 50 * 10; /* no limit for t8, use t7 instead */ |
| 5545 | spec.t9 = 50 * 10; /* no limit for t9, make it symmetric with t8 */ |
| 5546 | spec.t10 = 500 * 10; |
| 5547 | /* This one is special and actually in units of 100ms, but zero |
| 5548 | * based in the hw (so we need to add 100 ms). But the sw vbt |
| 5549 | * table multiplies it with 1000 to make it in units of 100usec, |
| 5550 | * too. */ |
| 5551 | spec.t11_t12 = (510 + 100) * 10; |
| 5552 | |
Imre Deak | de9c1b6 | 2016-06-16 20:01:46 +0300 | [diff] [blame] | 5553 | intel_pps_dump_state("vbt", &vbt); |
Daniel Vetter | 67a5456 | 2012-10-20 20:57:45 +0200 | [diff] [blame] | 5554 | |
| 5555 | /* Use the max of the register settings and vbt. If both are |
| 5556 | * unset, fall back to the spec limits. */ |
Ville Syrjälä | 36b5f42 | 2014-10-16 21:27:30 +0300 | [diff] [blame] | 5557 | #define assign_final(field) final->field = (max(cur.field, vbt.field) == 0 ? \ |
Daniel Vetter | 67a5456 | 2012-10-20 20:57:45 +0200 | [diff] [blame] | 5558 | spec.field : \ |
| 5559 | max(cur.field, vbt.field)) |
| 5560 | assign_final(t1_t3); |
| 5561 | assign_final(t8); |
| 5562 | assign_final(t9); |
| 5563 | assign_final(t10); |
| 5564 | assign_final(t11_t12); |
| 5565 | #undef assign_final |
| 5566 | |
Ville Syrjälä | 36b5f42 | 2014-10-16 21:27:30 +0300 | [diff] [blame] | 5567 | #define get_delay(field) (DIV_ROUND_UP(final->field, 10)) |
Daniel Vetter | 67a5456 | 2012-10-20 20:57:45 +0200 | [diff] [blame] | 5568 | intel_dp->panel_power_up_delay = get_delay(t1_t3); |
| 5569 | intel_dp->backlight_on_delay = get_delay(t8); |
| 5570 | intel_dp->backlight_off_delay = get_delay(t9); |
| 5571 | intel_dp->panel_power_down_delay = get_delay(t10); |
| 5572 | intel_dp->panel_power_cycle_delay = get_delay(t11_t12); |
| 5573 | #undef get_delay |
| 5574 | |
Jani Nikula | f30d26e | 2013-01-16 10:53:40 +0200 | [diff] [blame] | 5575 | DRM_DEBUG_KMS("panel power up delay %d, power down delay %d, power cycle delay %d\n", |
| 5576 | intel_dp->panel_power_up_delay, intel_dp->panel_power_down_delay, |
| 5577 | intel_dp->panel_power_cycle_delay); |
| 5578 | |
| 5579 | DRM_DEBUG_KMS("backlight on delay %d, off delay %d\n", |
| 5580 | intel_dp->backlight_on_delay, intel_dp->backlight_off_delay); |
Imre Deak | de9c1b6 | 2016-06-16 20:01:46 +0300 | [diff] [blame] | 5581 | |
| 5582 | /* |
| 5583 | * We override the HW backlight delays to 1 because we do manual waits |
| 5584 | * on them. For T8, even BSpec recommends doing it. For T9, if we |
| 5585 | * don't do this, we'll end up waiting for the backlight off delay |
| 5586 | * twice: once when we do the manual sleep, and once when we disable |
| 5587 | * the panel and wait for the PP_STATUS bit to become zero. |
| 5588 | */ |
| 5589 | final->t8 = 1; |
| 5590 | final->t9 = 1; |
Imre Deak | 5643205 | 2017-11-29 19:51:37 +0200 | [diff] [blame] | 5591 | |
| 5592 | /* |
| 5593 | * HW has only a 100msec granularity for t11_t12 so round it up |
| 5594 | * accordingly. |
| 5595 | */ |
| 5596 | final->t11_t12 = roundup(final->t11_t12, 100 * 10); |
Jani Nikula | f30d26e | 2013-01-16 10:53:40 +0200 | [diff] [blame] | 5597 | } |
| 5598 | |
| 5599 | static void |
Ville Syrjälä | 46bd838 | 2017-10-31 22:51:22 +0200 | [diff] [blame] | 5600 | intel_dp_init_panel_power_sequencer_registers(struct intel_dp *intel_dp, |
Ville Syrjälä | 5d5ab2d | 2016-12-20 18:51:17 +0200 | [diff] [blame] | 5601 | bool force_disable_vdd) |
Jani Nikula | f30d26e | 2013-01-16 10:53:40 +0200 | [diff] [blame] | 5602 | { |
Ville Syrjälä | 46bd838 | 2017-10-31 22:51:22 +0200 | [diff] [blame] | 5603 | struct drm_i915_private *dev_priv = to_i915(intel_dp_to_dev(intel_dp)); |
Jesse Barnes | 453c542 | 2013-03-28 09:55:41 -0700 | [diff] [blame] | 5604 | u32 pp_on, pp_off, pp_div, port_sel = 0; |
Ville Syrjälä | e7dc33f | 2016-03-02 17:22:13 +0200 | [diff] [blame] | 5605 | int div = dev_priv->rawclk_freq / 1000; |
Imre Deak | 8e8232d | 2016-06-16 16:37:21 +0300 | [diff] [blame] | 5606 | struct pps_registers regs; |
Ville Syrjälä | 8f4f279 | 2017-11-09 17:24:34 +0200 | [diff] [blame] | 5607 | enum port port = dp_to_dig_port(intel_dp)->base.port; |
Ville Syrjälä | 36b5f42 | 2014-10-16 21:27:30 +0300 | [diff] [blame] | 5608 | const struct edp_power_seq *seq = &intel_dp->pps_delays; |
Jesse Barnes | 453c542 | 2013-03-28 09:55:41 -0700 | [diff] [blame] | 5609 | |
Ville Syrjälä | e39b999 | 2014-09-04 14:53:14 +0300 | [diff] [blame] | 5610 | lockdep_assert_held(&dev_priv->pps_mutex); |
Jesse Barnes | 453c542 | 2013-03-28 09:55:41 -0700 | [diff] [blame] | 5611 | |
Ville Syrjälä | 46bd838 | 2017-10-31 22:51:22 +0200 | [diff] [blame] | 5612 | intel_pps_get_registers(intel_dp, ®s); |
Jesse Barnes | 453c542 | 2013-03-28 09:55:41 -0700 | [diff] [blame] | 5613 | |
Ville Syrjälä | 5d5ab2d | 2016-12-20 18:51:17 +0200 | [diff] [blame] | 5614 | /* |
| 5615 | * On some VLV machines the BIOS can leave the VDD |
| 5616 | * enabled even on power seqeuencers which aren't |
| 5617 | * hooked up to any port. This would mess up the |
| 5618 | * power domain tracking the first time we pick |
| 5619 | * one of these power sequencers for use since |
| 5620 | * edp_panel_vdd_on() would notice that the VDD was |
| 5621 | * already on and therefore wouldn't grab the power |
| 5622 | * domain reference. Disable VDD first to avoid this. |
| 5623 | * This also avoids spuriously turning the VDD on as |
| 5624 | * soon as the new power seqeuencer gets initialized. |
| 5625 | */ |
| 5626 | if (force_disable_vdd) { |
| 5627 | u32 pp = ironlake_get_pp_control(intel_dp); |
| 5628 | |
| 5629 | WARN(pp & PANEL_POWER_ON, "Panel power already on\n"); |
| 5630 | |
| 5631 | if (pp & EDP_FORCE_VDD) |
| 5632 | DRM_DEBUG_KMS("VDD already on, disabling first\n"); |
| 5633 | |
| 5634 | pp &= ~EDP_FORCE_VDD; |
| 5635 | |
| 5636 | I915_WRITE(regs.pp_ctrl, pp); |
| 5637 | } |
| 5638 | |
Jani Nikula | f30d26e | 2013-01-16 10:53:40 +0200 | [diff] [blame] | 5639 | pp_on = (seq->t1_t3 << PANEL_POWER_UP_DELAY_SHIFT) | |
Imre Deak | de9c1b6 | 2016-06-16 20:01:46 +0300 | [diff] [blame] | 5640 | (seq->t8 << PANEL_LIGHT_ON_DELAY_SHIFT); |
| 5641 | pp_off = (seq->t9 << PANEL_LIGHT_OFF_DELAY_SHIFT) | |
Jani Nikula | f30d26e | 2013-01-16 10:53:40 +0200 | [diff] [blame] | 5642 | (seq->t10 << PANEL_POWER_DOWN_DELAY_SHIFT); |
Daniel Vetter | 67a5456 | 2012-10-20 20:57:45 +0200 | [diff] [blame] | 5643 | /* Compute the divisor for the pp clock, simply match the Bspec |
| 5644 | * formula. */ |
Rodrigo Vivi | 938361e | 2017-06-02 13:06:44 -0700 | [diff] [blame] | 5645 | if (IS_GEN9_LP(dev_priv) || HAS_PCH_CNP(dev_priv)) { |
Imre Deak | 8e8232d | 2016-06-16 16:37:21 +0300 | [diff] [blame] | 5646 | pp_div = I915_READ(regs.pp_ctrl); |
Vandana Kannan | b0a08be | 2015-06-18 11:00:55 +0530 | [diff] [blame] | 5647 | pp_div &= ~BXT_POWER_CYCLE_DELAY_MASK; |
Manasi Navare | 12c8ca9 | 2017-06-26 12:21:45 -0700 | [diff] [blame] | 5648 | pp_div |= (DIV_ROUND_UP(seq->t11_t12, 1000) |
Vandana Kannan | b0a08be | 2015-06-18 11:00:55 +0530 | [diff] [blame] | 5649 | << BXT_POWER_CYCLE_DELAY_SHIFT); |
| 5650 | } else { |
| 5651 | pp_div = ((100 * div)/2 - 1) << PP_REFERENCE_DIVIDER_SHIFT; |
| 5652 | pp_div |= (DIV_ROUND_UP(seq->t11_t12, 1000) |
| 5653 | << PANEL_POWER_CYCLE_DELAY_SHIFT); |
| 5654 | } |
Daniel Vetter | 67a5456 | 2012-10-20 20:57:45 +0200 | [diff] [blame] | 5655 | |
| 5656 | /* Haswell doesn't have any port selection bits for the panel |
| 5657 | * power sequencer any more. */ |
Tvrtko Ursulin | 920a14b | 2016-10-14 10:13:44 +0100 | [diff] [blame] | 5658 | if (IS_VALLEYVIEW(dev_priv) || IS_CHERRYVIEW(dev_priv)) { |
Ville Syrjälä | ad933b5 | 2014-08-18 22:15:56 +0300 | [diff] [blame] | 5659 | port_sel = PANEL_PORT_SELECT_VLV(port); |
Tvrtko Ursulin | 6e26695 | 2016-10-13 11:02:53 +0100 | [diff] [blame] | 5660 | } else if (HAS_PCH_IBX(dev_priv) || HAS_PCH_CPT(dev_priv)) { |
Ville Syrjälä | ad933b5 | 2014-08-18 22:15:56 +0300 | [diff] [blame] | 5661 | if (port == PORT_A) |
Jani Nikula | a24c144 | 2013-09-05 16:44:46 +0300 | [diff] [blame] | 5662 | port_sel = PANEL_PORT_SELECT_DPA; |
Daniel Vetter | 67a5456 | 2012-10-20 20:57:45 +0200 | [diff] [blame] | 5663 | else |
Jani Nikula | a24c144 | 2013-09-05 16:44:46 +0300 | [diff] [blame] | 5664 | port_sel = PANEL_PORT_SELECT_DPD; |
Daniel Vetter | 67a5456 | 2012-10-20 20:57:45 +0200 | [diff] [blame] | 5665 | } |
| 5666 | |
Jesse Barnes | 453c542 | 2013-03-28 09:55:41 -0700 | [diff] [blame] | 5667 | pp_on |= port_sel; |
| 5668 | |
Imre Deak | 8e8232d | 2016-06-16 16:37:21 +0300 | [diff] [blame] | 5669 | I915_WRITE(regs.pp_on, pp_on); |
| 5670 | I915_WRITE(regs.pp_off, pp_off); |
Rodrigo Vivi | 938361e | 2017-06-02 13:06:44 -0700 | [diff] [blame] | 5671 | if (IS_GEN9_LP(dev_priv) || HAS_PCH_CNP(dev_priv)) |
Imre Deak | 8e8232d | 2016-06-16 16:37:21 +0300 | [diff] [blame] | 5672 | I915_WRITE(regs.pp_ctrl, pp_div); |
Vandana Kannan | b0a08be | 2015-06-18 11:00:55 +0530 | [diff] [blame] | 5673 | else |
Imre Deak | 8e8232d | 2016-06-16 16:37:21 +0300 | [diff] [blame] | 5674 | I915_WRITE(regs.pp_div, pp_div); |
Daniel Vetter | 67a5456 | 2012-10-20 20:57:45 +0200 | [diff] [blame] | 5675 | |
Daniel Vetter | 67a5456 | 2012-10-20 20:57:45 +0200 | [diff] [blame] | 5676 | DRM_DEBUG_KMS("panel power sequencer register settings: PP_ON %#x, PP_OFF %#x, PP_DIV %#x\n", |
Imre Deak | 8e8232d | 2016-06-16 16:37:21 +0300 | [diff] [blame] | 5677 | I915_READ(regs.pp_on), |
| 5678 | I915_READ(regs.pp_off), |
Rodrigo Vivi | 938361e | 2017-06-02 13:06:44 -0700 | [diff] [blame] | 5679 | (IS_GEN9_LP(dev_priv) || HAS_PCH_CNP(dev_priv)) ? |
Imre Deak | 8e8232d | 2016-06-16 16:37:21 +0300 | [diff] [blame] | 5680 | (I915_READ(regs.pp_ctrl) & BXT_POWER_CYCLE_DELAY_MASK) : |
| 5681 | I915_READ(regs.pp_div)); |
Zhenyu Wang | e3421a1 | 2010-04-08 09:43:27 +0800 | [diff] [blame] | 5682 | } |
| 5683 | |
Ville Syrjälä | 46bd838 | 2017-10-31 22:51:22 +0200 | [diff] [blame] | 5684 | static void intel_dp_pps_init(struct intel_dp *intel_dp) |
Imre Deak | 335f752 | 2016-08-10 14:07:32 +0300 | [diff] [blame] | 5685 | { |
Ville Syrjälä | 46bd838 | 2017-10-31 22:51:22 +0200 | [diff] [blame] | 5686 | struct drm_i915_private *dev_priv = to_i915(intel_dp_to_dev(intel_dp)); |
Tvrtko Ursulin | 920a14b | 2016-10-14 10:13:44 +0100 | [diff] [blame] | 5687 | |
| 5688 | if (IS_VALLEYVIEW(dev_priv) || IS_CHERRYVIEW(dev_priv)) { |
Imre Deak | 335f752 | 2016-08-10 14:07:32 +0300 | [diff] [blame] | 5689 | vlv_initial_power_sequencer_setup(intel_dp); |
| 5690 | } else { |
Ville Syrjälä | 46bd838 | 2017-10-31 22:51:22 +0200 | [diff] [blame] | 5691 | intel_dp_init_panel_power_sequencer(intel_dp); |
| 5692 | intel_dp_init_panel_power_sequencer_registers(intel_dp, false); |
Imre Deak | 335f752 | 2016-08-10 14:07:32 +0300 | [diff] [blame] | 5693 | } |
| 5694 | } |
| 5695 | |
Vandana Kannan | b33a281 | 2015-02-13 15:33:03 +0530 | [diff] [blame] | 5696 | /** |
| 5697 | * intel_dp_set_drrs_state - program registers for RR switch to take effect |
Maarten Lankhorst | 5423adf | 2016-08-31 11:01:36 +0200 | [diff] [blame] | 5698 | * @dev_priv: i915 device |
Maarten Lankhorst | e896402 | 2016-08-25 11:07:02 +0200 | [diff] [blame] | 5699 | * @crtc_state: a pointer to the active intel_crtc_state |
Vandana Kannan | b33a281 | 2015-02-13 15:33:03 +0530 | [diff] [blame] | 5700 | * @refresh_rate: RR to be programmed |
| 5701 | * |
| 5702 | * This function gets called when refresh rate (RR) has to be changed from |
| 5703 | * one frequency to another. Switches can be between high and low RR |
| 5704 | * supported by the panel or to any other RR based on media playback (in |
| 5705 | * this case, RR value needs to be passed from user space). |
| 5706 | * |
| 5707 | * The caller of this function needs to take a lock on dev_priv->drrs. |
| 5708 | */ |
Maarten Lankhorst | 85cb48a | 2016-08-09 17:04:13 +0200 | [diff] [blame] | 5709 | static void intel_dp_set_drrs_state(struct drm_i915_private *dev_priv, |
Ville Syrjälä | 5f88a9c | 2017-08-18 16:49:58 +0300 | [diff] [blame] | 5710 | const struct intel_crtc_state *crtc_state, |
Maarten Lankhorst | 85cb48a | 2016-08-09 17:04:13 +0200 | [diff] [blame] | 5711 | int refresh_rate) |
Pradeep Bhat | 439d7ac | 2014-04-05 12:13:28 +0530 | [diff] [blame] | 5712 | { |
Pradeep Bhat | 439d7ac | 2014-04-05 12:13:28 +0530 | [diff] [blame] | 5713 | struct intel_encoder *encoder; |
Vandana Kannan | 96178ee | 2015-01-10 02:25:56 +0530 | [diff] [blame] | 5714 | struct intel_digital_port *dig_port = NULL; |
| 5715 | struct intel_dp *intel_dp = dev_priv->drrs.dp; |
Maarten Lankhorst | 85cb48a | 2016-08-09 17:04:13 +0200 | [diff] [blame] | 5716 | struct intel_crtc *intel_crtc = to_intel_crtc(crtc_state->base.crtc); |
Vandana Kannan | 96178ee | 2015-01-10 02:25:56 +0530 | [diff] [blame] | 5717 | enum drrs_refresh_rate_type index = DRRS_HIGH_RR; |
Pradeep Bhat | 439d7ac | 2014-04-05 12:13:28 +0530 | [diff] [blame] | 5718 | |
| 5719 | if (refresh_rate <= 0) { |
| 5720 | DRM_DEBUG_KMS("Refresh rate should be positive non-zero.\n"); |
| 5721 | return; |
| 5722 | } |
| 5723 | |
Vandana Kannan | 96178ee | 2015-01-10 02:25:56 +0530 | [diff] [blame] | 5724 | if (intel_dp == NULL) { |
| 5725 | DRM_DEBUG_KMS("DRRS not supported.\n"); |
Pradeep Bhat | 439d7ac | 2014-04-05 12:13:28 +0530 | [diff] [blame] | 5726 | return; |
| 5727 | } |
| 5728 | |
Vandana Kannan | 96178ee | 2015-01-10 02:25:56 +0530 | [diff] [blame] | 5729 | dig_port = dp_to_dig_port(intel_dp); |
| 5730 | encoder = &dig_port->base; |
Pradeep Bhat | 439d7ac | 2014-04-05 12:13:28 +0530 | [diff] [blame] | 5731 | |
| 5732 | if (!intel_crtc) { |
| 5733 | DRM_DEBUG_KMS("DRRS: intel_crtc not initialized\n"); |
| 5734 | return; |
| 5735 | } |
| 5736 | |
Vandana Kannan | 96178ee | 2015-01-10 02:25:56 +0530 | [diff] [blame] | 5737 | if (dev_priv->drrs.type < SEAMLESS_DRRS_SUPPORT) { |
Pradeep Bhat | 439d7ac | 2014-04-05 12:13:28 +0530 | [diff] [blame] | 5738 | DRM_DEBUG_KMS("Only Seamless DRRS supported.\n"); |
| 5739 | return; |
| 5740 | } |
| 5741 | |
Vandana Kannan | 96178ee | 2015-01-10 02:25:56 +0530 | [diff] [blame] | 5742 | if (intel_dp->attached_connector->panel.downclock_mode->vrefresh == |
| 5743 | refresh_rate) |
Pradeep Bhat | 439d7ac | 2014-04-05 12:13:28 +0530 | [diff] [blame] | 5744 | index = DRRS_LOW_RR; |
| 5745 | |
Vandana Kannan | 96178ee | 2015-01-10 02:25:56 +0530 | [diff] [blame] | 5746 | if (index == dev_priv->drrs.refresh_rate_type) { |
Pradeep Bhat | 439d7ac | 2014-04-05 12:13:28 +0530 | [diff] [blame] | 5747 | DRM_DEBUG_KMS( |
| 5748 | "DRRS requested for previously set RR...ignoring\n"); |
| 5749 | return; |
| 5750 | } |
| 5751 | |
Maarten Lankhorst | 85cb48a | 2016-08-09 17:04:13 +0200 | [diff] [blame] | 5752 | if (!crtc_state->base.active) { |
Pradeep Bhat | 439d7ac | 2014-04-05 12:13:28 +0530 | [diff] [blame] | 5753 | DRM_DEBUG_KMS("eDP encoder disabled. CRTC not Active\n"); |
| 5754 | return; |
| 5755 | } |
| 5756 | |
Maarten Lankhorst | 85cb48a | 2016-08-09 17:04:13 +0200 | [diff] [blame] | 5757 | if (INTEL_GEN(dev_priv) >= 8 && !IS_CHERRYVIEW(dev_priv)) { |
Vandana Kannan | a4c30b1 | 2015-02-13 15:33:00 +0530 | [diff] [blame] | 5758 | switch (index) { |
| 5759 | case DRRS_HIGH_RR: |
| 5760 | intel_dp_set_m_n(intel_crtc, M1_N1); |
| 5761 | break; |
| 5762 | case DRRS_LOW_RR: |
| 5763 | intel_dp_set_m_n(intel_crtc, M2_N2); |
| 5764 | break; |
| 5765 | case DRRS_MAX_RR: |
| 5766 | default: |
| 5767 | DRM_ERROR("Unsupported refreshrate type\n"); |
| 5768 | } |
Maarten Lankhorst | 85cb48a | 2016-08-09 17:04:13 +0200 | [diff] [blame] | 5769 | } else if (INTEL_GEN(dev_priv) > 6) { |
| 5770 | i915_reg_t reg = PIPECONF(crtc_state->cpu_transcoder); |
Ville Syrjälä | 649636e | 2015-09-22 19:50:01 +0300 | [diff] [blame] | 5771 | u32 val; |
Vandana Kannan | a4c30b1 | 2015-02-13 15:33:00 +0530 | [diff] [blame] | 5772 | |
Ville Syrjälä | 649636e | 2015-09-22 19:50:01 +0300 | [diff] [blame] | 5773 | val = I915_READ(reg); |
Pradeep Bhat | 439d7ac | 2014-04-05 12:13:28 +0530 | [diff] [blame] | 5774 | if (index > DRRS_HIGH_RR) { |
Maarten Lankhorst | 85cb48a | 2016-08-09 17:04:13 +0200 | [diff] [blame] | 5775 | if (IS_VALLEYVIEW(dev_priv) || IS_CHERRYVIEW(dev_priv)) |
Vandana Kannan | 6fa7aec | 2015-02-13 15:33:01 +0530 | [diff] [blame] | 5776 | val |= PIPECONF_EDP_RR_MODE_SWITCH_VLV; |
| 5777 | else |
| 5778 | val |= PIPECONF_EDP_RR_MODE_SWITCH; |
Pradeep Bhat | 439d7ac | 2014-04-05 12:13:28 +0530 | [diff] [blame] | 5779 | } else { |
Maarten Lankhorst | 85cb48a | 2016-08-09 17:04:13 +0200 | [diff] [blame] | 5780 | if (IS_VALLEYVIEW(dev_priv) || IS_CHERRYVIEW(dev_priv)) |
Vandana Kannan | 6fa7aec | 2015-02-13 15:33:01 +0530 | [diff] [blame] | 5781 | val &= ~PIPECONF_EDP_RR_MODE_SWITCH_VLV; |
| 5782 | else |
| 5783 | val &= ~PIPECONF_EDP_RR_MODE_SWITCH; |
Pradeep Bhat | 439d7ac | 2014-04-05 12:13:28 +0530 | [diff] [blame] | 5784 | } |
| 5785 | I915_WRITE(reg, val); |
| 5786 | } |
| 5787 | |
Vandana Kannan | 4e9ac94 | 2015-01-22 15:14:45 +0530 | [diff] [blame] | 5788 | dev_priv->drrs.refresh_rate_type = index; |
| 5789 | |
| 5790 | DRM_DEBUG_KMS("eDP Refresh Rate set to : %dHz\n", refresh_rate); |
| 5791 | } |
| 5792 | |
Vandana Kannan | b33a281 | 2015-02-13 15:33:03 +0530 | [diff] [blame] | 5793 | /** |
| 5794 | * intel_edp_drrs_enable - init drrs struct if supported |
| 5795 | * @intel_dp: DP struct |
Maarten Lankhorst | 5423adf | 2016-08-31 11:01:36 +0200 | [diff] [blame] | 5796 | * @crtc_state: A pointer to the active crtc state. |
Vandana Kannan | b33a281 | 2015-02-13 15:33:03 +0530 | [diff] [blame] | 5797 | * |
| 5798 | * Initializes frontbuffer_bits and drrs.dp |
| 5799 | */ |
Maarten Lankhorst | 85cb48a | 2016-08-09 17:04:13 +0200 | [diff] [blame] | 5800 | void intel_edp_drrs_enable(struct intel_dp *intel_dp, |
Ville Syrjälä | 5f88a9c | 2017-08-18 16:49:58 +0300 | [diff] [blame] | 5801 | const struct intel_crtc_state *crtc_state) |
Vandana Kannan | c395578 | 2015-01-22 15:17:40 +0530 | [diff] [blame] | 5802 | { |
Ville Syrjälä | 2f77347 | 2017-11-09 17:27:58 +0200 | [diff] [blame] | 5803 | struct drm_i915_private *dev_priv = to_i915(intel_dp_to_dev(intel_dp)); |
Vandana Kannan | c395578 | 2015-01-22 15:17:40 +0530 | [diff] [blame] | 5804 | |
Maarten Lankhorst | 85cb48a | 2016-08-09 17:04:13 +0200 | [diff] [blame] | 5805 | if (!crtc_state->has_drrs) { |
Vandana Kannan | c395578 | 2015-01-22 15:17:40 +0530 | [diff] [blame] | 5806 | DRM_DEBUG_KMS("Panel doesn't support DRRS\n"); |
| 5807 | return; |
| 5808 | } |
| 5809 | |
Radhakrishna Sripada | da83ef8 | 2017-09-14 11:16:41 -0700 | [diff] [blame] | 5810 | if (dev_priv->psr.enabled) { |
| 5811 | DRM_DEBUG_KMS("PSR enabled. Not enabling DRRS.\n"); |
| 5812 | return; |
| 5813 | } |
| 5814 | |
Vandana Kannan | c395578 | 2015-01-22 15:17:40 +0530 | [diff] [blame] | 5815 | mutex_lock(&dev_priv->drrs.mutex); |
| 5816 | if (WARN_ON(dev_priv->drrs.dp)) { |
| 5817 | DRM_ERROR("DRRS already enabled\n"); |
| 5818 | goto unlock; |
| 5819 | } |
| 5820 | |
| 5821 | dev_priv->drrs.busy_frontbuffer_bits = 0; |
| 5822 | |
| 5823 | dev_priv->drrs.dp = intel_dp; |
| 5824 | |
| 5825 | unlock: |
| 5826 | mutex_unlock(&dev_priv->drrs.mutex); |
| 5827 | } |
| 5828 | |
Vandana Kannan | b33a281 | 2015-02-13 15:33:03 +0530 | [diff] [blame] | 5829 | /** |
| 5830 | * intel_edp_drrs_disable - Disable DRRS |
| 5831 | * @intel_dp: DP struct |
Maarten Lankhorst | 5423adf | 2016-08-31 11:01:36 +0200 | [diff] [blame] | 5832 | * @old_crtc_state: Pointer to old crtc_state. |
Vandana Kannan | b33a281 | 2015-02-13 15:33:03 +0530 | [diff] [blame] | 5833 | * |
| 5834 | */ |
Maarten Lankhorst | 85cb48a | 2016-08-09 17:04:13 +0200 | [diff] [blame] | 5835 | void intel_edp_drrs_disable(struct intel_dp *intel_dp, |
Ville Syrjälä | 5f88a9c | 2017-08-18 16:49:58 +0300 | [diff] [blame] | 5836 | const struct intel_crtc_state *old_crtc_state) |
Vandana Kannan | c395578 | 2015-01-22 15:17:40 +0530 | [diff] [blame] | 5837 | { |
Ville Syrjälä | 2f77347 | 2017-11-09 17:27:58 +0200 | [diff] [blame] | 5838 | struct drm_i915_private *dev_priv = to_i915(intel_dp_to_dev(intel_dp)); |
Vandana Kannan | c395578 | 2015-01-22 15:17:40 +0530 | [diff] [blame] | 5839 | |
Maarten Lankhorst | 85cb48a | 2016-08-09 17:04:13 +0200 | [diff] [blame] | 5840 | if (!old_crtc_state->has_drrs) |
Vandana Kannan | c395578 | 2015-01-22 15:17:40 +0530 | [diff] [blame] | 5841 | return; |
| 5842 | |
| 5843 | mutex_lock(&dev_priv->drrs.mutex); |
| 5844 | if (!dev_priv->drrs.dp) { |
| 5845 | mutex_unlock(&dev_priv->drrs.mutex); |
| 5846 | return; |
| 5847 | } |
| 5848 | |
| 5849 | if (dev_priv->drrs.refresh_rate_type == DRRS_LOW_RR) |
Maarten Lankhorst | 85cb48a | 2016-08-09 17:04:13 +0200 | [diff] [blame] | 5850 | intel_dp_set_drrs_state(dev_priv, old_crtc_state, |
| 5851 | intel_dp->attached_connector->panel.fixed_mode->vrefresh); |
Vandana Kannan | c395578 | 2015-01-22 15:17:40 +0530 | [diff] [blame] | 5852 | |
| 5853 | dev_priv->drrs.dp = NULL; |
| 5854 | mutex_unlock(&dev_priv->drrs.mutex); |
| 5855 | |
| 5856 | cancel_delayed_work_sync(&dev_priv->drrs.work); |
| 5857 | } |
| 5858 | |
Vandana Kannan | 4e9ac94 | 2015-01-22 15:14:45 +0530 | [diff] [blame] | 5859 | static void intel_edp_drrs_downclock_work(struct work_struct *work) |
| 5860 | { |
| 5861 | struct drm_i915_private *dev_priv = |
| 5862 | container_of(work, typeof(*dev_priv), drrs.work.work); |
| 5863 | struct intel_dp *intel_dp; |
Pradeep Bhat | 439d7ac | 2014-04-05 12:13:28 +0530 | [diff] [blame] | 5864 | |
Vandana Kannan | 96178ee | 2015-01-10 02:25:56 +0530 | [diff] [blame] | 5865 | mutex_lock(&dev_priv->drrs.mutex); |
Pradeep Bhat | 439d7ac | 2014-04-05 12:13:28 +0530 | [diff] [blame] | 5866 | |
Vandana Kannan | 4e9ac94 | 2015-01-22 15:14:45 +0530 | [diff] [blame] | 5867 | intel_dp = dev_priv->drrs.dp; |
| 5868 | |
| 5869 | if (!intel_dp) |
| 5870 | goto unlock; |
| 5871 | |
| 5872 | /* |
| 5873 | * The delayed work can race with an invalidate hence we need to |
| 5874 | * recheck. |
| 5875 | */ |
| 5876 | |
| 5877 | if (dev_priv->drrs.busy_frontbuffer_bits) |
| 5878 | goto unlock; |
| 5879 | |
Maarten Lankhorst | 85cb48a | 2016-08-09 17:04:13 +0200 | [diff] [blame] | 5880 | if (dev_priv->drrs.refresh_rate_type != DRRS_LOW_RR) { |
| 5881 | struct drm_crtc *crtc = dp_to_dig_port(intel_dp)->base.base.crtc; |
| 5882 | |
| 5883 | intel_dp_set_drrs_state(dev_priv, to_intel_crtc(crtc)->config, |
| 5884 | intel_dp->attached_connector->panel.downclock_mode->vrefresh); |
| 5885 | } |
Vandana Kannan | 4e9ac94 | 2015-01-22 15:14:45 +0530 | [diff] [blame] | 5886 | |
| 5887 | unlock: |
Vandana Kannan | 96178ee | 2015-01-10 02:25:56 +0530 | [diff] [blame] | 5888 | mutex_unlock(&dev_priv->drrs.mutex); |
Pradeep Bhat | 439d7ac | 2014-04-05 12:13:28 +0530 | [diff] [blame] | 5889 | } |
| 5890 | |
Vandana Kannan | b33a281 | 2015-02-13 15:33:03 +0530 | [diff] [blame] | 5891 | /** |
Ramalingam C | 0ddfd20 | 2015-06-15 20:50:05 +0530 | [diff] [blame] | 5892 | * intel_edp_drrs_invalidate - Disable Idleness DRRS |
Chris Wilson | 5748b6a | 2016-08-04 16:32:38 +0100 | [diff] [blame] | 5893 | * @dev_priv: i915 device |
Vandana Kannan | b33a281 | 2015-02-13 15:33:03 +0530 | [diff] [blame] | 5894 | * @frontbuffer_bits: frontbuffer plane tracking bits |
| 5895 | * |
Ramalingam C | 0ddfd20 | 2015-06-15 20:50:05 +0530 | [diff] [blame] | 5896 | * This function gets called everytime rendering on the given planes start. |
| 5897 | * Hence DRRS needs to be Upclocked, i.e. (LOW_RR -> HIGH_RR). |
Vandana Kannan | b33a281 | 2015-02-13 15:33:03 +0530 | [diff] [blame] | 5898 | * |
| 5899 | * Dirty frontbuffers relevant to DRRS are tracked in busy_frontbuffer_bits. |
| 5900 | */ |
Chris Wilson | 5748b6a | 2016-08-04 16:32:38 +0100 | [diff] [blame] | 5901 | void intel_edp_drrs_invalidate(struct drm_i915_private *dev_priv, |
| 5902 | unsigned int frontbuffer_bits) |
Vandana Kannan | a93fad0 | 2015-01-10 02:25:59 +0530 | [diff] [blame] | 5903 | { |
Vandana Kannan | a93fad0 | 2015-01-10 02:25:59 +0530 | [diff] [blame] | 5904 | struct drm_crtc *crtc; |
| 5905 | enum pipe pipe; |
| 5906 | |
Daniel Vetter | 9da7d69 | 2015-04-09 16:44:15 +0200 | [diff] [blame] | 5907 | if (dev_priv->drrs.type == DRRS_NOT_SUPPORTED) |
Vandana Kannan | a93fad0 | 2015-01-10 02:25:59 +0530 | [diff] [blame] | 5908 | return; |
| 5909 | |
Daniel Vetter | 88f933a | 2015-04-09 16:44:16 +0200 | [diff] [blame] | 5910 | cancel_delayed_work(&dev_priv->drrs.work); |
Ramalingam C | 3954e73 | 2015-03-03 12:11:46 +0530 | [diff] [blame] | 5911 | |
Vandana Kannan | a93fad0 | 2015-01-10 02:25:59 +0530 | [diff] [blame] | 5912 | mutex_lock(&dev_priv->drrs.mutex); |
Daniel Vetter | 9da7d69 | 2015-04-09 16:44:15 +0200 | [diff] [blame] | 5913 | if (!dev_priv->drrs.dp) { |
| 5914 | mutex_unlock(&dev_priv->drrs.mutex); |
| 5915 | return; |
| 5916 | } |
| 5917 | |
Vandana Kannan | a93fad0 | 2015-01-10 02:25:59 +0530 | [diff] [blame] | 5918 | crtc = dp_to_dig_port(dev_priv->drrs.dp)->base.base.crtc; |
| 5919 | pipe = to_intel_crtc(crtc)->pipe; |
| 5920 | |
Daniel Vetter | c1d038c | 2015-06-18 10:30:25 +0200 | [diff] [blame] | 5921 | frontbuffer_bits &= INTEL_FRONTBUFFER_ALL_MASK(pipe); |
| 5922 | dev_priv->drrs.busy_frontbuffer_bits |= frontbuffer_bits; |
| 5923 | |
Ramalingam C | 0ddfd20 | 2015-06-15 20:50:05 +0530 | [diff] [blame] | 5924 | /* invalidate means busy screen hence upclock */ |
Daniel Vetter | c1d038c | 2015-06-18 10:30:25 +0200 | [diff] [blame] | 5925 | if (frontbuffer_bits && dev_priv->drrs.refresh_rate_type == DRRS_LOW_RR) |
Maarten Lankhorst | 85cb48a | 2016-08-09 17:04:13 +0200 | [diff] [blame] | 5926 | intel_dp_set_drrs_state(dev_priv, to_intel_crtc(crtc)->config, |
| 5927 | dev_priv->drrs.dp->attached_connector->panel.fixed_mode->vrefresh); |
Vandana Kannan | a93fad0 | 2015-01-10 02:25:59 +0530 | [diff] [blame] | 5928 | |
Vandana Kannan | a93fad0 | 2015-01-10 02:25:59 +0530 | [diff] [blame] | 5929 | mutex_unlock(&dev_priv->drrs.mutex); |
| 5930 | } |
| 5931 | |
Vandana Kannan | b33a281 | 2015-02-13 15:33:03 +0530 | [diff] [blame] | 5932 | /** |
Ramalingam C | 0ddfd20 | 2015-06-15 20:50:05 +0530 | [diff] [blame] | 5933 | * intel_edp_drrs_flush - Restart Idleness DRRS |
Chris Wilson | 5748b6a | 2016-08-04 16:32:38 +0100 | [diff] [blame] | 5934 | * @dev_priv: i915 device |
Vandana Kannan | b33a281 | 2015-02-13 15:33:03 +0530 | [diff] [blame] | 5935 | * @frontbuffer_bits: frontbuffer plane tracking bits |
| 5936 | * |
Ramalingam C | 0ddfd20 | 2015-06-15 20:50:05 +0530 | [diff] [blame] | 5937 | * This function gets called every time rendering on the given planes has |
| 5938 | * completed or flip on a crtc is completed. So DRRS should be upclocked |
| 5939 | * (LOW_RR -> HIGH_RR). And also Idleness detection should be started again, |
| 5940 | * if no other planes are dirty. |
Vandana Kannan | b33a281 | 2015-02-13 15:33:03 +0530 | [diff] [blame] | 5941 | * |
| 5942 | * Dirty frontbuffers relevant to DRRS are tracked in busy_frontbuffer_bits. |
| 5943 | */ |
Chris Wilson | 5748b6a | 2016-08-04 16:32:38 +0100 | [diff] [blame] | 5944 | void intel_edp_drrs_flush(struct drm_i915_private *dev_priv, |
| 5945 | unsigned int frontbuffer_bits) |
Vandana Kannan | a93fad0 | 2015-01-10 02:25:59 +0530 | [diff] [blame] | 5946 | { |
Vandana Kannan | a93fad0 | 2015-01-10 02:25:59 +0530 | [diff] [blame] | 5947 | struct drm_crtc *crtc; |
| 5948 | enum pipe pipe; |
| 5949 | |
Daniel Vetter | 9da7d69 | 2015-04-09 16:44:15 +0200 | [diff] [blame] | 5950 | if (dev_priv->drrs.type == DRRS_NOT_SUPPORTED) |
Vandana Kannan | a93fad0 | 2015-01-10 02:25:59 +0530 | [diff] [blame] | 5951 | return; |
| 5952 | |
Daniel Vetter | 88f933a | 2015-04-09 16:44:16 +0200 | [diff] [blame] | 5953 | cancel_delayed_work(&dev_priv->drrs.work); |
Ramalingam C | 3954e73 | 2015-03-03 12:11:46 +0530 | [diff] [blame] | 5954 | |
Vandana Kannan | a93fad0 | 2015-01-10 02:25:59 +0530 | [diff] [blame] | 5955 | mutex_lock(&dev_priv->drrs.mutex); |
Daniel Vetter | 9da7d69 | 2015-04-09 16:44:15 +0200 | [diff] [blame] | 5956 | if (!dev_priv->drrs.dp) { |
| 5957 | mutex_unlock(&dev_priv->drrs.mutex); |
| 5958 | return; |
| 5959 | } |
| 5960 | |
Vandana Kannan | a93fad0 | 2015-01-10 02:25:59 +0530 | [diff] [blame] | 5961 | crtc = dp_to_dig_port(dev_priv->drrs.dp)->base.base.crtc; |
| 5962 | pipe = to_intel_crtc(crtc)->pipe; |
Daniel Vetter | c1d038c | 2015-06-18 10:30:25 +0200 | [diff] [blame] | 5963 | |
| 5964 | frontbuffer_bits &= INTEL_FRONTBUFFER_ALL_MASK(pipe); |
Vandana Kannan | a93fad0 | 2015-01-10 02:25:59 +0530 | [diff] [blame] | 5965 | dev_priv->drrs.busy_frontbuffer_bits &= ~frontbuffer_bits; |
| 5966 | |
Ramalingam C | 0ddfd20 | 2015-06-15 20:50:05 +0530 | [diff] [blame] | 5967 | /* flush means busy screen hence upclock */ |
Daniel Vetter | c1d038c | 2015-06-18 10:30:25 +0200 | [diff] [blame] | 5968 | if (frontbuffer_bits && dev_priv->drrs.refresh_rate_type == DRRS_LOW_RR) |
Maarten Lankhorst | 85cb48a | 2016-08-09 17:04:13 +0200 | [diff] [blame] | 5969 | intel_dp_set_drrs_state(dev_priv, to_intel_crtc(crtc)->config, |
| 5970 | dev_priv->drrs.dp->attached_connector->panel.fixed_mode->vrefresh); |
Ramalingam C | 0ddfd20 | 2015-06-15 20:50:05 +0530 | [diff] [blame] | 5971 | |
| 5972 | /* |
| 5973 | * flush also means no more activity hence schedule downclock, if all |
| 5974 | * other fbs are quiescent too |
| 5975 | */ |
| 5976 | if (!dev_priv->drrs.busy_frontbuffer_bits) |
Vandana Kannan | a93fad0 | 2015-01-10 02:25:59 +0530 | [diff] [blame] | 5977 | schedule_delayed_work(&dev_priv->drrs.work, |
| 5978 | msecs_to_jiffies(1000)); |
| 5979 | mutex_unlock(&dev_priv->drrs.mutex); |
| 5980 | } |
| 5981 | |
Vandana Kannan | b33a281 | 2015-02-13 15:33:03 +0530 | [diff] [blame] | 5982 | /** |
| 5983 | * DOC: Display Refresh Rate Switching (DRRS) |
| 5984 | * |
| 5985 | * Display Refresh Rate Switching (DRRS) is a power conservation feature |
| 5986 | * which enables swtching between low and high refresh rates, |
| 5987 | * dynamically, based on the usage scenario. This feature is applicable |
| 5988 | * for internal panels. |
| 5989 | * |
| 5990 | * Indication that the panel supports DRRS is given by the panel EDID, which |
| 5991 | * would list multiple refresh rates for one resolution. |
| 5992 | * |
| 5993 | * DRRS is of 2 types - static and seamless. |
| 5994 | * Static DRRS involves changing refresh rate (RR) by doing a full modeset |
| 5995 | * (may appear as a blink on screen) and is used in dock-undock scenario. |
| 5996 | * Seamless DRRS involves changing RR without any visual effect to the user |
| 5997 | * and can be used during normal system usage. This is done by programming |
| 5998 | * certain registers. |
| 5999 | * |
| 6000 | * Support for static/seamless DRRS may be indicated in the VBT based on |
| 6001 | * inputs from the panel spec. |
| 6002 | * |
| 6003 | * DRRS saves power by switching to low RR based on usage scenarios. |
| 6004 | * |
Daniel Vetter | 2e7a570 | 2016-06-01 23:40:36 +0200 | [diff] [blame] | 6005 | * The implementation is based on frontbuffer tracking implementation. When |
| 6006 | * there is a disturbance on the screen triggered by user activity or a periodic |
| 6007 | * system activity, DRRS is disabled (RR is changed to high RR). When there is |
| 6008 | * no movement on screen, after a timeout of 1 second, a switch to low RR is |
| 6009 | * made. |
| 6010 | * |
| 6011 | * For integration with frontbuffer tracking code, intel_edp_drrs_invalidate() |
| 6012 | * and intel_edp_drrs_flush() are called. |
Vandana Kannan | b33a281 | 2015-02-13 15:33:03 +0530 | [diff] [blame] | 6013 | * |
| 6014 | * DRRS can be further extended to support other internal panels and also |
| 6015 | * the scenario of video playback wherein RR is set based on the rate |
| 6016 | * requested by userspace. |
| 6017 | */ |
| 6018 | |
| 6019 | /** |
| 6020 | * intel_dp_drrs_init - Init basic DRRS work and mutex. |
Ville Syrjälä | 2f77347 | 2017-11-09 17:27:58 +0200 | [diff] [blame] | 6021 | * @connector: eDP connector |
Vandana Kannan | b33a281 | 2015-02-13 15:33:03 +0530 | [diff] [blame] | 6022 | * @fixed_mode: preferred mode of panel |
| 6023 | * |
| 6024 | * This function is called only once at driver load to initialize basic |
| 6025 | * DRRS stuff. |
| 6026 | * |
| 6027 | * Returns: |
| 6028 | * Downclock mode if panel supports it, else return NULL. |
| 6029 | * DRRS support is determined by the presence of downclock mode (apart |
| 6030 | * from VBT setting). |
| 6031 | */ |
Pradeep Bhat | 4f9db5b | 2014-04-05 12:12:31 +0530 | [diff] [blame] | 6032 | static struct drm_display_mode * |
Ville Syrjälä | 2f77347 | 2017-11-09 17:27:58 +0200 | [diff] [blame] | 6033 | intel_dp_drrs_init(struct intel_connector *connector, |
| 6034 | struct drm_display_mode *fixed_mode) |
Pradeep Bhat | 4f9db5b | 2014-04-05 12:12:31 +0530 | [diff] [blame] | 6035 | { |
Ville Syrjälä | 2f77347 | 2017-11-09 17:27:58 +0200 | [diff] [blame] | 6036 | struct drm_i915_private *dev_priv = to_i915(connector->base.dev); |
Pradeep Bhat | 4f9db5b | 2014-04-05 12:12:31 +0530 | [diff] [blame] | 6037 | struct drm_display_mode *downclock_mode = NULL; |
| 6038 | |
Daniel Vetter | 9da7d69 | 2015-04-09 16:44:15 +0200 | [diff] [blame] | 6039 | INIT_DELAYED_WORK(&dev_priv->drrs.work, intel_edp_drrs_downclock_work); |
| 6040 | mutex_init(&dev_priv->drrs.mutex); |
| 6041 | |
Tvrtko Ursulin | dd11bc1 | 2016-11-16 08:55:41 +0000 | [diff] [blame] | 6042 | if (INTEL_GEN(dev_priv) <= 6) { |
Pradeep Bhat | 4f9db5b | 2014-04-05 12:12:31 +0530 | [diff] [blame] | 6043 | DRM_DEBUG_KMS("DRRS supported for Gen7 and above\n"); |
| 6044 | return NULL; |
| 6045 | } |
| 6046 | |
| 6047 | if (dev_priv->vbt.drrs_type != SEAMLESS_DRRS_SUPPORT) { |
Damien Lespiau | 4079b8d | 2014-08-05 10:39:42 +0100 | [diff] [blame] | 6048 | DRM_DEBUG_KMS("VBT doesn't support DRRS\n"); |
Pradeep Bhat | 4f9db5b | 2014-04-05 12:12:31 +0530 | [diff] [blame] | 6049 | return NULL; |
| 6050 | } |
| 6051 | |
Ville Syrjälä | 2f77347 | 2017-11-09 17:27:58 +0200 | [diff] [blame] | 6052 | downclock_mode = intel_find_panel_downclock(dev_priv, fixed_mode, |
| 6053 | &connector->base); |
Pradeep Bhat | 4f9db5b | 2014-04-05 12:12:31 +0530 | [diff] [blame] | 6054 | |
| 6055 | if (!downclock_mode) { |
Ramalingam C | a1d2634 | 2015-02-23 17:38:33 +0530 | [diff] [blame] | 6056 | DRM_DEBUG_KMS("Downclock mode is not found. DRRS not supported\n"); |
Pradeep Bhat | 4f9db5b | 2014-04-05 12:12:31 +0530 | [diff] [blame] | 6057 | return NULL; |
| 6058 | } |
| 6059 | |
Vandana Kannan | 96178ee | 2015-01-10 02:25:56 +0530 | [diff] [blame] | 6060 | dev_priv->drrs.type = dev_priv->vbt.drrs_type; |
Pradeep Bhat | 439d7ac | 2014-04-05 12:13:28 +0530 | [diff] [blame] | 6061 | |
Vandana Kannan | 96178ee | 2015-01-10 02:25:56 +0530 | [diff] [blame] | 6062 | dev_priv->drrs.refresh_rate_type = DRRS_HIGH_RR; |
Damien Lespiau | 4079b8d | 2014-08-05 10:39:42 +0100 | [diff] [blame] | 6063 | DRM_DEBUG_KMS("seamless DRRS supported for eDP panel.\n"); |
Pradeep Bhat | 4f9db5b | 2014-04-05 12:12:31 +0530 | [diff] [blame] | 6064 | return downclock_mode; |
| 6065 | } |
| 6066 | |
Paulo Zanoni | ed92f0b | 2013-06-12 17:27:24 -0300 | [diff] [blame] | 6067 | static bool intel_edp_init_connector(struct intel_dp *intel_dp, |
Ville Syrjälä | 36b5f42 | 2014-10-16 21:27:30 +0300 | [diff] [blame] | 6068 | struct intel_connector *intel_connector) |
Paulo Zanoni | ed92f0b | 2013-06-12 17:27:24 -0300 | [diff] [blame] | 6069 | { |
Ville Syrjälä | 2f77347 | 2017-11-09 17:27:58 +0200 | [diff] [blame] | 6070 | struct drm_device *dev = intel_dp_to_dev(intel_dp); |
Chris Wilson | fac5e23 | 2016-07-04 11:34:36 +0100 | [diff] [blame] | 6071 | struct drm_i915_private *dev_priv = to_i915(dev); |
Ville Syrjälä | 2f77347 | 2017-11-09 17:27:58 +0200 | [diff] [blame] | 6072 | struct drm_connector *connector = &intel_connector->base; |
Paulo Zanoni | ed92f0b | 2013-06-12 17:27:24 -0300 | [diff] [blame] | 6073 | struct drm_display_mode *fixed_mode = NULL; |
Jim Bride | dc911f5 | 2017-08-09 12:48:53 -0700 | [diff] [blame] | 6074 | struct drm_display_mode *alt_fixed_mode = NULL; |
Pradeep Bhat | 4f9db5b | 2014-04-05 12:12:31 +0530 | [diff] [blame] | 6075 | struct drm_display_mode *downclock_mode = NULL; |
Paulo Zanoni | ed92f0b | 2013-06-12 17:27:24 -0300 | [diff] [blame] | 6076 | bool has_dpcd; |
| 6077 | struct drm_display_mode *scan; |
| 6078 | struct edid *edid; |
Ville Syrjälä | 6517d27 | 2014-11-07 11:16:02 +0200 | [diff] [blame] | 6079 | enum pipe pipe = INVALID_PIPE; |
Paulo Zanoni | ed92f0b | 2013-06-12 17:27:24 -0300 | [diff] [blame] | 6080 | |
Jani Nikula | 1853a9d | 2017-08-18 12:30:20 +0300 | [diff] [blame] | 6081 | if (!intel_dp_is_edp(intel_dp)) |
Paulo Zanoni | ed92f0b | 2013-06-12 17:27:24 -0300 | [diff] [blame] | 6082 | return true; |
| 6083 | |
Imre Deak | 97a824e1 | 2016-06-21 11:51:47 +0300 | [diff] [blame] | 6084 | /* |
| 6085 | * On IBX/CPT we may get here with LVDS already registered. Since the |
| 6086 | * driver uses the only internal power sequencer available for both |
| 6087 | * eDP and LVDS bail out early in this case to prevent interfering |
| 6088 | * with an already powered-on LVDS power sequencer. |
| 6089 | */ |
Ville Syrjälä | 2f77347 | 2017-11-09 17:27:58 +0200 | [diff] [blame] | 6090 | if (intel_get_lvds_encoder(&dev_priv->drm)) { |
Imre Deak | 97a824e1 | 2016-06-21 11:51:47 +0300 | [diff] [blame] | 6091 | WARN_ON(!(HAS_PCH_IBX(dev_priv) || HAS_PCH_CPT(dev_priv))); |
| 6092 | DRM_INFO("LVDS was detected, not registering eDP\n"); |
| 6093 | |
| 6094 | return false; |
| 6095 | } |
| 6096 | |
Ville Syrjälä | 49e6bc5 | 2014-10-28 16:15:52 +0200 | [diff] [blame] | 6097 | pps_lock(intel_dp); |
Imre Deak | b4d06ed | 2016-06-21 11:51:49 +0300 | [diff] [blame] | 6098 | |
| 6099 | intel_dp_init_panel_power_timestamps(intel_dp); |
Ville Syrjälä | 46bd838 | 2017-10-31 22:51:22 +0200 | [diff] [blame] | 6100 | intel_dp_pps_init(intel_dp); |
Ville Syrjälä | 49e6bc5 | 2014-10-28 16:15:52 +0200 | [diff] [blame] | 6101 | intel_edp_panel_vdd_sanitize(intel_dp); |
Imre Deak | b4d06ed | 2016-06-21 11:51:49 +0300 | [diff] [blame] | 6102 | |
Ville Syrjälä | 49e6bc5 | 2014-10-28 16:15:52 +0200 | [diff] [blame] | 6103 | pps_unlock(intel_dp); |
Paulo Zanoni | 6363521 | 2014-04-22 19:55:42 -0300 | [diff] [blame] | 6104 | |
Paulo Zanoni | ed92f0b | 2013-06-12 17:27:24 -0300 | [diff] [blame] | 6105 | /* Cache DPCD and EDID for edp. */ |
Ville Syrjälä | fe5a66f | 2016-07-29 16:52:39 +0300 | [diff] [blame] | 6106 | has_dpcd = intel_edp_init_dpcd(intel_dp); |
Paulo Zanoni | ed92f0b | 2013-06-12 17:27:24 -0300 | [diff] [blame] | 6107 | |
Ville Syrjälä | fe5a66f | 2016-07-29 16:52:39 +0300 | [diff] [blame] | 6108 | if (!has_dpcd) { |
Paulo Zanoni | ed92f0b | 2013-06-12 17:27:24 -0300 | [diff] [blame] | 6109 | /* if this fails, presume the device is a ghost */ |
| 6110 | DRM_INFO("failed to retrieve link info, disabling eDP\n"); |
Imre Deak | b4d06ed | 2016-06-21 11:51:49 +0300 | [diff] [blame] | 6111 | goto out_vdd_off; |
Paulo Zanoni | ed92f0b | 2013-06-12 17:27:24 -0300 | [diff] [blame] | 6112 | } |
| 6113 | |
Daniel Vetter | 060c877 | 2014-03-21 23:22:35 +0100 | [diff] [blame] | 6114 | mutex_lock(&dev->mode_config.mutex); |
Jani Nikula | 0b99836 | 2014-03-14 16:51:17 +0200 | [diff] [blame] | 6115 | edid = drm_get_edid(connector, &intel_dp->aux.ddc); |
Paulo Zanoni | ed92f0b | 2013-06-12 17:27:24 -0300 | [diff] [blame] | 6116 | if (edid) { |
| 6117 | if (drm_add_edid_modes(connector, edid)) { |
| 6118 | drm_mode_connector_update_edid_property(connector, |
| 6119 | edid); |
Paulo Zanoni | ed92f0b | 2013-06-12 17:27:24 -0300 | [diff] [blame] | 6120 | } else { |
| 6121 | kfree(edid); |
| 6122 | edid = ERR_PTR(-EINVAL); |
| 6123 | } |
| 6124 | } else { |
| 6125 | edid = ERR_PTR(-ENOENT); |
| 6126 | } |
| 6127 | intel_connector->edid = edid; |
| 6128 | |
Jim Bride | dc911f5 | 2017-08-09 12:48:53 -0700 | [diff] [blame] | 6129 | /* prefer fixed mode from EDID if available, save an alt mode also */ |
Paulo Zanoni | ed92f0b | 2013-06-12 17:27:24 -0300 | [diff] [blame] | 6130 | list_for_each_entry(scan, &connector->probed_modes, head) { |
| 6131 | if ((scan->type & DRM_MODE_TYPE_PREFERRED)) { |
| 6132 | fixed_mode = drm_mode_duplicate(dev, scan); |
Pradeep Bhat | 4f9db5b | 2014-04-05 12:12:31 +0530 | [diff] [blame] | 6133 | downclock_mode = intel_dp_drrs_init( |
Pradeep Bhat | 4f9db5b | 2014-04-05 12:12:31 +0530 | [diff] [blame] | 6134 | intel_connector, fixed_mode); |
Jim Bride | dc911f5 | 2017-08-09 12:48:53 -0700 | [diff] [blame] | 6135 | } else if (!alt_fixed_mode) { |
| 6136 | alt_fixed_mode = drm_mode_duplicate(dev, scan); |
Paulo Zanoni | ed92f0b | 2013-06-12 17:27:24 -0300 | [diff] [blame] | 6137 | } |
| 6138 | } |
| 6139 | |
| 6140 | /* fallback to VBT if available for eDP */ |
| 6141 | if (!fixed_mode && dev_priv->vbt.lfp_lvds_vbt_mode) { |
| 6142 | fixed_mode = drm_mode_duplicate(dev, |
| 6143 | dev_priv->vbt.lfp_lvds_vbt_mode); |
Ville Syrjälä | df45724 | 2016-05-31 12:08:34 +0300 | [diff] [blame] | 6144 | if (fixed_mode) { |
Paulo Zanoni | ed92f0b | 2013-06-12 17:27:24 -0300 | [diff] [blame] | 6145 | fixed_mode->type |= DRM_MODE_TYPE_PREFERRED; |
Ville Syrjälä | df45724 | 2016-05-31 12:08:34 +0300 | [diff] [blame] | 6146 | connector->display_info.width_mm = fixed_mode->width_mm; |
| 6147 | connector->display_info.height_mm = fixed_mode->height_mm; |
| 6148 | } |
Paulo Zanoni | ed92f0b | 2013-06-12 17:27:24 -0300 | [diff] [blame] | 6149 | } |
Daniel Vetter | 060c877 | 2014-03-21 23:22:35 +0100 | [diff] [blame] | 6150 | mutex_unlock(&dev->mode_config.mutex); |
Paulo Zanoni | ed92f0b | 2013-06-12 17:27:24 -0300 | [diff] [blame] | 6151 | |
Tvrtko Ursulin | 920a14b | 2016-10-14 10:13:44 +0100 | [diff] [blame] | 6152 | if (IS_VALLEYVIEW(dev_priv) || IS_CHERRYVIEW(dev_priv)) { |
Clint Taylor | 01527b3 | 2014-07-07 13:01:46 -0700 | [diff] [blame] | 6153 | intel_dp->edp_notifier.notifier_call = edp_notify_handler; |
| 6154 | register_reboot_notifier(&intel_dp->edp_notifier); |
Ville Syrjälä | 6517d27 | 2014-11-07 11:16:02 +0200 | [diff] [blame] | 6155 | |
| 6156 | /* |
| 6157 | * Figure out the current pipe for the initial backlight setup. |
| 6158 | * If the current pipe isn't valid, try the PPS pipe, and if that |
| 6159 | * fails just assume pipe A. |
| 6160 | */ |
Ville Syrjälä | 9f2bdb0 | 2016-12-14 20:00:23 +0200 | [diff] [blame] | 6161 | pipe = vlv_active_pipe(intel_dp); |
Ville Syrjälä | 6517d27 | 2014-11-07 11:16:02 +0200 | [diff] [blame] | 6162 | |
| 6163 | if (pipe != PIPE_A && pipe != PIPE_B) |
| 6164 | pipe = intel_dp->pps_pipe; |
| 6165 | |
| 6166 | if (pipe != PIPE_A && pipe != PIPE_B) |
| 6167 | pipe = PIPE_A; |
| 6168 | |
| 6169 | DRM_DEBUG_KMS("using pipe %c for initial backlight setup\n", |
| 6170 | pipe_name(pipe)); |
Clint Taylor | 01527b3 | 2014-07-07 13:01:46 -0700 | [diff] [blame] | 6171 | } |
| 6172 | |
Jim Bride | dc911f5 | 2017-08-09 12:48:53 -0700 | [diff] [blame] | 6173 | intel_panel_init(&intel_connector->panel, fixed_mode, alt_fixed_mode, |
| 6174 | downclock_mode); |
Jani Nikula | 5507fae | 2015-09-14 14:03:48 +0300 | [diff] [blame] | 6175 | intel_connector->panel.backlight.power = intel_edp_backlight_power; |
Ville Syrjälä | 6517d27 | 2014-11-07 11:16:02 +0200 | [diff] [blame] | 6176 | intel_panel_setup_backlight(connector, pipe); |
Paulo Zanoni | ed92f0b | 2013-06-12 17:27:24 -0300 | [diff] [blame] | 6177 | |
| 6178 | return true; |
Imre Deak | b4d06ed | 2016-06-21 11:51:49 +0300 | [diff] [blame] | 6179 | |
| 6180 | out_vdd_off: |
| 6181 | cancel_delayed_work_sync(&intel_dp->panel_vdd_work); |
| 6182 | /* |
| 6183 | * vdd might still be enabled do to the delayed vdd off. |
| 6184 | * Make sure vdd is actually turned off here. |
| 6185 | */ |
| 6186 | pps_lock(intel_dp); |
| 6187 | edp_panel_vdd_off_sync(intel_dp); |
| 6188 | pps_unlock(intel_dp); |
| 6189 | |
| 6190 | return false; |
Paulo Zanoni | ed92f0b | 2013-06-12 17:27:24 -0300 | [diff] [blame] | 6191 | } |
| 6192 | |
Ander Conselvan de Oliveira | 5432fca | 2017-02-22 08:34:26 +0200 | [diff] [blame] | 6193 | /* Set up the hotplug pin and aux power domain. */ |
Ander Conselvan de Oliveira | b71953a | 2017-02-03 16:03:14 +0200 | [diff] [blame] | 6194 | static void |
| 6195 | intel_dp_init_connector_port_info(struct intel_digital_port *intel_dig_port) |
| 6196 | { |
| 6197 | struct intel_encoder *encoder = &intel_dig_port->base; |
Ander Conselvan de Oliveira | 5432fca | 2017-02-22 08:34:26 +0200 | [diff] [blame] | 6198 | struct intel_dp *intel_dp = &intel_dig_port->dp; |
Ander Conselvan de Oliveira | b71953a | 2017-02-03 16:03:14 +0200 | [diff] [blame] | 6199 | |
Ville Syrjälä | 8f4f279 | 2017-11-09 17:24:34 +0200 | [diff] [blame] | 6200 | encoder->hpd_pin = intel_hpd_pin(encoder->port); |
Rodrigo Vivi | f761bef2 | 2017-08-11 11:26:50 -0700 | [diff] [blame] | 6201 | |
Ville Syrjälä | 8f4f279 | 2017-11-09 17:24:34 +0200 | [diff] [blame] | 6202 | switch (encoder->port) { |
Ander Conselvan de Oliveira | b71953a | 2017-02-03 16:03:14 +0200 | [diff] [blame] | 6203 | case PORT_A: |
Ander Conselvan de Oliveira | 5432fca | 2017-02-22 08:34:26 +0200 | [diff] [blame] | 6204 | intel_dp->aux_power_domain = POWER_DOMAIN_AUX_A; |
Ander Conselvan de Oliveira | b71953a | 2017-02-03 16:03:14 +0200 | [diff] [blame] | 6205 | break; |
| 6206 | case PORT_B: |
Ander Conselvan de Oliveira | 5432fca | 2017-02-22 08:34:26 +0200 | [diff] [blame] | 6207 | intel_dp->aux_power_domain = POWER_DOMAIN_AUX_B; |
Ander Conselvan de Oliveira | b71953a | 2017-02-03 16:03:14 +0200 | [diff] [blame] | 6208 | break; |
| 6209 | case PORT_C: |
Ander Conselvan de Oliveira | 5432fca | 2017-02-22 08:34:26 +0200 | [diff] [blame] | 6210 | intel_dp->aux_power_domain = POWER_DOMAIN_AUX_C; |
Ander Conselvan de Oliveira | b71953a | 2017-02-03 16:03:14 +0200 | [diff] [blame] | 6211 | break; |
| 6212 | case PORT_D: |
Ander Conselvan de Oliveira | 5432fca | 2017-02-22 08:34:26 +0200 | [diff] [blame] | 6213 | intel_dp->aux_power_domain = POWER_DOMAIN_AUX_D; |
Ander Conselvan de Oliveira | b71953a | 2017-02-03 16:03:14 +0200 | [diff] [blame] | 6214 | break; |
| 6215 | case PORT_E: |
Ander Conselvan de Oliveira | 5432fca | 2017-02-22 08:34:26 +0200 | [diff] [blame] | 6216 | /* FIXME: Check VBT for actual wiring of PORT E */ |
| 6217 | intel_dp->aux_power_domain = POWER_DOMAIN_AUX_D; |
Ander Conselvan de Oliveira | b71953a | 2017-02-03 16:03:14 +0200 | [diff] [blame] | 6218 | break; |
| 6219 | default: |
Ville Syrjälä | 8f4f279 | 2017-11-09 17:24:34 +0200 | [diff] [blame] | 6220 | MISSING_CASE(encoder->port); |
Ander Conselvan de Oliveira | b71953a | 2017-02-03 16:03:14 +0200 | [diff] [blame] | 6221 | } |
| 6222 | } |
| 6223 | |
Manasi Navare | 9301397 | 2017-04-06 16:44:19 +0300 | [diff] [blame] | 6224 | static void intel_dp_modeset_retry_work_fn(struct work_struct *work) |
| 6225 | { |
| 6226 | struct intel_connector *intel_connector; |
| 6227 | struct drm_connector *connector; |
| 6228 | |
| 6229 | intel_connector = container_of(work, typeof(*intel_connector), |
| 6230 | modeset_retry_work); |
| 6231 | connector = &intel_connector->base; |
| 6232 | DRM_DEBUG_KMS("[CONNECTOR:%d:%s]\n", connector->base.id, |
| 6233 | connector->name); |
| 6234 | |
| 6235 | /* Grab the locks before changing connector property*/ |
| 6236 | mutex_lock(&connector->dev->mode_config.mutex); |
| 6237 | /* Set connector link status to BAD and send a Uevent to notify |
| 6238 | * userspace to do a modeset. |
| 6239 | */ |
| 6240 | drm_mode_connector_set_link_status_property(connector, |
| 6241 | DRM_MODE_LINK_STATUS_BAD); |
| 6242 | mutex_unlock(&connector->dev->mode_config.mutex); |
| 6243 | /* Send Hotplug uevent so userspace can reprobe */ |
| 6244 | drm_kms_helper_hotplug_event(connector->dev); |
| 6245 | } |
| 6246 | |
Paulo Zanoni | 16c2553 | 2013-06-12 17:27:25 -0300 | [diff] [blame] | 6247 | bool |
Paulo Zanoni | f0fec3f | 2012-10-26 19:05:48 -0200 | [diff] [blame] | 6248 | intel_dp_init_connector(struct intel_digital_port *intel_dig_port, |
| 6249 | struct intel_connector *intel_connector) |
Keith Packard | a4fc5ed | 2009-04-07 16:16:42 -0700 | [diff] [blame] | 6250 | { |
Paulo Zanoni | f0fec3f | 2012-10-26 19:05:48 -0200 | [diff] [blame] | 6251 | struct drm_connector *connector = &intel_connector->base; |
| 6252 | struct intel_dp *intel_dp = &intel_dig_port->dp; |
| 6253 | struct intel_encoder *intel_encoder = &intel_dig_port->base; |
| 6254 | struct drm_device *dev = intel_encoder->base.dev; |
Chris Wilson | fac5e23 | 2016-07-04 11:34:36 +0100 | [diff] [blame] | 6255 | struct drm_i915_private *dev_priv = to_i915(dev); |
Ville Syrjälä | 8f4f279 | 2017-11-09 17:24:34 +0200 | [diff] [blame] | 6256 | enum port port = intel_encoder->port; |
Chris Wilson | 7a418e3 | 2016-06-24 14:00:14 +0100 | [diff] [blame] | 6257 | int type; |
Keith Packard | a4fc5ed | 2009-04-07 16:16:42 -0700 | [diff] [blame] | 6258 | |
Manasi Navare | 9301397 | 2017-04-06 16:44:19 +0300 | [diff] [blame] | 6259 | /* Initialize the work for modeset in case of link train failure */ |
| 6260 | INIT_WORK(&intel_connector->modeset_retry_work, |
| 6261 | intel_dp_modeset_retry_work_fn); |
| 6262 | |
Ville Syrjälä | ccb1a83 | 2015-12-08 19:59:38 +0200 | [diff] [blame] | 6263 | if (WARN(intel_dig_port->max_lanes < 1, |
| 6264 | "Not enough lanes (%d) for DP on port %c\n", |
| 6265 | intel_dig_port->max_lanes, port_name(port))) |
| 6266 | return false; |
| 6267 | |
Jani Nikula | 55cfc58 | 2017-03-28 17:59:04 +0300 | [diff] [blame] | 6268 | intel_dp_set_source_rates(intel_dp); |
| 6269 | |
Manasi Navare | d7e8ef0 | 2017-02-07 16:54:11 -0800 | [diff] [blame] | 6270 | intel_dp->reset_link_params = true; |
Ville Syrjälä | a4a5d2f | 2014-09-04 14:54:20 +0300 | [diff] [blame] | 6271 | intel_dp->pps_pipe = INVALID_PIPE; |
Ville Syrjälä | 9f2bdb0 | 2016-12-14 20:00:23 +0200 | [diff] [blame] | 6272 | intel_dp->active_pipe = INVALID_PIPE; |
Ville Syrjälä | a4a5d2f | 2014-09-04 14:54:20 +0300 | [diff] [blame] | 6273 | |
Damien Lespiau | ec5b01d | 2014-01-21 13:35:39 +0000 | [diff] [blame] | 6274 | /* intel_dp vfuncs */ |
Tvrtko Ursulin | dd11bc1 | 2016-11-16 08:55:41 +0000 | [diff] [blame] | 6275 | if (INTEL_GEN(dev_priv) >= 9) |
Damien Lespiau | b6b5e38 | 2014-01-20 16:00:59 +0000 | [diff] [blame] | 6276 | intel_dp->get_aux_clock_divider = skl_get_aux_clock_divider; |
Tvrtko Ursulin | 8652744 | 2016-10-13 11:03:00 +0100 | [diff] [blame] | 6277 | else if (IS_HASWELL(dev_priv) || IS_BROADWELL(dev_priv)) |
Damien Lespiau | ec5b01d | 2014-01-21 13:35:39 +0000 | [diff] [blame] | 6278 | intel_dp->get_aux_clock_divider = hsw_get_aux_clock_divider; |
Tvrtko Ursulin | 6e26695 | 2016-10-13 11:02:53 +0100 | [diff] [blame] | 6279 | else if (HAS_PCH_SPLIT(dev_priv)) |
Damien Lespiau | ec5b01d | 2014-01-21 13:35:39 +0000 | [diff] [blame] | 6280 | intel_dp->get_aux_clock_divider = ilk_get_aux_clock_divider; |
| 6281 | else |
Ville Syrjälä | 6ffb1be | 2016-03-02 17:22:14 +0200 | [diff] [blame] | 6282 | intel_dp->get_aux_clock_divider = g4x_get_aux_clock_divider; |
Damien Lespiau | ec5b01d | 2014-01-21 13:35:39 +0000 | [diff] [blame] | 6283 | |
Tvrtko Ursulin | dd11bc1 | 2016-11-16 08:55:41 +0000 | [diff] [blame] | 6284 | if (INTEL_GEN(dev_priv) >= 9) |
Damien Lespiau | b9ca5fa | 2014-01-20 16:01:00 +0000 | [diff] [blame] | 6285 | intel_dp->get_aux_send_ctl = skl_get_aux_send_ctl; |
| 6286 | else |
Ville Syrjälä | 6ffb1be | 2016-03-02 17:22:14 +0200 | [diff] [blame] | 6287 | intel_dp->get_aux_send_ctl = g4x_get_aux_send_ctl; |
Damien Lespiau | 153b110 | 2014-01-21 13:37:15 +0000 | [diff] [blame] | 6288 | |
Tvrtko Ursulin | 4f8036a | 2016-10-13 11:02:52 +0100 | [diff] [blame] | 6289 | if (HAS_DDI(dev_priv)) |
Ander Conselvan de Oliveira | ad64217 | 2015-10-23 13:01:49 +0300 | [diff] [blame] | 6290 | intel_dp->prepare_link_retrain = intel_ddi_prepare_link_retrain; |
| 6291 | |
Daniel Vetter | 0767935 | 2012-09-06 22:15:42 +0200 | [diff] [blame] | 6292 | /* Preserve the current hw state. */ |
| 6293 | intel_dp->DP = I915_READ(intel_dp->output_reg); |
Jani Nikula | dd06f90 | 2012-10-19 14:51:50 +0300 | [diff] [blame] | 6294 | intel_dp->attached_connector = intel_connector; |
Chris Wilson | 3d3dc14 | 2011-02-12 10:33:12 +0000 | [diff] [blame] | 6295 | |
Jani Nikula | 7b91bf7 | 2017-08-18 12:30:19 +0300 | [diff] [blame] | 6296 | if (intel_dp_is_port_edp(dev_priv, port)) |
Gajanan Bhat | 19c0392 | 2012-09-27 19:13:07 +0530 | [diff] [blame] | 6297 | type = DRM_MODE_CONNECTOR_eDP; |
Ville Syrjälä | 3b32a35 | 2013-11-01 18:22:41 +0200 | [diff] [blame] | 6298 | else |
| 6299 | type = DRM_MODE_CONNECTOR_DisplayPort; |
Adam Jackson | b329530 | 2010-07-16 14:46:28 -0400 | [diff] [blame] | 6300 | |
Ville Syrjälä | 9f2bdb0 | 2016-12-14 20:00:23 +0200 | [diff] [blame] | 6301 | if (IS_VALLEYVIEW(dev_priv) || IS_CHERRYVIEW(dev_priv)) |
| 6302 | intel_dp->active_pipe = vlv_active_pipe(intel_dp); |
| 6303 | |
Imre Deak | f7d2490 | 2013-05-08 13:14:05 +0300 | [diff] [blame] | 6304 | /* |
| 6305 | * For eDP we always set the encoder type to INTEL_OUTPUT_EDP, but |
| 6306 | * for DP the encoder type can be set by the caller to |
| 6307 | * INTEL_OUTPUT_UNKNOWN for DDI, so don't rewrite it. |
| 6308 | */ |
| 6309 | if (type == DRM_MODE_CONNECTOR_eDP) |
| 6310 | intel_encoder->type = INTEL_OUTPUT_EDP; |
| 6311 | |
Ville Syrjälä | c17ed5b | 2014-10-16 21:27:27 +0300 | [diff] [blame] | 6312 | /* eDP only on port B and/or C on vlv/chv */ |
Tvrtko Ursulin | 920a14b | 2016-10-14 10:13:44 +0100 | [diff] [blame] | 6313 | if (WARN_ON((IS_VALLEYVIEW(dev_priv) || IS_CHERRYVIEW(dev_priv)) && |
Jani Nikula | 1853a9d | 2017-08-18 12:30:20 +0300 | [diff] [blame] | 6314 | intel_dp_is_edp(intel_dp) && |
| 6315 | port != PORT_B && port != PORT_C)) |
Ville Syrjälä | c17ed5b | 2014-10-16 21:27:27 +0300 | [diff] [blame] | 6316 | return false; |
| 6317 | |
Imre Deak | e7281ea | 2013-05-08 13:14:08 +0300 | [diff] [blame] | 6318 | DRM_DEBUG_KMS("Adding %s connector on port %c\n", |
| 6319 | type == DRM_MODE_CONNECTOR_eDP ? "eDP" : "DP", |
| 6320 | port_name(port)); |
| 6321 | |
Adam Jackson | b329530 | 2010-07-16 14:46:28 -0400 | [diff] [blame] | 6322 | drm_connector_init(dev, connector, &intel_dp_connector_funcs, type); |
Keith Packard | a4fc5ed | 2009-04-07 16:16:42 -0700 | [diff] [blame] | 6323 | drm_connector_helper_add(connector, &intel_dp_connector_helper_funcs); |
| 6324 | |
Ville Syrjälä | 05021389 | 2017-11-29 20:08:47 +0200 | [diff] [blame] | 6325 | if (!IS_VALLEYVIEW(dev_priv) && !IS_CHERRYVIEW(dev_priv)) |
| 6326 | connector->interlace_allowed = true; |
Paulo Zanoni | f0fec3f | 2012-10-26 19:05:48 -0200 | [diff] [blame] | 6327 | connector->doublescan_allowed = 0; |
Ma Ling | f8aed70 | 2009-08-24 13:50:24 +0800 | [diff] [blame] | 6328 | |
Ander Conselvan de Oliveira | 5432fca | 2017-02-22 08:34:26 +0200 | [diff] [blame] | 6329 | intel_dp_init_connector_port_info(intel_dig_port); |
| 6330 | |
Mika Kahola | b633958 | 2016-09-09 14:10:52 +0300 | [diff] [blame] | 6331 | intel_dp_aux_init(intel_dp); |
Chris Wilson | 7a418e3 | 2016-06-24 14:00:14 +0100 | [diff] [blame] | 6332 | |
Daniel Vetter | 66a9278 | 2012-07-12 20:08:18 +0200 | [diff] [blame] | 6333 | INIT_DELAYED_WORK(&intel_dp->panel_vdd_work, |
Daniel Vetter | 4be7378 | 2014-01-17 14:39:48 +0100 | [diff] [blame] | 6334 | edp_panel_vdd_work); |
Zhenyu Wang | 6251ec0 | 2010-01-12 05:38:32 +0800 | [diff] [blame] | 6335 | |
Chris Wilson | df0e924 | 2010-09-09 16:20:55 +0100 | [diff] [blame] | 6336 | intel_connector_attach_encoder(intel_connector, intel_encoder); |
Keith Packard | a4fc5ed | 2009-04-07 16:16:42 -0700 | [diff] [blame] | 6337 | |
Tvrtko Ursulin | 4f8036a | 2016-10-13 11:02:52 +0100 | [diff] [blame] | 6338 | if (HAS_DDI(dev_priv)) |
Paulo Zanoni | bcbc889 | 2012-10-26 19:05:51 -0200 | [diff] [blame] | 6339 | intel_connector->get_hw_state = intel_ddi_connector_get_hw_state; |
| 6340 | else |
| 6341 | intel_connector->get_hw_state = intel_connector_get_hw_state; |
| 6342 | |
Dave Airlie | 0e32b39 | 2014-05-02 14:02:48 +1000 | [diff] [blame] | 6343 | /* init MST on ports that can support it */ |
Jani Nikula | 1853a9d | 2017-08-18 12:30:20 +0300 | [diff] [blame] | 6344 | if (HAS_DP_MST(dev_priv) && !intel_dp_is_edp(intel_dp) && |
Jani Nikula | 0c9b371 | 2015-05-18 17:10:01 +0300 | [diff] [blame] | 6345 | (port == PORT_B || port == PORT_C || port == PORT_D)) |
| 6346 | intel_dp_mst_encoder_init(intel_dig_port, |
| 6347 | intel_connector->base.base.id); |
Dave Airlie | 0e32b39 | 2014-05-02 14:02:48 +1000 | [diff] [blame] | 6348 | |
Ville Syrjälä | 36b5f42 | 2014-10-16 21:27:30 +0300 | [diff] [blame] | 6349 | if (!intel_edp_init_connector(intel_dp, intel_connector)) { |
Ville Syrjälä | a121f4e | 2015-11-11 20:34:11 +0200 | [diff] [blame] | 6350 | intel_dp_aux_fini(intel_dp); |
| 6351 | intel_dp_mst_encoder_cleanup(intel_dig_port); |
| 6352 | goto fail; |
Paulo Zanoni | b2f246a | 2013-06-12 17:27:26 -0300 | [diff] [blame] | 6353 | } |
Zhenyu Wang | 32f9d65 | 2009-07-24 01:00:32 +0800 | [diff] [blame] | 6354 | |
Chris Wilson | f684960 | 2010-09-19 09:29:33 +0100 | [diff] [blame] | 6355 | intel_dp_add_properties(intel_dp, connector); |
| 6356 | |
Sean Paul | 20f24d7 | 2018-01-08 14:55:43 -0500 | [diff] [blame] | 6357 | if (INTEL_GEN(dev_priv) >= 9 && !intel_dp_is_edp(intel_dp)) { |
| 6358 | int ret = intel_hdcp_init(intel_connector, &intel_dp_hdcp_shim); |
| 6359 | if (ret) |
| 6360 | DRM_DEBUG_KMS("HDCP init failed, skipping.\n"); |
| 6361 | } |
| 6362 | |
Keith Packard | a4fc5ed | 2009-04-07 16:16:42 -0700 | [diff] [blame] | 6363 | /* For G4X desktop chip, PEG_BAND_GAP_DATA 3:0 must first be written |
| 6364 | * 0xd. Failure to do so will result in spurious interrupts being |
| 6365 | * generated on the port when a cable is not attached. |
| 6366 | */ |
Tvrtko Ursulin | 50a0bc9 | 2016-10-13 11:02:58 +0100 | [diff] [blame] | 6367 | if (IS_G4X(dev_priv) && !IS_GM45(dev_priv)) { |
Keith Packard | a4fc5ed | 2009-04-07 16:16:42 -0700 | [diff] [blame] | 6368 | u32 temp = I915_READ(PEG_BAND_GAP_DATA); |
| 6369 | I915_WRITE(PEG_BAND_GAP_DATA, (temp & ~0xf) | 0xd); |
| 6370 | } |
Paulo Zanoni | 16c2553 | 2013-06-12 17:27:25 -0300 | [diff] [blame] | 6371 | |
| 6372 | return true; |
Ville Syrjälä | a121f4e | 2015-11-11 20:34:11 +0200 | [diff] [blame] | 6373 | |
| 6374 | fail: |
Ville Syrjälä | a121f4e | 2015-11-11 20:34:11 +0200 | [diff] [blame] | 6375 | drm_connector_cleanup(connector); |
| 6376 | |
| 6377 | return false; |
Keith Packard | a4fc5ed | 2009-04-07 16:16:42 -0700 | [diff] [blame] | 6378 | } |
Paulo Zanoni | f0fec3f | 2012-10-26 19:05:48 -0200 | [diff] [blame] | 6379 | |
Ander Conselvan de Oliveira | c39055b | 2016-11-23 16:21:44 +0200 | [diff] [blame] | 6380 | bool intel_dp_init(struct drm_i915_private *dev_priv, |
Chris Wilson | 457c52d | 2016-06-01 08:27:50 +0100 | [diff] [blame] | 6381 | i915_reg_t output_reg, |
| 6382 | enum port port) |
Paulo Zanoni | f0fec3f | 2012-10-26 19:05:48 -0200 | [diff] [blame] | 6383 | { |
| 6384 | struct intel_digital_port *intel_dig_port; |
| 6385 | struct intel_encoder *intel_encoder; |
| 6386 | struct drm_encoder *encoder; |
| 6387 | struct intel_connector *intel_connector; |
| 6388 | |
Daniel Vetter | b14c567 | 2013-09-19 12:18:32 +0200 | [diff] [blame] | 6389 | intel_dig_port = kzalloc(sizeof(*intel_dig_port), GFP_KERNEL); |
Paulo Zanoni | f0fec3f | 2012-10-26 19:05:48 -0200 | [diff] [blame] | 6390 | if (!intel_dig_port) |
Chris Wilson | 457c52d | 2016-06-01 08:27:50 +0100 | [diff] [blame] | 6391 | return false; |
Paulo Zanoni | f0fec3f | 2012-10-26 19:05:48 -0200 | [diff] [blame] | 6392 | |
Ander Conselvan de Oliveira | 08d9bc9 | 2015-04-10 10:59:10 +0300 | [diff] [blame] | 6393 | intel_connector = intel_connector_alloc(); |
Sudip Mukherjee | 11aee0f | 2015-10-08 19:27:59 +0530 | [diff] [blame] | 6394 | if (!intel_connector) |
| 6395 | goto err_connector_alloc; |
Paulo Zanoni | f0fec3f | 2012-10-26 19:05:48 -0200 | [diff] [blame] | 6396 | |
| 6397 | intel_encoder = &intel_dig_port->base; |
| 6398 | encoder = &intel_encoder->base; |
| 6399 | |
Ander Conselvan de Oliveira | c39055b | 2016-11-23 16:21:44 +0200 | [diff] [blame] | 6400 | if (drm_encoder_init(&dev_priv->drm, &intel_encoder->base, |
| 6401 | &intel_dp_enc_funcs, DRM_MODE_ENCODER_TMDS, |
| 6402 | "DP %c", port_name(port))) |
Sudip Mukherjee | 893da0c | 2015-10-08 19:28:00 +0530 | [diff] [blame] | 6403 | goto err_encoder_init; |
Paulo Zanoni | f0fec3f | 2012-10-26 19:05:48 -0200 | [diff] [blame] | 6404 | |
Daniel Vetter | 5bfe2ac | 2013-03-27 00:44:55 +0100 | [diff] [blame] | 6405 | intel_encoder->compute_config = intel_dp_compute_config; |
Paulo Zanoni | 00c09d7 | 2012-10-26 19:05:52 -0200 | [diff] [blame] | 6406 | intel_encoder->get_hw_state = intel_dp_get_hw_state; |
Jesse Barnes | 045ac3b | 2013-05-14 17:08:26 -0700 | [diff] [blame] | 6407 | intel_encoder->get_config = intel_dp_get_config; |
Imre Deak | 07f9cd0 | 2014-08-18 14:42:45 +0300 | [diff] [blame] | 6408 | intel_encoder->suspend = intel_dp_encoder_suspend; |
Tvrtko Ursulin | 920a14b | 2016-10-14 10:13:44 +0100 | [diff] [blame] | 6409 | if (IS_CHERRYVIEW(dev_priv)) { |
Ville Syrjälä | 9197c88 | 2014-04-09 13:29:05 +0300 | [diff] [blame] | 6410 | intel_encoder->pre_pll_enable = chv_dp_pre_pll_enable; |
Chon Ming Lee | e4a1d84 | 2014-04-09 13:28:20 +0300 | [diff] [blame] | 6411 | intel_encoder->pre_enable = chv_pre_enable_dp; |
| 6412 | intel_encoder->enable = vlv_enable_dp; |
Ville Syrjälä | 1a8ff60 | 2017-09-20 18:12:51 +0300 | [diff] [blame] | 6413 | intel_encoder->disable = vlv_disable_dp; |
Ville Syrjälä | 580d381 | 2014-04-09 13:29:00 +0300 | [diff] [blame] | 6414 | intel_encoder->post_disable = chv_post_disable_dp; |
Ville Syrjälä | d6db995 | 2015-07-08 23:45:49 +0300 | [diff] [blame] | 6415 | intel_encoder->post_pll_disable = chv_dp_post_pll_disable; |
Tvrtko Ursulin | 11a914c | 2016-10-13 11:03:08 +0100 | [diff] [blame] | 6416 | } else if (IS_VALLEYVIEW(dev_priv)) { |
Jani Nikula | ecff4f3 | 2013-09-06 07:38:29 +0300 | [diff] [blame] | 6417 | intel_encoder->pre_pll_enable = vlv_dp_pre_pll_enable; |
Jani Nikula | ab1f90f | 2013-07-30 12:20:30 +0300 | [diff] [blame] | 6418 | intel_encoder->pre_enable = vlv_pre_enable_dp; |
| 6419 | intel_encoder->enable = vlv_enable_dp; |
Ville Syrjälä | 1a8ff60 | 2017-09-20 18:12:51 +0300 | [diff] [blame] | 6420 | intel_encoder->disable = vlv_disable_dp; |
Ville Syrjälä | 49277c3 | 2014-03-31 18:21:26 +0300 | [diff] [blame] | 6421 | intel_encoder->post_disable = vlv_post_disable_dp; |
Ville Syrjälä | 1a8ff60 | 2017-09-20 18:12:51 +0300 | [diff] [blame] | 6422 | } else if (INTEL_GEN(dev_priv) >= 5) { |
| 6423 | intel_encoder->pre_enable = g4x_pre_enable_dp; |
| 6424 | intel_encoder->enable = g4x_enable_dp; |
| 6425 | intel_encoder->disable = ilk_disable_dp; |
| 6426 | intel_encoder->post_disable = ilk_post_disable_dp; |
Jani Nikula | ab1f90f | 2013-07-30 12:20:30 +0300 | [diff] [blame] | 6427 | } else { |
Jani Nikula | ecff4f3 | 2013-09-06 07:38:29 +0300 | [diff] [blame] | 6428 | intel_encoder->pre_enable = g4x_pre_enable_dp; |
| 6429 | intel_encoder->enable = g4x_enable_dp; |
Ville Syrjälä | 1a8ff60 | 2017-09-20 18:12:51 +0300 | [diff] [blame] | 6430 | intel_encoder->disable = g4x_disable_dp; |
Jani Nikula | ab1f90f | 2013-07-30 12:20:30 +0300 | [diff] [blame] | 6431 | } |
Paulo Zanoni | f0fec3f | 2012-10-26 19:05:48 -0200 | [diff] [blame] | 6432 | |
Paulo Zanoni | f0fec3f | 2012-10-26 19:05:48 -0200 | [diff] [blame] | 6433 | intel_dig_port->dp.output_reg = output_reg; |
Ville Syrjälä | ccb1a83 | 2015-12-08 19:59:38 +0200 | [diff] [blame] | 6434 | intel_dig_port->max_lanes = 4; |
Paulo Zanoni | f0fec3f | 2012-10-26 19:05:48 -0200 | [diff] [blame] | 6435 | |
Ville Syrjälä | cca0502 | 2016-06-22 21:57:06 +0300 | [diff] [blame] | 6436 | intel_encoder->type = INTEL_OUTPUT_DP; |
Ander Conselvan de Oliveira | 79f255a | 2017-02-22 08:34:27 +0200 | [diff] [blame] | 6437 | intel_encoder->power_domain = intel_port_to_power_domain(port); |
Tvrtko Ursulin | 920a14b | 2016-10-14 10:13:44 +0100 | [diff] [blame] | 6438 | if (IS_CHERRYVIEW(dev_priv)) { |
Ville Syrjälä | 882ec38 | 2014-04-28 14:07:43 +0300 | [diff] [blame] | 6439 | if (port == PORT_D) |
| 6440 | intel_encoder->crtc_mask = 1 << 2; |
| 6441 | else |
| 6442 | intel_encoder->crtc_mask = (1 << 0) | (1 << 1); |
| 6443 | } else { |
| 6444 | intel_encoder->crtc_mask = (1 << 0) | (1 << 1) | (1 << 2); |
| 6445 | } |
Ville Syrjälä | bc079e8 | 2014-03-03 16:15:28 +0200 | [diff] [blame] | 6446 | intel_encoder->cloneable = 0; |
Pandiyan, Dhinakaran | 03cdc1d | 2016-09-19 18:24:38 -0700 | [diff] [blame] | 6447 | intel_encoder->port = port; |
Paulo Zanoni | f0fec3f | 2012-10-26 19:05:48 -0200 | [diff] [blame] | 6448 | |
Dave Airlie | 13cf550 | 2014-06-18 11:29:35 +1000 | [diff] [blame] | 6449 | intel_dig_port->hpd_pulse = intel_dp_hpd_pulse; |
Jani Nikula | 5fcece8 | 2015-05-27 15:03:42 +0300 | [diff] [blame] | 6450 | dev_priv->hotplug.irq_port[port] = intel_dig_port; |
Dave Airlie | 13cf550 | 2014-06-18 11:29:35 +1000 | [diff] [blame] | 6451 | |
Ville Syrjälä | 385e4de | 2017-08-18 16:49:55 +0300 | [diff] [blame] | 6452 | if (port != PORT_A) |
| 6453 | intel_infoframe_init(intel_dig_port); |
| 6454 | |
Sudip Mukherjee | 11aee0f | 2015-10-08 19:27:59 +0530 | [diff] [blame] | 6455 | if (!intel_dp_init_connector(intel_dig_port, intel_connector)) |
| 6456 | goto err_init_connector; |
| 6457 | |
Chris Wilson | 457c52d | 2016-06-01 08:27:50 +0100 | [diff] [blame] | 6458 | return true; |
Sudip Mukherjee | 11aee0f | 2015-10-08 19:27:59 +0530 | [diff] [blame] | 6459 | |
| 6460 | err_init_connector: |
| 6461 | drm_encoder_cleanup(encoder); |
Sudip Mukherjee | 893da0c | 2015-10-08 19:28:00 +0530 | [diff] [blame] | 6462 | err_encoder_init: |
Sudip Mukherjee | 11aee0f | 2015-10-08 19:27:59 +0530 | [diff] [blame] | 6463 | kfree(intel_connector); |
| 6464 | err_connector_alloc: |
| 6465 | kfree(intel_dig_port); |
Chris Wilson | 457c52d | 2016-06-01 08:27:50 +0100 | [diff] [blame] | 6466 | return false; |
Paulo Zanoni | f0fec3f | 2012-10-26 19:05:48 -0200 | [diff] [blame] | 6467 | } |
Dave Airlie | 0e32b39 | 2014-05-02 14:02:48 +1000 | [diff] [blame] | 6468 | |
| 6469 | void intel_dp_mst_suspend(struct drm_device *dev) |
| 6470 | { |
Chris Wilson | fac5e23 | 2016-07-04 11:34:36 +0100 | [diff] [blame] | 6471 | struct drm_i915_private *dev_priv = to_i915(dev); |
Dave Airlie | 0e32b39 | 2014-05-02 14:02:48 +1000 | [diff] [blame] | 6472 | int i; |
| 6473 | |
| 6474 | /* disable MST */ |
| 6475 | for (i = 0; i < I915_MAX_PORTS; i++) { |
Jani Nikula | 5fcece8 | 2015-05-27 15:03:42 +0300 | [diff] [blame] | 6476 | struct intel_digital_port *intel_dig_port = dev_priv->hotplug.irq_port[i]; |
Ville Syrjälä | 5aa5696 | 2016-06-22 21:57:00 +0300 | [diff] [blame] | 6477 | |
| 6478 | if (!intel_dig_port || !intel_dig_port->dp.can_mst) |
Dave Airlie | 0e32b39 | 2014-05-02 14:02:48 +1000 | [diff] [blame] | 6479 | continue; |
| 6480 | |
Ville Syrjälä | 5aa5696 | 2016-06-22 21:57:00 +0300 | [diff] [blame] | 6481 | if (intel_dig_port->dp.is_mst) |
| 6482 | drm_dp_mst_topology_mgr_suspend(&intel_dig_port->dp.mst_mgr); |
Dave Airlie | 0e32b39 | 2014-05-02 14:02:48 +1000 | [diff] [blame] | 6483 | } |
| 6484 | } |
| 6485 | |
| 6486 | void intel_dp_mst_resume(struct drm_device *dev) |
| 6487 | { |
Chris Wilson | fac5e23 | 2016-07-04 11:34:36 +0100 | [diff] [blame] | 6488 | struct drm_i915_private *dev_priv = to_i915(dev); |
Dave Airlie | 0e32b39 | 2014-05-02 14:02:48 +1000 | [diff] [blame] | 6489 | int i; |
| 6490 | |
| 6491 | for (i = 0; i < I915_MAX_PORTS; i++) { |
Jani Nikula | 5fcece8 | 2015-05-27 15:03:42 +0300 | [diff] [blame] | 6492 | struct intel_digital_port *intel_dig_port = dev_priv->hotplug.irq_port[i]; |
Ville Syrjälä | 5aa5696 | 2016-06-22 21:57:00 +0300 | [diff] [blame] | 6493 | int ret; |
| 6494 | |
| 6495 | if (!intel_dig_port || !intel_dig_port->dp.can_mst) |
Dave Airlie | 0e32b39 | 2014-05-02 14:02:48 +1000 | [diff] [blame] | 6496 | continue; |
Dave Airlie | 0e32b39 | 2014-05-02 14:02:48 +1000 | [diff] [blame] | 6497 | |
Ville Syrjälä | 5aa5696 | 2016-06-22 21:57:00 +0300 | [diff] [blame] | 6498 | ret = drm_dp_mst_topology_mgr_resume(&intel_dig_port->dp.mst_mgr); |
| 6499 | if (ret) |
| 6500 | intel_dp_check_mst_status(&intel_dig_port->dp); |
Dave Airlie | 0e32b39 | 2014-05-02 14:02:48 +1000 | [diff] [blame] | 6501 | } |
| 6502 | } |