Eugeni Dodonov | 45244b8 | 2012-05-09 15:37:20 -0300 | [diff] [blame] | 1 | /* |
| 2 | * Copyright © 2012 Intel Corporation |
| 3 | * |
| 4 | * Permission is hereby granted, free of charge, to any person obtaining a |
| 5 | * copy of this software and associated documentation files (the "Software"), |
| 6 | * to deal in the Software without restriction, including without limitation |
| 7 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, |
| 8 | * and/or sell copies of the Software, and to permit persons to whom the |
| 9 | * Software is furnished to do so, subject to the following conditions: |
| 10 | * |
| 11 | * The above copyright notice and this permission notice (including the next |
| 12 | * paragraph) shall be included in all copies or substantial portions of the |
| 13 | * Software. |
| 14 | * |
| 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
| 18 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
| 20 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS |
| 21 | * IN THE SOFTWARE. |
| 22 | * |
| 23 | * Authors: |
| 24 | * Eugeni Dodonov <eugeni.dodonov@intel.com> |
| 25 | * |
| 26 | */ |
| 27 | |
| 28 | #include "i915_drv.h" |
| 29 | #include "intel_drv.h" |
| 30 | |
Jani Nikula | 1012205 | 2014-08-27 16:27:30 +0300 | [diff] [blame] | 31 | struct ddi_buf_trans { |
| 32 | u32 trans1; /* balance leg enable, de-emph level */ |
| 33 | u32 trans2; /* vref sel, vswing */ |
David Weinehall | f8896f5 | 2015-06-25 11:11:03 +0300 | [diff] [blame] | 34 | u8 i_boost; /* SKL: I_boost; valid: 0x0, 0x1, 0x3, 0x7 */ |
Jani Nikula | 1012205 | 2014-08-27 16:27:30 +0300 | [diff] [blame] | 35 | }; |
| 36 | |
Ville Syrjälä | 97eeb87 | 2017-02-23 19:35:06 +0200 | [diff] [blame] | 37 | static const u8 index_to_dp_signal_levels[] = { |
| 38 | [0] = DP_TRAIN_VOLTAGE_SWING_LEVEL_0 | DP_TRAIN_PRE_EMPH_LEVEL_0, |
| 39 | [1] = DP_TRAIN_VOLTAGE_SWING_LEVEL_0 | DP_TRAIN_PRE_EMPH_LEVEL_1, |
| 40 | [2] = DP_TRAIN_VOLTAGE_SWING_LEVEL_0 | DP_TRAIN_PRE_EMPH_LEVEL_2, |
| 41 | [3] = DP_TRAIN_VOLTAGE_SWING_LEVEL_0 | DP_TRAIN_PRE_EMPH_LEVEL_3, |
| 42 | [4] = DP_TRAIN_VOLTAGE_SWING_LEVEL_1 | DP_TRAIN_PRE_EMPH_LEVEL_0, |
| 43 | [5] = DP_TRAIN_VOLTAGE_SWING_LEVEL_1 | DP_TRAIN_PRE_EMPH_LEVEL_1, |
| 44 | [6] = DP_TRAIN_VOLTAGE_SWING_LEVEL_1 | DP_TRAIN_PRE_EMPH_LEVEL_2, |
| 45 | [7] = DP_TRAIN_VOLTAGE_SWING_LEVEL_2 | DP_TRAIN_PRE_EMPH_LEVEL_0, |
| 46 | [8] = DP_TRAIN_VOLTAGE_SWING_LEVEL_2 | DP_TRAIN_PRE_EMPH_LEVEL_1, |
| 47 | [9] = DP_TRAIN_VOLTAGE_SWING_LEVEL_3 | DP_TRAIN_PRE_EMPH_LEVEL_0, |
| 48 | }; |
| 49 | |
Eugeni Dodonov | 45244b8 | 2012-05-09 15:37:20 -0300 | [diff] [blame] | 50 | /* HDMI/DVI modes ignore everything but the last 2 items. So we share |
| 51 | * them for both DP and FDI transports, allowing those ports to |
| 52 | * automatically adapt to HDMI connections as well |
| 53 | */ |
Jani Nikula | 1012205 | 2014-08-27 16:27:30 +0300 | [diff] [blame] | 54 | static const struct ddi_buf_trans hsw_ddi_translations_dp[] = { |
David Weinehall | f8896f5 | 2015-06-25 11:11:03 +0300 | [diff] [blame] | 55 | { 0x00FFFFFF, 0x0006000E, 0x0 }, |
| 56 | { 0x00D75FFF, 0x0005000A, 0x0 }, |
| 57 | { 0x00C30FFF, 0x00040006, 0x0 }, |
| 58 | { 0x80AAAFFF, 0x000B0000, 0x0 }, |
| 59 | { 0x00FFFFFF, 0x0005000A, 0x0 }, |
| 60 | { 0x00D75FFF, 0x000C0004, 0x0 }, |
| 61 | { 0x80C30FFF, 0x000B0000, 0x0 }, |
| 62 | { 0x00FFFFFF, 0x00040006, 0x0 }, |
| 63 | { 0x80D75FFF, 0x000B0000, 0x0 }, |
Eugeni Dodonov | 45244b8 | 2012-05-09 15:37:20 -0300 | [diff] [blame] | 64 | }; |
| 65 | |
Jani Nikula | 1012205 | 2014-08-27 16:27:30 +0300 | [diff] [blame] | 66 | static const struct ddi_buf_trans hsw_ddi_translations_fdi[] = { |
David Weinehall | f8896f5 | 2015-06-25 11:11:03 +0300 | [diff] [blame] | 67 | { 0x00FFFFFF, 0x0007000E, 0x0 }, |
| 68 | { 0x00D75FFF, 0x000F000A, 0x0 }, |
| 69 | { 0x00C30FFF, 0x00060006, 0x0 }, |
| 70 | { 0x00AAAFFF, 0x001E0000, 0x0 }, |
| 71 | { 0x00FFFFFF, 0x000F000A, 0x0 }, |
| 72 | { 0x00D75FFF, 0x00160004, 0x0 }, |
| 73 | { 0x00C30FFF, 0x001E0000, 0x0 }, |
| 74 | { 0x00FFFFFF, 0x00060006, 0x0 }, |
| 75 | { 0x00D75FFF, 0x001E0000, 0x0 }, |
Paulo Zanoni | 6acab15 | 2013-09-12 17:06:24 -0300 | [diff] [blame] | 76 | }; |
| 77 | |
Jani Nikula | 1012205 | 2014-08-27 16:27:30 +0300 | [diff] [blame] | 78 | static const struct ddi_buf_trans hsw_ddi_translations_hdmi[] = { |
| 79 | /* Idx NT mV d T mV d db */ |
David Weinehall | f8896f5 | 2015-06-25 11:11:03 +0300 | [diff] [blame] | 80 | { 0x00FFFFFF, 0x0006000E, 0x0 },/* 0: 400 400 0 */ |
| 81 | { 0x00E79FFF, 0x000E000C, 0x0 },/* 1: 400 500 2 */ |
| 82 | { 0x00D75FFF, 0x0005000A, 0x0 },/* 2: 400 600 3.5 */ |
| 83 | { 0x00FFFFFF, 0x0005000A, 0x0 },/* 3: 600 600 0 */ |
| 84 | { 0x00E79FFF, 0x001D0007, 0x0 },/* 4: 600 750 2 */ |
| 85 | { 0x00D75FFF, 0x000C0004, 0x0 },/* 5: 600 900 3.5 */ |
| 86 | { 0x00FFFFFF, 0x00040006, 0x0 },/* 6: 800 800 0 */ |
| 87 | { 0x80E79FFF, 0x00030002, 0x0 },/* 7: 800 1000 2 */ |
| 88 | { 0x00FFFFFF, 0x00140005, 0x0 },/* 8: 850 850 0 */ |
| 89 | { 0x00FFFFFF, 0x000C0004, 0x0 },/* 9: 900 900 0 */ |
| 90 | { 0x00FFFFFF, 0x001C0003, 0x0 },/* 10: 950 950 0 */ |
| 91 | { 0x80FFFFFF, 0x00030002, 0x0 },/* 11: 1000 1000 0 */ |
Eugeni Dodonov | 45244b8 | 2012-05-09 15:37:20 -0300 | [diff] [blame] | 92 | }; |
| 93 | |
Jani Nikula | 1012205 | 2014-08-27 16:27:30 +0300 | [diff] [blame] | 94 | static const struct ddi_buf_trans bdw_ddi_translations_edp[] = { |
David Weinehall | f8896f5 | 2015-06-25 11:11:03 +0300 | [diff] [blame] | 95 | { 0x00FFFFFF, 0x00000012, 0x0 }, |
| 96 | { 0x00EBAFFF, 0x00020011, 0x0 }, |
| 97 | { 0x00C71FFF, 0x0006000F, 0x0 }, |
| 98 | { 0x00AAAFFF, 0x000E000A, 0x0 }, |
| 99 | { 0x00FFFFFF, 0x00020011, 0x0 }, |
| 100 | { 0x00DB6FFF, 0x0005000F, 0x0 }, |
| 101 | { 0x00BEEFFF, 0x000A000C, 0x0 }, |
| 102 | { 0x00FFFFFF, 0x0005000F, 0x0 }, |
| 103 | { 0x00DB6FFF, 0x000A000C, 0x0 }, |
Paulo Zanoni | 300644c | 2013-11-02 21:07:42 -0700 | [diff] [blame] | 104 | }; |
| 105 | |
Jani Nikula | 1012205 | 2014-08-27 16:27:30 +0300 | [diff] [blame] | 106 | static const struct ddi_buf_trans bdw_ddi_translations_dp[] = { |
David Weinehall | f8896f5 | 2015-06-25 11:11:03 +0300 | [diff] [blame] | 107 | { 0x00FFFFFF, 0x0007000E, 0x0 }, |
| 108 | { 0x00D75FFF, 0x000E000A, 0x0 }, |
| 109 | { 0x00BEFFFF, 0x00140006, 0x0 }, |
| 110 | { 0x80B2CFFF, 0x001B0002, 0x0 }, |
| 111 | { 0x00FFFFFF, 0x000E000A, 0x0 }, |
| 112 | { 0x00DB6FFF, 0x00160005, 0x0 }, |
| 113 | { 0x80C71FFF, 0x001A0002, 0x0 }, |
| 114 | { 0x00F7DFFF, 0x00180004, 0x0 }, |
| 115 | { 0x80D75FFF, 0x001B0002, 0x0 }, |
Art Runyan | e58623c | 2013-11-02 21:07:41 -0700 | [diff] [blame] | 116 | }; |
| 117 | |
Jani Nikula | 1012205 | 2014-08-27 16:27:30 +0300 | [diff] [blame] | 118 | static const struct ddi_buf_trans bdw_ddi_translations_fdi[] = { |
David Weinehall | f8896f5 | 2015-06-25 11:11:03 +0300 | [diff] [blame] | 119 | { 0x00FFFFFF, 0x0001000E, 0x0 }, |
| 120 | { 0x00D75FFF, 0x0004000A, 0x0 }, |
| 121 | { 0x00C30FFF, 0x00070006, 0x0 }, |
| 122 | { 0x00AAAFFF, 0x000C0000, 0x0 }, |
| 123 | { 0x00FFFFFF, 0x0004000A, 0x0 }, |
| 124 | { 0x00D75FFF, 0x00090004, 0x0 }, |
| 125 | { 0x00C30FFF, 0x000C0000, 0x0 }, |
| 126 | { 0x00FFFFFF, 0x00070006, 0x0 }, |
| 127 | { 0x00D75FFF, 0x000C0000, 0x0 }, |
Art Runyan | e58623c | 2013-11-02 21:07:41 -0700 | [diff] [blame] | 128 | }; |
| 129 | |
Jani Nikula | 1012205 | 2014-08-27 16:27:30 +0300 | [diff] [blame] | 130 | static const struct ddi_buf_trans bdw_ddi_translations_hdmi[] = { |
| 131 | /* Idx NT mV d T mV df db */ |
David Weinehall | f8896f5 | 2015-06-25 11:11:03 +0300 | [diff] [blame] | 132 | { 0x00FFFFFF, 0x0007000E, 0x0 },/* 0: 400 400 0 */ |
| 133 | { 0x00D75FFF, 0x000E000A, 0x0 },/* 1: 400 600 3.5 */ |
| 134 | { 0x00BEFFFF, 0x00140006, 0x0 },/* 2: 400 800 6 */ |
| 135 | { 0x00FFFFFF, 0x0009000D, 0x0 },/* 3: 450 450 0 */ |
| 136 | { 0x00FFFFFF, 0x000E000A, 0x0 },/* 4: 600 600 0 */ |
| 137 | { 0x00D7FFFF, 0x00140006, 0x0 },/* 5: 600 800 2.5 */ |
| 138 | { 0x80CB2FFF, 0x001B0002, 0x0 },/* 6: 600 1000 4.5 */ |
| 139 | { 0x00FFFFFF, 0x00140006, 0x0 },/* 7: 800 800 0 */ |
| 140 | { 0x80E79FFF, 0x001B0002, 0x0 },/* 8: 800 1000 2 */ |
| 141 | { 0x80FFFFFF, 0x001B0002, 0x0 },/* 9: 1000 1000 0 */ |
Damien Lespiau | a26aa8b | 2014-08-01 11:07:55 +0100 | [diff] [blame] | 142 | }; |
| 143 | |
Rodrigo Vivi | 5f8b253 | 2015-08-24 16:48:44 -0700 | [diff] [blame] | 144 | /* Skylake H and S */ |
Damien Lespiau | 7f88e3a | 2013-12-03 13:56:25 +0000 | [diff] [blame] | 145 | static const struct ddi_buf_trans skl_ddi_translations_dp[] = { |
David Weinehall | f8896f5 | 2015-06-25 11:11:03 +0300 | [diff] [blame] | 146 | { 0x00002016, 0x000000A0, 0x0 }, |
| 147 | { 0x00005012, 0x0000009B, 0x0 }, |
| 148 | { 0x00007011, 0x00000088, 0x0 }, |
Rodrigo Vivi | d7097cf | 2016-01-05 11:18:55 -0800 | [diff] [blame] | 149 | { 0x80009010, 0x000000C0, 0x1 }, |
David Weinehall | f8896f5 | 2015-06-25 11:11:03 +0300 | [diff] [blame] | 150 | { 0x00002016, 0x0000009B, 0x0 }, |
| 151 | { 0x00005012, 0x00000088, 0x0 }, |
Rodrigo Vivi | d7097cf | 2016-01-05 11:18:55 -0800 | [diff] [blame] | 152 | { 0x80007011, 0x000000C0, 0x1 }, |
David Weinehall | f8896f5 | 2015-06-25 11:11:03 +0300 | [diff] [blame] | 153 | { 0x00002016, 0x000000DF, 0x0 }, |
Rodrigo Vivi | d7097cf | 2016-01-05 11:18:55 -0800 | [diff] [blame] | 154 | { 0x80005012, 0x000000C0, 0x1 }, |
Damien Lespiau | 7f88e3a | 2013-12-03 13:56:25 +0000 | [diff] [blame] | 155 | }; |
| 156 | |
David Weinehall | f8896f5 | 2015-06-25 11:11:03 +0300 | [diff] [blame] | 157 | /* Skylake U */ |
| 158 | static const struct ddi_buf_trans skl_u_ddi_translations_dp[] = { |
Rodrigo Vivi | 5f8b253 | 2015-08-24 16:48:44 -0700 | [diff] [blame] | 159 | { 0x0000201B, 0x000000A2, 0x0 }, |
David Weinehall | f8896f5 | 2015-06-25 11:11:03 +0300 | [diff] [blame] | 160 | { 0x00005012, 0x00000088, 0x0 }, |
Ville Syrjälä | 5ac9056 | 2016-08-02 15:21:57 +0300 | [diff] [blame] | 161 | { 0x80007011, 0x000000CD, 0x1 }, |
Rodrigo Vivi | d7097cf | 2016-01-05 11:18:55 -0800 | [diff] [blame] | 162 | { 0x80009010, 0x000000C0, 0x1 }, |
Rodrigo Vivi | 5f8b253 | 2015-08-24 16:48:44 -0700 | [diff] [blame] | 163 | { 0x0000201B, 0x0000009D, 0x0 }, |
Rodrigo Vivi | d7097cf | 2016-01-05 11:18:55 -0800 | [diff] [blame] | 164 | { 0x80005012, 0x000000C0, 0x1 }, |
| 165 | { 0x80007011, 0x000000C0, 0x1 }, |
David Weinehall | f8896f5 | 2015-06-25 11:11:03 +0300 | [diff] [blame] | 166 | { 0x00002016, 0x00000088, 0x0 }, |
Rodrigo Vivi | d7097cf | 2016-01-05 11:18:55 -0800 | [diff] [blame] | 167 | { 0x80005012, 0x000000C0, 0x1 }, |
David Weinehall | f8896f5 | 2015-06-25 11:11:03 +0300 | [diff] [blame] | 168 | }; |
| 169 | |
Rodrigo Vivi | 5f8b253 | 2015-08-24 16:48:44 -0700 | [diff] [blame] | 170 | /* Skylake Y */ |
| 171 | static const struct ddi_buf_trans skl_y_ddi_translations_dp[] = { |
David Weinehall | f8896f5 | 2015-06-25 11:11:03 +0300 | [diff] [blame] | 172 | { 0x00000018, 0x000000A2, 0x0 }, |
| 173 | { 0x00005012, 0x00000088, 0x0 }, |
Ville Syrjälä | 5ac9056 | 2016-08-02 15:21:57 +0300 | [diff] [blame] | 174 | { 0x80007011, 0x000000CD, 0x3 }, |
Rodrigo Vivi | d7097cf | 2016-01-05 11:18:55 -0800 | [diff] [blame] | 175 | { 0x80009010, 0x000000C0, 0x3 }, |
David Weinehall | f8896f5 | 2015-06-25 11:11:03 +0300 | [diff] [blame] | 176 | { 0x00000018, 0x0000009D, 0x0 }, |
Rodrigo Vivi | d7097cf | 2016-01-05 11:18:55 -0800 | [diff] [blame] | 177 | { 0x80005012, 0x000000C0, 0x3 }, |
| 178 | { 0x80007011, 0x000000C0, 0x3 }, |
David Weinehall | f8896f5 | 2015-06-25 11:11:03 +0300 | [diff] [blame] | 179 | { 0x00000018, 0x00000088, 0x0 }, |
Rodrigo Vivi | d7097cf | 2016-01-05 11:18:55 -0800 | [diff] [blame] | 180 | { 0x80005012, 0x000000C0, 0x3 }, |
David Weinehall | f8896f5 | 2015-06-25 11:11:03 +0300 | [diff] [blame] | 181 | }; |
| 182 | |
Rodrigo Vivi | 0fdd491 | 2016-10-18 08:57:36 -0700 | [diff] [blame] | 183 | /* Kabylake H and S */ |
| 184 | static const struct ddi_buf_trans kbl_ddi_translations_dp[] = { |
| 185 | { 0x00002016, 0x000000A0, 0x0 }, |
| 186 | { 0x00005012, 0x0000009B, 0x0 }, |
| 187 | { 0x00007011, 0x00000088, 0x0 }, |
| 188 | { 0x80009010, 0x000000C0, 0x1 }, |
| 189 | { 0x00002016, 0x0000009B, 0x0 }, |
| 190 | { 0x00005012, 0x00000088, 0x0 }, |
| 191 | { 0x80007011, 0x000000C0, 0x1 }, |
| 192 | { 0x00002016, 0x00000097, 0x0 }, |
| 193 | { 0x80005012, 0x000000C0, 0x1 }, |
| 194 | }; |
| 195 | |
| 196 | /* Kabylake U */ |
| 197 | static const struct ddi_buf_trans kbl_u_ddi_translations_dp[] = { |
| 198 | { 0x0000201B, 0x000000A1, 0x0 }, |
| 199 | { 0x00005012, 0x00000088, 0x0 }, |
| 200 | { 0x80007011, 0x000000CD, 0x3 }, |
| 201 | { 0x80009010, 0x000000C0, 0x3 }, |
| 202 | { 0x0000201B, 0x0000009D, 0x0 }, |
| 203 | { 0x80005012, 0x000000C0, 0x3 }, |
| 204 | { 0x80007011, 0x000000C0, 0x3 }, |
| 205 | { 0x00002016, 0x0000004F, 0x0 }, |
| 206 | { 0x80005012, 0x000000C0, 0x3 }, |
| 207 | }; |
| 208 | |
| 209 | /* Kabylake Y */ |
| 210 | static const struct ddi_buf_trans kbl_y_ddi_translations_dp[] = { |
| 211 | { 0x00001017, 0x000000A1, 0x0 }, |
| 212 | { 0x00005012, 0x00000088, 0x0 }, |
| 213 | { 0x80007011, 0x000000CD, 0x3 }, |
| 214 | { 0x8000800F, 0x000000C0, 0x3 }, |
| 215 | { 0x00001017, 0x0000009D, 0x0 }, |
| 216 | { 0x80005012, 0x000000C0, 0x3 }, |
| 217 | { 0x80007011, 0x000000C0, 0x3 }, |
| 218 | { 0x00001017, 0x0000004C, 0x0 }, |
| 219 | { 0x80005012, 0x000000C0, 0x3 }, |
| 220 | }; |
| 221 | |
David Weinehall | f8896f5 | 2015-06-25 11:11:03 +0300 | [diff] [blame] | 222 | /* |
Rodrigo Vivi | 0fdd491 | 2016-10-18 08:57:36 -0700 | [diff] [blame] | 223 | * Skylake/Kabylake H and S |
David Weinehall | f8896f5 | 2015-06-25 11:11:03 +0300 | [diff] [blame] | 224 | * eDP 1.4 low vswing translation parameters |
| 225 | */ |
Sonika Jindal | 7ad14a2 | 2015-02-25 10:29:12 +0530 | [diff] [blame] | 226 | static const struct ddi_buf_trans skl_ddi_translations_edp[] = { |
David Weinehall | f8896f5 | 2015-06-25 11:11:03 +0300 | [diff] [blame] | 227 | { 0x00000018, 0x000000A8, 0x0 }, |
| 228 | { 0x00004013, 0x000000A9, 0x0 }, |
| 229 | { 0x00007011, 0x000000A2, 0x0 }, |
| 230 | { 0x00009010, 0x0000009C, 0x0 }, |
| 231 | { 0x00000018, 0x000000A9, 0x0 }, |
| 232 | { 0x00006013, 0x000000A2, 0x0 }, |
| 233 | { 0x00007011, 0x000000A6, 0x0 }, |
| 234 | { 0x00000018, 0x000000AB, 0x0 }, |
| 235 | { 0x00007013, 0x0000009F, 0x0 }, |
| 236 | { 0x00000018, 0x000000DF, 0x0 }, |
Sonika Jindal | 7ad14a2 | 2015-02-25 10:29:12 +0530 | [diff] [blame] | 237 | }; |
| 238 | |
David Weinehall | f8896f5 | 2015-06-25 11:11:03 +0300 | [diff] [blame] | 239 | /* |
Rodrigo Vivi | 0fdd491 | 2016-10-18 08:57:36 -0700 | [diff] [blame] | 240 | * Skylake/Kabylake U |
David Weinehall | f8896f5 | 2015-06-25 11:11:03 +0300 | [diff] [blame] | 241 | * eDP 1.4 low vswing translation parameters |
| 242 | */ |
| 243 | static const struct ddi_buf_trans skl_u_ddi_translations_edp[] = { |
| 244 | { 0x00000018, 0x000000A8, 0x0 }, |
| 245 | { 0x00004013, 0x000000A9, 0x0 }, |
| 246 | { 0x00007011, 0x000000A2, 0x0 }, |
| 247 | { 0x00009010, 0x0000009C, 0x0 }, |
| 248 | { 0x00000018, 0x000000A9, 0x0 }, |
| 249 | { 0x00006013, 0x000000A2, 0x0 }, |
| 250 | { 0x00007011, 0x000000A6, 0x0 }, |
| 251 | { 0x00002016, 0x000000AB, 0x0 }, |
| 252 | { 0x00005013, 0x0000009F, 0x0 }, |
| 253 | { 0x00000018, 0x000000DF, 0x0 }, |
| 254 | }; |
Sonika Jindal | 7ad14a2 | 2015-02-25 10:29:12 +0530 | [diff] [blame] | 255 | |
David Weinehall | f8896f5 | 2015-06-25 11:11:03 +0300 | [diff] [blame] | 256 | /* |
Rodrigo Vivi | 0fdd491 | 2016-10-18 08:57:36 -0700 | [diff] [blame] | 257 | * Skylake/Kabylake Y |
David Weinehall | f8896f5 | 2015-06-25 11:11:03 +0300 | [diff] [blame] | 258 | * eDP 1.4 low vswing translation parameters |
| 259 | */ |
Rodrigo Vivi | 5f8b253 | 2015-08-24 16:48:44 -0700 | [diff] [blame] | 260 | static const struct ddi_buf_trans skl_y_ddi_translations_edp[] = { |
David Weinehall | f8896f5 | 2015-06-25 11:11:03 +0300 | [diff] [blame] | 261 | { 0x00000018, 0x000000A8, 0x0 }, |
| 262 | { 0x00004013, 0x000000AB, 0x0 }, |
| 263 | { 0x00007011, 0x000000A4, 0x0 }, |
| 264 | { 0x00009010, 0x000000DF, 0x0 }, |
| 265 | { 0x00000018, 0x000000AA, 0x0 }, |
| 266 | { 0x00006013, 0x000000A4, 0x0 }, |
| 267 | { 0x00007011, 0x0000009D, 0x0 }, |
| 268 | { 0x00000018, 0x000000A0, 0x0 }, |
| 269 | { 0x00006012, 0x000000DF, 0x0 }, |
| 270 | { 0x00000018, 0x0000008A, 0x0 }, |
| 271 | }; |
| 272 | |
Rodrigo Vivi | 0fdd491 | 2016-10-18 08:57:36 -0700 | [diff] [blame] | 273 | /* Skylake/Kabylake U, H and S */ |
Damien Lespiau | 7f88e3a | 2013-12-03 13:56:25 +0000 | [diff] [blame] | 274 | static const struct ddi_buf_trans skl_ddi_translations_hdmi[] = { |
David Weinehall | f8896f5 | 2015-06-25 11:11:03 +0300 | [diff] [blame] | 275 | { 0x00000018, 0x000000AC, 0x0 }, |
| 276 | { 0x00005012, 0x0000009D, 0x0 }, |
| 277 | { 0x00007011, 0x00000088, 0x0 }, |
| 278 | { 0x00000018, 0x000000A1, 0x0 }, |
| 279 | { 0x00000018, 0x00000098, 0x0 }, |
| 280 | { 0x00004013, 0x00000088, 0x0 }, |
Rodrigo Vivi | 2e78416 | 2016-01-05 11:11:27 -0800 | [diff] [blame] | 281 | { 0x80006012, 0x000000CD, 0x1 }, |
David Weinehall | f8896f5 | 2015-06-25 11:11:03 +0300 | [diff] [blame] | 282 | { 0x00000018, 0x000000DF, 0x0 }, |
Rodrigo Vivi | 2e78416 | 2016-01-05 11:11:27 -0800 | [diff] [blame] | 283 | { 0x80003015, 0x000000CD, 0x1 }, /* Default */ |
| 284 | { 0x80003015, 0x000000C0, 0x1 }, |
| 285 | { 0x80000018, 0x000000C0, 0x1 }, |
David Weinehall | f8896f5 | 2015-06-25 11:11:03 +0300 | [diff] [blame] | 286 | }; |
| 287 | |
Rodrigo Vivi | 0fdd491 | 2016-10-18 08:57:36 -0700 | [diff] [blame] | 288 | /* Skylake/Kabylake Y */ |
Rodrigo Vivi | 5f8b253 | 2015-08-24 16:48:44 -0700 | [diff] [blame] | 289 | static const struct ddi_buf_trans skl_y_ddi_translations_hdmi[] = { |
David Weinehall | f8896f5 | 2015-06-25 11:11:03 +0300 | [diff] [blame] | 290 | { 0x00000018, 0x000000A1, 0x0 }, |
| 291 | { 0x00005012, 0x000000DF, 0x0 }, |
Rodrigo Vivi | 2e78416 | 2016-01-05 11:11:27 -0800 | [diff] [blame] | 292 | { 0x80007011, 0x000000CB, 0x3 }, |
David Weinehall | f8896f5 | 2015-06-25 11:11:03 +0300 | [diff] [blame] | 293 | { 0x00000018, 0x000000A4, 0x0 }, |
| 294 | { 0x00000018, 0x0000009D, 0x0 }, |
| 295 | { 0x00004013, 0x00000080, 0x0 }, |
Rodrigo Vivi | 2e78416 | 2016-01-05 11:11:27 -0800 | [diff] [blame] | 296 | { 0x80006013, 0x000000C0, 0x3 }, |
David Weinehall | f8896f5 | 2015-06-25 11:11:03 +0300 | [diff] [blame] | 297 | { 0x00000018, 0x0000008A, 0x0 }, |
Rodrigo Vivi | 2e78416 | 2016-01-05 11:11:27 -0800 | [diff] [blame] | 298 | { 0x80003015, 0x000000C0, 0x3 }, /* Default */ |
| 299 | { 0x80003015, 0x000000C0, 0x3 }, |
| 300 | { 0x80000018, 0x000000C0, 0x3 }, |
Damien Lespiau | 7f88e3a | 2013-12-03 13:56:25 +0000 | [diff] [blame] | 301 | }; |
| 302 | |
Vandana Kannan | 96fb9f9 | 2014-11-18 15:45:27 +0530 | [diff] [blame] | 303 | struct bxt_ddi_buf_trans { |
| 304 | u32 margin; /* swing value */ |
| 305 | u32 scale; /* scale value */ |
| 306 | u32 enable; /* scale enable */ |
| 307 | u32 deemphasis; |
| 308 | bool default_index; /* true if the entry represents default value */ |
| 309 | }; |
| 310 | |
Vandana Kannan | 96fb9f9 | 2014-11-18 15:45:27 +0530 | [diff] [blame] | 311 | static const struct bxt_ddi_buf_trans bxt_ddi_translations_dp[] = { |
| 312 | /* Idx NT mV diff db */ |
Imre Deak | fe4c63c | 2015-06-04 18:01:35 +0300 | [diff] [blame] | 313 | { 52, 0x9A, 0, 128, true }, /* 0: 400 0 */ |
| 314 | { 78, 0x9A, 0, 85, false }, /* 1: 400 3.5 */ |
| 315 | { 104, 0x9A, 0, 64, false }, /* 2: 400 6 */ |
| 316 | { 154, 0x9A, 0, 43, false }, /* 3: 400 9.5 */ |
| 317 | { 77, 0x9A, 0, 128, false }, /* 4: 600 0 */ |
| 318 | { 116, 0x9A, 0, 85, false }, /* 5: 600 3.5 */ |
| 319 | { 154, 0x9A, 0, 64, false }, /* 6: 600 6 */ |
| 320 | { 102, 0x9A, 0, 128, false }, /* 7: 800 0 */ |
| 321 | { 154, 0x9A, 0, 85, false }, /* 8: 800 3.5 */ |
David Weinehall | f8896f5 | 2015-06-25 11:11:03 +0300 | [diff] [blame] | 322 | { 154, 0x9A, 1, 128, false }, /* 9: 1200 0 */ |
Vandana Kannan | 96fb9f9 | 2014-11-18 15:45:27 +0530 | [diff] [blame] | 323 | }; |
| 324 | |
Sonika Jindal | d9d7000 | 2015-09-24 10:24:56 +0530 | [diff] [blame] | 325 | static const struct bxt_ddi_buf_trans bxt_ddi_translations_edp[] = { |
| 326 | /* Idx NT mV diff db */ |
| 327 | { 26, 0, 0, 128, false }, /* 0: 200 0 */ |
| 328 | { 38, 0, 0, 112, false }, /* 1: 200 1.5 */ |
| 329 | { 48, 0, 0, 96, false }, /* 2: 200 4 */ |
| 330 | { 54, 0, 0, 69, false }, /* 3: 200 6 */ |
| 331 | { 32, 0, 0, 128, false }, /* 4: 250 0 */ |
| 332 | { 48, 0, 0, 104, false }, /* 5: 250 1.5 */ |
| 333 | { 54, 0, 0, 85, false }, /* 6: 250 4 */ |
| 334 | { 43, 0, 0, 128, false }, /* 7: 300 0 */ |
| 335 | { 54, 0, 0, 101, false }, /* 8: 300 1.5 */ |
| 336 | { 48, 0, 0, 128, false }, /* 9: 300 0 */ |
| 337 | }; |
| 338 | |
Vandana Kannan | 96fb9f9 | 2014-11-18 15:45:27 +0530 | [diff] [blame] | 339 | /* BSpec has 2 recommended values - entries 0 and 8. |
| 340 | * Using the entry with higher vswing. |
| 341 | */ |
| 342 | static const struct bxt_ddi_buf_trans bxt_ddi_translations_hdmi[] = { |
| 343 | /* Idx NT mV diff db */ |
Imre Deak | fe4c63c | 2015-06-04 18:01:35 +0300 | [diff] [blame] | 344 | { 52, 0x9A, 0, 128, false }, /* 0: 400 0 */ |
| 345 | { 52, 0x9A, 0, 85, false }, /* 1: 400 3.5 */ |
| 346 | { 52, 0x9A, 0, 64, false }, /* 2: 400 6 */ |
| 347 | { 42, 0x9A, 0, 43, false }, /* 3: 400 9.5 */ |
| 348 | { 77, 0x9A, 0, 128, false }, /* 4: 600 0 */ |
| 349 | { 77, 0x9A, 0, 85, false }, /* 5: 600 3.5 */ |
| 350 | { 77, 0x9A, 0, 64, false }, /* 6: 600 6 */ |
| 351 | { 102, 0x9A, 0, 128, false }, /* 7: 800 0 */ |
| 352 | { 102, 0x9A, 0, 85, false }, /* 8: 800 3.5 */ |
Vandana Kannan | 96fb9f9 | 2014-11-18 15:45:27 +0530 | [diff] [blame] | 353 | { 154, 0x9A, 1, 128, true }, /* 9: 1200 0 */ |
| 354 | }; |
| 355 | |
Ville Syrjälä | 5a5d24d | 2016-07-12 15:59:35 +0300 | [diff] [blame] | 356 | enum port intel_ddi_get_encoder_port(struct intel_encoder *encoder) |
Paulo Zanoni | fc91463 | 2012-10-05 12:05:54 -0300 | [diff] [blame] | 357 | { |
Ville Syrjälä | 5a5d24d | 2016-07-12 15:59:35 +0300 | [diff] [blame] | 358 | switch (encoder->type) { |
Jani Nikula | 8cd21b7 | 2015-09-29 10:24:26 +0300 | [diff] [blame] | 359 | case INTEL_OUTPUT_DP_MST: |
Ville Syrjälä | 5a5d24d | 2016-07-12 15:59:35 +0300 | [diff] [blame] | 360 | return enc_to_mst(&encoder->base)->primary->port; |
Ville Syrjälä | cca0502 | 2016-06-22 21:57:06 +0300 | [diff] [blame] | 361 | case INTEL_OUTPUT_DP: |
Jani Nikula | 8cd21b7 | 2015-09-29 10:24:26 +0300 | [diff] [blame] | 362 | case INTEL_OUTPUT_EDP: |
| 363 | case INTEL_OUTPUT_HDMI: |
| 364 | case INTEL_OUTPUT_UNKNOWN: |
Ville Syrjälä | 5a5d24d | 2016-07-12 15:59:35 +0300 | [diff] [blame] | 365 | return enc_to_dig_port(&encoder->base)->port; |
Jani Nikula | 8cd21b7 | 2015-09-29 10:24:26 +0300 | [diff] [blame] | 366 | case INTEL_OUTPUT_ANALOG: |
Ville Syrjälä | 5a5d24d | 2016-07-12 15:59:35 +0300 | [diff] [blame] | 367 | return PORT_E; |
| 368 | default: |
| 369 | MISSING_CASE(encoder->type); |
| 370 | return PORT_A; |
Paulo Zanoni | fc91463 | 2012-10-05 12:05:54 -0300 | [diff] [blame] | 371 | } |
| 372 | } |
| 373 | |
Ville Syrjälä | acee299 | 2015-12-08 19:59:39 +0200 | [diff] [blame] | 374 | static const struct ddi_buf_trans * |
Ville Syrjälä | a930acd | 2016-07-12 15:59:36 +0300 | [diff] [blame] | 375 | bdw_get_buf_trans_edp(struct drm_i915_private *dev_priv, int *n_entries) |
| 376 | { |
| 377 | if (dev_priv->vbt.edp.low_vswing) { |
| 378 | *n_entries = ARRAY_SIZE(bdw_ddi_translations_edp); |
| 379 | return bdw_ddi_translations_edp; |
| 380 | } else { |
| 381 | *n_entries = ARRAY_SIZE(bdw_ddi_translations_dp); |
| 382 | return bdw_ddi_translations_dp; |
| 383 | } |
| 384 | } |
| 385 | |
| 386 | static const struct ddi_buf_trans * |
Ville Syrjälä | 78ab0ba | 2015-12-08 19:59:41 +0200 | [diff] [blame] | 387 | skl_get_buf_trans_dp(struct drm_i915_private *dev_priv, int *n_entries) |
David Weinehall | f8896f5 | 2015-06-25 11:11:03 +0300 | [diff] [blame] | 388 | { |
Rodrigo Vivi | 0fdd491 | 2016-10-18 08:57:36 -0700 | [diff] [blame] | 389 | if (IS_SKL_ULX(dev_priv)) { |
Rodrigo Vivi | 5f8b253 | 2015-08-24 16:48:44 -0700 | [diff] [blame] | 390 | *n_entries = ARRAY_SIZE(skl_y_ddi_translations_dp); |
Ville Syrjälä | acee299 | 2015-12-08 19:59:39 +0200 | [diff] [blame] | 391 | return skl_y_ddi_translations_dp; |
Rodrigo Vivi | 0fdd491 | 2016-10-18 08:57:36 -0700 | [diff] [blame] | 392 | } else if (IS_SKL_ULT(dev_priv)) { |
David Weinehall | f8896f5 | 2015-06-25 11:11:03 +0300 | [diff] [blame] | 393 | *n_entries = ARRAY_SIZE(skl_u_ddi_translations_dp); |
Ville Syrjälä | acee299 | 2015-12-08 19:59:39 +0200 | [diff] [blame] | 394 | return skl_u_ddi_translations_dp; |
David Weinehall | f8896f5 | 2015-06-25 11:11:03 +0300 | [diff] [blame] | 395 | } else { |
David Weinehall | f8896f5 | 2015-06-25 11:11:03 +0300 | [diff] [blame] | 396 | *n_entries = ARRAY_SIZE(skl_ddi_translations_dp); |
Ville Syrjälä | acee299 | 2015-12-08 19:59:39 +0200 | [diff] [blame] | 397 | return skl_ddi_translations_dp; |
David Weinehall | f8896f5 | 2015-06-25 11:11:03 +0300 | [diff] [blame] | 398 | } |
David Weinehall | f8896f5 | 2015-06-25 11:11:03 +0300 | [diff] [blame] | 399 | } |
| 400 | |
| 401 | static const struct ddi_buf_trans * |
Rodrigo Vivi | 0fdd491 | 2016-10-18 08:57:36 -0700 | [diff] [blame] | 402 | kbl_get_buf_trans_dp(struct drm_i915_private *dev_priv, int *n_entries) |
| 403 | { |
| 404 | if (IS_KBL_ULX(dev_priv)) { |
| 405 | *n_entries = ARRAY_SIZE(kbl_y_ddi_translations_dp); |
| 406 | return kbl_y_ddi_translations_dp; |
| 407 | } else if (IS_KBL_ULT(dev_priv)) { |
| 408 | *n_entries = ARRAY_SIZE(kbl_u_ddi_translations_dp); |
| 409 | return kbl_u_ddi_translations_dp; |
| 410 | } else { |
| 411 | *n_entries = ARRAY_SIZE(kbl_ddi_translations_dp); |
| 412 | return kbl_ddi_translations_dp; |
| 413 | } |
| 414 | } |
| 415 | |
| 416 | static const struct ddi_buf_trans * |
Ville Syrjälä | 78ab0ba | 2015-12-08 19:59:41 +0200 | [diff] [blame] | 417 | skl_get_buf_trans_edp(struct drm_i915_private *dev_priv, int *n_entries) |
David Weinehall | f8896f5 | 2015-06-25 11:11:03 +0300 | [diff] [blame] | 418 | { |
Jani Nikula | 06411f0 | 2016-03-24 17:50:21 +0200 | [diff] [blame] | 419 | if (dev_priv->vbt.edp.low_vswing) { |
Ville Syrjälä | 78ab0ba | 2015-12-08 19:59:41 +0200 | [diff] [blame] | 420 | if (IS_SKL_ULX(dev_priv) || IS_KBL_ULX(dev_priv)) { |
Ville Syrjälä | acee299 | 2015-12-08 19:59:39 +0200 | [diff] [blame] | 421 | *n_entries = ARRAY_SIZE(skl_y_ddi_translations_edp); |
| 422 | return skl_y_ddi_translations_edp; |
Ville Syrjälä | 78ab0ba | 2015-12-08 19:59:41 +0200 | [diff] [blame] | 423 | } else if (IS_SKL_ULT(dev_priv) || IS_KBL_ULT(dev_priv)) { |
Ville Syrjälä | acee299 | 2015-12-08 19:59:39 +0200 | [diff] [blame] | 424 | *n_entries = ARRAY_SIZE(skl_u_ddi_translations_edp); |
| 425 | return skl_u_ddi_translations_edp; |
| 426 | } else { |
Ville Syrjälä | acee299 | 2015-12-08 19:59:39 +0200 | [diff] [blame] | 427 | *n_entries = ARRAY_SIZE(skl_ddi_translations_edp); |
| 428 | return skl_ddi_translations_edp; |
Ville Syrjälä | acee299 | 2015-12-08 19:59:39 +0200 | [diff] [blame] | 429 | } |
David Weinehall | f8896f5 | 2015-06-25 11:11:03 +0300 | [diff] [blame] | 430 | } |
Ville Syrjälä | cd1101c | 2015-12-08 19:59:40 +0200 | [diff] [blame] | 431 | |
Rodrigo Vivi | 0fdd491 | 2016-10-18 08:57:36 -0700 | [diff] [blame] | 432 | if (IS_KABYLAKE(dev_priv)) |
| 433 | return kbl_get_buf_trans_dp(dev_priv, n_entries); |
| 434 | else |
| 435 | return skl_get_buf_trans_dp(dev_priv, n_entries); |
Ville Syrjälä | acee299 | 2015-12-08 19:59:39 +0200 | [diff] [blame] | 436 | } |
David Weinehall | f8896f5 | 2015-06-25 11:11:03 +0300 | [diff] [blame] | 437 | |
Ville Syrjälä | acee299 | 2015-12-08 19:59:39 +0200 | [diff] [blame] | 438 | static const struct ddi_buf_trans * |
Ville Syrjälä | 78ab0ba | 2015-12-08 19:59:41 +0200 | [diff] [blame] | 439 | skl_get_buf_trans_hdmi(struct drm_i915_private *dev_priv, int *n_entries) |
Ville Syrjälä | acee299 | 2015-12-08 19:59:39 +0200 | [diff] [blame] | 440 | { |
Ville Syrjälä | 78ab0ba | 2015-12-08 19:59:41 +0200 | [diff] [blame] | 441 | if (IS_SKL_ULX(dev_priv) || IS_KBL_ULX(dev_priv)) { |
Ville Syrjälä | acee299 | 2015-12-08 19:59:39 +0200 | [diff] [blame] | 442 | *n_entries = ARRAY_SIZE(skl_y_ddi_translations_hdmi); |
| 443 | return skl_y_ddi_translations_hdmi; |
| 444 | } else { |
| 445 | *n_entries = ARRAY_SIZE(skl_ddi_translations_hdmi); |
| 446 | return skl_ddi_translations_hdmi; |
| 447 | } |
David Weinehall | f8896f5 | 2015-06-25 11:11:03 +0300 | [diff] [blame] | 448 | } |
| 449 | |
Ville Syrjälä | 8d8bb85 | 2016-07-12 15:59:30 +0300 | [diff] [blame] | 450 | static int intel_ddi_hdmi_level(struct drm_i915_private *dev_priv, enum port port) |
| 451 | { |
| 452 | int n_hdmi_entries; |
| 453 | int hdmi_level; |
| 454 | int hdmi_default_entry; |
| 455 | |
| 456 | hdmi_level = dev_priv->vbt.ddi_port_info[port].hdmi_level_shift; |
| 457 | |
Ander Conselvan de Oliveira | cc3f90f | 2016-12-02 10:23:49 +0200 | [diff] [blame] | 458 | if (IS_GEN9_LP(dev_priv)) |
Ville Syrjälä | 8d8bb85 | 2016-07-12 15:59:30 +0300 | [diff] [blame] | 459 | return hdmi_level; |
| 460 | |
Rodrigo Vivi | b976dc5 | 2017-01-23 10:32:37 -0800 | [diff] [blame] | 461 | if (IS_GEN9_BC(dev_priv)) { |
Ville Syrjälä | 8d8bb85 | 2016-07-12 15:59:30 +0300 | [diff] [blame] | 462 | skl_get_buf_trans_hdmi(dev_priv, &n_hdmi_entries); |
| 463 | hdmi_default_entry = 8; |
| 464 | } else if (IS_BROADWELL(dev_priv)) { |
| 465 | n_hdmi_entries = ARRAY_SIZE(bdw_ddi_translations_hdmi); |
| 466 | hdmi_default_entry = 7; |
| 467 | } else if (IS_HASWELL(dev_priv)) { |
| 468 | n_hdmi_entries = ARRAY_SIZE(hsw_ddi_translations_hdmi); |
| 469 | hdmi_default_entry = 6; |
| 470 | } else { |
| 471 | WARN(1, "ddi translation table missing\n"); |
| 472 | n_hdmi_entries = ARRAY_SIZE(bdw_ddi_translations_hdmi); |
| 473 | hdmi_default_entry = 7; |
| 474 | } |
| 475 | |
| 476 | /* Choose a good default if VBT is badly populated */ |
| 477 | if (hdmi_level == HDMI_LEVEL_SHIFT_UNKNOWN || |
| 478 | hdmi_level >= n_hdmi_entries) |
| 479 | hdmi_level = hdmi_default_entry; |
| 480 | |
| 481 | return hdmi_level; |
| 482 | } |
| 483 | |
Ville Syrjälä | 7d1c42e | 2017-02-23 19:35:05 +0200 | [diff] [blame] | 484 | static const struct ddi_buf_trans * |
| 485 | intel_ddi_get_buf_trans_dp(struct drm_i915_private *dev_priv, |
| 486 | int *n_entries) |
| 487 | { |
| 488 | if (IS_KABYLAKE(dev_priv)) { |
| 489 | return kbl_get_buf_trans_dp(dev_priv, n_entries); |
| 490 | } else if (IS_SKYLAKE(dev_priv)) { |
| 491 | return skl_get_buf_trans_dp(dev_priv, n_entries); |
| 492 | } else if (IS_BROADWELL(dev_priv)) { |
| 493 | *n_entries = ARRAY_SIZE(bdw_ddi_translations_dp); |
| 494 | return bdw_ddi_translations_dp; |
| 495 | } else if (IS_HASWELL(dev_priv)) { |
| 496 | *n_entries = ARRAY_SIZE(hsw_ddi_translations_dp); |
| 497 | return hsw_ddi_translations_dp; |
| 498 | } |
| 499 | |
| 500 | *n_entries = 0; |
| 501 | return NULL; |
| 502 | } |
| 503 | |
| 504 | static const struct ddi_buf_trans * |
| 505 | intel_ddi_get_buf_trans_edp(struct drm_i915_private *dev_priv, |
| 506 | int *n_entries) |
| 507 | { |
| 508 | if (IS_KABYLAKE(dev_priv) || IS_SKYLAKE(dev_priv)) { |
| 509 | return skl_get_buf_trans_edp(dev_priv, n_entries); |
| 510 | } else if (IS_BROADWELL(dev_priv)) { |
| 511 | return bdw_get_buf_trans_edp(dev_priv, n_entries); |
| 512 | } else if (IS_HASWELL(dev_priv)) { |
| 513 | *n_entries = ARRAY_SIZE(hsw_ddi_translations_dp); |
| 514 | return hsw_ddi_translations_dp; |
| 515 | } |
| 516 | |
| 517 | *n_entries = 0; |
| 518 | return NULL; |
| 519 | } |
| 520 | |
| 521 | static const struct ddi_buf_trans * |
| 522 | intel_ddi_get_buf_trans_fdi(struct drm_i915_private *dev_priv, |
| 523 | int *n_entries) |
| 524 | { |
| 525 | if (IS_BROADWELL(dev_priv)) { |
| 526 | *n_entries = ARRAY_SIZE(hsw_ddi_translations_fdi); |
| 527 | return hsw_ddi_translations_fdi; |
| 528 | } else if (IS_HASWELL(dev_priv)) { |
| 529 | *n_entries = ARRAY_SIZE(hsw_ddi_translations_fdi); |
| 530 | return hsw_ddi_translations_fdi; |
| 531 | } |
| 532 | |
| 533 | *n_entries = 0; |
| 534 | return NULL; |
| 535 | } |
| 536 | |
Art Runyan | e58623c | 2013-11-02 21:07:41 -0700 | [diff] [blame] | 537 | /* |
| 538 | * Starting with Haswell, DDI port buffers must be programmed with correct |
Ville Syrjälä | 32bdc40 | 2016-07-12 15:59:33 +0300 | [diff] [blame] | 539 | * values in advance. This function programs the correct values for |
| 540 | * DP/eDP/FDI use cases. |
Eugeni Dodonov | 45244b8 | 2012-05-09 15:37:20 -0300 | [diff] [blame] | 541 | */ |
Ville Syrjälä | 32bdc40 | 2016-07-12 15:59:33 +0300 | [diff] [blame] | 542 | void intel_prepare_dp_ddi_buffers(struct intel_encoder *encoder) |
Eugeni Dodonov | 45244b8 | 2012-05-09 15:37:20 -0300 | [diff] [blame] | 543 | { |
Ville Syrjälä | 6a7e4f9 | 2015-12-08 19:59:44 +0200 | [diff] [blame] | 544 | struct drm_i915_private *dev_priv = to_i915(encoder->base.dev); |
Antti Koskipaa | 75067dd | 2015-07-10 14:10:55 +0300 | [diff] [blame] | 545 | u32 iboost_bit = 0; |
Ville Syrjälä | 7d1c42e | 2017-02-23 19:35:05 +0200 | [diff] [blame] | 546 | int i, n_entries; |
Ville Syrjälä | 32bdc40 | 2016-07-12 15:59:33 +0300 | [diff] [blame] | 547 | enum port port = intel_ddi_get_encoder_port(encoder); |
Jani Nikula | 1012205 | 2014-08-27 16:27:30 +0300 | [diff] [blame] | 548 | const struct ddi_buf_trans *ddi_translations; |
Art Runyan | e58623c | 2013-11-02 21:07:41 -0700 | [diff] [blame] | 549 | |
Ander Conselvan de Oliveira | cc3f90f | 2016-12-02 10:23:49 +0200 | [diff] [blame] | 550 | if (IS_GEN9_LP(dev_priv)) |
Vandana Kannan | 96fb9f9 | 2014-11-18 15:45:27 +0530 | [diff] [blame] | 551 | return; |
Ville Syrjälä | 6a7e4f9 | 2015-12-08 19:59:44 +0200 | [diff] [blame] | 552 | |
Ville Syrjälä | 7d1c42e | 2017-02-23 19:35:05 +0200 | [diff] [blame] | 553 | switch (encoder->type) { |
| 554 | case INTEL_OUTPUT_EDP: |
| 555 | ddi_translations = intel_ddi_get_buf_trans_edp(dev_priv, |
| 556 | &n_entries); |
| 557 | break; |
| 558 | case INTEL_OUTPUT_DP: |
| 559 | ddi_translations = intel_ddi_get_buf_trans_dp(dev_priv, |
| 560 | &n_entries); |
| 561 | break; |
| 562 | case INTEL_OUTPUT_ANALOG: |
| 563 | ddi_translations = intel_ddi_get_buf_trans_fdi(dev_priv, |
| 564 | &n_entries); |
| 565 | break; |
| 566 | default: |
| 567 | MISSING_CASE(encoder->type); |
| 568 | return; |
Art Runyan | e58623c | 2013-11-02 21:07:41 -0700 | [diff] [blame] | 569 | } |
| 570 | |
Rodrigo Vivi | b976dc5 | 2017-01-23 10:32:37 -0800 | [diff] [blame] | 571 | if (IS_GEN9_BC(dev_priv)) { |
Rodrigo Vivi | 0a91877 | 2016-09-30 11:05:56 -0700 | [diff] [blame] | 572 | /* If we're boosting the current, set bit 31 of trans1 */ |
| 573 | if (dev_priv->vbt.ddi_port_info[port].dp_boost_level) |
| 574 | iboost_bit = DDI_BUF_BALANCE_LEG_ENABLE; |
| 575 | |
| 576 | if (WARN_ON(encoder->type == INTEL_OUTPUT_EDP && |
| 577 | port != PORT_A && port != PORT_E && |
Ville Syrjälä | 7d1c42e | 2017-02-23 19:35:05 +0200 | [diff] [blame] | 578 | n_entries > 9)) |
| 579 | n_entries = 9; |
Rodrigo Vivi | 0a91877 | 2016-09-30 11:05:56 -0700 | [diff] [blame] | 580 | } |
| 581 | |
Ville Syrjälä | 7d1c42e | 2017-02-23 19:35:05 +0200 | [diff] [blame] | 582 | for (i = 0; i < n_entries; i++) { |
Ville Syrjälä | 9712e68 | 2015-09-18 20:03:22 +0300 | [diff] [blame] | 583 | I915_WRITE(DDI_BUF_TRANS_LO(port, i), |
| 584 | ddi_translations[i].trans1 | iboost_bit); |
| 585 | I915_WRITE(DDI_BUF_TRANS_HI(port, i), |
| 586 | ddi_translations[i].trans2); |
Eugeni Dodonov | 45244b8 | 2012-05-09 15:37:20 -0300 | [diff] [blame] | 587 | } |
Ville Syrjälä | 32bdc40 | 2016-07-12 15:59:33 +0300 | [diff] [blame] | 588 | } |
Damien Lespiau | ce4dd49 | 2014-08-01 11:07:54 +0100 | [diff] [blame] | 589 | |
Ville Syrjälä | 32bdc40 | 2016-07-12 15:59:33 +0300 | [diff] [blame] | 590 | /* |
| 591 | * Starting with Haswell, DDI port buffers must be programmed with correct |
| 592 | * values in advance. This function programs the correct values for |
| 593 | * HDMI/DVI use cases. |
| 594 | */ |
| 595 | static void intel_prepare_hdmi_ddi_buffers(struct intel_encoder *encoder) |
| 596 | { |
| 597 | struct drm_i915_private *dev_priv = to_i915(encoder->base.dev); |
| 598 | u32 iboost_bit = 0; |
| 599 | int n_hdmi_entries, hdmi_level; |
| 600 | enum port port = intel_ddi_get_encoder_port(encoder); |
| 601 | const struct ddi_buf_trans *ddi_translations_hdmi; |
| 602 | |
Ander Conselvan de Oliveira | cc3f90f | 2016-12-02 10:23:49 +0200 | [diff] [blame] | 603 | if (IS_GEN9_LP(dev_priv)) |
Damien Lespiau | ce3b7e9 | 2014-08-04 15:04:43 +0100 | [diff] [blame] | 604 | return; |
| 605 | |
Ville Syrjälä | 32bdc40 | 2016-07-12 15:59:33 +0300 | [diff] [blame] | 606 | hdmi_level = intel_ddi_hdmi_level(dev_priv, port); |
| 607 | |
Rodrigo Vivi | b976dc5 | 2017-01-23 10:32:37 -0800 | [diff] [blame] | 608 | if (IS_GEN9_BC(dev_priv)) { |
Ville Syrjälä | 32bdc40 | 2016-07-12 15:59:33 +0300 | [diff] [blame] | 609 | ddi_translations_hdmi = skl_get_buf_trans_hdmi(dev_priv, &n_hdmi_entries); |
Ville Syrjälä | 1edaaa2 | 2016-07-12 15:59:34 +0300 | [diff] [blame] | 610 | |
Ville Syrjälä | 32bdc40 | 2016-07-12 15:59:33 +0300 | [diff] [blame] | 611 | /* If we're boosting the current, set bit 31 of trans1 */ |
Ville Syrjälä | 1edaaa2 | 2016-07-12 15:59:34 +0300 | [diff] [blame] | 612 | if (dev_priv->vbt.ddi_port_info[port].hdmi_boost_level) |
Ville Syrjälä | 32bdc40 | 2016-07-12 15:59:33 +0300 | [diff] [blame] | 613 | iboost_bit = DDI_BUF_BALANCE_LEG_ENABLE; |
| 614 | } else if (IS_BROADWELL(dev_priv)) { |
| 615 | ddi_translations_hdmi = bdw_ddi_translations_hdmi; |
| 616 | n_hdmi_entries = ARRAY_SIZE(bdw_ddi_translations_hdmi); |
| 617 | } else if (IS_HASWELL(dev_priv)) { |
| 618 | ddi_translations_hdmi = hsw_ddi_translations_hdmi; |
| 619 | n_hdmi_entries = ARRAY_SIZE(hsw_ddi_translations_hdmi); |
| 620 | } else { |
| 621 | WARN(1, "ddi translation table missing\n"); |
| 622 | ddi_translations_hdmi = bdw_ddi_translations_hdmi; |
| 623 | n_hdmi_entries = ARRAY_SIZE(bdw_ddi_translations_hdmi); |
| 624 | } |
| 625 | |
Paulo Zanoni | 6acab15 | 2013-09-12 17:06:24 -0300 | [diff] [blame] | 626 | /* Entry 9 is for HDMI: */ |
Ville Syrjälä | ed9c77d | 2016-07-12 15:59:32 +0300 | [diff] [blame] | 627 | I915_WRITE(DDI_BUF_TRANS_LO(port, 9), |
Ville Syrjälä | 9712e68 | 2015-09-18 20:03:22 +0300 | [diff] [blame] | 628 | ddi_translations_hdmi[hdmi_level].trans1 | iboost_bit); |
Ville Syrjälä | ed9c77d | 2016-07-12 15:59:32 +0300 | [diff] [blame] | 629 | I915_WRITE(DDI_BUF_TRANS_HI(port, 9), |
Ville Syrjälä | 9712e68 | 2015-09-18 20:03:22 +0300 | [diff] [blame] | 630 | ddi_translations_hdmi[hdmi_level].trans2); |
Eugeni Dodonov | 45244b8 | 2012-05-09 15:37:20 -0300 | [diff] [blame] | 631 | } |
| 632 | |
Paulo Zanoni | 248138b | 2012-11-29 11:29:31 -0200 | [diff] [blame] | 633 | static void intel_wait_ddi_buf_idle(struct drm_i915_private *dev_priv, |
| 634 | enum port port) |
| 635 | { |
Ville Syrjälä | f0f59a0 | 2015-11-18 15:33:26 +0200 | [diff] [blame] | 636 | i915_reg_t reg = DDI_BUF_CTL(port); |
Paulo Zanoni | 248138b | 2012-11-29 11:29:31 -0200 | [diff] [blame] | 637 | int i; |
| 638 | |
Vandana Kannan | 3449ca8 | 2015-03-27 14:19:09 +0200 | [diff] [blame] | 639 | for (i = 0; i < 16; i++) { |
Paulo Zanoni | 248138b | 2012-11-29 11:29:31 -0200 | [diff] [blame] | 640 | udelay(1); |
| 641 | if (I915_READ(reg) & DDI_BUF_IS_IDLE) |
| 642 | return; |
| 643 | } |
| 644 | DRM_ERROR("Timeout waiting for DDI BUF %c idle bit\n", port_name(port)); |
| 645 | } |
Eugeni Dodonov | c82e4d2 | 2012-05-09 15:37:21 -0300 | [diff] [blame] | 646 | |
Ander Conselvan de Oliveira | c856052 | 2016-09-01 15:08:07 -0700 | [diff] [blame] | 647 | static uint32_t hsw_pll_to_ddi_pll_sel(struct intel_shared_dpll *pll) |
| 648 | { |
| 649 | switch (pll->id) { |
| 650 | case DPLL_ID_WRPLL1: |
| 651 | return PORT_CLK_SEL_WRPLL1; |
| 652 | case DPLL_ID_WRPLL2: |
| 653 | return PORT_CLK_SEL_WRPLL2; |
| 654 | case DPLL_ID_SPLL: |
| 655 | return PORT_CLK_SEL_SPLL; |
| 656 | case DPLL_ID_LCPLL_810: |
| 657 | return PORT_CLK_SEL_LCPLL_810; |
| 658 | case DPLL_ID_LCPLL_1350: |
| 659 | return PORT_CLK_SEL_LCPLL_1350; |
| 660 | case DPLL_ID_LCPLL_2700: |
| 661 | return PORT_CLK_SEL_LCPLL_2700; |
| 662 | default: |
| 663 | MISSING_CASE(pll->id); |
| 664 | return PORT_CLK_SEL_NONE; |
| 665 | } |
| 666 | } |
| 667 | |
Eugeni Dodonov | c82e4d2 | 2012-05-09 15:37:21 -0300 | [diff] [blame] | 668 | /* Starting with Haswell, different DDI ports can work in FDI mode for |
| 669 | * connection to the PCH-located connectors. For this, it is necessary to train |
| 670 | * both the DDI port and PCH receiver for the desired DDI buffer settings. |
| 671 | * |
| 672 | * The recommended port to work in FDI mode is DDI E, which we use here. Also, |
| 673 | * please note that when FDI mode is active on DDI E, it shares 2 lines with |
| 674 | * DDI A (which is used for eDP) |
| 675 | */ |
| 676 | |
Ander Conselvan de Oliveira | 4cbe4b2 | 2017-03-02 14:58:51 +0200 | [diff] [blame^] | 677 | void hsw_fdi_link_train(struct intel_crtc *crtc) |
Eugeni Dodonov | c82e4d2 | 2012-05-09 15:37:21 -0300 | [diff] [blame] | 678 | { |
Ander Conselvan de Oliveira | 4cbe4b2 | 2017-03-02 14:58:51 +0200 | [diff] [blame^] | 679 | struct drm_device *dev = crtc->base.dev; |
Chris Wilson | fac5e23 | 2016-07-04 11:34:36 +0100 | [diff] [blame] | 680 | struct drm_i915_private *dev_priv = to_i915(dev); |
Ville Syrjälä | 6a7e4f9 | 2015-12-08 19:59:44 +0200 | [diff] [blame] | 681 | struct intel_encoder *encoder; |
Ander Conselvan de Oliveira | c856052 | 2016-09-01 15:08:07 -0700 | [diff] [blame] | 682 | u32 temp, i, rx_ctl_val, ddi_pll_sel; |
Eugeni Dodonov | c82e4d2 | 2012-05-09 15:37:21 -0300 | [diff] [blame] | 683 | |
Ander Conselvan de Oliveira | 4cbe4b2 | 2017-03-02 14:58:51 +0200 | [diff] [blame^] | 684 | for_each_encoder_on_crtc(dev, &crtc->base, encoder) { |
Ville Syrjälä | 6a7e4f9 | 2015-12-08 19:59:44 +0200 | [diff] [blame] | 685 | WARN_ON(encoder->type != INTEL_OUTPUT_ANALOG); |
Ville Syrjälä | 32bdc40 | 2016-07-12 15:59:33 +0300 | [diff] [blame] | 686 | intel_prepare_dp_ddi_buffers(encoder); |
Ville Syrjälä | 6a7e4f9 | 2015-12-08 19:59:44 +0200 | [diff] [blame] | 687 | } |
| 688 | |
Paulo Zanoni | 0494564 | 2012-11-01 21:00:59 -0200 | [diff] [blame] | 689 | /* Set the FDI_RX_MISC pwrdn lanes and the 2 workarounds listed at the |
| 690 | * mode set "sequence for CRT port" document: |
| 691 | * - TP1 to TP2 time with the default value |
| 692 | * - FDI delay to 90h |
Damien Lespiau | 8693a82 | 2013-05-03 18:48:11 +0100 | [diff] [blame] | 693 | * |
| 694 | * WaFDIAutoLinkSetTimingOverrride:hsw |
Paulo Zanoni | 0494564 | 2012-11-01 21:00:59 -0200 | [diff] [blame] | 695 | */ |
Ville Syrjälä | eede3b5 | 2015-09-18 20:03:30 +0300 | [diff] [blame] | 696 | I915_WRITE(FDI_RX_MISC(PIPE_A), FDI_RX_PWRDN_LANE1_VAL(2) | |
Paulo Zanoni | 0494564 | 2012-11-01 21:00:59 -0200 | [diff] [blame] | 697 | FDI_RX_PWRDN_LANE0_VAL(2) | |
| 698 | FDI_RX_TP1_TO_TP2_48 | FDI_RX_FDI_DELAY_90); |
| 699 | |
| 700 | /* Enable the PCH Receiver FDI PLL */ |
Damien Lespiau | 3e68320 | 2012-12-11 18:48:29 +0000 | [diff] [blame] | 701 | rx_ctl_val = dev_priv->fdi_rx_config | FDI_RX_ENHANCE_FRAME_ENABLE | |
Daniel Vetter | 33d29b1 | 2013-02-13 18:04:45 +0100 | [diff] [blame] | 702 | FDI_RX_PLL_ENABLE | |
Ander Conselvan de Oliveira | 4cbe4b2 | 2017-03-02 14:58:51 +0200 | [diff] [blame^] | 703 | FDI_DP_PORT_WIDTH(crtc->config->fdi_lanes); |
Ville Syrjälä | eede3b5 | 2015-09-18 20:03:30 +0300 | [diff] [blame] | 704 | I915_WRITE(FDI_RX_CTL(PIPE_A), rx_ctl_val); |
| 705 | POSTING_READ(FDI_RX_CTL(PIPE_A)); |
Paulo Zanoni | 0494564 | 2012-11-01 21:00:59 -0200 | [diff] [blame] | 706 | udelay(220); |
| 707 | |
| 708 | /* Switch from Rawclk to PCDclk */ |
| 709 | rx_ctl_val |= FDI_PCDCLK; |
Ville Syrjälä | eede3b5 | 2015-09-18 20:03:30 +0300 | [diff] [blame] | 710 | I915_WRITE(FDI_RX_CTL(PIPE_A), rx_ctl_val); |
Paulo Zanoni | 0494564 | 2012-11-01 21:00:59 -0200 | [diff] [blame] | 711 | |
| 712 | /* Configure Port Clock Select */ |
Ander Conselvan de Oliveira | 4cbe4b2 | 2017-03-02 14:58:51 +0200 | [diff] [blame^] | 713 | ddi_pll_sel = hsw_pll_to_ddi_pll_sel(crtc->config->shared_dpll); |
Ander Conselvan de Oliveira | c856052 | 2016-09-01 15:08:07 -0700 | [diff] [blame] | 714 | I915_WRITE(PORT_CLK_SEL(PORT_E), ddi_pll_sel); |
| 715 | WARN_ON(ddi_pll_sel != PORT_CLK_SEL_SPLL); |
Paulo Zanoni | 0494564 | 2012-11-01 21:00:59 -0200 | [diff] [blame] | 716 | |
| 717 | /* Start the training iterating through available voltages and emphasis, |
| 718 | * testing each value twice. */ |
Jani Nikula | 1012205 | 2014-08-27 16:27:30 +0300 | [diff] [blame] | 719 | for (i = 0; i < ARRAY_SIZE(hsw_ddi_translations_fdi) * 2; i++) { |
Eugeni Dodonov | c82e4d2 | 2012-05-09 15:37:21 -0300 | [diff] [blame] | 720 | /* Configure DP_TP_CTL with auto-training */ |
| 721 | I915_WRITE(DP_TP_CTL(PORT_E), |
| 722 | DP_TP_CTL_FDI_AUTOTRAIN | |
| 723 | DP_TP_CTL_ENHANCED_FRAME_ENABLE | |
| 724 | DP_TP_CTL_LINK_TRAIN_PAT1 | |
| 725 | DP_TP_CTL_ENABLE); |
| 726 | |
Damien Lespiau | 876a8cd | 2012-12-11 18:48:30 +0000 | [diff] [blame] | 727 | /* Configure and enable DDI_BUF_CTL for DDI E with next voltage. |
| 728 | * DDI E does not support port reversal, the functionality is |
| 729 | * achieved on the PCH side in FDI_RX_CTL, so no need to set the |
| 730 | * port reversal bit */ |
Eugeni Dodonov | c82e4d2 | 2012-05-09 15:37:21 -0300 | [diff] [blame] | 731 | I915_WRITE(DDI_BUF_CTL(PORT_E), |
Paulo Zanoni | 0494564 | 2012-11-01 21:00:59 -0200 | [diff] [blame] | 732 | DDI_BUF_CTL_ENABLE | |
Ander Conselvan de Oliveira | 4cbe4b2 | 2017-03-02 14:58:51 +0200 | [diff] [blame^] | 733 | ((crtc->config->fdi_lanes - 1) << 1) | |
Sonika Jindal | c5fe6a0 | 2014-08-11 08:57:36 +0530 | [diff] [blame] | 734 | DDI_BUF_TRANS_SELECT(i / 2)); |
Paulo Zanoni | 0494564 | 2012-11-01 21:00:59 -0200 | [diff] [blame] | 735 | POSTING_READ(DDI_BUF_CTL(PORT_E)); |
Eugeni Dodonov | c82e4d2 | 2012-05-09 15:37:21 -0300 | [diff] [blame] | 736 | |
| 737 | udelay(600); |
| 738 | |
Paulo Zanoni | 0494564 | 2012-11-01 21:00:59 -0200 | [diff] [blame] | 739 | /* Program PCH FDI Receiver TU */ |
Ville Syrjälä | eede3b5 | 2015-09-18 20:03:30 +0300 | [diff] [blame] | 740 | I915_WRITE(FDI_RX_TUSIZE1(PIPE_A), TU_SIZE(64)); |
Eugeni Dodonov | 4acf518 | 2012-07-04 20:15:16 -0300 | [diff] [blame] | 741 | |
Paulo Zanoni | 0494564 | 2012-11-01 21:00:59 -0200 | [diff] [blame] | 742 | /* Enable PCH FDI Receiver with auto-training */ |
| 743 | rx_ctl_val |= FDI_RX_ENABLE | FDI_LINK_TRAIN_AUTO; |
Ville Syrjälä | eede3b5 | 2015-09-18 20:03:30 +0300 | [diff] [blame] | 744 | I915_WRITE(FDI_RX_CTL(PIPE_A), rx_ctl_val); |
| 745 | POSTING_READ(FDI_RX_CTL(PIPE_A)); |
Paulo Zanoni | 0494564 | 2012-11-01 21:00:59 -0200 | [diff] [blame] | 746 | |
| 747 | /* Wait for FDI receiver lane calibration */ |
| 748 | udelay(30); |
| 749 | |
| 750 | /* Unset FDI_RX_MISC pwrdn lanes */ |
Ville Syrjälä | eede3b5 | 2015-09-18 20:03:30 +0300 | [diff] [blame] | 751 | temp = I915_READ(FDI_RX_MISC(PIPE_A)); |
Paulo Zanoni | 0494564 | 2012-11-01 21:00:59 -0200 | [diff] [blame] | 752 | temp &= ~(FDI_RX_PWRDN_LANE1_MASK | FDI_RX_PWRDN_LANE0_MASK); |
Ville Syrjälä | eede3b5 | 2015-09-18 20:03:30 +0300 | [diff] [blame] | 753 | I915_WRITE(FDI_RX_MISC(PIPE_A), temp); |
| 754 | POSTING_READ(FDI_RX_MISC(PIPE_A)); |
Paulo Zanoni | 0494564 | 2012-11-01 21:00:59 -0200 | [diff] [blame] | 755 | |
| 756 | /* Wait for FDI auto training time */ |
| 757 | udelay(5); |
Eugeni Dodonov | c82e4d2 | 2012-05-09 15:37:21 -0300 | [diff] [blame] | 758 | |
| 759 | temp = I915_READ(DP_TP_STATUS(PORT_E)); |
| 760 | if (temp & DP_TP_STATUS_AUTOTRAIN_DONE) { |
Paulo Zanoni | 0494564 | 2012-11-01 21:00:59 -0200 | [diff] [blame] | 761 | DRM_DEBUG_KMS("FDI link training done on step %d\n", i); |
Ville Syrjälä | a308ccb | 2015-12-04 22:22:50 +0200 | [diff] [blame] | 762 | break; |
| 763 | } |
Eugeni Dodonov | c82e4d2 | 2012-05-09 15:37:21 -0300 | [diff] [blame] | 764 | |
Ville Syrjälä | a308ccb | 2015-12-04 22:22:50 +0200 | [diff] [blame] | 765 | /* |
| 766 | * Leave things enabled even if we failed to train FDI. |
| 767 | * Results in less fireworks from the state checker. |
| 768 | */ |
| 769 | if (i == ARRAY_SIZE(hsw_ddi_translations_fdi) * 2 - 1) { |
| 770 | DRM_ERROR("FDI link training failed!\n"); |
| 771 | break; |
Eugeni Dodonov | c82e4d2 | 2012-05-09 15:37:21 -0300 | [diff] [blame] | 772 | } |
Paulo Zanoni | 0494564 | 2012-11-01 21:00:59 -0200 | [diff] [blame] | 773 | |
Ville Syrjälä | 5b421c5 | 2016-03-01 16:16:23 +0200 | [diff] [blame] | 774 | rx_ctl_val &= ~FDI_RX_ENABLE; |
| 775 | I915_WRITE(FDI_RX_CTL(PIPE_A), rx_ctl_val); |
| 776 | POSTING_READ(FDI_RX_CTL(PIPE_A)); |
| 777 | |
Paulo Zanoni | 248138b | 2012-11-29 11:29:31 -0200 | [diff] [blame] | 778 | temp = I915_READ(DDI_BUF_CTL(PORT_E)); |
| 779 | temp &= ~DDI_BUF_CTL_ENABLE; |
| 780 | I915_WRITE(DDI_BUF_CTL(PORT_E), temp); |
| 781 | POSTING_READ(DDI_BUF_CTL(PORT_E)); |
| 782 | |
Paulo Zanoni | 0494564 | 2012-11-01 21:00:59 -0200 | [diff] [blame] | 783 | /* Disable DP_TP_CTL and FDI_RX_CTL and retry */ |
Paulo Zanoni | 248138b | 2012-11-29 11:29:31 -0200 | [diff] [blame] | 784 | temp = I915_READ(DP_TP_CTL(PORT_E)); |
| 785 | temp &= ~(DP_TP_CTL_ENABLE | DP_TP_CTL_LINK_TRAIN_MASK); |
| 786 | temp |= DP_TP_CTL_LINK_TRAIN_PAT1; |
| 787 | I915_WRITE(DP_TP_CTL(PORT_E), temp); |
| 788 | POSTING_READ(DP_TP_CTL(PORT_E)); |
| 789 | |
| 790 | intel_wait_ddi_buf_idle(dev_priv, PORT_E); |
Paulo Zanoni | 0494564 | 2012-11-01 21:00:59 -0200 | [diff] [blame] | 791 | |
Paulo Zanoni | 0494564 | 2012-11-01 21:00:59 -0200 | [diff] [blame] | 792 | /* Reset FDI_RX_MISC pwrdn lanes */ |
Ville Syrjälä | eede3b5 | 2015-09-18 20:03:30 +0300 | [diff] [blame] | 793 | temp = I915_READ(FDI_RX_MISC(PIPE_A)); |
Paulo Zanoni | 0494564 | 2012-11-01 21:00:59 -0200 | [diff] [blame] | 794 | temp &= ~(FDI_RX_PWRDN_LANE1_MASK | FDI_RX_PWRDN_LANE0_MASK); |
| 795 | temp |= FDI_RX_PWRDN_LANE1_VAL(2) | FDI_RX_PWRDN_LANE0_VAL(2); |
Ville Syrjälä | eede3b5 | 2015-09-18 20:03:30 +0300 | [diff] [blame] | 796 | I915_WRITE(FDI_RX_MISC(PIPE_A), temp); |
| 797 | POSTING_READ(FDI_RX_MISC(PIPE_A)); |
Eugeni Dodonov | c82e4d2 | 2012-05-09 15:37:21 -0300 | [diff] [blame] | 798 | } |
| 799 | |
Ville Syrjälä | a308ccb | 2015-12-04 22:22:50 +0200 | [diff] [blame] | 800 | /* Enable normal pixel sending for FDI */ |
| 801 | I915_WRITE(DP_TP_CTL(PORT_E), |
| 802 | DP_TP_CTL_FDI_AUTOTRAIN | |
| 803 | DP_TP_CTL_LINK_TRAIN_NORMAL | |
| 804 | DP_TP_CTL_ENHANCED_FRAME_ENABLE | |
| 805 | DP_TP_CTL_ENABLE); |
Eugeni Dodonov | c82e4d2 | 2012-05-09 15:37:21 -0300 | [diff] [blame] | 806 | } |
Eugeni Dodonov | 0e72a5b | 2012-05-09 15:37:27 -0300 | [diff] [blame] | 807 | |
Dave Airlie | 44905a27 | 2014-05-02 13:36:43 +1000 | [diff] [blame] | 808 | void intel_ddi_init_dp_buf_reg(struct intel_encoder *encoder) |
| 809 | { |
| 810 | struct intel_dp *intel_dp = enc_to_intel_dp(&encoder->base); |
| 811 | struct intel_digital_port *intel_dig_port = |
| 812 | enc_to_dig_port(&encoder->base); |
| 813 | |
| 814 | intel_dp->DP = intel_dig_port->saved_port_bits | |
Sonika Jindal | c5fe6a0 | 2014-08-11 08:57:36 +0530 | [diff] [blame] | 815 | DDI_BUF_CTL_ENABLE | DDI_BUF_TRANS_SELECT(0); |
Ville Syrjälä | 901c2da | 2015-08-17 18:05:12 +0300 | [diff] [blame] | 816 | intel_dp->DP |= DDI_PORT_WIDTH(intel_dp->lane_count); |
Dave Airlie | 44905a27 | 2014-05-02 13:36:43 +1000 | [diff] [blame] | 817 | } |
| 818 | |
Paulo Zanoni | 8d9ddbc | 2012-10-05 12:05:53 -0300 | [diff] [blame] | 819 | static struct intel_encoder * |
| 820 | intel_ddi_get_crtc_encoder(struct drm_crtc *crtc) |
| 821 | { |
| 822 | struct drm_device *dev = crtc->dev; |
| 823 | struct intel_crtc *intel_crtc = to_intel_crtc(crtc); |
| 824 | struct intel_encoder *intel_encoder, *ret = NULL; |
| 825 | int num_encoders = 0; |
| 826 | |
| 827 | for_each_encoder_on_crtc(dev, crtc, intel_encoder) { |
| 828 | ret = intel_encoder; |
| 829 | num_encoders++; |
| 830 | } |
| 831 | |
| 832 | if (num_encoders != 1) |
Ville Syrjälä | 84f44ce | 2013-04-17 17:48:49 +0300 | [diff] [blame] | 833 | WARN(1, "%d encoders on crtc for pipe %c\n", num_encoders, |
| 834 | pipe_name(intel_crtc->pipe)); |
Paulo Zanoni | 8d9ddbc | 2012-10-05 12:05:53 -0300 | [diff] [blame] | 835 | |
| 836 | BUG_ON(ret == NULL); |
| 837 | return ret; |
| 838 | } |
| 839 | |
Satheeshakrishna M | bcddf61 | 2014-08-22 09:49:10 +0530 | [diff] [blame] | 840 | struct intel_encoder * |
Ander Conselvan de Oliveira | 3165c07 | 2015-03-20 16:18:12 +0200 | [diff] [blame] | 841 | intel_ddi_get_crtc_new_encoder(struct intel_crtc_state *crtc_state) |
Ander Conselvan de Oliveira | d0737e1 | 2014-10-29 11:32:30 +0200 | [diff] [blame] | 842 | { |
Ander Conselvan de Oliveira | 3165c07 | 2015-03-20 16:18:12 +0200 | [diff] [blame] | 843 | struct intel_crtc *crtc = to_intel_crtc(crtc_state->base.crtc); |
| 844 | struct intel_encoder *ret = NULL; |
| 845 | struct drm_atomic_state *state; |
Ander Conselvan de Oliveira | da3ced2 | 2015-04-21 17:12:59 +0300 | [diff] [blame] | 846 | struct drm_connector *connector; |
| 847 | struct drm_connector_state *connector_state; |
Ander Conselvan de Oliveira | d0737e1 | 2014-10-29 11:32:30 +0200 | [diff] [blame] | 848 | int num_encoders = 0; |
Ander Conselvan de Oliveira | 3165c07 | 2015-03-20 16:18:12 +0200 | [diff] [blame] | 849 | int i; |
Ander Conselvan de Oliveira | d0737e1 | 2014-10-29 11:32:30 +0200 | [diff] [blame] | 850 | |
Ander Conselvan de Oliveira | 3165c07 | 2015-03-20 16:18:12 +0200 | [diff] [blame] | 851 | state = crtc_state->base.state; |
| 852 | |
Ander Conselvan de Oliveira | da3ced2 | 2015-04-21 17:12:59 +0300 | [diff] [blame] | 853 | for_each_connector_in_state(state, connector, connector_state, i) { |
| 854 | if (connector_state->crtc != crtc_state->base.crtc) |
Ander Conselvan de Oliveira | 3165c07 | 2015-03-20 16:18:12 +0200 | [diff] [blame] | 855 | continue; |
| 856 | |
Ander Conselvan de Oliveira | da3ced2 | 2015-04-21 17:12:59 +0300 | [diff] [blame] | 857 | ret = to_intel_encoder(connector_state->best_encoder); |
Ander Conselvan de Oliveira | 3165c07 | 2015-03-20 16:18:12 +0200 | [diff] [blame] | 858 | num_encoders++; |
Ander Conselvan de Oliveira | d0737e1 | 2014-10-29 11:32:30 +0200 | [diff] [blame] | 859 | } |
| 860 | |
| 861 | WARN(num_encoders != 1, "%d encoders on crtc for pipe %c\n", num_encoders, |
| 862 | pipe_name(crtc->pipe)); |
| 863 | |
| 864 | BUG_ON(ret == NULL); |
| 865 | return ret; |
| 866 | } |
| 867 | |
Damien Lespiau | 1c0b85c | 2013-05-10 14:01:51 +0100 | [diff] [blame] | 868 | #define LC_FREQ 2700 |
Damien Lespiau | 1c0b85c | 2013-05-10 14:01:51 +0100 | [diff] [blame] | 869 | |
Ville Syrjälä | f0f59a0 | 2015-11-18 15:33:26 +0200 | [diff] [blame] | 870 | static int hsw_ddi_calc_wrpll_link(struct drm_i915_private *dev_priv, |
| 871 | i915_reg_t reg) |
Jesse Barnes | 1157855 | 2014-01-21 12:42:10 -0800 | [diff] [blame] | 872 | { |
| 873 | int refclk = LC_FREQ; |
| 874 | int n, p, r; |
| 875 | u32 wrpll; |
| 876 | |
| 877 | wrpll = I915_READ(reg); |
Daniel Vetter | 114fe48 | 2014-06-25 22:01:48 +0300 | [diff] [blame] | 878 | switch (wrpll & WRPLL_PLL_REF_MASK) { |
| 879 | case WRPLL_PLL_SSC: |
| 880 | case WRPLL_PLL_NON_SSC: |
Jesse Barnes | 1157855 | 2014-01-21 12:42:10 -0800 | [diff] [blame] | 881 | /* |
| 882 | * We could calculate spread here, but our checking |
| 883 | * code only cares about 5% accuracy, and spread is a max of |
| 884 | * 0.5% downspread. |
| 885 | */ |
| 886 | refclk = 135; |
| 887 | break; |
Daniel Vetter | 114fe48 | 2014-06-25 22:01:48 +0300 | [diff] [blame] | 888 | case WRPLL_PLL_LCPLL: |
Jesse Barnes | 1157855 | 2014-01-21 12:42:10 -0800 | [diff] [blame] | 889 | refclk = LC_FREQ; |
| 890 | break; |
| 891 | default: |
| 892 | WARN(1, "bad wrpll refclk\n"); |
| 893 | return 0; |
| 894 | } |
| 895 | |
| 896 | r = wrpll & WRPLL_DIVIDER_REF_MASK; |
| 897 | p = (wrpll & WRPLL_DIVIDER_POST_MASK) >> WRPLL_DIVIDER_POST_SHIFT; |
| 898 | n = (wrpll & WRPLL_DIVIDER_FB_MASK) >> WRPLL_DIVIDER_FB_SHIFT; |
| 899 | |
Jesse Barnes | 20f0ec1 | 2014-01-22 12:58:04 -0800 | [diff] [blame] | 900 | /* Convert to KHz, p & r have a fixed point portion */ |
| 901 | return (refclk * n * 100) / (p * r); |
Jesse Barnes | 1157855 | 2014-01-21 12:42:10 -0800 | [diff] [blame] | 902 | } |
| 903 | |
Satheeshakrishna M | 540e732 | 2014-11-13 14:55:16 +0000 | [diff] [blame] | 904 | static int skl_calc_wrpll_link(struct drm_i915_private *dev_priv, |
| 905 | uint32_t dpll) |
| 906 | { |
Ville Syrjälä | f0f59a0 | 2015-11-18 15:33:26 +0200 | [diff] [blame] | 907 | i915_reg_t cfgcr1_reg, cfgcr2_reg; |
Satheeshakrishna M | 540e732 | 2014-11-13 14:55:16 +0000 | [diff] [blame] | 908 | uint32_t cfgcr1_val, cfgcr2_val; |
| 909 | uint32_t p0, p1, p2, dco_freq; |
| 910 | |
Ville Syrjälä | 923c1241 | 2015-09-30 17:06:43 +0300 | [diff] [blame] | 911 | cfgcr1_reg = DPLL_CFGCR1(dpll); |
| 912 | cfgcr2_reg = DPLL_CFGCR2(dpll); |
Satheeshakrishna M | 540e732 | 2014-11-13 14:55:16 +0000 | [diff] [blame] | 913 | |
| 914 | cfgcr1_val = I915_READ(cfgcr1_reg); |
| 915 | cfgcr2_val = I915_READ(cfgcr2_reg); |
| 916 | |
| 917 | p0 = cfgcr2_val & DPLL_CFGCR2_PDIV_MASK; |
| 918 | p2 = cfgcr2_val & DPLL_CFGCR2_KDIV_MASK; |
| 919 | |
| 920 | if (cfgcr2_val & DPLL_CFGCR2_QDIV_MODE(1)) |
| 921 | p1 = (cfgcr2_val & DPLL_CFGCR2_QDIV_RATIO_MASK) >> 8; |
| 922 | else |
| 923 | p1 = 1; |
| 924 | |
| 925 | |
| 926 | switch (p0) { |
| 927 | case DPLL_CFGCR2_PDIV_1: |
| 928 | p0 = 1; |
| 929 | break; |
| 930 | case DPLL_CFGCR2_PDIV_2: |
| 931 | p0 = 2; |
| 932 | break; |
| 933 | case DPLL_CFGCR2_PDIV_3: |
| 934 | p0 = 3; |
| 935 | break; |
| 936 | case DPLL_CFGCR2_PDIV_7: |
| 937 | p0 = 7; |
| 938 | break; |
| 939 | } |
| 940 | |
| 941 | switch (p2) { |
| 942 | case DPLL_CFGCR2_KDIV_5: |
| 943 | p2 = 5; |
| 944 | break; |
| 945 | case DPLL_CFGCR2_KDIV_2: |
| 946 | p2 = 2; |
| 947 | break; |
| 948 | case DPLL_CFGCR2_KDIV_3: |
| 949 | p2 = 3; |
| 950 | break; |
| 951 | case DPLL_CFGCR2_KDIV_1: |
| 952 | p2 = 1; |
| 953 | break; |
| 954 | } |
| 955 | |
| 956 | dco_freq = (cfgcr1_val & DPLL_CFGCR1_DCO_INTEGER_MASK) * 24 * 1000; |
| 957 | |
| 958 | dco_freq += (((cfgcr1_val & DPLL_CFGCR1_DCO_FRACTION_MASK) >> 9) * 24 * |
| 959 | 1000) / 0x8000; |
| 960 | |
| 961 | return dco_freq / (p0 * p1 * p2 * 5); |
| 962 | } |
| 963 | |
Ville Syrjälä | 398a017 | 2015-06-30 15:33:51 +0300 | [diff] [blame] | 964 | static void ddi_dotclock_get(struct intel_crtc_state *pipe_config) |
| 965 | { |
| 966 | int dotclock; |
| 967 | |
| 968 | if (pipe_config->has_pch_encoder) |
| 969 | dotclock = intel_dotclock_calculate(pipe_config->port_clock, |
| 970 | &pipe_config->fdi_m_n); |
Ville Syrjälä | 37a5650 | 2016-06-22 21:57:04 +0300 | [diff] [blame] | 971 | else if (intel_crtc_has_dp_encoder(pipe_config)) |
Ville Syrjälä | 398a017 | 2015-06-30 15:33:51 +0300 | [diff] [blame] | 972 | dotclock = intel_dotclock_calculate(pipe_config->port_clock, |
| 973 | &pipe_config->dp_m_n); |
| 974 | else if (pipe_config->has_hdmi_sink && pipe_config->pipe_bpp == 36) |
| 975 | dotclock = pipe_config->port_clock * 2 / 3; |
| 976 | else |
| 977 | dotclock = pipe_config->port_clock; |
| 978 | |
| 979 | if (pipe_config->pixel_multiplier) |
| 980 | dotclock /= pipe_config->pixel_multiplier; |
| 981 | |
| 982 | pipe_config->base.adjusted_mode.crtc_clock = dotclock; |
| 983 | } |
Satheeshakrishna M | 540e732 | 2014-11-13 14:55:16 +0000 | [diff] [blame] | 984 | |
| 985 | static void skl_ddi_clock_get(struct intel_encoder *encoder, |
Ander Conselvan de Oliveira | 5cec258 | 2015-01-15 14:55:21 +0200 | [diff] [blame] | 986 | struct intel_crtc_state *pipe_config) |
Satheeshakrishna M | 540e732 | 2014-11-13 14:55:16 +0000 | [diff] [blame] | 987 | { |
Chris Wilson | fac5e23 | 2016-07-04 11:34:36 +0100 | [diff] [blame] | 988 | struct drm_i915_private *dev_priv = to_i915(encoder->base.dev); |
Satheeshakrishna M | 540e732 | 2014-11-13 14:55:16 +0000 | [diff] [blame] | 989 | int link_clock = 0; |
| 990 | uint32_t dpll_ctl1, dpll; |
| 991 | |
Ander Conselvan de Oliveira | c856052 | 2016-09-01 15:08:07 -0700 | [diff] [blame] | 992 | dpll = intel_get_shared_dpll_id(dev_priv, pipe_config->shared_dpll); |
Satheeshakrishna M | 540e732 | 2014-11-13 14:55:16 +0000 | [diff] [blame] | 993 | |
| 994 | dpll_ctl1 = I915_READ(DPLL_CTRL1); |
| 995 | |
| 996 | if (dpll_ctl1 & DPLL_CTRL1_HDMI_MODE(dpll)) { |
| 997 | link_clock = skl_calc_wrpll_link(dev_priv, dpll); |
| 998 | } else { |
Damien Lespiau | 71cd842 | 2015-04-30 16:39:17 +0100 | [diff] [blame] | 999 | link_clock = dpll_ctl1 & DPLL_CTRL1_LINK_RATE_MASK(dpll); |
| 1000 | link_clock >>= DPLL_CTRL1_LINK_RATE_SHIFT(dpll); |
Satheeshakrishna M | 540e732 | 2014-11-13 14:55:16 +0000 | [diff] [blame] | 1001 | |
| 1002 | switch (link_clock) { |
Damien Lespiau | 71cd842 | 2015-04-30 16:39:17 +0100 | [diff] [blame] | 1003 | case DPLL_CTRL1_LINK_RATE_810: |
Satheeshakrishna M | 540e732 | 2014-11-13 14:55:16 +0000 | [diff] [blame] | 1004 | link_clock = 81000; |
| 1005 | break; |
Damien Lespiau | 71cd842 | 2015-04-30 16:39:17 +0100 | [diff] [blame] | 1006 | case DPLL_CTRL1_LINK_RATE_1080: |
Sonika Jindal | a8f3ef6 | 2015-03-05 10:02:30 +0530 | [diff] [blame] | 1007 | link_clock = 108000; |
| 1008 | break; |
Damien Lespiau | 71cd842 | 2015-04-30 16:39:17 +0100 | [diff] [blame] | 1009 | case DPLL_CTRL1_LINK_RATE_1350: |
Satheeshakrishna M | 540e732 | 2014-11-13 14:55:16 +0000 | [diff] [blame] | 1010 | link_clock = 135000; |
| 1011 | break; |
Damien Lespiau | 71cd842 | 2015-04-30 16:39:17 +0100 | [diff] [blame] | 1012 | case DPLL_CTRL1_LINK_RATE_1620: |
Sonika Jindal | a8f3ef6 | 2015-03-05 10:02:30 +0530 | [diff] [blame] | 1013 | link_clock = 162000; |
| 1014 | break; |
Damien Lespiau | 71cd842 | 2015-04-30 16:39:17 +0100 | [diff] [blame] | 1015 | case DPLL_CTRL1_LINK_RATE_2160: |
Sonika Jindal | a8f3ef6 | 2015-03-05 10:02:30 +0530 | [diff] [blame] | 1016 | link_clock = 216000; |
| 1017 | break; |
Damien Lespiau | 71cd842 | 2015-04-30 16:39:17 +0100 | [diff] [blame] | 1018 | case DPLL_CTRL1_LINK_RATE_2700: |
Satheeshakrishna M | 540e732 | 2014-11-13 14:55:16 +0000 | [diff] [blame] | 1019 | link_clock = 270000; |
| 1020 | break; |
| 1021 | default: |
| 1022 | WARN(1, "Unsupported link rate\n"); |
| 1023 | break; |
| 1024 | } |
| 1025 | link_clock *= 2; |
| 1026 | } |
| 1027 | |
| 1028 | pipe_config->port_clock = link_clock; |
| 1029 | |
Ville Syrjälä | 398a017 | 2015-06-30 15:33:51 +0300 | [diff] [blame] | 1030 | ddi_dotclock_get(pipe_config); |
Satheeshakrishna M | 540e732 | 2014-11-13 14:55:16 +0000 | [diff] [blame] | 1031 | } |
| 1032 | |
Daniel Vetter | 3d51278a | 2014-07-29 20:57:08 +0200 | [diff] [blame] | 1033 | static void hsw_ddi_clock_get(struct intel_encoder *encoder, |
Ander Conselvan de Oliveira | 5cec258 | 2015-01-15 14:55:21 +0200 | [diff] [blame] | 1034 | struct intel_crtc_state *pipe_config) |
Jesse Barnes | 1157855 | 2014-01-21 12:42:10 -0800 | [diff] [blame] | 1035 | { |
Chris Wilson | fac5e23 | 2016-07-04 11:34:36 +0100 | [diff] [blame] | 1036 | struct drm_i915_private *dev_priv = to_i915(encoder->base.dev); |
Jesse Barnes | 1157855 | 2014-01-21 12:42:10 -0800 | [diff] [blame] | 1037 | int link_clock = 0; |
| 1038 | u32 val, pll; |
| 1039 | |
Ander Conselvan de Oliveira | c856052 | 2016-09-01 15:08:07 -0700 | [diff] [blame] | 1040 | val = hsw_pll_to_ddi_pll_sel(pipe_config->shared_dpll); |
Jesse Barnes | 1157855 | 2014-01-21 12:42:10 -0800 | [diff] [blame] | 1041 | switch (val & PORT_CLK_SEL_MASK) { |
| 1042 | case PORT_CLK_SEL_LCPLL_810: |
| 1043 | link_clock = 81000; |
| 1044 | break; |
| 1045 | case PORT_CLK_SEL_LCPLL_1350: |
| 1046 | link_clock = 135000; |
| 1047 | break; |
| 1048 | case PORT_CLK_SEL_LCPLL_2700: |
| 1049 | link_clock = 270000; |
| 1050 | break; |
| 1051 | case PORT_CLK_SEL_WRPLL1: |
Ville Syrjälä | 01403de | 2015-09-18 20:03:33 +0300 | [diff] [blame] | 1052 | link_clock = hsw_ddi_calc_wrpll_link(dev_priv, WRPLL_CTL(0)); |
Jesse Barnes | 1157855 | 2014-01-21 12:42:10 -0800 | [diff] [blame] | 1053 | break; |
| 1054 | case PORT_CLK_SEL_WRPLL2: |
Ville Syrjälä | 01403de | 2015-09-18 20:03:33 +0300 | [diff] [blame] | 1055 | link_clock = hsw_ddi_calc_wrpll_link(dev_priv, WRPLL_CTL(1)); |
Jesse Barnes | 1157855 | 2014-01-21 12:42:10 -0800 | [diff] [blame] | 1056 | break; |
| 1057 | case PORT_CLK_SEL_SPLL: |
| 1058 | pll = I915_READ(SPLL_CTL) & SPLL_PLL_FREQ_MASK; |
| 1059 | if (pll == SPLL_PLL_FREQ_810MHz) |
| 1060 | link_clock = 81000; |
| 1061 | else if (pll == SPLL_PLL_FREQ_1350MHz) |
| 1062 | link_clock = 135000; |
| 1063 | else if (pll == SPLL_PLL_FREQ_2700MHz) |
| 1064 | link_clock = 270000; |
| 1065 | else { |
| 1066 | WARN(1, "bad spll freq\n"); |
| 1067 | return; |
| 1068 | } |
| 1069 | break; |
| 1070 | default: |
| 1071 | WARN(1, "bad port clock sel\n"); |
| 1072 | return; |
| 1073 | } |
| 1074 | |
| 1075 | pipe_config->port_clock = link_clock * 2; |
| 1076 | |
Ville Syrjälä | 398a017 | 2015-06-30 15:33:51 +0300 | [diff] [blame] | 1077 | ddi_dotclock_get(pipe_config); |
Jesse Barnes | 1157855 | 2014-01-21 12:42:10 -0800 | [diff] [blame] | 1078 | } |
| 1079 | |
Satheeshakrishna M | 977bb38 | 2014-08-22 09:49:12 +0530 | [diff] [blame] | 1080 | static int bxt_calc_pll_link(struct drm_i915_private *dev_priv, |
| 1081 | enum intel_dpll_id dpll) |
| 1082 | { |
Imre Deak | aa610dc | 2015-06-22 23:35:52 +0300 | [diff] [blame] | 1083 | struct intel_shared_dpll *pll; |
| 1084 | struct intel_dpll_hw_state *state; |
Ander Conselvan de Oliveira | 9e2c847 | 2016-05-04 12:11:57 +0300 | [diff] [blame] | 1085 | struct dpll clock; |
Imre Deak | aa610dc | 2015-06-22 23:35:52 +0300 | [diff] [blame] | 1086 | |
| 1087 | /* For DDI ports we always use a shared PLL. */ |
| 1088 | if (WARN_ON(dpll == DPLL_ID_PRIVATE)) |
| 1089 | return 0; |
| 1090 | |
| 1091 | pll = &dev_priv->shared_dplls[dpll]; |
Ander Conselvan de Oliveira | 2c42e53 | 2016-12-29 17:22:09 +0200 | [diff] [blame] | 1092 | state = &pll->state.hw_state; |
Imre Deak | aa610dc | 2015-06-22 23:35:52 +0300 | [diff] [blame] | 1093 | |
| 1094 | clock.m1 = 2; |
| 1095 | clock.m2 = (state->pll0 & PORT_PLL_M2_MASK) << 22; |
| 1096 | if (state->pll3 & PORT_PLL_M2_FRAC_ENABLE) |
| 1097 | clock.m2 |= state->pll2 & PORT_PLL_M2_FRAC_MASK; |
| 1098 | clock.n = (state->pll1 & PORT_PLL_N_MASK) >> PORT_PLL_N_SHIFT; |
| 1099 | clock.p1 = (state->ebb0 & PORT_PLL_P1_MASK) >> PORT_PLL_P1_SHIFT; |
| 1100 | clock.p2 = (state->ebb0 & PORT_PLL_P2_MASK) >> PORT_PLL_P2_SHIFT; |
| 1101 | |
| 1102 | return chv_calc_dpll_params(100000, &clock); |
Satheeshakrishna M | 977bb38 | 2014-08-22 09:49:12 +0530 | [diff] [blame] | 1103 | } |
| 1104 | |
| 1105 | static void bxt_ddi_clock_get(struct intel_encoder *encoder, |
| 1106 | struct intel_crtc_state *pipe_config) |
| 1107 | { |
Chris Wilson | fac5e23 | 2016-07-04 11:34:36 +0100 | [diff] [blame] | 1108 | struct drm_i915_private *dev_priv = to_i915(encoder->base.dev); |
Satheeshakrishna M | 977bb38 | 2014-08-22 09:49:12 +0530 | [diff] [blame] | 1109 | enum port port = intel_ddi_get_encoder_port(encoder); |
| 1110 | uint32_t dpll = port; |
| 1111 | |
Ville Syrjälä | 398a017 | 2015-06-30 15:33:51 +0300 | [diff] [blame] | 1112 | pipe_config->port_clock = bxt_calc_pll_link(dev_priv, dpll); |
Satheeshakrishna M | 977bb38 | 2014-08-22 09:49:12 +0530 | [diff] [blame] | 1113 | |
Ville Syrjälä | 398a017 | 2015-06-30 15:33:51 +0300 | [diff] [blame] | 1114 | ddi_dotclock_get(pipe_config); |
Satheeshakrishna M | 977bb38 | 2014-08-22 09:49:12 +0530 | [diff] [blame] | 1115 | } |
| 1116 | |
Daniel Vetter | 3d51278a | 2014-07-29 20:57:08 +0200 | [diff] [blame] | 1117 | void intel_ddi_clock_get(struct intel_encoder *encoder, |
Ander Conselvan de Oliveira | 5cec258 | 2015-01-15 14:55:21 +0200 | [diff] [blame] | 1118 | struct intel_crtc_state *pipe_config) |
Daniel Vetter | 3d51278a | 2014-07-29 20:57:08 +0200 | [diff] [blame] | 1119 | { |
Tvrtko Ursulin | 0853723 | 2016-10-13 11:03:02 +0100 | [diff] [blame] | 1120 | struct drm_i915_private *dev_priv = to_i915(encoder->base.dev); |
Damien Lespiau | 22606a1 | 2014-12-12 14:26:57 +0000 | [diff] [blame] | 1121 | |
Tvrtko Ursulin | 0853723 | 2016-10-13 11:03:02 +0100 | [diff] [blame] | 1122 | if (INTEL_GEN(dev_priv) <= 8) |
Damien Lespiau | 22606a1 | 2014-12-12 14:26:57 +0000 | [diff] [blame] | 1123 | hsw_ddi_clock_get(encoder, pipe_config); |
Rodrigo Vivi | b976dc5 | 2017-01-23 10:32:37 -0800 | [diff] [blame] | 1124 | else if (IS_GEN9_BC(dev_priv)) |
Damien Lespiau | 22606a1 | 2014-12-12 14:26:57 +0000 | [diff] [blame] | 1125 | skl_ddi_clock_get(encoder, pipe_config); |
Ander Conselvan de Oliveira | cc3f90f | 2016-12-02 10:23:49 +0200 | [diff] [blame] | 1126 | else if (IS_GEN9_LP(dev_priv)) |
Satheeshakrishna M | 977bb38 | 2014-08-22 09:49:12 +0530 | [diff] [blame] | 1127 | bxt_ddi_clock_get(encoder, pipe_config); |
Daniel Vetter | 3d51278a | 2014-07-29 20:57:08 +0200 | [diff] [blame] | 1128 | } |
| 1129 | |
Damien Lespiau | 0220ab6 | 2014-07-29 18:06:22 +0100 | [diff] [blame] | 1130 | static bool |
Damien Lespiau | d664c0c | 2014-07-29 18:06:23 +0100 | [diff] [blame] | 1131 | hsw_ddi_pll_select(struct intel_crtc *intel_crtc, |
Ander Conselvan de Oliveira | 190f68c | 2015-01-15 14:55:23 +0200 | [diff] [blame] | 1132 | struct intel_crtc_state *crtc_state, |
Ville Syrjälä | 96f3f1f | 2015-07-06 15:10:02 +0300 | [diff] [blame] | 1133 | struct intel_encoder *intel_encoder) |
Paulo Zanoni | 6441ab5 | 2012-10-05 12:05:58 -0300 | [diff] [blame] | 1134 | { |
Ander Conselvan de Oliveira | daedf20 | 2016-03-08 17:46:23 +0200 | [diff] [blame] | 1135 | struct intel_shared_dpll *pll; |
Ville Syrjälä | 96f3f1f | 2015-07-06 15:10:02 +0300 | [diff] [blame] | 1136 | |
Ander Conselvan de Oliveira | 9d16da6 | 2016-03-08 17:46:26 +0200 | [diff] [blame] | 1137 | pll = intel_get_shared_dpll(intel_crtc, crtc_state, |
| 1138 | intel_encoder); |
| 1139 | if (!pll) |
| 1140 | DRM_DEBUG_DRIVER("failed to find PLL for pipe %c\n", |
| 1141 | pipe_name(intel_crtc->pipe)); |
| 1142 | |
| 1143 | return pll; |
Paulo Zanoni | 6441ab5 | 2012-10-05 12:05:58 -0300 | [diff] [blame] | 1144 | } |
| 1145 | |
Satheeshakrishna M | 82d3543 | 2014-11-13 14:55:20 +0000 | [diff] [blame] | 1146 | static bool |
| 1147 | skl_ddi_pll_select(struct intel_crtc *intel_crtc, |
Ander Conselvan de Oliveira | 190f68c | 2015-01-15 14:55:23 +0200 | [diff] [blame] | 1148 | struct intel_crtc_state *crtc_state, |
Ville Syrjälä | 96f3f1f | 2015-07-06 15:10:02 +0300 | [diff] [blame] | 1149 | struct intel_encoder *intel_encoder) |
Satheeshakrishna M | 82d3543 | 2014-11-13 14:55:20 +0000 | [diff] [blame] | 1150 | { |
| 1151 | struct intel_shared_dpll *pll; |
Satheeshakrishna M | 82d3543 | 2014-11-13 14:55:20 +0000 | [diff] [blame] | 1152 | |
Ander Conselvan de Oliveira | daedf20 | 2016-03-08 17:46:23 +0200 | [diff] [blame] | 1153 | pll = intel_get_shared_dpll(intel_crtc, crtc_state, intel_encoder); |
Satheeshakrishna M | 82d3543 | 2014-11-13 14:55:20 +0000 | [diff] [blame] | 1154 | if (pll == NULL) { |
| 1155 | DRM_DEBUG_DRIVER("failed to find PLL for pipe %c\n", |
| 1156 | pipe_name(intel_crtc->pipe)); |
| 1157 | return false; |
| 1158 | } |
| 1159 | |
Satheeshakrishna M | 82d3543 | 2014-11-13 14:55:20 +0000 | [diff] [blame] | 1160 | return true; |
| 1161 | } |
Damien Lespiau | 0220ab6 | 2014-07-29 18:06:22 +0100 | [diff] [blame] | 1162 | |
Satheeshakrishna M | d683f3b | 2014-08-22 09:49:08 +0530 | [diff] [blame] | 1163 | static bool |
| 1164 | bxt_ddi_pll_select(struct intel_crtc *intel_crtc, |
| 1165 | struct intel_crtc_state *crtc_state, |
Ville Syrjälä | 96f3f1f | 2015-07-06 15:10:02 +0300 | [diff] [blame] | 1166 | struct intel_encoder *intel_encoder) |
Satheeshakrishna M | d683f3b | 2014-08-22 09:49:08 +0530 | [diff] [blame] | 1167 | { |
Ander Conselvan de Oliveira | 34177c2 | 2016-03-08 17:46:25 +0200 | [diff] [blame] | 1168 | return !!intel_get_shared_dpll(intel_crtc, crtc_state, intel_encoder); |
Satheeshakrishna M | d683f3b | 2014-08-22 09:49:08 +0530 | [diff] [blame] | 1169 | } |
| 1170 | |
Damien Lespiau | 0220ab6 | 2014-07-29 18:06:22 +0100 | [diff] [blame] | 1171 | /* |
| 1172 | * Tries to find a *shared* PLL for the CRTC and store it in |
| 1173 | * intel_crtc->ddi_pll_sel. |
| 1174 | * |
| 1175 | * For private DPLLs, compute_config() should do the selection for us. This |
| 1176 | * function should be folded into compute_config() eventually. |
| 1177 | */ |
Ander Conselvan de Oliveira | 190f68c | 2015-01-15 14:55:23 +0200 | [diff] [blame] | 1178 | bool intel_ddi_pll_select(struct intel_crtc *intel_crtc, |
| 1179 | struct intel_crtc_state *crtc_state) |
Damien Lespiau | 0220ab6 | 2014-07-29 18:06:22 +0100 | [diff] [blame] | 1180 | { |
Tvrtko Ursulin | 0853723 | 2016-10-13 11:03:02 +0100 | [diff] [blame] | 1181 | struct drm_i915_private *dev_priv = to_i915(intel_crtc->base.dev); |
Ander Conselvan de Oliveira | d0737e1 | 2014-10-29 11:32:30 +0200 | [diff] [blame] | 1182 | struct intel_encoder *intel_encoder = |
Ander Conselvan de Oliveira | 3165c07 | 2015-03-20 16:18:12 +0200 | [diff] [blame] | 1183 | intel_ddi_get_crtc_new_encoder(crtc_state); |
Damien Lespiau | 0220ab6 | 2014-07-29 18:06:22 +0100 | [diff] [blame] | 1184 | |
Rodrigo Vivi | b976dc5 | 2017-01-23 10:32:37 -0800 | [diff] [blame] | 1185 | if (IS_GEN9_BC(dev_priv)) |
Ander Conselvan de Oliveira | 190f68c | 2015-01-15 14:55:23 +0200 | [diff] [blame] | 1186 | return skl_ddi_pll_select(intel_crtc, crtc_state, |
Ville Syrjälä | 96f3f1f | 2015-07-06 15:10:02 +0300 | [diff] [blame] | 1187 | intel_encoder); |
Ander Conselvan de Oliveira | cc3f90f | 2016-12-02 10:23:49 +0200 | [diff] [blame] | 1188 | else if (IS_GEN9_LP(dev_priv)) |
Satheeshakrishna M | d683f3b | 2014-08-22 09:49:08 +0530 | [diff] [blame] | 1189 | return bxt_ddi_pll_select(intel_crtc, crtc_state, |
Ville Syrjälä | 96f3f1f | 2015-07-06 15:10:02 +0300 | [diff] [blame] | 1190 | intel_encoder); |
Satheeshakrishna M | 82d3543 | 2014-11-13 14:55:20 +0000 | [diff] [blame] | 1191 | else |
Ander Conselvan de Oliveira | 190f68c | 2015-01-15 14:55:23 +0200 | [diff] [blame] | 1192 | return hsw_ddi_pll_select(intel_crtc, crtc_state, |
Ville Syrjälä | 96f3f1f | 2015-07-06 15:10:02 +0300 | [diff] [blame] | 1193 | intel_encoder); |
Damien Lespiau | 0220ab6 | 2014-07-29 18:06:22 +0100 | [diff] [blame] | 1194 | } |
| 1195 | |
Paulo Zanoni | dae8479 | 2012-10-15 15:51:30 -0300 | [diff] [blame] | 1196 | void intel_ddi_set_pipe_settings(struct drm_crtc *crtc) |
| 1197 | { |
Chris Wilson | fac5e23 | 2016-07-04 11:34:36 +0100 | [diff] [blame] | 1198 | struct drm_i915_private *dev_priv = to_i915(crtc->dev); |
Paulo Zanoni | dae8479 | 2012-10-15 15:51:30 -0300 | [diff] [blame] | 1199 | struct intel_crtc *intel_crtc = to_intel_crtc(crtc); |
| 1200 | struct intel_encoder *intel_encoder = intel_ddi_get_crtc_encoder(crtc); |
Ander Conselvan de Oliveira | 6e3c971 | 2015-01-15 14:55:25 +0200 | [diff] [blame] | 1201 | enum transcoder cpu_transcoder = intel_crtc->config->cpu_transcoder; |
Paulo Zanoni | dae8479 | 2012-10-15 15:51:30 -0300 | [diff] [blame] | 1202 | int type = intel_encoder->type; |
| 1203 | uint32_t temp; |
| 1204 | |
Ville Syrjälä | cca0502 | 2016-06-22 21:57:06 +0300 | [diff] [blame] | 1205 | if (type == INTEL_OUTPUT_DP || type == INTEL_OUTPUT_EDP || type == INTEL_OUTPUT_DP_MST) { |
Jani Nikula | 4d1de97 | 2016-03-18 17:05:42 +0200 | [diff] [blame] | 1206 | WARN_ON(transcoder_is_dsi(cpu_transcoder)); |
| 1207 | |
Paulo Zanoni | c980979 | 2012-10-23 18:30:00 -0200 | [diff] [blame] | 1208 | temp = TRANS_MSA_SYNC_CLK; |
Ander Conselvan de Oliveira | 6e3c971 | 2015-01-15 14:55:25 +0200 | [diff] [blame] | 1209 | switch (intel_crtc->config->pipe_bpp) { |
Paulo Zanoni | dae8479 | 2012-10-15 15:51:30 -0300 | [diff] [blame] | 1210 | case 18: |
Paulo Zanoni | c980979 | 2012-10-23 18:30:00 -0200 | [diff] [blame] | 1211 | temp |= TRANS_MSA_6_BPC; |
Paulo Zanoni | dae8479 | 2012-10-15 15:51:30 -0300 | [diff] [blame] | 1212 | break; |
| 1213 | case 24: |
Paulo Zanoni | c980979 | 2012-10-23 18:30:00 -0200 | [diff] [blame] | 1214 | temp |= TRANS_MSA_8_BPC; |
Paulo Zanoni | dae8479 | 2012-10-15 15:51:30 -0300 | [diff] [blame] | 1215 | break; |
| 1216 | case 30: |
Paulo Zanoni | c980979 | 2012-10-23 18:30:00 -0200 | [diff] [blame] | 1217 | temp |= TRANS_MSA_10_BPC; |
Paulo Zanoni | dae8479 | 2012-10-15 15:51:30 -0300 | [diff] [blame] | 1218 | break; |
| 1219 | case 36: |
Paulo Zanoni | c980979 | 2012-10-23 18:30:00 -0200 | [diff] [blame] | 1220 | temp |= TRANS_MSA_12_BPC; |
Paulo Zanoni | dae8479 | 2012-10-15 15:51:30 -0300 | [diff] [blame] | 1221 | break; |
| 1222 | default: |
Daniel Vetter | 4e53c2e | 2013-03-27 00:44:58 +0100 | [diff] [blame] | 1223 | BUG(); |
Paulo Zanoni | dae8479 | 2012-10-15 15:51:30 -0300 | [diff] [blame] | 1224 | } |
Paulo Zanoni | c980979 | 2012-10-23 18:30:00 -0200 | [diff] [blame] | 1225 | I915_WRITE(TRANS_MSA_MISC(cpu_transcoder), temp); |
Paulo Zanoni | dae8479 | 2012-10-15 15:51:30 -0300 | [diff] [blame] | 1226 | } |
| 1227 | } |
| 1228 | |
Dave Airlie | 0e32b39 | 2014-05-02 14:02:48 +1000 | [diff] [blame] | 1229 | void intel_ddi_set_vc_payload_alloc(struct drm_crtc *crtc, bool state) |
| 1230 | { |
| 1231 | struct intel_crtc *intel_crtc = to_intel_crtc(crtc); |
| 1232 | struct drm_device *dev = crtc->dev; |
Chris Wilson | fac5e23 | 2016-07-04 11:34:36 +0100 | [diff] [blame] | 1233 | struct drm_i915_private *dev_priv = to_i915(dev); |
Ander Conselvan de Oliveira | 6e3c971 | 2015-01-15 14:55:25 +0200 | [diff] [blame] | 1234 | enum transcoder cpu_transcoder = intel_crtc->config->cpu_transcoder; |
Dave Airlie | 0e32b39 | 2014-05-02 14:02:48 +1000 | [diff] [blame] | 1235 | uint32_t temp; |
| 1236 | temp = I915_READ(TRANS_DDI_FUNC_CTL(cpu_transcoder)); |
| 1237 | if (state == true) |
| 1238 | temp |= TRANS_DDI_DP_VC_PAYLOAD_ALLOC; |
| 1239 | else |
| 1240 | temp &= ~TRANS_DDI_DP_VC_PAYLOAD_ALLOC; |
| 1241 | I915_WRITE(TRANS_DDI_FUNC_CTL(cpu_transcoder), temp); |
| 1242 | } |
| 1243 | |
Damien Lespiau | 8228c25 | 2013-03-07 15:30:27 +0000 | [diff] [blame] | 1244 | void intel_ddi_enable_transcoder_func(struct drm_crtc *crtc) |
Paulo Zanoni | 8d9ddbc | 2012-10-05 12:05:53 -0300 | [diff] [blame] | 1245 | { |
| 1246 | struct intel_crtc *intel_crtc = to_intel_crtc(crtc); |
| 1247 | struct intel_encoder *intel_encoder = intel_ddi_get_crtc_encoder(crtc); |
Paulo Zanoni | c7670b1 | 2013-11-02 21:07:37 -0700 | [diff] [blame] | 1248 | struct drm_device *dev = crtc->dev; |
Chris Wilson | fac5e23 | 2016-07-04 11:34:36 +0100 | [diff] [blame] | 1249 | struct drm_i915_private *dev_priv = to_i915(dev); |
Paulo Zanoni | 8d9ddbc | 2012-10-05 12:05:53 -0300 | [diff] [blame] | 1250 | enum pipe pipe = intel_crtc->pipe; |
Ander Conselvan de Oliveira | 6e3c971 | 2015-01-15 14:55:25 +0200 | [diff] [blame] | 1251 | enum transcoder cpu_transcoder = intel_crtc->config->cpu_transcoder; |
Paulo Zanoni | 174edf1 | 2012-10-26 19:05:50 -0200 | [diff] [blame] | 1252 | enum port port = intel_ddi_get_encoder_port(intel_encoder); |
Paulo Zanoni | 7739c33 | 2012-10-15 15:51:29 -0300 | [diff] [blame] | 1253 | int type = intel_encoder->type; |
Paulo Zanoni | 8d9ddbc | 2012-10-05 12:05:53 -0300 | [diff] [blame] | 1254 | uint32_t temp; |
| 1255 | |
Paulo Zanoni | ad80a81 | 2012-10-24 16:06:19 -0200 | [diff] [blame] | 1256 | /* Enable TRANS_DDI_FUNC_CTL for the pipe to work in HDMI mode */ |
| 1257 | temp = TRANS_DDI_FUNC_ENABLE; |
Paulo Zanoni | 174edf1 | 2012-10-26 19:05:50 -0200 | [diff] [blame] | 1258 | temp |= TRANS_DDI_SELECT_PORT(port); |
Paulo Zanoni | dfcef25 | 2012-08-08 14:15:29 -0300 | [diff] [blame] | 1259 | |
Ander Conselvan de Oliveira | 6e3c971 | 2015-01-15 14:55:25 +0200 | [diff] [blame] | 1260 | switch (intel_crtc->config->pipe_bpp) { |
Paulo Zanoni | dfcef25 | 2012-08-08 14:15:29 -0300 | [diff] [blame] | 1261 | case 18: |
Paulo Zanoni | ad80a81 | 2012-10-24 16:06:19 -0200 | [diff] [blame] | 1262 | temp |= TRANS_DDI_BPC_6; |
Paulo Zanoni | dfcef25 | 2012-08-08 14:15:29 -0300 | [diff] [blame] | 1263 | break; |
| 1264 | case 24: |
Paulo Zanoni | ad80a81 | 2012-10-24 16:06:19 -0200 | [diff] [blame] | 1265 | temp |= TRANS_DDI_BPC_8; |
Paulo Zanoni | dfcef25 | 2012-08-08 14:15:29 -0300 | [diff] [blame] | 1266 | break; |
| 1267 | case 30: |
Paulo Zanoni | ad80a81 | 2012-10-24 16:06:19 -0200 | [diff] [blame] | 1268 | temp |= TRANS_DDI_BPC_10; |
Paulo Zanoni | dfcef25 | 2012-08-08 14:15:29 -0300 | [diff] [blame] | 1269 | break; |
| 1270 | case 36: |
Paulo Zanoni | ad80a81 | 2012-10-24 16:06:19 -0200 | [diff] [blame] | 1271 | temp |= TRANS_DDI_BPC_12; |
Paulo Zanoni | dfcef25 | 2012-08-08 14:15:29 -0300 | [diff] [blame] | 1272 | break; |
| 1273 | default: |
Daniel Vetter | 4e53c2e | 2013-03-27 00:44:58 +0100 | [diff] [blame] | 1274 | BUG(); |
Paulo Zanoni | dfcef25 | 2012-08-08 14:15:29 -0300 | [diff] [blame] | 1275 | } |
Eugeni Dodonov | 72662e1 | 2012-05-09 15:37:31 -0300 | [diff] [blame] | 1276 | |
Ander Conselvan de Oliveira | 6e3c971 | 2015-01-15 14:55:25 +0200 | [diff] [blame] | 1277 | if (intel_crtc->config->base.adjusted_mode.flags & DRM_MODE_FLAG_PVSYNC) |
Paulo Zanoni | ad80a81 | 2012-10-24 16:06:19 -0200 | [diff] [blame] | 1278 | temp |= TRANS_DDI_PVSYNC; |
Ander Conselvan de Oliveira | 6e3c971 | 2015-01-15 14:55:25 +0200 | [diff] [blame] | 1279 | if (intel_crtc->config->base.adjusted_mode.flags & DRM_MODE_FLAG_PHSYNC) |
Paulo Zanoni | ad80a81 | 2012-10-24 16:06:19 -0200 | [diff] [blame] | 1280 | temp |= TRANS_DDI_PHSYNC; |
Paulo Zanoni | f63eb7c4 | 2012-08-08 14:15:28 -0300 | [diff] [blame] | 1281 | |
Paulo Zanoni | e6f0bfc | 2012-10-23 18:30:04 -0200 | [diff] [blame] | 1282 | if (cpu_transcoder == TRANSCODER_EDP) { |
| 1283 | switch (pipe) { |
| 1284 | case PIPE_A: |
Paulo Zanoni | c7670b1 | 2013-11-02 21:07:37 -0700 | [diff] [blame] | 1285 | /* On Haswell, can only use the always-on power well for |
| 1286 | * eDP when not using the panel fitter, and when not |
| 1287 | * using motion blur mitigation (which we don't |
| 1288 | * support). */ |
Tvrtko Ursulin | 772c2a5 | 2016-10-13 11:03:01 +0100 | [diff] [blame] | 1289 | if (IS_HASWELL(dev_priv) && |
Ander Conselvan de Oliveira | 6e3c971 | 2015-01-15 14:55:25 +0200 | [diff] [blame] | 1290 | (intel_crtc->config->pch_pfit.enabled || |
| 1291 | intel_crtc->config->pch_pfit.force_thru)) |
Daniel Vetter | d6dd9eb | 2013-01-29 16:35:20 -0200 | [diff] [blame] | 1292 | temp |= TRANS_DDI_EDP_INPUT_A_ONOFF; |
| 1293 | else |
| 1294 | temp |= TRANS_DDI_EDP_INPUT_A_ON; |
Paulo Zanoni | e6f0bfc | 2012-10-23 18:30:04 -0200 | [diff] [blame] | 1295 | break; |
| 1296 | case PIPE_B: |
| 1297 | temp |= TRANS_DDI_EDP_INPUT_B_ONOFF; |
| 1298 | break; |
| 1299 | case PIPE_C: |
| 1300 | temp |= TRANS_DDI_EDP_INPUT_C_ONOFF; |
| 1301 | break; |
| 1302 | default: |
| 1303 | BUG(); |
| 1304 | break; |
| 1305 | } |
| 1306 | } |
| 1307 | |
Paulo Zanoni | 7739c33 | 2012-10-15 15:51:29 -0300 | [diff] [blame] | 1308 | if (type == INTEL_OUTPUT_HDMI) { |
Ander Conselvan de Oliveira | 6e3c971 | 2015-01-15 14:55:25 +0200 | [diff] [blame] | 1309 | if (intel_crtc->config->has_hdmi_sink) |
Paulo Zanoni | ad80a81 | 2012-10-24 16:06:19 -0200 | [diff] [blame] | 1310 | temp |= TRANS_DDI_MODE_SELECT_HDMI; |
Paulo Zanoni | 8d9ddbc | 2012-10-05 12:05:53 -0300 | [diff] [blame] | 1311 | else |
Paulo Zanoni | ad80a81 | 2012-10-24 16:06:19 -0200 | [diff] [blame] | 1312 | temp |= TRANS_DDI_MODE_SELECT_DVI; |
Paulo Zanoni | 7739c33 | 2012-10-15 15:51:29 -0300 | [diff] [blame] | 1313 | } else if (type == INTEL_OUTPUT_ANALOG) { |
Paulo Zanoni | ad80a81 | 2012-10-24 16:06:19 -0200 | [diff] [blame] | 1314 | temp |= TRANS_DDI_MODE_SELECT_FDI; |
Ander Conselvan de Oliveira | 6e3c971 | 2015-01-15 14:55:25 +0200 | [diff] [blame] | 1315 | temp |= (intel_crtc->config->fdi_lanes - 1) << 1; |
Ville Syrjälä | cca0502 | 2016-06-22 21:57:06 +0300 | [diff] [blame] | 1316 | } else if (type == INTEL_OUTPUT_DP || |
Paulo Zanoni | 7739c33 | 2012-10-15 15:51:29 -0300 | [diff] [blame] | 1317 | type == INTEL_OUTPUT_EDP) { |
Ville Syrjälä | 64ee2fd | 2016-07-28 17:50:39 +0300 | [diff] [blame] | 1318 | temp |= TRANS_DDI_MODE_SELECT_DP_SST; |
Ville Syrjälä | 90a6b7b | 2015-07-06 16:39:15 +0300 | [diff] [blame] | 1319 | temp |= DDI_PORT_WIDTH(intel_crtc->config->lane_count); |
Dave Airlie | 0e32b39 | 2014-05-02 14:02:48 +1000 | [diff] [blame] | 1320 | } else if (type == INTEL_OUTPUT_DP_MST) { |
Ville Syrjälä | 64ee2fd | 2016-07-28 17:50:39 +0300 | [diff] [blame] | 1321 | temp |= TRANS_DDI_MODE_SELECT_DP_MST; |
Ville Syrjälä | 90a6b7b | 2015-07-06 16:39:15 +0300 | [diff] [blame] | 1322 | temp |= DDI_PORT_WIDTH(intel_crtc->config->lane_count); |
Paulo Zanoni | 8d9ddbc | 2012-10-05 12:05:53 -0300 | [diff] [blame] | 1323 | } else { |
Ville Syrjälä | 84f44ce | 2013-04-17 17:48:49 +0300 | [diff] [blame] | 1324 | WARN(1, "Invalid encoder type %d for pipe %c\n", |
| 1325 | intel_encoder->type, pipe_name(pipe)); |
Paulo Zanoni | 8d9ddbc | 2012-10-05 12:05:53 -0300 | [diff] [blame] | 1326 | } |
| 1327 | |
Paulo Zanoni | ad80a81 | 2012-10-24 16:06:19 -0200 | [diff] [blame] | 1328 | I915_WRITE(TRANS_DDI_FUNC_CTL(cpu_transcoder), temp); |
Paulo Zanoni | 8d9ddbc | 2012-10-05 12:05:53 -0300 | [diff] [blame] | 1329 | } |
| 1330 | |
Paulo Zanoni | ad80a81 | 2012-10-24 16:06:19 -0200 | [diff] [blame] | 1331 | void intel_ddi_disable_transcoder_func(struct drm_i915_private *dev_priv, |
| 1332 | enum transcoder cpu_transcoder) |
Paulo Zanoni | 8d9ddbc | 2012-10-05 12:05:53 -0300 | [diff] [blame] | 1333 | { |
Ville Syrjälä | f0f59a0 | 2015-11-18 15:33:26 +0200 | [diff] [blame] | 1334 | i915_reg_t reg = TRANS_DDI_FUNC_CTL(cpu_transcoder); |
Paulo Zanoni | 8d9ddbc | 2012-10-05 12:05:53 -0300 | [diff] [blame] | 1335 | uint32_t val = I915_READ(reg); |
| 1336 | |
Dave Airlie | 0e32b39 | 2014-05-02 14:02:48 +1000 | [diff] [blame] | 1337 | val &= ~(TRANS_DDI_FUNC_ENABLE | TRANS_DDI_PORT_MASK | TRANS_DDI_DP_VC_PAYLOAD_ALLOC); |
Paulo Zanoni | ad80a81 | 2012-10-24 16:06:19 -0200 | [diff] [blame] | 1338 | val |= TRANS_DDI_PORT_NONE; |
Paulo Zanoni | 8d9ddbc | 2012-10-05 12:05:53 -0300 | [diff] [blame] | 1339 | I915_WRITE(reg, val); |
Eugeni Dodonov | 72662e1 | 2012-05-09 15:37:31 -0300 | [diff] [blame] | 1340 | } |
| 1341 | |
Paulo Zanoni | bcbc889 | 2012-10-26 19:05:51 -0200 | [diff] [blame] | 1342 | bool intel_ddi_connector_get_hw_state(struct intel_connector *intel_connector) |
| 1343 | { |
| 1344 | struct drm_device *dev = intel_connector->base.dev; |
Chris Wilson | fac5e23 | 2016-07-04 11:34:36 +0100 | [diff] [blame] | 1345 | struct drm_i915_private *dev_priv = to_i915(dev); |
Paulo Zanoni | bcbc889 | 2012-10-26 19:05:51 -0200 | [diff] [blame] | 1346 | struct intel_encoder *intel_encoder = intel_connector->encoder; |
| 1347 | int type = intel_connector->base.connector_type; |
| 1348 | enum port port = intel_ddi_get_encoder_port(intel_encoder); |
| 1349 | enum pipe pipe = 0; |
| 1350 | enum transcoder cpu_transcoder; |
| 1351 | uint32_t tmp; |
Imre Deak | e27daab | 2016-02-12 18:55:16 +0200 | [diff] [blame] | 1352 | bool ret; |
Paulo Zanoni | bcbc889 | 2012-10-26 19:05:51 -0200 | [diff] [blame] | 1353 | |
Ander Conselvan de Oliveira | 79f255a | 2017-02-22 08:34:27 +0200 | [diff] [blame] | 1354 | if (!intel_display_power_get_if_enabled(dev_priv, |
| 1355 | intel_encoder->power_domain)) |
Paulo Zanoni | 882244a | 2014-04-01 14:55:12 -0300 | [diff] [blame] | 1356 | return false; |
| 1357 | |
Imre Deak | e27daab | 2016-02-12 18:55:16 +0200 | [diff] [blame] | 1358 | if (!intel_encoder->get_hw_state(intel_encoder, &pipe)) { |
| 1359 | ret = false; |
| 1360 | goto out; |
| 1361 | } |
Paulo Zanoni | bcbc889 | 2012-10-26 19:05:51 -0200 | [diff] [blame] | 1362 | |
| 1363 | if (port == PORT_A) |
| 1364 | cpu_transcoder = TRANSCODER_EDP; |
| 1365 | else |
Daniel Vetter | 1a240d4 | 2012-11-29 22:18:51 +0100 | [diff] [blame] | 1366 | cpu_transcoder = (enum transcoder) pipe; |
Paulo Zanoni | bcbc889 | 2012-10-26 19:05:51 -0200 | [diff] [blame] | 1367 | |
| 1368 | tmp = I915_READ(TRANS_DDI_FUNC_CTL(cpu_transcoder)); |
| 1369 | |
| 1370 | switch (tmp & TRANS_DDI_MODE_SELECT_MASK) { |
| 1371 | case TRANS_DDI_MODE_SELECT_HDMI: |
| 1372 | case TRANS_DDI_MODE_SELECT_DVI: |
Imre Deak | e27daab | 2016-02-12 18:55:16 +0200 | [diff] [blame] | 1373 | ret = type == DRM_MODE_CONNECTOR_HDMIA; |
| 1374 | break; |
Paulo Zanoni | bcbc889 | 2012-10-26 19:05:51 -0200 | [diff] [blame] | 1375 | |
| 1376 | case TRANS_DDI_MODE_SELECT_DP_SST: |
Imre Deak | e27daab | 2016-02-12 18:55:16 +0200 | [diff] [blame] | 1377 | ret = type == DRM_MODE_CONNECTOR_eDP || |
| 1378 | type == DRM_MODE_CONNECTOR_DisplayPort; |
| 1379 | break; |
| 1380 | |
Dave Airlie | 0e32b39 | 2014-05-02 14:02:48 +1000 | [diff] [blame] | 1381 | case TRANS_DDI_MODE_SELECT_DP_MST: |
| 1382 | /* if the transcoder is in MST state then |
| 1383 | * connector isn't connected */ |
Imre Deak | e27daab | 2016-02-12 18:55:16 +0200 | [diff] [blame] | 1384 | ret = false; |
| 1385 | break; |
Paulo Zanoni | bcbc889 | 2012-10-26 19:05:51 -0200 | [diff] [blame] | 1386 | |
| 1387 | case TRANS_DDI_MODE_SELECT_FDI: |
Imre Deak | e27daab | 2016-02-12 18:55:16 +0200 | [diff] [blame] | 1388 | ret = type == DRM_MODE_CONNECTOR_VGA; |
| 1389 | break; |
Paulo Zanoni | bcbc889 | 2012-10-26 19:05:51 -0200 | [diff] [blame] | 1390 | |
| 1391 | default: |
Imre Deak | e27daab | 2016-02-12 18:55:16 +0200 | [diff] [blame] | 1392 | ret = false; |
| 1393 | break; |
Paulo Zanoni | bcbc889 | 2012-10-26 19:05:51 -0200 | [diff] [blame] | 1394 | } |
Imre Deak | e27daab | 2016-02-12 18:55:16 +0200 | [diff] [blame] | 1395 | |
| 1396 | out: |
Ander Conselvan de Oliveira | 79f255a | 2017-02-22 08:34:27 +0200 | [diff] [blame] | 1397 | intel_display_power_put(dev_priv, intel_encoder->power_domain); |
Imre Deak | e27daab | 2016-02-12 18:55:16 +0200 | [diff] [blame] | 1398 | |
| 1399 | return ret; |
Paulo Zanoni | bcbc889 | 2012-10-26 19:05:51 -0200 | [diff] [blame] | 1400 | } |
| 1401 | |
Daniel Vetter | 85234cd | 2012-07-02 13:27:29 +0200 | [diff] [blame] | 1402 | bool intel_ddi_get_hw_state(struct intel_encoder *encoder, |
| 1403 | enum pipe *pipe) |
| 1404 | { |
| 1405 | struct drm_device *dev = encoder->base.dev; |
Chris Wilson | fac5e23 | 2016-07-04 11:34:36 +0100 | [diff] [blame] | 1406 | struct drm_i915_private *dev_priv = to_i915(dev); |
Paulo Zanoni | fe43d3f | 2012-10-15 15:51:39 -0300 | [diff] [blame] | 1407 | enum port port = intel_ddi_get_encoder_port(encoder); |
Daniel Vetter | 85234cd | 2012-07-02 13:27:29 +0200 | [diff] [blame] | 1408 | u32 tmp; |
| 1409 | int i; |
Imre Deak | e27daab | 2016-02-12 18:55:16 +0200 | [diff] [blame] | 1410 | bool ret; |
Daniel Vetter | 85234cd | 2012-07-02 13:27:29 +0200 | [diff] [blame] | 1411 | |
Ander Conselvan de Oliveira | 79f255a | 2017-02-22 08:34:27 +0200 | [diff] [blame] | 1412 | if (!intel_display_power_get_if_enabled(dev_priv, |
| 1413 | encoder->power_domain)) |
Imre Deak | 6d129be | 2014-03-05 16:20:54 +0200 | [diff] [blame] | 1414 | return false; |
| 1415 | |
Imre Deak | e27daab | 2016-02-12 18:55:16 +0200 | [diff] [blame] | 1416 | ret = false; |
| 1417 | |
Paulo Zanoni | fe43d3f | 2012-10-15 15:51:39 -0300 | [diff] [blame] | 1418 | tmp = I915_READ(DDI_BUF_CTL(port)); |
Daniel Vetter | 85234cd | 2012-07-02 13:27:29 +0200 | [diff] [blame] | 1419 | |
| 1420 | if (!(tmp & DDI_BUF_CTL_ENABLE)) |
Imre Deak | e27daab | 2016-02-12 18:55:16 +0200 | [diff] [blame] | 1421 | goto out; |
Daniel Vetter | 85234cd | 2012-07-02 13:27:29 +0200 | [diff] [blame] | 1422 | |
Paulo Zanoni | ad80a81 | 2012-10-24 16:06:19 -0200 | [diff] [blame] | 1423 | if (port == PORT_A) { |
| 1424 | tmp = I915_READ(TRANS_DDI_FUNC_CTL(TRANSCODER_EDP)); |
Daniel Vetter | 85234cd | 2012-07-02 13:27:29 +0200 | [diff] [blame] | 1425 | |
Paulo Zanoni | ad80a81 | 2012-10-24 16:06:19 -0200 | [diff] [blame] | 1426 | switch (tmp & TRANS_DDI_EDP_INPUT_MASK) { |
| 1427 | case TRANS_DDI_EDP_INPUT_A_ON: |
| 1428 | case TRANS_DDI_EDP_INPUT_A_ONOFF: |
| 1429 | *pipe = PIPE_A; |
| 1430 | break; |
| 1431 | case TRANS_DDI_EDP_INPUT_B_ONOFF: |
| 1432 | *pipe = PIPE_B; |
| 1433 | break; |
| 1434 | case TRANS_DDI_EDP_INPUT_C_ONOFF: |
| 1435 | *pipe = PIPE_C; |
| 1436 | break; |
| 1437 | } |
| 1438 | |
Imre Deak | e27daab | 2016-02-12 18:55:16 +0200 | [diff] [blame] | 1439 | ret = true; |
Paulo Zanoni | ad80a81 | 2012-10-24 16:06:19 -0200 | [diff] [blame] | 1440 | |
Imre Deak | e27daab | 2016-02-12 18:55:16 +0200 | [diff] [blame] | 1441 | goto out; |
| 1442 | } |
Dave Airlie | 0e32b39 | 2014-05-02 14:02:48 +1000 | [diff] [blame] | 1443 | |
Imre Deak | e27daab | 2016-02-12 18:55:16 +0200 | [diff] [blame] | 1444 | for (i = TRANSCODER_A; i <= TRANSCODER_C; i++) { |
| 1445 | tmp = I915_READ(TRANS_DDI_FUNC_CTL(i)); |
| 1446 | |
| 1447 | if ((tmp & TRANS_DDI_PORT_MASK) == TRANS_DDI_SELECT_PORT(port)) { |
| 1448 | if ((tmp & TRANS_DDI_MODE_SELECT_MASK) == |
| 1449 | TRANS_DDI_MODE_SELECT_DP_MST) |
| 1450 | goto out; |
| 1451 | |
| 1452 | *pipe = i; |
| 1453 | ret = true; |
| 1454 | |
| 1455 | goto out; |
Daniel Vetter | 85234cd | 2012-07-02 13:27:29 +0200 | [diff] [blame] | 1456 | } |
| 1457 | } |
| 1458 | |
Ville Syrjälä | 84f44ce | 2013-04-17 17:48:49 +0300 | [diff] [blame] | 1459 | DRM_DEBUG_KMS("No pipe for ddi port %c found\n", port_name(port)); |
Daniel Vetter | 85234cd | 2012-07-02 13:27:29 +0200 | [diff] [blame] | 1460 | |
Imre Deak | e27daab | 2016-02-12 18:55:16 +0200 | [diff] [blame] | 1461 | out: |
Ander Conselvan de Oliveira | cc3f90f | 2016-12-02 10:23:49 +0200 | [diff] [blame] | 1462 | if (ret && IS_GEN9_LP(dev_priv)) { |
Imre Deak | e93da0a | 2016-06-13 16:44:37 +0300 | [diff] [blame] | 1463 | tmp = I915_READ(BXT_PHY_CTL(port)); |
| 1464 | if ((tmp & (BXT_PHY_LANE_POWERDOWN_ACK | |
| 1465 | BXT_PHY_LANE_ENABLED)) != BXT_PHY_LANE_ENABLED) |
| 1466 | DRM_ERROR("Port %c enabled but PHY powered down? " |
| 1467 | "(PHY_CTL %08x)\n", port_name(port), tmp); |
| 1468 | } |
| 1469 | |
Ander Conselvan de Oliveira | 79f255a | 2017-02-22 08:34:27 +0200 | [diff] [blame] | 1470 | intel_display_power_put(dev_priv, encoder->power_domain); |
Imre Deak | e27daab | 2016-02-12 18:55:16 +0200 | [diff] [blame] | 1471 | |
| 1472 | return ret; |
Daniel Vetter | 85234cd | 2012-07-02 13:27:29 +0200 | [diff] [blame] | 1473 | } |
| 1474 | |
Ander Conselvan de Oliveira | 62b6956 | 2017-02-24 16:19:59 +0200 | [diff] [blame] | 1475 | static u64 intel_ddi_get_power_domains(struct intel_encoder *encoder) |
| 1476 | { |
| 1477 | struct intel_digital_port *dig_port = enc_to_dig_port(&encoder->base); |
| 1478 | enum pipe pipe; |
| 1479 | |
| 1480 | if (intel_ddi_get_hw_state(encoder, &pipe)) |
| 1481 | return BIT_ULL(dig_port->ddi_io_power_domain); |
| 1482 | |
| 1483 | return 0; |
| 1484 | } |
| 1485 | |
Paulo Zanoni | fc91463 | 2012-10-05 12:05:54 -0300 | [diff] [blame] | 1486 | void intel_ddi_enable_pipe_clock(struct intel_crtc *intel_crtc) |
| 1487 | { |
| 1488 | struct drm_crtc *crtc = &intel_crtc->base; |
Shashank Sharma | 7d4aefd | 2015-10-01 22:23:49 +0530 | [diff] [blame] | 1489 | struct drm_device *dev = crtc->dev; |
Chris Wilson | fac5e23 | 2016-07-04 11:34:36 +0100 | [diff] [blame] | 1490 | struct drm_i915_private *dev_priv = to_i915(dev); |
Paulo Zanoni | fc91463 | 2012-10-05 12:05:54 -0300 | [diff] [blame] | 1491 | struct intel_encoder *intel_encoder = intel_ddi_get_crtc_encoder(crtc); |
| 1492 | enum port port = intel_ddi_get_encoder_port(intel_encoder); |
Ander Conselvan de Oliveira | 6e3c971 | 2015-01-15 14:55:25 +0200 | [diff] [blame] | 1493 | enum transcoder cpu_transcoder = intel_crtc->config->cpu_transcoder; |
Paulo Zanoni | fc91463 | 2012-10-05 12:05:54 -0300 | [diff] [blame] | 1494 | |
Paulo Zanoni | bb523fc | 2012-10-23 18:29:56 -0200 | [diff] [blame] | 1495 | if (cpu_transcoder != TRANSCODER_EDP) |
| 1496 | I915_WRITE(TRANS_CLK_SEL(cpu_transcoder), |
| 1497 | TRANS_CLK_SEL_PORT(port)); |
Paulo Zanoni | fc91463 | 2012-10-05 12:05:54 -0300 | [diff] [blame] | 1498 | } |
| 1499 | |
| 1500 | void intel_ddi_disable_pipe_clock(struct intel_crtc *intel_crtc) |
| 1501 | { |
Chris Wilson | fac5e23 | 2016-07-04 11:34:36 +0100 | [diff] [blame] | 1502 | struct drm_i915_private *dev_priv = to_i915(intel_crtc->base.dev); |
Ander Conselvan de Oliveira | 6e3c971 | 2015-01-15 14:55:25 +0200 | [diff] [blame] | 1503 | enum transcoder cpu_transcoder = intel_crtc->config->cpu_transcoder; |
Paulo Zanoni | fc91463 | 2012-10-05 12:05:54 -0300 | [diff] [blame] | 1504 | |
Paulo Zanoni | bb523fc | 2012-10-23 18:29:56 -0200 | [diff] [blame] | 1505 | if (cpu_transcoder != TRANSCODER_EDP) |
| 1506 | I915_WRITE(TRANS_CLK_SEL(cpu_transcoder), |
| 1507 | TRANS_CLK_SEL_DISABLED); |
Paulo Zanoni | fc91463 | 2012-10-05 12:05:54 -0300 | [diff] [blame] | 1508 | } |
| 1509 | |
Ville Syrjälä | a7d8dbc | 2016-07-12 15:59:28 +0300 | [diff] [blame] | 1510 | static void _skl_ddi_set_iboost(struct drm_i915_private *dev_priv, |
| 1511 | enum port port, uint8_t iboost) |
David Weinehall | f8896f5 | 2015-06-25 11:11:03 +0300 | [diff] [blame] | 1512 | { |
Ville Syrjälä | a7d8dbc | 2016-07-12 15:59:28 +0300 | [diff] [blame] | 1513 | u32 tmp; |
| 1514 | |
| 1515 | tmp = I915_READ(DISPIO_CR_TX_BMU_CR0); |
| 1516 | tmp &= ~(BALANCE_LEG_MASK(port) | BALANCE_LEG_DISABLE(port)); |
| 1517 | if (iboost) |
| 1518 | tmp |= iboost << BALANCE_LEG_SHIFT(port); |
| 1519 | else |
| 1520 | tmp |= BALANCE_LEG_DISABLE(port); |
| 1521 | I915_WRITE(DISPIO_CR_TX_BMU_CR0, tmp); |
| 1522 | } |
| 1523 | |
| 1524 | static void skl_ddi_set_iboost(struct intel_encoder *encoder, u32 level) |
| 1525 | { |
| 1526 | struct intel_digital_port *intel_dig_port = enc_to_dig_port(&encoder->base); |
| 1527 | struct drm_i915_private *dev_priv = to_i915(intel_dig_port->base.base.dev); |
| 1528 | enum port port = intel_dig_port->port; |
| 1529 | int type = encoder->type; |
David Weinehall | f8896f5 | 2015-06-25 11:11:03 +0300 | [diff] [blame] | 1530 | const struct ddi_buf_trans *ddi_translations; |
| 1531 | uint8_t iboost; |
Antti Koskipaa | 75067dd | 2015-07-10 14:10:55 +0300 | [diff] [blame] | 1532 | uint8_t dp_iboost, hdmi_iboost; |
David Weinehall | f8896f5 | 2015-06-25 11:11:03 +0300 | [diff] [blame] | 1533 | int n_entries; |
David Weinehall | f8896f5 | 2015-06-25 11:11:03 +0300 | [diff] [blame] | 1534 | |
Antti Koskipaa | 75067dd | 2015-07-10 14:10:55 +0300 | [diff] [blame] | 1535 | /* VBT may override standard boost values */ |
| 1536 | dp_iboost = dev_priv->vbt.ddi_port_info[port].dp_boost_level; |
| 1537 | hdmi_iboost = dev_priv->vbt.ddi_port_info[port].hdmi_boost_level; |
| 1538 | |
Ville Syrjälä | cca0502 | 2016-06-22 21:57:06 +0300 | [diff] [blame] | 1539 | if (type == INTEL_OUTPUT_DP) { |
Antti Koskipaa | 75067dd | 2015-07-10 14:10:55 +0300 | [diff] [blame] | 1540 | if (dp_iboost) { |
| 1541 | iboost = dp_iboost; |
| 1542 | } else { |
Rodrigo Vivi | 0fdd491 | 2016-10-18 08:57:36 -0700 | [diff] [blame] | 1543 | if (IS_KABYLAKE(dev_priv)) |
| 1544 | ddi_translations = kbl_get_buf_trans_dp(dev_priv, |
| 1545 | &n_entries); |
| 1546 | else |
| 1547 | ddi_translations = skl_get_buf_trans_dp(dev_priv, |
| 1548 | &n_entries); |
Ander Conselvan de Oliveira | e4d4c05 | 2015-11-11 15:15:54 +0200 | [diff] [blame] | 1549 | iboost = ddi_translations[level].i_boost; |
Antti Koskipaa | 75067dd | 2015-07-10 14:10:55 +0300 | [diff] [blame] | 1550 | } |
David Weinehall | f8896f5 | 2015-06-25 11:11:03 +0300 | [diff] [blame] | 1551 | } else if (type == INTEL_OUTPUT_EDP) { |
Antti Koskipaa | 75067dd | 2015-07-10 14:10:55 +0300 | [diff] [blame] | 1552 | if (dp_iboost) { |
| 1553 | iboost = dp_iboost; |
| 1554 | } else { |
Ville Syrjälä | 78ab0ba | 2015-12-08 19:59:41 +0200 | [diff] [blame] | 1555 | ddi_translations = skl_get_buf_trans_edp(dev_priv, &n_entries); |
Ville Syrjälä | 10afa0b | 2015-12-08 19:59:43 +0200 | [diff] [blame] | 1556 | |
| 1557 | if (WARN_ON(port != PORT_A && |
| 1558 | port != PORT_E && n_entries > 9)) |
| 1559 | n_entries = 9; |
| 1560 | |
Ander Conselvan de Oliveira | e4d4c05 | 2015-11-11 15:15:54 +0200 | [diff] [blame] | 1561 | iboost = ddi_translations[level].i_boost; |
Antti Koskipaa | 75067dd | 2015-07-10 14:10:55 +0300 | [diff] [blame] | 1562 | } |
David Weinehall | f8896f5 | 2015-06-25 11:11:03 +0300 | [diff] [blame] | 1563 | } else if (type == INTEL_OUTPUT_HDMI) { |
Antti Koskipaa | 75067dd | 2015-07-10 14:10:55 +0300 | [diff] [blame] | 1564 | if (hdmi_iboost) { |
| 1565 | iboost = hdmi_iboost; |
| 1566 | } else { |
Ville Syrjälä | 78ab0ba | 2015-12-08 19:59:41 +0200 | [diff] [blame] | 1567 | ddi_translations = skl_get_buf_trans_hdmi(dev_priv, &n_entries); |
Ander Conselvan de Oliveira | e4d4c05 | 2015-11-11 15:15:54 +0200 | [diff] [blame] | 1568 | iboost = ddi_translations[level].i_boost; |
Antti Koskipaa | 75067dd | 2015-07-10 14:10:55 +0300 | [diff] [blame] | 1569 | } |
David Weinehall | f8896f5 | 2015-06-25 11:11:03 +0300 | [diff] [blame] | 1570 | } else { |
| 1571 | return; |
| 1572 | } |
| 1573 | |
| 1574 | /* Make sure that the requested I_boost is valid */ |
| 1575 | if (iboost && iboost != 0x1 && iboost != 0x3 && iboost != 0x7) { |
| 1576 | DRM_ERROR("Invalid I_boost value %u\n", iboost); |
| 1577 | return; |
| 1578 | } |
| 1579 | |
Ville Syrjälä | a7d8dbc | 2016-07-12 15:59:28 +0300 | [diff] [blame] | 1580 | _skl_ddi_set_iboost(dev_priv, port, iboost); |
David Weinehall | f8896f5 | 2015-06-25 11:11:03 +0300 | [diff] [blame] | 1581 | |
Ville Syrjälä | a7d8dbc | 2016-07-12 15:59:28 +0300 | [diff] [blame] | 1582 | if (port == PORT_A && intel_dig_port->max_lanes == 4) |
| 1583 | _skl_ddi_set_iboost(dev_priv, PORT_E, iboost); |
David Weinehall | f8896f5 | 2015-06-25 11:11:03 +0300 | [diff] [blame] | 1584 | } |
| 1585 | |
Ville Syrjälä | 78ab0ba | 2015-12-08 19:59:41 +0200 | [diff] [blame] | 1586 | static void bxt_ddi_vswing_sequence(struct drm_i915_private *dev_priv, |
| 1587 | u32 level, enum port port, int type) |
Vandana Kannan | 96fb9f9 | 2014-11-18 15:45:27 +0530 | [diff] [blame] | 1588 | { |
Vandana Kannan | 96fb9f9 | 2014-11-18 15:45:27 +0530 | [diff] [blame] | 1589 | const struct bxt_ddi_buf_trans *ddi_translations; |
| 1590 | u32 n_entries, i; |
Vandana Kannan | 96fb9f9 | 2014-11-18 15:45:27 +0530 | [diff] [blame] | 1591 | |
Jani Nikula | 06411f0 | 2016-03-24 17:50:21 +0200 | [diff] [blame] | 1592 | if (type == INTEL_OUTPUT_EDP && dev_priv->vbt.edp.low_vswing) { |
Sonika Jindal | d9d7000 | 2015-09-24 10:24:56 +0530 | [diff] [blame] | 1593 | n_entries = ARRAY_SIZE(bxt_ddi_translations_edp); |
| 1594 | ddi_translations = bxt_ddi_translations_edp; |
Ville Syrjälä | cca0502 | 2016-06-22 21:57:06 +0300 | [diff] [blame] | 1595 | } else if (type == INTEL_OUTPUT_DP |
Sonika Jindal | d9d7000 | 2015-09-24 10:24:56 +0530 | [diff] [blame] | 1596 | || type == INTEL_OUTPUT_EDP) { |
Vandana Kannan | 96fb9f9 | 2014-11-18 15:45:27 +0530 | [diff] [blame] | 1597 | n_entries = ARRAY_SIZE(bxt_ddi_translations_dp); |
| 1598 | ddi_translations = bxt_ddi_translations_dp; |
| 1599 | } else if (type == INTEL_OUTPUT_HDMI) { |
| 1600 | n_entries = ARRAY_SIZE(bxt_ddi_translations_hdmi); |
| 1601 | ddi_translations = bxt_ddi_translations_hdmi; |
| 1602 | } else { |
| 1603 | DRM_DEBUG_KMS("Vswing programming not done for encoder %d\n", |
| 1604 | type); |
| 1605 | return; |
| 1606 | } |
| 1607 | |
| 1608 | /* Check if default value has to be used */ |
| 1609 | if (level >= n_entries || |
| 1610 | (type == INTEL_OUTPUT_HDMI && level == HDMI_LEVEL_SHIFT_UNKNOWN)) { |
| 1611 | for (i = 0; i < n_entries; i++) { |
| 1612 | if (ddi_translations[i].default_index) { |
| 1613 | level = i; |
| 1614 | break; |
| 1615 | } |
| 1616 | } |
| 1617 | } |
| 1618 | |
Ander Conselvan de Oliveira | b6e0820 | 2016-10-06 19:22:19 +0300 | [diff] [blame] | 1619 | bxt_ddi_phy_set_signal_level(dev_priv, port, |
| 1620 | ddi_translations[level].margin, |
| 1621 | ddi_translations[level].scale, |
| 1622 | ddi_translations[level].enable, |
| 1623 | ddi_translations[level].deemphasis); |
Vandana Kannan | 96fb9f9 | 2014-11-18 15:45:27 +0530 | [diff] [blame] | 1624 | } |
| 1625 | |
Ville Syrjälä | ffe5111 | 2017-02-23 19:49:01 +0200 | [diff] [blame] | 1626 | u8 intel_ddi_dp_voltage_max(struct intel_encoder *encoder) |
| 1627 | { |
| 1628 | struct drm_i915_private *dev_priv = to_i915(encoder->base.dev); |
| 1629 | int n_entries; |
| 1630 | |
| 1631 | if (encoder->type == INTEL_OUTPUT_EDP) |
| 1632 | intel_ddi_get_buf_trans_edp(dev_priv, &n_entries); |
| 1633 | else |
| 1634 | intel_ddi_get_buf_trans_dp(dev_priv, &n_entries); |
| 1635 | |
| 1636 | if (WARN_ON(n_entries < 1)) |
| 1637 | n_entries = 1; |
| 1638 | if (WARN_ON(n_entries > ARRAY_SIZE(index_to_dp_signal_levels))) |
| 1639 | n_entries = ARRAY_SIZE(index_to_dp_signal_levels); |
| 1640 | |
| 1641 | return index_to_dp_signal_levels[n_entries - 1] & |
| 1642 | DP_TRAIN_VOLTAGE_SWING_MASK; |
| 1643 | } |
| 1644 | |
David Weinehall | f8896f5 | 2015-06-25 11:11:03 +0300 | [diff] [blame] | 1645 | static uint32_t translate_signal_level(int signal_levels) |
| 1646 | { |
Ville Syrjälä | 97eeb87 | 2017-02-23 19:35:06 +0200 | [diff] [blame] | 1647 | int i; |
David Weinehall | f8896f5 | 2015-06-25 11:11:03 +0300 | [diff] [blame] | 1648 | |
Ville Syrjälä | 97eeb87 | 2017-02-23 19:35:06 +0200 | [diff] [blame] | 1649 | for (i = 0; i < ARRAY_SIZE(index_to_dp_signal_levels); i++) { |
| 1650 | if (index_to_dp_signal_levels[i] == signal_levels) |
| 1651 | return i; |
David Weinehall | f8896f5 | 2015-06-25 11:11:03 +0300 | [diff] [blame] | 1652 | } |
| 1653 | |
Ville Syrjälä | 97eeb87 | 2017-02-23 19:35:06 +0200 | [diff] [blame] | 1654 | WARN(1, "Unsupported voltage swing/pre-emphasis level: 0x%x\n", |
| 1655 | signal_levels); |
| 1656 | |
| 1657 | return 0; |
David Weinehall | f8896f5 | 2015-06-25 11:11:03 +0300 | [diff] [blame] | 1658 | } |
| 1659 | |
| 1660 | uint32_t ddi_signal_levels(struct intel_dp *intel_dp) |
| 1661 | { |
| 1662 | struct intel_digital_port *dport = dp_to_dig_port(intel_dp); |
Ville Syrjälä | 78ab0ba | 2015-12-08 19:59:41 +0200 | [diff] [blame] | 1663 | struct drm_i915_private *dev_priv = to_i915(dport->base.base.dev); |
David Weinehall | f8896f5 | 2015-06-25 11:11:03 +0300 | [diff] [blame] | 1664 | struct intel_encoder *encoder = &dport->base; |
| 1665 | uint8_t train_set = intel_dp->train_set[0]; |
| 1666 | int signal_levels = train_set & (DP_TRAIN_VOLTAGE_SWING_MASK | |
| 1667 | DP_TRAIN_PRE_EMPHASIS_MASK); |
| 1668 | enum port port = dport->port; |
| 1669 | uint32_t level; |
| 1670 | |
| 1671 | level = translate_signal_level(signal_levels); |
| 1672 | |
Rodrigo Vivi | b976dc5 | 2017-01-23 10:32:37 -0800 | [diff] [blame] | 1673 | if (IS_GEN9_BC(dev_priv)) |
Ville Syrjälä | a7d8dbc | 2016-07-12 15:59:28 +0300 | [diff] [blame] | 1674 | skl_ddi_set_iboost(encoder, level); |
Ander Conselvan de Oliveira | cc3f90f | 2016-12-02 10:23:49 +0200 | [diff] [blame] | 1675 | else if (IS_GEN9_LP(dev_priv)) |
Ville Syrjälä | 78ab0ba | 2015-12-08 19:59:41 +0200 | [diff] [blame] | 1676 | bxt_ddi_vswing_sequence(dev_priv, level, port, encoder->type); |
David Weinehall | f8896f5 | 2015-06-25 11:11:03 +0300 | [diff] [blame] | 1677 | |
| 1678 | return DDI_BUF_TRANS_SELECT(level); |
| 1679 | } |
| 1680 | |
Ville Syrjälä | e404ba8d | 2015-08-17 18:46:20 +0300 | [diff] [blame] | 1681 | void intel_ddi_clk_select(struct intel_encoder *encoder, |
Ander Conselvan de Oliveira | c856052 | 2016-09-01 15:08:07 -0700 | [diff] [blame] | 1682 | struct intel_shared_dpll *pll) |
Paulo Zanoni | 6441ab5 | 2012-10-05 12:05:58 -0300 | [diff] [blame] | 1683 | { |
Ville Syrjälä | e404ba8d | 2015-08-17 18:46:20 +0300 | [diff] [blame] | 1684 | struct drm_i915_private *dev_priv = to_i915(encoder->base.dev); |
| 1685 | enum port port = intel_ddi_get_encoder_port(encoder); |
Paulo Zanoni | 82a4d9c | 2012-10-23 18:30:07 -0200 | [diff] [blame] | 1686 | |
Ander Conselvan de Oliveira | c856052 | 2016-09-01 15:08:07 -0700 | [diff] [blame] | 1687 | if (WARN_ON(!pll)) |
| 1688 | return; |
| 1689 | |
Rodrigo Vivi | b976dc5 | 2017-01-23 10:32:37 -0800 | [diff] [blame] | 1690 | if (IS_GEN9_BC(dev_priv)) { |
Satheeshakrishna M | efa80ad | 2014-11-13 14:55:19 +0000 | [diff] [blame] | 1691 | uint32_t val; |
| 1692 | |
Damien Lespiau | 5416d87 | 2014-11-14 17:24:33 +0000 | [diff] [blame] | 1693 | /* DDI -> PLL mapping */ |
Satheeshakrishna M | efa80ad | 2014-11-13 14:55:19 +0000 | [diff] [blame] | 1694 | val = I915_READ(DPLL_CTRL2); |
| 1695 | |
| 1696 | val &= ~(DPLL_CTRL2_DDI_CLK_OFF(port) | |
| 1697 | DPLL_CTRL2_DDI_CLK_SEL_MASK(port)); |
Ander Conselvan de Oliveira | c856052 | 2016-09-01 15:08:07 -0700 | [diff] [blame] | 1698 | val |= (DPLL_CTRL2_DDI_CLK_SEL(pll->id, port) | |
Satheeshakrishna M | efa80ad | 2014-11-13 14:55:19 +0000 | [diff] [blame] | 1699 | DPLL_CTRL2_DDI_SEL_OVERRIDE(port)); |
| 1700 | |
| 1701 | I915_WRITE(DPLL_CTRL2, val); |
Damien Lespiau | 5416d87 | 2014-11-14 17:24:33 +0000 | [diff] [blame] | 1702 | |
Ville Syrjälä | e404ba8d | 2015-08-17 18:46:20 +0300 | [diff] [blame] | 1703 | } else if (INTEL_INFO(dev_priv)->gen < 9) { |
Ander Conselvan de Oliveira | c856052 | 2016-09-01 15:08:07 -0700 | [diff] [blame] | 1704 | I915_WRITE(PORT_CLK_SEL(port), hsw_pll_to_ddi_pll_sel(pll)); |
Satheeshakrishna M | efa80ad | 2014-11-13 14:55:19 +0000 | [diff] [blame] | 1705 | } |
Ville Syrjälä | e404ba8d | 2015-08-17 18:46:20 +0300 | [diff] [blame] | 1706 | } |
| 1707 | |
Manasi Navare | ba88d15 | 2016-09-01 15:08:08 -0700 | [diff] [blame] | 1708 | static void intel_ddi_pre_enable_dp(struct intel_encoder *encoder, |
| 1709 | int link_rate, uint32_t lane_count, |
| 1710 | struct intel_shared_dpll *pll, |
| 1711 | bool link_mst) |
| 1712 | { |
| 1713 | struct intel_dp *intel_dp = enc_to_intel_dp(&encoder->base); |
| 1714 | struct drm_i915_private *dev_priv = to_i915(encoder->base.dev); |
| 1715 | enum port port = intel_ddi_get_encoder_port(encoder); |
Ander Conselvan de Oliveira | 62b6956 | 2017-02-24 16:19:59 +0200 | [diff] [blame] | 1716 | struct intel_digital_port *dig_port = enc_to_dig_port(&encoder->base); |
Manasi Navare | ba88d15 | 2016-09-01 15:08:08 -0700 | [diff] [blame] | 1717 | |
| 1718 | intel_dp_set_link_params(intel_dp, link_rate, lane_count, |
| 1719 | link_mst); |
| 1720 | if (encoder->type == INTEL_OUTPUT_EDP) |
| 1721 | intel_edp_panel_on(intel_dp); |
| 1722 | |
| 1723 | intel_ddi_clk_select(encoder, pll); |
Ander Conselvan de Oliveira | 62b6956 | 2017-02-24 16:19:59 +0200 | [diff] [blame] | 1724 | |
| 1725 | intel_display_power_get(dev_priv, dig_port->ddi_io_power_domain); |
| 1726 | |
Manasi Navare | ba88d15 | 2016-09-01 15:08:08 -0700 | [diff] [blame] | 1727 | intel_prepare_dp_ddi_buffers(encoder); |
| 1728 | intel_ddi_init_dp_buf_reg(encoder); |
| 1729 | intel_dp_sink_dpms(intel_dp, DRM_MODE_DPMS_ON); |
| 1730 | intel_dp_start_link_train(intel_dp); |
| 1731 | if (port != PORT_A || INTEL_GEN(dev_priv) >= 9) |
| 1732 | intel_dp_stop_link_train(intel_dp); |
| 1733 | } |
| 1734 | |
| 1735 | static void intel_ddi_pre_enable_hdmi(struct intel_encoder *encoder, |
| 1736 | bool has_hdmi_sink, |
Maarten Lankhorst | ac24028 | 2016-11-23 15:57:00 +0100 | [diff] [blame] | 1737 | const struct intel_crtc_state *crtc_state, |
| 1738 | const struct drm_connector_state *conn_state, |
Manasi Navare | ba88d15 | 2016-09-01 15:08:08 -0700 | [diff] [blame] | 1739 | struct intel_shared_dpll *pll) |
| 1740 | { |
| 1741 | struct intel_hdmi *intel_hdmi = enc_to_intel_hdmi(&encoder->base); |
| 1742 | struct drm_i915_private *dev_priv = to_i915(encoder->base.dev); |
| 1743 | struct drm_encoder *drm_encoder = &encoder->base; |
| 1744 | enum port port = intel_ddi_get_encoder_port(encoder); |
| 1745 | int level = intel_ddi_hdmi_level(dev_priv, port); |
Ander Conselvan de Oliveira | 62b6956 | 2017-02-24 16:19:59 +0200 | [diff] [blame] | 1746 | struct intel_digital_port *dig_port = enc_to_dig_port(&encoder->base); |
Manasi Navare | ba88d15 | 2016-09-01 15:08:08 -0700 | [diff] [blame] | 1747 | |
| 1748 | intel_dp_dual_mode_set_tmds_output(intel_hdmi, true); |
| 1749 | intel_ddi_clk_select(encoder, pll); |
Ander Conselvan de Oliveira | 62b6956 | 2017-02-24 16:19:59 +0200 | [diff] [blame] | 1750 | |
| 1751 | intel_display_power_get(dev_priv, dig_port->ddi_io_power_domain); |
| 1752 | |
Manasi Navare | ba88d15 | 2016-09-01 15:08:08 -0700 | [diff] [blame] | 1753 | intel_prepare_hdmi_ddi_buffers(encoder); |
Rodrigo Vivi | b976dc5 | 2017-01-23 10:32:37 -0800 | [diff] [blame] | 1754 | if (IS_GEN9_BC(dev_priv)) |
Manasi Navare | ba88d15 | 2016-09-01 15:08:08 -0700 | [diff] [blame] | 1755 | skl_ddi_set_iboost(encoder, level); |
Ander Conselvan de Oliveira | cc3f90f | 2016-12-02 10:23:49 +0200 | [diff] [blame] | 1756 | else if (IS_GEN9_LP(dev_priv)) |
Manasi Navare | ba88d15 | 2016-09-01 15:08:08 -0700 | [diff] [blame] | 1757 | bxt_ddi_vswing_sequence(dev_priv, level, port, |
| 1758 | INTEL_OUTPUT_HDMI); |
| 1759 | |
| 1760 | intel_hdmi->set_infoframes(drm_encoder, |
| 1761 | has_hdmi_sink, |
Maarten Lankhorst | ac24028 | 2016-11-23 15:57:00 +0100 | [diff] [blame] | 1762 | crtc_state, conn_state); |
Manasi Navare | ba88d15 | 2016-09-01 15:08:08 -0700 | [diff] [blame] | 1763 | } |
| 1764 | |
Maarten Lankhorst | fd6bbda | 2016-08-09 17:04:04 +0200 | [diff] [blame] | 1765 | static void intel_ddi_pre_enable(struct intel_encoder *intel_encoder, |
| 1766 | struct intel_crtc_state *pipe_config, |
| 1767 | struct drm_connector_state *conn_state) |
Ville Syrjälä | e404ba8d | 2015-08-17 18:46:20 +0300 | [diff] [blame] | 1768 | { |
| 1769 | struct drm_encoder *encoder = &intel_encoder->base; |
Ville Syrjälä | e404ba8d | 2015-08-17 18:46:20 +0300 | [diff] [blame] | 1770 | struct intel_crtc *crtc = to_intel_crtc(encoder->crtc); |
Ville Syrjälä | e404ba8d | 2015-08-17 18:46:20 +0300 | [diff] [blame] | 1771 | int type = intel_encoder->type; |
Ville Syrjälä | 6a7e4f9 | 2015-12-08 19:59:44 +0200 | [diff] [blame] | 1772 | |
Ville Syrjälä | cca0502 | 2016-06-22 21:57:06 +0300 | [diff] [blame] | 1773 | if (type == INTEL_OUTPUT_DP || type == INTEL_OUTPUT_EDP) { |
Manasi Navare | ba88d15 | 2016-09-01 15:08:08 -0700 | [diff] [blame] | 1774 | intel_ddi_pre_enable_dp(intel_encoder, |
| 1775 | crtc->config->port_clock, |
| 1776 | crtc->config->lane_count, |
| 1777 | crtc->config->shared_dpll, |
| 1778 | intel_crtc_has_type(crtc->config, |
| 1779 | INTEL_OUTPUT_DP_MST)); |
| 1780 | } |
| 1781 | if (type == INTEL_OUTPUT_HDMI) { |
| 1782 | intel_ddi_pre_enable_hdmi(intel_encoder, |
Maarten Lankhorst | ac24028 | 2016-11-23 15:57:00 +0100 | [diff] [blame] | 1783 | pipe_config->has_hdmi_sink, |
| 1784 | pipe_config, conn_state, |
Manasi Navare | ba88d15 | 2016-09-01 15:08:08 -0700 | [diff] [blame] | 1785 | crtc->config->shared_dpll); |
Paulo Zanoni | c19b066 | 2012-10-15 15:51:41 -0300 | [diff] [blame] | 1786 | } |
Paulo Zanoni | 6441ab5 | 2012-10-05 12:05:58 -0300 | [diff] [blame] | 1787 | } |
| 1788 | |
Maarten Lankhorst | fd6bbda | 2016-08-09 17:04:04 +0200 | [diff] [blame] | 1789 | static void intel_ddi_post_disable(struct intel_encoder *intel_encoder, |
| 1790 | struct intel_crtc_state *old_crtc_state, |
| 1791 | struct drm_connector_state *old_conn_state) |
Paulo Zanoni | 6441ab5 | 2012-10-05 12:05:58 -0300 | [diff] [blame] | 1792 | { |
| 1793 | struct drm_encoder *encoder = &intel_encoder->base; |
Tvrtko Ursulin | 6647847 | 2016-11-16 08:55:40 +0000 | [diff] [blame] | 1794 | struct drm_i915_private *dev_priv = to_i915(encoder->dev); |
Paulo Zanoni | 6441ab5 | 2012-10-05 12:05:58 -0300 | [diff] [blame] | 1795 | enum port port = intel_ddi_get_encoder_port(intel_encoder); |
Ander Conselvan de Oliveira | 62b6956 | 2017-02-24 16:19:59 +0200 | [diff] [blame] | 1796 | struct intel_digital_port *dig_port = enc_to_dig_port(encoder); |
Paulo Zanoni | 82a4d9c | 2012-10-23 18:30:07 -0200 | [diff] [blame] | 1797 | int type = intel_encoder->type; |
Paulo Zanoni | 2886e93 | 2012-10-05 12:06:00 -0300 | [diff] [blame] | 1798 | uint32_t val; |
Paulo Zanoni | a836bdf | 2012-10-15 15:51:32 -0300 | [diff] [blame] | 1799 | bool wait = false; |
Paulo Zanoni | 2886e93 | 2012-10-05 12:06:00 -0300 | [diff] [blame] | 1800 | |
Maarten Lankhorst | fd6bbda | 2016-08-09 17:04:04 +0200 | [diff] [blame] | 1801 | /* old_crtc_state and old_conn_state are NULL when called from DP_MST */ |
| 1802 | |
Paulo Zanoni | 2886e93 | 2012-10-05 12:06:00 -0300 | [diff] [blame] | 1803 | val = I915_READ(DDI_BUF_CTL(port)); |
| 1804 | if (val & DDI_BUF_CTL_ENABLE) { |
| 1805 | val &= ~DDI_BUF_CTL_ENABLE; |
| 1806 | I915_WRITE(DDI_BUF_CTL(port), val); |
Paulo Zanoni | a836bdf | 2012-10-15 15:51:32 -0300 | [diff] [blame] | 1807 | wait = true; |
Paulo Zanoni | 2886e93 | 2012-10-05 12:06:00 -0300 | [diff] [blame] | 1808 | } |
Paulo Zanoni | 6441ab5 | 2012-10-05 12:05:58 -0300 | [diff] [blame] | 1809 | |
Paulo Zanoni | a836bdf | 2012-10-15 15:51:32 -0300 | [diff] [blame] | 1810 | val = I915_READ(DP_TP_CTL(port)); |
| 1811 | val &= ~(DP_TP_CTL_ENABLE | DP_TP_CTL_LINK_TRAIN_MASK); |
| 1812 | val |= DP_TP_CTL_LINK_TRAIN_PAT1; |
| 1813 | I915_WRITE(DP_TP_CTL(port), val); |
| 1814 | |
| 1815 | if (wait) |
| 1816 | intel_wait_ddi_buf_idle(dev_priv, port); |
| 1817 | |
Ville Syrjälä | cca0502 | 2016-06-22 21:57:06 +0300 | [diff] [blame] | 1818 | if (type == INTEL_OUTPUT_DP || type == INTEL_OUTPUT_EDP) { |
Paulo Zanoni | 82a4d9c | 2012-10-23 18:30:07 -0200 | [diff] [blame] | 1819 | struct intel_dp *intel_dp = enc_to_intel_dp(encoder); |
Jani Nikula | 76bb80e | 2013-11-15 15:29:57 +0200 | [diff] [blame] | 1820 | intel_dp_sink_dpms(intel_dp, DRM_MODE_DPMS_OFF); |
Jani Nikula | 24f3e09 | 2014-03-17 16:43:36 +0200 | [diff] [blame] | 1821 | intel_edp_panel_vdd_on(intel_dp); |
Daniel Vetter | 4be7378 | 2014-01-17 14:39:48 +0100 | [diff] [blame] | 1822 | intel_edp_panel_off(intel_dp); |
Paulo Zanoni | 82a4d9c | 2012-10-23 18:30:07 -0200 | [diff] [blame] | 1823 | } |
| 1824 | |
Ander Conselvan de Oliveira | 62b6956 | 2017-02-24 16:19:59 +0200 | [diff] [blame] | 1825 | if (dig_port) |
| 1826 | intel_display_power_put(dev_priv, dig_port->ddi_io_power_domain); |
| 1827 | |
Rodrigo Vivi | b976dc5 | 2017-01-23 10:32:37 -0800 | [diff] [blame] | 1828 | if (IS_GEN9_BC(dev_priv)) |
Satheeshakrishna M | efa80ad | 2014-11-13 14:55:19 +0000 | [diff] [blame] | 1829 | I915_WRITE(DPLL_CTRL2, (I915_READ(DPLL_CTRL2) | |
| 1830 | DPLL_CTRL2_DDI_CLK_OFF(port))); |
Tvrtko Ursulin | 6647847 | 2016-11-16 08:55:40 +0000 | [diff] [blame] | 1831 | else if (INTEL_GEN(dev_priv) < 9) |
Satheeshakrishna M | efa80ad | 2014-11-13 14:55:19 +0000 | [diff] [blame] | 1832 | I915_WRITE(PORT_CLK_SEL(port), PORT_CLK_SEL_NONE); |
Ville Syrjälä | b2ccb82 | 2016-05-02 22:08:24 +0300 | [diff] [blame] | 1833 | |
| 1834 | if (type == INTEL_OUTPUT_HDMI) { |
| 1835 | struct intel_hdmi *intel_hdmi = enc_to_intel_hdmi(encoder); |
| 1836 | |
| 1837 | intel_dp_dual_mode_set_tmds_output(intel_hdmi, false); |
| 1838 | } |
Paulo Zanoni | 6441ab5 | 2012-10-05 12:05:58 -0300 | [diff] [blame] | 1839 | } |
| 1840 | |
Maarten Lankhorst | b707654 | 2016-08-23 16:18:08 +0200 | [diff] [blame] | 1841 | void intel_ddi_fdi_post_disable(struct intel_encoder *intel_encoder, |
| 1842 | struct intel_crtc_state *old_crtc_state, |
| 1843 | struct drm_connector_state *old_conn_state) |
| 1844 | { |
| 1845 | struct drm_i915_private *dev_priv = to_i915(intel_encoder->base.dev); |
| 1846 | uint32_t val; |
| 1847 | |
| 1848 | /* |
| 1849 | * Bspec lists this as both step 13 (before DDI_BUF_CTL disable) |
| 1850 | * and step 18 (after clearing PORT_CLK_SEL). Based on a BUN, |
| 1851 | * step 13 is the correct place for it. Step 18 is where it was |
| 1852 | * originally before the BUN. |
| 1853 | */ |
| 1854 | val = I915_READ(FDI_RX_CTL(PIPE_A)); |
| 1855 | val &= ~FDI_RX_ENABLE; |
| 1856 | I915_WRITE(FDI_RX_CTL(PIPE_A), val); |
| 1857 | |
| 1858 | intel_ddi_post_disable(intel_encoder, old_crtc_state, old_conn_state); |
| 1859 | |
| 1860 | val = I915_READ(FDI_RX_MISC(PIPE_A)); |
| 1861 | val &= ~(FDI_RX_PWRDN_LANE1_MASK | FDI_RX_PWRDN_LANE0_MASK); |
| 1862 | val |= FDI_RX_PWRDN_LANE1_VAL(2) | FDI_RX_PWRDN_LANE0_VAL(2); |
| 1863 | I915_WRITE(FDI_RX_MISC(PIPE_A), val); |
| 1864 | |
| 1865 | val = I915_READ(FDI_RX_CTL(PIPE_A)); |
| 1866 | val &= ~FDI_PCDCLK; |
| 1867 | I915_WRITE(FDI_RX_CTL(PIPE_A), val); |
| 1868 | |
| 1869 | val = I915_READ(FDI_RX_CTL(PIPE_A)); |
| 1870 | val &= ~FDI_RX_PLL_ENABLE; |
| 1871 | I915_WRITE(FDI_RX_CTL(PIPE_A), val); |
| 1872 | } |
| 1873 | |
Maarten Lankhorst | fd6bbda | 2016-08-09 17:04:04 +0200 | [diff] [blame] | 1874 | static void intel_enable_ddi(struct intel_encoder *intel_encoder, |
| 1875 | struct intel_crtc_state *pipe_config, |
| 1876 | struct drm_connector_state *conn_state) |
Eugeni Dodonov | 72662e1 | 2012-05-09 15:37:31 -0300 | [diff] [blame] | 1877 | { |
Paulo Zanoni | 6547fef | 2012-10-15 15:51:40 -0300 | [diff] [blame] | 1878 | struct drm_encoder *encoder = &intel_encoder->base; |
Tvrtko Ursulin | 6647847 | 2016-11-16 08:55:40 +0000 | [diff] [blame] | 1879 | struct drm_i915_private *dev_priv = to_i915(encoder->dev); |
Paulo Zanoni | 6547fef | 2012-10-15 15:51:40 -0300 | [diff] [blame] | 1880 | enum port port = intel_ddi_get_encoder_port(intel_encoder); |
| 1881 | int type = intel_encoder->type; |
Eugeni Dodonov | 72662e1 | 2012-05-09 15:37:31 -0300 | [diff] [blame] | 1882 | |
Paulo Zanoni | 6547fef | 2012-10-15 15:51:40 -0300 | [diff] [blame] | 1883 | if (type == INTEL_OUTPUT_HDMI) { |
Damien Lespiau | 876a8cd | 2012-12-11 18:48:30 +0000 | [diff] [blame] | 1884 | struct intel_digital_port *intel_dig_port = |
| 1885 | enc_to_dig_port(encoder); |
| 1886 | |
Paulo Zanoni | 6547fef | 2012-10-15 15:51:40 -0300 | [diff] [blame] | 1887 | /* In HDMI/DVI mode, the port width, and swing/emphasis values |
| 1888 | * are ignored so nothing special needs to be done besides |
| 1889 | * enabling the port. |
| 1890 | */ |
Damien Lespiau | 876a8cd | 2012-12-11 18:48:30 +0000 | [diff] [blame] | 1891 | I915_WRITE(DDI_BUF_CTL(port), |
Stéphane Marchesin | bcf53de | 2013-07-12 13:54:41 -0700 | [diff] [blame] | 1892 | intel_dig_port->saved_port_bits | |
| 1893 | DDI_BUF_CTL_ENABLE); |
Paulo Zanoni | d6c50ff | 2012-10-23 18:30:06 -0200 | [diff] [blame] | 1894 | } else if (type == INTEL_OUTPUT_EDP) { |
| 1895 | struct intel_dp *intel_dp = enc_to_intel_dp(encoder); |
| 1896 | |
Tvrtko Ursulin | 6647847 | 2016-11-16 08:55:40 +0000 | [diff] [blame] | 1897 | if (port == PORT_A && INTEL_GEN(dev_priv) < 9) |
Imre Deak | 3ab9c63 | 2013-05-03 12:57:41 +0300 | [diff] [blame] | 1898 | intel_dp_stop_link_train(intel_dp); |
| 1899 | |
Daniel Vetter | 4be7378 | 2014-01-17 14:39:48 +0100 | [diff] [blame] | 1900 | intel_edp_backlight_on(intel_dp); |
Rodrigo Vivi | 0bc12bc | 2014-11-14 08:52:28 -0800 | [diff] [blame] | 1901 | intel_psr_enable(intel_dp); |
Maarten Lankhorst | 85cb48a | 2016-08-09 17:04:13 +0200 | [diff] [blame] | 1902 | intel_edp_drrs_enable(intel_dp, pipe_config); |
Paulo Zanoni | 6547fef | 2012-10-15 15:51:40 -0300 | [diff] [blame] | 1903 | } |
Wang Xingchao | 7b9f35a | 2013-01-22 23:25:25 +0800 | [diff] [blame] | 1904 | |
Maarten Lankhorst | 37255d8 | 2016-12-15 15:29:43 +0100 | [diff] [blame] | 1905 | if (pipe_config->has_audio) |
Maarten Lankhorst | bbf35e9 | 2016-11-08 13:55:38 +0100 | [diff] [blame] | 1906 | intel_audio_codec_enable(intel_encoder, pipe_config, conn_state); |
Daniel Vetter | 5ab432e | 2012-06-30 08:59:56 +0200 | [diff] [blame] | 1907 | } |
| 1908 | |
Maarten Lankhorst | fd6bbda | 2016-08-09 17:04:04 +0200 | [diff] [blame] | 1909 | static void intel_disable_ddi(struct intel_encoder *intel_encoder, |
| 1910 | struct intel_crtc_state *old_crtc_state, |
| 1911 | struct drm_connector_state *old_conn_state) |
Daniel Vetter | 5ab432e | 2012-06-30 08:59:56 +0200 | [diff] [blame] | 1912 | { |
Paulo Zanoni | d6c50ff | 2012-10-23 18:30:06 -0200 | [diff] [blame] | 1913 | struct drm_encoder *encoder = &intel_encoder->base; |
| 1914 | int type = intel_encoder->type; |
| 1915 | |
Maarten Lankhorst | 37255d8 | 2016-12-15 15:29:43 +0100 | [diff] [blame] | 1916 | if (old_crtc_state->has_audio) |
Jani Nikula | 69bfe1a | 2014-10-27 16:26:50 +0200 | [diff] [blame] | 1917 | intel_audio_codec_disable(intel_encoder); |
Paulo Zanoni | 2831d842 | 2013-03-06 20:03:09 -0300 | [diff] [blame] | 1918 | |
Paulo Zanoni | d6c50ff | 2012-10-23 18:30:06 -0200 | [diff] [blame] | 1919 | if (type == INTEL_OUTPUT_EDP) { |
| 1920 | struct intel_dp *intel_dp = enc_to_intel_dp(encoder); |
| 1921 | |
Maarten Lankhorst | 85cb48a | 2016-08-09 17:04:13 +0200 | [diff] [blame] | 1922 | intel_edp_drrs_disable(intel_dp, old_crtc_state); |
Rodrigo Vivi | 0bc12bc | 2014-11-14 08:52:28 -0800 | [diff] [blame] | 1923 | intel_psr_disable(intel_dp); |
Daniel Vetter | 4be7378 | 2014-01-17 14:39:48 +0100 | [diff] [blame] | 1924 | intel_edp_backlight_off(intel_dp); |
Paulo Zanoni | d6c50ff | 2012-10-23 18:30:06 -0200 | [diff] [blame] | 1925 | } |
Eugeni Dodonov | 72662e1 | 2012-05-09 15:37:31 -0300 | [diff] [blame] | 1926 | } |
Paulo Zanoni | 79f689a | 2012-10-05 12:05:52 -0300 | [diff] [blame] | 1927 | |
Maarten Lankhorst | fd6bbda | 2016-08-09 17:04:04 +0200 | [diff] [blame] | 1928 | static void bxt_ddi_pre_pll_enable(struct intel_encoder *encoder, |
| 1929 | struct intel_crtc_state *pipe_config, |
| 1930 | struct drm_connector_state *conn_state) |
Imre Deak | 95a7a2a | 2016-06-13 16:44:35 +0300 | [diff] [blame] | 1931 | { |
Imre Deak | 95a7a2a | 2016-06-13 16:44:35 +0300 | [diff] [blame] | 1932 | struct intel_crtc *intel_crtc = to_intel_crtc(encoder->base.crtc); |
Ander Conselvan de Oliveira | 47a6bc6 | 2016-10-06 19:22:17 +0300 | [diff] [blame] | 1933 | uint8_t mask = intel_crtc->config->lane_lat_optim_mask; |
Imre Deak | 95a7a2a | 2016-06-13 16:44:35 +0300 | [diff] [blame] | 1934 | |
Ander Conselvan de Oliveira | 47a6bc6 | 2016-10-06 19:22:17 +0300 | [diff] [blame] | 1935 | bxt_ddi_phy_set_lane_optim_mask(encoder, mask); |
Imre Deak | 95a7a2a | 2016-06-13 16:44:35 +0300 | [diff] [blame] | 1936 | } |
| 1937 | |
Ander Conselvan de Oliveira | ad64217 | 2015-10-23 13:01:49 +0300 | [diff] [blame] | 1938 | void intel_ddi_prepare_link_retrain(struct intel_dp *intel_dp) |
Paulo Zanoni | c19b066 | 2012-10-15 15:51:41 -0300 | [diff] [blame] | 1939 | { |
Ander Conselvan de Oliveira | ad64217 | 2015-10-23 13:01:49 +0300 | [diff] [blame] | 1940 | struct intel_digital_port *intel_dig_port = dp_to_dig_port(intel_dp); |
| 1941 | struct drm_i915_private *dev_priv = |
| 1942 | to_i915(intel_dig_port->base.base.dev); |
Paulo Zanoni | 174edf1 | 2012-10-26 19:05:50 -0200 | [diff] [blame] | 1943 | enum port port = intel_dig_port->port; |
Paulo Zanoni | c19b066 | 2012-10-15 15:51:41 -0300 | [diff] [blame] | 1944 | uint32_t val; |
Syam Sidhardhan | f3e227d | 2013-02-25 04:05:38 +0530 | [diff] [blame] | 1945 | bool wait = false; |
Paulo Zanoni | c19b066 | 2012-10-15 15:51:41 -0300 | [diff] [blame] | 1946 | |
| 1947 | if (I915_READ(DP_TP_CTL(port)) & DP_TP_CTL_ENABLE) { |
| 1948 | val = I915_READ(DDI_BUF_CTL(port)); |
| 1949 | if (val & DDI_BUF_CTL_ENABLE) { |
| 1950 | val &= ~DDI_BUF_CTL_ENABLE; |
| 1951 | I915_WRITE(DDI_BUF_CTL(port), val); |
| 1952 | wait = true; |
| 1953 | } |
| 1954 | |
| 1955 | val = I915_READ(DP_TP_CTL(port)); |
| 1956 | val &= ~(DP_TP_CTL_ENABLE | DP_TP_CTL_LINK_TRAIN_MASK); |
| 1957 | val |= DP_TP_CTL_LINK_TRAIN_PAT1; |
| 1958 | I915_WRITE(DP_TP_CTL(port), val); |
| 1959 | POSTING_READ(DP_TP_CTL(port)); |
| 1960 | |
| 1961 | if (wait) |
| 1962 | intel_wait_ddi_buf_idle(dev_priv, port); |
| 1963 | } |
| 1964 | |
Dave Airlie | 0e32b39 | 2014-05-02 14:02:48 +1000 | [diff] [blame] | 1965 | val = DP_TP_CTL_ENABLE | |
Paulo Zanoni | c19b066 | 2012-10-15 15:51:41 -0300 | [diff] [blame] | 1966 | DP_TP_CTL_LINK_TRAIN_PAT1 | DP_TP_CTL_SCRAMBLE_DISABLE; |
Ville Syrjälä | 64ee2fd | 2016-07-28 17:50:39 +0300 | [diff] [blame] | 1967 | if (intel_dp->link_mst) |
Dave Airlie | 0e32b39 | 2014-05-02 14:02:48 +1000 | [diff] [blame] | 1968 | val |= DP_TP_CTL_MODE_MST; |
| 1969 | else { |
| 1970 | val |= DP_TP_CTL_MODE_SST; |
| 1971 | if (drm_dp_enhanced_frame_cap(intel_dp->dpcd)) |
| 1972 | val |= DP_TP_CTL_ENHANCED_FRAME_ENABLE; |
| 1973 | } |
Paulo Zanoni | c19b066 | 2012-10-15 15:51:41 -0300 | [diff] [blame] | 1974 | I915_WRITE(DP_TP_CTL(port), val); |
| 1975 | POSTING_READ(DP_TP_CTL(port)); |
| 1976 | |
| 1977 | intel_dp->DP |= DDI_BUF_CTL_ENABLE; |
| 1978 | I915_WRITE(DDI_BUF_CTL(port), intel_dp->DP); |
| 1979 | POSTING_READ(DDI_BUF_CTL(port)); |
| 1980 | |
| 1981 | udelay(600); |
| 1982 | } |
Paulo Zanoni | 00c09d7 | 2012-10-26 19:05:52 -0200 | [diff] [blame] | 1983 | |
Libin Yang | 9935f7f | 2016-11-28 20:07:06 +0800 | [diff] [blame] | 1984 | bool intel_ddi_is_audio_enabled(struct drm_i915_private *dev_priv, |
| 1985 | struct intel_crtc *intel_crtc) |
| 1986 | { |
| 1987 | u32 temp; |
| 1988 | |
| 1989 | if (intel_display_power_is_enabled(dev_priv, POWER_DOMAIN_AUDIO)) { |
| 1990 | temp = I915_READ(HSW_AUD_PIN_ELD_CP_VLD); |
| 1991 | if (temp & AUDIO_OUTPUT_ENABLE(intel_crtc->pipe)) |
| 1992 | return true; |
| 1993 | } |
| 1994 | return false; |
| 1995 | } |
| 1996 | |
Ville Syrjälä | 6801c18 | 2013-09-24 14:24:05 +0300 | [diff] [blame] | 1997 | void intel_ddi_get_config(struct intel_encoder *encoder, |
Ander Conselvan de Oliveira | 5cec258 | 2015-01-15 14:55:21 +0200 | [diff] [blame] | 1998 | struct intel_crtc_state *pipe_config) |
Jesse Barnes | 045ac3b | 2013-05-14 17:08:26 -0700 | [diff] [blame] | 1999 | { |
Chris Wilson | fac5e23 | 2016-07-04 11:34:36 +0100 | [diff] [blame] | 2000 | struct drm_i915_private *dev_priv = to_i915(encoder->base.dev); |
Jesse Barnes | 045ac3b | 2013-05-14 17:08:26 -0700 | [diff] [blame] | 2001 | struct intel_crtc *intel_crtc = to_intel_crtc(encoder->base.crtc); |
Ander Conselvan de Oliveira | 0cb09a9 | 2015-01-30 12:17:23 +0200 | [diff] [blame] | 2002 | enum transcoder cpu_transcoder = pipe_config->cpu_transcoder; |
Daniel Vetter | bbd440f | 2014-11-20 22:33:59 +0100 | [diff] [blame] | 2003 | struct intel_hdmi *intel_hdmi; |
Jesse Barnes | 045ac3b | 2013-05-14 17:08:26 -0700 | [diff] [blame] | 2004 | u32 temp, flags = 0; |
| 2005 | |
Jani Nikula | 4d1de97 | 2016-03-18 17:05:42 +0200 | [diff] [blame] | 2006 | /* XXX: DSI transcoder paranoia */ |
| 2007 | if (WARN_ON(transcoder_is_dsi(cpu_transcoder))) |
| 2008 | return; |
| 2009 | |
Jesse Barnes | 045ac3b | 2013-05-14 17:08:26 -0700 | [diff] [blame] | 2010 | temp = I915_READ(TRANS_DDI_FUNC_CTL(cpu_transcoder)); |
| 2011 | if (temp & TRANS_DDI_PHSYNC) |
| 2012 | flags |= DRM_MODE_FLAG_PHSYNC; |
| 2013 | else |
| 2014 | flags |= DRM_MODE_FLAG_NHSYNC; |
| 2015 | if (temp & TRANS_DDI_PVSYNC) |
| 2016 | flags |= DRM_MODE_FLAG_PVSYNC; |
| 2017 | else |
| 2018 | flags |= DRM_MODE_FLAG_NVSYNC; |
| 2019 | |
Ander Conselvan de Oliveira | 2d112de | 2015-01-15 14:55:22 +0200 | [diff] [blame] | 2020 | pipe_config->base.adjusted_mode.flags |= flags; |
Ville Syrjälä | 42571ae | 2013-09-06 23:29:00 +0300 | [diff] [blame] | 2021 | |
| 2022 | switch (temp & TRANS_DDI_BPC_MASK) { |
| 2023 | case TRANS_DDI_BPC_6: |
| 2024 | pipe_config->pipe_bpp = 18; |
| 2025 | break; |
| 2026 | case TRANS_DDI_BPC_8: |
| 2027 | pipe_config->pipe_bpp = 24; |
| 2028 | break; |
| 2029 | case TRANS_DDI_BPC_10: |
| 2030 | pipe_config->pipe_bpp = 30; |
| 2031 | break; |
| 2032 | case TRANS_DDI_BPC_12: |
| 2033 | pipe_config->pipe_bpp = 36; |
| 2034 | break; |
| 2035 | default: |
| 2036 | break; |
| 2037 | } |
Ville Syrjälä | eb14cb7 | 2013-09-10 17:02:54 +0300 | [diff] [blame] | 2038 | |
| 2039 | switch (temp & TRANS_DDI_MODE_SELECT_MASK) { |
| 2040 | case TRANS_DDI_MODE_SELECT_HDMI: |
Daniel Vetter | 6897b4b | 2014-04-24 23:54:47 +0200 | [diff] [blame] | 2041 | pipe_config->has_hdmi_sink = true; |
Daniel Vetter | bbd440f | 2014-11-20 22:33:59 +0100 | [diff] [blame] | 2042 | intel_hdmi = enc_to_intel_hdmi(&encoder->base); |
| 2043 | |
Ville Syrjälä | cda0aaa | 2015-11-26 18:27:07 +0200 | [diff] [blame] | 2044 | if (intel_hdmi->infoframe_enabled(&encoder->base, pipe_config)) |
Daniel Vetter | bbd440f | 2014-11-20 22:33:59 +0100 | [diff] [blame] | 2045 | pipe_config->has_infoframe = true; |
Ander Conselvan de Oliveira | d4d6279 | 2016-04-27 15:44:16 +0300 | [diff] [blame] | 2046 | /* fall through */ |
Ville Syrjälä | eb14cb7 | 2013-09-10 17:02:54 +0300 | [diff] [blame] | 2047 | case TRANS_DDI_MODE_SELECT_DVI: |
Ander Conselvan de Oliveira | d4d6279 | 2016-04-27 15:44:16 +0300 | [diff] [blame] | 2048 | pipe_config->lane_count = 4; |
| 2049 | break; |
Ville Syrjälä | eb14cb7 | 2013-09-10 17:02:54 +0300 | [diff] [blame] | 2050 | case TRANS_DDI_MODE_SELECT_FDI: |
| 2051 | break; |
| 2052 | case TRANS_DDI_MODE_SELECT_DP_SST: |
| 2053 | case TRANS_DDI_MODE_SELECT_DP_MST: |
Ville Syrjälä | 90a6b7b | 2015-07-06 16:39:15 +0300 | [diff] [blame] | 2054 | pipe_config->lane_count = |
| 2055 | ((temp & DDI_PORT_WIDTH_MASK) >> DDI_PORT_WIDTH_SHIFT) + 1; |
Ville Syrjälä | eb14cb7 | 2013-09-10 17:02:54 +0300 | [diff] [blame] | 2056 | intel_dp_get_m_n(intel_crtc, pipe_config); |
| 2057 | break; |
| 2058 | default: |
| 2059 | break; |
| 2060 | } |
Daniel Vetter | 1021442 | 2013-11-18 07:38:16 +0100 | [diff] [blame] | 2061 | |
Libin Yang | 9935f7f | 2016-11-28 20:07:06 +0800 | [diff] [blame] | 2062 | pipe_config->has_audio = |
| 2063 | intel_ddi_is_audio_enabled(dev_priv, intel_crtc); |
Daniel Vetter | 9ed109a | 2014-04-24 23:54:52 +0200 | [diff] [blame] | 2064 | |
Jani Nikula | 6aa23e6 | 2016-03-24 17:50:20 +0200 | [diff] [blame] | 2065 | if (encoder->type == INTEL_OUTPUT_EDP && dev_priv->vbt.edp.bpp && |
| 2066 | pipe_config->pipe_bpp > dev_priv->vbt.edp.bpp) { |
Daniel Vetter | 1021442 | 2013-11-18 07:38:16 +0100 | [diff] [blame] | 2067 | /* |
| 2068 | * This is a big fat ugly hack. |
| 2069 | * |
| 2070 | * Some machines in UEFI boot mode provide us a VBT that has 18 |
| 2071 | * bpp and 1.62 GHz link bandwidth for eDP, which for reasons |
| 2072 | * unknown we fail to light up. Yet the same BIOS boots up with |
| 2073 | * 24 bpp and 2.7 GHz link. Use the same bpp as the BIOS uses as |
| 2074 | * max, not what it tells us to use. |
| 2075 | * |
| 2076 | * Note: This will still be broken if the eDP panel is not lit |
| 2077 | * up by the BIOS, and thus we can't get the mode at module |
| 2078 | * load. |
| 2079 | */ |
| 2080 | 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] | 2081 | pipe_config->pipe_bpp, dev_priv->vbt.edp.bpp); |
| 2082 | dev_priv->vbt.edp.bpp = pipe_config->pipe_bpp; |
Daniel Vetter | 1021442 | 2013-11-18 07:38:16 +0100 | [diff] [blame] | 2083 | } |
Jesse Barnes | 1157855 | 2014-01-21 12:42:10 -0800 | [diff] [blame] | 2084 | |
Damien Lespiau | 22606a1 | 2014-12-12 14:26:57 +0000 | [diff] [blame] | 2085 | intel_ddi_clock_get(encoder, pipe_config); |
Imre Deak | 95a7a2a | 2016-06-13 16:44:35 +0300 | [diff] [blame] | 2086 | |
Ander Conselvan de Oliveira | cc3f90f | 2016-12-02 10:23:49 +0200 | [diff] [blame] | 2087 | if (IS_GEN9_LP(dev_priv)) |
Imre Deak | 95a7a2a | 2016-06-13 16:44:35 +0300 | [diff] [blame] | 2088 | pipe_config->lane_lat_optim_mask = |
| 2089 | bxt_ddi_phy_get_lane_lat_optim_mask(encoder); |
Jesse Barnes | 045ac3b | 2013-05-14 17:08:26 -0700 | [diff] [blame] | 2090 | } |
| 2091 | |
Daniel Vetter | 5bfe2ac | 2013-03-27 00:44:55 +0100 | [diff] [blame] | 2092 | static bool intel_ddi_compute_config(struct intel_encoder *encoder, |
Maarten Lankhorst | 0a478c2 | 2016-08-09 17:04:05 +0200 | [diff] [blame] | 2093 | struct intel_crtc_state *pipe_config, |
| 2094 | struct drm_connector_state *conn_state) |
Paulo Zanoni | 00c09d7 | 2012-10-26 19:05:52 -0200 | [diff] [blame] | 2095 | { |
Chris Wilson | fac5e23 | 2016-07-04 11:34:36 +0100 | [diff] [blame] | 2096 | struct drm_i915_private *dev_priv = to_i915(encoder->base.dev); |
Daniel Vetter | 5bfe2ac | 2013-03-27 00:44:55 +0100 | [diff] [blame] | 2097 | int type = encoder->type; |
Daniel Vetter | eccb140 | 2013-05-22 00:50:22 +0200 | [diff] [blame] | 2098 | int port = intel_ddi_get_encoder_port(encoder); |
Imre Deak | 95a7a2a | 2016-06-13 16:44:35 +0300 | [diff] [blame] | 2099 | int ret; |
Paulo Zanoni | 00c09d7 | 2012-10-26 19:05:52 -0200 | [diff] [blame] | 2100 | |
Daniel Vetter | 5bfe2ac | 2013-03-27 00:44:55 +0100 | [diff] [blame] | 2101 | WARN(type == INTEL_OUTPUT_UNKNOWN, "compute_config() on unknown output!\n"); |
Paulo Zanoni | 00c09d7 | 2012-10-26 19:05:52 -0200 | [diff] [blame] | 2102 | |
Daniel Vetter | eccb140 | 2013-05-22 00:50:22 +0200 | [diff] [blame] | 2103 | if (port == PORT_A) |
| 2104 | pipe_config->cpu_transcoder = TRANSCODER_EDP; |
| 2105 | |
Paulo Zanoni | 00c09d7 | 2012-10-26 19:05:52 -0200 | [diff] [blame] | 2106 | if (type == INTEL_OUTPUT_HDMI) |
Maarten Lankhorst | 0a478c2 | 2016-08-09 17:04:05 +0200 | [diff] [blame] | 2107 | ret = intel_hdmi_compute_config(encoder, pipe_config, conn_state); |
Paulo Zanoni | 00c09d7 | 2012-10-26 19:05:52 -0200 | [diff] [blame] | 2108 | else |
Maarten Lankhorst | 0a478c2 | 2016-08-09 17:04:05 +0200 | [diff] [blame] | 2109 | ret = intel_dp_compute_config(encoder, pipe_config, conn_state); |
Imre Deak | 95a7a2a | 2016-06-13 16:44:35 +0300 | [diff] [blame] | 2110 | |
Ander Conselvan de Oliveira | cc3f90f | 2016-12-02 10:23:49 +0200 | [diff] [blame] | 2111 | if (IS_GEN9_LP(dev_priv) && ret) |
Imre Deak | 95a7a2a | 2016-06-13 16:44:35 +0300 | [diff] [blame] | 2112 | pipe_config->lane_lat_optim_mask = |
| 2113 | bxt_ddi_phy_calc_lane_lat_optim_mask(encoder, |
Ander Conselvan de Oliveira | b284eed | 2016-10-06 19:22:16 +0300 | [diff] [blame] | 2114 | pipe_config->lane_count); |
Imre Deak | 95a7a2a | 2016-06-13 16:44:35 +0300 | [diff] [blame] | 2115 | |
| 2116 | return ret; |
| 2117 | |
Paulo Zanoni | 00c09d7 | 2012-10-26 19:05:52 -0200 | [diff] [blame] | 2118 | } |
| 2119 | |
| 2120 | static const struct drm_encoder_funcs intel_ddi_funcs = { |
Imre Deak | bf93ba6 | 2016-04-18 10:04:21 +0300 | [diff] [blame] | 2121 | .reset = intel_dp_encoder_reset, |
| 2122 | .destroy = intel_dp_encoder_destroy, |
Paulo Zanoni | 00c09d7 | 2012-10-26 19:05:52 -0200 | [diff] [blame] | 2123 | }; |
| 2124 | |
Paulo Zanoni | 4a28ae5 | 2013-10-09 13:52:36 -0300 | [diff] [blame] | 2125 | static struct intel_connector * |
| 2126 | intel_ddi_init_dp_connector(struct intel_digital_port *intel_dig_port) |
| 2127 | { |
| 2128 | struct intel_connector *connector; |
| 2129 | enum port port = intel_dig_port->port; |
| 2130 | |
Ander Conselvan de Oliveira | 9bdbd0b | 2015-04-10 10:59:10 +0300 | [diff] [blame] | 2131 | connector = intel_connector_alloc(); |
Paulo Zanoni | 4a28ae5 | 2013-10-09 13:52:36 -0300 | [diff] [blame] | 2132 | if (!connector) |
| 2133 | return NULL; |
| 2134 | |
| 2135 | intel_dig_port->dp.output_reg = DDI_BUF_CTL(port); |
| 2136 | if (!intel_dp_init_connector(intel_dig_port, connector)) { |
| 2137 | kfree(connector); |
| 2138 | return NULL; |
| 2139 | } |
| 2140 | |
| 2141 | return connector; |
| 2142 | } |
| 2143 | |
| 2144 | static struct intel_connector * |
| 2145 | intel_ddi_init_hdmi_connector(struct intel_digital_port *intel_dig_port) |
| 2146 | { |
| 2147 | struct intel_connector *connector; |
| 2148 | enum port port = intel_dig_port->port; |
| 2149 | |
Ander Conselvan de Oliveira | 9bdbd0b | 2015-04-10 10:59:10 +0300 | [diff] [blame] | 2150 | connector = intel_connector_alloc(); |
Paulo Zanoni | 4a28ae5 | 2013-10-09 13:52:36 -0300 | [diff] [blame] | 2151 | if (!connector) |
| 2152 | return NULL; |
| 2153 | |
| 2154 | intel_dig_port->hdmi.hdmi_reg = DDI_BUF_CTL(port); |
| 2155 | intel_hdmi_init_connector(intel_dig_port, connector); |
| 2156 | |
| 2157 | return connector; |
| 2158 | } |
| 2159 | |
Ander Conselvan de Oliveira | c39055b | 2016-11-23 16:21:44 +0200 | [diff] [blame] | 2160 | void intel_ddi_init(struct drm_i915_private *dev_priv, enum port port) |
Paulo Zanoni | 00c09d7 | 2012-10-26 19:05:52 -0200 | [diff] [blame] | 2161 | { |
| 2162 | struct intel_digital_port *intel_dig_port; |
| 2163 | struct intel_encoder *intel_encoder; |
| 2164 | struct drm_encoder *encoder; |
Shashank Sharma | ff66212 | 2016-10-14 19:56:51 +0530 | [diff] [blame] | 2165 | bool init_hdmi, init_dp, init_lspcon = false; |
Ville Syrjälä | 10e7bec | 2015-12-08 19:59:37 +0200 | [diff] [blame] | 2166 | int max_lanes; |
| 2167 | |
| 2168 | if (I915_READ(DDI_BUF_CTL(PORT_A)) & DDI_A_4_LANES) { |
| 2169 | switch (port) { |
| 2170 | case PORT_A: |
| 2171 | max_lanes = 4; |
| 2172 | break; |
| 2173 | case PORT_E: |
| 2174 | max_lanes = 0; |
| 2175 | break; |
| 2176 | default: |
| 2177 | max_lanes = 4; |
| 2178 | break; |
| 2179 | } |
| 2180 | } else { |
| 2181 | switch (port) { |
| 2182 | case PORT_A: |
| 2183 | max_lanes = 2; |
| 2184 | break; |
| 2185 | case PORT_E: |
| 2186 | max_lanes = 2; |
| 2187 | break; |
| 2188 | default: |
| 2189 | max_lanes = 4; |
| 2190 | break; |
| 2191 | } |
| 2192 | } |
Paulo Zanoni | 311a209 | 2013-09-12 17:12:18 -0300 | [diff] [blame] | 2193 | |
| 2194 | init_hdmi = (dev_priv->vbt.ddi_port_info[port].supports_dvi || |
| 2195 | dev_priv->vbt.ddi_port_info[port].supports_hdmi); |
| 2196 | init_dp = dev_priv->vbt.ddi_port_info[port].supports_dp; |
Shashank Sharma | ff66212 | 2016-10-14 19:56:51 +0530 | [diff] [blame] | 2197 | |
| 2198 | if (intel_bios_is_lspcon_present(dev_priv, port)) { |
| 2199 | /* |
| 2200 | * Lspcon device needs to be driven with DP connector |
| 2201 | * with special detection sequence. So make sure DP |
| 2202 | * is initialized before lspcon. |
| 2203 | */ |
| 2204 | init_dp = true; |
| 2205 | init_lspcon = true; |
| 2206 | init_hdmi = false; |
| 2207 | DRM_DEBUG_KMS("VBT says port %c has lspcon\n", port_name(port)); |
| 2208 | } |
| 2209 | |
Paulo Zanoni | 311a209 | 2013-09-12 17:12:18 -0300 | [diff] [blame] | 2210 | if (!init_dp && !init_hdmi) { |
Rodrigo Vivi | 500ea70 | 2015-08-07 17:01:16 -0700 | [diff] [blame] | 2211 | DRM_DEBUG_KMS("VBT says port %c is not DVI/HDMI/DP compatible, respect it\n", |
Paulo Zanoni | 311a209 | 2013-09-12 17:12:18 -0300 | [diff] [blame] | 2212 | port_name(port)); |
Rodrigo Vivi | 500ea70 | 2015-08-07 17:01:16 -0700 | [diff] [blame] | 2213 | return; |
Paulo Zanoni | 311a209 | 2013-09-12 17:12:18 -0300 | [diff] [blame] | 2214 | } |
Paulo Zanoni | 00c09d7 | 2012-10-26 19:05:52 -0200 | [diff] [blame] | 2215 | |
Daniel Vetter | b14c567 | 2013-09-19 12:18:32 +0200 | [diff] [blame] | 2216 | intel_dig_port = kzalloc(sizeof(*intel_dig_port), GFP_KERNEL); |
Paulo Zanoni | 00c09d7 | 2012-10-26 19:05:52 -0200 | [diff] [blame] | 2217 | if (!intel_dig_port) |
| 2218 | return; |
| 2219 | |
Paulo Zanoni | 00c09d7 | 2012-10-26 19:05:52 -0200 | [diff] [blame] | 2220 | intel_encoder = &intel_dig_port->base; |
| 2221 | encoder = &intel_encoder->base; |
| 2222 | |
Ander Conselvan de Oliveira | c39055b | 2016-11-23 16:21:44 +0200 | [diff] [blame] | 2223 | drm_encoder_init(&dev_priv->drm, encoder, &intel_ddi_funcs, |
Ville Syrjälä | 580d8ed | 2016-05-27 20:59:24 +0300 | [diff] [blame] | 2224 | DRM_MODE_ENCODER_TMDS, "DDI %c", port_name(port)); |
Paulo Zanoni | 00c09d7 | 2012-10-26 19:05:52 -0200 | [diff] [blame] | 2225 | |
Daniel Vetter | 5bfe2ac | 2013-03-27 00:44:55 +0100 | [diff] [blame] | 2226 | intel_encoder->compute_config = intel_ddi_compute_config; |
Paulo Zanoni | 00c09d7 | 2012-10-26 19:05:52 -0200 | [diff] [blame] | 2227 | intel_encoder->enable = intel_enable_ddi; |
Ander Conselvan de Oliveira | cc3f90f | 2016-12-02 10:23:49 +0200 | [diff] [blame] | 2228 | if (IS_GEN9_LP(dev_priv)) |
Imre Deak | 95a7a2a | 2016-06-13 16:44:35 +0300 | [diff] [blame] | 2229 | intel_encoder->pre_pll_enable = bxt_ddi_pre_pll_enable; |
Paulo Zanoni | 00c09d7 | 2012-10-26 19:05:52 -0200 | [diff] [blame] | 2230 | intel_encoder->pre_enable = intel_ddi_pre_enable; |
| 2231 | intel_encoder->disable = intel_disable_ddi; |
| 2232 | intel_encoder->post_disable = intel_ddi_post_disable; |
| 2233 | intel_encoder->get_hw_state = intel_ddi_get_hw_state; |
Jesse Barnes | 045ac3b | 2013-05-14 17:08:26 -0700 | [diff] [blame] | 2234 | intel_encoder->get_config = intel_ddi_get_config; |
Imre Deak | bf93ba6 | 2016-04-18 10:04:21 +0300 | [diff] [blame] | 2235 | intel_encoder->suspend = intel_dp_encoder_suspend; |
Ander Conselvan de Oliveira | 62b6956 | 2017-02-24 16:19:59 +0200 | [diff] [blame] | 2236 | intel_encoder->get_power_domains = intel_ddi_get_power_domains; |
Paulo Zanoni | 00c09d7 | 2012-10-26 19:05:52 -0200 | [diff] [blame] | 2237 | |
| 2238 | intel_dig_port->port = port; |
Stéphane Marchesin | bcf53de | 2013-07-12 13:54:41 -0700 | [diff] [blame] | 2239 | intel_dig_port->saved_port_bits = I915_READ(DDI_BUF_CTL(port)) & |
| 2240 | (DDI_BUF_PORT_REVERSAL | |
| 2241 | DDI_A_4_LANES); |
Paulo Zanoni | 00c09d7 | 2012-10-26 19:05:52 -0200 | [diff] [blame] | 2242 | |
Ander Conselvan de Oliveira | 62b6956 | 2017-02-24 16:19:59 +0200 | [diff] [blame] | 2243 | switch (port) { |
| 2244 | case PORT_A: |
| 2245 | intel_dig_port->ddi_io_power_domain = |
| 2246 | POWER_DOMAIN_PORT_DDI_A_IO; |
| 2247 | break; |
| 2248 | case PORT_B: |
| 2249 | intel_dig_port->ddi_io_power_domain = |
| 2250 | POWER_DOMAIN_PORT_DDI_B_IO; |
| 2251 | break; |
| 2252 | case PORT_C: |
| 2253 | intel_dig_port->ddi_io_power_domain = |
| 2254 | POWER_DOMAIN_PORT_DDI_C_IO; |
| 2255 | break; |
| 2256 | case PORT_D: |
| 2257 | intel_dig_port->ddi_io_power_domain = |
| 2258 | POWER_DOMAIN_PORT_DDI_D_IO; |
| 2259 | break; |
| 2260 | case PORT_E: |
| 2261 | intel_dig_port->ddi_io_power_domain = |
| 2262 | POWER_DOMAIN_PORT_DDI_E_IO; |
| 2263 | break; |
| 2264 | default: |
| 2265 | MISSING_CASE(port); |
| 2266 | } |
| 2267 | |
Matt Roper | 6c566dc | 2015-11-05 14:53:32 -0800 | [diff] [blame] | 2268 | /* |
| 2269 | * Bspec says that DDI_A_4_LANES is the only supported configuration |
| 2270 | * for Broxton. Yet some BIOS fail to set this bit on port A if eDP |
| 2271 | * wasn't lit up at boot. Force this bit on in our internal |
| 2272 | * configuration so that we use the proper lane count for our |
| 2273 | * calculations. |
| 2274 | */ |
Ander Conselvan de Oliveira | cc3f90f | 2016-12-02 10:23:49 +0200 | [diff] [blame] | 2275 | if (IS_GEN9_LP(dev_priv) && port == PORT_A) { |
Matt Roper | 6c566dc | 2015-11-05 14:53:32 -0800 | [diff] [blame] | 2276 | if (!(intel_dig_port->saved_port_bits & DDI_A_4_LANES)) { |
| 2277 | DRM_DEBUG_KMS("BXT BIOS forgot to set DDI_A_4_LANES for port A; fixing\n"); |
| 2278 | intel_dig_port->saved_port_bits |= DDI_A_4_LANES; |
Matt Roper | ed8d60f | 2016-01-28 15:09:37 -0800 | [diff] [blame] | 2279 | max_lanes = 4; |
Matt Roper | 6c566dc | 2015-11-05 14:53:32 -0800 | [diff] [blame] | 2280 | } |
| 2281 | } |
| 2282 | |
Matt Roper | ed8d60f | 2016-01-28 15:09:37 -0800 | [diff] [blame] | 2283 | intel_dig_port->max_lanes = max_lanes; |
| 2284 | |
Paulo Zanoni | 00c09d7 | 2012-10-26 19:05:52 -0200 | [diff] [blame] | 2285 | intel_encoder->type = INTEL_OUTPUT_UNKNOWN; |
Ander Conselvan de Oliveira | 79f255a | 2017-02-22 08:34:27 +0200 | [diff] [blame] | 2286 | intel_encoder->power_domain = intel_port_to_power_domain(port); |
Pandiyan, Dhinakaran | 03cdc1d | 2016-09-19 18:24:38 -0700 | [diff] [blame] | 2287 | intel_encoder->port = port; |
Chris Wilson | f68d697 | 2014-08-04 07:15:09 +0100 | [diff] [blame] | 2288 | intel_encoder->crtc_mask = (1 << 0) | (1 << 1) | (1 << 2); |
Ville Syrjälä | bc079e8 | 2014-03-03 16:15:28 +0200 | [diff] [blame] | 2289 | intel_encoder->cloneable = 0; |
Paulo Zanoni | 00c09d7 | 2012-10-26 19:05:52 -0200 | [diff] [blame] | 2290 | |
Chris Wilson | f68d697 | 2014-08-04 07:15:09 +0100 | [diff] [blame] | 2291 | if (init_dp) { |
| 2292 | if (!intel_ddi_init_dp_connector(intel_dig_port)) |
| 2293 | goto err; |
Dave Airlie | 13cf550 | 2014-06-18 11:29:35 +1000 | [diff] [blame] | 2294 | |
Chris Wilson | f68d697 | 2014-08-04 07:15:09 +0100 | [diff] [blame] | 2295 | intel_dig_port->hpd_pulse = intel_dp_hpd_pulse; |
Ander Conselvan de Oliveira | ca4c389 | 2017-02-03 16:03:13 +0200 | [diff] [blame] | 2296 | dev_priv->hotplug.irq_port[port] = intel_dig_port; |
Chris Wilson | f68d697 | 2014-08-04 07:15:09 +0100 | [diff] [blame] | 2297 | } |
Daniel Vetter | 21a8e6a | 2013-04-10 23:28:35 +0200 | [diff] [blame] | 2298 | |
Paulo Zanoni | 311a209 | 2013-09-12 17:12:18 -0300 | [diff] [blame] | 2299 | /* In theory we don't need the encoder->type check, but leave it just in |
| 2300 | * case we have some really bad VBTs... */ |
Chris Wilson | f68d697 | 2014-08-04 07:15:09 +0100 | [diff] [blame] | 2301 | if (intel_encoder->type != INTEL_OUTPUT_EDP && init_hdmi) { |
| 2302 | if (!intel_ddi_init_hdmi_connector(intel_dig_port)) |
| 2303 | goto err; |
Daniel Vetter | 21a8e6a | 2013-04-10 23:28:35 +0200 | [diff] [blame] | 2304 | } |
Chris Wilson | f68d697 | 2014-08-04 07:15:09 +0100 | [diff] [blame] | 2305 | |
Shashank Sharma | ff66212 | 2016-10-14 19:56:51 +0530 | [diff] [blame] | 2306 | if (init_lspcon) { |
| 2307 | if (lspcon_init(intel_dig_port)) |
| 2308 | /* TODO: handle hdmi info frame part */ |
| 2309 | DRM_DEBUG_KMS("LSPCON init success on port %c\n", |
| 2310 | port_name(port)); |
| 2311 | else |
| 2312 | /* |
| 2313 | * LSPCON init faied, but DP init was success, so |
| 2314 | * lets try to drive as DP++ port. |
| 2315 | */ |
| 2316 | DRM_ERROR("LSPCON init failed on port %c\n", |
| 2317 | port_name(port)); |
| 2318 | } |
| 2319 | |
Chris Wilson | f68d697 | 2014-08-04 07:15:09 +0100 | [diff] [blame] | 2320 | return; |
| 2321 | |
| 2322 | err: |
| 2323 | drm_encoder_cleanup(encoder); |
| 2324 | kfree(intel_dig_port); |
Paulo Zanoni | 00c09d7 | 2012-10-26 19:05:52 -0200 | [diff] [blame] | 2325 | } |