Rev 5060 | Rev 6320 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 5060 | Rev 5354 | ||
---|---|---|---|
Line 26... | Line 26... | ||
26 | */ |
26 | */ |
Line 27... | Line 27... | ||
27 | 27 | ||
28 | #include "i915_drv.h" |
28 | #include "i915_drv.h" |
Line -... | Line 29... | ||
- | 29 | #include "intel_drv.h" |
|
- | 30 | ||
- | 31 | struct ddi_buf_trans { |
|
- | 32 | u32 trans1; /* balance leg enable, de-emph level */ |
|
- | 33 | u32 trans2; /* vref sel, vswing */ |
|
29 | #include "intel_drv.h" |
34 | }; |
30 | 35 | ||
31 | /* HDMI/DVI modes ignore everything but the last 2 items. So we share |
36 | /* HDMI/DVI modes ignore everything but the last 2 items. So we share |
32 | * them for both DP and FDI transports, allowing those ports to |
37 | * them for both DP and FDI transports, allowing those ports to |
33 | * automatically adapt to HDMI connections as well |
38 | * automatically adapt to HDMI connections as well |
34 | */ |
39 | */ |
35 | static const u32 hsw_ddi_translations_dp[] = { |
40 | static const struct ddi_buf_trans hsw_ddi_translations_dp[] = { |
36 | 0x00FFFFFF, 0x0006000E, /* DP parameters */ |
41 | { 0x00FFFFFF, 0x0006000E }, |
37 | 0x00D75FFF, 0x0005000A, |
42 | { 0x00D75FFF, 0x0005000A }, |
38 | 0x00C30FFF, 0x00040006, |
43 | { 0x00C30FFF, 0x00040006 }, |
39 | 0x80AAAFFF, 0x000B0000, |
44 | { 0x80AAAFFF, 0x000B0000 }, |
40 | 0x00FFFFFF, 0x0005000A, |
45 | { 0x00FFFFFF, 0x0005000A }, |
41 | 0x00D75FFF, 0x000C0004, |
46 | { 0x00D75FFF, 0x000C0004 }, |
42 | 0x80C30FFF, 0x000B0000, |
47 | { 0x80C30FFF, 0x000B0000 }, |
- | 48 | { 0x00FFFFFF, 0x00040006 }, |
|
- | 49 | { 0x80D75FFF, 0x000B0000 }, |
|
- | 50 | }; |
|
- | 51 | ||
- | 52 | static const struct ddi_buf_trans hsw_ddi_translations_fdi[] = { |
|
- | 53 | { 0x00FFFFFF, 0x0007000E }, |
|
- | 54 | { 0x00D75FFF, 0x000F000A }, |
|
- | 55 | { 0x00C30FFF, 0x00060006 }, |
|
- | 56 | { 0x00AAAFFF, 0x001E0000 }, |
|
- | 57 | { 0x00FFFFFF, 0x000F000A }, |
|
- | 58 | { 0x00D75FFF, 0x00160004 }, |
|
- | 59 | { 0x00C30FFF, 0x001E0000 }, |
|
- | 60 | { 0x00FFFFFF, 0x00060006 }, |
|
- | 61 | { 0x00D75FFF, 0x001E0000 }, |
|
- | 62 | }; |
|
- | 63 | ||
- | 64 | static const struct ddi_buf_trans hsw_ddi_translations_hdmi[] = { |
|
- | 65 | /* Idx NT mV d T mV d db */ |
|
- | 66 | { 0x00FFFFFF, 0x0006000E }, /* 0: 400 400 0 */ |
|
- | 67 | { 0x00E79FFF, 0x000E000C }, /* 1: 400 500 2 */ |
|
- | 68 | { 0x00D75FFF, 0x0005000A }, /* 2: 400 600 3.5 */ |
|
- | 69 | { 0x00FFFFFF, 0x0005000A }, /* 3: 600 600 0 */ |
|
- | 70 | { 0x00E79FFF, 0x001D0007 }, /* 4: 600 750 2 */ |
|
- | 71 | { 0x00D75FFF, 0x000C0004 }, /* 5: 600 900 3.5 */ |
|
- | 72 | { 0x00FFFFFF, 0x00040006 }, /* 6: 800 800 0 */ |
|
- | 73 | { 0x80E79FFF, 0x00030002 }, /* 7: 800 1000 2 */ |
|
- | 74 | { 0x00FFFFFF, 0x00140005 }, /* 8: 850 850 0 */ |
|
- | 75 | { 0x00FFFFFF, 0x000C0004 }, /* 9: 900 900 0 */ |
|
43 | 0x00FFFFFF, 0x00040006, |
76 | { 0x00FFFFFF, 0x001C0003 }, /* 10: 950 950 0 */ |
Line 44... | Line 77... | ||
44 | 0x80D75FFF, 0x000B0000, |
77 | { 0x80FFFFFF, 0x00030002 }, /* 11: 1000 1000 0 */ |
45 | }; |
78 | }; |
46 | 79 | ||
47 | static const u32 hsw_ddi_translations_fdi[] = { |
80 | static const struct ddi_buf_trans bdw_ddi_translations_edp[] = { |
48 | 0x00FFFFFF, 0x0007000E, /* FDI parameters */ |
81 | { 0x00FFFFFF, 0x00000012 }, |
49 | 0x00D75FFF, 0x000F000A, |
82 | { 0x00EBAFFF, 0x00020011 }, |
50 | 0x00C30FFF, 0x00060006, |
83 | { 0x00C71FFF, 0x0006000F }, |
51 | 0x00AAAFFF, 0x001E0000, |
84 | { 0x00AAAFFF, 0x000E000A }, |
52 | 0x00FFFFFF, 0x000F000A, |
85 | { 0x00FFFFFF, 0x00020011 }, |
53 | 0x00D75FFF, 0x00160004, |
86 | { 0x00DB6FFF, 0x0005000F }, |
54 | 0x00C30FFF, 0x001E0000, |
87 | { 0x00BEEFFF, 0x000A000C }, |
Line 55... | Line 88... | ||
55 | 0x00FFFFFF, 0x00060006, |
88 | { 0x00FFFFFF, 0x0005000F }, |
56 | 0x00D75FFF, 0x001E0000, |
- | |
57 | }; |
89 | { 0x00DB6FFF, 0x000A000C }, |
58 | - | ||
59 | static const u32 hsw_ddi_translations_hdmi[] = { |
90 | }; |
60 | /* Idx NT mV diff T mV diff db */ |
91 | |
61 | 0x00FFFFFF, 0x0006000E, /* 0: 400 400 0 */ |
92 | static const struct ddi_buf_trans bdw_ddi_translations_dp[] = { |
62 | 0x00E79FFF, 0x000E000C, /* 1: 400 500 2 */ |
93 | { 0x00FFFFFF, 0x0007000E }, |
63 | 0x00D75FFF, 0x0005000A, /* 2: 400 600 3.5 */ |
94 | { 0x00D75FFF, 0x000E000A }, |
64 | 0x00FFFFFF, 0x0005000A, /* 3: 600 600 0 */ |
95 | { 0x00BEFFFF, 0x00140006 }, |
65 | 0x00E79FFF, 0x001D0007, /* 4: 600 750 2 */ |
96 | { 0x80B2CFFF, 0x001B0002 }, |
66 | 0x00D75FFF, 0x000C0004, /* 5: 600 900 3.5 */ |
- | |
67 | 0x00FFFFFF, 0x00040006, /* 6: 800 800 0 */ |
97 | { 0x00FFFFFF, 0x000E000A }, |
68 | 0x80E79FFF, 0x00030002, /* 7: 800 1000 2 */ |
- | |
69 | 0x00FFFFFF, 0x00140005, /* 8: 850 850 0 */ |
98 | { 0x00DB6FFF, 0x00160005 }, |
Line 70... | Line 99... | ||
70 | 0x00FFFFFF, 0x000C0004, /* 9: 900 900 0 */ |
99 | { 0x80C71FFF, 0x001A0002 }, |
71 | 0x00FFFFFF, 0x001C0003, /* 10: 950 950 0 */ |
100 | { 0x00F7DFFF, 0x00180004 }, |
72 | 0x80FFFFFF, 0x00030002, /* 11: 1000 1000 0 */ |
101 | { 0x80D75FFF, 0x001B0002 }, |
73 | }; |
102 | }; |
74 | 103 | ||
75 | static const u32 bdw_ddi_translations_edp[] = { |
104 | static const struct ddi_buf_trans bdw_ddi_translations_fdi[] = { |
76 | 0x00FFFFFF, 0x00000012, /* eDP parameters */ |
105 | { 0x00FFFFFF, 0x0001000E }, |
77 | 0x00EBAFFF, 0x00020011, |
106 | { 0x00D75FFF, 0x0004000A }, |
78 | 0x00C71FFF, 0x0006000F, |
107 | { 0x00C30FFF, 0x00070006 }, |
79 | 0x00AAAFFF, 0x000E000A, |
108 | { 0x00AAAFFF, 0x000C0000 }, |
80 | 0x00FFFFFF, 0x00020011, |
- | |
81 | 0x00DB6FFF, 0x0005000F, |
109 | { 0x00FFFFFF, 0x0004000A }, |
Line 82... | Line 110... | ||
82 | 0x00BEEFFF, 0x000A000C, |
110 | { 0x00D75FFF, 0x00090004 }, |
- | 111 | { 0x00C30FFF, 0x000C0000 }, |
|
83 | 0x00FFFFFF, 0x0005000F, |
112 | { 0x00FFFFFF, 0x00070006 }, |
84 | 0x00DB6FFF, 0x000A000C, |
113 | { 0x00D75FFF, 0x000C0000 }, |
85 | 0x00FFFFFF, 0x00140006 /* HDMI parameters 800mV 0dB*/ |
114 | }; |
86 | }; |
115 | |
87 | 116 | static const struct ddi_buf_trans bdw_ddi_translations_hdmi[] = { |
|
88 | static const u32 bdw_ddi_translations_dp[] = { |
117 | /* Idx NT mV d T mV df db */ |
89 | 0x00FFFFFF, 0x0007000E, /* DP parameters */ |
118 | { 0x00FFFFFF, 0x0007000E }, /* 0: 400 400 0 */ |
90 | 0x00D75FFF, 0x000E000A, |
119 | { 0x00D75FFF, 0x000E000A }, /* 1: 400 600 3.5 */ |
91 | 0x00BEFFFF, 0x00140006, |
120 | { 0x00BEFFFF, 0x00140006 }, /* 2: 400 800 6 */ |
92 | 0x80B2CFFF, 0x001B0002, |
121 | { 0x00FFFFFF, 0x0009000D }, /* 3: 450 450 0 */ |
93 | 0x00FFFFFF, 0x000E000A, |
122 | { 0x00FFFFFF, 0x000E000A }, /* 4: 600 600 0 */ |
Line 94... | Line 123... | ||
94 | 0x00D75FFF, 0x00180004, |
123 | { 0x00D7FFFF, 0x00140006 }, /* 5: 600 800 2.5 */ |
95 | 0x80CB2FFF, 0x001B0002, |
124 | { 0x80CB2FFF, 0x001B0002 }, /* 6: 600 1000 4.5 */ |
96 | 0x00F7DFFF, 0x00180004, |
125 | { 0x00FFFFFF, 0x00140006 }, /* 7: 800 800 0 */ |
97 | 0x80D75FFF, 0x001B0002, |
126 | { 0x80E79FFF, 0x001B0002 }, /* 8: 800 1000 2 */ |
98 | 0x00FFFFFF, 0x00140006 /* HDMI parameters 800mV 0dB*/ |
127 | { 0x80FFFFFF, 0x001B0002 }, /* 9: 1000 1000 0 */ |
99 | }; |
128 | }; |
100 | 129 | ||
101 | static const u32 bdw_ddi_translations_fdi[] = { |
130 | static const struct ddi_buf_trans skl_ddi_translations_dp[] = { |
102 | 0x00FFFFFF, 0x0001000E, /* FDI parameters */ |
131 | { 0x00000018, 0x000000a0 }, |
103 | 0x00D75FFF, 0x0004000A, |
132 | { 0x00004014, 0x00000098 }, |
- | 133 | { 0x00006012, 0x00000088 }, |
|
- | 134 | { 0x00008010, 0x00000080 }, |
|
- | 135 | { 0x00000018, 0x00000098 }, |
|
- | 136 | { 0x00004014, 0x00000088 }, |
|
- | 137 | { 0x00006012, 0x00000080 }, |
|
- | 138 | { 0x00000018, 0x00000088 }, |
|
- | 139 | { 0x00004014, 0x00000080 }, |
|
- | 140 | }; |
|
- | 141 | ||
- | 142 | static const struct ddi_buf_trans skl_ddi_translations_hdmi[] = { |
|
- | 143 | /* Idx NT mV T mV db */ |
|
- | 144 | { 0x00000018, 0x000000a0 }, /* 0: 400 400 0 */ |
|
- | 145 | { 0x00004014, 0x00000098 }, /* 1: 400 600 3.5 */ |
|
104 | 0x00C30FFF, 0x00070006, |
146 | { 0x00006012, 0x00000088 }, /* 2: 400 800 6 */ |
105 | 0x00AAAFFF, 0x000C0000, |
147 | { 0x00000018, 0x0000003c }, /* 3: 450 450 0 */ |
Line 106... | Line 148... | ||
106 | 0x00FFFFFF, 0x0004000A, |
148 | { 0x00000018, 0x00000098 }, /* 4: 600 600 0 */ |
107 | 0x00D75FFF, 0x00090004, |
149 | { 0x00003015, 0x00000088 }, /* 5: 600 800 2.5 */ |
108 | 0x00C30FFF, 0x000C0000, |
150 | { 0x00005013, 0x00000080 }, /* 6: 600 1000 4.5 */ |
Line 143... | Line 185... | ||
143 | */ |
185 | */ |
144 | static void intel_prepare_ddi_buffers(struct drm_device *dev, enum port port) |
186 | static void intel_prepare_ddi_buffers(struct drm_device *dev, enum port port) |
145 | { |
187 | { |
146 | struct drm_i915_private *dev_priv = dev->dev_private; |
188 | struct drm_i915_private *dev_priv = dev->dev_private; |
147 | u32 reg; |
189 | u32 reg; |
148 | int i; |
190 | int i, n_hdmi_entries, hdmi_800mV_0dB; |
149 | int hdmi_level = dev_priv->vbt.ddi_port_info[port].hdmi_level_shift; |
191 | int hdmi_level = dev_priv->vbt.ddi_port_info[port].hdmi_level_shift; |
150 | const u32 *ddi_translations_fdi; |
192 | const struct ddi_buf_trans *ddi_translations_fdi; |
151 | const u32 *ddi_translations_dp; |
193 | const struct ddi_buf_trans *ddi_translations_dp; |
152 | const u32 *ddi_translations_edp; |
194 | const struct ddi_buf_trans *ddi_translations_edp; |
- | 195 | const struct ddi_buf_trans *ddi_translations_hdmi; |
|
153 | const u32 *ddi_translations; |
196 | const struct ddi_buf_trans *ddi_translations; |
154 | 197 | ||
- | 198 | if (IS_SKYLAKE(dev)) { |
|
- | 199 | ddi_translations_fdi = NULL; |
|
- | 200 | ddi_translations_dp = skl_ddi_translations_dp; |
|
- | 201 | ddi_translations_edp = skl_ddi_translations_dp; |
|
- | 202 | ddi_translations_hdmi = skl_ddi_translations_hdmi; |
|
- | 203 | n_hdmi_entries = ARRAY_SIZE(skl_ddi_translations_hdmi); |
|
- | 204 | hdmi_800mV_0dB = 7; |
|
155 | if (IS_BROADWELL(dev)) { |
205 | } else if (IS_BROADWELL(dev)) { |
156 | ddi_translations_fdi = bdw_ddi_translations_fdi; |
206 | ddi_translations_fdi = bdw_ddi_translations_fdi; |
157 | ddi_translations_dp = bdw_ddi_translations_dp; |
207 | ddi_translations_dp = bdw_ddi_translations_dp; |
158 | ddi_translations_edp = bdw_ddi_translations_edp; |
208 | ddi_translations_edp = bdw_ddi_translations_edp; |
- | 209 | ddi_translations_hdmi = bdw_ddi_translations_hdmi; |
|
- | 210 | n_hdmi_entries = ARRAY_SIZE(bdw_ddi_translations_hdmi); |
|
- | 211 | hdmi_800mV_0dB = 7; |
|
159 | } else if (IS_HASWELL(dev)) { |
212 | } else if (IS_HASWELL(dev)) { |
160 | ddi_translations_fdi = hsw_ddi_translations_fdi; |
213 | ddi_translations_fdi = hsw_ddi_translations_fdi; |
161 | ddi_translations_dp = hsw_ddi_translations_dp; |
214 | ddi_translations_dp = hsw_ddi_translations_dp; |
162 | ddi_translations_edp = hsw_ddi_translations_dp; |
215 | ddi_translations_edp = hsw_ddi_translations_dp; |
- | 216 | ddi_translations_hdmi = hsw_ddi_translations_hdmi; |
|
- | 217 | n_hdmi_entries = ARRAY_SIZE(hsw_ddi_translations_hdmi); |
|
- | 218 | hdmi_800mV_0dB = 6; |
|
163 | } else { |
219 | } else { |
164 | WARN(1, "ddi translation table missing\n"); |
220 | WARN(1, "ddi translation table missing\n"); |
165 | ddi_translations_edp = bdw_ddi_translations_dp; |
221 | ddi_translations_edp = bdw_ddi_translations_dp; |
166 | ddi_translations_fdi = bdw_ddi_translations_fdi; |
222 | ddi_translations_fdi = bdw_ddi_translations_fdi; |
167 | ddi_translations_dp = bdw_ddi_translations_dp; |
223 | ddi_translations_dp = bdw_ddi_translations_dp; |
- | 224 | ddi_translations_hdmi = bdw_ddi_translations_hdmi; |
|
- | 225 | n_hdmi_entries = ARRAY_SIZE(bdw_ddi_translations_hdmi); |
|
- | 226 | hdmi_800mV_0dB = 7; |
|
168 | } |
227 | } |
Line 169... | Line 228... | ||
169 | 228 | ||
170 | switch (port) { |
229 | switch (port) { |
171 | case PORT_A: |
230 | case PORT_A: |
Line 180... | Line 239... | ||
180 | ddi_translations = ddi_translations_edp; |
239 | ddi_translations = ddi_translations_edp; |
181 | else |
240 | else |
182 | ddi_translations = ddi_translations_dp; |
241 | ddi_translations = ddi_translations_dp; |
183 | break; |
242 | break; |
184 | case PORT_E: |
243 | case PORT_E: |
- | 244 | if (ddi_translations_fdi) |
|
185 | ddi_translations = ddi_translations_fdi; |
245 | ddi_translations = ddi_translations_fdi; |
- | 246 | else |
|
- | 247 | ddi_translations = ddi_translations_dp; |
|
186 | break; |
248 | break; |
187 | default: |
249 | default: |
188 | BUG(); |
250 | BUG(); |
189 | } |
251 | } |
Line 190... | Line 252... | ||
190 | 252 | ||
191 | for (i = 0, reg = DDI_BUF_TRANS(port); |
253 | for (i = 0, reg = DDI_BUF_TRANS(port); |
192 | i < ARRAY_SIZE(hsw_ddi_translations_fdi); i++) { |
254 | i < ARRAY_SIZE(hsw_ddi_translations_fdi); i++) { |
- | 255 | I915_WRITE(reg, ddi_translations[i].trans1); |
|
- | 256 | reg += 4; |
|
193 | I915_WRITE(reg, ddi_translations[i]); |
257 | I915_WRITE(reg, ddi_translations[i].trans2); |
194 | reg += 4; |
258 | reg += 4; |
- | 259 | } |
|
- | 260 | ||
- | 261 | /* Choose a good default if VBT is badly populated */ |
|
- | 262 | if (hdmi_level == HDMI_LEVEL_SHIFT_UNKNOWN || |
|
- | 263 | hdmi_level >= n_hdmi_entries) |
|
- | 264 | hdmi_level = hdmi_800mV_0dB; |
|
195 | } |
265 | |
- | 266 | /* Entry 9 is for HDMI: */ |
|
196 | /* Entry 9 is for HDMI: */ |
267 | I915_WRITE(reg, ddi_translations_hdmi[hdmi_level].trans1); |
197 | for (i = 0; i < 2; i++) { |
268 | reg += 4; |
198 | I915_WRITE(reg, hsw_ddi_translations_hdmi[hdmi_level * 2 + i]); |
269 | I915_WRITE(reg, ddi_translations_hdmi[hdmi_level].trans2); |
199 | reg += 4; |
- | |
200 | } |
270 | reg += 4; |
Line 201... | Line 271... | ||
201 | } |
271 | } |
202 | 272 | ||
203 | /* Program DDI buffers translations for DP. By default, program ports A-D in DP |
273 | /* Program DDI buffers translations for DP. By default, program ports A-D in DP |
Line 212... | Line 282... | ||
212 | 282 | ||
213 | for (port = PORT_A; port <= PORT_E; port++) |
283 | for (port = PORT_A; port <= PORT_E; port++) |
214 | intel_prepare_ddi_buffers(dev, port); |
284 | intel_prepare_ddi_buffers(dev, port); |
Line 215... | Line -... | ||
215 | } |
- | |
216 | - | ||
217 | static const long hsw_ddi_buf_ctl_values[] = { |
- | |
218 | DDI_BUF_EMP_400MV_0DB_HSW, |
- | |
219 | DDI_BUF_EMP_400MV_3_5DB_HSW, |
- | |
220 | DDI_BUF_EMP_400MV_6DB_HSW, |
- | |
221 | DDI_BUF_EMP_400MV_9_5DB_HSW, |
- | |
222 | DDI_BUF_EMP_600MV_0DB_HSW, |
- | |
223 | DDI_BUF_EMP_600MV_3_5DB_HSW, |
- | |
224 | DDI_BUF_EMP_600MV_6DB_HSW, |
- | |
225 | DDI_BUF_EMP_800MV_0DB_HSW, |
- | |
226 | DDI_BUF_EMP_800MV_3_5DB_HSW |
- | |
227 | }; |
285 | } |
228 | 286 | ||
229 | static void intel_wait_ddi_buf_idle(struct drm_i915_private *dev_priv, |
287 | static void intel_wait_ddi_buf_idle(struct drm_i915_private *dev_priv, |
230 | enum port port) |
288 | enum port port) |
231 | { |
289 | { |
Line 283... | Line 341... | ||
283 | I915_WRITE(PORT_CLK_SEL(PORT_E), intel_crtc->config.ddi_pll_sel); |
341 | I915_WRITE(PORT_CLK_SEL(PORT_E), intel_crtc->config.ddi_pll_sel); |
284 | WARN_ON(intel_crtc->config.ddi_pll_sel != PORT_CLK_SEL_SPLL); |
342 | WARN_ON(intel_crtc->config.ddi_pll_sel != PORT_CLK_SEL_SPLL); |
Line 285... | Line 343... | ||
285 | 343 | ||
286 | /* Start the training iterating through available voltages and emphasis, |
344 | /* Start the training iterating through available voltages and emphasis, |
287 | * testing each value twice. */ |
345 | * testing each value twice. */ |
288 | for (i = 0; i < ARRAY_SIZE(hsw_ddi_buf_ctl_values) * 2; i++) { |
346 | for (i = 0; i < ARRAY_SIZE(hsw_ddi_translations_fdi) * 2; i++) { |
289 | /* Configure DP_TP_CTL with auto-training */ |
347 | /* Configure DP_TP_CTL with auto-training */ |
290 | I915_WRITE(DP_TP_CTL(PORT_E), |
348 | I915_WRITE(DP_TP_CTL(PORT_E), |
291 | DP_TP_CTL_FDI_AUTOTRAIN | |
349 | DP_TP_CTL_FDI_AUTOTRAIN | |
292 | DP_TP_CTL_ENHANCED_FRAME_ENABLE | |
350 | DP_TP_CTL_ENHANCED_FRAME_ENABLE | |
Line 298... | Line 356... | ||
298 | * achieved on the PCH side in FDI_RX_CTL, so no need to set the |
356 | * achieved on the PCH side in FDI_RX_CTL, so no need to set the |
299 | * port reversal bit */ |
357 | * port reversal bit */ |
300 | I915_WRITE(DDI_BUF_CTL(PORT_E), |
358 | I915_WRITE(DDI_BUF_CTL(PORT_E), |
301 | DDI_BUF_CTL_ENABLE | |
359 | DDI_BUF_CTL_ENABLE | |
302 | ((intel_crtc->config.fdi_lanes - 1) << 1) | |
360 | ((intel_crtc->config.fdi_lanes - 1) << 1) | |
303 | hsw_ddi_buf_ctl_values[i / 2]); |
361 | DDI_BUF_TRANS_SELECT(i / 2)); |
304 | POSTING_READ(DDI_BUF_CTL(PORT_E)); |
362 | POSTING_READ(DDI_BUF_CTL(PORT_E)); |
Line 305... | Line 363... | ||
305 | 363 | ||
Line 306... | Line 364... | ||
306 | udelay(600); |
364 | udelay(600); |
Line 373... | Line 431... | ||
373 | struct intel_dp *intel_dp = enc_to_intel_dp(&encoder->base); |
431 | struct intel_dp *intel_dp = enc_to_intel_dp(&encoder->base); |
374 | struct intel_digital_port *intel_dig_port = |
432 | struct intel_digital_port *intel_dig_port = |
375 | enc_to_dig_port(&encoder->base); |
433 | enc_to_dig_port(&encoder->base); |
Line 376... | Line 434... | ||
376 | 434 | ||
377 | intel_dp->DP = intel_dig_port->saved_port_bits | |
435 | intel_dp->DP = intel_dig_port->saved_port_bits | |
378 | DDI_BUF_CTL_ENABLE | DDI_BUF_EMP_400MV_0DB_HSW; |
436 | DDI_BUF_CTL_ENABLE | DDI_BUF_TRANS_SELECT(0); |
Line 379... | Line 437... | ||
379 | intel_dp->DP |= DDI_PORT_WIDTH(intel_dp->lane_count); |
437 | intel_dp->DP |= DDI_PORT_WIDTH(intel_dp->lane_count); |
Line 380... | Line 438... | ||
380 | 438 | ||
Line 399... | Line 457... | ||
399 | 457 | ||
400 | BUG_ON(ret == NULL); |
458 | BUG_ON(ret == NULL); |
401 | return ret; |
459 | return ret; |
Line -... | Line 460... | ||
- | 460 | } |
|
- | 461 | ||
- | 462 | static struct intel_encoder * |
|
- | 463 | intel_ddi_get_crtc_new_encoder(struct intel_crtc *crtc) |
|
- | 464 | { |
|
- | 465 | struct drm_device *dev = crtc->base.dev; |
|
- | 466 | struct intel_encoder *intel_encoder, *ret = NULL; |
|
- | 467 | int num_encoders = 0; |
|
- | 468 | ||
- | 469 | for_each_intel_encoder(dev, intel_encoder) { |
|
- | 470 | if (intel_encoder->new_crtc == crtc) { |
|
- | 471 | ret = intel_encoder; |
|
- | 472 | num_encoders++; |
|
- | 473 | } |
|
- | 474 | } |
|
- | 475 | ||
- | 476 | WARN(num_encoders != 1, "%d encoders on crtc for pipe %c\n", num_encoders, |
|
- | 477 | pipe_name(crtc->pipe)); |
|
- | 478 | ||
- | 479 | BUG_ON(ret == NULL); |
|
- | 480 | return ret; |
|
402 | } |
481 | } |
403 | 482 | ||
Line 404... | Line 483... | ||
404 | #define LC_FREQ 2700 |
483 | #define LC_FREQ 2700 |
405 | #define LC_FREQ_2K (LC_FREQ * 2000) |
484 | #define LC_FREQ_2K U64_C(LC_FREQ * 2000) |
406 | 485 | ||
Line 412... | Line 491... | ||
412 | #define REF_MIN 48 |
491 | #define REF_MIN 48 |
413 | #define REF_MAX 400 |
492 | #define REF_MAX 400 |
414 | #define VCO_MIN 2400 |
493 | #define VCO_MIN 2400 |
415 | #define VCO_MAX 4800 |
494 | #define VCO_MAX 4800 |
Line -... | Line 495... | ||
- | 495 | ||
- | 496 | #define abs_diff(a, b) ({ \ |
|
- | 497 | typeof(a) __a = (a); \ |
|
- | 498 | typeof(b) __b = (b); \ |
|
416 | 499 | (void) (&__a == &__b); \ |
|
Line 417... | Line 500... | ||
417 | #define ABS_DIFF(a, b) ((a > b) ? (a - b) : (b - a)) |
500 | __a > __b ? (__a - __b) : (__b - __a); }) |
418 | 501 | ||
419 | struct wrpll_rnp { |
502 | struct wrpll_rnp { |
Line 522... | Line 605... | ||
522 | * improve upon the previous solution. However, if you're within the |
605 | * improve upon the previous solution. However, if you're within the |
523 | * budget, try to maximize Ref * VCO, that is N / (P * R^2). |
606 | * budget, try to maximize Ref * VCO, that is N / (P * R^2). |
524 | */ |
607 | */ |
525 | a = freq2k * budget * p * r2; |
608 | a = freq2k * budget * p * r2; |
526 | b = freq2k * budget * best->p * best->r2; |
609 | b = freq2k * budget * best->p * best->r2; |
527 | diff = ABS_DIFF((freq2k * p * r2), (LC_FREQ_2K * n2)); |
610 | diff = abs_diff(freq2k * p * r2, LC_FREQ_2K * n2); |
528 | diff_best = ABS_DIFF((freq2k * best->p * best->r2), |
611 | diff_best = abs_diff(freq2k * best->p * best->r2, |
529 | (LC_FREQ_2K * best->n2)); |
612 | LC_FREQ_2K * best->n2); |
530 | c = 1000000 * diff; |
613 | c = 1000000 * diff; |
531 | d = 1000000 * diff_best; |
614 | d = 1000000 * diff_best; |
Line 532... | Line 615... | ||
532 | 615 | ||
533 | if (a < c && b < d) { |
616 | if (a < c && b < d) { |
Line 585... | Line 668... | ||
585 | 668 | ||
586 | /* Convert to KHz, p & r have a fixed point portion */ |
669 | /* Convert to KHz, p & r have a fixed point portion */ |
587 | return (refclk * n * 100) / (p * r); |
670 | return (refclk * n * 100) / (p * r); |
Line -... | Line 671... | ||
- | 671 | } |
|
- | 672 | ||
- | 673 | static int skl_calc_wrpll_link(struct drm_i915_private *dev_priv, |
|
- | 674 | uint32_t dpll) |
|
- | 675 | { |
|
- | 676 | uint32_t cfgcr1_reg, cfgcr2_reg; |
|
- | 677 | uint32_t cfgcr1_val, cfgcr2_val; |
|
- | 678 | uint32_t p0, p1, p2, dco_freq; |
|
- | 679 | ||
- | 680 | cfgcr1_reg = GET_CFG_CR1_REG(dpll); |
|
- | 681 | cfgcr2_reg = GET_CFG_CR2_REG(dpll); |
|
- | 682 | ||
- | 683 | cfgcr1_val = I915_READ(cfgcr1_reg); |
|
- | 684 | cfgcr2_val = I915_READ(cfgcr2_reg); |
|
- | 685 | ||
- | 686 | p0 = cfgcr2_val & DPLL_CFGCR2_PDIV_MASK; |
|
- | 687 | p2 = cfgcr2_val & DPLL_CFGCR2_KDIV_MASK; |
|
- | 688 | ||
- | 689 | if (cfgcr2_val & DPLL_CFGCR2_QDIV_MODE(1)) |
|
- | 690 | p1 = (cfgcr2_val & DPLL_CFGCR2_QDIV_RATIO_MASK) >> 8; |
|
- | 691 | else |
|
- | 692 | p1 = 1; |
|
- | 693 | ||
- | 694 | ||
- | 695 | switch (p0) { |
|
- | 696 | case DPLL_CFGCR2_PDIV_1: |
|
- | 697 | p0 = 1; |
|
- | 698 | break; |
|
- | 699 | case DPLL_CFGCR2_PDIV_2: |
|
- | 700 | p0 = 2; |
|
- | 701 | break; |
|
- | 702 | case DPLL_CFGCR2_PDIV_3: |
|
- | 703 | p0 = 3; |
|
- | 704 | break; |
|
- | 705 | case DPLL_CFGCR2_PDIV_7: |
|
- | 706 | p0 = 7; |
|
- | 707 | break; |
|
- | 708 | } |
|
- | 709 | ||
- | 710 | switch (p2) { |
|
- | 711 | case DPLL_CFGCR2_KDIV_5: |
|
- | 712 | p2 = 5; |
|
- | 713 | break; |
|
- | 714 | case DPLL_CFGCR2_KDIV_2: |
|
- | 715 | p2 = 2; |
|
- | 716 | break; |
|
- | 717 | case DPLL_CFGCR2_KDIV_3: |
|
- | 718 | p2 = 3; |
|
- | 719 | break; |
|
- | 720 | case DPLL_CFGCR2_KDIV_1: |
|
- | 721 | p2 = 1; |
|
- | 722 | break; |
|
- | 723 | } |
|
- | 724 | ||
- | 725 | dco_freq = (cfgcr1_val & DPLL_CFGCR1_DCO_INTEGER_MASK) * 24 * 1000; |
|
- | 726 | ||
- | 727 | dco_freq += (((cfgcr1_val & DPLL_CFGCR1_DCO_FRACTION_MASK) >> 9) * 24 * |
|
- | 728 | 1000) / 0x8000; |
|
- | 729 | ||
- | 730 | return dco_freq / (p0 * p1 * p2 * 5); |
|
- | 731 | } |
|
588 | } |
732 | |
- | 733 | ||
- | 734 | static void skl_ddi_clock_get(struct intel_encoder *encoder, |
|
- | 735 | struct intel_crtc_config *pipe_config) |
|
- | 736 | { |
|
- | 737 | struct drm_i915_private *dev_priv = encoder->base.dev->dev_private; |
|
- | 738 | int link_clock = 0; |
|
- | 739 | uint32_t dpll_ctl1, dpll; |
|
- | 740 | ||
- | 741 | dpll = pipe_config->ddi_pll_sel; |
|
- | 742 | ||
- | 743 | dpll_ctl1 = I915_READ(DPLL_CTRL1); |
|
- | 744 | ||
- | 745 | if (dpll_ctl1 & DPLL_CTRL1_HDMI_MODE(dpll)) { |
|
- | 746 | link_clock = skl_calc_wrpll_link(dev_priv, dpll); |
|
- | 747 | } else { |
|
- | 748 | link_clock = dpll_ctl1 & DPLL_CRTL1_LINK_RATE_MASK(dpll); |
|
- | 749 | link_clock >>= DPLL_CRTL1_LINK_RATE_SHIFT(dpll); |
|
- | 750 | ||
- | 751 | switch (link_clock) { |
|
- | 752 | case DPLL_CRTL1_LINK_RATE_810: |
|
- | 753 | link_clock = 81000; |
|
- | 754 | break; |
|
- | 755 | case DPLL_CRTL1_LINK_RATE_1350: |
|
- | 756 | link_clock = 135000; |
|
- | 757 | break; |
|
- | 758 | case DPLL_CRTL1_LINK_RATE_2700: |
|
- | 759 | link_clock = 270000; |
|
- | 760 | break; |
|
- | 761 | default: |
|
- | 762 | WARN(1, "Unsupported link rate\n"); |
|
- | 763 | break; |
|
- | 764 | } |
|
- | 765 | link_clock *= 2; |
|
- | 766 | } |
|
- | 767 | ||
- | 768 | pipe_config->port_clock = link_clock; |
|
- | 769 | ||
- | 770 | if (pipe_config->has_dp_encoder) |
|
- | 771 | pipe_config->adjusted_mode.crtc_clock = |
|
- | 772 | intel_dotclock_calculate(pipe_config->port_clock, |
|
- | 773 | &pipe_config->dp_m_n); |
|
- | 774 | else |
|
- | 775 | pipe_config->adjusted_mode.crtc_clock = pipe_config->port_clock; |
|
- | 776 | } |
|
589 | 777 | ||
590 | void intel_ddi_clock_get(struct intel_encoder *encoder, |
778 | static void hsw_ddi_clock_get(struct intel_encoder *encoder, |
591 | struct intel_crtc_config *pipe_config) |
779 | struct intel_crtc_config *pipe_config) |
592 | { |
780 | { |
593 | struct drm_i915_private *dev_priv = encoder->base.dev->dev_private; |
781 | struct drm_i915_private *dev_priv = encoder->base.dev->dev_private; |
Line 641... | Line 829... | ||
641 | &pipe_config->dp_m_n); |
829 | &pipe_config->dp_m_n); |
642 | else |
830 | else |
643 | pipe_config->adjusted_mode.crtc_clock = pipe_config->port_clock; |
831 | pipe_config->adjusted_mode.crtc_clock = pipe_config->port_clock; |
644 | } |
832 | } |
Line -... | Line 833... | ||
- | 833 | ||
- | 834 | void intel_ddi_clock_get(struct intel_encoder *encoder, |
|
- | 835 | struct intel_crtc_config *pipe_config) |
|
- | 836 | { |
|
- | 837 | hsw_ddi_clock_get(encoder, pipe_config); |
|
- | 838 | } |
|
645 | 839 | ||
646 | static void |
840 | static void |
647 | intel_ddi_calculate_wrpll(int clock /* in Hz */, |
841 | hsw_ddi_calculate_wrpll(int clock /* in Hz */, |
648 | unsigned *r2_out, unsigned *n2_out, unsigned *p_out) |
842 | unsigned *r2_out, unsigned *n2_out, unsigned *p_out) |
649 | { |
843 | { |
650 | uint64_t freq2k; |
844 | uint64_t freq2k; |
651 | unsigned p, n2, r2; |
845 | unsigned p, n2, r2; |
Line 706... | Line 900... | ||
706 | *n2_out = best.n2; |
900 | *n2_out = best.n2; |
707 | *p_out = best.p; |
901 | *p_out = best.p; |
708 | *r2_out = best.r2; |
902 | *r2_out = best.r2; |
709 | } |
903 | } |
Line 710... | Line 904... | ||
710 | 904 | ||
711 | /* |
- | |
712 | * Tries to find a PLL for the CRTC. If it finds, it increases the refcount and |
905 | static bool |
713 | * stores it in intel_crtc->ddi_pll_sel, so other mode sets won't be able to |
906 | hsw_ddi_pll_select(struct intel_crtc *intel_crtc, |
714 | * steal the selected PLL. You need to call intel_ddi_pll_enable to actually |
907 | struct intel_encoder *intel_encoder, |
715 | * enable the PLL. |
- | |
716 | */ |
- | |
717 | bool intel_ddi_pll_select(struct intel_crtc *intel_crtc) |
908 | int clock) |
718 | { |
- | |
719 | struct drm_crtc *crtc = &intel_crtc->base; |
- | |
720 | struct intel_encoder *intel_encoder = intel_ddi_get_crtc_encoder(crtc); |
- | |
721 | int type = intel_encoder->type; |
- | |
722 | int clock = intel_crtc->config.port_clock; |
- | |
723 | - | ||
724 | intel_put_shared_dpll(intel_crtc); |
- | |
725 | 909 | { |
|
726 | if (type == INTEL_OUTPUT_HDMI) { |
910 | if (intel_encoder->type == INTEL_OUTPUT_HDMI) { |
727 | struct intel_shared_dpll *pll; |
911 | struct intel_shared_dpll *pll; |
728 | uint32_t val; |
912 | uint32_t val; |
Line 729... | Line 913... | ||
729 | unsigned p, n2, r2; |
913 | unsigned p, n2, r2; |
Line 730... | Line 914... | ||
730 | 914 | ||
731 | intel_ddi_calculate_wrpll(clock * 1000, &r2, &n2, &p); |
915 | hsw_ddi_calculate_wrpll(clock * 1000, &r2, &n2, &p); |
732 | 916 | ||
Line 733... | Line 917... | ||
733 | val = WRPLL_PLL_ENABLE | WRPLL_PLL_LCPLL | |
917 | val = WRPLL_PLL_ENABLE | WRPLL_PLL_LCPLL | |
Line 734... | Line 918... | ||
734 | WRPLL_DIVIDER_REFERENCE(r2) | WRPLL_DIVIDER_FEEDBACK(n2) | |
918 | WRPLL_DIVIDER_REFERENCE(r2) | WRPLL_DIVIDER_FEEDBACK(n2) | |
735 | WRPLL_DIVIDER_POST(p); |
919 | WRPLL_DIVIDER_POST(p); |
736 | 920 | ||
737 | intel_crtc->config.dpll_hw_state.wrpll = val; |
921 | intel_crtc->new_config->dpll_hw_state.wrpll = val; |
738 | 922 | ||
739 | pll = intel_get_shared_dpll(intel_crtc); |
923 | pll = intel_get_shared_dpll(intel_crtc); |
Line 740... | Line 924... | ||
740 | if (pll == NULL) { |
924 | if (pll == NULL) { |
- | 925 | DRM_DEBUG_DRIVER("failed to find PLL for pipe %c\n", |
|
- | 926 | pipe_name(intel_crtc->pipe)); |
|
- | 927 | return false; |
|
- | 928 | } |
|
- | 929 | ||
- | 930 | intel_crtc->new_config->ddi_pll_sel = PORT_CLK_SEL_WRPLL(pll->id); |
|
- | 931 | } |
|
- | 932 | ||
- | 933 | return true; |
|
- | 934 | } |
|
- | 935 | ||
- | 936 | struct skl_wrpll_params { |
|
- | 937 | uint32_t dco_fraction; |
|
- | 938 | uint32_t dco_integer; |
|
- | 939 | uint32_t qdiv_ratio; |
|
- | 940 | uint32_t qdiv_mode; |
|
- | 941 | uint32_t kdiv; |
|
- | 942 | uint32_t pdiv; |
|
- | 943 | uint32_t central_freq; |
|
- | 944 | }; |
|
- | 945 | ||
- | 946 | static void |
|
- | 947 | skl_ddi_calculate_wrpll(int clock /* in Hz */, |
|
- | 948 | struct skl_wrpll_params *wrpll_params) |
|
- | 949 | { |
|
- | 950 | uint64_t afe_clock = clock * 5; /* AFE Clock is 5x Pixel clock */ |
|
- | 951 | uint64_t dco_central_freq[3] = {8400000000ULL, |
|
- | 952 | 9000000000ULL, |
|
- | 953 | 9600000000ULL}; |
|
- | 954 | uint32_t min_dco_deviation = 400; |
|
- | 955 | uint32_t min_dco_index = 3; |
|
- | 956 | uint32_t P0[4] = {1, 2, 3, 7}; |
|
- | 957 | uint32_t P2[4] = {1, 2, 3, 5}; |
|
- | 958 | bool found = false; |
|
- | 959 | uint32_t candidate_p = 0; |
|
- | 960 | uint32_t candidate_p0[3] = {0}, candidate_p1[3] = {0}; |
|
- | 961 | uint32_t candidate_p2[3] = {0}; |
|
- | 962 | uint32_t dco_central_freq_deviation[3]; |
|
- | 963 | uint32_t i, P1, k, dco_count; |
|
- | 964 | bool retry_with_odd = false; |
|
- | 965 | uint64_t dco_freq; |
|
- | 966 | ||
- | 967 | /* Determine P0, P1 or P2 */ |
|
- | 968 | for (dco_count = 0; dco_count < 3; dco_count++) { |
|
- | 969 | found = false; |
|
- | 970 | candidate_p = |
|
- | 971 | div64_u64(dco_central_freq[dco_count], afe_clock); |
|
- | 972 | if (retry_with_odd == false) |
|
- | 973 | candidate_p = (candidate_p % 2 == 0 ? |
|
- | 974 | candidate_p : candidate_p + 1); |
|
- | 975 | ||
- | 976 | for (P1 = 1; P1 < candidate_p; P1++) { |
|
- | 977 | for (i = 0; i < 4; i++) { |
|
- | 978 | if (!(P0[i] != 1 || P1 == 1)) |
|
- | 979 | continue; |
|
- | 980 | ||
- | 981 | for (k = 0; k < 4; k++) { |
|
- | 982 | if (P1 != 1 && P2[k] != 2) |
|
- | 983 | continue; |
|
- | 984 | ||
- | 985 | if (candidate_p == P0[i] * P1 * P2[k]) { |
|
- | 986 | /* Found possible P0, P1, P2 */ |
|
- | 987 | found = true; |
|
- | 988 | candidate_p0[dco_count] = P0[i]; |
|
- | 989 | candidate_p1[dco_count] = P1; |
|
- | 990 | candidate_p2[dco_count] = P2[k]; |
|
- | 991 | goto found; |
|
- | 992 | } |
|
- | 993 | ||
- | 994 | } |
|
- | 995 | } |
|
- | 996 | } |
|
- | 997 | ||
- | 998 | found: |
|
- | 999 | if (found) { |
|
- | 1000 | dco_central_freq_deviation[dco_count] = |
|
- | 1001 | div64_u64(10000 * |
|
- | 1002 | abs_diff((candidate_p * afe_clock), |
|
- | 1003 | dco_central_freq[dco_count]), |
|
- | 1004 | dco_central_freq[dco_count]); |
|
- | 1005 | ||
- | 1006 | if (dco_central_freq_deviation[dco_count] < |
|
- | 1007 | min_dco_deviation) { |
|
- | 1008 | min_dco_deviation = |
|
- | 1009 | dco_central_freq_deviation[dco_count]; |
|
- | 1010 | min_dco_index = dco_count; |
|
- | 1011 | } |
|
- | 1012 | } |
|
- | 1013 | ||
- | 1014 | if (min_dco_index > 2 && dco_count == 2) { |
|
- | 1015 | retry_with_odd = true; |
|
- | 1016 | dco_count = 0; |
|
- | 1017 | } |
|
- | 1018 | } |
|
- | 1019 | ||
- | 1020 | if (min_dco_index > 2) { |
|
- | 1021 | WARN(1, "No valid values found for the given pixel clock\n"); |
|
- | 1022 | } else { |
|
- | 1023 | wrpll_params->central_freq = dco_central_freq[min_dco_index]; |
|
- | 1024 | ||
- | 1025 | switch (dco_central_freq[min_dco_index]) { |
|
- | 1026 | case 9600000000ULL: |
|
- | 1027 | wrpll_params->central_freq = 0; |
|
- | 1028 | break; |
|
- | 1029 | case 9000000000ULL: |
|
- | 1030 | wrpll_params->central_freq = 1; |
|
- | 1031 | break; |
|
- | 1032 | case 8400000000ULL: |
|
- | 1033 | wrpll_params->central_freq = 3; |
|
- | 1034 | } |
|
- | 1035 | ||
- | 1036 | switch (candidate_p0[min_dco_index]) { |
|
- | 1037 | case 1: |
|
- | 1038 | wrpll_params->pdiv = 0; |
|
- | 1039 | break; |
|
- | 1040 | case 2: |
|
- | 1041 | wrpll_params->pdiv = 1; |
|
- | 1042 | break; |
|
- | 1043 | case 3: |
|
- | 1044 | wrpll_params->pdiv = 2; |
|
- | 1045 | break; |
|
- | 1046 | case 7: |
|
- | 1047 | wrpll_params->pdiv = 4; |
|
- | 1048 | break; |
|
- | 1049 | default: |
|
- | 1050 | WARN(1, "Incorrect PDiv\n"); |
|
- | 1051 | } |
|
- | 1052 | ||
- | 1053 | switch (candidate_p2[min_dco_index]) { |
|
- | 1054 | case 5: |
|
- | 1055 | wrpll_params->kdiv = 0; |
|
- | 1056 | break; |
|
- | 1057 | case 2: |
|
- | 1058 | wrpll_params->kdiv = 1; |
|
- | 1059 | break; |
|
- | 1060 | case 3: |
|
- | 1061 | wrpll_params->kdiv = 2; |
|
- | 1062 | break; |
|
- | 1063 | case 1: |
|
- | 1064 | wrpll_params->kdiv = 3; |
|
- | 1065 | break; |
|
- | 1066 | default: |
|
- | 1067 | WARN(1, "Incorrect KDiv\n"); |
|
- | 1068 | } |
|
- | 1069 | ||
- | 1070 | wrpll_params->qdiv_ratio = candidate_p1[min_dco_index]; |
|
- | 1071 | wrpll_params->qdiv_mode = |
|
- | 1072 | (wrpll_params->qdiv_ratio == 1) ? 0 : 1; |
|
- | 1073 | ||
- | 1074 | dco_freq = candidate_p0[min_dco_index] * |
|
- | 1075 | candidate_p1[min_dco_index] * |
|
- | 1076 | candidate_p2[min_dco_index] * afe_clock; |
|
- | 1077 | ||
- | 1078 | /* |
|
- | 1079 | * Intermediate values are in Hz. |
|
- | 1080 | * Divide by MHz to match bsepc |
|
- | 1081 | */ |
|
- | 1082 | wrpll_params->dco_integer = div_u64(dco_freq, (24 * MHz(1))); |
|
- | 1083 | wrpll_params->dco_fraction = |
|
- | 1084 | div_u64(((div_u64(dco_freq, 24) - |
|
- | 1085 | wrpll_params->dco_integer * MHz(1)) * 0x8000), MHz(1)); |
|
- | 1086 | ||
- | 1087 | } |
|
- | 1088 | } |
|
- | 1089 | ||
- | 1090 | ||
- | 1091 | static bool |
|
- | 1092 | skl_ddi_pll_select(struct intel_crtc *intel_crtc, |
|
- | 1093 | struct intel_encoder *intel_encoder, |
|
- | 1094 | int clock) |
|
- | 1095 | { |
|
- | 1096 | struct intel_shared_dpll *pll; |
|
- | 1097 | uint32_t ctrl1, cfgcr1, cfgcr2; |
|
- | 1098 | ||
- | 1099 | /* |
|
- | 1100 | * See comment in intel_dpll_hw_state to understand why we always use 0 |
|
- | 1101 | * as the DPLL id in this function. |
|
- | 1102 | */ |
|
- | 1103 | ||
- | 1104 | ctrl1 = DPLL_CTRL1_OVERRIDE(0); |
|
- | 1105 | ||
- | 1106 | if (intel_encoder->type == INTEL_OUTPUT_HDMI) { |
|
- | 1107 | struct skl_wrpll_params wrpll_params = { 0, }; |
|
- | 1108 | ||
- | 1109 | ctrl1 |= DPLL_CTRL1_HDMI_MODE(0); |
|
- | 1110 | ||
- | 1111 | skl_ddi_calculate_wrpll(clock * 1000, &wrpll_params); |
|
- | 1112 | ||
- | 1113 | cfgcr1 = DPLL_CFGCR1_FREQ_ENABLE | |
|
- | 1114 | DPLL_CFGCR1_DCO_FRACTION(wrpll_params.dco_fraction) | |
|
- | 1115 | wrpll_params.dco_integer; |
|
- | 1116 | ||
- | 1117 | cfgcr2 = DPLL_CFGCR2_QDIV_RATIO(wrpll_params.qdiv_ratio) | |
|
- | 1118 | DPLL_CFGCR2_QDIV_MODE(wrpll_params.qdiv_mode) | |
|
- | 1119 | DPLL_CFGCR2_KDIV(wrpll_params.kdiv) | |
|
- | 1120 | DPLL_CFGCR2_PDIV(wrpll_params.pdiv) | |
|
- | 1121 | wrpll_params.central_freq; |
|
- | 1122 | } else if (intel_encoder->type == INTEL_OUTPUT_DISPLAYPORT) { |
|
- | 1123 | struct drm_encoder *encoder = &intel_encoder->base; |
|
- | 1124 | struct intel_dp *intel_dp = enc_to_intel_dp(encoder); |
|
- | 1125 | ||
- | 1126 | switch (intel_dp->link_bw) { |
|
- | 1127 | case DP_LINK_BW_1_62: |
|
- | 1128 | ctrl1 |= DPLL_CRTL1_LINK_RATE(DPLL_CRTL1_LINK_RATE_810, 0); |
|
- | 1129 | break; |
|
- | 1130 | case DP_LINK_BW_2_7: |
|
- | 1131 | ctrl1 |= DPLL_CRTL1_LINK_RATE(DPLL_CRTL1_LINK_RATE_1350, 0); |
|
- | 1132 | break; |
|
- | 1133 | case DP_LINK_BW_5_4: |
|
- | 1134 | ctrl1 |= DPLL_CRTL1_LINK_RATE(DPLL_CRTL1_LINK_RATE_2700, 0); |
|
- | 1135 | break; |
|
- | 1136 | } |
|
- | 1137 | ||
- | 1138 | cfgcr1 = cfgcr2 = 0; |
|
- | 1139 | } else /* eDP */ |
|
- | 1140 | return true; |
|
- | 1141 | ||
- | 1142 | intel_crtc->new_config->dpll_hw_state.ctrl1 = ctrl1; |
|
- | 1143 | intel_crtc->new_config->dpll_hw_state.cfgcr1 = cfgcr1; |
|
- | 1144 | intel_crtc->new_config->dpll_hw_state.cfgcr2 = cfgcr2; |
|
741 | DRM_DEBUG_DRIVER("failed to find PLL for pipe %c\n", |
1145 | |
Line -... | Line 1146... | ||
- | 1146 | pll = intel_get_shared_dpll(intel_crtc); |
|
- | 1147 | if (pll == NULL) { |
|
- | 1148 | DRM_DEBUG_DRIVER("failed to find PLL for pipe %c\n", |
|
742 | pipe_name(intel_crtc->pipe)); |
1149 | pipe_name(intel_crtc->pipe)); |
743 | return false; |
1150 | return false; |
Line -... | Line 1151... | ||
- | 1151 | } |
|
- | 1152 | ||
- | 1153 | /* shared DPLL id 0 is DPLL 1 */ |
|
- | 1154 | intel_crtc->new_config->ddi_pll_sel = pll->id + 1; |
|
- | 1155 | ||
- | 1156 | return true; |
|
- | 1157 | } |
|
- | 1158 | ||
- | 1159 | /* |
|
- | 1160 | * Tries to find a *shared* PLL for the CRTC and store it in |
|
- | 1161 | * intel_crtc->ddi_pll_sel. |
|
- | 1162 | * |
|
- | 1163 | * For private DPLLs, compute_config() should do the selection for us. This |
|
- | 1164 | * function should be folded into compute_config() eventually. |
|
- | 1165 | */ |
|
- | 1166 | bool intel_ddi_pll_select(struct intel_crtc *intel_crtc) |
|
- | 1167 | { |
|
- | 1168 | struct drm_device *dev = intel_crtc->base.dev; |
|
- | 1169 | struct intel_encoder *intel_encoder = |
|
- | 1170 | intel_ddi_get_crtc_new_encoder(intel_crtc); |
|
744 | } |
1171 | int clock = intel_crtc->new_config->port_clock; |
745 | 1172 | ||
746 | intel_crtc->config.ddi_pll_sel = PORT_CLK_SEL_WRPLL(pll->id); |
1173 | if (IS_SKYLAKE(dev)) |
747 | } |
1174 | return skl_ddi_pll_select(intel_crtc, intel_encoder, clock); |
748 | 1175 | else |
|
Line 919... | Line 1346... | ||
919 | enum transcoder cpu_transcoder; |
1346 | enum transcoder cpu_transcoder; |
920 | enum intel_display_power_domain power_domain; |
1347 | enum intel_display_power_domain power_domain; |
921 | uint32_t tmp; |
1348 | uint32_t tmp; |
Line 922... | Line 1349... | ||
922 | 1349 | ||
923 | power_domain = intel_display_port_power_domain(intel_encoder); |
1350 | power_domain = intel_display_port_power_domain(intel_encoder); |
924 | if (!intel_display_power_enabled(dev_priv, power_domain)) |
1351 | if (!intel_display_power_is_enabled(dev_priv, power_domain)) |
Line 925... | Line 1352... | ||
925 | return false; |
1352 | return false; |
926 | 1353 | ||
Line 965... | Line 1392... | ||
965 | enum intel_display_power_domain power_domain; |
1392 | enum intel_display_power_domain power_domain; |
966 | u32 tmp; |
1393 | u32 tmp; |
967 | int i; |
1394 | int i; |
Line 968... | Line 1395... | ||
968 | 1395 | ||
969 | power_domain = intel_display_port_power_domain(encoder); |
1396 | power_domain = intel_display_port_power_domain(encoder); |
970 | if (!intel_display_power_enabled(dev_priv, power_domain)) |
1397 | if (!intel_display_power_is_enabled(dev_priv, power_domain)) |
Line 971... | Line 1398... | ||
971 | return false; |
1398 | return false; |
Line 972... | Line 1399... | ||
972 | 1399 | ||
Line 1036... | Line 1463... | ||
1036 | } |
1463 | } |
Line 1037... | Line 1464... | ||
1037 | 1464 | ||
1038 | static void intel_ddi_pre_enable(struct intel_encoder *intel_encoder) |
1465 | static void intel_ddi_pre_enable(struct intel_encoder *intel_encoder) |
1039 | { |
1466 | { |
- | 1467 | struct drm_encoder *encoder = &intel_encoder->base; |
|
1040 | struct drm_encoder *encoder = &intel_encoder->base; |
1468 | struct drm_device *dev = encoder->dev; |
1041 | struct drm_i915_private *dev_priv = encoder->dev->dev_private; |
1469 | struct drm_i915_private *dev_priv = dev->dev_private; |
1042 | struct intel_crtc *crtc = to_intel_crtc(encoder->crtc); |
1470 | struct intel_crtc *crtc = to_intel_crtc(encoder->crtc); |
1043 | enum port port = intel_ddi_get_encoder_port(intel_encoder); |
1471 | enum port port = intel_ddi_get_encoder_port(intel_encoder); |
Line 1044... | Line -... | ||
1044 | int type = intel_encoder->type; |
- | |
1045 | - | ||
1046 | if (crtc->config.has_audio) { |
- | |
1047 | DRM_DEBUG_DRIVER("Audio on pipe %c on DDI\n", |
- | |
1048 | pipe_name(crtc->pipe)); |
- | |
1049 | - | ||
1050 | /* write eld */ |
- | |
1051 | DRM_DEBUG_DRIVER("DDI audio: write eld information\n"); |
- | |
1052 | intel_write_eld(encoder, &crtc->config.adjusted_mode); |
- | |
1053 | } |
1472 | int type = intel_encoder->type; |
1054 | 1473 | ||
1055 | if (type == INTEL_OUTPUT_EDP) { |
1474 | if (type == INTEL_OUTPUT_EDP) { |
1056 | struct intel_dp *intel_dp = enc_to_intel_dp(encoder); |
1475 | struct intel_dp *intel_dp = enc_to_intel_dp(encoder); |
Line -... | Line 1476... | ||
- | 1476 | intel_edp_panel_on(intel_dp); |
|
- | 1477 | } |
|
- | 1478 | ||
- | 1479 | if (IS_SKYLAKE(dev)) { |
|
- | 1480 | uint32_t dpll = crtc->config.ddi_pll_sel; |
|
- | 1481 | uint32_t val; |
|
- | 1482 | ||
- | 1483 | /* |
|
- | 1484 | * DPLL0 is used for eDP and is the only "private" DPLL (as |
|
- | 1485 | * opposed to shared) on SKL |
|
- | 1486 | */ |
|
- | 1487 | if (type == INTEL_OUTPUT_EDP) { |
|
- | 1488 | WARN_ON(dpll != SKL_DPLL0); |
|
- | 1489 | ||
- | 1490 | val = I915_READ(DPLL_CTRL1); |
|
- | 1491 | ||
- | 1492 | val &= ~(DPLL_CTRL1_HDMI_MODE(dpll) | |
|
- | 1493 | DPLL_CTRL1_SSC(dpll) | |
|
- | 1494 | DPLL_CRTL1_LINK_RATE_MASK(dpll)); |
|
- | 1495 | val |= crtc->config.dpll_hw_state.ctrl1 << (dpll * 6); |
|
- | 1496 | ||
- | 1497 | I915_WRITE(DPLL_CTRL1, val); |
|
- | 1498 | POSTING_READ(DPLL_CTRL1); |
|
- | 1499 | } |
|
- | 1500 | ||
- | 1501 | /* DDI -> PLL mapping */ |
|
- | 1502 | val = I915_READ(DPLL_CTRL2); |
|
- | 1503 | ||
- | 1504 | val &= ~(DPLL_CTRL2_DDI_CLK_OFF(port) | |
|
- | 1505 | DPLL_CTRL2_DDI_CLK_SEL_MASK(port)); |
|
- | 1506 | val |= (DPLL_CTRL2_DDI_CLK_SEL(dpll, port) | |
|
- | 1507 | DPLL_CTRL2_DDI_SEL_OVERRIDE(port)); |
|
- | 1508 | ||
1057 | intel_edp_panel_on(intel_dp); |
1509 | I915_WRITE(DPLL_CTRL2, val); |
1058 | } |
1510 | |
- | 1511 | } else { |
|
Line 1059... | Line 1512... | ||
1059 | 1512 | WARN_ON(crtc->config.ddi_pll_sel == PORT_CLK_SEL_NONE); |
|
1060 | WARN_ON(crtc->config.ddi_pll_sel == PORT_CLK_SEL_NONE); |
1513 | I915_WRITE(PORT_CLK_SEL(port), crtc->config.ddi_pll_sel); |
Line 1061... | Line 1514... | ||
1061 | I915_WRITE(PORT_CLK_SEL(port), crtc->config.ddi_pll_sel); |
1514 | } |
Line 1062... | Line 1515... | ||
1062 | 1515 | ||
1063 | if (type == INTEL_OUTPUT_DISPLAYPORT || type == INTEL_OUTPUT_EDP) { |
1516 | if (type == INTEL_OUTPUT_DISPLAYPORT || type == INTEL_OUTPUT_EDP) { |
1064 | struct intel_dp *intel_dp = enc_to_intel_dp(encoder); |
1517 | struct intel_dp *intel_dp = enc_to_intel_dp(encoder); |
1065 | 1518 | ||
1066 | intel_ddi_init_dp_buf_reg(intel_encoder); |
1519 | intel_ddi_init_dp_buf_reg(intel_encoder); |
1067 | 1520 | ||
1068 | intel_dp_sink_dpms(intel_dp, DRM_MODE_DPMS_ON); |
1521 | intel_dp_sink_dpms(intel_dp, DRM_MODE_DPMS_ON); |
Line 1069... | Line 1522... | ||
1069 | intel_dp_start_link_train(intel_dp); |
1522 | intel_dp_start_link_train(intel_dp); |
Line 1080... | Line 1533... | ||
1080 | } |
1533 | } |
Line 1081... | Line 1534... | ||
1081 | 1534 | ||
1082 | static void intel_ddi_post_disable(struct intel_encoder *intel_encoder) |
1535 | static void intel_ddi_post_disable(struct intel_encoder *intel_encoder) |
1083 | { |
1536 | { |
- | 1537 | struct drm_encoder *encoder = &intel_encoder->base; |
|
1084 | struct drm_encoder *encoder = &intel_encoder->base; |
1538 | struct drm_device *dev = encoder->dev; |
1085 | struct drm_i915_private *dev_priv = encoder->dev->dev_private; |
1539 | struct drm_i915_private *dev_priv = dev->dev_private; |
1086 | enum port port = intel_ddi_get_encoder_port(intel_encoder); |
1540 | enum port port = intel_ddi_get_encoder_port(intel_encoder); |
1087 | int type = intel_encoder->type; |
1541 | int type = intel_encoder->type; |
1088 | uint32_t val; |
1542 | uint32_t val; |
Line 1108... | Line 1562... | ||
1108 | intel_dp_sink_dpms(intel_dp, DRM_MODE_DPMS_OFF); |
1562 | intel_dp_sink_dpms(intel_dp, DRM_MODE_DPMS_OFF); |
1109 | intel_edp_panel_vdd_on(intel_dp); |
1563 | intel_edp_panel_vdd_on(intel_dp); |
1110 | intel_edp_panel_off(intel_dp); |
1564 | intel_edp_panel_off(intel_dp); |
1111 | } |
1565 | } |
Line -... | Line 1566... | ||
- | 1566 | ||
- | 1567 | if (IS_SKYLAKE(dev)) |
|
- | 1568 | I915_WRITE(DPLL_CTRL2, (I915_READ(DPLL_CTRL2) | |
|
- | 1569 | DPLL_CTRL2_DDI_CLK_OFF(port))); |
|
1112 | 1570 | else |
|
1113 | I915_WRITE(PORT_CLK_SEL(port), PORT_CLK_SEL_NONE); |
1571 | I915_WRITE(PORT_CLK_SEL(port), PORT_CLK_SEL_NONE); |
Line 1114... | Line 1572... | ||
1114 | } |
1572 | } |
1115 | 1573 | ||
1116 | static void intel_enable_ddi(struct intel_encoder *intel_encoder) |
1574 | static void intel_enable_ddi(struct intel_encoder *intel_encoder) |
1117 | { |
1575 | { |
1118 | struct drm_encoder *encoder = &intel_encoder->base; |
1576 | struct drm_encoder *encoder = &intel_encoder->base; |
1119 | struct drm_crtc *crtc = encoder->crtc; |
- | |
1120 | struct intel_crtc *intel_crtc = to_intel_crtc(crtc); |
1577 | struct drm_crtc *crtc = encoder->crtc; |
1121 | int pipe = intel_crtc->pipe; |
1578 | struct intel_crtc *intel_crtc = to_intel_crtc(crtc); |
1122 | struct drm_device *dev = encoder->dev; |
1579 | struct drm_device *dev = encoder->dev; |
1123 | struct drm_i915_private *dev_priv = dev->dev_private; |
1580 | struct drm_i915_private *dev_priv = dev->dev_private; |
1124 | enum port port = intel_ddi_get_encoder_port(intel_encoder); |
- | |
Line 1125... | Line 1581... | ||
1125 | int type = intel_encoder->type; |
1581 | enum port port = intel_ddi_get_encoder_port(intel_encoder); |
1126 | uint32_t tmp; |
1582 | int type = intel_encoder->type; |
1127 | 1583 | ||
Line 1137... | Line 1593... | ||
1137 | intel_dig_port->saved_port_bits | |
1593 | intel_dig_port->saved_port_bits | |
1138 | DDI_BUF_CTL_ENABLE); |
1594 | DDI_BUF_CTL_ENABLE); |
1139 | } else if (type == INTEL_OUTPUT_EDP) { |
1595 | } else if (type == INTEL_OUTPUT_EDP) { |
1140 | struct intel_dp *intel_dp = enc_to_intel_dp(encoder); |
1596 | struct intel_dp *intel_dp = enc_to_intel_dp(encoder); |
Line 1141... | Line 1597... | ||
1141 | 1597 | ||
1142 | if (port == PORT_A) |
1598 | if (port == PORT_A && INTEL_INFO(dev)->gen < 9) |
Line 1143... | Line 1599... | ||
1143 | intel_dp_stop_link_train(intel_dp); |
1599 | intel_dp_stop_link_train(intel_dp); |
1144 | 1600 | ||
1145 | intel_edp_backlight_on(intel_dp); |
1601 | intel_edp_backlight_on(intel_dp); |
Line 1146... | Line 1602... | ||
1146 | intel_edp_psr_enable(intel_dp); |
1602 | intel_psr_enable(intel_dp); |
1147 | } |
1603 | } |
1148 | - | ||
1149 | if (intel_crtc->config.has_audio) { |
- | |
1150 | intel_display_power_get(dev_priv, POWER_DOMAIN_AUDIO); |
1604 | |
1151 | tmp = I915_READ(HSW_AUD_PIN_ELD_CP_VLD); |
1605 | if (intel_crtc->config.has_audio) { |
1152 | tmp |= ((AUDIO_OUTPUT_ENABLE_A | AUDIO_ELD_VALID_A) << (pipe * 4)); |
1606 | intel_display_power_get(dev_priv, POWER_DOMAIN_AUDIO); |
Line 1153... | Line 1607... | ||
1153 | I915_WRITE(HSW_AUD_PIN_ELD_CP_VLD, tmp); |
1607 | intel_audio_codec_enable(intel_encoder); |
1154 | } |
1608 | } |
1155 | } |
1609 | } |
1156 | 1610 | ||
1157 | static void intel_disable_ddi(struct intel_encoder *intel_encoder) |
1611 | static void intel_disable_ddi(struct intel_encoder *intel_encoder) |
1158 | { |
- | |
1159 | struct drm_encoder *encoder = &intel_encoder->base; |
1612 | { |
1160 | struct drm_crtc *crtc = encoder->crtc; |
1613 | struct drm_encoder *encoder = &intel_encoder->base; |
1161 | struct intel_crtc *intel_crtc = to_intel_crtc(crtc); |
1614 | struct drm_crtc *crtc = encoder->crtc; |
1162 | int pipe = intel_crtc->pipe; |
- | |
Line 1163... | Line -... | ||
1163 | int type = intel_encoder->type; |
- | |
1164 | struct drm_device *dev = encoder->dev; |
- | |
1165 | struct drm_i915_private *dev_priv = dev->dev_private; |
1615 | struct intel_crtc *intel_crtc = to_intel_crtc(crtc); |
1166 | uint32_t tmp; |
- | |
1167 | - | ||
1168 | /* We can't touch HSW_AUD_PIN_ELD_CP_VLD uncionditionally because this |
- | |
1169 | * register is part of the power well on Haswell. */ |
1616 | int type = intel_encoder->type; |
1170 | if (intel_crtc->config.has_audio) { |
1617 | struct drm_device *dev = encoder->dev; |
1171 | tmp = I915_READ(HSW_AUD_PIN_ELD_CP_VLD); |
1618 | struct drm_i915_private *dev_priv = dev->dev_private; |
Line 1172... | Line 1619... | ||
1172 | tmp &= ~((AUDIO_OUTPUT_ENABLE_A | AUDIO_ELD_VALID_A) << |
1619 | |
1173 | (pipe * 4)); |
1620 | if (intel_crtc->config.has_audio) { |
Line 1174... | Line 1621... | ||
1174 | I915_WRITE(HSW_AUD_PIN_ELD_CP_VLD, tmp); |
1621 | intel_audio_codec_disable(intel_encoder); |
1175 | intel_display_power_put(dev_priv, POWER_DOMAIN_AUDIO); |
1622 | intel_display_power_put(dev_priv, POWER_DOMAIN_AUDIO); |
1176 | } |
1623 | } |
1177 | 1624 | ||
Line -... | Line 1625... | ||
- | 1625 | if (type == INTEL_OUTPUT_EDP) { |
|
- | 1626 | struct intel_dp *intel_dp = enc_to_intel_dp(encoder); |
|
- | 1627 | ||
- | 1628 | intel_psr_disable(intel_dp); |
|
- | 1629 | intel_edp_backlight_off(intel_dp); |
|
- | 1630 | } |
|
- | 1631 | } |
|
- | 1632 | ||
- | 1633 | static int skl_get_cdclk_freq(struct drm_i915_private *dev_priv) |
|
- | 1634 | { |
|
- | 1635 | uint32_t lcpll1 = I915_READ(LCPLL1_CTL); |
|
- | 1636 | uint32_t cdctl = I915_READ(CDCLK_CTL); |
|
- | 1637 | uint32_t linkrate; |
|
- | 1638 | ||
- | 1639 | if (!(lcpll1 & LCPLL_PLL_ENABLE)) { |
|
- | 1640 | WARN(1, "LCPLL1 not enabled\n"); |
|
- | 1641 | return 24000; /* 24MHz is the cd freq with NSSC ref */ |
|
- | 1642 | } |
|
- | 1643 | ||
- | 1644 | if ((cdctl & CDCLK_FREQ_SEL_MASK) == CDCLK_FREQ_540) |
|
- | 1645 | return 540000; |
|
- | 1646 | ||
- | 1647 | linkrate = (I915_READ(DPLL_CTRL1) & |
|
- | 1648 | DPLL_CRTL1_LINK_RATE_MASK(SKL_DPLL0)) >> 1; |
|
- | 1649 | ||
- | 1650 | if (linkrate == DPLL_CRTL1_LINK_RATE_2160 || |
|
- | 1651 | linkrate == DPLL_CRTL1_LINK_RATE_1080) { |
|
- | 1652 | /* vco 8640 */ |
|
- | 1653 | switch (cdctl & CDCLK_FREQ_SEL_MASK) { |
|
- | 1654 | case CDCLK_FREQ_450_432: |
|
- | 1655 | return 432000; |
|
- | 1656 | case CDCLK_FREQ_337_308: |
|
- | 1657 | return 308570; |
|
- | 1658 | case CDCLK_FREQ_675_617: |
|
- | 1659 | return 617140; |
|
- | 1660 | default: |
|
- | 1661 | WARN(1, "Unknown cd freq selection\n"); |
|
- | 1662 | } |
|
- | 1663 | } else { |
|
- | 1664 | /* vco 8100 */ |
|
- | 1665 | switch (cdctl & CDCLK_FREQ_SEL_MASK) { |
|
- | 1666 | case CDCLK_FREQ_450_432: |
|
- | 1667 | return 450000; |
|
- | 1668 | case CDCLK_FREQ_337_308: |
|
- | 1669 | return 337500; |
|
- | 1670 | case CDCLK_FREQ_675_617: |
|
- | 1671 | return 675000; |
|
- | 1672 | default: |
|
1178 | if (type == INTEL_OUTPUT_EDP) { |
1673 | WARN(1, "Unknown cd freq selection\n"); |
1179 | struct intel_dp *intel_dp = enc_to_intel_dp(encoder); |
1674 | } |
1180 | - | ||
1181 | intel_edp_psr_disable(intel_dp); |
1675 | } |
1182 | intel_edp_backlight_off(intel_dp); |
1676 | |
Line 1183... | Line 1677... | ||
1183 | } |
1677 | /* error case, do as if DPLL0 isn't enabled */ |
1184 | } |
1678 | return 24000; |
1185 | 1679 | } |
|
1186 | int intel_ddi_get_cdclk_freq(struct drm_i915_private *dev_priv) |
1680 | |
1187 | { |
1681 | static int bdw_get_cdclk_freq(struct drm_i915_private *dev_priv) |
1188 | struct drm_device *dev = dev_priv->dev; |
1682 | { |
1189 | uint32_t lcpll = I915_READ(LCPLL_CTL); |
- | |
1190 | uint32_t freq = lcpll & LCPLL_CLK_FREQ_MASK; |
- | |
1191 | - | ||
1192 | if (lcpll & LCPLL_CD_SOURCE_FCLK) { |
- | |
1193 | return 800000; |
- | |
1194 | } else if (I915_READ(FUSE_STRAP) & HSW_CDCLK_LIMIT) { |
- | |
1195 | return 450000; |
1683 | uint32_t lcpll = I915_READ(LCPLL_CTL); |
1196 | } else if (freq == LCPLL_CLK_FREQ_450) { |
1684 | uint32_t freq = lcpll & LCPLL_CLK_FREQ_MASK; |
1197 | return 450000; |
1685 | |
1198 | } else if (IS_HASWELL(dev)) { |
1686 | if (lcpll & LCPLL_CD_SOURCE_FCLK) |
1199 | if (IS_ULT(dev)) |
1687 | return 800000; |
1200 | return 337500; |
1688 | else if (I915_READ(FUSE_STRAP) & HSW_CDCLK_LIMIT) |
1201 | else |
1689 | return 450000; |
- | 1690 | else if (freq == LCPLL_CLK_FREQ_450) |
|
- | 1691 | return 450000; |
|
- | 1692 | else if (freq == LCPLL_CLK_FREQ_54O_BDW) |
|
- | 1693 | return 540000; |
|
- | 1694 | else if (freq == LCPLL_CLK_FREQ_337_5_BDW) |
|
- | 1695 | return 337500; |
|
- | 1696 | else |
|
- | 1697 | return 675000; |
|
- | 1698 | } |
|
- | 1699 | ||
- | 1700 | static int hsw_get_cdclk_freq(struct drm_i915_private *dev_priv) |
|
- | 1701 | { |
|
- | 1702 | struct drm_device *dev = dev_priv->dev; |
|
- | 1703 | uint32_t lcpll = I915_READ(LCPLL_CTL); |
|
- | 1704 | uint32_t freq = lcpll & LCPLL_CLK_FREQ_MASK; |
|
- | 1705 | ||
- | 1706 | if (lcpll & LCPLL_CD_SOURCE_FCLK) |
|
- | 1707 | return 800000; |
|
- | 1708 | else if (I915_READ(FUSE_STRAP) & HSW_CDCLK_LIMIT) |
|
- | 1709 | return 450000; |
|
- | 1710 | else if (freq == LCPLL_CLK_FREQ_450) |
|
- | 1711 | return 450000; |
|
- | 1712 | else if (IS_HSW_ULT(dev)) |
|
- | 1713 | return 337500; |
|
- | 1714 | else |
|
- | 1715 | return 540000; |
|
- | 1716 | } |
|
- | 1717 | ||
- | 1718 | int intel_ddi_get_cdclk_freq(struct drm_i915_private *dev_priv) |
|
- | 1719 | { |
|
- | 1720 | struct drm_device *dev = dev_priv->dev; |
|
1202 | return 540000; |
1721 | |
Line 1203... | Line 1722... | ||
1203 | } else { |
1722 | if (IS_SKYLAKE(dev)) |
1204 | if (freq == LCPLL_CLK_FREQ_54O_BDW) |
1723 | return skl_get_cdclk_freq(dev_priv); |
1205 | return 540000; |
1724 | |
1206 | else if (freq == LCPLL_CLK_FREQ_337_5_BDW) |
1725 | if (IS_BROADWELL(dev)) |
1207 | return 337500; |
1726 | return bdw_get_cdclk_freq(dev_priv); |
1208 | else |
1727 | |
1209 | return 675000; |
1728 | /* Haswell */ |
Line 1210... | Line 1729... | ||
1210 | } |
1729 | return hsw_get_cdclk_freq(dev_priv); |
Line 1232... | Line 1751... | ||
1232 | struct intel_shared_dpll *pll, |
1751 | struct intel_shared_dpll *pll, |
1233 | struct intel_dpll_hw_state *hw_state) |
1752 | struct intel_dpll_hw_state *hw_state) |
1234 | { |
1753 | { |
1235 | uint32_t val; |
1754 | uint32_t val; |
Line 1236... | Line 1755... | ||
1236 | 1755 | ||
1237 | if (!intel_display_power_enabled(dev_priv, POWER_DOMAIN_PLLS)) |
1756 | if (!intel_display_power_is_enabled(dev_priv, POWER_DOMAIN_PLLS)) |
Line 1238... | Line 1757... | ||
1238 | return false; |
1757 | return false; |
1239 | 1758 | ||
Line 1246... | Line 1765... | ||
1246 | static const char * const hsw_ddi_pll_names[] = { |
1765 | static const char * const hsw_ddi_pll_names[] = { |
1247 | "WRPLL 1", |
1766 | "WRPLL 1", |
1248 | "WRPLL 2", |
1767 | "WRPLL 2", |
1249 | }; |
1768 | }; |
Line 1250... | Line 1769... | ||
1250 | 1769 | ||
1251 | void intel_ddi_pll_init(struct drm_device *dev) |
1770 | static void hsw_shared_dplls_init(struct drm_i915_private *dev_priv) |
1252 | { |
- | |
1253 | struct drm_i915_private *dev_priv = dev->dev_private; |
- | |
1254 | uint32_t val = I915_READ(LCPLL_CTL); |
1771 | { |
Line 1255... | Line 1772... | ||
1255 | int i; |
1772 | int i; |
Line 1256... | Line 1773... | ||
1256 | 1773 | ||
Line 1262... | Line 1779... | ||
1262 | dev_priv->shared_dplls[i].disable = hsw_ddi_pll_disable; |
1779 | dev_priv->shared_dplls[i].disable = hsw_ddi_pll_disable; |
1263 | dev_priv->shared_dplls[i].enable = hsw_ddi_pll_enable; |
1780 | dev_priv->shared_dplls[i].enable = hsw_ddi_pll_enable; |
1264 | dev_priv->shared_dplls[i].get_hw_state = |
1781 | dev_priv->shared_dplls[i].get_hw_state = |
1265 | hsw_ddi_pll_get_hw_state; |
1782 | hsw_ddi_pll_get_hw_state; |
1266 | } |
1783 | } |
- | 1784 | } |
|
Line -... | Line 1785... | ||
- | 1785 | ||
- | 1786 | static const char * const skl_ddi_pll_names[] = { |
|
- | 1787 | "DPLL 1", |
|
- | 1788 | "DPLL 2", |
|
- | 1789 | "DPLL 3", |
|
- | 1790 | }; |
|
- | 1791 | ||
- | 1792 | struct skl_dpll_regs { |
|
- | 1793 | u32 ctl, cfgcr1, cfgcr2; |
|
- | 1794 | }; |
|
1267 | 1795 | ||
- | 1796 | /* this array is indexed by the *shared* pll id */ |
|
- | 1797 | static const struct skl_dpll_regs skl_dpll_regs[3] = { |
|
- | 1798 | { |
|
- | 1799 | /* DPLL 1 */ |
|
- | 1800 | .ctl = LCPLL2_CTL, |
|
- | 1801 | .cfgcr1 = DPLL1_CFGCR1, |
|
- | 1802 | .cfgcr2 = DPLL1_CFGCR2, |
|
- | 1803 | }, |
|
- | 1804 | { |
|
- | 1805 | /* DPLL 2 */ |
|
- | 1806 | .ctl = WRPLL_CTL1, |
|
- | 1807 | .cfgcr1 = DPLL2_CFGCR1, |
|
- | 1808 | .cfgcr2 = DPLL2_CFGCR2, |
|
- | 1809 | }, |
|
- | 1810 | { |
|
- | 1811 | /* DPLL 3 */ |
|
- | 1812 | .ctl = WRPLL_CTL2, |
|
- | 1813 | .cfgcr1 = DPLL3_CFGCR1, |
|
- | 1814 | .cfgcr2 = DPLL3_CFGCR2, |
|
- | 1815 | }, |
|
- | 1816 | }; |
|
- | 1817 | ||
- | 1818 | static void skl_ddi_pll_enable(struct drm_i915_private *dev_priv, |
|
- | 1819 | struct intel_shared_dpll *pll) |
|
- | 1820 | { |
|
- | 1821 | uint32_t val; |
|
- | 1822 | unsigned int dpll; |
|
- | 1823 | const struct skl_dpll_regs *regs = skl_dpll_regs; |
|
1268 | /* The LCPLL register should be turned on by the BIOS. For now let's |
1824 | |
- | 1825 | /* DPLL0 is not part of the shared DPLLs, so pll->id is 0 for DPLL1 */ |
|
- | 1826 | dpll = pll->id + 1; |
|
- | 1827 | ||
- | 1828 | val = I915_READ(DPLL_CTRL1); |
|
- | 1829 | ||
- | 1830 | val &= ~(DPLL_CTRL1_HDMI_MODE(dpll) | DPLL_CTRL1_SSC(dpll) | |
|
- | 1831 | DPLL_CRTL1_LINK_RATE_MASK(dpll)); |
|
- | 1832 | val |= pll->config.hw_state.ctrl1 << (dpll * 6); |
|
- | 1833 | ||
- | 1834 | I915_WRITE(DPLL_CTRL1, val); |
|
- | 1835 | POSTING_READ(DPLL_CTRL1); |
|
- | 1836 | ||
- | 1837 | I915_WRITE(regs[pll->id].cfgcr1, pll->config.hw_state.cfgcr1); |
|
- | 1838 | I915_WRITE(regs[pll->id].cfgcr2, pll->config.hw_state.cfgcr2); |
|
- | 1839 | POSTING_READ(regs[pll->id].cfgcr1); |
|
- | 1840 | POSTING_READ(regs[pll->id].cfgcr2); |
|
1269 | * just check its state and print errors in case something is wrong. |
1841 | |
- | 1842 | /* the enable bit is always bit 31 */ |
|
- | 1843 | I915_WRITE(regs[pll->id].ctl, |
|
- | 1844 | I915_READ(regs[pll->id].ctl) | LCPLL_PLL_ENABLE); |
|
- | 1845 | ||
- | 1846 | if (wait_for(I915_READ(DPLL_STATUS) & DPLL_LOCK(dpll), 5)) |
|
- | 1847 | DRM_ERROR("DPLL %d not locked\n", dpll); |
|
- | 1848 | } |
|
- | 1849 | ||
- | 1850 | static void skl_ddi_pll_disable(struct drm_i915_private *dev_priv, |
|
- | 1851 | struct intel_shared_dpll *pll) |
|
- | 1852 | { |
|
- | 1853 | const struct skl_dpll_regs *regs = skl_dpll_regs; |
|
- | 1854 | ||
- | 1855 | /* the enable bit is always bit 31 */ |
|
- | 1856 | I915_WRITE(regs[pll->id].ctl, |
|
- | 1857 | I915_READ(regs[pll->id].ctl) & ~LCPLL_PLL_ENABLE); |
|
- | 1858 | POSTING_READ(regs[pll->id].ctl); |
|
- | 1859 | } |
|
- | 1860 | ||
- | 1861 | static bool skl_ddi_pll_get_hw_state(struct drm_i915_private *dev_priv, |
|
- | 1862 | struct intel_shared_dpll *pll, |
|
- | 1863 | struct intel_dpll_hw_state *hw_state) |
|
- | 1864 | { |
|
- | 1865 | uint32_t val; |
|
- | 1866 | unsigned int dpll; |
|
- | 1867 | const struct skl_dpll_regs *regs = skl_dpll_regs; |
|
- | 1868 | ||
- | 1869 | if (!intel_display_power_is_enabled(dev_priv, POWER_DOMAIN_PLLS)) |
|
- | 1870 | return false; |
|
- | 1871 | ||
- | 1872 | /* DPLL0 is not part of the shared DPLLs, so pll->id is 0 for DPLL1 */ |
|
- | 1873 | dpll = pll->id + 1; |
|
- | 1874 | ||
- | 1875 | val = I915_READ(regs[pll->id].ctl); |
|
- | 1876 | if (!(val & LCPLL_PLL_ENABLE)) |
|
- | 1877 | return false; |
|
- | 1878 | ||
- | 1879 | val = I915_READ(DPLL_CTRL1); |
|
- | 1880 | hw_state->ctrl1 = (val >> (dpll * 6)) & 0x3f; |
|
- | 1881 | ||
- | 1882 | /* avoid reading back stale values if HDMI mode is not enabled */ |
|
- | 1883 | if (val & DPLL_CTRL1_HDMI_MODE(dpll)) { |
|
- | 1884 | hw_state->cfgcr1 = I915_READ(regs[pll->id].cfgcr1); |
|
- | 1885 | hw_state->cfgcr2 = I915_READ(regs[pll->id].cfgcr2); |
|
- | 1886 | } |
|
- | 1887 | ||
- | 1888 | return true; |
|
- | 1889 | } |
|
- | 1890 | ||
- | 1891 | static void skl_shared_dplls_init(struct drm_i915_private *dev_priv) |
|
- | 1892 | { |
|
- | 1893 | int i; |
|
- | 1894 | ||
- | 1895 | dev_priv->num_shared_dpll = 3; |
|
- | 1896 | ||
- | 1897 | for (i = 0; i < dev_priv->num_shared_dpll; i++) { |
|
- | 1898 | dev_priv->shared_dplls[i].id = i; |
|
- | 1899 | dev_priv->shared_dplls[i].name = skl_ddi_pll_names[i]; |
|
- | 1900 | dev_priv->shared_dplls[i].disable = skl_ddi_pll_disable; |
|
- | 1901 | dev_priv->shared_dplls[i].enable = skl_ddi_pll_enable; |
|
- | 1902 | dev_priv->shared_dplls[i].get_hw_state = |
|
1270 | * Don't even try to turn it on. |
1903 | skl_ddi_pll_get_hw_state; |
- | 1904 | } |
|
- | 1905 | } |
|
- | 1906 | ||
- | 1907 | void intel_ddi_pll_init(struct drm_device *dev) |
|
- | 1908 | { |
|
- | 1909 | struct drm_i915_private *dev_priv = dev->dev_private; |
|
- | 1910 | uint32_t val = I915_READ(LCPLL_CTL); |
|
- | 1911 | ||
- | 1912 | if (IS_SKYLAKE(dev)) |
|
- | 1913 | skl_shared_dplls_init(dev_priv); |
|
- | 1914 | else |
|
Line 1271... | Line 1915... | ||
1271 | */ |
1915 | hsw_shared_dplls_init(dev_priv); |
1272 | 1916 | ||
Line -... | Line 1917... | ||
- | 1917 | DRM_DEBUG_KMS("CDCLK running at %dKHz\n", |
|
- | 1918 | intel_ddi_get_cdclk_freq(dev_priv)); |
|
- | 1919 | ||
- | 1920 | if (IS_SKYLAKE(dev)) { |
|
- | 1921 | if (!(I915_READ(LCPLL1_CTL) & LCPLL_PLL_ENABLE)) |
|
- | 1922 | DRM_ERROR("LCPLL1 is disabled\n"); |
|
- | 1923 | } else { |
|
- | 1924 | /* |
|
- | 1925 | * The LCPLL register should be turned on by the BIOS. For now |
|
- | 1926 | * let's just check its state and print errors in case |
|
1273 | DRM_DEBUG_KMS("CDCLK running at %dKHz\n", |
1927 | * something is wrong. Don't even try to turn it on. |
1274 | intel_ddi_get_cdclk_freq(dev_priv)); |
1928 | */ |
Line 1275... | Line 1929... | ||
1275 | 1929 | ||
1276 | if (val & LCPLL_CD_SOURCE_FCLK) |
1930 | if (val & LCPLL_CD_SOURCE_FCLK) |
1277 | DRM_ERROR("CDCLK source is not LCPLL\n"); |
1931 | DRM_ERROR("CDCLK source is not LCPLL\n"); |
- | 1932 | ||
Line 1278... | Line 1933... | ||
1278 | 1933 | if (val & LCPLL_PLL_DISABLE) |
|
1279 | if (val & LCPLL_PLL_DISABLE) |
1934 | DRM_ERROR("LCPLL is disabled\n"); |
1280 | DRM_ERROR("LCPLL is disabled\n"); |
1935 | } |
1281 | } |
1936 | } |
Line 1370... | Line 2025... | ||
1370 | struct intel_crtc_config *pipe_config) |
2025 | struct intel_crtc_config *pipe_config) |
1371 | { |
2026 | { |
1372 | struct drm_i915_private *dev_priv = encoder->base.dev->dev_private; |
2027 | struct drm_i915_private *dev_priv = encoder->base.dev->dev_private; |
1373 | struct intel_crtc *intel_crtc = to_intel_crtc(encoder->base.crtc); |
2028 | struct intel_crtc *intel_crtc = to_intel_crtc(encoder->base.crtc); |
1374 | enum transcoder cpu_transcoder = intel_crtc->config.cpu_transcoder; |
2029 | enum transcoder cpu_transcoder = intel_crtc->config.cpu_transcoder; |
- | 2030 | struct intel_hdmi *intel_hdmi; |
|
1375 | u32 temp, flags = 0; |
2031 | u32 temp, flags = 0; |
- | 2032 | struct drm_device *dev = dev_priv->dev; |
|
Line 1376... | Line 2033... | ||
1376 | 2033 | ||
1377 | temp = I915_READ(TRANS_DDI_FUNC_CTL(cpu_transcoder)); |
2034 | temp = I915_READ(TRANS_DDI_FUNC_CTL(cpu_transcoder)); |
1378 | if (temp & TRANS_DDI_PHSYNC) |
2035 | if (temp & TRANS_DDI_PHSYNC) |
1379 | flags |= DRM_MODE_FLAG_PHSYNC; |
2036 | flags |= DRM_MODE_FLAG_PHSYNC; |
Line 1404... | Line 2061... | ||
1404 | } |
2061 | } |
Line 1405... | Line 2062... | ||
1405 | 2062 | ||
1406 | switch (temp & TRANS_DDI_MODE_SELECT_MASK) { |
2063 | switch (temp & TRANS_DDI_MODE_SELECT_MASK) { |
1407 | case TRANS_DDI_MODE_SELECT_HDMI: |
2064 | case TRANS_DDI_MODE_SELECT_HDMI: |
- | 2065 | pipe_config->has_hdmi_sink = true; |
|
- | 2066 | intel_hdmi = enc_to_intel_hdmi(&encoder->base); |
|
- | 2067 | ||
- | 2068 | if (intel_hdmi->infoframe_enabled(&encoder->base)) |
|
- | 2069 | pipe_config->has_infoframe = true; |
|
1408 | pipe_config->has_hdmi_sink = true; |
2070 | break; |
1409 | case TRANS_DDI_MODE_SELECT_DVI: |
2071 | case TRANS_DDI_MODE_SELECT_DVI: |
1410 | case TRANS_DDI_MODE_SELECT_FDI: |
2072 | case TRANS_DDI_MODE_SELECT_FDI: |
1411 | break; |
2073 | break; |
1412 | case TRANS_DDI_MODE_SELECT_DP_SST: |
2074 | case TRANS_DDI_MODE_SELECT_DP_SST: |
Line 1416... | Line 2078... | ||
1416 | break; |
2078 | break; |
1417 | default: |
2079 | default: |
1418 | break; |
2080 | break; |
1419 | } |
2081 | } |
Line 1420... | Line 2082... | ||
1420 | 2082 | ||
1421 | if (intel_display_power_enabled(dev_priv, POWER_DOMAIN_AUDIO)) { |
2083 | if (intel_display_power_is_enabled(dev_priv, POWER_DOMAIN_AUDIO)) { |
1422 | temp = I915_READ(HSW_AUD_PIN_ELD_CP_VLD); |
2084 | temp = I915_READ(HSW_AUD_PIN_ELD_CP_VLD); |
1423 | if (temp & (AUDIO_OUTPUT_ENABLE_A << (intel_crtc->pipe * 4))) |
2085 | if (temp & AUDIO_OUTPUT_ENABLE(intel_crtc->pipe)) |
1424 | pipe_config->has_audio = true; |
2086 | pipe_config->has_audio = true; |
Line 1425... | Line 2087... | ||
1425 | } |
2087 | } |
1426 | 2088 | ||
Line 1442... | Line 2104... | ||
1442 | DRM_DEBUG_KMS("pipe has %d bpp for eDP panel, overriding BIOS-provided max %d bpp\n", |
2104 | DRM_DEBUG_KMS("pipe has %d bpp for eDP panel, overriding BIOS-provided max %d bpp\n", |
1443 | pipe_config->pipe_bpp, dev_priv->vbt.edp_bpp); |
2105 | pipe_config->pipe_bpp, dev_priv->vbt.edp_bpp); |
1444 | dev_priv->vbt.edp_bpp = pipe_config->pipe_bpp; |
2106 | dev_priv->vbt.edp_bpp = pipe_config->pipe_bpp; |
1445 | } |
2107 | } |
Line -... | Line 2108... | ||
- | 2108 | ||
- | 2109 | if (INTEL_INFO(dev)->gen <= 8) |
|
- | 2110 | hsw_ddi_clock_get(encoder, pipe_config); |
|
1446 | 2111 | else |
|
1447 | intel_ddi_clock_get(encoder, pipe_config); |
2112 | skl_ddi_clock_get(encoder, pipe_config); |
Line 1448... | Line 2113... | ||
1448 | } |
2113 | } |
1449 | 2114 | ||
1450 | static void intel_ddi_destroy(struct drm_encoder *encoder) |
2115 | static void intel_ddi_destroy(struct drm_encoder *encoder) |