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