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